diff --git a/.github/ISSUE_TEMPLATE/bug-report.md b/.github/ISSUE_TEMPLATE/bug-report.md
index 43c22561d3b4b..8812e97306023 100644
--- a/.github/ISSUE_TEMPLATE/bug-report.md
+++ b/.github/ISSUE_TEMPLATE/bug-report.md
@@ -11,7 +11,7 @@ about: Report a bug in Roslyn
2.
3.
-A minimal repro, with source-code provided, is ideal. Most compiler/language issues can be distilled into a snippet that can be pasted into [sharplab](https://sharplab.io/).
+A minimal repro, with source-code provided, is ideal. Most compiler/language issues can be distilled into a snippet that can be pasted into [.NET Lab](https://lab.razor.fyi/#csharp).
**Diagnostic Id**:
diff --git a/.vscode/tasks.json b/.vscode/tasks.json
index 78745a3ada316..eecd040d5dd02 100644
--- a/.vscode/tasks.json
+++ b/.vscode/tasks.json
@@ -103,6 +103,7 @@
"command": "dotnet",
"args": [
"build",
+ "-p:InnerTargets=CopyFilesForDebugging",
"-p:GenerateFullPaths=true",
"${workspaceFolder}/src/NuGet/Microsoft.Net.Compilers.Toolset/AnyCpu/Microsoft.Net.Compilers.Toolset.Package.csproj"
],
diff --git a/Compilers.slnf b/Compilers.slnf
index 49acd2063d586..458efec9fbc6d 100644
--- a/Compilers.slnf
+++ b/Compilers.slnf
@@ -53,6 +53,7 @@
"src\\ExpressionEvaluator\\Core\\Source\\ExpressionCompiler\\Microsoft.CodeAnalysis.ExpressionCompiler.csproj",
"src\\ExpressionEvaluator\\VisualBasic\\Source\\ExpressionCompiler\\Microsoft.CodeAnalysis.VisualBasic.ExpressionCompiler.vbproj",
"src\\Interactive\\csi\\csi.csproj",
+ "src\\NuGet\\Microsoft.CodeAnalysis.BuildClient.Package\\Microsoft.CodeAnalysis.BuildClient.Package.csproj",
"src\\NuGet\\Microsoft.CodeAnalysis.Compilers.Package\\Microsoft.CodeAnalysis.Compilers.Package.csproj",
"src\\NuGet\\Microsoft.CodeAnalysis.Package\\Microsoft.CodeAnalysis.Package.csproj",
"src\\NuGet\\Microsoft.Net.Compilers.Toolset\\AnyCpu\\Microsoft.Net.Compilers.Toolset.Package.csproj",
diff --git a/NuGet.config b/NuGet.config
index 26a2f6f90d445..0472eeb256e12 100644
--- a/NuGet.config
+++ b/NuGet.config
@@ -5,13 +5,16 @@
+
-
+
+
-
+
-
+
+
diff --git a/Roslyn.sln b/Roslyn.sln
index 980009f1a1d57..3e4776aca3d40 100644
--- a/Roslyn.sln
+++ b/Roslyn.sln
@@ -1,6 +1,6 @@
Microsoft Visual Studio Solution File, Format Version 12.00
-# Visual Studio Version 18
-VisualStudioVersion = 18.0.10623.112 main
+# Visual Studio Version 17
+VisualStudioVersion = 17.14.36203.30
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RoslynDeployment", "src\Deployment\RoslynDeployment.csproj", "{600AF682-E097-407B-AD85-EE3CED37E680}"
EndProject
@@ -374,10 +374,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CompilersIOperationGenerator", "src\Tools\Source\CompilerGeneratorTools\Source\IOperationGenerator\CompilersIOperationGenerator.csproj", "{D55FB2BD-CC9E-454B-9654-94AF5D910BF7}"
EndProject
-Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.LanguageServerIndexFormat.Generator", "src\Features\Lsif\Generator\Microsoft.CodeAnalysis.LanguageServerIndexFormat.Generator.csproj", "{B9899CF1-E0EB-4599-9E24-6939A04B4979}"
-EndProject
-Project("{778DAE3C-4631-46EA-AA77-85C1314464D9}") = "Microsoft.CodeAnalysis.LanguageServerIndexFormat.Generator.UnitTests", "src\Features\Lsif\GeneratorTest\Microsoft.CodeAnalysis.LanguageServerIndexFormat.Generator.UnitTests.vbproj", "{D15BF03E-04ED-4BEE-A72B-7620F541F4E2}"
-EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Analyzers", "Analyzers", "{4A49D526-1644-4819-AA4F-95B348D447D4}"
EndProject
Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "CompilerExtensions", "src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\CompilerExtensions.shproj", "{EC946164-1E17-410B-B7D9-7DE7E6268D63}"
@@ -635,10 +631,6 @@ Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "FlowAnalysis.Utilities", "s
EndProject
Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "Refactoring.Utilities", "src\RoslynAnalyzers\Utilities\Refactoring\Refactoring.Utilities.shproj", "{68528C1C-B163-49A6-A19D-24E10F500F90}"
EndProject
-Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "Refactoring.CSharp.Utilities", "src\RoslynAnalyzers\Utilities\Refactoring.CSharp\Refactoring.CSharp.Utilities.shproj", "{3055F932-0D1E-4823-A03A-7B62C7639BDA}"
-EndProject
-Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "Refactoring.VisualBasic.Utilities", "src\RoslynAnalyzers\Utilities\Refactoring.VisualBasic\Refactoring.VisualBasic.Utilities.shproj", "{4C362C30-C4B1-4C4B-A545-DBF67C7E9153}"
-EndProject
Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "Workspaces.Utilities", "src\RoslynAnalyzers\Utilities\Workspaces\Workspaces.Utilities.shproj", "{9C4BC501-C0A6-4130-BA68-EF5FB0C640B0}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Utilities", "Utilities", "{0DDCFE67-7D4E-4709-9882-EC032A031789}"
@@ -733,6 +725,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Build.Tasks.CodeA
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Build.Tasks.CodeAnalysis.Sdk.UnitTests", "src\Compilers\Core\SdkTaskTests\Microsoft.Build.Tasks.CodeAnalysis.Sdk.UnitTests.csproj", "{5399BBCC-417F-C710-46DE-EB0C0074C34D}"
EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.BuildClient.Package", "src\NuGet\Microsoft.CodeAnalysis.BuildClient.Package\Microsoft.CodeAnalysis.BuildClient.Package.csproj", "{5E4F7448-B00B-4F5B-859F-6ED0354253D5}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -1295,14 +1289,6 @@ Global
{D55FB2BD-CC9E-454B-9654-94AF5D910BF7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D55FB2BD-CC9E-454B-9654-94AF5D910BF7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D55FB2BD-CC9E-454B-9654-94AF5D910BF7}.Release|Any CPU.Build.0 = Release|Any CPU
- {B9899CF1-E0EB-4599-9E24-6939A04B4979}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {B9899CF1-E0EB-4599-9E24-6939A04B4979}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {B9899CF1-E0EB-4599-9E24-6939A04B4979}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {B9899CF1-E0EB-4599-9E24-6939A04B4979}.Release|Any CPU.Build.0 = Release|Any CPU
- {D15BF03E-04ED-4BEE-A72B-7620F541F4E2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {D15BF03E-04ED-4BEE-A72B-7620F541F4E2}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {D15BF03E-04ED-4BEE-A72B-7620F541F4E2}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {D15BF03E-04ED-4BEE-A72B-7620F541F4E2}.Release|Any CPU.Build.0 = Release|Any CPU
{B64766CD-1A1F-4C1B-B11F-C30F82B8E41E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B64766CD-1A1F-4C1B-B11F-C30F82B8E41E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B64766CD-1A1F-4C1B-B11F-C30F82B8E41E}.Release|Any CPU.ActiveCfg = Release|Any CPU
@@ -1807,6 +1793,10 @@ Global
{5399BBCC-417F-C710-46DE-EB0C0074C34D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5399BBCC-417F-C710-46DE-EB0C0074C34D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5399BBCC-417F-C710-46DE-EB0C0074C34D}.Release|Any CPU.Build.0 = Release|Any CPU
+ {5E4F7448-B00B-4F5B-859F-6ED0354253D5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {5E4F7448-B00B-4F5B-859F-6ED0354253D5}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {5E4F7448-B00B-4F5B-859F-6ED0354253D5}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {5E4F7448-B00B-4F5B-859F-6ED0354253D5}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -1974,8 +1964,6 @@ Global
{CE7F7553-DB2D-4839-92E3-F042E4261B4E} = {8DBA5174-B0AA-4561-82B1-A46607697753}
{FF38E9C9-7A25-44F0-B2C4-24C9BFD6A8F6} = {FD0FAF5F-1DED-485C-99FA-84B97F3A8EEC}
{D55FB2BD-CC9E-454B-9654-94AF5D910BF7} = {FD0FAF5F-1DED-485C-99FA-84B97F3A8EEC}
- {B9899CF1-E0EB-4599-9E24-6939A04B4979} = {D449D505-CC6A-4E0B-AF1B-976E2D0AE67A}
- {D15BF03E-04ED-4BEE-A72B-7620F541F4E2} = {D449D505-CC6A-4E0B-AF1B-976E2D0AE67A}
{4A49D526-1644-4819-AA4F-95B348D447D4} = {3E5FE3DB-45F7-4D83-9097-8F05D3B3AEC6}
{EC946164-1E17-410B-B7D9-7DE7E6268D63} = {7A69EA65-4411-4CD0-B439-035E720C1BD3}
{99F594B1-3916-471D-A761-A6731FC50E9A} = {9C1BE25C-5926-4E56-84AE-D2242CB0627E}
@@ -2101,8 +2089,6 @@ Global
{BE5FE32C-DA73-4EC5-809E-E11B05ACA398} = {0DDCFE67-7D4E-4709-9882-EC032A031789}
{FCB56CBA-FA35-46A8-86B7-BAE5433197D9} = {0DDCFE67-7D4E-4709-9882-EC032A031789}
{68528C1C-B163-49A6-A19D-24E10F500F90} = {0DDCFE67-7D4E-4709-9882-EC032A031789}
- {3055F932-0D1E-4823-A03A-7B62C7639BDA} = {0DDCFE67-7D4E-4709-9882-EC032A031789}
- {4C362C30-C4B1-4C4B-A545-DBF67C7E9153} = {0DDCFE67-7D4E-4709-9882-EC032A031789}
{9C4BC501-C0A6-4130-BA68-EF5FB0C640B0} = {0DDCFE67-7D4E-4709-9882-EC032A031789}
{0DDCFE67-7D4E-4709-9882-EC032A031789} = {02EA681E-C7D8-13C7-8484-4AC65E1B71E8}
{34A07D0C-32E6-E19B-337E-4E6CB722C606} = {0DDCFE67-7D4E-4709-9882-EC032A031789}
@@ -2150,6 +2136,7 @@ Global
{1B4AC233-B345-123F-E004-DAA28DE1CB08} = {A41D1B99-F489-4C43-BBDF-96D61B19A6B9}
{91F9EAA4-ACA2-87EE-868E-6CC3B73D6A11} = {A41D1B99-F489-4C43-BBDF-96D61B19A6B9}
{5399BBCC-417F-C710-46DE-EB0C0074C34D} = {A41D1B99-F489-4C43-BBDF-96D61B19A6B9}
+ {5E4F7448-B00B-4F5B-859F-6ED0354253D5} = {C52D8057-43AF-40E6-A01B-6CDBB7301985}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {604E6B91-7BC0-4126-AE07-D4D2FEFC3D29}
@@ -2160,8 +2147,14 @@ Global
src\Compilers\CSharp\csc\CscCommandLine.projitems*{0161e25c-918a-4dc8-9648-30fdcc8e31e9}*SharedItemsImports = 5
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Extensions\Microsoft.CodeAnalysis.Extensions.projitems*{02bcc112-0a29-43aa-84fa-c71c18a9486c}*SharedItemsImports = 13
src\RoslynAnalyzers\Utilities\Compiler\Analyzer.Utilities.projitems*{08735294-3e6b-4420-9916-e7b8c4eb874d}*SharedItemsImports = 13
+ src\Dependencies\Collections\Microsoft.CodeAnalysis.Collections.projitems*{0a1267e9-52ff-b8de-8522-802be55f41da}*SharedItemsImports = 5
+ src\Dependencies\Contracts\Microsoft.CodeAnalysis.Contracts.projitems*{0a1267e9-52ff-b8de-8522-802be55f41da}*SharedItemsImports = 5
+ src\Dependencies\PooledObjects\Microsoft.CodeAnalysis.PooledObjects.projitems*{0a1267e9-52ff-b8de-8522-802be55f41da}*SharedItemsImports = 5
+ src\Dependencies\Threading\Microsoft.CodeAnalysis.Threading.projitems*{0a1267e9-52ff-b8de-8522-802be55f41da}*SharedItemsImports = 5
src\RoslynAnalyzers\Utilities\Compiler\Analyzer.Utilities.projitems*{0a1267e9-52ff-b8de-8522-802be55f41da}*SharedItemsImports = 5
src\RoslynAnalyzers\Utilities\FlowAnalysis\FlowAnalysis.Utilities.projitems*{0a1267e9-52ff-b8de-8522-802be55f41da}*SharedItemsImports = 5
+ src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\CompilerExtensions.projitems*{0a1267e9-52ff-b8de-8522-802be55f41da}*SharedItemsImports = 5
+ src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Extensions\Microsoft.CodeAnalysis.Extensions.projitems*{0a1267e9-52ff-b8de-8522-802be55f41da}*SharedItemsImports = 5
src\Dependencies\Contracts\Microsoft.CodeAnalysis.Contracts.projitems*{0c2e1633-1462-4712-88f4-a0c945bad3a8}*SharedItemsImports = 5
src\Dependencies\PooledObjects\Microsoft.CodeAnalysis.PooledObjects.projitems*{0c2e1633-1462-4712-88f4-a0c945bad3a8}*SharedItemsImports = 5
src\Dependencies\Contracts\Microsoft.CodeAnalysis.Contracts.projitems*{1b4ac233-b345-123f-e004-daa28de1cb08}*SharedItemsImports = 5
@@ -2188,19 +2181,23 @@ Global
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\CompilerExtensions.projitems*{275812ee-dedb-4232-9439-91c9757d2ae4}*SharedItemsImports = 5
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Extensions\Microsoft.CodeAnalysis.Extensions.projitems*{275812ee-dedb-4232-9439-91c9757d2ae4}*SharedItemsImports = 5
src\Dependencies\Contracts\Microsoft.CodeAnalysis.Contracts.projitems*{2801f82b-78ce-4bae-b06f-537574751e2e}*SharedItemsImports = 5
- src\RoslynAnalyzers\Utilities\Refactoring.CSharp\Refactoring.CSharp.Utilities.projitems*{3055f932-0d1e-4823-a03a-7b62c7639bda}*SharedItemsImports = 13
src\ExpressionEvaluator\VisualBasic\Source\ResultProvider\BasicResultProvider.projitems*{3140fe61-0856-4367-9aa3-8081b9a80e35}*SharedItemsImports = 13
src\ExpressionEvaluator\CSharp\Source\ResultProvider\CSharpResultProvider.projitems*{3140fe61-0856-4367-9aa3-8081b9a80e36}*SharedItemsImports = 13
src\Analyzers\CSharp\Analyzers\CSharpAnalyzers.projitems*{3973b09a-4fbf-44a5-8359-3d22ceb71f71}*SharedItemsImports = 5
src\Analyzers\CSharp\CodeFixes\CSharpCodeFixes.projitems*{3973b09a-4fbf-44a5-8359-3d22ceb71f71}*SharedItemsImports = 5
src\Compilers\CSharp\CSharpAnalyzerDriver\CSharpAnalyzerDriver.projitems*{3973b09a-4fbf-44a5-8359-3d22ceb71f71}*SharedItemsImports = 5
+ src\Dependencies\Collections\Microsoft.CodeAnalysis.Collections.projitems*{3f65d29d-ed95-2d6f-b927-47c5cf070aa5}*SharedItemsImports = 5
+ src\Dependencies\Contracts\Microsoft.CodeAnalysis.Contracts.projitems*{3f65d29d-ed95-2d6f-b927-47c5cf070aa5}*SharedItemsImports = 5
+ src\Dependencies\PooledObjects\Microsoft.CodeAnalysis.PooledObjects.projitems*{3f65d29d-ed95-2d6f-b927-47c5cf070aa5}*SharedItemsImports = 5
+ src\Dependencies\Threading\Microsoft.CodeAnalysis.Threading.projitems*{3f65d29d-ed95-2d6f-b927-47c5cf070aa5}*SharedItemsImports = 5
src\RoslynAnalyzers\Utilities\Compiler\Analyzer.Utilities.projitems*{3f65d29d-ed95-2d6f-b927-47c5cf070aa5}*SharedItemsImports = 5
src\RoslynAnalyzers\Utilities\Workspaces\Workspaces.Utilities.projitems*{3f65d29d-ed95-2d6f-b927-47c5cf070aa5}*SharedItemsImports = 5
+ src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\CompilerExtensions.projitems*{3f65d29d-ed95-2d6f-b927-47c5cf070aa5}*SharedItemsImports = 5
+ src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Extensions\Microsoft.CodeAnalysis.Extensions.projitems*{3f65d29d-ed95-2d6f-b927-47c5cf070aa5}*SharedItemsImports = 5
src\Dependencies\Contracts\Microsoft.CodeAnalysis.Contracts.projitems*{41ed1bfa-fdad-4fe4-8118-db23fb49b0b0}*SharedItemsImports = 5
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\CSharpWorkspaceExtensions.projitems*{438db8af-f3f0-4ed9-80b5-13fddd5b8787}*SharedItemsImports = 13
src\Dependencies\Contracts\Microsoft.CodeAnalysis.Contracts.projitems*{49e7c367-181b-499c-ac2e-8e17c81418d6}*SharedItemsImports = 5
src\Compilers\CSharp\csc\CscCommandLine.projitems*{4b45ca0c-03a0-400f-b454-3d4bcb16af38}*SharedItemsImports = 5
- src\RoslynAnalyzers\Utilities\Refactoring.VisualBasic\Refactoring.VisualBasic.Utilities.projitems*{4c362c30-c4b1-4c4b-a545-dbf67c7e9153}*SharedItemsImports = 13
src\Analyzers\CSharp\Tests\CSharpAnalyzers.UnitTests.projitems*{5018d049-5870-465a-889b-c742ce1e31cb}*SharedItemsImports = 5
src\Compilers\CSharp\CSharpAnalyzerDriver\CSharpAnalyzerDriver.projitems*{54e08bf5-f819-404f-a18d-0ab9ea81ea04}*SharedItemsImports = 13
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\VisualBasic\VisualBasicCompilerExtensions.projitems*{57ca988d-f010-4bf2-9a2e-07d6dcd2ff2c}*SharedItemsImports = 5
@@ -2222,24 +2219,57 @@ Global
src\LanguageServer\Microsoft.CommonLanguageServerProtocol.Framework\Microsoft.CommonLanguageServerProtocol.Framework.Shared.projitems*{686bf57e-a6ff-467b-aab3-44de916a9772}*SharedItemsImports = 5
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\CSharpCompilerExtensions.projitems*{699fea05-aea7-403d-827e-53cf4e826955}*SharedItemsImports = 13
src\Dependencies\Contracts\Microsoft.CodeAnalysis.Contracts.projitems*{6fc8e6f5-659c-424d-aeb5-331b95883e29}*SharedItemsImports = 5
+ src\Dependencies\Collections\Microsoft.CodeAnalysis.Collections.projitems*{7005dd7b-d3b6-1360-313b-975974aa6254}*SharedItemsImports = 5
+ src\Dependencies\Contracts\Microsoft.CodeAnalysis.Contracts.projitems*{7005dd7b-d3b6-1360-313b-975974aa6254}*SharedItemsImports = 5
+ src\Dependencies\PooledObjects\Microsoft.CodeAnalysis.PooledObjects.projitems*{7005dd7b-d3b6-1360-313b-975974aa6254}*SharedItemsImports = 5
+ src\Dependencies\Threading\Microsoft.CodeAnalysis.Threading.projitems*{7005dd7b-d3b6-1360-313b-975974aa6254}*SharedItemsImports = 5
src\RoslynAnalyzers\Utilities\Compiler\Analyzer.Utilities.projitems*{7005dd7b-d3b6-1360-313b-975974aa6254}*SharedItemsImports = 5
src\RoslynAnalyzers\Utilities\Workspaces\Workspaces.Utilities.projitems*{7005dd7b-d3b6-1360-313b-975974aa6254}*SharedItemsImports = 5
+ src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\CompilerExtensions.projitems*{7005dd7b-d3b6-1360-313b-975974aa6254}*SharedItemsImports = 5
+ src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Extensions\Microsoft.CodeAnalysis.Extensions.projitems*{7005dd7b-d3b6-1360-313b-975974aa6254}*SharedItemsImports = 5
src\ExpressionEvaluator\VisualBasic\Source\ResultProvider\BasicResultProvider.projitems*{76242a2d-2600-49dd-8c15-fea07ecb1843}*SharedItemsImports = 5
src\Analyzers\Core\Analyzers\Analyzers.projitems*{76e96966-4780-4040-8197-bde2879516f4}*SharedItemsImports = 13
src\Analyzers\VisualBasic\Tests\VisualBasicAnalyzers.UnitTests.projitems*{7b7f4153-ae93-4908-b8f0-430871589f83}*SharedItemsImports = 13
+ src\Dependencies\Collections\Microsoft.CodeAnalysis.Collections.projitems*{8087bde4-6707-05a5-5f84-dfe6628e8ec8}*SharedItemsImports = 5
+ src\Dependencies\Contracts\Microsoft.CodeAnalysis.Contracts.projitems*{8087bde4-6707-05a5-5f84-dfe6628e8ec8}*SharedItemsImports = 5
+ src\Dependencies\PooledObjects\Microsoft.CodeAnalysis.PooledObjects.projitems*{8087bde4-6707-05a5-5f84-dfe6628e8ec8}*SharedItemsImports = 5
+ src\Dependencies\Threading\Microsoft.CodeAnalysis.Threading.projitems*{8087bde4-6707-05a5-5f84-dfe6628e8ec8}*SharedItemsImports = 5
src\RoslynAnalyzers\Utilities\Compiler\Analyzer.Utilities.projitems*{8087bde4-6707-05a5-5f84-dfe6628e8ec8}*SharedItemsImports = 5
src\RoslynAnalyzers\Utilities\Workspaces\Workspaces.Utilities.projitems*{8087bde4-6707-05a5-5f84-dfe6628e8ec8}*SharedItemsImports = 5
+ src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\CompilerExtensions.projitems*{8087bde4-6707-05a5-5f84-dfe6628e8ec8}*SharedItemsImports = 5
+ src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Extensions\Microsoft.CodeAnalysis.Extensions.projitems*{8087bde4-6707-05a5-5f84-dfe6628e8ec8}*SharedItemsImports = 5
+ src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\WorkspaceExtensions.projitems*{8087bde4-6707-05a5-5f84-dfe6628e8ec8}*SharedItemsImports = 5
src\Compilers\VisualBasic\vbc\VbcCommandLine.projitems*{810b02ad-2ea5-4422-88ac-b71b8ab0df0b}*SharedItemsImports = 13
+ src\Dependencies\Collections\Microsoft.CodeAnalysis.Collections.projitems*{8252a386-069a-0d7d-eab4-b2e77833b443}*SharedItemsImports = 5
+ src\Dependencies\Contracts\Microsoft.CodeAnalysis.Contracts.projitems*{8252a386-069a-0d7d-eab4-b2e77833b443}*SharedItemsImports = 5
+ src\Dependencies\PooledObjects\Microsoft.CodeAnalysis.PooledObjects.projitems*{8252a386-069a-0d7d-eab4-b2e77833b443}*SharedItemsImports = 5
+ src\Dependencies\Threading\Microsoft.CodeAnalysis.Threading.projitems*{8252a386-069a-0d7d-eab4-b2e77833b443}*SharedItemsImports = 5
src\RoslynAnalyzers\Utilities\Compiler\Analyzer.Utilities.projitems*{8252a386-069a-0d7d-eab4-b2e77833b443}*SharedItemsImports = 5
src\RoslynAnalyzers\Utilities\Workspaces\Workspaces.Utilities.projitems*{8252a386-069a-0d7d-eab4-b2e77833b443}*SharedItemsImports = 5
+ src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\CompilerExtensions.projitems*{8252a386-069a-0d7d-eab4-b2e77833b443}*SharedItemsImports = 5
+ src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Extensions\Microsoft.CodeAnalysis.Extensions.projitems*{8252a386-069a-0d7d-eab4-b2e77833b443}*SharedItemsImports = 5
+ src\Dependencies\Collections\Microsoft.CodeAnalysis.Collections.projitems*{8ce66034-25e2-8ff2-93a1-0bd3672ad86d}*SharedItemsImports = 5
+ src\Dependencies\Contracts\Microsoft.CodeAnalysis.Contracts.projitems*{8ce66034-25e2-8ff2-93a1-0bd3672ad86d}*SharedItemsImports = 5
+ src\Dependencies\PooledObjects\Microsoft.CodeAnalysis.PooledObjects.projitems*{8ce66034-25e2-8ff2-93a1-0bd3672ad86d}*SharedItemsImports = 5
+ src\Dependencies\Threading\Microsoft.CodeAnalysis.Threading.projitems*{8ce66034-25e2-8ff2-93a1-0bd3672ad86d}*SharedItemsImports = 5
src\RoslynAnalyzers\Utilities\Compiler\Analyzer.Utilities.projitems*{8ce66034-25e2-8ff2-93a1-0bd3672ad86d}*SharedItemsImports = 5
+ src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\CompilerExtensions.projitems*{8ce66034-25e2-8ff2-93a1-0bd3672ad86d}*SharedItemsImports = 5
+ src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Extensions\Microsoft.CodeAnalysis.Extensions.projitems*{8ce66034-25e2-8ff2-93a1-0bd3672ad86d}*SharedItemsImports = 5
+ src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\WorkspaceExtensions.projitems*{8ce66034-25e2-8ff2-93a1-0bd3672ad86d}*SharedItemsImports = 5
src\Dependencies\Collections\Microsoft.CodeAnalysis.Collections.projitems*{8e2a252e-a140-45a6-a81a-2652996ea589}*SharedItemsImports = 5
src\Dependencies\Contracts\Microsoft.CodeAnalysis.Contracts.projitems*{8e2a252e-a140-45a6-a81a-2652996ea589}*SharedItemsImports = 5
src\Dependencies\PooledObjects\Microsoft.CodeAnalysis.PooledObjects.projitems*{8e2a252e-a140-45a6-a81a-2652996ea589}*SharedItemsImports = 5
src\Dependencies\Threading\Microsoft.CodeAnalysis.Threading.projitems*{8e2a252e-a140-45a6-a81a-2652996ea589}*SharedItemsImports = 5
src\Dependencies\Contracts\Microsoft.CodeAnalysis.Contracts.projitems*{91f9eaa4-aca2-87ee-868e-6cc3b73d6a11}*SharedItemsImports = 5
+ src\Dependencies\Collections\Microsoft.CodeAnalysis.Collections.projitems*{923e34ba-ca8a-971e-7ff7-51dd346394a1}*SharedItemsImports = 5
+ src\Dependencies\Contracts\Microsoft.CodeAnalysis.Contracts.projitems*{923e34ba-ca8a-971e-7ff7-51dd346394a1}*SharedItemsImports = 5
+ src\Dependencies\PooledObjects\Microsoft.CodeAnalysis.PooledObjects.projitems*{923e34ba-ca8a-971e-7ff7-51dd346394a1}*SharedItemsImports = 5
+ src\Dependencies\Threading\Microsoft.CodeAnalysis.Threading.projitems*{923e34ba-ca8a-971e-7ff7-51dd346394a1}*SharedItemsImports = 5
src\RoslynAnalyzers\Utilities\Compiler\Analyzer.Utilities.projitems*{923e34ba-ca8a-971e-7ff7-51dd346394a1}*SharedItemsImports = 5
src\RoslynAnalyzers\Utilities\Workspaces\Workspaces.Utilities.projitems*{923e34ba-ca8a-971e-7ff7-51dd346394a1}*SharedItemsImports = 5
+ src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\CompilerExtensions.projitems*{923e34ba-ca8a-971e-7ff7-51dd346394a1}*SharedItemsImports = 5
+ src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Extensions\Microsoft.CodeAnalysis.Extensions.projitems*{923e34ba-ca8a-971e-7ff7-51dd346394a1}*SharedItemsImports = 5
+ src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\WorkspaceExtensions.projitems*{923e34ba-ca8a-971e-7ff7-51dd346394a1}*SharedItemsImports = 5
src\Analyzers\VisualBasic\Analyzers\VisualBasicAnalyzers.projitems*{94faf461-2e74-4dbb-9813-6b2cde6f1880}*SharedItemsImports = 13
src\Compilers\Server\VBCSCompiler\VBCSCompilerCommandLine.projitems*{9508f118-f62e-4c16-a6f4-7c3b56e166ad}*SharedItemsImports = 5
src\Dependencies\Threading\Microsoft.CodeAnalysis.Threading.projitems*{967723e8-4fdd-447b-99f6-4f8c47cb5433}*SharedItemsImports = 13
@@ -2252,16 +2282,40 @@ Global
src\Analyzers\VisualBasic\Analyzers\VisualBasicAnalyzers.projitems*{a1bcd0ce-6c2f-4f8c-9a48-d9d93928e26d}*SharedItemsImports = 5
src\Analyzers\VisualBasic\CodeFixes\VisualBasicCodeFixes.projitems*{a1bcd0ce-6c2f-4f8c-9a48-d9d93928e26d}*SharedItemsImports = 5
src\Compilers\VisualBasic\BasicAnalyzerDriver\BasicAnalyzerDriver.projitems*{a1bcd0ce-6c2f-4f8c-9a48-d9d93928e26d}*SharedItemsImports = 5
- src\RoslynAnalyzers\Utilities\Refactoring.VisualBasic\Refactoring.VisualBasic.Utilities.projitems*{a4a3650e-164f-9339-fa7b-606effd06268}*SharedItemsImports = 5
+ src\Dependencies\Collections\Microsoft.CodeAnalysis.Collections.projitems*{a1ebc0bc-d378-b9b7-7a57-ef7df11e3ed7}*SharedItemsImports = 5
+ src\Dependencies\Contracts\Microsoft.CodeAnalysis.Contracts.projitems*{a1ebc0bc-d378-b9b7-7a57-ef7df11e3ed7}*SharedItemsImports = 5
+ src\Dependencies\PooledObjects\Microsoft.CodeAnalysis.PooledObjects.projitems*{a1ebc0bc-d378-b9b7-7a57-ef7df11e3ed7}*SharedItemsImports = 5
+ src\Dependencies\Threading\Microsoft.CodeAnalysis.Threading.projitems*{a1ebc0bc-d378-b9b7-7a57-ef7df11e3ed7}*SharedItemsImports = 5
+ src\RoslynAnalyzers\Utilities\Compiler\Analyzer.Utilities.projitems*{a1ebc0bc-d378-b9b7-7a57-ef7df11e3ed7}*SharedItemsImports = 5
+ src\RoslynAnalyzers\Utilities\Workspaces\Workspaces.Utilities.projitems*{a1ebc0bc-d378-b9b7-7a57-ef7df11e3ed7}*SharedItemsImports = 5
+ src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\CompilerExtensions.projitems*{a1ebc0bc-d378-b9b7-7a57-ef7df11e3ed7}*SharedItemsImports = 5
+ src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Extensions\Microsoft.CodeAnalysis.Extensions.projitems*{a1ebc0bc-d378-b9b7-7a57-ef7df11e3ed7}*SharedItemsImports = 5
+ src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\WorkspaceExtensions.projitems*{a1ebc0bc-d378-b9b7-7a57-ef7df11e3ed7}*SharedItemsImports = 5
+ src\Workspaces\SharedUtilitiesAndExtensions\Compiler\VisualBasic\VisualBasicCompilerExtensions.projitems*{a4a3650e-164f-9339-fa7b-606effd06268}*SharedItemsImports = 5
+ src\Workspaces\SharedUtilitiesAndExtensions\Workspace\VisualBasic\VisualBasicWorkspaceExtensions.projitems*{a4a3650e-164f-9339-fa7b-606effd06268}*SharedItemsImports = 5
+ src\Dependencies\Collections\Microsoft.CodeAnalysis.Collections.projitems*{a6844326-e313-f10a-7e99-89f54c73774c}*SharedItemsImports = 5
+ src\Dependencies\Contracts\Microsoft.CodeAnalysis.Contracts.projitems*{a6844326-e313-f10a-7e99-89f54c73774c}*SharedItemsImports = 5
+ src\Dependencies\PooledObjects\Microsoft.CodeAnalysis.PooledObjects.projitems*{a6844326-e313-f10a-7e99-89f54c73774c}*SharedItemsImports = 5
+ src\Dependencies\Threading\Microsoft.CodeAnalysis.Threading.projitems*{a6844326-e313-f10a-7e99-89f54c73774c}*SharedItemsImports = 5
src\RoslynAnalyzers\Utilities\Compiler\Analyzer.Utilities.projitems*{a6844326-e313-f10a-7e99-89f54c73774c}*SharedItemsImports = 5
+ src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\CompilerExtensions.projitems*{a6844326-e313-f10a-7e99-89f54c73774c}*SharedItemsImports = 5
+ src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Extensions\Microsoft.CodeAnalysis.Extensions.projitems*{a6844326-e313-f10a-7e99-89f54c73774c}*SharedItemsImports = 5
+ src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\WorkspaceExtensions.projitems*{a6844326-e313-f10a-7e99-89f54c73774c}*SharedItemsImports = 5
src\Analyzers\CSharp\Analyzers\CSharpAnalyzers.projitems*{aa87bfed-089a-4096-b8d5-690bdc7d5b24}*SharedItemsImports = 5
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\CSharpCompilerExtensions.projitems*{aa87bfed-089a-4096-b8d5-690bdc7d5b24}*SharedItemsImports = 5
src\Dependencies\Contracts\Microsoft.CodeAnalysis.Contracts.projitems*{abdbac1e-350e-4dc3-bb45-3504404545ee}*SharedItemsImports = 5
src\ExpressionEvaluator\Core\Source\ResultProvider\ResultProvider.projitems*{abdbac1e-350e-4dc3-bb45-3504404545ee}*SharedItemsImports = 5
src\ExpressionEvaluator\VisualBasic\Source\ResultProvider\BasicResultProvider.projitems*{ace53515-482c-4c6a-e2d2-4242a687dfee}*SharedItemsImports = 5
+ src\Dependencies\Collections\Microsoft.CodeAnalysis.Collections.projitems*{ad0837be-7912-aedf-bda9-2d2e4fe0ce0b}*SharedItemsImports = 5
+ src\Dependencies\Contracts\Microsoft.CodeAnalysis.Contracts.projitems*{ad0837be-7912-aedf-bda9-2d2e4fe0ce0b}*SharedItemsImports = 5
+ src\Dependencies\PooledObjects\Microsoft.CodeAnalysis.PooledObjects.projitems*{ad0837be-7912-aedf-bda9-2d2e4fe0ce0b}*SharedItemsImports = 5
+ src\Dependencies\Threading\Microsoft.CodeAnalysis.Threading.projitems*{ad0837be-7912-aedf-bda9-2d2e4fe0ce0b}*SharedItemsImports = 5
src\RoslynAnalyzers\Utilities\Compiler\Analyzer.Utilities.projitems*{ad0837be-7912-aedf-bda9-2d2e4fe0ce0b}*SharedItemsImports = 5
src\RoslynAnalyzers\Utilities\Refactoring\Refactoring.Utilities.projitems*{ad0837be-7912-aedf-bda9-2d2e4fe0ce0b}*SharedItemsImports = 5
src\RoslynAnalyzers\Utilities\Workspaces\Workspaces.Utilities.projitems*{ad0837be-7912-aedf-bda9-2d2e4fe0ce0b}*SharedItemsImports = 5
+ src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\CompilerExtensions.projitems*{ad0837be-7912-aedf-bda9-2d2e4fe0ce0b}*SharedItemsImports = 5
+ src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Extensions\Microsoft.CodeAnalysis.Extensions.projitems*{ad0837be-7912-aedf-bda9-2d2e4fe0ce0b}*SharedItemsImports = 5
+ src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\WorkspaceExtensions.projitems*{ad0837be-7912-aedf-bda9-2d2e4fe0ce0b}*SharedItemsImports = 5
src\Compilers\CSharp\csc\CscCommandLine.projitems*{b021ccbc-b2af-4560-af28-ed055f0ed696}*SharedItemsImports = 13
src\Dependencies\Collections\Microsoft.CodeAnalysis.Collections.projitems*{b1481d94-682e-46ec-adbe-a16eb46feee9}*SharedItemsImports = 5
src\Dependencies\Contracts\Microsoft.CodeAnalysis.Contracts.projitems*{b1481d94-682e-46ec-adbe-a16eb46feee9}*SharedItemsImports = 5
@@ -2273,7 +2327,13 @@ Global
src\RoslynAnalyzers\Utilities\Compiler.CSharp\Analyzer.CSharp.Utilities.projitems*{be5fe32c-da73-4ec5-809e-e11b05aca398}*SharedItemsImports = 13
src\ExpressionEvaluator\CSharp\Source\ResultProvider\CSharpResultProvider.projitems*{bf9dac1e-3a5e-4dc3-bb44-9a64e0d4e9d4}*SharedItemsImports = 5
src\Dependencies\PooledObjects\Microsoft.CodeAnalysis.PooledObjects.projitems*{c1930979-c824-496b-a630-70f5369a636f}*SharedItemsImports = 13
+ src\Dependencies\Collections\Microsoft.CodeAnalysis.Collections.projitems*{ce7c15d3-3b1b-84cf-1b4b-da45533e9e83}*SharedItemsImports = 5
+ src\Dependencies\Contracts\Microsoft.CodeAnalysis.Contracts.projitems*{ce7c15d3-3b1b-84cf-1b4b-da45533e9e83}*SharedItemsImports = 5
+ src\Dependencies\PooledObjects\Microsoft.CodeAnalysis.PooledObjects.projitems*{ce7c15d3-3b1b-84cf-1b4b-da45533e9e83}*SharedItemsImports = 5
+ src\Dependencies\Threading\Microsoft.CodeAnalysis.Threading.projitems*{ce7c15d3-3b1b-84cf-1b4b-da45533e9e83}*SharedItemsImports = 5
src\RoslynAnalyzers\Utilities\Compiler\Analyzer.Utilities.projitems*{ce7c15d3-3b1b-84cf-1b4b-da45533e9e83}*SharedItemsImports = 5
+ src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\CompilerExtensions.projitems*{ce7c15d3-3b1b-84cf-1b4b-da45533e9e83}*SharedItemsImports = 5
+ src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Extensions\Microsoft.CodeAnalysis.Extensions.projitems*{ce7c15d3-3b1b-84cf-1b4b-da45533e9e83}*SharedItemsImports = 5
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\VisualBasic\VisualBasicCompilerExtensions.projitems*{cec0dce7-8d52-45c3-9295-fc7b16bd2451}*SharedItemsImports = 13
src\Compilers\Core\AnalyzerDriver\AnalyzerDriver.projitems*{d0bc9be7-24f6-40ca-8dc6-fcb93bd44b34}*SharedItemsImports = 13
src\Dependencies\Contracts\Microsoft.CodeAnalysis.Contracts.projitems*{d2589bce-4f2e-4113-b7e7-37392c0c5492}*SharedItemsImports = 5
@@ -2282,7 +2342,8 @@ Global
src\Analyzers\CSharp\CodeFixes\CSharpCodeFixes.projitems*{da973826-c985-4128-9948-0b445e638bdb}*SharedItemsImports = 13
src\Dependencies\Contracts\Microsoft.CodeAnalysis.Contracts.projitems*{db96c25f-39a9-4a6a-92bc-d1e42717308f}*SharedItemsImports = 5
src\Compilers\Server\VBCSCompiler\VBCSCompilerCommandLine.projitems*{dc8c78cc-b6fe-47bf-93b1-b65a1c67c08d}*SharedItemsImports = 5
- src\RoslynAnalyzers\Utilities\Refactoring.CSharp\Refactoring.CSharp.Utilities.projitems*{dee77b19-9559-d47d-8ec4-c207152a9c2c}*SharedItemsImports = 5
+ src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\CSharpCompilerExtensions.projitems*{dee77b19-9559-d47d-8ec4-c207152a9c2c}*SharedItemsImports = 5
+ src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\CSharpWorkspaceExtensions.projitems*{dee77b19-9559-d47d-8ec4-c207152a9c2c}*SharedItemsImports = 5
src\Analyzers\VisualBasic\Tests\VisualBasicAnalyzers.UnitTests.projitems*{e512c6c1-f085-4ad7-b0d9-e8f1a0a2a510}*SharedItemsImports = 5
src\Compilers\VisualBasic\vbc\VbcCommandLine.projitems*{e58ee9d7-1239-4961-a0c1-f9ec3952c4c1}*SharedItemsImports = 5
src\Analyzers\CSharp\Tests\CSharpAnalyzers.UnitTests.projitems*{e645b517-5766-46fb-aa4a-d4d30c9e3be6}*SharedItemsImports = 5
@@ -2303,7 +2364,13 @@ Global
src\Dependencies\Contracts\Microsoft.CodeAnalysis.Contracts.projitems*{fc2ae90b-2e4b-4045-9fdd-73d4f5ed6c89}*SharedItemsImports = 5
src\Dependencies\PooledObjects\Microsoft.CodeAnalysis.PooledObjects.projitems*{fc2ae90b-2e4b-4045-9fdd-73d4f5ed6c89}*SharedItemsImports = 5
src\RoslynAnalyzers\Utilities\FlowAnalysis\FlowAnalysis.Utilities.projitems*{fcb56cba-fa35-46a8-86b7-bae5433197d9}*SharedItemsImports = 13
+ src\Dependencies\Collections\Microsoft.CodeAnalysis.Collections.projitems*{fce0046b-03f8-78f6-86a1-8ddcee8f4c9f}*SharedItemsImports = 5
+ src\Dependencies\Contracts\Microsoft.CodeAnalysis.Contracts.projitems*{fce0046b-03f8-78f6-86a1-8ddcee8f4c9f}*SharedItemsImports = 5
+ src\Dependencies\PooledObjects\Microsoft.CodeAnalysis.PooledObjects.projitems*{fce0046b-03f8-78f6-86a1-8ddcee8f4c9f}*SharedItemsImports = 5
+ src\Dependencies\Threading\Microsoft.CodeAnalysis.Threading.projitems*{fce0046b-03f8-78f6-86a1-8ddcee8f4c9f}*SharedItemsImports = 5
src\RoslynAnalyzers\Utilities\Compiler\Analyzer.Utilities.projitems*{fce0046b-03f8-78f6-86a1-8ddcee8f4c9f}*SharedItemsImports = 5
+ src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\CompilerExtensions.projitems*{fce0046b-03f8-78f6-86a1-8ddcee8f4c9f}*SharedItemsImports = 5
+ src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Extensions\Microsoft.CodeAnalysis.Extensions.projitems*{fce0046b-03f8-78f6-86a1-8ddcee8f4c9f}*SharedItemsImports = 5
src\Dependencies\Contracts\Microsoft.CodeAnalysis.Contracts.projitems*{fce88bbd-9bbd-4871-b9b0-de176d73a6b0}*SharedItemsImports = 5
EndGlobalSection
EndGlobal
diff --git a/azure-pipelines-integration-dartlab.yml b/azure-pipelines-integration-dartlab.yml
index c9dca1e99484e..da0b456b9b248 100644
--- a/azure-pipelines-integration-dartlab.yml
+++ b/azure-pipelines-integration-dartlab.yml
@@ -22,7 +22,7 @@ resources:
name: internal/dotnet-roslyn
ref: $(Build.SourceBranch)
trigger:
- - main
+ - main-vs-deps
parameters:
- name: prNumber
@@ -122,4 +122,4 @@ stages:
gitHubConnection: 'dotnet-comment-bot-service-connection'
repositoryName: '$(Build.Repository.Name)'
id: ${{ parameters.prNumber }}
- comment: 'DartLab pipeline [run]($(System.TeamFoundationCollectionUri)$(System.TeamProject)/_build/results?buildId=$(Build.BuildId)) did not complete successfully for ${{ parameters.sha }}'
\ No newline at end of file
+ comment: 'DartLab pipeline [run]($(System.TeamFoundationCollectionUri)$(System.TeamProject)/_build/results?buildId=$(Build.BuildId)) did not complete successfully for ${{ parameters.sha }}'
diff --git a/azure-pipelines-integration.yml b/azure-pipelines-integration.yml
index cf70c67c5c5d2..afddf6a20c094 100644
--- a/azure-pipelines-integration.yml
+++ b/azure-pipelines-integration.yml
@@ -68,7 +68,7 @@ parameters:
- name: queueName
displayName: Queue Name
type: string
- default: windows.vs2022preview.amd64.open
+ default: windows.vs2022preview.scout.amd64.open
values:
- windows.vs2022.amd64.open
- windows.vs2022.scout.amd64.open
diff --git a/docs/contributing/Compiler Test Plan.md b/docs/contributing/Compiler Test Plan.md
index 60a70c63dae06..c9f0f5ea2a3ce 100644
--- a/docs/contributing/Compiler Test Plan.md
+++ b/docs/contributing/Compiler Test Plan.md
@@ -80,7 +80,7 @@ This document provides guidance for thinking about language interactions and tes
- Readonly members on structs (methods, property/indexer accessors, custom event accessors)
- SkipLocalsInit
- Method override or explicit implementation with `where T : { class, struct, default }`
-- `extension` blocks
+- `extension` blocks (emitted with content-based names)
# Code
- Operators (see Eric's list below)
diff --git a/docs/features/incremental-generators.cookbook.md b/docs/features/incremental-generators.cookbook.md
index a8d9afdde0eda..05958dc20deb6 100644
--- a/docs/features/incremental-generators.cookbook.md
+++ b/docs/features/incremental-generators.cookbook.md
@@ -21,6 +21,8 @@ of scope in the final design of the shipping feature.
- [Pipeline model design](#pipeline-model-design)
- [Use `ForAttributeWithMetadataName`](#use-forattributewithmetadataname)
- [Use an indented text writer, not `SyntaxNode`s, for generation](#use-an-indented-text-writer-not-syntaxnodes-for-generation)
+ - [Put `Microsoft.CodeAnalysis.EmbeddedAttribute` on generated marker types](#put-microsoftcodeanalysisembeddedattribute-on-generated-marker-types)
+ - [Do not scan for types that indirectly implement interfaces, indirectly inherit from types, or are indirectly marked by an attribute from an interface or base type](#do-not-scan-for-types-that-indirectly-implement-interfaces-indirectly-inherit-from-types-or-are-indirectly-marked-by-an-attribute-from-an-interface-or-base-type)
- [Designs](#designs)
- [Generated class](#generated-class)
- [Additional file transformation](#additional-file-transformation)
@@ -135,6 +137,27 @@ project, it will not include that type in lookup results. To ensure that `Micros
Another option is to provide an assembly in your nuget package that defines your marker attributes, but this can be more difficult to author. We recommend the
`EmbeddedAttribute` approach, unless you need to support versions of Roslyn lower than 4.14.
+### Do not scan for types that indirectly implement interfaces, indirectly inherit from types, or are indirectly marked by an attribute from an interface or base type
+
+Using an interface/base type marker can be a very tempting and natural fit for generators. However, scanning for these types of markers is _very_ expensive, and cannot
+be done incrementally. Doing so can have an outsized impact on IDE and command-line performance, even for fairly small consuming users. These scenarios are:
+
+* A user implements an interface on `BaseModelType`, and then the generator looks all derived types from `BaseModelType`. Because the generator cannot know ahead of time
+ what `BaseModelType` actually is, it means that the generator has to fetch `AllInterfaces` on every single type in the compilation so it can scan for the marker
+ interface. This will end up occurring either on every keystroke or every file save, depending on what mode the user is running generators in; either one is disastrous
+ for IDE performance, even when trying to optimize by scoping down the scanning to only types with a base list.
+* A user inherits from a generator-defined `BaseSerializerType`, and the generator looks for anything that inherits from that type, either directly or indirectly. Similar
+ to the above scenario, the generator will need to scan all types with a base type in the entire compilation for the inherited `BaseSerializerType`, which will heavily
+ impact IDE performance.
+* A generator looks among all base types/implemented interfaces for a type that is attributed with a generator's marker attribute. This is effectively either scenario 1
+ or 2, just with a different search criteria.
+* A generator leaves its marker attribute unsealed, and expects users to be able to derive their own attributes from that marker, as a source of parameter customization.
+ This has a couple of problems: first, every attributed type needs to be checked to see if the attribute inherits from the marker attribute. While not as performance
+ impacting as the first three scenarios, this isn't great for performance. Second, and more importantly, there is no good way to retrieve any customizations from the
+ inherited attribute. These attributes are not instantiated by the source generator, so any parameters passed to the `base()` constructor call or values that are assigned
+ to any properties of the base attribute are not visible to the generator. Prefer using FAWMN-driven development here, and using an analyzer to inform the user if they
+ need to inherit from some base class for your generator to work correctly.
+
## Designs
This section is broken down by user scenarios, with general solutions listed first, and more specific examples later on.
diff --git a/eng/Directory.Packages.props b/eng/Directory.Packages.props
index 75ead14245059..aa611b4cbb49c 100644
--- a/eng/Directory.Packages.props
+++ b/eng/Directory.Packages.props
@@ -199,7 +199,7 @@
-
+
@@ -215,7 +215,7 @@
-
+
@@ -273,7 +273,7 @@
-
+
@@ -319,16 +319,16 @@
but not higher than our minimum dogfoodable Visual Studio version, or else
the generators we build would load on the command line but not load in IDEs.
-->
-
+
-
-
-
-
-
-
+
+
+
+
+
+
diff --git a/eng/Publishing.props b/eng/Publishing.props
index 7968b1a8ca5a7..2a0c88ef1b25c 100644
--- a/eng/Publishing.props
+++ b/eng/Publishing.props
@@ -5,8 +5,9 @@
-
+ Depending on channel configuration, this means that these assets could be pushed to a different feed.
+ Do not include these for source-only builds since these files aren't intended to be published in that mode. -->
+
diff --git a/eng/Version.Details.xml b/eng/Version.Details.xml
index b6f602b74c189..a1e403bfb4226 100644
--- a/eng/Version.Details.xml
+++ b/eng/Version.Details.xml
@@ -1,6 +1,6 @@
-
+
@@ -110,13 +110,13 @@
-
+
https://github.com/dotnet/arcade
- 086a1771875b63404b4a710d27250fe384dc2810
+ 80c4e4d26cb85c86f7e1be77d2d9eceeef0f3493
-
+
https://github.com/dotnet/arcade
- 086a1771875b63404b4a710d27250fe384dc2810
+ 80c4e4d26cb85c86f7e1be77d2d9eceeef0f3493
https://github.com/dotnet/symreader
@@ -126,9 +126,9 @@
https://github.com/dotnet/roslyn
5d10d428050c0d6afef30a072c4ae68776621877
-
+
https://github.com/dotnet/arcade
- 086a1771875b63404b4a710d27250fe384dc2810
+ 80c4e4d26cb85c86f7e1be77d2d9eceeef0f3493
https://github.com/dotnet/roslyn-analyzers
diff --git a/eng/Versions.props b/eng/Versions.props
index 14c052e19fa99..a70c92287985a 100644
--- a/eng/Versions.props
+++ b/eng/Versions.props
@@ -8,7 +8,7 @@
5
0
0
- 1
+ 2
$(MajorVersion).$(MinorVersion).$(PatchVersion)
+
-
- 3.11.0
- 1.2.1
- 3.11.0
- 3.11.0
- 4.0.1
- 3.11.0
- 3.11.0
- 3.11.0
- 4.0.1
+ 4.12.0
- 4.9.0-3.final
- 4.6.0-1.final
+ 4.12.0
+ 4.12.0
- 4.0.1
- $(MicrosoftCodeAnalysisVersionFromSbrp)
- $(MicrosoftCodeAnalysisVersionFromSbrp)
- $(MicrosoftCodeAnalysisVersionFromSbrp)
- $(MicrosoftCodeAnalysisVersionFromSbrp)
- $(MicrosoftCodeAnalysisVersionFromSbrp)
- $(MicrosoftCodeAnalysisVersionFromSbrp)
- $(MicrosoftCodeAnalysisVersionFromSbrp)
- $(MicrosoftCodeAnalysisVersionFromSbrp)
- $(MicrosoftCodeAnalysisVersionFromSbrp)
- $(MicrosoftCodeAnalysisVersionFromSbrp)
+ 4.12.0
+ $(MicrosoftCodeAnalysisVersionFromSbrp)
+ $(MicrosoftCodeAnalysisVersionFromSbrp)
@@ -184,6 +155,6 @@
in Directory.Packages.props - Microsoft.TestPlatform.TranslationLayer and Microsoft.TestPlatform.ObjectModel.
This version needs to match the Test SDK version consumed by Arcade.
-->
- 17.5.0
+ 17.13.0
diff --git a/eng/common/CIBuild.cmd b/eng/common/CIBuild.cmd
index 56c2f25ac22ff..ac1f72bf94e05 100644
--- a/eng/common/CIBuild.cmd
+++ b/eng/common/CIBuild.cmd
@@ -1,2 +1,2 @@
@echo off
-powershell -ExecutionPolicy ByPass -NoProfile -command "& """%~dp0Build.ps1""" -restore -build -test -sign -pack -publish -ci %*"
\ No newline at end of file
+powershell -ExecutionPolicy ByPass -NoProfile -command "& """%~dp0Build.ps1""" -restore -build -test -sign -pack -publish -ci %*"
diff --git a/eng/common/build.ps1 b/eng/common/build.ps1
index 438f9920c43e4..8cfee107e7a35 100644
--- a/eng/common/build.ps1
+++ b/eng/common/build.ps1
@@ -7,6 +7,7 @@ Param(
[string] $msbuildEngine = $null,
[bool] $warnAsError = $true,
[bool] $nodeReuse = $true,
+ [switch] $buildCheck = $false,
[switch][Alias('r')]$restore,
[switch] $deployDeps,
[switch][Alias('b')]$build,
@@ -20,6 +21,7 @@ Param(
[switch] $publish,
[switch] $clean,
[switch][Alias('pb')]$productBuild,
+ [switch]$fromVMR,
[switch][Alias('bl')]$binaryLog,
[switch][Alias('nobl')]$excludeCIBinarylog,
[switch] $ci,
@@ -71,6 +73,9 @@ function Print-Usage() {
Write-Host " -msbuildEngine Msbuild engine to use to run build ('dotnet', 'vs', or unspecified)."
Write-Host " -excludePrereleaseVS Set to exclude build engines in prerelease versions of Visual Studio"
Write-Host " -nativeToolsOnMachine Sets the native tools on machine environment variable (indicating that the script should use native tools on machine)"
+ Write-Host " -nodeReuse Sets nodereuse msbuild parameter ('true' or 'false')"
+ Write-Host " -buildCheck Sets /check msbuild parameter"
+ Write-Host " -fromVMR Set when building from within the VMR"
Write-Host ""
Write-Host "Command line arguments not listed above are passed thru to msbuild."
@@ -97,6 +102,7 @@ function Build {
$bl = if ($binaryLog) { '/bl:' + (Join-Path $LogDir 'Build.binlog') } else { '' }
$platformArg = if ($platform) { "/p:Platform=$platform" } else { '' }
+ $check = if ($buildCheck) { '/check' } else { '' }
if ($projects) {
# Re-assign properties to a new variable because PowerShell doesn't let us append properties directly for unclear reasons.
@@ -113,6 +119,7 @@ function Build {
MSBuild $toolsetBuildProj `
$bl `
$platformArg `
+ $check `
/p:Configuration=$configuration `
/p:RepoRoot=$RepoRoot `
/p:Restore=$restore `
@@ -122,11 +129,13 @@ function Build {
/p:Deploy=$deploy `
/p:Test=$test `
/p:Pack=$pack `
- /p:DotNetBuildRepo=$productBuild `
+ /p:DotNetBuild=$productBuild `
+ /p:DotNetBuildFromVMR=$fromVMR `
/p:IntegrationTest=$integrationTest `
/p:PerformanceTest=$performanceTest `
/p:Sign=$sign `
/p:Publish=$publish `
+ /p:RestoreStaticGraphEnableBinaryLogger=$binaryLog `
@properties
}
diff --git a/eng/common/build.sh b/eng/common/build.sh
index ac1ee8620cd2a..9767bb411a4f0 100755
--- a/eng/common/build.sh
+++ b/eng/common/build.sh
@@ -42,6 +42,8 @@ usage()
echo " --prepareMachine Prepare machine for CI run, clean up processes after build"
echo " --nodeReuse Sets nodereuse msbuild parameter ('true' or 'false')"
echo " --warnAsError Sets warnaserror msbuild parameter ('true' or 'false')"
+ echo " --buildCheck Sets /check msbuild parameter"
+ echo " --fromVMR Set when building from within the VMR"
echo ""
echo "Command line arguments not listed above are passed thru to msbuild."
echo "Arguments can also be passed in with a single hyphen."
@@ -63,6 +65,7 @@ restore=false
build=false
source_build=false
product_build=false
+from_vmr=false
rebuild=false
test=false
integration_test=false
@@ -76,6 +79,7 @@ clean=false
warn_as_error=true
node_reuse=true
+build_check=false
binary_log=false
exclude_ci_binary_log=false
pipelines_log=false
@@ -87,7 +91,7 @@ verbosity='minimal'
runtime_source_feed=''
runtime_source_feed_key=''
-properties=''
+properties=()
while [[ $# > 0 ]]; do
opt="$(echo "${1/#--/-}" | tr "[:upper:]" "[:lower:]")"
case "$opt" in
@@ -127,19 +131,22 @@ while [[ $# > 0 ]]; do
-pack)
pack=true
;;
- -sourcebuild|-sb)
+ -sourcebuild|-source-build|-sb)
build=true
source_build=true
product_build=true
restore=true
pack=true
;;
- -productBuild|-pb)
+ -productbuild|-product-build|-pb)
build=true
product_build=true
restore=true
pack=true
;;
+ -fromvmr|-from-vmr)
+ from_vmr=true
+ ;;
-test|-t)
test=true
;;
@@ -173,6 +180,9 @@ while [[ $# > 0 ]]; do
node_reuse=$2
shift
;;
+ -buildcheck)
+ build_check=true
+ ;;
-runtimesourcefeed)
runtime_source_feed=$2
shift
@@ -182,7 +192,7 @@ while [[ $# > 0 ]]; do
shift
;;
*)
- properties="$properties $1"
+ properties+=("$1")
;;
esac
@@ -216,7 +226,7 @@ function Build {
InitializeCustomToolset
if [[ ! -z "$projects" ]]; then
- properties="$properties /p:Projects=$projects"
+ properties+=("/p:Projects=$projects")
fi
local bl=""
@@ -224,15 +234,21 @@ function Build {
bl="/bl:\"$log_dir/Build.binlog\""
fi
+ local check=""
+ if [[ "$build_check" == true ]]; then
+ check="/check"
+ fi
+
MSBuild $_InitializeToolset \
$bl \
+ $check \
/p:Configuration=$configuration \
/p:RepoRoot="$repo_root" \
/p:Restore=$restore \
/p:Build=$build \
- /p:DotNetBuildRepo=$product_build \
- /p:ArcadeBuildFromSource=$source_build \
+ /p:DotNetBuild=$product_build \
/p:DotNetBuildSourceOnly=$source_build \
+ /p:DotNetBuildFromVMR=$from_vmr \
/p:Rebuild=$rebuild \
/p:Test=$test \
/p:Pack=$pack \
@@ -240,7 +256,8 @@ function Build {
/p:PerformanceTest=$performance_test \
/p:Sign=$sign \
/p:Publish=$publish \
- $properties
+ /p:RestoreStaticGraphEnableBinaryLogger=$binary_log \
+ ${properties[@]+"${properties[@]}"}
ExitWithExitCode 0
}
diff --git a/eng/common/cibuild.sh b/eng/common/cibuild.sh
index 1a02c0dec8fd7..66e3b0ac61c36 100755
--- a/eng/common/cibuild.sh
+++ b/eng/common/cibuild.sh
@@ -13,4 +13,4 @@ while [[ -h $source ]]; do
done
scriptroot="$( cd -P "$( dirname "$source" )" && pwd )"
-. "$scriptroot/build.sh" --restore --build --test --pack --publish --ci $@
\ No newline at end of file
+. "$scriptroot/build.sh" --restore --build --test --pack --publish --ci $@
diff --git a/eng/common/core-templates/job/job.yml b/eng/common/core-templates/job/job.yml
index ba53ebfbd5133..6badecba7bcc4 100644
--- a/eng/common/core-templates/job/job.yml
+++ b/eng/common/core-templates/job/job.yml
@@ -19,10 +19,10 @@ parameters:
# publishing defaults
artifacts: ''
enableMicrobuild: false
+ enableMicrobuildForMacAndLinux: false
enablePublishBuildArtifacts: false
enablePublishBuildAssets: false
enablePublishTestResults: false
- enablePublishUsingPipelines: false
enableBuildRetry: false
mergeTestResults: false
testRunTitle: ''
@@ -73,9 +73,6 @@ jobs:
- ${{ if ne(parameters.enableTelemetry, 'false') }}:
- name: DOTNET_CLI_TELEMETRY_PROFILE
value: '$(Build.Repository.Uri)'
- - ${{ if eq(parameters.enableRichCodeNavigation, 'true') }}:
- - name: EnableRichCodeNavigation
- value: 'true'
# Retry signature validation up to three times, waiting 2 seconds between attempts.
# See https://learn.microsoft.com/en-us/nuget/reference/errors-and-warnings/nu3028#retry-untrusted-root-failures
- name: NUGET_EXPERIMENTAL_CHAIN_BUILD_RETRY_POLICY
@@ -127,18 +124,11 @@ jobs:
- ${{ preStep }}
- ${{ if and(eq(parameters.runAsPublic, 'false'), ne(variables['System.TeamProject'], 'public'), notin(variables['Build.Reason'], 'PullRequest')) }}:
- - ${{ if eq(parameters.enableMicrobuild, 'true') }}:
- - task: MicroBuildSigningPlugin@4
- displayName: Install MicroBuild plugin
- inputs:
- signType: $(_SignType)
- zipSources: false
- feedSource: https://dnceng.pkgs.visualstudio.com/_packaging/MicroBuildToolset/nuget/v3/index.json
- env:
- TeamName: $(_TeamName)
- MicroBuildOutputFolderOverride: '$(Agent.TempDirectory)'
+ - template: /eng/common/core-templates/steps/install-microbuild.yml
+ parameters:
+ enableMicrobuild: ${{ parameters.enableMicrobuild }}
+ enableMicrobuildForMacAndLinux: ${{ parameters.enableMicrobuildForMacAndLinux }}
continueOnError: ${{ parameters.continueOnError }}
- condition: and(succeeded(), in(variables['_SignType'], 'real', 'test'), eq(variables['Agent.Os'], 'Windows_NT'))
- ${{ if and(eq(parameters.runAsPublic, 'false'), eq(variables['System.TeamProject'], 'internal')) }}:
- task: NuGetAuthenticate@1
@@ -154,27 +144,15 @@ jobs:
- ${{ each step in parameters.steps }}:
- ${{ step }}
- - ${{ if eq(parameters.enableRichCodeNavigation, true) }}:
- - task: RichCodeNavIndexer@0
- displayName: RichCodeNav Upload
- inputs:
- languages: ${{ coalesce(parameters.richCodeNavigationLanguage, 'csharp') }}
- environment: ${{ coalesce(parameters.richCodeNavigationEnvironment, 'internal') }}
- richNavLogOutputDirectory: $(Build.SourcesDirectory)/artifacts/bin
- uploadRichNavArtifacts: ${{ coalesce(parameters.richCodeNavigationUploadArtifacts, false) }}
- continueOnError: true
-
- ${{ each step in parameters.componentGovernanceSteps }}:
- ${{ step }}
- - ${{ if eq(parameters.enableMicrobuild, 'true') }}:
- - ${{ if and(eq(parameters.runAsPublic, 'false'), ne(variables['System.TeamProject'], 'public'), notin(variables['Build.Reason'], 'PullRequest')) }}:
- - task: MicroBuildCleanup@1
- displayName: Execute Microbuild cleanup tasks
- condition: and(always(), in(variables['_SignType'], 'real', 'test'), eq(variables['Agent.Os'], 'Windows_NT'))
+ - ${{ if and(eq(parameters.runAsPublic, 'false'), ne(variables['System.TeamProject'], 'public'), notin(variables['Build.Reason'], 'PullRequest')) }}:
+ - template: /eng/common/core-templates/steps/cleanup-microbuild.yml
+ parameters:
+ enableMicrobuild: ${{ parameters.enableMicrobuild }}
+ enableMicrobuildForMacAndLinux: ${{ parameters.enableMicrobuildForMacAndLinux }}
continueOnError: ${{ parameters.continueOnError }}
- env:
- TeamName: $(_TeamName)
# Publish test results
- ${{ if or(and(eq(parameters.enablePublishTestResults, 'true'), eq(parameters.testResultsFormat, '')), eq(parameters.testResultsFormat, 'xunit')) }}:
diff --git a/eng/common/core-templates/job/onelocbuild.yml b/eng/common/core-templates/job/onelocbuild.yml
index 00feec8ebbc3a..8034815f4213b 100644
--- a/eng/common/core-templates/job/onelocbuild.yml
+++ b/eng/common/core-templates/job/onelocbuild.yml
@@ -86,8 +86,7 @@ jobs:
isAutoCompletePrSelected: ${{ parameters.AutoCompletePr }}
${{ if eq(parameters.CreatePr, true) }}:
isUseLfLineEndingsSelected: ${{ parameters.UseLfLineEndings }}
- ${{ if eq(parameters.RepoType, 'gitHub') }}:
- isShouldReusePrSelected: ${{ parameters.ReusePr }}
+ isShouldReusePrSelected: ${{ parameters.ReusePr }}
packageSourceAuth: patAuth
patVariable: ${{ parameters.CeapexPat }}
${{ if eq(parameters.RepoType, 'gitHub') }}:
@@ -118,4 +117,4 @@ jobs:
pathToPublish: '$(Build.SourcesDirectory)/eng/Localize/'
publishLocation: Container
artifactName: Loc
- condition: ${{ parameters.condition }}
\ No newline at end of file
+ condition: ${{ parameters.condition }}
diff --git a/eng/common/core-templates/job/publish-build-assets.yml b/eng/common/core-templates/job/publish-build-assets.yml
index 3d3356e319672..d5303229c97e2 100644
--- a/eng/common/core-templates/job/publish-build-assets.yml
+++ b/eng/common/core-templates/job/publish-build-assets.yml
@@ -20,9 +20,6 @@ parameters:
# if 'true', the build won't run any of the internal only steps, even if it is running in non-public projects.
runAsPublic: false
- # Optional: whether the build's artifacts will be published using release pipelines or direct feed publishing
- publishUsingPipelines: false
-
# Optional: whether the build's artifacts will be published using release pipelines or direct feed publishing
publishAssetsImmediately: false
@@ -32,6 +29,15 @@ parameters:
is1ESPipeline: ''
+ # Optional: 🌤️ or not the build has assets it wants to publish to BAR
+ isAssetlessBuild: false
+
+ # Optional, publishing version
+ publishingVersion: 3
+
+ # Optional: A minimatch pattern for the asset manifests to publish to BAR
+ assetManifestsPattern: '*/manifests/**/*.xml'
+
jobs:
- job: Asset_Registry_Publish
@@ -75,15 +81,33 @@ jobs:
- checkout: self
fetchDepth: 3
clean: true
-
- - task: DownloadBuildArtifacts@0
- displayName: Download artifact
- inputs:
- artifactName: AssetManifests
- downloadPath: '$(Build.StagingDirectory)/Download'
- checkDownloadedFiles: true
- condition: ${{ parameters.condition }}
- continueOnError: ${{ parameters.continueOnError }}
+
+ - ${{ if eq(parameters.isAssetlessBuild, 'false') }}:
+ - ${{ if eq(parameters.publishingVersion, 3) }}:
+ - task: DownloadPipelineArtifact@2
+ displayName: Download Asset Manifests
+ inputs:
+ artifactName: AssetManifests
+ targetPath: '$(Build.StagingDirectory)/AssetManifests'
+ condition: ${{ parameters.condition }}
+ continueOnError: ${{ parameters.continueOnError }}
+ - ${{ if eq(parameters.publishingVersion, 4) }}:
+ - task: DownloadPipelineArtifact@2
+ displayName: Download V4 asset manifests
+ inputs:
+ itemPattern: '*/manifests/**/*.xml'
+ targetPath: '$(Build.StagingDirectory)/AllAssetManifests'
+ condition: ${{ parameters.condition }}
+ continueOnError: ${{ parameters.continueOnError }}
+ - task: CopyFiles@2
+ displayName: Copy V4 asset manifests to AssetManifests
+ inputs:
+ SourceFolder: '$(Build.StagingDirectory)/AllAssetManifests'
+ Contents: ${{ parameters.assetManifestsPattern }}
+ TargetFolder: '$(Build.StagingDirectory)/AssetManifests'
+ flattenFolders: true
+ condition: ${{ parameters.condition }}
+ continueOnError: ${{ parameters.continueOnError }}
- task: NuGetAuthenticate@1
@@ -95,9 +119,9 @@ jobs:
scriptLocation: scriptPath
scriptPath: $(Build.SourcesDirectory)/eng/common/sdk-task.ps1
arguments: -task PublishBuildAssets -restore -msbuildEngine dotnet
- /p:ManifestsPath='$(Build.StagingDirectory)/Download/AssetManifests'
+ /p:ManifestsPath='$(Build.StagingDirectory)/AssetManifests'
+ /p:IsAssetlessBuild=${{ parameters.isAssetlessBuild }}
/p:MaestroApiEndpoint=https://maestro.dot.net
- /p:PublishUsingPipelines=${{ parameters.publishUsingPipelines }}
/p:OfficialBuildId=$(Build.BuildNumber)
condition: ${{ parameters.condition }}
continueOnError: ${{ parameters.continueOnError }}
@@ -120,6 +144,17 @@ jobs:
Copy-Item -Path $symbolExclusionfile -Destination "$(Build.StagingDirectory)/ReleaseConfigs"
}
+ - ${{ if eq(parameters.publishingVersion, 4) }}:
+ - template: /eng/common/core-templates/steps/publish-pipeline-artifacts.yml
+ parameters:
+ is1ESPipeline: ${{ parameters.is1ESPipeline }}
+ args:
+ targetPath: '$(Build.ArtifactStagingDirectory)/MergedManifest.xml'
+ artifactName: AssetManifests
+ displayName: 'Publish Merged Manifest'
+ retryCountOnTaskFailure: 10 # for any logs being locked
+ sbomEnabled: false # we don't need SBOM for logs
+
- template: /eng/common/core-templates/steps/publish-build-artifacts.yml
parameters:
is1ESPipeline: ${{ parameters.is1ESPipeline }}
@@ -129,7 +164,7 @@ jobs:
publishLocation: Container
artifactName: ReleaseConfigs
- - ${{ if eq(parameters.publishAssetsImmediately, 'true') }}:
+ - ${{ if or(eq(parameters.publishAssetsImmediately, 'true'), eq(parameters.isAssetlessBuild, 'true')) }}:
- template: /eng/common/core-templates/post-build/setup-maestro-vars.yml
parameters:
BARBuildId: ${{ parameters.BARBuildId }}
@@ -150,6 +185,7 @@ jobs:
-WaitPublishingFinish true
-ArtifactsPublishingAdditionalParameters '${{ parameters.artifactsPublishingAdditionalParameters }}'
-SymbolPublishingAdditionalParameters '${{ parameters.symbolPublishingAdditionalParameters }}'
+ -SkipAssetsPublishing '${{ parameters.isAssetlessBuild }}'
- ${{ if eq(parameters.enablePublishBuildArtifacts, 'true') }}:
- template: /eng/common/core-templates/steps/publish-logs.yml
diff --git a/eng/common/core-templates/job/source-build.yml b/eng/common/core-templates/job/source-build.yml
index d47f09d58fd9a..d805d5faeb947 100644
--- a/eng/common/core-templates/job/source-build.yml
+++ b/eng/common/core-templates/job/source-build.yml
@@ -12,9 +12,10 @@ parameters:
# The name of the job. This is included in the job ID.
# targetRID: ''
# The name of the target RID to use, instead of the one auto-detected by Arcade.
- # nonPortable: false
+ # portableBuild: false
# Enables non-portable mode. This means a more specific RID (e.g. fedora.32-x64 rather than
- # linux-x64), and compiling against distro-provided packages rather than portable ones.
+ # linux-x64), and compiling against distro-provided packages rather than portable ones. The
+ # default is portable mode.
# skipPublishValidation: false
# Disables publishing validation. By default, a check is performed to ensure no packages are
# published by source-build.
diff --git a/eng/common/core-templates/job/source-index-stage1.yml b/eng/common/core-templates/job/source-index-stage1.yml
index 8b833332b3ee9..30530359a5d6d 100644
--- a/eng/common/core-templates/job/source-index-stage1.yml
+++ b/eng/common/core-templates/job/source-index-stage1.yml
@@ -1,8 +1,5 @@
parameters:
runAsPublic: false
- sourceIndexUploadPackageVersion: 2.0.0-20250425.2
- sourceIndexProcessBinlogPackageVersion: 1.0.1-20250425.2
- sourceIndexPackageSource: https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-tools/nuget/v3/index.json
sourceIndexBuildCommand: powershell -NoLogo -NoProfile -ExecutionPolicy Bypass -Command "eng/common/build.ps1 -restore -build -binarylog -ci"
preSteps: []
binlogPath: artifacts/log/Debug/Build.binlog
@@ -16,12 +13,6 @@ jobs:
dependsOn: ${{ parameters.dependsOn }}
condition: ${{ parameters.condition }}
variables:
- - name: SourceIndexUploadPackageVersion
- value: ${{ parameters.sourceIndexUploadPackageVersion }}
- - name: SourceIndexProcessBinlogPackageVersion
- value: ${{ parameters.sourceIndexProcessBinlogPackageVersion }}
- - name: SourceIndexPackageSource
- value: ${{ parameters.sourceIndexPackageSource }}
- name: BinlogPath
value: ${{ parameters.binlogPath }}
- template: /eng/common/core-templates/variables/pool-providers.yml
@@ -34,12 +25,10 @@ jobs:
pool:
${{ if eq(variables['System.TeamProject'], 'public') }}:
name: $(DncEngPublicBuildPool)
- image: 1es-windows-2022-open
- os: windows
+ image: windows.vs2022.amd64.open
${{ if eq(variables['System.TeamProject'], 'internal') }}:
name: $(DncEngInternalBuildPool)
- image: 1es-windows-2022
- os: windows
+ image: windows.vs2022.amd64
steps:
- ${{ if eq(parameters.is1ESPipeline, '') }}:
@@ -47,35 +36,9 @@ jobs:
- ${{ each preStep in parameters.preSteps }}:
- ${{ preStep }}
-
- - task: UseDotNet@2
- displayName: Use .NET 8 SDK
- inputs:
- packageType: sdk
- version: 8.0.x
- installationPath: $(Agent.TempDirectory)/dotnet
- workingDirectory: $(Agent.TempDirectory)
-
- - script: |
- $(Agent.TempDirectory)/dotnet/dotnet tool install BinLogToSln --version $(sourceIndexProcessBinlogPackageVersion) --add-source $(SourceIndexPackageSource) --tool-path $(Agent.TempDirectory)/.source-index/tools
- $(Agent.TempDirectory)/dotnet/dotnet tool install UploadIndexStage1 --version $(sourceIndexUploadPackageVersion) --add-source $(SourceIndexPackageSource) --tool-path $(Agent.TempDirectory)/.source-index/tools
- displayName: Download Tools
- # Set working directory to temp directory so 'dotnet' doesn't try to use global.json and use the repo's sdk.
- workingDirectory: $(Agent.TempDirectory)
-
- script: ${{ parameters.sourceIndexBuildCommand }}
displayName: Build Repository
- - script: $(Agent.TempDirectory)/.source-index/tools/BinLogToSln -i $(BinlogPath) -r $(Build.SourcesDirectory) -n $(Build.Repository.Name) -o .source-index/stage1output
- displayName: Process Binlog into indexable sln
-
- - ${{ if and(eq(parameters.runAsPublic, 'false'), ne(variables['System.TeamProject'], 'public'), notin(variables['Build.Reason'], 'PullRequest')) }}:
- - task: AzureCLI@2
- displayName: Log in to Azure and upload stage1 artifacts to source index
- inputs:
- azureSubscription: 'SourceDotNet Stage1 Publish'
- addSpnToEnvironment: true
- scriptType: 'ps'
- scriptLocation: 'inlineScript'
- inlineScript: |
- $(Agent.TempDirectory)/.source-index/tools/UploadIndexStage1 -i .source-index/stage1output -n $(Build.Repository.Name) -s netsourceindexstage1 -b stage1
+ - template: /eng/common/core-templates/steps/source-index-stage1-publish.yml
+ parameters:
+ binLogPath: ${{ parameters.binLogPath }}
\ No newline at end of file
diff --git a/eng/common/core-templates/jobs/codeql-build.yml b/eng/common/core-templates/jobs/codeql-build.yml
index f2144252cc65c..693b00b370447 100644
--- a/eng/common/core-templates/jobs/codeql-build.yml
+++ b/eng/common/core-templates/jobs/codeql-build.yml
@@ -15,7 +15,6 @@ jobs:
enablePublishBuildArtifacts: false
enablePublishTestResults: false
enablePublishBuildAssets: false
- enablePublishUsingPipelines: false
enableTelemetry: true
variables:
diff --git a/eng/common/core-templates/jobs/jobs.yml b/eng/common/core-templates/jobs/jobs.yml
index ea69be4341c62..bf35b78faa60e 100644
--- a/eng/common/core-templates/jobs/jobs.yml
+++ b/eng/common/core-templates/jobs/jobs.yml
@@ -5,9 +5,6 @@ parameters:
# Optional: Include PublishBuildArtifacts task
enablePublishBuildArtifacts: false
- # Optional: Enable publishing using release pipelines
- enablePublishUsingPipelines: false
-
# Optional: Enable running the source-build jobs to build repo from source
enableSourceBuild: false
@@ -30,6 +27,9 @@ parameters:
# Optional: Publish the assets as soon as the publish to BAR stage is complete, rather doing so in a separate stage.
publishAssetsImmediately: false
+ # Optional: 🌤️ or not the build has assets it wants to publish to BAR
+ isAssetlessBuild: false
+
# Optional: If using publishAssetsImmediately and additional parameters are needed, can be used to send along additional parameters (normally sent to post-build.yml)
artifactsPublishingAdditionalParameters: ''
signingValidationAdditionalParameters: ''
@@ -96,7 +96,7 @@ jobs:
${{ parameter.key }}: ${{ parameter.value }}
- ${{ if and(eq(parameters.runAsPublic, 'false'), ne(variables['System.TeamProject'], 'public'), notin(variables['Build.Reason'], 'PullRequest')) }}:
- - ${{ if or(eq(parameters.enablePublishBuildAssets, true), eq(parameters.artifacts.publish.manifests, 'true'), ne(parameters.artifacts.publish.manifests, '')) }}:
+ - ${{ if or(eq(parameters.enablePublishBuildAssets, true), eq(parameters.artifacts.publish.manifests, 'true'), ne(parameters.artifacts.publish.manifests, ''), eq(parameters.isAssetlessBuild, true)) }}:
- template: ../job/publish-build-assets.yml
parameters:
is1ESPipeline: ${{ parameters.is1ESPipeline }}
@@ -112,8 +112,8 @@ jobs:
- Source_Build_Complete
runAsPublic: ${{ parameters.runAsPublic }}
- publishUsingPipelines: ${{ parameters.enablePublishUsingPipelines }}
- publishAssetsImmediately: ${{ parameters.publishAssetsImmediately }}
+ publishAssetsImmediately: ${{ or(parameters.publishAssetsImmediately, parameters.isAssetlessBuild) }}
+ isAssetlessBuild: ${{ parameters.isAssetlessBuild }}
enablePublishBuildArtifacts: ${{ parameters.enablePublishBuildArtifacts }}
artifactsPublishingAdditionalParameters: ${{ parameters.artifactsPublishingAdditionalParameters }}
signingValidationAdditionalParameters: ${{ parameters.signingValidationAdditionalParameters }}
diff --git a/eng/common/core-templates/jobs/source-build.yml b/eng/common/core-templates/jobs/source-build.yml
index a10ccfbee6de6..df24c948ba127 100644
--- a/eng/common/core-templates/jobs/source-build.yml
+++ b/eng/common/core-templates/jobs/source-build.yml
@@ -14,7 +14,7 @@ parameters:
# This is the default platform provided by Arcade, intended for use by a managed-only repo.
defaultManagedPlatform:
name: 'Managed'
- container: 'mcr.microsoft.com/dotnet-buildtools/prereqs:centos-stream9'
+ container: 'mcr.microsoft.com/dotnet-buildtools/prereqs:centos-stream-10-amd64'
# Defines the platforms on which to run build jobs. One job is created for each platform, and the
# object in this array is sent to the job template as 'platform'. If no platforms are specified,
diff --git a/eng/common/core-templates/post-build/post-build.yml b/eng/common/core-templates/post-build/post-build.yml
index 454fd75c7aff1..a151fd811e3e4 100644
--- a/eng/common/core-templates/post-build/post-build.yml
+++ b/eng/common/core-templates/post-build/post-build.yml
@@ -44,6 +44,11 @@ parameters:
displayName: Publish installers and checksums
type: boolean
default: true
+
+ - name: requireDefaultChannels
+ displayName: Fail the build if there are no default channel(s) registrations for the current build
+ type: boolean
+ default: false
- name: SDLValidationParameters
type: object
@@ -55,6 +60,11 @@ parameters:
artifactNames: ''
downloadArtifacts: true
+ - name: isAssetlessBuild
+ type: boolean
+ displayName: Is Assetless Build
+ default: false
+
# These parameters let the user customize the call to sdk-task.ps1 for publishing
# symbols & general artifacts as well as for signing validation
- name: symbolPublishingAdditionalParameters
@@ -183,9 +193,6 @@ stages:
buildId: $(AzDOBuildId)
artifactName: PackageArtifacts
checkDownloadedFiles: true
- itemPattern: |
- **
- !**/Microsoft.SourceBuild.Intermediate.*.nupkg
# This is necessary whenever we want to publish/restore to an AzDO private feed
# Since sdk-task.ps1 tries to restore packages we need to do this authentication here
@@ -312,5 +319,7 @@ stages:
-PublishingInfraVersion ${{ parameters.publishingInfraVersion }}
-AzdoToken '$(System.AccessToken)'
-WaitPublishingFinish true
+ -RequireDefaultChannels ${{ parameters.requireDefaultChannels }}
-ArtifactsPublishingAdditionalParameters '${{ parameters.artifactsPublishingAdditionalParameters }}'
-SymbolPublishingAdditionalParameters '${{ parameters.symbolPublishingAdditionalParameters }}'
+ -SkipAssetsPublishing '${{ parameters.isAssetlessBuild }}'
diff --git a/eng/common/core-templates/steps/cleanup-microbuild.yml b/eng/common/core-templates/steps/cleanup-microbuild.yml
new file mode 100644
index 0000000000000..c0fdcd3379d73
--- /dev/null
+++ b/eng/common/core-templates/steps/cleanup-microbuild.yml
@@ -0,0 +1,28 @@
+parameters:
+ # Enable cleanup tasks for MicroBuild
+ enableMicrobuild: false
+ # Enable cleanup tasks for MicroBuild on Mac and Linux
+ # Will be ignored if 'enableMicrobuild' is false or 'Agent.Os' is 'Windows_NT'
+ enableMicrobuildForMacAndLinux: false
+ continueOnError: false
+
+steps:
+ - ${{ if eq(parameters.enableMicrobuild, 'true') }}:
+ - task: MicroBuildCleanup@1
+ displayName: Execute Microbuild cleanup tasks
+ condition: and(
+ always(),
+ or(
+ and(
+ eq(variables['Agent.Os'], 'Windows_NT'),
+ in(variables['_SignType'], 'real', 'test')
+ ),
+ and(
+ ${{ eq(parameters.enableMicrobuildForMacAndLinux, true) }},
+ ne(variables['Agent.Os'], 'Windows_NT'),
+ eq(variables['_SignType'], 'real')
+ )
+ ))
+ continueOnError: ${{ parameters.continueOnError }}
+ env:
+ TeamName: $(_TeamName)
diff --git a/eng/common/core-templates/steps/generate-sbom.yml b/eng/common/core-templates/steps/generate-sbom.yml
index 56a090094824f..44a9636cdff90 100644
--- a/eng/common/core-templates/steps/generate-sbom.yml
+++ b/eng/common/core-templates/steps/generate-sbom.yml
@@ -5,7 +5,7 @@
# IgnoreDirectories - Directories to ignore for SBOM generation. This will be passed through to the CG component detector.
parameters:
- PackageVersion: 9.0.0
+ PackageVersion: 10.0.0
BuildDropPath: '$(Build.SourcesDirectory)/artifacts'
PackageName: '.NET'
ManifestDirPath: $(Build.ArtifactStagingDirectory)/sbom
diff --git a/eng/common/core-templates/steps/get-delegation-sas.yml b/eng/common/core-templates/steps/get-delegation-sas.yml
index 9db5617ea7dea..d2901470a7f0b 100644
--- a/eng/common/core-templates/steps/get-delegation-sas.yml
+++ b/eng/common/core-templates/steps/get-delegation-sas.yml
@@ -31,16 +31,7 @@ steps:
# Calculate the expiration of the SAS token and convert to UTC
$expiry = (Get-Date).AddHours(${{ parameters.expiryInHours }}).ToUniversalTime().ToString("yyyy-MM-ddTHH:mm:ssZ")
- # Temporarily work around a helix issue where SAS tokens with / in them will cause incorrect downloads
- # of correlation payloads. https://github.com/dotnet/dnceng/issues/3484
- $sas = ""
- do {
- $sas = az storage container generate-sas --account-name ${{ parameters.storageAccount }} --name ${{ parameters.container }} --permissions ${{ parameters.permissions }} --expiry $expiry --auth-mode login --as-user -o tsv
- if ($LASTEXITCODE -ne 0) {
- Write-Error "Failed to generate SAS token."
- exit 1
- }
- } while($sas.IndexOf('/') -ne -1)
+ $sas = az storage container generate-sas --account-name ${{ parameters.storageAccount }} --name ${{ parameters.container }} --permissions ${{ parameters.permissions }} --expiry $expiry --auth-mode login --as-user -o tsv
if ($LASTEXITCODE -ne 0) {
Write-Error "Failed to generate SAS token."
diff --git a/eng/common/core-templates/steps/install-microbuild.yml b/eng/common/core-templates/steps/install-microbuild.yml
new file mode 100644
index 0000000000000..a3540ba00c7eb
--- /dev/null
+++ b/eng/common/core-templates/steps/install-microbuild.yml
@@ -0,0 +1,50 @@
+parameters:
+ # Enable install tasks for MicroBuild
+ enableMicrobuild: false
+ # Enable install tasks for MicroBuild on Mac and Linux
+ # Will be ignored if 'enableMicrobuild' is false or 'Agent.Os' is 'Windows_NT'
+ enableMicrobuildForMacAndLinux: false
+ # Location of the MicroBuild output folder
+ microBuildOutputFolder: '$(Build.SourcesDirectory)'
+ continueOnError: false
+
+steps:
+ - ${{ if eq(parameters.enableMicrobuild, 'true') }}:
+ - ${{ if eq(parameters.enableMicrobuildForMacAndLinux, 'true') }}:
+ # Needed to download the MicroBuild plugin nupkgs on Mac and Linux when nuget.exe is unavailable
+ - task: UseDotNet@2
+ displayName: Install .NET 8.0 SDK for MicroBuild Plugin
+ inputs:
+ packageType: sdk
+ version: 8.0.x
+ installationPath: ${{ parameters.microBuildOutputFolder }}/.dotnet
+ workingDirectory: ${{ parameters.microBuildOutputFolder }}
+ condition: and(succeeded(), ne(variables['Agent.Os'], 'Windows_NT'))
+
+ - task: MicroBuildSigningPlugin@4
+ displayName: Install MicroBuild plugin
+ inputs:
+ signType: $(_SignType)
+ zipSources: false
+ feedSource: https://dnceng.pkgs.visualstudio.com/_packaging/MicroBuildToolset/nuget/v3/index.json
+ ${{ if and(eq(parameters.enableMicrobuildForMacAndLinux, 'true'), ne(variables['Agent.Os'], 'Windows_NT')) }}:
+ azureSubscription: 'MicroBuild Signing Task (DevDiv)'
+ useEsrpCli: true
+ env:
+ TeamName: $(_TeamName)
+ MicroBuildOutputFolderOverride: ${{ parameters.microBuildOutputFolder }}
+ SYSTEM_ACCESSTOKEN: $(System.AccessToken)
+ continueOnError: ${{ parameters.continueOnError }}
+ condition: and(
+ succeeded(),
+ or(
+ and(
+ eq(variables['Agent.Os'], 'Windows_NT'),
+ in(variables['_SignType'], 'real', 'test')
+ ),
+ and(
+ ${{ eq(parameters.enableMicrobuildForMacAndLinux, true) }},
+ ne(variables['Agent.Os'], 'Windows_NT'),
+ eq(variables['_SignType'], 'real')
+ )
+ ))
diff --git a/eng/common/core-templates/steps/publish-logs.yml b/eng/common/core-templates/steps/publish-logs.yml
index 80788c5231912..de24d0087c58b 100644
--- a/eng/common/core-templates/steps/publish-logs.yml
+++ b/eng/common/core-templates/steps/publish-logs.yml
@@ -34,7 +34,9 @@ steps:
'$(akams-client-id)'
'$(microsoft-symbol-server-pat)'
'$(symweb-symbol-server-pat)'
+ '$(dnceng-symbol-server-pat)'
'$(dn-bot-all-orgs-build-rw-code-rw)'
+ '$(System.AccessToken)'
${{parameters.CustomSensitiveDataList}}
continueOnError: true
condition: always()
@@ -45,6 +47,7 @@ steps:
SourceFolder: '$(Build.SourcesDirectory)/PostBuildLogs'
Contents: '**'
TargetFolder: '$(Build.ArtifactStagingDirectory)/PostBuildLogs'
+ condition: always()
- template: /eng/common/core-templates/steps/publish-build-artifacts.yml
parameters:
diff --git a/eng/common/core-templates/steps/source-build.yml b/eng/common/core-templates/steps/source-build.yml
index 37133b55b7541..0dde553c3ebfb 100644
--- a/eng/common/core-templates/steps/source-build.yml
+++ b/eng/common/core-templates/steps/source-build.yml
@@ -19,25 +19,12 @@ steps:
set -x
df -h
- # If file changes are detected, set CopyWipIntoInnerSourceBuildRepo to copy the WIP changes into the inner source build repo.
- internalRestoreArgs=
- if ! git diff --quiet; then
- internalRestoreArgs='/p:CopyWipIntoInnerSourceBuildRepo=true'
- # The 'Copy WIP' feature of source build uses git stash to apply changes from the original repo.
- # This only works if there is a username/email configured, which won't be the case in most CI runs.
- git config --get user.email
- if [ $? -ne 0 ]; then
- git config user.email dn-bot@microsoft.com
- git config user.name dn-bot
- fi
- fi
-
# If building on the internal project, the internal storage variable may be available (usually only if needed)
# In that case, add variables to allow the download of internal runtimes if the specified versions are not found
# in the default public locations.
internalRuntimeDownloadArgs=
if [ '$(dotnetbuilds-internal-container-read-token-base64)' != '$''(dotnetbuilds-internal-container-read-token-base64)' ]; then
- internalRuntimeDownloadArgs='/p:DotNetRuntimeSourceFeed=https://dotnetbuilds.blob.core.windows.net/internal /p:DotNetRuntimeSourceFeedKey=$(dotnetbuilds-internal-container-read-token-base64) --runtimesourcefeed https://dotnetbuilds.blob.core.windows.net/internal --runtimesourcefeedkey $(dotnetbuilds-internal-container-read-token-base64)'
+ internalRuntimeDownloadArgs='/p:DotNetRuntimeSourceFeed=https://ci.dot.net/internal /p:DotNetRuntimeSourceFeedKey=$(dotnetbuilds-internal-container-read-token-base64) --runtimesourcefeed https://ci.dot.net/internal --runtimesourcefeedkey $(dotnetbuilds-internal-container-read-token-base64)'
fi
buildConfig=Release
@@ -46,85 +33,39 @@ steps:
buildConfig='$(_BuildConfig)'
fi
- officialBuildArgs=
- if [ '${{ and(ne(variables['System.TeamProject'], 'public'), notin(variables['Build.Reason'], 'PullRequest')) }}' = 'True' ]; then
- officialBuildArgs='/p:DotNetPublishUsingPipelines=true /p:OfficialBuildId=$(BUILD.BUILDNUMBER)'
- fi
-
targetRidArgs=
if [ '${{ parameters.platform.targetRID }}' != '' ]; then
targetRidArgs='/p:TargetRid=${{ parameters.platform.targetRID }}'
fi
- runtimeOsArgs=
- if [ '${{ parameters.platform.runtimeOS }}' != '' ]; then
- runtimeOsArgs='/p:RuntimeOS=${{ parameters.platform.runtimeOS }}'
- fi
-
- baseOsArgs=
- if [ '${{ parameters.platform.baseOS }}' != '' ]; then
- baseOsArgs='/p:BaseOS=${{ parameters.platform.baseOS }}'
+ baseRidArgs=
+ if [ '${{ parameters.platform.baseRID }}' != '' ]; then
+ baseRidArgs='/p:BaseRid=${{ parameters.platform.baseRID }}'
fi
- publishArgs=
- if [ '${{ parameters.platform.skipPublishValidation }}' != 'true' ]; then
- publishArgs='--publish'
- fi
-
- assetManifestFileName=SourceBuild_RidSpecific.xml
- if [ '${{ parameters.platform.name }}' != '' ]; then
- assetManifestFileName=SourceBuild_${{ parameters.platform.name }}.xml
+ portableBuildArgs=
+ if [ '${{ parameters.platform.portableBuild }}' != '' ]; then
+ portableBuildArgs='/p:PortableBuild=${{ parameters.platform.portableBuild }}'
fi
${{ coalesce(parameters.platform.buildScript, './build.sh') }} --ci \
--configuration $buildConfig \
- --restore --build --pack $publishArgs -bl \
+ --restore --build --pack -bl \
+ --source-build \
${{ parameters.platform.buildArguments }} \
- $officialBuildArgs \
$internalRuntimeDownloadArgs \
- $internalRestoreArgs \
$targetRidArgs \
- $runtimeOsArgs \
- $baseOsArgs \
- /p:SourceBuildNonPortable=${{ parameters.platform.nonPortable }} \
- /p:ArcadeBuildFromSource=true \
- /p:DotNetBuildSourceOnly=true \
- /p:DotNetBuildRepo=true \
- /p:AssetManifestFileName=$assetManifestFileName
+ $baseRidArgs \
+ $portableBuildArgs \
displayName: Build
-# Upload build logs for diagnosis.
-- task: CopyFiles@2
- displayName: Prepare BuildLogs staging directory
- inputs:
- SourceFolder: '$(Build.SourcesDirectory)'
- Contents: |
- **/*.log
- **/*.binlog
- artifacts/sb/prebuilt-report/**
- TargetFolder: '$(Build.StagingDirectory)/BuildLogs'
- CleanTargetFolder: true
- continueOnError: true
- condition: succeededOrFailed()
-
- template: /eng/common/core-templates/steps/publish-pipeline-artifacts.yml
parameters:
is1ESPipeline: ${{ parameters.is1ESPipeline }}
args:
displayName: Publish BuildLogs
- targetPath: '$(Build.StagingDirectory)/BuildLogs'
+ targetPath: artifacts/log/${{ coalesce(variables._BuildConfig, 'Release') }}
artifactName: BuildLogs_SourceBuild_${{ parameters.platform.name }}_Attempt$(System.JobAttempt)
continueOnError: true
condition: succeededOrFailed()
sbomEnabled: false # we don't need SBOM for logs
-
-# Manually inject component detection so that we can ignore the source build upstream cache, which contains
-# a nupkg cache of input packages (a local feed).
-# This path must match the upstream cache path in property 'CurrentRepoSourceBuiltNupkgCacheDir'
-# in src\Microsoft.DotNet.Arcade.Sdk\tools\SourceBuild\SourceBuildArcade.targets
-- template: /eng/common/core-templates/steps/component-governance.yml
- parameters:
- displayName: Component Detection (Exclude upstream cache)
- is1ESPipeline: ${{ parameters.is1ESPipeline }}
- componentGovernanceIgnoreDirectories: '$(Build.SourcesDirectory)/artifacts/sb/src/artifacts/obj/source-built-upstream-cache'
- disableComponentGovernance: ${{ eq(variables['System.TeamProject'], 'public') }}
diff --git a/eng/common/core-templates/steps/source-index-stage1-publish.yml b/eng/common/core-templates/steps/source-index-stage1-publish.yml
new file mode 100644
index 0000000000000..c2917c1efc1cb
--- /dev/null
+++ b/eng/common/core-templates/steps/source-index-stage1-publish.yml
@@ -0,0 +1,35 @@
+parameters:
+ sourceIndexUploadPackageVersion: 2.0.0-20250425.2
+ sourceIndexProcessBinlogPackageVersion: 1.0.1-20250515.1
+ sourceIndexPackageSource: https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-tools/nuget/v3/index.json
+ binlogPath: artifacts/log/Debug/Build.binlog
+
+steps:
+- task: UseDotNet@2
+ displayName: "Source Index: Use .NET 9 SDK"
+ inputs:
+ packageType: sdk
+ version: 9.0.x
+ installationPath: $(Agent.TempDirectory)/dotnet
+ workingDirectory: $(Agent.TempDirectory)
+
+- script: |
+ $(Agent.TempDirectory)/dotnet/dotnet tool install BinLogToSln --version ${{parameters.sourceIndexProcessBinlogPackageVersion}} --add-source ${{parameters.SourceIndexPackageSource}} --tool-path $(Agent.TempDirectory)/.source-index/tools
+ $(Agent.TempDirectory)/dotnet/dotnet tool install UploadIndexStage1 --version ${{parameters.sourceIndexUploadPackageVersion}} --add-source ${{parameters.SourceIndexPackageSource}} --tool-path $(Agent.TempDirectory)/.source-index/tools
+ displayName: "Source Index: Download netsourceindex Tools"
+ # Set working directory to temp directory so 'dotnet' doesn't try to use global.json and use the repo's sdk.
+ workingDirectory: $(Agent.TempDirectory)
+
+- script: $(Agent.TempDirectory)/.source-index/tools/BinLogToSln -i ${{parameters.BinlogPath}} -r $(Build.SourcesDirectory) -n $(Build.Repository.Name) -o .source-index/stage1output
+ displayName: "Source Index: Process Binlog into indexable sln"
+
+- ${{ if and(ne(parameters.runAsPublic, 'true'), ne(variables['System.TeamProject'], 'public'), notin(variables['Build.Reason'], 'PullRequest')) }}:
+ - task: AzureCLI@2
+ displayName: "Source Index: Upload Source Index stage1 artifacts to Azure"
+ inputs:
+ azureSubscription: 'SourceDotNet Stage1 Publish'
+ addSpnToEnvironment: true
+ scriptType: 'ps'
+ scriptLocation: 'inlineScript'
+ inlineScript: |
+ $(Agent.TempDirectory)/.source-index/tools/UploadIndexStage1 -i .source-index/stage1output -n $(Build.Repository.Name) -s netsourceindexstage1 -b stage1
diff --git a/eng/common/cross/arm64/tizen/tizen.patch b/eng/common/cross/arm64/tizen/tizen.patch
index af7c8be059068..2cebc547382e3 100644
--- a/eng/common/cross/arm64/tizen/tizen.patch
+++ b/eng/common/cross/arm64/tizen/tizen.patch
@@ -5,5 +5,5 @@ diff -u -r a/usr/lib/libc.so b/usr/lib/libc.so
Use the shared library, but some functions are only in
the static library, so try that secondarily. */
OUTPUT_FORMAT(elf64-littleaarch64)
--GROUP ( /lib64/libc.so.6 /usr/lib64/libc_nonshared.a AS_NEEDED ( /lib/ld-linux-aarch64.so.1 ) )
+-GROUP ( /lib64/libc.so.6 /usr/lib64/libc_nonshared.a AS_NEEDED ( /lib64/ld-linux-aarch64.so.1 ) )
+GROUP ( libc.so.6 libc_nonshared.a AS_NEEDED ( ld-linux-aarch64.so.1 ) )
diff --git a/eng/common/cross/armel/armel.jessie.patch b/eng/common/cross/armel/armel.jessie.patch
deleted file mode 100644
index 2d2615619351f..0000000000000
--- a/eng/common/cross/armel/armel.jessie.patch
+++ /dev/null
@@ -1,43 +0,0 @@
-diff -u -r a/usr/include/urcu/uatomic/generic.h b/usr/include/urcu/uatomic/generic.h
---- a/usr/include/urcu/uatomic/generic.h 2014-10-22 15:00:58.000000000 -0700
-+++ b/usr/include/urcu/uatomic/generic.h 2020-10-30 21:38:28.550000000 -0700
-@@ -69,10 +69,10 @@
- #endif
- #ifdef UATOMIC_HAS_ATOMIC_SHORT
- case 2:
-- return __sync_val_compare_and_swap_2(addr, old, _new);
-+ return __sync_val_compare_and_swap_2((uint16_t*) addr, old, _new);
- #endif
- case 4:
-- return __sync_val_compare_and_swap_4(addr, old, _new);
-+ return __sync_val_compare_and_swap_4((uint32_t*) addr, old, _new);
- #if (CAA_BITS_PER_LONG == 64)
- case 8:
- return __sync_val_compare_and_swap_8(addr, old, _new);
-@@ -109,7 +109,7 @@
- return;
- #endif
- case 4:
-- __sync_and_and_fetch_4(addr, val);
-+ __sync_and_and_fetch_4((uint32_t*) addr, val);
- return;
- #if (CAA_BITS_PER_LONG == 64)
- case 8:
-@@ -148,7 +148,7 @@
- return;
- #endif
- case 4:
-- __sync_or_and_fetch_4(addr, val);
-+ __sync_or_and_fetch_4((uint32_t*) addr, val);
- return;
- #if (CAA_BITS_PER_LONG == 64)
- case 8:
-@@ -187,7 +187,7 @@
- return __sync_add_and_fetch_2(addr, val);
- #endif
- case 4:
-- return __sync_add_and_fetch_4(addr, val);
-+ return __sync_add_and_fetch_4((uint32_t*) addr, val);
- #if (CAA_BITS_PER_LONG == 64)
- case 8:
- return __sync_add_and_fetch_8(addr, val);
diff --git a/eng/common/cross/build-android-rootfs.sh b/eng/common/cross/build-android-rootfs.sh
index 7e9ba2b75ed35..fbd8d80848a6c 100755
--- a/eng/common/cross/build-android-rootfs.sh
+++ b/eng/common/cross/build-android-rootfs.sh
@@ -6,10 +6,11 @@ usage()
{
echo "Creates a toolchain and sysroot used for cross-compiling for Android."
echo
- echo "Usage: $0 [BuildArch] [ApiLevel]"
+ echo "Usage: $0 [BuildArch] [ApiLevel] [--ndk NDKVersion]"
echo
echo "BuildArch is the target architecture of Android. Currently only arm64 is supported."
echo "ApiLevel is the target Android API level. API levels usually match to Android releases. See https://source.android.com/source/build-numbers.html"
+ echo "NDKVersion is the version of Android NDK. The default is r21. See https://developer.android.com/ndk/downloads/revision_history"
echo
echo "By default, the toolchain and sysroot will be generated in cross/android-rootfs/toolchain/[BuildArch]. You can change this behavior"
echo "by setting the TOOLCHAIN_DIR environment variable"
@@ -25,10 +26,15 @@ __BuildArch=arm64
__AndroidArch=aarch64
__AndroidToolchain=aarch64-linux-android
-for i in "$@"
- do
- lowerI="$(echo $i | tr "[:upper:]" "[:lower:]")"
- case $lowerI in
+while :; do
+ if [[ "$#" -le 0 ]]; then
+ break
+ fi
+
+ i=$1
+
+ lowerI="$(echo $i | tr "[:upper:]" "[:lower:]")"
+ case $lowerI in
-?|-h|--help)
usage
exit 1
@@ -43,6 +49,10 @@ for i in "$@"
__AndroidArch=arm
__AndroidToolchain=arm-linux-androideabi
;;
+ --ndk)
+ shift
+ __NDK_Version=$1
+ ;;
*[0-9])
__ApiLevel=$i
;;
@@ -50,8 +60,17 @@ for i in "$@"
__UnprocessedBuildArgs="$__UnprocessedBuildArgs $i"
;;
esac
+ shift
done
+if [[ "$__NDK_Version" == "r21" ]] || [[ "$__NDK_Version" == "r22" ]]; then
+ __NDK_File_Arch_Spec=-x86_64
+ __SysRoot=sysroot
+else
+ __NDK_File_Arch_Spec=
+ __SysRoot=toolchains/llvm/prebuilt/linux-x86_64/sysroot
+fi
+
# Obtain the location of the bash script to figure out where the root of the repo is.
__ScriptBaseDir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
@@ -78,6 +97,7 @@ fi
echo "Target API level: $__ApiLevel"
echo "Target architecture: $__BuildArch"
+echo "NDK version: $__NDK_Version"
echo "NDK location: $__NDK_Dir"
echo "Target Toolchain location: $__ToolchainDir"
@@ -85,8 +105,8 @@ echo "Target Toolchain location: $__ToolchainDir"
if [ ! -d $__NDK_Dir ]; then
echo Downloading the NDK into $__NDK_Dir
mkdir -p $__NDK_Dir
- wget -q --progress=bar:force:noscroll --show-progress https://dl.google.com/android/repository/android-ndk-$__NDK_Version-linux-x86_64.zip -O $__CrossDir/android-ndk-$__NDK_Version-linux-x86_64.zip
- unzip -q $__CrossDir/android-ndk-$__NDK_Version-linux-x86_64.zip -d $__CrossDir
+ wget -q --progress=bar:force:noscroll --show-progress https://dl.google.com/android/repository/android-ndk-$__NDK_Version-linux$__NDK_File_Arch_Spec.zip -O $__CrossDir/android-ndk-$__NDK_Version-linux.zip
+ unzip -q $__CrossDir/android-ndk-$__NDK_Version-linux.zip -d $__CrossDir
fi
if [ ! -d $__lldb_Dir ]; then
@@ -116,16 +136,11 @@ for path in $(wget -qO- https://packages.termux.dev/termux-main-21/dists/stable/
fi
done
-cp -R "$__TmpDir/data/data/com.termux/files/usr/"* "$__ToolchainDir/sysroot/usr/"
+cp -R "$__TmpDir/data/data/com.termux/files/usr/"* "$__ToolchainDir/$__SysRoot/usr/"
# Generate platform file for build.sh script to assign to __DistroRid
echo "Generating platform file..."
-echo "RID=android.${__ApiLevel}-${__BuildArch}" > $__ToolchainDir/sysroot/android_platform
-
-echo "Now to build coreclr, libraries and installers; run:"
-echo ROOTFS_DIR=\$\(realpath $__ToolchainDir/sysroot\) ./build.sh --cross --arch $__BuildArch \
- --subsetCategory coreclr
-echo ROOTFS_DIR=\$\(realpath $__ToolchainDir/sysroot\) ./build.sh --cross --arch $__BuildArch \
- --subsetCategory libraries
-echo ROOTFS_DIR=\$\(realpath $__ToolchainDir/sysroot\) ./build.sh --cross --arch $__BuildArch \
- --subsetCategory installer
+echo "RID=android.${__ApiLevel}-${__BuildArch}" > $__ToolchainDir/$__SysRoot/android_platform
+
+echo "Now to build coreclr, libraries and host; run:"
+echo ROOTFS_DIR=$(realpath $__ToolchainDir/$__SysRoot) ./build.sh clr+libs+host --cross --arch $__BuildArch
diff --git a/eng/common/cross/build-rootfs.sh b/eng/common/cross/build-rootfs.sh
index 4b5e8d7166bd9..8abfb71f72752 100755
--- a/eng/common/cross/build-rootfs.sh
+++ b/eng/common/cross/build-rootfs.sh
@@ -5,7 +5,7 @@ set -e
usage()
{
echo "Usage: $0 [BuildArch] [CodeName] [lldbx.y] [llvmx[.y]] [--skipunmount] --rootfsdir ]"
- echo "BuildArch can be: arm(default), arm64, armel, armv6, ppc64le, riscv64, s390x, x64, x86"
+ echo "BuildArch can be: arm(default), arm64, armel, armv6, loongarch64, ppc64le, riscv64, s390x, x64, x86"
echo "CodeName - optional, Code name for Linux, can be: xenial(default), zesty, bionic, alpine"
echo " for alpine can be specified with version: alpineX.YY or alpineedge"
echo " for FreeBSD can be: freebsd13, freebsd14"
@@ -15,6 +15,7 @@ usage()
echo "llvmx[.y] - optional, LLVM version for LLVM related packages."
echo "--skipunmount - optional, will skip the unmount of rootfs folder."
echo "--skipsigcheck - optional, will skip package signature checks (allowing untrusted packages)."
+ echo "--skipemulation - optional, will skip qemu and debootstrap requirement when building environment for debian based systems."
echo "--use-mirror - optional, use mirror URL to fetch resources, when available."
echo "--jobs N - optional, restrict to N jobs."
exit 1
@@ -52,28 +53,27 @@ __UbuntuPackages+=" symlinks"
__UbuntuPackages+=" libicu-dev"
__UbuntuPackages+=" liblttng-ust-dev"
__UbuntuPackages+=" libunwind8-dev"
-__UbuntuPackages+=" libnuma-dev"
__AlpinePackages+=" gettext-dev"
__AlpinePackages+=" icu-dev"
__AlpinePackages+=" libunwind-dev"
__AlpinePackages+=" lttng-ust-dev"
__AlpinePackages+=" compiler-rt"
-__AlpinePackages+=" numactl-dev"
# runtime libraries' dependencies
__UbuntuPackages+=" libcurl4-openssl-dev"
__UbuntuPackages+=" libkrb5-dev"
__UbuntuPackages+=" libssl-dev"
__UbuntuPackages+=" zlib1g-dev"
+__UbuntuPackages+=" libbrotli-dev"
__AlpinePackages+=" curl-dev"
__AlpinePackages+=" krb5-dev"
__AlpinePackages+=" openssl-dev"
__AlpinePackages+=" zlib-dev"
-__FreeBSDBase="13.3-RELEASE"
-__FreeBSDPkg="1.17.0"
+__FreeBSDBase="13.4-RELEASE"
+__FreeBSDPkg="1.21.3"
__FreeBSDABI="13"
__FreeBSDPackages="libunwind"
__FreeBSDPackages+=" icu"
@@ -91,18 +91,18 @@ __HaikuPackages="gcc_syslibs"
__HaikuPackages+=" gcc_syslibs_devel"
__HaikuPackages+=" gmp"
__HaikuPackages+=" gmp_devel"
-__HaikuPackages+=" icu66"
-__HaikuPackages+=" icu66_devel"
+__HaikuPackages+=" icu[0-9]+"
+__HaikuPackages+=" icu[0-9]*_devel"
__HaikuPackages+=" krb5"
__HaikuPackages+=" krb5_devel"
__HaikuPackages+=" libiconv"
__HaikuPackages+=" libiconv_devel"
-__HaikuPackages+=" llvm12_libunwind"
-__HaikuPackages+=" llvm12_libunwind_devel"
+__HaikuPackages+=" llvm[0-9]*_libunwind"
+__HaikuPackages+=" llvm[0-9]*_libunwind_devel"
__HaikuPackages+=" mpfr"
__HaikuPackages+=" mpfr_devel"
-__HaikuPackages+=" openssl"
-__HaikuPackages+=" openssl_devel"
+__HaikuPackages+=" openssl3"
+__HaikuPackages+=" openssl3_devel"
__HaikuPackages+=" zlib"
__HaikuPackages+=" zlib_devel"
@@ -128,10 +128,12 @@ __AlpineKeys='
616adfeb:MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAq0BFD1D4lIxQcsqEpQzU\npNCYM3aP1V/fxxVdT4DWvSI53JHTwHQamKdMWtEXetWVbP5zSROniYKFXd/xrD9X\n0jiGHey3lEtylXRIPxe5s+wXoCmNLcJVnvTcDtwx/ne2NLHxp76lyc25At+6RgE6\nADjLVuoD7M4IFDkAsd8UQ8zM0Dww9SylIk/wgV3ZkifecvgUQRagrNUdUjR56EBZ\nraQrev4hhzOgwelT0kXCu3snbUuNY/lU53CoTzfBJ5UfEJ5pMw1ij6X0r5S9IVsy\nKLWH1hiO0NzU2c8ViUYCly4Fe9xMTFc6u2dy/dxf6FwERfGzETQxqZvSfrRX+GLj\n/QZAXiPg5178hT/m0Y3z5IGenIC/80Z9NCi+byF1WuJlzKjDcF/TU72zk0+PNM/H\nKuppf3JT4DyjiVzNC5YoWJT2QRMS9KLP5iKCSThwVceEEg5HfhQBRT9M6KIcFLSs\nmFjx9kNEEmc1E8hl5IR3+3Ry8G5/bTIIruz14jgeY9u5jhL8Vyyvo41jgt9sLHR1\n/J1TxKfkgksYev7PoX6/ZzJ1ksWKZY5NFoDXTNYUgzFUTOoEaOg3BAQKadb3Qbbq\nXIrxmPBdgrn9QI7NCgfnAY3Tb4EEjs3ON/BNyEhUENcXOH6I1NbcuBQ7g9P73kE4\nVORdoc8MdJ5eoKBpO8Ww8HECAwEAAQ==
616ae350:MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAyduVzi1mWm+lYo2Tqt/0\nXkCIWrDNP1QBMVPrE0/ZlU2bCGSoo2Z9FHQKz/mTyMRlhNqTfhJ5qU3U9XlyGOPJ\npiM+b91g26pnpXJ2Q2kOypSgOMOPA4cQ42PkHBEqhuzssfj9t7x47ppS94bboh46\nxLSDRff/NAbtwTpvhStV3URYkxFG++cKGGa5MPXBrxIp+iZf9GnuxVdST5PGiVGP\nODL/b69sPJQNbJHVquqUTOh5Ry8uuD2WZuXfKf7/C0jC/ie9m2+0CttNu9tMciGM\nEyKG1/Xhk5iIWO43m4SrrT2WkFlcZ1z2JSf9Pjm4C2+HovYpihwwdM/OdP8Xmsnr\nDzVB4YvQiW+IHBjStHVuyiZWc+JsgEPJzisNY0Wyc/kNyNtqVKpX6dRhMLanLmy+\nf53cCSI05KPQAcGj6tdL+D60uKDkt+FsDa0BTAobZ31OsFVid0vCXtsbplNhW1IF\nHwsGXBTVcfXg44RLyL8Lk/2dQxDHNHzAUslJXzPxaHBLmt++2COa2EI1iWlvtznk\nOk9WP8SOAIj+xdqoiHcC4j72BOVVgiITIJNHrbppZCq6qPR+fgXmXa+sDcGh30m6\n9Wpbr28kLMSHiENCWTdsFij+NQTd5S47H7XTROHnalYDuF1RpS+DpQidT5tUimaT\nJZDr++FjKrnnijbyNF8b98UCAwEAAQ==
616db30d:MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAnpUpyWDWjlUk3smlWeA0\nlIMW+oJ38t92CRLHH3IqRhyECBRW0d0aRGtq7TY8PmxjjvBZrxTNDpJT6KUk4LRm\na6A6IuAI7QnNK8SJqM0DLzlpygd7GJf8ZL9SoHSH+gFsYF67Cpooz/YDqWrlN7Vw\ntO00s0B+eXy+PCXYU7VSfuWFGK8TGEv6HfGMALLjhqMManyvfp8hz3ubN1rK3c8C\nUS/ilRh1qckdbtPvoDPhSbTDmfU1g/EfRSIEXBrIMLg9ka/XB9PvWRrekrppnQzP\nhP9YE3x/wbFc5QqQWiRCYyQl/rgIMOXvIxhkfe8H5n1Et4VAorkpEAXdsfN8KSVv\nLSMazVlLp9GYq5SUpqYX3KnxdWBgN7BJoZ4sltsTpHQ/34SXWfu3UmyUveWj7wp0\nx9hwsPirVI00EEea9AbP7NM2rAyu6ukcm4m6ATd2DZJIViq2es6m60AE6SMCmrQF\nwmk4H/kdQgeAELVfGOm2VyJ3z69fQuywz7xu27S6zTKi05Qlnohxol4wVb6OB7qG\nLPRtK9ObgzRo/OPumyXqlzAi/Yvyd1ZQk8labZps3e16bQp8+pVPiumWioMFJDWV\nGZjCmyMSU8V6MB6njbgLHoyg2LCukCAeSjbPGGGYhnKLm1AKSoJh3IpZuqcKCk5C\n8CM1S15HxV78s9dFntEqIokCAwEAAQ==
+66ba20fe:MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAtfB12w4ZgqsXWZDfUAV/\n6Y4aHUKIu3q4SXrNZ7CXF9nXoAVYrS7NAxJdAodsY3vPCN0g5O8DFXR+390LdOuQ\n+HsGKCc1k5tX5ZXld37EZNTNSbR0k+NKhd9h6X3u6wqPOx7SIKxwAQR8qeeFq4pP\nrt9GAGlxtuYgzIIcKJPwE0dZlcBCg+GnptCUZXp/38BP1eYC+xTXSL6Muq1etYfg\nodXdb7Yl+2h1IHuOwo5rjgY5kpY7GcAs8AjGk3lDD/av60OTYccknH0NCVSmPoXK\nvrxDBOn0LQRNBLcAfnTKgHrzy0Q5h4TNkkyTgxkoQw5ObDk9nnabTxql732yy9BY\ns+hM9+dSFO1HKeVXreYSA2n1ndF18YAvAumzgyqzB7I4pMHXq1kC/8bONMJxwSkS\nYm6CoXKyavp7RqGMyeVpRC7tV+blkrrUml0BwNkxE+XnwDRB3xDV6hqgWe0XrifD\nYTfvd9ScZQP83ip0r4IKlq4GMv/R5shcCRJSkSZ6QSGshH40JYSoiwJf5FHbj9ND\n7do0UAqebWo4yNx63j/wb2ULorW3AClv0BCFSdPsIrCStiGdpgJDBR2P2NZOCob3\nG9uMj+wJD6JJg2nWqNJxkANXX37Qf8plgzssrhrgOvB0fjjS7GYhfkfmZTJ0wPOw\nA8+KzFseBh4UFGgue78KwgkCAwEAAQ==
'
__Keyring=
__KeyringFile="/usr/share/keyrings/ubuntu-archive-keyring.gpg"
__SkipSigCheck=0
+__SkipEmulation=0
__UseMirror=0
__UnprocessedBuildArgs=
@@ -162,9 +164,13 @@ while :; do
armel)
__BuildArch=armel
__UbuntuArch=armel
- __UbuntuRepo="http://ftp.debian.org/debian/"
- __CodeName=jessie
+ __UbuntuRepo="http://archive.debian.org/debian/"
+ __CodeName=buster
__KeyringFile="/usr/share/keyrings/debian-archive-keyring.gpg"
+ __LLDB_Package="liblldb-6.0-dev"
+ __UbuntuPackages="${__UbuntuPackages// libomp-dev/}"
+ __UbuntuPackages="${__UbuntuPackages// libomp5/}"
+ __UbuntuSuites=
;;
armv6)
__BuildArch=armv6
@@ -180,6 +186,18 @@ while :; do
__Keyring="--keyring $__KeyringFile"
fi
;;
+ loongarch64)
+ __BuildArch=loongarch64
+ __AlpineArch=loongarch64
+ __QEMUArch=loongarch64
+ __UbuntuArch=loong64
+ __UbuntuSuites=unreleased
+ __LLDB_Package="liblldb-19-dev"
+
+ if [[ "$__CodeName" == "sid" ]]; then
+ __UbuntuRepo="http://ftp.ports.debian.org/debian-ports/"
+ fi
+ ;;
riscv64)
__BuildArch=riscv64
__AlpineArch=riscv64
@@ -264,44 +282,21 @@ while :; do
;;
xenial) # Ubuntu 16.04
- if [[ "$__CodeName" != "jessie" ]]; then
- __CodeName=xenial
- fi
- ;;
- zesty) # Ubuntu 17.04
- if [[ "$__CodeName" != "jessie" ]]; then
- __CodeName=zesty
- fi
+ __CodeName=xenial
;;
bionic) # Ubuntu 18.04
- if [[ "$__CodeName" != "jessie" ]]; then
- __CodeName=bionic
- fi
+ __CodeName=bionic
;;
focal) # Ubuntu 20.04
- if [[ "$__CodeName" != "jessie" ]]; then
- __CodeName=focal
- fi
+ __CodeName=focal
;;
jammy) # Ubuntu 22.04
- if [[ "$__CodeName" != "jessie" ]]; then
- __CodeName=jammy
- fi
+ __CodeName=jammy
;;
noble) # Ubuntu 24.04
- if [[ "$__CodeName" != "jessie" ]]; then
- __CodeName=noble
- fi
- if [[ -n "$__LLDB_Package" ]]; then
- __LLDB_Package="liblldb-18-dev"
- fi
- ;;
- jessie) # Debian 8
- __CodeName=jessie
- __KeyringFile="/usr/share/keyrings/debian-archive-keyring.gpg"
-
- if [[ -z "$__UbuntuRepo" ]]; then
- __UbuntuRepo="http://ftp.debian.org/debian/"
+ __CodeName=noble
+ if [[ -z "$__LLDB_Package" ]]; then
+ __LLDB_Package="liblldb-19-dev"
fi
;;
stretch) # Debian 9
@@ -319,7 +314,7 @@ while :; do
__KeyringFile="/usr/share/keyrings/debian-archive-keyring.gpg"
if [[ -z "$__UbuntuRepo" ]]; then
- __UbuntuRepo="http://ftp.debian.org/debian/"
+ __UbuntuRepo="http://archive.debian.org/debian/"
fi
;;
bullseye) # Debian 11
@@ -340,10 +335,28 @@ while :; do
;;
sid) # Debian sid
__CodeName=sid
- __KeyringFile="/usr/share/keyrings/debian-archive-keyring.gpg"
+ __UbuntuSuites=
- if [[ -z "$__UbuntuRepo" ]]; then
- __UbuntuRepo="http://ftp.debian.org/debian/"
+ # Debian-Ports architectures need different values
+ case "$__UbuntuArch" in
+ amd64|arm64|armel|armhf|i386|mips64el|ppc64el|riscv64|s390x)
+ __KeyringFile="/usr/share/keyrings/debian-archive-keyring.gpg"
+
+ if [[ -z "$__UbuntuRepo" ]]; then
+ __UbuntuRepo="http://ftp.debian.org/debian/"
+ fi
+ ;;
+ *)
+ __KeyringFile="/usr/share/keyrings/debian-ports-archive-keyring.gpg"
+
+ if [[ -z "$__UbuntuRepo" ]]; then
+ __UbuntuRepo="http://ftp.ports.debian.org/debian-ports/"
+ fi
+ ;;
+ esac
+
+ if [[ -e "$__KeyringFile" ]]; then
+ __Keyring="--keyring $__KeyringFile"
fi
;;
tizen)
@@ -370,7 +383,7 @@ while :; do
;;
freebsd14)
__CodeName=freebsd
- __FreeBSDBase="14.0-RELEASE"
+ __FreeBSDBase="14.2-RELEASE"
__FreeBSDABI="14"
__SkipUnmount=1
;;
@@ -388,6 +401,9 @@ while :; do
--skipsigcheck)
__SkipSigCheck=1
;;
+ --skipemulation)
+ __SkipEmulation=1
+ ;;
--rootfsdir|-rootfsdir)
shift
__RootfsDir="$1"
@@ -420,16 +436,15 @@ case "$__AlpineVersion" in
elif [[ "$__AlpineArch" == "x86" ]]; then
__AlpineVersion=3.17 # minimum version that supports lldb-dev
__AlpinePackages+=" llvm15-libs"
- elif [[ "$__AlpineArch" == "riscv64" ]]; then
+ elif [[ "$__AlpineArch" == "riscv64" || "$__AlpineArch" == "loongarch64" ]]; then
+ __AlpineVersion=3.21 # minimum version that supports lldb-dev
+ __AlpinePackages+=" llvm19-libs"
+ elif [[ -n "$__AlpineMajorVersion" ]]; then
+ # use whichever alpine version is provided and select the latest toolchain libs
__AlpineLlvmLibsLookup=1
- __AlpineVersion=edge # minimum version with APKINDEX.tar.gz (packages archive)
else
__AlpineVersion=3.13 # 3.13 to maximize compatibility
__AlpinePackages+=" llvm10-libs"
-
- if [[ "$__AlpineArch" == "armv7" ]]; then
- __AlpinePackages="${__AlpinePackages//numactl-dev/}"
- fi
fi
esac
@@ -439,15 +454,6 @@ if [[ "$__AlpineVersion" =~ 3\.1[345] ]]; then
__AlpinePackages="${__AlpinePackages/compiler-rt/compiler-rt-static}"
fi
-if [[ "$__BuildArch" == "armel" ]]; then
- __LLDB_Package="lldb-3.5-dev"
-fi
-
-if [[ "$__CodeName" == "xenial" && "$__UbuntuArch" == "armhf" ]]; then
- # libnuma-dev is not available on armhf for xenial
- __UbuntuPackages="${__UbuntuPackages//libnuma-dev/}"
-fi
-
__UbuntuPackages+=" ${__LLDB_Package:-}"
if [[ -z "$__UbuntuRepo" ]]; then
@@ -496,7 +502,7 @@ if [[ "$__CodeName" == "alpine" ]]; then
arch="$(uname -m)"
ensureDownloadTool
-
+
if [[ "$__hasWget" == 1 ]]; then
wget -P "$__ApkToolsDir" "https://gitlab.alpinelinux.org/api/v4/projects/5/packages/generic/v$__ApkToolsVersion/$arch/apk.static"
else
@@ -512,11 +518,6 @@ if [[ "$__CodeName" == "alpine" ]]; then
echo "$__ApkToolsSHA512SUM $__ApkToolsDir/apk.static" | sha512sum -c
chmod +x "$__ApkToolsDir/apk.static"
- if [[ -f "/usr/bin/qemu-$__QEMUArch-static" ]]; then
- mkdir -p "$__RootfsDir"/usr/bin
- cp -v "/usr/bin/qemu-$__QEMUArch-static" "$__RootfsDir/usr/bin"
- fi
-
if [[ "$__AlpineVersion" == "edge" ]]; then
version=edge
else
@@ -536,6 +537,10 @@ if [[ "$__CodeName" == "alpine" ]]; then
__ApkSignatureArg="--keys-dir $__ApkKeysDir"
fi
+ if [[ "$__SkipEmulation" == "1" ]]; then
+ __NoEmulationArg="--no-scripts"
+ fi
+
# initialize DB
# shellcheck disable=SC2086
"$__ApkToolsDir/apk.static" \
@@ -557,7 +562,7 @@ if [[ "$__CodeName" == "alpine" ]]; then
"$__ApkToolsDir/apk.static" \
-X "http://dl-cdn.alpinelinux.org/alpine/$version/main" \
-X "http://dl-cdn.alpinelinux.org/alpine/$version/community" \
- -U $__ApkSignatureArg --root "$__RootfsDir" --arch "$__AlpineArch" \
+ -U $__ApkSignatureArg --root "$__RootfsDir" --arch "$__AlpineArch" $__NoEmulationArg \
add $__AlpinePackages
rm -r "$__ApkToolsDir"
@@ -573,7 +578,7 @@ elif [[ "$__CodeName" == "freebsd" ]]; then
curl -SL "https://download.freebsd.org/ftp/releases/${__FreeBSDArch}/${__FreeBSDMachineArch}/${__FreeBSDBase}/base.txz" | tar -C "$__RootfsDir" -Jxf - ./lib ./usr/lib ./usr/libdata ./usr/include ./usr/share/keys ./etc ./bin/freebsd-version
fi
echo "ABI = \"FreeBSD:${__FreeBSDABI}:${__FreeBSDMachineArch}\"; FINGERPRINTS = \"${__RootfsDir}/usr/share/keys\"; REPOS_DIR = [\"${__RootfsDir}/etc/pkg\"]; REPO_AUTOUPDATE = NO; RUN_SCRIPTS = NO;" > "${__RootfsDir}"/usr/local/etc/pkg.conf
- echo "FreeBSD: { url: \"pkg+http://pkg.FreeBSD.org/\${ABI}/quarterly\", mirror_type: \"srv\", signature_type: \"fingerprints\", fingerprints: \"${__RootfsDir}/usr/share/keys/pkg\", enabled: yes }" > "${__RootfsDir}"/etc/pkg/FreeBSD.conf
+ echo "FreeBSD: { url: \"pkg+http://pkg.FreeBSD.org/\${ABI}/quarterly\", mirror_type: \"srv\", signature_type: \"fingerprints\", fingerprints: \"/usr/share/keys/pkg\", enabled: yes }" > "${__RootfsDir}"/etc/pkg/FreeBSD.conf
mkdir -p "$__RootfsDir"/tmp
# get and build package manager
if [[ "$__hasWget" == 1 ]]; then
@@ -681,7 +686,7 @@ elif [[ "$__CodeName" == "haiku" ]]; then
ensureDownloadTool
- echo "Downloading Haiku package tool"
+ echo "Downloading Haiku package tools"
git clone https://github.com/haiku/haiku-toolchains-ubuntu --depth 1 "$__RootfsDir/tmp/script"
if [[ "$__hasWget" == 1 ]]; then
wget -O "$__RootfsDir/tmp/download/hosttools.zip" "$("$__RootfsDir/tmp/script/fetch.sh" --hosttools)"
@@ -691,34 +696,42 @@ elif [[ "$__CodeName" == "haiku" ]]; then
unzip -o "$__RootfsDir/tmp/download/hosttools.zip" -d "$__RootfsDir/tmp/bin"
- DepotBaseUrl="https://depot.haiku-os.org/__api/v2/pkg/get-pkg"
- HpkgBaseUrl="https://eu.hpkg.haiku-os.org/haiku/master/$__HaikuArch/current"
+ HaikuBaseUrl="https://eu.hpkg.haiku-os.org/haiku/master/$__HaikuArch/current"
+ HaikuPortsBaseUrl="https://eu.hpkg.haiku-os.org/haikuports/master/$__HaikuArch/current"
+
+ echo "Downloading HaikuPorts package repository index..."
+ if [[ "$__hasWget" == 1 ]]; then
+ wget -P "$__RootfsDir/tmp/download" "$HaikuPortsBaseUrl/repo"
+ else
+ curl -SLO --create-dirs --output-dir "$__RootfsDir/tmp/download" "$HaikuPortsBaseUrl/repo"
+ fi
- # Download Haiku packages
echo "Downloading Haiku packages"
read -ra array <<<"$__HaikuPackages"
for package in "${array[@]}"; do
echo "Downloading $package..."
- # API documented here: https://github.com/haiku/haikudepotserver/blob/master/haikudepotserver-api2/src/main/resources/api2/pkg.yaml#L60
- # The schema here: https://github.com/haiku/haikudepotserver/blob/master/haikudepotserver-api2/src/main/resources/api2/pkg.yaml#L598
+ hpkgFilename="$(LD_LIBRARY_PATH="$__RootfsDir/tmp/bin" "$__RootfsDir/tmp/bin/package_repo" list -f "$__RootfsDir/tmp/download/repo" |
+ grep -E "${package}-" | sort -V | tail -n 1 | xargs)"
+ if [ -z "$hpkgFilename" ]; then
+ >&2 echo "ERROR: package $package missing."
+ exit 1
+ fi
+ echo "Resolved filename: $hpkgFilename..."
+ hpkgDownloadUrl="$HaikuPortsBaseUrl/packages/$hpkgFilename"
if [[ "$__hasWget" == 1 ]]; then
- hpkgDownloadUrl="$(wget -qO- --post-data '{"name":"'"$package"'","repositorySourceCode":"haikuports_'$__HaikuArch'","versionType":"LATEST","naturalLanguageCode":"en"}' \
- --header 'Content-Type:application/json' "$DepotBaseUrl" | jq -r '.result.versions[].hpkgDownloadURL')"
wget -P "$__RootfsDir/tmp/download" "$hpkgDownloadUrl"
else
- hpkgDownloadUrl="$(curl -sSL -XPOST --data '{"name":"'"$package"'","repositorySourceCode":"haikuports_'$__HaikuArch'","versionType":"LATEST","naturalLanguageCode":"en"}' \
- --header 'Content-Type:application/json' "$DepotBaseUrl" | jq -r '.result.versions[].hpkgDownloadURL')"
curl -SLO --create-dirs --output-dir "$__RootfsDir/tmp/download" "$hpkgDownloadUrl"
fi
done
for package in haiku haiku_devel; do
echo "Downloading $package..."
if [[ "$__hasWget" == 1 ]]; then
- hpkgVersion="$(wget -qO- "$HpkgBaseUrl" | sed -n 's/^.*version: "\([^"]*\)".*$/\1/p')"
- wget -P "$__RootfsDir/tmp/download" "$HpkgBaseUrl/packages/$package-$hpkgVersion-1-$__HaikuArch.hpkg"
+ hpkgVersion="$(wget -qO- "$HaikuBaseUrl" | sed -n 's/^.*version: "\([^"]*\)".*$/\1/p')"
+ wget -P "$__RootfsDir/tmp/download" "$HaikuBaseUrl/packages/$package-$hpkgVersion-1-$__HaikuArch.hpkg"
else
- hpkgVersion="$(curl -sSL "$HpkgBaseUrl" | sed -n 's/^.*version: "\([^"]*\)".*$/\1/p')"
- curl -SLO --create-dirs --output-dir "$__RootfsDir/tmp/download" "$HpkgBaseUrl/packages/$package-$hpkgVersion-1-$__HaikuArch.hpkg"
+ hpkgVersion="$(curl -sSL "$HaikuBaseUrl" | sed -n 's/^.*version: "\([^"]*\)".*$/\1/p')"
+ curl -SLO --create-dirs --output-dir "$__RootfsDir/tmp/download" "$HaikuBaseUrl/packages/$package-$hpkgVersion-1-$__HaikuArch.hpkg"
fi
done
@@ -744,25 +757,67 @@ elif [[ "$__CodeName" == "haiku" ]]; then
popd
rm -rf "$__RootfsDir/tmp"
elif [[ -n "$__CodeName" ]]; then
+ __Suites="$__CodeName $(for suite in $__UbuntuSuites; do echo -n "$__CodeName-$suite "; done)"
+
+ if [[ "$__SkipEmulation" == "1" ]]; then
+ if [[ -z "$AR" ]]; then
+ if command -v ar &>/dev/null; then
+ AR="$(command -v ar)"
+ elif command -v llvm-ar &>/dev/null; then
+ AR="$(command -v llvm-ar)"
+ else
+ echo "Unable to find ar or llvm-ar on PATH, add them to PATH or set AR environment variable pointing to the available AR tool"
+ exit 1
+ fi
+ fi
+
+ PYTHON=${PYTHON_EXECUTABLE:-python3}
+
+ # shellcheck disable=SC2086,SC2046
+ echo running "$PYTHON" "$__CrossDir/install-debs.py" --arch "$__UbuntuArch" --mirror "$__UbuntuRepo" --rootfsdir "$__RootfsDir" --artool "$AR" \
+ $(for suite in $__Suites; do echo -n "--suite $suite "; done) \
+ $__UbuntuPackages
+
+ # shellcheck disable=SC2086,SC2046
+ "$PYTHON" "$__CrossDir/install-debs.py" --arch "$__UbuntuArch" --mirror "$__UbuntuRepo" --rootfsdir "$__RootfsDir" --artool "$AR" \
+ $(for suite in $__Suites; do echo -n "--suite $suite "; done) \
+ $__UbuntuPackages
+ exit 0
+ fi
+
+ __UpdateOptions=
if [[ "$__SkipSigCheck" == "0" ]]; then
__Keyring="$__Keyring --force-check-gpg"
+ else
+ __Keyring=
+ __UpdateOptions="--allow-unauthenticated --allow-insecure-repositories"
fi
# shellcheck disable=SC2086
echo running debootstrap "--variant=minbase" $__Keyring --arch "$__UbuntuArch" "$__CodeName" "$__RootfsDir" "$__UbuntuRepo"
- debootstrap "--variant=minbase" $__Keyring --arch "$__UbuntuArch" "$__CodeName" "$__RootfsDir" "$__UbuntuRepo"
+ # shellcheck disable=SC2086
+ if ! debootstrap "--variant=minbase" $__Keyring --arch "$__UbuntuArch" "$__CodeName" "$__RootfsDir" "$__UbuntuRepo"; then
+ echo "debootstrap failed! dumping debootstrap.log"
+ cat "$__RootfsDir/debootstrap/debootstrap.log"
+ exit 1
+ fi
+
+ rm -rf "$__RootfsDir"/etc/apt/*.{sources,list} "$__RootfsDir"/etc/apt/sources.list.d
mkdir -p "$__RootfsDir/etc/apt/sources.list.d/"
+
+ # shellcheck disable=SC2086
cat > "$__RootfsDir/etc/apt/sources.list.d/$__CodeName.sources" < token2) - (token1 < token2)
+ else:
+ return -1 if isinstance(token1, str) else 1
+
+ return len(tokens1) - len(tokens2)
+
+def compare_debian_versions(version1, version2):
+ """Compare two Debian package versions."""
+ epoch1, upstream1, revision1 = parse_debian_version(version1)
+ epoch2, upstream2, revision2 = parse_debian_version(version2)
+
+ if epoch1 != epoch2:
+ return epoch1 - epoch2
+
+ result = compare_upstream_version(upstream1, upstream2)
+ if result != 0:
+ return result
+
+ return compare_upstream_version(revision1, revision2)
+
+def resolve_dependencies(packages, aliases, desired_packages):
+ """Recursively resolves dependencies for the desired packages."""
+ resolved = []
+ to_process = deque(desired_packages)
+
+ while to_process:
+ current = to_process.popleft()
+ resolved_package = current if current in packages else aliases.get(current, [None])[0]
+
+ if not resolved_package:
+ print(f"Error: Package '{current}' was not found in the available packages.")
+ sys.exit(1)
+
+ if resolved_package not in resolved:
+ resolved.append(resolved_package)
+
+ deps = packages.get(resolved_package, {}).get("Depends", "")
+ if deps:
+ deps = [dep.split(' ')[0] for dep in deps.split(', ') if dep]
+ for dep in deps:
+ if dep not in resolved and dep not in to_process and dep in packages:
+ to_process.append(dep)
+
+ return resolved
+
+def parse_package_index(content):
+ """Parses the Packages.gz file and returns package information."""
+ packages = {}
+ aliases = {}
+ entries = re.split(r'\n\n+', content)
+
+ for entry in entries:
+ fields = dict(re.findall(r'^(\S+): (.+)$', entry, re.MULTILINE))
+ if "Package" in fields:
+ package_name = fields["Package"]
+ version = fields.get("Version")
+ filename = fields.get("Filename")
+ depends = fields.get("Depends")
+ provides = fields.get("Provides", None)
+
+ # Only update if package_name is not in packages or if the new version is higher
+ if package_name not in packages or compare_debian_versions(version, packages[package_name]["Version"]) > 0:
+ packages[package_name] = {
+ "Version": version,
+ "Filename": filename,
+ "Depends": depends
+ }
+
+ # Update aliases if package provides any alternatives
+ if provides:
+ provides_list = [x.strip() for x in provides.split(",")]
+ for alias in provides_list:
+ # Strip version specifiers
+ alias_name = re.sub(r'\s*\(=.*\)', '', alias)
+ if alias_name not in aliases:
+ aliases[alias_name] = []
+ if package_name not in aliases[alias_name]:
+ aliases[alias_name].append(package_name)
+
+ return packages, aliases
+
+def install_packages(mirror, packages_info, aliases, tmp_dir, extract_dir, ar_tool, desired_packages):
+ """Downloads .deb files and extracts them."""
+ resolved_packages = resolve_dependencies(packages_info, aliases, desired_packages)
+ print(f"Resolved packages (including dependencies): {resolved_packages}")
+
+ packages_to_download = {}
+
+ for pkg in resolved_packages:
+ if pkg in packages_info:
+ packages_to_download[pkg] = packages_info[pkg]
+
+ if pkg in aliases:
+ for alias in aliases[pkg]:
+ if alias in packages_info:
+ packages_to_download[alias] = packages_info[alias]
+
+ asyncio.run(download_deb_files_parallel(mirror, packages_to_download, tmp_dir))
+
+ package_to_deb_file_map = {}
+ for pkg in resolved_packages:
+ pkg_info = packages_info.get(pkg)
+ if pkg_info:
+ deb_filename = pkg_info.get("Filename")
+ if deb_filename:
+ deb_file_path = os.path.join(tmp_dir, os.path.basename(deb_filename))
+ package_to_deb_file_map[pkg] = deb_file_path
+
+ for pkg in reversed(resolved_packages):
+ deb_file = package_to_deb_file_map.get(pkg)
+ if deb_file and os.path.exists(deb_file):
+ extract_deb_file(deb_file, tmp_dir, extract_dir, ar_tool)
+
+ print("All done!")
+
+def extract_deb_file(deb_file, tmp_dir, extract_dir, ar_tool):
+ """Extract .deb file contents"""
+
+ os.makedirs(extract_dir, exist_ok=True)
+
+ with tempfile.TemporaryDirectory(dir=tmp_dir) as tmp_subdir:
+ result = subprocess.run(f"{ar_tool} t {os.path.abspath(deb_file)}", cwd=tmp_subdir, check=True, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+
+ tar_filename = None
+ for line in result.stdout.decode().splitlines():
+ if line.startswith("data.tar"):
+ tar_filename = line.strip()
+ break
+
+ if not tar_filename:
+ raise FileNotFoundError(f"Could not find 'data.tar.*' in {deb_file}.")
+
+ tar_file_path = os.path.join(tmp_subdir, tar_filename)
+ print(f"Extracting {tar_filename} from {deb_file}..")
+
+ subprocess.run(f"{ar_tool} p {os.path.abspath(deb_file)} {tar_filename} > {tar_file_path}", check=True, shell=True)
+
+ file_extension = os.path.splitext(tar_file_path)[1].lower()
+
+ if file_extension == ".xz":
+ mode = "r:xz"
+ elif file_extension == ".gz":
+ mode = "r:gz"
+ elif file_extension == ".zst":
+ # zstd is not supported by standard library yet
+ decompressed_tar_path = tar_file_path.replace(".zst", "")
+ with open(tar_file_path, "rb") as zst_file, open(decompressed_tar_path, "wb") as decompressed_file:
+ dctx = zstandard.ZstdDecompressor()
+ dctx.copy_stream(zst_file, decompressed_file)
+
+ tar_file_path = decompressed_tar_path
+ mode = "r"
+ else:
+ raise ValueError(f"Unsupported compression format: {file_extension}")
+
+ with tarfile.open(tar_file_path, mode) as tar:
+ tar.extractall(path=extract_dir, filter='fully_trusted')
+
+def finalize_setup(rootfsdir):
+ lib_dir = os.path.join(rootfsdir, 'lib')
+ usr_lib_dir = os.path.join(rootfsdir, 'usr', 'lib')
+
+ if os.path.exists(lib_dir):
+ if os.path.islink(lib_dir):
+ os.remove(lib_dir)
+ else:
+ os.makedirs(usr_lib_dir, exist_ok=True)
+
+ for item in os.listdir(lib_dir):
+ src = os.path.join(lib_dir, item)
+ dest = os.path.join(usr_lib_dir, item)
+
+ if os.path.isdir(src):
+ shutil.copytree(src, dest, dirs_exist_ok=True)
+ else:
+ shutil.copy2(src, dest)
+
+ shutil.rmtree(lib_dir)
+
+ os.symlink(usr_lib_dir, lib_dir)
+
+if __name__ == "__main__":
+ parser = argparse.ArgumentParser(description="Generate rootfs for .NET runtime on Debian-like OS")
+ parser.add_argument("--distro", required=False, help="Distro name (e.g., debian, ubuntu, etc.)")
+ parser.add_argument("--arch", required=True, help="Architecture (e.g., amd64, loong64, etc.)")
+ parser.add_argument("--rootfsdir", required=True, help="Destination directory.")
+ parser.add_argument('--suite', required=True, action='append', help='Specify one or more repository suites to collect index data.')
+ parser.add_argument("--mirror", required=False, help="Mirror (e.g., http://ftp.debian.org/debian-ports etc.)")
+ parser.add_argument("--artool", required=False, default="ar", help="ar tool to extract debs (e.g., ar, llvm-ar etc.)")
+ parser.add_argument("packages", nargs="+", help="List of package names to be installed.")
+
+ args = parser.parse_args()
+
+ if args.mirror is None:
+ if args.distro == "ubuntu":
+ args.mirror = "http://archive.ubuntu.com/ubuntu" if args.arch in ["amd64", "i386"] else "http://ports.ubuntu.com/ubuntu-ports"
+ elif args.distro == "debian":
+ args.mirror = "http://ftp.debian.org/debian-ports"
+ else:
+ raise Exception("Unsupported distro")
+
+ DESIRED_PACKAGES = args.packages + [ # base packages
+ "dpkg",
+ "busybox",
+ "libc-bin",
+ "base-files",
+ "base-passwd",
+ "debianutils"
+ ]
+
+ print(f"Creating rootfs. rootfsdir: {args.rootfsdir}, distro: {args.distro}, arch: {args.arch}, suites: {args.suite}, mirror: {args.mirror}")
+
+ package_index_content = asyncio.run(download_package_index_parallel(args.mirror, args.arch, args.suite))
+
+ packages_info, aliases = parse_package_index(package_index_content)
+
+ with tempfile.TemporaryDirectory() as tmp_dir:
+ install_packages(args.mirror, packages_info, aliases, tmp_dir, args.rootfsdir, args.artool, DESIRED_PACKAGES)
+
+ finalize_setup(args.rootfsdir)
diff --git a/eng/common/cross/tizen-fetch.sh b/eng/common/cross/tizen-fetch.sh
index 28936ceef3a71..37c3a61f1de80 100644
--- a/eng/common/cross/tizen-fetch.sh
+++ b/eng/common/cross/tizen-fetch.sh
@@ -156,13 +156,8 @@ fetch_tizen_pkgs()
done
}
-if [ "$TIZEN_ARCH" == "riscv64" ]; then
- BASE="Tizen-Base-RISCV"
- UNIFIED="Tizen-Unified-RISCV"
-else
- BASE="Tizen-Base"
- UNIFIED="Tizen-Unified"
-fi
+BASE="Tizen-Base"
+UNIFIED="Tizen-Unified"
Inform "Initialize ${TIZEN_ARCH} base"
fetch_tizen_pkgs_init standard $BASE
diff --git a/eng/common/cross/toolchain.cmake b/eng/common/cross/toolchain.cmake
index 9a7ecfbd42c5f..0ff85cf0367ee 100644
--- a/eng/common/cross/toolchain.cmake
+++ b/eng/common/cross/toolchain.cmake
@@ -67,6 +67,13 @@ elseif(TARGET_ARCH_NAME STREQUAL "armv6")
else()
set(TOOLCHAIN "arm-linux-gnueabihf")
endif()
+elseif(TARGET_ARCH_NAME STREQUAL "loongarch64")
+ set(CMAKE_SYSTEM_PROCESSOR "loongarch64")
+ if(EXISTS ${CROSS_ROOTFS}/usr/lib/gcc/loongarch64-alpine-linux-musl)
+ set(TOOLCHAIN "loongarch64-alpine-linux-musl")
+ else()
+ set(TOOLCHAIN "loongarch64-linux-gnu")
+ endif()
elseif(TARGET_ARCH_NAME STREQUAL "ppc64le")
set(CMAKE_SYSTEM_PROCESSOR ppc64le)
if(EXISTS ${CROSS_ROOTFS}/usr/lib/gcc/powerpc64le-alpine-linux-musl)
@@ -118,7 +125,7 @@ elseif(TARGET_ARCH_NAME STREQUAL "x86")
set(TIZEN_TOOLCHAIN "i586-tizen-linux-gnu")
endif()
else()
- message(FATAL_ERROR "Arch is ${TARGET_ARCH_NAME}. Only arm, arm64, armel, armv6, ppc64le, riscv64, s390x, x64 and x86 are supported!")
+ message(FATAL_ERROR "Arch is ${TARGET_ARCH_NAME}. Only arm, arm64, armel, armv6, loongarch64, ppc64le, riscv64, s390x, x64 and x86 are supported!")
endif()
if(DEFINED ENV{TOOLCHAIN})
@@ -148,6 +155,25 @@ if(TIZEN)
include_directories(SYSTEM ${TIZEN_TOOLCHAIN_PATH}/include/c++/${TIZEN_TOOLCHAIN})
endif()
+function(locate_toolchain_exec exec var)
+ set(TOOLSET_PREFIX ${TOOLCHAIN}-)
+ string(TOUPPER ${exec} EXEC_UPPERCASE)
+ if(NOT "$ENV{CLR_${EXEC_UPPERCASE}}" STREQUAL "")
+ set(${var} "$ENV{CLR_${EXEC_UPPERCASE}}" PARENT_SCOPE)
+ return()
+ endif()
+
+ find_program(EXEC_LOCATION_${exec}
+ NAMES
+ "${TOOLSET_PREFIX}${exec}${CLR_CMAKE_COMPILER_FILE_NAME_VERSION}"
+ "${TOOLSET_PREFIX}${exec}")
+
+ if (EXEC_LOCATION_${exec} STREQUAL "EXEC_LOCATION_${exec}-NOTFOUND")
+ message(FATAL_ERROR "Unable to find toolchain executable. Name: ${exec}, Prefix: ${TOOLSET_PREFIX}.")
+ endif()
+ set(${var} ${EXEC_LOCATION_${exec}} PARENT_SCOPE)
+endfunction()
+
if(ANDROID)
if(TARGET_ARCH_NAME STREQUAL "arm")
set(ANDROID_ABI armeabi-v7a)
@@ -178,66 +204,24 @@ elseif(FREEBSD)
set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -fuse-ld=lld")
elseif(ILLUMOS)
set(CMAKE_SYSROOT "${CROSS_ROOTFS}")
+ set(CMAKE_SYSTEM_PREFIX_PATH "${CROSS_ROOTFS}")
+ set(CMAKE_C_STANDARD_LIBRARIES "${CMAKE_C_STANDARD_LIBRARIES} -lssp")
+ set(CMAKE_CXX_STANDARD_LIBRARIES "${CMAKE_CXX_STANDARD_LIBRARIES} -lssp")
include_directories(SYSTEM ${CROSS_ROOTFS}/include)
- set(TOOLSET_PREFIX ${TOOLCHAIN}-)
- function(locate_toolchain_exec exec var)
- string(TOUPPER ${exec} EXEC_UPPERCASE)
- if(NOT "$ENV{CLR_${EXEC_UPPERCASE}}" STREQUAL "")
- set(${var} "$ENV{CLR_${EXEC_UPPERCASE}}" PARENT_SCOPE)
- return()
- endif()
-
- find_program(EXEC_LOCATION_${exec}
- NAMES
- "${TOOLSET_PREFIX}${exec}${CLR_CMAKE_COMPILER_FILE_NAME_VERSION}"
- "${TOOLSET_PREFIX}${exec}")
-
- if (EXEC_LOCATION_${exec} STREQUAL "EXEC_LOCATION_${exec}-NOTFOUND")
- message(FATAL_ERROR "Unable to find toolchain executable. Name: ${exec}, Prefix: ${TOOLSET_PREFIX}.")
- endif()
- set(${var} ${EXEC_LOCATION_${exec}} PARENT_SCOPE)
- endfunction()
-
- set(CMAKE_SYSTEM_PREFIX_PATH "${CROSS_ROOTFS}")
-
locate_toolchain_exec(gcc CMAKE_C_COMPILER)
locate_toolchain_exec(g++ CMAKE_CXX_COMPILER)
-
- set(CMAKE_C_STANDARD_LIBRARIES "${CMAKE_C_STANDARD_LIBRARIES} -lssp")
- set(CMAKE_CXX_STANDARD_LIBRARIES "${CMAKE_CXX_STANDARD_LIBRARIES} -lssp")
elseif(HAIKU)
set(CMAKE_SYSROOT "${CROSS_ROOTFS}")
set(CMAKE_PROGRAM_PATH "${CMAKE_PROGRAM_PATH};${CROSS_ROOTFS}/cross-tools-x86_64/bin")
-
- set(TOOLSET_PREFIX ${TOOLCHAIN}-)
- function(locate_toolchain_exec exec var)
- string(TOUPPER ${exec} EXEC_UPPERCASE)
- if(NOT "$ENV{CLR_${EXEC_UPPERCASE}}" STREQUAL "")
- set(${var} "$ENV{CLR_${EXEC_UPPERCASE}}" PARENT_SCOPE)
- return()
- endif()
-
- find_program(EXEC_LOCATION_${exec}
- NAMES
- "${TOOLSET_PREFIX}${exec}${CLR_CMAKE_COMPILER_FILE_NAME_VERSION}"
- "${TOOLSET_PREFIX}${exec}")
-
- if (EXEC_LOCATION_${exec} STREQUAL "EXEC_LOCATION_${exec}-NOTFOUND")
- message(FATAL_ERROR "Unable to find toolchain executable. Name: ${exec}, Prefix: ${TOOLSET_PREFIX}.")
- endif()
- set(${var} ${EXEC_LOCATION_${exec}} PARENT_SCOPE)
- endfunction()
-
set(CMAKE_SYSTEM_PREFIX_PATH "${CROSS_ROOTFS}")
+ set(CMAKE_C_STANDARD_LIBRARIES "${CMAKE_C_STANDARD_LIBRARIES} -lssp")
+ set(CMAKE_CXX_STANDARD_LIBRARIES "${CMAKE_CXX_STANDARD_LIBRARIES} -lssp")
locate_toolchain_exec(gcc CMAKE_C_COMPILER)
locate_toolchain_exec(g++ CMAKE_CXX_COMPILER)
- set(CMAKE_C_STANDARD_LIBRARIES "${CMAKE_C_STANDARD_LIBRARIES} -lssp")
- set(CMAKE_CXX_STANDARD_LIBRARIES "${CMAKE_CXX_STANDARD_LIBRARIES} -lssp")
-
# let CMake set up the correct search paths
include(Platform/Haiku)
else()
@@ -307,7 +291,7 @@ endif()
# Specify compile options
-if((TARGET_ARCH_NAME MATCHES "^(arm|arm64|armel|armv6|ppc64le|riscv64|s390x|x64|x86)$" AND NOT ANDROID AND NOT FREEBSD) OR ILLUMOS OR HAIKU)
+if((TARGET_ARCH_NAME MATCHES "^(arm|arm64|armel|armv6|loongarch64|ppc64le|riscv64|s390x|x64|x86)$" AND NOT ANDROID AND NOT FREEBSD) OR ILLUMOS OR HAIKU)
set(CMAKE_C_COMPILER_TARGET ${TOOLCHAIN})
set(CMAKE_CXX_COMPILER_TARGET ${TOOLCHAIN})
set(CMAKE_ASM_COMPILER_TARGET ${TOOLCHAIN})
diff --git a/eng/common/darc-init.sh b/eng/common/darc-init.sh
index 36dbd45e1ce86..e889f439b8dc9 100755
--- a/eng/common/darc-init.sh
+++ b/eng/common/darc-init.sh
@@ -68,7 +68,7 @@ function InstallDarcCli {
fi
fi
- local arcadeServicesSource="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-tools/nuget/v3/index.json"
+ local arcadeServicesSource="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-eng/nuget/v3/index.json"
echo "Installing Darc CLI version $darcVersion..."
echo "You may need to restart your command shell if this is the first dotnet tool you have installed."
diff --git a/eng/common/native/install-dependencies.sh b/eng/common/native/install-dependencies.sh
new file mode 100644
index 0000000000000..477a44f335be3
--- /dev/null
+++ b/eng/common/native/install-dependencies.sh
@@ -0,0 +1,62 @@
+#!/bin/sh
+
+set -e
+
+# This is a simple script primarily used for CI to install necessary dependencies
+#
+# Usage:
+#
+# ./install-dependencies.sh
+
+os="$(echo "$1" | tr "[:upper:]" "[:lower:]")"
+
+if [ -z "$os" ]; then
+ . "$(dirname "$0")"/init-os-and-arch.sh
+fi
+
+case "$os" in
+ linux)
+ if [ -e /etc/os-release ]; then
+ . /etc/os-release
+ fi
+
+ if [ "$ID" = "debian" ] || [ "$ID_LIKE" = "debian" ]; then
+ apt update
+
+ apt install -y build-essential gettext locales cmake llvm clang lld lldb liblldb-dev libunwind8-dev libicu-dev liblttng-ust-dev \
+ libssl-dev libkrb5-dev pigz cpio
+
+ localedef -i en_US -c -f UTF-8 -A /usr/share/locale/locale.alias en_US.UTF-8
+ elif [ "$ID" = "fedora" ] || [ "$ID" = "rhel" ] || [ "$ID" = "azurelinux" ]; then
+ pkg_mgr="$(command -v tdnf 2>/dev/null || command -v dnf)"
+ $pkg_mgr install -y cmake llvm lld lldb clang python curl libicu-devel openssl-devel krb5-devel lttng-ust-devel pigz cpio
+ elif [ "$ID" = "alpine" ]; then
+ apk add build-base cmake bash curl clang llvm-dev lld lldb krb5-dev lttng-ust-dev icu-dev openssl-dev pigz cpio
+ else
+ echo "Unsupported distro. distro: $ID"
+ exit 1
+ fi
+ ;;
+
+ osx|maccatalyst|ios|iossimulator|tvos|tvossimulator)
+ echo "Installed xcode version: $(xcode-select -p)"
+
+ export HOMEBREW_NO_INSTALL_CLEANUP=1
+ export HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK=1
+ # Skip brew update for now, see https://github.com/actions/setup-python/issues/577
+ # brew update --preinstall
+ brew bundle --no-upgrade --file=- < Msbuild engine to use to run build ('dotnet', 'vs', or unspecified)."
+ Write-Host " -excludeCIBinaryLog When running on CI, allow no binary log (short: -nobl)"
Write-Host ""
Write-Host "Command line arguments not listed above are passed thru to msbuild."
}
@@ -34,10 +36,11 @@ function Print-Usage() {
function Build([string]$target) {
$logSuffix = if ($target -eq 'Execute') { '' } else { ".$target" }
$log = Join-Path $LogDir "$task$logSuffix.binlog"
+ $binaryLogArg = if ($binaryLog) { "/bl:$log" } else { "" }
$outputPath = Join-Path $ToolsetDir "$task\"
MSBuild $taskProject `
- /bl:$log `
+ $binaryLogArg `
/t:$target `
/p:Configuration=$configuration `
/p:RepoRoot=$RepoRoot `
@@ -64,7 +67,7 @@ try {
$GlobalJson.tools | Add-Member -Name "vs" -Value (ConvertFrom-Json "{ `"version`": `"16.5`" }") -MemberType NoteProperty
}
if( -not ($GlobalJson.tools.PSObject.Properties.Name -match "xcopy-msbuild" )) {
- $GlobalJson.tools | Add-Member -Name "xcopy-msbuild" -Value "17.12.0" -MemberType NoteProperty
+ $GlobalJson.tools | Add-Member -Name "xcopy-msbuild" -Value "17.13.0" -MemberType NoteProperty
}
if ($GlobalJson.tools."xcopy-msbuild".Trim() -ine "none") {
$xcopyMSBuildToolsFolder = InitializeXCopyMSBuild $GlobalJson.tools."xcopy-msbuild" -install $true
diff --git a/eng/common/sdk-task.sh b/eng/common/sdk-task.sh
new file mode 100644
index 0000000000000..2f83adc0269fa
--- /dev/null
+++ b/eng/common/sdk-task.sh
@@ -0,0 +1,116 @@
+#!/usr/bin/env bash
+
+show_usage() {
+ echo "Common settings:"
+ echo " --task Name of Arcade task (name of a project in SdkTasks directory of the Arcade SDK package)"
+ echo " --restore Restore dependencies"
+ echo " --verbosity Msbuild verbosity: q[uiet], m[inimal], n[ormal], d[etailed], and diag[nostic]"
+ echo " --help Print help and exit"
+ echo ""
+
+ echo "Advanced settings:"
+ echo " --excludeCIBinarylog Don't output binary log (short: -nobl)"
+ echo ""
+ echo "Command line arguments not listed above are passed thru to msbuild."
+}
+
+source="${BASH_SOURCE[0]}"
+
+# resolve $source until the file is no longer a symlink
+while [[ -h "$source" ]]; do
+ scriptroot="$( cd -P "$( dirname "$source" )" && pwd )"
+ source="$(readlink "$source")"
+ # if $source was a relative symlink, we need to resolve it relative to the path where the
+ # symlink file was located
+ [[ $source != /* ]] && source="$scriptroot/$source"
+done
+scriptroot="$( cd -P "$( dirname "$source" )" && pwd )"
+
+Build() {
+ local target=$1
+ local log_suffix=""
+ [[ "$target" != "Execute" ]] && log_suffix=".$target"
+ local log="$log_dir/$task$log_suffix.binlog"
+ local binaryLogArg=""
+ [[ $binary_log == true ]] && binaryLogArg="/bl:$log"
+ local output_path="$toolset_dir/$task/"
+
+ MSBuild "$taskProject" \
+ $binaryLogArg \
+ /t:"$target" \
+ /p:Configuration="$configuration" \
+ /p:RepoRoot="$repo_root" \
+ /p:BaseIntermediateOutputPath="$output_path" \
+ /v:"$verbosity" \
+ $properties
+}
+
+binary_log=true
+configuration="Debug"
+verbosity="minimal"
+exclude_ci_binary_log=false
+restore=false
+help=false
+properties=''
+
+while (($# > 0)); do
+ lowerI="$(echo $1 | tr "[:upper:]" "[:lower:]")"
+ case $lowerI in
+ --task)
+ task=$2
+ shift 2
+ ;;
+ --restore)
+ restore=true
+ shift 1
+ ;;
+ --verbosity)
+ verbosity=$2
+ shift 2
+ ;;
+ --excludecibinarylog|--nobl)
+ binary_log=false
+ exclude_ci_binary_log=true
+ shift 1
+ ;;
+ --help)
+ help=true
+ shift 1
+ ;;
+ *)
+ properties="$properties $1"
+ shift 1
+ ;;
+ esac
+done
+
+ci=true
+warnAsError=true
+
+if $help; then
+ show_usage
+ exit 0
+fi
+
+. "$scriptroot/tools.sh"
+InitializeToolset
+
+if [[ -z "$task" ]]; then
+ Write-PipelineTelemetryError -Category 'Task' -Name 'MissingTask' -Message "Missing required parameter '-task '"
+ ExitWithExitCode 1
+fi
+
+taskProject=$(GetSdkTaskProject "$task")
+if [[ ! -e "$taskProject" ]]; then
+ Write-PipelineTelemetryError -Category 'Task' -Name 'UnknownTask' -Message "Unknown task: $task"
+ ExitWithExitCode 1
+fi
+
+if $restore; then
+ Build "Restore"
+fi
+
+Build "Execute"
+
+
+ExitWithExitCode 0
diff --git a/eng/common/sdl/packages.config b/eng/common/sdl/packages.config
index 4585cfd6bba1e..e5f543ea68c27 100644
--- a/eng/common/sdl/packages.config
+++ b/eng/common/sdl/packages.config
@@ -1,4 +1,4 @@
-
+
diff --git a/eng/common/templates-official/job/job.yml b/eng/common/templates-official/job/job.yml
index 817555505aa60..a8a9432874582 100644
--- a/eng/common/templates-official/job/job.yml
+++ b/eng/common/templates-official/job/job.yml
@@ -31,6 +31,7 @@ jobs:
PathtoPublish: '$(Build.ArtifactStagingDirectory)/artifacts'
ArtifactName: ${{ coalesce(parameters.artifacts.publish.artifacts.name , 'Artifacts_$(Agent.Os)_$(_BuildConfig)') }}
condition: always()
+ retryCountOnTaskFailure: 10 # for any logs being locked
continueOnError: true
- ${{ if and(ne(parameters.artifacts.publish.logs, 'false'), ne(parameters.artifacts.publish.logs, '')) }}:
- output: pipelineArtifact
@@ -39,6 +40,7 @@ jobs:
displayName: 'Publish logs'
continueOnError: true
condition: always()
+ retryCountOnTaskFailure: 10 # for any logs being locked
sbomEnabled: false # we don't need SBOM for logs
- ${{ if eq(parameters.enablePublishBuildArtifacts, true) }}:
@@ -46,7 +48,7 @@ jobs:
displayName: Publish Logs
PathtoPublish: '$(Build.ArtifactStagingDirectory)/artifacts/log/$(_BuildConfig)'
publishLocation: Container
- ArtifactName: ${{ coalesce(parameters.enablePublishBuildArtifacts.artifactName, '$(Agent.Os)_$(Agent.JobName)' ) }}
+ ArtifactName: ${{ coalesce(parameters.enablePublishBuildArtifacts.artifactName, '$(Agent.Os)_$(Agent.JobName)_Attempt$(System.JobAttempt)' ) }}
continueOnError: true
condition: always()
sbomEnabled: false # we don't need SBOM for logs
diff --git a/eng/common/templates-official/steps/publish-build-artifacts.yml b/eng/common/templates-official/steps/publish-build-artifacts.yml
index 100a3fc98493c..fcf6637b2ebcc 100644
--- a/eng/common/templates-official/steps/publish-build-artifacts.yml
+++ b/eng/common/templates-official/steps/publish-build-artifacts.yml
@@ -24,6 +24,10 @@ parameters:
- name: is1ESPipeline
type: boolean
default: true
+
+- name: retryCountOnTaskFailure
+ type: string
+ default: 10
steps:
- ${{ if ne(parameters.is1ESPipeline, true) }}:
@@ -38,4 +42,5 @@ steps:
PathtoPublish: ${{ parameters.pathToPublish }}
${{ if parameters.artifactName }}:
ArtifactName: ${{ parameters.artifactName }}
-
+ ${{ if parameters.retryCountOnTaskFailure }}:
+ retryCountOnTaskFailure: ${{ parameters.retryCountOnTaskFailure }}
diff --git a/eng/common/templates-official/steps/source-index-stage1-publish.yml b/eng/common/templates-official/steps/source-index-stage1-publish.yml
new file mode 100644
index 0000000000000..9b8b80942b5c3
--- /dev/null
+++ b/eng/common/templates-official/steps/source-index-stage1-publish.yml
@@ -0,0 +1,7 @@
+steps:
+- template: /eng/common/core-templates/steps/source-index-stage1-publish.yml
+ parameters:
+ is1ESPipeline: true
+
+ ${{ each parameter in parameters }}:
+ ${{ parameter.key }}: ${{ parameter.value }}
diff --git a/eng/common/templates/job/job.yml b/eng/common/templates/job/job.yml
index d1aeb92fcea51..7cbf668c22bc0 100644
--- a/eng/common/templates/job/job.yml
+++ b/eng/common/templates/job/job.yml
@@ -46,6 +46,7 @@ jobs:
artifactName: ${{ coalesce(parameters.artifacts.publish.artifacts.name , 'Artifacts_$(Agent.Os)_$(_BuildConfig)') }}
continueOnError: true
condition: always()
+ retryCountOnTaskFailure: 10 # for any logs being locked
- ${{ if and(ne(parameters.artifacts.publish.logs, 'false'), ne(parameters.artifacts.publish.logs, '')) }}:
- template: /eng/common/core-templates/steps/publish-pipeline-artifacts.yml
parameters:
@@ -56,6 +57,7 @@ jobs:
displayName: 'Publish logs'
continueOnError: true
condition: always()
+ retryCountOnTaskFailure: 10 # for any logs being locked
sbomEnabled: false # we don't need SBOM for logs
- ${{ if ne(parameters.enablePublishBuildArtifacts, 'false') }}:
@@ -66,7 +68,7 @@ jobs:
displayName: Publish Logs
pathToPublish: '$(Build.ArtifactStagingDirectory)/artifacts/log/$(_BuildConfig)'
publishLocation: Container
- artifactName: ${{ coalesce(parameters.enablePublishBuildArtifacts.artifactName, '$(Agent.Os)_$(Agent.JobName)' ) }}
+ artifactName: ${{ coalesce(parameters.enablePublishBuildArtifacts.artifactName, '$(Agent.Os)_$(Agent.JobName)_Attempt$(System.JobAttempt)' ) }}
continueOnError: true
condition: always()
diff --git a/eng/common/templates/steps/publish-build-artifacts.yml b/eng/common/templates/steps/publish-build-artifacts.yml
index 6428a98dfef68..605e602e94d13 100644
--- a/eng/common/templates/steps/publish-build-artifacts.yml
+++ b/eng/common/templates/steps/publish-build-artifacts.yml
@@ -25,6 +25,10 @@ parameters:
type: string
default: 'Container'
+- name: retryCountOnTaskFailure
+ type: string
+ default: 10
+
steps:
- ${{ if eq(parameters.is1ESPipeline, true) }}:
- 'eng/common/templates cannot be referenced from a 1ES managed template': error
@@ -37,4 +41,6 @@ steps:
PublishLocation: ${{ parameters.publishLocation }}
PathtoPublish: ${{ parameters.pathToPublish }}
${{ if parameters.artifactName }}:
- ArtifactName: ${{ parameters.artifactName }}
\ No newline at end of file
+ ArtifactName: ${{ parameters.artifactName }}
+ ${{ if parameters.retryCountOnTaskFailure }}:
+ retryCountOnTaskFailure: ${{ parameters.retryCountOnTaskFailure }}
diff --git a/eng/common/templates/steps/source-index-stage1-publish.yml b/eng/common/templates/steps/source-index-stage1-publish.yml
new file mode 100644
index 0000000000000..182cec33a7bb7
--- /dev/null
+++ b/eng/common/templates/steps/source-index-stage1-publish.yml
@@ -0,0 +1,7 @@
+steps:
+- template: /eng/common/core-templates/steps/source-index-stage1-publish.yml
+ parameters:
+ is1ESPipeline: false
+
+ ${{ each parameter in parameters }}:
+ ${{ parameter.key }}: ${{ parameter.value }}
diff --git a/eng/common/templates/steps/vmr-sync.yml b/eng/common/templates/steps/vmr-sync.yml
new file mode 100644
index 0000000000000..599afb6186b8f
--- /dev/null
+++ b/eng/common/templates/steps/vmr-sync.yml
@@ -0,0 +1,207 @@
+### These steps synchronize new code from product repositories into the VMR (https://github.com/dotnet/dotnet).
+### They initialize the darc CLI and pull the new updates.
+### Changes are applied locally onto the already cloned VMR (located in $vmrPath).
+
+parameters:
+- name: targetRef
+ displayName: Target revision in dotnet/ to synchronize
+ type: string
+ default: $(Build.SourceVersion)
+
+- name: vmrPath
+ displayName: Path where the dotnet/dotnet is checked out to
+ type: string
+ default: $(Agent.BuildDirectory)/vmr
+
+- name: additionalSyncs
+ displayName: Optional list of package names whose repo's source will also be synchronized in the local VMR, e.g. NuGet.Protocol
+ type: object
+ default: []
+
+steps:
+- checkout: vmr
+ displayName: Clone dotnet/dotnet
+ path: vmr
+ clean: true
+
+- checkout: self
+ displayName: Clone $(Build.Repository.Name)
+ path: repo
+ fetchDepth: 0
+
+# This step is needed so that when we get a detached HEAD / shallow clone,
+# we still pull the commit into the temporary repo clone to use it during the sync.
+# Also unshallow the clone so that forwardflow command would work.
+- script: |
+ git branch repo-head
+ git rev-parse HEAD
+ displayName: Label PR commit
+ workingDirectory: $(Agent.BuildDirectory)/repo
+
+- script: |
+ vmr_sha=$(grep -oP '(?<=Sha=")[^"]*' $(Agent.BuildDirectory)/repo/eng/Version.Details.xml)
+ echo "##vso[task.setvariable variable=vmr_sha]$vmr_sha"
+ displayName: Obtain the vmr sha from Version.Details.xml (Unix)
+ condition: ne(variables['Agent.OS'], 'Windows_NT')
+ workingDirectory: $(Agent.BuildDirectory)/repo
+
+- powershell: |
+ [xml]$xml = Get-Content -Path $(Agent.BuildDirectory)/repo/eng/Version.Details.xml
+ $vmr_sha = $xml.SelectSingleNode("//Source").Sha
+ Write-Output "##vso[task.setvariable variable=vmr_sha]$vmr_sha"
+ displayName: Obtain the vmr sha from Version.Details.xml (Windows)
+ condition: eq(variables['Agent.OS'], 'Windows_NT')
+ workingDirectory: $(Agent.BuildDirectory)/repo
+
+- script: |
+ git fetch --all
+ git checkout $(vmr_sha)
+ displayName: Checkout VMR at correct sha for repo flow
+ workingDirectory: ${{ parameters.vmrPath }}
+
+- script: |
+ git config --global user.name "dotnet-maestro[bot]"
+ git config --global user.email "dotnet-maestro[bot]@users.noreply.github.com"
+ displayName: Set git author to dotnet-maestro[bot]
+ workingDirectory: ${{ parameters.vmrPath }}
+
+- script: |
+ ./eng/common/vmr-sync.sh \
+ --vmr ${{ parameters.vmrPath }} \
+ --tmp $(Agent.TempDirectory) \
+ --azdev-pat '$(dn-bot-all-orgs-code-r)' \
+ --ci \
+ --debug
+
+ if [ "$?" -ne 0 ]; then
+ echo "##vso[task.logissue type=error]Failed to synchronize the VMR"
+ exit 1
+ fi
+ displayName: Sync repo into VMR (Unix)
+ condition: ne(variables['Agent.OS'], 'Windows_NT')
+ workingDirectory: $(Agent.BuildDirectory)/repo
+
+- script: |
+ git config --global diff.astextplain.textconv echo
+ git config --system core.longpaths true
+ displayName: Configure Windows git (longpaths, astextplain)
+ condition: eq(variables['Agent.OS'], 'Windows_NT')
+
+- powershell: |
+ ./eng/common/vmr-sync.ps1 `
+ -vmr ${{ parameters.vmrPath }} `
+ -tmp $(Agent.TempDirectory) `
+ -azdevPat '$(dn-bot-all-orgs-code-r)' `
+ -ci `
+ -debugOutput
+
+ if ($LASTEXITCODE -ne 0) {
+ echo "##vso[task.logissue type=error]Failed to synchronize the VMR"
+ exit 1
+ }
+ displayName: Sync repo into VMR (Windows)
+ condition: eq(variables['Agent.OS'], 'Windows_NT')
+ workingDirectory: $(Agent.BuildDirectory)/repo
+
+- ${{ if eq(variables['Build.Reason'], 'PullRequest') }}:
+ - task: CopyFiles@2
+ displayName: Collect failed patches
+ condition: failed()
+ inputs:
+ SourceFolder: '$(Agent.TempDirectory)'
+ Contents: '*.patch'
+ TargetFolder: '$(Build.ArtifactStagingDirectory)/FailedPatches'
+
+ - publish: '$(Build.ArtifactStagingDirectory)/FailedPatches'
+ artifact: $(System.JobDisplayName)_FailedPatches
+ displayName: Upload failed patches
+ condition: failed()
+
+- ${{ each assetName in parameters.additionalSyncs }}:
+ # The vmr-sync script ends up staging files in the local VMR so we have to commit those
+ - script:
+ git commit --allow-empty -am "Forward-flow $(Build.Repository.Name)"
+ displayName: Commit local VMR changes
+ workingDirectory: ${{ parameters.vmrPath }}
+
+ - script: |
+ set -ex
+
+ echo "Searching for details of asset ${{ assetName }}..."
+
+ # Use darc to get dependencies information
+ dependencies=$(./.dotnet/dotnet darc get-dependencies --name '${{ assetName }}' --ci)
+
+ # Extract repository URL and commit hash
+ repository=$(echo "$dependencies" | grep 'Repo:' | sed 's/Repo:[[:space:]]*//' | head -1)
+
+ if [ -z "$repository" ]; then
+ echo "##vso[task.logissue type=error]Asset ${{ assetName }} not found in the dependency list"
+ exit 1
+ fi
+
+ commit=$(echo "$dependencies" | grep 'Commit:' | sed 's/Commit:[[:space:]]*//' | head -1)
+
+ echo "Updating the VMR from $repository / $commit..."
+ cd ..
+ git clone $repository ${{ assetName }}
+ cd ${{ assetName }}
+ git checkout $commit
+ git branch "sync/$commit"
+
+ ./eng/common/vmr-sync.sh \
+ --vmr ${{ parameters.vmrPath }} \
+ --tmp $(Agent.TempDirectory) \
+ --azdev-pat '$(dn-bot-all-orgs-code-r)' \
+ --ci \
+ --debug
+
+ if [ "$?" -ne 0 ]; then
+ echo "##vso[task.logissue type=error]Failed to synchronize the VMR"
+ exit 1
+ fi
+ displayName: Sync ${{ assetName }} into (Unix)
+ condition: ne(variables['Agent.OS'], 'Windows_NT')
+ workingDirectory: $(Agent.BuildDirectory)/repo
+
+ - powershell: |
+ $ErrorActionPreference = 'Stop'
+
+ Write-Host "Searching for details of asset ${{ assetName }}..."
+
+ $dependencies = .\.dotnet\dotnet darc get-dependencies --name '${{ assetName }}' --ci
+
+ $repository = $dependencies | Select-String -Pattern 'Repo:\s+([^\s]+)' | Select-Object -First 1
+ $repository -match 'Repo:\s+([^\s]+)' | Out-Null
+ $repository = $matches[1]
+
+ if ($repository -eq $null) {
+ Write-Error "Asset ${{ assetName }} not found in the dependency list"
+ exit 1
+ }
+
+ $commit = $dependencies | Select-String -Pattern 'Commit:\s+([^\s]+)' | Select-Object -First 1
+ $commit -match 'Commit:\s+([^\s]+)' | Out-Null
+ $commit = $matches[1]
+
+ Write-Host "Updating the VMR from $repository / $commit..."
+ cd ..
+ git clone $repository ${{ assetName }}
+ cd ${{ assetName }}
+ git checkout $commit
+ git branch "sync/$commit"
+
+ .\eng\common\vmr-sync.ps1 `
+ -vmr ${{ parameters.vmrPath }} `
+ -tmp $(Agent.TempDirectory) `
+ -azdevPat '$(dn-bot-all-orgs-code-r)' `
+ -ci `
+ -debugOutput
+
+ if ($LASTEXITCODE -ne 0) {
+ echo "##vso[task.logissue type=error]Failed to synchronize the VMR"
+ exit 1
+ }
+ displayName: Sync ${{ assetName }} into (Windows)
+ condition: ne(variables['Agent.OS'], 'Windows_NT')
+ workingDirectory: $(Agent.BuildDirectory)/repo
diff --git a/eng/common/templates/vmr-build-pr.yml b/eng/common/templates/vmr-build-pr.yml
new file mode 100644
index 0000000000000..670cf32c3bd1f
--- /dev/null
+++ b/eng/common/templates/vmr-build-pr.yml
@@ -0,0 +1,33 @@
+trigger: none
+pr:
+ branches:
+ include:
+ - main
+ - release/*
+ paths:
+ exclude:
+ - documentation/*
+ - README.md
+ - CODEOWNERS
+
+variables:
+- template: /eng/common/templates/variables/pool-providers.yml@self
+
+- name: skipComponentGovernanceDetection # we run CG on internal builds only
+ value: true
+
+- name: Codeql.Enabled # we run CodeQL on internal builds only
+ value: false
+
+resources:
+ repositories:
+ - repository: vmr
+ type: github
+ name: dotnet/dotnet
+ endpoint: dotnet
+
+stages:
+- template: /eng/pipelines/templates/stages/vmr-build.yml@vmr
+ parameters:
+ isBuiltFromVmr: false
+ scope: lite
diff --git a/eng/common/tools.ps1 b/eng/common/tools.ps1
index 22b49e09d09b5..c9e39595b586c 100644
--- a/eng/common/tools.ps1
+++ b/eng/common/tools.ps1
@@ -65,10 +65,8 @@ $ErrorActionPreference = 'Stop'
# Base-64 encoded SAS token that has permission to storage container described by $runtimeSourceFeed
[string]$runtimeSourceFeedKey = if (Test-Path variable:runtimeSourceFeedKey) { $runtimeSourceFeedKey } else { $null }
-# True if the build is a product build
-[bool]$productBuild = if (Test-Path variable:productBuild) { $productBuild } else { $false }
-
-[String[]]$properties = if (Test-Path variable:properties) { $properties } else { @() }
+# True when the build is running within the VMR.
+[bool]$fromVMR = if (Test-Path variable:fromVMR) { $fromVMR } else { $false }
function Create-Directory ([string[]] $path) {
New-Item -Path $path -Force -ItemType 'Directory' | Out-Null
@@ -383,8 +381,8 @@ function InitializeVisualStudioMSBuild([bool]$install, [object]$vsRequirements =
# If the version of msbuild is going to be xcopied,
# use this version. Version matches a package here:
- # https://dev.azure.com/dnceng/public/_artifacts/feed/dotnet-eng/NuGet/Microsoft.DotNet.Arcade.MSBuild.Xcopy/versions/17.12.0
- $defaultXCopyMSBuildVersion = '17.12.0'
+ # https://dev.azure.com/dnceng/public/_artifacts/feed/dotnet-eng/NuGet/Microsoft.DotNet.Arcade.MSBuild.Xcopy/versions/17.13.0
+ $defaultXCopyMSBuildVersion = '17.13.0'
if (!$vsRequirements) {
if (Get-Member -InputObject $GlobalJson.tools -Name 'vs') {
@@ -604,14 +602,7 @@ function InitializeBuildTool() {
}
$dotnetPath = Join-Path $dotnetRoot (GetExecutableFileName 'dotnet')
- # Use override if it exists - commonly set by source-build
- if ($null -eq $env:_OverrideArcadeInitializeBuildToolFramework) {
- $initializeBuildToolFramework="net9.0"
- } else {
- $initializeBuildToolFramework=$env:_OverrideArcadeInitializeBuildToolFramework
- }
-
- $buildTool = @{ Path = $dotnetPath; Command = 'msbuild'; Tool = 'dotnet'; Framework = $initializeBuildToolFramework }
+ $buildTool = @{ Path = $dotnetPath; Command = 'msbuild'; Tool = 'dotnet'; Framework = 'net' }
} elseif ($msbuildEngine -eq "vs") {
try {
$msbuildPath = InitializeVisualStudioMSBuild -install:$restore
@@ -620,7 +611,7 @@ function InitializeBuildTool() {
ExitWithExitCode 1
}
- $buildTool = @{ Path = $msbuildPath; Command = ""; Tool = "vs"; Framework = "net472"; ExcludePrereleaseVS = $excludePrereleaseVS }
+ $buildTool = @{ Path = $msbuildPath; Command = ""; Tool = "vs"; Framework = "netframework"; ExcludePrereleaseVS = $excludePrereleaseVS }
} else {
Write-PipelineTelemetryError -Category 'InitializeToolset' -Message "Unexpected value of -msbuildEngine: '$msbuildEngine'."
ExitWithExitCode 1
@@ -653,7 +644,6 @@ function GetNuGetPackageCachePath() {
$env:NUGET_PACKAGES = Join-Path $env:UserProfile '.nuget\packages\'
} else {
$env:NUGET_PACKAGES = Join-Path $RepoRoot '.packages\'
- $env:RESTORENOHTTPCACHE = $true
}
}
@@ -779,8 +769,10 @@ function MSBuild() {
# new scripts need to work with old packages, so we need to look for the old names/versions
(Join-Path $basePath (Join-Path $buildTool.Framework 'Microsoft.DotNet.ArcadeLogging.dll')),
(Join-Path $basePath (Join-Path $buildTool.Framework 'Microsoft.DotNet.Arcade.Sdk.dll')),
- (Join-Path $basePath (Join-Path net7.0 'Microsoft.DotNet.ArcadeLogging.dll')),
- (Join-Path $basePath (Join-Path net7.0 'Microsoft.DotNet.Arcade.Sdk.dll')),
+
+ # This list doesn't need to be updated anymore and can eventually be removed.
+ (Join-Path $basePath (Join-Path net9.0 'Microsoft.DotNet.ArcadeLogging.dll')),
+ (Join-Path $basePath (Join-Path net9.0 'Microsoft.DotNet.Arcade.Sdk.dll')),
(Join-Path $basePath (Join-Path net8.0 'Microsoft.DotNet.ArcadeLogging.dll')),
(Join-Path $basePath (Join-Path net8.0 'Microsoft.DotNet.Arcade.Sdk.dll'))
)
@@ -857,8 +849,8 @@ function MSBuild-Core() {
}
# When running on Azure Pipelines, override the returned exit code to avoid double logging.
- # Skip this when the build is a child of the VMR orchestrator build.
- if ($ci -and $env:SYSTEM_TEAMPROJECT -ne $null -and !$productBuild -and -not($properties -like "*DotNetBuildRepo=true*")) {
+ # Skip this when the build is a child of the VMR build.
+ if ($ci -and $env:SYSTEM_TEAMPROJECT -ne $null -and !$fromVMR) {
Write-PipelineSetResult -Result "Failed" -Message "msbuild execution failed."
# Exiting with an exit code causes the azure pipelines task to log yet another "noise" error
# The above Write-PipelineSetResult will cause the task to be marked as failure without adding yet another error
diff --git a/eng/common/tools.sh b/eng/common/tools.sh
index 01b09b65796c1..a7e8493151067 100755
--- a/eng/common/tools.sh
+++ b/eng/common/tools.sh
@@ -5,6 +5,9 @@
# CI mode - set to true on CI server for PR validation build or official build.
ci=${ci:-false}
+# Build mode
+source_build=${source_build:-false}
+
# Set to true to use the pipelines logger which will enable Azure logging output.
# https://github.com/Microsoft/azure-pipelines-tasks/blob/master/docs/authoring/commands.md
# This flag is meant as a temporary opt-opt for the feature while validate it across
@@ -58,7 +61,8 @@ use_installed_dotnet_cli=${use_installed_dotnet_cli:-true}
dotnetInstallScriptVersion=${dotnetInstallScriptVersion:-'v1'}
# True to use global NuGet cache instead of restoring packages to repository-local directory.
-if [[ "$ci" == true ]]; then
+# Keep in sync with NuGetPackageroot in Arcade SDK's RepositoryLayout.props.
+if [[ "$ci" == true || "$source_build" == true ]]; then
use_global_nuget_cache=${use_global_nuget_cache:-false}
else
use_global_nuget_cache=${use_global_nuget_cache:-true}
@@ -68,8 +72,8 @@ fi
runtime_source_feed=${runtime_source_feed:-''}
runtime_source_feed_key=${runtime_source_feed_key:-''}
-# True if the build is a product build
-product_build=${product_build:-false}
+# True when the build is running within the VMR.
+from_vmr=${from_vmr:-false}
# Resolve any symlinks in the given path.
function ResolvePath {
@@ -339,22 +343,14 @@ function InitializeBuildTool {
# return values
_InitializeBuildTool="$_InitializeDotNetCli/dotnet"
_InitializeBuildToolCommand="msbuild"
- # use override if it exists - commonly set by source-build
- if [[ "${_OverrideArcadeInitializeBuildToolFramework:-x}" == "x" ]]; then
- _InitializeBuildToolFramework="net9.0"
- else
- _InitializeBuildToolFramework="${_OverrideArcadeInitializeBuildToolFramework}"
- fi
}
-# Set RestoreNoHttpCache as a workaround for https://github.com/NuGet/Home/issues/3116
function GetNuGetPackageCachePath {
if [[ -z ${NUGET_PACKAGES:-} ]]; then
if [[ "$use_global_nuget_cache" == true ]]; then
export NUGET_PACKAGES="$HOME/.nuget/packages/"
else
export NUGET_PACKAGES="$repo_root/.packages/"
- export RESTORENOHTTPCACHE=true
fi
fi
@@ -454,10 +450,12 @@ function MSBuild {
# new scripts need to work with old packages, so we need to look for the old names/versions
local selectedPath=
local possiblePaths=()
- possiblePaths+=( "$toolset_dir/$_InitializeBuildToolFramework/Microsoft.DotNet.ArcadeLogging.dll" )
- possiblePaths+=( "$toolset_dir/$_InitializeBuildToolFramework/Microsoft.DotNet.Arcade.Sdk.dll" )
- possiblePaths+=( "$toolset_dir/net7.0/Microsoft.DotNet.ArcadeLogging.dll" )
- possiblePaths+=( "$toolset_dir/net7.0/Microsoft.DotNet.Arcade.Sdk.dll" )
+ possiblePaths+=( "$toolset_dir/net/Microsoft.DotNet.ArcadeLogging.dll" )
+ possiblePaths+=( "$toolset_dir/net/Microsoft.DotNet.Arcade.Sdk.dll" )
+
+ # This list doesn't need to be updated anymore and can eventually be removed.
+ possiblePaths+=( "$toolset_dir/net9.0/Microsoft.DotNet.ArcadeLogging.dll" )
+ possiblePaths+=( "$toolset_dir/net9.0/Microsoft.DotNet.Arcade.Sdk.dll" )
possiblePaths+=( "$toolset_dir/net8.0/Microsoft.DotNet.ArcadeLogging.dll" )
possiblePaths+=( "$toolset_dir/net8.0/Microsoft.DotNet.Arcade.Sdk.dll" )
for path in "${possiblePaths[@]}"; do
@@ -506,8 +504,8 @@ function MSBuild-Core {
echo "Build failed with exit code $exit_code. Check errors above."
# When running on Azure Pipelines, override the returned exit code to avoid double logging.
- # Skip this when the build is a child of the VMR orchestrator build.
- if [[ "$ci" == true && -n ${SYSTEM_TEAMPROJECT:-} && "$product_build" != true && "$properties" != *"DotNetBuildRepo=true"* ]]; then
+ # Skip this when the build is a child of the VMR build.
+ if [[ "$ci" == true && -n ${SYSTEM_TEAMPROJECT:-} && "$from_vmr" != true ]]; then
Write-PipelineSetResult -result "Failed" -message "msbuild execution failed."
# Exiting with an exit code causes the azure pipelines task to log yet another "noise" error
# The above Write-PipelineSetResult will cause the task to be marked as failure without adding yet another error
@@ -530,6 +528,13 @@ function GetDarc {
fi
"$eng_root/common/darc-init.sh" --toolpath "$darc_path" $version
+ darc_tool="$darc_path/darc"
+}
+
+# Returns a full path to an Arcade SDK task project file.
+function GetSdkTaskProject {
+ taskName=$1
+ echo "$(dirname $_InitializeToolset)/SdkTasks/$taskName.proj"
}
ResolvePath "${BASH_SOURCE[0]}"
diff --git a/eng/common/vmr-sync.ps1 b/eng/common/vmr-sync.ps1
new file mode 100644
index 0000000000000..97302f3205be9
--- /dev/null
+++ b/eng/common/vmr-sync.ps1
@@ -0,0 +1,138 @@
+<#
+.SYNOPSIS
+
+This script is used for synchronizing the current repository into a local VMR.
+It pulls the current repository's code into the specified VMR directory for local testing or
+Source-Build validation.
+
+.DESCRIPTION
+
+The tooling used for synchronization will clone the VMR repository into a temporary folder if
+it does not already exist. These clones can be reused in future synchronizations, so it is
+recommended to dedicate a folder for this to speed up re-runs.
+
+.EXAMPLE
+ Synchronize current repository into a local VMR:
+ ./vmr-sync.ps1 -vmrDir "$HOME/repos/dotnet" -tmpDir "$HOME/repos/tmp"
+
+.PARAMETER tmpDir
+Required. Path to the temporary folder where repositories will be cloned
+
+.PARAMETER vmrBranch
+Optional. Branch of the 'dotnet/dotnet' repo to synchronize. The VMR will be checked out to this branch
+
+.PARAMETER azdevPat
+Optional. Azure DevOps PAT to use for cloning private repositories.
+
+.PARAMETER vmrDir
+Optional. Path to the dotnet/dotnet repository. When null, gets cloned to the temporary folder
+
+.PARAMETER debugOutput
+Optional. Enables debug logging in the darc vmr command.
+
+.PARAMETER ci
+Optional. Denotes that the script is running in a CI environment.
+#>
+param (
+ [Parameter(Mandatory=$true, HelpMessage="Path to the temporary folder where repositories will be cloned")]
+ [string][Alias('t', 'tmp')]$tmpDir,
+ [string][Alias('b', 'branch')]$vmrBranch,
+ [string]$remote,
+ [string]$azdevPat,
+ [string][Alias('v', 'vmr')]$vmrDir,
+ [switch]$ci,
+ [switch]$debugOutput
+)
+
+function Fail {
+ Write-Host "> $($args[0])" -ForegroundColor 'Red'
+}
+
+function Highlight {
+ Write-Host "> $($args[0])" -ForegroundColor 'Cyan'
+}
+
+$verbosity = 'verbose'
+if ($debugOutput) {
+ $verbosity = 'debug'
+}
+# Validation
+
+if (-not $tmpDir) {
+ Fail "Missing -tmpDir argument. Please specify the path to the temporary folder where the repositories will be cloned"
+ exit 1
+}
+
+# Sanitize the input
+
+if (-not $vmrDir) {
+ $vmrDir = Join-Path $tmpDir 'dotnet'
+}
+
+if (-not (Test-Path -Path $tmpDir -PathType Container)) {
+ New-Item -ItemType Directory -Path $tmpDir | Out-Null
+}
+
+# Prepare the VMR
+
+if (-not (Test-Path -Path $vmrDir -PathType Container)) {
+ Highlight "Cloning 'dotnet/dotnet' into $vmrDir.."
+ git clone https://github.com/dotnet/dotnet $vmrDir
+
+ if ($vmrBranch) {
+ git -C $vmrDir switch -c $vmrBranch
+ }
+}
+else {
+ if ((git -C $vmrDir diff --quiet) -eq $false) {
+ Fail "There are changes in the working tree of $vmrDir. Please commit or stash your changes"
+ exit 1
+ }
+
+ if ($vmrBranch) {
+ Highlight "Preparing $vmrDir"
+ git -C $vmrDir checkout $vmrBranch
+ git -C $vmrDir pull
+ }
+}
+
+Set-StrictMode -Version Latest
+
+# Prepare darc
+
+Highlight 'Installing .NET, preparing the tooling..'
+. .\eng\common\tools.ps1
+$dotnetRoot = InitializeDotNetCli -install:$true
+$darc = Get-Darc
+$dotnet = "$dotnetRoot\dotnet.exe"
+
+Highlight "Starting the synchronization of VMR.."
+
+# Synchronize the VMR
+$darcArgs = (
+ "vmr", "forwardflow",
+ "--tmp", $tmpDir,
+ "--$verbosity",
+ $vmrDir
+)
+
+if ($ci) {
+ $darcArgs += ("--ci")
+}
+
+if ($azdevPat) {
+ $darcArgs += ("--azdev-pat", $azdevPat)
+}
+
+& "$darc" $darcArgs
+
+if ($LASTEXITCODE -eq 0) {
+ Highlight "Synchronization succeeded"
+}
+else {
+ Fail "Synchronization of repo to VMR failed!"
+ Fail "'$vmrDir' is left in its last state (re-run of this script will reset it)."
+ Fail "Please inspect the logs which contain path to the failing patch file (use -debugOutput to get all the details)."
+ Fail "Once you make changes to the conflicting VMR patch, commit it locally and re-run this script."
+ exit 1
+}
diff --git a/eng/common/vmr-sync.sh b/eng/common/vmr-sync.sh
new file mode 100644
index 0000000000000..44239e331c0cc
--- /dev/null
+++ b/eng/common/vmr-sync.sh
@@ -0,0 +1,207 @@
+#!/bin/bash
+
+### This script is used for synchronizing the current repository into a local VMR.
+### It pulls the current repository's code into the specified VMR directory for local testing or
+### Source-Build validation.
+###
+### The tooling used for synchronization will clone the VMR repository into a temporary folder if
+### it does not already exist. These clones can be reused in future synchronizations, so it is
+### recommended to dedicate a folder for this to speed up re-runs.
+###
+### USAGE:
+### Synchronize current repository into a local VMR:
+### ./vmr-sync.sh --tmp "$HOME/repos/tmp" "$HOME/repos/dotnet"
+###
+### Options:
+### -t, --tmp, --tmp-dir PATH
+### Required. Path to the temporary folder where repositories will be cloned
+###
+### -b, --branch, --vmr-branch BRANCH_NAME
+### Optional. Branch of the 'dotnet/dotnet' repo to synchronize. The VMR will be checked out to this branch
+###
+### --debug
+### Optional. Turns on the most verbose logging for the VMR tooling
+###
+### --remote name:URI
+### Optional. Additional remote to use during the synchronization
+### This can be used to synchronize to a commit from a fork of the repository
+### Example: 'runtime:https://github.com/yourfork/runtime'
+###
+### --azdev-pat
+### Optional. Azure DevOps PAT to use for cloning private repositories.
+###
+### -v, --vmr, --vmr-dir PATH
+### Optional. Path to the dotnet/dotnet repository. When null, gets cloned to the temporary folder
+
+source="${BASH_SOURCE[0]}"
+
+# resolve $source until the file is no longer a symlink
+while [[ -h "$source" ]]; do
+ scriptroot="$( cd -P "$( dirname "$source" )" && pwd )"
+ source="$(readlink "$source")"
+ # if $source was a relative symlink, we need to resolve it relative to the path where the
+ # symlink file was located
+ [[ $source != /* ]] && source="$scriptroot/$source"
+done
+scriptroot="$( cd -P "$( dirname "$source" )" && pwd )"
+
+function print_help () {
+ sed -n '/^### /,/^$/p' "$source" | cut -b 5-
+}
+
+COLOR_RED=$(tput setaf 1 2>/dev/null || true)
+COLOR_CYAN=$(tput setaf 6 2>/dev/null || true)
+COLOR_CLEAR=$(tput sgr0 2>/dev/null || true)
+COLOR_RESET=uniquesearchablestring
+FAILURE_PREFIX='> '
+
+function fail () {
+ echo "${COLOR_RED}$FAILURE_PREFIX${1//${COLOR_RESET}/${COLOR_RED}}${COLOR_CLEAR}" >&2
+}
+
+function highlight () {
+ echo "${COLOR_CYAN}$FAILURE_PREFIX${1//${COLOR_RESET}/${COLOR_CYAN}}${COLOR_CLEAR}"
+}
+
+tmp_dir=''
+vmr_dir=''
+vmr_branch=''
+additional_remotes=''
+verbosity=verbose
+azdev_pat=''
+ci=false
+
+while [[ $# -gt 0 ]]; do
+ opt="$(echo "$1" | tr "[:upper:]" "[:lower:]")"
+ case "$opt" in
+ -t|--tmp|--tmp-dir)
+ tmp_dir=$2
+ shift
+ ;;
+ -v|--vmr|--vmr-dir)
+ vmr_dir=$2
+ shift
+ ;;
+ -b|--branch|--vmr-branch)
+ vmr_branch=$2
+ shift
+ ;;
+ --remote)
+ additional_remotes="$additional_remotes $2"
+ shift
+ ;;
+ --azdev-pat)
+ azdev_pat=$2
+ shift
+ ;;
+ --ci)
+ ci=true
+ ;;
+ -d|--debug)
+ verbosity=debug
+ ;;
+ -h|--help)
+ print_help
+ exit 0
+ ;;
+ *)
+ fail "Invalid argument: $1"
+ print_help
+ exit 1
+ ;;
+ esac
+
+ shift
+done
+
+# Validation
+
+if [[ -z "$tmp_dir" ]]; then
+ fail "Missing --tmp-dir argument. Please specify the path to the temporary folder where the repositories will be cloned"
+ exit 1
+fi
+
+# Sanitize the input
+
+if [[ -z "$vmr_dir" ]]; then
+ vmr_dir="$tmp_dir/dotnet"
+fi
+
+if [[ ! -d "$tmp_dir" ]]; then
+ mkdir -p "$tmp_dir"
+fi
+
+if [[ "$verbosity" == "debug" ]]; then
+ set -x
+fi
+
+# Prepare the VMR
+
+if [[ ! -d "$vmr_dir" ]]; then
+ highlight "Cloning 'dotnet/dotnet' into $vmr_dir.."
+ git clone https://github.com/dotnet/dotnet "$vmr_dir"
+
+ if [[ -n "$vmr_branch" ]]; then
+ git -C "$vmr_dir" switch -c "$vmr_branch"
+ fi
+else
+ if ! git -C "$vmr_dir" diff --quiet; then
+ fail "There are changes in the working tree of $vmr_dir. Please commit or stash your changes"
+ exit 1
+ fi
+
+ if [[ -n "$vmr_branch" ]]; then
+ highlight "Preparing $vmr_dir"
+ git -C "$vmr_dir" checkout "$vmr_branch"
+ git -C "$vmr_dir" pull
+ fi
+fi
+
+set -e
+
+# Prepare darc
+
+highlight 'Installing .NET, preparing the tooling..'
+source "./eng/common/tools.sh"
+InitializeDotNetCli true
+GetDarc
+dotnetDir=$( cd ./.dotnet/; pwd -P )
+dotnet=$dotnetDir/dotnet
+
+highlight "Starting the synchronization of VMR.."
+set +e
+
+if [[ -n "$additional_remotes" ]]; then
+ additional_remotes="--additional-remotes $additional_remotes"
+fi
+
+if [[ -n "$azdev_pat" ]]; then
+ azdev_pat="--azdev-pat $azdev_pat"
+fi
+
+ci_arg=''
+if [[ "$ci" == "true" ]]; then
+ ci_arg="--ci"
+fi
+
+# Synchronize the VMR
+
+export DOTNET_ROOT="$dotnetDir"
+
+"$darc_tool" vmr forwardflow \
+ --tmp "$tmp_dir" \
+ $azdev_pat \
+ --$verbosity \
+ $ci_arg \
+ $additional_remotes \
+ "$vmr_dir"
+
+if [[ $? == 0 ]]; then
+ highlight "Synchronization succeeded"
+else
+ fail "Synchronization of repo to VMR failed!"
+ fail "'$vmr_dir' is left in its last state (re-run of this script will reset it)."
+ fail "Please inspect the logs which contain path to the failing patch file (use --debug to get all the details)."
+ fail "Once you make changes to the conflicting VMR patch, commit it locally and re-run this script."
+ exit 1
+fi
diff --git a/eng/config/BannedSymbols.txt b/eng/config/BannedSymbols.txt
index 8558e121b5dc2..5e56729488866 100644
--- a/eng/config/BannedSymbols.txt
+++ b/eng/config/BannedSymbols.txt
@@ -47,14 +47,14 @@ M:Microsoft.CodeAnalysis.Editing.SyntaxEditor.#ctor(Microsoft.CodeAnalysis.Synta
M:Microsoft.CodeAnalysis.FileTextLoader.#ctor(System.String,System.Text.Encoding); use WorkspaceFileTextLoader that calls on ITextFactoryService to create SourceText
M:Microsoft.CodeAnalysis.CSharp.SyntaxFactory.SyntaxTree(Microsoft.CodeAnalysis.SyntaxNode,Microsoft.CodeAnalysis.ParseOptions,System.String,System.Text.Encoding); Use CSharpSyntaxTree sublass that takes checksum algorithm
M:Microsoft.CodeAnalysis.CSharp.SyntaxFactory.ParseSyntaxTree(System.String,Microsoft.CodeAnalysis.ParseOptions,System.String,System.Text.Encoding,System.Threading.CancellationToken); Use CSharpSyntaxTree sublass that takes checksum algorithm
-M:Microsoft.CodeAnalysis.CSharp.CSharpSyntaxTree.CreateWithoutClone(Microsoft.CodeAnalysis.CSharp.CSharpSyntaxNode); Use CSharpSyntaxTree sublass that takes checksum algorithm
+M:Microsoft.CodeAnalysis.CSharp.CSharpSyntaxTree.CreateWithoutClone(Microsoft.CodeAnalysis.CSharp.CSharpSyntaxNode,Microsoft.CodeAnalysis.CSharp.CSharpParseOptions); Use CSharpSyntaxTree sublass that takes checksum algorithm
M:Microsoft.CodeAnalysis.CSharp.CSharpSyntaxTree.Create(Microsoft.CodeAnalysis.CSharp.CSharpSyntaxNode, Microsoft.CodeAnalysis.CSharp.CSharpParseOptions options, System.String path, System.Text.Encoding encoding); Use CSharpSyntaxTree sublass that takes checksum algorithm
M:Microsoft.CodeAnalysis.CSharp.CSharpSyntaxTree.ParseText(System.String,Microsoft.CodeAnalysis.CSharp.CSharpParseOptions,System.String,System.Text.Encoding,System.Threading.CancellationToken); Use API that takes SourceText
M:Microsoft.CodeAnalysis.CSharp.CSharpSyntaxTree.ParseText(System.String,Microsoft.CodeAnalysis.CSharp.CSharpParseOptions,System.String,System.Text.Encoding,System.Collections.Immutable.ImmutableDictionary{System.String,Microsoft.CodeAnalysis.ReportDiagnostic},System.Nullable{System.Boolean},System.Threading.CancellationToken); Use API that takes SourceText
M:Microsoft.CodeAnalysis.VisualBasic.SyntaxFactory.SyntaxTree(Microsoft.CodeAnalysis.SyntaxNode,Microsoft.CodeAnalysis.ParseOptions,System.String,System.Text.Encoding); Use VisualBasicSyntaxTree sublass that takes checksum algorithm
M:Microsoft.CodeAnalysis.VisualBasic.SyntaxFactory.ParseSyntaxTree(System.String,Microsoft.CodeAnalysis.ParseOptions,System.String,System.Text.Encoding,System.Threading.CancellationToken); Use overload with SourceText
M:Microsoft.CodeAnalysis.VisualBasic.SyntaxFactory.ParseSyntaxTree(System.String,Microsoft.CodeAnalysis.ParseOptions,System.String,System.Text.Encoding,System.Collections.Immutable.ImmutableDictionary{System.String,Microsoft.CodeAnalysis.ReportDiagnostic},System.Threading.CancellationToken); Use overload with SourceText
-M:Microsoft.CodeAnalysis.VisualBasic.VisualBasicSyntaxTree.CreateWithoutClone(Microsoft.CodeAnalysis.VisualBasic.VisualBasicSyntaxNode); Use VisualBasicSyntaxTree sublass that takes checksum algorithm
+M:Microsoft.CodeAnalysis.VisualBasic.VisualBasicSyntaxTree.CreateWithoutClone(Microsoft.CodeAnalysis.VisualBasic.VisualBasicSyntaxNode,Microsoft.CodeAnalysis.VisualBasic.VisualBasicParseOptions); Use VisualBasicSyntaxTree sublass that takes checksum algorithm
M:Microsoft.CodeAnalysis.VisualBasic.VisualBasicSyntaxTree.Create(Microsoft.CodeAnalysis.VisualBasic.VisualBasicSyntaxNode,Microsoft.CodeAnalysis.VisualBasic.VisualBasicParseOptions,System.String,System.Text.Encoding,System.Collections.Immutable.ImmutableDictionary{System.String,Microsoft.CodeAnalysis.ReportDiagnostic}); Use VisualBasicSyntaxTree sublass that takes checksum algorithm
M:Microsoft.CodeAnalysis.VisualBasic.VisualBasicSyntaxTree.Create(Microsoft.CodeAnalysis.VisualBasic.VisualBasicSyntaxNode,Microsoft.CodeAnalysis.VisualBasic.VisualBasicParseOptions,System.String,System.Text.Encoding); Use VisualBasicSyntaxTree sublass that takes checksum algorithm
M:Microsoft.CodeAnalysis.VisualBasic.VisualBasicSyntaxTree.ParseText(System.String,Microsoft.CodeAnalysis.VisualBasic.VisualBasicParseOptions,System.String,System.Text.Encoding,System.Collections.Immutable.ImmutableDictionary{System.String,Microsoft.CodeAnalysis.ReportDiagnostic},System.Threading.CancellationToken); Use overload with SourceText
@@ -70,11 +70,4 @@ M:Microsoft.CodeAnalysis.CodeActions.CodeAction.ComputeOperationsAsync(System.Th
M:Microsoft.CodeAnalysis.CodeActions.CodeAction.GetChangedSolutionAsync(CSystem.Threading.CancellationToken); Use overload that takes progress
M:Microsoft.CodeAnalysis.CodeActions.CodeAction.GetChangedDocumentAsync(CancellationToken); Use overload that takes progress
M:Microsoft.CodeAnalysis.DesktopStrongNameProvider.#ctor(System.Collections.Immutable.ImmutableArray{System.String}); Use overload that takes in temp directory
-M:System.Diagnostics.Tracing.EventSource.WriteEvent(System.Int32,System.Object[]); Use WriteEventCore instead
-E:Microsoft.CodeAnalysis.Workspace.WorkspaceChanged; Use RegisterWorkspaceChangedHandler instead
-E:Microsoft.CodeAnalysis.Workspace.WorkspaceFailed; Use RegisterWorkspaceFailedHandler instead
-E:Microsoft.CodeAnalysis.Workspace.DocumentOpened; Use RegisterDocumentOpenedHandler instead
-E:Microsoft.CodeAnalysis.Workspace.TextDocumentOpened; Use RegisterTextDocumentOpenedHandler instead
-E:Microsoft.CodeAnalysis.Workspace.DocumentClosed; Use RegisterDocumentClosedHandler instead
-E:Microsoft.CodeAnalysis.Workspace.TextDocumentClosed; Use RegisterTextDocumentClosedHandler instead
-E:Microsoft.CodeAnalysis.Workspace.DocumentActiveContextChanged; Use RegisterDocumentActiveContextChangedHandler instead
\ No newline at end of file
+M:System.Diagnostics.Tracing.EventSource.WriteEvent(System.Int32,System.Object[]); Use WriteEventCore instead
\ No newline at end of file
diff --git a/eng/config/PublishData.json b/eng/config/PublishData.json
index e2ad4fac15ab1..4ad30f47e3744 100644
--- a/eng/config/PublishData.json
+++ b/eng/config/PublishData.json
@@ -31,6 +31,7 @@
"Microsoft.Net.Compilers.Toolset.Arm64": "arcade",
"Microsoft.Net.Compilers.Toolset.Framework": "arcade",
"Microsoft.NETCore.Compilers": "arcade",
+ "Microsoft.CodeAnalysis.BuildClient": "arcade",
"Microsoft.CodeAnalysis.Contracts": "arcade",
"Microsoft.CodeAnalysis.Debugging": "arcade",
"Microsoft.CodeAnalysis.PooledObjects": "arcade",
@@ -175,6 +176,15 @@
"insertionTitlePrefix": "[d17.14]",
"insertionCreateDraftPR": false
},
+ "release/dev-next": {
+ "nugetKind": [
+ "Shipping",
+ "NonShipping"
+ ],
+ "vsBranch": "main",
+ "insertionTitlePrefix": "[dNext]",
+ "insertionCreateDraftPR": false
+ },
"main": {
"nugetKind": [
"Shipping",
@@ -190,8 +200,8 @@
"NonShipping"
],
"vsBranch": "main",
- "insertionCreateDraftPR": false,
- "insertionTitlePrefix": "[d17.15 P1]"
+ "insertionCreateDraftPR": true,
+ "insertionTitlePrefix": "[dNext.1]"
}
}
}
diff --git a/eng/pipelines/build-unix-job.yml b/eng/pipelines/build-unix-job.yml
index dda4777ae5128..9e3a2f3e14db5 100644
--- a/eng/pipelines/build-unix-job.yml
+++ b/eng/pipelines/build-unix-job.yml
@@ -27,7 +27,7 @@ jobs:
- script: ./eng/build.sh --ci --restore --prepareMachine --binaryLog --configuration ${{ parameters.configuration }}
displayName: Restore
- - script: ./eng/build.sh --ci --build --publish --pack --prepareMachine --binaryLog --skipDocumentation --configuration ${{ parameters.configuration }}
+ - script: ./eng/build.sh --ci --build --prepareMachine --binaryLog --skipDocumentation --configuration ${{ parameters.configuration }}
displayName: Build
- script: ./eng/prepare-tests.sh
diff --git a/eng/targets/Settings.props b/eng/targets/Settings.props
index d6ed357dadc0c..0da58812dbe3a 100644
--- a/eng/targets/Settings.props
+++ b/eng/targets/Settings.props
@@ -12,7 +12,7 @@
RoslynDev
- $(NoWarn);NU1507
+ $(NoWarn);NU1507;NU1510
CommonExtensions
Microsoft\VBCSharp\LanguageServices
@@ -34,7 +34,7 @@
NON_EXISTENT_FILE
- 15.0
+ 17.0
$(VisualStudioVersion.Substring($([System.Convert]::ToInt32(0)), $(VisualStudioVersion.IndexOf('.'))))
$(VisualStudioReferenceMajorVersion).0.0.0
$(VisualStudioVersion)
@@ -137,11 +137,6 @@
true
-
-
- false
-
-
$([System.Environment]::ExpandEnvironmentVariables("%VS$(VisualStudioReferenceMajorVersion)0COMNTOOLS%"))
$(DevEnvDir)\..\IDE
diff --git a/global.json b/global.json
index e72c8a57d82a0..765ae32155ef0 100644
--- a/global.json
+++ b/global.json
@@ -1,19 +1,19 @@
{
"sdk": {
- "version": "9.0.106",
+ "version": "10.0.100-preview.5.25277.114",
"allowPrerelease": false,
"rollForward": "patch"
},
"tools": {
- "dotnet": "9.0.106",
+ "dotnet": "10.0.100-preview.5.25277.114",
"vs": {
- "version": "17.8.0"
+ "version": "17.14.0"
},
"vswhere": "3.1.7"
},
"msbuild-sdks": {
- "Microsoft.DotNet.Arcade.Sdk": "9.0.0-beta.25271.1",
- "Microsoft.DotNet.Helix.Sdk": "9.0.0-beta.25271.1",
+ "Microsoft.DotNet.Arcade.Sdk": "10.0.0-beta.25259.2",
+ "Microsoft.DotNet.Helix.Sdk": "10.0.0-beta.25259.2",
"Microsoft.Build.Traversal": "3.4.0"
}
-}
+}
\ No newline at end of file
diff --git a/src/Analyzers/CSharp/Analyzers/AddRequiredParentheses/CSharpAddRequiredExpressionParenthesesDiagnosticAnalyzer.cs b/src/Analyzers/CSharp/Analyzers/AddRequiredParentheses/CSharpAddRequiredExpressionParenthesesDiagnosticAnalyzer.cs
index 714016c706018..ebee197687030 100644
--- a/src/Analyzers/CSharp/Analyzers/AddRequiredParentheses/CSharpAddRequiredExpressionParenthesesDiagnosticAnalyzer.cs
+++ b/src/Analyzers/CSharp/Analyzers/AddRequiredParentheses/CSharpAddRequiredExpressionParenthesesDiagnosticAnalyzer.cs
@@ -13,15 +13,10 @@
namespace Microsoft.CodeAnalysis.CSharp.AddRequiredParentheses;
[DiagnosticAnalyzer(LanguageNames.CSharp)]
-internal sealed class CSharpAddRequiredExpressionParenthesesDiagnosticAnalyzer :
+internal sealed class CSharpAddRequiredExpressionParenthesesDiagnosticAnalyzer() :
AbstractAddRequiredParenthesesDiagnosticAnalyzer<
- ExpressionSyntax, ExpressionSyntax, SyntaxKind>
+ ExpressionSyntax, ExpressionSyntax, SyntaxKind>(CSharpExpressionPrecedenceService.Instance)
{
- public CSharpAddRequiredExpressionParenthesesDiagnosticAnalyzer()
- : base(CSharpExpressionPrecedenceService.Instance)
- {
- }
-
private static readonly ImmutableArray s_kinds =
[
SyntaxKind.AddExpression,
@@ -56,7 +51,7 @@ protected override int GetPrecedence(ExpressionSyntax binaryLike)
protected override bool IsBinaryLike(ExpressionSyntax node)
=> node is BinaryExpressionSyntax ||
- node is IsPatternExpressionSyntax isPattern && isPattern.Pattern is ConstantPatternSyntax;
+ node is IsPatternExpressionSyntax { Pattern: ConstantPatternSyntax };
protected override (ExpressionSyntax, SyntaxToken, ExpressionSyntax) GetPartsOfBinaryLike(ExpressionSyntax binaryLike)
{
@@ -66,8 +61,8 @@ protected override (ExpressionSyntax, SyntaxToken, ExpressionSyntax) GetPartsOfB
case BinaryExpressionSyntax binaryExpression:
return (binaryExpression.Left, binaryExpression.OperatorToken, binaryExpression.Right);
- case IsPatternExpressionSyntax isPatternExpression:
- return (isPatternExpression.Expression, isPatternExpression.IsKeyword, ((ConstantPatternSyntax)isPatternExpression.Pattern).Expression);
+ case IsPatternExpressionSyntax { Pattern: ConstantPatternSyntax constantPattern } isPatternExpression:
+ return (isPatternExpression.Expression, isPatternExpression.IsKeyword, constantPattern.Expression);
default:
throw ExceptionUtilities.UnexpectedValue(binaryLike);
@@ -78,4 +73,7 @@ protected override (ExpressionSyntax, SyntaxToken, ExpressionSyntax) GetPartsOfB
=> binaryLike.Parent is ConstantPatternSyntax
? binaryLike.Parent.Parent as ExpressionSyntax
: binaryLike.Parent as ExpressionSyntax;
+
+ protected override bool IsAsExpression(ExpressionSyntax node)
+ => node.Kind() == SyntaxKind.AsExpression;
}
diff --git a/src/Analyzers/CSharp/Analyzers/AddRequiredParentheses/CSharpAddRequiredPatternParenthesesDiagnosticAnalyzer.cs b/src/Analyzers/CSharp/Analyzers/AddRequiredParentheses/CSharpAddRequiredPatternParenthesesDiagnosticAnalyzer.cs
index 06314ec57184e..d34ba9a664277 100644
--- a/src/Analyzers/CSharp/Analyzers/AddRequiredParentheses/CSharpAddRequiredPatternParenthesesDiagnosticAnalyzer.cs
+++ b/src/Analyzers/CSharp/Analyzers/AddRequiredParentheses/CSharpAddRequiredPatternParenthesesDiagnosticAnalyzer.cs
@@ -13,15 +13,10 @@
namespace Microsoft.CodeAnalysis.CSharp.AddRequiredParentheses;
[DiagnosticAnalyzer(LanguageNames.CSharp)]
-internal sealed class CSharpAddRequiredPatternParenthesesDiagnosticAnalyzer :
+internal sealed class CSharpAddRequiredPatternParenthesesDiagnosticAnalyzer() :
AbstractAddRequiredParenthesesDiagnosticAnalyzer<
- PatternSyntax, BinaryPatternSyntax, SyntaxKind>
+ PatternSyntax, BinaryPatternSyntax, SyntaxKind>(CSharpPatternPrecedenceService.Instance)
{
- public CSharpAddRequiredPatternParenthesesDiagnosticAnalyzer()
- : base(CSharpPatternPrecedenceService.Instance)
- {
- }
-
private static readonly ImmutableArray s_kinds = [SyntaxKind.AndPattern, SyntaxKind.OrPattern];
protected override ImmutableArray GetSyntaxNodeKinds()
@@ -41,4 +36,7 @@ protected override (PatternSyntax, SyntaxToken, PatternSyntax) GetPartsOfBinaryL
protected override PatternSyntax? TryGetAppropriateParent(BinaryPatternSyntax binaryLike)
=> binaryLike.Parent as PatternSyntax;
+
+ protected override bool IsAsExpression(BinaryPatternSyntax node)
+ => false;
}
diff --git a/src/Analyzers/CSharp/Analyzers/ConvertProgram/ConvertProgramAnalysis_ProgramMain.cs b/src/Analyzers/CSharp/Analyzers/ConvertProgram/ConvertProgramAnalysis_ProgramMain.cs
index 160c519dc0e26..2f1bd4366343f 100644
--- a/src/Analyzers/CSharp/Analyzers/ConvertProgram/ConvertProgramAnalysis_ProgramMain.cs
+++ b/src/Analyzers/CSharp/Analyzers/ConvertProgram/ConvertProgramAnalysis_ProgramMain.cs
@@ -8,7 +8,6 @@
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.Shared.Extensions;
using Microsoft.CodeAnalysis.Text;
-using Roslyn.Utilities;
namespace Microsoft.CodeAnalysis.CSharp.Analyzers.ConvertProgram;
diff --git a/src/Analyzers/CSharp/Analyzers/MatchFolderAndNamespace/CSharpMatchFolderAndNamespaceDiagnosticAnalyzer.cs b/src/Analyzers/CSharp/Analyzers/MatchFolderAndNamespace/CSharpMatchFolderAndNamespaceDiagnosticAnalyzer.cs
index 43a22404b99d9..e14c37850a6ad 100644
--- a/src/Analyzers/CSharp/Analyzers/MatchFolderAndNamespace/CSharpMatchFolderAndNamespaceDiagnosticAnalyzer.cs
+++ b/src/Analyzers/CSharp/Analyzers/MatchFolderAndNamespace/CSharpMatchFolderAndNamespaceDiagnosticAnalyzer.cs
@@ -2,13 +2,13 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-using Microsoft.CodeAnalysis.CSharp.Syntax;
-using Microsoft.CodeAnalysis.Analyzers.MatchFolderAndNamespace;
-using Microsoft.CodeAnalysis.LanguageService;
-using Microsoft.CodeAnalysis.Diagnostics;
-using Microsoft.CodeAnalysis.CSharp.LanguageService;
using System;
using System.Collections.Immutable;
+using Microsoft.CodeAnalysis.Analyzers.MatchFolderAndNamespace;
+using Microsoft.CodeAnalysis.CSharp.LanguageService;
+using Microsoft.CodeAnalysis.CSharp.Syntax;
+using Microsoft.CodeAnalysis.Diagnostics;
+using Microsoft.CodeAnalysis.LanguageService;
#if !CODE_STYLE
using System.Composition;
using Microsoft.CodeAnalysis.Host.Mef;
diff --git a/src/Analyzers/CSharp/Analyzers/RemoveUnnecessaryImports/CSharpRemoveUnnecessaryImportsDiagnosticAnalyzer.cs b/src/Analyzers/CSharp/Analyzers/RemoveUnnecessaryImports/CSharpRemoveUnnecessaryImportsDiagnosticAnalyzer.cs
index c750fbf86a3d3..370eb44b0a60a 100644
--- a/src/Analyzers/CSharp/Analyzers/RemoveUnnecessaryImports/CSharpRemoveUnnecessaryImportsDiagnosticAnalyzer.cs
+++ b/src/Analyzers/CSharp/Analyzers/RemoveUnnecessaryImports/CSharpRemoveUnnecessaryImportsDiagnosticAnalyzer.cs
@@ -52,18 +52,16 @@ protected override IEnumerable GetFixableDiagnosticSpans(
{
Contract.ThrowIfFalse(nodes.Any());
- var nodesContainingUnnecessaryUsings = new HashSet();
- foreach (var node in nodes)
+ foreach (var node in nodes.Select(n => n.GetAncestors().First(n => n is BaseNamespaceDeclarationSyntax or CompilationUnitSyntax)).Distinct())
{
- var nodeContainingUnnecessaryUsings = node.GetAncestors().First(n => n is BaseNamespaceDeclarationSyntax or CompilationUnitSyntax);
- if (!nodesContainingUnnecessaryUsings.Add(nodeContainingUnnecessaryUsings))
+ if (node is BaseNamespaceDeclarationSyntax namespaceDeclaration)
{
- continue;
+ yield return namespaceDeclaration.Usings.GetContainedSpan();
+ }
+ else if (node is CompilationUnitSyntax compilationUnit)
+ {
+ yield return compilationUnit.Usings.GetContainedSpan();
}
-
- yield return nodeContainingUnnecessaryUsings is BaseNamespaceDeclarationSyntax namespaceDeclaration
- ? namespaceDeclaration.Usings.GetContainedSpan()
- : ((CompilationUnitSyntax)nodeContainingUnnecessaryUsings).Usings.GetContainedSpan();
}
}
}
diff --git a/src/Analyzers/CSharp/Analyzers/RemoveUnnecessaryNullableDirective/CSharpRemoveUnnecessaryNullableDirectiveDiagnosticAnalyzer.cs b/src/Analyzers/CSharp/Analyzers/RemoveUnnecessaryNullableDirective/CSharpRemoveUnnecessaryNullableDirectiveDiagnosticAnalyzer.cs
index f2db2bf4e7ad5..544731492afc0 100644
--- a/src/Analyzers/CSharp/Analyzers/RemoveUnnecessaryNullableDirective/CSharpRemoveUnnecessaryNullableDirectiveDiagnosticAnalyzer.cs
+++ b/src/Analyzers/CSharp/Analyzers/RemoveUnnecessaryNullableDirective/CSharpRemoveUnnecessaryNullableDirectiveDiagnosticAnalyzer.cs
@@ -7,6 +7,7 @@
using System.Diagnostics.CodeAnalysis;
using System.Threading;
using Microsoft.CodeAnalysis.CodeStyle;
+using Microsoft.CodeAnalysis.Collections;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.CSharp.Analyzers.RemoveUnnecessaryNullableDirective;
using Microsoft.CodeAnalysis.CSharp.Syntax;
@@ -18,26 +19,19 @@
namespace Microsoft.CodeAnalysis.RemoveUnnecessaryNullableDirective;
[DiagnosticAnalyzer(LanguageNames.CSharp)]
-internal sealed class CSharpRemoveUnnecessaryNullableDirectiveDiagnosticAnalyzer
- : AbstractBuiltInUnnecessaryCodeStyleDiagnosticAnalyzer
+internal sealed class CSharpRemoveUnnecessaryNullableDirectiveDiagnosticAnalyzer()
+ : AbstractBuiltInUnnecessaryCodeStyleDiagnosticAnalyzer(IDEDiagnosticIds.RemoveUnnecessaryNullableDirectiveDiagnosticId,
+ EnforceOnBuildValues.RemoveUnnecessaryNullableDirective,
+ option: null,
+ fadingOption: null,
+ new LocalizableResourceString(nameof(CSharpAnalyzersResources.Remove_unnecessary_nullable_directive), CSharpAnalyzersResources.ResourceManager, typeof(CSharpAnalyzersResources)),
+ new LocalizableResourceString(nameof(CSharpAnalyzersResources.Nullable_directive_is_unnecessary), CSharpAnalyzersResources.ResourceManager, typeof(CSharpAnalyzersResources)))
{
- public CSharpRemoveUnnecessaryNullableDirectiveDiagnosticAnalyzer()
- : base(IDEDiagnosticIds.RemoveUnnecessaryNullableDirectiveDiagnosticId,
- EnforceOnBuildValues.RemoveUnnecessaryNullableDirective,
- option: null,
- fadingOption: null,
- new LocalizableResourceString(nameof(CSharpAnalyzersResources.Remove_unnecessary_nullable_directive), CSharpAnalyzersResources.ResourceManager, typeof(CSharpAnalyzersResources)),
- new LocalizableResourceString(nameof(CSharpAnalyzersResources.Nullable_directive_is_unnecessary), CSharpAnalyzersResources.ResourceManager, typeof(CSharpAnalyzersResources)))
- {
- }
-
public override DiagnosticAnalyzerCategory GetAnalyzerCategory()
=> DiagnosticAnalyzerCategory.SemanticDocumentAnalysis;
protected override void InitializeWorker(AnalysisContext context)
- {
- context.RegisterCompilationStartAction(AnalyzeCompilation);
- }
+ => context.RegisterCompilationStartAction(AnalyzeCompilation);
private void AnalyzeCompilation(CompilationStartAnalysisContext context)
{
diff --git a/src/Analyzers/CSharp/Analyzers/RemoveUnnecessaryNullableDirective/NullableImpactingSpanWalker.cs b/src/Analyzers/CSharp/Analyzers/RemoveUnnecessaryNullableDirective/NullableImpactingSpanWalker.cs
index 38622e35bf702..372636faed961 100644
--- a/src/Analyzers/CSharp/Analyzers/RemoveUnnecessaryNullableDirective/NullableImpactingSpanWalker.cs
+++ b/src/Analyzers/CSharp/Analyzers/RemoveUnnecessaryNullableDirective/NullableImpactingSpanWalker.cs
@@ -97,6 +97,10 @@ private static bool IsLanguageRestrictedToNonNullForm(TypeSyntax node)
return true;
}
+ // An attribute name cannot itself be nullable. `[CLSCompliant?]` is not a thing.
+ if (node.IsParentKind(SyntaxKind.Attribute))
+ return true;
+
return false;
// If this is Y in X.Y, walk up to X.Y
diff --git a/src/Analyzers/CSharp/Analyzers/RemoveUnreachableCode/CSharpRemoveUnreachableCodeDiagnosticAnalyzer.cs b/src/Analyzers/CSharp/Analyzers/RemoveUnreachableCode/CSharpRemoveUnreachableCodeDiagnosticAnalyzer.cs
index 85512b65664f8..2b5b01f7f4dcc 100644
--- a/src/Analyzers/CSharp/Analyzers/RemoveUnreachableCode/CSharpRemoveUnreachableCodeDiagnosticAnalyzer.cs
+++ b/src/Analyzers/CSharp/Analyzers/RemoveUnreachableCode/CSharpRemoveUnreachableCodeDiagnosticAnalyzer.cs
@@ -9,7 +9,6 @@
using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.CodeAnalysis.Text;
using Microsoft.CodeAnalysis.Utilities;
-using Roslyn.Utilities;
namespace Microsoft.CodeAnalysis.CSharp.RemoveUnreachableCode;
diff --git a/src/Analyzers/CSharp/Analyzers/UseCollectionExpression/AbstractCSharpUseCollectionExpressionDiagnosticAnalyzer.cs b/src/Analyzers/CSharp/Analyzers/UseCollectionExpression/AbstractCSharpUseCollectionExpressionDiagnosticAnalyzer.cs
index b1daeecb8190a..47b500b4a4c8b 100644
--- a/src/Analyzers/CSharp/Analyzers/UseCollectionExpression/AbstractCSharpUseCollectionExpressionDiagnosticAnalyzer.cs
+++ b/src/Analyzers/CSharp/Analyzers/UseCollectionExpression/AbstractCSharpUseCollectionExpressionDiagnosticAnalyzer.cs
@@ -7,7 +7,6 @@
using Microsoft.CodeAnalysis.CSharp.Extensions;
using Microsoft.CodeAnalysis.CSharp.Shared.Extensions;
using Microsoft.CodeAnalysis.Diagnostics;
-using Microsoft.CodeAnalysis.Shared.Extensions;
using Microsoft.CodeAnalysis.UseCollectionInitializer;
namespace Microsoft.CodeAnalysis.CSharp.UseCollectionExpression;
diff --git a/src/Analyzers/CSharp/Analyzers/UseCollectionExpression/CSharpUseCollectionExpressionForBuilderDiagnosticAnalyzer.cs b/src/Analyzers/CSharp/Analyzers/UseCollectionExpression/CSharpUseCollectionExpressionForBuilderDiagnosticAnalyzer.cs
index 7406d96480af4..3f0c11bdaacc0 100644
--- a/src/Analyzers/CSharp/Analyzers/UseCollectionExpression/CSharpUseCollectionExpressionForBuilderDiagnosticAnalyzer.cs
+++ b/src/Analyzers/CSharp/Analyzers/UseCollectionExpression/CSharpUseCollectionExpressionForBuilderDiagnosticAnalyzer.cs
@@ -27,7 +27,7 @@ internal sealed partial class CSharpUseCollectionExpressionForBuilderDiagnosticA
EnforceOnBuildValues.UseCollectionExpressionForBuilder)
{
private const string CreateBuilderName = nameof(ImmutableArray.CreateBuilder);
- private const string GetInstanceName = nameof(ArrayBuilder.GetInstance);
+ private const string GetInstanceName = nameof(ArrayBuilder<>.GetInstance);
protected override void InitializeWorker(CodeBlockStartAnalysisContext context, INamedTypeSymbol? expressionType)
=> context.RegisterSyntaxNodeAction(context => AnalyzeInvocationExpression(context, expressionType), SyntaxKind.InvocationExpression);
@@ -117,7 +117,7 @@ void FadeOutCode(SyntaxNodeAnalysisContext context, AnalysisResult analysisResul
return null;
if (memberAccessExpression.Name.Identifier.ValueText == GetInstanceName &&
- memberAccessExpression.Expression is not GenericNameSyntax { Identifier.ValueText: nameof(ArrayBuilder) })
+ memberAccessExpression.Expression is not GenericNameSyntax { Identifier.ValueText: nameof(ArrayBuilder<>) })
{
return null;
}
@@ -217,12 +217,12 @@ identifierName.Parent is MemberAccessExpressionSyntax(SyntaxKind.SimpleMemberAcc
memberAccess.Expression == identifierName &&
memberAccess.Parent is InvocationExpressionSyntax { ArgumentList.Arguments.Count: 0 } invocationExpression &&
memberAccess.Name.Identifier.ValueText
- is nameof(ImmutableArray.Builder.ToImmutable)
- or nameof(ImmutableArray.Builder.MoveToImmutable)
- or nameof(ImmutableArray.Builder.ToArray)
- or nameof(ArrayBuilder.ToImmutableAndClear)
- or nameof(ArrayBuilder.ToImmutableAndFree)
- or nameof(ArrayBuilder.ToArrayAndFree)
+ is nameof(ImmutableArray<>.Builder.ToImmutable)
+ or nameof(ImmutableArray<>.Builder.MoveToImmutable)
+ or nameof(ImmutableArray<>.Builder.ToArray)
+ or nameof(ArrayBuilder<>.ToImmutableAndClear)
+ or nameof(ArrayBuilder<>.ToImmutableAndFree)
+ or nameof(ArrayBuilder<>.ToArrayAndFree)
or nameof(Enumerable.ToList))
{
return invocationExpression;
diff --git a/src/Analyzers/CSharp/Analyzers/UseCollectionExpression/CSharpUseCollectionExpressionForFluentDiagnosticAnalyzer.cs b/src/Analyzers/CSharp/Analyzers/UseCollectionExpression/CSharpUseCollectionExpressionForFluentDiagnosticAnalyzer.cs
index db35d9137dbb4..c2d735d8cf6a9 100644
--- a/src/Analyzers/CSharp/Analyzers/UseCollectionExpression/CSharpUseCollectionExpressionForFluentDiagnosticAnalyzer.cs
+++ b/src/Analyzers/CSharp/Analyzers/UseCollectionExpression/CSharpUseCollectionExpressionForFluentDiagnosticAnalyzer.cs
@@ -13,7 +13,6 @@
using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.CodeAnalysis.PooledObjects;
using Microsoft.CodeAnalysis.Shared.CodeStyle;
-using Microsoft.CodeAnalysis.Shared.Extensions;
using Microsoft.CodeAnalysis.Text;
using Microsoft.CodeAnalysis.UseCollectionExpression;
using Microsoft.CodeAnalysis.UseCollectionInitializer;
@@ -21,8 +20,8 @@
namespace Microsoft.CodeAnalysis.CSharp.UseCollectionExpression;
-using static UseCollectionExpressionHelpers;
using static SyntaxFactory;
+using static UseCollectionExpressionHelpers;
using FluentState = UpdateExpressionState;
[DiagnosticAnalyzer(LanguageNames.CSharp)]
@@ -42,24 +41,24 @@ internal sealed partial class CSharpUseCollectionExpressionForFluentDiagnosticAn
private static readonly ImmutableArray s_suffixes =
[
nameof(Array),
- nameof(Span),
- nameof(ReadOnlySpan),
- nameof(System.Collections.Generic.List),
- nameof(HashSet),
- nameof(LinkedList),
- nameof(Queue),
- nameof(SortedSet),
- nameof(Stack),
- nameof(ICollection),
- nameof(IReadOnlyCollection),
- nameof(IList),
- nameof(IReadOnlyList),
- nameof(ImmutableArray),
- nameof(ImmutableHashSet),
- nameof(ImmutableList),
- nameof(ImmutableQueue),
- nameof(ImmutableSortedSet),
- nameof(ImmutableStack),
+ nameof(Span<>),
+ nameof(ReadOnlySpan<>),
+ nameof(System.Collections.Generic.List<>),
+ nameof(HashSet<>),
+ nameof(LinkedList<>),
+ nameof(Queue<>),
+ nameof(SortedSet<>),
+ nameof(Stack<>),
+ nameof(ICollection<>),
+ nameof(IReadOnlyCollection<>),
+ nameof(IList<>),
+ nameof(IReadOnlyList<>),
+ nameof(ImmutableArray<>),
+ nameof(ImmutableHashSet<>),
+ nameof(ImmutableList<>),
+ nameof(ImmutableQueue<>),
+ nameof(ImmutableSortedSet<>),
+ nameof(ImmutableStack<>),
nameof(System.Collections.Immutable),
];
diff --git a/src/Analyzers/CSharp/Analyzers/UseCollectionExpression/CSharpUseCollectionExpressionForNewDiagnosticAnalyzer.cs b/src/Analyzers/CSharp/Analyzers/UseCollectionExpression/CSharpUseCollectionExpressionForNewDiagnosticAnalyzer.cs
index 24db63134a0ba..cd9f1f005d860 100644
--- a/src/Analyzers/CSharp/Analyzers/UseCollectionExpression/CSharpUseCollectionExpressionForNewDiagnosticAnalyzer.cs
+++ b/src/Analyzers/CSharp/Analyzers/UseCollectionExpression/CSharpUseCollectionExpressionForNewDiagnosticAnalyzer.cs
@@ -53,7 +53,7 @@ private void AnalyzeBaseObjectCreationExpression(
var symbol = semanticModel.GetSymbolInfo(objectCreationExpression, cancellationToken).Symbol;
if (symbol is not IMethodSymbol { MethodKind: MethodKind.Constructor, Parameters: [var constructorParameter] } ||
- constructorParameter.Type.Name != nameof(IEnumerable))
+ constructorParameter.Type.Name != nameof(IEnumerable<>))
{
return;
}
diff --git a/src/Analyzers/CSharp/Analyzers/UseCollectionExpression/UseCollectionExpressionHelpers.cs b/src/Analyzers/CSharp/Analyzers/UseCollectionExpression/UseCollectionExpressionHelpers.cs
index 3ad3e5986aad9..4a6ff87c46508 100644
--- a/src/Analyzers/CSharp/Analyzers/UseCollectionExpression/UseCollectionExpressionHelpers.cs
+++ b/src/Analyzers/CSharp/Analyzers/UseCollectionExpression/UseCollectionExpressionHelpers.cs
@@ -193,11 +193,11 @@ bool IsSafeConversionWhenTypesDoNotMatch(out bool changesSemantics)
var convertedType = originalTypeInfo.ConvertedType;
var convertedToReadOnlySpan =
- convertedType.Name == nameof(ReadOnlySpan) &&
+ convertedType.Name == nameof(ReadOnlySpan<>) &&
convertedType.OriginalDefinition.Equals(compilation.ReadOnlySpanOfTType());
var convertedToSpan =
- convertedType.Name == nameof(Span) &&
+ convertedType.Name == nameof(Span<>) &&
convertedType.OriginalDefinition.Equals(compilation.SpanOfTType());
// ReadOnlySpan x = stackalloc[] ...
@@ -206,7 +206,7 @@ bool IsSafeConversionWhenTypesDoNotMatch(out bool changesSemantics)
// restrictive than Span
var isSpanToReadOnlySpan =
convertedToReadOnlySpan &&
- type.Name == nameof(Span) &&
+ type.Name == nameof(Span<>) &&
type.OriginalDefinition.Equals(compilation.SpanOfTType()) &&
convertedType.GetTypeArguments()[0].Equals(type.GetTypeArguments()[0]);
if (isSpanToReadOnlySpan)
@@ -264,7 +264,7 @@ bool IsSafeConversionWhenTypesDoNotMatch(out bool changesSemantics)
// disallow converting those types to ensure semantics are preserved. We do this even though
// allowSemanticsChange is true because this will basically be certain to break semantics, as opposed to
// the more common case where semantics may change slightly, but likely not in a way that breaks code.
- if (type.Name is nameof(ObservableCollection) or nameof(ReadOnlyObservableCollection))
+ if (type.Name is nameof(ObservableCollection<>) or nameof(ReadOnlyObservableCollection<>))
return false;
// If the original expression was creating a set, but is being assigned to one of the well known
@@ -933,7 +933,7 @@ bool IsCompatibleSignatureAndArguments(
{
Type: INamedTypeSymbol
{
- Name: nameof(IEnumerable),
+ Name: nameof(IEnumerable<>),
TypeArguments: [ITypeParameterSymbol { TypeParameterKind: TypeParameterKind.Method }]
} enumerableType
}] &&
@@ -980,7 +980,7 @@ originalCreateMethod.Parameters is [
{
Type: INamedTypeSymbol
{
- Name: nameof(Span) or nameof(ReadOnlySpan),
+ Name: nameof(Span<>) or nameof(ReadOnlySpan<>),
TypeArguments: [ITypeParameterSymbol { TypeParameterKind: TypeParameterKind.Method }]
} spanType
}])
diff --git a/src/Analyzers/CSharp/Analyzers/UseCollectionInitializer/CSharpUseCollectionInitializerAnalyzer.cs b/src/Analyzers/CSharp/Analyzers/UseCollectionInitializer/CSharpUseCollectionInitializerAnalyzer.cs
index 6a93604eb7369..4e3f515b70bde 100644
--- a/src/Analyzers/CSharp/Analyzers/UseCollectionInitializer/CSharpUseCollectionInitializerAnalyzer.cs
+++ b/src/Analyzers/CSharp/Analyzers/UseCollectionInitializer/CSharpUseCollectionInitializerAnalyzer.cs
@@ -205,11 +205,20 @@ bool CanSpreadFirstParameter(INamedTypeSymbol constructedType, IParameterSymbol
var compilation = this.SemanticModel.Compilation;
var ienumerableOfTType = compilation.IEnumerableOfTType();
- if (!Equals(firstParameter.Type.OriginalDefinition, ienumerableOfTType) &&
- !firstParameter.Type.AllInterfaces.Any(i => Equals(i.OriginalDefinition, ienumerableOfTType)))
- {
+ var implementedInterface = firstParameter.Type
+ .GetAllInterfacesIncludingThis()
+ .FirstOrDefault(i => Equals(i.OriginalDefinition, ienumerableOfTType));
+
+ var elementType = implementedInterface?.GetTypeArguments().SingleOrDefault();
+ if (elementType is null)
+ return false;
+
+ // Ok, the constructor takes some `IEnumerable` type. If it also has an `Add(X)` method, then we
+ // can take those constructor arguments and pass them along to the final collection by spreading them.
+ // If not, then we can't convert this to a collection expression.
+ var addMethods = this.GetAddMethods(cancellationToken);
+ if (!addMethods.Any(m => m.Parameters is [{ Type: var parameterType }] && Equals(parameterType, elementType)))
return false;
- }
// Looks like something passed to the constructor call that we could potentially spread instead. e.g. `new
// HashSet(someList)` can become `[.. someList]`. However, check for certain cases we know where this is
diff --git a/src/Analyzers/CSharp/Analyzers/UseExpressionBody/Helpers/UseExpressionBodyHelper.cs b/src/Analyzers/CSharp/Analyzers/UseExpressionBody/Helpers/UseExpressionBodyHelper.cs
index b1b692a21fb52..8ccc6d381a4ac 100644
--- a/src/Analyzers/CSharp/Analyzers/UseExpressionBody/Helpers/UseExpressionBodyHelper.cs
+++ b/src/Analyzers/CSharp/Analyzers/UseExpressionBody/Helpers/UseExpressionBodyHelper.cs
@@ -3,12 +3,12 @@
// See the LICENSE file in the project root for more information.
using System.Collections.Immutable;
-using Microsoft.CodeAnalysis.CodeStyle;
-using Microsoft.CodeAnalysis.Options;
-using Microsoft.CodeAnalysis.CSharp.Syntax;
using System.Diagnostics.CodeAnalysis;
-using Microsoft.CodeAnalysis.CSharp.CodeGeneration;
using System.Threading;
+using Microsoft.CodeAnalysis.CodeStyle;
+using Microsoft.CodeAnalysis.CSharp.CodeGeneration;
+using Microsoft.CodeAnalysis.CSharp.Syntax;
+using Microsoft.CodeAnalysis.Options;
namespace Microsoft.CodeAnalysis.CSharp.UseExpressionBody;
diff --git a/src/Analyzers/CSharp/Analyzers/UseImplicitObjectCreation/CSharpUseImplicitObjectCreationDiagnosticAnalyzer.cs b/src/Analyzers/CSharp/Analyzers/UseImplicitObjectCreation/CSharpUseImplicitObjectCreationDiagnosticAnalyzer.cs
index d452e58779d16..4e4f1ae0a87db 100644
--- a/src/Analyzers/CSharp/Analyzers/UseImplicitObjectCreation/CSharpUseImplicitObjectCreationDiagnosticAnalyzer.cs
+++ b/src/Analyzers/CSharp/Analyzers/UseImplicitObjectCreation/CSharpUseImplicitObjectCreationDiagnosticAnalyzer.cs
@@ -16,17 +16,14 @@
namespace Microsoft.CodeAnalysis.CSharp.UseImplicitObjectCreation;
[DiagnosticAnalyzer(LanguageNames.CSharp)]
-internal sealed class CSharpUseImplicitObjectCreationDiagnosticAnalyzer : AbstractBuiltInCodeStyleDiagnosticAnalyzer
+internal sealed class CSharpUseImplicitObjectCreationDiagnosticAnalyzer()
+ : AbstractBuiltInCodeStyleDiagnosticAnalyzer(
+ IDEDiagnosticIds.UseImplicitObjectCreationDiagnosticId,
+ EnforceOnBuildValues.UseImplicitObjectCreation,
+ CSharpCodeStyleOptions.ImplicitObjectCreationWhenTypeIsApparent,
+ new LocalizableResourceString(nameof(CSharpAnalyzersResources.Use_new), CSharpAnalyzersResources.ResourceManager, typeof(CSharpAnalyzersResources)),
+ new LocalizableResourceString(nameof(CSharpAnalyzersResources.new_expression_can_be_simplified), CSharpAnalyzersResources.ResourceManager, typeof(CSharpAnalyzersResources)))
{
- public CSharpUseImplicitObjectCreationDiagnosticAnalyzer()
- : base(IDEDiagnosticIds.UseImplicitObjectCreationDiagnosticId,
- EnforceOnBuildValues.UseImplicitObjectCreation,
- CSharpCodeStyleOptions.ImplicitObjectCreationWhenTypeIsApparent,
- new LocalizableResourceString(nameof(CSharpAnalyzersResources.Use_new), CSharpAnalyzersResources.ResourceManager, typeof(CSharpAnalyzersResources)),
- new LocalizableResourceString(nameof(CSharpAnalyzersResources.new_expression_can_be_simplified), CSharpAnalyzersResources.ResourceManager, typeof(CSharpAnalyzersResources)))
- {
- }
-
public override DiagnosticAnalyzerCategory GetAnalyzerCategory()
=> DiagnosticAnalyzerCategory.SemanticSpanAnalysis;
@@ -56,7 +53,10 @@ private void AnalyzeSyntax(SyntaxNodeAnalysisContext context)
context.ReportDiagnostic(DiagnosticHelper.Create(
Descriptor,
- objectCreation.Type.GetLocation(),
+ // Place the suggestion on the 'new' keyword. This is both the earliest part of the object creation
+ // expression, and it also matches the location we place the 'use collection expression' analyzer,
+ // ensuring consistency between the two analyzers.
+ objectCreation.NewKeyword.GetLocation(),
styleOption.Notification,
context.Options,
[objectCreation.GetLocation()],
diff --git a/src/Analyzers/CSharp/Analyzers/UseIndexOrRangeOperator/CSharpUseRangeOperatorDiagnosticAnalyzer.InfoCache.cs b/src/Analyzers/CSharp/Analyzers/UseIndexOrRangeOperator/CSharpUseRangeOperatorDiagnosticAnalyzer.InfoCache.cs
index 26ea15936fa4a..dee9c249b8a93 100644
--- a/src/Analyzers/CSharp/Analyzers/UseIndexOrRangeOperator/CSharpUseRangeOperatorDiagnosticAnalyzer.InfoCache.cs
+++ b/src/Analyzers/CSharp/Analyzers/UseIndexOrRangeOperator/CSharpUseRangeOperatorDiagnosticAnalyzer.InfoCache.cs
@@ -158,7 +158,7 @@ private MemberInfo ComputeMemberInfo(IMethodSymbol sliceLikeMethod, bool require
// Also, look to see if the type has a `.Slice(int start, int length)` method.
// This is also a method the compiler knows to look for when a user writes `x[a..b]`
var actualSliceMethod =
- sliceLikeMethod.ContainingType.GetMembers(nameof(Span.Slice))
+ sliceLikeMethod.ContainingType.GetMembers(nameof(Span<>.Slice))
.OfType()
.FirstOrDefault(s => IsTwoArgumentSliceLikeMethod(s));
if (actualSliceMethod != null)
diff --git a/src/Analyzers/CSharp/Analyzers/UseIndexOrRangeOperator/CSharpUseRangeOperatorDiagnosticAnalyzer.cs b/src/Analyzers/CSharp/Analyzers/UseIndexOrRangeOperator/CSharpUseRangeOperatorDiagnosticAnalyzer.cs
index f6bfbb9944301..c8d7838f53517 100644
--- a/src/Analyzers/CSharp/Analyzers/UseIndexOrRangeOperator/CSharpUseRangeOperatorDiagnosticAnalyzer.cs
+++ b/src/Analyzers/CSharp/Analyzers/UseIndexOrRangeOperator/CSharpUseRangeOperatorDiagnosticAnalyzer.cs
@@ -311,8 +311,6 @@ private Diagnostic CreateDiagnostic(Result result, NotificationOption2 notificat
{
// Keep track of the invocation node
var invocation = result.Invocation;
- var additionalLocations = ImmutableArray.Create(
- invocation.GetLocation());
// Mark the span under the two arguments to .Slice(..., ...) as what we will be
// updating.
@@ -325,7 +323,7 @@ private Diagnostic CreateDiagnostic(Result result, NotificationOption2 notificat
location,
notificationOption,
analyzerOptions,
- additionalLocations,
+ [invocation.GetLocation()],
ImmutableDictionary.Empty,
result.SliceLikeMethod.Name);
}
diff --git a/src/Analyzers/CSharp/Analyzers/UseNullPropagation/CSharpUseNullPropagationDiagnosticAnalyzer.cs b/src/Analyzers/CSharp/Analyzers/UseNullPropagation/CSharpUseNullPropagationDiagnosticAnalyzer.cs
index 368a8df73ab1e..32ead852438b1 100644
--- a/src/Analyzers/CSharp/Analyzers/UseNullPropagation/CSharpUseNullPropagationDiagnosticAnalyzer.cs
+++ b/src/Analyzers/CSharp/Analyzers/UseNullPropagation/CSharpUseNullPropagationDiagnosticAnalyzer.cs
@@ -2,6 +2,7 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
+using System.Collections.Immutable;
using System.Diagnostics.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp.Extensions;
using Microsoft.CodeAnalysis.CSharp.Syntax;
@@ -26,6 +27,8 @@ internal sealed class CSharpUseNullPropagationDiagnosticAnalyzer :
IfStatementSyntax,
ExpressionStatementSyntax>
{
+ public static readonly CSharpUseNullPropagationDiagnosticAnalyzer Instance = new();
+
protected override SyntaxKind IfStatementSyntaxKind
=> SyntaxKind.IfStatement;
@@ -65,7 +68,7 @@ protected override bool TryAnalyzePatternCondition(
protected override bool TryGetPartsOfIfStatement(
IfStatementSyntax ifStatement,
[NotNullWhen(true)] out ExpressionSyntax? condition,
- [NotNullWhen(true)] out StatementSyntax? trueStatement)
+ out ImmutableArray trueStatements)
{
// has to be of the form:
//
@@ -78,23 +81,25 @@ protected override bool TryGetPartsOfIfStatement(
// {
// statement
// }
+ //
+ // or
+ //
+ // if (...)
+ // {
+ // statement
+ // val = null;
+ // }
condition = ifStatement.Condition;
- trueStatement = null;
+ trueStatements = [];
if (ifStatement.Else == null)
{
- if (ifStatement.Statement is BlockSyntax block)
- {
- if (block.Statements.Count == 1)
- trueStatement = block.Statements[0];
- }
- else
- {
- trueStatement = ifStatement.Statement;
- }
+ trueStatements = ifStatement.Statement is BlockSyntax block
+ ? [.. block.Statements]
+ : [ifStatement.Statement];
}
- return trueStatement != null;
+ return true;
}
}
diff --git a/src/Analyzers/CSharp/Analyzers/UsePatternCombinators/CSharpUsePatternCombinatorsAnalyzer.cs b/src/Analyzers/CSharp/Analyzers/UsePatternCombinators/CSharpUsePatternCombinatorsAnalyzer.cs
index 553259e2d5568..11e32dcd6bb00 100644
--- a/src/Analyzers/CSharp/Analyzers/UsePatternCombinators/CSharpUsePatternCombinatorsAnalyzer.cs
+++ b/src/Analyzers/CSharp/Analyzers/UsePatternCombinators/CSharpUsePatternCombinatorsAnalyzer.cs
@@ -7,8 +7,8 @@
namespace Microsoft.CodeAnalysis.CSharp.UsePatternCombinators;
-using static BinaryOperatorKind;
using static AnalyzedPattern;
+using static BinaryOperatorKind;
internal static class CSharpUsePatternCombinatorsAnalyzer
{
diff --git a/src/Analyzers/CSharp/Analyzers/UsePatternCombinators/CSharpUsePatternCombinatorsDiagnosticAnalyzer.cs b/src/Analyzers/CSharp/Analyzers/UsePatternCombinators/CSharpUsePatternCombinatorsDiagnosticAnalyzer.cs
index 0f71c68e633be..4e08c3d57ddbf 100644
--- a/src/Analyzers/CSharp/Analyzers/UsePatternCombinators/CSharpUsePatternCombinatorsDiagnosticAnalyzer.cs
+++ b/src/Analyzers/CSharp/Analyzers/UsePatternCombinators/CSharpUsePatternCombinatorsDiagnosticAnalyzer.cs
@@ -9,7 +9,6 @@
using Microsoft.CodeAnalysis.CSharp.Extensions;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.Diagnostics;
-using Microsoft.CodeAnalysis.Shared.Extensions;
namespace Microsoft.CodeAnalysis.CSharp.UsePatternCombinators;
diff --git a/src/Analyzers/CSharp/Analyzers/UseSimpleUsingStatement/UseSimpleUsingStatementDiagnosticAnalyzer.cs b/src/Analyzers/CSharp/Analyzers/UseSimpleUsingStatement/UseSimpleUsingStatementDiagnosticAnalyzer.cs
index b560a039097c2..057d50af3bf47 100644
--- a/src/Analyzers/CSharp/Analyzers/UseSimpleUsingStatement/UseSimpleUsingStatementDiagnosticAnalyzer.cs
+++ b/src/Analyzers/CSharp/Analyzers/UseSimpleUsingStatement/UseSimpleUsingStatementDiagnosticAnalyzer.cs
@@ -4,6 +4,7 @@
using System.Collections.Generic;
using System.Collections.Immutable;
+using System.Linq;
using System.Threading;
using Microsoft.CodeAnalysis.CodeStyle;
using Microsoft.CodeAnalysis.CSharp.CodeStyle;
diff --git a/src/Analyzers/CSharp/Analyzers/UseSystemThreadingLock/CSharpUseSystemThreadingLockDiagnosticAnalyzer.cs b/src/Analyzers/CSharp/Analyzers/UseSystemThreadingLock/CSharpUseSystemThreadingLockDiagnosticAnalyzer.cs
index 3f750b3e7483f..2f7f930d6186a 100644
--- a/src/Analyzers/CSharp/Analyzers/UseSystemThreadingLock/CSharpUseSystemThreadingLockDiagnosticAnalyzer.cs
+++ b/src/Analyzers/CSharp/Analyzers/UseSystemThreadingLock/CSharpUseSystemThreadingLockDiagnosticAnalyzer.cs
@@ -2,6 +2,7 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
+using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using Microsoft.CodeAnalysis.CodeStyle;
@@ -13,7 +14,6 @@
using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.CodeAnalysis.Operations;
using Microsoft.CodeAnalysis.Shared.Collections;
-using Microsoft.CodeAnalysis.Shared.Extensions;
using Roslyn.Utilities;
namespace Microsoft.CodeAnalysis.CSharp.UseSystemThreadingLock;
diff --git a/src/Analyzers/CSharp/Analyzers/UseUtf8StringLiteral/UseUtf8StringLiteralDiagnosticAnalyzer.cs b/src/Analyzers/CSharp/Analyzers/UseUtf8StringLiteral/UseUtf8StringLiteralDiagnosticAnalyzer.cs
index 18076827975d7..2e869ed4b452a 100644
--- a/src/Analyzers/CSharp/Analyzers/UseUtf8StringLiteral/UseUtf8StringLiteralDiagnosticAnalyzer.cs
+++ b/src/Analyzers/CSharp/Analyzers/UseUtf8StringLiteral/UseUtf8StringLiteralDiagnosticAnalyzer.cs
@@ -16,7 +16,6 @@
using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.CodeAnalysis.Operations;
using Microsoft.CodeAnalysis.Shared.Collections;
-using Microsoft.CodeAnalysis.Shared.Extensions;
using Microsoft.CodeAnalysis.Text;
using Roslyn.Utilities;
diff --git a/src/Analyzers/CSharp/CodeFixes/AddInheritdoc/AddInheritdocCodeFixProvider.cs b/src/Analyzers/CSharp/CodeFixes/AddInheritdoc/AddInheritdocCodeFixProvider.cs
index 465f33a6f4f84..06e7c4d91c353 100644
--- a/src/Analyzers/CSharp/CodeFixes/AddInheritdoc/AddInheritdocCodeFixProvider.cs
+++ b/src/Analyzers/CSharp/CodeFixes/AddInheritdoc/AddInheritdocCodeFixProvider.cs
@@ -9,12 +9,12 @@
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.CodeFixes;
+using Microsoft.CodeAnalysis.CSharp.Extensions;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.Editing;
using Microsoft.CodeAnalysis.Formatting;
using Microsoft.CodeAnalysis.Host.Mef;
using Microsoft.CodeAnalysis.Shared.Extensions;
-using Microsoft.CodeAnalysis.CSharp.Extensions;
namespace Microsoft.CodeAnalysis.CSharp.CodeFixes.AddInheritdoc;
diff --git a/src/Analyzers/CSharp/CodeFixes/ConditionalExpressionInStringInterpolation/CSharpAddParenthesesAroundConditionalExpressionInInterpolatedStringCodeFixProvider.cs b/src/Analyzers/CSharp/CodeFixes/ConditionalExpressionInStringInterpolation/CSharpAddParenthesesAroundConditionalExpressionInInterpolatedStringCodeFixProvider.cs
index 61aee9bcc433a..9f1bd6ce979ed 100644
--- a/src/Analyzers/CSharp/CodeFixes/ConditionalExpressionInStringInterpolation/CSharpAddParenthesesAroundConditionalExpressionInInterpolatedStringCodeFixProvider.cs
+++ b/src/Analyzers/CSharp/CodeFixes/ConditionalExpressionInStringInterpolation/CSharpAddParenthesesAroundConditionalExpressionInInterpolatedStringCodeFixProvider.cs
@@ -13,7 +13,6 @@
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.Shared.Extensions;
using Microsoft.CodeAnalysis.Text;
-using Roslyn.Utilities;
namespace Microsoft.CodeAnalysis.CSharp.ConditionalExpressionInStringInterpolation;
diff --git a/src/Analyzers/CSharp/CodeFixes/ConvertNamespace/ConvertNamespaceCodeFixProvider.cs b/src/Analyzers/CSharp/CodeFixes/ConvertNamespace/ConvertNamespaceCodeFixProvider.cs
index 7bcd0962149a7..f37a7574042de 100644
--- a/src/Analyzers/CSharp/CodeFixes/ConvertNamespace/ConvertNamespaceCodeFixProvider.cs
+++ b/src/Analyzers/CSharp/CodeFixes/ConvertNamespace/ConvertNamespaceCodeFixProvider.cs
@@ -17,7 +17,6 @@
using Microsoft.CodeAnalysis.Editing;
using Microsoft.CodeAnalysis.Host.Mef;
using Microsoft.CodeAnalysis.Shared.Extensions;
-using Roslyn.Utilities;
namespace Microsoft.CodeAnalysis.CSharp.ConvertNamespace;
diff --git a/src/Analyzers/CSharp/CodeFixes/ConvertSwitchStatementToExpression/ConvertSwitchStatementToExpressionCodeFixProvider.cs b/src/Analyzers/CSharp/CodeFixes/ConvertSwitchStatementToExpression/ConvertSwitchStatementToExpressionCodeFixProvider.cs
index 752bc049b3622..d68ba05e14247 100644
--- a/src/Analyzers/CSharp/CodeFixes/ConvertSwitchStatementToExpression/ConvertSwitchStatementToExpressionCodeFixProvider.cs
+++ b/src/Analyzers/CSharp/CodeFixes/ConvertSwitchStatementToExpression/ConvertSwitchStatementToExpressionCodeFixProvider.cs
@@ -19,7 +19,6 @@
using Microsoft.CodeAnalysis.PooledObjects;
using Microsoft.CodeAnalysis.Shared.Extensions;
using Microsoft.CodeAnalysis.Text;
-using Roslyn.Utilities;
namespace Microsoft.CodeAnalysis.CSharp.ConvertSwitchStatementToExpression;
diff --git a/src/Analyzers/CSharp/CodeFixes/GenerateParameterizedMember/CSharpGenerateParameterizedMemberService.cs b/src/Analyzers/CSharp/CodeFixes/GenerateParameterizedMember/CSharpGenerateParameterizedMemberService.cs
index 0ffa1eca11bc4..ad0ecf70a3b22 100644
--- a/src/Analyzers/CSharp/CodeFixes/GenerateParameterizedMember/CSharpGenerateParameterizedMemberService.cs
+++ b/src/Analyzers/CSharp/CodeFixes/GenerateParameterizedMember/CSharpGenerateParameterizedMemberService.cs
@@ -3,7 +3,6 @@
// See the LICENSE file in the project root for more information.
using System;
-using System.Collections.Generic;
using System.Collections.Immutable;
using System.Linq;
using System.Threading;
diff --git a/src/Analyzers/CSharp/CodeFixes/HideBase/HideBaseCodeFixProvider.AddNewKeywordAction.cs b/src/Analyzers/CSharp/CodeFixes/HideBase/HideBaseCodeFixProvider.AddNewKeywordAction.cs
index 566daa3dd5da9..097323ff0681d 100644
--- a/src/Analyzers/CSharp/CodeFixes/HideBase/HideBaseCodeFixProvider.AddNewKeywordAction.cs
+++ b/src/Analyzers/CSharp/CodeFixes/HideBase/HideBaseCodeFixProvider.AddNewKeywordAction.cs
@@ -2,17 +2,16 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
+using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
-using Microsoft.CodeAnalysis.CodeActions;
using Microsoft.CodeAnalysis.CSharp.CodeStyle;
using Microsoft.CodeAnalysis.CSharp.LanguageService;
using Microsoft.CodeAnalysis.CSharp.OrderModifiers;
using Microsoft.CodeAnalysis.Options;
using Microsoft.CodeAnalysis.OrderModifiers;
using Microsoft.CodeAnalysis.Shared.Extensions;
-using Roslyn.Utilities;
namespace Microsoft.CodeAnalysis.CSharp.CodeFixes.HideBase;
@@ -20,46 +19,36 @@ namespace Microsoft.CodeAnalysis.CSharp.CodeFixes.HideBase;
internal sealed partial class HideBaseCodeFixProvider
{
- private sealed class AddNewKeywordAction(Document document, SyntaxNode node) : CodeAction
+ private static async Task GetChangedDocumentAsync(
+ Document document, SyntaxNode node, CancellationToken cancellationToken)
{
- private readonly Document _document = document;
- private readonly SyntaxNode _node = node;
+ var root = await document.GetRequiredSyntaxRootAsync(cancellationToken).ConfigureAwait(false);
+ var modifierOrder = await GetModifierOrderAsync(document, cancellationToken).ConfigureAwait(false);
- public override string Title => CSharpCodeFixesResources.Hide_base_member;
-
- protected override async Task GetChangedDocumentAsync(CancellationToken cancellationToken)
- {
- var root = await _document.GetRequiredSyntaxRootAsync(cancellationToken).ConfigureAwait(false);
- var configOptions = await _document.GetHostAnalyzerConfigOptionsAsync(cancellationToken).ConfigureAwait(false);
-
- var newNode = GetNewNode(_node, configOptions.GetOption(CSharpCodeStyleOptions.PreferredModifierOrder).Value);
- var newRoot = root.ReplaceNode(_node, newNode);
+ return document.WithSyntaxRoot(root.ReplaceNode(node, GetNewNode(node, modifierOrder)));
+ }
- return _document.WithSyntaxRoot(newRoot);
- }
+ private static SyntaxNode GetNewNode(SyntaxNode node, Dictionary? preferredOrder)
+ {
+ var syntaxFacts = CSharpSyntaxFacts.Instance;
+ var modifiers = syntaxFacts.GetModifiers(node);
+ var newModifiers = modifiers.Add(NewKeyword);
- private static SyntaxNode GetNewNode(SyntaxNode node, string preferredModifierOrder)
+ if (preferredOrder is null ||
+ !AbstractOrderModifiersHelpers.IsOrdered(preferredOrder, modifiers))
{
- var syntaxFacts = CSharpSyntaxFacts.Instance;
- var modifiers = syntaxFacts.GetModifiers(node);
- var newModifiers = modifiers.Add(NewKeyword);
-
- if (!CSharpOrderModifiersHelper.Instance.TryGetOrComputePreferredOrder(preferredModifierOrder, out var preferredOrder) ||
- !AbstractOrderModifiersHelpers.IsOrdered(preferredOrder, modifiers))
- {
- return syntaxFacts.WithModifiers(node, newModifiers);
- }
+ return syntaxFacts.WithModifiers(node, newModifiers);
+ }
- var orderedModifiers = new SyntaxTokenList(
- newModifiers.OrderBy(CompareModifiers));
+ var orderedModifiers = new SyntaxTokenList(
+ newModifiers.OrderBy(CompareModifiers));
- return syntaxFacts.WithModifiers(node, orderedModifiers);
+ return syntaxFacts.WithModifiers(node, orderedModifiers);
- int CompareModifiers(SyntaxToken left, SyntaxToken right)
- => GetOrder(left) - GetOrder(right);
+ int CompareModifiers(SyntaxToken left, SyntaxToken right)
+ => GetOrder(left) - GetOrder(right);
- int GetOrder(SyntaxToken token)
- => preferredOrder.TryGetValue(token.RawKind, out var value) ? value : int.MaxValue;
- }
+ int GetOrder(SyntaxToken token)
+ => preferredOrder.TryGetValue(token.RawKind, out var value) ? value : int.MaxValue;
}
}
diff --git a/src/Analyzers/CSharp/CodeFixes/HideBase/HideBaseCodeFixProvider.cs b/src/Analyzers/CSharp/CodeFixes/HideBase/HideBaseCodeFixProvider.cs
index cfc813e2319e6..0143983311f31 100644
--- a/src/Analyzers/CSharp/CodeFixes/HideBase/HideBaseCodeFixProvider.cs
+++ b/src/Analyzers/CSharp/CodeFixes/HideBase/HideBaseCodeFixProvider.cs
@@ -2,13 +2,20 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
+using System.Collections.Generic;
using System.Collections.Immutable;
using System.Composition;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
+using System.Threading;
using System.Threading.Tasks;
+using Microsoft.CodeAnalysis.CodeActions;
using Microsoft.CodeAnalysis.CodeFixes;
+using Microsoft.CodeAnalysis.CSharp.CodeStyle;
+using Microsoft.CodeAnalysis.CSharp.OrderModifiers;
using Microsoft.CodeAnalysis.CSharp.Syntax;
+using Microsoft.CodeAnalysis.Editing;
+using Microsoft.CodeAnalysis.Options;
using Microsoft.CodeAnalysis.Shared.Extensions;
namespace Microsoft.CodeAnalysis.CSharp.CodeFixes.HideBase;
@@ -16,31 +23,60 @@ namespace Microsoft.CodeAnalysis.CSharp.CodeFixes.HideBase;
[ExportCodeFixProvider(LanguageNames.CSharp, Name = PredefinedCodeFixProviderNames.AddNew), Shared]
[method: ImportingConstructor]
[method: SuppressMessage("RoslynDiagnosticsReliability", "RS0033:Importing constructor should be [Obsolete]", Justification = "Used in test code: https://github.com/dotnet/roslyn/issues/42814")]
-internal sealed partial class HideBaseCodeFixProvider() : CodeFixProvider
+internal sealed partial class HideBaseCodeFixProvider() : SyntaxEditorBasedCodeFixProvider
{
internal const string CS0108 = nameof(CS0108); // 'SomeClass.SomeMember' hides inherited member 'SomeClass.SomeMember'. Use the new keyword if hiding was intended.
public override ImmutableArray FixableDiagnosticIds => [CS0108];
- public override FixAllProvider GetFixAllProvider()
- => WellKnownFixAllProviders.BatchFixer;
-
- public sealed override async Task RegisterCodeFixesAsync(CodeFixContext context)
+ private static SyntaxNode? GetOriginalNode(SyntaxNode root, Diagnostic diagnostic)
{
- var root = await context.Document.GetRequiredSyntaxRootAsync(context.CancellationToken).ConfigureAwait(false);
-
- var diagnostic = context.Diagnostics.First();
var diagnosticSpan = diagnostic.Location.SourceSpan;
-
var token = root.FindToken(diagnosticSpan.Start);
var originalNode = token.GetAncestor() ??
token.GetAncestor() ??
(SyntaxNode?)token.GetAncestor();
+ return originalNode;
+ }
+
+ public sealed override async Task RegisterCodeFixesAsync(CodeFixContext context)
+ {
+ var root = await context.Document.GetRequiredSyntaxRootAsync(context.CancellationToken).ConfigureAwait(false);
+ var originalNode = GetOriginalNode(root, context.Diagnostics.First());
if (originalNode == null)
return;
- context.RegisterCodeFix(new AddNewKeywordAction(context.Document, originalNode), context.Diagnostics);
+ context.RegisterCodeFix(CodeAction.Create(
+ CSharpCodeFixesResources.Hide_base_member,
+ cancellationToken => GetChangedDocumentAsync(context.Document, originalNode, cancellationToken),
+ nameof(CSharpCodeFixesResources.Hide_base_member)),
+ context.Diagnostics);
+ }
+
+ protected override async Task FixAllAsync(
+ Document document, ImmutableArray diagnostics, SyntaxEditor editor, CancellationToken cancellationToken)
+ {
+ var modifierOrder = await GetModifierOrderAsync(document, cancellationToken).ConfigureAwait(false);
+
+ var root = editor.OriginalRoot;
+ foreach (var diagnostic in diagnostics)
+ {
+ var originalNode = GetOriginalNode(root, diagnostic);
+ if (originalNode == null)
+ continue;
+
+ var newNode = GetNewNode(originalNode, modifierOrder);
+ editor.ReplaceNode(originalNode, newNode);
+ }
+ }
+
+ private static async Task?> GetModifierOrderAsync(Document document, CancellationToken cancellationToken)
+ {
+ var configOptions = await document.GetHostAnalyzerConfigOptionsAsync(cancellationToken).ConfigureAwait(false);
+ var modifierOrder = configOptions.GetOption(CSharpCodeStyleOptions.PreferredModifierOrder).Value;
+ CSharpOrderModifiersHelper.Instance.TryGetOrComputePreferredOrder(modifierOrder, out var preferredOrder);
+ return preferredOrder;
}
}
diff --git a/src/Analyzers/CSharp/CodeFixes/Iterator/CSharpChangeToIEnumerableCodeFixProvider.cs b/src/Analyzers/CSharp/CodeFixes/Iterator/CSharpChangeToIEnumerableCodeFixProvider.cs
index d707a2b05c0c2..a1ebbb3099f84 100644
--- a/src/Analyzers/CSharp/CodeFixes/Iterator/CSharpChangeToIEnumerableCodeFixProvider.cs
+++ b/src/Analyzers/CSharp/CodeFixes/Iterator/CSharpChangeToIEnumerableCodeFixProvider.cs
@@ -16,7 +16,6 @@
using Microsoft.CodeAnalysis.CSharp.Extensions;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.Shared.Extensions;
-using Roslyn.Utilities;
namespace Microsoft.CodeAnalysis.CSharp.CodeFixes.Iterator;
diff --git a/src/Analyzers/CSharp/CodeFixes/MakeMethodAsynchronous/CSharpMakeMethodAsynchronousCodeFixProvider.cs b/src/Analyzers/CSharp/CodeFixes/MakeMethodAsynchronous/CSharpMakeMethodAsynchronousCodeFixProvider.cs
index ebdf9616f9161..1450fca34c80f 100644
--- a/src/Analyzers/CSharp/CodeFixes/MakeMethodAsynchronous/CSharpMakeMethodAsynchronousCodeFixProvider.cs
+++ b/src/Analyzers/CSharp/CodeFixes/MakeMethodAsynchronous/CSharpMakeMethodAsynchronousCodeFixProvider.cs
@@ -131,13 +131,13 @@ private static TypeSyntax FixMethodReturnType(
if (IsIEnumerable(returnType, knownTypes) && IsIterator(methodSymbol, cancellationToken))
{
newReturnType = knownTypes.IAsyncEnumerableOfTType is null
- ? MakeGenericType(nameof(IAsyncEnumerable), methodSymbol.ReturnType)
+ ? MakeGenericType(nameof(IAsyncEnumerable<>), methodSymbol.ReturnType)
: knownTypes.IAsyncEnumerableOfTType.Construct(methodSymbol.ReturnType.GetTypeArguments()[0]).GenerateTypeSyntax();
}
else if (IsIEnumerator(returnType, knownTypes) && IsIterator(methodSymbol, cancellationToken))
{
newReturnType = knownTypes.IAsyncEnumeratorOfTType is null
- ? MakeGenericType(nameof(IAsyncEnumerator), methodSymbol.ReturnType)
+ ? MakeGenericType(nameof(IAsyncEnumerator<>), methodSymbol.ReturnType)
: knownTypes.IAsyncEnumeratorOfTType.Construct(methodSymbol.ReturnType.GetTypeArguments()[0]).GenerateTypeSyntax();
}
else if (IsIAsyncEnumerableOrEnumerator(returnType, knownTypes))
diff --git a/src/Analyzers/CSharp/CodeFixes/MisplacedUsingDirectives/MisplacedUsingDirectivesCodeFixProvider.cs b/src/Analyzers/CSharp/CodeFixes/MisplacedUsingDirectives/MisplacedUsingDirectivesCodeFixProvider.cs
index 46c989508c2ed..9ba94be199535 100644
--- a/src/Analyzers/CSharp/CodeFixes/MisplacedUsingDirectives/MisplacedUsingDirectivesCodeFixProvider.cs
+++ b/src/Analyzers/CSharp/CodeFixes/MisplacedUsingDirectives/MisplacedUsingDirectivesCodeFixProvider.cs
@@ -328,10 +328,9 @@ private static SyntaxList GetMembers(SyntaxNode node)
private static TSyntaxNode RemoveLeadingBlankLinesFromFirstMember(TSyntaxNode node) where TSyntaxNode : SyntaxNode
{
var members = GetMembers(node);
- if (members.Count == 0)
+ if (members is not [var firstMember, ..])
return node;
- var firstMember = members.First();
var firstMemberTrivia = firstMember.GetLeadingTrivia();
// If there is no leading trivia, then return the node as it is.
@@ -367,10 +366,9 @@ private static IEnumerable> SplitIntoLines(SyntaxTrivi
private static TSyntaxNode EnsureLeadingBlankLineBeforeFirstMember(TSyntaxNode node) where TSyntaxNode : SyntaxNode
{
var members = GetMembers(node);
- if (members.Count == 0)
+ if (members is not [var firstMember, ..])
return node;
- var firstMember = members.First();
var firstMemberTrivia = firstMember.GetLeadingTrivia();
// If the first member already contains a leading new line then, this will already break up the usings from these members.
diff --git a/src/Analyzers/CSharp/CodeFixes/NewLines/ArrowExpressionClausePlacement/ArrowExpressionClausePlacementCodeFixProvider.cs b/src/Analyzers/CSharp/CodeFixes/NewLines/ArrowExpressionClausePlacement/ArrowExpressionClausePlacementCodeFixProvider.cs
index 91f10bc2d37bd..8cde1756070e7 100644
--- a/src/Analyzers/CSharp/CodeFixes/NewLines/ArrowExpressionClausePlacement/ArrowExpressionClausePlacementCodeFixProvider.cs
+++ b/src/Analyzers/CSharp/CodeFixes/NewLines/ArrowExpressionClausePlacement/ArrowExpressionClausePlacementCodeFixProvider.cs
@@ -16,7 +16,6 @@
using Microsoft.CodeAnalysis.PooledObjects;
using Microsoft.CodeAnalysis.Shared.Extensions;
using Microsoft.CodeAnalysis.Text;
-using Roslyn.Utilities;
namespace Microsoft.CodeAnalysis.CSharp.NewLines.ArrowExpressionClausePlacement;
diff --git a/src/Analyzers/CSharp/CodeFixes/NewLines/ConditionalExpressionPlacement/ConditionalExpressionPlacementCodeFixProvider.cs b/src/Analyzers/CSharp/CodeFixes/NewLines/ConditionalExpressionPlacement/ConditionalExpressionPlacementCodeFixProvider.cs
index 50cce8f2d95b2..13ba977508273 100644
--- a/src/Analyzers/CSharp/CodeFixes/NewLines/ConditionalExpressionPlacement/ConditionalExpressionPlacementCodeFixProvider.cs
+++ b/src/Analyzers/CSharp/CodeFixes/NewLines/ConditionalExpressionPlacement/ConditionalExpressionPlacementCodeFixProvider.cs
@@ -16,7 +16,6 @@
using Microsoft.CodeAnalysis.PooledObjects;
using Microsoft.CodeAnalysis.Shared.Extensions;
using Microsoft.CodeAnalysis.Text;
-using Roslyn.Utilities;
namespace Microsoft.CodeAnalysis.CSharp.NewLines.ConditionalExpressionPlacement;
diff --git a/src/Analyzers/CSharp/CodeFixes/RemoveConfusingSuppression/CSharpRemoveConfusingSuppressionCodeFixProvider.cs b/src/Analyzers/CSharp/CodeFixes/RemoveConfusingSuppression/CSharpRemoveConfusingSuppressionCodeFixProvider.cs
index 685d47fe4f6cb..f7fbba37cde3c 100644
--- a/src/Analyzers/CSharp/CodeFixes/RemoveConfusingSuppression/CSharpRemoveConfusingSuppressionCodeFixProvider.cs
+++ b/src/Analyzers/CSharp/CodeFixes/RemoveConfusingSuppression/CSharpRemoveConfusingSuppressionCodeFixProvider.cs
@@ -16,7 +16,6 @@
using Microsoft.CodeAnalysis.Editing;
using Microsoft.CodeAnalysis.Host.Mef;
using Microsoft.CodeAnalysis.Shared.Extensions;
-using Roslyn.Utilities;
namespace Microsoft.CodeAnalysis.CSharp.RemoveConfusingSuppression;
diff --git a/src/Analyzers/CSharp/CodeFixes/UseCollectionExpression/CSharpUseCollectionExpressionForFluentCodeFixProvider.cs b/src/Analyzers/CSharp/CodeFixes/UseCollectionExpression/CSharpUseCollectionExpressionForFluentCodeFixProvider.cs
index 0d6ebea4aa39d..907ff9a5a9501 100644
--- a/src/Analyzers/CSharp/CodeFixes/UseCollectionExpression/CSharpUseCollectionExpressionForFluentCodeFixProvider.cs
+++ b/src/Analyzers/CSharp/CodeFixes/UseCollectionExpression/CSharpUseCollectionExpressionForFluentCodeFixProvider.cs
@@ -9,6 +9,7 @@
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.CodeFixes;
+using Microsoft.CodeAnalysis.Collections;
using Microsoft.CodeAnalysis.CSharp.Formatting;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.Diagnostics;
@@ -25,8 +26,8 @@
namespace Microsoft.CodeAnalysis.CSharp.UseCollectionExpression;
using static CSharpCollectionExpressionRewriter;
-using static CSharpUseCollectionExpressionForFluentDiagnosticAnalyzer;
using static CSharpSyntaxTokens;
+using static CSharpUseCollectionExpressionForFluentDiagnosticAnalyzer;
using static SyntaxFactory;
[ExportCodeFixProvider(LanguageNames.CSharp, Name = PredefinedCodeFixProviderNames.UseCollectionExpressionForFluent), Shared]
diff --git a/src/Analyzers/CSharp/CodeFixes/UseCollectionExpression/CSharpUseCollectionExpressionForNewCodeFixProvider.cs b/src/Analyzers/CSharp/CodeFixes/UseCollectionExpression/CSharpUseCollectionExpressionForNewCodeFixProvider.cs
index 4111e3e2db128..fa4e7ac9200d2 100644
--- a/src/Analyzers/CSharp/CodeFixes/UseCollectionExpression/CSharpUseCollectionExpressionForNewCodeFixProvider.cs
+++ b/src/Analyzers/CSharp/CodeFixes/UseCollectionExpression/CSharpUseCollectionExpressionForNewCodeFixProvider.cs
@@ -23,6 +23,7 @@ namespace Microsoft.CodeAnalysis.CSharp.UseCollectionExpression;
using static UseCollectionExpressionHelpers;
[ExportCodeFixProvider(LanguageNames.CSharp, Name = PredefinedCodeFixProviderNames.UseCollectionExpressionForNew), Shared]
+[ExtensionOrder(Before = PredefinedCodeFixProviderNames.UseImplicitObjectCreation)]
[method: ImportingConstructor]
[method: Obsolete(MefConstruction.ImportingConstructorMessage, error: true)]
internal sealed partial class CSharpUseCollectionExpressionForNewCodeFixProvider()
diff --git a/src/Analyzers/CSharp/CodeFixes/UseCollectionInitializer/CSharpUseCollectionInitializerCodeFixProvider.cs b/src/Analyzers/CSharp/CodeFixes/UseCollectionInitializer/CSharpUseCollectionInitializerCodeFixProvider.cs
index 0a323d76ecdb0..524292ebe2e50 100644
--- a/src/Analyzers/CSharp/CodeFixes/UseCollectionInitializer/CSharpUseCollectionInitializerCodeFixProvider.cs
+++ b/src/Analyzers/CSharp/CodeFixes/UseCollectionInitializer/CSharpUseCollectionInitializerCodeFixProvider.cs
@@ -15,6 +15,7 @@
namespace Microsoft.CodeAnalysis.CSharp.UseCollectionInitializer;
[ExportCodeFixProvider(LanguageNames.CSharp, Name = PredefinedCodeFixProviderNames.UseCollectionInitializer), Shared]
+[ExtensionOrder(Before = PredefinedCodeFixProviderNames.UseImplicitObjectCreation)]
[method: ImportingConstructor]
[method: SuppressMessage("RoslynDiagnosticsReliability", "RS0033:Importing constructor should be [Obsolete]", Justification = "Used in test code: https://github.com/dotnet/roslyn/issues/42814")]
internal sealed partial class CSharpUseCollectionInitializerCodeFixProvider() :
diff --git a/src/Analyzers/CSharp/CodeFixes/UseExpressionBody/UseExpressionBodyCodeFixProvider.cs b/src/Analyzers/CSharp/CodeFixes/UseExpressionBody/UseExpressionBodyCodeFixProvider.cs
index e0473bf958f77..60291f55e829a 100644
--- a/src/Analyzers/CSharp/CodeFixes/UseExpressionBody/UseExpressionBodyCodeFixProvider.cs
+++ b/src/Analyzers/CSharp/CodeFixes/UseExpressionBody/UseExpressionBodyCodeFixProvider.cs
@@ -16,7 +16,6 @@
using Microsoft.CodeAnalysis.Formatting;
using Microsoft.CodeAnalysis.Host.Mef;
using Microsoft.CodeAnalysis.Shared.Extensions;
-using Roslyn.Utilities;
namespace Microsoft.CodeAnalysis.CSharp.UseExpressionBody;
diff --git a/src/Analyzers/CSharp/CodeFixes/UseImplicitObjectCreation/CSharpUseImplicitObjectCreationCodeFixProvider.cs b/src/Analyzers/CSharp/CodeFixes/UseImplicitObjectCreation/CSharpUseImplicitObjectCreationCodeFixProvider.cs
index 576f76620d1cb..cd77173715f61 100644
--- a/src/Analyzers/CSharp/CodeFixes/UseImplicitObjectCreation/CSharpUseImplicitObjectCreationCodeFixProvider.cs
+++ b/src/Analyzers/CSharp/CodeFixes/UseImplicitObjectCreation/CSharpUseImplicitObjectCreationCodeFixProvider.cs
@@ -25,6 +25,8 @@ namespace Microsoft.CodeAnalysis.CSharp.UseImplicitObjectCreation;
using static SyntaxFactory;
[ExportCodeFixProvider(LanguageNames.CSharp, Name = PredefinedCodeFixProviderNames.UseImplicitObjectCreation), Shared]
+[ExtensionOrder(After = PredefinedCodeFixProviderNames.UseCollectionExpressionForNew)]
+[ExtensionOrder(After = PredefinedCodeFixProviderNames.UseCollectionInitializer)]
[method: ImportingConstructor]
[method: Obsolete(MefConstruction.ImportingConstructorMessage, error: true)]
internal sealed class CSharpUseImplicitObjectCreationCodeFixProvider() : SyntaxEditorBasedCodeFixProvider
diff --git a/src/Analyzers/CSharp/CodeFixes/UseIsNullCheck/CSharpUseIsNullCheckForCastAndEqualityOperatorCodeFixProvider.cs b/src/Analyzers/CSharp/CodeFixes/UseIsNullCheck/CSharpUseIsNullCheckForCastAndEqualityOperatorCodeFixProvider.cs
index 2cc538d91b2c4..74c11ed1b67a4 100644
--- a/src/Analyzers/CSharp/CodeFixes/UseIsNullCheck/CSharpUseIsNullCheckForCastAndEqualityOperatorCodeFixProvider.cs
+++ b/src/Analyzers/CSharp/CodeFixes/UseIsNullCheck/CSharpUseIsNullCheckForCastAndEqualityOperatorCodeFixProvider.cs
@@ -15,7 +15,6 @@
using Microsoft.CodeAnalysis.Editing;
using Microsoft.CodeAnalysis.Shared.Extensions;
using Microsoft.CodeAnalysis.UseIsNullCheck;
-using Roslyn.Utilities;
namespace Microsoft.CodeAnalysis.CSharp.UseIsNullCheck;
diff --git a/src/Analyzers/CSharp/CodeFixes/UseLocalFunction/CSharpUseLocalFunctionCodeFixProvider.cs b/src/Analyzers/CSharp/CodeFixes/UseLocalFunction/CSharpUseLocalFunctionCodeFixProvider.cs
index 4b0d32d68b08c..968fc5a76882a 100644
--- a/src/Analyzers/CSharp/CodeFixes/UseLocalFunction/CSharpUseLocalFunctionCodeFixProvider.cs
+++ b/src/Analyzers/CSharp/CodeFixes/UseLocalFunction/CSharpUseLocalFunctionCodeFixProvider.cs
@@ -14,6 +14,7 @@
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.CodeFixes;
using Microsoft.CodeAnalysis.CodeGeneration;
+using Microsoft.CodeAnalysis.Collections;
using Microsoft.CodeAnalysis.CSharp.CodeGeneration;
using Microsoft.CodeAnalysis.CSharp.Extensions;
using Microsoft.CodeAnalysis.CSharp.Syntax;
diff --git a/src/Analyzers/CSharp/CodeFixes/UseNullPropagation/CSharpUseNullPropagationCodeFixProvider.cs b/src/Analyzers/CSharp/CodeFixes/UseNullPropagation/CSharpUseNullPropagationCodeFixProvider.cs
index 84b3074c92ac6..40077ec354ee0 100644
--- a/src/Analyzers/CSharp/CodeFixes/UseNullPropagation/CSharpUseNullPropagationCodeFixProvider.cs
+++ b/src/Analyzers/CSharp/CodeFixes/UseNullPropagation/CSharpUseNullPropagationCodeFixProvider.cs
@@ -4,8 +4,10 @@
using System.Composition;
using System.Diagnostics.CodeAnalysis;
+using System.Linq;
using Microsoft.CodeAnalysis.CodeFixes;
using Microsoft.CodeAnalysis.CSharp.Syntax;
+using Microsoft.CodeAnalysis.Formatting;
using Microsoft.CodeAnalysis.Shared.Extensions;
using Microsoft.CodeAnalysis.UseNullPropagation;
@@ -15,6 +17,7 @@ namespace Microsoft.CodeAnalysis.CSharp.UseNullPropagation;
[method: ImportingConstructor]
[method: SuppressMessage("RoslynDiagnosticsReliability", "RS0033:Importing constructor should be [Obsolete]", Justification = "Used in test code: https://github.com/dotnet/roslyn/issues/42814")]
internal sealed class CSharpUseNullPropagationCodeFixProvider() : AbstractUseNullPropagationCodeFixProvider<
+ CSharpUseNullPropagationDiagnosticAnalyzer,
SyntaxKind,
ExpressionSyntax,
StatementSyntax,
@@ -29,23 +32,18 @@ internal sealed class CSharpUseNullPropagationCodeFixProvider() : AbstractUseNul
ExpressionStatementSyntax,
BracketedArgumentListSyntax>
{
- protected override bool TryGetBlock(SyntaxNode? statement, [NotNullWhen(true)] out StatementSyntax? block)
- {
- if (statement is BlockSyntax statementBlock)
- {
- block = statementBlock;
- return true;
- }
-
- block = null;
- return false;
- }
+ protected override CSharpUseNullPropagationDiagnosticAnalyzer Analyzer
+ => CSharpUseNullPropagationDiagnosticAnalyzer.Instance;
- protected override StatementSyntax ReplaceBlockStatements(StatementSyntax block, StatementSyntax newInnerStatement)
- => ((BlockSyntax)block).WithStatements([newInnerStatement]);
+ private static BlockSyntax ReplaceBlockStatements(BlockSyntax block, StatementSyntax newInnerStatement)
+ => block.WithStatements([newInnerStatement, .. block.Statements.Skip(1).Select(s => s.WithAdditionalAnnotations(Formatter.Annotation))]);
- protected override SyntaxNode PostProcessElseIf(IfStatementSyntax ifStatement, StatementSyntax newWhenTrueStatement)
+ protected override SyntaxNode PostProcessElseIf(
+ IfStatementSyntax ifStatement, StatementSyntax newWhenTrueStatement)
{
+ if (ifStatement.Statement is BlockSyntax block)
+ newWhenTrueStatement = ReplaceBlockStatements(block, newWhenTrueStatement);
+
var elseClauseSyntax = (ElseClauseSyntax)ifStatement.Parent!;
return elseClauseSyntax
.WithElseKeyword(elseClauseSyntax.ElseKeyword.WithTrailingTrivia())
diff --git a/src/Analyzers/CSharp/CodeFixes/UsePrimaryConstructor/CSharpUsePrimaryConstructorCodeFixProvider.cs b/src/Analyzers/CSharp/CodeFixes/UsePrimaryConstructor/CSharpUsePrimaryConstructorCodeFixProvider.cs
index 02e9292bf5637..c496dfd59323a 100644
--- a/src/Analyzers/CSharp/CodeFixes/UsePrimaryConstructor/CSharpUsePrimaryConstructorCodeFixProvider.cs
+++ b/src/Analyzers/CSharp/CodeFixes/UsePrimaryConstructor/CSharpUsePrimaryConstructorCodeFixProvider.cs
@@ -28,8 +28,8 @@
namespace Microsoft.CodeAnalysis.CSharp.UsePrimaryConstructor;
-using static CSharpUsePrimaryConstructorDiagnosticAnalyzer;
using static CSharpSyntaxTokens;
+using static CSharpUsePrimaryConstructorDiagnosticAnalyzer;
using static SyntaxFactory;
[ExportCodeFixProvider(LanguageNames.CSharp, Name = PredefinedCodeFixProviderNames.UsePrimaryConstructor), Shared]
diff --git a/src/Analyzers/CSharp/CodeFixes/UsePrimaryConstructor/CSharpUsePrimaryConstructorFixAllProvider.cs b/src/Analyzers/CSharp/CodeFixes/UsePrimaryConstructor/CSharpUsePrimaryConstructorFixAllProvider.cs
index 852746d403c20..15e87059cdbef 100644
--- a/src/Analyzers/CSharp/CodeFixes/UsePrimaryConstructor/CSharpUsePrimaryConstructorFixAllProvider.cs
+++ b/src/Analyzers/CSharp/CodeFixes/UsePrimaryConstructor/CSharpUsePrimaryConstructorFixAllProvider.cs
@@ -4,6 +4,7 @@
// Ignore Spelling: loc kvp
+using System.Collections.Generic;
using System.Collections.Immutable;
using System.Linq;
using System.Threading.Tasks;
diff --git a/src/Analyzers/CSharp/CodeFixes/UseSystemThreadingLock/CSharpUseSystemThreadingLockFixAllProvider.cs b/src/Analyzers/CSharp/CodeFixes/UseSystemThreadingLock/CSharpUseSystemThreadingLockFixAllProvider.cs
index 055c1a263711e..dbe882b312d1a 100644
--- a/src/Analyzers/CSharp/CodeFixes/UseSystemThreadingLock/CSharpUseSystemThreadingLockFixAllProvider.cs
+++ b/src/Analyzers/CSharp/CodeFixes/UseSystemThreadingLock/CSharpUseSystemThreadingLockFixAllProvider.cs
@@ -2,6 +2,7 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
+using System.Collections.Generic;
using System.Collections.Immutable;
using System.Linq;
using System.Threading.Tasks;
diff --git a/src/Analyzers/CSharp/CodeFixes/UseUtf8StringLiteral/UseUtf8StringLiteralCodeFixProvider.cs b/src/Analyzers/CSharp/CodeFixes/UseUtf8StringLiteral/UseUtf8StringLiteralCodeFixProvider.cs
index f82a29f839e6e..067362b58ca4f 100644
--- a/src/Analyzers/CSharp/CodeFixes/UseUtf8StringLiteral/UseUtf8StringLiteralCodeFixProvider.cs
+++ b/src/Analyzers/CSharp/CodeFixes/UseUtf8StringLiteral/UseUtf8StringLiteralCodeFixProvider.cs
@@ -206,7 +206,7 @@ private static ExpressionSyntax CreateUtf8String(SyntaxTriviaList leadingTrivia,
MemberAccessExpression(
SyntaxKind.SimpleMemberAccessExpression,
stringLiteral,
- IdentifierName(nameof(ReadOnlySpan.ToArray))))
+ IdentifierName(nameof(ReadOnlySpan<>.ToArray))))
.WithTrailingTrivia(trailingTrivia);
}
}
diff --git a/src/Analyzers/CSharp/Tests/AddAccessibilityModifiers/AddOrRemoveAccessibilityModifiersFixAllTests.cs b/src/Analyzers/CSharp/Tests/AddAccessibilityModifiers/AddOrRemoveAccessibilityModifiersFixAllTests.cs
index 4b196a1453e0f..a85c02622f160 100644
--- a/src/Analyzers/CSharp/Tests/AddAccessibilityModifiers/AddOrRemoveAccessibilityModifiersFixAllTests.cs
+++ b/src/Analyzers/CSharp/Tests/AddAccessibilityModifiers/AddOrRemoveAccessibilityModifiersFixAllTests.cs
@@ -23,22 +23,16 @@ internal override (DiagnosticAnalyzer, CodeFixProvider) CreateDiagnosticProvider
[Fact, WorkItem("https://github.com/dotnet/vscode-csharp/issues/6611")]
[Trait(Traits.Feature, Traits.Features.CodeActionsFixAllOccurrences)]
- public async Task TestFixAllInContainingType_DoesNotCrashInDuplicateProgramInTopLevelStatements()
- {
- var input = """
+ public Task TestFixAllInContainingType_DoesNotCrashInDuplicateProgramInTopLevelStatements()
+ => TestAsync("""
Console.WriteLine("Hello, World!");
class {|FixAllInContainingType:Program|}
{
}
- """;
-
- var expected = """
+ """, """
Console.WriteLine("Hello, World!");
internal class Program
{
}
- """;
-
- await TestAsync(input, expected, TestParameters.Default.parseOptions);
- }
+ """, TestParameters.Default.parseOptions);
}
diff --git a/src/Analyzers/CSharp/Tests/AddAccessibilityModifiers/AddOrRemoveAccessibilityModifiersTests.cs b/src/Analyzers/CSharp/Tests/AddAccessibilityModifiers/AddOrRemoveAccessibilityModifiersTests.cs
index 1f39e56ab48d8..326fd779c7579 100644
--- a/src/Analyzers/CSharp/Tests/AddAccessibilityModifiers/AddOrRemoveAccessibilityModifiersTests.cs
+++ b/src/Analyzers/CSharp/Tests/AddAccessibilityModifiers/AddOrRemoveAccessibilityModifiersTests.cs
@@ -25,9 +25,8 @@ public void TestStandardProperty(AnalyzerProperty property)
=> VerifyCS.VerifyStandardProperty(property);
[Fact]
- public async Task TestAllConstructs()
- {
- await VerifyCS.VerifyCodeFixAsync(
+ public Task TestAllConstructs()
+ => VerifyCS.VerifyCodeFixAsync(
"""
using System;
namespace Outer
@@ -150,12 +149,10 @@ internal enum E
}
}
""");
- }
[Fact]
- public async Task TestRefStructs()
- {
- await VerifyCS.VerifyCodeFixAsync("""
+ public Task TestRefStructs()
+ => VerifyCS.VerifyCodeFixAsync("""
namespace Test
{
ref struct [|S1|] { }
@@ -166,12 +163,13 @@ namespace Test
internal ref struct S1 { }
}
""");
- }
[Fact]
public async Task TestRecords()
{
- var source = """
+ var test = new VerifyCS.Test
+ {
+ TestCode = """
record [|Record|]
{
int [|field|];
@@ -182,8 +180,8 @@ public sealed class IsExternalInit
{
}
}
- """;
- var fixedSource = """
+ """,
+ FixedCode = """
internal record Record
{
private int field;
@@ -194,12 +192,7 @@ public sealed class IsExternalInit
{
}
}
- """;
-
- var test = new VerifyCS.Test
- {
- TestCode = source,
- FixedCode = fixedSource,
+ """,
LanguageVersion = LanguageVersion.CSharp9,
};
@@ -209,23 +202,20 @@ public sealed class IsExternalInit
[Fact]
public async Task TestRecordStructs()
{
- var source = """
+ var test = new VerifyCS.Test
+ {
+ TestCode = """
record struct [|Record|]
{
int [|field|];
}
- """;
- var fixedSource = """
+ """,
+ FixedCode = """
internal record struct Record
{
private int field;
}
- """;
-
- var test = new VerifyCS.Test
- {
- TestCode = source,
- FixedCode = fixedSource,
+ """,
LanguageVersion = LanguageVersion.CSharp12,
};
@@ -233,9 +223,8 @@ internal record struct Record
}
[Fact]
- public async Task TestReadOnlyStructs()
- {
- await VerifyCS.VerifyCodeFixAsync("""
+ public Task TestReadOnlyStructs()
+ => VerifyCS.VerifyCodeFixAsync("""
namespace Test
{
readonly struct [|S1|] { }
@@ -246,12 +235,10 @@ namespace Test
internal readonly struct S1 { }
}
""");
- }
[Fact]
- public async Task TestAllConstructsWithOmit()
- {
- await new VerifyCS.Test
+ public Task TestAllConstructsWithOmit()
+ => new VerifyCS.Test
{
TestState =
{
@@ -394,12 +381,10 @@ enum E
{ CodeStyleOptions2.AccessibilityModifiersRequired, AccessibilityModifiersRequired.OmitIfDefault },
},
}.RunAsync();
- }
[Fact]
- public async Task TestRefStructsWithOmit()
- {
- await new VerifyCS.Test
+ public Task TestRefStructsWithOmit()
+ => new VerifyCS.Test
{
TestCode = """
namespace Test
@@ -418,12 +403,10 @@ ref struct S1 { }
{ CodeStyleOptions2.AccessibilityModifiersRequired, AccessibilityModifiersRequired.OmitIfDefault },
},
}.RunAsync();
- }
[Fact]
- public async Task TestReadOnlyStructsWithOmit()
- {
- await new VerifyCS.Test
+ public Task TestReadOnlyStructsWithOmit()
+ => new VerifyCS.Test
{
TestCode = """
namespace Test
@@ -442,12 +425,10 @@ readonly struct S1 { }
{ CodeStyleOptions2.AccessibilityModifiersRequired, AccessibilityModifiersRequired.OmitIfDefault },
},
}.RunAsync();
- }
[Fact]
- public async Task TestClassOutsideNamespace()
- {
- await new VerifyCS.Test
+ public Task TestClassOutsideNamespace()
+ => new VerifyCS.Test
{
TestCode = """
internal class [|C1|] { }
@@ -460,12 +441,10 @@ class C1 { }
{ CodeStyleOptions2.AccessibilityModifiersRequired, AccessibilityModifiersRequired.OmitIfDefault },
},
}.RunAsync();
- }
[Fact]
- public async Task TestExternMethod()
- {
- await VerifyCS.VerifyCodeFixAsync("""
+ public Task TestExternMethod()
+ => VerifyCS.VerifyCodeFixAsync("""
using System;
using System.Runtime.InteropServices;
@@ -485,12 +464,10 @@ internal class Program
private static extern int [|MessageBox|](IntPtr h, string m, string c, int type);
}
""");
- }
[Fact]
- public async Task TestVolatile()
- {
- await VerifyCS.VerifyCodeFixAsync("""
+ public Task TestVolatile()
+ => VerifyCS.VerifyCodeFixAsync("""
internal class Program
{
volatile int [|x|];
@@ -502,12 +479,10 @@ internal class Program
private volatile int x;
}
""");
- }
[Fact, WorkItem("https://github.com/dotnet/roslyn/issues/48899")]
- public async Task TestAbstractMethod()
- {
- await VerifyCS.VerifyCodeFixAsync("""
+ public Task TestAbstractMethod()
+ => VerifyCS.VerifyCodeFixAsync("""
public abstract class TestClass
{
abstract string {|CS0621:[|Test|]|} { get; }
@@ -519,12 +494,10 @@ public abstract class TestClass
protected abstract string Test { get; }
}
""");
- }
[Fact, WorkItem("https://github.com/dotnet/roslyn/issues/48899")]
- public async Task TestOverriddenMethod()
- {
- await VerifyCS.VerifyCodeFixAsync("""
+ public Task TestOverriddenMethod()
+ => VerifyCS.VerifyCodeFixAsync("""
public abstract class TestClass
{
public abstract string Test { get; }
@@ -546,12 +519,10 @@ public class Derived : TestClass
public override string Test { get; }
}
""");
- }
[Fact]
- public async Task TestFileScopedNamespaces()
- {
- await new VerifyCS.Test
+ public Task TestFileScopedNamespaces()
+ => new VerifyCS.Test
{
TestCode = """
namespace Test;
@@ -565,12 +536,13 @@ internal struct S1 { }
""",
LanguageVersion = LanguageVersion.CSharp10,
}.RunAsync();
- }
[Fact, WorkItem("https://github.com/dotnet/roslyn/issues/55703")]
public async Task TestPartial_WithExistingModifier()
{
- var source = """
+ var test = new VerifyCS.Test
+ {
+ TestCode = """
partial class [|C|]
{
}
@@ -578,8 +550,8 @@ partial class [|C|]
public partial class C
{
}
- """;
- var fixedSource = """
+ """,
+ FixedCode = """
public partial class C
{
}
@@ -587,12 +559,7 @@ public partial class C
public partial class C
{
}
- """;
-
- var test = new VerifyCS.Test
- {
- TestCode = source,
- FixedCode = fixedSource,
+ """,
LanguageVersion = LanguageVersion.CSharp12,
};
@@ -602,7 +569,9 @@ public partial class C
[Fact, WorkItem("https://github.com/dotnet/roslyn/issues/58914")]
public async Task TestStaticOperatorInInterface()
{
- var source = """
+ var test = new VerifyCS.Test
+ {
+ TestCode = """
internal interface I where T : I
{
abstract static int operator +(T x);
@@ -615,11 +584,7 @@ internal class C : I
throw new System.NotImplementedException();
}
}
- """;
-
- var test = new VerifyCS.Test
- {
- TestCode = source,
+ """,
LanguageVersion = LanguageVersion.CSharp12,
ReferenceAssemblies = Testing.ReferenceAssemblies.Net.Net60
};
@@ -635,28 +600,20 @@ internal class C : I
[InlineData("interface")]
[InlineData("enum")]
[WorkItem("https://github.com/dotnet/roslyn/issues/62259")]
- public async Task TestFileDeclaration(string declarationKind)
- {
- var source = $"file {declarationKind} C {{ }}";
-
- await new VerifyCS.Test
+ public Task TestFileDeclaration(string declarationKind)
+ => new VerifyCS.Test
{
- TestCode = source,
+ TestCode = $"file {declarationKind} C {{ }}",
LanguageVersion = LanguageVersion.CSharp12,
}.RunAsync();
- }
[Fact, WorkItem("https://github.com/dotnet/roslyn/issues/62259")]
- public async Task TestFileDelegate()
- {
- var source = "file delegate void M();";
-
- await new VerifyCS.Test
+ public Task TestFileDelegate()
+ => new VerifyCS.Test
{
- TestCode = source,
+ TestCode = "file delegate void M();",
LanguageVersion = LanguageVersion.CSharp12,
}.RunAsync();
- }
[Theory]
[InlineData("class")]
@@ -666,50 +623,41 @@ public async Task TestFileDelegate()
[InlineData("interface")]
[InlineData("enum")]
[WorkItem("https://github.com/dotnet/roslyn/issues/62259")]
- public async Task TestNestedFileDeclaration(string declarationKind)
- {
- var source = $$"""
+ public Task TestNestedFileDeclaration(string declarationKind)
+ => new VerifyCS.Test
+ {
+ TestCode = $$"""
file class C1
{
{{declarationKind}} [|C2|] { }
}
- """;
-
- var fixedSource = $$"""
+ """,
+ FixedCode = $$"""
file class C1
{
private {{declarationKind}} C2 { }
}
- """;
-
- await new VerifyCS.Test
- {
- TestCode = source,
- FixedCode = fixedSource,
+ """,
LanguageVersion = LanguageVersion.CSharp12,
}.RunAsync();
- }
[Fact, WorkItem("https://github.com/dotnet/roslyn/issues/29633")]
public async Task TestTitle1()
{
- var source = """
+ var test = new VerifyCS.Test
+ {
+ TestCode = """
internal class C
{
int [|field|];
}
- """;
- var fixedSource = """
+ """,
+ FixedCode = """
internal class C
{
private int field;
}
- """;
-
- var test = new VerifyCS.Test
- {
- TestCode = source,
- FixedCode = fixedSource,
+ """,
LanguageVersion = LanguageVersion.CSharp12,
CodeActionEquivalenceKey = nameof(AnalyzersResources.Add_accessibility_modifiers),
};
@@ -718,25 +666,21 @@ internal class C
}
[Fact, WorkItem("https://github.com/dotnet/roslyn/issues/29633")]
- public async Task TestTitle2()
- {
- var source = """
+ public Task TestTitle2()
+ => new VerifyCS.Test
+ {
+ TestCode = """
class C
{
private int [|field|];
}
- """;
- var fixedSource = """
+ """,
+ FixedCode = """
class C
{
int field;
}
- """;
-
- await new VerifyCS.Test
- {
- TestCode = source,
- FixedCode = fixedSource,
+ """,
LanguageVersion = LanguageVersion.CSharp12,
CodeActionEquivalenceKey = nameof(AnalyzersResources.Remove_accessibility_modifiers),
Options =
@@ -744,13 +688,10 @@ class C
{ CodeStyleOptions2.AccessibilityModifiersRequired,AccessibilityModifiersRequired.OmitIfDefault }
}
}.RunAsync();
- }
[Fact, WorkItem("https://github.com/dotnet/roslyn/issues/74244")]
- public async Task TestAlwaysForInterfaceMembers()
- {
-
- await new VerifyCS.Test
+ public Task TestAlwaysForInterfaceMembers()
+ => new VerifyCS.Test
{
TestCode = """
using System;
@@ -793,12 +734,10 @@ private void M() { }
{ CodeStyleOptions2.AccessibilityModifiersRequired, AccessibilityModifiersRequired.Always }
}
}.RunAsync();
- }
[Fact, WorkItem("https://github.com/dotnet/roslyn/issues/74244")]
- public async Task TestOmitIfDefaultForInterfaceMembers()
- {
- await new VerifyCS.Test
+ public Task TestOmitIfDefaultForInterfaceMembers()
+ => new VerifyCS.Test
{
TestCode = """
using System;
@@ -841,12 +780,10 @@ void M() { }
{ CodeStyleOptions2.AccessibilityModifiersRequired, AccessibilityModifiersRequired.OmitIfDefault }
}
}.RunAsync();
- }
[Fact, WorkItem("https://github.com/dotnet/roslyn/issues/74244")]
- public async Task TestForNonInterfaceMembers()
- {
- await new VerifyCS.Test
+ public Task TestForNonInterfaceMembers()
+ => new VerifyCS.Test
{
TestCode = """
using System;
@@ -889,12 +826,10 @@ private void M() { }
{ CodeStyleOptions2.AccessibilityModifiersRequired, AccessibilityModifiersRequired.ForNonInterfaceMembers }
}
}.RunAsync();
- }
[Fact, WorkItem("https://github.com/dotnet/roslyn/issues/78395")]
- public async Task TestOmitIfDefaultWithFixedField()
- {
- await new VerifyCS.Test
+ public Task TestOmitIfDefaultWithFixedField()
+ => new VerifyCS.Test
{
TestCode = """
unsafe struct MyStruct
@@ -915,5 +850,4 @@ unsafe struct MyStruct
{ CodeStyleOptions2.AccessibilityModifiersRequired, AccessibilityModifiersRequired.OmitIfDefault }
}
}.RunAsync();
- }
}
diff --git a/src/Analyzers/CSharp/Tests/AddAnonymousTypeMemberName/AddAnonymousTypeMemberNameTests.cs b/src/Analyzers/CSharp/Tests/AddAnonymousTypeMemberName/AddAnonymousTypeMemberNameTests.cs
index b1aeec63412ec..4383dce76b037 100644
--- a/src/Analyzers/CSharp/Tests/AddAnonymousTypeMemberName/AddAnonymousTypeMemberNameTests.cs
+++ b/src/Analyzers/CSharp/Tests/AddAnonymousTypeMemberName/AddAnonymousTypeMemberNameTests.cs
@@ -25,9 +25,8 @@ internal override (DiagnosticAnalyzer?, CodeFixProvider) CreateDiagnosticProvide
=> (null, new CSharpAddAnonymousTypeMemberNameCodeFixProvider());
[Fact]
- public async Task Test1()
- {
- await TestInRegularAndScript1Async(
+ public Task Test1()
+ => TestInRegularAndScript1Async(
"""
class C
{
@@ -46,12 +45,10 @@ void M()
}
}
""");
- }
[Fact]
- public async Task TestExistingName()
- {
- await TestInRegularAndScript1Async(
+ public Task TestExistingName()
+ => TestInRegularAndScript1Async(
"""
class C
{
@@ -70,12 +67,10 @@ void M()
}
}
""");
- }
[Fact]
- public async Task TestFixAll1()
- {
- await TestInRegularAndScript1Async(
+ public Task TestFixAll1()
+ => TestInRegularAndScript1Async(
"""
class C
{
@@ -94,12 +89,10 @@ void M()
}
}
""");
- }
[Fact]
- public async Task TestFixAll2()
- {
- await TestInRegularAndScript1Async(
+ public Task TestFixAll2()
+ => TestInRegularAndScript1Async(
"""
class C
{
@@ -118,12 +111,10 @@ void M()
}
}
""");
- }
[Fact]
- public async Task TestFixAll3()
- {
- await TestInRegularAndScript1Async(
+ public Task TestFixAll3()
+ => TestInRegularAndScript1Async(
"""
class C
{
@@ -142,5 +133,4 @@ void M()
}
}
""");
- }
}
diff --git a/src/Analyzers/CSharp/Tests/AddBraces/AddBracesFixAllTests.cs b/src/Analyzers/CSharp/Tests/AddBraces/AddBracesFixAllTests.cs
index 867a2c4ac8ff5..47523b9eeaf3f 100644
--- a/src/Analyzers/CSharp/Tests/AddBraces/AddBracesFixAllTests.cs
+++ b/src/Analyzers/CSharp/Tests/AddBraces/AddBracesFixAllTests.cs
@@ -13,9 +13,8 @@ public sealed partial class AddBracesTests
{
[Fact]
[Trait(Traits.Feature, Traits.Features.CodeActionsFixAllOccurrences)]
- public async Task TestFixAllInDocument1()
- {
- var input = """
+ public Task TestFixAllInDocument1()
+ => TestInRegularAndScriptAsync("""
class Program1
{
static void Main()
@@ -23,9 +22,7 @@ static void Main()
{|FixAllInDocument:if|} (true) if (true) return;
}
}
- """;
-
- var expected = """
+ """, """
class Program1
{
static void Main()
@@ -39,16 +36,12 @@ static void Main()
}
}
}
- """;
-
- await TestInRegularAndScriptAsync(input, expected);
- }
+ """);
[Fact]
[Trait(Traits.Feature, Traits.Features.CodeActionsFixAllOccurrences)]
- public async Task TestFixAllInDocument2()
- {
- var input = """
+ public Task TestFixAllInDocument2()
+ => TestInRegularAndScriptAsync("""
class Program1
{
static void Main()
@@ -56,9 +49,7 @@ static void Main()
if (true) {|FixAllInDocument:if|} (true) return;
}
}
- """;
-
- var expected = """
+ """, """
class Program1
{
static void Main()
@@ -72,16 +63,12 @@ static void Main()
}
}
}
- """;
-
- await TestInRegularAndScriptAsync(input, expected);
- }
+ """);
[Fact]
[Trait(Traits.Feature, Traits.Features.CodeActionsFixAllOccurrences)]
- public async Task TestFixAllInDocument()
- {
- var input = """
+ public Task TestFixAllInDocument()
+ => TestInRegularAndScriptAsync("""
@@ -116,9 +103,7 @@ static void Main()
- """;
-
- var expected = """
+ """, """
@@ -160,16 +145,12 @@ static void Main()
- """;
-
- await TestInRegularAndScriptAsync(input, expected);
- }
+ """);
[Fact]
[Trait(Traits.Feature, Traits.Features.CodeActionsFixAllOccurrences)]
- public async Task TestFixAllInProject()
- {
- var input = """
+ public Task TestFixAllInProject()
+ => TestInRegularAndScriptAsync("""
@@ -203,9 +184,7 @@ static void Main()
- """;
-
- var expected = """
+ """, """
@@ -245,16 +224,12 @@ static void Main()
- """;
-
- await TestInRegularAndScriptAsync(input, expected);
- }
+ """);
[Fact]
[Trait(Traits.Feature, Traits.Features.CodeActionsFixAllOccurrences)]
- public async Task TestFixAllInSolution()
- {
- var input = """
+ public Task TestFixAllInSolution()
+ => TestInRegularAndScriptAsync("""
@@ -288,9 +263,7 @@ static void Main()
- """;
-
- var expected = """
+ """, """
@@ -333,16 +306,12 @@ static void Main()
- """;
-
- await TestInRegularAndScriptAsync(input, expected);
- }
+ """);
[Fact]
[Trait(Traits.Feature, Traits.Features.CodeActionsFixAllOccurrences)]
- public async Task TestFixAllInContainingMember()
- {
- var input = """
+ public Task TestFixAllInContainingMember()
+ => TestInRegularAndScriptAsync("""
class Program1
{
static void Main()
@@ -365,9 +334,7 @@ void OtherMethod()
if (true) if (true) return;
}
}
- """;
-
- var expected = """
+ """, """
class Program1
{
static void Main()
@@ -402,16 +369,12 @@ void OtherMethod()
if (true) if (true) return;
}
}
- """;
-
- await TestInRegularAndScriptAsync(input, expected);
- }
+ """);
[Fact]
[Trait(Traits.Feature, Traits.Features.CodeActionsFixAllOccurrences)]
- public async Task TestFixAllInContainingType_AcrossSingleFile()
- {
- var input = """
+ public Task TestFixAllInContainingType_AcrossSingleFile()
+ => TestInRegularAndScriptAsync("""
class Program1
{
static void Main()
@@ -434,9 +397,7 @@ void OtherMethod()
if (true) if (true) return;
}
}
- """;
-
- var expected = """
+ """, """
class Program1
{
static void Main()
@@ -477,16 +438,12 @@ void OtherMethod()
if (true) if (true) return;
}
}
- """;
-
- await TestInRegularAndScriptAsync(input, expected);
- }
+ """);
[Fact]
[Trait(Traits.Feature, Traits.Features.CodeActionsFixAllOccurrences)]
- public async Task TestFixAllInContainingType_AcrossMultipleFiles()
- {
- var input = """
+ public Task TestFixAllInContainingType_AcrossMultipleFiles()
+ => TestInRegularAndScriptAsync("""
@@ -525,9 +482,7 @@ void OtherTypeMethod()
- """;
-
- var expected = """
+ """, """
@@ -590,10 +545,7 @@ void OtherTypeMethod()
- """;
-
- await TestInRegularAndScriptAsync(input, expected);
- }
+ """);
[Theory]
[InlineData("FixAllInContainingMember")]
@@ -601,9 +553,8 @@ void OtherTypeMethod()
[Trait(Traits.Feature, Traits.Features.CodeActionsAddBraces)]
[Trait(Traits.Feature, Traits.Features.CodeActionsAddBraces)]
[Trait(Traits.Feature, Traits.Features.CodeActionsFixAllOccurrences)]
- public async Task TestFixAllInContainingMemberAndType_TopLevelStatements(string fixAllScope)
- {
- var input = $$"""
+ public Task TestFixAllInContainingMemberAndType_TopLevelStatements(string fixAllScope)
+ => TestInRegularAndScriptAsync($$"""
{|{{fixAllScope}}:if|} (true) if (true) return;
if (false) if (false) return;
@@ -615,9 +566,7 @@ void OtherMethod()
if (true) if (true) return;
}
}
- """;
-
- var expected = """
+ """, """
if (true)
{
if (true)
@@ -641,18 +590,14 @@ void OtherMethod()
if (true) if (true) return;
}
}
- """;
-
- await TestInRegularAndScriptAsync(input, expected);
- }
+ """);
[Theory]
[InlineData("FixAllInContainingMember")]
[InlineData("FixAllInContainingType")]
[Trait(Traits.Feature, Traits.Features.CodeActionsFixAllOccurrences)]
- public async Task TestFixAllInContainingMemberAndType_TopLevelStatements_02(string fixAllScope)
- {
- var input = $$"""
+ public Task TestFixAllInContainingMemberAndType_TopLevelStatements_02(string fixAllScope)
+ => TestInRegularAndScriptAsync($$"""
using System;
{|{{fixAllScope}}:if|} (true) if (true) return;
@@ -669,9 +614,7 @@ void OtherMethod()
}
}
}
- """;
-
- var expected = """
+ """, """
using System;
if (true)
@@ -700,19 +643,14 @@ void OtherMethod()
}
}
}
- """;
-
- await TestInRegularAndScriptAsync(input, expected);
- }
+ """);
[Theory]
[InlineData("FixAllInContainingMember")]
[InlineData("FixAllInContainingType")]
[Trait(Traits.Feature, Traits.Features.CodeActionsFixAllOccurrences)]
- public async Task TestFixAllInContainingMemberAndType_TopLevelStatements_ErrorCase(string fixAllScope)
- {
- // Error case: Global statements should precede non-global statements.
- var input = $$"""
+ public Task TestFixAllInContainingMemberAndType_TopLevelStatements_ErrorCase(string fixAllScope)
+ => TestMissingInRegularAndScriptAsync($$"""
class OtherType
{
void OtherMethod()
@@ -724,8 +662,5 @@ void OtherMethod()
{|{{fixAllScope}}:if|} (true) if (true) return;
if (false) if (false) return;
- """;
-
- await TestMissingInRegularAndScriptAsync(input);
- }
+ """);
}
diff --git a/src/Analyzers/CSharp/Tests/AddBraces/AddBracesTests.cs b/src/Analyzers/CSharp/Tests/AddBraces/AddBracesTests.cs
index a3eed92e3ca07..4323abdea61f5 100644
--- a/src/Analyzers/CSharp/Tests/AddBraces/AddBracesTests.cs
+++ b/src/Analyzers/CSharp/Tests/AddBraces/AddBracesTests.cs
@@ -31,9 +31,8 @@ internal override (DiagnosticAnalyzer, CodeFixProvider) CreateDiagnosticProvider
[InlineData((int)PreferBracesPreference.None)]
[InlineData((int)PreferBracesPreference.WhenMultiline)]
[InlineData((int)PreferBracesPreference.Always)]
- public async Task DoNotFireForIfWithBraces(int bracesPreference)
- {
- await TestMissingInRegularAndScriptAsync(
+ public Task DoNotFireForIfWithBraces(int bracesPreference)
+ => TestMissingInRegularAndScriptAsync(
"""
class Program
{
@@ -47,15 +46,13 @@ static void Main()
}
""",
new TestParameters(options: Option(CSharpCodeStyleOptions.PreferBraces, (PreferBracesPreference)bracesPreference, NotificationOption2.Silent)));
- }
[Theory]
[InlineData((int)PreferBracesPreference.None)]
[InlineData((int)PreferBracesPreference.WhenMultiline)]
[InlineData((int)PreferBracesPreference.Always)]
- public async Task DoNotFireForElseWithBraces(int bracesPreference)
- {
- await TestMissingInRegularAndScriptAsync(
+ public Task DoNotFireForElseWithBraces(int bracesPreference)
+ => TestMissingInRegularAndScriptAsync(
"""
class Program
{
@@ -73,15 +70,13 @@ static void Main()
}
""",
new TestParameters(options: Option(CSharpCodeStyleOptions.PreferBraces, (PreferBracesPreference)bracesPreference, NotificationOption2.Silent)));
- }
[Theory]
[InlineData((int)PreferBracesPreference.None)]
[InlineData((int)PreferBracesPreference.WhenMultiline)]
[InlineData((int)PreferBracesPreference.Always)]
- public async Task DoNotFireForElseWithChildIf(int bracesPreference)
- {
- await TestMissingInRegularAndScriptAsync(
+ public Task DoNotFireForElseWithChildIf(int bracesPreference)
+ => TestMissingInRegularAndScriptAsync(
"""
class Program
{
@@ -95,15 +90,13 @@ static void Main()
}
""",
new TestParameters(options: Option(CSharpCodeStyleOptions.PreferBraces, (PreferBracesPreference)bracesPreference, NotificationOption2.Silent)));
- }
[Theory]
[InlineData((int)PreferBracesPreference.None)]
[InlineData((int)PreferBracesPreference.WhenMultiline)]
[InlineData((int)PreferBracesPreference.Always)]
- public async Task DoNotFireForForWithBraces(int bracesPreference)
- {
- await TestMissingInRegularAndScriptAsync(
+ public Task DoNotFireForForWithBraces(int bracesPreference)
+ => TestMissingInRegularAndScriptAsync(
"""
class Program
{
@@ -117,15 +110,13 @@ static void Main()
}
""",
new TestParameters(options: Option(CSharpCodeStyleOptions.PreferBraces, (PreferBracesPreference)bracesPreference, NotificationOption2.Silent)));
- }
[Theory]
[InlineData((int)PreferBracesPreference.None)]
[InlineData((int)PreferBracesPreference.WhenMultiline)]
[InlineData((int)PreferBracesPreference.Always)]
- public async Task DoNotFireForForEachWithBraces(int bracesPreference)
- {
- await TestMissingInRegularAndScriptAsync(
+ public Task DoNotFireForForEachWithBraces(int bracesPreference)
+ => TestMissingInRegularAndScriptAsync(
"""
class Program
{
@@ -139,15 +130,13 @@ static void Main()
}
""",
new TestParameters(options: Option(CSharpCodeStyleOptions.PreferBraces, (PreferBracesPreference)bracesPreference, NotificationOption2.Silent)));
- }
[Theory]
[InlineData((int)PreferBracesPreference.None)]
[InlineData((int)PreferBracesPreference.WhenMultiline)]
[InlineData((int)PreferBracesPreference.Always)]
- public async Task DoNotFireForWhileWithBraces(int bracesPreference)
- {
- await TestMissingInRegularAndScriptAsync(
+ public Task DoNotFireForWhileWithBraces(int bracesPreference)
+ => TestMissingInRegularAndScriptAsync(
"""
class Program
{
@@ -161,15 +150,13 @@ static void Main()
}
""",
new TestParameters(options: Option(CSharpCodeStyleOptions.PreferBraces, (PreferBracesPreference)bracesPreference, NotificationOption2.Silent)));
- }
[Theory]
[InlineData((int)PreferBracesPreference.None)]
[InlineData((int)PreferBracesPreference.WhenMultiline)]
[InlineData((int)PreferBracesPreference.Always)]
- public async Task DoNotFireForDoWhileWithBraces(int bracesPreference)
- {
- await TestMissingInRegularAndScriptAsync(
+ public Task DoNotFireForDoWhileWithBraces(int bracesPreference)
+ => TestMissingInRegularAndScriptAsync(
"""
class Program
{
@@ -184,15 +171,13 @@ static void Main()
}
""",
new TestParameters(options: Option(CSharpCodeStyleOptions.PreferBraces, (PreferBracesPreference)bracesPreference, NotificationOption2.Silent)));
- }
[Theory]
[InlineData((int)PreferBracesPreference.None)]
[InlineData((int)PreferBracesPreference.WhenMultiline)]
[InlineData((int)PreferBracesPreference.Always)]
- public async Task DoNotFireForUsingWithBraces(int bracesPreference)
- {
- await TestMissingInRegularAndScriptAsync(
+ public Task DoNotFireForUsingWithBraces(int bracesPreference)
+ => TestMissingInRegularAndScriptAsync(
"""
class Program
{
@@ -214,15 +199,13 @@ public void Dispose()
}
""",
new TestParameters(options: Option(CSharpCodeStyleOptions.PreferBraces, (PreferBracesPreference)bracesPreference, NotificationOption2.Silent)));
- }
[Theory]
[InlineData((int)PreferBracesPreference.None)]
[InlineData((int)PreferBracesPreference.WhenMultiline)]
[InlineData((int)PreferBracesPreference.Always)]
- public async Task DoNotFireForUsingWithChildUsing(int bracesPreference)
- {
- await TestMissingInRegularAndScriptAsync(
+ public Task DoNotFireForUsingWithChildUsing(int bracesPreference)
+ => TestMissingInRegularAndScriptAsync(
"""
class Program
{
@@ -251,15 +234,13 @@ public void Dispose()
}
""",
new TestParameters(options: Option(CSharpCodeStyleOptions.PreferBraces, (PreferBracesPreference)bracesPreference, NotificationOption2.Silent)));
- }
[Theory]
[InlineData((int)PreferBracesPreference.None)]
[InlineData((int)PreferBracesPreference.WhenMultiline)]
[InlineData((int)PreferBracesPreference.Always)]
- public async Task DoNotFireForLockWithBraces(int bracesPreference)
- {
- await TestMissingInRegularAndScriptAsync(
+ public Task DoNotFireForLockWithBraces(int bracesPreference)
+ => TestMissingInRegularAndScriptAsync(
"""
class Program
{
@@ -274,15 +255,13 @@ static void Main()
}
""",
new TestParameters(options: Option(CSharpCodeStyleOptions.PreferBraces, (PreferBracesPreference)bracesPreference, NotificationOption2.Silent)));
- }
[Theory]
[InlineData((int)PreferBracesPreference.None)]
[InlineData((int)PreferBracesPreference.WhenMultiline)]
[InlineData((int)PreferBracesPreference.Always)]
- public async Task DoNotFireForLockWithChildLock(int bracesPreference)
- {
- await TestMissingInRegularAndScriptAsync(
+ public Task DoNotFireForLockWithChildLock(int bracesPreference)
+ => TestMissingInRegularAndScriptAsync(
"""
class Program
{
@@ -297,15 +276,13 @@ static void Main()
}
""",
new TestParameters(options: Option(CSharpCodeStyleOptions.PreferBraces, (PreferBracesPreference)bracesPreference, NotificationOption2.Silent)));
- }
[Theory]
[InlineData((int)PreferBracesPreference.None)]
[InlineData((int)PreferBracesPreference.WhenMultiline)]
[InlineData((int)PreferBracesPreference.Always)]
- public async Task DoNotFireForFixedWithChildFixed(int bracesPreference)
- {
- await TestMissingInRegularAndScriptAsync(
+ public Task DoNotFireForFixedWithChildFixed(int bracesPreference)
+ => TestMissingInRegularAndScriptAsync(
"""
class Program
{
@@ -319,15 +296,13 @@ unsafe static void Main()
}
""",
new TestParameters(options: Option(CSharpCodeStyleOptions.PreferBraces, (PreferBracesPreference)bracesPreference, NotificationOption2.Silent)));
- }
[Theory]
[InlineData((int)PreferBracesPreference.None, false)]
[InlineData((int)PreferBracesPreference.WhenMultiline, false)]
[InlineData((int)PreferBracesPreference.Always, true)]
- public async Task FireForFixedWithoutBraces(int bracesPreference, bool expectDiagnostic)
- {
- await TestAsync(
+ public Task FireForFixedWithoutBraces(int bracesPreference, bool expectDiagnostic)
+ => TestAsync(
"""
class Program
{
@@ -354,15 +329,13 @@ unsafe static void Main()
""",
(PreferBracesPreference)bracesPreference,
expectDiagnostic);
- }
[Theory]
[InlineData((int)PreferBracesPreference.None, false)]
[InlineData((int)PreferBracesPreference.WhenMultiline, false)]
[InlineData((int)PreferBracesPreference.Always, true)]
- public async Task FireForIfWithoutBraces(int bracesPreference, bool expectDiagnostic)
- {
- await TestAsync(
+ public Task FireForIfWithoutBraces(int bracesPreference, bool expectDiagnostic)
+ => TestAsync(
"""
class Program
{
@@ -387,15 +360,13 @@ static void Main()
""",
(PreferBracesPreference)bracesPreference,
expectDiagnostic);
- }
[Theory, WorkItem("https://github.com/dotnet/roslyn/issues/57770")]
[InlineData((int)PreferBracesPreference.None, false)]
[InlineData((int)PreferBracesPreference.WhenMultiline, false)]
[InlineData((int)PreferBracesPreference.Always, true)]
- public async Task FireForIfWithoutBracesTopLevel(int bracesPreference, bool expectDiagnostic)
- {
- await TestAsync(
+ public Task FireForIfWithoutBracesTopLevel(int bracesPreference, bool expectDiagnostic)
+ => TestAsync(
"""
[|if|] (true) return;
""",
@@ -407,15 +378,13 @@ await TestAsync(
""",
(PreferBracesPreference)bracesPreference,
expectDiagnostic);
- }
[Theory]
[InlineData((int)PreferBracesPreference.None, false)]
[InlineData((int)PreferBracesPreference.WhenMultiline, true)]
[InlineData((int)PreferBracesPreference.Always, true)]
- public async Task FireForElseWithoutBracesButHasContextBraces(int bracesPreference, bool expectDiagnostic)
- {
- await TestAsync(
+ public Task FireForElseWithoutBracesButHasContextBraces(int bracesPreference, bool expectDiagnostic)
+ => TestAsync(
"""
class Program
{
@@ -442,15 +411,13 @@ static void Main()
""",
(PreferBracesPreference)bracesPreference,
expectDiagnostic);
- }
[Theory]
[InlineData((int)PreferBracesPreference.None, false)]
[InlineData((int)PreferBracesPreference.WhenMultiline, false)]
[InlineData((int)PreferBracesPreference.Always, true)]
- public async Task FireForElseWithoutBraces(int bracesPreference, bool expectDiagnostic)
- {
- await TestAsync(
+ public Task FireForElseWithoutBraces(int bracesPreference, bool expectDiagnostic)
+ => TestAsync(
"""
class Program
{
@@ -477,15 +444,13 @@ static void Main()
""",
(PreferBracesPreference)bracesPreference,
expectDiagnostic);
- }
[Theory]
[InlineData((int)PreferBracesPreference.None, false)]
[InlineData((int)PreferBracesPreference.WhenMultiline, false)]
[InlineData((int)PreferBracesPreference.Always, true)]
- public async Task FireForStandaloneElseWithoutBraces(int bracesPreference, bool expectDiagnostic)
- {
- await TestAsync(
+ public Task FireForStandaloneElseWithoutBraces(int bracesPreference, bool expectDiagnostic)
+ => TestAsync(
"""
class Program
{
@@ -511,15 +476,13 @@ static void Main()
""",
(PreferBracesPreference)bracesPreference,
expectDiagnostic);
- }
[Theory]
[InlineData((int)PreferBracesPreference.None, false)]
[InlineData((int)PreferBracesPreference.WhenMultiline, false)]
[InlineData((int)PreferBracesPreference.Always, true)]
- public async Task FireForIfNestedInElseWithoutBraces(int bracesPreference, bool expectDiagnostic)
- {
- await TestAsync(
+ public Task FireForIfNestedInElseWithoutBraces(int bracesPreference, bool expectDiagnostic)
+ => TestAsync(
"""
class Program
{
@@ -546,15 +509,13 @@ static void Main()
""",
(PreferBracesPreference)bracesPreference,
expectDiagnostic);
- }
[Theory]
[InlineData((int)PreferBracesPreference.None, false)]
[InlineData((int)PreferBracesPreference.WhenMultiline, false)]
[InlineData((int)PreferBracesPreference.Always, true)]
- public async Task FireForIfNestedInElseWithoutBracesWithMultilineContext1(int bracesPreference, bool expectDiagnostic)
- {
- await TestAsync(
+ public Task FireForIfNestedInElseWithoutBracesWithMultilineContext1(int bracesPreference, bool expectDiagnostic)
+ => TestAsync(
"""
class Program
{
@@ -589,15 +550,13 @@ static void Main()
""",
(PreferBracesPreference)bracesPreference,
expectDiagnostic);
- }
[Theory]
[InlineData((int)PreferBracesPreference.None, false)]
[InlineData((int)PreferBracesPreference.WhenMultiline, true)]
[InlineData((int)PreferBracesPreference.Always, true)]
- public async Task FireForIfNestedInElseWithoutBracesWithMultilineContext2(int bracesPreference, bool expectDiagnostic)
- {
- await TestAsync(
+ public Task FireForIfNestedInElseWithoutBracesWithMultilineContext2(int bracesPreference, bool expectDiagnostic)
+ => TestAsync(
"""
class Program
{
@@ -636,15 +595,13 @@ static void Main()
""",
(PreferBracesPreference)bracesPreference,
expectDiagnostic);
- }
[Theory]
[InlineData((int)PreferBracesPreference.None, false)]
[InlineData((int)PreferBracesPreference.WhenMultiline, false)]
[InlineData((int)PreferBracesPreference.Always, true)]
- public async Task FireForIfNestedInElseWithoutBracesWithMultilineContext3(int bracesPreference, bool expectDiagnostic)
- {
- await TestAsync(
+ public Task FireForIfNestedInElseWithoutBracesWithMultilineContext3(int bracesPreference, bool expectDiagnostic)
+ => TestAsync(
"""
class Program
{
@@ -682,15 +639,13 @@ static void Main()
""",
(PreferBracesPreference)bracesPreference,
expectDiagnostic);
- }
[Theory]
[InlineData((int)PreferBracesPreference.None, false)]
[InlineData((int)PreferBracesPreference.WhenMultiline, false)]
[InlineData((int)PreferBracesPreference.Always, true)]
- public async Task FireForIfNestedInElseWithoutBracesWithMultilineContext4(int bracesPreference, bool expectDiagnostic)
- {
- await TestAsync(
+ public Task FireForIfNestedInElseWithoutBracesWithMultilineContext4(int bracesPreference, bool expectDiagnostic)
+ => TestAsync(
"""
class Program
{
@@ -728,7 +683,6 @@ static void Main()
""",
(PreferBracesPreference)bracesPreference,
expectDiagnostic);
- }
#pragma warning disable CA1200 // Avoid using cref tags with a prefix - Remove the suppression when https://github.com/dotnet/roslyn/issues/42611 is fixed.
///
@@ -742,9 +696,8 @@ static void Main()
[InlineData((int)PreferBracesPreference.None, false)]
[InlineData((int)PreferBracesPreference.WhenMultiline, false)]
[InlineData((int)PreferBracesPreference.Always, true)]
- public async Task FireForIfNestedInElseWithoutBracesWithMultilineContext5(int bracesPreference, bool expectDiagnostic)
- {
- await TestAsync(
+ public Task FireForIfNestedInElseWithoutBracesWithMultilineContext5(int bracesPreference, bool expectDiagnostic)
+ => TestAsync(
"""
class Program
{
@@ -782,15 +735,13 @@ static void Main()
""",
(PreferBracesPreference)bracesPreference,
expectDiagnostic);
- }
[Theory]
[InlineData((int)PreferBracesPreference.None, false)]
[InlineData((int)PreferBracesPreference.WhenMultiline, false)]
[InlineData((int)PreferBracesPreference.Always, true)]
- public async Task FireForForWithoutBraces(int bracesPreference, bool expectDiagnostic)
- {
- await TestAsync(
+ public Task FireForForWithoutBraces(int bracesPreference, bool expectDiagnostic)
+ => TestAsync(
"""
class Program
{
@@ -815,15 +766,13 @@ static void Main()
""",
(PreferBracesPreference)bracesPreference,
expectDiagnostic);
- }
[Theory]
[InlineData((int)PreferBracesPreference.None, false)]
[InlineData((int)PreferBracesPreference.WhenMultiline, true)]
[InlineData((int)PreferBracesPreference.Always, true)]
- public async Task FireForMultilineForWithoutBraces1(int bracesPreference, bool expectDiagnostic)
- {
- await TestAsync(
+ public Task FireForMultilineForWithoutBraces1(int bracesPreference, bool expectDiagnostic)
+ => TestAsync(
"""
class Program
{
@@ -852,15 +801,13 @@ static void Main()
""",
(PreferBracesPreference)bracesPreference,
expectDiagnostic);
- }
[Theory]
[InlineData((int)PreferBracesPreference.None, false)]
[InlineData((int)PreferBracesPreference.WhenMultiline, true)]
[InlineData((int)PreferBracesPreference.Always, true)]
- public async Task FireForMultilineForWithoutBraces2(int bracesPreference, bool expectDiagnostic)
- {
- await TestAsync(
+ public Task FireForMultilineForWithoutBraces2(int bracesPreference, bool expectDiagnostic)
+ => TestAsync(
"""
class Program
{
@@ -887,15 +834,13 @@ static void Main()
""",
(PreferBracesPreference)bracesPreference,
expectDiagnostic);
- }
[Theory]
[InlineData((int)PreferBracesPreference.None, false)]
[InlineData((int)PreferBracesPreference.WhenMultiline, true)]
[InlineData((int)PreferBracesPreference.Always, true)]
- public async Task FireForMultilineForWithoutBraces3(int bracesPreference, bool expectDiagnostic)
- {
- await TestAsync(
+ public Task FireForMultilineForWithoutBraces3(int bracesPreference, bool expectDiagnostic)
+ => TestAsync(
"""
class Program
{
@@ -923,15 +868,13 @@ static void Main()
""",
(PreferBracesPreference)bracesPreference,
expectDiagnostic);
- }
[Theory]
[InlineData((int)PreferBracesPreference.None, false)]
[InlineData((int)PreferBracesPreference.WhenMultiline, false)]
[InlineData((int)PreferBracesPreference.Always, true)]
- public async Task FireForForEachWithoutBraces(int bracesPreference, bool expectDiagnostic)
- {
- await TestAsync(
+ public Task FireForForEachWithoutBraces(int bracesPreference, bool expectDiagnostic)
+ => TestAsync(
"""
class Program
{
@@ -956,15 +899,13 @@ static void Main()
""",
(PreferBracesPreference)bracesPreference,
expectDiagnostic);
- }
[Theory]
[InlineData((int)PreferBracesPreference.None, false)]
[InlineData((int)PreferBracesPreference.WhenMultiline, false)]
[InlineData((int)PreferBracesPreference.Always, true)]
- public async Task FireForWhileWithoutBraces(int bracesPreference, bool expectDiagnostic)
- {
- await TestAsync(
+ public Task FireForWhileWithoutBraces(int bracesPreference, bool expectDiagnostic)
+ => TestAsync(
"""
class Program
{
@@ -989,15 +930,13 @@ static void Main()
""",
(PreferBracesPreference)bracesPreference,
expectDiagnostic);
- }
[Theory]
[InlineData((int)PreferBracesPreference.None, false)]
[InlineData((int)PreferBracesPreference.WhenMultiline, false)]
[InlineData((int)PreferBracesPreference.Always, true)]
- public async Task FireForDoWhileWithoutBraces1(int bracesPreference, bool expectDiagnostic)
- {
- await TestAsync(
+ public Task FireForDoWhileWithoutBraces1(int bracesPreference, bool expectDiagnostic)
+ => TestAsync(
"""
class Program
{
@@ -1023,15 +962,13 @@ static void Main()
""",
(PreferBracesPreference)bracesPreference,
expectDiagnostic);
- }
[Theory]
[InlineData((int)PreferBracesPreference.None, false)]
[InlineData((int)PreferBracesPreference.WhenMultiline, false)]
[InlineData((int)PreferBracesPreference.Always, true)]
- public async Task FireForDoWhileWithoutBraces2(int bracesPreference, bool expectDiagnostic)
- {
- await TestAsync(
+ public Task FireForDoWhileWithoutBraces2(int bracesPreference, bool expectDiagnostic)
+ => TestAsync(
"""
class Program
{
@@ -1059,15 +996,13 @@ static void Main()
""",
(PreferBracesPreference)bracesPreference,
expectDiagnostic);
- }
[Theory]
[InlineData((int)PreferBracesPreference.None, false)]
[InlineData((int)PreferBracesPreference.WhenMultiline, true)]
[InlineData((int)PreferBracesPreference.Always, true)]
- public async Task FireForMultilineDoWhileWithoutBraces1(int bracesPreference, bool expectDiagnostic)
- {
- await TestAsync(
+ public Task FireForMultilineDoWhileWithoutBraces1(int bracesPreference, bool expectDiagnostic)
+ => TestAsync(
"""
class Program
{
@@ -1095,15 +1030,13 @@ static void Main()
""",
(PreferBracesPreference)bracesPreference,
expectDiagnostic);
- }
[Theory]
[InlineData((int)PreferBracesPreference.None, false)]
[InlineData((int)PreferBracesPreference.WhenMultiline, false)]
[InlineData((int)PreferBracesPreference.Always, true)]
- public async Task FireForUsingWithoutBraces(int bracesPreference, bool expectDiagnostic)
- {
- await TestAsync(
+ public Task FireForUsingWithoutBraces(int bracesPreference, bool expectDiagnostic)
+ => TestAsync(
"""
class Program
{
@@ -1145,15 +1078,13 @@ public void Dispose()
""",
(PreferBracesPreference)bracesPreference,
expectDiagnostic);
- }
[Theory]
[InlineData((int)PreferBracesPreference.None, false)]
[InlineData((int)PreferBracesPreference.WhenMultiline, false)]
[InlineData((int)PreferBracesPreference.Always, true)]
- public async Task FireForUsingWithoutBracesNestedInUsing(int bracesPreference, bool expectDiagnostic)
- {
- await TestAsync(
+ public Task FireForUsingWithoutBracesNestedInUsing(int bracesPreference, bool expectDiagnostic)
+ => TestAsync(
"""
class Program
{
@@ -1213,15 +1144,13 @@ public void Dispose()
""",
(PreferBracesPreference)bracesPreference,
expectDiagnostic);
- }
[Theory]
[InlineData((int)PreferBracesPreference.None, false)]
[InlineData((int)PreferBracesPreference.WhenMultiline, false)]
[InlineData((int)PreferBracesPreference.Always, true)]
- public async Task FireForMultilineUsingWithoutBracesNestedInUsing1(int bracesPreference, bool expectDiagnostic)
- {
- await TestAsync(
+ public Task FireForMultilineUsingWithoutBracesNestedInUsing1(int bracesPreference, bool expectDiagnostic)
+ => TestAsync(
"""
class Program
{
@@ -1283,15 +1212,13 @@ public void Dispose()
""",
(PreferBracesPreference)bracesPreference,
expectDiagnostic);
- }
[Theory]
[InlineData((int)PreferBracesPreference.None, false)]
[InlineData((int)PreferBracesPreference.WhenMultiline, true)]
[InlineData((int)PreferBracesPreference.Always, true)]
- public async Task FireForMultilineUsingWithoutBracesNestedInUsing2(int bracesPreference, bool expectDiagnostic)
- {
- await TestAsync(
+ public Task FireForMultilineUsingWithoutBracesNestedInUsing2(int bracesPreference, bool expectDiagnostic)
+ => TestAsync(
"""
class Program
{
@@ -1353,15 +1280,13 @@ public void Dispose()
""",
(PreferBracesPreference)bracesPreference,
expectDiagnostic);
- }
[Theory]
[InlineData((int)PreferBracesPreference.None, false)]
[InlineData((int)PreferBracesPreference.WhenMultiline, false)]
[InlineData((int)PreferBracesPreference.Always, true)]
- public async Task FireForLockWithoutBraces(int bracesPreference, bool expectDiagnostic)
- {
- await TestAsync(
+ public Task FireForLockWithoutBraces(int bracesPreference, bool expectDiagnostic)
+ => TestAsync(
"""
class Program
{
@@ -1389,15 +1314,13 @@ static void Main()
""",
(PreferBracesPreference)bracesPreference,
expectDiagnostic);
- }
[Theory]
[InlineData((int)PreferBracesPreference.None, false)]
[InlineData((int)PreferBracesPreference.WhenMultiline, false)]
[InlineData((int)PreferBracesPreference.Always, true)]
- public async Task FireForLockWithoutBracesNestedInLock(int bracesPreference, bool expectDiagnostic)
- {
- await TestAsync(
+ public Task FireForLockWithoutBracesNestedInLock(int bracesPreference, bool expectDiagnostic)
+ => TestAsync(
"""
class Program
{
@@ -1431,16 +1354,14 @@ static void Main()
""",
(PreferBracesPreference)bracesPreference,
expectDiagnostic);
- }
[Theory]
[InlineData((int)PreferBracesPreference.None)]
[InlineData((int)PreferBracesPreference.WhenMultiline)]
[InlineData((int)PreferBracesPreference.Always)]
[WorkItem("https://github.com/dotnet/roslyn/issues/32480")]
- public async Task DoNotFireForIfWhenIntercedingDirectiveBefore(int bracesPreference)
- {
- await TestMissingInRegularAndScriptAsync(
+ public Task DoNotFireForIfWhenIntercedingDirectiveBefore(int bracesPreference)
+ => TestMissingInRegularAndScriptAsync(
"""
#define test
class Program
@@ -1455,16 +1376,14 @@ static void Main()
}
""",
new TestParameters(options: Option(CSharpCodeStyleOptions.PreferBraces, (PreferBracesPreference)bracesPreference, NotificationOption2.Silent)));
- }
[Theory]
[InlineData((int)PreferBracesPreference.None)]
[InlineData((int)PreferBracesPreference.WhenMultiline)]
[InlineData((int)PreferBracesPreference.Always)]
[WorkItem("https://github.com/dotnet/roslyn/issues/32480")]
- public async Task DoNotFireForIfWithIntercedingDirectiveAfter(int bracesPreference)
- {
- await TestMissingInRegularAndScriptAsync(
+ public Task DoNotFireForIfWithIntercedingDirectiveAfter(int bracesPreference)
+ => TestMissingInRegularAndScriptAsync(
"""
#define test
class Program
@@ -1479,16 +1398,14 @@ static void Main()
}
""",
new TestParameters(options: Option(CSharpCodeStyleOptions.PreferBraces, (PreferBracesPreference)bracesPreference, NotificationOption2.Silent)));
- }
[Theory]
[InlineData((int)PreferBracesPreference.None)]
[InlineData((int)PreferBracesPreference.WhenMultiline)]
[InlineData((int)PreferBracesPreference.Always)]
[WorkItem("https://github.com/dotnet/roslyn/issues/32480")]
- public async Task DoNotFireForIfElseWithIntercedingDirectiveInBoth(int bracesPreference)
- {
- await TestMissingInRegularAndScriptAsync(
+ public Task DoNotFireForIfElseWithIntercedingDirectiveInBoth(int bracesPreference)
+ => TestMissingInRegularAndScriptAsync(
"""
#define test
class Program
@@ -1505,16 +1422,14 @@ static void Main()
}
""",
new TestParameters(options: Option(CSharpCodeStyleOptions.PreferBraces, (PreferBracesPreference)bracesPreference, NotificationOption2.Silent)));
- }
[Theory]
[InlineData((int)PreferBracesPreference.None, false)]
[InlineData((int)PreferBracesPreference.WhenMultiline, false)]
[InlineData((int)PreferBracesPreference.Always, true)]
[WorkItem("https://github.com/dotnet/roslyn/issues/32480")]
- public async Task OnlyFireForIfWithIntercedingDirectiveInElseAroundIf(int bracesPreference, bool expectDiagnostic)
- {
- await TestAsync(
+ public Task OnlyFireForIfWithIntercedingDirectiveInElseAroundIf(int bracesPreference, bool expectDiagnostic)
+ => TestAsync(
"""
#define test
class Program
@@ -1550,16 +1465,14 @@ static void Main()
""",
(PreferBracesPreference)bracesPreference,
expectDiagnostic);
- }
[Theory]
[InlineData((int)PreferBracesPreference.None, false)]
[InlineData((int)PreferBracesPreference.WhenMultiline, false)]
[InlineData((int)PreferBracesPreference.Always, true)]
[WorkItem("https://github.com/dotnet/roslyn/issues/32480")]
- public async Task OnlyFireForElseWithIntercedingDirectiveInIfAroundElse(int bracesPreference, bool expectDiagnostic)
- {
- await TestAsync(
+ public Task OnlyFireForElseWithIntercedingDirectiveInIfAroundElse(int bracesPreference, bool expectDiagnostic)
+ => TestAsync(
"""
#define test
class Program
@@ -1595,16 +1508,14 @@ static void Main()
""",
(PreferBracesPreference)bracesPreference,
expectDiagnostic);
- }
[Theory]
[InlineData((int)PreferBracesPreference.None, false)]
[InlineData((int)PreferBracesPreference.WhenMultiline, false)]
[InlineData((int)PreferBracesPreference.Always, true)]
[WorkItem("https://github.com/dotnet/roslyn/issues/32480")]
- public async Task OnlyFireForElseWithIntercedingDirectiveInIf(int bracesPreference, bool expectDiagnostic)
- {
- await TestAsync(
+ public Task OnlyFireForElseWithIntercedingDirectiveInIf(int bracesPreference, bool expectDiagnostic)
+ => TestAsync(
"""
#define test
class Program
@@ -1640,16 +1551,14 @@ static void Main()
""",
(PreferBracesPreference)bracesPreference,
expectDiagnostic);
- }
[Theory]
[InlineData((int)PreferBracesPreference.None, false)]
[InlineData((int)PreferBracesPreference.WhenMultiline, false)]
[InlineData((int)PreferBracesPreference.Always, true)]
[WorkItem("https://github.com/dotnet/roslyn/issues/32480")]
- public async Task OnlyFireForIfWithIntercedingDirectiveInElse(int bracesPreference, bool expectDiagnostic)
- {
- await TestAsync(
+ public Task OnlyFireForIfWithIntercedingDirectiveInElse(int bracesPreference, bool expectDiagnostic)
+ => TestAsync(
"""
#define test
class Program
@@ -1685,16 +1594,14 @@ static void Main()
""",
(PreferBracesPreference)bracesPreference,
expectDiagnostic);
- }
[Theory]
[InlineData((int)PreferBracesPreference.None, false)]
[InlineData((int)PreferBracesPreference.WhenMultiline, true)]
[InlineData((int)PreferBracesPreference.Always, true)]
[WorkItem("https://github.com/dotnet/roslyn/issues/32480")]
- public async Task FireForIfElseWithDirectiveAroundIf(int bracesPreference, bool expectDiagnostic)
- {
- await TestAsync(
+ public Task FireForIfElseWithDirectiveAroundIf(int bracesPreference, bool expectDiagnostic)
+ => TestAsync(
"""
#define test
class Program
@@ -1734,16 +1641,14 @@ static void Main()
""",
(PreferBracesPreference)bracesPreference,
expectDiagnostic);
- }
[Theory]
[InlineData((int)PreferBracesPreference.None, false)]
[InlineData((int)PreferBracesPreference.WhenMultiline, true)]
[InlineData((int)PreferBracesPreference.Always, true)]
[WorkItem("https://github.com/dotnet/roslyn/issues/32480")]
- public async Task FireForIfElseWithDirectiveAroundElse(int bracesPreference, bool expectDiagnostic)
- {
- await TestAsync(
+ public Task FireForIfElseWithDirectiveAroundElse(int bracesPreference, bool expectDiagnostic)
+ => TestAsync(
"""
#define test
class Program
@@ -1783,16 +1688,14 @@ static void Main()
""",
(PreferBracesPreference)bracesPreference,
expectDiagnostic);
- }
[Theory]
[InlineData((int)PreferBracesPreference.None, false)]
[InlineData((int)PreferBracesPreference.WhenMultiline, false)]
[InlineData((int)PreferBracesPreference.Always, true)]
[WorkItem("https://github.com/dotnet/roslyn/issues/32480")]
- public async Task FireForIfWithoutIntercedingDirective(int bracesPreference, bool expectDiagnostic)
- {
- await TestAsync(
+ public Task FireForIfWithoutIntercedingDirective(int bracesPreference, bool expectDiagnostic)
+ => TestAsync(
"""
#define test
class Program
@@ -1824,16 +1727,14 @@ static void Main()
""",
(PreferBracesPreference)bracesPreference,
expectDiagnostic);
- }
[Theory]
[InlineData((int)PreferBracesPreference.None, false)]
[InlineData((int)PreferBracesPreference.WhenMultiline, false)]
[InlineData((int)PreferBracesPreference.Always, true)]
[WorkItem("https://github.com/dotnet/roslyn/issues/32480")]
- public async Task FireForIfWithDirectiveAfterEmbeddedStatement(int bracesPreference, bool expectDiagnostic)
- {
- await TestAsync(
+ public Task FireForIfWithDirectiveAfterEmbeddedStatement(int bracesPreference, bool expectDiagnostic)
+ => TestAsync(
"""
#define test
class Program
@@ -1865,16 +1766,14 @@ static void Main()
""",
(PreferBracesPreference)bracesPreference,
expectDiagnostic);
- }
[Theory]
[InlineData((int)PreferBracesPreference.None, false)]
[InlineData((int)PreferBracesPreference.WhenMultiline, false)]
[InlineData((int)PreferBracesPreference.Always, true)]
[WorkItem("https://github.com/dotnet/roslyn/issues/32480")]
- public async Task FireForInnerNestedStatementWhenDirectiveEntirelyInside(int bracesPreference, bool expectDiagnostic)
- {
- await TestAsync(
+ public Task FireForInnerNestedStatementWhenDirectiveEntirelyInside(int bracesPreference, bool expectDiagnostic)
+ => TestAsync(
"""
#define test
class Program
@@ -1908,16 +1807,14 @@ static void Main()
""",
(PreferBracesPreference)bracesPreference,
expectDiagnostic);
- }
[Theory]
[InlineData((int)PreferBracesPreference.None, false)]
[InlineData((int)PreferBracesPreference.WhenMultiline, true)]
[InlineData((int)PreferBracesPreference.Always, true)]
[WorkItem("https://github.com/dotnet/roslyn/issues/32480")]
- public async Task FireForOuterNestedStatementWhenDirectiveEntirelyInside(int bracesPreference, bool expectDiagnostic)
- {
- await TestAsync(
+ public Task FireForOuterNestedStatementWhenDirectiveEntirelyInside(int bracesPreference, bool expectDiagnostic)
+ => TestAsync(
"""
#define test
class Program
@@ -1951,7 +1848,6 @@ static void Main()
""",
(PreferBracesPreference)bracesPreference,
expectDiagnostic);
- }
private async Task TestAsync(string initialMarkup, string expectedMarkup, PreferBracesPreference bracesPreference, bool expectDiagnostic)
{
diff --git a/src/Analyzers/CSharp/Tests/AddExplicitCast/AddExplicitCastTests.cs b/src/Analyzers/CSharp/Tests/AddExplicitCast/AddExplicitCastTests.cs
index dd4ed4904b05c..483305cd2fb86 100644
--- a/src/Analyzers/CSharp/Tests/AddExplicitCast/AddExplicitCastTests.cs
+++ b/src/Analyzers/CSharp/Tests/AddExplicitCast/AddExplicitCastTests.cs
@@ -26,9 +26,8 @@ protected override ImmutableArray MassageActions(ImmutableArray FlattenActions(actions);
[Fact]
- public async Task SimpleVariableDeclaration()
- {
- await TestInRegularAndScriptAsync(
+ public Task SimpleVariableDeclaration()
+ => TestInRegularAndScriptAsync(
"""
class Program
{
@@ -53,12 +52,10 @@ void M()
}
}
""");
- }
[Fact]
- public async Task SimpleVariableDeclarationWithFunctionInnvocation()
- {
- await TestInRegularAndScriptAsync(
+ public Task SimpleVariableDeclarationWithFunctionInnvocation()
+ => TestInRegularAndScriptAsync(
"""
class Program
{
@@ -93,12 +90,10 @@ void M()
}
}
""");
- }
[Fact]
- public async Task ReturnStatementWithObject()
- {
- await TestInRegularAndScriptAsync(
+ public Task ReturnStatementWithObject()
+ => TestInRegularAndScriptAsync(
"""
class Program
{
@@ -123,12 +118,10 @@ Derived returnBase() {
}
}
""");
- }
[Fact]
- public async Task ReturnStatementWithIEnumerable()
- {
- await TestInRegularAndScriptAsync(
+ public Task ReturnStatementWithIEnumerable()
+ => TestInRegularAndScriptAsync(
"""
using System.Collections.Generic;
class Program
@@ -155,12 +148,10 @@ IEnumerable returnBase() {
}
}
""");
- }
[Fact]
- public async Task ReturnStatementWithIEnumerator()
- {
- await TestInRegularAndScriptAsync(
+ public Task ReturnStatementWithIEnumerator()
+ => TestInRegularAndScriptAsync(
"""
using System.Collections.Generic;
class Program
@@ -187,12 +178,10 @@ IEnumerator returnBase() {
}
}
""");
- }
[Fact]
- public async Task ReturnStatementWithFunctionInnvocation()
- {
- await TestInRegularAndScriptAsync(
+ public Task ReturnStatementWithFunctionInnvocation()
+ => TestInRegularAndScriptAsync(
"""
class Program
{
@@ -225,12 +214,10 @@ Derived returnDerived() {
}
}
""");
- }
[Fact]
- public async Task SimpleFunctionArgumentsWithObject1()
- {
- await TestInRegularAndScriptAsync(
+ public Task SimpleFunctionArgumentsWithObject1()
+ => TestInRegularAndScriptAsync(
"""
class Program
{
@@ -269,12 +256,10 @@ void M() {
}
}
""");
- }
[Fact]
- public async Task SimpleFunctionArgumentsWithObject2()
- {
- await TestInRegularAndScriptAsync(
+ public Task SimpleFunctionArgumentsWithObject2()
+ => TestInRegularAndScriptAsync(
"""
class Program
{
@@ -313,12 +298,10 @@ void M() {
}
}
""");
- }
[Fact]
- public async Task SimpleFunctionArgumentsWithFunctionInvocation()
- {
- await TestInRegularAndScriptAsync(
+ public Task SimpleFunctionArgumentsWithFunctionInvocation()
+ => TestInRegularAndScriptAsync(
"""
class Program
{
@@ -355,12 +338,10 @@ void M() {
}
}
""");
- }
[Fact]
- public async Task YieldReturnStatementWithObject()
- {
- await TestInRegularAndScriptAsync(
+ public Task YieldReturnStatementWithObject()
+ => TestInRegularAndScriptAsync(
"""
using System.Collections.Generic;
class Program
@@ -387,12 +368,10 @@ IEnumerable returnDerived() {
}
}
""");
- }
[Fact]
- public async Task SimpleConstructorArgumentsWithObject()
- {
- await TestInRegularAndScriptAsync(
+ public Task SimpleConstructorArgumentsWithObject()
+ => TestInRegularAndScriptAsync(
"""
class Program
{
@@ -423,12 +402,10 @@ void M() {
}
}
""");
- }
[Fact]
- public async Task ReturnTypeWithTask()
- {
- await TestInRegularAndScriptAsync(
+ public Task ReturnTypeWithTask()
+ => TestInRegularAndScriptAsync(
"""
using System.Threading.Tasks;
@@ -457,12 +434,10 @@ async Task M() {
}
}
""");
- }
[Fact]
- public async Task VariableDeclarationWithPublicFieldMember()
- {
- await TestInRegularAndScriptAsync(
+ public Task VariableDeclarationWithPublicFieldMember()
+ => TestInRegularAndScriptAsync(
"""
class Program
{
@@ -497,12 +472,10 @@ void M() {
}
}
""");
- }
[Fact]
- public async Task VariableDeclarationWithPrivateFieldMember()
- {
- await TestMissingInRegularAndScriptAsync(
+ public Task VariableDeclarationWithPrivateFieldMember()
+ => TestMissingInRegularAndScriptAsync(
"""
class Program
{
@@ -520,12 +493,10 @@ void M() {
}
}
""");
- }
[Fact]
- public async Task PublicMemberFunctionArgument1()
- {
- await TestInRegularAndScriptAsync(
+ public Task PublicMemberFunctionArgument1()
+ => TestInRegularAndScriptAsync(
"""
using System.Collections.Generic;
@@ -556,12 +527,10 @@ void M() {
}
}
""");
- }
[Fact]
- public async Task PublicMemberFunctionArgument2()
- {
- await TestInRegularAndScriptAsync(
+ public Task PublicMemberFunctionArgument2()
+ => TestInRegularAndScriptAsync(
"""
class Program
{
@@ -594,12 +563,10 @@ void M() {
}
}
""");
- }
[Fact]
- public async Task PrivateMemberFunctionArgument()
- {
- await TestMissingInRegularAndScriptAsync(
+ public Task PrivateMemberFunctionArgument()
+ => TestMissingInRegularAndScriptAsync(
"""
class Program
{
@@ -616,12 +583,10 @@ void M() {
}
}
""");
- }
[Fact]
- public async Task MemberFunctions()
- {
- await TestInRegularAndScriptAsync(
+ public Task MemberFunctions()
+ => TestInRegularAndScriptAsync(
"""
class Program
{
@@ -656,12 +621,10 @@ void M() {
}
}
""");
- }
[Fact]
- public async Task BaseConstructorArgument()
- {
- await TestInRegularAndScriptAsync(
+ public Task BaseConstructorArgument()
+ => TestInRegularAndScriptAsync(
"""
class Program
{
@@ -688,12 +651,10 @@ public Derived_Test (Base b) : base((Derived)b) {}
}
}
""");
- }
[Fact]
- public async Task ThisConstructorArgument()
- {
- await TestInRegularAndScriptAsync(
+ public Task ThisConstructorArgument()
+ => TestInRegularAndScriptAsync(
"""
class Program
{
@@ -716,12 +677,10 @@ public Test(Base b, int i) : this((Derived)b) {}
}
}
""");
- }
[Fact]
- public async Task LambdaFunction1()
- {
- await TestInRegularAndScriptAsync(
+ public Task LambdaFunction1()
+ => TestInRegularAndScriptAsync(
"""
using System;
@@ -746,12 +705,10 @@ void M() {
}
}
""");
- }
[Fact]
- public async Task LambdaFunction2()
- {
- await TestInRegularAndScriptAsync(
+ public Task LambdaFunction2()
+ => TestInRegularAndScriptAsync(
"""
using System;
@@ -782,12 +739,10 @@ void Goo() {
}
}
""");
- }
[Fact]
- public async Task LambdaFunction3()
- {
- await TestInRegularAndScriptAsync(
+ public Task LambdaFunction3()
+ => TestInRegularAndScriptAsync(
"""
using System;
@@ -818,12 +773,10 @@ void Goo() {
}
}
""");
- }
[Fact]
- public async Task LambdaFunction4()
- {
- await TestInRegularAndScriptAsync(
+ public Task LambdaFunction4()
+ => TestInRegularAndScriptAsync(
"""
using System;
@@ -854,12 +807,10 @@ Derived Goo() {
}
}
""");
- }
[Fact]
- public async Task LambdaFunction5_ReturnStatement()
- {
- await TestMissingInRegularAndScriptAsync(
+ public Task LambdaFunction5_ReturnStatement()
+ => TestMissingInRegularAndScriptAsync(
"""
using System;
@@ -873,12 +824,10 @@ Action Goo() {
}
}
""");
- }
[Fact]
- public async Task LambdaFunction6_Arguments()
- {
- await TestInRegularAndScriptAsync(
+ public Task LambdaFunction6_Arguments()
+ => TestInRegularAndScriptAsync(
"""
using System;
@@ -909,12 +858,10 @@ void Goo() {
}
}
""");
- }
[Fact]
- public async Task LambdaFunction7_Arguments()
- {
- await TestMissingInRegularAndScriptAsync(
+ public Task LambdaFunction7_Arguments()
+ => TestMissingInRegularAndScriptAsync(
"""
using System;
@@ -930,12 +877,10 @@ void Goo() {
}
}
""");
- }
[Fact]
- public async Task LambdaFunction8_Arguments()
- {
- await TestInRegularAndScriptAsync(
+ public Task LambdaFunction8_Arguments()
+ => TestInRegularAndScriptAsync(
"""
using System;
@@ -966,12 +911,10 @@ void Goo() {
}
}
""");
- }
[Fact]
- public async Task LambdaFunction9_Arguments()
- {
- await TestMissingInRegularAndScriptAsync(
+ public Task LambdaFunction9_Arguments()
+ => TestMissingInRegularAndScriptAsync(
"""
using System;
@@ -987,12 +930,10 @@ void Goo() {
}
}
""");
- }
[Fact]
- public async Task InheritInterfaces1()
- {
- await TestInRegularAndScriptAsync(
+ public Task InheritInterfaces1()
+ => TestInRegularAndScriptAsync(
"""
class Program
{
@@ -1017,12 +958,10 @@ void Goo(Base2 b) {
}
}
""");
- }
[Fact]
- public async Task InheritInterfaces2()
- {
- await TestInRegularAndScriptAsync(
+ public Task InheritInterfaces2()
+ => TestInRegularAndScriptAsync(
"""
class Program
{
@@ -1049,12 +988,10 @@ void Goo(Base2 b) {
}
}
""");
- }
[Fact]
- public async Task InheritInterfaces3()
- {
- await TestInRegularAndScriptAsync(
+ public Task InheritInterfaces3()
+ => TestInRegularAndScriptAsync(
"""
class Program
{
@@ -1077,12 +1014,10 @@ Base2 Goo(Base1 b) {
}
}
""");
- }
[Fact]
- public async Task InheritInterfaces4()
- {
- await TestInRegularAndScriptAsync(
+ public Task InheritInterfaces4()
+ => TestInRegularAndScriptAsync(
"""
class Program
{
@@ -1105,12 +1040,10 @@ void Goo(Base1 b) {
}
}
""");
- }
[Fact]
- public async Task InheritInterfaces5()
- {
- await TestInRegularAndScriptAsync(
+ public Task InheritInterfaces5()
+ => TestInRegularAndScriptAsync(
"""
class Program
{
@@ -1141,12 +1074,10 @@ void M(Base1 b) {
}
}
""");
- }
[Fact]
- public async Task GenericType()
- {
- await TestInRegularAndScriptAsync(
+ public Task GenericType()
+ => TestInRegularAndScriptAsync(
"""
using System;
class Program
@@ -1175,12 +1106,10 @@ void M()
}
}
""");
- }
[Fact]
- public async Task GenericType2()
- {
- await TestInRegularAndScriptAsync(
+ public Task GenericType2()
+ => TestInRegularAndScriptAsync(
"""
using System;
class Program
@@ -1211,12 +1140,10 @@ void M()
}
}
""");
- }
[Fact]
- public async Task GenericType3()
- {
- await TestInRegularAndScriptAsync(
+ public Task GenericType3()
+ => TestInRegularAndScriptAsync(
"""
using System;
class Program
@@ -1243,12 +1170,10 @@ Func Goo(Func func)
}
}
""");
- }
[Fact]
- public async Task GenericType4()
- {
- await TestInRegularAndScriptAsync(
+ public Task GenericType4()
+ => TestInRegularAndScriptAsync(
"""
class Program
{
@@ -1281,12 +1206,10 @@ public interface A where T : IA { }
public class B : A where T : CB { }
}
""");
- }
[Fact]
- public async Task GenericType5()
- {
- await TestMissingInRegularAndScriptAsync(
+ public Task GenericType5()
+ => TestMissingInRegularAndScriptAsync(
"""
class Program
{
@@ -1303,12 +1226,10 @@ public class A where T : IA { }
public class B : A where T : IB { }
}
""");
- }
[Fact]
- public async Task GenericType6()
- {
- await TestInRegularAndScriptAsync(
+ public Task GenericType6()
+ => TestInRegularAndScriptAsync(
"""
class Program
{
@@ -1341,12 +1262,10 @@ public interface A where T : IA { }
public class B : A where T : IB { }
}
""");
- }
[Fact]
- public async Task ObjectInitializer()
- {
- await TestMissingInRegularAndScriptAsync(
+ public Task ObjectInitializer()
+ => TestMissingInRegularAndScriptAsync(
"""
class Program
{
@@ -1362,12 +1281,10 @@ void M() {
}
}
""");
- }
[Fact]
- public async Task ObjectInitializer2()
- {
- await TestInRegularAndScriptAsync(
+ public Task ObjectInitializer2()
+ => TestInRegularAndScriptAsync(
"""
class Program
{
@@ -1398,12 +1315,10 @@ void M() {
}
}
""");
- }
[Fact]
- public async Task ObjectInitializer3()
- {
- await TestMissingInRegularAndScriptAsync(
+ public Task ObjectInitializer3()
+ => TestMissingInRegularAndScriptAsync(
"""
class Program
{
@@ -1418,12 +1333,10 @@ Derived returnDerived() {
}
}
""");
- }
[Fact]
- public async Task ObjectInitializer4()
- {
- await TestInRegularAndScriptAsync(
+ public Task ObjectInitializer4()
+ => TestInRegularAndScriptAsync(
"""
class Program
{
@@ -1452,12 +1365,10 @@ Derived returnDerived() {
}
}
""");
- }
[Fact]
- public async Task ObjectInitializer5()
- {
- await TestMissingInRegularAndScriptAsync(
+ public Task ObjectInitializer5()
+ => TestMissingInRegularAndScriptAsync(
"""
class Program
{
@@ -1473,12 +1384,10 @@ void Goo() {
}
}
""");
- }
[Fact]
- public async Task ObjectInitializer6()
- {
- await TestInRegularAndScriptAsync(
+ public Task ObjectInitializer6()
+ => TestInRegularAndScriptAsync(
"""
class Program
{
@@ -1509,12 +1418,10 @@ void Goo() {
}
}
""");
- }
[Fact]
- public async Task ObjectInitializer7()
- {
- await TestMissingInRegularAndScriptAsync(
+ public Task ObjectInitializer7()
+ => TestMissingInRegularAndScriptAsync(
"""
class Program
{
@@ -1530,12 +1437,10 @@ void Goo() {
}
}
""");
- }
[Fact]
- public async Task RedundantCast1()
- {
- await TestInRegularAndScriptAsync(
+ public Task RedundantCast1()
+ => TestInRegularAndScriptAsync(
"""
class Program
{
@@ -1558,12 +1463,10 @@ void Goo() {
}
}
""");
- }
[Fact]
- public async Task RedundantCast2()
- {
- await TestInRegularAndScriptAsync(
+ public Task RedundantCast2()
+ => TestInRegularAndScriptAsync(
"""
class Program
{
@@ -1588,12 +1491,10 @@ void Goo() {
}
}
""");
- }
[Fact]
- public async Task RedundantCast3()
- {
- await TestInRegularAndScriptAsync(
+ public Task RedundantCast3()
+ => TestInRegularAndScriptAsync(
"""
class Program
{
@@ -1618,12 +1519,10 @@ void Goo() {
}
}
""");
- }
[Fact]
- public async Task RedundantCast4()
- {
- await TestInRegularAndScriptAsync(
+ public Task RedundantCast4()
+ => TestInRegularAndScriptAsync(
"""
class Program
{
@@ -1650,12 +1549,10 @@ void Goo() {
}
}
""");
- }
[Fact]
- public async Task ExactMethodCandidate()
- {
- await TestMissingInRegularAndScriptAsync(
+ public Task ExactMethodCandidate()
+ => TestMissingInRegularAndScriptAsync(
"""
class Program
{
@@ -1676,12 +1573,10 @@ void M()
}
}
""");
- }
[Fact]
- public async Task MethodCandidates1_ArgumentsInOrder_NoLabels()
- {
- await TestInRegularAndScriptAsync(
+ public Task MethodCandidates1_ArgumentsInOrder_NoLabels()
+ => TestInRegularAndScriptAsync(
"""
class Program
{
@@ -1714,12 +1609,10 @@ void M()
}
}
""");
- }
[Fact]
- public async Task MethodCandidates2_ArgumentsInOrder_NoLabels()
- {
- await TestInRegularAndScriptAsync(
+ public Task MethodCandidates2_ArgumentsInOrder_NoLabels()
+ => TestInRegularAndScriptAsync(
"""
class Program
{
@@ -1756,12 +1649,10 @@ void M()
}
}
""");
- }
[Fact]
- public async Task MethodCandidates3_ArgumentsInOrder_NoLabels_Params()
- {
- await TestInRegularAndScriptAsync(
+ public Task MethodCandidates3_ArgumentsInOrder_NoLabels_Params()
+ => TestInRegularAndScriptAsync(
"""
class Program
{
@@ -1798,12 +1689,10 @@ void M()
}
}
""");
- }
[Fact]
- public async Task MethodCandidates4_ArgumentsInOrder_NoLabels_Params()
- {
- await TestInRegularAndScriptAsync(
+ public Task MethodCandidates4_ArgumentsInOrder_NoLabels_Params()
+ => TestInRegularAndScriptAsync(
"""
class Program
{
@@ -1840,12 +1729,10 @@ void M()
}
}
""");
- }
[Fact]
- public async Task MethodCandidates5_ArgumentsInOrder_NoLabels_Params()
- {
- await TestInRegularAndScriptAsync(
+ public Task MethodCandidates5_ArgumentsInOrder_NoLabels_Params()
+ => TestInRegularAndScriptAsync(
"""
class Program
{
@@ -1882,12 +1769,10 @@ void M()
}
}
""");
- }
[Fact]
- public async Task MethodCandidates6_ArgumentsInOrder_NoLabels_Params()
- {
- await TestInRegularAndScriptAsync(
+ public Task MethodCandidates6_ArgumentsInOrder_NoLabels_Params()
+ => TestInRegularAndScriptAsync(
"""
class Program
{
@@ -1922,12 +1807,10 @@ void M()
}
}
""");
- }
[Fact]
- public async Task MethodCandidates7_ArgumentsInOrder_NoLabels_Params()
- {
- await TestInRegularAndScriptAsync(
+ public Task MethodCandidates7_ArgumentsInOrder_NoLabels_Params()
+ => TestInRegularAndScriptAsync(
"""
class Program
{
@@ -1962,12 +1845,10 @@ void M()
}
}
""");
- }
[Fact]
- public async Task MethodCandidates8_ArgumentsInOrder_NoLabels()
- {
- await TestInRegularAndScriptAsync(
+ public Task MethodCandidates8_ArgumentsInOrder_NoLabels()
+ => TestInRegularAndScriptAsync(
"""
namespace ExtensionMethods
{
@@ -2012,12 +1893,10 @@ public static void Goo(this string str, Derived d, Derived d2) { }
}
}
""");
- }
[Fact]
- public async Task MethodCandidates9_ArgumentsOutOfOrder_NoLabels()
- {
- await TestMissingInRegularAndScriptAsync(
+ public Task MethodCandidates9_ArgumentsOutOfOrder_NoLabels()
+ => TestMissingInRegularAndScriptAsync(
"""
class Program
{
@@ -2035,12 +1914,10 @@ void M()
}
}
""");
- }
[Fact]
- public async Task MethodCandidates10_ArgumentsInOrder_SomeLabels()
- {
- await TestInRegularAndScriptAsync(
+ public Task MethodCandidates10_ArgumentsInOrder_SomeLabels()
+ => TestInRegularAndScriptAsync(
"""
class Program
{
@@ -2075,12 +1952,10 @@ void M()
}
}
""");
- }
[Fact]
- public async Task MethodCandidates11_ArgumentsInOrder_SomeLabels_Params()
- {
- await TestInRegularAndScriptAsync(
+ public Task MethodCandidates11_ArgumentsInOrder_SomeLabels_Params()
+ => TestInRegularAndScriptAsync(
"""
class Program
{
@@ -2117,12 +1992,10 @@ void M()
}
}
""");
- }
[Fact]
- public async Task MethodCandidates12_ArgumentsInOrder_SomeLabels_Params()
- {
- await TestInRegularAndScriptAsync(
+ public Task MethodCandidates12_ArgumentsInOrder_SomeLabels_Params()
+ => TestInRegularAndScriptAsync(
"""
class Program
{
@@ -2159,12 +2032,10 @@ void M()
}
}
""");
- }
[Fact]
- public async Task MethodCandidates13_ArgumentsOutOfOrder_SomeLabels()
- {
- await TestMissingInRegularAndScriptAsync(
+ public Task MethodCandidates13_ArgumentsOutOfOrder_SomeLabels()
+ => TestMissingInRegularAndScriptAsync(
"""
class Program
{
@@ -2183,12 +2054,10 @@ void M()
}
}
""");
- }
[Fact]
- public async Task MethodCandidates14_ArgumentsOutOfOrder_AllLabels()
- {
- await TestInRegularAndScriptAsync(
+ public Task MethodCandidates14_ArgumentsOutOfOrder_AllLabels()
+ => TestInRegularAndScriptAsync(
"""
class Program
{
@@ -2225,12 +2094,10 @@ void M()
}
}
""");
- }
[Fact]
- public async Task MethodCandidates15_ArgumentsOutOfOrder_AllLabels()
- {
- await TestMissingInRegularAndScriptAsync(
+ public Task MethodCandidates15_ArgumentsOutOfOrder_AllLabels()
+ => TestMissingInRegularAndScriptAsync(
"""
class Program
{
@@ -2249,12 +2116,10 @@ void M()
}
}
""");
- }
[Fact]
- public async Task MethodCandidates17_ArgumentsInOrder_SomeLabels()
- {
- await TestInRegularAndScriptAsync(
+ public Task MethodCandidates17_ArgumentsInOrder_SomeLabels()
+ => TestInRegularAndScriptAsync(
"""
class Program
{
@@ -2289,12 +2154,10 @@ void M()
}
}
""");
- }
[Fact]
- public async Task MethodCandidates18_ArgumentsInOrder_SomeLabels()
- {
- await TestInRegularAndScriptAsync(
+ public Task MethodCandidates18_ArgumentsInOrder_SomeLabels()
+ => TestInRegularAndScriptAsync(
"""
class Program
{
@@ -2331,12 +2194,10 @@ void M()
}
}
""");
- }
[Fact]
- public async Task MethodCandidates19_ArgumentsInOrder_NoLabels_Params()
- {
- await TestMissingInRegularAndScriptAsync(
+ public Task MethodCandidates19_ArgumentsInOrder_NoLabels_Params()
+ => TestMissingInRegularAndScriptAsync(
"""
class Program
{
@@ -2355,12 +2216,10 @@ void M()
}
}
""");
- }
[Fact]
- public async Task MethodCandidates20_ArgumentsInOrder_NoLabels_Params()
- {
- await TestMissingInRegularAndScriptAsync(
+ public Task MethodCandidates20_ArgumentsInOrder_NoLabels_Params()
+ => TestMissingInRegularAndScriptAsync(
"""
class Program
{
@@ -2379,12 +2238,10 @@ void M()
}
}
""");
- }
[Fact]
- public async Task MethodCandidates21_ArgumentsInOrder_Labels()
- {
- await TestMissingInRegularAndScriptAsync(
+ public Task MethodCandidates21_ArgumentsInOrder_Labels()
+ => TestMissingInRegularAndScriptAsync(
"""
class Program
{
@@ -2400,12 +2257,10 @@ void M()
}
}
""");
- }
[Fact]
- public async Task MethodCandidates22_ArgumentsInOrder()
- {
- await TestMissingInRegularAndScriptAsync(
+ public Task MethodCandidates22_ArgumentsInOrder()
+ => TestMissingInRegularAndScriptAsync(
"""
class Program
{
@@ -2424,12 +2279,10 @@ void M()
}
}
""");
- }
[Fact]
- public async Task ConstructorCandidates1()
- {
- await TestInRegularAndScriptAsync(
+ public Task ConstructorCandidates1()
+ => TestInRegularAndScriptAsync(
"""
class Program
{
@@ -2472,12 +2325,10 @@ void M()
}
}
""");
- }
[Fact]
- public async Task ConstructorCandidates2()
- {
- await TestInRegularAndScriptAsync(
+ public Task ConstructorCandidates2()
+ => TestInRegularAndScriptAsync(
"""
class Program
{
@@ -2524,12 +2375,10 @@ void M()
}
}
""");
- }
[Fact]
- public async Task ConstructorCandidates3()
- {
- await TestInRegularAndScriptAsync(
+ public Task ConstructorCandidates3()
+ => TestInRegularAndScriptAsync(
"""
class Program
{
@@ -2560,7 +2409,6 @@ public Test(string s, Base b, int i, params object[] list) : this(d : (Derived)b
}
}
""");
- }
[Fact]
public async Task MultipleOptions1()
@@ -2588,8 +2436,7 @@ public Test(string s, Base b, int i, params object[] list) : this(d : [||]b, s :
Assert.Equal(2, actions.Length);
}
- var expect_0 =
- """
+ await TestInRegularAndScriptAsync(initialMarkup, """
class Program
{
class Base { }
@@ -2604,12 +2451,9 @@ public Test(string s, Base b, int i, params object[] list) : this(d : (Derived)b
Test(string s, Derived2 d, int i) { }
}
}
- """;
- await TestInRegularAndScriptAsync(initialMarkup, expect_0, index: 0,
+ """, index: 0,
title: string.Format(CodeFixesResources.Convert_type_to_0, "Derived"));
-
- var expect_1 =
- """
+ await TestInRegularAndScriptAsync(initialMarkup, """
class Program
{
class Base { }
@@ -2624,8 +2468,7 @@ public Test(string s, Base b, int i, params object[] list) : this(d : (Derived2)
Test(string s, Derived2 d, int i) { }
}
}
- """;
- await TestInRegularAndScriptAsync(initialMarkup, expect_1, index: 1,
+ """, index: 1,
title: string.Format(CodeFixesResources.Convert_type_to_0, "Derived2"));
}
@@ -2656,8 +2499,7 @@ public Test(string s, Base b, int i, params object[] list) : this(d : [||]b, s :
Assert.Equal(2, actions.Length);
}
- var expect_0 =
- """
+ await TestInRegularAndScriptAsync(initialMarkup, """
class Program
{
class Base { }
@@ -2672,12 +2514,9 @@ public Test(string s, Base b, int i, params object[] list) : this(d : (Derived)b
Test(string s, int i, Derived2 d) { }
}
}
- """;
- await TestInRegularAndScriptAsync(initialMarkup, expect_0, index: 0,
+ """, index: 0,
title: string.Format(CodeFixesResources.Convert_type_to_0, "Derived"));
-
- var expect_1 =
- """
+ await TestInRegularAndScriptAsync(initialMarkup, """
class Program
{
class Base { }
@@ -2692,17 +2531,14 @@ public Test(string s, Base b, int i, params object[] list) : this(d : (Derived2)
Test(string s, int i, Derived2 d) { }
}
}
- """;
- await TestInRegularAndScriptAsync(initialMarkup, expect_1, index: 1,
+ """, index: 1,
title: string.Format(CodeFixesResources.Convert_type_to_0, "Derived2"));
}
[Fact]
- public async Task MultipleOptions3()
- {
- var initialMarkup =
- """
+ public Task MultipleOptions3()
+ => TestInRegularAndScriptAsync("""
class Program
{
class Base { }
@@ -2717,9 +2553,7 @@ public Test(string s, Base b, int i, params object[] list) : this(d : [||]b, s :
Test(string s, Derived d, int i, params object[] list)) { }
}
}
- """;
- var expected =
- """
+ """, """
class Program
{
class Base { }
@@ -2734,15 +2568,11 @@ public Test(string s, Base b, int i, params object[] list) : this(d : (Derived)b
Test(string s, Derived d, int i, params object[] list)) { }
}
}
- """;
- await TestInRegularAndScriptAsync(initialMarkup, expected);
- }
+ """);
[Fact]
- public async Task MultipleOptions4()
- {
- var initialMarkup =
- """
+ public Task MultipleOptions4()
+ => TestInRegularAndScriptAsync("""
class Program
{
class Base { }
@@ -2760,9 +2590,7 @@ void M()
Goo("", 1, i:1, d: [||]b);
}
}
- """;
- var expected =
- """
+ """, """
class Program
{
class Base { }
@@ -2780,9 +2608,7 @@ void M()
Goo("", 1, i:1, d: (Derived)b);
}
}
- """;
- await TestInRegularAndScriptAsync(initialMarkup, expected);
- }
+ """);
[Fact]
public async Task MultipleOptions5()
@@ -2813,8 +2639,7 @@ void M()
Assert.Equal(2, actions.Length);
}
- var expect_0 =
- """
+ await TestInRegularAndScriptAsync(initialMarkup, """
class Program
{
class Base { }
@@ -2832,12 +2657,9 @@ void M()
Goo("", d: (Derived)b, list: strlist, i: 1);
}
}
- """;
- await TestInRegularAndScriptAsync(initialMarkup, expect_0, index: 0,
+ """, index: 0,
title: string.Format(CodeFixesResources.Convert_type_to_0, "Derived"));
-
- var expect_1 =
- """
+ await TestInRegularAndScriptAsync(initialMarkup, """
class Program
{
class Base { }
@@ -2855,8 +2677,7 @@ void M()
Goo("", d: (Derived2)b, list: strlist, i: 1);
}
}
- """;
- await TestInRegularAndScriptAsync(initialMarkup, expect_1, index: 1,
+ """, index: 1,
title: string.Format(CodeFixesResources.Convert_type_to_0, "Derived2"));
}
@@ -2892,8 +2713,7 @@ void M()
Assert.Equal(3, actions.Length);
}
- var expect_0 =
- """
+ await TestInRegularAndScriptAsync(initialMarkup, """
class Program
{
class Base {
@@ -2914,12 +2734,9 @@ void M()
Goo("", d: (string)b, i: 1);
}
}
- """;
- await TestInRegularAndScriptAsync(initialMarkup, expect_0, index: 0,
+ """, index: 0,
title: string.Format(CodeFixesResources.Convert_type_to_0, "string"));
-
- var expect_1 =
- """
+ await TestInRegularAndScriptAsync(initialMarkup, """
class Program
{
class Base {
@@ -2940,12 +2757,9 @@ void M()
Goo("", d: (Derived)b, i: 1);
}
}
- """;
- await TestInRegularAndScriptAsync(initialMarkup, expect_1, index: 1,
+ """, index: 1,
title: string.Format(CodeFixesResources.Convert_type_to_0, "Derived"));
-
- var expect_2 =
- """
+ await TestInRegularAndScriptAsync(initialMarkup, """
class Program
{
class Base {
@@ -2966,16 +2780,13 @@ void M()
Goo("", d: (Derived2)b, i: 1);
}
}
- """;
- await TestInRegularAndScriptAsync(initialMarkup, expect_2, index: 2,
+ """, index: 2,
title: string.Format(CodeFixesResources.Convert_type_to_0, "Derived2"));
}
[Fact]
- public async Task MultipleOptions7()
- {
- var initialMarkup =
- """
+ public Task MultipleOptions7()
+ => TestInRegularAndScriptAsync("""
class Program
{
class Base { }
@@ -2994,9 +2805,7 @@ void M()
Goo(s1:"", 1, d: [||]b);
}
}
- """;
- var expected =
- """
+ """, """
class Program
{
class Base { }
@@ -3015,15 +2824,11 @@ void M()
Goo(s1:"", 1, d: (Derived)b);
}
}
- """;
- await TestInRegularAndScriptAsync(initialMarkup, expected);
- }
+ """);
[Fact]
- public async Task MultipleOptions8()
- {
- var initialMarkup =
- """
+ public Task MultipleOptions8()
+ => TestInRegularAndScriptAsync("""
class Program
{
class Base { }
@@ -3041,9 +2846,7 @@ void M()
Foo4([||]b, "1", "2", list: strlist);
}
}
- """;
- var expected =
- """
+ """, """
class Program
{
class Base { }
@@ -3061,15 +2864,11 @@ void M()
Foo4((Derived)b, "1", "2", list: strlist);
}
}
- """;
- await TestInRegularAndScriptAsync(initialMarkup, expected);
- }
+ """);
[Fact]
- public async Task MultipleOptions9()
- {
- var initialMarkup =
- """
+ public Task MultipleOptions9()
+ => TestMissingInRegularAndScriptAsync("""
class Program
{
class Base { }
@@ -3084,14 +2883,11 @@ void M() {
Goo([||]new Base());
}
}
- """;
- await TestMissingInRegularAndScriptAsync(initialMarkup);
- }
+ """);
[Fact]
- public async Task MultipleErrors1()
- {
- await TestInRegularAndScriptAsync(
+ public Task MultipleErrors1()
+ => TestInRegularAndScriptAsync(
"""
class Program
{
@@ -3124,12 +2920,10 @@ void Goo(Base b) {
}
}
""");
- }
[Fact]
- public async Task MultipleErrors2()
- {
- await TestInRegularAndScriptAsync(
+ public Task MultipleErrors2()
+ => TestInRegularAndScriptAsync(
"""
class Program
{
@@ -3162,12 +2956,10 @@ void Goo(Base b) {
}
}
""");
- }
[Fact]
- public async Task ErrorType()
- {
- await TestMissingInRegularAndScriptAsync(
+ public Task ErrorType()
+ => TestMissingInRegularAndScriptAsync(
"""
class C
{
@@ -3178,12 +2970,10 @@ void M(C c)
}
}
""");
- }
[Fact]
- public async Task AttributeArgument()
- {
- await TestInRegularAndScriptAsync(
+ public Task AttributeArgument()
+ => TestInRegularAndScriptAsync(
"""
using System;
class C
@@ -3208,12 +2998,10 @@ void M()
}
}
""");
- }
[Fact, WorkItem("https://github.com/dotnet/roslyn/issues/50493")]
- public async Task ArrayAccess()
- {
- await TestInRegularAndScriptAsync(
+ public Task ArrayAccess()
+ => TestInRegularAndScriptAsync(
"""
class C
{
@@ -3236,12 +3024,10 @@ public void M(object o)
}
}
""");
- }
[Fact]
- public async Task RemoveExistingCast1()
- {
- await TestInRegularAndScriptAsync(
+ public Task RemoveExistingCast1()
+ => TestInRegularAndScriptAsync(
"""
class Program
{
@@ -3266,12 +3052,10 @@ void Goo() {
}
}
""");
- }
[Fact, WorkItem(56141, "https://github.com/dotnet/roslyn/issues/56141")]
- public async Task CompoundAssignment1()
- {
- await TestInRegularAndScriptAsync(
+ public Task CompoundAssignment1()
+ => TestInRegularAndScriptAsync(
"""
class C
{
@@ -3294,12 +3078,10 @@ void M()
}
}
""");
- }
[Fact, WorkItem(56141, "https://github.com/dotnet/roslyn/issues/56141")]
- public async Task CompoundAssignment2()
- {
- await TestInRegularAndScriptAsync(
+ public Task CompoundAssignment2()
+ => TestInRegularAndScriptAsync(
"""
class C
{
@@ -3322,12 +3104,10 @@ void M()
}
}
""");
- }
[Fact, WorkItem(56141, "https://github.com/dotnet/roslyn/issues/56141")]
- public async Task CompoundAssignment3()
- {
- await TestInRegularAndScriptAsync(
+ public Task CompoundAssignment3()
+ => TestInRegularAndScriptAsync(
"""
class C
{
@@ -3350,12 +3130,10 @@ void M()
}
}
""");
- }
[Fact, WorkItem(56141, "https://github.com/dotnet/roslyn/issues/56141")]
- public async Task CompoundAssignment4()
- {
- await TestInRegularAndScriptAsync(
+ public Task CompoundAssignment4()
+ => TestInRegularAndScriptAsync(
"""
class C
{
@@ -3378,12 +3156,10 @@ void M()
}
}
""");
- }
[Fact, WorkItem(56141, "https://github.com/dotnet/roslyn/issues/56141")]
- public async Task CompoundAssignment5()
- {
- await TestInRegularAndScriptAsync(
+ public Task CompoundAssignment5()
+ => TestInRegularAndScriptAsync(
"""
class C
{
@@ -3406,5 +3182,4 @@ void M()
}
}
""");
- }
}
diff --git a/src/Analyzers/CSharp/Tests/AddExplicitCast/AddExplicitCastTests_FixAllTests.cs b/src/Analyzers/CSharp/Tests/AddExplicitCast/AddExplicitCastTests_FixAllTests.cs
index cad6b00cbdf78..d85f3cea7d164 100644
--- a/src/Analyzers/CSharp/Tests/AddExplicitCast/AddExplicitCastTests_FixAllTests.cs
+++ b/src/Analyzers/CSharp/Tests/AddExplicitCast/AddExplicitCastTests_FixAllTests.cs
@@ -15,9 +15,8 @@ public sealed partial class AddExplicitCastTests
[Fact]
[Trait(Traits.Feature, Traits.Features.CodeActionsAddExplicitCast)]
[Trait(Traits.Feature, Traits.Features.CodeActionsFixAllOccurrences)]
- public async Task CS0266TestFixAllInDocument()
- {
- var input = """
+ public Task CS0266TestFixAllInDocument()
+ => TestInRegularAndScriptAsync("""
@@ -155,9 +154,7 @@ Derived2 returnD2(Base b)
- """;
-
- var expected = """
+ """, """
@@ -295,17 +292,13 @@ Derived2 returnD2(Base b)
- """;
-
- await TestInRegularAndScriptAsync(input, expected);
- }
+ """);
[Fact]
[Trait(Traits.Feature, Traits.Features.CodeActionsAddExplicitCast)]
[Trait(Traits.Feature, Traits.Features.CodeActionsFixAllOccurrences)]
- public async Task CS0266TestFixAllInProject()
- {
- var input = """
+ public Task CS0266TestFixAllInProject()
+ => TestInRegularAndScriptAsync("""
@@ -443,9 +436,7 @@ Derived2 returnD2(Base b)
- """;
-
- var expected = """
+ """, """
@@ -583,17 +574,13 @@ Derived2 returnD2(Base b)
- """;
-
- await TestInRegularAndScriptAsync(input, expected);
- }
+ """);
[Fact]
[Trait(Traits.Feature, Traits.Features.CodeActionsAddExplicitCast)]
[Trait(Traits.Feature, Traits.Features.CodeActionsFixAllOccurrences)]
- public async Task CS0266TestFixAllInSolution()
- {
- var input = """
+ public Task CS0266TestFixAllInSolution()
+ => TestInRegularAndScriptAsync("""
@@ -731,9 +718,7 @@ Derived2 returnD2(Base b)
- """;
-
- var expected = """
+ """, """
@@ -871,17 +856,13 @@ Derived2 returnD2(Base b)
- """;
-
- await TestInRegularAndScriptAsync(input, expected);
- }
+ """);
[Fact]
[Trait(Traits.Feature, Traits.Features.CodeActionsAddExplicitCast)]
[Trait(Traits.Feature, Traits.Features.CodeActionsFixAllOccurrences)]
- public async Task CS1503TestFixAllInDocument()
- {
- var input = """
+ public Task CS1503TestFixAllInDocument()
+ => TestInRegularAndScriptAsync("""
@@ -1007,9 +988,7 @@ private void M2(Base1 b1, Base2 b2, Base3 b3, Derived1 d1, Derived2 d2)
- """;
-
- var expected = """
+ """, """
@@ -1135,17 +1114,13 @@ private void M2(Base1 b1, Base2 b2, Base3 b3, Derived1 d1, Derived2 d2)
- """;
-
- await TestInRegularAndScriptAsync(input, expected);
- }
+ """);
[Fact]
[Trait(Traits.Feature, Traits.Features.CodeActionsAddExplicitCast)]
[Trait(Traits.Feature, Traits.Features.CodeActionsFixAllOccurrences)]
- public async Task CS1503TestFixAllInProject()
- {
- var input = """
+ public Task CS1503TestFixAllInProject()
+ => TestInRegularAndScriptAsync("""
@@ -1310,9 +1285,7 @@ private void M2(Base1 b1, Base2 b2, Base3 b3, Derived1 d1, Derived2 d2)
- """;
-
- var expected = """
+ """, """
@@ -1477,17 +1450,13 @@ private void M2(Base1 b1, Base2 b2, Base3 b3, Derived1 d1, Derived2 d2)
- """;
-
- await TestInRegularAndScriptAsync(input, expected);
- }
+ """);
[Fact]
[Trait(Traits.Feature, Traits.Features.CodeActionsAddExplicitCast)]
[Trait(Traits.Feature, Traits.Features.CodeActionsFixAllOccurrences)]
- public async Task CS1503TestFixAllInSolution()
- {
- var input = """
+ public Task CS1503TestFixAllInSolution()
+ => TestInRegularAndScriptAsync("""
@@ -1615,9 +1584,7 @@ private void M2(Base b, Derived1 d1, Derived2 d2)
- """;
-
- var expected = """
+ """, """
@@ -1745,9 +1712,6 @@ private void M2(Base b, Derived1 d1, Derived2 d2)
- """;
-
- await TestInRegularAndScriptAsync(input, expected);
- }
+ """);
#endregion
}
diff --git a/src/Analyzers/CSharp/Tests/AddInheritdoc/AddInheritdocTests.cs b/src/Analyzers/CSharp/Tests/AddInheritdoc/AddInheritdocTests.cs
index 029b1309b31b1..55327f641a8db 100644
--- a/src/Analyzers/CSharp/Tests/AddInheritdoc/AddInheritdocTests.cs
+++ b/src/Analyzers/CSharp/Tests/AddInheritdoc/AddInheritdocTests.cs
@@ -31,9 +31,8 @@ private static Task TestMissingAsync(string initialMarkup)
=> VerifyCS.VerifyCodeFixAsync(initialMarkup, initialMarkup);
[Fact]
- public async Task AddMissingInheritdocOnOverriddenMethod()
- {
- await TestAsync(
+ public Task AddMissingInheritdocOnOverriddenMethod()
+ => TestAsync(
"""
/// Some doc.
public class BaseClass
@@ -61,15 +60,13 @@ public class Derived: BaseClass
public override void M() { }
}
""");
- }
[Theory]
[InlineData("public void {|CS1591:OtherMethod|}() { }")]
[InlineData("public void {|CS1591:M|}() { }")]
[InlineData("public new void {|CS1591:M|}() { }")]
- public async Task DoNotOfferOnNotOverriddenMethod(string methodDefinition)
- {
- await TestMissingAsync(
+ public Task DoNotOfferOnNotOverriddenMethod(string methodDefinition)
+ => TestMissingAsync(
$$"""
/// Some doc.
public class BaseClass
@@ -83,12 +80,10 @@ public class Derived: BaseClass
{{methodDefinition}}
}
""");
- }
[Fact]
- public async Task AddMissingInheritdocOnImplicitInterfaceMethod()
- {
- await TestAsync(
+ public Task AddMissingInheritdocOnImplicitInterfaceMethod()
+ => TestAsync(
"""
/// Some doc.
public interface IInterface
@@ -116,12 +111,10 @@ public class MyClass: IInterface
public void M() { }
}
""");
- }
[Fact]
- public async Task DoNotOfferOnExplicitInterfaceMethod()
- {
- await TestMissingAsync(
+ public Task DoNotOfferOnExplicitInterfaceMethod()
+ => TestMissingAsync(
"""
/// Some doc.
public interface IInterface
@@ -135,11 +128,9 @@ public class MyClass: IInterface
void IInterface.M() { }
}
""");
- }
[Fact]
- public async Task AddMissingInheritdocOnOverriddenProperty()
- {
- await TestAsync(
+ public Task AddMissingInheritdocOnOverriddenProperty()
+ => TestAsync(
"""
/// Some doc.
public class BaseClass
@@ -167,12 +158,10 @@ public class Derived: BaseClass
public override string P { get; set; }
}
""");
- }
[Fact]
- public async Task AddMissingInheritdocOnImplicitInterfaceProperty()
- {
- await TestAsync(
+ public Task AddMissingInheritdocOnImplicitInterfaceProperty()
+ => TestAsync(
"""
/// Some doc.
public interface IInterface
@@ -200,12 +189,10 @@ public class MyClass: IInterface
public string P { get; }
}
""");
- }
[Fact]
- public async Task AddMissingInheritdocOnImplicitInterfaceEvent()
- {
- await TestAsync(
+ public Task AddMissingInheritdocOnImplicitInterfaceEvent()
+ => TestAsync(
"""
/// Some doc.
public interface IInterface
@@ -237,12 +224,10 @@ public class MyClass: IInterface
void OnSomething() => SomeEvent?.Invoke();
}
""");
- }
[Fact]
- public async Task AddMissingInheritdocTriviaTest_1()
- {
- await TestAsync(
+ public Task AddMissingInheritdocTriviaTest_1()
+ => TestAsync(
"""
/// Some doc.
public class BaseClass
@@ -272,12 +257,10 @@ public class Derived: BaseClass
public override void M() { }
}
""");
- }
[Fact]
- public async Task AddMissingInheritdocTriviaTest_2()
- {
- await TestAsync(
+ public Task AddMissingInheritdocTriviaTest_2()
+ => TestAsync(
"""
/// Some doc.
public class BaseClass
@@ -307,12 +290,10 @@ public class Derived: BaseClass
public /* Comment 3 */ override void M /* Comment 4 */ () /* Comment 5 */ { } /* Comment 6 */
}
""");
- }
[Fact]
- public async Task AddMissingInheritdocMethodWithAttribute()
- {
- await TestAsync(
+ public Task AddMissingInheritdocMethodWithAttribute()
+ => TestAsync(
"""
/// Some doc.
[System.AttributeUsage(System.AttributeTargets.Method)]
@@ -354,12 +335,10 @@ public class Derived: BaseClass
public override void M() { }
}
""");
- }
[Fact]
- public async Task AddMissingInheritdocFixAll()
- {
- await TestAsync(
+ public Task AddMissingInheritdocFixAll()
+ => TestAsync(
"""
/// Some doc.
public class BaseClass
@@ -394,12 +373,10 @@ public override void M() { }
public override string P { get; }
}
""");
- }
[Fact, WorkItem("https://github.com/dotnet/roslyn/issues/61562")]
- public async Task TestOverrideBelowMember()
- {
- await TestAsync(
+ public Task TestOverrideBelowMember()
+ => TestAsync(
"""
using System;
@@ -455,5 +432,4 @@ public class Class2 : Class1
}
}
""");
- }
}
diff --git a/src/Analyzers/CSharp/Tests/AddObsoleteAttribute/AddObsoleteAttributeTests.cs b/src/Analyzers/CSharp/Tests/AddObsoleteAttribute/AddObsoleteAttributeTests.cs
index a90a3a2687f14..a940ac5dcca60 100644
--- a/src/Analyzers/CSharp/Tests/AddObsoleteAttribute/AddObsoleteAttributeTests.cs
+++ b/src/Analyzers/CSharp/Tests/AddObsoleteAttribute/AddObsoleteAttributeTests.cs
@@ -3,21 +3,24 @@
// See the LICENSE file in the project root for more information.
using System.Threading.Tasks;
+using Microsoft.CodeAnalysis.CSharp.AddObsoleteAttribute;
+using Microsoft.CodeAnalysis.Editor.UnitTests.CodeActions;
using Microsoft.CodeAnalysis.Test.Utilities;
+using Microsoft.CodeAnalysis.Testing;
using Xunit;
-using VerifyCS = Microsoft.CodeAnalysis.Editor.UnitTests.CodeActions.CSharpCodeFixVerifier<
- Microsoft.CodeAnalysis.Testing.EmptyDiagnosticAnalyzer,
- Microsoft.CodeAnalysis.CSharp.AddObsoleteAttribute.CSharpAddObsoleteAttributeCodeFixProvider>;
namespace Microsoft.CodeAnalysis.Editor.CSharp.UnitTests.AddObsoleteAttribute;
+using VerifyCS = CSharpCodeFixVerifier<
+ EmptyDiagnosticAnalyzer,
+ CSharpAddObsoleteAttributeCodeFixProvider>;
+
[Trait(Traits.Feature, Traits.Features.CodeActionsAddObsoleteAttribute)]
public sealed class AddObsoleteAttributeTests
{
[Fact]
- public async Task TestObsoleteClassNoMessage()
- {
- await VerifyCS.VerifyCodeFixAsync(
+ public Task TestObsoleteClassNoMessage()
+ => VerifyCS.VerifyCodeFixAsync(
"""
[System.Obsolete]
class Base {}
@@ -33,12 +36,10 @@ class Base {}
class Derived : Base {
}
""");
- }
[Fact]
- public async Task TestObsoleteClassWithMessage()
- {
- await VerifyCS.VerifyCodeFixAsync(
+ public Task TestObsoleteClassWithMessage()
+ => VerifyCS.VerifyCodeFixAsync(
"""
[System.Obsolete("message")]
class Base {}
@@ -54,12 +55,10 @@ class Base {}
class Derived : Base {
}
""");
- }
[Fact]
- public async Task TestObsoleteClassWithMessageAndErrorFalse()
- {
- await VerifyCS.VerifyCodeFixAsync(
+ public Task TestObsoleteClassWithMessageAndErrorFalse()
+ => VerifyCS.VerifyCodeFixAsync(
"""
[System.Obsolete("message", error: false)]
class Base {}
@@ -75,7 +74,6 @@ class Base {}
class Derived : Base {
}
""");
- }
[Fact]
public async Task TestObsoleteClassWithMessageAndErrorTrue()
@@ -91,9 +89,8 @@ class Derived : {|CS0619:Base|} {
}
[Fact]
- public async Task TestObsoleteClassUsedInField()
- {
- await VerifyCS.VerifyCodeFixAsync(
+ public Task TestObsoleteClassUsedInField()
+ => VerifyCS.VerifyCodeFixAsync(
"""
[System.Obsolete]
class Base { public static int i; }
@@ -111,12 +108,10 @@ class Derived {
int i = Base.i;
}
""");
- }
[Fact]
- public async Task TestObsoleteClassUsedInMethod()
- {
- await VerifyCS.VerifyCodeFixAsync(
+ public Task TestObsoleteClassUsedInMethod()
+ => VerifyCS.VerifyCodeFixAsync(
"""
[System.Obsolete]
class Base { public static int i; }
@@ -138,12 +133,10 @@ void Goo() {
}
}
""");
- }
[Fact]
- public async Task TestObsoleteOverride()
- {
- await VerifyCS.VerifyCodeFixAsync(
+ public Task TestObsoleteOverride()
+ => VerifyCS.VerifyCodeFixAsync(
"""
class Base {
[System.Obsolete]
@@ -165,12 +158,10 @@ class Derived : Base {
protected override void ObMethod() { }
}
""");
- }
[Fact]
- public async Task TestObsoleteClassFixAll1()
- {
- await VerifyCS.VerifyCodeFixAsync(
+ public Task TestObsoleteClassFixAll1()
+ => VerifyCS.VerifyCodeFixAsync(
"""
[System.Obsolete]
class Base { public static int i; }
@@ -194,12 +185,10 @@ void Goo() {
}
}
""");
- }
[Fact]
- public async Task TestObsoleteClassFixAll2()
- {
- await VerifyCS.VerifyCodeFixAsync(
+ public Task TestObsoleteClassFixAll2()
+ => VerifyCS.VerifyCodeFixAsync(
"""
[System.Obsolete]
class Base { public static int i; }
@@ -223,12 +212,10 @@ void Goo() {
}
}
""");
- }
[Fact]
- public async Task TestObsoleteClassFixAll3()
- {
- await VerifyCS.VerifyCodeFixAsync(
+ public Task TestObsoleteClassFixAll3()
+ => VerifyCS.VerifyCodeFixAsync(
"""
[System.Obsolete]
class Base { public static int i; }
@@ -259,12 +246,10 @@ void Bar() {
}
}
""");
- }
[Fact]
- public async Task TestObsoleteCollectionAddMethod()
- {
- await VerifyCS.VerifyCodeFixAsync(
+ public Task TestObsoleteCollectionAddMethod()
+ => VerifyCS.VerifyCodeFixAsync(
"""
class Collection : System.Collections.Generic.IEnumerable {
[System.Obsolete]
@@ -300,12 +285,10 @@ void Goo() {
}
}
""");
- }
[Fact]
- public async Task TestObsoleteCollectionAddMethodWithMessage()
- {
- await VerifyCS.VerifyCodeFixAsync(
+ public Task TestObsoleteCollectionAddMethodWithMessage()
+ => VerifyCS.VerifyCodeFixAsync(
"""
class Collection : System.Collections.Generic.IEnumerable {
[System.Obsolete("message")]
@@ -341,12 +324,10 @@ void Goo() {
}
}
""");
- }
[Fact]
- public async Task TestObsoleteCollectionAddMethodWithMessageAndErrorFalse()
- {
- await VerifyCS.VerifyCodeFixAsync(
+ public Task TestObsoleteCollectionAddMethodWithMessageAndErrorFalse()
+ => VerifyCS.VerifyCodeFixAsync(
"""
class Collection : System.Collections.Generic.IEnumerable {
[System.Obsolete("message", error: false)]
@@ -382,7 +363,6 @@ void Goo() {
}
}
""");
- }
[Fact]
public async Task TestObsoleteCollectionAddMethodWithMessageAndErrorTrue()
diff --git a/src/Analyzers/CSharp/Tests/AddParameter/AddParameterTests.cs b/src/Analyzers/CSharp/Tests/AddParameter/AddParameterTests.cs
index 4ba988c1bd171..c93c2fe17ac50 100644
--- a/src/Analyzers/CSharp/Tests/AddParameter/AddParameterTests.cs
+++ b/src/Analyzers/CSharp/Tests/AddParameter/AddParameterTests.cs
@@ -29,9 +29,8 @@ protected override ImmutableArray MassageActions(ImmutableArray FlattenActions(actions);
[Fact]
- public async Task TestMissingWithImplicitConstructor()
- {
- await TestMissingAsync(
+ public Task TestMissingWithImplicitConstructor()
+ => TestMissingAsync(
"""
class C
{
@@ -45,12 +44,10 @@ void M()
}
}
""");
- }
[Fact]
- public async Task TestOnEmptyConstructor()
- {
- await TestInRegularAndScriptAsync(
+ public Task TestOnEmptyConstructor()
+ => TestInRegularAndScriptAsync(
"""
class C
{
@@ -79,12 +76,10 @@ void M()
}
}
""");
- }
[Fact]
- public async Task TestNamedArg()
- {
- await TestInRegularAndScriptAsync(
+ public Task TestNamedArg()
+ => TestInRegularAndScriptAsync(
"""
class C
{
@@ -113,12 +108,10 @@ void M()
}
}
""");
- }
[Fact]
- public async Task TestMissingWithConstructorWithSameNumberOfParams()
- {
- await TestMissingAsync(
+ public Task TestMissingWithConstructorWithSameNumberOfParams()
+ => TestMissingAsync(
"""
class C
{
@@ -133,12 +126,10 @@ void M()
}
}
""");
- }
[Fact]
- public async Task TestAddBeforeMatchingArg()
- {
- await TestInRegularAndScriptAsync(
+ public Task TestAddBeforeMatchingArg()
+ => TestInRegularAndScriptAsync(
"""
class C
{
@@ -167,12 +158,10 @@ void M()
}
}
""");
- }
[Fact]
- public async Task TestAddAfterMatchingConstructorParam()
- {
- await TestInRegularAndScriptAsync(
+ public Task TestAddAfterMatchingConstructorParam()
+ => TestInRegularAndScriptAsync(
"""
class C
{
@@ -201,12 +190,10 @@ void M()
}
}
""");
- }
[Fact]
- public async Task TestParams1()
- {
- await TestInRegularAndScriptAsync(
+ public Task TestParams1()
+ => TestInRegularAndScriptAsync(
"""
class C
{
@@ -235,12 +222,10 @@ void M()
}
}
""");
- }
[Fact]
- public async Task TestParams2()
- {
- await TestMissingAsync(
+ public Task TestParams2()
+ => TestMissingAsync(
"""
class C
{
@@ -255,12 +240,10 @@ void M()
}
}
""");
- }
[Fact, WorkItem("https://github.com/dotnet/roslyn/issues/20708")]
- public async Task TestMultiLineParameters1()
- {
- await TestInRegularAndScriptAsync(
+ public Task TestMultiLineParameters1()
+ => TestInRegularAndScriptAsync(
"""
class C
{
@@ -292,12 +275,10 @@ private void Goo()
}
}
""");
- }
[Fact, WorkItem("https://github.com/dotnet/roslyn/issues/20708")]
- public async Task TestMultiLineParameters2()
- {
- await TestInRegularAndScriptAsync(
+ public Task TestMultiLineParameters2()
+ => TestInRegularAndScriptAsync(
"""
class C
{
@@ -329,12 +310,10 @@ private void Goo()
}
}
""");
- }
[Fact, WorkItem("https://github.com/dotnet/roslyn/issues/20708")]
- public async Task TestMultiLineParameters3()
- {
- await TestInRegularAndScriptAsync(
+ public Task TestMultiLineParameters3()
+ => TestInRegularAndScriptAsync(
"""
class C
{
@@ -366,12 +345,10 @@ private void Goo()
}
}
""");
- }
[Fact, WorkItem("https://github.com/dotnet/roslyn/issues/20708")]
- public async Task TestMultiLineParameters4()
- {
- await TestInRegularAndScriptAsync(
+ public Task TestMultiLineParameters4()
+ => TestInRegularAndScriptAsync(
"""
class C
{
@@ -405,12 +382,10 @@ private void Goo()
}
}
""");
- }
[Fact, WorkItem("https://github.com/dotnet/roslyn/issues/20708")]
- public async Task TestMultiLineParameters5()
- {
- await TestInRegularAndScriptAsync(
+ public Task TestMultiLineParameters5()
+ => TestInRegularAndScriptAsync(
"""
class C
{
@@ -444,12 +419,10 @@ private void Goo()
}
}
""");
- }
[Fact, WorkItem("https://github.com/dotnet/roslyn/issues/20708")]
- public async Task TestMultiLineParameters6()
- {
- await TestInRegularAndScriptAsync(
+ public Task TestMultiLineParameters6()
+ => TestInRegularAndScriptAsync(
"""
class C
{
@@ -483,12 +456,10 @@ private void Goo()
}
}
""");
- }
[Fact, WorkItem("https://github.com/dotnet/roslyn/issues/20973")]
- public async Task TestNullArg1()
- {
- await TestInRegularAndScriptAsync(
+ public Task TestNullArg1()
+ => TestInRegularAndScriptAsync(
"""
class C
{
@@ -517,12 +488,10 @@ void M()
}
}
""");
- }
[Fact, WorkItem("https://github.com/dotnet/roslyn/issues/20973")]
- public async Task TestNullArg2()
- {
- await TestInRegularAndScriptAsync(
+ public Task TestNullArg2()
+ => TestInRegularAndScriptAsync(
"""
class C
{
@@ -551,12 +520,10 @@ void M()
}
}
""");
- }
[Fact, WorkItem("https://github.com/dotnet/roslyn/issues/20973")]
- public async Task TestDefaultArg1()
- {
- await TestInRegularAndScriptAsync(
+ public Task TestDefaultArg1()
+ => TestInRegularAndScriptAsync(
"""
class C
{
@@ -585,12 +552,10 @@ void M()
}
}
""");
- }
[Fact, WorkItem("https://github.com/dotnet/roslyn/issues/20973")]
- public async Task TestDefaultArg2()
- {
- await TestInRegularAndScriptAsync(
+ public Task TestDefaultArg2()
+ => TestInRegularAndScriptAsync(
"""
class C
{
@@ -619,12 +584,10 @@ void M()
}
}
""");
- }
[Fact, WorkItem("https://github.com/dotnet/roslyn/issues/21446")]
- public async Task TestInvocationInstanceMethod1()
- {
- await TestInRegularAndScriptAsync(
+ public Task TestInvocationInstanceMethod1()
+ => TestInRegularAndScriptAsync(
"""
class C
{
@@ -651,12 +614,10 @@ void M2()
}
}
""");
- }
[Fact, WorkItem("https://github.com/dotnet/roslyn/issues/21446")]
- public async Task TestInvocationInheritedMethodGetFixed()
- {
- await TestInRegularAndScriptAsync(
+ public Task TestInvocationInheritedMethodGetFixed()
+ => TestInRegularAndScriptAsync(
"""
class Base
{
@@ -689,12 +650,10 @@ void M2()
}
}
""");
- }
[Fact, WorkItem("https://github.com/dotnet/roslyn/issues/21446")]
- public async Task TestInvocationInheritedMethodInMetadatGetsNotFixed()
- {
- await TestMissingAsync(
+ public Task TestInvocationInheritedMethodInMetadatGetsNotFixed()
+ => TestMissingAsync(
"""
class C1
{
@@ -705,12 +664,10 @@ void M2()
}
}
""");
- }
[Fact, WorkItem("https://github.com/dotnet/roslyn/issues/21446")]
- public async Task TestInvocationLocalFunction()
- {
- await TestInRegularAndScriptAsync(
+ public Task TestInvocationLocalFunction()
+ => TestInRegularAndScriptAsync(
"""
class C1
{
@@ -731,13 +688,11 @@ void M1()
}
}
""");
- }
[Fact, WorkItem("https://github.com/dotnet/roslyn/issues/21446")]
[Trait("TODO", "Fix broken")]
- public async Task TestInvocationLambda1()
- {
- await TestMissingInRegularAndScriptAsync(
+ public Task TestInvocationLambda1()
+ => TestMissingInRegularAndScriptAsync(
"""
using System;
class C1
@@ -749,13 +704,10 @@ void M1()
}
}
""");
- //Should be Action a = (int v) => { };
- }
[Fact, WorkItem("https://github.com/dotnet/roslyn/issues/21446")]
- public async Task TestInvocationStaticMethod()
- {
- await TestInRegularAndScriptAsync(
+ public Task TestInvocationStaticMethod()
+ => TestInRegularAndScriptAsync(
"""
class C1
{
@@ -780,13 +732,10 @@ void M2()
}
}
""");
- }
[Fact, WorkItem("https://github.com/dotnet/roslyn/issues/21446")]
- public async Task TestInvocationExtensionMethod()
- {
- var code =
- """
+ public Task TestInvocationExtensionMethod()
+ => TestInRegularAndScriptAsync("""
namespace N {
static class Extensions
{
@@ -801,9 +750,7 @@ void M1()
new object().[|ExtensionM1|](1);
}
}}
- """;
- var fix =
- """
+ """, """
namespace N {
static class Extensions
{
@@ -818,16 +765,11 @@ void M1()
new object().ExtensionM1(1);
}
}}
- """;
- await TestInRegularAndScriptAsync(code, fix);
- }
+ """);
[Fact, WorkItem("https://github.com/dotnet/roslyn/issues/21446")]
- public async Task TestInvocationExtensionMethod_StaticInvocationStyle()
- {
- // error CS1501: No overload for method 'ExtensionM1' takes 2 arguments
- var code =
- """
+ public Task TestInvocationExtensionMethod_StaticInvocationStyle()
+ => TestInRegularAndScriptAsync("""
namespace N {
static class Extensions
{
@@ -842,9 +784,7 @@ void M1()
Extensions.[|ExtensionM1|](new object(), 1);
}
}}
- """;
- var fix =
- """
+ """, """
namespace N {
static class Extensions
{
@@ -859,9 +799,7 @@ void M1()
Extensions.ExtensionM1(new object(), 1);
}
}}
- """;
- await TestInRegularAndScriptAsync(code, fix);
- }
+ """);
[Fact, WorkItem("https://github.com/dotnet/roslyn/issues/21446")]
public async Task TestInvocationOverride()
@@ -880,7 +818,7 @@ void M2()
}
}
""";
- var fix_DeclarationOnly = """
+ await TestInRegularAndScriptAsync(code, """
class Base
{
protected virtual void M1() { }
@@ -893,8 +831,8 @@ void M2()
M1(1);
}
}
- """;
- var fix_All = """
+ """, index: 0);
+ await TestInRegularAndScriptAsync(code, """
class Base
{
protected virtual void M1(int v) { }
@@ -907,9 +845,7 @@ void M2()
M1(1);
}
}
- """;
- await TestInRegularAndScriptAsync(code, fix_DeclarationOnly, index: 0);
- await TestInRegularAndScriptAsync(code, fix_All, index: 1);
+ """, index: 1);
}
[Fact, WorkItem("https://github.com/dotnet/roslyn/issues/21446")]
@@ -929,7 +865,7 @@ void M2()
}
}
""";
- var fix_DeclarationOnly = """
+ await TestInRegularAndScriptAsync(code, """
interface I1
{
void M1(int v);
@@ -942,8 +878,8 @@ void M2()
((I1)this).M1(1);
}
}
- """;
- var fix_All = """
+ """, index: 0);
+ await TestInRegularAndScriptAsync(code, """
interface I1
{
void M1(int v);
@@ -956,9 +892,7 @@ void M2()
((I1)this).M1(1);
}
}
- """;
- await TestInRegularAndScriptAsync(code, fix_DeclarationOnly, index: 0);
- await TestInRegularAndScriptAsync(code, fix_All, index: 1);
+ """, index: 1);
}
[Fact, WorkItem("https://github.com/dotnet/roslyn/issues/21446")]
@@ -979,7 +913,7 @@ void M2()
}
}
""";
- var fix_DeclarationOnly = """
+ await TestInRegularAndScriptAsync(code, """
interface I1
{
void M1();
@@ -992,8 +926,8 @@ void M2()
M1(1);
}
}
- """;
- var fix_All = """
+ """, index: 0);
+ await TestInRegularAndScriptAsync(code, """
interface I1
{
void M1(int v);
@@ -1006,9 +940,7 @@ void M2()
M1(1);
}
}
- """;
- await TestInRegularAndScriptAsync(code, fix_DeclarationOnly, index: 0);
- await TestInRegularAndScriptAsync(code, fix_All, index: 1);
+ """, index: 1);
}
[Fact, WorkItem("https://github.com/dotnet/roslyn/issues/21446")]
@@ -1033,7 +965,7 @@ void M2()
}
}
""";
- var fix_DeclarationOnly = """
+ await TestInRegularAndScriptAsync(code, """
interface I1
{
void M1();
@@ -1050,8 +982,8 @@ void M2()
M1(1);
}
}
- """;
- var fix_All = """
+ """, index: 0);
+ await TestInRegularAndScriptAsync(code, """
interface I1
{
void M1(int v);
@@ -1068,16 +1000,13 @@ void M2()
M1(1);
}
}
- """;
- await TestInRegularAndScriptAsync(code, fix_DeclarationOnly, index: 0);
- await TestInRegularAndScriptAsync(code, fix_All, index: 1);
+ """, index: 1);
}
[Fact, WorkItem("https://github.com/dotnet/roslyn/issues/21446")]
[Trait("TODO", "Fix broken")]
- public async Task TestInvocationGenericMethod()
- {
- await TestInRegularAndScriptAsync(
+ public Task TestInvocationGenericMethod()
+ => TestInRegularAndScriptAsync(
"""
class C1
{
@@ -1098,12 +1027,10 @@ void M2()
}
}
""");
- }
[Fact, WorkItem("https://github.com/dotnet/roslyn/issues/21446")]
- public async Task TestInvocationRecursion()
- {
- await TestInRegularAndScriptAsync(
+ public Task TestInvocationRecursion()
+ => TestInRegularAndScriptAsync(
"""
class C1
{
@@ -1122,7 +1049,6 @@ void M1(int v)
}
}
""");
- }
[Fact, WorkItem("https://github.com/dotnet/roslyn/issues/21446")]
public async Task TestInvocationOverloads1()
@@ -1139,8 +1065,7 @@ void M2()
}
}
""";
- var fix0 =
- """
+ await TestInRegularAndScriptAsync(code, """
class C1
{
void M1(string s) { }
@@ -1150,9 +1075,8 @@ void M2()
M1(1, 2);
}
}
- """;
- var fix1 =
- """
+ """, 0);
+ await TestInRegularAndScriptAsync(code, """
class C1
{
void M1(int v, string s) { }
@@ -1162,9 +1086,7 @@ void M2()
M1(1, 2);
}
}
- """;
- await TestInRegularAndScriptAsync(code, fix0, 0);
- await TestInRegularAndScriptAsync(code, fix1, 1);
+ """, 1);
}
[Fact, WorkItem("https://github.com/dotnet/roslyn/issues/21446")]
@@ -1183,8 +1105,7 @@ void M2()
}
}
""";
- var fix0 =
- """
+ await TestInRegularAndScriptAsync(code, """
class C1
{
void M1(string s1, string s2) { }
@@ -1195,9 +1116,8 @@ void M2()
M1(1, 2);
}
}
- """;
- var fix1 =
- """
+ """, 0);
+ await TestInRegularAndScriptAsync(code, """
class C1
{
void M1(string s1, string s2) { }
@@ -1208,16 +1128,12 @@ void M2()
M1(1, 2);
}
}
- """;
- await TestInRegularAndScriptAsync(code, fix0, 0);
- await TestInRegularAndScriptAsync(code, fix1, 1);
+ """, 1);
}
[Fact, WorkItem("https://github.com/dotnet/roslyn/issues/21446")]
- public async Task TestInvocationTuple1()
- {
- var code =
- """
+ public Task TestInvocationTuple1()
+ => TestInRegularAndScriptAsync("""
class C1
{
void M1((int, int) t1)
@@ -1228,9 +1144,7 @@ void M2()
[|M1|]((0, 0), (1, "1"));
}
}
- """;
- var fix0 =
- """
+ """, """
class C1
{
void M1((int, int) t1, (int, string) value)
@@ -1241,15 +1155,11 @@ void M2()
M1((0, 0), (1, "1"));
}
}
- """;
- await TestInRegularAndScriptAsync(code, fix0, 0);
- }
+ """, 0);
[Fact, WorkItem("https://github.com/dotnet/roslyn/issues/21446")]
- public async Task TestInvocationTuple2()
- {
- var code =
- """
+ public Task TestInvocationTuple2()
+ => TestInRegularAndScriptAsync("""
class C1
{
void M1((int, int) t1)
@@ -1261,9 +1171,7 @@ void M2()
[|M1|]((0, 0), tup);
}
}
- """;
- var fix0 =
- """
+ """, """
class C1
{
void M1((int, int) t1, (int, string) tup)
@@ -1275,15 +1183,11 @@ void M2()
M1((0, 0), tup);
}
}
- """;
- await TestInRegularAndScriptAsync(code, fix0, 0);
- }
+ """, 0);
[Fact, WorkItem("https://github.com/dotnet/roslyn/issues/21446")]
- public async Task TestInvocationTuple3()
- {
- var code =
- """
+ public Task TestInvocationTuple3()
+ => TestInRegularAndScriptAsync("""
class C1
{
void M1((int, int) t1)
@@ -1295,9 +1199,7 @@ void M2()
[|M1|]((0, 0), tup);
}
}
- """;
- var fix0 =
- """
+ """, """
class C1
{
void M1((int, int) t1, (int i, string s) tup)
@@ -1309,16 +1211,11 @@ void M2()
M1((0, 0), tup);
}
}
- """;
- await TestInRegularAndScriptAsync(code, fix0, 0);
- }
+ """, 0);
[Fact, WorkItem("https://github.com/dotnet/roslyn/issues/21446")]
- public async Task TestInvocation_Missing_TypeArguments_AddingTypeArgumentAndParameter()
- {
- // error CS0305: Using the generic method 'C1.M1(T)' requires 1 type arguments
- var code =
- """
+ public Task TestInvocation_Missing_TypeArguments_AddingTypeArgumentAndParameter()
+ => TestMissingInRegularAndScriptAsync("""
class C1
{
void M1(T i) { }
@@ -1327,17 +1224,11 @@ void M2()
[|M1|](1, true);
}
}
- """;
- // Could be fixed as void M1(T i, T1 v) { }
- await TestMissingInRegularAndScriptAsync(code);
- }
+ """);
[Fact, WorkItem("https://github.com/dotnet/roslyn/issues/21446")]
- public async Task TestInvocation_Missing_TypeArguments_AddingTypeArgument()
- {
- // error CS0308: The non-generic method 'C1.M1(int)' cannot be used with type arguments
- var code =
- """
+ public Task TestInvocation_Missing_TypeArguments_AddingTypeArgument()
+ => TestMissingInRegularAndScriptAsync("""
class C1
{
void M1(int i) { }
@@ -1346,18 +1237,12 @@ void M2()
[|M1|](1, true);
}
}
- """;
- // Could be fixed as void M1(int i, T v) { }
- await TestMissingInRegularAndScriptAsync(code);
- }
+ """);
[Fact, WorkItem("https://github.com/dotnet/roslyn/issues/21446")]
[Trait("TODO", "Fix missing")]
- public async Task TestInvocation_Missing_ExplicitInterfaceImplementation()
- {
- // error CS0539: 'C1.M1(int)' in explicit interface declaration is not a member of interface
- var code =
- """
+ public Task TestInvocation_Missing_ExplicitInterfaceImplementation()
+ => TestMissingAsync("""
interface I1
{
void M1();
@@ -1367,17 +1252,11 @@ class C1 : I1
void I1.M1() { }
void I1.[|M1|](int i) { }
}
- """;
- // Could apply argument to interface method: void M1(int i);
- await TestMissingAsync(code);
- }
+ """);
[Fact, WorkItem("https://github.com/dotnet/roslyn/issues/21446")]
- public async Task TestInvocation_OverloadResolutionFailure()
- {
- // error CS1503: Argument 1: cannot convert from 'double' to 'int'
- var code =
- """
+ public Task TestInvocation_OverloadResolutionFailure()
+ => TestInRegularAndScriptAsync("""
class C1
{
void M1(int i1, int i2) { }
@@ -1387,9 +1266,7 @@ void M2()
M1([|1.0|], 1);
}
}
- """;
- var fix0 =
- """
+ """, """
class C1
{
void M1(int i1, int i2) { }
@@ -1399,16 +1276,11 @@ void M2()
M1(1.0, 1);
}
}
- """;
- await TestInRegularAndScriptAsync(code, fix0);
- }
+ """);
[Fact, WorkItem("https://github.com/dotnet/roslyn/issues/21446")]
- public async Task TestInvocation_LambdaExpressionParameter()
- {
- // error CS1660: Cannot convert lambda expression to type 'int' because it is not a delegate type
- var code =
- """
+ public Task TestInvocation_LambdaExpressionParameter()
+ => TestInRegularAndScriptAsync("""
class C1
{
void M1(int i1, int i2) { }
@@ -1418,9 +1290,7 @@ void M2()
M1([|()=> { }|], 1);
}
}
- """;
- var fix =
- """
+ """, """
class C1
{
void M1(int i1, int i2) { }
@@ -1430,16 +1300,11 @@ void M2()
M1(()=> { }, 1);
}
}
- """;
- await TestInRegularAndScriptAsync(code, fix);
- }
+ """);
[Fact, WorkItem("https://github.com/dotnet/roslyn/issues/21446")]
- public async Task TestInvocation_NamedParameter()
- {
- // error CS1739: The best overload for 'M1' does not have a parameter named 'i2'
- var code =
- """
+ public Task TestInvocation_NamedParameter()
+ => TestInRegularAndScriptAsync("""
class C1
{
void M1(int i1) { }
@@ -1448,9 +1313,7 @@ void M2()
M1([|i2|]: 1);
}
}
- """;
- var fix =
- """
+ """, """
class C1
{
void M1(int i1, int i2) { }
@@ -1459,15 +1322,11 @@ void M2()
M1(i2: 1);
}
}
- """;
- await TestInRegularAndScriptAsync(code, fix);
- }
+ """);
[Fact, WorkItem("https://github.com/dotnet/roslyn/issues/21446")]
- public async Task TestInvocationAddTypeParameter_AddTypeParameterIfUserSpecifiesOne_OnlyTypeArgument()
- {
- var code =
- """
+ public Task TestInvocationAddTypeParameter_AddTypeParameterIfUserSpecifiesOne_OnlyTypeArgument()
+ => TestMissingInRegularAndScriptAsync("""
class C1
{
void M1() { }
@@ -1476,16 +1335,11 @@ void M2()
[|M1|]();
}
}
- """;
- // Could be fixed as void M1() { }
- await TestMissingInRegularAndScriptAsync(code);
- }
+ """);
[Fact, WorkItem("https://github.com/dotnet/roslyn/issues/21446")]
- public async Task TestInvocationAddTypeParameter_AddTypeParameterIfUserSpecifiesOne_TypeArgumentAndParameterArgument()
- {
- var code =
- """
+ public Task TestInvocationAddTypeParameter_AddTypeParameterIfUserSpecifiesOne_TypeArgumentAndParameterArgument()
+ => TestMissingInRegularAndScriptAsync("""
class C1
{
void M1() { }
@@ -1494,16 +1348,11 @@ void M2()
[|M1|](true);
}
}
- """;
- // Could be fixed to void M1(T v) { }
- await TestMissingInRegularAndScriptAsync(code);
- }
+ """);
[Fact, WorkItem("https://github.com/dotnet/roslyn/issues/21446")]
- public async Task TestInvocation_ExisitingTypeArgumentIsNotGeneralized()
- {
- var code =
- """
+ public Task TestInvocation_ExisitingTypeArgumentIsNotGeneralized()
+ => TestInRegularAndScriptAsync("""
class C1
{
void M1(T v) { }
@@ -1512,9 +1361,7 @@ void M2()
[|M1|](true, true);
}
}
- """;
- var fix0 =
- """
+ """, """
class C1
{
void M1(T v, bool v1) { }
@@ -1523,16 +1370,11 @@ void M2()
M1(true, true);
}
}
- """;
- await TestInRegularAndScriptAsync(code, fix0);
- }
+ """);
[Fact, WorkItem("https://github.com/dotnet/roslyn/issues/21446")]
- public async Task TestInvocation_AddParameterToMethodWithParams()
- {
- // error CS1503: Argument 1: cannot convert from 'bool' to 'int'
- var code =
- """
+ public Task TestInvocation_AddParameterToMethodWithParams()
+ => TestInRegularAndScriptAsync("""
class C1
{
static void M1(params int[] nums) { }
@@ -1541,9 +1383,7 @@ static void M2()
M1([|true|], 4);
}
}
- """;
- var fix0 =
- """
+ """, """
class C1
{
static void M1(bool v, params int[] nums) { }
@@ -1552,9 +1392,7 @@ static void M2()
M1(true, 4);
}
}
- """;
- await TestInRegularAndScriptAsync(code, fix0);
- }
+ """);
[Fact, WorkItem("https://github.com/dotnet/roslyn/issues/21446")]
public async Task TestInvocation_Cascading_FixingVirtualFixesOverrideToo()
@@ -1578,8 +1416,7 @@ void M2()
}
}
""";
- var fix_DeclarationOnly =
- """
+ await TestInRegularAndScriptAsync(code, """
class BaseClass
{
protected virtual void M1(int v) { }
@@ -1595,9 +1432,8 @@ void M2()
M1(1);
}
}
- """;
- var fix_All =
- """
+ """, index: 0);
+ await TestInRegularAndScriptAsync(code, """
class BaseClass
{
protected virtual void M1(int v) { }
@@ -1613,16 +1449,12 @@ void M2()
M1(1);
}
}
- """;
- await TestInRegularAndScriptAsync(code, fix_DeclarationOnly, index: 0);
- await TestInRegularAndScriptAsync(code, fix_All, index: 1);
+ """, index: 1);
}
[Fact, WorkItem("https://github.com/dotnet/roslyn/issues/21446")]
- public async Task TestInvocation_Cascading_PartialMethods()
- {
- var code =
- """
+ public Task TestInvocation_Cascading_PartialMethods()
+ => TestInRegularAndScriptAsync("""
@@ -1649,9 +1481,7 @@ void M1()
- """;
- var fix0 =
- """
+ """, """
@@ -1678,15 +1508,11 @@ void M1()
- """;
- await TestInRegularAndScriptAsync(code, fix0);
- }
+ """);
[Fact]
- public async Task TestInvocation_Cascading_ExtendedPartialMethods()
- {
- var code =
- """
+ public Task TestInvocation_Cascading_ExtendedPartialMethods()
+ => TestInRegularAndScriptAsync("""
@@ -1713,9 +1539,7 @@ void M1()
- """;
- var fix0 =
- """
+ """, """
@@ -1742,15 +1566,11 @@ void M1()
- """;
- await TestInRegularAndScriptAsync(code, fix0);
- }
+ """);
[Fact, WorkItem("https://github.com/dotnet/roslyn/issues/21446")]
- public async Task TestInvocation_Cascading_PartialMethodsInSameDocument()
- {
- var code =
- """
+ public Task TestInvocation_Cascading_PartialMethodsInSameDocument()
+ => TestInRegularAndScriptAsync("""
namespace N1
{
partial class C1
@@ -1766,9 +1586,7 @@ void M1()
}
}
}
- """;
- var fix0 =
- """
+ """, """
namespace N1
{
partial class C1
@@ -1784,16 +1602,11 @@ void M1()
}
}
}
- """;
- await TestInRegularAndScriptAsync(code, fix0);
- }
+ """);
[Fact, WorkItem("https://github.com/dotnet/roslyn/issues/21446")]
- public async Task TestInvocation_Cascading_BaseNotInSource()
- {
- // error CS1501: No overload for method 'M' takes 1 arguments
- var code =
- """
+ public Task TestInvocation_Cascading_BaseNotInSource()
+ => TestMissingAsync("""
@@ -1821,9 +1634,7 @@ public void M2()
- """;
- await TestMissingAsync(code);
- }
+ """);
[Fact, WorkItem("https://github.com/dotnet/roslyn/issues/21446")]
public async Task TestInvocation_Cascading_RootNotInSource()
@@ -1859,7 +1670,7 @@ public void M2()
""";
- var fixedDocumentWithoutConflictAnnotation = """
+ await TestInRegularAndScriptAsync(code, """
namespace N
{
public class Derived: BaseClass
@@ -1874,8 +1685,8 @@ public void M2()
}
}
}
- """;
- var fixedDocumentWithConflictAnnotation = """
+ """, index: 0);
+ await TestInRegularAndScriptAsync(code, """
namespace N
{
public class Derived: BaseClass
@@ -1890,17 +1701,12 @@ public void M2()
}
}
}
- """;
- await TestInRegularAndScriptAsync(code, fixedDocumentWithoutConflictAnnotation, index: 0);
- await TestInRegularAndScriptAsync(code, fixedDocumentWithConflictAnnotation, index: 1);
+ """, index: 1);
}
[Fact, WorkItem("https://github.com/dotnet/roslyn/issues/21446")]
- public async Task TestInvocation_Cascading_ManyReferencesInManyProjects()
- {
- // error CS1501: No overload for method 'M' takes 1 arguments
- var code =
- """
+ public Task TestInvocation_Cascading_ManyReferencesInManyProjects()
+ => TestInRegularAndScriptAsync("""
@@ -1952,9 +1758,7 @@ public void Test() {
- """;
- var fix_All =
- """
+ """, """
@@ -2006,9 +1810,7 @@ public void Test() {
- """;
- await TestInRegularAndScriptAsync(code, fix_All, index: 1);
- }
+ """, index: 1);
[Fact, WorkItem("https://github.com/dotnet/roslyn/issues/21446")]
public async Task TestInvocation_Cascading_OfferFixCascadingForImplicitInterface()
@@ -2029,8 +1831,7 @@ void MTest()
}
}
""";
- var fix_DeclarationOnly =
- """
+ await TestInRegularAndScriptAsync(code, """
interface I1
{
void M1();
@@ -2043,9 +1844,8 @@ void MTest()
M1(1);
}
}
- """;
- var fix_All =
- """
+ """, index: 0);
+ await TestInRegularAndScriptAsync(code, """
interface I1
{
void M1(int v);
@@ -2058,9 +1858,7 @@ void MTest()
M1(1);
}
}
- """;
- await TestInRegularAndScriptAsync(code, fix_DeclarationOnly, index: 0);
- await TestInRegularAndScriptAsync(code, fix_All, index: 1);
+ """, index: 1);
}
#if !CODE_STYLE
@@ -2068,10 +1866,8 @@ void MTest()
// CodeStyle layer does not support cross language application of fixes.
[Fact, WorkItem("https://github.com/dotnet/roslyn/issues/21446")]
- public async Task TestInvocation_Cascading_CrossLanguage()
- {
- var code =
- """
+ public Task TestInvocation_Cascading_CrossLanguage()
+ => TestInRegularAndScriptAsync("""
@@ -2102,9 +1898,7 @@ public void Test() {
- """;
- var fix =
- """
+ """, """
@@ -2135,9 +1929,7 @@ public void Test() {
- """;
- await TestInRegularAndScriptAsync(code, fix, index: 1);
- }
+ """, index: 1);
#endif
@@ -2155,8 +1947,8 @@ void Test()
}
}
""";
- var fix0 =
- """
+ await TestActionCountAsync(code, 1);
+ await TestInRegularAndScriptAsync(code, """
class C
{
void M(int v) { }
@@ -2165,17 +1957,12 @@ void Test()
M(1, 2, 3, 4);
}
}
- """;
- await TestActionCountAsync(code, 1);
- await TestInRegularAndScriptAsync(code, fix0, index: 0);
+ """, index: 0);
}
[Fact, WorkItem("https://github.com/dotnet/roslyn/issues/21446")]
- public async Task TestInvocation_InvocationStyles_Positional_WithOptionalParam()
- {
- // error CS1501: No overload for method 'M' takes 2 arguments
- var code =
- """
+ public Task TestInvocation_InvocationStyles_Positional_WithOptionalParam()
+ => TestInRegularAndScriptAsync("""
class C
{
void M(int i = 1) { }
@@ -2184,9 +1971,7 @@ void Test()
[|M|](1, 2);
}
}
- """;
- var fix0 =
- """
+ """, """
class C
{
void M(int i = 1, int v = 0) { }
@@ -2195,16 +1980,11 @@ void Test()
M(1, 2);
}
}
- """;
- await TestInRegularAndScriptAsync(code, fix0, index: 0);
- }
+ """, index: 0);
[Fact, WorkItem("https://github.com/dotnet/roslyn/issues/21446")]
- public async Task TestInvocation_InvocationStyles_Named_WithOptionalParam()
- {
- // error CS1739: The best overload for 'M' does not have a parameter named 'i3'
- var code =
- """
+ public Task TestInvocation_InvocationStyles_Named_WithOptionalParam()
+ => TestInRegularAndScriptAsync("""
class C
{
void M(int i1, int i2 = 1) { }
@@ -2213,9 +1993,7 @@ void Test()
M(1, i2: 2, [|i3|]: 3);
}
}
- """;
- var fix0 =
- """
+ """, """
class C
{
void M(int i1, int i2 = 1, int i3 = 0) { }
@@ -2224,16 +2002,11 @@ void Test()
M(1, i2: 2, i3: 3);
}
}
- """;
- await TestInRegularAndScriptAsync(code, fix0, index: 0);
- }
+ """, index: 0);
[Fact, WorkItem("https://github.com/dotnet/roslyn/issues/21446")]
- public async Task TestInvocation_InvocationStyles_Positional_WithParams()
- {
- // error CS1503: Argument 1: cannot convert from 'string' to 'int'
- var code =
- """
+ public Task TestInvocation_InvocationStyles_Positional_WithParams()
+ => TestInRegularAndScriptAsync("""
class C
{
void M(params int[] ints) { }
@@ -2242,9 +2015,7 @@ void Test()
M([|"text"|]);
}
}
- """;
- var fix0 =
- """
+ """, """
class C
{
void M(string v, params int[] ints) { }
@@ -2253,16 +2024,11 @@ void Test()
M("text");
}
}
- """;
- await TestInRegularAndScriptAsync(code, fix0, index: 0);
- }
+ """, index: 0);
[Fact, WorkItem("https://github.com/dotnet/roslyn/issues/21446")]
- public async Task TestInvocation_InvocationStyles_Named_WithTypemissmatch()
- {
- // error CS1503: Argument 1: cannot convert from 'string' to 'int'
- var code =
- """
+ public Task TestInvocation_InvocationStyles_Named_WithTypemissmatch()
+ => TestMissingInRegularAndScriptAsync("""
class C
{
void M(int i) { }
@@ -2271,16 +2037,11 @@ void Test()
M(i: [|"text"|]);
}
}
- """;
- await TestMissingInRegularAndScriptAsync(code);
- }
+ """);
[Fact, WorkItem("https://github.com/dotnet/roslyn/issues/21446")]
- public async Task TestInvocation_InvocationStyles_NamedAndPositional1()
- {
- // error CS1739: The best overload for 'M' does not have a parameter named 'i2'
- var code =
- """
+ public Task TestInvocation_InvocationStyles_NamedAndPositional1()
+ => TestInRegularAndScriptAsync("""
class C
{
void M(int i1, string s) { }
@@ -2289,9 +2050,7 @@ void Test()
M(1, s: "text", [|i2|]: 0);
}
}
- """;
- var fix0 =
- """
+ """, """
class C
{
void M(int i1, string s, int i2) { }
@@ -2300,17 +2059,11 @@ void Test()
M(1, s: "text", i2: 0);
}
}
- """;
- await TestInRegularAndScriptAsync(code, fix0, index: 0);
- }
+ """, index: 0);
[Fact, WorkItem("https://github.com/dotnet/roslyn/issues/21446")]
- public async Task TestInvocation_InvocationStyles_NamedAndPositional2()
- {
- // CS1744 is not yet a supported diagnostic (just declaring the diagnostic as supported does not work)
- // error CS1744: Named argument 's' specifies a parameter for which a positional argument has already been given
- var code =
- """
+ public Task TestInvocation_InvocationStyles_NamedAndPositional2()
+ => TestMissingInRegularAndScriptAsync("""
class C
{
void M(string s) { }
@@ -2319,16 +2072,11 @@ void Test()
M(1, [|s|]: "text");
}
}
- """;
- await TestMissingInRegularAndScriptAsync(code);
- }
+ """);
[Fact, WorkItem("https://github.com/dotnet/roslyn/issues/21446")]
- public async Task TestInvocation_InvocationStyles_Incomplete_1()
- {
- // error CS1501: No overload for method 'M' takes 1 arguments
- var code =
- """
+ public Task TestInvocation_InvocationStyles_Incomplete_1()
+ => TestInRegularAndScriptAsync("""
class C
{
void M() { }
@@ -2337,9 +2085,7 @@ void Test()
[|M|](1
}
}
- """;
- var fix0 =
- """
+ """, """
class C
{
void M(int v) { }
@@ -2348,41 +2094,29 @@ void Test()
M(1
}
}
- """;
- await TestInRegularAndScriptAsync(code, fix0, index: 0);
- }
+ """, index: 0);
[Fact, WorkItem("https://github.com/dotnet/roslyn/issues/21446")]
- public async Task TestInvocation_InvocationStyles_Incomplete_2()
- {
- // error CS1503: Argument 1: cannot convert from 'string' to 'int'
- var code =
- """
+ public Task TestInvocation_InvocationStyles_Incomplete_2()
+ => TestInRegularAndScriptAsync("""
class C
{
void M(int v) { }
void Test()
{
[|M|]("text", 1
- """;
- var fix0 =
- """
+ """, """
class C
{
void M(string v1, int v) { }
void Test()
{
M("text", 1
- """;
- await TestInRegularAndScriptAsync(code, fix0, index: 0);
- }
+ """, index: 0);
[Fact, WorkItem("https://github.com/dotnet/roslyn/issues/21446")]
- public async Task TestInvocation_InvocationStyles_RefParameter()
- {
- // error CS1501: No overload for method 'M' takes 1 arguments
- var code =
- """
+ public Task TestInvocation_InvocationStyles_RefParameter()
+ => TestInRegularAndScriptAsync("""
class C
{
void M() { }
@@ -2392,9 +2126,7 @@ void Test()
[|M|](ref i);
}
}
- """;
- var fix0 =
- """
+ """, """
class C
{
void M(ref int i) { }
@@ -2404,16 +2136,11 @@ void Test()
M(ref i);
}
}
- """;
- await TestInRegularAndScriptAsync(code, fix0, index: 0);
- }
+ """, index: 0);
[Fact, WorkItem("https://github.com/dotnet/roslyn/issues/21446")]
- public async Task TestInvocation_InvocationStyles_OutParameter_WithTypeDeclarationOutsideArgument()
- {
- // error CS1501: No overload for method 'M' takes 1 arguments
- var code =
- """
+ public Task TestInvocation_InvocationStyles_OutParameter_WithTypeDeclarationOutsideArgument()
+ => TestInRegularAndScriptAsync("""
class C
{
void M() { }
@@ -2423,9 +2150,7 @@ void Test()
[|M|](out i);
}
}
- """;
- var fix0 =
- """
+ """, """
class C
{
void M(out int i) { }
@@ -2435,16 +2160,11 @@ void Test()
M(out i);
}
}
- """;
- await TestInRegularAndScriptAsync(code, fix0, index: 0);
- }
+ """, index: 0);
[Fact, WorkItem("https://github.com/dotnet/roslyn/issues/21446")]
- public async Task TestInvocation_InvocationStyles_OutParameter_WithTypeDeclarationInArgument()
- {
- // error CS1501: No overload for method 'M' takes 1 arguments
- var code =
- """
+ public Task TestInvocation_InvocationStyles_OutParameter_WithTypeDeclarationInArgument()
+ => TestInRegularAndScriptAsync("""
class C
{
void M() { }
@@ -2453,9 +2173,7 @@ void Test()
[|M|](out int i);
}
}
- """;
- var fix0 =
- """
+ """, """
class C
{
void M(out int i) { }
@@ -2464,16 +2182,11 @@ void Test()
M(out int i);
}
}
- """;
- await TestInRegularAndScriptAsync(code, fix0, index: 0);
- }
+ """, index: 0);
[Fact, WorkItem("https://github.com/dotnet/roslyn/issues/21446")]
- public async Task TestInvocation_InvocationStyles_OutParameter_WithVarTypeDeclarationInArgument()
- {
- // error CS1501: No overload for method 'M' takes 1 arguments
- var code =
- """
+ public Task TestInvocation_InvocationStyles_OutParameter_WithVarTypeDeclarationInArgument()
+ => TestInRegularAndScriptAsync("""
class C
{
void M() { }
@@ -2482,9 +2195,7 @@ void Test()
[|M|](out var i);
}
}
- """;
- var fix0 =
- """
+ """, """
class C
{
void M(out object i) { }
@@ -2493,18 +2204,11 @@ void Test()
M(out var i);
}
}
- """;
- await TestInRegularAndScriptAsync(code, fix0, index: 0);
- }
+ """, index: 0);
[Fact, WorkItem("https://github.com/dotnet/roslyn/issues/21446")]
- public async Task TestInvocation_Indexer_NotSupported()
- {
- // Could be fixed by allowing ElementAccessExpression next to InvocationExpression
- // in AbstractAddParameterCodeFixProvider.RegisterCodeFixesAsync.
- // error CS1501: No overload for method 'this' takes 2 arguments
- var code =
- """
+ public Task TestInvocation_Indexer_NotSupported()
+ => TestMissingAsync("""
public class C {
public int this[int i]
{
@@ -2516,24 +2220,17 @@ public void Test() {
var i = [|this[0,0]|];
}
}
- """;
- await TestMissingAsync(code);
- }
+ """);
[Fact, WorkItem("https://github.com/dotnet/roslyn/issues/29061")]
- public async Task TestThis_DoNotOfferToFixTheConstructorWithTheDiagnosticOnIt()
- {
- // error CS1729: 'C' does not contain a constructor that takes 1 arguments
- var code =
- """
+ public Task TestThis_DoNotOfferToFixTheConstructorWithTheDiagnosticOnIt()
+ => TestMissingAsync("""
public class C {
public C(): [|this|](1)
{ }
}
- """;
- await TestMissingAsync(code);
- }
+ """);
[Fact, WorkItem("https://github.com/dotnet/roslyn/issues/29061")]
public async Task TestThis_Fix_IfACandidateIsAvailable()
@@ -2549,8 +2246,7 @@ public C(): [|this|](1, 1)
{ }
}
""";
- var fix0 =
- """
+ await TestInRegularAndScriptAsync(code, """
class C
{
public C(int i, int v) { }
@@ -2558,8 +2254,7 @@ public C(int i, int v) { }
public C(): this(1, 1)
{ }
}
- """;
- await TestInRegularAndScriptAsync(code, fix0, index: 0);
+ """, index: 0);
await TestActionCountAsync(code, 1);
}
@@ -2578,8 +2273,7 @@ public class C : B
public C(int i) : [|base|](i) { }
}
""";
- var fix0 =
- """
+ await TestInRegularAndScriptAsync(code, """
public class B
{
B(int i) { }
@@ -2588,17 +2282,13 @@ public class C : B
{
public C(int i) : base(i) { }
}
- """;
- await TestInRegularAndScriptAsync(code, fix0, index: 0);
+ """, index: 0);
await TestActionCountAsync(code, 1);
}
[Fact, WorkItem("https://github.com/dotnet/roslyn/issues/29753")]
- public async Task LocalFunction_AddParameterToLocalFunctionWithOneParameter()
- {
- // CS1501 No overload for method takes 2 arguments
- var code =
- """
+ public Task LocalFunction_AddParameterToLocalFunctionWithOneParameter()
+ => TestInRegularAndScriptAsync("""
class Rsrp
{
public void M()
@@ -2610,9 +2300,7 @@ void Local(string whatever)
}
}
}
- """;
- var fix0 =
- """
+ """, """
class Rsrp
{
public void M()
@@ -2624,16 +2312,11 @@ void Local(string whatever, bool v)
}
}
}
- """;
- await TestInRegularAndScriptAsync(code, fix0, index: 0);
- }
+ """, index: 0);
[Fact, WorkItem("https://github.com/dotnet/roslyn/issues/29752")]
- public async Task LocalFunction_AddNamedParameterToLocalFunctionWithOneParameter()
- {
- // CS1739: The best overload for 'Local' does not have a parameter named 'mynewparameter'
- var code =
- """
+ public Task LocalFunction_AddNamedParameterToLocalFunctionWithOneParameter()
+ => TestInRegularAndScriptAsync("""
class Rsrp
{
public void M()
@@ -2645,9 +2328,7 @@ void Local(string whatever)
}
}
}
- """;
- var fix0 =
- """
+ """, """
class Rsrp
{
public void M()
@@ -2659,14 +2340,11 @@ void Local(string whatever, bool mynewparameter)
}
}
}
- """;
- await TestInRegularAndScriptAsync(code, fix0, index: 0);
- }
+ """, index: 0);
[Fact, WorkItem("https://github.com/dotnet/roslyn/issues/39270")]
- public async Task TestWithArgThatHasImplicitConversionToParamType1()
- {
- await TestInRegularAndScriptAsync(
+ public Task TestWithArgThatHasImplicitConversionToParamType1()
+ => TestInRegularAndScriptAsync(
"""
class BaseClass { }
@@ -2699,13 +2377,10 @@ void TestFunc()
void MyFunc(BaseClass param1, int newparam) { }
}
""");
- }
[Fact]
- public async Task TestOnExtensionGetEnumerator()
- {
- var code =
- """
+ public Task TestOnExtensionGetEnumerator()
+ => TestInRegularAndScriptAsync("""
using System.Collections.Generic;
namespace N {
static class Extensions
@@ -2722,9 +2397,7 @@ void M1()
foreach (var a in new object());
}
}}
- """;
- var fix =
- """
+ """, """
using System.Collections.Generic;
namespace N {
static class Extensions
@@ -2741,9 +2414,7 @@ void M1()
foreach (var a in new object());
}
}}
- """;
- await TestInRegularAndScriptAsync(code, fix);
- }
+ """);
[Fact]
public async Task TestOnExtensionGetAsyncEnumerator()
@@ -2792,9 +2463,8 @@ async Task M1()
}
[Fact, WorkItem("https://github.com/dotnet/roslyn/issues/44271")]
- public async Task TopLevelStatement()
- {
- await TestInRegularAndScriptAsync("""
+ public Task TopLevelStatement()
+ => TestInRegularAndScriptAsync("""
[|local|](1, 2, 3);
void local(int x, int y)
@@ -2808,12 +2478,10 @@ void local(int x, int y, int v)
{
}
""", parseOptions: TestOptions.Regular.WithLanguageVersion(LanguageVersion.CSharp9));
- }
[Fact, WorkItem("https://github.com/dotnet/roslyn/issues/44271")]
- public async Task TopLevelStatement_Nested()
- {
- await TestInRegularAndScriptAsync("""
+ public Task TopLevelStatement_Nested()
+ => TestInRegularAndScriptAsync("""
void outer()
{
[|local|](1, 2, 3);
@@ -2833,12 +2501,10 @@ void local(int x, int y, int v)
}
}
""");
- }
[Fact, WorkItem("https://github.com/dotnet/roslyn/issues/42559")]
- public async Task TestAddParameter_ImplicitObjectCreation()
- {
- await TestInRegularAndScriptAsync("""
+ public Task TestAddParameter_ImplicitObjectCreation()
+ => TestInRegularAndScriptAsync("""
class C
{
C(int i) { }
@@ -2860,12 +2526,10 @@ void M()
}
}
""");
- }
[Fact, WorkItem("https://github.com/dotnet/roslyn/issues/48042")]
- public async Task TestNamedArgOnExtensionMethod()
- {
- await TestInRegularAndScriptAsync(
+ public Task TestNamedArgOnExtensionMethod()
+ => TestInRegularAndScriptAsync(
"""
namespace r
{
@@ -2892,12 +2556,10 @@ void Test()
}
}
""");
- }
[Fact, WorkItem("https://github.com/dotnet/roslyn/issues/54408")]
- public async Task TestPositionalRecord()
- {
- await TestInRegularAndScriptAsync("""
+ public Task TestPositionalRecord()
+ => TestInRegularAndScriptAsync("""
var b = "B";
var r = [|new R(1, b)|];
@@ -2918,12 +2580,10 @@ namespace System.Runtime.CompilerServices
public static class IsExternalInit { }
}
""", parseOptions: TestOptions.Regular.WithLanguageVersion(LanguageVersion.CSharp9));
- }
[Fact]
- public async Task Test_PrimaryConstructor_Class()
- {
- await TestInRegularAndScriptAsync("""
+ public Task Test_PrimaryConstructor_Class()
+ => TestInRegularAndScriptAsync("""
var b = "B";
var r = [|new R(1, b)|];
@@ -2934,12 +2594,10 @@ class R(int A);
class R(int A, string b);
""", parseOptions: TestOptions.Regular.WithLanguageVersion(LanguageVersion.CSharp12));
- }
[Fact, WorkItem("https://github.com/dotnet/roslyn/issues/54408")]
- public async Task TestPositionalRecordStruct()
- {
- await TestInRegularAndScriptAsync("""
+ public Task TestPositionalRecordStruct()
+ => TestInRegularAndScriptAsync("""
var b = "B";
var r = [|new R(1, b)|];
@@ -2960,12 +2618,10 @@ namespace System.Runtime.CompilerServices
public static class IsExternalInit { }
}
""", parseOptions: TestOptions.Regular.WithLanguageVersion(LanguageVersion.CSharp9));
- }
[Fact]
- public async Task Test_PrimaryConstructor_Struct()
- {
- await TestInRegularAndScriptAsync("""
+ public Task Test_PrimaryConstructor_Struct()
+ => TestInRegularAndScriptAsync("""
var b = "B";
var r = [|new R(1, b)|];
@@ -2976,12 +2632,10 @@ struct R(int A);
struct R(int A, string b);
""", parseOptions: TestOptions.Regular.WithLanguageVersion(LanguageVersion.CSharp12));
- }
[Fact, WorkItem("https://github.com/dotnet/roslyn/issues/56952")]
- public async Task TestRecordsNamingConventions()
- {
- await TestInRegularAndScript1Async("""
+ public Task TestRecordsNamingConventions()
+ => TestInRegularAndScript1Async("""
[|new Test("repro")|];
record Test();
@@ -2992,12 +2646,10 @@ record Test();
record Test(string V);
""");
- }
[Fact]
- public async Task TestNamingConventions_PrimaryConstructor_Class()
- {
- await TestInRegularAndScript1Async("""
+ public Task TestNamingConventions_PrimaryConstructor_Class()
+ => TestInRegularAndScript1Async("""
[|new Test("repro")|];
class Test();
@@ -3006,12 +2658,10 @@ class Test();
class Test(string v);
""");
- }
[Fact, WorkItem("https://github.com/dotnet/roslyn/issues/56952")]
- public async Task TestRecordsNamingConventions_RecordStruct()
- {
- await TestInRegularAndScript1Async("""
+ public Task TestRecordsNamingConventions_RecordStruct()
+ => TestInRegularAndScript1Async("""
[|new Test("repro")|];
record struct Test();
@@ -3022,12 +2672,10 @@ record struct Test();
record struct Test(string V);
""");
- }
[Fact]
- public async Task TestNamingConventions_PrimaryConstructor_Struct()
- {
- await TestInRegularAndScript1Async("""
+ public Task TestNamingConventions_PrimaryConstructor_Struct()
+ => TestInRegularAndScript1Async("""
[|new Test("repro")|];
struct Test();
@@ -3036,12 +2684,10 @@ struct Test();
struct Test(string v);
""");
- }
[Fact, WorkItem("https://github.com/dotnet/roslyn/issues/61715")]
- public async Task TestMethodGroup1()
- {
- await TestInRegularAndScript1Async("""
+ public Task TestMethodGroup1()
+ => TestInRegularAndScript1Async("""
public class Example
{
public void Add(int x)
@@ -3074,12 +2720,10 @@ public void Main()
}
}
""");
- }
[Fact, WorkItem("https://github.com/dotnet/roslyn/issues/61715")]
- public async Task TestMethodGroup2()
- {
- await TestInRegularAndScript1Async("""
+ public Task TestMethodGroup2()
+ => TestInRegularAndScript1Async("""
public class Example
{
public void Add(int x, string y)
@@ -3112,12 +2756,10 @@ public void Main()
}
}
""");
- }
[Fact, WorkItem("https://github.com/dotnet/roslyn/issues/61715")]
- public async Task TestMethodGroup3()
- {
- await TestInRegularAndScript1Async("""
+ public Task TestMethodGroup3()
+ => TestInRegularAndScript1Async("""
public class Example
{
public int Add(int x, string y)
@@ -3152,12 +2794,10 @@ public void Main()
}
}
""");
- }
[Fact, WorkItem("https://github.com/dotnet/roslyn/issues/71428")]
- public async Task TestAddConstructorParameterWithExistingField_BlockInitialize()
- {
- await TestInRegularAndScript1Async(
+ public Task TestAddConstructorParameterWithExistingField_BlockInitialize()
+ => TestInRegularAndScript1Async(
"""
class C
{
@@ -3203,12 +2843,10 @@ void M(string t)
}
}
""");
- }
[Fact, WorkItem("https://github.com/dotnet/roslyn/issues/71428")]
- public async Task TestAddConstructorParameterWithExistingField_ExpressionBodyInitialize()
- {
- await TestInRegularAndScript1Async(
+ public Task TestAddConstructorParameterWithExistingField_ExpressionBodyInitialize()
+ => TestInRegularAndScript1Async(
"""
class C
{
@@ -3248,12 +2886,10 @@ void M(string t)
}
}
""");
- }
[Fact, WorkItem("https://github.com/dotnet/roslyn/issues/71428")]
- public async Task TestAddConstructorParameterWithExistingField_TupleInitialize()
- {
- await TestInRegularAndScript1Async(
+ public Task TestAddConstructorParameterWithExistingField_TupleInitialize()
+ => TestInRegularAndScript1Async(
"""
class C
{
@@ -3296,12 +2932,10 @@ void M(string i)
}
}
""");
- }
[Fact, WorkItem("https://github.com/dotnet/roslyn/issues/71428")]
- public async Task TestAddConstructorParameterWithExistingField_UnderscoreName()
- {
- await TestInRegularAndScript1Async(
+ public Task TestAddConstructorParameterWithExistingField_UnderscoreName()
+ => TestInRegularAndScript1Async(
"""
class C
{
@@ -3339,12 +2973,10 @@ void M(string s)
}
}
""");
- }
[Fact, WorkItem("https://github.com/dotnet/roslyn/issues/71428")]
- public async Task TestAddConstructorParameterWithExistingField_PrimaryConstructor()
- {
- await TestInRegularAndScript1Async(
+ public Task TestAddConstructorParameterWithExistingField_PrimaryConstructor()
+ => TestInRegularAndScript1Async(
"""
class C()
{
@@ -3373,12 +3005,10 @@ void M(string name)
}
}
""");
- }
[Fact, WorkItem("https://github.com/dotnet/roslyn/issues/71428")]
- public async Task TestAddConstructorParameterWithExistingProperty_PrimaryConstructor()
- {
- await TestInRegularAndScript1Async(
+ public Task TestAddConstructorParameterWithExistingProperty_PrimaryConstructor()
+ => TestInRegularAndScript1Async(
"""
class C()
{
@@ -3407,12 +3037,10 @@ void M(string name)
}
}
""");
- }
[Fact, WorkItem("https://github.com/dotnet/roslyn/issues/71428")]
- public async Task TestAddConstructorParameterWithExistingThrowingProperty_PrimaryConstructor()
- {
- await TestInRegularAndScript1Async(
+ public Task TestAddConstructorParameterWithExistingThrowingProperty_PrimaryConstructor()
+ => TestInRegularAndScript1Async(
"""
using System;
@@ -3445,5 +3073,4 @@ void M(string name)
}
}
""");
- }
}
diff --git a/src/Analyzers/CSharp/Tests/AddRequiredParentheses/AddRequiredExpressionParenthesesTests.cs b/src/Analyzers/CSharp/Tests/AddRequiredParentheses/AddRequiredExpressionParenthesesTests.cs
index f2bf61baf6005..4ef7a537ce6e9 100644
--- a/src/Analyzers/CSharp/Tests/AddRequiredParentheses/AddRequiredExpressionParenthesesTests.cs
+++ b/src/Analyzers/CSharp/Tests/AddRequiredParentheses/AddRequiredExpressionParenthesesTests.cs
@@ -10,6 +10,7 @@
using Microsoft.CodeAnalysis.Editor.CSharp.UnitTests.Diagnostics;
using Microsoft.CodeAnalysis.Editor.UnitTests.CodeActions;
using Microsoft.CodeAnalysis.Test.Utilities;
+using Roslyn.Test.Utilities;
using Xunit;
using Xunit.Abstractions;
@@ -29,9 +30,8 @@ private Task TestAsync(string initialMarkup, string expected, OptionsCollection
=> TestInRegularAndScript1Async(initialMarkup, expected, parameters: new TestParameters(options: options));
[Fact]
- public async Task TestArithmeticPrecedence()
- {
- await TestAsync(
+ public Task TestArithmeticPrecedence()
+ => TestAsync(
"""
class C
{
@@ -50,12 +50,10 @@ void M()
}
}
""", RequireAllParenthesesForClarity);
- }
[Fact]
- public async Task TestNoArithmeticOnLowerPrecedence()
- {
- await TestMissingAsync(
+ public Task TestNoArithmeticOnLowerPrecedence()
+ => TestMissingAsync(
"""
class C
{
@@ -65,12 +63,10 @@ void M()
}
}
""", RequireAllParenthesesForClarity);
- }
[Fact]
- public async Task TestNotIfArithmeticPrecedenceStaysTheSame()
- {
- await TestMissingAsync(
+ public Task TestNotIfArithmeticPrecedenceStaysTheSame()
+ => TestMissingAsync(
"""
class C
{
@@ -80,12 +76,10 @@ void M()
}
}
""", RequireAllParenthesesForClarity);
- }
[Fact]
- public async Task TestNotIfArithmeticPrecedenceIsNotEnforced1()
- {
- await TestMissingAsync(
+ public Task TestNotIfArithmeticPrecedenceIsNotEnforced1()
+ => TestMissingAsync(
"""
class C
{
@@ -95,12 +89,10 @@ void M()
}
}
""", RequireOtherBinaryParenthesesForClarity);
- }
[Fact]
- public async Task TestNotIfArithmeticPrecedenceIsNotEnforced2()
- {
- await TestMissingAsync(
+ public Task TestNotIfArithmeticPrecedenceIsNotEnforced2()
+ => TestMissingAsync(
"""
class C
{
@@ -110,12 +102,10 @@ void M()
}
}
""", RequireOtherBinaryParenthesesForClarity);
- }
[Fact]
- public async Task TestRelationalPrecedence()
- {
- await TestAsync(
+ public Task TestRelationalPrecedence()
+ => TestAsync(
"""
class C
{
@@ -134,12 +124,10 @@ void M()
}
}
""", RequireAllParenthesesForClarity);
- }
[Fact]
- public async Task TestLogicalPrecedence()
- {
- await TestAsync(
+ public Task TestLogicalPrecedence()
+ => TestAsync(
"""
class C
{
@@ -158,12 +146,10 @@ void M()
}
}
""", RequireAllParenthesesForClarity);
- }
[Fact]
- public async Task TestNoLogicalOnLowerPrecedence()
- {
- await TestMissingAsync(
+ public Task TestNoLogicalOnLowerPrecedence()
+ => TestMissingAsync(
"""
class C
{
@@ -173,12 +159,10 @@ void M()
}
}
""", RequireAllParenthesesForClarity);
- }
[Fact]
- public async Task TestNotIfLogicalPrecedenceStaysTheSame()
- {
- await TestMissingAsync(
+ public Task TestNotIfLogicalPrecedenceStaysTheSame()
+ => TestMissingAsync(
"""
class C
{
@@ -188,12 +172,10 @@ void M()
}
}
""", RequireAllParenthesesForClarity);
- }
[Fact]
- public async Task TestNotIfLogicalPrecedenceIsNotEnforced()
- {
- await TestMissingAsync(
+ public Task TestNotIfLogicalPrecedenceIsNotEnforced()
+ => TestMissingAsync(
"""
class C
{
@@ -203,12 +185,10 @@ void M()
}
}
""", RequireArithmeticBinaryParenthesesForClarity);
- }
[Fact]
- public async Task TestMixedArithmeticAndLogical()
- {
- await TestMissingAsync(
+ public Task TestMixedArithmeticAndLogical()
+ => TestMissingAsync(
"""
class C
{
@@ -218,12 +198,10 @@ void M()
}
}
""", RequireAllParenthesesForClarity);
- }
[Fact]
- public async Task TestLogicalPrecedenceMultipleEqualPrecedenceParts1()
- {
- await TestAsync(
+ public Task TestLogicalPrecedenceMultipleEqualPrecedenceParts1()
+ => TestAsync(
"""
class C
{
@@ -242,12 +220,10 @@ void M()
}
}
""", RequireAllParenthesesForClarity);
- }
[Fact]
- public async Task TestLogicalPrecedenceMultipleEqualPrecedenceParts2()
- {
- await TestAsync(
+ public Task TestLogicalPrecedenceMultipleEqualPrecedenceParts2()
+ => TestAsync(
"""
class C
{
@@ -266,12 +242,10 @@ void M()
}
}
""", RequireAllParenthesesForClarity);
- }
[Fact]
- public async Task TestShiftPrecedence1()
- {
- await TestAsync(
+ public Task TestShiftPrecedence1()
+ => TestAsync(
"""
class C
{
@@ -290,12 +264,10 @@ void M()
}
}
""", RequireAllParenthesesForClarity);
- }
[Fact]
- public async Task TestShiftPrecedence2()
- {
- await TestAsync(
+ public Task TestShiftPrecedence2()
+ => TestAsync(
"""
class C
{
@@ -314,12 +286,10 @@ void M()
}
}
""", RequireArithmeticBinaryParenthesesForClarity);
- }
[Fact]
- public async Task TestShiftPrecedence3()
- {
- await TestMissingAsync(
+ public Task TestShiftPrecedence3()
+ => TestMissingAsync(
"""
class C
{
@@ -329,12 +299,10 @@ void M()
}
}
""", RequireOtherBinaryParenthesesForClarity);
- }
[Fact]
- public async Task TestNotIfShiftPrecedenceStaysTheSame1()
- {
- await TestMissingAsync(
+ public Task TestNotIfShiftPrecedenceStaysTheSame1()
+ => TestMissingAsync(
"""
class C
{
@@ -344,12 +312,10 @@ void M()
}
}
""", RequireAllParenthesesForClarity);
- }
[Fact]
- public async Task TestNotIfShiftPrecedenceStaysTheSame2()
- {
- await TestMissingAsync(
+ public Task TestNotIfShiftPrecedenceStaysTheSame2()
+ => TestMissingAsync(
"""
class C
{
@@ -359,12 +325,10 @@ void M()
}
}
""", RequireAllParenthesesForClarity);
- }
[Fact]
- public async Task TestEqualityPrecedence1()
- {
- await TestMissingAsync(
+ public Task TestEqualityPrecedence1()
+ => TestMissingAsync(
"""
class C
{
@@ -374,12 +338,10 @@ void M()
}
}
""", RequireOtherBinaryParenthesesForClarity);
- }
[Fact]
- public async Task TestEqualityPrecedence2()
- {
- await TestMissingAsync(
+ public Task TestEqualityPrecedence2()
+ => TestMissingAsync(
"""
class C
{
@@ -389,12 +351,10 @@ void M()
}
}
""", RequireOtherBinaryParenthesesForClarity);
- }
[Fact]
- public async Task TestEqualityPrecedence3()
- {
- await TestMissingAsync(
+ public Task TestEqualityPrecedence3()
+ => TestMissingAsync(
"""
class C
{
@@ -404,12 +364,10 @@ void M()
}
}
""", RequireRelationalBinaryParenthesesForClarity);
- }
[Fact]
- public async Task TestEqualityPrecedence4()
- {
- await TestMissingAsync(
+ public Task TestEqualityPrecedence4()
+ => TestMissingAsync(
"""
class C
{
@@ -419,12 +377,10 @@ void M()
}
}
""", RequireRelationalBinaryParenthesesForClarity);
- }
- [Fact]
- public async Task TestCoalescePrecedence1()
- {
- await TestMissingAsync(
+ [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/78841")]
+ public Task TestCoalescePrecedence1()
+ => TestAsync(
"""
class C
{
@@ -433,13 +389,20 @@ void M()
int x = a $$+ b ?? c;
}
}
+ """,
+ """
+ class C
+ {
+ void M()
+ {
+ int x = (a + b) ?? c;
+ }
+ }
""", RequireAllParenthesesForClarity);
- }
[Fact]
- public async Task TestCoalescePrecedence2()
- {
- await TestMissingAsync(
+ public Task TestCoalescePrecedence2()
+ => TestMissingAsync(
"""
class C
{
@@ -449,10 +412,22 @@ void M()
}
}
""", RequireAllParenthesesForClarity);
- }
[Fact]
- public async Task TestCoalescePrecedence3()
+ public Task TestCoalescePrecedence3()
+ => TestMissingAsync(
+ """
+ class C
+ {
+ void M()
+ {
+ int x = a ?? b $$?? c;
+ }
+ }
+ """, RequireAllParenthesesForClarity);
+
+ [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/79286")]
+ public async Task TestCoalescePrecedence4()
{
await TestMissingAsync(
"""
@@ -460,16 +435,15 @@ class C
{
void M()
{
- int x = a ?? b $$?? c;
+ int x = a $$as b ?? c;
}
}
""", RequireAllParenthesesForClarity);
}
[Fact]
- public async Task TestBitwisePrecedence1()
- {
- await TestAsync(
+ public Task TestBitwisePrecedence1()
+ => TestAsync(
"""
class C
{
@@ -488,12 +462,10 @@ void M()
}
}
""", RequireAllParenthesesForClarity);
- }
[Fact]
- public async Task TestBitwisePrecedence2()
- {
- await TestMissingAsync(
+ public Task TestBitwisePrecedence2()
+ => TestMissingAsync(
"""
class C
{
@@ -503,12 +475,10 @@ void M()
}
}
""", RequireAllParenthesesForClarity);
- }
[Fact]
- public async Task TestBitwisePrecedence3()
- {
- await TestAsync(
+ public Task TestBitwisePrecedence3()
+ => TestAsync(
"""
class C
{
@@ -527,12 +497,10 @@ void M()
}
}
""", RequireAllParenthesesForClarity);
- }
[Fact]
- public async Task TestBitwisePrecedence4()
- {
- await TestMissingAsync(
+ public Task TestBitwisePrecedence4()
+ => TestMissingAsync(
"""
class C
{
@@ -542,12 +510,10 @@ void M()
}
}
""", RequireAllParenthesesForClarity);
- }
[Fact]
- public async Task TestNotForEqualityAfterEquals()
- {
- await TestMissingAsync(
+ public Task TestNotForEqualityAfterEquals()
+ => TestMissingAsync(
"""
class C
{
@@ -557,12 +523,10 @@ void M()
}
}
""", RequireAllParenthesesForClarity);
- }
[Fact]
- public async Task TestNotForAssignmentEqualsAfterLocal()
- {
- await TestMissingAsync(
+ public Task TestNotForAssignmentEqualsAfterLocal()
+ => TestMissingAsync(
"""
class C
{
@@ -572,12 +536,10 @@ void M(int a)
}
}
""", RequireAllParenthesesForClarity);
- }
[Fact]
- public async Task TestForAssignmentAndEquality1()
- {
- await TestMissingAsync(
+ public Task TestForAssignmentAndEquality1()
+ => TestMissingAsync(
"""
class C
{
@@ -587,12 +549,10 @@ void M(bool x, bool y, bool z)
}
}
""", RequireAllParenthesesForClarity);
- }
[Fact]
- public async Task TestMissingForAssignmentAndEquality2()
- {
- await TestMissingAsync(
+ public Task TestMissingForAssignmentAndEquality2()
+ => TestMissingAsync(
"""
class C
{
@@ -602,12 +562,10 @@ void M(bool x, bool y, bool z)
}
}
""", RequireAllParenthesesForClarity);
- }
[Fact]
- public async Task TestUnclearCast1()
- {
- await TestMissingAsync(
+ public Task TestUnclearCast1()
+ => TestMissingAsync(
"""
class C
{
@@ -617,12 +575,10 @@ void M()
}
}
""", RequireAllParenthesesForClarity);
- }
[Fact]
- public async Task TestUnclearCast_NotOfferedWithIgnore()
- {
- await TestMissingAsync(
+ public Task TestUnclearCast_NotOfferedWithIgnore()
+ => TestMissingAsync(
"""
class C
{
@@ -632,12 +588,10 @@ void M()
}
}
""", IgnoreAllParentheses);
- }
[Fact]
- public async Task TestUnclearCast_NotOfferedWithRemoveForClarity()
- {
- await TestMissingAsync(
+ public Task TestUnclearCast_NotOfferedWithRemoveForClarity()
+ => TestMissingAsync(
"""
class C
{
@@ -647,12 +601,10 @@ void M()
}
}
""", RemoveAllUnnecessaryParentheses);
- }
[Fact]
- public async Task TestUnclearCast2()
- {
- await TestMissingAsync(
+ public Task TestUnclearCast2()
+ => TestMissingAsync(
"""
class C
{
@@ -662,12 +614,10 @@ void M()
}
}
""", RequireAllParenthesesForClarity);
- }
[Fact]
- public async Task TestUnclearCast3()
- {
- await TestMissingAsync(
+ public Task TestUnclearCast3()
+ => TestMissingAsync(
"""
class C
{
@@ -677,12 +627,10 @@ void M()
}
}
""", RequireAllParenthesesForClarity);
- }
[Fact]
- public async Task TestUnclearCast4()
- {
- await TestMissingAsync(
+ public Task TestUnclearCast4()
+ => TestMissingAsync(
"""
class C
{
@@ -692,12 +640,10 @@ void M()
}
}
""", RequireAllParenthesesForClarity);
- }
[Fact]
- public async Task TestNotForPrimary()
- {
- await TestMissingAsync(
+ public Task TestNotForPrimary()
+ => TestMissingAsync(
"""
class C
{
@@ -707,12 +653,10 @@ void M()
}
}
""", RequireAllParenthesesForClarity);
- }
[Fact]
- public async Task TestNotForMemberAccess()
- {
- await TestMissingAsync(
+ public Task TestNotForMemberAccess()
+ => TestMissingAsync(
"""
class C
{
@@ -722,12 +666,10 @@ void M()
}
}
""", RequireAllParenthesesForClarity);
- }
[Fact]
- public async Task TestNotForCastOfCast()
- {
- await TestMissingAsync(
+ public Task TestNotForCastOfCast()
+ => TestMissingAsync(
"""
class C
{
@@ -737,12 +679,10 @@ void M()
}
}
""", RequireAllParenthesesForClarity);
- }
[Fact]
- public async Task TestNotForNonAmbiguousUnary()
- {
- await TestMissingAsync(
+ public Task TestNotForNonAmbiguousUnary()
+ => TestMissingAsync(
"""
class C
{
@@ -752,12 +692,10 @@ void M()
}
}
""", RequireAllParenthesesForClarity);
- }
[Fact]
- public async Task TestFixAll1()
- {
- await TestMissingAsync(
+ public Task TestFixAll1()
+ => TestMissingAsync(
"""
class C
{
@@ -769,12 +707,10 @@ void M()
}
}
""", RequireAllParenthesesForClarity);
- }
[Fact]
- public async Task TestFixAll2()
- {
- await TestInRegularAndScriptAsync(
+ public Task TestFixAll2()
+ => TestInRegularAndScriptAsync(
"""
class C
{
@@ -797,12 +733,10 @@ void M()
}
}
""", options: RequireAllParenthesesForClarity);
- }
[Fact]
- public async Task TestFixAll3()
- {
- await TestMissingAsync(
+ public Task TestFixAll3()
+ => TestMissingAsync(
"""
class C
{
@@ -814,12 +748,10 @@ void M()
}
}
""", RequireAllParenthesesForClarity);
- }
[Fact]
- public async Task TestSeams1()
- {
- await TestInRegularAndScriptAsync(
+ public Task TestSeams1()
+ => TestInRegularAndScriptAsync(
"""
class C
{
@@ -838,5 +770,4 @@ void M()
}
}
""", options: RequireAllParenthesesForClarity);
- }
}
diff --git a/src/Analyzers/CSharp/Tests/AddRequiredParentheses/AddRequiredPatternParenthesesTests.cs b/src/Analyzers/CSharp/Tests/AddRequiredParentheses/AddRequiredPatternParenthesesTests.cs
index ab61e7e1401c3..7085621118ab6 100644
--- a/src/Analyzers/CSharp/Tests/AddRequiredParentheses/AddRequiredPatternParenthesesTests.cs
+++ b/src/Analyzers/CSharp/Tests/AddRequiredParentheses/AddRequiredPatternParenthesesTests.cs
@@ -29,9 +29,8 @@ private Task TestAsync(string initialMarkup, string expected, OptionsCollection
=> TestInRegularAndScript1Async(initialMarkup, expected, parameters: new TestParameters(options: options));
[Fact]
- public async Task TestLogicalPrecedence()
- {
- await TestAsync(
+ public Task TestLogicalPrecedence()
+ => TestAsync(
"""
class C
{
@@ -50,12 +49,10 @@ void M(object o)
}
}
""", RequireAllParenthesesForClarity);
- }
[Fact]
- public async Task TestNoLogicalOnLowerPrecedence()
- {
- await TestMissingAsync(
+ public Task TestNoLogicalOnLowerPrecedence()
+ => TestMissingAsync(
"""
class C
{
@@ -65,12 +62,10 @@ void M(object o)
}
}
""", RequireAllParenthesesForClarity);
- }
[Fact]
- public async Task TestNotIfLogicalPrecedenceStaysTheSame()
- {
- await TestMissingAsync(
+ public Task TestNotIfLogicalPrecedenceStaysTheSame()
+ => TestMissingAsync(
"""
class C
{
@@ -80,12 +75,10 @@ void M(object o)
}
}
""", RequireAllParenthesesForClarity);
- }
[Fact]
- public async Task TestNotIfLogicalPrecedenceIsNotEnforced()
- {
- await TestMissingAsync(
+ public Task TestNotIfLogicalPrecedenceIsNotEnforced()
+ => TestMissingAsync(
"""
class C
{
@@ -95,12 +88,10 @@ void M(object o)
}
}
""", RequireArithmeticBinaryParenthesesForClarity);
- }
[Fact]
- public async Task TestLogicalPrecedenceMultipleEqualPrecedenceParts1()
- {
- await TestAsync(
+ public Task TestLogicalPrecedenceMultipleEqualPrecedenceParts1()
+ => TestAsync(
"""
class C
{
@@ -119,12 +110,10 @@ void M(object o)
}
}
""", RequireAllParenthesesForClarity);
- }
[Fact]
- public async Task TestLogicalPrecedenceMultipleEqualPrecedenceParts2()
- {
- await TestAsync(
+ public Task TestLogicalPrecedenceMultipleEqualPrecedenceParts2()
+ => TestAsync(
"""
class C
{
@@ -143,5 +132,4 @@ void M(object o)
}
}
""", RequireAllParenthesesForClarity);
- }
}
diff --git a/src/Analyzers/CSharp/Tests/AliasAmbiguousType/AliasAmbiguousTypeTests.cs b/src/Analyzers/CSharp/Tests/AliasAmbiguousType/AliasAmbiguousTypeTests.cs
index 61a67630c278b..643d25633472c 100644
--- a/src/Analyzers/CSharp/Tests/AliasAmbiguousType/AliasAmbiguousTypeTests.cs
+++ b/src/Analyzers/CSharp/Tests/AliasAmbiguousType/AliasAmbiguousTypeTests.cs
@@ -19,77 +19,78 @@
namespace Microsoft.CodeAnalysis.Editor.CSharp.UnitTests.AliasAmbiguousType;
[Trait(Traits.Feature, Traits.Features.CodeActionsAliasAmbiguousType)]
-public sealed class AliasAmbiguousTypeTests : AbstractCSharpDiagnosticProviderBasedUserDiagnosticTest_NoEditor
+public sealed class AliasAmbiguousTypeTests(ITestOutputHelper logger) : AbstractCSharpDiagnosticProviderBasedUserDiagnosticTest_NoEditor(logger)
{
- public AliasAmbiguousTypeTests(ITestOutputHelper logger)
- : base(logger)
- {
- }
-
internal override (DiagnosticAnalyzer?, CodeFixProvider) CreateDiagnosticProviderAndFixer(Workspace workspace)
=> (null, new CSharpAliasAmbiguousTypeCodeFixProvider());
protected override ImmutableArray MassageActions(ImmutableArray actions)
=> FlattenActions(actions);
- private static string GetAmbiguousDefinition(string typeDefinion, string ns1Name = "N1", string ns2Name = "N2")
- => $@"
-namespace {ns1Name}
-{{
- {typeDefinion}
-}}
-namespace {ns2Name}
-{{
- {typeDefinion}
-}}";
+ private static string GetAmbiguousDefinition(string typeDefinition, string ns1Name = "N1", string ns2Name = "N2")
+ => $$"""
- [Fact]
- public async Task TestAmbiguousClassObjectCreationUsingsInNamespace()
- {
- var classDef = GetAmbiguousDefinition("public class Ambiguous { }");
- var initialMarkup = classDef + @"
-namespace Test
-{
- using N1;
- using N2;
- class C
- {
- void M()
+ namespace {{ns1Name}}
{
- var a = new [|Ambiguous|]();
+ {{typeDefinition}}
}
- }
-}";
- var expectedMarkup0 = classDef + @"
-namespace Test
-{
- using N1;
- using N2;
- using Ambiguous = N1.Ambiguous;
-
- class C
- {
- void M()
+ namespace {{ns2Name}}
{
- var a = new Ambiguous();
+ {{typeDefinition}}
}
- }
-}";
- var expectedMarkup1 = classDef + @"
-namespace Test
-{
- using N1;
- using N2;
- using Ambiguous = N2.Ambiguous;
- class C
+ """;
+
+ [Fact]
+ public async Task TestAmbiguousClassObjectCreationUsingsInNamespace()
{
- void M()
- {
- var a = new Ambiguous();
- }
- }
-}";
+ var classDef = GetAmbiguousDefinition("public class Ambiguous { }");
+ var initialMarkup = classDef + """
+ namespace Test
+ {
+ using N1;
+ using N2;
+ class C
+ {
+ void M()
+ {
+ var a = new [|Ambiguous|]();
+ }
+ }
+ }
+ """;
+ var expectedMarkup0 = classDef + """
+ namespace Test
+ {
+ using N1;
+ using N2;
+ using Ambiguous = N1.Ambiguous;
+
+ class C
+ {
+ void M()
+ {
+ var a = new Ambiguous();
+ }
+ }
+ }
+ """;
+ var expectedMarkup1 = classDef + """
+ namespace Test
+ {
+ using N1;
+ using N2;
+ using Ambiguous = N2.Ambiguous;
+
+ class C
+ {
+ void M()
+ {
+ var a = new Ambiguous();
+ }
+ }
+ }
+ """;
await TestInRegularAndScriptAsync(initialMarkup, expectedMarkup0, index: 0);
await TestInRegularAndScriptAsync(initialMarkup, expectedMarkup1, index: 1);
await TestSmartTagTextAsync(initialMarkup, "using Ambiguous = N1.Ambiguous;");
@@ -99,211 +100,210 @@ void M()
public async Task TestAmbiguousClassObjectCreationUsingsInCompilationUnit()
{
var classDef = GetAmbiguousDefinition("public class Ambiguous { }");
- await TestInRegularAndScriptAsync(@"
-using N1;
-using N2;
-" + classDef + @"
-namespace Test
-{
- class C
- {
- void M()
- {
- var a = new [|Ambiguous|]();
- }
- }
-}", @"
-using N1;
-using N2;
-using Ambiguous = N1.Ambiguous;
-" + classDef + @"
-namespace Test
-{
- class C
- {
- void M()
- {
- var a = new Ambiguous();
- }
- }
-}");
+ await TestInRegularAndScriptAsync("""
+ using N1;
+ using N2;
+ """ + classDef + """
+ namespace Test
+ {
+ class C
+ {
+ void M()
+ {
+ var a = new [|Ambiguous|]();
+ }
+ }
+ }
+ """, """
+ using N1;
+ using N2;
+ using Ambiguous = N1.Ambiguous;
+ """ + classDef + """
+ namespace Test
+ {
+ class C
+ {
+ void M()
+ {
+ var a = new Ambiguous();
+ }
+ }
+ }
+ """);
}
[Fact]
public async Task TestAmbiguousClassObjectCreationGenericsDoNotOfferDiagnostic()
{
var genericAmbiguousClassDefinition = GetAmbiguousDefinition("public class Ambiguous { }");
- await TestMissingAsync(@"
-using N1;
-using N2;
-" + genericAmbiguousClassDefinition + @"
-namespace Test
-{
- class C
- {
- void M()
- {
- var a = new [|Ambiguous|]();
- }
- }
-}");
+ await TestMissingAsync("""
+ using N1;
+ using N2;
+ """ + genericAmbiguousClassDefinition + """
+ namespace Test
+ {
+ class C
+ {
+ void M()
+ {
+ var a = new [|Ambiguous|]();
+ }
+ }
+ }
+ """);
}
[Fact]
public async Task TestAmbiguousAttribute()
{
var classDef = GetAmbiguousDefinition("public class AmbiguousAttribute: System.Attribute { }");
- await TestInRegularAndScriptAsync(@"
-using N1;
-using N2;
-" + classDef + @"
-namespace Test
-{
- [[|Ambiguous|]]
- class C
- {
- }
-}", @"
-using N1;
-using N2;
-using AmbiguousAttribute = N1.AmbiguousAttribute;
-" + classDef + @"
-namespace Test
-{
- [Ambiguous]
- class C
- {
- }
-}");
+ await TestInRegularAndScriptAsync("""
+ using N1;
+ using N2;
+ """ + classDef + """
+ namespace Test
+ {
+ [[|Ambiguous|]]
+ class C
+ {
+ }
+ }
+ """, """
+ using N1;
+ using N2;
+ using AmbiguousAttribute = N1.AmbiguousAttribute;
+ """ + classDef + """
+ namespace Test
+ {
+ [Ambiguous]
+ class C
+ {
+ }
+ }
+ """);
}
[Fact]
- public async Task TestNamespaceAndTypenameIdenticalOffersNoDiagnostics()
- {
- // This gives CS0433: The type 'Ambiguous' exists in both 'Assembly1' and 'Assembly2'
- // Couldn't get a CS0104 in this situation. Keep the test anyway if someone finds a way to force CS0104 here
- // or CS0433 is added as a supported diagnostic for this fix.
- await TestMissingAsync(@"
-
-
-
-namespace N
-{
- public class Ambiguous { }
-}
-
-
-
-
-namespace N
-{
- public class Ambiguous { }
-}
-
-
-
- Assembly1
- Assembly2
-
-extern alias A1;
-extern alias A2;
-using A1::N;
-using A2::N;
-namespace N1
-{
- public class C
- {
- void M()
- {
- var a = new [|Ambiguous|]();
- }
- }
-}
-
-
-
-");
- }
+ public Task TestNamespaceAndTypenameIdenticalOffersNoDiagnostics()
+ => TestMissingAsync("""
+
+
+
+ namespace N
+ {
+ public class Ambiguous { }
+ }
+
+
+
+
+ namespace N
+ {
+ public class Ambiguous { }
+ }
+
+
+
+ Assembly1
+ Assembly2
+
+ extern alias A1;
+ extern alias A2;
+ using A1::N;
+ using A2::N;
+ namespace N1
+ {
+ public class C
+ {
+ void M()
+ {
+ var a = new [|Ambiguous|]();
+ }
+ }
+ }
+
+
+
+ """);
[Fact]
- public async Task TestAmbiguousAliasNoDiagnostics()
- {
- await TestMissingAsync(@"
-extern alias alias;
-using alias=alias;
-class myClass : [|alias|]::Uri
- {
- }
-");
- }
+ public Task TestAmbiguousAliasNoDiagnostics()
+ => TestMissingAsync("""
+ extern alias alias;
+ using alias=alias;
+ class myClass : [|alias|]::Uri
+ {
+ }
+ """);
[Fact]
public async Task TestAmbiguousNestedClass()
{
- var initialMarkup = @"
-using static Static;
-using static Static;
-
-public static class Static
-{
- public class Nested
- {
- public void M() { }
- }
-}
-
-class D
-{
- static void Main(string[] args)
- {
- var c = new [|Nested|]();
- c.M();
- }
-}";
- var expectedMarkup0 = @"
-using static Static;
-using static Static;
-using Nested = Static.Nested;
+ var initialMarkup = """
+ using static Static;
+ using static Static;
-public static class Static
-{
- public class Nested
- {
- public void M() { }
- }
-}
-
-class D
-{
- static void Main(string[] args)
- {
- var c = new Nested();
- c.M();
- }
-}";
- var expectedMarkup1 = @"
-using static Static;
-using static Static;
-using Nested = Static.Nested;
+ public static class Static
+ {
+ public class Nested
+ {
+ public void M() { }
+ }
+ }
-public static class Static
-{
- public class Nested
- {
- public void M() { }
- }
-}
-
-class D
-{
- static void Main(string[] args)
- {
- var c = new Nested();
- c.M();
- }
-}";
- await TestInRegularAndScriptAsync(initialMarkup, expectedMarkup0, index: 0);
- await TestInRegularAndScriptAsync(initialMarkup, expectedMarkup1, index: 1);
+ class D
+ {
+ static void Main(string[] args)
+ {
+ var c = new [|Nested|]();
+ c.M();
+ }
+ }
+ """;
+ await TestInRegularAndScriptAsync(initialMarkup, """
+ using static Static;
+ using static Static;
+ using Nested = Static.Nested;
+
+ public static class Static
+ {
+ public class Nested
+ {
+ public void M() { }
+ }
+ }
+
+ class D
+ {
+ static void Main(string[] args)
+ {
+ var c = new Nested();
+ c.M();
+ }
+ }
+ """, index: 0);
+ await TestInRegularAndScriptAsync(initialMarkup, """
+ using static Static;
+ using static Static;
+ using Nested = Static.Nested;
+
+ public static class Static
+ {
+ public class Nested
+ {
+ public void M() { }
+ }
+ }
+
+ class D
+ {
+ static void Main(string[] args)
+ {
+ var c = new Nested();
+ c.M();
+ }
+ }
+ """, index: 1);
await TestSmartTagTextAsync(initialMarkup, "using Nested = Static.Nested;");
}
@@ -311,25 +311,25 @@ static void Main(string[] args)
public async Task TestAmbiguousClassDiagnosedAtBaseList()
{
var classDef = GetAmbiguousDefinition(@"public class AmbiguousClass { }");
- var initialMarkup = @"
-using N1;
-using N2;
-" + classDef + @"
-namespace NTest
-{
- public class Test : [|AmbiguousClass|] { }
-}
-";
- var expectedMarkup = @"
-using N1;
-using N2;
-using AmbiguousClass = N1.AmbiguousClass;
-" + classDef + @"
-namespace NTest
-{
- public class Test : AmbiguousClass { }
-}
-";
+ var initialMarkup = """
+ using N1;
+ using N2;
+ """ + classDef + """
+ namespace NTest
+ {
+ public class Test : [|AmbiguousClass|] { }
+ }
+ """;
+ var expectedMarkup = """
+ using N1;
+ using N2;
+ using AmbiguousClass = N1.AmbiguousClass;
+ """ + classDef + """
+ namespace NTest
+ {
+ public class Test : AmbiguousClass { }
+ }
+ """;
await TestInRegularAndScriptAsync(initialMarkup, expectedMarkup);
}
@@ -337,25 +337,25 @@ public class Test : AmbiguousClass { }
public async Task TestAmbiguousClassDiagnosedAtTypeConstraint()
{
var classDef = GetAmbiguousDefinition(@"public class AmbiguousClass { }");
- var initialMarkup = @"
-using N1;
-using N2;
-" + classDef + @"
-namespace NTest
-{
- public class Test where T : [|AmbiguousClass|] { }
-}
-";
- var expectedMarkup = @"
-using N1;
-using N2;
-using AmbiguousClass = N1.AmbiguousClass;
-" + classDef + @"
-namespace NTest
-{
- public class Test where T : AmbiguousClass { }
-}
-";
+ var initialMarkup = """
+ using N1;
+ using N2;
+ """ + classDef + """
+ namespace NTest
+ {
+ public class Test where T : [|AmbiguousClass|] { }
+ }
+ """;
+ var expectedMarkup = """
+ using N1;
+ using N2;
+ using AmbiguousClass = N1.AmbiguousClass;
+ """ + classDef + """
+ namespace NTest
+ {
+ public class Test where T : AmbiguousClass { }
+ }
+ """;
await TestInRegularAndScriptAsync(initialMarkup, expectedMarkup);
}
@@ -363,31 +363,31 @@ public class Test where T : AmbiguousClass { }
public async Task TestAmbiguousEnumDiagnosedAtFieldDeclaration()
{
var enumDef = GetAmbiguousDefinition(@"public enum AmbiguousEnum { }");
- var initialMarkup = @"
-using N1;
-using N2;
-" + enumDef + @"
-namespace NTest
-{
- public class Test
- {
- private [|AmbiguousEnum|] _AmbiguousEnum;
- }
-}
-";
- var expectedMarkup = @"
-using N1;
-using N2;
-using AmbiguousEnum = N1.AmbiguousEnum;
-" + enumDef + @"
-namespace NTest
-{
- public class Test
- {
- private AmbiguousEnum _AmbiguousEnum;
- }
-}
-";
+ var initialMarkup = """
+ using N1;
+ using N2;
+ """ + enumDef + """
+ namespace NTest
+ {
+ public class Test
+ {
+ private [|AmbiguousEnum|] _AmbiguousEnum;
+ }
+ }
+ """;
+ var expectedMarkup = """
+ using N1;
+ using N2;
+ using AmbiguousEnum = N1.AmbiguousEnum;
+ """ + enumDef + """
+ namespace NTest
+ {
+ public class Test
+ {
+ private AmbiguousEnum _AmbiguousEnum;
+ }
+ }
+ """;
await TestInRegularAndScriptAsync(initialMarkup, expectedMarkup);
}
@@ -395,31 +395,31 @@ public class Test
public async Task TestAmbiguousStructDiagnosedAtPropertyDeclaration()
{
var strcutDef = GetAmbiguousDefinition(@"public struct AmbiguousStruct { }");
- var initialMarkup = @"
-using N1;
-using N2;
-" + strcutDef + @"
-namespace NTest
-{
- public class Test
- {
- public [|AmbiguousStruct|] AmbiguousStruct { get; }
- }
-}
-";
- var expectedMarkup = @"
-using N1;
-using N2;
-using AmbiguousStruct = N1.AmbiguousStruct;
-" + strcutDef + @"
-namespace NTest
-{
- public class Test
- {
- public AmbiguousStruct AmbiguousStruct { get; }
- }
-}
-";
+ var initialMarkup = """
+ using N1;
+ using N2;
+ """ + strcutDef + """
+ namespace NTest
+ {
+ public class Test
+ {
+ public [|AmbiguousStruct|] AmbiguousStruct { get; }
+ }
+ }
+ """;
+ var expectedMarkup = """
+ using N1;
+ using N2;
+ using AmbiguousStruct = N1.AmbiguousStruct;
+ """ + strcutDef + """
+ namespace NTest
+ {
+ public class Test
+ {
+ public AmbiguousStruct AmbiguousStruct { get; }
+ }
+ }
+ """;
await TestInRegularAndScriptAsync(initialMarkup, expectedMarkup);
}
@@ -427,37 +427,37 @@ public class Test
public async Task TestAmbiguousClassDiagnosedAtTypeArgument()
{
var classDef = GetAmbiguousDefinition(@"public class AmbiguousClass { }");
- var initialMarkup = @"
-using N1;
-using N2;
-" + classDef + @"
-namespace NTest
-{
- public class Test
- {
- public void M()
- {
- var list = new System.Collections.Generic.List<[|AmbiguousClass|]> { new AmbiguousClass() };
- }
- }
-}
-";
- var expectedMarkup = @"
-using N1;
-using N2;
-using AmbiguousClass = N1.AmbiguousClass;
-" + classDef + @"
-namespace NTest
-{
- public class Test
- {
- public void M()
- {
- var list = new System.Collections.Generic.List { new AmbiguousClass() };
- }
- }
-}
-";
+ var initialMarkup = """
+ using N1;
+ using N2;
+ """ + classDef + """
+ namespace NTest
+ {
+ public class Test
+ {
+ public void M()
+ {
+ var list = new System.Collections.Generic.List<[|AmbiguousClass|]> { new AmbiguousClass() };
+ }
+ }
+ }
+ """;
+ var expectedMarkup = """
+ using N1;
+ using N2;
+ using AmbiguousClass = N1.AmbiguousClass;
+ """ + classDef + """
+ namespace NTest
+ {
+ public class Test
+ {
+ public void M()
+ {
+ var list = new System.Collections.Generic.List { new AmbiguousClass() };
+ }
+ }
+ }
+ """;
await TestInRegularAndScriptAsync(initialMarkup, expectedMarkup);
}
@@ -465,37 +465,37 @@ public void M()
public async Task TestAmbiguousClassDiagnosedAtIdentifierOfIncompleteExpression()
{
var classDef = GetAmbiguousDefinition(@"public class AmbiguousClass { }");
- var initialMarkup = @"
-using N1;
-using N2;
-" + classDef + @"
-namespace NTest
-{
- public class Test
- {
- public void M()
- {
- [|AmbiguousClass|]
- }
- }
-}
-";
- var expectedMarkup = @"
-using N1;
-using N2;
-using AmbiguousClass = N1.AmbiguousClass;
-" + classDef + @"
-namespace NTest
-{
- public class Test
- {
- public void M()
- {
- AmbiguousClass
- }
- }
-}
-";
+ var initialMarkup = """
+ using N1;
+ using N2;
+ """ + classDef + """
+ namespace NTest
+ {
+ public class Test
+ {
+ public void M()
+ {
+ [|AmbiguousClass|]
+ }
+ }
+ }
+ """;
+ var expectedMarkup = """
+ using N1;
+ using N2;
+ using AmbiguousClass = N1.AmbiguousClass;
+ """ + classDef + """
+ namespace NTest
+ {
+ public class Test
+ {
+ public void M()
+ {
+ AmbiguousClass
+ }
+ }
+ }
+ """;
await TestInRegularAndScriptAsync(initialMarkup, expectedMarkup);
}
@@ -503,35 +503,35 @@ public void M()
public async Task TestAmbiguousClassDiagnosedAtMethodParameter()
{
var classDef = GetAmbiguousDefinition(@"public class AmbiguousClass { }");
- var initialMarkup = @"
-using N1;
-using N2;
-" + classDef + @"
-namespace NTest
-{
- public class Test
- {
- public void M([|AmbiguousClass|] a)
- {
- }
- }
-}
-";
- var expectedMarkup = @"
-using N1;
-using N2;
-using AmbiguousClass = N1.AmbiguousClass;
-" + classDef + @"
-namespace NTest
-{
- public class Test
- {
- public void M(AmbiguousClass a)
- {
- }
- }
-}
-";
+ var initialMarkup = """
+ using N1;
+ using N2;
+ """ + classDef + """
+ namespace NTest
+ {
+ public class Test
+ {
+ public void M([|AmbiguousClass|] a)
+ {
+ }
+ }
+ }
+ """;
+ var expectedMarkup = """
+ using N1;
+ using N2;
+ using AmbiguousClass = N1.AmbiguousClass;
+ """ + classDef + """
+ namespace NTest
+ {
+ public class Test
+ {
+ public void M(AmbiguousClass a)
+ {
+ }
+ }
+ }
+ """;
await TestInRegularAndScriptAsync(initialMarkup, expectedMarkup);
}
@@ -539,41 +539,41 @@ public void M(AmbiguousClass a)
public async Task TestAmbiguousClassDiagnosedAtFromClauseTypeIdentifier()
{
var classDef = GetAmbiguousDefinition(@"public class AmbiguousClass { }");
- var initialMarkup = @"
-using N1;
-using N2;
-using System.Linq;
-" + classDef + @"
-namespace NTest
-{
- public class Test
- {
- public void M()
- {
- var qry = from [|AmbiguousClass|] a in new object[] { }
- select a;
- }
- }
-}
-";
- var expectedMarkup = @"
-using N1;
-using N2;
-using System.Linq;
-using AmbiguousClass = N1.AmbiguousClass;
-" + classDef + @"
-namespace NTest
-{
- public class Test
- {
- public void M()
- {
- var qry = from AmbiguousClass a in new object[] { }
- select a;
- }
- }
-}
-";
+ var initialMarkup = """
+ using N1;
+ using N2;
+ using System.Linq;
+ """ + classDef + """
+ namespace NTest
+ {
+ public class Test
+ {
+ public void M()
+ {
+ var qry = from [|AmbiguousClass|] a in new object[] { }
+ select a;
+ }
+ }
+ }
+ """;
+ var expectedMarkup = """
+ using N1;
+ using N2;
+ using System.Linq;
+ using AmbiguousClass = N1.AmbiguousClass;
+ """ + classDef + """
+ namespace NTest
+ {
+ public class Test
+ {
+ public void M()
+ {
+ var qry = from AmbiguousClass a in new object[] { }
+ select a;
+ }
+ }
+ }
+ """;
await TestInRegularAndScriptAsync(initialMarkup, expectedMarkup);
}
@@ -581,49 +581,52 @@ public void M()
public async Task TestSortSystemFirst1()
{
var classDef = GetAmbiguousDefinition("public class Ambiguous { }", "Microsoft", "System");
- var initialMarkup = classDef + @"
-namespace Test
-{
- using System;
- using Microsoft;
- class C
- {
- void M()
- {
- var a = new [|Ambiguous|]();
- }
- }
-}";
- var expectedMarkup0 = classDef + @"
-namespace Test
-{
- using System;
- using Microsoft;
- using Ambiguous = System.Ambiguous;
+ var initialMarkup = classDef + """
+ namespace Test
+ {
+ using System;
+ using Microsoft;
+ class C
+ {
+ void M()
+ {
+ var a = new [|Ambiguous|]();
+ }
+ }
+ }
+ """;
+ var expectedMarkup0 = classDef + """
+ namespace Test
+ {
+ using System;
+ using Microsoft;
+ using Ambiguous = System.Ambiguous;
- class C
- {
- void M()
- {
- var a = new Ambiguous();
- }
- }
-}";
- var expectedMarkup1 = classDef + @"
-namespace Test
-{
- using System;
- using Microsoft;
- using Ambiguous = Microsoft.Ambiguous;
+ class C
+ {
+ void M()
+ {
+ var a = new Ambiguous();
+ }
+ }
+ }
+ """;
+ var expectedMarkup1 = classDef + """
+ namespace Test
+ {
+ using System;
+ using Microsoft;
+ using Ambiguous = Microsoft.Ambiguous;
- class C
- {
- void M()
- {
- var a = new Ambiguous();
- }
- }
-}";
+ class C
+ {
+ void M()
+ {
+ var a = new Ambiguous();
+ }
+ }
+ }
+ """;
await TestInRegularAndScriptAsync(initialMarkup, expectedMarkup0, index: 0);
await TestInRegularAndScriptAsync(initialMarkup, expectedMarkup1, index: 1);
}
@@ -632,49 +635,52 @@ void M()
public async Task TestSortSystemFirst2()
{
var classDef = GetAmbiguousDefinition("public class Ambiguous { }", "Microsoft", "System");
- var initialMarkup = classDef + @"
-namespace Test
-{
- using System;
- using Microsoft;
- class C
- {
- void M()
- {
- var a = new [|Ambiguous|]();
- }
- }
-}";
- var expectedMarkup0 = classDef + @"
-namespace Test
-{
- using System;
- using Microsoft;
- using Ambiguous = Microsoft.Ambiguous;
+ var initialMarkup = classDef + """
+ namespace Test
+ {
+ using System;
+ using Microsoft;
+ class C
+ {
+ void M()
+ {
+ var a = new [|Ambiguous|]();
+ }
+ }
+ }
+ """;
+ var expectedMarkup0 = classDef + """
+ namespace Test
+ {
+ using System;
+ using Microsoft;
+ using Ambiguous = Microsoft.Ambiguous;
- class C
- {
- void M()
- {
- var a = new Ambiguous();
- }
- }
-}";
- var expectedMarkup1 = classDef + @"
-namespace Test
-{
- using System;
- using Microsoft;
- using Ambiguous = System.Ambiguous;
+ class C
+ {
+ void M()
+ {
+ var a = new Ambiguous();
+ }
+ }
+ }
+ """;
+ var expectedMarkup1 = classDef + """
+ namespace Test
+ {
+ using System;
+ using Microsoft;
+ using Ambiguous = System.Ambiguous;
- class C
- {
- void M()
- {
- var a = new Ambiguous();
- }
- }
-}";
+ class C
+ {
+ void M()
+ {
+ var a = new Ambiguous();
+ }
+ }
+ }
+ """;
var options = new OptionsCollection(LanguageNames.CSharp)
{
{ GenerationOptions.PlaceSystemNamespaceFirst, false }
diff --git a/src/Analyzers/CSharp/Tests/AssignOutParameters/AssignOutParametersAboveReturnTests.cs b/src/Analyzers/CSharp/Tests/AssignOutParameters/AssignOutParametersAboveReturnTests.cs
index 5edcbc84e80ef..a34038ab097a5 100644
--- a/src/Analyzers/CSharp/Tests/AssignOutParameters/AssignOutParametersAboveReturnTests.cs
+++ b/src/Analyzers/CSharp/Tests/AssignOutParameters/AssignOutParametersAboveReturnTests.cs
@@ -19,9 +19,8 @@ namespace Microsoft.CodeAnalysis.Editor.CSharp.UnitTests.AssignOutParameters;
public sealed class AssignOutParametersAboveReturnTests
{
[Fact]
- public async Task TestForSimpleReturn()
- {
- await VerifyCS.VerifyCodeFixAsync(
+ public Task TestForSimpleReturn()
+ => VerifyCS.VerifyCodeFixAsync(
"""
class C
{
@@ -41,12 +40,10 @@ char M(out int i)
}
}
""");
- }
[Fact]
- public async Task TestForSwitchSectionReturn()
- {
- await VerifyCS.VerifyCodeFixAsync(
+ public Task TestForSwitchSectionReturn()
+ => VerifyCS.VerifyCodeFixAsync(
"""
class C
{
@@ -74,7 +71,6 @@ char M(out int i)
}
}
""");
- }
[Fact]
public async Task TestMissingWhenVariableAssigned()
@@ -94,9 +90,8 @@ char M(out int i)
}
[Fact]
- public async Task TestWhenNotAssignedThroughAllPaths1()
- {
- await VerifyCS.VerifyCodeFixAsync(
+ public Task TestWhenNotAssignedThroughAllPaths1()
+ => VerifyCS.VerifyCodeFixAsync(
"""
class C
{
@@ -121,12 +116,10 @@ char M(bool b, out int i)
}
}
""");
- }
[Fact]
- public async Task TestWhenNotAssignedThroughAllPaths2()
- {
- await VerifyCS.VerifyCodeFixAsync(
+ public Task TestWhenNotAssignedThroughAllPaths2()
+ => VerifyCS.VerifyCodeFixAsync(
"""
class C
{
@@ -158,7 +151,6 @@ bool Try(out int i)
}
}
""");
- }
[Fact]
public async Task TestMissingWhenAssignedThroughAllPaths()
@@ -182,9 +174,8 @@ char M(bool b, out int i)
}
[Fact]
- public async Task TestMultiple()
- {
- await VerifyCS.VerifyCodeFixAsync(
+ public Task TestMultiple()
+ => VerifyCS.VerifyCodeFixAsync(
"""
class C
{
@@ -205,12 +196,10 @@ char M(out int i, out string s)
}
}
""");
- }
[Fact]
- public async Task TestMultiple_AssignedInReturn1()
- {
- await VerifyCS.VerifyCodeFixAsync(
+ public Task TestMultiple_AssignedInReturn1()
+ => VerifyCS.VerifyCodeFixAsync(
"""
class C
{
@@ -230,12 +219,10 @@ string M(out int i, out string s)
}
}
""");
- }
[Fact]
- public async Task TestMultiple_AssignedInReturn2()
- {
- await VerifyCS.VerifyCodeFixAsync(
+ public Task TestMultiple_AssignedInReturn2()
+ => VerifyCS.VerifyCodeFixAsync(
"""
class C
{
@@ -255,12 +242,10 @@ string M(out int i, out string s)
}
}
""");
- }
[Fact]
- public async Task TestNestedReturn()
- {
- await VerifyCS.VerifyCodeFixAsync(
+ public Task TestNestedReturn()
+ => VerifyCS.VerifyCodeFixAsync(
"""
class C
{
@@ -286,12 +271,10 @@ char M(out int i)
}
}
""");
- }
[Fact]
- public async Task TestNestedReturnNoBlock()
- {
- await VerifyCS.VerifyCodeFixAsync(
+ public Task TestNestedReturnNoBlock()
+ => VerifyCS.VerifyCodeFixAsync(
"""
class C
{
@@ -315,12 +298,10 @@ char M(out int i)
}
}
""");
- }
[Fact]
- public async Task TestNestedReturnEvenWhenWrittenAfter()
- {
- await VerifyCS.VerifyCodeFixAsync(
+ public Task TestNestedReturnEvenWhenWrittenAfter()
+ => VerifyCS.VerifyCodeFixAsync(
"""
class C
{
@@ -352,12 +333,10 @@ char M(bool b, out int i)
}
}
""");
- }
[Fact]
- public async Task TestForExpressionBodyMember()
- {
- await VerifyCS.VerifyCodeFixAsync(
+ public Task TestForExpressionBodyMember()
+ => VerifyCS.VerifyCodeFixAsync(
"""
class C
{
@@ -374,12 +353,10 @@ char M(out int i)
}
}
""");
- }
[Fact]
- public async Task TestForLambdaExpressionBody()
- {
- await VerifyCS.VerifyCodeFixAsync(
+ public Task TestForLambdaExpressionBody()
+ => VerifyCS.VerifyCodeFixAsync(
"""
class C
{
@@ -400,12 +377,10 @@ void X()
}
}
""");
- }
[Fact]
- public async Task TestMissingForLocalFunctionExpressionBody()
- {
- await VerifyCS.VerifyCodeFixAsync(
+ public Task TestMissingForLocalFunctionExpressionBody()
+ => VerifyCS.VerifyCodeFixAsync(
"""
class C
{
@@ -427,12 +402,10 @@ void X()
}
}
""");
- }
[Fact]
- public async Task TestForLambdaBlockBody()
- {
- await VerifyCS.VerifyCodeFixAsync(
+ public Task TestForLambdaBlockBody()
+ => VerifyCS.VerifyCodeFixAsync(
"""
class C
{
@@ -460,12 +433,10 @@ void X()
}
}
""");
- }
[Fact]
- public async Task TestForLocalFunctionBlockBody()
- {
- await VerifyCS.VerifyCodeFixAsync(
+ public Task TestForLocalFunctionBlockBody()
+ => VerifyCS.VerifyCodeFixAsync(
"""
class C
{
@@ -495,7 +466,6 @@ char D(out int i)
}
}
""");
- }
[Fact]
public async Task TestForOutParamInSinglePath()
@@ -521,9 +491,8 @@ char M(bool b, out int i)
}
[Fact]
- public async Task TestFixAll1()
- {
- await VerifyCS.VerifyCodeFixAsync(
+ public Task TestFixAll1()
+ => VerifyCS.VerifyCodeFixAsync(
"""
class C
{
@@ -560,12 +529,10 @@ char M(bool b, out int i, out int j)
}
}
""");
- }
[Fact]
- public async Task TestFixAll1_MultipleMethods()
- {
- await VerifyCS.VerifyCodeFixAsync(
+ public Task TestFixAll1_MultipleMethods()
+ => VerifyCS.VerifyCodeFixAsync(
"""
class C
{
@@ -628,12 +595,10 @@ char N(bool b, out int i, out int j)
}
}
""");
- }
[Fact]
- public async Task TestFixAll2()
- {
- await VerifyCS.VerifyCodeFixAsync(
+ public Task TestFixAll2()
+ => VerifyCS.VerifyCodeFixAsync(
"""
class C
{
@@ -666,12 +631,10 @@ char M(bool b, out int i, out int j)
}
}
""");
- }
[Fact]
- public async Task TestFixAll2_MultipleMethods()
- {
- await VerifyCS.VerifyCodeFixAsync(
+ public Task TestFixAll2_MultipleMethods()
+ => VerifyCS.VerifyCodeFixAsync(
"""
class C
{
@@ -726,12 +689,10 @@ char N(bool b, out int i, out int j)
}
}
""");
- }
[Fact]
- public async Task TestFixAll3()
- {
- await VerifyCS.VerifyCodeFixAsync(
+ public Task TestFixAll3()
+ => VerifyCS.VerifyCodeFixAsync(
"""
class C
{
@@ -770,12 +731,10 @@ char M(bool b, out int i, out int j)
}
}
""");
- }
[Fact]
- public async Task TestFixAll3_MultipleMethods()
- {
- await VerifyCS.VerifyCodeFixAsync(
+ public Task TestFixAll3_MultipleMethods()
+ => VerifyCS.VerifyCodeFixAsync(
"""
class C
{
@@ -842,5 +801,4 @@ char N(bool b, out int i, out int j)
}
}
""");
- }
}
diff --git a/src/Analyzers/CSharp/Tests/AssignOutParameters/AssignOutParametersAtStartTests.cs b/src/Analyzers/CSharp/Tests/AssignOutParameters/AssignOutParametersAtStartTests.cs
index 4635adcafca23..d9f4682861ec3 100644
--- a/src/Analyzers/CSharp/Tests/AssignOutParameters/AssignOutParametersAtStartTests.cs
+++ b/src/Analyzers/CSharp/Tests/AssignOutParameters/AssignOutParametersAtStartTests.cs
@@ -41,9 +41,8 @@ char M(out int i)
}
[Fact]
- public async Task TestForSwitchSectionReturn()
- {
- await VerifyCS.VerifyCodeFixAsync(
+ public Task TestForSwitchSectionReturn()
+ => VerifyCS.VerifyCodeFixAsync(
"""
class C
{
@@ -71,7 +70,6 @@ char M(out int i)
}
}
""");
- }
[Fact]
public async Task TestMissingWhenVariableAssigned()
@@ -91,9 +89,8 @@ char M(out int i)
}
[Fact]
- public async Task TestWhenNotAssignedThroughAllPaths1()
- {
- await VerifyCS.VerifyCodeFixAsync(
+ public Task TestWhenNotAssignedThroughAllPaths1()
+ => VerifyCS.VerifyCodeFixAsync(
"""
class C
{
@@ -119,7 +116,6 @@ char M(bool b, out int i)
}
}
""");
- }
[Fact]
public async Task TestWhenNotAssignedThroughAllPaths2()
@@ -217,9 +213,8 @@ string M(out int i, out string s)
}
[Fact]
- public async Task TestNestedReturn()
- {
- await VerifyCS.VerifyCodeFixAsync(
+ public Task TestNestedReturn()
+ => VerifyCS.VerifyCodeFixAsync(
"""
class C
{
@@ -245,12 +240,10 @@ char M(out int i)
}
}
""");
- }
[Fact]
- public async Task TestNestedReturnNoBlock()
- {
- await VerifyCS.VerifyCodeFixAsync(
+ public Task TestNestedReturnNoBlock()
+ => VerifyCS.VerifyCodeFixAsync(
"""
class C
{
@@ -272,12 +265,10 @@ char M(out int i)
}
}
""");
- }
[Fact]
- public async Task TestNestedReturnEvenWhenWrittenAfter()
- {
- await VerifyCS.VerifyCodeFixAsync(
+ public Task TestNestedReturnEvenWhenWrittenAfter()
+ => VerifyCS.VerifyCodeFixAsync(
"""
class C
{
@@ -309,7 +300,6 @@ char M(bool b, out int i)
}
}
""");
- }
[Fact]
public async Task TestForExpressionBodyMember()
@@ -428,9 +418,8 @@ char M(bool b, out int i)
}
[Fact]
- public async Task TestFixAll1()
- {
- await VerifyCS.VerifyCodeFixAsync(
+ public Task TestFixAll1()
+ => VerifyCS.VerifyCodeFixAsync(
"""
class C
{
@@ -465,12 +454,10 @@ char M(bool b, out int i, out int j)
}
}
""");
- }
[Fact]
- public async Task TestFixAll1_MultipleMethods()
- {
- await VerifyCS.VerifyCodeFixAsync(
+ public Task TestFixAll1_MultipleMethods()
+ => VerifyCS.VerifyCodeFixAsync(
"""
class C
{
@@ -529,12 +516,10 @@ char N(bool b, out int i, out int j)
}
}
""");
- }
[Fact]
- public async Task TestFixAll2()
- {
- await VerifyCS.VerifyCodeFixAsync(
+ public Task TestFixAll2()
+ => VerifyCS.VerifyCodeFixAsync(
"""
class C
{
@@ -561,12 +546,10 @@ char M(bool b, out int i, out int j)
}
}
""");
- }
[Fact]
- public async Task TestFixAll2_MultipleMethods()
- {
- await VerifyCS.VerifyCodeFixAsync(
+ public Task TestFixAll2_MultipleMethods()
+ => VerifyCS.VerifyCodeFixAsync(
"""
class C
{
@@ -609,12 +592,10 @@ char N(bool b, out int i, out int j)
}
}
""");
- }
[Fact]
- public async Task TestFixAll3()
- {
- await VerifyCS.VerifyCodeFixAsync(
+ public Task TestFixAll3()
+ => VerifyCS.VerifyCodeFixAsync(
"""
class C
{
@@ -653,12 +634,10 @@ char M(bool b, out int i, out int j)
}
}
""");
- }
[Fact]
- public async Task TestFixAll3_MultipleMethods()
- {
- await VerifyCS.VerifyCodeFixAsync(
+ public Task TestFixAll3_MultipleMethods()
+ => VerifyCS.VerifyCodeFixAsync(
"""
class C
{
@@ -725,5 +704,4 @@ char N(bool b, out int i, out int j)
}
}
""");
- }
}
diff --git a/src/Analyzers/CSharp/Tests/ConditionalExpressionInStringInterpolation/CSharpAddParenthesesAroundConditionalExpressionInInterpolatedStringCodeFixProviderTests.cs b/src/Analyzers/CSharp/Tests/ConditionalExpressionInStringInterpolation/CSharpAddParenthesesAroundConditionalExpressionInInterpolatedStringCodeFixProviderTests.cs
index 2fb2222dfad5e..c6efb0a63901f 100644
--- a/src/Analyzers/CSharp/Tests/ConditionalExpressionInStringInterpolation/CSharpAddParenthesesAroundConditionalExpressionInInterpolatedStringCodeFixProviderTests.cs
+++ b/src/Analyzers/CSharp/Tests/ConditionalExpressionInStringInterpolation/CSharpAddParenthesesAroundConditionalExpressionInInterpolatedStringCodeFixProviderTests.cs
@@ -41,17 +41,14 @@ await TestInRegularAndScriptAsync(
}
[Fact]
- public async Task TestAddParenthesesSimpleConditionalExpression()
- {
- await TestInMethodAsync(
+ public Task TestAddParenthesesSimpleConditionalExpression()
+ => TestInMethodAsync(
"""var s = $"{ true ? 1 [|:|] 2}";""",
"""var s = $"{ (true ? 1 : 2)}";""");
- }
[Fact]
- public async Task TestAddParenthesesMultiLineConditionalExpression1()
- {
- await TestInMethodAsync("""
+ public Task TestAddParenthesesMultiLineConditionalExpression1()
+ => TestInMethodAsync("""
var s = $@"{ true
[|? 1|]
: 2}";
@@ -60,12 +57,10 @@ await TestInMethodAsync("""
? 1
: 2)}";
""");
- }
[Fact]
- public async Task TestAddParenthesesMultiLineConditionalExpression2()
- {
- await TestInMethodAsync("""
+ public Task TestAddParenthesesMultiLineConditionalExpression2()
+ => TestInMethodAsync("""
var s = $@"{
true
?
@@ -82,120 +77,92 @@ await TestInMethodAsync("""
2
) }";
""");
- }
[Fact]
- public async Task TestAddParenthesesWithTrivia()
- {
- await TestInMethodAsync(
+ public Task TestAddParenthesesWithTrivia()
+ => TestInMethodAsync(
"""var s = $"{ /* Leading1 */ true /* Leading2 */ ? /* TruePart1 */ 1 /* TruePart2 */[|:|] /* FalsePart1 */ 2 /* FalsePart2 */ }";""",
"""var s = $"{ /* Leading1 */ (true /* Leading2 */ ? /* TruePart1 */ 1 /* TruePart2 */: /* FalsePart1 */ 2) /* FalsePart2 */ }";""");
- }
[Fact]
- public async Task TestAddParenthesesClosingBracketInFalseCondition()
- {
- await TestInMethodAsync(
+ public Task TestAddParenthesesClosingBracketInFalseCondition()
+ => TestInMethodAsync(
"""var s = $"{ true ? new int[0] [|:|] new int[] {} }";""",
"""var s = $"{ (true ? new int[0] : new int[] {}) }";""");
- }
[Fact]
- public async Task TestAddParenthesesStringLiteralInFalseCondition()
- {
- await TestInMethodAsync(
+ public Task TestAddParenthesesStringLiteralInFalseCondition()
+ => TestInMethodAsync(
"""var s = $"{ true ? "1" [|:|] "2" }";""",
"""var s = $"{ (true ? "1" : "2") }";""");
- }
[Fact]
- public async Task TestAddParenthesesVerbatimStringLiteralInFalseCondition()
- {
- await TestInMethodAsync(
+ public Task TestAddParenthesesVerbatimStringLiteralInFalseCondition()
+ => TestInMethodAsync(
""""var s = $"{ true ? "1" [|:|] @"""2""" }";"""",
""""var s = $"{ (true ? "1" : @"""2""") }";"""");
- }
[Fact]
- public async Task TestAddParenthesesStringLiteralInFalseConditionWithClosingParenthesisInLiteral()
- {
- await TestInMethodAsync(
+ public Task TestAddParenthesesStringLiteralInFalseConditionWithClosingParenthesisInLiteral()
+ => TestInMethodAsync(
"""var s = $"{ true ? "1" [|:|] "2)" }";""",
"""var s = $"{ (true ? "1" : "2)") }";""");
- }
[Fact]
- public async Task TestAddParenthesesStringLiteralInFalseConditionWithEscapedDoubleQuotes()
- {
- await TestInMethodAsync(
+ public Task TestAddParenthesesStringLiteralInFalseConditionWithEscapedDoubleQuotes()
+ => TestInMethodAsync(
"""var s = $"{ true ? "1" [|:|] "2\"" }";""",
"""var s = $"{ (true ? "1" : "2\"") }";""");
- }
[Fact]
- public async Task TestAddParenthesesStringLiteralInFalseConditionWithCodeLikeContent()
- {
- await TestInMethodAsync(
+ public Task TestAddParenthesesStringLiteralInFalseConditionWithCodeLikeContent()
+ => TestInMethodAsync(
"""var s = $"{ true ? "1" [|:|] "M(new int[] {}, \"Parameter\");" }";""",
"""var s = $"{ (true ? "1" : "M(new int[] {}, \"Parameter\");") }";""");
- }
[Fact]
- public async Task TestAddParenthesesNestedConditionalExpression1()
- {
- await TestInMethodAsync(
+ public Task TestAddParenthesesNestedConditionalExpression1()
+ => TestInMethodAsync(
"""var s2 = $"{ true ? "1" [|:|] (false ? "2" : "3") };""",
"""var s2 = $"{ (true ? "1" : (false ? "2" : "3")) };""");
- }
[Fact]
- public async Task TestAddParenthesesNestedConditionalExpression2()
- {
- await TestInMethodAsync(
+ public Task TestAddParenthesesNestedConditionalExpression2()
+ => TestInMethodAsync(
"""var s2 = $"{ true ? "1" [|:|] false ? "2" : "3" };""",
"""var s2 = $"{ (true ? "1" : false ? "2" : "3") };""");
- }
[Fact]
- public async Task TestAddParenthesesNestedConditionalWithNestedInterpolatedString()
- {
- await TestInMethodAsync(
+ public Task TestAddParenthesesNestedConditionalWithNestedInterpolatedString()
+ => TestInMethodAsync(
"""
var s2 = $"{ (true ? "1" : false ? $"{ true ? "2" [|:|] "3"}" : "4") }"
""",
"""
var s2 = $"{ (true ? "1" : false ? $"{ (true ? "2" : "3")}" : "4") }"
""");
- }
[Fact]
- public async Task TestAddParenthesesMultipleInterpolatedSections1()
- {
- await TestInMethodAsync(
+ public Task TestAddParenthesesMultipleInterpolatedSections1()
+ => TestInMethodAsync(
"""var s3 = $"Text1 { true ? "Text2" [|:|] "Text3"} Text4 { (true ? "Text5" : "Text6")} Text7";""",
"""var s3 = $"Text1 { (true ? "Text2" : "Text3")} Text4 { (true ? "Text5" : "Text6")} Text7";""");
- }
[Fact]
- public async Task TestAddParenthesesMultipleInterpolatedSections2()
- {
- await TestInMethodAsync(
+ public Task TestAddParenthesesMultipleInterpolatedSections2()
+ => TestInMethodAsync(
"""var s3 = $"Text1 { (true ? "Text2" : "Text3")} Text4 { true ? "Text5" [|:|] "Text6"} Text7";""",
"""var s3 = $"Text1 { (true ? "Text2" : "Text3")} Text4 { (true ? "Text5" : "Text6")} Text7";""");
- }
[Fact]
- public async Task TestAddParenthesesMultipleInterpolatedSections3()
- {
- await TestInMethodAsync(
+ public Task TestAddParenthesesMultipleInterpolatedSections3()
+ => TestInMethodAsync(
"""var s3 = $"Text1 { true ? "Text2" [|:|] "Text3"} Text4 { true ? "Text5" : "Text6"} Text7";""",
"""var s3 = $"Text1 { (true ? "Text2" : "Text3")} Text4 { true ? "Text5" : "Text6"} Text7";""");
- }
[Fact]
- public async Task TestAddParenthesesWhileTyping1()
- {
- await TestInMethodAsync(
+ public Task TestAddParenthesesWhileTyping1()
+ => TestInMethodAsync(
"""
PreviousLineOfCode();
var s3 = $"Text1 { true ? "Text2" [|:|]
@@ -206,12 +173,10 @@ await TestInMethodAsync(
var s3 = $"Text1 { (true ? "Text2" :)
NextLineOfCode();
""");
- }
[Fact]
- public async Task TestAddParenthesesWhileTyping2()
- {
- await TestInMethodAsync(
+ public Task TestAddParenthesesWhileTyping2()
+ => TestInMethodAsync(
"""
PreviousLineOfCode();
var s3 = $"Text1 { true ? "Text2" [|:|] "
@@ -222,12 +187,10 @@ await TestInMethodAsync(
var s3 = $"Text1 { (true ? "Text2" : ")
NextLineOfCode();
""");
- }
[Fact]
- public async Task TestAddParenthesesWhileTyping3()
- {
- await TestInMethodAsync(
+ public Task TestAddParenthesesWhileTyping3()
+ => TestInMethodAsync(
"""
PreviousLineOfCode();
var s3 = $"Text1 { true ? "Text2" [|:|] "Text3
@@ -238,12 +201,10 @@ await TestInMethodAsync(
var s3 = $"Text1 { (true ? "Text2" : "Text3)
NextLineOfCode();
""");
- }
[Fact]
- public async Task TestAddParenthesesWhileTyping4()
- {
- await TestInMethodAsync(
+ public Task TestAddParenthesesWhileTyping4()
+ => TestInMethodAsync(
"""
PreviousLineOfCode();
var s3 = $"Text1 { true ? "Text2" [|:|] "Text3"
@@ -254,12 +215,10 @@ await TestInMethodAsync(
var s3 = $"Text1 { (true ? "Text2" : "Text3")
NextLineOfCode();
""");
- }
[Fact]
- public async Task TestAddParenthesesWhileTyping5()
- {
- await TestInMethodAsync(
+ public Task TestAddParenthesesWhileTyping5()
+ => TestInMethodAsync(
"""
PreviousLineOfCode();
var s3 = $"Text1 { true ? "Text2" [|:|] "Text3" }
@@ -270,12 +229,10 @@ await TestInMethodAsync(
var s3 = $"Text1 { (true ? "Text2" : "Text3") }
NextLineOfCode();
""");
- }
[Fact]
- public async Task TestAddParenthesesWithCS1026PresentBeforeFixIsApplied1()
- {
- await TestInMethodAsync(
+ public Task TestAddParenthesesWithCS1026PresentBeforeFixIsApplied1()
+ => TestInMethodAsync(
"""
(
var s3 = $"Text1 { true ? "Text2" [|:|] "Text3" }
@@ -286,12 +243,10 @@ await TestInMethodAsync(
var s3 = $"Text1 { (true ? "Text2" : "Text3") }
NextLineOfCode();
""");
- }
[Fact]
- public async Task TestAddParenthesesWithCS1026PresentBeforeFixIsApplied2()
- {
- await TestInMethodAsync(
+ public Task TestAddParenthesesWithCS1026PresentBeforeFixIsApplied2()
+ => TestInMethodAsync(
"""
PreviousLineOfCode();
var s3 = $"Text1 { true ? "Text2" [|:|] "Text3" }
@@ -302,12 +257,10 @@ await TestInMethodAsync(
var s3 = $"Text1 { (true ? "Text2" : "Text3") }
NextLineOfCode(
""");
- }
[Fact]
- public async Task TestAddParenthesesWithCS1026PresentBeforeFixIsApplied3()
- {
- await TestInMethodAsync(
+ public Task TestAddParenthesesWithCS1026PresentBeforeFixIsApplied3()
+ => TestInMethodAsync(
"""
PreviousLineOfCode();
var s3 = ($"Text1 { true ? "Text2" [|:|] "Text3" }
@@ -318,17 +271,14 @@ await TestInMethodAsync(
var s3 = ($"Text1 { (true ? "Text2" : "Text3") }
NextLineOfCode();
""");
- }
[Fact]
- public async Task TestAddParenthesesAddOpeningParenthesisOnly()
- {
- await TestInMethodAsync(
+ public Task TestAddParenthesesAddOpeningParenthesisOnly()
+ => TestInMethodAsync(
"""
var s3 = $"{ true ? 1 [|:|] 2 )}"
""",
"""
var s3 = $"{ (true ? 1 : 2 )}"
""");
- }
}
diff --git a/src/Analyzers/CSharp/Tests/ConflictMarkerResolution/ConflictMarkerResolutionTests.cs b/src/Analyzers/CSharp/Tests/ConflictMarkerResolution/ConflictMarkerResolutionTests.cs
index 1080fae583157..95eaa07c81bea 100644
--- a/src/Analyzers/CSharp/Tests/ConflictMarkerResolution/ConflictMarkerResolutionTests.cs
+++ b/src/Analyzers/CSharp/Tests/ConflictMarkerResolution/ConflictMarkerResolutionTests.cs
@@ -19,9 +19,10 @@ namespace Microsoft.CodeAnalysis.Editor.CSharp.UnitTests.ConflictMarkerResolutio
public sealed class ConflictMarkerResolutionTests
{
[Fact]
- public async Task TestTakeTop1()
- {
- var source = """
+ public Task TestTakeTop1()
+ => new VerifyCS.Test
+ {
+ TestCode = """
using System;
namespace N
@@ -46,8 +47,8 @@ static void Main2(string[] args)
}
{|CS8300:>>>>>>>|} This is theirs!
}
- """;
- var fixedSource = """
+ """,
+ FixedCode = """
using System;
namespace N
@@ -61,21 +62,16 @@ static void Main(string[] args)
}
}
}
- """;
-
- await new VerifyCS.Test
- {
- TestCode = source,
- FixedCode = fixedSource,
+ """,
NumberOfIncrementalIterations = 1,
CodeActionEquivalenceKey = AbstractResolveConflictMarkerCodeFixProvider.TakeTopEquivalenceKey,
}.RunAsync();
- }
[Fact]
- public async Task TestTakeBottom1()
- {
- var source = """
+ public Task TestTakeBottom1()
+ => new VerifyCS.Test
+ {
+ TestCode = """
using System;
namespace N
@@ -100,8 +96,8 @@ static void Main2(string[] args)
}
{|CS8300:>>>>>>>|} This is theirs!
}
- """;
- var fixedSource = """
+ """,
+ FixedCode = """
using System;
namespace N
@@ -115,22 +111,17 @@ static void Main2(string[] args)
}
}
}
- """;
-
- await new VerifyCS.Test
- {
- TestCode = source,
- FixedCode = fixedSource,
+ """,
NumberOfIncrementalIterations = 1,
CodeActionIndex = 1,
CodeActionEquivalenceKey = AbstractResolveConflictMarkerCodeFixProvider.TakeBottomEquivalenceKey,
}.RunAsync();
- }
[Fact]
- public async Task TestTakeBoth1()
- {
- var source = """
+ public Task TestTakeBoth1()
+ => new VerifyCS.Test
+ {
+ TestCode = """
using System;
namespace N
@@ -155,8 +146,8 @@ static void Main2(string[] args)
}
{|CS8300:>>>>>>>|} This is theirs!
}
- """;
- var fixedSource = """
+ """,
+ FixedCode = """
using System;
namespace N
@@ -178,22 +169,17 @@ static void Main2(string[] args)
}
}
}
- """;
-
- await new VerifyCS.Test
- {
- TestCode = source,
- FixedCode = fixedSource,
+ """,
NumberOfIncrementalIterations = 1,
CodeActionIndex = 2,
CodeActionEquivalenceKey = AbstractResolveConflictMarkerCodeFixProvider.TakeBothEquivalenceKey,
}.RunAsync();
- }
[Fact]
- public async Task TestEmptyTop_TakeTop()
- {
- var source = """
+ public Task TestEmptyTop_TakeTop()
+ => new VerifyCS.Test
+ {
+ TestCode = """
using System;
namespace N
@@ -210,28 +196,23 @@ static void Main2(string[] args)
}
{|CS8300:>>>>>>>|} This is theirs!
}
- """;
- var fixedSource = """
+ """,
+ FixedCode = """
using System;
namespace N
{
}
- """;
-
- await new VerifyCS.Test
- {
- TestCode = source,
- FixedCode = fixedSource,
+ """,
NumberOfIncrementalIterations = 1,
CodeActionEquivalenceKey = AbstractResolveConflictMarkerCodeFixProvider.TakeTopEquivalenceKey,
}.RunAsync();
- }
[Fact]
- public async Task TestEmptyTop_TakeBottom()
- {
- var source = """
+ public Task TestEmptyTop_TakeBottom()
+ => new VerifyCS.Test
+ {
+ TestCode = """
using System;
namespace N
@@ -248,8 +229,8 @@ static void Main2(string[] args)
}
{|CS8300:>>>>>>>|} This is theirs!
}
- """;
- var fixedSource = """
+ """,
+ FixedCode = """
using System;
namespace N
@@ -263,22 +244,17 @@ static void Main2(string[] args)
}
}
}
- """;
-
- await new VerifyCS.Test
- {
- TestCode = source,
- FixedCode = fixedSource,
+ """,
NumberOfIncrementalIterations = 1,
CodeActionIndex = 1,
CodeActionEquivalenceKey = AbstractResolveConflictMarkerCodeFixProvider.TakeBottomEquivalenceKey,
}.RunAsync();
- }
[Fact]
- public async Task TestEmptyBottom_TakeTop()
- {
- var source = """
+ public Task TestEmptyBottom_TakeTop()
+ => new VerifyCS.Test
+ {
+ TestCode = """
using System;
namespace N
@@ -295,8 +271,8 @@ static void Main(string[] args)
{|CS8300:=======|}
{|CS8300:>>>>>>>|} This is theirs!
}
- """;
- var fixedSource = """
+ """,
+ FixedCode = """
using System;
namespace N
@@ -310,21 +286,16 @@ static void Main(string[] args)
}
}
}
- """;
-
- await new VerifyCS.Test
- {
- TestCode = source,
- FixedCode = fixedSource,
+ """,
NumberOfIncrementalIterations = 1,
CodeActionEquivalenceKey = AbstractResolveConflictMarkerCodeFixProvider.TakeTopEquivalenceKey,
}.RunAsync();
- }
[Fact]
- public async Task TestEmptyBottom_TakeBottom()
- {
- var source = """
+ public Task TestEmptyBottom_TakeBottom()
+ => new VerifyCS.Test
+ {
+ TestCode = """
using System;
namespace N
@@ -341,29 +312,24 @@ static void Main(string[] args)
{|CS8300:=======|}
{|CS8300:>>>>>>>|} This is theirs!
}
- """;
- var fixedSource = """
+ """,
+ FixedCode = """
using System;
namespace N
{
}
- """;
-
- await new VerifyCS.Test
- {
- TestCode = source,
- FixedCode = fixedSource,
+ """,
NumberOfIncrementalIterations = 1,
CodeActionIndex = 1,
CodeActionEquivalenceKey = AbstractResolveConflictMarkerCodeFixProvider.TakeBottomEquivalenceKey,
}.RunAsync();
- }
[Fact]
- public async Task TestTakeTop_WhitespaceInSection()
- {
- var source = """
+ public Task TestTakeTop_WhitespaceInSection()
+ => new VerifyCS.Test
+ {
+ TestCode = """
using System;
namespace N
@@ -390,8 +356,8 @@ static void Main2(string[] args)
}
{|CS8300:>>>>>>>|} This is theirs!
}
- """;
- var fixedSource = """
+ """,
+ FixedCode = """
using System;
namespace N
@@ -407,21 +373,16 @@ static void Main(string[] args)
}
}
- """;
-
- await new VerifyCS.Test
- {
- TestCode = source,
- FixedCode = fixedSource,
+ """,
NumberOfIncrementalIterations = 1,
CodeActionEquivalenceKey = AbstractResolveConflictMarkerCodeFixProvider.TakeTopEquivalenceKey,
}.RunAsync();
- }
[Fact]
- public async Task TestTakeBottom1_WhitespaceInSection()
- {
- var source = """
+ public Task TestTakeBottom1_WhitespaceInSection()
+ => new VerifyCS.Test
+ {
+ TestCode = """
using System;
namespace N
@@ -448,8 +409,8 @@ static void Main2(string[] args)
{|CS8300:>>>>>>>|} This is theirs!
}
- """;
- var fixedSource = """
+ """,
+ FixedCode = """
using System;
namespace N
@@ -465,22 +426,17 @@ static void Main2(string[] args)
}
}
- """;
-
- await new VerifyCS.Test
- {
- TestCode = source,
- FixedCode = fixedSource,
+ """,
NumberOfIncrementalIterations = 1,
CodeActionIndex = 1,
CodeActionEquivalenceKey = AbstractResolveConflictMarkerCodeFixProvider.TakeBottomEquivalenceKey,
}.RunAsync();
- }
[Fact]
- public async Task TestTakeBoth_WhitespaceInSection()
- {
- var source = """
+ public Task TestTakeBoth_WhitespaceInSection()
+ => new VerifyCS.Test
+ {
+ TestCode = """
using System;
namespace N
@@ -509,8 +465,8 @@ static void Main2(string[] args)
{|CS8300:>>>>>>>|} This is theirs!
}
- """;
- var fixedSource = """
+ """,
+ FixedCode = """
using System;
namespace N
@@ -536,22 +492,17 @@ static void Main2(string[] args)
}
}
- """;
-
- await new VerifyCS.Test
- {
- TestCode = source,
- FixedCode = fixedSource,
+ """,
NumberOfIncrementalIterations = 1,
CodeActionIndex = 2,
CodeActionEquivalenceKey = AbstractResolveConflictMarkerCodeFixProvider.TakeBothEquivalenceKey,
}.RunAsync();
- }
[Fact, WorkItem("https://github.com/dotnet/roslyn/issues/23847")]
- public async Task TestTakeTop_TopCommentedOut()
- {
- var source = """
+ public Task TestTakeTop_TopCommentedOut()
+ => new VerifyCS.Test
+ {
+ TestCode = """
public class Class1
{
public void M()
@@ -567,8 +518,8 @@ public void M()
// */
}
}
- """;
- var fixedSource = """
+ """,
+ FixedCode = """
public class Class1
{
public void M()
@@ -579,21 +530,16 @@ public void M()
// */
}
}
- """;
-
- await new VerifyCS.Test
- {
- TestCode = source,
- FixedCode = fixedSource,
+ """,
NumberOfIncrementalIterations = 1,
CodeActionEquivalenceKey = AbstractResolveConflictMarkerCodeFixProvider.TakeTopEquivalenceKey,
}.RunAsync();
- }
[Fact, WorkItem("https://github.com/dotnet/roslyn/issues/23847")]
- public async Task TestTakeTop_SecondMiddleAndBottomCommentedOut()
- {
- var source = """
+ public Task TestTakeTop_SecondMiddleAndBottomCommentedOut()
+ => new VerifyCS.Test
+ {
+ TestCode = """
public class Class1
{
public void M()
@@ -608,8 +554,8 @@ public void M()
*/
}
}
- """;
- var fixedSource = """
+ """,
+ FixedCode = """
public class Class1
{
public void M()
@@ -619,21 +565,16 @@ public void M()
*/
}
}
- """;
-
- await new VerifyCS.Test
- {
- TestCode = source,
- FixedCode = fixedSource,
+ """,
NumberOfIncrementalIterations = 1,
CodeActionEquivalenceKey = AbstractResolveConflictMarkerCodeFixProvider.TakeTopEquivalenceKey,
}.RunAsync();
- }
[Fact, WorkItem("https://github.com/dotnet/roslyn/issues/23847")]
- public async Task TestTakeTop_TopInString()
- {
- var source = """
+ public Task TestTakeTop_TopInString()
+ => new VerifyCS.Test
+ {
+ TestCode = """
class X {
void x() {
var x = @"
@@ -644,29 +585,24 @@ void x() {
{|CS8300:>>>>>>>|} merge rev
}
}
- """;
- var fixedSource = """
+ """,
+ FixedCode = """
class X {
void x() {
var x = @"
a";
}
}
- """;
-
- await new VerifyCS.Test
- {
- TestCode = source,
- FixedCode = fixedSource,
+ """,
NumberOfIncrementalIterations = 1,
CodeActionEquivalenceKey = AbstractResolveConflictMarkerCodeFixProvider.TakeTopEquivalenceKey,
}.RunAsync();
- }
[Fact, WorkItem("https://github.com/dotnet/roslyn/issues/23847")]
- public async Task TestTakeBottom_TopInString()
- {
- var source = """
+ public Task TestTakeBottom_TopInString()
+ => new VerifyCS.Test
+ {
+ TestCode = """
class X {
void x() {
var x = @"
@@ -677,78 +613,61 @@ void x() {
{|CS8300:>>>>>>>|} merge rev
}
}
- """;
- var fixedSource = """
+ """,
+ FixedCode = """
class X {
void x() {
var x = @"
b";
}
}
- """;
-
- await new VerifyCS.Test
- {
- TestCode = source,
- FixedCode = fixedSource,
+ """,
NumberOfIncrementalIterations = 1,
CodeActionIndex = 1,
CodeActionEquivalenceKey = AbstractResolveConflictMarkerCodeFixProvider.TakeBottomEquivalenceKey,
}.RunAsync();
- }
[Fact, WorkItem("https://github.com/dotnet/roslyn/issues/23847")]
- public async Task TestMissingWithMiddleMarkerAtTopOfFile()
- {
- var source = """
+ public Task TestMissingWithMiddleMarkerAtTopOfFile()
+ => new VerifyCS.Test
+ {
+ TestCode = """
{|CS8300:=======|}
class X {
}
{|CS8300:>>>>>>>|} merge rev
- """;
-
- await new VerifyCS.Test
- {
- TestCode = source,
+ """,
}.RunAsync();
- }
[Fact, WorkItem("https://github.com/dotnet/roslyn/issues/23847")]
- public async Task TestMissingWithMiddleMarkerAtBottomOfFile()
- {
- var source = """
+ public Task TestMissingWithMiddleMarkerAtBottomOfFile()
+ => new VerifyCS.Test
+ {
+ TestCode = """
{|CS8300:<<<<<<<|} working copy
class X {
}
{|CS8300:=======|}
- """;
-
- await new VerifyCS.Test
- {
- TestCode = source,
+ """,
}.RunAsync();
- }
[Fact]
- public async Task TestMissingWithFirstMiddleMarkerAtBottomOfFile()
- {
- var source = """
+ public Task TestMissingWithFirstMiddleMarkerAtBottomOfFile()
+ => new VerifyCS.Test
+ {
+ TestCode = """
{|CS8300:<<<<<<<|} working copy
class X {
}
{|CS8300:||||||||}
- """;
-
- await new VerifyCS.Test
- {
- TestCode = source,
+ """,
}.RunAsync();
- }
[Fact, WorkItem("https://github.com/dotnet/roslyn/issues/21107")]
- public async Task TestFixAll1()
- {
- var source = """
+ public Task TestFixAll1()
+ => new VerifyCS.Test
+ {
+ TestCode = """
using System;
namespace N
@@ -773,8 +692,8 @@ class Program4
}
{|CS8300:>>>>>>>|} This is theirs!
}
- """;
- var fixedSource = """
+ """,
+ FixedCode = """
using System;
namespace N
@@ -787,21 +706,16 @@ class Program3
{
}
}
- """;
-
- await new VerifyCS.Test
- {
- TestCode = source,
- FixedCode = fixedSource,
+ """,
NumberOfIncrementalIterations = 2,
CodeActionEquivalenceKey = AbstractResolveConflictMarkerCodeFixProvider.TakeTopEquivalenceKey,
}.RunAsync();
- }
[Fact, WorkItem("https://github.com/dotnet/roslyn/issues/21107")]
- public async Task TestFixAll2()
- {
- var source = """
+ public Task TestFixAll2()
+ => new VerifyCS.Test
+ {
+ TestCode = """
using System;
namespace N
@@ -826,8 +740,8 @@ class Program4
}
{|CS8300:>>>>>>>|} This is theirs!
}
- """;
- var fixedSource = """
+ """,
+ FixedCode = """
using System;
namespace N
@@ -840,22 +754,17 @@ class Program4
{
}
}
- """;
-
- await new VerifyCS.Test
- {
- TestCode = source,
- FixedCode = fixedSource,
+ """,
NumberOfIncrementalIterations = 2,
CodeActionIndex = 1,
CodeActionEquivalenceKey = AbstractResolveConflictMarkerCodeFixProvider.TakeBottomEquivalenceKey,
}.RunAsync();
- }
[Fact, WorkItem("https://github.com/dotnet/roslyn/issues/21107")]
- public async Task TestFixAll3()
- {
- var source = """
+ public Task TestFixAll3()
+ => new VerifyCS.Test
+ {
+ TestCode = """
using System;
namespace N
@@ -880,8 +789,8 @@ class Program4
}
{|CS8300:>>>>>>>|} This is theirs!
}
- """;
- var fixedSource = """
+ """,
+ FixedCode = """
using System;
namespace N
@@ -900,22 +809,17 @@ class Program4
{
}
}
- """;
-
- await new VerifyCS.Test
- {
- TestCode = source,
- FixedCode = fixedSource,
+ """,
NumberOfIncrementalIterations = 2,
CodeActionIndex = 2,
CodeActionEquivalenceKey = AbstractResolveConflictMarkerCodeFixProvider.TakeBothEquivalenceKey,
}.RunAsync();
- }
[Fact]
- public async Task TestTakeTop_WithBaseline()
- {
- var source = """
+ public Task TestTakeTop_WithBaseline()
+ => new VerifyCS.Test
+ {
+ TestCode = """
using System;
namespace N
@@ -942,8 +846,8 @@ static void Main2(string[] args)
}
{|CS8300:>>>>>>>|} This is theirs!
}
- """;
- var fixedSource = """
+ """,
+ FixedCode = """
using System;
namespace N
@@ -957,21 +861,16 @@ static void Main(string[] args)
}
}
}
- """;
-
- await new VerifyCS.Test
- {
- TestCode = source,
- FixedCode = fixedSource,
+ """,
NumberOfIncrementalIterations = 1,
CodeActionEquivalenceKey = AbstractResolveConflictMarkerCodeFixProvider.TakeTopEquivalenceKey,
}.RunAsync();
- }
[Fact]
- public async Task TestTakeBottom1_WithBaseline()
- {
- var source = """
+ public Task TestTakeBottom1_WithBaseline()
+ => new VerifyCS.Test
+ {
+ TestCode = """
using System;
namespace N
@@ -998,8 +897,8 @@ static void Main2(string[] args)
}
{|CS8300:>>>>>>>|} This is theirs!
}
- """;
- var fixedSource = """
+ """,
+ FixedCode = """
using System;
namespace N
@@ -1013,22 +912,17 @@ static void Main2(string[] args)
}
}
}
- """;
-
- await new VerifyCS.Test
- {
- TestCode = source,
- FixedCode = fixedSource,
+ """,
NumberOfIncrementalIterations = 1,
CodeActionIndex = 1,
CodeActionEquivalenceKey = AbstractResolveConflictMarkerCodeFixProvider.TakeBottomEquivalenceKey,
}.RunAsync();
- }
[Fact]
- public async Task TestTakeBoth1_WithBaseline()
- {
- var source = """
+ public Task TestTakeBoth1_WithBaseline()
+ => new VerifyCS.Test
+ {
+ TestCode = """
using System;
namespace N
@@ -1055,8 +949,8 @@ static void Main2(string[] args)
}
{|CS8300:>>>>>>>|} This is theirs!
}
- """;
- var fixedSource = """
+ """,
+ FixedCode = """
using System;
namespace N
@@ -1078,22 +972,17 @@ static void Main2(string[] args)
}
}
}
- """;
-
- await new VerifyCS.Test
- {
- TestCode = source,
- FixedCode = fixedSource,
+ """,
NumberOfIncrementalIterations = 1,
CodeActionIndex = 2,
CodeActionEquivalenceKey = AbstractResolveConflictMarkerCodeFixProvider.TakeBothEquivalenceKey,
}.RunAsync();
- }
[Fact]
- public async Task TestEmptyTop_TakeTop_WithBaseline()
- {
- var source = """
+ public Task TestEmptyTop_TakeTop_WithBaseline()
+ => new VerifyCS.Test
+ {
+ TestCode = """
using System;
namespace N
@@ -1112,28 +1001,23 @@ static void Main2(string[] args)
}
{|CS8300:>>>>>>>|} This is theirs!
}
- """;
- var fixedSource = """
+ """,
+ FixedCode = """
using System;
namespace N
{
}
- """;
-
- await new VerifyCS.Test
- {
- TestCode = source,
- FixedCode = fixedSource,
+ """,
NumberOfIncrementalIterations = 1,
CodeActionEquivalenceKey = AbstractResolveConflictMarkerCodeFixProvider.TakeTopEquivalenceKey,
}.RunAsync();
- }
[Fact]
- public async Task TestEmptyTop_TakeBottom_WithBaseline()
- {
- var source = """
+ public Task TestEmptyTop_TakeBottom_WithBaseline()
+ => new VerifyCS.Test
+ {
+ TestCode = """
using System;
namespace N
@@ -1152,8 +1036,8 @@ static void Main2(string[] args)
}
{|CS8300:>>>>>>>|} This is theirs!
}
- """;
- var fixedSource = """
+ """,
+ FixedCode = """
using System;
namespace N
@@ -1167,22 +1051,17 @@ static void Main2(string[] args)
}
}
}
- """;
-
- await new VerifyCS.Test
- {
- TestCode = source,
- FixedCode = fixedSource,
+ """,
NumberOfIncrementalIterations = 1,
CodeActionIndex = 1,
CodeActionEquivalenceKey = AbstractResolveConflictMarkerCodeFixProvider.TakeBottomEquivalenceKey,
}.RunAsync();
- }
[Fact]
- public async Task TestEmptyBottom_TakeTop_WithBaseline()
- {
- var source = """
+ public Task TestEmptyBottom_TakeTop_WithBaseline()
+ => new VerifyCS.Test
+ {
+ TestCode = """
using System;
namespace N
@@ -1201,8 +1080,8 @@ class Removed { }
{|CS8300:=======|}
{|CS8300:>>>>>>>|} This is theirs!
}
- """;
- var fixedSource = """
+ """,
+ FixedCode = """
using System;
namespace N
@@ -1216,21 +1095,16 @@ static void Main(string[] args)
}
}
}
- """;
-
- await new VerifyCS.Test
- {
- TestCode = source,
- FixedCode = fixedSource,
+ """,
NumberOfIncrementalIterations = 1,
CodeActionEquivalenceKey = AbstractResolveConflictMarkerCodeFixProvider.TakeTopEquivalenceKey,
}.RunAsync();
- }
[Fact]
- public async Task TestEmptyBottom_TakeBottom_WithBaseline()
- {
- var source = """
+ public Task TestEmptyBottom_TakeBottom_WithBaseline()
+ => new VerifyCS.Test
+ {
+ TestCode = """
using System;
namespace N
@@ -1249,29 +1123,24 @@ class Removed { }
{|CS8300:=======|}
{|CS8300:>>>>>>>|} This is theirs!
}
- """;
- var fixedSource = """
+ """,
+ FixedCode = """
using System;
namespace N
{
}
- """;
-
- await new VerifyCS.Test
- {
- TestCode = source,
- FixedCode = fixedSource,
+ """,
NumberOfIncrementalIterations = 1,
CodeActionIndex = 1,
CodeActionEquivalenceKey = AbstractResolveConflictMarkerCodeFixProvider.TakeBottomEquivalenceKey,
}.RunAsync();
- }
[Fact]
- public async Task TestTakeTop_TopCommentedOut_WithBaseline()
- {
- var source = """
+ public Task TestTakeTop_TopCommentedOut_WithBaseline()
+ => new VerifyCS.Test
+ {
+ TestCode = """
public class Class1
{
public void M()
@@ -1290,8 +1159,8 @@ public void M()
// */
}
}
- """;
- var fixedSource = """
+ """,
+ FixedCode = """
public class Class1
{
public void M()
@@ -1302,21 +1171,16 @@ public void M()
// */
}
}
- """;
-
- await new VerifyCS.Test
- {
- TestCode = source,
- FixedCode = fixedSource,
+ """,
NumberOfIncrementalIterations = 1,
CodeActionEquivalenceKey = AbstractResolveConflictMarkerCodeFixProvider.TakeTopEquivalenceKey,
}.RunAsync();
- }
[Fact]
- public async Task TestTakeTop_FirstMiddleAndSecondMiddleAndBottomCommentedOut()
- {
- var source = """
+ public Task TestTakeTop_FirstMiddleAndSecondMiddleAndBottomCommentedOut()
+ => new VerifyCS.Test
+ {
+ TestCode = """
public class Class1
{
public void M()
@@ -1333,8 +1197,8 @@ public void M()
*/
}
}
- """;
- var fixedSource = """
+ """,
+ FixedCode = """
public class Class1
{
public void M()
@@ -1344,21 +1208,16 @@ public void M()
*/
}
}
- """;
-
- await new VerifyCS.Test
- {
- TestCode = source,
- FixedCode = fixedSource,
+ """,
NumberOfIncrementalIterations = 1,
CodeActionEquivalenceKey = AbstractResolveConflictMarkerCodeFixProvider.TakeTopEquivalenceKey,
}.RunAsync();
- }
[Fact]
- public async Task TestTakeTop_TopInString_WithBaseline()
- {
- var source = """
+ public Task TestTakeTop_TopInString_WithBaseline()
+ => new VerifyCS.Test
+ {
+ TestCode = """
class X {
void x() {
var x = @"
@@ -1371,29 +1230,24 @@ void x() {
{|CS8300:>>>>>>>|} merge rev
}
}
- """;
- var fixedSource = """
+ """,
+ FixedCode = """
class X {
void x() {
var x = @"
a";
}
}
- """;
-
- await new VerifyCS.Test
- {
- TestCode = source,
- FixedCode = fixedSource,
+ """,
NumberOfIncrementalIterations = 1,
CodeActionEquivalenceKey = AbstractResolveConflictMarkerCodeFixProvider.TakeTopEquivalenceKey,
}.RunAsync();
- }
[Fact]
- public async Task TestTakeBottom_TopInString_WithBaseline()
- {
- var source = """
+ public Task TestTakeBottom_TopInString_WithBaseline()
+ => new VerifyCS.Test
+ {
+ TestCode = """
class X {
void x() {
var x = @"
@@ -1406,47 +1260,38 @@ void x() {
{|CS8300:>>>>>>>|} merge rev
}
}
- """;
- var fixedSource = """
+ """,
+ FixedCode = """
class X {
void x() {
var x = @"
b";
}
}
- """;
-
- await new VerifyCS.Test
- {
- TestCode = source,
- FixedCode = fixedSource,
+ """,
NumberOfIncrementalIterations = 1,
CodeActionIndex = 1,
CodeActionEquivalenceKey = AbstractResolveConflictMarkerCodeFixProvider.TakeBottomEquivalenceKey,
}.RunAsync();
- }
[Fact]
- public async Task TestMissingWithFirstMiddleMarkerAtTopOfFile()
- {
- var source = """
+ public Task TestMissingWithFirstMiddleMarkerAtTopOfFile()
+ => new VerifyCS.Test
+ {
+ TestCode = """
{|CS8300:||||||||} baseline
{|CS8300:=======|}
class X {
}
{|CS8300:>>>>>>>|} merge rev
- """;
-
- await new VerifyCS.Test
- {
- TestCode = source,
+ """,
}.RunAsync();
- }
[Fact]
- public async Task TestFixAll1_WithBaseline()
- {
- var source = """
+ public Task TestFixAll1_WithBaseline()
+ => new VerifyCS.Test
+ {
+ TestCode = """
using System;
namespace N
@@ -1475,8 +1320,8 @@ class Program4
}
{|CS8300:>>>>>>>|} This is theirs!
}
- """;
- var fixedSource = """
+ """,
+ FixedCode = """
using System;
namespace N
@@ -1489,21 +1334,16 @@ class Program3
{
}
}
- """;
-
- await new VerifyCS.Test
- {
- TestCode = source,
- FixedCode = fixedSource,
+ """,
NumberOfIncrementalIterations = 2,
CodeActionEquivalenceKey = AbstractResolveConflictMarkerCodeFixProvider.TakeTopEquivalenceKey,
}.RunAsync();
- }
[Fact]
- public async Task TestFixAll2_WithBaseline()
- {
- var source = """
+ public Task TestFixAll2_WithBaseline()
+ => new VerifyCS.Test
+ {
+ TestCode = """
using System;
namespace N
@@ -1532,8 +1372,8 @@ class Program4
}
{|CS8300:>>>>>>>|} This is theirs!
}
- """;
- var fixedSource = """
+ """,
+ FixedCode = """
using System;
namespace N
@@ -1546,22 +1386,17 @@ class Program4
{
}
}
- """;
-
- await new VerifyCS.Test
- {
- TestCode = source,
- FixedCode = fixedSource,
+ """,
NumberOfIncrementalIterations = 2,
CodeActionIndex = 1,
CodeActionEquivalenceKey = AbstractResolveConflictMarkerCodeFixProvider.TakeBottomEquivalenceKey,
}.RunAsync();
- }
[Fact]
- public async Task TestFixAll3_WithBaseline()
- {
- var source = """
+ public Task TestFixAll3_WithBaseline()
+ => new VerifyCS.Test
+ {
+ TestCode = """
using System;
namespace N
@@ -1590,8 +1425,8 @@ class Program4
}
{|CS8300:>>>>>>>|} This is theirs!
}
- """;
- var fixedSource = """
+ """,
+ FixedCode = """
using System;
namespace N
@@ -1610,15 +1445,9 @@ class Program4
{
}
}
- """;
-
- await new VerifyCS.Test
- {
- TestCode = source,
- FixedCode = fixedSource,
+ """,
NumberOfIncrementalIterations = 2,
CodeActionIndex = 2,
CodeActionEquivalenceKey = AbstractResolveConflictMarkerCodeFixProvider.TakeBothEquivalenceKey,
}.RunAsync();
- }
}
diff --git a/src/Analyzers/CSharp/Tests/ConvertNamespace/ConvertToBlockScopedNamespaceAnalyzerTests.cs b/src/Analyzers/CSharp/Tests/ConvertNamespace/ConvertToBlockScopedNamespaceAnalyzerTests.cs
index d982794e9faaf..ba01489e1d6ea 100644
--- a/src/Analyzers/CSharp/Tests/ConvertNamespace/ConvertToBlockScopedNamespaceAnalyzerTests.cs
+++ b/src/Analyzers/CSharp/Tests/ConvertNamespace/ConvertToBlockScopedNamespaceAnalyzerTests.cs
@@ -31,9 +31,8 @@ public static IEnumerable