Skip to content

AnalyzerReference vs ProjectReference #69111

@ViktorHofer

Description

@ViktorHofer

For a library to include analyzers in its package, AnalyzerReference items must be defined. In contrast to that, for a library to consume an analyzer, a ProjectReference item with some metadata needs to be defined.

The Regex source generator is currently enabled in projects by setting a property which then just enables the ProjectReference with the metadata in the generators.targets file. We could avoid this indirection by supporting an AnalyzerReference item to also consume an analyzer and not just package it.

I think a good default behavior for the AnalyzerReference item would be:

<ProjectReference Include="..."
      OutputItemType="Analyzer"
      ReferenceOutputAssembly="false" />

and by explicitly setting the Pack metadata on the AnalyzerReference item (<AnalyzerReference Include="..." Pack="true" />) it would be added to the package.

@ericstj what do you think about this?
cc @joperezr and @eerhardt for opinions

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions