File tree Expand file tree Collapse file tree
src/bunit.generators/Web.Stubs Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ using System ;
12using System . Collections . Generic ;
23using System . Collections . Immutable ;
4+ using System . Diagnostics . CodeAnalysis ;
35using System . Linq ;
46using System . Text ;
57using Microsoft . CodeAnalysis ;
@@ -42,17 +44,18 @@ private static StubClassInfo GetStubClassInfo(GeneratorSyntaxContext context)
4244 if ( context . SemanticModel . GetSymbolInfo ( typeArgument ) . Symbol is ITypeSymbol symbol )
4345 {
4446 var path = GetInterceptorFilePath ( context . Node . SyntaxTree , context . SemanticModel . Compilation ) ;
45- var line = context . SemanticModel . SyntaxTree . GetLineSpan ( context . Node . Span ) . StartLinePosition . Line + 1 ;
46- // Find then column for "AddGeneratedStub" in the invocation expression
47- var column = context . SemanticModel . SyntaxTree . GetLineSpan ( context . Node . Span ) . StartLinePosition . Character + 1 ;
47+ var lineSpan = context . SemanticModel . SyntaxTree . GetLineSpan ( context . Node . Span ) ;
48+ var line = lineSpan . StartLinePosition . Line + 1 ;
49+ var column = lineSpan . Span . Start . Character + context . Node . ToString ( ) . IndexOf ( "AddGeneratedStub" , StringComparison . Ordinal ) ;
50+
4851 return new StubClassInfo
4952 {
5053 StubClassName = $ "{ symbol . Name } Stub",
5154 TargetTypeNamespace = symbol . ContainingNamespace . ToDisplayString ( ) ,
5255 TargetType = symbol ,
5356 Path = path ,
5457 Line = line ,
55- Column = column + 19 , // Yeah - no - well - it works (Future Steven can take care of it)
58+ Column = column + 1 ,
5659 } ;
5760 }
5861 }
You can’t perform that action at this time.
0 commit comments