diff --git a/template_feed/Microsoft.DotNet.Common.ProjectTemplates.6.0/content/ClassLibrary-CSharp/.template.config/template.json b/template_feed/Microsoft.DotNet.Common.ProjectTemplates.6.0/content/ClassLibrary-CSharp/.template.config/template.json
index 144d4d9de37..13be525a7d0 100644
--- a/template_feed/Microsoft.DotNet.Common.ProjectTemplates.6.0/content/ClassLibrary-CSharp/.template.config/template.json
+++ b/template_feed/Microsoft.DotNet.Common.ProjectTemplates.6.0/content/ClassLibrary-CSharp/.template.config/template.json
@@ -84,6 +84,36 @@
"description": "If specified, skips the automatic restore of the project on create.",
"defaultValue": "false",
"displayName": "Skip restore"
+ },
+ "csharp10orLater": {
+ "type": "generated",
+ "generator": "regexMatch",
+ "datatype": "bool",
+ "parameters": {
+ "pattern": "^(|10\\.0|10|preview|latest|default|latestMajor)$",
+ "source": "langVersion"
+ }
+ },
+ "csharp8orLater": {
+ "type": "generated",
+ "generator": "regexMatch",
+ "datatype": "bool",
+ "parameters": {
+ "pattern": "^(|8|8\\.0|9|9\\.0|10\\.0|10|preview|latest|default|latestMajor)$",
+ "source": "langVersion"
+ }
+ },
+ "csharpFeature_ImplicitUsings": {
+ "type": "computed",
+ "value": "Framework != \"netstandard2.0\" && Framework != \"netstandard2.1\" && csharp10orLater == \"true\""
+ },
+ "csharpFeature_FileScopedNamespaces": {
+ "type": "computed",
+ "value": "Framework != \"netstandard2.0\" && Framework != \"netstandard2.1\" && csharp10orLater == \"true\""
+ },
+ "csharpFeature_Nullable": {
+ "type": "computed",
+ "value": "(Framework != \"netstandard2.0\" || Framework == \"netstandard2.0\" && langVersion != \"\") && csharp8orLater == \"true\""
}
},
"primaryOutputs": [
diff --git a/template_feed/Microsoft.DotNet.Common.ProjectTemplates.6.0/content/ClassLibrary-CSharp/Class1.cs b/template_feed/Microsoft.DotNet.Common.ProjectTemplates.6.0/content/ClassLibrary-CSharp/Class1.cs
index a6325f3fb1b..2dcafee5a35 100644
--- a/template_feed/Microsoft.DotNet.Common.ProjectTemplates.6.0/content/ClassLibrary-CSharp/Class1.cs
+++ b/template_feed/Microsoft.DotNet.Common.ProjectTemplates.6.0/content/ClassLibrary-CSharp/Class1.cs
@@ -1,6 +1,11 @@
-namespace Company.ClassLibrary1
+#if (!csharpFeature_ImplicitUsings)
+using System;
+
+#endif
+namespace Company.ClassLibrary1
{
public class Class1
{
+
}
}
diff --git a/template_feed/Microsoft.DotNet.Common.ProjectTemplates.6.0/content/ClassLibrary-CSharp/Company.ClassLibrary1.csproj b/template_feed/Microsoft.DotNet.Common.ProjectTemplates.6.0/content/ClassLibrary-CSharp/Company.ClassLibrary1.csproj
index 892876e76de..46784087ed7 100644
--- a/template_feed/Microsoft.DotNet.Common.ProjectTemplates.6.0/content/ClassLibrary-CSharp/Company.ClassLibrary1.csproj
+++ b/template_feed/Microsoft.DotNet.Common.ProjectTemplates.6.0/content/ClassLibrary-CSharp/Company.ClassLibrary1.csproj
@@ -5,7 +5,8 @@
TargetFrameworkOverride
Company.ClassLibrary1
$(ProjectLanguageVersion)
- enable
+ true
+ enable
diff --git a/template_feed/Microsoft.DotNet.Common.ProjectTemplates.6.0/content/ConsoleApplication-CSharp/.template.config/template.json b/template_feed/Microsoft.DotNet.Common.ProjectTemplates.6.0/content/ConsoleApplication-CSharp/.template.config/template.json
index 0d33dafa0e6..1a08e0a395f 100644
--- a/template_feed/Microsoft.DotNet.Common.ProjectTemplates.6.0/content/ConsoleApplication-CSharp/.template.config/template.json
+++ b/template_feed/Microsoft.DotNet.Common.ProjectTemplates.6.0/content/ConsoleApplication-CSharp/.template.config/template.json
@@ -60,6 +60,45 @@
"description": "If specified, skips the automatic restore of the project on create.",
"defaultValue": "false",
"displayName": "Skip restore"
+ },
+ "csharp10orLater": {
+ "type": "generated",
+ "generator": "regexMatch",
+ "datatype": "bool",
+ "parameters": {
+ "pattern": "^(|10\\.0|10|preview|latest|default|latestMajor)$",
+ "source": "langVersion"
+ }
+ },
+ "csharp9orLater": {
+ "type": "generated",
+ "generator": "regexMatch",
+ "datatype": "bool",
+ "parameters": {
+ "pattern": "^(|9|9\\.0|10\\.0|10|preview|latest|default|latestMajor)$",
+ "source": "langVersion"
+ }
+ },
+ "csharp8orLater": {
+ "type": "generated",
+ "generator": "regexMatch",
+ "datatype": "bool",
+ "parameters": {
+ "pattern": "^(|8|8\\.0|9|9\\.0|10\\.0|10|preview|latest|default|latestMajor)$",
+ "source": "langVersion"
+ }
+ },
+ "csharpFeature_ImplicitUsings": {
+ "type": "computed",
+ "value": "csharp10orLater == \"true\""
+ },
+ "csharpFeature_Nullable": {
+ "type": "computed",
+ "value": "csharp8orLater == \"true\""
+ },
+ "csharpFeature_TopLevelProgram": {
+ "type": "computed",
+ "value": "csharp9orLater == \"true\""
}
},
"primaryOutputs": [
diff --git a/template_feed/Microsoft.DotNet.Common.ProjectTemplates.6.0/content/ConsoleApplication-CSharp/Company.ConsoleApplication1.csproj b/template_feed/Microsoft.DotNet.Common.ProjectTemplates.6.0/content/ConsoleApplication-CSharp/Company.ConsoleApplication1.csproj
index 66e0f74129c..ced2071aa9f 100644
--- a/template_feed/Microsoft.DotNet.Common.ProjectTemplates.6.0/content/ConsoleApplication-CSharp/Company.ConsoleApplication1.csproj
+++ b/template_feed/Microsoft.DotNet.Common.ProjectTemplates.6.0/content/ConsoleApplication-CSharp/Company.ConsoleApplication1.csproj
@@ -4,8 +4,10 @@
Exe
net6.0
TargetFrameworkOverride
+ Company.ConsoleApplication1
$(ProjectLanguageVersion)
- enable
+ true
+ enable
diff --git a/template_feed/Microsoft.DotNet.Common.ProjectTemplates.6.0/content/ConsoleApplication-CSharp/Program.cs b/template_feed/Microsoft.DotNet.Common.ProjectTemplates.6.0/content/ConsoleApplication-CSharp/Program.cs
index 68c6516d215..bdeb5843bdb 100644
--- a/template_feed/Microsoft.DotNet.Common.ProjectTemplates.6.0/content/ConsoleApplication-CSharp/Program.cs
+++ b/template_feed/Microsoft.DotNet.Common.ProjectTemplates.6.0/content/ConsoleApplication-CSharp/Program.cs
@@ -1,2 +1,21 @@
-Console.WriteLine("Hello, World!");
+#if (csharpFeature_TopLevelProgram)
// See https://aka.ms/new-console-template for more information
+#endif
+#if (!csharpFeature_ImplicitUsings)
+using System;
+
+#endif
+#if (csharpFeature_TopLevelProgram)
+Console.WriteLine("Hello, World!");
+#else
+namespace Company.ConsoleApplication1
+{
+ class Program
+ {
+ static void Main(string[] args)
+ {
+ Console.WriteLine("Hello, World!");
+ }
+ }
+}
+#endif
diff --git a/test/dotnet-new3.UnitTests/CommonTemplatesTests.cs b/test/dotnet-new3.UnitTests/CommonTemplatesTests.cs
index 88132affd06..b72c56fc23b 100644
--- a/test/dotnet-new3.UnitTests/CommonTemplatesTests.cs
+++ b/test/dotnet-new3.UnitTests/CommonTemplatesTests.cs
@@ -66,21 +66,6 @@ public CommonTemplatesTests(SharedHomeDirectory fixture, ITestOutputHelper log)
[InlineData("Class Library", "classlib", "VB", "netstandard2.0")]
[InlineData("Class Library", "classlib", "F#", "netstandard2.0")]
- [InlineData("Class Library", "classlib", "C#", "net6.0", "10.0")]
- [InlineData("Class Library", "classlib", "C#", "net6.0", "9.0", Skip = "https://github.com/dotnet/templating/issues/3449")]
- [InlineData("Class Library", "classlib", "C#", "net6.0", "8.0", Skip = "https://github.com/dotnet/templating/issues/3449")]
- [InlineData("Class Library", "classlib", "C#", "net6.0", "7.3", Skip = "https://github.com/dotnet/templating/issues/3449")]
- [InlineData("Class Library", "classlib", "C#", "net6.0", "7.2", Skip = "https://github.com/dotnet/templating/issues/3449")]
- [InlineData("Class Library", "classlib", "C#", "net6.0", "7.1", Skip = "https://github.com/dotnet/templating/issues/3449")]
- [InlineData("Class Library", "classlib", "C#", "net6.0", "7", Skip = "https://github.com/dotnet/templating/issues/3449")]
-
- [InlineData("Console Application", "console", "C#", "net6.0", "10.0")]
- [InlineData("Console Application", "console", "C#", "net6.0", "9.0", Skip = "https://github.com/dotnet/templating/issues/3449")]
- [InlineData("Console Application", "console", "C#", "net6.0", "8.0", Skip = "https://github.com/dotnet/templating/issues/3449")]
- [InlineData("Console Application", "console", "C#", "net6.0", "7.3", Skip = "https://github.com/dotnet/templating/issues/3449")]
- [InlineData("Console Application", "console", "C#", "net6.0", "7.2", Skip = "https://github.com/dotnet/templating/issues/3449")]
- [InlineData("Console Application", "console", "C#", "net6.0", "7.1", Skip = "https://github.com/dotnet/templating/issues/3449")]
- [InlineData("Console Application", "console", "C#", "net6.0", "7", Skip = "https://github.com/dotnet/templating/issues/3449")]
public void AllCommonProjectsCreateRestoreAndBuild(string expectedTemplateName, string templateShortName, string? language = null, string? framework = null, string? langVersion = null)
{
string workingDir = TestUtils.CreateTemporaryFolder();
@@ -152,6 +137,272 @@ Determining projects to restore\.\.\.
Directory.Delete(workingDir, true);
}
+ public static IEnumerable