@@ -22,6 +22,8 @@ private Constructor(Context cx, IMethodSymbol init)
2222 . ToList ( ) ;
2323 }
2424
25+ protected override IMethodSymbol BodyDeclaringSymbol => Symbol . PartialImplementationPart ?? Symbol ;
26+
2527 public override void Populate ( TextWriter trapFile )
2628 {
2729 PopulateMethod ( trapFile ) ;
@@ -176,6 +178,14 @@ private void ExtractSourceInitializer(TextWriter trapFile, ITypeSymbol? type, IM
176178 init . PopulateArguments ( trapFile , arguments , 0 ) ;
177179 }
178180
181+ private ConstructorDeclarationSyntax ? OrdinaryConstructorSyntaxForLocation =>
182+ BodyDeclaringSymbol
183+ . DeclaringSyntaxReferences
184+ . Select ( r => r . GetSyntax ( ) )
185+ . ToList ( )
186+ . OfType < ConstructorDeclarationSyntax > ( )
187+ . FirstOrDefault ( ) ;
188+
179189 private ConstructorDeclarationSyntax ? OrdinaryConstructorSyntax =>
180190 declaringReferenceSyntax
181191 . OfType < ConstructorDeclarationSyntax > ( )
@@ -253,14 +263,14 @@ public override Microsoft.CodeAnalysis.Location? ReportingLocation
253263 {
254264 get
255265 {
256- if ( OrdinaryConstructorSyntax is not null )
266+ if ( OrdinaryConstructorSyntaxForLocation is ConstructorDeclarationSyntax constructor )
257267 {
258- return OrdinaryConstructorSyntax . Identifier . GetLocation ( ) ;
268+ return constructor . Identifier . GetLocation ( ) ;
259269 }
260270
261- if ( PrimaryConstructorSyntax is not null )
271+ if ( PrimaryConstructorSyntax is TypeDeclarationSyntax primary )
262272 {
263- return PrimaryConstructorSyntax . Identifier . GetLocation ( ) ;
273+ return primary . Identifier . GetLocation ( ) ;
264274 }
265275
266276 if ( Symbol . IsImplicitlyDeclared )
0 commit comments