-
Notifications
You must be signed in to change notification settings - Fork 5k
LibraryImportGenerator, .NET 7: possible error in the 'Equals' method implementation #78145
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label. |
Tagging subscribers to this area: @dotnet/interop-contrib Issue DetailsDescriptionCode: public bool Equals(IncrementalStubGenerationContext? other)
{
return other is not null
&& StubEnvironment.AreCompilationSettingsEqual(Environment, other.Environment)
&& SignatureContext.Equals(other.SignatureContext)
&& ContainingSyntaxContext.Equals(other.ContainingSyntaxContext)
&& StubMethodSyntaxTemplate.Equals(other.StubMethodSyntaxTemplate)
&& LibraryImportData.Equals(other.LibraryImportData)
&& DiagnosticLocation.Equals(DiagnosticLocation) // <=
&& ForwardedAttributes.SequenceEqual(other.ForwardedAttributes, (IEqualityComparer<AttributeSyntax>)SyntaxEquivalentComparer.Instance)
&& GeneratorFactoryKey.Equals(other.GeneratorFactoryKey)
&& Diagnostics.SequenceEqual(other.Diagnostics);
} Looks suspicious that Reproduction StepsExpected behaviorActual behaviorRegression?No response Known WorkaroundsNo response ConfigurationNo response Other informationNo response
|
@VasilievSerg Agreed, this does look odd. Care to submit a PR for adding the @jkoritzinsky Are we missing a test for this or is this one of those checks that doesn't matter often enough in practice? |
I fixed this in .NET 8 and found that we did have a test validating the behavior. Unfortunately, the test is wrong in .NET 7 and didn't catch it. The fix and the updated test were part of https://github.com/dotnet/runtime/pull/76474/files#diff-e5ffd09434c9daa4ab5234b83ae383b344c4c20d15a93216b93d358226a10586 In particular, the updates to the |
Updating the milestone to .NET 7.0.X as this was already fixed in .NET 8. |
@jkoritzinsky What is the fallout for this? How are customers impacted by this bug? |
Diagnostics from the source generator would be reported in the wrong location if the user changes the file above the LibraryImport. This can affect both the IDE experience and an inner-loop command line build experience as the compiler server also has the incremental generator support enabled. |
I see. The referenced PR isn't too big. We can try porting this now or wait until we hear from people. Since it doesn't impact the actual generated code, I don't have a strong opinion either way. |
This doesn't see to be actionable any longer. Closing. |
Description
Code:
Link to the sources.
Looks suspicious that
DiagnosticLocation
compares to itself.Reproduction Steps
Expected behavior
Actual behavior
Regression?
No response
Known Workarounds
No response
Configuration
No response
Other information
No response
The text was updated successfully, but these errors were encountered: