Skip to content

Consider setting LangVersion for down-level targets in PolySharp's .targets files #135

@baronfel

Description

@baronfel

Description (optional)

The docs for this project suggest that users should set LangVersion in the projects (esp. for downlevel TFMs) - but this leads to a lot of LangVersion snippets lingering in project files across the ecosystem that are likely to get stale.

I think that PolySharp, which has knowledge of which language features and capabilities it is polyfilling, should include a snippet in the .targets it ships as part of the nuget package that do this on behalf of users:

Something along the lines of

<PropertyGroup Condition="'$(TargetFramework)' != '' and [MSBuild]::IsTargetFrameworkCompatible('net472', '$(TargetFramework)')">
  <LangVersion>$(PolySharp_LangVersionSupported)</LangVersion>
</PropertyGroup>

Rationale

This

  • reduces random MSBuild snippets in the wild, which virtually always go stale
  • makes the modification of LangVersion something principled - PolySharp specifically enables this change, so it can manage the change

I'm most interested in the first bullet point - as part of my job as MSBuild/SDK Product Manager I am constantly fighting bugs where people have set LangVersion sometime in the distant past and no longer know why. If PolySharp made this change and removed the documentation guidance pushing people towards setting LangVersion themselves I would buy the dev team so many beers/coffees/etc 🗡️

Drawbacks

LangVersion modifications become more 'invisible' to end users, though I'd argue that most of them don't fully realize the implications of changing LangVersion in this way!

Alternatives

PolySharp could ship warnings if the user set LangVersion to something that PolySharp supported a 'higher' version of, or something along those lines.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions