Open Youssef1313 opened 1 year ago
For now, I'm going with an ugly workaround like this: https://github.com/unoplatform/uno/pull/13273
cc @mavasani
Most analyzers report diagnostics for the first symbol location. If the analyzer is configured to not report in generated code, then the behavior differs based on whether the first symbol location is in generated syntax tree or not.
I would not expect the first symbol location to ever be in generated code. Specifically, generated code is syntax trees appended to a compilation. So symbols should always return locations from real files closer in their ordering list versus generated files.
@jasonmalinowski @chsienki to confirm. But i find this surprising.
@CyrusNajmabadi We persist generated code on disk. That is why.
@CyrusNajmabadi We persist generated code on disk. That is why.
Who is 'we' here?
Sorry for the confusion. I mean at Uno Platform.
Sorry for the confusion. I mean at Uno Platform.
If you're generating the code to disk, and you're now referencing those files. Then those aren't source-generator files. THey would be considered normal files. There's no way the compiler woudl know they were source-generated either to report in some other location.
They are marked as auto generated (with // <auto-generated>
comment) because we don't want analyzers to report diagnostics in them, but we want analyzers to report diagnostics in the other partials :/
but you're emitting to disk (and presumably manually updating them?). Just remove auto-generated, since it soundsl ike you do want to report issues. :)
IIRC it was previously not marked as auto-generated and I got some warnings that I didn't care about in these specific files. That was long time ago so I'll need to revisit this.
Another concern is that we have 6294 files. Not sure if enabling analyzers for them will have a performance impact, but worth trying.
@CyrusNajmabadi I tried that. It didn't work well. For the generated files that don't have a non-generated partial, we don't really need any diagnostics (there are currently a lot of them)
Most analyzers report diagnostics for the first symbol location. If the analyzer is configured to not report in generated code, then the behavior differs based on whether the first symbol location is in generated syntax tree or not.
This is not an ideal experience.
Suggested approaches:
ISymbol.FirstNonGeneratedLocation
or aGetFirstNonGeneratedLocation
extension method that analyzer authors should use.