-
Notifications
You must be signed in to change notification settings - Fork 4k
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
SimpleDiagnostic
class uses reference equality when comparing message arguments
#68291
Comments
Diagnostics do not have value-semantics (and arbritrary parts of our stack produce different instances of them which themselves are not comparable). You should store the data you collect to create the diagnostic in some value-record and store that in your model. |
@CyrusNajmabadi This was not true in the compiler, as far as I know, which is why the abstract |
In particular, the observed behavior is caused by this line:
I suspect that the use of This interpretation as a bug also lines up with the hash code implementation, which does a virtual call to |
…86908) Creates DiagnosticInfo record to replace Diagnostic in the incremental pipeline to work around dotnet/roslyn#68291
OK, went back and looked at the pre-github source code. I'm confident this is a bug. At first, we had arguments in SimpleDiagnostic. Then, we briefly decide to move them elsewhere in the hierarchy. Later, we decided to bring them back, in much the same form they are in right now. However, the contact added |
I just encountered this bug while developing my source generator. |
Whether or not diagnostic arguments are compared sequentially is somewhat of a moot point from the perspective of source generators. Diagnostics know their Arguably, we should never have made it possible to report diagnostics from a source generator itself, but instead forced the use of analyzers to report issues. It's basically impossible to do this correctly. |
Encountered the following issue when trying to debug an incremental source generator false positive:
Minimal reproduction
The issue appears to be caused by the following line:
roslyn/src/Compilers/Core/Portable/Diagnostic/Diagnostic_SimpleDiagnostic.cs
Line 165 in 687921f
The text was updated successfully, but these errors were encountered: