-
Notifications
You must be signed in to change notification settings - Fork 6.1k
Add docs for DisableFrameworkReferenceAnalyzers #24896
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
Conversation
50008bc to
cfd2f06
Compare
|
|
||
| ### DisableFrameworkReferenceAnalyzers | ||
|
|
||
| The `DisableFrameworkReferenceAnalyzers` property can be used to disable all analyzers and/or source generators that are resolved from `FrameworkReference` items. Similar to [EnableNETAnalyzers](#enablenetanalyzers) which controls analyzers that come from the SDK, however this property can be used to disable analyzers that are part of the framework itself (for example, `net6.0`). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This makes me question, should we really have two different properties for this? If someone set EnableNETAnalyzers to false, wouldn't they expect not to get the FrameworkReference-based analyzers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was thinking we should have a separate property since these are different in the source component and the reasons for disabling them might be different (eg: source build on old frameworks).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To me it's pretty much an implementation detail that we decided to put analyzers in FrameworkReferences. Most developers don't even need to know what FrameworkReferences are, or the fact that we have implicit ones for the base Framework.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jmarolf what is your thinking about this? Does it make sense to have different properties?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- I think we want to keep the Enable/Disable language consistent here. If we do have both I do not think it makes sense to have
EnableNETAnalyzersandDisableFrameworkReferenceAnalyzers. It should either beDisableNETAnalyzersandDisableFrameworkReferenceAnalyzersorEnableNETAnalyzersandEnableFrameworkReferenceAnalyzers - I need to think about these cases. For this case what is the user trying to do? They are trying to disable framework analyzers but keep other ones? Why?
<DisableFrameworkReferenceAnalyzers>true</DisableFrameworkReferenceAnalyzers>
<EnableNETAnalyzers>true</EnableNETAnalyzers>alternatively, what is happening here?
<DisableFrameworkReferenceAnalyzers>false</DisableFrameworkReferenceAnalyzers>
<EnableNETAnalyzers>false</EnableNETAnalyzers>I agree with @dsplaisted that we should not add configuration complexity just to add it. It must enable a specific scenario and that scenario must happen "in the wild" for at least one customer. As it stands I cannot think of a situation this applies to and am learning towards just having one property. Alternatively, we could have both, but I do not think we need to document both.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How is the user going to be able to determine that it is a source generator coming from a framework reference? If the build is broken by turning off framework reference generators then its not less broken by turning off all analyzers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jmarolf Just wanted to clarify that our case with dotnet/runtime#56702 had to do with a specific framework SG, which we were not depending on or using at all in our code. Just because there is a problematic SG, especially the one that's not being relied upon by user code, it does not make sense to turn of all SGs, let alone all analyzers. Ideally a user should have granular control over which SGs are enabled on a per-project basis, without resorting to targets trick, perhaps with the super option (in IDE maybe) to disable all SGs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, that makes sense. But that is not what this property does. It disables all source generators coming as framework references. Still do not understand the user case of disabling all framework source generators but not all source generators. If you are trying to disable source generators for your build you are doing build surgery and frankly, really need to know what you are doing. My position is that adding this property does not make this daunting task simpler or easier.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All right, I think I'm in agreement. This property provides limited value, and might even be worse than that. Potentially there is an opportunity for another feature here, which is to provide a hook to disable certain / all source generators. Let's discuss that as a new SDK issue. I will close this PR and remove the property from the SDK.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just to follow up on a few questions.
It looks like a problem with the specific SG (is it trying to do too much?).
It's hot path is too costly, so large SLNs pay that hot path on a lot of source and it becomes too expensive. I think we might have a similar problem in multiple source generators added this release.
How is the user going to be able to determine that it is a source generator coming from a framework reference
I think we need some source generator diagnostics like https://github.com/dotnet/roslyn/blob/315c2e149ba7889b0937d872274c33fcbfe9af5f/docs/analyzers/Report%20Analyzer%20Format.md to help folks realize what's going on. We're going to talk to roslyn folks about this.
Co-authored-by: Genevieve Warren <[email protected]>
Summary
Add docs for property added in dotnet/sdk#18501.
Design doc: https://github.com/dotnet/designs/blob/main/accepted/2021/InboxSourceGenerators.md