-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Update convention how to ref&pkg an analyzer again #69237
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
Tagging subscribers to this area: @dotnet/area-infrastructure-libraries Issue Detailsd3af492 made it possible to reference While reviewing other places that could use the AnalyzerReference item, Instead, IMHO it makes much more sense to keep using a To summarize the change:
<!-- Before -->
<AnalyzerReference Include="..." />
<!-- After -->
<ProjectReference Include="..." ReferenceOutputAssembly="false" OutputItemType="Analyzer" />
<!-- Before -->
<AnalyzerReference Include="..." Pack="true" />
<!-- After -->
<ProjectReference Include="..." ReferenceOutputAssembly="false" OutputItemType="Analyzer" PackAsAnalyzer="true" />
<!-- Before -->
<AnalyzerReference Include="..." Pack="true" ReferenceAnalyzer="false" />
<!-- After -->
<ProjectReference Include="..." ReferenceOutputAssembly="false" PackAsAnalyzer="true" />
|
d3af492 made it possible to reference and package an analyzer via the same msbuild item by setting custom metadata. While reviewing other places that could use the AnalyzerReference item, I realized that using this custom item doesn't provide much value and makes us different to rest of the stack / customers as we don't follow our own documentation. Instead, IMHO it makes much more sense to keep using a `ProjectReference` item with the documented set of required metadata, to reference an analyzer and just define an additional custom metadata to support packaging the analyzer: `PackAsAnalyzer`. The reason for that is that the additional metadata explains how the reference works vs. the `AnalyzerReference` which is a repo custom item that doesn't tell you that behind the scenes it actually gets converted to a `ProjectReference` with the same metadata as if you would declare that yourself as a P2P. To summarize the change: 1. Consume an analyzer ```xml <!-- Before --> <AnalyzerReference Include="..." /> <!-- After --> <ProjectReference Include="..." ReferenceOutputAssembly="false" OutputItemType="Analyzer" /> ``` 2. Pack an analyzer and consume it ```xml <!-- Before --> <AnalyzerReference Include="..." Pack="true" /> <!-- After --> <ProjectReference Include="..." ReferenceOutputAssembly="false" OutputItemType="Analyzer" PackAsAnalyzer="true" /> ``` 3. Pack an analyzer without consuming it ```xml <!-- Before --> <AnalyzerReference Include="..." Pack="true" ReferenceAnalyzer="false" /> <!-- After --> <ProjectReference Include="..." ReferenceOutputAssembly="false" PackAsAnalyzer="true" /> ```
020f129
to
2d8d159
Compare
I'm not sure I am excited about this approach, since it creates a burden on all the projects that want to consume an analyzer. <!-- Before -->
<AnalyzerReference Include="..." />
<!-- After -->
<ProjectReference Include="..." ReferenceOutputAssembly="false" OutputItemType="Analyzer" /> The "Before" is much cleaner, and easy to read/understand. What if we supported 2 scenarios: 1 & 3 above. (I don't think 2 is a common scenario, or really will be used ever. But we will see.):
<!-- Before -->
<AnalyzerReference Include="..." />
<!-- After -->
<AnalyzerReference Include="..." />
<!-- Before -->
<AnalyzerReference Include="..." Pack="true" ReferenceAnalyzer="false" />
<!-- After -->
<ProjectReference Include="..." ReferenceOutputAssembly="false" PackAsAnalyzer="true" /> UPDATE: Thinking more about this, how does a "normal dev" reference a local Analyzer they have in their repo in another project? Is it like you are proposing? |
@ViktorHofer if this isn't going to be merged in |
Agreed, closing. I will bring this back later. |
d3af492 made it possible to reference
and package an analyzer via the same msbuild item by setting custom
metadata.
While reviewing other places that could use the AnalyzerReference item,
I realized that using this custom item doesn't provide much value and
creates an artificial difference to the rest of the stack and our customers
as we don't adhere to our own documentation.
Instead, IMHO it makes much more sense to keep using a
ProjectReference
item with the documented set of required metadata, toreference an analyzer and just define an additional custom metadata to
support packaging the analyzer:
PackAsAnalyzer
.The reason for that is that the additional metadata explains how the
reference works (no assembly output reference, added as an Analyzer
output item) vs. the
AnalyzerReference
which is a repo custom itemthat doesn't tell you that behind the scenes it actually gets converted
to a
ProjectReference
with the same metadata as if you would declarethat yourself as a P2P.
To summarize the change: