remove explicit LangVersion from a few projects (#75806)
authorkasperk81 <83082615+kasperk81@users.noreply.github.com>
Thu, 29 Sep 2022 16:24:02 +0000 (19:24 +0300)
committerGitHub <noreply@github.com>
Thu, 29 Sep 2022 16:24:02 +0000 (18:24 +0200)
* remove explicit LangVersion from a few projects

* feedback

* net7.0

* net7.0

Co-authored-by: kasperk81 <kasperk81 83082615+kasperk81@users.noreply.github.com>
Co-authored-by: kasperk81 <kasperk81 kasperk81 83082615+kasperk81@users.noreply.github.com>
src/coreclr/tools/dotnet-pgo/dotnet-pgo.csproj
src/libraries/Common/tests/StaticTestGenerator/Program.cs
src/libraries/Common/tests/StaticTestGenerator/StaticTestGenerator.csproj
src/libraries/System.Diagnostics.DiagnosticSource/src/System.Diagnostics.DiagnosticSource.csproj
src/libraries/System.Net.Http/tests/StressTests/HttpStress/HttpStress.csproj
src/libraries/System.Private.CoreLib/gen/System.Private.CoreLib.Generators.csproj
src/libraries/System.Text.RegularExpressions/tools/GenerateRegexCasingTable.csproj
src/tests/Regressions/coreclr/GitHub_49826/test49826.csproj
src/tests/Regressions/coreclr/GitHub_49982/test49982.csproj

index ab5cc92..14a99e9 100644 (file)
@@ -21,9 +21,6 @@
     <PackageReleaseNotes>$(Description)</PackageReleaseNotes>
     <RootNamespace>Microsoft.Diagnostics.Tools.Pgo</RootNamespace>
     <RollForward>Major</RollForward>
-    <!-- TODO Remove the language version limitation when the reference assemblies
-        are updated with the new scoped keyword. -->
-    <LangVersion>10</LangVersion>
   </PropertyGroup>
 
   <ItemGroup>
index bd81a9e..f5c2e72 100644 (file)
@@ -199,9 +199,10 @@ namespace StaticTestGenerator
 
             // Write out the associated .csproj
             string csprojPath = Path.Combine(outputPath, Path.GetFileNameWithoutExtension(testAssemblyPath) + "-runner.csproj");
+            Version version = Environment.Version;
             File.WriteAllText(
                 csprojPath,
-                CSProjTemplate
+                GetCsprojTemplate($"net{version.Major}.{version.Minor}")
                 .Replace("#HelperAssemblyLocation#", Path.GetDirectoryName(testAssemblyPath) + Path.DirectorySeparatorChar)
                 .Replace("#TestAssembly#", Path.GetFullPath(testAssemblyPath))
                 .Replace("#TestAssemblyLocation#", testAssemblyPath));
@@ -1127,13 +1128,11 @@ public static class Test
 }
 ";
 
-        /// <summary>The template for the .csproj.</summary>
-        private const string CSProjTemplate =
-@"<Project Sdk=""Microsoft.NET.Sdk"">
+        private string GetCsprojTemplate(string targetFramework) =>
+$@"<Project Sdk=""Microsoft.NET.Sdk"">
   <PropertyGroup>
     <OutputType>Exe</OutputType>
-    <TargetFramework>net5.0</TargetFramework>
-    <LangVersion>preview</LangVersion>
+    <TargetFramework>{targetFramework}</TargetFramework>
     <TreatWarningsAsErrors>true</TreatWarningsAsErrors>
     <NoWarn>IDE0049</NoWarn> <!-- names can be simplified -->
   </PropertyGroup>
index 035387e..ae6943c 100644 (file)
@@ -1,9 +1,8 @@
 <Project Sdk="Microsoft.NET.Sdk">
   <PropertyGroup>
     <OutputType>Exe</OutputType>
-    <TargetFramework>net6.0</TargetFramework>
+    <TargetFramework>net7.0</TargetFramework>
     <EnableDefaultItems>false</EnableDefaultItems>
-    <LangVersion>preview</LangVersion>
     <TreatWarningsAsErrors>true</TreatWarningsAsErrors>
     <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
     <NoWarn />
index 97163bb..4c20a73 100644 (file)
@@ -6,8 +6,6 @@
     <NoWarn>$(NoWarn);SA1205;CA1845</NoWarn>
     <EnableTrimAnalyzer Condition="$([MSBuild]::GetTargetFrameworkIdentifier('$(TargetFramework)')) == '.NETFramework'">false</EnableTrimAnalyzer>
     <IsPackable>true</IsPackable>
-    <!-- Lifetime rules introduced in C# 11 impact scenarios in net6 framework -->
-    <LangVersion Condition="'$(TargetFramework)' == 'net6.0'">10</LangVersion>
     <EnableAOTAnalyzer>true</EnableAOTAnalyzer>
     <PackageDescription>Provides Classes that allow you to decouple code logging rich (unserializable) diagnostics/telemetry (e.g. framework) from code that consumes it (e.g. tools)
 
index 7a6f987..bb71d66 100644 (file)
@@ -2,7 +2,6 @@
   <PropertyGroup>
     <OutputType>Exe</OutputType>
     <TargetFramework>$(NetCoreAppCurrent)</TargetFramework>
-    <LangVersion>preview</LangVersion>
     <Nullable>enable</Nullable>
     <EnablePreviewFeatures>True</EnablePreviewFeatures>
   </PropertyGroup>
index 9b8934e..d7db8cf 100644 (file)
@@ -1,7 +1,6 @@
 <Project Sdk="Microsoft.NET.Sdk">
   <PropertyGroup>
     <TargetFramework>netstandard2.0</TargetFramework>
-    <LangVersion>10.0</LangVersion>
     <NoWarn>$(NoWarn);CS3001</NoWarn>
   </PropertyGroup>
 
index 26b5733..173f255 100644 (file)
@@ -2,8 +2,7 @@
 
   <PropertyGroup>
       <OutputType>Exe</OutputType>
-      <TargetFramework>net6.0</TargetFramework>
-      <LangVersion>latest</LangVersion>
+      <TargetFramework>net7.0</TargetFramework>
       <Nullable>enable</Nullable>
   </PropertyGroup>
 
index b4093c3..55d1e87 100644 (file)
@@ -3,7 +3,6 @@
     <OutputType>Exe</OutputType>
     <CLRTestPriority>1</CLRTestPriority>
     <Nullable>enable</Nullable>
-    <LangVersion>9.0</LangVersion>
 
     <!-- ilasm round-trip testing test failure: https://github.com/dotnet/runtime/issues/49985 -->
     <IlasmRoundTripIncompatible>true</IlasmRoundTripIncompatible>
index 4ec2516..0264633 100644 (file)
@@ -3,7 +3,6 @@
     <OutputType>Exe</OutputType>
     <CLRTestPriority>1</CLRTestPriority>
     <Nullable>enable</Nullable>
-    <LangVersion>9.0</LangVersion>
     <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
 
     <!-- This is an explicit crossgen test -->