Skip to content

Conversation

@ericstj
Copy link
Member

@ericstj ericstj commented Jun 29, 2021

@ericstj ericstj force-pushed the addFrameworkAnalyzerDoc branch from 50008bc to cfd2f06 Compare June 29, 2021 07:18

### 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`).
Copy link
Member

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.

Copy link
Member Author

@ericstj ericstj Jul 2, 2021

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).

Copy link
Member

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.

Copy link
Member Author

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?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. 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 EnableNETAnalyzers and DisableFrameworkReferenceAnalyzers. It should either be DisableNETAnalyzers and DisableFrameworkReferenceAnalyzers or EnableNETAnalyzers and EnableFrameworkReferenceAnalyzers
  2. 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.

Copy link
Contributor

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.

Copy link

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.

Copy link
Contributor

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.

Copy link
Member Author

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.

Copy link
Member Author

@ericstj ericstj Aug 4, 2021

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants