Skip to content

unlock LangVersion latest for all c# snippets #46228

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

SimonCropp
Copy link
Contributor

so that we can modernize samples

i made a change to one sample to prove the approach works

@SimonCropp SimonCropp requested a review from a team as a code owner May 16, 2025 00:14
@dotnetrepoman dotnetrepoman bot added this to the May 2025 milestone May 16, 2025
@dotnet-policy-service dotnet-policy-service bot added the community-contribution Indicates PR is created by someone from the .NET community. label May 16, 2025
@BillWagner
Copy link
Member

Hi @SimonCropp

I like the direction here to make it easier for more of our code snippets to use the latest language features. Our team has been updating snippets as we make changes to them.

However, we had a couple concerns:

  1. This pulls all the snippets toward an unsupported scenario: using a higher C# language with a lower TFM. Users could accidentally fall into an unsupported scenario. Or, if they copied a single project rather than clone the repo, the samples might not build.
  2. Some snippets are set to an older version by design. This is either because it's the starting point for a migration or a snippet that targets .NET Framework (WebForms, for example). It feels odd to add back the default setting.

So, we wonder about a different way to achieve the same goal. Suppose the Directory.build.props file set the TFM. Something like:

<?xml version="1.0" encoding="utf-8"?>
<Project>
  <PropertyGroup>
    <TargetFramework Condition="$(MSBuildProjectExtension) == '.csproj'">net10.0</TargetFramework>
  </PropertyGroup>
</Project>

(Or start with net9.0 for now).

Then, as we make any updates, we remove the TargetFramework node for the project. In time, the only projects with a TFM either need some extensions, are designed to be an older framework and version, or are using the current preview version.

What are your thoughts?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
community-contribution Indicates PR is created by someone from the .NET community.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants