File tree Expand file tree Collapse file tree 1 file changed +12
-1
lines changed
tracer/src/Datadog.Trace/Ci Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -136,9 +136,20 @@ public void SetTestMethodInfo(MethodInfo methodInfo)
136136 {
137137 if ( MethodSymbolResolver . Instance . TryGetMethodSymbol ( methodInfo , out var methodSymbol ) )
138138 {
139+ var startLine = methodSymbol . StartLine ;
140+ // startline refers to the first instruction of method body.
141+ // In order to improve the source code in the CI Visibility UI, we decrease
142+ // this value by 2 so <bold>most of the time</bold> will show the missing
143+ // `{` char and the method signature.
144+ // There's no an easy way to extract the correct startline number.
145+ if ( startLine > 1 )
146+ {
147+ startLine -= 2 ;
148+ }
149+
139150 var tags = ( TestSpanTags ) _scope . Span . Tags ;
140151 tags . SourceFile = CIEnvironmentValues . Instance . MakeRelativePathFromSourceRoot ( methodSymbol . File , false ) ;
141- tags . SourceStart = methodSymbol . StartLine ;
152+ tags . SourceStart = startLine ;
142153 tags . SourceEnd = methodSymbol . EndLine ;
143154
144155 if ( CIEnvironmentValues . Instance . CodeOwners is { } codeOwners )
You can’t perform that action at this time.
0 commit comments