Skip to content

Consider deprecating older source generators and their associated infrastructure #83383

Open
@ViktorHofer

Description

@ViktorHofer

See #82179 (comment) for the initial conversation.

Packages which include source generators are growing unboundedly because they not just contain assemblies targeting the current roslyn but also carry along all the previous targeted source generators, i.e. roslyn3.11, roslyn4.0 and roslyn4.4. Those never get deleted because the package could be loaded in an environment (SDK / Visual Studio) that doesn't support the newer version of the compiler.

That effectively means that we need to support our roslyn3.11 source generators until the minimum version of Visual Studio that supports the generators is EOL. Based on the official lifecycle document, that is April 2029.

Consequences based on that:

  • Packages are growing unboundedly whenever their underlying source generators target a new version of roslyn.
  • Old / legacy source generator source code can't be removed. In the example of roslyn3.11 source generators, they aren't incremental and cause performance issues.
  • Custom infrastructure for polyfilling SDK features in older environments adds complexity to packages. That infrastructure is repository specific (their is no shared code today at all) and written in msbuild. A package consumer needs to pay for evaluating that custom infrastructure even on a current environment.
  • Whenever a new source generator is added, we need to add new projects and grow the build graph as msbuild doesn't allow multi-targeting based on the compiler version.

Those pain points could be mitigated by applying a required toolset version to our packages. While the toolset version refers to the minimum NuGet client version, the compiler and NuGet both ship in the SDK and Visual Studio and by picking a specific NuGet version, a compiler version is enforced as well. Alternatively we could discuss if we want to add another metadata to the nuspec file that indicates the required compiler version. Downside of that is that we would need to backport that support into those very old versions of the SDK and Visual Studio.

By applying a minimum required toolset version, we could remove those old source generators, their underlying infrastructure and with that make our packages smaller and less complex. The downside in doing that is that we would prevent customers on older environments to reference the very latest versions of our packages.

cc @ericstj @eerhardt @jaredpar @stephentoub @jkotas

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions