Skip to content

Commit aead2b6

Browse files
authored
Fix METGEN004 error message: print return type in ErrorInvalidMethodReturnType
1 parent 1eb963e commit aead2b6

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

src/Generators/Microsoft.Gen.Metrics/Parser.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -574,7 +574,7 @@ private bool CheckMethodReturnType(IMethodSymbol methodSymbol)
574574
returnType.TypeKind != TypeKind.Error)
575575
{
576576
// Make sure return type is not from existing known type
577-
Diag(DiagDescriptors.ErrorInvalidMethodReturnType, methodSymbol.ReturnType.GetLocation(), methodSymbol.Name);
577+
Diag(DiagDescriptors.ErrorInvalidMethodReturnType, returnType.GetLocation(), returnType.ToDisplayString(SymbolDisplayFormat.MinimallyQualifiedFormat));
578578
return false;
579579
}
580580

test/Generators/Microsoft.Gen.Metrics/Unit/ParserTests.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ class CustomClass {{ }}
8181

8282
_ = Assert.Single(d);
8383
Assert.Equal(DiagDescriptors.ErrorInvalidMethodReturnType.Id, d[0].Id);
84+
Assert.Contains($"must not return '{returnType}'", d[0].GetMessage());
8485
}
8586

8687
[Theory]

0 commit comments

Comments
 (0)