diff --git a/.editorconfig b/.editorconfig
index 4c92a8eef97a3..e95967a09e126 100644
--- a/.editorconfig
+++ b/.editorconfig
@@ -154,7 +154,7 @@ dotnet_diagnostic.IDE0055.severity = warning
# https://github.com/dotnet/roslyn-analyzers/issues/7436 - False positives from valid GetDeclaredSymbol calls
dotnet_diagnostic.RS1039.severity = none
-# These xUnit analyzers were disabled temporarily to let us move to the
+# These xUnit analyzers were disabled temporarily to let us move to the
# new xUnit and get past several component governance issues. The
# following issue tracks enabling them
#
diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS
index 34ac25cb4275e..e5433ff66698f 100644
--- a/.github/CODEOWNERS
+++ b/.github/CODEOWNERS
@@ -1,5 +1,6 @@
# Automatically request reviews when a pull request changes any owned files
-# More information: https://github.com/blog/2392-introducing-code-owners
+
+# More information: https://github.com/blog/2392-introducing-code-owners
*.yml @dotnet/roslyn-infrastructure
.github/ @dotnet/roslyn-infrastructure
@@ -15,15 +16,20 @@ scripts/ @dotnet/roslyn-infrastructure
src/Analyzers/ @dotnet/roslyn-ide
src/CodeStyle/ @dotnet/roslyn-ide
src/Compilers/ @dotnet/roslyn-compiler
+
# Both IDE and Compiler traits are in this file, so we don't want to ping each other for changes to just this file.
+
# Technically this means that if someone changes _just_ this file no reviewers will be tagged, but this isn't likely
+
# to happen.
+
src/Compilers/Test/Core/Traits/Traits.cs
src/EditorFeatures/ @dotnet/roslyn-ide
src/Features/ @dotnet/roslyn-ide
src/Interactive/ @dotnet/roslyn-interactive
src/LanguageServer/ @dotnet/roslyn-ide
src/NuGet/ @dotnet/roslyn-infrastructure
+src/RoslynAnalyzers/ @dotnet/roslyn-ide
src/Scripting/ @dotnet/roslyn-interactive
src/Setup/ @dotnet/roslyn-infrastructure
src/Tools/AnalyzerRunner @dotnet/roslyn-ide
diff --git a/.github/policies/resourceManagement.yml b/.github/policies/resourceManagement.yml
index 379cea47b9f11..b87713780d643 100644
--- a/.github/policies/resourceManagement.yml
+++ b/.github/policies/resourceManagement.yml
@@ -27,23 +27,6 @@ configuration:
eventResponderTasks:
- - description: Auto-approve auto-merge PRs
- triggerOnOwnActions: false
- if:
- - payloadType: Pull_Request
- - isPullRequest
- - labelAdded:
- label: auto-merge
- - or:
- - activitySenderHasPermission:
- permission: Admin
- - isActivitySender:
- user: dotnet-bot
- issueAuthor: False
- then:
- - approvePullRequest:
- comment: Auto-approval
-
- description: Auto-approve maestro PRs
triggerOnOwnActions: false
if:
@@ -80,7 +63,7 @@ configuration:
- addMilestone:
milestone: Next
- - description: Auto-approve OneLoc PRs
+ - description: Auto-approve/merge OneLoc PRs
triggerOnOwnActions: false
if:
- payloadType: Pull_Request
@@ -94,8 +77,29 @@ configuration:
- isAction:
action: Opened
then:
- - addLabel:
- label: auto-merge
+ - approvePullRequest:
+ comment: Auto-approve
+ - enableAutoMerge:
+ mergeMethod: merge
+
+ - description: Auto-approve/merge automated merge PRs
+ triggerOnOwnActions: false
+ if:
+ - payloadType: Pull_Request
+ - isPullRequest
+ - isActivitySender:
+ user: github-actions[bot]
+ issueAuthor: False
+ - titleContains:
+ pattern: "[automated] Merge branch"
+ isRegex: False
+ - isAction:
+ action: Opened
+ then:
+ - approvePullRequest:
+ comment: Auto-approve
+ - enableAutoMerge:
+ mergeMethod: merge
- description: Remove "Need More Info" on comment
triggerOnOwnActions: false
@@ -147,7 +151,7 @@ configuration:
issueAuthor: False
- not:
isActivitySender:
- user: github-actions
+ user: github-actions[bot]
issueAuthor: False
then:
- addLabel:
@@ -168,7 +172,7 @@ configuration:
issueAuthor: False
- not:
isActivitySender:
- user: github-actions
+ user: github-actions[bot]
issueAuthor: False
- or:
- isAction:
diff --git a/.github/workflows/main-merge.yml b/.github/workflows/main-merge.yml
index 21dfaefe4cd4c..8f90cffb5883b 100644
--- a/.github/workflows/main-merge.yml
+++ b/.github/workflows/main-merge.yml
@@ -1,18 +1,25 @@
-# Merges any changes from release/prerelease to main (e.g. servicing changes)
+# See https://github.com/dotnet/arcade/blob/e52018a/Documentation/Maestro/New-Inter-Branch-Merge-Approach.md
-name: Flow main to release/dev18.0
+name: Inter-branch merge
on:
schedule:
- # once a day at 13:00 UTC to cleanup old runs
- - cron: '0 13 * * *'
+ # Create a merge every 3 hours (works only for merges from `main`, others would need a `push` trigger).
+ - cron: '0 */3 * * *'
workflow_dispatch:
+ inputs:
+ configuration_file_branch:
+ description: 'Branch to use for configuration file'
+ required: true
+ default: 'main'
permissions:
contents: write
pull-requests: write
jobs:
- check-script:
+ merge:
+ if: github.repository == 'dotnet/roslyn'
uses: dotnet/arcade/.github/workflows/inter-branch-merge-base.yml@main
with:
- configuration_file_path: '.config/branch-merge.json'
\ No newline at end of file
+ configuration_file_path: 'eng/config/branch-merge.jsonc'
+ configuration_file_branch: ${{ inputs.configuration_file_branch || 'main' }}
diff --git a/Roslyn.sln b/Roslyn.sln
index e78ca2d58f566..704cad8e79ba5 100644
--- a/Roslyn.sln
+++ b/Roslyn.sln
@@ -352,8 +352,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ExternalAccess", "ExternalA
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.ExternalAccess.FSharp", "src\VisualStudio\ExternalAccess\FSharp\Microsoft.CodeAnalysis.ExternalAccess.FSharp.csproj", "{BD8CE303-5F04-45EC-8DCF-73C9164CD614}"
EndProject
-Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.ExternalAccess.Razor", "src\Tools\ExternalAccess\Razor\Microsoft.CodeAnalysis.ExternalAccess.Razor.csproj", "{2FB6C157-DF91-4B1C-9827-A4D1C08C73EC}"
-EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.VisualStudio.LanguageServices.CodeLens", "src\VisualStudio\CodeLens\Microsoft.VisualStudio.LanguageServices.CodeLens.csproj", "{5E6E9184-DEC5-4EC5-B0A4-77CFDC8CDEBE}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.LanguageServer.Protocol", "src\LanguageServer\Protocol\Microsoft.CodeAnalysis.LanguageServer.Protocol.csproj", "{686BF57E-A6FF-467B-AAB3-44DE916A9772}"
@@ -579,8 +577,158 @@ Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "Microsoft.CodeAnalysis.Cont
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.Contracts.Package", "src\Dependencies\Contracts\Microsoft.CodeAnalysis.Contracts.Package.csproj", "{A8D5CFFA-7F9E-C35B-4F19-D63F6EC1D5CA}"
EndProject
+Project("{9a19103f-16f7-4668-be54-9a1e7a4f7556}") = "Microsoft.CodeAnalysis.ExternalAccess.Razor", "src\Tools\ExternalAccess\Razor\EditorFeatures\Microsoft.CodeAnalysis.ExternalAccess.Razor.csproj", "{068CD9AA-CEC3-CA68-1BAB-2B1B9FD711D3}"
+EndProject
+Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "Microsoft.CodeAnalysis.ExternalAccess.Razor.Shared", "src\Tools\ExternalAccess\Razor\Shared\Microsoft.CodeAnalysis.ExternalAccess.Razor.Shared.shproj", "{4853A78A-4EC4-4D86-9F02-D0DDEAE85520}"
+EndProject
+Project("{9a19103f-16f7-4668-be54-9a1e7a4f7556}") = "Microsoft.CodeAnalysis.ExternalAccess.Razor.Features", "src\Tools\ExternalAccess\Razor\Features\Microsoft.CodeAnalysis.ExternalAccess.Razor.Features.csproj", "{D5A8E20C-E8D2-4A57-906A-263994D8731D}"
+EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.VisualStudio.LanguageServices.ExternalAccess.Copilot", "src\VisualStudio\ExternalAccess\Copilot\Microsoft.VisualStudio.LanguageServices.ExternalAccess.Copilot.csproj", "{9EB058F3-10C9-8F3F-AD9E-72CB362A0928}"
EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Analyzers", "Analyzers", "{02EA681E-C7D8-13C7-8484-4AC65E1B71E8}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Text.Analyzers", "src\RoslynAnalyzers\Text.Analyzers\Core\Text.Analyzers.csproj", "{8087BDE4-6707-05A5-5F84-DFE6628E8EC8}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Text.CSharp.Analyzers", "src\RoslynAnalyzers\Text.Analyzers\CSharp\Text.CSharp.Analyzers.csproj", "{B095320B-6854-EBEC-98DB-26E06D97183A}"
+EndProject
+Project("{778DAE3C-4631-46EA-AA77-85C1314464D9}") = "Text.VisualBasic.Analyzers", "src\RoslynAnalyzers\Text.Analyzers\VisualBasic\Text.VisualBasic.Analyzers.vbproj", "{451EC146-D85B-EA72-D064-0A75E9F52C7F}"
+EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Text.Analyzers", "Text.Analyzers", "{6FE0875A-E178-4766-BCC6-87D37F273102}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Text.Analyzers.Setup", "src\RoslynAnalyzers\Text.Analyzers\Setup\Text.Analyzers.Setup.csproj", "{2C3B6892-A23A-9A8F-431E-30869231F832}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Text.Analyzers.UnitTests", "src\RoslynAnalyzers\Text.Analyzers\UnitTests\Text.Analyzers.UnitTests.csproj", "{DE29FFE1-ABB8-3B45-0D58-768727CA8DB1}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.PublicApiAnalyzers", "src\RoslynAnalyzers\PublicApiAnalyzers\Core\Analyzers\Microsoft.CodeAnalysis.PublicApiAnalyzers.csproj", "{CE7C15D3-3B1B-84CF-1B4B-DA45533E9E83}"
+EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "PublicApiAnalyzers", "PublicApiAnalyzers", "{0AD92ED3-387B-4975-BA2E-68A76E727959}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.PublicApiAnalyzers.CodeFixes", "src\RoslynAnalyzers\PublicApiAnalyzers\Core\CodeFixes\Microsoft.CodeAnalysis.PublicApiAnalyzers.CodeFixes.csproj", "{6167C216-0C39-EBBA-2841-A8F864642DF1}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.PublicApiAnalyzers.Setup", "src\RoslynAnalyzers\PublicApiAnalyzers\Setup\Microsoft.CodeAnalysis.PublicApiAnalyzers.Setup.csproj", "{B3AADD0B-E103-A0F9-385F-1D18262B9C41}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.PublicApiAnalyzers.UnitTests", "src\RoslynAnalyzers\PublicApiAnalyzers\UnitTests\Microsoft.CodeAnalysis.PublicApiAnalyzers.UnitTests.csproj", "{E8D25897-E52E-47DE-B3B8-CE916C9B9B80}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.PerformanceSensitiveAnalyzers", "src\RoslynAnalyzers\PerformanceSensitiveAnalyzers\Core\Microsoft.CodeAnalysis.PerformanceSensitiveAnalyzers.csproj", "{A6844326-E313-F10A-7E99-89F54C73774C}"
+EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "PerformanceSensitiveAnalyzers", "PerformanceSensitiveAnalyzers", "{76B913A2-E33D-4C48-B206-8F14F0F94B06}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.CSharp.PerformanceSensitiveAnalyzers", "src\RoslynAnalyzers\PerformanceSensitiveAnalyzers\CSharp\Analyzers\Microsoft.CodeAnalysis.CSharp.PerformanceSensitiveAnalyzers.csproj", "{C7CAB909-965B-8674-56F1-98F3BE0BD87A}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.CSharp.PerformanceSensitiveAnalyzers.CodeFixes", "src\RoslynAnalyzers\PerformanceSensitiveAnalyzers\CSharp\CodeFixes\Microsoft.CodeAnalysis.CSharp.PerformanceSensitiveAnalyzers.CodeFixes.csproj", "{24CB433D-438B-04D0-29F7-9F29EC7DC3C6}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.PerformanceSensitiveAnalyzers.Setup", "src\RoslynAnalyzers\PerformanceSensitiveAnalyzers\Setup\Microsoft.CodeAnalysis.PerformanceSensitiveAnalyzers.Setup.csproj", "{9A98EE2B-BBBC-0D54-60D8-C36ABE80B340}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.PerformanceSensitiveAnalyzers.UnitTests", "src\RoslynAnalyzers\PerformanceSensitiveAnalyzers\UnitTests\Microsoft.CodeAnalysis.PerformanceSensitiveAnalyzers.UnitTests.csproj", "{C5591759-58B0-73D0-6EDC-4FFCBE819303}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Roslyn.Diagnostics.Analyzers", "src\RoslynAnalyzers\Roslyn.Diagnostics.Analyzers\Core\Roslyn.Diagnostics.Analyzers.csproj", "{AD0837BE-7912-AEDF-BDA9-2D2E4FE0CE0B}"
+EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Roslyn.Diagnostic.Analyzers", "Roslyn.Diagnostic.Analyzers", "{56053920-5095-430D-9C8B-AFB2C40407B4}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Roslyn.Diagnostics.CSharp.Analyzers", "src\RoslynAnalyzers\Roslyn.Diagnostics.Analyzers\CSharp\Roslyn.Diagnostics.CSharp.Analyzers.csproj", "{DEE77B19-9559-D47D-8EC4-C207152A9C2C}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Roslyn.Diagnostics.Analyzers.Setup", "src\RoslynAnalyzers\Roslyn.Diagnostics.Analyzers\Setup\Roslyn.Diagnostics.Analyzers.Setup.csproj", "{93256CB0-F5C1-CF7B-1D19-307E6E01191B}"
+EndProject
+Project("{778DAE3C-4631-46EA-AA77-85C1314464D9}") = "Roslyn.Diagnostics.VisualBasic.Analyzers", "src\RoslynAnalyzers\Roslyn.Diagnostics.Analyzers\VisualBasic\Roslyn.Diagnostics.VisualBasic.Analyzers.vbproj", "{A4A3650E-164F-9339-FA7B-606EFFD06268}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Roslyn.Diagnostics.Analyzers.UnitTests", "src\RoslynAnalyzers\Roslyn.Diagnostics.Analyzers\UnitTests\Roslyn.Diagnostics.Analyzers.UnitTests.csproj", "{B0453D30-45FE-B2BC-5404-4A9C985D7BFF}"
+EndProject
+Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "Analyzer.Utilities", "src\RoslynAnalyzers\Utilities\Compiler\Analyzer.Utilities.shproj", "{08735294-3E6B-4420-9916-E7B8C4EB874D}"
+EndProject
+Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "Analyzer.CSharp.Utilities", "src\RoslynAnalyzers\Utilities\Compiler.CSharp\Analyzer.CSharp.Utilities.shproj", "{BE5FE32C-DA73-4EC5-809E-E11B05ACA398}"
+EndProject
+Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "FlowAnalysis.Utilities", "src\RoslynAnalyzers\Utilities\FlowAnalysis\FlowAnalysis.Utilities.shproj", "{FCB56CBA-FA35-46A8-86B7-BAE5433197D9}"
+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}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Analyzer.Utilities.UnitTests", "src\RoslynAnalyzers\Utilities.UnitTests\Analyzer.Utilities.UnitTests.csproj", "{34A07D0C-32E6-E19B-337E-4E6CB722C606}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.ResxSourceGenerator", "src\RoslynAnalyzers\Microsoft.CodeAnalysis.ResxSourceGenerator\Microsoft.CodeAnalysis.ResxSourceGenerator\Microsoft.CodeAnalysis.ResxSourceGenerator.csproj", "{FCE0046B-03F8-78F6-86A1-8DDCEE8F4C9F}"
+EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ResxSourceGenerator", "ResxSourceGenerator", "{616B9154-1EE8-45AE-9299-EBD0D51446E5}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.ResxSourceGenerator.CSharp", "src\RoslynAnalyzers\Microsoft.CodeAnalysis.ResxSourceGenerator\Microsoft.CodeAnalysis.ResxSourceGenerator.CSharp\Microsoft.CodeAnalysis.ResxSourceGenerator.CSharp.csproj", "{5DB3749D-E83C-7093-75B9-B617D1FB72C0}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.ResxSourceGenerator.VisualBasic", "src\RoslynAnalyzers\Microsoft.CodeAnalysis.ResxSourceGenerator\Microsoft.CodeAnalysis.ResxSourceGenerator.VisualBasic\Microsoft.CodeAnalysis.ResxSourceGenerator.VisualBasic.csproj", "{DD05B30B-7C7D-CFF3-9C36-839D54A13B0C}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.ResxSourceGenerator.UnitTests", "src\RoslynAnalyzers\Microsoft.CodeAnalysis.ResxSourceGenerator\Microsoft.CodeAnalysis.ResxSourceGenerator.UnitTests\Microsoft.CodeAnalysis.ResxSourceGenerator.UnitTests.csproj", "{7BA618DE-0BC8-886C-36DD-989B9C05FA96}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.BannedApiAnalyzers", "src\RoslynAnalyzers\Microsoft.CodeAnalysis.BannedApiAnalyzers\Core\Microsoft.CodeAnalysis.BannedApiAnalyzers.csproj", "{8CE66034-25E2-8FF2-93A1-0BD3672AD86D}"
+EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "BannedApiAnalyzers", "BannedApiAnalyzers", "{FBF49D7B-F60C-41B5-8CEF-F1D41F84A387}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.CSharp.BannedApiAnalyzers", "src\RoslynAnalyzers\Microsoft.CodeAnalysis.BannedApiAnalyzers\CSharp\Microsoft.CodeAnalysis.CSharp.BannedApiAnalyzers.csproj", "{3C4BCE69-B353-B5AA-E824-209A6D627BA3}"
+EndProject
+Project("{778DAE3C-4631-46EA-AA77-85C1314464D9}") = "Microsoft.CodeAnalysis.VisualBasic.BannedApiAnalyzers", "src\RoslynAnalyzers\Microsoft.CodeAnalysis.BannedApiAnalyzers\VisualBasic\Microsoft.CodeAnalysis.VisualBasic.BannedApiAnalyzers.vbproj", "{E11BAB8D-39ED-AC6C-6D69-1E5B5F3FB286}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.BannedApiAnalyzers.Setup", "src\RoslynAnalyzers\Microsoft.CodeAnalysis.BannedApiAnalyzers\Setup\Microsoft.CodeAnalysis.BannedApiAnalyzers.Setup.csproj", "{D21CCB70-1EDB-8D13-F00F-CA280DE4C83E}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.BannedApiAnalyzers.UnitTests", "src\RoslynAnalyzers\Microsoft.CodeAnalysis.BannedApiAnalyzers\UnitTests\Microsoft.CodeAnalysis.BannedApiAnalyzers.UnitTests.csproj", "{801E5330-F8E0-CC40-CC9A-47FE42284871}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.AnalyzerUtilities", "src\RoslynAnalyzers\Microsoft.CodeAnalysis.AnalyzerUtilities\Microsoft.CodeAnalysis.AnalyzerUtilities.csproj", "{0A1267E9-52FF-B8DE-8522-802BE55F41DA}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GenerateAnalyzerNuspec", "src\RoslynAnalyzers\Tools\GenerateAnalyzerNuspec\GenerateAnalyzerNuspec.csproj", "{4312B163-9507-6A25-893B-C18ECBF896BF}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Metrics", "src\RoslynAnalyzers\Tools\Metrics\Metrics.csproj", "{7005DD7B-D3B6-1360-313B-975974AA6254}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RulesetToEditorconfigConverter", "src\RoslynAnalyzers\Tools\RulesetToEditorconfigConverter\Source\RulesetToEditorconfigConverter.csproj", "{10E2810B-AEDC-AE32-911A-750DF29322F0}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RulesetToEditorconfigConverter.UnitTests", "src\RoslynAnalyzers\Tools\RulesetToEditorconfigConverter\Tests\RulesetToEditorconfigConverter.UnitTests.csproj", "{6A85289A-97BE-DC01-FB92-7FD258FCDDB7}"
+EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tools", "Tools", "{482C1FC7-4FD6-4381-8078-73BEBFAF4349}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.Analyzers", "src\RoslynAnalyzers\Microsoft.CodeAnalysis.Analyzers\Core\Microsoft.CodeAnalysis.Analyzers.csproj", "{923E34BA-CA8A-971E-7FF7-51DD346394A1}"
+EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Microsoft.CodeAnalysis.Analyzers", "Microsoft.CodeAnalysis.Analyzers", "{A4E65246-D2F6-492F-8BD5-FE11DD89A19B}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.CSharp.Analyzers", "src\RoslynAnalyzers\Microsoft.CodeAnalysis.Analyzers\CSharp\Microsoft.CodeAnalysis.CSharp.Analyzers.csproj", "{CBC75308-5C91-83F0-5472-39C9445C8FFC}"
+EndProject
+Project("{778DAE3C-4631-46EA-AA77-85C1314464D9}") = "Microsoft.CodeAnalysis.VisualBasic.Analyzers", "src\RoslynAnalyzers\Microsoft.CodeAnalysis.Analyzers\VisualBasic\Microsoft.CodeAnalysis.VisualBasic.Analyzers.vbproj", "{BB08E86A-946F-C3BD-C607-989716B05D46}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.Analyzers.UnitTests", "src\RoslynAnalyzers\Microsoft.CodeAnalysis.Analyzers\UnitTests\Microsoft.CodeAnalysis.Analyzers.UnitTests.csproj", "{290ED315-ED26-F504-0583-848669298657}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.Analyzers.Setup", "src\RoslynAnalyzers\Microsoft.CodeAnalysis.Analyzers\Setup\Microsoft.CodeAnalysis.Analyzers.Setup.csproj", "{E234FD18-B133-4CF4-2AC1-7E219BF54242}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Metrics.Legacy", "src\RoslynAnalyzers\Tools\Metrics.Legacy\Metrics.Legacy.csproj", "{8252A386-069A-0D7D-EAB4-B2E77833B443}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Test.Utilities", "src\RoslynAnalyzers\Test.Utilities\Test.Utilities.csproj", "{3F65D29D-ED95-2D6F-B927-47C5CF070AA5}"
+EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "NuGet", "NuGet", "{7F040742-3C10-406A-A0FF-7FE621DEF671}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.Analyzers.Package", "src\RoslynAnalyzers\NuGet\Microsoft.CodeAnalysis.Analyzers\Microsoft.CodeAnalysis.Analyzers.Package.csproj", "{BEF66A04-80EF-F6FD-E969-F441F709ECDA}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.AnalyzerUtilities.Package", "src\RoslynAnalyzers\NuGet\Microsoft.CodeAnalysis.AnalyzerUtilities\Microsoft.CodeAnalysis.AnalyzerUtilities.Package.csproj", "{612E7B7D-8BE1-C279-2BD9-6191A97F2D03}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.BannedApiAnalyzers.Package", "src\RoslynAnalyzers\NuGet\Microsoft.CodeAnalysis.BannedApiAnalyzers\Microsoft.CodeAnalysis.BannedApiAnalyzers.Package.csproj", "{491BC06C-DEEC-0D65-985A-E192EC710BEF}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.Metrics.Package", "src\RoslynAnalyzers\NuGet\Microsoft.CodeAnalysis.Metrics\Microsoft.CodeAnalysis.Metrics.Package.csproj", "{E297099A-564C-A98A-BED5-547AD4799C81}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.ResxSourceGenerator.Package", "src\RoslynAnalyzers\NuGet\Microsoft.CodeAnalysis.ResxSourceGenerator\Microsoft.CodeAnalysis.ResxSourceGenerator.Package.csproj", "{839F00DC-B547-E6C3-AB0B-EFABD62C5C82}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.RulesetToEditorconfigConverter.Package", "src\RoslynAnalyzers\NuGet\Microsoft.CodeAnalysis.RulesetToEditorconfigConverter\Microsoft.CodeAnalysis.RulesetToEditorconfigConverter.Package.csproj", "{5F15CE31-9DF5-CD0F-F998-8BF358F11752}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.PerformanceSensitiveAnalyzers.Package", "src\RoslynAnalyzers\NuGet\PerformanceSensitiveAnalyzers\Microsoft.CodeAnalysis.PerformanceSensitiveAnalyzers.Package.csproj", "{B2C73083-9F69-D41B-572D-050157413338}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.CodeAnalysis.PublicApiAnalyzers.Package", "src\RoslynAnalyzers\NuGet\PublicApiAnalyzers\Microsoft.CodeAnalysis.PublicApiAnalyzers.Package.csproj", "{E27FA26C-6E34-F3F5-3005-67EF18A5CB8B}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Roslyn.Diagnostics.Analyzers.Package", "src\RoslynAnalyzers\NuGet\Roslyn.Diagnostics.Analyzers\Roslyn.Diagnostics.Analyzers.Package.csproj", "{295E850B-D94D-3328-75AB-62828B4B85BA}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Text.Analyzers.Package", "src\RoslynAnalyzers\NuGet\Text.Analyzers\Text.Analyzers.Package.csproj", "{A8C385EE-1798-2802-5533-9E9A12CC603E}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GenerateDocumentationAndConfigFiles", "src\RoslynAnalyzers\Tools\GenerateDocumentationAndConfigFiles\GenerateDocumentationAndConfigFiles.csproj", "{A1EBC0BC-D378-B9B7-7A57-EF7DF11E3ED7}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GenerateDocumentationAndConfigFilesForBrokenRuntime", "src\RoslynAnalyzers\Tools\GenerateDocumentationAndConfigFilesForBrokenRuntime\GenerateDocumentationAndConfigFilesForBrokenRuntime.csproj", "{29080628-23A6-1DCB-F15E-93F1D1682CC1}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestReferenceAssembly", "src\RoslynAnalyzers\TestReferenceAssembly\TestReferenceAssembly.csproj", "{31EB654C-B562-73B4-2456-78FA875515D2}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -1111,10 +1259,6 @@ Global
{BD8CE303-5F04-45EC-8DCF-73C9164CD614}.Debug|Any CPU.Build.0 = Debug|Any CPU
{BD8CE303-5F04-45EC-8DCF-73C9164CD614}.Release|Any CPU.ActiveCfg = Release|Any CPU
{BD8CE303-5F04-45EC-8DCF-73C9164CD614}.Release|Any CPU.Build.0 = Release|Any CPU
- {2FB6C157-DF91-4B1C-9827-A4D1C08C73EC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {2FB6C157-DF91-4B1C-9827-A4D1C08C73EC}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {2FB6C157-DF91-4B1C-9827-A4D1C08C73EC}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {2FB6C157-DF91-4B1C-9827-A4D1C08C73EC}.Release|Any CPU.Build.0 = Release|Any CPU
{5E6E9184-DEC5-4EC5-B0A4-77CFDC8CDEBE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5E6E9184-DEC5-4EC5-B0A4-77CFDC8CDEBE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5E6E9184-DEC5-4EC5-B0A4-77CFDC8CDEBE}.Release|Any CPU.ActiveCfg = Release|Any CPU
@@ -1427,6 +1571,230 @@ Global
{9EB058F3-10C9-8F3F-AD9E-72CB362A0928}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9EB058F3-10C9-8F3F-AD9E-72CB362A0928}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9EB058F3-10C9-8F3F-AD9E-72CB362A0928}.Release|Any CPU.Build.0 = Release|Any CPU
+ {8087BDE4-6707-05A5-5F84-DFE6628E8EC8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {8087BDE4-6707-05A5-5F84-DFE6628E8EC8}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {8087BDE4-6707-05A5-5F84-DFE6628E8EC8}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {8087BDE4-6707-05A5-5F84-DFE6628E8EC8}.Release|Any CPU.Build.0 = Release|Any CPU
+ {B095320B-6854-EBEC-98DB-26E06D97183A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {B095320B-6854-EBEC-98DB-26E06D97183A}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {B095320B-6854-EBEC-98DB-26E06D97183A}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {B095320B-6854-EBEC-98DB-26E06D97183A}.Release|Any CPU.Build.0 = Release|Any CPU
+ {451EC146-D85B-EA72-D064-0A75E9F52C7F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {451EC146-D85B-EA72-D064-0A75E9F52C7F}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {451EC146-D85B-EA72-D064-0A75E9F52C7F}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {451EC146-D85B-EA72-D064-0A75E9F52C7F}.Release|Any CPU.Build.0 = Release|Any CPU
+ {2C3B6892-A23A-9A8F-431E-30869231F832}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {2C3B6892-A23A-9A8F-431E-30869231F832}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {2C3B6892-A23A-9A8F-431E-30869231F832}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {2C3B6892-A23A-9A8F-431E-30869231F832}.Release|Any CPU.Build.0 = Release|Any CPU
+ {DE29FFE1-ABB8-3B45-0D58-768727CA8DB1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {DE29FFE1-ABB8-3B45-0D58-768727CA8DB1}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {DE29FFE1-ABB8-3B45-0D58-768727CA8DB1}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {DE29FFE1-ABB8-3B45-0D58-768727CA8DB1}.Release|Any CPU.Build.0 = Release|Any CPU
+ {CE7C15D3-3B1B-84CF-1B4B-DA45533E9E83}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {CE7C15D3-3B1B-84CF-1B4B-DA45533E9E83}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {CE7C15D3-3B1B-84CF-1B4B-DA45533E9E83}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {CE7C15D3-3B1B-84CF-1B4B-DA45533E9E83}.Release|Any CPU.Build.0 = Release|Any CPU
+ {6167C216-0C39-EBBA-2841-A8F864642DF1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {6167C216-0C39-EBBA-2841-A8F864642DF1}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {6167C216-0C39-EBBA-2841-A8F864642DF1}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {6167C216-0C39-EBBA-2841-A8F864642DF1}.Release|Any CPU.Build.0 = Release|Any CPU
+ {B3AADD0B-E103-A0F9-385F-1D18262B9C41}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {B3AADD0B-E103-A0F9-385F-1D18262B9C41}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {B3AADD0B-E103-A0F9-385F-1D18262B9C41}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {B3AADD0B-E103-A0F9-385F-1D18262B9C41}.Release|Any CPU.Build.0 = Release|Any CPU
+ {E8D25897-E52E-47DE-B3B8-CE916C9B9B80}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {E8D25897-E52E-47DE-B3B8-CE916C9B9B80}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {E8D25897-E52E-47DE-B3B8-CE916C9B9B80}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {E8D25897-E52E-47DE-B3B8-CE916C9B9B80}.Release|Any CPU.Build.0 = Release|Any CPU
+ {A6844326-E313-F10A-7E99-89F54C73774C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {A6844326-E313-F10A-7E99-89F54C73774C}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {A6844326-E313-F10A-7E99-89F54C73774C}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {A6844326-E313-F10A-7E99-89F54C73774C}.Release|Any CPU.Build.0 = Release|Any CPU
+ {C7CAB909-965B-8674-56F1-98F3BE0BD87A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {C7CAB909-965B-8674-56F1-98F3BE0BD87A}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {C7CAB909-965B-8674-56F1-98F3BE0BD87A}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {C7CAB909-965B-8674-56F1-98F3BE0BD87A}.Release|Any CPU.Build.0 = Release|Any CPU
+ {24CB433D-438B-04D0-29F7-9F29EC7DC3C6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {24CB433D-438B-04D0-29F7-9F29EC7DC3C6}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {24CB433D-438B-04D0-29F7-9F29EC7DC3C6}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {24CB433D-438B-04D0-29F7-9F29EC7DC3C6}.Release|Any CPU.Build.0 = Release|Any CPU
+ {9A98EE2B-BBBC-0D54-60D8-C36ABE80B340}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {9A98EE2B-BBBC-0D54-60D8-C36ABE80B340}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {9A98EE2B-BBBC-0D54-60D8-C36ABE80B340}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {9A98EE2B-BBBC-0D54-60D8-C36ABE80B340}.Release|Any CPU.Build.0 = Release|Any CPU
+ {C5591759-58B0-73D0-6EDC-4FFCBE819303}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {C5591759-58B0-73D0-6EDC-4FFCBE819303}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {C5591759-58B0-73D0-6EDC-4FFCBE819303}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {C5591759-58B0-73D0-6EDC-4FFCBE819303}.Release|Any CPU.Build.0 = Release|Any CPU
+ {AD0837BE-7912-AEDF-BDA9-2D2E4FE0CE0B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {AD0837BE-7912-AEDF-BDA9-2D2E4FE0CE0B}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {AD0837BE-7912-AEDF-BDA9-2D2E4FE0CE0B}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {AD0837BE-7912-AEDF-BDA9-2D2E4FE0CE0B}.Release|Any CPU.Build.0 = Release|Any CPU
+ {DEE77B19-9559-D47D-8EC4-C207152A9C2C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {DEE77B19-9559-D47D-8EC4-C207152A9C2C}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {DEE77B19-9559-D47D-8EC4-C207152A9C2C}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {DEE77B19-9559-D47D-8EC4-C207152A9C2C}.Release|Any CPU.Build.0 = Release|Any CPU
+ {93256CB0-F5C1-CF7B-1D19-307E6E01191B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {93256CB0-F5C1-CF7B-1D19-307E6E01191B}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {93256CB0-F5C1-CF7B-1D19-307E6E01191B}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {93256CB0-F5C1-CF7B-1D19-307E6E01191B}.Release|Any CPU.Build.0 = Release|Any CPU
+ {A4A3650E-164F-9339-FA7B-606EFFD06268}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {A4A3650E-164F-9339-FA7B-606EFFD06268}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {A4A3650E-164F-9339-FA7B-606EFFD06268}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {A4A3650E-164F-9339-FA7B-606EFFD06268}.Release|Any CPU.Build.0 = Release|Any CPU
+ {B0453D30-45FE-B2BC-5404-4A9C985D7BFF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {B0453D30-45FE-B2BC-5404-4A9C985D7BFF}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {B0453D30-45FE-B2BC-5404-4A9C985D7BFF}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {B0453D30-45FE-B2BC-5404-4A9C985D7BFF}.Release|Any CPU.Build.0 = Release|Any CPU
+ {34A07D0C-32E6-E19B-337E-4E6CB722C606}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {34A07D0C-32E6-E19B-337E-4E6CB722C606}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {34A07D0C-32E6-E19B-337E-4E6CB722C606}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {34A07D0C-32E6-E19B-337E-4E6CB722C606}.Release|Any CPU.Build.0 = Release|Any CPU
+ {FCE0046B-03F8-78F6-86A1-8DDCEE8F4C9F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {FCE0046B-03F8-78F6-86A1-8DDCEE8F4C9F}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {FCE0046B-03F8-78F6-86A1-8DDCEE8F4C9F}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {FCE0046B-03F8-78F6-86A1-8DDCEE8F4C9F}.Release|Any CPU.Build.0 = Release|Any CPU
+ {5DB3749D-E83C-7093-75B9-B617D1FB72C0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {5DB3749D-E83C-7093-75B9-B617D1FB72C0}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {5DB3749D-E83C-7093-75B9-B617D1FB72C0}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {5DB3749D-E83C-7093-75B9-B617D1FB72C0}.Release|Any CPU.Build.0 = Release|Any CPU
+ {DD05B30B-7C7D-CFF3-9C36-839D54A13B0C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {DD05B30B-7C7D-CFF3-9C36-839D54A13B0C}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {DD05B30B-7C7D-CFF3-9C36-839D54A13B0C}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {DD05B30B-7C7D-CFF3-9C36-839D54A13B0C}.Release|Any CPU.Build.0 = Release|Any CPU
+ {7BA618DE-0BC8-886C-36DD-989B9C05FA96}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {7BA618DE-0BC8-886C-36DD-989B9C05FA96}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {7BA618DE-0BC8-886C-36DD-989B9C05FA96}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {7BA618DE-0BC8-886C-36DD-989B9C05FA96}.Release|Any CPU.Build.0 = Release|Any CPU
+ {8CE66034-25E2-8FF2-93A1-0BD3672AD86D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {8CE66034-25E2-8FF2-93A1-0BD3672AD86D}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {8CE66034-25E2-8FF2-93A1-0BD3672AD86D}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {8CE66034-25E2-8FF2-93A1-0BD3672AD86D}.Release|Any CPU.Build.0 = Release|Any CPU
+ {3C4BCE69-B353-B5AA-E824-209A6D627BA3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {3C4BCE69-B353-B5AA-E824-209A6D627BA3}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {3C4BCE69-B353-B5AA-E824-209A6D627BA3}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {3C4BCE69-B353-B5AA-E824-209A6D627BA3}.Release|Any CPU.Build.0 = Release|Any CPU
+ {E11BAB8D-39ED-AC6C-6D69-1E5B5F3FB286}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {E11BAB8D-39ED-AC6C-6D69-1E5B5F3FB286}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {E11BAB8D-39ED-AC6C-6D69-1E5B5F3FB286}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {E11BAB8D-39ED-AC6C-6D69-1E5B5F3FB286}.Release|Any CPU.Build.0 = Release|Any CPU
+ {D21CCB70-1EDB-8D13-F00F-CA280DE4C83E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {D21CCB70-1EDB-8D13-F00F-CA280DE4C83E}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {D21CCB70-1EDB-8D13-F00F-CA280DE4C83E}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {D21CCB70-1EDB-8D13-F00F-CA280DE4C83E}.Release|Any CPU.Build.0 = Release|Any CPU
+ {801E5330-F8E0-CC40-CC9A-47FE42284871}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {801E5330-F8E0-CC40-CC9A-47FE42284871}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {801E5330-F8E0-CC40-CC9A-47FE42284871}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {801E5330-F8E0-CC40-CC9A-47FE42284871}.Release|Any CPU.Build.0 = Release|Any CPU
+ {0A1267E9-52FF-B8DE-8522-802BE55F41DA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {0A1267E9-52FF-B8DE-8522-802BE55F41DA}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {0A1267E9-52FF-B8DE-8522-802BE55F41DA}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {0A1267E9-52FF-B8DE-8522-802BE55F41DA}.Release|Any CPU.Build.0 = Release|Any CPU
+ {4312B163-9507-6A25-893B-C18ECBF896BF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {4312B163-9507-6A25-893B-C18ECBF896BF}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {4312B163-9507-6A25-893B-C18ECBF896BF}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {4312B163-9507-6A25-893B-C18ECBF896BF}.Release|Any CPU.Build.0 = Release|Any CPU
+ {7005DD7B-D3B6-1360-313B-975974AA6254}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {7005DD7B-D3B6-1360-313B-975974AA6254}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {7005DD7B-D3B6-1360-313B-975974AA6254}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {7005DD7B-D3B6-1360-313B-975974AA6254}.Release|Any CPU.Build.0 = Release|Any CPU
+ {10E2810B-AEDC-AE32-911A-750DF29322F0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {10E2810B-AEDC-AE32-911A-750DF29322F0}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {10E2810B-AEDC-AE32-911A-750DF29322F0}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {10E2810B-AEDC-AE32-911A-750DF29322F0}.Release|Any CPU.Build.0 = Release|Any CPU
+ {6A85289A-97BE-DC01-FB92-7FD258FCDDB7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {6A85289A-97BE-DC01-FB92-7FD258FCDDB7}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {6A85289A-97BE-DC01-FB92-7FD258FCDDB7}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {6A85289A-97BE-DC01-FB92-7FD258FCDDB7}.Release|Any CPU.Build.0 = Release|Any CPU
+ {923E34BA-CA8A-971E-7FF7-51DD346394A1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {923E34BA-CA8A-971E-7FF7-51DD346394A1}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {923E34BA-CA8A-971E-7FF7-51DD346394A1}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {923E34BA-CA8A-971E-7FF7-51DD346394A1}.Release|Any CPU.Build.0 = Release|Any CPU
+ {CBC75308-5C91-83F0-5472-39C9445C8FFC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {CBC75308-5C91-83F0-5472-39C9445C8FFC}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {CBC75308-5C91-83F0-5472-39C9445C8FFC}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {CBC75308-5C91-83F0-5472-39C9445C8FFC}.Release|Any CPU.Build.0 = Release|Any CPU
+ {BB08E86A-946F-C3BD-C607-989716B05D46}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {BB08E86A-946F-C3BD-C607-989716B05D46}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {BB08E86A-946F-C3BD-C607-989716B05D46}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {BB08E86A-946F-C3BD-C607-989716B05D46}.Release|Any CPU.Build.0 = Release|Any CPU
+ {290ED315-ED26-F504-0583-848669298657}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {290ED315-ED26-F504-0583-848669298657}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {290ED315-ED26-F504-0583-848669298657}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {290ED315-ED26-F504-0583-848669298657}.Release|Any CPU.Build.0 = Release|Any CPU
+ {E234FD18-B133-4CF4-2AC1-7E219BF54242}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {E234FD18-B133-4CF4-2AC1-7E219BF54242}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {E234FD18-B133-4CF4-2AC1-7E219BF54242}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {E234FD18-B133-4CF4-2AC1-7E219BF54242}.Release|Any CPU.Build.0 = Release|Any CPU
+ {8252A386-069A-0D7D-EAB4-B2E77833B443}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {8252A386-069A-0D7D-EAB4-B2E77833B443}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {8252A386-069A-0D7D-EAB4-B2E77833B443}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {8252A386-069A-0D7D-EAB4-B2E77833B443}.Release|Any CPU.Build.0 = Release|Any CPU
+ {3F65D29D-ED95-2D6F-B927-47C5CF070AA5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {3F65D29D-ED95-2D6F-B927-47C5CF070AA5}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {3F65D29D-ED95-2D6F-B927-47C5CF070AA5}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {3F65D29D-ED95-2D6F-B927-47C5CF070AA5}.Release|Any CPU.Build.0 = Release|Any CPU
+ {BEF66A04-80EF-F6FD-E969-F441F709ECDA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {BEF66A04-80EF-F6FD-E969-F441F709ECDA}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {BEF66A04-80EF-F6FD-E969-F441F709ECDA}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {BEF66A04-80EF-F6FD-E969-F441F709ECDA}.Release|Any CPU.Build.0 = Release|Any CPU
+ {612E7B7D-8BE1-C279-2BD9-6191A97F2D03}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {612E7B7D-8BE1-C279-2BD9-6191A97F2D03}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {612E7B7D-8BE1-C279-2BD9-6191A97F2D03}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {612E7B7D-8BE1-C279-2BD9-6191A97F2D03}.Release|Any CPU.Build.0 = Release|Any CPU
+ {491BC06C-DEEC-0D65-985A-E192EC710BEF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {491BC06C-DEEC-0D65-985A-E192EC710BEF}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {491BC06C-DEEC-0D65-985A-E192EC710BEF}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {491BC06C-DEEC-0D65-985A-E192EC710BEF}.Release|Any CPU.Build.0 = Release|Any CPU
+ {E297099A-564C-A98A-BED5-547AD4799C81}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {E297099A-564C-A98A-BED5-547AD4799C81}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {E297099A-564C-A98A-BED5-547AD4799C81}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {E297099A-564C-A98A-BED5-547AD4799C81}.Release|Any CPU.Build.0 = Release|Any CPU
+ {839F00DC-B547-E6C3-AB0B-EFABD62C5C82}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {839F00DC-B547-E6C3-AB0B-EFABD62C5C82}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {839F00DC-B547-E6C3-AB0B-EFABD62C5C82}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {839F00DC-B547-E6C3-AB0B-EFABD62C5C82}.Release|Any CPU.Build.0 = Release|Any CPU
+ {5F15CE31-9DF5-CD0F-F998-8BF358F11752}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {5F15CE31-9DF5-CD0F-F998-8BF358F11752}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {5F15CE31-9DF5-CD0F-F998-8BF358F11752}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {5F15CE31-9DF5-CD0F-F998-8BF358F11752}.Release|Any CPU.Build.0 = Release|Any CPU
+ {B2C73083-9F69-D41B-572D-050157413338}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {B2C73083-9F69-D41B-572D-050157413338}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {B2C73083-9F69-D41B-572D-050157413338}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {B2C73083-9F69-D41B-572D-050157413338}.Release|Any CPU.Build.0 = Release|Any CPU
+ {E27FA26C-6E34-F3F5-3005-67EF18A5CB8B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {E27FA26C-6E34-F3F5-3005-67EF18A5CB8B}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {E27FA26C-6E34-F3F5-3005-67EF18A5CB8B}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {E27FA26C-6E34-F3F5-3005-67EF18A5CB8B}.Release|Any CPU.Build.0 = Release|Any CPU
+ {295E850B-D94D-3328-75AB-62828B4B85BA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {295E850B-D94D-3328-75AB-62828B4B85BA}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {295E850B-D94D-3328-75AB-62828B4B85BA}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {295E850B-D94D-3328-75AB-62828B4B85BA}.Release|Any CPU.Build.0 = Release|Any CPU
+ {A8C385EE-1798-2802-5533-9E9A12CC603E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {A8C385EE-1798-2802-5533-9E9A12CC603E}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {A8C385EE-1798-2802-5533-9E9A12CC603E}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {A8C385EE-1798-2802-5533-9E9A12CC603E}.Release|Any CPU.Build.0 = Release|Any CPU
+ {A1EBC0BC-D378-B9B7-7A57-EF7DF11E3ED7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {A1EBC0BC-D378-B9B7-7A57-EF7DF11E3ED7}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {A1EBC0BC-D378-B9B7-7A57-EF7DF11E3ED7}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {A1EBC0BC-D378-B9B7-7A57-EF7DF11E3ED7}.Release|Any CPU.Build.0 = Release|Any CPU
+ {29080628-23A6-1DCB-F15E-93F1D1682CC1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {29080628-23A6-1DCB-F15E-93F1D1682CC1}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {29080628-23A6-1DCB-F15E-93F1D1682CC1}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {29080628-23A6-1DCB-F15E-93F1D1682CC1}.Release|Any CPU.Build.0 = Release|Any CPU
+ {31EB654C-B562-73B4-2456-78FA875515D2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {31EB654C-B562-73B4-2456-78FA875515D2}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {31EB654C-B562-73B4-2456-78FA875515D2}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {31EB654C-B562-73B4-2456-78FA875515D2}.Release|Any CPU.Build.0 = Release|Any CPU
+ {068CD9AA-CEC3-CA68-1BAB-2B1B9FD711D3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {068CD9AA-CEC3-CA68-1BAB-2B1B9FD711D3}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {068CD9AA-CEC3-CA68-1BAB-2B1B9FD711D3}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {068CD9AA-CEC3-CA68-1BAB-2B1B9FD711D3}.Release|Any CPU.Build.0 = Release|Any CPU
+ {D5A8E20C-E8D2-4A57-906A-263994D8731D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {D5A8E20C-E8D2-4A57-906A-263994D8731D}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {D5A8E20C-E8D2-4A57-906A-263994D8731D}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {D5A8E20C-E8D2-4A57-906A-263994D8731D}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -1586,7 +1954,6 @@ Global
{6362616E-6A47-48F0-9EE0-27800B306ACB} = {AFA5F921-0650-45E8-B293-51A0BB89DEA0}
{8977A560-45C2-4EC2-A849-97335B382C74} = {FD0FAF5F-1DED-485C-99FA-84B97F3A8EEC}
{BD8CE303-5F04-45EC-8DCF-73C9164CD614} = {5880FECB-91F1-4AB8-8726-75EAFA8A918E}
- {2FB6C157-DF91-4B1C-9827-A4D1C08C73EC} = {8977A560-45C2-4EC2-A849-97335B382C74}
{5E6E9184-DEC5-4EC5-B0A4-77CFDC8CDEBE} = {8DBA5174-B0AA-4561-82B1-A46607697753}
{686BF57E-A6FF-467B-AAB3-44DE916A9772} = {D449D505-CC6A-4E0B-AF1B-976E2D0AE67A}
{1DDE89EE-5819-441F-A060-2FF4A986F372} = {D449D505-CC6A-4E0B-AF1B-976E2D0AE67A}
@@ -1695,6 +2062,80 @@ Global
{BD974609-C68B-4BE6-9682-EB132462B50D} = {C2D1346B-9665-4150-B644-075CF1636BAA}
{A8D5CFFA-7F9E-C35B-4F19-D63F6EC1D5CA} = {C2D1346B-9665-4150-B644-075CF1636BAA}
{9EB058F3-10C9-8F3F-AD9E-72CB362A0928} = {5880FECB-91F1-4AB8-8726-75EAFA8A918E}
+ {8087BDE4-6707-05A5-5F84-DFE6628E8EC8} = {6FE0875A-E178-4766-BCC6-87D37F273102}
+ {B095320B-6854-EBEC-98DB-26E06D97183A} = {6FE0875A-E178-4766-BCC6-87D37F273102}
+ {451EC146-D85B-EA72-D064-0A75E9F52C7F} = {6FE0875A-E178-4766-BCC6-87D37F273102}
+ {6FE0875A-E178-4766-BCC6-87D37F273102} = {02EA681E-C7D8-13C7-8484-4AC65E1B71E8}
+ {2C3B6892-A23A-9A8F-431E-30869231F832} = {6FE0875A-E178-4766-BCC6-87D37F273102}
+ {DE29FFE1-ABB8-3B45-0D58-768727CA8DB1} = {6FE0875A-E178-4766-BCC6-87D37F273102}
+ {CE7C15D3-3B1B-84CF-1B4B-DA45533E9E83} = {0AD92ED3-387B-4975-BA2E-68A76E727959}
+ {0AD92ED3-387B-4975-BA2E-68A76E727959} = {02EA681E-C7D8-13C7-8484-4AC65E1B71E8}
+ {6167C216-0C39-EBBA-2841-A8F864642DF1} = {0AD92ED3-387B-4975-BA2E-68A76E727959}
+ {B3AADD0B-E103-A0F9-385F-1D18262B9C41} = {0AD92ED3-387B-4975-BA2E-68A76E727959}
+ {E8D25897-E52E-47DE-B3B8-CE916C9B9B80} = {0AD92ED3-387B-4975-BA2E-68A76E727959}
+ {A6844326-E313-F10A-7E99-89F54C73774C} = {76B913A2-E33D-4C48-B206-8F14F0F94B06}
+ {76B913A2-E33D-4C48-B206-8F14F0F94B06} = {02EA681E-C7D8-13C7-8484-4AC65E1B71E8}
+ {C7CAB909-965B-8674-56F1-98F3BE0BD87A} = {76B913A2-E33D-4C48-B206-8F14F0F94B06}
+ {24CB433D-438B-04D0-29F7-9F29EC7DC3C6} = {76B913A2-E33D-4C48-B206-8F14F0F94B06}
+ {9A98EE2B-BBBC-0D54-60D8-C36ABE80B340} = {76B913A2-E33D-4C48-B206-8F14F0F94B06}
+ {C5591759-58B0-73D0-6EDC-4FFCBE819303} = {76B913A2-E33D-4C48-B206-8F14F0F94B06}
+ {AD0837BE-7912-AEDF-BDA9-2D2E4FE0CE0B} = {56053920-5095-430D-9C8B-AFB2C40407B4}
+ {56053920-5095-430D-9C8B-AFB2C40407B4} = {02EA681E-C7D8-13C7-8484-4AC65E1B71E8}
+ {DEE77B19-9559-D47D-8EC4-C207152A9C2C} = {56053920-5095-430D-9C8B-AFB2C40407B4}
+ {93256CB0-F5C1-CF7B-1D19-307E6E01191B} = {56053920-5095-430D-9C8B-AFB2C40407B4}
+ {A4A3650E-164F-9339-FA7B-606EFFD06268} = {56053920-5095-430D-9C8B-AFB2C40407B4}
+ {B0453D30-45FE-B2BC-5404-4A9C985D7BFF} = {56053920-5095-430D-9C8B-AFB2C40407B4}
+ {08735294-3E6B-4420-9916-E7B8C4EB874D} = {0DDCFE67-7D4E-4709-9882-EC032A031789}
+ {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}
+ {FCE0046B-03F8-78F6-86A1-8DDCEE8F4C9F} = {616B9154-1EE8-45AE-9299-EBD0D51446E5}
+ {616B9154-1EE8-45AE-9299-EBD0D51446E5} = {02EA681E-C7D8-13C7-8484-4AC65E1B71E8}
+ {5DB3749D-E83C-7093-75B9-B617D1FB72C0} = {616B9154-1EE8-45AE-9299-EBD0D51446E5}
+ {DD05B30B-7C7D-CFF3-9C36-839D54A13B0C} = {616B9154-1EE8-45AE-9299-EBD0D51446E5}
+ {7BA618DE-0BC8-886C-36DD-989B9C05FA96} = {616B9154-1EE8-45AE-9299-EBD0D51446E5}
+ {8CE66034-25E2-8FF2-93A1-0BD3672AD86D} = {FBF49D7B-F60C-41B5-8CEF-F1D41F84A387}
+ {FBF49D7B-F60C-41B5-8CEF-F1D41F84A387} = {02EA681E-C7D8-13C7-8484-4AC65E1B71E8}
+ {3C4BCE69-B353-B5AA-E824-209A6D627BA3} = {FBF49D7B-F60C-41B5-8CEF-F1D41F84A387}
+ {E11BAB8D-39ED-AC6C-6D69-1E5B5F3FB286} = {FBF49D7B-F60C-41B5-8CEF-F1D41F84A387}
+ {D21CCB70-1EDB-8D13-F00F-CA280DE4C83E} = {FBF49D7B-F60C-41B5-8CEF-F1D41F84A387}
+ {801E5330-F8E0-CC40-CC9A-47FE42284871} = {FBF49D7B-F60C-41B5-8CEF-F1D41F84A387}
+ {0A1267E9-52FF-B8DE-8522-802BE55F41DA} = {0DDCFE67-7D4E-4709-9882-EC032A031789}
+ {4312B163-9507-6A25-893B-C18ECBF896BF} = {482C1FC7-4FD6-4381-8078-73BEBFAF4349}
+ {7005DD7B-D3B6-1360-313B-975974AA6254} = {482C1FC7-4FD6-4381-8078-73BEBFAF4349}
+ {10E2810B-AEDC-AE32-911A-750DF29322F0} = {482C1FC7-4FD6-4381-8078-73BEBFAF4349}
+ {6A85289A-97BE-DC01-FB92-7FD258FCDDB7} = {482C1FC7-4FD6-4381-8078-73BEBFAF4349}
+ {482C1FC7-4FD6-4381-8078-73BEBFAF4349} = {02EA681E-C7D8-13C7-8484-4AC65E1B71E8}
+ {923E34BA-CA8A-971E-7FF7-51DD346394A1} = {A4E65246-D2F6-492F-8BD5-FE11DD89A19B}
+ {A4E65246-D2F6-492F-8BD5-FE11DD89A19B} = {02EA681E-C7D8-13C7-8484-4AC65E1B71E8}
+ {CBC75308-5C91-83F0-5472-39C9445C8FFC} = {A4E65246-D2F6-492F-8BD5-FE11DD89A19B}
+ {BB08E86A-946F-C3BD-C607-989716B05D46} = {A4E65246-D2F6-492F-8BD5-FE11DD89A19B}
+ {290ED315-ED26-F504-0583-848669298657} = {A4E65246-D2F6-492F-8BD5-FE11DD89A19B}
+ {E234FD18-B133-4CF4-2AC1-7E219BF54242} = {A4E65246-D2F6-492F-8BD5-FE11DD89A19B}
+ {8252A386-069A-0D7D-EAB4-B2E77833B443} = {482C1FC7-4FD6-4381-8078-73BEBFAF4349}
+ {3F65D29D-ED95-2D6F-B927-47C5CF070AA5} = {0DDCFE67-7D4E-4709-9882-EC032A031789}
+ {7F040742-3C10-406A-A0FF-7FE621DEF671} = {02EA681E-C7D8-13C7-8484-4AC65E1B71E8}
+ {BEF66A04-80EF-F6FD-E969-F441F709ECDA} = {7F040742-3C10-406A-A0FF-7FE621DEF671}
+ {612E7B7D-8BE1-C279-2BD9-6191A97F2D03} = {7F040742-3C10-406A-A0FF-7FE621DEF671}
+ {491BC06C-DEEC-0D65-985A-E192EC710BEF} = {7F040742-3C10-406A-A0FF-7FE621DEF671}
+ {E297099A-564C-A98A-BED5-547AD4799C81} = {7F040742-3C10-406A-A0FF-7FE621DEF671}
+ {839F00DC-B547-E6C3-AB0B-EFABD62C5C82} = {7F040742-3C10-406A-A0FF-7FE621DEF671}
+ {5F15CE31-9DF5-CD0F-F998-8BF358F11752} = {7F040742-3C10-406A-A0FF-7FE621DEF671}
+ {B2C73083-9F69-D41B-572D-050157413338} = {7F040742-3C10-406A-A0FF-7FE621DEF671}
+ {E27FA26C-6E34-F3F5-3005-67EF18A5CB8B} = {7F040742-3C10-406A-A0FF-7FE621DEF671}
+ {295E850B-D94D-3328-75AB-62828B4B85BA} = {7F040742-3C10-406A-A0FF-7FE621DEF671}
+ {A8C385EE-1798-2802-5533-9E9A12CC603E} = {7F040742-3C10-406A-A0FF-7FE621DEF671}
+ {A1EBC0BC-D378-B9B7-7A57-EF7DF11E3ED7} = {482C1FC7-4FD6-4381-8078-73BEBFAF4349}
+ {29080628-23A6-1DCB-F15E-93F1D1682CC1} = {482C1FC7-4FD6-4381-8078-73BEBFAF4349}
+ {31EB654C-B562-73B4-2456-78FA875515D2} = {0DDCFE67-7D4E-4709-9882-EC032A031789}
+ {068CD9AA-CEC3-CA68-1BAB-2B1B9FD711D3} = {8977A560-45C2-4EC2-A849-97335B382C74}
+ {4853A78A-4EC4-4D86-9F02-D0DDEAE85520} = {8977A560-45C2-4EC2-A849-97335B382C74}
+ {D5A8E20C-E8D2-4A57-906A-263994D8731D} = {8977A560-45C2-4EC2-A849-97335B382C74}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {604E6B91-7BC0-4126-AE07-D4D2FEFC3D29}
@@ -1703,7 +2144,11 @@ Global
src\Analyzers\VisualBasic\CodeFixes\VisualBasicCodeFixes.projitems*{0141285d-8f6c-42c7-baf3-3c0ccd61c716}*SharedItemsImports = 5
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\VisualBasic\VisualBasicWorkspaceExtensions.projitems*{0141285d-8f6c-42c7-baf3-3c0ccd61c716}*SharedItemsImports = 5
src\Compilers\CSharp\csc\CscCommandLine.projitems*{0161e25c-918a-4dc8-9648-30fdcc8e31e9}*SharedItemsImports = 5
+ src\Tools\ExternalAccess\Razor\Shared\Microsoft.CodeAnalysis.ExternalAccess.Razor.Shared.projitems*{068cd9aa-cec3-ca68-1bab-2b1b9fd711d3}*SharedItemsImports = 5
src\Dependencies\Contracts\Microsoft.CodeAnalysis.Contracts.projitems*{0c2e1633-1462-4712-88f4-a0c945bad3a8}*SharedItemsImports = 5
+ src\RoslynAnalyzers\Utilities\Compiler\Analyzer.Utilities.projitems*{08735294-3e6b-4420-9916-e7b8c4eb874d}*SharedItemsImports = 13
+ 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\Analyzers\Core\CodeFixes\CodeFixes.projitems*{1b6c4a1a-413b-41fb-9f85-5c09118e541b}*SharedItemsImports = 13
src\Compilers\Core\AnalyzerDriver\AnalyzerDriver.projitems*{1ee8cad3-55f9-4d91-96b2-084641da9a6c}*SharedItemsImports = 5
src\Dependencies\CodeAnalysis.Debugging\Microsoft.CodeAnalysis.Debugging.projitems*{1ee8cad3-55f9-4d91-96b2-084641da9a6c}*SharedItemsImports = 5
@@ -1712,6 +2157,7 @@ Global
src\Dependencies\PooledObjects\Microsoft.CodeAnalysis.PooledObjects.projitems*{1ee8cad3-55f9-4d91-96b2-084641da9a6c}*SharedItemsImports = 5
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\CSharpCompilerExtensions.projitems*{21b239d0-d144-430f-a394-c066d58ee267}*SharedItemsImports = 5
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\CSharpWorkspaceExtensions.projitems*{21b239d0-d144-430f-a394-c066d58ee267}*SharedItemsImports = 5
+ src\RoslynAnalyzers\Utilities\Workspaces\Workspaces.Utilities.projitems*{24cb433d-438b-04d0-29f7-9f29ec7dc3c6}*SharedItemsImports = 5
src\Compilers\VisualBasic\BasicAnalyzerDriver\BasicAnalyzerDriver.projitems*{2523d0e6-df32-4a3e-8ae0-a19bffae2ef6}*SharedItemsImports = 5
src\Analyzers\VisualBasic\Analyzers\VisualBasicAnalyzers.projitems*{2531a8c4-97dd-47bc-a79c-b7846051e137}*SharedItemsImports = 5
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\VisualBasic\VisualBasicCompilerExtensions.projitems*{2531a8c4-97dd-47bc-a79c-b7846051e137}*SharedItemsImports = 5
@@ -1725,14 +2171,19 @@ Global
src\Dependencies\Threading\Microsoft.CodeAnalysis.Threading.projitems*{275812ee-dedb-4232-9439-91c9757d2ae4}*SharedItemsImports = 5
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\CompilerExtensions.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\Contracts\Microsoft.CodeAnalysis.Contracts.projitems*{41ed1bfa-fdad-4fe4-8118-db23fb49b0b0}*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\Workspace\CSharp\CSharpWorkspaceExtensions.projitems*{438db8af-f3f0-4ed9-80b5-13fddd5b8787}*SharedItemsImports = 13
+ src\Tools\ExternalAccess\Razor\Shared\Microsoft.CodeAnalysis.ExternalAccess.Razor.Shared.projitems*{4853a78a-4ec4-4d86-9f02-d0ddeae85520}*SharedItemsImports = 13
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
@@ -1747,34 +2198,51 @@ Global
src\Analyzers\Core\CodeFixes\CodeFixes.projitems*{5ff1e493-69cc-4d0b-83f2-039f469a04e1}*SharedItemsImports = 5
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\WorkspaceExtensions.projitems*{5ff1e493-69cc-4d0b-83f2-039f469a04e1}*SharedItemsImports = 5
src\ExpressionEvaluator\CSharp\Source\ResultProvider\CSharpResultProvider.projitems*{60db272a-21c9-4e8d-9803-ff4e132392c8}*SharedItemsImports = 5
+ src\RoslynAnalyzers\Utilities\Workspaces\Workspaces.Utilities.projitems*{6167c216-0c39-ebba-2841-a8f864642df1}*SharedItemsImports = 5
src\LanguageServer\Microsoft.CommonLanguageServerProtocol.Framework\Microsoft.CommonLanguageServerProtocol.Framework.Shared.projitems*{64eaded3-4b5d-4431-bbe5-a4aba1c38c00}*SharedItemsImports = 13
+ src\RoslynAnalyzers\Utilities\Refactoring\Refactoring.Utilities.projitems*{68528c1c-b163-49a6-a19d-24e10f500f90}*SharedItemsImports = 13
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\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\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\Dependencies\Contracts\Microsoft.CodeAnalysis.Contracts.projitems*{7ad4fe65-9a30-41a6-8004-aa8f89bcb7f3}*SharedItemsImports = 5
src\Analyzers\VisualBasic\Tests\VisualBasicAnalyzers.UnitTests.projitems*{7b7f4153-ae93-4908-b8f0-430871589f83}*SharedItemsImports = 13
+ 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\Compilers\VisualBasic\vbc\VbcCommandLine.projitems*{810b02ad-2ea5-4422-88ac-b71b8ab0df0b}*SharedItemsImports = 13
+ 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\RoslynAnalyzers\Utilities\Compiler\Analyzer.Utilities.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\Threading\Microsoft.CodeAnalysis.Threading.projitems*{8e2a252e-a140-45a6-a81a-2652996ea589}*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\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
src\Compilers\VisualBasic\vbc\VbcCommandLine.projitems*{975cd834-45f4-4ea0-a395-cb60dbd0e214}*SharedItemsImports = 5
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\Core\WorkspaceExtensions.projitems*{99f594b1-3916-471d-a761-a6731fc50e9a}*SharedItemsImports = 13
+ src\RoslynAnalyzers\Utilities\Workspaces\Workspaces.Utilities.projitems*{9c4bc501-c0a6-4130-ba68-ef5fb0c640b0}*SharedItemsImports = 13
src\Analyzers\VisualBasic\CodeFixes\VisualBasicCodeFixes.projitems*{9f9ccc78-7487-4127-9d46-db23e501f001}*SharedItemsImports = 13
src\Analyzers\CSharp\CodeFixes\CSharpCodeFixes.projitems*{a07abcf5-bc43-4ee9-8fd8-b2d77fd54d73}*SharedItemsImports = 5
src\Workspaces\SharedUtilitiesAndExtensions\Workspace\CSharp\CSharpWorkspaceExtensions.projitems*{a07abcf5-bc43-4ee9-8fd8-b2d77fd54d73}*SharedItemsImports = 5
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\RoslynAnalyzers\Utilities\Compiler\Analyzer.Utilities.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\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\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
@@ -1783,16 +2251,20 @@ Global
src\ExpressionEvaluator\Core\Source\ResultProvider\ResultProvider.projitems*{bb3ca047-5d00-48d4-b7d3-233c1265c065}*SharedItemsImports = 13
src\Dependencies\Contracts\Microsoft.CodeAnalysis.Contracts.projitems*{bd9539eb-aa5e-4e67-ac7f-97d7cbc4d0c9}*SharedItemsImports = 5
src\Dependencies\Contracts\Microsoft.CodeAnalysis.Contracts.projitems*{bd974609-c68b-4be6-9682-eb132462b50d}*SharedItemsImports = 13
+ 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\RoslynAnalyzers\Utilities\Compiler\Analyzer.Utilities.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
+ src\Tools\ExternalAccess\Razor\Shared\Microsoft.CodeAnalysis.ExternalAccess.Razor.Shared.projitems*{d5a8e20c-e8d2-4a57-906a-263994d8731d}*SharedItemsImports = 5
src\Dependencies\CodeAnalysis.Debugging\Microsoft.CodeAnalysis.Debugging.projitems*{d73adf7d-2c1c-42ae-b2ab-edc9497e4b71}*SharedItemsImports = 13
src\Compilers\Server\VBCSCompiler\VBCSCompilerCommandLine.projitems*{d8ef0777-9d65-4849-a7d6-ac81e58e2317}*SharedItemsImports = 13
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\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
@@ -1808,5 +2280,7 @@ Global
src\Dependencies\Contracts\Microsoft.CodeAnalysis.Contracts.projitems*{fa0e905d-ec46-466d-b7b2-3b5557f9428c}*SharedItemsImports = 5
src\ExpressionEvaluator\Core\Source\ResultProvider\ResultProvider.projitems*{fa0e905d-ec46-466d-b7b2-3b5557f9428c}*SharedItemsImports = 5
src\Dependencies\Contracts\Microsoft.CodeAnalysis.Contracts.projitems*{fce88bbd-9bbd-4871-b9b0-de176d73a6b0}*SharedItemsImports = 5
+ src\RoslynAnalyzers\Utilities\FlowAnalysis\FlowAnalysis.Utilities.projitems*{fcb56cba-fa35-46a8-86b7-bae5433197d9}*SharedItemsImports = 13
+ src\RoslynAnalyzers\Utilities\Compiler\Analyzer.Utilities.projitems*{fce0046b-03f8-78f6-86a1-8ddcee8f4c9f}*SharedItemsImports = 5
EndGlobalSection
EndGlobal
diff --git a/azure-pipelines-integration.yml b/azure-pipelines-integration.yml
index 241c0fec59dfc..afddf6a20c094 100644
--- a/azure-pipelines-integration.yml
+++ b/azure-pipelines-integration.yml
@@ -10,9 +10,9 @@ trigger:
exclude:
# Since the version of VS on the integration VM images are a moving target,
# we are unable to reliably run integration tests on servicing branches.
- - release/dev17.0-vs-deps
- - release/dev17.2
- - release/dev17.3
+ - release/dev17.8
+ - release/dev17.10
+ - release/dev17.12
# Branches that trigger builds on PR
pr:
@@ -26,19 +26,25 @@ pr:
exclude:
# Since the version of VS on the integration VM images are a moving target,
# we are unable to reliably run integration tests on servicing branches.
- - release/dev17.0-vs-deps
- - release/dev17.2
- - release/dev17.3
+ - release/dev17.8
+ - release/dev17.10
+ - release/dev17.12
paths:
exclude:
- docs/*
- eng/config/OptProf.json
- eng/config/PublishData.json
+ - eng/setup-pr-validation.ps1
- .vscode/*
- .github/*
- .devcontainer/*
- .git-blame-ignore-revs
- .vsconfig
+ - azure-pipelines-compliance.yml
+ - azure-pipelines-integration-dartlab.yml
+ - azure-pipelines-integration-scouting.yml
+ - azure-pipelines-official.yml
+ - azure-pipelines-pr-validation.yml
- CODE-OF-CONDUCT.md
- CONTRIBUTING.md
- README.md
diff --git a/azure-pipelines-official.yml b/azure-pipelines-official.yml
index 9010a8640f791..f5b090c67753f 100644
--- a/azure-pipelines-official.yml
+++ b/azure-pipelines-official.yml
@@ -7,6 +7,7 @@ trigger:
- release/dev17.*
- release/dev18.*
- features/lsp_tools_host
+ - features/runtime-async
exclude:
- release/dev17.0
pr: none
@@ -163,7 +164,7 @@ extends:
- output: pipelineArtifact
displayName: 'Publish Ngen Logs'
- condition: succeeded()
+ condition: and(succeeded(), ${{ not(parameters.SkipApplyOptimizationData) }})
targetPath: '$(Build.SourcesDirectory)\artifacts\log\$(BuildConfiguration)\ngen'
artifactName: 'NGen Logs'
publishLocation: Container
@@ -304,7 +305,7 @@ extends:
-configuration $(BuildConfiguration)
-officialBuildId $(Build.BuildNumber)
-officialSkipTests $(SkipTests)
- -officialSkipApplyOptimizationData $(SkipApplyOptimizationData)
+ -officialSkipApplyOptimizationData ${{ parameters.SkipApplyOptimizationData }}
-officialSourceBranchName $(SourceBranchName)
-officialIbcDrop $(IbcDrop)
-officialVisualStudioDropAccessToken $(_DevDivDropAccessToken)
diff --git a/azure-pipelines-pr-validation.yml b/azure-pipelines-pr-validation.yml
index d779e1a90d00a..39295f2ece19a 100644
--- a/azure-pipelines-pr-validation.yml
+++ b/azure-pipelines-pr-validation.yml
@@ -13,6 +13,9 @@ parameters:
type: number
- name: CommitSHA
type: string
+- name: EnforceLatestCommit
+ type: boolean
+ default: true
- name: VisualStudioBranchName
type: string
default: default
@@ -95,7 +98,7 @@ extends:
- output: pipelineArtifact
displayName: 'Publish Ngen Logs'
- condition: succeeded()
+ condition: and(succeeded(), ${{ not(parameters.SkipApplyOptimizationData) }})
targetPath: '$(Build.SourcesDirectory)\artifacts\log\$(BuildConfiguration)\ngen'
artifactName: 'NGen Logs'
publishLocation: Container
@@ -195,7 +198,7 @@ extends:
displayName: Setup branch for insertion validation
inputs:
filePath: 'eng\setup-pr-validation.ps1'
- arguments: '-sourceBranchName $(SourceBranchName) -prNumber ${{ parameters.PRNumber }} -commitSHA ${{ parameters.CommitSHA }}'
+ arguments: "-sourceBranchName $(SourceBranchName) -prNumber ${{ parameters.PRNumber }} -commitSHA ${{ parameters.CommitSHA }} -enforceLatestCommit ${{ iif(parameters.EnforceLatestCommit, '1', '0') }}"
condition: succeeded()
- powershell: Write-Host "##vso[task.setvariable variable=VisualStudio.DropName]Products/$(System.TeamProject)/$(Build.Repository.Name)/$(SourceBranchName)/$(OriginalBuildNumber)"
@@ -239,7 +242,7 @@ extends:
-configuration $(BuildConfiguration)
-officialBuildId $(OriginalBuildNumber)
-officialSkipTests $(SkipTests)
- -officialSkipApplyOptimizationData $(SkipApplyOptimizationData)
+ -officialSkipApplyOptimizationData ${{ parameters.SkipApplyOptimizationData }}
-officialSourceBranchName $(SourceBranchName)
-officialIbcDrop $(IbcDrop)
-officialVisualStudioDropAccessToken $(_DevDivDropAccessToken)
diff --git a/azure-pipelines-richnav.yml b/azure-pipelines-richnav.yml
deleted file mode 100644
index 26079c6b43d89..0000000000000
--- a/azure-pipelines-richnav.yml
+++ /dev/null
@@ -1,71 +0,0 @@
-# Branches that trigger a build on commit
-trigger:
-- main
-- main-vs-deps
-- release/*
-- features/*
-- demos/*
-
-# Branches that trigger builds on PR
-pr: none
-# Temporarily disabling richnav job on PRs
-# pr:
-# - main
-# - main-vs-deps
-# - release/*
-# - features/*
-# - demos/*
-
-variables:
-- name: Codeql.Enabled
- value: false
-- name: Codeql.SkipTaskAutoInjection
- value: true
-
-parameters:
-- name: poolName
- displayName: Pool Name
- type: string
- default: NetCore-Public
- values:
- - NetCore-Public
- - NetCore-Svc-Public
-- name: queueName
- displayName: Queue Name
- type: string
- default: windows.vs2022preview.amd64.open
- values:
- - windows.vs2022.amd64.open
- - windows.vs2022.scout.amd64.open
- - windows.vs2022preview.amd64.open
- - windows.vs2022preview.scout.amd64.open
-- name: timeout
- displayName: Timeout in Minutes
- type: number
- default: 260
-
-jobs:
-- job: RichCodeNav_Indexing
- pool:
- name: ${{ parameters.poolName }}
- demands: ImageOverride -equals ${{ parameters.queueName }}
- timeoutInMinutes: ${{ parameters.timeout }}
- variables:
- EnableRichCodeNavigation: true
-
- steps:
- - task: PowerShell@2
- displayName: Build
- inputs:
- filePath: eng/build.ps1
- arguments: -ci -restore -build -configuration Debug -prepareMachine
-
- - task: RichCodeNavIndexer@0
- displayName: RichCodeNav Upload
- inputs:
- languages: 'csharp'
- environment: production
- richNavLogOutputDirectory: $(Build.SourcesDirectory)/artifacts/bin
- continueOnError: true
- env:
- DOTNET_ROOT: $(Build.SourcesDirectory)/.dotnet
diff --git a/azure-pipelines.yml b/azure-pipelines.yml
index 0f26c4fff3483..494714e8fde8b 100644
--- a/azure-pipelines.yml
+++ b/azure-pipelines.yml
@@ -18,13 +18,20 @@ pr:
paths:
exclude:
- docs/*
+ - eng/config/OptProf.json
- eng/config/PublishData.json
+ - eng/setup-pr-validation.ps1
- src/LanguageServer/Microsoft.CommonLanguageServerProtocol.Framework/README.md
- .vscode/*
- .github/*
- .devcontainer/*
- .git-blame-ignore-revs
- .vsconfig
+ - azure-pipelines-compliance.yml
+ - azure-pipelines-integration-dartlab.yml
+ - azure-pipelines-integration-scouting.yml
+ - azure-pipelines-official.yml
+ - azure-pipelines-pr-validation.yml
- CODE-OF-CONDUCT.md
- CONTRIBUTING.md
- README.md
@@ -61,9 +68,9 @@ variables:
- name: UbuntuQueueName
${{ if eq(variables['System.TeamProject'], 'public') }}:
- value: Build.Ubuntu.2004.Amd64.Open
+ value: Build.Ubuntu.2204.Amd64.Open
${{ else }}:
- value: Build.Ubuntu.2004.Amd64
+ value: Build.Ubuntu.2204.Amd64
- name: WindowsQueueName
${{ if eq(variables['System.TeamProject'], 'public') }}:
@@ -85,15 +92,15 @@ variables:
- name: HelixUbuntuQueueName
${{ if eq(variables['System.TeamProject'], 'public') }}:
- value: Ubuntu.2004.Amd64.Open
+ value: Ubuntu.2204.Amd64.Open
${{ else }}:
- value: Ubuntu.2004.Amd64
+ value: Ubuntu.2204.Amd64
- name: HelixMacOsQueueName
${{ if eq(variables['System.TeamProject'], 'public') }}:
- value: OSX.13.Amd64.Open
+ value: OSX.15.Amd64.Open
${{ else }}:
- value: OSX.13.Amd64
+ value: OSX.15.Amd64
parameters:
# These pools allow us to configure the pools once for multiple jobs.
@@ -399,7 +406,7 @@ stages:
- powershell: eng/build.ps1 -configuration Release -prepareMachine -ci -restore -binaryLogName Restore.binlog
displayName: Restore
- - powershell: eng/build.ps1 -configuration Release -prepareMachine -ci -build -pack -publish -sign -binaryLogName Build.binlog /p:DotnetPublishUsingPipelines=true
+ - powershell: eng/build.ps1 -configuration Release -prepareMachine -ci -build -pack -publish -sign -binaryLogName Build.binlog /p:DotnetPublishUsingPipelines=true /p:ContinuousIntegrationBuildCorrectness=true
displayName: Build
# While this task is not executed in the official build, this serves as a PR check for whether symbol exclusions
diff --git a/docs/Language Feature Status.md b/docs/Language Feature Status.md
index a35439764e167..38a1ed4a00216 100644
--- a/docs/Language Feature Status.md
+++ b/docs/Language Feature Status.md
@@ -11,7 +11,6 @@ efforts behind them.
| Feature | Branch | State | Developer | Reviewer | IDE Buddy | LDM Champ |
| ------- | ------ | ----- | --------- | -------- | --------- | --------- |
| [User Defined Compound Assignment Operators](https://github.com/dotnet/csharplang/issues/9101) | [UserDefinedCompoundAssignment](https://github.com/dotnet/roslyn/tree/features/UserDefinedCompoundAssignment) | [In Progress](https://github.com/dotnet/roslyn/issues/76934) | [AlekseyTs](https://github.com/AlekseyTs) | [333fred](https://github.com/333fred), [cston](https://github.com/cston) | TBD | [AlekseyTs](https://github.com/AlekseyTs) |
-| [Partial Events and Constructors](https://github.com/dotnet/csharplang/issues/9058) | [PartialEventsCtors](https://github.com/dotnet/roslyn/tree/features/PartialEventsCtors) | [In Progress](https://github.com/dotnet/roslyn/issues/76859) | [jjonescz](https://github.com/jjonescz) | [cston](https://github.com/cston), [RikkiGibson](https://github.com/RikkiGibson) | | |
| Runtime Async | [runtime-async](https://github.com/dotnet/roslyn/tree/features/runtime-async) | [In Progress](https://github.com/dotnet/roslyn/issues/75960) | [333fred](https://github.com/333fred) | [jcouv](https://github.com/jcouv), [RikkiGibson](https://github.com/RikkiGibson) | | |
| [Null-conditional assignment](https://github.com/dotnet/csharplang/issues/6045) | [null-conditional-assignment](https://github.com/dotnet/roslyn/tree/features/null-conditional-assignment) | [In Progress](https://github.com/dotnet/roslyn/issues/75554) | [RikkiGibson](https://github.com/RikkiGibson) | [cston](https://github.com/cston), [jjonescz](https://github.com/jjonescz) | TBD | [RikkiGibson](https://github.com/RikkiGibson) |
| [Extensions](https://github.com/dotnet/csharplang/issues/8697) | [extensions](https://github.com/dotnet/roslyn/tree/features/extensions) | [In Progress](https://github.com/dotnet/roslyn/issues/76130) | [jcouv](https://github.com/jcouv), [AlekseyTs](https://github.com/AlekseyTs) | [jjonescz](https://github.com/jjonescz), TBD | [CyrusNajmabadi](https://github.com/CyrusNajmabadi) | [MadsTorgersen](https://github.com/MadsTorgersen) |
@@ -21,6 +20,7 @@ efforts behind them.
| [Unbound generic types in `nameof`](https://github.com/dotnet/csharplang/issues/8480) | [PR](https://github.com/dotnet/roslyn/pull/75368) | [Merged into 17.13p2](https://github.com/dotnet/roslyn/pull/75368) | [CyrusNajmabadi](https://github.com/CyrusNajmabadi) | [jcouv](https://github.com/jcouv), [AlekseyTs](https://github.com/AlekseyTs) | [CyrusNajmabadi](https://github.com/CyrusNajmabadi) | [CyrusNajmabadi](https://github.com/CyrusNajmabadi) |
| [String literals in data section as UTF8](https://github.com/dotnet/roslyn/blob/main/docs/features/string-literals-data-section.md) | [PR](https://github.com/dotnet/roslyn/pull/76036) | [Merged into 17.13p4](https://github.com/dotnet/roslyn/issues/76234) | [jjonescz](https://github.com/jjonescz) | [AlekseyTs](https://github.com/AlekseyTs), [cston](https://github.com/cston) | N/A | N/A |
| [Simple lambda parameters with modifiers](https://github.com/dotnet/csharplang/blob/main/proposals/simple-lambda-parameters-with-modifiers.md) | [PR](https://github.com/dotnet/roslyn/pull/75400) | [Merged into 17.14p1](https://github.com/dotnet/roslyn/pull/75400) | [CyrusNajmabadi](https://github.com/CyrusNajmabadi) | [jjonescz](https://github.com/jjonescz), [cston](https://github.com/cston) | [CyrusNajmabadi](https://github.com/CyrusNajmabadi) | [CyrusNajmabadi](https://github.com/CyrusNajmabadi) |
+| [Partial Events and Constructors](https://github.com/dotnet/csharplang/issues/9058) | [PartialEventsCtors](https://github.com/dotnet/roslyn/tree/features/PartialEventsCtors) | [Merged into 17.14p3](https://github.com/dotnet/roslyn/issues/76859) | [jjonescz](https://github.com/jjonescz) | [cston](https://github.com/cston), [RikkiGibson](https://github.com/RikkiGibson) | [CyrusNajmabadi](https://github.com/CyrusNajmabadi) | [jaredpar](https://github.com/jaredpar) |
# Working Set VB
diff --git a/docs/analyzers/FixAllProvider.md b/docs/analyzers/FixAllProvider.md
index c6b947950fb72..98548349e887a 100644
--- a/docs/analyzers/FixAllProvider.md
+++ b/docs/analyzers/FixAllProvider.md
@@ -1,120 +1,120 @@
-Introduction
-============
+# Introduction
This document covers the following:
- - Introductory definitions
- - What is a FixAll occurrences code fix?
- - How is a FixAll occurrences code fix computed?
- - Adding FixAll support to your code fixer
- - Selecting an Equivalence key for code actions
- - Spectrum of FixAll providers
- - Built-in FixAllProvider and its limitations
- - Implementing a custom FixAllProvider
-
-Definitions
-===========
-
- - **Analyzer:** An instance of a type derived from `DiagnosticAnalyzer` that reports diagnostics.
- - **Code fixer:** An instance of a type derived from `CodeFixProvider` that provides code fixes for compiler and/or analyzer diagnostics.
- - **Code refactoring:** An instance of a type derived from `CodeRefactoringProvider` that provides source code refactorings.
- - **Code action:** An action registered by `CodeFixProvider.RegisterCodeFixesAsync` that performs a code fix OR an action registered by `CodeRefactoringProvider.ComputeRefactoringsAsync` that performs a code refactoring.
- - **Equivalence Key:** A string value representing an equivalence class of all code actions registered by a code fixer or refactoring. Two code actions are treated as equivalent if they have equal `EquivalenceKey` values and were generated by the same code fixer or refactoring.
- - **FixAll provider:** An instance of a type derived from `FixAllProvider` that provides a FixAll occurrences code fix. A FixAll provider is associated with a corresponding code fixer by `CodeFixProvider.GetFixAllProvider` method.
- - **FixAll occurrences code fix:** A code action returned by `FixAllProvider.GetFixAsync`, that fixes all or multiple occurrences of diagnostics fixed by the corresponding code fixer, within a given `FixAllScope`.
-
-What is a FixAll occurrences code fix?
-======================================
+
+- Introductory definitions
+- What is a FixAll occurrences code fix?
+- How is a FixAll occurrences code fix computed?
+- Adding FixAll support to your code fixer
+- Selecting an Equivalence key for code actions
+- Spectrum of FixAll providers
+- Built-in FixAllProvider and its limitations
+- Implementing a custom FixAllProvider
+
+# Definitions
+
+- **Analyzer:** An instance of a type derived from `DiagnosticAnalyzer` that reports diagnostics.
+- **Code fixer:** An instance of a type derived from `CodeFixProvider` that provides code fixes for compiler and/or analyzer diagnostics.
+- **Code refactoring:** An instance of a type derived from `CodeRefactoringProvider` that provides source code refactorings.
+- **Code action:** An action registered by `CodeFixProvider.RegisterCodeFixesAsync` that performs a code fix OR an action registered by `CodeRefactoringProvider.ComputeRefactoringsAsync` that performs a code refactoring.
+- **Equivalence Key:** A string value representing an equivalence class of all code actions registered by a code fixer or refactoring. Two code actions are treated as equivalent if they have equal `EquivalenceKey` values and were generated by the same code fixer or refactoring.
+- **FixAll provider:** An instance of a type derived from `FixAllProvider` that provides a FixAll occurrences code fix. A FixAll provider is associated with a corresponding code fixer by `CodeFixProvider.GetFixAllProvider` method.
+- **FixAll occurrences code fix:** A code action returned by `FixAllProvider.GetFixAsync`, that fixes all or multiple occurrences of diagnostics fixed by the corresponding code fixer, within a given `FixAllScope`.
+
+# What is a FixAll occurrences code fix?
In layman terms, a FixAll occurrences code fix means: I have a code fix 'C', that fixes a specific instance of diagnostic 'D' in my source and I want to apply this fix to all instances of 'D' across a broader scope, such as a document or a project or the entire solution.
In more technical terms: Given a particular code action registered by a code fixer to fix one or more diagnostics, a corresponding code action registered by its FixAll provider, that applies the original trigger code action across a broader scope (such as a document/project/solution) to fix multiple instances of such diagnostics.
-How is a FixAll occurrences code fix computed?
-==============================================
+# How is a FixAll occurrences code fix computed?
Following steps are used to compute a FixAll occurrences code fix:
- - Given a specific instance of a diagnostic, compute the set of code actions that claim to fix the diagnostic.
- - Select a specific code action from this set. In the Visual Studio IDE, this is done by selecting a specific code action in the light bulb menu.
- - The equivalence key of the selected code action represents the class of code actions that must be applied as part of a FixAll occurrences code fix.
- - Given this code action, get the FixAll provider corresponding to the code fixer that registered this code action.
- - If non-null, then request the FixAll provider for its supported FixAllScopes.
- - Select a specific `FixAllScope` from this set. In the Visual Studio IDE, this is done by clicking on the scope hyperlink in the preview dialog.
- - Given the trigger diagnostic(s), the equivalence key of the trigger code action, and the FixAll scope, invoke `FixAllProvider.GetFixAsync` to compute the FixAll occurrences code fix.
-Adding FixAll support to your code fixer
-========================================
+- Given a specific instance of a diagnostic, compute the set of code actions that claim to fix the diagnostic.
+- Select a specific code action from this set. In the Visual Studio IDE, this is done by selecting a specific code action in the light bulb menu.
+- The equivalence key of the selected code action represents the class of code actions that must be applied as part of a FixAll occurrences code fix.
+- Given this code action, get the FixAll provider corresponding to the code fixer that registered this code action.
+- If non-null, then request the FixAll provider for its supported FixAllScopes.
+- Select a specific `FixAllScope` from this set. In the Visual Studio IDE, this is done by clicking on the scope hyperlink in the preview dialog.
+- Given the trigger diagnostic(s), the equivalence key of the trigger code action, and the FixAll scope, invoke `FixAllProvider.GetFixAsync` to compute the FixAll occurrences code fix.
+
+# Adding FixAll support to your code fixer
Follow the below steps to add FixAll support to your code fixer:
- - Override the `CodeFixProvider.GetFixAllProvider` method and return a non-null instance of a `FixAllProvider`. You may either use our built-in FixAllProvider or implement a custom FixAllProvider. See the following sections in this document for determining the correct approach for your fixer.
- - Ensure that all the code actions registered by your code fixer have a non-null equivalence key. See the following section to determine how to select an equivalence key.
-Selecting an Equivalence key for code actions
-=============================================
+- Override the `CodeFixProvider.GetFixAllProvider` method and return a non-null instance of a `FixAllProvider`. You may either use our built-in FixAllProvider or implement a custom FixAllProvider. See the following sections in this document for determining the correct approach for your fixer.
+- Ensure that all the code actions registered by your code fixer have a non-null equivalence key. See the following section to determine how to select an equivalence key.
+
+# Selecting an Equivalence key for code actions
Each unique equivalence key for a code fixer defines a unique equivalence class of code actions. Equivalence key of the trigger code action is part of the `FixAllContext` and is used to determine the FixAll occurrences code fix.
Normally, you can use the **'title'** of the code action as the equivalence key. However, there are cases where you may desire to have different values. Let us take an example to get a better understanding.
Let us consider the [C# SimplifyTypeNamesCodeFixProvider](https://github.com/dotnet/roslyn/blob/main/src/Features/CSharp/Portable/SimplifyTypeNames/SimplifyTypeNamesCodeFixProvider.cs) that registers multiple code actions and also has FixAll support. This code fixer offers fixes to simplify the following expressions:
- - `this` expressions of the form 'this.x' to 'x'.
- - Qualified type names of the form 'A.B' to 'B'.
- - Member access expressions of the form 'A.M' to 'M'.
+
+- `this` expressions of the form 'this.x' to 'x'.
+- Qualified type names of the form 'A.B' to 'B'.
+- Member access expressions of the form 'A.M' to 'M'.
This fixer needs the following semantics for the corresponding FixAll occurrences code fixes:
- - `this` expression simplification: Fix all should simplify all this expressions, regardless of the member being accessed (this.x, this.y, this.z, etc.).
- - Qualified type name simplification: Fix all should simplify all qualified type names 'A.B' to 'B'. However, we don't want to simplify **all** qualified type names, such as 'C.D', 'E.F', etc. as that would be too generic a fix, which is not likely intended by the user.
- - Member access expressions: Fix all should simplify all member access expressions 'A.M' to 'M'.
+
+- `this` expression simplification: Fix all should simplify all this expressions, regardless of the member being accessed (this.x, this.y, this.z, etc.).
+- Qualified type name simplification: Fix all should simplify all qualified type names 'A.B' to 'B'. However, we don't want to simplify **all** qualified type names, such as 'C.D', 'E.F', etc. as that would be too generic a fix, which is not likely intended by the user.
+- Member access expressions: Fix all should simplify all member access expressions 'A.M' to 'M'.
It uses the below equivalence keys for its registered code actions to get the desired FixAll behavior:
- - `this` expression simplification: Generic resource string "Simplify this expression", which explicitly excludes the contents of the node being simplified.
- - Qualified type name simplification: Formatted resource string "Simplify type name A.B", which explicitly includes the contents of the node being simplified.
- - Member access expressions: Formatted resource string "Simplify type name A.M", which explicitly includes the contents of the node being simplified.
+
+- `this` expression simplification: Generic resource string "Simplify this expression", which explicitly excludes the contents of the node being simplified.
+- Qualified type name simplification: Formatted resource string "Simplify type name A.B", which explicitly includes the contents of the node being simplified.
+- Member access expressions: Formatted resource string "Simplify type name A.M", which explicitly includes the contents of the node being simplified.
Note that '`this` expression simplification' fix requires a different kind of an equivalence class from the other two simplifications. See method [GetCodeActionId](https://github.com/dotnet/roslyn/blob/main/src/Features/Core/Portable/ImplementAbstractClass/AbstractImplementAbstractClassCodeFixProvider.cs) for the actual implementation.
To summarize, use the equivalence key that best suits the category of fixes to be applied as part of a FixAll operation.
-Spectrum of FixAll providers
-============================
+# Spectrum of FixAll providers
When multiple fixes need to be applied to documents, there are various ways to do it:
+
- **Sequential approach**: One way to do it is to compute diagnostics, pick one, ask a fixer to produce a code action to fix that, apply it. Now for the resulting new compilation, recompute diagnostics, pick the next one and repeat the process. This approach would be very slow but would lead to correct results (unless it doesn't converge where one fix introduces a diagnostic that was just fixed by a previous fix). We chose to not implement this approach.
- **Batch fix approach**: Another way is to compute all the diagnostics, pick each diagnostic and give it to a fixer and apply it to produce a new solution. If there were 'n' diagnostics, there would be 'n' new solutions. Now just merge them all together in one go. This may produce incorrect results (when different fixes change the same region of code in different ways) but it is very fast. We have one implementation of this approach in `WellKnownFixAllProviders.BatchFixer`
- **Custom approach**: Depending on the fix, there may be a custom solution to fix multiple issues. For example, consider an analyzer that simply needs to generate one file as the fix for any instance of the issue. Instead of generating the same file over and over using the previous two approaches, one could write a custom `FixAllProvider` that simply generates the file once if there were any diagnostics at all.
Since there are various ways of fixing all issues, we've implemented a framework and provided the one general implementation that we think is useful in many cases.
-Built-in FixAllProvider
-=======================
+# Built-in FixAllProvider
We provide a default `BatchFixAllProvider` implementation of a FixAll provider that uses the underlying code fixer to compute the FixAll occurrences code fixes.
To use the batch fixer, you should return the static `WellKnownFixAllProviders.BatchFixer` instance in the `CodeFixProvider.GetFixAllProvider` override.
NOTE: See the following section on **'Limitations of the BatchFixer'** to determine if the batch fixer can be used by your code fixer.
Given a trigger diagnostic, a trigger code action, the underlying code fixer and the FixAll scope, the BatchFixer computes FixAll occurrences code fix with the following steps:
- - Compute all instances of the trigger diagnostic across the FixAll scope.
- - For each computed diagnostic, invoke the underlying code fixer to compute the set of code actions to fix the diagnostic.
- - Collect all the registered code actions that have the same equivalence key as the trigger code action.
- - Apply all these code actions on the original solution snapshot to compute new solution snapshots. The batch fixer only batches code action operations of type `ApplyChangesOperation` present within the individual code actions, other types of operations are ignored.
- - Sequentially merge the new solution snapshots into a final solution snapshot. Only non-conflicting code actions whose fix spans don't overlap the fix spans of prior merged code actions are retained.
-Limitations of the BatchFixer
-=============================
+- Compute all instances of the trigger diagnostic across the FixAll scope.
+- For each computed diagnostic, invoke the underlying code fixer to compute the set of code actions to fix the diagnostic.
+- Collect all the registered code actions that have the same equivalence key as the trigger code action.
+- Apply all these code actions on the original solution snapshot to compute new solution snapshots. The batch fixer only batches code action operations of type `ApplyChangesOperation` present within the individual code actions, other types of operations are ignored.
+- Sequentially merge the new solution snapshots into a final solution snapshot. Only non-conflicting code actions whose fix spans don't overlap the fix spans of prior merged code actions are retained.
+
+# Limitations of the BatchFixer
The BatchFixer is designed for a common category of fixers where fix spans for diagnostics don't overlap with each other. For example, assume there is a diagnostic that spans a particular expression, and a fixer that fixes that expression. If all the instances of this diagnostic are guaranteed to have non-overlapping spans, then their fixes can be computed independently and this batch of fixes can be subsequently merged together.
However, there are cases where the BatchFixer might not work for your fixer. Following are some such examples:
- - Code fixer registers code actions without an equivalence key or with a null equivalence key.
- - Code fixer registers non-local code actions, i.e. a code action whose fix span is completely distinct from diagnostic span. For example, a fix that adds a new declaration node. Multiple such fixes are likely to have overlapping spans and hence could be conflicting.
- - Diagnostics to be fixed as part of FixAll occurrences have overlapping spans. It is likely that fixes for such diagnostics will have overlapping spans too, and hence would conflict with each other.
- - Code fixer registers code actions with operations other than `ApplyChangesOperation`. BatchFixer ignores such operations and hence may produce unexpected results.
-Implementing a custom FixAllProvider
-====================================
+- Code fixer registers code actions without an equivalence key or with a null equivalence key.
+- Code fixer registers non-local code actions, i.e. a code action whose fix span is completely distinct from diagnostic span. For example, a fix that adds a new declaration node. Multiple such fixes are likely to have overlapping spans and hence could be conflicting.
+- Diagnostics to be fixed as part of FixAll occurrences have overlapping spans. It is likely that fixes for such diagnostics will have overlapping spans too, and hence would conflict with each other.
+- Code fixer registers code actions with operations other than `ApplyChangesOperation`. BatchFixer ignores such operations and hence may produce unexpected results.
+
+# Implementing a custom FixAllProvider
For cases where you cannot use the BatchFixer, you must implement your own `FixAllProvider`. It is recommended that you create a singleton instance of the FixAll provider, instead of creating a new instance for every `CodeFixProvider.GetFixAllProvider` invocation.
Following guidelines should help in the implementation:
- - **GetFixAsync:** Primary method to compute the FixAll occurrences code fix for a given `FixAllContext`. You may use the set of 'GetXXXDiagnosticsAsync' methods on the `FixAllContext` to compute the diagnostics to be fixed. You must return a single code action that fixes all the diagnostics in the given FixAll scope.
- - **GetSupportedFixAllScopes:** Virtual method to get all the supported FixAll scopes. By default, it returns all the three supported scopes: document, project and solution scopes. Generally, you need not override this method. However, you may do so if you wish to support a subset of these scopes.
- - **GetSupportedFixAllDiagnosticIds:** Virtual method to get all the fixable diagnostic ids. By default, it returns the underlying code fixer's `FixableDiagnosticIds`. Generally, you need not override this method. However, you may do so if you wish to support FixAll only for a subset of these ids.
-See [DeclarePublicAPIFix](https://github.com/dotnet/roslyn-analyzers/blob/main/src/PublicApiAnalyzers/Core/CodeFixes/DeclarePublicApiFix.cs) for an example implementation of a custom FixAllProvider.
+- **GetFixAsync:** Primary method to compute the FixAll occurrences code fix for a given `FixAllContext`. You may use the set of 'GetXXXDiagnosticsAsync' methods on the `FixAllContext` to compute the diagnostics to be fixed. You must return a single code action that fixes all the diagnostics in the given FixAll scope.
+- **GetSupportedFixAllScopes:** Virtual method to get all the supported FixAll scopes. By default, it returns all the three supported scopes: document, project and solution scopes. Generally, you need not override this method. However, you may do so if you wish to support a subset of these scopes.
+- **GetSupportedFixAllDiagnosticIds:** Virtual method to get all the fixable diagnostic ids. By default, it returns the underlying code fixer's `FixableDiagnosticIds`. Generally, you need not override this method. However, you may do so if you wish to support FixAll only for a subset of these ids.
+
+See [DeclarePublicAPIFix](https://github.com/dotnet/roslyn/blob/main/src/RoslynAnalyzers/PublicApiAnalyzers/Core/CodeFixes/DeclarePublicApiFix.cs) for an example implementation of a custom FixAllProvider.
diff --git a/docs/compilers/CSharp/Compiler Breaking Changes - DotNet 10.md b/docs/compilers/CSharp/Compiler Breaking Changes - DotNet 10.md
index da3ecdd5166a7..af85d951a3b53 100644
--- a/docs/compilers/CSharp/Compiler Breaking Changes - DotNet 10.md
+++ b/docs/compilers/CSharp/Compiler Breaking Changes - DotNet 10.md
@@ -314,3 +314,46 @@ CSharpCompilation.Create("test",
Similarly this can be observed when using the command-line argument `/refonly`
or the `ProduceOnlyReferenceAssembly` MSBuild property.
+
+## `partial` cannot be a return type of methods
+
+***Introduced in Visual Studio 2022 version 17.14***
+
+The [partial events and constructors](https://github.com/dotnet/csharplang/issues/9058) language feature
+allows the `partial` modifier in more places and so it cannot be a return type unless escaped:
+
+```cs
+class C
+{
+ partial F() => new partial(); // previously worked
+ @partial F() => new partial(); // workaround
+}
+
+class partial { }
+```
+
+## `extension` treated as a contextual keyword
+
+PROTOTYPE record which version this break is introduced in
+
+Starting with C# 14, the `extension` keyword serves a special purpose in denoting extension containers.
+This changes how the compiler interprets certain code constructs.
+
+If you need to use "extension" as an identifier rather than a keyword, escape it with the `@` prefix: `@extension`. This tells the compiler to treat it as a regular identifier instead of a keyword.
+
+The compiler will parse this as an extension container rather than a constructor.
+```csharp
+class extension
+{
+ extension(object o) { } // parsed as an extension container
+}
+```
+
+The compiler will fail to parse this as a method with return type `extension`.
+```csharp
+class extension
+{
+ extension M() { } // will not compile
+}
+```
+
diff --git a/docs/compilers/CSharp/Compiler Breaking Changes - DotNet 9.md b/docs/compilers/CSharp/Compiler Breaking Changes - DotNet 9.md
index 3ebc24cd2fe0a..ede353e5c7d71 100644
--- a/docs/compilers/CSharp/Compiler Breaking Changes - DotNet 9.md
+++ b/docs/compilers/CSharp/Compiler Breaking Changes - DotNet 9.md
@@ -183,4 +183,4 @@ of the value is as follows:
5. `omit_if_default`. Redundant modifiers are disallowed. For example a private class member will be disallowed from
using `private`, and a public interface member will be disallowed from using `public`. This is the option to use
if you feel that restating the accessibility when it matches what the language chooses by default is redundant and
- should be disalloed.
+ should be disallowed.
diff --git a/docs/contributing/Building, Debugging, and Testing on Windows.md b/docs/contributing/Building, Debugging, and Testing on Windows.md
index 87a3722a7adb5..235ae3e82854c 100644
--- a/docs/contributing/Building, Debugging, and Testing on Windows.md
+++ b/docs/contributing/Building, Debugging, and Testing on Windows.md
@@ -223,15 +223,16 @@ Before pushing a relevant fix to CI, you can validate locally using the `-testUs
### Running the PublicAPI fixer
-1. Install `dotnet-format` as a global tool. It does ship as part of the SDK, but a separate version can be installed as a global tool and invoked with `dotnet-format {options}`.
-`C:\Source\roslyn> dotnet tool install -g dotnet-format --version "6.*" --add-source https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet6/nuget/v3/index.json`
-2. Restore and build `Compilers.slnf`. This is necessary to ensure the source generator project is built and we can load the generator assembly when running `dotnet-format`.
-`C:\Source\roslyn> .\restore.cmd`
-`C:\Source\roslyn> .\build.cmd`
-3. Invoke the `dotnet-format` global tool. Running only the analyzers subcommand and fixing only the "missing Public API signature" diagnostic. We must also pass the `--include-generated` flag to include source generated documents in the analysis.
-`C:\Source\roslyn> cd ..`
-`C:\Source> dotnet-format analyzers .\roslyn\Compilers.slnf --diagnostics=RS0016 --no-restore --include-generated -v diag`
-
+1. Restore and build `Compilers.slnf`. This is necessary to ensure the source generator project is built and we can load the generator assembly when running `dotnet format`.
+ ```ps1
+ C:\Source\roslyn> .\restore.cmd
+ C:\Source\roslyn> .\build.cmd
+ ```
+2. Invoke `dotnet format` (the one included in .NET SDK, not the global tool `dotnet-format` which is deprecated). Running only the analyzers subcommand and fixing only the "missing Public API signature" diagnostic. We must also pass the `--include-generated` flag to include source generated documents in the analysis.
+ ```ps1
+ C:\Source\roslyn> cd ..
+ C:\Source> dotnet format analyzers .\roslyn\Compilers.slnf --diagnostics=RS0016 --no-restore --include-generated -v diag
+ ```
## Contributing
diff --git a/docs/features/field-nullability.md b/docs/features/field-nullability.md
new file mode 100644
index 0000000000000..5dd2f97992271
--- /dev/null
+++ b/docs/features/field-nullability.md
@@ -0,0 +1,23 @@
+# `field` keyword nullable analysis implementation
+
+See also [specification](https://github.com/dotnet/csharplang/blob/94205582d0f5c73e5765cb5888311c2f14890b95/proposals/field-keyword.md#nullability).
+
+## Symbol API behavior
+
+In order to decide the NullableAnnotation of a SynthesizedBackingFieldSymbol we need to:
+1. Decide if the getter associated with this field requires a null-resilience analysis.
+2. If it *doesn't* require such an analysis, then the nullable annotation of the property is used.
+3. If it *does*, then a binding+nullable analysis of the getter must be performed to decide the nullability of the backing field.
+
+There are some significant problems with directly exposing the nullable annotation on this field symbol.
+1. Cost. It's not clear if it's OK for reading the NullableAnnotation off a field to cause us to bind and nullable analyze something. If some tooling is traversing member symbols for indexing or some such, it may be a problem if that causes unexpected method binding to occur where it didn't before.
+2. Stack cycles. In the process of binding+flow analyzing, we may want to access the nullable annotation of the field. If we are *already* in the process of determining that field's nullable annotation, then we would need to "short-circuit" and return some "placeholder" value. We would need to take care to isolate the "internal" implementation from any public implementation, in order to ensure that a consistent answer is given to users of the public API.
+...
+
+It's tempting to avoid exposing the inferred nullable annotation in the public symbol model. This might be problematic for automated tooling which is trying to reason about nullable initialization. For example, if a diagnostic suppressor wants to suppress `CS8618` nullable initialization warnings under certain conditions. How should it decide whether/why a property like `string Prop => field ??= GetValue();` requires initialization in constructors? It's unclear to me whether this matters.
+
+In the interests of *simplicity* (first make it correct, then make it fast), I'd like to move forward by *not* exposing the inferred annotation in the symbol model. Rather, we introduce a new internal API `SynthesizedBackingFieldSymbol.GetInferredNullableAnnotation()`, which `NullableWalker` will use to decide initial nullable state, report warnings, and so on. The implementation simply does an on-demand binding of the get accessor, then nullable analyzes and decides the nullable annotation. Care needs to be taken to avoid using this API in a re-entrant manner--so, the `NullableWalker` passes which are used to infer the nullability annotation must avoid calling it.
+
+This means that the ordinary `FieldSymbol.TypeWithAnnotations` API would not expose the inferred nullability, and neither would `IFieldSymbol.Type` or `IFieldSymbol.NullableAnnotation`. Instead the field's nullability would always match the property's. This is something I would actually like to fix, maybe before merging to main. It feels like Quick Info, etc., should expose the inferred nullability through the ordinary APIs.
+
+Once we get a handle on the behaviors of the getter null resilience, we can start talking about how to reduce cost associated with it. For example, we could try to reduce redundant binding, by forcing nullable annotations to be inferred prior to analyzing certain methods. Before processing a constructor in `MethodCompiler`, for example, maybe we would identify the getters that need to be compiled for purposes of inference, and force those to compile first.
\ No newline at end of file
diff --git a/docs/roslyn-analyzers/README.md b/docs/roslyn-analyzers/README.md
new file mode 100644
index 0000000000000..be255b10a37e8
--- /dev/null
+++ b/docs/roslyn-analyzers/README.md
@@ -0,0 +1,37 @@
+# Roslyn Analyzers
+
+## Microsoft.CodeAnalysis.Analyzers
+
+*Latest stable version:* [](https://www.nuget.org/packages/Microsoft.CodeAnalysis.Analyzers)
+
+*Latest pre-release version:* [here](https://dev.azure.com/dnceng/public/_artifacts/feed/dotnet7/NuGet/Microsoft.CodeAnalysis.Analyzers/versions)
+
+This package contains rules for correct usage of APIs from the [Microsoft.CodeAnalysis](https://www.nuget.org/packages/Microsoft.CodeAnalysis) NuGet package, i.e. .NET Compiler Platform ("Roslyn") APIs. These are primarily aimed towards helping authors of diagnostic analyzers and code fix providers to invoke the Microsoft.CodeAnalysis APIs in a recommended manner. [More info about rules in this package](../../src/RoslynAnalyzers/Microsoft.CodeAnalysis.Analyzers/Microsoft.CodeAnalysis.Analyzers.md)
+
+## Roslyn.Diagnostics.Analyzers
+
+*Latest stable version:* [](https://www.nuget.org/packages/Roslyn.Diagnostics.Analyzers)
+
+*Latest pre-release version:* [here](https://dev.azure.com/dnceng/public/_artifacts/feed/dotnet7/NuGet/Roslyn.Diagnostics.Analyzers/versions)
+
+This package contains rules that are very specific to the .NET Compiler Platform ("Roslyn") project, i.e. [dotnet/roslyn](https://github.com/dotnet/roslyn) repo. This analyzer package is *not intended for general consumption* outside the Roslyn repo. [More info about rules in this package](../../src/RoslynAnalyzers/Roslyn.Diagnostics.Analyzers/Roslyn.Diagnostics.Analyzers.md)
+
+## Microsoft.CodeAnalysis.BannedApiAnalyzers
+
+*Latest stable version:* [](https://www.nuget.org/packages/Microsoft.CodeAnalysis.BannedApiAnalyzers)
+
+*Latest pre-release version:* [here](https://dev.azure.com/dnceng/public/_artifacts/feed/dotnet7/NuGet/Microsoft.CodeAnalysis.BannedApiAnalyzers/versions)
+
+This package contains customizable rules for identifying references to banned APIs. [More info about rules in this package](../../src/RoslynAnalyzers/Microsoft.CodeAnalysis.BannedApiAnalyzers/Microsoft.CodeAnalysis.BannedApiAnalyzers.md)
+
+For instructions on using this analyzer, see [Instructions](../../src/RoslynAnalyzers/Microsoft.CodeAnalysis.BannedApiAnalyzers/BannedApiAnalyzers.Help.md).
+
+## Microsoft.CodeAnalysis.PublicApiAnalyzers
+
+*Latest stable version:* [](https://www.nuget.org/packages/Microsoft.CodeAnalysis.PublicApiAnalyzers)
+
+*Latest pre-release version:* [here](https://dev.azure.com/dnceng/public/_artifacts/feed/dotnet7/NuGet/Microsoft.CodeAnalysis.PublicApiAnalyzers/versions)
+
+This package contains rules to help library authors monitoring change to their public APIs. [More info about rules in this package](../../src/RoslynAnalyzers/PublicApiAnalyzers/Microsoft.CodeAnalysis.PublicApiAnalyzers.md)
+
+For instructions on using this analyzer, see [Instructions](../../src/RoslynAnalyzers/PublicApiAnalyzers/PublicApiAnalyzers.Help.md).
\ No newline at end of file
diff --git a/docs/roslyn-analyzers/rules/RS1022.md b/docs/roslyn-analyzers/rules/RS1022.md
new file mode 100644
index 0000000000000..ecdb021e08d2b
--- /dev/null
+++ b/docs/roslyn-analyzers/rules/RS1022.md
@@ -0,0 +1,22 @@
+## RS1022: Do not use types from Workspaces assembly in an analyzer
+
+Diagnostic analyzer types should not use types from Workspaces assemblies. Workspaces assemblies are only available when the analyzer executes in Visual Studio IDE live analysis, but are not available during command line build. Referencing types from Workspaces assemblies will lead to runtime exception during analyzer execution in command line build.
+
+|Item|Value|
+|-|-|
+|Category|MicrosoftCodeAnalysisCorrectness|
+|Enabled|True|
+|Severity|Warning|
+|CodeFix|False|
+---
+
+> **Warning**
+>
+> The analysis performed by RS1022 is slow and relies on implementation details of the JIT compiler for correctness.
+> Authors of compiler extensions are encouraged to use the stricter (and faster) analyzer RS1038 instead of this rule.
+>
+> RS1038 is enabled by default. To enable RS1022 instead, the following configuration may be added to **.globalconfig**:
+>
+> ```ini
+> roslyn_correctness.assembly_reference_validation = relaxed
+> ```
diff --git a/docs/roslyn-analyzers/rules/RS1038.md b/docs/roslyn-analyzers/rules/RS1038.md
new file mode 100644
index 0000000000000..e0d73e8db2d4d
--- /dev/null
+++ b/docs/roslyn-analyzers/rules/RS1038.md
@@ -0,0 +1,46 @@
+## RS1038: Compiler extensions should be implemented in assemblies with compiler-provided references
+
+Types which implement compiler extension points should not be declared in assemblies that contain references to assemblies which are not provided by all compilation scenarios. Doing so may cause the feature to behave unpredictably.
+
+|Item|Value|
+|-|-|
+|Category|MicrosoftCodeAnalysisCorrectness|
+|Enabled|True|
+|Severity|Warning|
+|CodeFix|False|
+---
+
+This rule helps ensure compiler extensions (e.g. analyzers and source generators) will load correctly in all compilation
+scenarios. Depending on the manner in which the compiler is invoked, some assemblies may not be present during a build,
+and attempting to reference them will result in exceptions that prevent the compiler extension from loading. RS1038 is
+the most strict and best performing validation for this scenario.
+
+RS1038 is enabled by default unless relaxed validation has been manually enabled in **.globalconfig** as described in
+[RS1022](RS1022.md).
+
+### Rules for compiler feature references
+
+* Compiler features supporting C# code should only reference the NuGet packages **Microsoft.CodeAnalysis.Common** and/or **Microsoft.CodeAnalysis.CSharp**
+* Compiler features supporting Visual Basic code should only reference **Microsoft.CodeAnalysis.Common** and/or **Microsoft.CodeAnalysis.VisualBasic**
+* Compiler features supporting both C# and Visual Basic should only reference **Microsoft.CodeAnalysis.Common**
+* Compiler features should not be implemented in assemblies containing a reference to **Microsoft.CodeAnalysis.Workspaces.Common**
+
+> **Note**
+>
+> This analyzer only checks references to the core Roslyn assemblies. Compiler extensions with other dependencies may
+> face restrictions and/or packaging requirements outside the scope of this analyzer.
+
+### Compiler extension points
+
+The following compiler extension points are examined by this analyzer:
+
+* `DiagnosticAnalyzer`
+* `DiagnosticSuppressor`
+* `ISourceGenerator`
+* `IIncrementalGenerator`
+
+### Other extension points
+
+Some extension points provided by Roslyn are IDE extensions (e.g. code fixes and completion providers). These features
+may ship in the same package as compiler features, but should be implemented in their own assembly since they require a
+reference to non-compiler package **Microsoft.CodeAnalysis.Workspaces.Common**.
diff --git a/docs/roslyn-analyzers/rules/RS1041.md b/docs/roslyn-analyzers/rules/RS1041.md
new file mode 100644
index 0000000000000..4d60ec77358bb
--- /dev/null
+++ b/docs/roslyn-analyzers/rules/RS1041.md
@@ -0,0 +1,25 @@
+## RS1041: Compiler extensions should be implemented in assemblies targeting netstandard2.0
+
+Types which implement compiler extension points should only be declared in assemblies targeting netstandard2.0. More specific target frameworks are only available in a subset of supported compilation scenarios, so targeting them may cause the feature to behave unpredictably.
+
+|Item|Value|
+|-|-|
+|Category|MicrosoftCodeAnalysisCorrectness|
+|Enabled|True|
+|Severity|Warning|
+|CodeFix|False|
+---
+
+This rule helps ensure compiler extensions (e.g. analyzers and source generators) will load correctly in all compilation
+scenarios. Depending on the manner in which the compiler is invoked, the compiler may execute under .NET Framework or
+.NET, and compiler extensions are expected to work consistently in both cases. By targeting netstandard2.0, compiler
+extensions are known to be compatible with both execution environments.
+
+### Compiler extension points
+
+The following compiler extension points are examined by this analyzer:
+
+* `DiagnosticAnalyzer`
+* `DiagnosticSuppressor`
+* `ISourceGenerator`
+* `IIncrementalGenerator`
diff --git a/docs/specs/PortablePdb-Metadata.md b/docs/specs/PortablePdb-Metadata.md
index e4d139ba0a351..7c4c9cab968f1 100644
--- a/docs/specs/PortablePdb-Metadata.md
+++ b/docs/specs/PortablePdb-Metadata.md
@@ -1,4 +1,4 @@
# Portable PDB v1.0: Format Specification
-Moved to
-https://github.com/dotnet/corefx/blob/main/src/System.Reflection.Metadata/specs/PortablePdb-Metadata.md
+Moved to
+https://github.com/dotnet/runtime/blob/main/docs/design/specs/PortablePdb-Metadata.md
diff --git a/docs/wiki/NuGet-packages.md b/docs/wiki/NuGet-packages.md
index 3caad8005c828..f7a0c0c41b582 100644
--- a/docs/wiki/NuGet-packages.md
+++ b/docs/wiki/NuGet-packages.md
@@ -51,6 +51,7 @@ Below are the versions of the language available in the NuGet packages. Remember
- Version `4.10` includes C# 12.0 (Visual Studio 2022 version 17.10, .NET 8)
- Version `4.11` includes C# 12.0 (Visual Studio 2022 version 17.11, .NET 8)
- Version `4.12` includes C# 13.0 (Visual Studio 2022 version 17.12, .NET 9)
+- Version `4.13` includes C# 13.0 (Visual Studio 2022 version 17.13, .NET 9)
See the [history of C# language features](https://github.com/dotnet/csharplang/blob/main/Language-Version-History.md) for more details.
diff --git a/eng/Directory.Packages.props b/eng/Directory.Packages.props
index c21a629429963..20ded129bd665 100644
--- a/eng/Directory.Packages.props
+++ b/eng/Directory.Packages.props
@@ -21,6 +21,8 @@
8.0.10
<_xunitVersion>2.9.2
2.1.0
+
+ 2.14.1
@@ -225,8 +227,12 @@
+
+
+
+
-
+
@@ -237,10 +243,15 @@
+
+
+
+
+
@@ -301,7 +312,6 @@
-
@@ -314,5 +324,15 @@
the generators we build would load on the command line but not load in IDEs.
-->
-
+
+
+
+
+
+
+
+
diff --git a/eng/SourceBuildPrebuiltBaseline.xml b/eng/SourceBuildPrebuiltBaseline.xml
index 140179baf5d0d..1de1443142a26 100644
--- a/eng/SourceBuildPrebuiltBaseline.xml
+++ b/eng/SourceBuildPrebuiltBaseline.xml
@@ -3,52 +3,61 @@
-
+ overridden by previous repo outputs or come from previously source-built artifacts. -->
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/eng/Version.Details.xml b/eng/Version.Details.xml
index 1fe07fb69f12a..ed9fd3a97dcec 100644
--- a/eng/Version.Details.xml
+++ b/eng/Version.Details.xml
@@ -1,6 +1,11 @@
+
+
+ https://github.com/dotnet/roslyn
+ ae1fff344d46976624e68ae17164e0607ab68b10
+ https://github.com/dotnet/source-build-externals
@@ -8,9 +13,9 @@
-
+ https://github.com/dotnet/source-build-reference-packages
- d794781cc75921b4ebbefe2eabdb0d6cd1713005
+ 1556b6c639edcaee959013681afcf2e66b118537
@@ -24,117 +29,117 @@
-
+ https://github.com/dotnet/runtime
- 5535e31a712343a63f5d7d796cd874e563e5ac14
+ 9d5a6a9aa463d6d10b0b0ba6d5982cc82f363dc3
-
+ https://github.com/dotnet/runtime
- 5535e31a712343a63f5d7d796cd874e563e5ac14
+ 9d5a6a9aa463d6d10b0b0ba6d5982cc82f363dc3
-
+ https://github.com/dotnet/runtime
- 5535e31a712343a63f5d7d796cd874e563e5ac14
+ 9d5a6a9aa463d6d10b0b0ba6d5982cc82f363dc3
-
+ https://github.com/dotnet/runtime
- 5535e31a712343a63f5d7d796cd874e563e5ac14
+ 9d5a6a9aa463d6d10b0b0ba6d5982cc82f363dc3
-
+ https://github.com/dotnet/runtime
- 5535e31a712343a63f5d7d796cd874e563e5ac14
+ 9d5a6a9aa463d6d10b0b0ba6d5982cc82f363dc3
-
+ https://github.com/dotnet/runtime
- 5535e31a712343a63f5d7d796cd874e563e5ac14
+ 9d5a6a9aa463d6d10b0b0ba6d5982cc82f363dc3https://github.com/dotnet/runtime5535e31a712343a63f5d7d796cd874e563e5ac14
-
+ https://github.com/dotnet/runtime
- 5535e31a712343a63f5d7d796cd874e563e5ac14
+ 9d5a6a9aa463d6d10b0b0ba6d5982cc82f363dc3
-
+ https://github.com/dotnet/runtime
- 5535e31a712343a63f5d7d796cd874e563e5ac14
+ 9d5a6a9aa463d6d10b0b0ba6d5982cc82f363dc3
-
+ https://github.com/dotnet/runtime
- 5535e31a712343a63f5d7d796cd874e563e5ac14
+ 9d5a6a9aa463d6d10b0b0ba6d5982cc82f363dc3
-
+ https://github.com/dotnet/runtime
- 5535e31a712343a63f5d7d796cd874e563e5ac14
+ 9d5a6a9aa463d6d10b0b0ba6d5982cc82f363dc3
-
+ https://github.com/dotnet/runtime
- 5535e31a712343a63f5d7d796cd874e563e5ac14
+ 9d5a6a9aa463d6d10b0b0ba6d5982cc82f363dc3
-
+ https://github.com/dotnet/runtime
- 5535e31a712343a63f5d7d796cd874e563e5ac14
+ 9d5a6a9aa463d6d10b0b0ba6d5982cc82f363dc3
-
+ https://github.com/dotnet/runtime
- 5535e31a712343a63f5d7d796cd874e563e5ac14
+ 9d5a6a9aa463d6d10b0b0ba6d5982cc82f363dc3
-
+ https://github.com/dotnet/runtime
- 5535e31a712343a63f5d7d796cd874e563e5ac14
+ 9d5a6a9aa463d6d10b0b0ba6d5982cc82f363dc3
-
+ https://github.com/dotnet/runtime
- 5535e31a712343a63f5d7d796cd874e563e5ac14
+ 9d5a6a9aa463d6d10b0b0ba6d5982cc82f363dc3
-
+ https://github.com/dotnet/runtime
- 5535e31a712343a63f5d7d796cd874e563e5ac14
+ 9d5a6a9aa463d6d10b0b0ba6d5982cc82f363dc3
-
+ https://github.com/dotnet/runtime
- 5535e31a712343a63f5d7d796cd874e563e5ac14
+ 9d5a6a9aa463d6d10b0b0ba6d5982cc82f363dc3
-
+ https://github.com/dotnet/runtime
- 5535e31a712343a63f5d7d796cd874e563e5ac14
+ 9d5a6a9aa463d6d10b0b0ba6d5982cc82f363dc3
-
+ https://github.com/dotnet/runtime
- 5535e31a712343a63f5d7d796cd874e563e5ac14
+ 9d5a6a9aa463d6d10b0b0ba6d5982cc82f363dc3
-
+ https://github.com/dotnet/runtime
- 5535e31a712343a63f5d7d796cd874e563e5ac14
+ 9d5a6a9aa463d6d10b0b0ba6d5982cc82f363dc3
-
+ https://github.com/dotnet/runtime
- 5535e31a712343a63f5d7d796cd874e563e5ac14
+ 9d5a6a9aa463d6d10b0b0ba6d5982cc82f363dc3
-
+ https://github.com/dotnet/runtime
- 5535e31a712343a63f5d7d796cd874e563e5ac14
+ 9d5a6a9aa463d6d10b0b0ba6d5982cc82f363dc3
-
+ https://github.com/dotnet/runtime
- 5535e31a712343a63f5d7d796cd874e563e5ac14
+ 9d5a6a9aa463d6d10b0b0ba6d5982cc82f363dc3
-
+ https://github.com/dotnet/arcade
- 5da211e1c42254cb35e7ef3d5a8428fb24853169
+ 5ba9ca776c1d0bb72b2791591e54cf51fc52dfee
-
+ https://github.com/dotnet/arcade
- 5da211e1c42254cb35e7ef3d5a8428fb24853169
+ 5ba9ca776c1d0bb72b2791591e54cf51fc52dfee
-
+ https://github.com/dotnet/arcade
- 5da211e1c42254cb35e7ef3d5a8428fb24853169
+ 5ba9ca776c1d0bb72b2791591e54cf51fc52dfeehttps://github.com/dotnet/symreader
@@ -150,9 +155,9 @@
https://github.com/dotnet/roslyn5d10d428050c0d6afef30a072c4ae68776621877
-
+ https://github.com/dotnet/arcade
- 5da211e1c42254cb35e7ef3d5a8428fb24853169
+ 5ba9ca776c1d0bb72b2791591e54cf51fc52dfeehttps://github.com/dotnet/roslyn-analyzers
@@ -160,9 +165,9 @@
-
+ https://github.com/dotnet/runtime
- 5535e31a712343a63f5d7d796cd874e563e5ac14
+ 9d5a6a9aa463d6d10b0b0ba6d5982cc82f363dc3https://github.com/dotnet/roslyn-analyzers
diff --git a/eng/Versions.props b/eng/Versions.props
index e9301bb188b0b..3ff54c131b63b 100644
--- a/eng/Versions.props
+++ b/eng/Versions.props
@@ -8,7 +8,7 @@
4140
- 2
+ 3$(MajorVersion).$(MinorVersion).$(PatchVersion)
- 6.1.0
- 4.6.0
+ 6.1.2
+ 4.6.14.9.0
- 4.6.0
- 4.6.0
- 6.1.0
- 4.6.0
+ 4.6.2
+ 4.6.1
+ 6.1.1
+ 4.6.26.0.1
@@ -47,38 +47,38 @@
-->
2.0.0-beta4.24528.1
- 8.0.0
- 8.0.0
- 8.0.0
- 8.0.0
- 8.0.0
- 8.0.1
- 8.0.0
- 8.0.0
- 8.0.0
- 8.0.0
- 8.0.0
- 8.0.0
- 8.0.0
+ 9.0.0
+ 9.0.0
+ 9.0.0
+ 9.0.0
+ 9.0.0
+ 9.0.0
+ 9.0.0
+ 9.0.0
+ 9.0.0
+ 9.0.0
+ 9.0.0
+ 9.0.0
+ 9.0.0
- 8.0.5
- 8.0.0
- 8.0.0
- 8.0.0
+ 9.0.0
+ 9.0.0
+ 9.0.0
+ 9.0.03.11.03.3.08.0.0-preview.23468.12.0.0
- 8.0.0
- 8.0.0
+ 9.0.0
+ 9.0.08.0.0
- 8.0.0
- 8.0.0
- 8.0.0
+ 9.0.0
+ 9.0.0
+ 9.0.08.0.0
- 8.0.0
- 8.0.0
- 17.9.3137-preview3
+ 9.0.0
+ 9.0.0
+ 17.14.1043-preview22.4.1
+
+
+
+
+ 3.11.0
+ 1.2.1
+ 3.11.0
+ 3.11.0
+ 4.0.1
+ 3.11.0
+ 3.11.0
+ 3.11.0
+ 3.11.0
+ 4.0.1
+
+
+ 4.9.0-3.final
+ 4.6.0-1.final
+ truefalse
@@ -104,7 +157,7 @@
falsetrue
- true
+ true
+
+
+ $(MSBuildAllProjects);$(MSBuildThisFileFullPath)
+
+
+
+ $(IntermediateOutputPath)$(NuspecPackageId).nuspec
+ $(ArtifactsBinDir)
+ false
+ $(TargetFrameworks)
+ $(TargetFramework)
+
+
+
+
+ false
+ false
+ false
+ MIT
+
+
+
+ $(DotNetRoot)dotnet.exe
+ $(DotNetRoot)dotnet
+ \
+
+
+
+
+
+ <_GeneratedRulesetsDir>$(IntermediateOutputPath)Rulesets
+ <_GeneratedEditorconfigsDir>$(IntermediateOutputPath)Editorconfig
+ <_GeneratedGlobalAnalyzerConfigsDir>$(IntermediateOutputPath)GlobalAnalyzerConfigs
+ <_ValidateOffline Condition="'$(DotNetBuildSourceOnly)' == 'true' or '$(DotNetBuild)' == 'true'">true
+ <_ValidateOffline Condition="'$(_ValidateOffline)' == ''">false
+ false
+ true
+ true
+ true
+ true
+ true
+ true
+
+
+
+
+ true
+
+ false
+
+
+
+ false
+
+
+
+ $(IntermediateOutputPath)Build
+ $(NuspecPackageId).props
+
+
+
+
+
+
+ DisableNETAnalyzersForNuGetPackage.props
+
+
+
+
+
+
+ $(IntermediateOutputPath)Build
+ $(NuspecPackageId).targets
+
+
+
+ $(RepoRoot)src\RoslynAnalyzers\$(NuspecPackageId)
+ $(NuspecPackageId).md
+
+
+
+ $(RepoRoot)src\RoslynAnalyzers\$(NuspecPackageId)
+ $(NuspecPackageId).sarif
+
+
+
+ $(RepoRoot)docs\roslyn-analyzers
+ Analyzer Configuration.md
+
+
+
+
+ ForBrokenRuntime
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <_GenerateAnalyzerNuspecPath>$(ArtifactsBinDir)GenerateAnalyzerNuspec\$(Configuration)\$(NetRoslyn)\GenerateAnalyzerNuspec.dll
+
+
+
+
+
+
+
+
+
+
+
+ <_NuspecMetadata Include="version=$(PackageVersion)" />
+ <_NuspecMetadata Include="id=$(NuspecPackageId)" />
+ <_NuspecMetadata Include="authors=$(Authors)" />
+ <_NuspecMetadata Include="owners=$(Authors)" />
+ <_NuspecMetadata Include="requireLicenseAcceptance=$(PackageRequireLicenseAcceptance)" />
+ <_NuspecMetadata Include="description=$(Description)" />
+ <_NuspecMetadata Include="copyright=$(Copyright)" />
+ <_NuspecMetadata Include="license=$(PackageLicenseExpression)" />
+ <_NuspecMetadata Include="projectUrl=$(PackageProjectUrl)" />
+ <_NuspecMetadata Include="icon=$(PackageIcon)" />
+ <_NuspecMetadata Include="releaseNotes=$(PackageReleaseNotes)" />
+ <_NuspecMetadata Include="tags=$(PackageTags)" />
+ <_NuspecMetadata Include="serviceable=$(Serviceable)" />
+ <_NuspecMetadata Include="developmentDependency=$(DevelopmentDependency)" />
+ <_NuspecMetadata Include="repositoryType=$(RepositoryType)" />
+ <_NuspecMetadata Include="repositoryCommit=$(SourceRevisionId)" />
+ <_NuspecMetadata Include="repositoryUrl=$(PrivateRepositoryUrl)" />
+ <_NuspecMetadata Include="readme=$(PackageReadmeFile)" />
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/eng/targets/Imports.targets b/eng/targets/Imports.targets
index fdd6d2f8e4eaa..c646c49984d5d 100644
--- a/eng/targets/Imports.targets
+++ b/eng/targets/Imports.targets
@@ -4,7 +4,6 @@
- $(NoWarn);NU1507
+ $(NoWarn);RSEXPERIMENTAL005
+
CommonExtensionsMicrosoft\VBCSharp\LanguageServices
@@ -168,13 +171,6 @@
false
-
-
-
-
-
-
-
- $(CollectUpToDateCheckInputDesignTimeDependsOn);AddUpToDateCheckVSIXSourceItems
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/eng/targets/VisualStudio.targets b/eng/targets/VisualStudio.targets
index 93a24918b4da5..c8bd4122f585a 100644
--- a/eng/targets/VisualStudio.targets
+++ b/eng/targets/VisualStudio.targets
@@ -45,7 +45,7 @@
@@ -59,7 +59,7 @@
We join PackageReference list with ReferenceCopyLocalPaths items to get the list of dlls to include in the VSIX.
-->
- <_NuGetPackageToIncludeInVsix Include="@(PackageReference)" Condition="'%(PackageReference.IncludeInVsix)' == 'true' or '%(PackageReference.PkgDefEntry)' != ''"/>
+ <_NuGetPackageToIncludeInVsix Include="@(PackageReference)" Condition="'%(PackageReference.ForceIncludeInVsix)' == 'true' or '%(PackageReference.PkgDefEntry)' != ''"/>
<_RuntimeAssetsByPackageId Include="@(ReferenceCopyLocalPaths->'%(NuGetPackageId)')" Condition="%(ReferenceCopyLocalPaths.AssetType) == 'runtime'">
%(ReferenceCopyLocalPaths.Identity)
@@ -73,7 +73,7 @@
-
+ truetruetrue
@@ -86,7 +86,7 @@
- <_UnknownAssets Include="@(_NuGetPackageToIncludeInVsix)" Condition="'%(_NuGetPackageToIncludeInVsix.IncludeInVsix)' == 'true'" />
+ <_UnknownAssets Include="@(_NuGetPackageToIncludeInVsix)" Condition="'%(_NuGetPackageToIncludeInVsix.ForceIncludeInVsix)' == 'true'" />
<_UnknownAssets Remove="@(_RuntimeAssetsWithMetadata)" />
@@ -186,7 +186,7 @@
@@ -194,7 +194,7 @@
-
+
diff --git a/eng/targets/WpfWorkarounds.targets b/eng/targets/WpfWorkarounds.targets
deleted file mode 100644
index 4bc46a00f1ccb..0000000000000
--- a/eng/targets/WpfWorkarounds.targets
+++ /dev/null
@@ -1,12 +0,0 @@
-
-
-
-
-
-
- <_WindowsDesktopSDKDir>$(NuGetPackageRoot)microsoft.net.sdk.windowsdesktop\9.0.0-rc.1.24425.3\
- <_PresentationBuildTasksTfm Condition="'$(MSBuildRuntimeType)' == 'Core'">net9.0
- <_PresentationBuildTasksTfm Condition="'$(MSBuildRuntimeType)' != 'Core'">net472
- <_PresentationBuildTasksAssembly Condition="'$(_PresentationBuildTasksAssembly)'==''">$([MSBuild]::Unescape($([System.IO.Path]::GetFullPath('$(_WindowsDesktopSDKDir)tools\$(_PresentationBuildTasksTfm)\PresentationBuildTasks.dll'))))
-
-
\ No newline at end of file
diff --git a/eng/targets/XUnit.targets b/eng/targets/XUnit.targets
index d6f404fe5ad65..c516e0e27296a 100644
--- a/eng/targets/XUnit.targets
+++ b/eng/targets/XUnit.targets
@@ -19,12 +19,12 @@
-
+
diff --git a/eng/test-determinism.ps1 b/eng/test-determinism.ps1
index 3a16cef0b11b5..18ef2f3fb1df1 100644
--- a/eng/test-determinism.ps1
+++ b/eng/test-determinism.ps1
@@ -29,7 +29,10 @@ $script:skipList = @(
"Microsoft.CodeAnalysis.EditorFeatures2.UnitTests.dll",
# Work around XLF issues https://github.com/dotnet/roslyn/issues/58840
- "Roslyn.VisualStudio.DiagnosticsWindow.dll.key"
+ "Roslyn.VisualStudio.DiagnosticsWindow.dll.key",
+
+ # Work around resx issues https://github.com/dotnet/roslyn/issues/77544
+ "Text.Analyzers.dll.key"
)
function Run-Build([string]$rootDir, [string]$logFileName) {
diff --git a/eng/test-rebuild.ps1 b/eng/test-rebuild.ps1
index 74017ea313302..1401cb308e4c4 100644
--- a/eng/test-rebuild.ps1
+++ b/eng/test-rebuild.ps1
@@ -73,6 +73,7 @@ try {
# The assemblies are not marked with ReferenceAssemblyAttribute attribute.
" --exclude net8.0\GeneratedRefAssemblies\Microsoft.CodeAnalysis.dll" +
" --exclude net8.0\GeneratedRefAssemblies\Microsoft.CodeAnalysis.CSharp.dll" +
+ " --exclude net8.0\GeneratedRefAssemblies\System.Collections.Immutable.dll" +
" --debugPath `"$ArtifactsDir/BuildValidator`"" +
" --sourcePath `"$RepoRoot/`"" +
diff --git a/global.json b/global.json
index ef8ab9a2d7469..b094e3f86ce6c 100644
--- a/global.json
+++ b/global.json
@@ -1,18 +1,18 @@
{
"sdk": {
- "version": "9.0.103",
+ "version": "9.0.104",
"allowPrerelease": false,
"rollForward": "patch"
},
"tools": {
- "dotnet": "9.0.103",
+ "dotnet": "9.0.104",
"vs": {
"version": "17.8.0"
}
},
"msbuild-sdks": {
- "Microsoft.DotNet.Arcade.Sdk": "9.0.0-beta.25111.5",
- "Microsoft.DotNet.Helix.Sdk": "9.0.0-beta.25111.5",
+ "Microsoft.DotNet.Arcade.Sdk": "9.0.0-beta.25164.2",
+ "Microsoft.DotNet.Helix.Sdk": "9.0.0-beta.25164.2",
"Microsoft.Build.Traversal": "3.4.0"
}
}
diff --git a/src/Analyzers/CSharp/Analyzers/AddAccessibilityModifiers/CSharpAddAccessibilityModifiers.cs b/src/Analyzers/CSharp/Analyzers/AddAccessibilityModifiers/CSharpAddAccessibilityModifiers.cs
index 0e3b9dbb57afb..cc3aee619211d 100644
--- a/src/Analyzers/CSharp/Analyzers/AddAccessibilityModifiers/CSharpAddAccessibilityModifiers.cs
+++ b/src/Analyzers/CSharp/Analyzers/AddAccessibilityModifiers/CSharpAddAccessibilityModifiers.cs
@@ -8,7 +8,6 @@
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.LanguageService;
using Microsoft.CodeAnalysis.Shared.Extensions;
-using Roslyn.Utilities;
namespace Microsoft.CodeAnalysis.CSharp.AddOrRemoveAccessibilityModifiers;
diff --git a/src/Analyzers/CSharp/Analyzers/AddBraces/CSharpAddBracesDiagnosticAnalyzer.cs b/src/Analyzers/CSharp/Analyzers/AddBraces/CSharpAddBracesDiagnosticAnalyzer.cs
index f5abee1dd2a0c..34118b0e488ba 100644
--- a/src/Analyzers/CSharp/Analyzers/AddBraces/CSharpAddBracesDiagnosticAnalyzer.cs
+++ b/src/Analyzers/CSharp/Analyzers/AddBraces/CSharpAddBracesDiagnosticAnalyzer.cs
@@ -11,7 +11,6 @@
using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.CodeAnalysis.Shared.Extensions;
using Microsoft.CodeAnalysis.Text;
-using Roslyn.Utilities;
using FormattingRangeHelper = Microsoft.CodeAnalysis.CSharp.Utilities.FormattingRangeHelper;
namespace Microsoft.CodeAnalysis.CSharp.Diagnostics.AddBraces;
diff --git a/src/Analyzers/CSharp/Analyzers/AddRequiredParentheses/CSharpAddRequiredExpressionParenthesesDiagnosticAnalyzer.cs b/src/Analyzers/CSharp/Analyzers/AddRequiredParentheses/CSharpAddRequiredExpressionParenthesesDiagnosticAnalyzer.cs
index 4979dc2c8f9ea..ae50bf8ea186b 100644
--- a/src/Analyzers/CSharp/Analyzers/AddRequiredParentheses/CSharpAddRequiredExpressionParenthesesDiagnosticAnalyzer.cs
+++ b/src/Analyzers/CSharp/Analyzers/AddRequiredParentheses/CSharpAddRequiredExpressionParenthesesDiagnosticAnalyzer.cs
@@ -9,7 +9,6 @@
using Microsoft.CodeAnalysis.CSharp.Precedence;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.Diagnostics;
-using Roslyn.Utilities;
namespace Microsoft.CodeAnalysis.CSharp.AddRequiredParentheses;
diff --git a/src/Analyzers/CSharp/Analyzers/CSharpAnalyzersResources.resx b/src/Analyzers/CSharp/Analyzers/CSharpAnalyzersResources.resx
index 4ebe1d626a4ea..622002791820c 100644
--- a/src/Analyzers/CSharp/Analyzers/CSharpAnalyzersResources.resx
+++ b/src/Analyzers/CSharp/Analyzers/CSharpAnalyzersResources.resx
@@ -431,4 +431,7 @@
Use unbound generic type
+
+ Implement with Copilot
+
\ No newline at end of file
diff --git a/src/Analyzers/CSharp/Analyzers/ConvertNamespace/ConvertToBlockScopedNamespaceDiagnosticAnalyzer.cs b/src/Analyzers/CSharp/Analyzers/ConvertNamespace/ConvertToBlockScopedNamespaceDiagnosticAnalyzer.cs
index e4fbc30f17fee..7595c2653512b 100644
--- a/src/Analyzers/CSharp/Analyzers/ConvertNamespace/ConvertToBlockScopedNamespaceDiagnosticAnalyzer.cs
+++ b/src/Analyzers/CSharp/Analyzers/ConvertNamespace/ConvertToBlockScopedNamespaceDiagnosticAnalyzer.cs
@@ -7,7 +7,6 @@
using Microsoft.CodeAnalysis.CSharp.CodeStyle;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.Diagnostics;
-using Microsoft.CodeAnalysis.Options;
using Microsoft.CodeAnalysis.Text;
namespace Microsoft.CodeAnalysis.CSharp.ConvertNamespace;
diff --git a/src/Analyzers/CSharp/Analyzers/ConvertNamespace/ConvertToFileScopedNamespaceDiagnosticAnalyzer.cs b/src/Analyzers/CSharp/Analyzers/ConvertNamespace/ConvertToFileScopedNamespaceDiagnosticAnalyzer.cs
index 89eafd4a3148f..84096e2b2af3f 100644
--- a/src/Analyzers/CSharp/Analyzers/ConvertNamespace/ConvertToFileScopedNamespaceDiagnosticAnalyzer.cs
+++ b/src/Analyzers/CSharp/Analyzers/ConvertNamespace/ConvertToFileScopedNamespaceDiagnosticAnalyzer.cs
@@ -7,7 +7,6 @@
using Microsoft.CodeAnalysis.CSharp.CodeStyle;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.Diagnostics;
-using Microsoft.CodeAnalysis.Options;
using Microsoft.CodeAnalysis.Text;
namespace Microsoft.CodeAnalysis.CSharp.ConvertNamespace;
diff --git a/src/Analyzers/CSharp/Analyzers/ConvertSwitchStatementToExpression/ConvertSwitchStatementToExpressionDiagnosticAnalyzer.cs b/src/Analyzers/CSharp/Analyzers/ConvertSwitchStatementToExpression/ConvertSwitchStatementToExpressionDiagnosticAnalyzer.cs
index 67e5ccb33901f..0ed3abec8cc64 100644
--- a/src/Analyzers/CSharp/Analyzers/ConvertSwitchStatementToExpression/ConvertSwitchStatementToExpressionDiagnosticAnalyzer.cs
+++ b/src/Analyzers/CSharp/Analyzers/ConvertSwitchStatementToExpression/ConvertSwitchStatementToExpressionDiagnosticAnalyzer.cs
@@ -7,7 +7,6 @@
using System.Linq;
using Microsoft.CodeAnalysis.CodeStyle;
using Microsoft.CodeAnalysis.CSharp.CodeStyle;
-using Microsoft.CodeAnalysis.CSharp.Diagnostics;
using Microsoft.CodeAnalysis.CSharp.Extensions;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.Diagnostics;
diff --git a/src/Analyzers/CSharp/Analyzers/ConvertSwitchStatementToExpression/ConvertSwitchStatementToExpressionHelpers.cs b/src/Analyzers/CSharp/Analyzers/ConvertSwitchStatementToExpression/ConvertSwitchStatementToExpressionHelpers.cs
index 3a26494309d74..31dacb65a3c9c 100644
--- a/src/Analyzers/CSharp/Analyzers/ConvertSwitchStatementToExpression/ConvertSwitchStatementToExpressionHelpers.cs
+++ b/src/Analyzers/CSharp/Analyzers/ConvertSwitchStatementToExpression/ConvertSwitchStatementToExpressionHelpers.cs
@@ -2,7 +2,6 @@
// 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.Extensions;
using Microsoft.CodeAnalysis.CSharp.Syntax;
namespace Microsoft.CodeAnalysis.CSharp.ConvertSwitchStatementToExpression;
diff --git a/src/Analyzers/CSharp/Analyzers/ConvertTypeofToNameof/CSharpConvertTypeOfToNameOfDiagnosticAnalyzer.cs b/src/Analyzers/CSharp/Analyzers/ConvertTypeofToNameof/CSharpConvertTypeOfToNameOfDiagnosticAnalyzer.cs
index 8beb2a5c885fb..f8a82406481d4 100644
--- a/src/Analyzers/CSharp/Analyzers/ConvertTypeofToNameof/CSharpConvertTypeOfToNameOfDiagnosticAnalyzer.cs
+++ b/src/Analyzers/CSharp/Analyzers/ConvertTypeofToNameof/CSharpConvertTypeOfToNameOfDiagnosticAnalyzer.cs
@@ -4,7 +4,6 @@
using Microsoft.CodeAnalysis.ConvertTypeOfToNameOf;
using Microsoft.CodeAnalysis.CSharp.Extensions;
-using Microsoft.CodeAnalysis.CSharp.Shared.Extensions;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.Diagnostics;
diff --git a/src/Analyzers/CSharp/Analyzers/FileHeaders/CSharpFileHeaderHelper.cs b/src/Analyzers/CSharp/Analyzers/FileHeaders/CSharpFileHeaderHelper.cs
index b02038e02b62b..07731ad060358 100644
--- a/src/Analyzers/CSharp/Analyzers/FileHeaders/CSharpFileHeaderHelper.cs
+++ b/src/Analyzers/CSharp/Analyzers/FileHeaders/CSharpFileHeaderHelper.cs
@@ -5,7 +5,6 @@
using System;
using Microsoft.CodeAnalysis.CSharp.LanguageService;
using Microsoft.CodeAnalysis.FileHeaders;
-using Roslyn.Utilities;
namespace Microsoft.CodeAnalysis.CSharp.FileHeaders;
diff --git a/src/Analyzers/CSharp/Analyzers/InvokeDelegateWithConditionalAccess/InvokeDelegateWithConditionalAccessAnalyzer.cs b/src/Analyzers/CSharp/Analyzers/InvokeDelegateWithConditionalAccess/InvokeDelegateWithConditionalAccessAnalyzer.cs
index dc8321bd3ca71..8757ccf17a123 100644
--- a/src/Analyzers/CSharp/Analyzers/InvokeDelegateWithConditionalAccess/InvokeDelegateWithConditionalAccessAnalyzer.cs
+++ b/src/Analyzers/CSharp/Analyzers/InvokeDelegateWithConditionalAccess/InvokeDelegateWithConditionalAccessAnalyzer.cs
@@ -4,7 +4,6 @@
using System;
using System.Collections.Immutable;
-using System.Threading;
using Microsoft.CodeAnalysis.CodeStyle;
using Microsoft.CodeAnalysis.CSharp.CodeStyle;
using Microsoft.CodeAnalysis.CSharp.Extensions;
diff --git a/src/Analyzers/CSharp/Analyzers/MakeLocalFunctionStatic/MakeLocalFunctionStaticDiagnosticAnalyzer.cs b/src/Analyzers/CSharp/Analyzers/MakeLocalFunctionStatic/MakeLocalFunctionStaticDiagnosticAnalyzer.cs
index 745c105ea3e46..86eac8a5562e3 100644
--- a/src/Analyzers/CSharp/Analyzers/MakeLocalFunctionStatic/MakeLocalFunctionStaticDiagnosticAnalyzer.cs
+++ b/src/Analyzers/CSharp/Analyzers/MakeLocalFunctionStatic/MakeLocalFunctionStaticDiagnosticAnalyzer.cs
@@ -2,7 +2,6 @@
// 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 Microsoft.CodeAnalysis.CodeStyle;
using Microsoft.CodeAnalysis.CSharp.CodeStyle;
using Microsoft.CodeAnalysis.CSharp.Extensions;
diff --git a/src/Analyzers/CSharp/Analyzers/MakeStructFieldsWritable/CSharpMakeStructFieldsWritableDiagnosticAnalyzer.cs b/src/Analyzers/CSharp/Analyzers/MakeStructFieldsWritable/CSharpMakeStructFieldsWritableDiagnosticAnalyzer.cs
index d32f40f33f558..419164ef2831f 100644
--- a/src/Analyzers/CSharp/Analyzers/MakeStructFieldsWritable/CSharpMakeStructFieldsWritableDiagnosticAnalyzer.cs
+++ b/src/Analyzers/CSharp/Analyzers/MakeStructFieldsWritable/CSharpMakeStructFieldsWritableDiagnosticAnalyzer.cs
@@ -2,7 +2,6 @@
// 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.Linq;
using System.Threading;
using Microsoft.CodeAnalysis.CodeQuality;
diff --git a/src/Analyzers/CSharp/Analyzers/MakeStructMemberReadOnly/CSharpMakeStructMemberReadOnlyAnalyzer.cs b/src/Analyzers/CSharp/Analyzers/MakeStructMemberReadOnly/CSharpMakeStructMemberReadOnlyAnalyzer.cs
index cd8ed002775e4..e48b7cb79de81 100644
--- a/src/Analyzers/CSharp/Analyzers/MakeStructMemberReadOnly/CSharpMakeStructMemberReadOnlyAnalyzer.cs
+++ b/src/Analyzers/CSharp/Analyzers/MakeStructMemberReadOnly/CSharpMakeStructMemberReadOnlyAnalyzer.cs
@@ -4,9 +4,7 @@
using System;
using System.Collections.Generic;
-using System.Collections.Immutable;
using System.Diagnostics.CodeAnalysis;
-using System.Linq;
using System.Threading;
using Microsoft.CodeAnalysis.CodeStyle;
using Microsoft.CodeAnalysis.CSharp.CodeStyle;
diff --git a/src/Analyzers/CSharp/Analyzers/MakeStructReadOnly/CSharpMakeStructReadOnlyDiagnosticAnalyzer.cs b/src/Analyzers/CSharp/Analyzers/MakeStructReadOnly/CSharpMakeStructReadOnlyDiagnosticAnalyzer.cs
index 3d98b37a812ab..5196ad7362b29 100644
--- a/src/Analyzers/CSharp/Analyzers/MakeStructReadOnly/CSharpMakeStructReadOnlyDiagnosticAnalyzer.cs
+++ b/src/Analyzers/CSharp/Analyzers/MakeStructReadOnly/CSharpMakeStructReadOnlyDiagnosticAnalyzer.cs
@@ -2,7 +2,6 @@
// 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.CodeStyle;
using Microsoft.CodeAnalysis.CSharp.CodeStyle;
diff --git a/src/Analyzers/CSharp/Analyzers/NewLines/ConsecutiveBracePlacement/ConsecutiveBracePlacementDiagnosticAnalyzer.cs b/src/Analyzers/CSharp/Analyzers/NewLines/ConsecutiveBracePlacement/ConsecutiveBracePlacementDiagnosticAnalyzer.cs
index 82381f588feb8..7749d8ea7072a 100644
--- a/src/Analyzers/CSharp/Analyzers/NewLines/ConsecutiveBracePlacement/ConsecutiveBracePlacementDiagnosticAnalyzer.cs
+++ b/src/Analyzers/CSharp/Analyzers/NewLines/ConsecutiveBracePlacement/ConsecutiveBracePlacementDiagnosticAnalyzer.cs
@@ -6,7 +6,6 @@
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CodeStyle;
using Microsoft.CodeAnalysis.CSharp.CodeStyle;
-using Microsoft.CodeAnalysis.CSharp.Diagnostics;
using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.CodeAnalysis.PooledObjects;
using Microsoft.CodeAnalysis.Text;
diff --git a/src/Analyzers/CSharp/Analyzers/NewLines/ConstructorInitializerPlacement/ConstructorInitializerPlacementDiagnosticAnalyzer.cs b/src/Analyzers/CSharp/Analyzers/NewLines/ConstructorInitializerPlacement/ConstructorInitializerPlacementDiagnosticAnalyzer.cs
index 28d61950d84f8..b13ead044f34e 100644
--- a/src/Analyzers/CSharp/Analyzers/NewLines/ConstructorInitializerPlacement/ConstructorInitializerPlacementDiagnosticAnalyzer.cs
+++ b/src/Analyzers/CSharp/Analyzers/NewLines/ConstructorInitializerPlacement/ConstructorInitializerPlacementDiagnosticAnalyzer.cs
@@ -2,7 +2,6 @@
// 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.Linq;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CodeStyle;
diff --git a/src/Analyzers/CSharp/Analyzers/OrderModifiers/CSharpOrderModifiersDiagnosticAnalyzer.cs b/src/Analyzers/CSharp/Analyzers/OrderModifiers/CSharpOrderModifiersDiagnosticAnalyzer.cs
index b4220b4071083..da2fc052e794e 100644
--- a/src/Analyzers/CSharp/Analyzers/OrderModifiers/CSharpOrderModifiersDiagnosticAnalyzer.cs
+++ b/src/Analyzers/CSharp/Analyzers/OrderModifiers/CSharpOrderModifiersDiagnosticAnalyzer.cs
@@ -5,7 +5,6 @@
using System.Collections.Generic;
using Microsoft.CodeAnalysis.CodeStyle;
using Microsoft.CodeAnalysis.CSharp.CodeStyle;
-using Microsoft.CodeAnalysis.CSharp.Diagnostics;
using Microsoft.CodeAnalysis.CSharp.LanguageService;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.Diagnostics;
diff --git a/src/Analyzers/CSharp/Analyzers/RemoveConfusingSuppression/CSharpRemoveConfusingSuppressionDiagnosticAnalyzer.cs b/src/Analyzers/CSharp/Analyzers/RemoveConfusingSuppression/CSharpRemoveConfusingSuppressionDiagnosticAnalyzer.cs
index 9fa30811f8c11..ceff4a71942d0 100644
--- a/src/Analyzers/CSharp/Analyzers/RemoveConfusingSuppression/CSharpRemoveConfusingSuppressionDiagnosticAnalyzer.cs
+++ b/src/Analyzers/CSharp/Analyzers/RemoveConfusingSuppression/CSharpRemoveConfusingSuppressionDiagnosticAnalyzer.cs
@@ -2,11 +2,9 @@
// 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 Microsoft.CodeAnalysis.CodeStyle;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.Diagnostics;
-using Roslyn.Utilities;
namespace Microsoft.CodeAnalysis.CSharp.RemoveConfusingSuppression;
diff --git a/src/Analyzers/CSharp/Analyzers/RemoveUnnecessaryCast/CSharpRemoveUnnecessaryCastDiagnosticAnalyzer.cs b/src/Analyzers/CSharp/Analyzers/RemoveUnnecessaryCast/CSharpRemoveUnnecessaryCastDiagnosticAnalyzer.cs
index a313c1d8a5d35..f4f616f2f1e07 100644
--- a/src/Analyzers/CSharp/Analyzers/RemoveUnnecessaryCast/CSharpRemoveUnnecessaryCastDiagnosticAnalyzer.cs
+++ b/src/Analyzers/CSharp/Analyzers/RemoveUnnecessaryCast/CSharpRemoveUnnecessaryCastDiagnosticAnalyzer.cs
@@ -9,7 +9,6 @@
using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.CodeAnalysis.RemoveUnnecessaryCast;
using Microsoft.CodeAnalysis.Text;
-using Roslyn.Utilities;
namespace Microsoft.CodeAnalysis.CSharp.RemoveUnnecessaryCast;
diff --git a/src/Analyzers/CSharp/Analyzers/RemoveUnnecessaryNullableDirective/CSharpRemoveRedundantNullableDirectiveDiagnosticAnalyzer.cs b/src/Analyzers/CSharp/Analyzers/RemoveUnnecessaryNullableDirective/CSharpRemoveRedundantNullableDirectiveDiagnosticAnalyzer.cs
index f1ed887255e6a..01f60a7845fc8 100644
--- a/src/Analyzers/CSharp/Analyzers/RemoveUnnecessaryNullableDirective/CSharpRemoveRedundantNullableDirectiveDiagnosticAnalyzer.cs
+++ b/src/Analyzers/CSharp/Analyzers/RemoveUnnecessaryNullableDirective/CSharpRemoveRedundantNullableDirectiveDiagnosticAnalyzer.cs
@@ -2,7 +2,6 @@
// 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;
using System.Collections.Generic;
using Microsoft.CodeAnalysis.CodeStyle;
using Microsoft.CodeAnalysis.CSharp.LanguageService;
diff --git a/src/Analyzers/CSharp/Analyzers/RemoveUnnecessaryNullableDirective/CSharpRemoveUnnecessaryNullableDirectiveDiagnosticAnalyzer.cs b/src/Analyzers/CSharp/Analyzers/RemoveUnnecessaryNullableDirective/CSharpRemoveUnnecessaryNullableDirectiveDiagnosticAnalyzer.cs
index 2b51deb885fd6..f2db2bf4e7ad5 100644
--- a/src/Analyzers/CSharp/Analyzers/RemoveUnnecessaryNullableDirective/CSharpRemoveUnnecessaryNullableDirectiveDiagnosticAnalyzer.cs
+++ b/src/Analyzers/CSharp/Analyzers/RemoveUnnecessaryNullableDirective/CSharpRemoveUnnecessaryNullableDirectiveDiagnosticAnalyzer.cs
@@ -2,7 +2,6 @@
// 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;
using System.Collections.Concurrent;
using System.Collections.Immutable;
using System.Diagnostics.CodeAnalysis;
diff --git a/src/Analyzers/CSharp/Analyzers/RemoveUnreachableCode/RemoveUnreachableCodeHelpers.cs b/src/Analyzers/CSharp/Analyzers/RemoveUnreachableCode/RemoveUnreachableCodeHelpers.cs
index deb1fb1dbc378..e68dc53df57db 100644
--- a/src/Analyzers/CSharp/Analyzers/RemoveUnreachableCode/RemoveUnreachableCodeHelpers.cs
+++ b/src/Analyzers/CSharp/Analyzers/RemoveUnreachableCode/RemoveUnreachableCodeHelpers.cs
@@ -2,9 +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;
using System.Collections.Immutable;
-using System.Linq;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.PooledObjects;
diff --git a/src/Analyzers/CSharp/Analyzers/SimplifyPropertyPattern/CSharpSimplifyPropertyPatternDiagnosticAnalyzer.cs b/src/Analyzers/CSharp/Analyzers/SimplifyPropertyPattern/CSharpSimplifyPropertyPatternDiagnosticAnalyzer.cs
index a38d9870c2d2d..3cd17d794b3e7 100644
--- a/src/Analyzers/CSharp/Analyzers/SimplifyPropertyPattern/CSharpSimplifyPropertyPatternDiagnosticAnalyzer.cs
+++ b/src/Analyzers/CSharp/Analyzers/SimplifyPropertyPattern/CSharpSimplifyPropertyPatternDiagnosticAnalyzer.cs
@@ -2,7 +2,6 @@
// 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 Microsoft.CodeAnalysis.CodeStyle;
using Microsoft.CodeAnalysis.CSharp.CodeStyle;
using Microsoft.CodeAnalysis.CSharp.Extensions;
diff --git a/src/Analyzers/CSharp/Analyzers/SimplifyPropertyPattern/SimplifyPropertyPatternHelpers.cs b/src/Analyzers/CSharp/Analyzers/SimplifyPropertyPattern/SimplifyPropertyPatternHelpers.cs
index 02ebe5f6963b3..369af480ac10d 100644
--- a/src/Analyzers/CSharp/Analyzers/SimplifyPropertyPattern/SimplifyPropertyPatternHelpers.cs
+++ b/src/Analyzers/CSharp/Analyzers/SimplifyPropertyPattern/SimplifyPropertyPatternHelpers.cs
@@ -2,7 +2,6 @@
// 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;
using System.Diagnostics.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp.Syntax;
diff --git a/src/Analyzers/CSharp/Analyzers/UseAutoProperty/CSharpUseAutoPropertyAnalyzer.cs b/src/Analyzers/CSharp/Analyzers/UseAutoProperty/CSharpUseAutoPropertyAnalyzer.cs
index ea3ff1d9974e4..614c3841f23fd 100644
--- a/src/Analyzers/CSharp/Analyzers/UseAutoProperty/CSharpUseAutoPropertyAnalyzer.cs
+++ b/src/Analyzers/CSharp/Analyzers/UseAutoProperty/CSharpUseAutoPropertyAnalyzer.cs
@@ -8,7 +8,6 @@
using System.Linq;
using System.Threading;
using Microsoft.CodeAnalysis.CSharp.Extensions;
-using Microsoft.CodeAnalysis.CSharp.Shared.Extensions;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.CodeAnalysis.Shared.Extensions;
diff --git a/src/Analyzers/CSharp/Analyzers/UseCollectionExpression/CSharpUseCollectionExpressionForCreateDiagnosticAnalyzer.cs b/src/Analyzers/CSharp/Analyzers/UseCollectionExpression/CSharpUseCollectionExpressionForCreateDiagnosticAnalyzer.cs
index 8ce1cd87c339a..e238eba97b3ed 100644
--- a/src/Analyzers/CSharp/Analyzers/UseCollectionExpression/CSharpUseCollectionExpressionForCreateDiagnosticAnalyzer.cs
+++ b/src/Analyzers/CSharp/Analyzers/UseCollectionExpression/CSharpUseCollectionExpressionForCreateDiagnosticAnalyzer.cs
@@ -8,7 +8,6 @@
using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.CodeAnalysis.Shared.CodeStyle;
using Microsoft.CodeAnalysis.Text;
-using Microsoft.CodeAnalysis.UseCollectionInitializer;
namespace Microsoft.CodeAnalysis.CSharp.UseCollectionExpression;
diff --git a/src/Analyzers/CSharp/Analyzers/UseCollectionExpression/CSharpUseCollectionExpressionForEmptyDiagnosticAnalyzer.cs b/src/Analyzers/CSharp/Analyzers/UseCollectionExpression/CSharpUseCollectionExpressionForEmptyDiagnosticAnalyzer.cs
index a1e87aac06ea7..161ac829c1d07 100644
--- a/src/Analyzers/CSharp/Analyzers/UseCollectionExpression/CSharpUseCollectionExpressionForEmptyDiagnosticAnalyzer.cs
+++ b/src/Analyzers/CSharp/Analyzers/UseCollectionExpression/CSharpUseCollectionExpressionForEmptyDiagnosticAnalyzer.cs
@@ -2,7 +2,6 @@
// 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 Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.CodeAnalysis.Shared.CodeStyle;
diff --git a/src/Analyzers/CSharp/Analyzers/UseCollectionExpression/CSharpUseCollectionExpressionForNewDiagnosticAnalyzer.cs b/src/Analyzers/CSharp/Analyzers/UseCollectionExpression/CSharpUseCollectionExpressionForNewDiagnosticAnalyzer.cs
index 32cab2512c9eb..24db63134a0ba 100644
--- a/src/Analyzers/CSharp/Analyzers/UseCollectionExpression/CSharpUseCollectionExpressionForNewDiagnosticAnalyzer.cs
+++ b/src/Analyzers/CSharp/Analyzers/UseCollectionExpression/CSharpUseCollectionExpressionForNewDiagnosticAnalyzer.cs
@@ -12,7 +12,6 @@
using Microsoft.CodeAnalysis.Shared.CodeStyle;
using Microsoft.CodeAnalysis.Shared.Extensions;
using Microsoft.CodeAnalysis.Text;
-using Microsoft.CodeAnalysis.UseCollectionInitializer;
namespace Microsoft.CodeAnalysis.CSharp.UseCollectionExpression;
diff --git a/src/Analyzers/CSharp/Analyzers/UseCollectionInitializer/CSharpUseCollectionInitializerAnalyzer.cs b/src/Analyzers/CSharp/Analyzers/UseCollectionInitializer/CSharpUseCollectionInitializerAnalyzer.cs
index fabc39b46613b..6a93604eb7369 100644
--- a/src/Analyzers/CSharp/Analyzers/UseCollectionInitializer/CSharpUseCollectionInitializerAnalyzer.cs
+++ b/src/Analyzers/CSharp/Analyzers/UseCollectionInitializer/CSharpUseCollectionInitializerAnalyzer.cs
@@ -48,8 +48,11 @@ protected override bool HasExistingInvalidInitializerForCollection()
protected override bool AnalyzeMatchesAndCollectionConstructorForCollectionExpression(
ArrayBuilder> preMatches,
ArrayBuilder> postMatches,
+ out bool mayChangeSemantics,
CancellationToken cancellationToken)
{
+ mayChangeSemantics = false;
+
// Constructor wasn't called with any arguments. Nothing to validate.
var argumentList = _objectCreationExpression.ArgumentList;
if (argumentList is null || argumentList.Arguments.Count == 0)
@@ -63,20 +66,21 @@ protected override bool AnalyzeMatchesAndCollectionConstructorForCollectionExpre
if (this.SemanticModel.GetSymbolInfo(_objectCreationExpression, cancellationToken).Symbol is not IMethodSymbol
{
MethodKind: MethodKind.Constructor,
- Parameters.Length: 1,
+ Parameters: [var firstParameter],
} constructor)
{
return false;
}
- var ienumerableOfTType = this.SemanticModel.Compilation.IEnumerableOfTType();
- var firstParameter = constructor.Parameters[0];
- if (Equals(firstParameter.Type.OriginalDefinition, ienumerableOfTType) ||
- firstParameter.Type.AllInterfaces.Any(i => Equals(i.OriginalDefinition, ienumerableOfTType)))
+ if (CanSpreadFirstParameter(constructor.ContainingType, firstParameter))
{
// Took a single argument that implements IEnumerable. We handle this by spreading that argument as the
// first thing added to the collection.
preMatches.Add(new(argumentList.Arguments[0].Expression, UseSpread: true));
+
+ // Can't be certain that spreading the elements will be the same as passing to the constructor. So pass
+ // that uncertainty up to the caller so they can inform the user.
+ mayChangeSemantics = true;
return true;
}
else if (firstParameter is { Type.SpecialType: SpecialType.System_Int32, Name: "capacity" })
@@ -195,5 +199,36 @@ protected override bool AnalyzeMatchesAndCollectionConstructorForCollectionExpre
}
return false;
+
+ bool CanSpreadFirstParameter(INamedTypeSymbol constructedType, IParameterSymbol firstParameter)
+ {
+ var compilation = this.SemanticModel.Compilation;
+
+ var ienumerableOfTType = compilation.IEnumerableOfTType();
+ if (!Equals(firstParameter.Type.OriginalDefinition, ienumerableOfTType) &&
+ !firstParameter.Type.AllInterfaces.Any(i => Equals(i.OriginalDefinition, ienumerableOfTType)))
+ {
+ 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
+ // wrong and we can't do this.
+
+ // BlockingCollection and Collection both take ownership of the collection passed to them. So adds to
+ // them will add through to the original collection. They do not take the original collection and add their
+ // elements to itself.
+
+ var collectionType = compilation.CollectionOfTType();
+ var blockingCollectionType = compilation.BlockingCollectionOfTType();
+ if (constructedType.GetBaseTypesAndThis().Any(
+ t => Equals(collectionType, t.OriginalDefinition) ||
+ Equals(blockingCollectionType, t.OriginalDefinition)))
+ {
+ return false;
+ }
+
+ return true;
+ }
}
}
diff --git a/src/Analyzers/CSharp/Analyzers/UseCompoundAssignment/CSharpUseCompoundCoalesceAssignmentDiagnosticAnalyzer.cs b/src/Analyzers/CSharp/Analyzers/UseCompoundAssignment/CSharpUseCompoundCoalesceAssignmentDiagnosticAnalyzer.cs
index 11a7bc2ca3928..3d39d9fb1637e 100644
--- a/src/Analyzers/CSharp/Analyzers/UseCompoundAssignment/CSharpUseCompoundCoalesceAssignmentDiagnosticAnalyzer.cs
+++ b/src/Analyzers/CSharp/Analyzers/UseCompoundAssignment/CSharpUseCompoundCoalesceAssignmentDiagnosticAnalyzer.cs
@@ -3,7 +3,6 @@
// See the LICENSE file in the project root for more information.
using System;
-using System.Collections.Immutable;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Threading;
diff --git a/src/Analyzers/CSharp/Analyzers/UseCompoundAssignment/Utilities.cs b/src/Analyzers/CSharp/Analyzers/UseCompoundAssignment/Utilities.cs
index 3a2bed7c95e77..e9607afdd5ef0 100644
--- a/src/Analyzers/CSharp/Analyzers/UseCompoundAssignment/Utilities.cs
+++ b/src/Analyzers/CSharp/Analyzers/UseCompoundAssignment/Utilities.cs
@@ -3,7 +3,6 @@
// See the LICENSE file in the project root for more information.
using System.Collections.Immutable;
-using Roslyn.Utilities;
namespace Microsoft.CodeAnalysis.CSharp.UseCompoundAssignment;
diff --git a/src/Analyzers/CSharp/Analyzers/UseDefaultLiteral/CSharpUseDefaultLiteralDiagnosticAnalyzer.cs b/src/Analyzers/CSharp/Analyzers/UseDefaultLiteral/CSharpUseDefaultLiteralDiagnosticAnalyzer.cs
index ecc03d73a3d9f..4cf5a40ab9c57 100644
--- a/src/Analyzers/CSharp/Analyzers/UseDefaultLiteral/CSharpUseDefaultLiteralDiagnosticAnalyzer.cs
+++ b/src/Analyzers/CSharp/Analyzers/UseDefaultLiteral/CSharpUseDefaultLiteralDiagnosticAnalyzer.cs
@@ -2,7 +2,6 @@
// 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 Microsoft.CodeAnalysis.CodeStyle;
using Microsoft.CodeAnalysis.CSharp.CodeStyle;
using Microsoft.CodeAnalysis.CSharp.Extensions;
diff --git a/src/Analyzers/CSharp/Analyzers/UseExpressionBody/Helpers/UseExpressionBodyForAccessorsHelper.cs b/src/Analyzers/CSharp/Analyzers/UseExpressionBody/Helpers/UseExpressionBodyForAccessorsHelper.cs
index 7e7dbaa7c19de..1e5c0660e3aba 100644
--- a/src/Analyzers/CSharp/Analyzers/UseExpressionBody/Helpers/UseExpressionBodyForAccessorsHelper.cs
+++ b/src/Analyzers/CSharp/Analyzers/UseExpressionBody/Helpers/UseExpressionBodyForAccessorsHelper.cs
@@ -2,7 +2,6 @@
// 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.Linq;
using Microsoft.CodeAnalysis.CodeStyle;
using Microsoft.CodeAnalysis.CSharp.CodeGeneration;
diff --git a/src/Analyzers/CSharp/Analyzers/UseExpressionBody/Helpers/UseExpressionBodyForConstructorsHelper.cs b/src/Analyzers/CSharp/Analyzers/UseExpressionBody/Helpers/UseExpressionBodyForConstructorsHelper.cs
index cedba7091590f..31b42df2a7e65 100644
--- a/src/Analyzers/CSharp/Analyzers/UseExpressionBody/Helpers/UseExpressionBodyForConstructorsHelper.cs
+++ b/src/Analyzers/CSharp/Analyzers/UseExpressionBody/Helpers/UseExpressionBodyForConstructorsHelper.cs
@@ -2,7 +2,6 @@
// 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 Microsoft.CodeAnalysis.CodeStyle;
using Microsoft.CodeAnalysis.CSharp.CodeGeneration;
using Microsoft.CodeAnalysis.CSharp.CodeStyle;
diff --git a/src/Analyzers/CSharp/Analyzers/UseExpressionBody/Helpers/UseExpressionBodyForConversionOperatorsHelper.cs b/src/Analyzers/CSharp/Analyzers/UseExpressionBody/Helpers/UseExpressionBodyForConversionOperatorsHelper.cs
index d963bbcd567ec..1278c59a1d3e2 100644
--- a/src/Analyzers/CSharp/Analyzers/UseExpressionBody/Helpers/UseExpressionBodyForConversionOperatorsHelper.cs
+++ b/src/Analyzers/CSharp/Analyzers/UseExpressionBody/Helpers/UseExpressionBodyForConversionOperatorsHelper.cs
@@ -2,7 +2,6 @@
// 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 Microsoft.CodeAnalysis.CodeStyle;
using Microsoft.CodeAnalysis.CSharp.CodeGeneration;
using Microsoft.CodeAnalysis.CSharp.CodeStyle;
diff --git a/src/Analyzers/CSharp/Analyzers/UseExpressionBody/Helpers/UseExpressionBodyForIndexersHelper.cs b/src/Analyzers/CSharp/Analyzers/UseExpressionBody/Helpers/UseExpressionBodyForIndexersHelper.cs
index 1037084de70a6..2f51fcf2a6579 100644
--- a/src/Analyzers/CSharp/Analyzers/UseExpressionBody/Helpers/UseExpressionBodyForIndexersHelper.cs
+++ b/src/Analyzers/CSharp/Analyzers/UseExpressionBody/Helpers/UseExpressionBodyForIndexersHelper.cs
@@ -5,7 +5,6 @@
#nullable disable
using System;
-using System.Collections.Immutable;
using System.Threading;
using Microsoft.CodeAnalysis.CodeStyle;
using Microsoft.CodeAnalysis.CSharp.CodeGeneration;
diff --git a/src/Analyzers/CSharp/Analyzers/UseExpressionBody/Helpers/UseExpressionBodyForLocalFunctionHelper.cs b/src/Analyzers/CSharp/Analyzers/UseExpressionBody/Helpers/UseExpressionBodyForLocalFunctionHelper.cs
index d09df06b807fb..c6f9a78066f71 100644
--- a/src/Analyzers/CSharp/Analyzers/UseExpressionBody/Helpers/UseExpressionBodyForLocalFunctionHelper.cs
+++ b/src/Analyzers/CSharp/Analyzers/UseExpressionBody/Helpers/UseExpressionBodyForLocalFunctionHelper.cs
@@ -4,7 +4,6 @@
#nullable disable
-using System.Collections.Immutable;
using Microsoft.CodeAnalysis.CodeStyle;
using Microsoft.CodeAnalysis.CSharp.CodeGeneration;
using Microsoft.CodeAnalysis.CSharp.CodeStyle;
diff --git a/src/Analyzers/CSharp/Analyzers/UseExpressionBody/Helpers/UseExpressionBodyForMethodsHelper.cs b/src/Analyzers/CSharp/Analyzers/UseExpressionBody/Helpers/UseExpressionBodyForMethodsHelper.cs
index f7b57bc77ca5a..d05bc5bfb5231 100644
--- a/src/Analyzers/CSharp/Analyzers/UseExpressionBody/Helpers/UseExpressionBodyForMethodsHelper.cs
+++ b/src/Analyzers/CSharp/Analyzers/UseExpressionBody/Helpers/UseExpressionBodyForMethodsHelper.cs
@@ -4,7 +4,6 @@
#nullable disable
-using System.Collections.Immutable;
using Microsoft.CodeAnalysis.CodeStyle;
using Microsoft.CodeAnalysis.CSharp.CodeGeneration;
using Microsoft.CodeAnalysis.CSharp.CodeStyle;
diff --git a/src/Analyzers/CSharp/Analyzers/UseExpressionBody/Helpers/UseExpressionBodyForOperatorsHelper.cs b/src/Analyzers/CSharp/Analyzers/UseExpressionBody/Helpers/UseExpressionBodyForOperatorsHelper.cs
index dd75fabe5d456..5965c35c1d8ba 100644
--- a/src/Analyzers/CSharp/Analyzers/UseExpressionBody/Helpers/UseExpressionBodyForOperatorsHelper.cs
+++ b/src/Analyzers/CSharp/Analyzers/UseExpressionBody/Helpers/UseExpressionBodyForOperatorsHelper.cs
@@ -4,7 +4,6 @@
#nullable disable
-using System.Collections.Immutable;
using Microsoft.CodeAnalysis.CodeStyle;
using Microsoft.CodeAnalysis.CSharp.CodeGeneration;
using Microsoft.CodeAnalysis.CSharp.CodeStyle;
diff --git a/src/Analyzers/CSharp/Analyzers/UseExpressionBody/Helpers/UseExpressionBodyForPropertiesHelper.cs b/src/Analyzers/CSharp/Analyzers/UseExpressionBody/Helpers/UseExpressionBodyForPropertiesHelper.cs
index 5681617779e31..7d6679ca5135c 100644
--- a/src/Analyzers/CSharp/Analyzers/UseExpressionBody/Helpers/UseExpressionBodyForPropertiesHelper.cs
+++ b/src/Analyzers/CSharp/Analyzers/UseExpressionBody/Helpers/UseExpressionBodyForPropertiesHelper.cs
@@ -5,7 +5,6 @@
#nullable disable
using System;
-using System.Collections.Immutable;
using System.Threading;
using Microsoft.CodeAnalysis.CodeStyle;
using Microsoft.CodeAnalysis.CSharp.CodeGeneration;
diff --git a/src/Analyzers/CSharp/Analyzers/UseImplicitObjectCreation/CSharpUseImplicitObjectCreationDiagnosticAnalyzer.cs b/src/Analyzers/CSharp/Analyzers/UseImplicitObjectCreation/CSharpUseImplicitObjectCreationDiagnosticAnalyzer.cs
index 418df4bc955ee..cb74292d302d9 100644
--- a/src/Analyzers/CSharp/Analyzers/UseImplicitObjectCreation/CSharpUseImplicitObjectCreationDiagnosticAnalyzer.cs
+++ b/src/Analyzers/CSharp/Analyzers/UseImplicitObjectCreation/CSharpUseImplicitObjectCreationDiagnosticAnalyzer.cs
@@ -2,7 +2,6 @@
// 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.Threading;
using Microsoft.CodeAnalysis.CodeStyle;
using Microsoft.CodeAnalysis.CSharp.CodeStyle;
diff --git a/src/Analyzers/CSharp/Analyzers/UseImplicitlyTypedLambdaExpression/CSharpUseImplicitlyTypedLambdaExpressionDiagnosticAnalyzer.cs b/src/Analyzers/CSharp/Analyzers/UseImplicitlyTypedLambdaExpression/CSharpUseImplicitlyTypedLambdaExpressionDiagnosticAnalyzer.cs
index 747bd949e2fca..69b85a660d257 100644
--- a/src/Analyzers/CSharp/Analyzers/UseImplicitlyTypedLambdaExpression/CSharpUseImplicitlyTypedLambdaExpressionDiagnosticAnalyzer.cs
+++ b/src/Analyzers/CSharp/Analyzers/UseImplicitlyTypedLambdaExpression/CSharpUseImplicitlyTypedLambdaExpressionDiagnosticAnalyzer.cs
@@ -2,7 +2,6 @@
// 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;
using System.Linq;
using System.Threading;
using Microsoft.CodeAnalysis.CodeStyle;
@@ -12,7 +11,6 @@
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.CSharp.Utilities;
using Microsoft.CodeAnalysis.Diagnostics;
-using Microsoft.CodeAnalysis.Operations;
using Microsoft.CodeAnalysis.Shared.Extensions;
using Microsoft.CodeAnalysis.Shared.Utilities;
diff --git a/src/Analyzers/CSharp/Analyzers/UseIndexOrRangeOperator/CSharpUseIndexOperatorDiagnosticAnalyzer.cs b/src/Analyzers/CSharp/Analyzers/UseIndexOrRangeOperator/CSharpUseIndexOperatorDiagnosticAnalyzer.cs
index 3999c3accfdc2..def0b366e6230 100644
--- a/src/Analyzers/CSharp/Analyzers/UseIndexOrRangeOperator/CSharpUseIndexOperatorDiagnosticAnalyzer.cs
+++ b/src/Analyzers/CSharp/Analyzers/UseIndexOrRangeOperator/CSharpUseIndexOperatorDiagnosticAnalyzer.cs
@@ -11,7 +11,6 @@
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.CodeAnalysis.Operations;
-using Roslyn.Utilities;
namespace Microsoft.CodeAnalysis.CSharp.UseIndexOrRangeOperator;
diff --git a/src/Analyzers/CSharp/Analyzers/UseIndexOrRangeOperator/CSharpUseRangeOperatorDiagnosticAnalyzer.Result.cs b/src/Analyzers/CSharp/Analyzers/UseIndexOrRangeOperator/CSharpUseRangeOperatorDiagnosticAnalyzer.Result.cs
index 7c9fd695c5004..9843f50846533 100644
--- a/src/Analyzers/CSharp/Analyzers/UseIndexOrRangeOperator/CSharpUseRangeOperatorDiagnosticAnalyzer.Result.cs
+++ b/src/Analyzers/CSharp/Analyzers/UseIndexOrRangeOperator/CSharpUseRangeOperatorDiagnosticAnalyzer.Result.cs
@@ -2,7 +2,6 @@
// 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.CodeStyle;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.Operations;
diff --git a/src/Analyzers/CSharp/Analyzers/UseIndexOrRangeOperator/CSharpUseRangeOperatorDiagnosticAnalyzer.cs b/src/Analyzers/CSharp/Analyzers/UseIndexOrRangeOperator/CSharpUseRangeOperatorDiagnosticAnalyzer.cs
index 71d9f11c5ccda..f6bfbb9944301 100644
--- a/src/Analyzers/CSharp/Analyzers/UseIndexOrRangeOperator/CSharpUseRangeOperatorDiagnosticAnalyzer.cs
+++ b/src/Analyzers/CSharp/Analyzers/UseIndexOrRangeOperator/CSharpUseRangeOperatorDiagnosticAnalyzer.cs
@@ -13,7 +13,6 @@
using Microsoft.CodeAnalysis.Operations;
using Microsoft.CodeAnalysis.Shared.Extensions;
using Microsoft.CodeAnalysis.Text;
-using Roslyn.Utilities;
namespace Microsoft.CodeAnalysis.CSharp.UseIndexOrRangeOperator;
diff --git a/src/Analyzers/CSharp/Analyzers/UseInferredMemberName/CSharpUseInferredMemberNameDiagnosticAnalyzer.cs b/src/Analyzers/CSharp/Analyzers/UseInferredMemberName/CSharpUseInferredMemberNameDiagnosticAnalyzer.cs
index 6750377d7e3e8..40a6644d602ec 100644
--- a/src/Analyzers/CSharp/Analyzers/UseInferredMemberName/CSharpUseInferredMemberNameDiagnosticAnalyzer.cs
+++ b/src/Analyzers/CSharp/Analyzers/UseInferredMemberName/CSharpUseInferredMemberNameDiagnosticAnalyzer.cs
@@ -2,16 +2,11 @@
// 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.Threading;
-using Microsoft.CodeAnalysis.CodeStyle;
-using Microsoft.CodeAnalysis.CSharp.Extensions;
using Microsoft.CodeAnalysis.CSharp.Simplification;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.CodeAnalysis.Text;
using Microsoft.CodeAnalysis.UseInferredMemberName;
-using Roslyn.Utilities;
namespace Microsoft.CodeAnalysis.CSharp.UseInferredMemberName;
diff --git a/src/Analyzers/CSharp/Analyzers/UseIsNullCheck/CSharpUseNullCheckOverTypeCheckDiagnosticAnalyzer.cs b/src/Analyzers/CSharp/Analyzers/UseIsNullCheck/CSharpUseNullCheckOverTypeCheckDiagnosticAnalyzer.cs
index ca11e6fbb1ee3..d8c7f61244005 100644
--- a/src/Analyzers/CSharp/Analyzers/UseIsNullCheck/CSharpUseNullCheckOverTypeCheckDiagnosticAnalyzer.cs
+++ b/src/Analyzers/CSharp/Analyzers/UseIsNullCheck/CSharpUseNullCheckOverTypeCheckDiagnosticAnalyzer.cs
@@ -9,7 +9,6 @@
using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.CodeAnalysis.Operations;
using Microsoft.CodeAnalysis.Shared.Extensions;
-using Roslyn.Utilities;
namespace Microsoft.CodeAnalysis.CSharp.UseIsNullCheck;
diff --git a/src/Analyzers/CSharp/Analyzers/UseNameofInNullableAttribute/CSharpUseNameofInNullableAttributeDiagnosticAnalyzer.cs b/src/Analyzers/CSharp/Analyzers/UseNameofInNullableAttribute/CSharpUseNameofInNullableAttributeDiagnosticAnalyzer.cs
index 14504a2b6eb16..1ea6b49bf4b2d 100644
--- a/src/Analyzers/CSharp/Analyzers/UseNameofInNullableAttribute/CSharpUseNameofInNullableAttributeDiagnosticAnalyzer.cs
+++ b/src/Analyzers/CSharp/Analyzers/UseNameofInNullableAttribute/CSharpUseNameofInNullableAttributeDiagnosticAnalyzer.cs
@@ -4,18 +4,12 @@
using System;
using System.Collections.Immutable;
-using System.Diagnostics.CodeAnalysis;
using System.Linq;
-using System.Linq.Expressions;
-using System.Threading;
using Microsoft.CodeAnalysis.CodeStyle;
-using Microsoft.CodeAnalysis.CSharp.CodeStyle;
using Microsoft.CodeAnalysis.CSharp.Extensions;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.Diagnostics;
-using Microsoft.CodeAnalysis.PooledObjects;
using Microsoft.CodeAnalysis.Shared.Extensions;
-using Microsoft.CodeAnalysis.Simplification;
using Roslyn.Utilities;
namespace Microsoft.CodeAnalysis.CSharp.UseNameofInAttribute;
diff --git a/src/Analyzers/CSharp/Analyzers/UsePatternCombinators/CSharpUsePatternCombinatorsAnalyzer.cs b/src/Analyzers/CSharp/Analyzers/UsePatternCombinators/CSharpUsePatternCombinatorsAnalyzer.cs
index 31f759e0dffe3..553259e2d5568 100644
--- a/src/Analyzers/CSharp/Analyzers/UsePatternCombinators/CSharpUsePatternCombinatorsAnalyzer.cs
+++ b/src/Analyzers/CSharp/Analyzers/UsePatternCombinators/CSharpUsePatternCombinatorsAnalyzer.cs
@@ -4,7 +4,6 @@
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.Operations;
-using Roslyn.Utilities;
namespace Microsoft.CodeAnalysis.CSharp.UsePatternCombinators;
diff --git a/src/Analyzers/CSharp/Analyzers/UsePatternMatching/CSharpAsAndMemberAccessDiagnosticAnalyzer.cs b/src/Analyzers/CSharp/Analyzers/UsePatternMatching/CSharpAsAndMemberAccessDiagnosticAnalyzer.cs
index c082fd6d437b3..937afd4fb19d7 100644
--- a/src/Analyzers/CSharp/Analyzers/UsePatternMatching/CSharpAsAndMemberAccessDiagnosticAnalyzer.cs
+++ b/src/Analyzers/CSharp/Analyzers/UsePatternMatching/CSharpAsAndMemberAccessDiagnosticAnalyzer.cs
@@ -8,7 +8,6 @@
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.CodeAnalysis.Shared.Extensions;
-using Roslyn.Utilities;
namespace Microsoft.CodeAnalysis.CSharp.UsePatternMatching;
diff --git a/src/Analyzers/CSharp/Analyzers/UsePatternMatching/CSharpIsAndCastCheckDiagnosticAnalyzer.cs b/src/Analyzers/CSharp/Analyzers/UsePatternMatching/CSharpIsAndCastCheckDiagnosticAnalyzer.cs
index 3d490403c7d1e..40f3aa5fc10e6 100644
--- a/src/Analyzers/CSharp/Analyzers/UsePatternMatching/CSharpIsAndCastCheckDiagnosticAnalyzer.cs
+++ b/src/Analyzers/CSharp/Analyzers/UsePatternMatching/CSharpIsAndCastCheckDiagnosticAnalyzer.cs
@@ -4,7 +4,6 @@
using System.Collections.Immutable;
using System.Diagnostics.CodeAnalysis;
-using System.Linq;
using Microsoft.CodeAnalysis.CodeStyle;
using Microsoft.CodeAnalysis.CSharp.CodeStyle;
using Microsoft.CodeAnalysis.CSharp.Extensions;
diff --git a/src/Analyzers/CSharp/Analyzers/UseSystemThreadingLock/CSharpUseSystemThreadingLockDiagnosticAnalyzer.cs b/src/Analyzers/CSharp/Analyzers/UseSystemThreadingLock/CSharpUseSystemThreadingLockDiagnosticAnalyzer.cs
index 84b0b251f3ee1..3f750b3e7483f 100644
--- a/src/Analyzers/CSharp/Analyzers/UseSystemThreadingLock/CSharpUseSystemThreadingLockDiagnosticAnalyzer.cs
+++ b/src/Analyzers/CSharp/Analyzers/UseSystemThreadingLock/CSharpUseSystemThreadingLockDiagnosticAnalyzer.cs
@@ -12,7 +12,6 @@
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.CodeAnalysis.Operations;
-using Microsoft.CodeAnalysis.PooledObjects;
using Microsoft.CodeAnalysis.Shared.Collections;
using Microsoft.CodeAnalysis.Shared.Extensions;
using Roslyn.Utilities;
diff --git a/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.cs.xlf b/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.cs.xlf
index b42bdd3e44dda..576a142a0ecc7 100644
--- a/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.cs.xlf
+++ b/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.cs.xlf
@@ -82,6 +82,11 @@
Vložené příkazy musí mít svůj vlastní řádek.
+
+ Implement with Copilot
+ Implement with Copilot
+
+ Indexing can be simplifiedIndexování může být zjednodušené.
diff --git a/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.de.xlf b/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.de.xlf
index 059b0b878c2a3..96dccc829b54f 100644
--- a/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.de.xlf
+++ b/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.de.xlf
@@ -82,6 +82,11 @@
Eingebettete Anweisungen müssen in einer eigenen Zeile enthalten sein.
+
+ Implement with Copilot
+ Implement with Copilot
+
+ Indexing can be simplifiedDie Indizierung kann vereinfacht werden
diff --git a/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.es.xlf b/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.es.xlf
index 7e39549a2581d..808bededb715e 100644
--- a/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.es.xlf
+++ b/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.es.xlf
@@ -82,6 +82,11 @@
Las instrucciones incrustadas deben estar en su propia línea
+
+ Implement with Copilot
+ Implement with Copilot
+
+ Indexing can be simplifiedLa indexación de direcciones se puede simplificar
diff --git a/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.fr.xlf b/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.fr.xlf
index 5af0777e2db40..7125923272b2b 100644
--- a/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.fr.xlf
+++ b/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.fr.xlf
@@ -82,6 +82,11 @@
Les instructions imbriquées doivent être placées sur leur propre ligne
+
+ Implement with Copilot
+ Implement with Copilot
+
+ Indexing can be simplifiedL'indexation peut être simplifiée
diff --git a/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.it.xlf b/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.it.xlf
index c29a6dfa1f5ae..1c47f131846cf 100644
--- a/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.it.xlf
+++ b/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.it.xlf
@@ -82,6 +82,11 @@
Le istruzioni incorporate devono essere posizionate nella rispettiva riga
+
+ Implement with Copilot
+ Implement with Copilot
+
+ Indexing can be simplifiedL'indicizzazione può essere semplificata
diff --git a/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.ja.xlf b/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.ja.xlf
index 5bcffb1b763ce..498434b70baad 100644
--- a/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.ja.xlf
+++ b/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.ja.xlf
@@ -82,6 +82,11 @@
埋め込みステートメントは独自の行に配置する必要があります
+
+ Implement with Copilot
+ Implement with Copilot
+
+ Indexing can be simplifiedインデックスの作成を簡素化することができます
diff --git a/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.ko.xlf b/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.ko.xlf
index 2154b0285991f..38e28ac74b712 100644
--- a/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.ko.xlf
+++ b/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.ko.xlf
@@ -82,6 +82,11 @@
포함 문은 고유한 줄에 있어야 합니다.
+
+ Implement with Copilot
+ Implement with Copilot
+
+ Indexing can be simplified인덱싱을 단순화할 수 있습니다.
diff --git a/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.pl.xlf b/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.pl.xlf
index cb8612fbc4bf2..6df51c97b6ce0 100644
--- a/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.pl.xlf
+++ b/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.pl.xlf
@@ -82,6 +82,11 @@
Osadzone instrukcje muszą znajdować się w osobnym wierszu
+
+ Implement with Copilot
+ Implement with Copilot
+
+ Indexing can be simplifiedIndeksowanie można uprościć
diff --git a/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.pt-BR.xlf b/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.pt-BR.xlf
index 55bcedeceae12..3d1c3ff54e34e 100644
--- a/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.pt-BR.xlf
+++ b/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.pt-BR.xlf
@@ -82,6 +82,11 @@
As instruções inseridas precisam estar nas próprias linhas
+
+ Implement with Copilot
+ Implement with Copilot
+
+ Indexing can be simplifiedA indexação pode ser simplificada
diff --git a/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.ru.xlf b/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.ru.xlf
index f62102c4a4559..f4c2e65836c99 100644
--- a/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.ru.xlf
+++ b/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.ru.xlf
@@ -82,6 +82,11 @@
Встроенные операторы должны располагаться на отдельной строке.
+
+ Implement with Copilot
+ Implement with Copilot
+
+ Indexing can be simplifiedВы можете упростить индексирование
diff --git a/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.tr.xlf b/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.tr.xlf
index b70da67fc51ba..fd2429f73c4f1 100644
--- a/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.tr.xlf
+++ b/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.tr.xlf
@@ -82,6 +82,11 @@
Katıştırılmış deyimler kendi satırına yerleştirilmelidir
+
+ Implement with Copilot
+ Implement with Copilot
+
+ Indexing can be simplifiedDizin oluşturma basitleştirilebilir
diff --git a/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.zh-Hans.xlf b/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.zh-Hans.xlf
index 86416561f2480..e86aa58e241ca 100644
--- a/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.zh-Hans.xlf
+++ b/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.zh-Hans.xlf
@@ -82,6 +82,11 @@
嵌入的语句必须放在其自己的行上
+
+ Implement with Copilot
+ Implement with Copilot
+
+ Indexing can be simplified索引可以简化
diff --git a/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.zh-Hant.xlf b/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.zh-Hant.xlf
index b3503b34e2199..c2ee335464254 100644
--- a/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.zh-Hant.xlf
+++ b/src/Analyzers/CSharp/Analyzers/xlf/CSharpAnalyzersResources.zh-Hant.xlf
@@ -82,6 +82,11 @@
內嵌陳述式必須位於自己的行中
+
+ Implement with Copilot
+ Implement with Copilot
+
+ Indexing can be simplified可簡化索引
diff --git a/src/Analyzers/CSharp/CodeFixes/AssignOutParameters/AbstractAssignOutParametersCodeFixProvider.cs b/src/Analyzers/CSharp/CodeFixes/AssignOutParameters/AbstractAssignOutParametersCodeFixProvider.cs
index 68b7d5aed208f..3a616c4443e65 100644
--- a/src/Analyzers/CSharp/CodeFixes/AssignOutParameters/AbstractAssignOutParametersCodeFixProvider.cs
+++ b/src/Analyzers/CSharp/CodeFixes/AssignOutParameters/AbstractAssignOutParametersCodeFixProvider.cs
@@ -6,7 +6,6 @@
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
-using Microsoft.CodeAnalysis.CodeActions;
using Microsoft.CodeAnalysis.CodeFixes;
using Microsoft.CodeAnalysis.CSharp.CodeGeneration;
using Microsoft.CodeAnalysis.CSharp.Extensions;
diff --git a/src/Analyzers/CSharp/CodeFixes/ConditionalExpressionInStringInterpolation/CSharpAddParenthesesAroundConditionalExpressionInInterpolatedStringCodeFixProvider.cs b/src/Analyzers/CSharp/CodeFixes/ConditionalExpressionInStringInterpolation/CSharpAddParenthesesAroundConditionalExpressionInInterpolatedStringCodeFixProvider.cs
index be9a3102fe507..61aee9bcc433a 100644
--- a/src/Analyzers/CSharp/CodeFixes/ConditionalExpressionInStringInterpolation/CSharpAddParenthesesAroundConditionalExpressionInInterpolatedStringCodeFixProvider.cs
+++ b/src/Analyzers/CSharp/CodeFixes/ConditionalExpressionInStringInterpolation/CSharpAddParenthesesAroundConditionalExpressionInInterpolatedStringCodeFixProvider.cs
@@ -2,7 +2,6 @@
// 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;
using System.Collections.Immutable;
using System.Composition;
using System.Diagnostics.CodeAnalysis;
diff --git a/src/Analyzers/CSharp/CodeFixes/ConvertSwitchStatementToExpression/ConvertSwitchStatementToExpressionCodeFixProvider.cs b/src/Analyzers/CSharp/CodeFixes/ConvertSwitchStatementToExpression/ConvertSwitchStatementToExpressionCodeFixProvider.cs
index 43785bf880ddb..752bc049b3622 100644
--- a/src/Analyzers/CSharp/CodeFixes/ConvertSwitchStatementToExpression/ConvertSwitchStatementToExpressionCodeFixProvider.cs
+++ b/src/Analyzers/CSharp/CodeFixes/ConvertSwitchStatementToExpression/ConvertSwitchStatementToExpressionCodeFixProvider.cs
@@ -9,7 +9,6 @@
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
-using Microsoft.CodeAnalysis.CodeActions;
using Microsoft.CodeAnalysis.CodeFixes;
using Microsoft.CodeAnalysis.CSharp.Extensions;
using Microsoft.CodeAnalysis.CSharp.Syntax;
diff --git a/src/Analyzers/CSharp/CodeFixes/ConvertTypeOfToNameOf/CSharpConvertTypeOfToNameOfCodeFixProvider.cs b/src/Analyzers/CSharp/CodeFixes/ConvertTypeOfToNameOf/CSharpConvertTypeOfToNameOfCodeFixProvider.cs
index 54b91bec84e9a..f0ea3d4eecd0d 100644
--- a/src/Analyzers/CSharp/CodeFixes/ConvertTypeOfToNameOf/CSharpConvertTypeOfToNameOfCodeFixProvider.cs
+++ b/src/Analyzers/CSharp/CodeFixes/ConvertTypeOfToNameOf/CSharpConvertTypeOfToNameOfCodeFixProvider.cs
@@ -12,7 +12,6 @@
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.CSharp.UseUnboundGenericTypeInNameOf;
using Microsoft.CodeAnalysis.Shared.Extensions;
-using Roslyn.Utilities;
namespace Microsoft.CodeAnalysis.CSharp.ConvertTypeOfToNameOf;
diff --git a/src/Analyzers/CSharp/CodeFixes/ForEachCast/CSharpForEachCastCodeFixProvider.cs b/src/Analyzers/CSharp/CodeFixes/ForEachCast/CSharpForEachCastCodeFixProvider.cs
index c066622935221..a3d6e24716c20 100644
--- a/src/Analyzers/CSharp/CodeFixes/ForEachCast/CSharpForEachCastCodeFixProvider.cs
+++ b/src/Analyzers/CSharp/CodeFixes/ForEachCast/CSharpForEachCastCodeFixProvider.cs
@@ -8,7 +8,6 @@
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.ForEachCast;
using Microsoft.CodeAnalysis.Host.Mef;
-using Roslyn.Utilities;
namespace Microsoft.CodeAnalysis.CSharp.CodeFixes.ForEachCast;
diff --git a/src/Analyzers/CSharp/CodeFixes/GenerateConstructor/GenerateConstructorCodeFixProvider.cs b/src/Analyzers/CSharp/CodeFixes/GenerateConstructor/GenerateConstructorCodeFixProvider.cs
index e2b20ae46539f..2aaa29a31d5f1 100644
--- a/src/Analyzers/CSharp/CodeFixes/GenerateConstructor/GenerateConstructorCodeFixProvider.cs
+++ b/src/Analyzers/CSharp/CodeFixes/GenerateConstructor/GenerateConstructorCodeFixProvider.cs
@@ -12,7 +12,6 @@
using Microsoft.CodeAnalysis.CodeActions;
using Microsoft.CodeAnalysis.CodeFixes;
using Microsoft.CodeAnalysis.CodeFixes.GenerateMember;
-using Microsoft.CodeAnalysis.CodeGeneration;
using Microsoft.CodeAnalysis.CSharp.Extensions;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.GenerateMember.GenerateConstructor;
diff --git a/src/Analyzers/CSharp/CodeFixes/GenerateEnumMember/GenerateEnumMemberCodeFixProvider.cs b/src/Analyzers/CSharp/CodeFixes/GenerateEnumMember/GenerateEnumMemberCodeFixProvider.cs
index 0c6119fbe7905..d823bca790c2f 100644
--- a/src/Analyzers/CSharp/CodeFixes/GenerateEnumMember/GenerateEnumMemberCodeFixProvider.cs
+++ b/src/Analyzers/CSharp/CodeFixes/GenerateEnumMember/GenerateEnumMemberCodeFixProvider.cs
@@ -10,7 +10,6 @@
using Microsoft.CodeAnalysis.CodeActions;
using Microsoft.CodeAnalysis.CodeFixes;
using Microsoft.CodeAnalysis.CodeFixes.GenerateMember;
-using Microsoft.CodeAnalysis.CodeGeneration;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.GenerateMember.GenerateEnumMember;
using Microsoft.CodeAnalysis.Shared.Extensions;
diff --git a/src/Analyzers/CSharp/CodeFixes/GenerateMethod/GenerateConversionCodeFixProvider.cs b/src/Analyzers/CSharp/CodeFixes/GenerateMethod/GenerateConversionCodeFixProvider.cs
index af47c46976f2f..0c47a95aa4c16 100644
--- a/src/Analyzers/CSharp/CodeFixes/GenerateMethod/GenerateConversionCodeFixProvider.cs
+++ b/src/Analyzers/CSharp/CodeFixes/GenerateMethod/GenerateConversionCodeFixProvider.cs
@@ -10,7 +10,6 @@
using Microsoft.CodeAnalysis.CodeActions;
using Microsoft.CodeAnalysis.CodeFixes;
using Microsoft.CodeAnalysis.CodeFixes.GenerateMember;
-using Microsoft.CodeAnalysis.CodeGeneration;
using Microsoft.CodeAnalysis.CSharp.Extensions;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.GenerateMember.GenerateParameterizedMember;
diff --git a/src/Analyzers/CSharp/CodeFixes/GenerateMethod/GenerateMethodCodeFixProvider.cs b/src/Analyzers/CSharp/CodeFixes/GenerateMethod/GenerateMethodCodeFixProvider.cs
index ebdc100c1d1a4..db9456c44dcf5 100644
--- a/src/Analyzers/CSharp/CodeFixes/GenerateMethod/GenerateMethodCodeFixProvider.cs
+++ b/src/Analyzers/CSharp/CodeFixes/GenerateMethod/GenerateMethodCodeFixProvider.cs
@@ -10,7 +10,6 @@
using Microsoft.CodeAnalysis.CodeActions;
using Microsoft.CodeAnalysis.CodeFixes;
using Microsoft.CodeAnalysis.CodeFixes.GenerateMember;
-using Microsoft.CodeAnalysis.CodeGeneration;
using Microsoft.CodeAnalysis.CSharp.Extensions;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.GenerateMember.GenerateParameterizedMember;
diff --git a/src/Analyzers/CSharp/CodeFixes/GenerateParameterizedMember/CSharpGenerateConversionService.cs b/src/Analyzers/CSharp/CodeFixes/GenerateParameterizedMember/CSharpGenerateConversionService.cs
index 084ccf0323348..a06d54e729e62 100644
--- a/src/Analyzers/CSharp/CodeFixes/GenerateParameterizedMember/CSharpGenerateConversionService.cs
+++ b/src/Analyzers/CSharp/CodeFixes/GenerateParameterizedMember/CSharpGenerateConversionService.cs
@@ -28,9 +28,9 @@ internal sealed partial class CSharpGenerateConversionService() :
protected override bool IsImplicitConversionGeneration(SyntaxNode node)
{
return node is ExpressionSyntax &&
- (node.Parent is AssignmentExpressionSyntax || node.Parent is EqualsValueClauseSyntax) &&
- !(node is CastExpressionSyntax) &&
- !(node is MemberAccessExpressionSyntax);
+ node.Parent is AssignmentExpressionSyntax or EqualsValueClauseSyntax &&
+ node is not CastExpressionSyntax &&
+ node is not MemberAccessExpressionSyntax;
}
protected override bool IsExplicitConversionGeneration(SyntaxNode node)
diff --git a/src/Analyzers/CSharp/CodeFixes/GenerateParameterizedMember/CSharpGenerateDeconstructMethodService.cs b/src/Analyzers/CSharp/CodeFixes/GenerateParameterizedMember/CSharpGenerateDeconstructMethodService.cs
index 862f7db6e3f54..e5e245993adc7 100644
--- a/src/Analyzers/CSharp/CodeFixes/GenerateParameterizedMember/CSharpGenerateDeconstructMethodService.cs
+++ b/src/Analyzers/CSharp/CodeFixes/GenerateParameterizedMember/CSharpGenerateDeconstructMethodService.cs
@@ -2,8 +2,6 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-#nullable disable
-
using System;
using System.Collections.Immutable;
using System.Composition;
diff --git a/src/Analyzers/CSharp/CodeFixes/GenerateParameterizedMember/CSharpGenerateMethodService.cs b/src/Analyzers/CSharp/CodeFixes/GenerateParameterizedMember/CSharpGenerateMethodService.cs
index f6986582d93d0..2c92ece627cf0 100644
--- a/src/Analyzers/CSharp/CodeFixes/GenerateParameterizedMember/CSharpGenerateMethodService.cs
+++ b/src/Analyzers/CSharp/CodeFixes/GenerateParameterizedMember/CSharpGenerateMethodService.cs
@@ -87,15 +87,18 @@ protected override bool TryInitializeSimpleNameState(
identifierToken = simpleName.Identifier;
var memberAccess = simpleName?.Parent as MemberAccessExpressionSyntax;
- var conditionalMemberAccess = simpleName?.Parent?.Parent?.Parent as ConditionalAccessExpressionSyntax;
- var inConditionalMemberAccess = conditionalMemberAccess != null;
+ var (conditionalAccessExpression, invocation) =
+ simpleName is { Parent: MemberBindingExpressionSyntax { Parent: InvocationExpressionSyntax { Parent: ConditionalAccessExpressionSyntax conditionalAccessExpression1 } invocation1 } memberBinding } &&
+ conditionalAccessExpression1.WhenNotNull == invocation1 &&
+ invocation1.Expression == memberBinding &&
+ memberBinding.Name == simpleName ? (conditionalAccessExpression1, invocation1) : default;
if (memberAccess != null)
{
simpleNameOrMemberAccessExpression = memberAccess;
}
- else if (inConditionalMemberAccess)
+ else if (conditionalAccessExpression != null)
{
- simpleNameOrMemberAccessExpression = conditionalMemberAccess;
+ simpleNameOrMemberAccessExpression = conditionalAccessExpression;
}
else
{
@@ -106,37 +109,29 @@ protected override bool TryInitializeSimpleNameState(
{
if (simpleNameOrMemberAccessExpression.IsParentKind(SyntaxKind.InvocationExpression, out invocationExpressionOpt))
{
- isInConditionalAccessExpression = inConditionalMemberAccess;
+ // want to look for anything of the form: a?.B() a?.B.C() a?.B.C.D() etc
+ isInConditionalAccessExpression = invocationExpressionOpt.Parent is ConditionalAccessExpressionSyntax { WhenNotNull: var whenNotNull } &&
+ whenNotNull == invocationExpressionOpt;
return !invocationExpressionOpt.ArgumentList.CloseParenToken.IsMissing;
}
- // We need to check that the tree is structured like so:
- // ConditionalAccessExpressionSyntax
- // -> InvocationExpressionSyntax
- // -> MemberBindingExpressionSyntax
- // and that the name at the end of this expression matches the simple name we were given
- else if ((((simpleNameOrMemberAccessExpression as ConditionalAccessExpressionSyntax)
- ?.WhenNotNull as InvocationExpressionSyntax)
- ?.Expression as MemberBindingExpressionSyntax)
- ?.Name == simpleName)
+
+ if (conditionalAccessExpression != null)
{
- invocationExpressionOpt = (InvocationExpressionSyntax)((ConditionalAccessExpressionSyntax)simpleNameOrMemberAccessExpression).WhenNotNull;
- isInConditionalAccessExpression = inConditionalMemberAccess;
+ invocationExpressionOpt = invocation;
+ isInConditionalAccessExpression = true;
return !invocationExpressionOpt.ArgumentList.CloseParenToken.IsMissing;
}
- else if (simpleName.IsKind(SyntaxKind.IdentifierName))
+
+ // If we don't have an invocation node, then see if we can infer a delegate in
+ // this location. Check if this is a place where a delegate can go. Only do this
+ // for identifier names. for now. It gets really funky if you have to deal with
+ // a generic name here.
+ if (simpleName is IdentifierNameSyntax &&
+ !simpleNameOrMemberAccessExpression.IsLeftSideOfAnyAssignExpression())
{
- // If we don't have an invocation node, then see if we can infer a delegate in
- // this location. Check if this is a place where a delegate can go. Only do this
- // for identifier names. for now. It gets really funky if you have to deal with
- // a generic name here.
-
- // Can't assign into a method.
- if (!simpleNameOrMemberAccessExpression.IsLeftSideOfAnyAssignExpression())
- {
- invocationExpressionOpt = null;
- isInConditionalAccessExpression = inConditionalMemberAccess;
- return true;
- }
+ invocationExpressionOpt = null;
+ isInConditionalAccessExpression = conditionalAccessExpression != null;
+ return true;
}
}
diff --git a/src/Analyzers/CSharp/CodeFixes/GenerateParameterizedMember/CSharpGenerateParameterizedMemberService.cs b/src/Analyzers/CSharp/CodeFixes/GenerateParameterizedMember/CSharpGenerateParameterizedMemberService.cs
index 85694ee84cbb9..23a79435f3a53 100644
--- a/src/Analyzers/CSharp/CodeFixes/GenerateParameterizedMember/CSharpGenerateParameterizedMemberService.cs
+++ b/src/Analyzers/CSharp/CodeFixes/GenerateParameterizedMember/CSharpGenerateParameterizedMemberService.cs
@@ -18,7 +18,6 @@
using Microsoft.CodeAnalysis.PooledObjects;
using Microsoft.CodeAnalysis.Shared.Extensions;
using Microsoft.CodeAnalysis.Shared.Utilities;
-using Microsoft.CodeAnalysis.Utilities;
namespace Microsoft.CodeAnalysis.CSharp.GenerateMember.GenerateMethod;
@@ -51,15 +50,15 @@ protected override ITypeSymbol DetermineReturnTypeWorker(CancellationToken cance
protected override ImmutableArray GetCapturedTypeParameters(CancellationToken cancellationToken)
{
- var result = new List();
+ using var _ = ArrayBuilder.GetInstance(out var result);
var semanticModel = Document.SemanticModel;
foreach (var argument in _invocationExpression.ArgumentList.Arguments)
{
var type = argument.DetermineParameterType(semanticModel, cancellationToken);
- type.GetReferencedTypeParameters(result);
+ type.AddReferencedTypeParameters(result);
}
- return [.. result];
+ return result.ToImmutableAndClear();
}
protected override ImmutableArray GenerateTypeParameters(CancellationToken cancellationToken)
diff --git a/src/Analyzers/CSharp/CodeFixes/GenerateVariable/CSharpGenerateVariableCodeFixProvider.cs b/src/Analyzers/CSharp/CodeFixes/GenerateVariable/CSharpGenerateVariableCodeFixProvider.cs
index efef64913eba6..cccff24a15d89 100644
--- a/src/Analyzers/CSharp/CodeFixes/GenerateVariable/CSharpGenerateVariableCodeFixProvider.cs
+++ b/src/Analyzers/CSharp/CodeFixes/GenerateVariable/CSharpGenerateVariableCodeFixProvider.cs
@@ -5,7 +5,6 @@
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;
@@ -39,14 +38,8 @@ protected override bool IsCandidate(SyntaxNode node, SyntaxToken token, Diagnost
protected override SyntaxNode? GetTargetNode(SyntaxNode node)
{
- if (node.IsKind(SyntaxKind.MemberBindingExpression))
- {
- var nameNode = node.ChildNodes().FirstOrDefault(n => n.IsKind(SyntaxKind.IdentifierName));
- if (nameNode != null)
- {
- return nameNode;
- }
- }
+ if (node is MemberBindingExpressionSyntax memberBinding)
+ return memberBinding.Name;
return base.GetTargetNode(node);
}
diff --git a/src/Analyzers/CSharp/CodeFixes/Iterator/CSharpAddYieldCodeFixProvider.cs b/src/Analyzers/CSharp/CodeFixes/Iterator/CSharpAddYieldCodeFixProvider.cs
index 9a25f4ae39100..368c6cf882b65 100644
--- a/src/Analyzers/CSharp/CodeFixes/Iterator/CSharpAddYieldCodeFixProvider.cs
+++ b/src/Analyzers/CSharp/CodeFixes/Iterator/CSharpAddYieldCodeFixProvider.cs
@@ -13,7 +13,6 @@
using Microsoft.CodeAnalysis.CodeActions;
using Microsoft.CodeAnalysis.CodeFixes;
using Microsoft.CodeAnalysis.CodeFixes.Iterator;
-using Microsoft.CodeAnalysis.CSharp.Extensions;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.Formatting;
using Microsoft.CodeAnalysis.Shared.Extensions;
diff --git a/src/Analyzers/CSharp/CodeFixes/MakeLocalFunctionStatic/MakeLocalFunctionStaticCodeFixHelper.cs b/src/Analyzers/CSharp/CodeFixes/MakeLocalFunctionStatic/MakeLocalFunctionStaticCodeFixHelper.cs
index bdea1f83c6eb7..0be3c5fc586cf 100644
--- a/src/Analyzers/CSharp/CodeFixes/MakeLocalFunctionStatic/MakeLocalFunctionStaticCodeFixHelper.cs
+++ b/src/Analyzers/CSharp/CodeFixes/MakeLocalFunctionStatic/MakeLocalFunctionStaticCodeFixHelper.cs
@@ -2,14 +2,12 @@
// 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;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.CodeActions;
using Microsoft.CodeAnalysis.CodeGeneration;
-using Microsoft.CodeAnalysis.CSharp.CodeGeneration;
using Microsoft.CodeAnalysis.CSharp.Extensions;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.Editing;
diff --git a/src/Analyzers/CSharp/CodeFixes/MakeMemberRequired/CSharpMakeMemberRequiredCodeFixProvider.cs b/src/Analyzers/CSharp/CodeFixes/MakeMemberRequired/CSharpMakeMemberRequiredCodeFixProvider.cs
index 457ed7d684699..3e8d66b3a3a39 100644
--- a/src/Analyzers/CSharp/CodeFixes/MakeMemberRequired/CSharpMakeMemberRequiredCodeFixProvider.cs
+++ b/src/Analyzers/CSharp/CodeFixes/MakeMemberRequired/CSharpMakeMemberRequiredCodeFixProvider.cs
@@ -15,7 +15,6 @@
using Microsoft.CodeAnalysis.Host.Mef;
using Microsoft.CodeAnalysis.Shared.Extensions;
using Microsoft.CodeAnalysis.Shared.Utilities;
-using Roslyn.Utilities;
namespace Microsoft.CodeAnalysis.CSharp.CodeFixes.MakeMemberRequired;
diff --git a/src/Analyzers/CSharp/CodeFixes/Nullable/CSharpDeclareAsNullableCodeFixProvider.cs b/src/Analyzers/CSharp/CodeFixes/Nullable/CSharpDeclareAsNullableCodeFixProvider.cs
index db2870ee9e8f6..239e5b7fc3a68 100644
--- a/src/Analyzers/CSharp/CodeFixes/Nullable/CSharpDeclareAsNullableCodeFixProvider.cs
+++ b/src/Analyzers/CSharp/CodeFixes/Nullable/CSharpDeclareAsNullableCodeFixProvider.cs
@@ -10,7 +10,6 @@
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
-using Microsoft.CodeAnalysis.CodeActions;
using Microsoft.CodeAnalysis.CodeFixes;
using Microsoft.CodeAnalysis.CSharp.Extensions;
using Microsoft.CodeAnalysis.CSharp.Syntax;
diff --git a/src/Analyzers/CSharp/CodeFixes/RemoveAsyncModifier/CSharpRemoveAsyncModifierCodeFixProvider.cs b/src/Analyzers/CSharp/CodeFixes/RemoveAsyncModifier/CSharpRemoveAsyncModifierCodeFixProvider.cs
index 15e80e1eee832..9c5c3e275524b 100644
--- a/src/Analyzers/CSharp/CodeFixes/RemoveAsyncModifier/CSharpRemoveAsyncModifierCodeFixProvider.cs
+++ b/src/Analyzers/CSharp/CodeFixes/RemoveAsyncModifier/CSharpRemoveAsyncModifierCodeFixProvider.cs
@@ -11,7 +11,6 @@
using Microsoft.CodeAnalysis.Editing;
using Microsoft.CodeAnalysis.Formatting;
using Microsoft.CodeAnalysis.RemoveAsyncModifier;
-using Roslyn.Utilities;
namespace Microsoft.CodeAnalysis.CSharp.RemoveAsyncModifier;
diff --git a/src/Analyzers/CSharp/CodeFixes/RemoveUnnecessaryCast/CSharpRemoveUnnecessaryCastCodeFixProvider.cs b/src/Analyzers/CSharp/CodeFixes/RemoveUnnecessaryCast/CSharpRemoveUnnecessaryCastCodeFixProvider.cs
index 726efeaf9df28..d901756a39dfb 100644
--- a/src/Analyzers/CSharp/CodeFixes/RemoveUnnecessaryCast/CSharpRemoveUnnecessaryCastCodeFixProvider.cs
+++ b/src/Analyzers/CSharp/CodeFixes/RemoveUnnecessaryCast/CSharpRemoveUnnecessaryCastCodeFixProvider.cs
@@ -16,7 +16,6 @@
using Microsoft.CodeAnalysis.Formatting;
using Microsoft.CodeAnalysis.Shared.Extensions;
using Microsoft.CodeAnalysis.Simplification;
-using Roslyn.Utilities;
namespace Microsoft.CodeAnalysis.CSharp.RemoveUnnecessaryCast;
diff --git a/src/Analyzers/CSharp/CodeFixes/RemoveUnnecessaryNullableDirective/CSharpRemoveUnnecessaryNullableDirectiveCodeFixProvider.cs b/src/Analyzers/CSharp/CodeFixes/RemoveUnnecessaryNullableDirective/CSharpRemoveUnnecessaryNullableDirectiveCodeFixProvider.cs
index 616707576572e..43efc0ada18ef 100644
--- a/src/Analyzers/CSharp/CodeFixes/RemoveUnnecessaryNullableDirective/CSharpRemoveUnnecessaryNullableDirectiveCodeFixProvider.cs
+++ b/src/Analyzers/CSharp/CodeFixes/RemoveUnnecessaryNullableDirective/CSharpRemoveUnnecessaryNullableDirectiveCodeFixProvider.cs
@@ -8,7 +8,6 @@
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
-using Microsoft.CodeAnalysis.CodeActions;
using Microsoft.CodeAnalysis.CodeFixes;
using Microsoft.CodeAnalysis.CSharp.Extensions;
using Microsoft.CodeAnalysis.CSharp.Syntax;
diff --git a/src/Analyzers/CSharp/CodeFixes/RemoveUnusedParametersAndValues/CSharpRemoveUnusedValuesCodeFixProvider.cs b/src/Analyzers/CSharp/CodeFixes/RemoveUnusedParametersAndValues/CSharpRemoveUnusedValuesCodeFixProvider.cs
index b459db309e58d..0e85b35b2c7a4 100644
--- a/src/Analyzers/CSharp/CodeFixes/RemoveUnusedParametersAndValues/CSharpRemoveUnusedValuesCodeFixProvider.cs
+++ b/src/Analyzers/CSharp/CodeFixes/RemoveUnusedParametersAndValues/CSharpRemoveUnusedValuesCodeFixProvider.cs
@@ -15,7 +15,6 @@
using Microsoft.CodeAnalysis.LanguageService;
using Microsoft.CodeAnalysis.RemoveUnusedParametersAndValues;
using Microsoft.CodeAnalysis.Shared.Extensions;
-using Roslyn.Utilities;
namespace Microsoft.CodeAnalysis.CSharp.RemoveUnusedParametersAndValues;
diff --git a/src/Analyzers/CSharp/CodeFixes/UpdateProjectToAllowUnsafe/CSharpUpdateProjectToAllowUnsafeCodeFixProvider.cs b/src/Analyzers/CSharp/CodeFixes/UpdateProjectToAllowUnsafe/CSharpUpdateProjectToAllowUnsafeCodeFixProvider.cs
index 4c7fe2d7c1435..3151c2fcc7490 100644
--- a/src/Analyzers/CSharp/CodeFixes/UpdateProjectToAllowUnsafe/CSharpUpdateProjectToAllowUnsafeCodeFixProvider.cs
+++ b/src/Analyzers/CSharp/CodeFixes/UpdateProjectToAllowUnsafe/CSharpUpdateProjectToAllowUnsafeCodeFixProvider.cs
@@ -8,7 +8,6 @@
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.CodeFixes;
using Microsoft.CodeAnalysis.UpgradeProject;
-using Roslyn.Utilities;
namespace Microsoft.CodeAnalysis.CSharp.UpdateProjectToAllowUnsafe;
diff --git a/src/Analyzers/CSharp/CodeFixes/UpgradeProject/CSharpUpgradeProjectCodeFixProvider.cs b/src/Analyzers/CSharp/CodeFixes/UpgradeProject/CSharpUpgradeProjectCodeFixProvider.cs
index f76ddccb4aa3f..3c7b708944495 100644
--- a/src/Analyzers/CSharp/CodeFixes/UpgradeProject/CSharpUpgradeProjectCodeFixProvider.cs
+++ b/src/Analyzers/CSharp/CodeFixes/UpgradeProject/CSharpUpgradeProjectCodeFixProvider.cs
@@ -8,7 +8,6 @@
using Microsoft.CodeAnalysis.CodeFixes;
using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.CodeAnalysis.UpgradeProject;
-using Roslyn.Utilities;
namespace Microsoft.CodeAnalysis.CSharp.UpgradeProject;
diff --git a/src/Analyzers/CSharp/CodeFixes/UseCoalesceExpression/CSharpUseCoalesceExpressionForIfNullStatementCheckCodeFixProvider.cs b/src/Analyzers/CSharp/CodeFixes/UseCoalesceExpression/CSharpUseCoalesceExpressionForIfNullStatementCheckCodeFixProvider.cs
index ebb1f88d3d23a..3943d6e13cabf 100644
--- a/src/Analyzers/CSharp/CodeFixes/UseCoalesceExpression/CSharpUseCoalesceExpressionForIfNullStatementCheckCodeFixProvider.cs
+++ b/src/Analyzers/CSharp/CodeFixes/UseCoalesceExpression/CSharpUseCoalesceExpressionForIfNullStatementCheckCodeFixProvider.cs
@@ -7,7 +7,6 @@
using System.Threading;
using Microsoft.CodeAnalysis.CodeFixes;
using Microsoft.CodeAnalysis.Host.Mef;
-using Microsoft.CodeAnalysis.LanguageService;
using Microsoft.CodeAnalysis.UseCoalesceExpression;
namespace Microsoft.CodeAnalysis.CSharp.UseCoalesceExpression;
diff --git a/src/Analyzers/CSharp/CodeFixes/UseCollectionExpression/CSharpCollectionExpressionRewriter.cs b/src/Analyzers/CSharp/CodeFixes/UseCollectionExpression/CSharpCollectionExpressionRewriter.cs
index 23b878b52e152..1ef954157683c 100644
--- a/src/Analyzers/CSharp/CodeFixes/UseCollectionExpression/CSharpCollectionExpressionRewriter.cs
+++ b/src/Analyzers/CSharp/CodeFixes/UseCollectionExpression/CSharpCollectionExpressionRewriter.cs
@@ -5,13 +5,9 @@
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
-using System.Diagnostics;
using System.Linq;
-using System.Linq.Expressions;
-using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;
-using Microsoft.CodeAnalysis.CodeActions;
using Microsoft.CodeAnalysis.CSharp.Extensions;
using Microsoft.CodeAnalysis.CSharp.Formatting;
using Microsoft.CodeAnalysis.CSharp.Syntax;
diff --git a/src/Analyzers/CSharp/CodeFixes/UseCollectionExpression/CSharpUseCollectionExpressionForArrayCodeFixProvider.cs b/src/Analyzers/CSharp/CodeFixes/UseCollectionExpression/CSharpUseCollectionExpressionForArrayCodeFixProvider.cs
index 99e656162ca91..ca2da4d011601 100644
--- a/src/Analyzers/CSharp/CodeFixes/UseCollectionExpression/CSharpUseCollectionExpressionForArrayCodeFixProvider.cs
+++ b/src/Analyzers/CSharp/CodeFixes/UseCollectionExpression/CSharpUseCollectionExpressionForArrayCodeFixProvider.cs
@@ -16,7 +16,6 @@
using Microsoft.CodeAnalysis.Shared.Extensions;
using Microsoft.CodeAnalysis.Text;
using Microsoft.CodeAnalysis.UseCollectionExpression;
-using Roslyn.Utilities;
namespace Microsoft.CodeAnalysis.CSharp.UseCollectionExpression;
diff --git a/src/Analyzers/CSharp/CodeFixes/UseCollectionExpression/CSharpUseCollectionExpressionForCreateCodeFixProvider.cs b/src/Analyzers/CSharp/CodeFixes/UseCollectionExpression/CSharpUseCollectionExpressionForCreateCodeFixProvider.cs
index d29cecd68c36e..461891172f126 100644
--- a/src/Analyzers/CSharp/CodeFixes/UseCollectionExpression/CSharpUseCollectionExpressionForCreateCodeFixProvider.cs
+++ b/src/Analyzers/CSharp/CodeFixes/UseCollectionExpression/CSharpUseCollectionExpressionForCreateCodeFixProvider.cs
@@ -8,7 +8,6 @@
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
-using Microsoft.CodeAnalysis.CodeActions;
using Microsoft.CodeAnalysis.CodeFixes;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.Diagnostics;
diff --git a/src/Analyzers/CSharp/CodeFixes/UseCollectionExpression/CSharpUseCollectionExpressionForEmptyCodeFixProvider.cs b/src/Analyzers/CSharp/CodeFixes/UseCollectionExpression/CSharpUseCollectionExpressionForEmptyCodeFixProvider.cs
index 8dd7fc80b9d32..be93c2fc486f8 100644
--- a/src/Analyzers/CSharp/CodeFixes/UseCollectionExpression/CSharpUseCollectionExpressionForEmptyCodeFixProvider.cs
+++ b/src/Analyzers/CSharp/CodeFixes/UseCollectionExpression/CSharpUseCollectionExpressionForEmptyCodeFixProvider.cs
@@ -7,7 +7,6 @@
using System.Composition;
using System.Threading;
using System.Threading.Tasks;
-using Microsoft.CodeAnalysis.CodeActions;
using Microsoft.CodeAnalysis.CodeFixes;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.Diagnostics;
diff --git a/src/Analyzers/CSharp/CodeFixes/UseCollectionExpression/CSharpUseCollectionExpressionForFluentCodeFixProvider.cs b/src/Analyzers/CSharp/CodeFixes/UseCollectionExpression/CSharpUseCollectionExpressionForFluentCodeFixProvider.cs
index 7a2f79d97a432..0d6ebea4aa39d 100644
--- a/src/Analyzers/CSharp/CodeFixes/UseCollectionExpression/CSharpUseCollectionExpressionForFluentCodeFixProvider.cs
+++ b/src/Analyzers/CSharp/CodeFixes/UseCollectionExpression/CSharpUseCollectionExpressionForFluentCodeFixProvider.cs
@@ -8,7 +8,6 @@
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
-using Microsoft.CodeAnalysis.CodeActions;
using Microsoft.CodeAnalysis.CodeFixes;
using Microsoft.CodeAnalysis.CSharp.Formatting;
using Microsoft.CodeAnalysis.CSharp.Syntax;
@@ -22,7 +21,6 @@
using Microsoft.CodeAnalysis.Shared.Extensions;
using Microsoft.CodeAnalysis.UseCollectionExpression;
using Microsoft.CodeAnalysis.UseCollectionInitializer;
-using Roslyn.Utilities;
namespace Microsoft.CodeAnalysis.CSharp.UseCollectionExpression;
diff --git a/src/Analyzers/CSharp/CodeFixes/UseCollectionExpression/CSharpUseCollectionExpressionForStackAllocCodeFixProvider.cs b/src/Analyzers/CSharp/CodeFixes/UseCollectionExpression/CSharpUseCollectionExpressionForStackAllocCodeFixProvider.cs
index 50e3a5d17a274..2c43d39c30587 100644
--- a/src/Analyzers/CSharp/CodeFixes/UseCollectionExpression/CSharpUseCollectionExpressionForStackAllocCodeFixProvider.cs
+++ b/src/Analyzers/CSharp/CodeFixes/UseCollectionExpression/CSharpUseCollectionExpressionForStackAllocCodeFixProvider.cs
@@ -14,7 +14,6 @@
using Microsoft.CodeAnalysis.Host.Mef;
using Microsoft.CodeAnalysis.Shared.Extensions;
using Microsoft.CodeAnalysis.UseCollectionExpression;
-using Roslyn.Utilities;
namespace Microsoft.CodeAnalysis.CSharp.UseCollectionExpression;
diff --git a/src/Analyzers/CSharp/CodeFixes/UseCollectionInitializer/CSharpUseCollectionInitializerCodeFixProvider_CollectionExpression.cs b/src/Analyzers/CSharp/CodeFixes/UseCollectionInitializer/CSharpUseCollectionInitializerCodeFixProvider_CollectionExpression.cs
index 849f1568fbcfd..44ff887dca1e2 100644
--- a/src/Analyzers/CSharp/CodeFixes/UseCollectionInitializer/CSharpUseCollectionInitializerCodeFixProvider_CollectionExpression.cs
+++ b/src/Analyzers/CSharp/CodeFixes/UseCollectionInitializer/CSharpUseCollectionInitializerCodeFixProvider_CollectionExpression.cs
@@ -8,7 +8,6 @@
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.CSharp.UseCollectionExpression;
using Microsoft.CodeAnalysis.UseCollectionExpression;
-using Microsoft.CodeAnalysis.UseCollectionInitializer;
namespace Microsoft.CodeAnalysis.CSharp.UseCollectionInitializer;
diff --git a/src/Analyzers/CSharp/CodeFixes/UseCollectionInitializer/CSharpUseCollectionInitializerCodeFixProvider_CollectionInitializer.cs b/src/Analyzers/CSharp/CodeFixes/UseCollectionInitializer/CSharpUseCollectionInitializerCodeFixProvider_CollectionInitializer.cs
index a3fc69030e6d3..62b5922704c0c 100644
--- a/src/Analyzers/CSharp/CodeFixes/UseCollectionInitializer/CSharpUseCollectionInitializerCodeFixProvider_CollectionInitializer.cs
+++ b/src/Analyzers/CSharp/CodeFixes/UseCollectionInitializer/CSharpUseCollectionInitializerCodeFixProvider_CollectionInitializer.cs
@@ -12,7 +12,6 @@
using Microsoft.CodeAnalysis.PooledObjects;
using Microsoft.CodeAnalysis.Shared.Extensions;
using Microsoft.CodeAnalysis.UseCollectionExpression;
-using Microsoft.CodeAnalysis.UseCollectionInitializer;
using Roslyn.Utilities;
namespace Microsoft.CodeAnalysis.CSharp.UseCollectionInitializer;
diff --git a/src/Analyzers/CSharp/CodeFixes/UseConditionalExpression/CSharpUseConditionalExpressionHelpers.cs b/src/Analyzers/CSharp/CodeFixes/UseConditionalExpression/CSharpUseConditionalExpressionHelpers.cs
index 135ffe0faee5b..59e78ac8f5e71 100644
--- a/src/Analyzers/CSharp/CodeFixes/UseConditionalExpression/CSharpUseConditionalExpressionHelpers.cs
+++ b/src/Analyzers/CSharp/CodeFixes/UseConditionalExpression/CSharpUseConditionalExpressionHelpers.cs
@@ -2,9 +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;
using System.Linq;
-using Microsoft.CodeAnalysis.CSharp.CodeGeneration;
using Microsoft.CodeAnalysis.CSharp.Extensions;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.Operations;
diff --git a/src/Analyzers/CSharp/CodeFixes/UseIsNullCheck/CSharpUseNullCheckOverTypeCheckCodeFixProvider.cs b/src/Analyzers/CSharp/CodeFixes/UseIsNullCheck/CSharpUseNullCheckOverTypeCheckCodeFixProvider.cs
index 5c49751d76deb..6b3a01664eb5f 100644
--- a/src/Analyzers/CSharp/CodeFixes/UseIsNullCheck/CSharpUseNullCheckOverTypeCheckCodeFixProvider.cs
+++ b/src/Analyzers/CSharp/CodeFixes/UseIsNullCheck/CSharpUseNullCheckOverTypeCheckCodeFixProvider.cs
@@ -13,7 +13,6 @@
using Microsoft.CodeAnalysis.Editing;
using Microsoft.CodeAnalysis.Host.Mef;
using Microsoft.CodeAnalysis.Shared.Extensions;
-using Roslyn.Utilities;
using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory;
diff --git a/src/Analyzers/CSharp/CodeFixes/UseNameofInAttribute/CSharpUseNameofInAttributeCodeFixProvider.cs b/src/Analyzers/CSharp/CodeFixes/UseNameofInAttribute/CSharpUseNameofInAttributeCodeFixProvider.cs
index 56a91d73f3a41..59059f826e54d 100644
--- a/src/Analyzers/CSharp/CodeFixes/UseNameofInAttribute/CSharpUseNameofInAttributeCodeFixProvider.cs
+++ b/src/Analyzers/CSharp/CodeFixes/UseNameofInAttribute/CSharpUseNameofInAttributeCodeFixProvider.cs
@@ -13,7 +13,6 @@
using Microsoft.CodeAnalysis.Editing;
using Microsoft.CodeAnalysis.Host.Mef;
using Microsoft.CodeAnalysis.Shared.Extensions;
-using Roslyn.Utilities;
namespace Microsoft.CodeAnalysis.CSharp.CodeFixes.UseNameofInAttribute;
diff --git a/src/Analyzers/CSharp/CodeFixes/UseSimpleUsingStatement/UseSimpleUsingStatementCodeFixProvider.cs b/src/Analyzers/CSharp/CodeFixes/UseSimpleUsingStatement/UseSimpleUsingStatementCodeFixProvider.cs
index 09fb8e4b3b937..038b093530b9c 100644
--- a/src/Analyzers/CSharp/CodeFixes/UseSimpleUsingStatement/UseSimpleUsingStatementCodeFixProvider.cs
+++ b/src/Analyzers/CSharp/CodeFixes/UseSimpleUsingStatement/UseSimpleUsingStatementCodeFixProvider.cs
@@ -7,7 +7,6 @@
using System.Collections.Immutable;
using System.Composition;
using System.Linq;
-using System.Linq.Expressions;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.CodeFixes;
@@ -20,7 +19,6 @@
using Microsoft.CodeAnalysis.Host.Mef;
using Microsoft.CodeAnalysis.PooledObjects;
using Microsoft.CodeAnalysis.Shared.Extensions;
-using Microsoft.CodeAnalysis.Utilities;
using Roslyn.Utilities;
namespace Microsoft.CodeAnalysis.CSharp.UseSimpleUsingStatement;
diff --git a/src/Analyzers/CSharp/Tests/Formatting/FormattingAnalyzerTests.cs b/src/Analyzers/CSharp/Tests/Formatting/FormattingAnalyzerTests.cs
index cbe2148fab052..80c96a2536846 100644
--- a/src/Analyzers/CSharp/Tests/Formatting/FormattingAnalyzerTests.cs
+++ b/src/Analyzers/CSharp/Tests/Formatting/FormattingAnalyzerTests.cs
@@ -4,7 +4,6 @@
using System;
using System.Threading.Tasks;
-using Microsoft.CodeAnalysis.CSharp.Shared.Extensions;
using Microsoft.CodeAnalysis.Editor.UnitTests.CodeActions;
using Microsoft.CodeAnalysis.Test.Utilities;
using Xunit;
diff --git a/src/Analyzers/CSharp/Tests/GenerateMethod/GenerateMethodTests.cs b/src/Analyzers/CSharp/Tests/GenerateMethod/GenerateMethodTests.cs
index 5dc8bbc1fc38c..37b12812aab52 100644
--- a/src/Analyzers/CSharp/Tests/GenerateMethod/GenerateMethodTests.cs
+++ b/src/Analyzers/CSharp/Tests/GenerateMethod/GenerateMethodTests.cs
@@ -7,6 +7,7 @@
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.CSharp.CodeFixes.GenerateMethod;
using Microsoft.CodeAnalysis.CSharp.CodeStyle;
+using Microsoft.CodeAnalysis.CSharp.Shared.Extensions;
using Microsoft.CodeAnalysis.CSharp.Test.Utilities;
using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.CodeAnalysis.Test.Utilities;
@@ -7686,6 +7687,50 @@ internal int C()
""");
}
+ [Fact, WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/1064748")]
+ public async Task TestGenerateMethodInConditionalAccess7_B()
+ {
+ await TestInRegularAndScriptAsync(
+ """
+ class C
+ {
+ public C B { get; private set; }
+ public E D { get; private set; }
+
+ void Main(C a)
+ {
+ int? x = a?.B.B.D.[|C|]();
+ }
+
+ public class E
+ {
+ }
+ }
+ """,
+ """
+ using System;
+
+ class C
+ {
+ public C B { get; private set; }
+ public E D { get; private set; }
+
+ void Main(C a)
+ {
+ int? x = a?.B.B.D.C();
+ }
+
+ public class E
+ {
+ internal int C()
+ {
+ throw new NotImplementedException();
+ }
+ }
+ }
+ """);
+ }
+
[Fact, WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/1064748")]
public async Task TestGenerateMethodInConditionalAccess8()
{
@@ -11145,4 +11190,80 @@ private static void Test()
}
""", parseOptions: CSharpParseOptions.Default);
}
+
+ [Fact]
+ public async Task TestNullConditionalAssignment1()
+ {
+ await TestAsync(
+ """
+ using System;
+
+ internal class Program
+ {
+ int x;
+
+ void M(Program p)
+ {
+ p?.x = [|Goo|]();
+ }
+ }
+ """,
+ """
+ using System;
+
+ internal class Program
+ {
+ int x;
+
+ void M(Program p)
+ {
+ p?.x = [|Goo|]();
+ }
+
+ private int Goo()
+ {
+ throw new NotImplementedException();
+ }
+ }
+ """, parseOptions: CSharpParseOptions.Default.WithLanguageVersion(LanguageVersionExtensions.CSharpNext));
+ }
+
+ [Fact]
+ public async Task TestNullConditionalAssignment2()
+ {
+ await TestAsync(
+ """
+ using System;
+
+ internal class Program
+ {
+ Program P;
+ int x;
+
+ void M(Program p)
+ {
+ p?.P.x = [|Goo|]();
+ }
+ }
+ """,
+ """
+ using System;
+
+ internal class Program
+ {
+ Program P;
+ int x;
+
+ void M(Program p)
+ {
+ p?.P.x = [|Goo|]();
+ }
+
+ private int Goo()
+ {
+ throw new NotImplementedException();
+ }
+ }
+ """, parseOptions: CSharpParseOptions.Default.WithLanguageVersion(LanguageVersionExtensions.CSharpNext));
+ }
}
diff --git a/src/Analyzers/CSharp/Tests/MakeRefStruct/MakeRefStructTests.cs b/src/Analyzers/CSharp/Tests/MakeRefStruct/MakeRefStructTests.cs
index 151a515c1e686..23b1e49a73dcd 100644
--- a/src/Analyzers/CSharp/Tests/MakeRefStruct/MakeRefStructTests.cs
+++ b/src/Analyzers/CSharp/Tests/MakeRefStruct/MakeRefStructTests.cs
@@ -2,17 +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 System;
-using System.Collections.Immutable;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.CodeFixes;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.CSharp.MakeRefStruct;
-using Microsoft.CodeAnalysis.CSharp.Shared.Extensions;
using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.CodeAnalysis.Editor.CSharp.UnitTests.Diagnostics;
using Microsoft.CodeAnalysis.Test.Utilities;
-using Roslyn.Test.Utilities;
using Xunit;
using Xunit.Abstractions;
diff --git a/src/Analyzers/CSharp/Tests/MakeStructMemberReadOnly/MakeStructMemberReadOnlyTests.cs b/src/Analyzers/CSharp/Tests/MakeStructMemberReadOnly/MakeStructMemberReadOnlyTests.cs
index 0ef176175dd9e..5f5a53e1780a5 100644
--- a/src/Analyzers/CSharp/Tests/MakeStructMemberReadOnly/MakeStructMemberReadOnlyTests.cs
+++ b/src/Analyzers/CSharp/Tests/MakeStructMemberReadOnly/MakeStructMemberReadOnlyTests.cs
@@ -2,7 +2,6 @@
// 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;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.CSharp.MakeStructMemberReadOnly;
diff --git a/src/Analyzers/CSharp/Tests/NamingStyles/NamingStylesTests.cs b/src/Analyzers/CSharp/Tests/NamingStyles/NamingStylesTests.cs
index 3752f621c91a2..a011670dbdd0d 100644
--- a/src/Analyzers/CSharp/Tests/NamingStyles/NamingStylesTests.cs
+++ b/src/Analyzers/CSharp/Tests/NamingStyles/NamingStylesTests.cs
@@ -2,7 +2,6 @@
// 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.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.CodeFixes;
diff --git a/src/Analyzers/CSharp/Tests/NewLines/ArrowExpressionClausePlacement/ArrowExpressionClausePlacementTests.cs b/src/Analyzers/CSharp/Tests/NewLines/ArrowExpressionClausePlacement/ArrowExpressionClausePlacementTests.cs
index f1a7c333867f5..d5dc138ae07f0 100644
--- a/src/Analyzers/CSharp/Tests/NewLines/ArrowExpressionClausePlacement/ArrowExpressionClausePlacementTests.cs
+++ b/src/Analyzers/CSharp/Tests/NewLines/ArrowExpressionClausePlacement/ArrowExpressionClausePlacementTests.cs
@@ -2,12 +2,10 @@
// 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.Threading.Tasks;
using Microsoft.CodeAnalysis.CodeStyle;
using Microsoft.CodeAnalysis.CSharp.CodeStyle;
using Microsoft.CodeAnalysis.CSharp.NewLines.ArrowExpressionClausePlacement;
-using Microsoft.CodeAnalysis.CSharp.NewLines.ConstructorInitializerPlacement;
using Microsoft.CodeAnalysis.Editor.UnitTests.CodeActions;
using Xunit;
diff --git a/src/Analyzers/CSharp/Tests/NewLines/ConditionalExpressionPlacement/ConditionalExpressionPlacementTests.cs b/src/Analyzers/CSharp/Tests/NewLines/ConditionalExpressionPlacement/ConditionalExpressionPlacementTests.cs
index de48866e2e01c..0cde7328329e9 100644
--- a/src/Analyzers/CSharp/Tests/NewLines/ConditionalExpressionPlacement/ConditionalExpressionPlacementTests.cs
+++ b/src/Analyzers/CSharp/Tests/NewLines/ConditionalExpressionPlacement/ConditionalExpressionPlacementTests.cs
@@ -6,7 +6,6 @@
using Microsoft.CodeAnalysis.CodeStyle;
using Microsoft.CodeAnalysis.CSharp.CodeStyle;
using Microsoft.CodeAnalysis.CSharp.NewLines.ConditionalExpressionPlacement;
-using Microsoft.CodeAnalysis.CSharp.NewLines.ConstructorInitializerPlacement;
using Microsoft.CodeAnalysis.Editor.UnitTests.CodeActions;
using Xunit;
diff --git a/src/Analyzers/CSharp/Tests/PopulateSwitch/PopulateSwitchExpressionTests_FixAllTests.cs b/src/Analyzers/CSharp/Tests/PopulateSwitch/PopulateSwitchExpressionTests_FixAllTests.cs
index f34cf81e504b1..d2c22cb448ae9 100644
--- a/src/Analyzers/CSharp/Tests/PopulateSwitch/PopulateSwitchExpressionTests_FixAllTests.cs
+++ b/src/Analyzers/CSharp/Tests/PopulateSwitch/PopulateSwitchExpressionTests_FixAllTests.cs
@@ -5,7 +5,6 @@
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.Test.Utilities;
using Xunit;
-using Xunit.Abstractions;
namespace Microsoft.CodeAnalysis.Editor.CSharp.UnitTests.Diagnostics.PopulateSwitch;
diff --git a/src/Analyzers/CSharp/Tests/PopulateSwitch/PopulateSwitchStatementTests_FixAllTests.cs b/src/Analyzers/CSharp/Tests/PopulateSwitch/PopulateSwitchStatementTests_FixAllTests.cs
index 95918924d3f2a..73de5c402ff37 100644
--- a/src/Analyzers/CSharp/Tests/PopulateSwitch/PopulateSwitchStatementTests_FixAllTests.cs
+++ b/src/Analyzers/CSharp/Tests/PopulateSwitch/PopulateSwitchStatementTests_FixAllTests.cs
@@ -7,7 +7,6 @@
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.Test.Utilities;
using Xunit;
-using Xunit.Abstractions;
namespace Microsoft.CodeAnalysis.Editor.CSharp.UnitTests.Diagnostics.PopulateSwitch;
diff --git a/src/Analyzers/CSharp/Tests/QualifyMemberAccess/QualifyMemberAccessTests_FixAllTests.cs b/src/Analyzers/CSharp/Tests/QualifyMemberAccess/QualifyMemberAccessTests_FixAllTests.cs
index e10214afc70e1..2175522703dea 100644
--- a/src/Analyzers/CSharp/Tests/QualifyMemberAccess/QualifyMemberAccessTests_FixAllTests.cs
+++ b/src/Analyzers/CSharp/Tests/QualifyMemberAccess/QualifyMemberAccessTests_FixAllTests.cs
@@ -6,10 +6,8 @@
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.CodeStyle;
-using Microsoft.CodeAnalysis.Editor.CSharp.UnitTests.Diagnostics;
using Microsoft.CodeAnalysis.Test.Utilities;
using Xunit;
-using Xunit.Abstractions;
namespace Microsoft.CodeAnalysis.Editor.CSharp.UnitTests.QualifyMemberAccess;
diff --git a/src/Analyzers/CSharp/Tests/RemoveUnnecessaryNullableDirective/CSharpRemoveRedundantNullableDirectiveTests.cs b/src/Analyzers/CSharp/Tests/RemoveUnnecessaryNullableDirective/CSharpRemoveRedundantNullableDirectiveTests.cs
index 9843d4e171bee..b020574a54c38 100644
--- a/src/Analyzers/CSharp/Tests/RemoveUnnecessaryNullableDirective/CSharpRemoveRedundantNullableDirectiveTests.cs
+++ b/src/Analyzers/CSharp/Tests/RemoveUnnecessaryNullableDirective/CSharpRemoveRedundantNullableDirectiveTests.cs
@@ -8,7 +8,6 @@
using Microsoft.CodeAnalysis.Editor.UnitTests.CodeActions;
using Microsoft.CodeAnalysis.Shared.Extensions;
using Microsoft.CodeAnalysis.Test.Utilities;
-using Roslyn.Utilities;
using Xunit;
namespace Microsoft.CodeAnalysis.CSharp.Analyzers.UnitTests.RemoveUnnecessaryNullableDirective;
diff --git a/src/Analyzers/CSharp/Tests/RemoveUnnecessaryNullableDirective/CSharpRemoveUnnecessaryNullableDirectiveTests.cs b/src/Analyzers/CSharp/Tests/RemoveUnnecessaryNullableDirective/CSharpRemoveUnnecessaryNullableDirectiveTests.cs
index 3096264bec24d..6acbfd5841f8a 100644
--- a/src/Analyzers/CSharp/Tests/RemoveUnnecessaryNullableDirective/CSharpRemoveUnnecessaryNullableDirectiveTests.cs
+++ b/src/Analyzers/CSharp/Tests/RemoveUnnecessaryNullableDirective/CSharpRemoveUnnecessaryNullableDirectiveTests.cs
@@ -8,7 +8,6 @@
using Microsoft.CodeAnalysis.RemoveUnnecessaryNullableDirective;
using Microsoft.CodeAnalysis.Shared.Extensions;
using Microsoft.CodeAnalysis.Test.Utilities;
-using Roslyn.Utilities;
using Xunit;
namespace Microsoft.CodeAnalysis.CSharp.Analyzers.UnitTests.RemoveUnnecessaryNullableDirective;
diff --git a/src/Analyzers/CSharp/Tests/RemoveUnusedParametersAndValues/RemoveUnusedValueAssignmentTests.cs b/src/Analyzers/CSharp/Tests/RemoveUnusedParametersAndValues/RemoveUnusedValueAssignmentTests.cs
index a0cd8ae3d72fe..70413925b1361 100644
--- a/src/Analyzers/CSharp/Tests/RemoveUnusedParametersAndValues/RemoveUnusedValueAssignmentTests.cs
+++ b/src/Analyzers/CSharp/Tests/RemoveUnusedParametersAndValues/RemoveUnusedValueAssignmentTests.cs
@@ -11,7 +11,6 @@
using Microsoft.CodeAnalysis.Test.Utilities;
using Microsoft.CodeAnalysis.Testing;
using Roslyn.Test.Utilities;
-using Roslyn.Utilities;
using Xunit;
using Xunit.Abstractions;
using static Roslyn.Test.Utilities.TestHelpers;
diff --git a/src/Analyzers/CSharp/Tests/SimplifyLinqExpression/CSharpSimplifyLinqTypeCheckAndCastTests.cs b/src/Analyzers/CSharp/Tests/SimplifyLinqExpression/CSharpSimplifyLinqTypeCheckAndCastTests.cs
index 8553feaa83b5e..af8407685b83b 100644
--- a/src/Analyzers/CSharp/Tests/SimplifyLinqExpression/CSharpSimplifyLinqTypeCheckAndCastTests.cs
+++ b/src/Analyzers/CSharp/Tests/SimplifyLinqExpression/CSharpSimplifyLinqTypeCheckAndCastTests.cs
@@ -5,9 +5,7 @@
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.CSharp.SimplifyLinqExpression;
using Microsoft.CodeAnalysis.Editor.UnitTests.CodeActions;
-using Microsoft.CodeAnalysis.SimplifyLinqExpression;
using Microsoft.CodeAnalysis.Test.Utilities;
-using Roslyn.Test.Utilities;
using Xunit;
namespace Microsoft.CodeAnalysis.CSharp.Analyzers.UnitTests.SimplifyLinqExpression;
diff --git a/src/Analyzers/CSharp/Tests/UseCollectionExpression/UseCollectionExpressionForArrayTests.cs b/src/Analyzers/CSharp/Tests/UseCollectionExpression/UseCollectionExpressionForArrayTests.cs
index 8e8bf8c71c873..49622fce27f7e 100644
--- a/src/Analyzers/CSharp/Tests/UseCollectionExpression/UseCollectionExpressionForArrayTests.cs
+++ b/src/Analyzers/CSharp/Tests/UseCollectionExpression/UseCollectionExpressionForArrayTests.cs
@@ -2,7 +2,6 @@
// 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;
using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.CSharp.UseCollectionExpression;
diff --git a/src/Analyzers/CSharp/Tests/UseCollectionExpression/UseCollectionExpressionForEmptyTests.cs b/src/Analyzers/CSharp/Tests/UseCollectionExpression/UseCollectionExpressionForEmptyTests.cs
index a8319d76ccc68..8caff98c38684 100644
--- a/src/Analyzers/CSharp/Tests/UseCollectionExpression/UseCollectionExpressionForEmptyTests.cs
+++ b/src/Analyzers/CSharp/Tests/UseCollectionExpression/UseCollectionExpressionForEmptyTests.cs
@@ -2,7 +2,6 @@
// 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.Threading.Tasks;
using Microsoft.CodeAnalysis.CSharp.UseCollectionExpression;
using Microsoft.CodeAnalysis.Editor.UnitTests.CodeActions;
diff --git a/src/Analyzers/CSharp/Tests/UseCollectionExpression/UseCollectionExpressionForStackAllocTests.cs b/src/Analyzers/CSharp/Tests/UseCollectionExpression/UseCollectionExpressionForStackAllocTests.cs
index 208437f6edf7c..14a7dec386faf 100644
--- a/src/Analyzers/CSharp/Tests/UseCollectionExpression/UseCollectionExpressionForStackAllocTests.cs
+++ b/src/Analyzers/CSharp/Tests/UseCollectionExpression/UseCollectionExpressionForStackAllocTests.cs
@@ -2,7 +2,6 @@
// 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;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.CSharp.UseCollectionExpression;
using Microsoft.CodeAnalysis.Editor.UnitTests.CodeActions;
diff --git a/src/Analyzers/CSharp/Tests/UseCollectionInitializer/UseCollectionInitializerTests.cs b/src/Analyzers/CSharp/Tests/UseCollectionInitializer/UseCollectionInitializerTests.cs
index d70e33ad6cbad..f33a25452afca 100644
--- a/src/Analyzers/CSharp/Tests/UseCollectionInitializer/UseCollectionInitializerTests.cs
+++ b/src/Analyzers/CSharp/Tests/UseCollectionInitializer/UseCollectionInitializerTests.cs
@@ -7,6 +7,7 @@
using Microsoft.CodeAnalysis.CSharp.UseCollectionInitializer;
using Microsoft.CodeAnalysis.Editor.UnitTests.CodeActions;
using Microsoft.CodeAnalysis.Test.Utilities;
+using Microsoft.CodeAnalysis.Testing;
using Roslyn.Test.Utilities;
using Xunit;
@@ -1826,4 +1827,42 @@ void M(List? list1)
LanguageVersion = LanguageVersion.CSharp12,
}.RunAsync();
}
+
+ [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/77416")]
+ public async Task TestNoCollectionExpressionForBlockingCollection()
+ {
+ await new VerifyCS.Test
+ {
+ TestCode = """
+ using System;
+ using System.Collections.Concurrent;
+
+ class A
+ {
+ public void Main(ConcurrentQueue queue)
+ {
+ BlockingCollection bc = [|new|](queue);
+ [|bc.Add(|]42);
+ }
+ }
+ """,
+ FixedCode = """
+ using System;
+ using System.Collections.Concurrent;
+
+ class A
+ {
+ public void Main(ConcurrentQueue queue)
+ {
+ BlockingCollection bc = new(queue)
+ {
+ 42
+ };
+ }
+ }
+ """,
+ LanguageVersion = LanguageVersion.CSharp13,
+ ReferenceAssemblies = ReferenceAssemblies.Net.Net90,
+ }.RunAsync();
+ }
}
diff --git a/src/Analyzers/CSharp/Tests/UseConditionalExpression/UseConditionalExpressionForAssignmentTests.cs b/src/Analyzers/CSharp/Tests/UseConditionalExpression/UseConditionalExpressionForAssignmentTests.cs
index 8055ed9663f4a..29193e52345ca 100644
--- a/src/Analyzers/CSharp/Tests/UseConditionalExpression/UseConditionalExpressionForAssignmentTests.cs
+++ b/src/Analyzers/CSharp/Tests/UseConditionalExpression/UseConditionalExpressionForAssignmentTests.cs
@@ -7,6 +7,7 @@
using Microsoft.CodeAnalysis.CodeStyle;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.CSharp.CodeStyle;
+using Microsoft.CodeAnalysis.CSharp.Shared.Extensions;
using Microsoft.CodeAnalysis.CSharp.UseConditionalExpression;
using Microsoft.CodeAnalysis.Editor.UnitTests.CodeActions;
using Microsoft.CodeAnalysis.Test.Utilities;
@@ -2487,4 +2488,40 @@ public void Convert(Type type, string body)
}
""");
}
+
+ [Fact]
+ public async Task TestOnNullConditionalAssignment1()
+ {
+ await TestInRegularAndScript1Async(
+ """
+ class C
+ {
+ int i;
+
+ void M(C c)
+ {
+ [|if|] (true)
+ {
+ c?.i = 0;
+ }
+ else
+ {
+ c?.i = 1;
+ }
+ }
+ }
+ """,
+ """
+ class C
+ {
+ int i;
+
+ void M(C c)
+ {
+ c?.i = true ? 0 : 1;
+ }
+ }
+ """,
+ languageVersion: LanguageVersionExtensions.CSharpNext);
+ }
}
diff --git a/src/Analyzers/CSharp/Tests/UseNullPropagation/UseNullPropagationTests.cs b/src/Analyzers/CSharp/Tests/UseNullPropagation/UseNullPropagationTests.cs
index cb0d5a578ce24..0b9c88a1085a7 100644
--- a/src/Analyzers/CSharp/Tests/UseNullPropagation/UseNullPropagationTests.cs
+++ b/src/Analyzers/CSharp/Tests/UseNullPropagation/UseNullPropagationTests.cs
@@ -2,8 +2,11 @@
// 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.Diagnostics.CodeAnalysis;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.CSharp;
+using Microsoft.CodeAnalysis.CSharp.Extensions;
+using Microsoft.CodeAnalysis.CSharp.Shared.Extensions;
using Microsoft.CodeAnalysis.CSharp.UseNullPropagation;
using Microsoft.CodeAnalysis.Editor.UnitTests.CodeActions;
using Microsoft.CodeAnalysis.Test.Utilities;
@@ -20,7 +23,11 @@ namespace Microsoft.CodeAnalysis.Editor.CSharp.UnitTests.UseNullPropagation;
[Trait(Traits.Feature, Traits.Features.CodeActionsUseNullPropagation)]
public partial class UseNullPropagationTests
{
- private static async Task TestInRegularAndScript1Async(string testCode, string fixedCode, OutputKind outputKind = OutputKind.DynamicallyLinkedLibrary)
+ private static async Task TestInRegularAndScript1Async(
+ [StringSyntax(PredefinedEmbeddedLanguageNames.CSharpTest)] string testCode,
+ [StringSyntax(PredefinedEmbeddedLanguageNames.CSharpTest)] string fixedCode,
+ OutputKind outputKind = OutputKind.DynamicallyLinkedLibrary,
+ LanguageVersion languageVersion = LanguageVersion.CSharp9)
{
await new VerifyCS.Test
{
@@ -30,7 +37,7 @@ private static async Task TestInRegularAndScript1Async(string testCode, string f
// by just rewriting `x.Y` into `x?.Y`. That is not correct. the RHS of the `?` should `.Y()` not
// `.Y`.
CodeActionValidationMode = CodeActionValidationMode.None,
- LanguageVersion = LanguageVersion.CSharp9,
+ LanguageVersion = languageVersion,
TestState =
{
OutputKind = outputKind,
@@ -38,7 +45,9 @@ private static async Task TestInRegularAndScript1Async(string testCode, string f
}.RunAsync();
}
- private static async Task TestMissingInRegularAndScriptAsync(string testCode, LanguageVersion languageVersion = LanguageVersion.CSharp9)
+ private static async Task TestMissingInRegularAndScriptAsync(
+ [StringSyntax(PredefinedEmbeddedLanguageNames.CSharpTest)] string testCode,
+ LanguageVersion languageVersion = LanguageVersion.CSharp9)
{
await new VerifyCS.Test
{
@@ -2508,4 +2517,58 @@ void M(byte? o)
}
""");
}
+
+ [Fact]
+ public async Task TestNullConditionalAssignment1()
+ {
+ await TestInRegularAndScript1Async(
+ """
+ using System;
+
+ class C
+ {
+ int x;
+
+ void M(C c)
+ {
+ [|if|] (c != null)
+ c.x = 1;
+ }
+ }
+ """,
+ """
+ using System;
+
+ class C
+ {
+ int x;
+
+ void M(C c)
+ {
+ c?.x = 1;
+ }
+ }
+ """,
+ languageVersion: LanguageVersionExtensions.CSharpNext);
+ }
+
+ [Fact]
+ public async Task TestNullConditionalAssignment2()
+ {
+ await TestMissingInRegularAndScriptAsync(
+ """
+ using System;
+
+ class C
+ {
+ int x;
+
+ void M(C c)
+ {
+ if (c != null)
+ c.x = 1;
+ }
+ }
+ """);
+ }
}
diff --git a/src/Analyzers/CSharp/Tests/UsePatternMatching/CSharpAsAndMemberAccessTests.cs b/src/Analyzers/CSharp/Tests/UsePatternMatching/CSharpAsAndMemberAccessTests.cs
index 250125e5fea12..97c9f4d03f53b 100644
--- a/src/Analyzers/CSharp/Tests/UsePatternMatching/CSharpAsAndMemberAccessTests.cs
+++ b/src/Analyzers/CSharp/Tests/UsePatternMatching/CSharpAsAndMemberAccessTests.cs
@@ -2,7 +2,6 @@
// 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;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.CSharp.UsePatternMatching;
diff --git a/src/Analyzers/CSharp/Tests/UseThrowExpression/UseThrowExpressionTests.cs b/src/Analyzers/CSharp/Tests/UseThrowExpression/UseThrowExpressionTests.cs
index c3fe4a3616fae..449b210f685b1 100644
--- a/src/Analyzers/CSharp/Tests/UseThrowExpression/UseThrowExpressionTests.cs
+++ b/src/Analyzers/CSharp/Tests/UseThrowExpression/UseThrowExpressionTests.cs
@@ -5,13 +5,11 @@
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.CodeFixes;
using Microsoft.CodeAnalysis.CSharp;
-using Microsoft.CodeAnalysis.CSharp.Shared.Extensions;
using Microsoft.CodeAnalysis.CSharp.Test.Utilities;
using Microsoft.CodeAnalysis.CSharp.UseThrowExpression;
using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.CodeAnalysis.Editor.CSharp.UnitTests.Diagnostics;
using Microsoft.CodeAnalysis.Test.Utilities;
-using Microsoft.CodeAnalysis.UseThrowExpression;
using Roslyn.Test.Utilities;
using Xunit;
using Xunit.Abstractions;
diff --git a/src/Analyzers/CSharp/Tests/UseThrowExpression/UseThrowExpressionTests_FixAllTests.cs b/src/Analyzers/CSharp/Tests/UseThrowExpression/UseThrowExpressionTests_FixAllTests.cs
index 90265892987c6..d8bf92d5cbcb4 100644
--- a/src/Analyzers/CSharp/Tests/UseThrowExpression/UseThrowExpressionTests_FixAllTests.cs
+++ b/src/Analyzers/CSharp/Tests/UseThrowExpression/UseThrowExpressionTests_FixAllTests.cs
@@ -5,7 +5,6 @@
#nullable disable
using System.Threading.Tasks;
-using Microsoft.CodeAnalysis.Editor.CSharp.UnitTests.Diagnostics;
using Microsoft.CodeAnalysis.Test.Utilities;
using Xunit;
diff --git a/src/Analyzers/CSharp/Tests/UseUtf8StringLiteral/UseUtf8StringLiteralTests.cs b/src/Analyzers/CSharp/Tests/UseUtf8StringLiteral/UseUtf8StringLiteralTests.cs
index 5a36f81c5cd43..1cb5ba3943b6e 100644
--- a/src/Analyzers/CSharp/Tests/UseUtf8StringLiteral/UseUtf8StringLiteralTests.cs
+++ b/src/Analyzers/CSharp/Tests/UseUtf8StringLiteral/UseUtf8StringLiteralTests.cs
@@ -2,10 +2,8 @@
// 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.Text;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.CSharp;
-using Microsoft.CodeAnalysis.CSharp.Shared.Extensions;
using Microsoft.CodeAnalysis.CSharp.UseUtf8StringLiteral;
using Microsoft.CodeAnalysis.Editor.UnitTests.CodeActions;
using Microsoft.CodeAnalysis.Test.Utilities;
diff --git a/src/Analyzers/Core/Analyzers/AbstractBuiltInCodeStyleDiagnosticAnalyzer.cs b/src/Analyzers/Core/Analyzers/AbstractBuiltInCodeStyleDiagnosticAnalyzer.cs
index 97702dfc3f137..9ff82c4829633 100644
--- a/src/Analyzers/Core/Analyzers/AbstractBuiltInCodeStyleDiagnosticAnalyzer.cs
+++ b/src/Analyzers/Core/Analyzers/AbstractBuiltInCodeStyleDiagnosticAnalyzer.cs
@@ -7,7 +7,6 @@
using System.Linq;
using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.CodeAnalysis.Options;
-using Microsoft.CodeAnalysis.Simplification;
using Roslyn.Utilities;
namespace Microsoft.CodeAnalysis.CodeStyle;
diff --git a/src/Analyzers/Core/Analyzers/AbstractCodeQualityDiagnosticAnalyzer.cs b/src/Analyzers/Core/Analyzers/AbstractCodeQualityDiagnosticAnalyzer.cs
index cf388d119420c..a04161d32b1d7 100644
--- a/src/Analyzers/Core/Analyzers/AbstractCodeQualityDiagnosticAnalyzer.cs
+++ b/src/Analyzers/Core/Analyzers/AbstractCodeQualityDiagnosticAnalyzer.cs
@@ -5,7 +5,6 @@
using System.Collections.Immutable;
using Microsoft.CodeAnalysis.CodeStyle;
using Microsoft.CodeAnalysis.Diagnostics;
-using Microsoft.CodeAnalysis.Simplification;
namespace Microsoft.CodeAnalysis.CodeQuality;
diff --git a/src/Analyzers/Core/Analyzers/AddRequiredParentheses/AbstractAddRequiredParenthesesDiagnosticAnalyzer.cs b/src/Analyzers/Core/Analyzers/AddRequiredParentheses/AbstractAddRequiredParenthesesDiagnosticAnalyzer.cs
index 7fd9f9a64c66e..75fe79115341b 100644
--- a/src/Analyzers/Core/Analyzers/AddRequiredParentheses/AbstractAddRequiredParenthesesDiagnosticAnalyzer.cs
+++ b/src/Analyzers/Core/Analyzers/AddRequiredParentheses/AbstractAddRequiredParenthesesDiagnosticAnalyzer.cs
@@ -4,13 +4,10 @@
using System.Collections.Generic;
using System.Collections.Immutable;
-using System.Diagnostics;
using Microsoft.CodeAnalysis.CodeStyle;
using Microsoft.CodeAnalysis.Diagnostics;
-using Microsoft.CodeAnalysis.Options;
using Microsoft.CodeAnalysis.Precedence;
using Microsoft.CodeAnalysis.RemoveUnnecessaryParentheses;
-using Roslyn.Utilities;
namespace Microsoft.CodeAnalysis.AddRequiredParentheses;
diff --git a/src/Analyzers/Core/Analyzers/DiagnosticCustomTags.cs b/src/Analyzers/Core/Analyzers/DiagnosticCustomTags.cs
index 05c5275fa1f7f..edf3612290edf 100644
--- a/src/Analyzers/Core/Analyzers/DiagnosticCustomTags.cs
+++ b/src/Analyzers/Core/Analyzers/DiagnosticCustomTags.cs
@@ -2,8 +2,6 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-#nullable disable
-
using System.Collections.Immutable;
using System.Diagnostics;
using Microsoft.CodeAnalysis.CodeStyle;
diff --git a/src/Analyzers/Core/Analyzers/EnforceOnBuildValues.cs b/src/Analyzers/Core/Analyzers/EnforceOnBuildValues.cs
index 6dc7526db970f..45b60093d331d 100644
--- a/src/Analyzers/Core/Analyzers/EnforceOnBuildValues.cs
+++ b/src/Analyzers/Core/Analyzers/EnforceOnBuildValues.cs
@@ -140,6 +140,7 @@ internal static class EnforceOnBuildValues
public const EnforceOnBuild ConvertAnonymousTypeToTuple = /*IDE0050*/ EnforceOnBuild.Never;
public const EnforceOnBuild RemoveUnreachableCode = /*IDE0035*/ EnforceOnBuild.Never; // Non-configurable fading diagnostic corresponding to CS0162.
public const EnforceOnBuild RemoveUnnecessarySuppression = /*IDE0079*/ EnforceOnBuild.Never; // IDE-only analyzer.
+ public const EnforceOnBuild CopilotImplementNotImplementedException = /*IDE3000*/ EnforceOnBuild.Never; // IDE-only analyzer.
// Pure IDE feature for lighting up editor features. Do not enforce on build.
public const EnforceOnBuild DetectProbableJsonStrings = /*JSON002*/ EnforceOnBuild.Never;
diff --git a/src/Analyzers/Core/Analyzers/Helpers/DiagnosticHelper.cs b/src/Analyzers/Core/Analyzers/Helpers/DiagnosticHelper.cs
index 6429b6c763d3f..b04b43d75d3a6 100644
--- a/src/Analyzers/Core/Analyzers/Helpers/DiagnosticHelper.cs
+++ b/src/Analyzers/Core/Analyzers/Helpers/DiagnosticHelper.cs
@@ -11,7 +11,6 @@
using System.Runtime.Serialization.Json;
using System.Text;
using Microsoft.CodeAnalysis.CodeStyle;
-using Microsoft.CodeAnalysis.PooledObjects;
using Roslyn.Utilities;
namespace Microsoft.CodeAnalysis.Diagnostics;
diff --git a/src/Analyzers/Core/Analyzers/IDEDiagnosticIdToOptionMappingHelper.cs b/src/Analyzers/Core/Analyzers/IDEDiagnosticIdToOptionMappingHelper.cs
index b657d4cd0f720..e3ae127f7728d 100644
--- a/src/Analyzers/Core/Analyzers/IDEDiagnosticIdToOptionMappingHelper.cs
+++ b/src/Analyzers/Core/Analyzers/IDEDiagnosticIdToOptionMappingHelper.cs
@@ -4,7 +4,6 @@
using System;
using System.Collections.Concurrent;
-using System.Collections.Generic;
using System.Collections.Immutable;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
diff --git a/src/Analyzers/Core/Analyzers/IDEDiagnosticIds.cs b/src/Analyzers/Core/Analyzers/IDEDiagnosticIds.cs
index 66cbc65fec400..5d2a44f2f4121 100644
--- a/src/Analyzers/Core/Analyzers/IDEDiagnosticIds.cs
+++ b/src/Analyzers/Core/Analyzers/IDEDiagnosticIds.cs
@@ -230,4 +230,7 @@ internal static class IDEDiagnosticIds
public const string ConstructorInitializerPlacementDiagnosticId = "IDE2004";
public const string ConditionalExpressionPlacementDiagnosticId = "IDE2005";
public const string ArrowExpressionClausePlacementDiagnosticId = "IDE2006";
+
+ // 3000 range for copilot features.
+ public const string CopilotImplementNotImplementedExceptionDiagnosticId = "IDE3000";
}
diff --git a/src/Analyzers/Core/Analyzers/NamingStyle/NamingStyleDiagnosticAnalyzerBase.cs b/src/Analyzers/Core/Analyzers/NamingStyle/NamingStyleDiagnosticAnalyzerBase.cs
index 9f0a78a621d0a..2917357fb50a3 100644
--- a/src/Analyzers/Core/Analyzers/NamingStyle/NamingStyleDiagnosticAnalyzerBase.cs
+++ b/src/Analyzers/Core/Analyzers/NamingStyle/NamingStyleDiagnosticAnalyzerBase.cs
@@ -6,11 +6,9 @@
using System.Collections.Concurrent;
using System.Collections.Immutable;
using System.Linq;
-using System.Threading;
using Microsoft.CodeAnalysis.CodeStyle;
using Microsoft.CodeAnalysis.NamingStyles;
using Microsoft.CodeAnalysis.Shared.Extensions;
-using Microsoft.CodeAnalysis.Simplification;
using Roslyn.Utilities;
namespace Microsoft.CodeAnalysis.Diagnostics.Analyzers.NamingStyles;
diff --git a/src/Analyzers/Core/Analyzers/NewLines/ConsecutiveStatementPlacement/AbstractConsecutiveStatementPlacementDiagnosticAnalyzer.cs b/src/Analyzers/Core/Analyzers/NewLines/ConsecutiveStatementPlacement/AbstractConsecutiveStatementPlacementDiagnosticAnalyzer.cs
index ae9f026291946..d3bd4e24ba3e3 100644
--- a/src/Analyzers/Core/Analyzers/NewLines/ConsecutiveStatementPlacement/AbstractConsecutiveStatementPlacementDiagnosticAnalyzer.cs
+++ b/src/Analyzers/Core/Analyzers/NewLines/ConsecutiveStatementPlacement/AbstractConsecutiveStatementPlacementDiagnosticAnalyzer.cs
@@ -2,7 +2,6 @@
// 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.Linq;
using System.Threading;
using Microsoft.CodeAnalysis.CodeStyle;
diff --git a/src/Analyzers/Core/Analyzers/NewLines/MultipleBlankLines/AbstractMultipleBlankLinesDiagnosticAnalyzer.cs b/src/Analyzers/Core/Analyzers/NewLines/MultipleBlankLines/AbstractMultipleBlankLinesDiagnosticAnalyzer.cs
index 1c7006f6e007a..2dcadfc761b3c 100644
--- a/src/Analyzers/Core/Analyzers/NewLines/MultipleBlankLines/AbstractMultipleBlankLinesDiagnosticAnalyzer.cs
+++ b/src/Analyzers/Core/Analyzers/NewLines/MultipleBlankLines/AbstractMultipleBlankLinesDiagnosticAnalyzer.cs
@@ -2,7 +2,6 @@
// 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.Threading;
using Microsoft.CodeAnalysis.CodeStyle;
using Microsoft.CodeAnalysis.Diagnostics;
diff --git a/src/Analyzers/Core/Analyzers/ParenthesesDiagnosticAnalyzersHelper.cs b/src/Analyzers/Core/Analyzers/ParenthesesDiagnosticAnalyzersHelper.cs
index 0e2a7ad3e5b88..bed0d607f92d0 100644
--- a/src/Analyzers/Core/Analyzers/ParenthesesDiagnosticAnalyzersHelper.cs
+++ b/src/Analyzers/Core/Analyzers/ParenthesesDiagnosticAnalyzersHelper.cs
@@ -7,7 +7,6 @@
using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.CodeAnalysis.Options;
using Microsoft.CodeAnalysis.Precedence;
-using Roslyn.Utilities;
namespace Microsoft.CodeAnalysis.RemoveUnnecessaryParentheses;
diff --git a/src/Analyzers/Core/Analyzers/PopulateSwitch/AbstractPopulateSwitchDiagnosticAnalyzer.cs b/src/Analyzers/Core/Analyzers/PopulateSwitch/AbstractPopulateSwitchDiagnosticAnalyzer.cs
index 0e68fc6b49fdc..d83beb780833f 100644
--- a/src/Analyzers/Core/Analyzers/PopulateSwitch/AbstractPopulateSwitchDiagnosticAnalyzer.cs
+++ b/src/Analyzers/Core/Analyzers/PopulateSwitch/AbstractPopulateSwitchDiagnosticAnalyzer.cs
@@ -2,10 +2,8 @@
// 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;
using System.Collections.Generic;
using System.Collections.Immutable;
-using System.Diagnostics;
using Microsoft.CodeAnalysis.CodeStyle;
using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.CodeAnalysis.Shared.Extensions;
diff --git a/src/Analyzers/Core/Analyzers/QualifyMemberAccess/AbstractQualifyMemberAccessDiagnosticAnalyzer.cs b/src/Analyzers/Core/Analyzers/QualifyMemberAccess/AbstractQualifyMemberAccessDiagnosticAnalyzer.cs
index 88d45c840dc76..931b836d09bcc 100644
--- a/src/Analyzers/Core/Analyzers/QualifyMemberAccess/AbstractQualifyMemberAccessDiagnosticAnalyzer.cs
+++ b/src/Analyzers/Core/Analyzers/QualifyMemberAccess/AbstractQualifyMemberAccessDiagnosticAnalyzer.cs
@@ -2,13 +2,10 @@
// 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 Microsoft.CodeAnalysis.CodeStyle;
using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.CodeAnalysis.Operations;
-using Microsoft.CodeAnalysis.Options;
using Microsoft.CodeAnalysis.Simplification;
-using Roslyn.Utilities;
namespace Microsoft.CodeAnalysis.QualifyMemberAccess;
diff --git a/src/Analyzers/Core/Analyzers/RemoveUnnecessarySuppressions/SuppressMessageAttributeState.cs b/src/Analyzers/Core/Analyzers/RemoveUnnecessarySuppressions/SuppressMessageAttributeState.cs
index 72af7310791af..7973a2f23d404 100644
--- a/src/Analyzers/Core/Analyzers/RemoveUnnecessarySuppressions/SuppressMessageAttributeState.cs
+++ b/src/Analyzers/Core/Analyzers/RemoveUnnecessarySuppressions/SuppressMessageAttributeState.cs
@@ -4,7 +4,6 @@
using System;
using System.Collections.Immutable;
-using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Threading;
using Microsoft.CodeAnalysis.Operations;
diff --git a/src/Analyzers/Core/Analyzers/SimplifyBooleanExpression/AbstractSimplifyConditionalDiagnosticAnalyzer.cs b/src/Analyzers/Core/Analyzers/SimplifyBooleanExpression/AbstractSimplifyConditionalDiagnosticAnalyzer.cs
index 558c79e19bf31..ced7f82e05d10 100644
--- a/src/Analyzers/Core/Analyzers/SimplifyBooleanExpression/AbstractSimplifyConditionalDiagnosticAnalyzer.cs
+++ b/src/Analyzers/Core/Analyzers/SimplifyBooleanExpression/AbstractSimplifyConditionalDiagnosticAnalyzer.cs
@@ -4,7 +4,6 @@
using System.Collections.Immutable;
using System.Threading;
-using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CodeStyle;
using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.CodeAnalysis.LanguageService;
diff --git a/src/Analyzers/Core/Analyzers/SimplifyLinqExpression/AbstractSimplifyLinqExpressionDiagnosticAnalyzer.cs b/src/Analyzers/Core/Analyzers/SimplifyLinqExpression/AbstractSimplifyLinqExpressionDiagnosticAnalyzer.cs
index 0ec7a513d5e1c..e57851f20ebba 100644
--- a/src/Analyzers/Core/Analyzers/SimplifyLinqExpression/AbstractSimplifyLinqExpressionDiagnosticAnalyzer.cs
+++ b/src/Analyzers/Core/Analyzers/SimplifyLinqExpression/AbstractSimplifyLinqExpressionDiagnosticAnalyzer.cs
@@ -2,7 +2,6 @@
// 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;
using System.Collections.Immutable;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
diff --git a/src/Analyzers/Core/Analyzers/UseAutoProperty/AnalysisResult.cs b/src/Analyzers/Core/Analyzers/UseAutoProperty/AnalysisResult.cs
index e38aa38ee311e..98bd2523855dd 100644
--- a/src/Analyzers/Core/Analyzers/UseAutoProperty/AnalysisResult.cs
+++ b/src/Analyzers/Core/Analyzers/UseAutoProperty/AnalysisResult.cs
@@ -2,7 +2,6 @@
// 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;
using Microsoft.CodeAnalysis.CodeStyle;
namespace Microsoft.CodeAnalysis.UseAutoProperty;
diff --git a/src/Analyzers/Core/Analyzers/UseAutoProperty/UseAutoPropertiesHelpers.cs b/src/Analyzers/Core/Analyzers/UseAutoProperty/UseAutoPropertiesHelpers.cs
index 19679570faf23..d69fae6d30bfd 100644
--- a/src/Analyzers/Core/Analyzers/UseAutoProperty/UseAutoPropertiesHelpers.cs
+++ b/src/Analyzers/Core/Analyzers/UseAutoProperty/UseAutoPropertiesHelpers.cs
@@ -2,12 +2,6 @@
// 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;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
namespace Microsoft.CodeAnalysis.UseAutoProperty;
internal static class UseAutoPropertiesHelpers
diff --git a/src/Analyzers/Core/Analyzers/UseCollectionInitializer/AbstractObjectCreationExpressionAnalyzer.cs b/src/Analyzers/Core/Analyzers/UseCollectionInitializer/AbstractObjectCreationExpressionAnalyzer.cs
index 5dee730834d73..682ab67dc1160 100644
--- a/src/Analyzers/Core/Analyzers/UseCollectionInitializer/AbstractObjectCreationExpressionAnalyzer.cs
+++ b/src/Analyzers/Core/Analyzers/UseCollectionInitializer/AbstractObjectCreationExpressionAnalyzer.cs
@@ -9,7 +9,6 @@
using Microsoft.CodeAnalysis.LanguageService;
using Microsoft.CodeAnalysis.PooledObjects;
using Microsoft.CodeAnalysis.Shared.Extensions;
-using Microsoft.CodeAnalysis.UseCollectionExpression;
namespace Microsoft.CodeAnalysis.UseCollectionInitializer;
@@ -37,7 +36,8 @@ internal abstract class AbstractObjectCreationExpressionAnalyzer<
{
public readonly record struct AnalysisResult(
ImmutableArray PreMatches,
- ImmutableArray PostMatches);
+ ImmutableArray PostMatches,
+ bool ChangesSemantics);
protected UpdateExpressionState State;
@@ -48,7 +48,7 @@ public readonly record struct AnalysisResult(
protected SemanticModel SemanticModel => this.State.SemanticModel;
protected abstract bool ShouldAnalyze(CancellationToken cancellationToken);
- protected abstract bool TryAddMatches(ArrayBuilder preMatches, ArrayBuilder postMatches, CancellationToken cancellationToken);
+ protected abstract bool TryAddMatches(ArrayBuilder preMatches, ArrayBuilder postMatches, out bool changesSemantics, CancellationToken cancellationToken);
protected abstract bool IsInitializerOfLocalDeclarationStatement(
TLocalDeclarationStatementSyntax localDeclarationStatement, TObjectCreationExpressionSyntax rootExpression, [NotNullWhen(true)] out TVariableDeclaratorSyntax? variableDeclarator);
@@ -87,10 +87,10 @@ protected AnalysisResult AnalyzeWorker(CancellationToken cancellationToken)
using var _1 = ArrayBuilder.GetInstance(out var preMatches);
using var _2 = ArrayBuilder.GetInstance(out var postMatches);
- if (!TryAddMatches(preMatches, postMatches, cancellationToken))
+ if (!TryAddMatches(preMatches, postMatches, out var mayChangeSemantics, cancellationToken))
return default;
- return new(preMatches.ToImmutableAndClear(), postMatches.ToImmutableAndClear());
+ return new(preMatches.ToImmutableAndClear(), postMatches.ToImmutableAndClear(), mayChangeSemantics);
}
protected UpdateExpressionState? TryInitializeState(
diff --git a/src/Analyzers/Core/Analyzers/UseCollectionInitializer/AbstractUseCollectionInitializerAnalyzer.cs b/src/Analyzers/Core/Analyzers/UseCollectionInitializer/AbstractUseCollectionInitializerAnalyzer.cs
index 1a8d7140e317b..e5093ced3782a 100644
--- a/src/Analyzers/Core/Analyzers/UseCollectionInitializer/AbstractUseCollectionInitializerAnalyzer.cs
+++ b/src/Analyzers/Core/Analyzers/UseCollectionInitializer/AbstractUseCollectionInitializerAnalyzer.cs
@@ -50,7 +50,10 @@ internal abstract class AbstractUseCollectionInitializerAnalyzer<
protected abstract bool IsComplexElementInitializer(SyntaxNode expression);
protected abstract bool HasExistingInvalidInitializerForCollection();
protected abstract bool AnalyzeMatchesAndCollectionConstructorForCollectionExpression(
- ArrayBuilder> preMatches, ArrayBuilder> postMatches, CancellationToken cancellationToken);
+ ArrayBuilder> preMatches,
+ ArrayBuilder> postMatches,
+ out bool mayChangeSemantics,
+ CancellationToken cancellationToken);
protected abstract IUpdateExpressionSyntaxHelper SyntaxHelper { get; }
@@ -66,7 +69,7 @@ public AnalysisResult Analyze(
return default;
this.Initialize(state.Value, objectCreationExpression, analyzeForCollectionExpression);
- var (preMatches, postMatches) = this.AnalyzeWorker(cancellationToken);
+ var (preMatches, postMatches, mayChangeSemantics) = this.AnalyzeWorker(cancellationToken);
// If analysis failed entirely, immediately bail out.
if (preMatches.IsDefault || postMatches.IsDefault)
@@ -81,15 +84,19 @@ public AnalysisResult Analyze(
// other words, we don't want to suggest changing `new List()` to `new List() { }` as that's just
// noise. So convert empty results to an invalid result here.
if (analyzeForCollectionExpression)
- return new(preMatches, postMatches);
+ return new(preMatches, postMatches, mayChangeSemantics);
// Downgrade an empty result to a failure for the normal collection-initializer case.
- return postMatches.IsEmpty ? default : new(preMatches, postMatches);
+ return postMatches.IsEmpty ? default : new(preMatches, postMatches, mayChangeSemantics);
}
protected sealed override bool TryAddMatches(
- ArrayBuilder> preMatches, ArrayBuilder> postMatches, CancellationToken cancellationToken)
+ ArrayBuilder> preMatches,
+ ArrayBuilder> postMatches,
+ out bool mayChangeSemantics,
+ CancellationToken cancellationToken)
{
+ mayChangeSemantics = false;
var seenInvocation = false;
var seenIndexAssignment = false;
@@ -127,7 +134,10 @@ protected sealed override bool TryAddMatches(
}
if (_analyzeForCollectionExpression)
- return AnalyzeMatchesAndCollectionConstructorForCollectionExpression(preMatches, postMatches, cancellationToken);
+ {
+ return AnalyzeMatchesAndCollectionConstructorForCollectionExpression(
+ preMatches, postMatches, out mayChangeSemantics, cancellationToken);
+ }
return true;
}
diff --git a/src/Analyzers/Core/Analyzers/UseCollectionInitializer/AbstractUseCollectionInitializerDiagnosticAnalyzer.cs b/src/Analyzers/Core/Analyzers/UseCollectionInitializer/AbstractUseCollectionInitializerDiagnosticAnalyzer.cs
index 671b11f76ec94..d4410ebb3eaee 100644
--- a/src/Analyzers/Core/Analyzers/UseCollectionInitializer/AbstractUseCollectionInitializerDiagnosticAnalyzer.cs
+++ b/src/Analyzers/Core/Analyzers/UseCollectionInitializer/AbstractUseCollectionInitializerDiagnosticAnalyzer.cs
@@ -68,10 +68,7 @@ public override DiagnosticAnalyzerCategory GetAnalyzerCategory()
isUnnecessary: true);
protected AbstractUseCollectionInitializerDiagnosticAnalyzer()
- : base(
- [
- (s_descriptor, CodeStyleOptions2.PreferCollectionInitializer)
- ])
+ : base([(s_descriptor, CodeStyleOptions2.PreferCollectionInitializer)])
{
}
@@ -117,9 +114,9 @@ private void OnCompilationStart(CompilationStartAnalysisContext context)
// as a non-local diagnostic and would not participate in lightbulb for computing code fixes.
var expressionType = context.Compilation.ExpressionOfTType();
context.RegisterCodeBlockStartAction(blockStartContext =>
- blockStartContext.RegisterSyntaxNodeAction(
- nodeContext => AnalyzeNode(nodeContext, ienumerableType, expressionType),
- matchKindsArray));
+ blockStartContext.RegisterSyntaxNodeAction(
+ nodeContext => AnalyzeNode(nodeContext, ienumerableType, expressionType),
+ matchKindsArray));
}
private void AnalyzeNode(
@@ -206,13 +203,13 @@ private void AnalyzeNode(
if (!preferInitializerOption.Value)
return null;
- var (_, matches) = analyzer.Analyze(semanticModel, syntaxFacts, objectCreationExpression, analyzeForCollectionExpression: false, cancellationToken);
+ var (_, matches, changesSemantics) = analyzer.Analyze(semanticModel, syntaxFacts, objectCreationExpression, analyzeForCollectionExpression: false, cancellationToken);
// If analysis failed, we can't change this, no matter what.
if (matches.IsDefault)
return null;
- return (matches, shouldUseCollectionExpression: false, changesSemantics: false);
+ return (matches, shouldUseCollectionExpression: false, changesSemantics);
}
(ImmutableArray> matches, bool shouldUseCollectionExpression, bool changesSemantics)? GetCollectionExpressionMatches()
@@ -224,7 +221,7 @@ private void AnalyzeNode(
if (!this.AreCollectionExpressionsSupported(context.Compilation))
return null;
- var (preMatches, postMatches) = analyzer.Analyze(semanticModel, syntaxFacts, objectCreationExpression, analyzeForCollectionExpression: true, cancellationToken);
+ var (preMatches, postMatches, changesSemantics1) = analyzer.Analyze(semanticModel, syntaxFacts, objectCreationExpression, analyzeForCollectionExpression: true, cancellationToken);
// If analysis failed, we can't change this, no matter what.
if (preMatches.IsDefault || postMatches.IsDefault)
@@ -232,10 +229,10 @@ private void AnalyzeNode(
// Check if it would actually be legal to use a collection expression here though.
var allowSemanticsChange = preferExpressionOption.Value == CollectionExpressionPreference.WhenTypesLooselyMatch;
- if (!CanUseCollectionExpression(semanticModel, objectCreationExpression, expressionType, preMatches, allowSemanticsChange, cancellationToken, out var changesSemantics))
+ if (!CanUseCollectionExpression(semanticModel, objectCreationExpression, expressionType, preMatches, allowSemanticsChange, cancellationToken, out var changesSemantics2))
return null;
- return (preMatches.Concat(postMatches), shouldUseCollectionExpression: true, changesSemantics);
+ return (preMatches.Concat(postMatches), shouldUseCollectionExpression: true, changesSemantics1 || changesSemantics2);
}
}
diff --git a/src/Analyzers/Core/Analyzers/UseConditionalExpression/AbstractUseConditionalExpressionDiagnosticAnalyzer.cs b/src/Analyzers/Core/Analyzers/UseConditionalExpression/AbstractUseConditionalExpressionDiagnosticAnalyzer.cs
index 63c14bc0cf351..0c8a9804428c1 100644
--- a/src/Analyzers/Core/Analyzers/UseConditionalExpression/AbstractUseConditionalExpressionDiagnosticAnalyzer.cs
+++ b/src/Analyzers/Core/Analyzers/UseConditionalExpression/AbstractUseConditionalExpressionDiagnosticAnalyzer.cs
@@ -11,26 +11,21 @@
namespace Microsoft.CodeAnalysis.UseConditionalExpression;
-internal abstract class AbstractUseConditionalExpressionDiagnosticAnalyzer
- : AbstractBuiltInCodeStyleDiagnosticAnalyzer
+internal abstract class AbstractUseConditionalExpressionDiagnosticAnalyzer(
+ string descriptorId,
+ EnforceOnBuild enforceOnBuild,
+ LocalizableResourceString message,
+ PerLanguageOption2> option)
+ : AbstractBuiltInCodeStyleDiagnosticAnalyzer(descriptorId,
+ enforceOnBuild,
+ option,
+ new LocalizableResourceString(nameof(AnalyzersResources.Convert_to_conditional_expression), AnalyzersResources.ResourceManager, typeof(AnalyzersResources)),
+ message)
where TIfStatementSyntax : SyntaxNode
{
public sealed override DiagnosticAnalyzerCategory GetAnalyzerCategory()
=> DiagnosticAnalyzerCategory.SemanticSpanAnalysis;
- protected AbstractUseConditionalExpressionDiagnosticAnalyzer(
- string descriptorId,
- EnforceOnBuild enforceOnBuild,
- LocalizableResourceString message,
- PerLanguageOption2> option)
- : base(descriptorId,
- enforceOnBuild,
- option,
- new LocalizableResourceString(nameof(AnalyzersResources.Convert_to_conditional_expression), AnalyzersResources.ResourceManager, typeof(AnalyzersResources)),
- message)
- {
- }
-
protected abstract ISyntaxFacts GetSyntaxFacts();
protected abstract (bool matched, bool canSimplify) TryMatchPattern(
IConditionalOperation ifOperation, ISymbol containingSymbol, CancellationToken cancellationToken);
diff --git a/src/Analyzers/Core/Analyzers/UseConditionalExpression/ForAssignment/UseConditionalExpressionForAssignmentHelpers.cs b/src/Analyzers/Core/Analyzers/UseConditionalExpression/ForAssignment/UseConditionalExpressionForAssignmentHelpers.cs
index ef89d6ada6424..cb2916d775d49 100644
--- a/src/Analyzers/Core/Analyzers/UseConditionalExpression/ForAssignment/UseConditionalExpressionForAssignmentHelpers.cs
+++ b/src/Analyzers/Core/Analyzers/UseConditionalExpression/ForAssignment/UseConditionalExpressionForAssignmentHelpers.cs
@@ -209,12 +209,19 @@ private static bool TryGetAssignmentOrThrow(
// Both the WhenTrue and WhenFalse statements must be of the form:
// target = value;
- if (statement is IExpressionStatementOperation exprStatement &&
- exprStatement.Operation is ISimpleAssignmentOperation assignmentOp &&
- assignmentOp.Target != null)
+ if (statement is IExpressionStatementOperation exprStatement)
{
- assignment = assignmentOp;
- return true;
+ if (exprStatement.Operation is ISimpleAssignmentOperation { Target: not null } assignmentOp1)
+ {
+ assignment = assignmentOp1;
+ return true;
+ }
+
+ if (exprStatement.Operation is IConditionalAccessOperation { WhenNotNull: ISimpleAssignmentOperation assignmentOp2 })
+ {
+ assignment = assignmentOp2;
+ return true;
+ }
}
return false;
diff --git a/src/Analyzers/Core/Analyzers/UseNullPropagation/AbstractUseNullPropagationDiagnosticAnalyzer.cs b/src/Analyzers/Core/Analyzers/UseNullPropagation/AbstractUseNullPropagationDiagnosticAnalyzer.cs
index 51e3b7c980898..4bec6bacab283 100644
--- a/src/Analyzers/Core/Analyzers/UseNullPropagation/AbstractUseNullPropagationDiagnosticAnalyzer.cs
+++ b/src/Analyzers/Core/Analyzers/UseNullPropagation/AbstractUseNullPropagationDiagnosticAnalyzer.cs
@@ -397,6 +397,12 @@ private static TExpressionSyntax RemoveObjectCastIfAny(
if (node is TElementAccessExpressionSyntax elementAccess)
return (TExpressionSyntax?)syntaxFacts.GetExpressionOfElementAccessExpression(elementAccess);
+ if (syntaxFacts.SyntaxKinds.SimpleAssignmentExpression == node.RawKind && syntaxFacts.SupportsNullConditionalAssignment(node.SyntaxTree.Options))
+ {
+ syntaxFacts.GetPartsOfAssignmentExpressionOrStatement(node, out var left, out _, out _);
+ return (TExpressionSyntax)left;
+ }
+
return null;
}
}
diff --git a/src/Analyzers/Core/Analyzers/UseObjectInitializer/UseNamedMemberInitializerAnalyzer.cs b/src/Analyzers/Core/Analyzers/UseObjectInitializer/UseNamedMemberInitializerAnalyzer.cs
index 1564a3a2d687b..6760960332f27 100644
--- a/src/Analyzers/Core/Analyzers/UseObjectInitializer/UseNamedMemberInitializerAnalyzer.cs
+++ b/src/Analyzers/Core/Analyzers/UseObjectInitializer/UseNamedMemberInitializerAnalyzer.cs
@@ -69,8 +69,10 @@ protected sealed override bool ShouldAnalyze(CancellationToken cancellationToken
protected sealed override bool TryAddMatches(
ArrayBuilder> preMatches,
ArrayBuilder> postMatches,
+ out bool changesSemantics,
CancellationToken cancellationToken)
{
+ changesSemantics = false;
using var _1 = PooledHashSet.GetInstance(out var seenNames);
var initializer = this.SyntaxFacts.GetInitializerOfBaseObjectCreationExpression(_objectCreationExpression);
diff --git a/src/Analyzers/Core/Analyzers/UseThrowExpression/AbstractUseThrowExpressionDiagnosticAnalyzer.cs b/src/Analyzers/Core/Analyzers/UseThrowExpression/AbstractUseThrowExpressionDiagnosticAnalyzer.cs
index 2088447ffec98..7f5cdcd6cbfab 100644
--- a/src/Analyzers/Core/Analyzers/UseThrowExpression/AbstractUseThrowExpressionDiagnosticAnalyzer.cs
+++ b/src/Analyzers/Core/Analyzers/UseThrowExpression/AbstractUseThrowExpressionDiagnosticAnalyzer.cs
@@ -11,7 +11,6 @@
using Microsoft.CodeAnalysis.Operations;
using Microsoft.CodeAnalysis.Options;
using Microsoft.CodeAnalysis.Shared.Extensions;
-using Roslyn.Utilities;
namespace Microsoft.CodeAnalysis.UseThrowExpression;
diff --git a/src/Analyzers/Core/CodeFixes/AddAccessibilityModifiers/AbstractAddAccessibilityModifiersCodeFixProvider.cs b/src/Analyzers/Core/CodeFixes/AddAccessibilityModifiers/AbstractAddAccessibilityModifiersCodeFixProvider.cs
index feccbc95b2600..3253d23929b57 100644
--- a/src/Analyzers/Core/CodeFixes/AddAccessibilityModifiers/AbstractAddAccessibilityModifiersCodeFixProvider.cs
+++ b/src/Analyzers/Core/CodeFixes/AddAccessibilityModifiers/AbstractAddAccessibilityModifiersCodeFixProvider.cs
@@ -2,7 +2,6 @@
// 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;
using System.Collections.Immutable;
using System.Linq;
using System.Threading;
diff --git a/src/Analyzers/Core/CodeFixes/AddAccessibilityModifiers/AddAccessibilityModifiersHelpers.cs b/src/Analyzers/Core/CodeFixes/AddAccessibilityModifiers/AddAccessibilityModifiersHelpers.cs
index e8bb74983cb44..1c9e20fbac9cb 100644
--- a/src/Analyzers/Core/CodeFixes/AddAccessibilityModifiers/AddAccessibilityModifiersHelpers.cs
+++ b/src/Analyzers/Core/CodeFixes/AddAccessibilityModifiers/AddAccessibilityModifiersHelpers.cs
@@ -2,10 +2,8 @@
// 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.Threading;
using Microsoft.CodeAnalysis.Editing;
using Microsoft.CodeAnalysis.Shared.Extensions;
-using Roslyn.Utilities;
namespace Microsoft.CodeAnalysis.AddOrRemoveAccessibilityModifiers;
diff --git a/src/Analyzers/Core/CodeFixes/AddAnonymousTypeMemberName/AbstractAddAnonymousTypeMemberNameCodeFixProvider.cs b/src/Analyzers/Core/CodeFixes/AddAnonymousTypeMemberName/AbstractAddAnonymousTypeMemberNameCodeFixProvider.cs
index 29762c5ad3f12..db1c67659a107 100644
--- a/src/Analyzers/Core/CodeFixes/AddAnonymousTypeMemberName/AbstractAddAnonymousTypeMemberNameCodeFixProvider.cs
+++ b/src/Analyzers/Core/CodeFixes/AddAnonymousTypeMemberName/AbstractAddAnonymousTypeMemberNameCodeFixProvider.cs
@@ -2,7 +2,6 @@
// 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;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Threading;
diff --git a/src/Analyzers/Core/CodeFixes/AddObsoleteAttribute/AbstractAddObsoleteAttributeCodeFixProvider.cs b/src/Analyzers/Core/CodeFixes/AddObsoleteAttribute/AbstractAddObsoleteAttributeCodeFixProvider.cs
index 4c59eb92ce7ed..61a78a6f5ae33 100644
--- a/src/Analyzers/Core/CodeFixes/AddObsoleteAttribute/AbstractAddObsoleteAttributeCodeFixProvider.cs
+++ b/src/Analyzers/Core/CodeFixes/AddObsoleteAttribute/AbstractAddObsoleteAttributeCodeFixProvider.cs
@@ -7,7 +7,6 @@
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
-using Microsoft.CodeAnalysis.CodeActions;
using Microsoft.CodeAnalysis.CodeFixes;
using Microsoft.CodeAnalysis.Editing;
using Microsoft.CodeAnalysis.LanguageService;
diff --git a/src/Analyzers/Core/CodeFixes/AliasAmbiguousType/AbstractAliasAmbiguousTypeCodeFixProvider.cs b/src/Analyzers/Core/CodeFixes/AliasAmbiguousType/AbstractAliasAmbiguousTypeCodeFixProvider.cs
index 841a9a77dc4c9..a3f98de9b4f4d 100644
--- a/src/Analyzers/Core/CodeFixes/AliasAmbiguousType/AbstractAliasAmbiguousTypeCodeFixProvider.cs
+++ b/src/Analyzers/Core/CodeFixes/AliasAmbiguousType/AbstractAliasAmbiguousTypeCodeFixProvider.cs
@@ -6,8 +6,6 @@
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Linq;
-using System.Runtime.InteropServices;
-using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.AddImport;
using Microsoft.CodeAnalysis.CodeActions;
diff --git a/src/Analyzers/Core/CodeFixes/DocumentationComments/AbstractAddDocCommentNodesCodeFixProvider.cs b/src/Analyzers/Core/CodeFixes/DocumentationComments/AbstractAddDocCommentNodesCodeFixProvider.cs
index 41df8ea0b326a..39d5cba615d4a 100644
--- a/src/Analyzers/Core/CodeFixes/DocumentationComments/AbstractAddDocCommentNodesCodeFixProvider.cs
+++ b/src/Analyzers/Core/CodeFixes/DocumentationComments/AbstractAddDocCommentNodesCodeFixProvider.cs
@@ -12,7 +12,6 @@
using Microsoft.CodeAnalysis.CodeFixes;
using Microsoft.CodeAnalysis.Formatting;
using Microsoft.CodeAnalysis.Shared.Extensions;
-using Microsoft.CodeAnalysis.Text;
using Roslyn.Utilities;
namespace Microsoft.CodeAnalysis.DocumentationComments;
diff --git a/src/Analyzers/Core/CodeFixes/DocumentationComments/AbstractRemoveDocCommentNodeCodeFixProvider.cs b/src/Analyzers/Core/CodeFixes/DocumentationComments/AbstractRemoveDocCommentNodeCodeFixProvider.cs
index ba25d7971bd2c..e992a7e6fc30f 100644
--- a/src/Analyzers/Core/CodeFixes/DocumentationComments/AbstractRemoveDocCommentNodeCodeFixProvider.cs
+++ b/src/Analyzers/Core/CodeFixes/DocumentationComments/AbstractRemoveDocCommentNodeCodeFixProvider.cs
@@ -11,7 +11,6 @@
using Microsoft.CodeAnalysis.CodeFixes;
using Microsoft.CodeAnalysis.Shared.Extensions;
using Microsoft.CodeAnalysis.Text;
-using Roslyn.Utilities;
namespace Microsoft.CodeAnalysis.DocumentationComments;
diff --git a/src/Analyzers/Core/CodeFixes/FileHeaders/AbstractFileHeaderCodeFixProvider.cs b/src/Analyzers/Core/CodeFixes/FileHeaders/AbstractFileHeaderCodeFixProvider.cs
index 40061d4fb71dd..07605e3783cdf 100644
--- a/src/Analyzers/Core/CodeFixes/FileHeaders/AbstractFileHeaderCodeFixProvider.cs
+++ b/src/Analyzers/Core/CodeFixes/FileHeaders/AbstractFileHeaderCodeFixProvider.cs
@@ -2,7 +2,6 @@
// 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;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.IO;
diff --git a/src/Analyzers/Core/CodeFixes/ForEachCast/AbstractForEachCastCodeFixProvider.cs b/src/Analyzers/Core/CodeFixes/ForEachCast/AbstractForEachCastCodeFixProvider.cs
index 87cff8def721e..cfd86259a4a42 100644
--- a/src/Analyzers/Core/CodeFixes/ForEachCast/AbstractForEachCastCodeFixProvider.cs
+++ b/src/Analyzers/Core/CodeFixes/ForEachCast/AbstractForEachCastCodeFixProvider.cs
@@ -2,12 +2,10 @@
// 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;
using System.Collections.Immutable;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
-using Microsoft.CodeAnalysis.CodeActions;
using Microsoft.CodeAnalysis.CodeFixes;
using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.CodeAnalysis.Editing;
diff --git a/src/Analyzers/Core/CodeFixes/GenerateConstructor/AbstractGenerateConstructorService.State.cs b/src/Analyzers/Core/CodeFixes/GenerateConstructor/AbstractGenerateConstructorService.State.cs
index 6a37a3b9d4ab7..e59af87ddedd5 100644
--- a/src/Analyzers/Core/CodeFixes/GenerateConstructor/AbstractGenerateConstructorService.State.cs
+++ b/src/Analyzers/Core/CodeFixes/GenerateConstructor/AbstractGenerateConstructorService.State.cs
@@ -15,10 +15,8 @@
using Microsoft.CodeAnalysis.FindSymbols;
using Microsoft.CodeAnalysis.Host;
using Microsoft.CodeAnalysis.LanguageService;
-using Microsoft.CodeAnalysis.PooledObjects;
using Microsoft.CodeAnalysis.Shared.Extensions;
using Microsoft.CodeAnalysis.Shared.Utilities;
-using Microsoft.CodeAnalysis.Utilities;
using Roslyn.Utilities;
#if CODE_STYLE
diff --git a/src/Analyzers/Core/CodeFixes/GenerateConstructor/AbstractGenerateConstructorService.cs b/src/Analyzers/Core/CodeFixes/GenerateConstructor/AbstractGenerateConstructorService.cs
index c43f64ffbb3d0..cf267839ece5f 100644
--- a/src/Analyzers/Core/CodeFixes/GenerateConstructor/AbstractGenerateConstructorService.cs
+++ b/src/Analyzers/Core/CodeFixes/GenerateConstructor/AbstractGenerateConstructorService.cs
@@ -15,7 +15,6 @@
using Microsoft.CodeAnalysis.Shared.Collections;
using Microsoft.CodeAnalysis.Shared.Extensions;
using Microsoft.CodeAnalysis.Shared.Utilities;
-using Microsoft.CodeAnalysis.Utilities;
using Roslyn.Utilities;
namespace Microsoft.CodeAnalysis.GenerateMember.GenerateConstructor;
diff --git a/src/Analyzers/Core/CodeFixes/GenerateConstructor/IGenerateConstructorService.cs b/src/Analyzers/Core/CodeFixes/GenerateConstructor/IGenerateConstructorService.cs
index e44d9b87d1ed2..6606e909d748b 100644
--- a/src/Analyzers/Core/CodeFixes/GenerateConstructor/IGenerateConstructorService.cs
+++ b/src/Analyzers/Core/CodeFixes/GenerateConstructor/IGenerateConstructorService.cs
@@ -6,7 +6,6 @@
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.CodeActions;
-using Microsoft.CodeAnalysis.CodeGeneration;
using Microsoft.CodeAnalysis.Host;
namespace Microsoft.CodeAnalysis.GenerateMember.GenerateConstructor;
diff --git a/src/Analyzers/Core/CodeFixes/GenerateDefaultConstructors/GenerateDefaultConstructorsCodeAction.cs b/src/Analyzers/Core/CodeFixes/GenerateDefaultConstructors/GenerateDefaultConstructorsCodeAction.cs
index 6aed37df43145..67ef2bbaac580 100644
--- a/src/Analyzers/Core/CodeFixes/GenerateDefaultConstructors/GenerateDefaultConstructorsCodeAction.cs
+++ b/src/Analyzers/Core/CodeFixes/GenerateDefaultConstructors/GenerateDefaultConstructorsCodeAction.cs
@@ -10,7 +10,6 @@
using Microsoft.CodeAnalysis.CodeGeneration;
using Microsoft.CodeAnalysis.Editing;
using Microsoft.CodeAnalysis.Shared.Extensions;
-using Roslyn.Utilities;
#if CODE_STYLE
using DeclarationModifiers = Microsoft.CodeAnalysis.Internal.Editing.DeclarationModifiers;
diff --git a/src/Analyzers/Core/CodeFixes/GenerateEnumMember/AbstractGenerateEnumMemberService.cs b/src/Analyzers/Core/CodeFixes/GenerateEnumMember/AbstractGenerateEnumMemberService.cs
index c7912852061bb..7bc5f356d097d 100644
--- a/src/Analyzers/Core/CodeFixes/GenerateEnumMember/AbstractGenerateEnumMemberService.cs
+++ b/src/Analyzers/Core/CodeFixes/GenerateEnumMember/AbstractGenerateEnumMemberService.cs
@@ -2,8 +2,6 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-#nullable disable
-
using System.Collections.Immutable;
using System.Threading;
using System.Threading.Tasks;
diff --git a/src/Analyzers/Core/CodeFixes/GenerateMember/AbstractGenerateMemberCodeFixProvider.cs b/src/Analyzers/Core/CodeFixes/GenerateMember/AbstractGenerateMemberCodeFixProvider.cs
index 81e779dad1590..c254ca042d3ac 100644
--- a/src/Analyzers/Core/CodeFixes/GenerateMember/AbstractGenerateMemberCodeFixProvider.cs
+++ b/src/Analyzers/Core/CodeFixes/GenerateMember/AbstractGenerateMemberCodeFixProvider.cs
@@ -8,7 +8,6 @@
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.CodeActions;
-using Microsoft.CodeAnalysis.CodeGeneration;
using Microsoft.CodeAnalysis.LanguageService;
using Microsoft.CodeAnalysis.Shared.Extensions;
using Microsoft.CodeAnalysis.Text;
diff --git a/src/Analyzers/Core/CodeFixes/GenerateMember/AbstractGenerateMemberService.cs b/src/Analyzers/Core/CodeFixes/GenerateMember/AbstractGenerateMemberService.cs
index c804217770776..066b43781528e 100644
--- a/src/Analyzers/Core/CodeFixes/GenerateMember/AbstractGenerateMemberService.cs
+++ b/src/Analyzers/Core/CodeFixes/GenerateMember/AbstractGenerateMemberService.cs
@@ -64,8 +64,13 @@ protected static bool TryDetermineTypeToGenerateIn(
TryDetermineTypeToGenerateInWorker(
document, containingType, simpleNameOrMemberAccessExpression, cancellationToken, out typeToGenerateIn, out isStatic, out isColorColorCase);
- typeToGenerateIn = typeToGenerateIn?.OriginalDefinition;
+ if (typeToGenerateIn.IsNullable(out var underlyingType) &&
+ underlyingType is INamedTypeSymbol underlyingNamedType)
+ {
+ typeToGenerateIn = underlyingNamedType;
+ }
+ typeToGenerateIn = typeToGenerateIn?.OriginalDefinition;
return typeToGenerateIn != null;
}
@@ -96,11 +101,8 @@ private static void TryDetermineTypeToGenerateInWorker(
DetermineTypeToGenerateInWorker(
semanticModel, beforeDotExpression, out typeToGenerateIn, out isStatic, out isColorColorCase, cancellationToken);
}
-
- return;
}
-
- if (syntaxFacts.IsConditionalAccessExpression(expression))
+ else if (syntaxFacts.IsConditionalAccessExpression(expression))
{
var beforeDotExpression = syntaxFacts.GetExpressionOfConditionalAccessExpression(expression);
@@ -108,17 +110,9 @@ private static void TryDetermineTypeToGenerateInWorker(
{
DetermineTypeToGenerateInWorker(
semanticModel, beforeDotExpression, out typeToGenerateIn, out isStatic, out isColorColorCase, cancellationToken);
- if (typeToGenerateIn.IsNullable(out var underlyingType) &&
- underlyingType is INamedTypeSymbol underlyingNamedType)
- {
- typeToGenerateIn = underlyingNamedType;
- }
}
-
- return;
}
-
- if (syntaxFacts.IsPointerMemberAccessExpression(expression))
+ else if (syntaxFacts.IsPointerMemberAccessExpression(expression))
{
var beforeArrowExpression = syntaxFacts.GetExpressionOfMemberAccessExpression(expression);
if (beforeArrowExpression != null)
@@ -128,14 +122,10 @@ private static void TryDetermineTypeToGenerateInWorker(
if (typeInfo.Type is IPointerTypeSymbol pointerType)
{
typeToGenerateIn = pointerType.PointedAtType as INamedTypeSymbol;
- isStatic = false;
}
}
-
- return;
}
-
- if (syntaxFacts.IsAttributeNamedArgumentIdentifier(expression))
+ else if (syntaxFacts.IsAttributeNamedArgumentIdentifier(expression))
{
var attributeNode = expression.GetAncestors().FirstOrDefault(syntaxFacts.IsAttribute);
Contract.ThrowIfNull(attributeNode);
@@ -144,16 +134,11 @@ private static void TryDetermineTypeToGenerateInWorker(
var attributeType = semanticModel.GetTypeInfo(attributeName, cancellationToken);
typeToGenerateIn = attributeType.Type as INamedTypeSymbol;
- isStatic = false;
- return;
}
-
- if (syntaxFacts.IsMemberInitializerNamedAssignmentIdentifier(
+ else if (syntaxFacts.IsMemberInitializerNamedAssignmentIdentifier(
expression, out var initializedObject))
{
typeToGenerateIn = semanticModel.GetTypeInfo(initializedObject, cancellationToken).Type as INamedTypeSymbol;
- isStatic = false;
- return;
}
else if (syntaxFacts.IsNameOfSubpattern(expression))
{
@@ -164,15 +149,23 @@ private static void TryDetermineTypeToGenerateInWorker(
// something like: { [|X|]: int i } or like: Blah { [|X|]: int i }
var inferenceService = semanticDocument.Document.GetRequiredLanguageService();
typeToGenerateIn = inferenceService.InferType(semanticModel, propertyPatternClause, objectAsDefault: true, cancellationToken) as INamedTypeSymbol;
-
- isStatic = false;
- return;
}
}
+ else if (syntaxFacts.IsMemberBindingExpression(expression))
+ {
+ var target = syntaxFacts.GetTargetOfMemberBinding(expression);
- // Generating into the containing type.
- typeToGenerateIn = containingType;
- isStatic = syntaxFacts.IsInStaticContext(expression);
+ if (target != null)
+ {
+ typeToGenerateIn = semanticModel.GetTypeInfo(target, cancellationToken).Type as INamedTypeSymbol;
+ }
+ }
+ else
+ {
+ // Generating into the containing type.
+ typeToGenerateIn = containingType;
+ isStatic = syntaxFacts.IsInStaticContext(expression);
+ }
}
private static void DetermineTypeToGenerateInWorker(
diff --git a/src/Analyzers/Core/CodeFixes/GenerateParameterizedMember/AbstractGenerateConversionService.cs b/src/Analyzers/Core/CodeFixes/GenerateParameterizedMember/AbstractGenerateConversionService.cs
index 596ae892b8e81..6b7f6706f78ab 100644
--- a/src/Analyzers/Core/CodeFixes/GenerateParameterizedMember/AbstractGenerateConversionService.cs
+++ b/src/Analyzers/Core/CodeFixes/GenerateParameterizedMember/AbstractGenerateConversionService.cs
@@ -2,14 +2,11 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-#nullable disable
-
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.CodeActions;
-using Microsoft.CodeAnalysis.CodeGeneration;
using Microsoft.CodeAnalysis.Internal.Log;
namespace Microsoft.CodeAnalysis.GenerateMember.GenerateParameterizedMember;
diff --git a/src/Analyzers/Core/CodeFixes/GenerateParameterizedMember/AbstractGenerateDeconstructMethodService.cs b/src/Analyzers/Core/CodeFixes/GenerateParameterizedMember/AbstractGenerateDeconstructMethodService.cs
index e5733af1c5217..fd41ad0aeed5d 100644
--- a/src/Analyzers/Core/CodeFixes/GenerateParameterizedMember/AbstractGenerateDeconstructMethodService.cs
+++ b/src/Analyzers/Core/CodeFixes/GenerateParameterizedMember/AbstractGenerateDeconstructMethodService.cs
@@ -6,7 +6,6 @@
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.CodeActions;
-using Microsoft.CodeAnalysis.CodeGeneration;
using Microsoft.CodeAnalysis.Internal.Log;
namespace Microsoft.CodeAnalysis.GenerateMember.GenerateParameterizedMember;
diff --git a/src/Analyzers/Core/CodeFixes/GenerateParameterizedMember/AbstractGenerateMethodService.State.cs b/src/Analyzers/Core/CodeFixes/GenerateParameterizedMember/AbstractGenerateMethodService.State.cs
index 80ce3f8f46692..161124c7c707b 100644
--- a/src/Analyzers/Core/CodeFixes/GenerateParameterizedMember/AbstractGenerateMethodService.State.cs
+++ b/src/Analyzers/Core/CodeFixes/GenerateParameterizedMember/AbstractGenerateMethodService.State.cs
@@ -14,7 +14,6 @@
using Microsoft.CodeAnalysis.PooledObjects;
using Microsoft.CodeAnalysis.Shared.Extensions;
using Microsoft.CodeAnalysis.Shared.Utilities;
-using Microsoft.CodeAnalysis.Utilities;
using Roslyn.Utilities;
namespace Microsoft.CodeAnalysis.GenerateMember.GenerateParameterizedMember;
diff --git a/src/Analyzers/Core/CodeFixes/GenerateParameterizedMember/AbstractGenerateMethodService.cs b/src/Analyzers/Core/CodeFixes/GenerateParameterizedMember/AbstractGenerateMethodService.cs
index 466eff0317b09..ee4269d346b55 100644
--- a/src/Analyzers/Core/CodeFixes/GenerateParameterizedMember/AbstractGenerateMethodService.cs
+++ b/src/Analyzers/Core/CodeFixes/GenerateParameterizedMember/AbstractGenerateMethodService.cs
@@ -2,13 +2,10 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-#nullable disable
-
using System.Collections.Immutable;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.CodeActions;
-using Microsoft.CodeAnalysis.CodeGeneration;
using Microsoft.CodeAnalysis.Internal.Log;
using Microsoft.CodeAnalysis.LanguageService;
diff --git a/src/Analyzers/Core/CodeFixes/GenerateParameterizedMember/AbstractGenerateParameterizedMemberService.AbstractInvocationInfo.cs b/src/Analyzers/Core/CodeFixes/GenerateParameterizedMember/AbstractGenerateParameterizedMemberService.AbstractInvocationInfo.cs
index 163d6abfdb221..98c664fbbe944 100644
--- a/src/Analyzers/Core/CodeFixes/GenerateParameterizedMember/AbstractGenerateParameterizedMemberService.AbstractInvocationInfo.cs
+++ b/src/Analyzers/Core/CodeFixes/GenerateParameterizedMember/AbstractGenerateParameterizedMemberService.AbstractInvocationInfo.cs
@@ -2,8 +2,6 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-#nullable disable
-
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Linq;
diff --git a/src/Analyzers/Core/CodeFixes/GenerateParameterizedMember/AbstractGenerateParameterizedMemberService.CodeAction.cs b/src/Analyzers/Core/CodeFixes/GenerateParameterizedMember/AbstractGenerateParameterizedMemberService.CodeAction.cs
index c97ab60e9897b..814681b4c53f1 100644
--- a/src/Analyzers/Core/CodeFixes/GenerateParameterizedMember/AbstractGenerateParameterizedMemberService.CodeAction.cs
+++ b/src/Analyzers/Core/CodeFixes/GenerateParameterizedMember/AbstractGenerateParameterizedMemberService.CodeAction.cs
@@ -2,14 +2,11 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-#nullable disable
-
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.CodeActions;
using Microsoft.CodeAnalysis.CodeGeneration;
using Microsoft.CodeAnalysis.Editing;
-using Roslyn.Utilities;
namespace Microsoft.CodeAnalysis.GenerateMember.GenerateParameterizedMember;
diff --git a/src/Analyzers/Core/CodeFixes/GenerateParameterizedMember/AbstractGenerateParameterizedMemberService.MethodSignatureInfo.cs b/src/Analyzers/Core/CodeFixes/GenerateParameterizedMember/AbstractGenerateParameterizedMemberService.MethodSignatureInfo.cs
index 8c1bcbe895d3e..8448595576acf 100644
--- a/src/Analyzers/Core/CodeFixes/GenerateParameterizedMember/AbstractGenerateParameterizedMemberService.MethodSignatureInfo.cs
+++ b/src/Analyzers/Core/CodeFixes/GenerateParameterizedMember/AbstractGenerateParameterizedMemberService.MethodSignatureInfo.cs
@@ -2,8 +2,6 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-#nullable disable
-
using System.Collections.Immutable;
using System.Threading;
using Microsoft.CodeAnalysis.CodeGeneration;
diff --git a/src/Analyzers/Core/CodeFixes/GenerateParameterizedMember/AbstractGenerateParameterizedMemberService.SignatureInfo.cs b/src/Analyzers/Core/CodeFixes/GenerateParameterizedMember/AbstractGenerateParameterizedMemberService.SignatureInfo.cs
index 73576ea358ae1..2c87d938875cc 100644
--- a/src/Analyzers/Core/CodeFixes/GenerateParameterizedMember/AbstractGenerateParameterizedMemberService.SignatureInfo.cs
+++ b/src/Analyzers/Core/CodeFixes/GenerateParameterizedMember/AbstractGenerateParameterizedMemberService.SignatureInfo.cs
@@ -17,7 +17,6 @@
using Microsoft.CodeAnalysis.LanguageService;
using Microsoft.CodeAnalysis.Shared.Extensions;
using Microsoft.CodeAnalysis.Shared.Utilities;
-using Microsoft.CodeAnalysis.Utilities;
using Roslyn.Utilities;
#if CODE_STYLE
diff --git a/src/Analyzers/Core/CodeFixes/GenerateParameterizedMember/IGenerateDeconstructMemberService.cs b/src/Analyzers/Core/CodeFixes/GenerateParameterizedMember/IGenerateDeconstructMemberService.cs
index 7d4bb7a675e5f..70b78b797c788 100644
--- a/src/Analyzers/Core/CodeFixes/GenerateParameterizedMember/IGenerateDeconstructMemberService.cs
+++ b/src/Analyzers/Core/CodeFixes/GenerateParameterizedMember/IGenerateDeconstructMemberService.cs
@@ -6,7 +6,6 @@
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.CodeActions;
-using Microsoft.CodeAnalysis.CodeGeneration;
using Microsoft.CodeAnalysis.Host;
namespace Microsoft.CodeAnalysis.GenerateMember.GenerateParameterizedMember;
diff --git a/src/Analyzers/Core/CodeFixes/GenerateParameterizedMember/IGenerateParameterizedMemberService.cs b/src/Analyzers/Core/CodeFixes/GenerateParameterizedMember/IGenerateParameterizedMemberService.cs
index 82dac9dd59a98..7a545f5da627e 100644
--- a/src/Analyzers/Core/CodeFixes/GenerateParameterizedMember/IGenerateParameterizedMemberService.cs
+++ b/src/Analyzers/Core/CodeFixes/GenerateParameterizedMember/IGenerateParameterizedMemberService.cs
@@ -6,7 +6,6 @@
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.CodeActions;
-using Microsoft.CodeAnalysis.CodeGeneration;
using Microsoft.CodeAnalysis.Host;
namespace Microsoft.CodeAnalysis.GenerateMember.GenerateParameterizedMember;
diff --git a/src/Analyzers/Core/CodeFixes/GenerateVariable/AbstractGenerateVariableService.State.cs b/src/Analyzers/Core/CodeFixes/GenerateVariable/AbstractGenerateVariableService.State.cs
index 5bc4fc2132c35..4bef0b1c90b76 100644
--- a/src/Analyzers/Core/CodeFixes/GenerateVariable/AbstractGenerateVariableService.State.cs
+++ b/src/Analyzers/Core/CodeFixes/GenerateVariable/AbstractGenerateVariableService.State.cs
@@ -8,7 +8,6 @@
using System.Collections.Immutable;
using System.Linq;
using System.Threading;
-using System.Threading.Tasks;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CodeGeneration;
using Microsoft.CodeAnalysis.FindSymbols;
@@ -462,7 +461,9 @@ private bool TryDetermineFieldType(CancellationToken cancellationToken)
// Substitute 'object' for all captured method type parameters. Note: we may need to
// do this for things like anonymous types, as well as captured type parameters that
// aren't in scope in the destination type.
- var capturedMethodTypeParameters = inferredType.GetReferencedMethodTypeParameters();
+ using var _1 = ArrayBuilder.GetInstance(out var capturedMethodTypeParameters);
+ inferredType.AddReferencedMethodTypeParameters(capturedMethodTypeParameters);
+
var mapping = capturedMethodTypeParameters.ToDictionary(tp => tp,
tp => compilation.ObjectType);
@@ -474,7 +475,7 @@ private bool TryDetermineFieldType(CancellationToken cancellationToken)
var enclosingMethodSymbol = _document.SemanticModel.GetEnclosingSymbol(SimpleNameOrMemberAccessExpressionOpt.SpanStart, cancellationToken);
if (enclosingMethodSymbol != null && enclosingMethodSymbol.TypeParameters != null && enclosingMethodSymbol.TypeParameters.Length != 0)
{
- using var _ = ArrayBuilder.GetInstance(out var combinedTypeParameters);
+ using var _2 = ArrayBuilder.GetInstance(out var combinedTypeParameters);
combinedTypeParameters.AddRange(availableTypeParameters);
combinedTypeParameters.AddRange(enclosingMethodSymbol.TypeParameters);
LocalType = inferredType.RemoveUnavailableTypeParameters(compilation, combinedTypeParameters);
diff --git a/src/Analyzers/Core/CodeFixes/GenerateVariable/IGenerateVariableService.cs b/src/Analyzers/Core/CodeFixes/GenerateVariable/IGenerateVariableService.cs
index 742f3d0d3e369..fc649281aed02 100644
--- a/src/Analyzers/Core/CodeFixes/GenerateVariable/IGenerateVariableService.cs
+++ b/src/Analyzers/Core/CodeFixes/GenerateVariable/IGenerateVariableService.cs
@@ -2,8 +2,6 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-#nullable disable
-
using System.Collections.Immutable;
using System.Threading;
using System.Threading.Tasks;
diff --git a/src/Analyzers/Core/CodeFixes/ImplementAbstractClass/AbstractImplementAbstractClassCodeFixProvider.cs b/src/Analyzers/Core/CodeFixes/ImplementAbstractClass/AbstractImplementAbstractClassCodeFixProvider.cs
index a512895b3c5b2..9687d3a3f6c10 100644
--- a/src/Analyzers/Core/CodeFixes/ImplementAbstractClass/AbstractImplementAbstractClassCodeFixProvider.cs
+++ b/src/Analyzers/Core/CodeFixes/ImplementAbstractClass/AbstractImplementAbstractClassCodeFixProvider.cs
@@ -6,7 +6,6 @@
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.CodeActions;
using Microsoft.CodeAnalysis.CodeFixes;
-using Microsoft.CodeAnalysis.ImplementType;
using Microsoft.CodeAnalysis.Shared.Extensions;
namespace Microsoft.CodeAnalysis.ImplementAbstractClass;
diff --git a/src/Analyzers/Core/CodeFixes/ImplementInterface/ImplementInterfaceGenerator_Property.cs b/src/Analyzers/Core/CodeFixes/ImplementInterface/ImplementInterfaceGenerator_Property.cs
index 7707dc33fb3eb..9390f123877c1 100644
--- a/src/Analyzers/Core/CodeFixes/ImplementInterface/ImplementInterfaceGenerator_Property.cs
+++ b/src/Analyzers/Core/CodeFixes/ImplementInterface/ImplementInterfaceGenerator_Property.cs
@@ -2,7 +2,6 @@
// 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 Microsoft.CodeAnalysis.CodeGeneration;
diff --git a/src/Analyzers/Core/CodeFixes/MakeFieldReadonly/AbstractMakeFieldReadonlyCodeFixProvider.cs b/src/Analyzers/Core/CodeFixes/MakeFieldReadonly/AbstractMakeFieldReadonlyCodeFixProvider.cs
index 5db2af601d9f0..092139a4ba4a8 100644
--- a/src/Analyzers/Core/CodeFixes/MakeFieldReadonly/AbstractMakeFieldReadonlyCodeFixProvider.cs
+++ b/src/Analyzers/Core/CodeFixes/MakeFieldReadonly/AbstractMakeFieldReadonlyCodeFixProvider.cs
@@ -8,7 +8,6 @@
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
-using Microsoft.CodeAnalysis.CodeActions;
using Microsoft.CodeAnalysis.CodeFixes;
using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.CodeAnalysis.Editing;
diff --git a/src/Analyzers/Core/CodeFixes/MakeMemberStatic/AbstractMakeMemberStaticCodeFixProvider.cs b/src/Analyzers/Core/CodeFixes/MakeMemberStatic/AbstractMakeMemberStaticCodeFixProvider.cs
index 1ee2dd22b664e..4dfca14b6c208 100644
--- a/src/Analyzers/Core/CodeFixes/MakeMemberStatic/AbstractMakeMemberStaticCodeFixProvider.cs
+++ b/src/Analyzers/Core/CodeFixes/MakeMemberStatic/AbstractMakeMemberStaticCodeFixProvider.cs
@@ -2,12 +2,10 @@
// 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;
using System.Collections.Immutable;
using System.Diagnostics.CodeAnalysis;
using System.Threading;
using System.Threading.Tasks;
-using Microsoft.CodeAnalysis.CodeActions;
using Microsoft.CodeAnalysis.CodeFixes;
using Microsoft.CodeAnalysis.Editing;
using Microsoft.CodeAnalysis.Shared.Extensions;
diff --git a/src/Analyzers/Core/CodeFixes/MakeMethodAsynchronous/AbstractMakeMethodAsynchronousCodeFixProvider.cs b/src/Analyzers/Core/CodeFixes/MakeMethodAsynchronous/AbstractMakeMethodAsynchronousCodeFixProvider.cs
index 73af02c92ae82..8560a63ed58d3 100644
--- a/src/Analyzers/Core/CodeFixes/MakeMethodAsynchronous/AbstractMakeMethodAsynchronousCodeFixProvider.cs
+++ b/src/Analyzers/Core/CodeFixes/MakeMethodAsynchronous/AbstractMakeMethodAsynchronousCodeFixProvider.cs
@@ -2,7 +2,6 @@
// 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.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
diff --git a/src/Analyzers/Core/CodeFixes/MakeTypeAbstract/AbstractMakeTypeAbstractCodeFixProvider.cs b/src/Analyzers/Core/CodeFixes/MakeTypeAbstract/AbstractMakeTypeAbstractCodeFixProvider.cs
index 82d39e92f2fcd..024c04392cf5e 100644
--- a/src/Analyzers/Core/CodeFixes/MakeTypeAbstract/AbstractMakeTypeAbstractCodeFixProvider.cs
+++ b/src/Analyzers/Core/CodeFixes/MakeTypeAbstract/AbstractMakeTypeAbstractCodeFixProvider.cs
@@ -2,12 +2,10 @@
// 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;
using System.Collections.Immutable;
using System.Diagnostics.CodeAnalysis;
using System.Threading;
using System.Threading.Tasks;
-using Microsoft.CodeAnalysis.CodeActions;
using Microsoft.CodeAnalysis.CodeFixes;
using Microsoft.CodeAnalysis.Editing;
using Microsoft.CodeAnalysis.Shared.Extensions;
diff --git a/src/Analyzers/Core/CodeFixes/MakeTypePartial/AbstractMakeTypePartialCodeFixProvider.cs b/src/Analyzers/Core/CodeFixes/MakeTypePartial/AbstractMakeTypePartialCodeFixProvider.cs
index 37f501bdb90d5..4de179bac6305 100644
--- a/src/Analyzers/Core/CodeFixes/MakeTypePartial/AbstractMakeTypePartialCodeFixProvider.cs
+++ b/src/Analyzers/Core/CodeFixes/MakeTypePartial/AbstractMakeTypePartialCodeFixProvider.cs
@@ -6,7 +6,6 @@
using System.Diagnostics;
using System.Threading;
using System.Threading.Tasks;
-using Microsoft.CodeAnalysis.CodeActions;
using Microsoft.CodeAnalysis.CodeFixes;
using Microsoft.CodeAnalysis.Editing;
using Microsoft.CodeAnalysis.Shared.Extensions;
diff --git a/src/Analyzers/Core/CodeFixes/Naming/FallbackNamingRules.cs b/src/Analyzers/Core/CodeFixes/Naming/FallbackNamingRules.cs
index 2e3518127d5e3..0ce937d7ba07d 100644
--- a/src/Analyzers/Core/CodeFixes/Naming/FallbackNamingRules.cs
+++ b/src/Analyzers/Core/CodeFixes/Naming/FallbackNamingRules.cs
@@ -2,8 +2,6 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-#nullable disable
-
using System;
using System.Collections.Immutable;
using Microsoft.CodeAnalysis.Diagnostics.Analyzers.NamingStyles;
diff --git a/src/Analyzers/Core/CodeFixes/Naming/NamingExtensions.cs b/src/Analyzers/Core/CodeFixes/Naming/NamingExtensions.cs
index f9365fd6e1c45..01b3ab7184f7a 100644
--- a/src/Analyzers/Core/CodeFixes/Naming/NamingExtensions.cs
+++ b/src/Analyzers/Core/CodeFixes/Naming/NamingExtensions.cs
@@ -8,7 +8,6 @@
using Microsoft.CodeAnalysis.CodeStyle;
using Microsoft.CodeAnalysis.Diagnostics.Analyzers.NamingStyles;
using Microsoft.CodeAnalysis.Shared.Naming;
-using Roslyn.Utilities;
namespace Microsoft.CodeAnalysis.Shared.Extensions;
diff --git a/src/Analyzers/Core/CodeFixes/OrderModifiers/AbstractOrderModifiersCodeFixProvider.cs b/src/Analyzers/Core/CodeFixes/OrderModifiers/AbstractOrderModifiersCodeFixProvider.cs
index 5715e8a08182c..b061646a01f88 100644
--- a/src/Analyzers/Core/CodeFixes/OrderModifiers/AbstractOrderModifiersCodeFixProvider.cs
+++ b/src/Analyzers/Core/CodeFixes/OrderModifiers/AbstractOrderModifiersCodeFixProvider.cs
@@ -2,17 +2,14 @@
// 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;
using System.Collections.Immutable;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
-using Microsoft.CodeAnalysis.CodeActions;
using Microsoft.CodeAnalysis.CodeStyle;
using Microsoft.CodeAnalysis.CodeFixes;
using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.CodeAnalysis.Editing;
-using Microsoft.CodeAnalysis.Options;
using Microsoft.CodeAnalysis.LanguageService;
using Microsoft.CodeAnalysis.Shared.Extensions;
using Roslyn.Utilities;
diff --git a/src/Analyzers/Core/CodeFixes/PopulateSwitch/AbstractPopulateSwitchCodeFixProvider.cs b/src/Analyzers/Core/CodeFixes/PopulateSwitch/AbstractPopulateSwitchCodeFixProvider.cs
index 145908f6c307d..5f7d4c204b58e 100644
--- a/src/Analyzers/Core/CodeFixes/PopulateSwitch/AbstractPopulateSwitchCodeFixProvider.cs
+++ b/src/Analyzers/Core/CodeFixes/PopulateSwitch/AbstractPopulateSwitchCodeFixProvider.cs
@@ -2,7 +2,6 @@
// 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;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Diagnostics;
diff --git a/src/Analyzers/Core/CodeFixes/PopulateSwitch/AbstractPopulateSwitchExpressionCodeFixProvider.cs b/src/Analyzers/Core/CodeFixes/PopulateSwitch/AbstractPopulateSwitchExpressionCodeFixProvider.cs
index 5b452e4e68a46..27f5502d3ecc8 100644
--- a/src/Analyzers/Core/CodeFixes/PopulateSwitch/AbstractPopulateSwitchExpressionCodeFixProvider.cs
+++ b/src/Analyzers/Core/CodeFixes/PopulateSwitch/AbstractPopulateSwitchExpressionCodeFixProvider.cs
@@ -8,7 +8,6 @@
using Microsoft.CodeAnalysis.Formatting;
using Microsoft.CodeAnalysis.Operations;
using Microsoft.CodeAnalysis.Shared.Extensions;
-using Roslyn.Utilities;
namespace Microsoft.CodeAnalysis.PopulateSwitch;
diff --git a/src/Analyzers/Core/CodeFixes/PredefinedCodeFixProviderNames.cs b/src/Analyzers/Core/CodeFixes/PredefinedCodeFixProviderNames.cs
index b25199c960ec8..13066ab750497 100644
--- a/src/Analyzers/Core/CodeFixes/PredefinedCodeFixProviderNames.cs
+++ b/src/Analyzers/Core/CodeFixes/PredefinedCodeFixProviderNames.cs
@@ -43,6 +43,7 @@ internal static class PredefinedCodeFixProviderNames
public const string ConvertToRecord = nameof(ConvertToRecord);
public const string ConvertToTopLevelStatements = nameof(ConvertToTopLevelStatements);
public const string ConvertTypeOfToNameOf = nameof(ConvertTypeOfToNameOf);
+ public const string CopilotImplementNotImplementedException = nameof(CopilotImplementNotImplementedException);
public const string CopilotSuggestions = nameof(CopilotSuggestions);
public const string CorrectNextControlVariable = nameof(CorrectNextControlVariable);
public const string DeclareAsNullable = nameof(DeclareAsNullable);
diff --git a/src/Analyzers/Core/CodeFixes/QualifyMemberAccess/AbstractQualifyMemberAccessCodeFixProvider.cs b/src/Analyzers/Core/CodeFixes/QualifyMemberAccess/AbstractQualifyMemberAccessCodeFixProvider.cs
index 4b0cb0f386fa3..1c7d70e0c4d0e 100644
--- a/src/Analyzers/Core/CodeFixes/QualifyMemberAccess/AbstractQualifyMemberAccessCodeFixProvider.cs
+++ b/src/Analyzers/Core/CodeFixes/QualifyMemberAccess/AbstractQualifyMemberAccessCodeFixProvider.cs
@@ -2,11 +2,9 @@
// 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;
using System.Collections.Immutable;
using System.Threading;
using System.Threading.Tasks;
-using Microsoft.CodeAnalysis.CodeActions;
using Microsoft.CodeAnalysis.CodeFixes;
using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.CodeAnalysis.Editing;
diff --git a/src/Analyzers/Core/CodeFixes/RemoveRedundantEquality/RemoveRedundantEqualityCodeFixProvider.cs b/src/Analyzers/Core/CodeFixes/RemoveRedundantEquality/RemoveRedundantEqualityCodeFixProvider.cs
index 56ec6abe94604..4a31e92a587f8 100644
--- a/src/Analyzers/Core/CodeFixes/RemoveRedundantEquality/RemoveRedundantEqualityCodeFixProvider.cs
+++ b/src/Analyzers/Core/CodeFixes/RemoveRedundantEquality/RemoveRedundantEqualityCodeFixProvider.cs
@@ -2,14 +2,12 @@
// 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;
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.Diagnostics;
using Microsoft.CodeAnalysis.Editing;
diff --git a/src/Analyzers/Core/CodeFixes/RemoveUnnecessaryParentheses/AbstractRemoveUnnecessaryParenthesesCodeFixProvider.cs b/src/Analyzers/Core/CodeFixes/RemoveUnnecessaryParentheses/AbstractRemoveUnnecessaryParenthesesCodeFixProvider.cs
index c21ae53bb9a8c..41407b1e686b0 100644
--- a/src/Analyzers/Core/CodeFixes/RemoveUnnecessaryParentheses/AbstractRemoveUnnecessaryParenthesesCodeFixProvider.cs
+++ b/src/Analyzers/Core/CodeFixes/RemoveUnnecessaryParentheses/AbstractRemoveUnnecessaryParenthesesCodeFixProvider.cs
@@ -2,11 +2,9 @@
// 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;
using System.Collections.Immutable;
using System.Threading;
using System.Threading.Tasks;
-using Microsoft.CodeAnalysis.CodeActions;
using Microsoft.CodeAnalysis.CodeFixes;
using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.CodeAnalysis.Editing;
diff --git a/src/Analyzers/Core/CodeFixes/RemoveUnnecessarySuppressions/RemoveUnnecessaryAttributeSuppressionsCodeFixProvider.cs b/src/Analyzers/Core/CodeFixes/RemoveUnnecessarySuppressions/RemoveUnnecessaryAttributeSuppressionsCodeFixProvider.cs
index b5e2c50e00f1b..df44ed978de39 100644
--- a/src/Analyzers/Core/CodeFixes/RemoveUnnecessarySuppressions/RemoveUnnecessaryAttributeSuppressionsCodeFixProvider.cs
+++ b/src/Analyzers/Core/CodeFixes/RemoveUnnecessarySuppressions/RemoveUnnecessaryAttributeSuppressionsCodeFixProvider.cs
@@ -7,7 +7,6 @@
using System.Composition;
using System.Threading;
using System.Threading.Tasks;
-using Microsoft.CodeAnalysis.CodeActions;
using Microsoft.CodeAnalysis.CodeFixes;
using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.CodeAnalysis.Editing;
diff --git a/src/Analyzers/Core/CodeFixes/RemoveUnnecessarySuppressions/RemoveUnnecessaryPragmaSuppressionsCodeFixProvider.cs b/src/Analyzers/Core/CodeFixes/RemoveUnnecessarySuppressions/RemoveUnnecessaryPragmaSuppressionsCodeFixProvider.cs
index 8d6418a13237f..fcb86a7ac9f86 100644
--- a/src/Analyzers/Core/CodeFixes/RemoveUnnecessarySuppressions/RemoveUnnecessaryPragmaSuppressionsCodeFixProvider.cs
+++ b/src/Analyzers/Core/CodeFixes/RemoveUnnecessarySuppressions/RemoveUnnecessaryPragmaSuppressionsCodeFixProvider.cs
@@ -2,14 +2,12 @@
// 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;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Composition;
using System.Diagnostics.CodeAnalysis;
using System.Threading;
using System.Threading.Tasks;
-using Microsoft.CodeAnalysis.CodeActions;
using Microsoft.CodeAnalysis.CodeFixes;
using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.CodeAnalysis.Editing;
diff --git a/src/Analyzers/Core/CodeFixes/UpdateLegacySuppressions/UpdateLegacySuppressionsCodeFixProvider.cs b/src/Analyzers/Core/CodeFixes/UpdateLegacySuppressions/UpdateLegacySuppressionsCodeFixProvider.cs
index 6733f37c256e8..1770445ee3502 100644
--- a/src/Analyzers/Core/CodeFixes/UpdateLegacySuppressions/UpdateLegacySuppressionsCodeFixProvider.cs
+++ b/src/Analyzers/Core/CodeFixes/UpdateLegacySuppressions/UpdateLegacySuppressionsCodeFixProvider.cs
@@ -7,7 +7,6 @@
using System.Composition;
using System.Threading;
using System.Threading.Tasks;
-using Microsoft.CodeAnalysis.CodeActions;
using Microsoft.CodeAnalysis.CodeFixes;
using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.CodeAnalysis.Editing;
diff --git a/src/Analyzers/Core/CodeFixes/UseCoalesceExpression/AbstractUseCoalesceExpressionForIfNullStatementCheckCodeFixProvider.cs b/src/Analyzers/Core/CodeFixes/UseCoalesceExpression/AbstractUseCoalesceExpressionForIfNullStatementCheckCodeFixProvider.cs
index 6bcdd1ce88458..6c11e4cfffccb 100644
--- a/src/Analyzers/Core/CodeFixes/UseCoalesceExpression/AbstractUseCoalesceExpressionForIfNullStatementCheckCodeFixProvider.cs
+++ b/src/Analyzers/Core/CodeFixes/UseCoalesceExpression/AbstractUseCoalesceExpressionForIfNullStatementCheckCodeFixProvider.cs
@@ -3,7 +3,6 @@
// See the LICENSE file in the project root for more information.
using System.Collections.Immutable;
-using System.Diagnostics.CodeAnalysis;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.CodeFixes;
@@ -11,7 +10,6 @@
using Microsoft.CodeAnalysis.Editing;
using Microsoft.CodeAnalysis.LanguageService;
using Microsoft.CodeAnalysis.Shared.Extensions;
-using Roslyn.Utilities;
namespace Microsoft.CodeAnalysis.UseCoalesceExpression;
diff --git a/src/Analyzers/Core/CodeFixes/UseCoalesceExpression/UseCoalesceExpressionForNullableTernaryConditionalCheckCodeFixProvider.cs b/src/Analyzers/Core/CodeFixes/UseCoalesceExpression/UseCoalesceExpressionForNullableTernaryConditionalCheckCodeFixProvider.cs
index 208cdecb01d30..7a994f7fe81d2 100644
--- a/src/Analyzers/Core/CodeFixes/UseCoalesceExpression/UseCoalesceExpressionForNullableTernaryConditionalCheckCodeFixProvider.cs
+++ b/src/Analyzers/Core/CodeFixes/UseCoalesceExpression/UseCoalesceExpressionForNullableTernaryConditionalCheckCodeFixProvider.cs
@@ -2,7 +2,6 @@
// 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;
using System.Collections.Immutable;
using System.Composition;
using System.Diagnostics.CodeAnalysis;
diff --git a/src/Analyzers/Core/CodeFixes/UseCoalesceExpression/UseCoalesceExpressionForTernaryConditionalCheckCodeFixProvider.cs b/src/Analyzers/Core/CodeFixes/UseCoalesceExpression/UseCoalesceExpressionForTernaryConditionalCheckCodeFixProvider.cs
index adba206a1f33d..2334bc175a664 100644
--- a/src/Analyzers/Core/CodeFixes/UseCoalesceExpression/UseCoalesceExpressionForTernaryConditionalCheckCodeFixProvider.cs
+++ b/src/Analyzers/Core/CodeFixes/UseCoalesceExpression/UseCoalesceExpressionForTernaryConditionalCheckCodeFixProvider.cs
@@ -2,7 +2,6 @@
// 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;
using System.Collections.Immutable;
using System.Composition;
using System.Diagnostics.CodeAnalysis;
diff --git a/src/Analyzers/Core/CodeFixes/UseCollectionInitializer/AbstractUseCollectionInitializerCodeFixProvider.cs b/src/Analyzers/Core/CodeFixes/UseCollectionInitializer/AbstractUseCollectionInitializerCodeFixProvider.cs
index d1c1ed93b6077..3894a87ce428f 100644
--- a/src/Analyzers/Core/CodeFixes/UseCollectionInitializer/AbstractUseCollectionInitializerCodeFixProvider.cs
+++ b/src/Analyzers/Core/CodeFixes/UseCollectionInitializer/AbstractUseCollectionInitializerCodeFixProvider.cs
@@ -76,7 +76,7 @@ protected sealed override async Task FixAsync(
using var analyzer = GetAnalyzer();
var useCollectionExpression = properties.ContainsKey(UseCollectionInitializerHelpers.UseCollectionExpressionName) is true;
- var (preMatches, postMatches) = analyzer.Analyze(
+ var (preMatches, postMatches, _) = analyzer.Analyze(
semanticModel, syntaxFacts, objectCreation, useCollectionExpression, cancellationToken);
if (preMatches.IsDefault || postMatches.IsDefault)
diff --git a/src/Analyzers/Core/CodeFixes/UseCompoundAssignment/AbstractUseCompoundAssignmentCodeFixProvider.cs b/src/Analyzers/Core/CodeFixes/UseCompoundAssignment/AbstractUseCompoundAssignmentCodeFixProvider.cs
index 20ec1d9dfe293..a5ae0ef3a13e9 100644
--- a/src/Analyzers/Core/CodeFixes/UseCompoundAssignment/AbstractUseCompoundAssignmentCodeFixProvider.cs
+++ b/src/Analyzers/Core/CodeFixes/UseCompoundAssignment/AbstractUseCompoundAssignmentCodeFixProvider.cs
@@ -2,11 +2,9 @@
// 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;
using System.Collections.Immutable;
using System.Threading;
using System.Threading.Tasks;
-using Microsoft.CodeAnalysis.CodeActions;
using Microsoft.CodeAnalysis.CodeFixes;
using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.CodeAnalysis.Editing;
diff --git a/src/Analyzers/Core/CodeFixes/UseConditionalExpression/ForAssignment/AbstractUseConditionalExpressionForAssignmentCodeFixProvider.cs b/src/Analyzers/Core/CodeFixes/UseConditionalExpression/ForAssignment/AbstractUseConditionalExpressionForAssignmentCodeFixProvider.cs
index 2622d19c5ccf7..2b3ed157e4237 100644
--- a/src/Analyzers/Core/CodeFixes/UseConditionalExpression/ForAssignment/AbstractUseConditionalExpressionForAssignmentCodeFixProvider.cs
+++ b/src/Analyzers/Core/CodeFixes/UseConditionalExpression/ForAssignment/AbstractUseConditionalExpressionForAssignmentCodeFixProvider.cs
@@ -104,19 +104,25 @@ protected override async Task FixOneAsync(
private void ConvertOnlyIfToConditionalExpression(
SyntaxEditor editor,
IConditionalOperation ifOperation,
- ISimpleAssignmentOperation assignment,
+ ISimpleAssignmentOperation assignmentOperation,
TExpressionSyntax conditionalExpression)
{
var generator = editor.Generator;
var ifStatement = (TIfStatementSyntax)ifOperation.Syntax;
- var expressionStatement = (TStatementSyntax)generator.ExpressionStatement(
- generator.AssignmentStatement(
- assignment.Target.Syntax,
- conditionalExpression)).WithTriviaFrom(ifStatement);
+ var assignment = generator.AssignmentStatement(assignmentOperation.Target.Syntax, conditionalExpression);
+
+ if (assignmentOperation.Parent is IConditionalAccessOperation conditionalAccess)
+ {
+ assignment = generator.ConditionalAccessExpression(
+ conditionalAccess.Operation.Syntax,
+ assignment);
+ }
+
+ var expressionStatement = (TStatementSyntax)generator.ExpressionStatement(assignment);
editor.ReplaceNode(
ifOperation.Syntax,
- WrapWithBlockIfAppropriate(ifStatement, expressionStatement));
+ WrapWithBlockIfAppropriate(ifStatement, expressionStatement).WithTriviaFrom(ifStatement));
}
private bool TryConvertWhenAssignmentToLocalDeclaredImmediateAbove(
diff --git a/src/Analyzers/Core/CodeFixes/UseConditionalExpression/ForReturn/AbstractUseConditionalExpressionForReturnCodeFixProvider.cs b/src/Analyzers/Core/CodeFixes/UseConditionalExpression/ForReturn/AbstractUseConditionalExpressionForReturnCodeFixProvider.cs
index 525e9164b2126..61ab3eec1b0cd 100644
--- a/src/Analyzers/Core/CodeFixes/UseConditionalExpression/ForReturn/AbstractUseConditionalExpressionForReturnCodeFixProvider.cs
+++ b/src/Analyzers/Core/CodeFixes/UseConditionalExpression/ForReturn/AbstractUseConditionalExpressionForReturnCodeFixProvider.cs
@@ -2,12 +2,10 @@
// 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;
using System.Collections.Immutable;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
-using Microsoft.CodeAnalysis.CodeActions;
using Microsoft.CodeAnalysis.CodeFixes;
using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.CodeAnalysis.Editing;
diff --git a/src/Analyzers/Core/CodeFixes/UseExplicitTupleName/UseExplicitTupleNameCodeFixProvider.cs b/src/Analyzers/Core/CodeFixes/UseExplicitTupleName/UseExplicitTupleNameCodeFixProvider.cs
index 3e93da6cf6d98..6d57a354baa1b 100644
--- a/src/Analyzers/Core/CodeFixes/UseExplicitTupleName/UseExplicitTupleNameCodeFixProvider.cs
+++ b/src/Analyzers/Core/CodeFixes/UseExplicitTupleName/UseExplicitTupleNameCodeFixProvider.cs
@@ -7,13 +7,11 @@
using System.Composition;
using System.Threading;
using System.Threading.Tasks;
-using Microsoft.CodeAnalysis.CodeActions;
using Microsoft.CodeAnalysis.CodeFixes;
using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.CodeAnalysis.Editing;
using Microsoft.CodeAnalysis.Host.Mef;
using Microsoft.CodeAnalysis.Shared.Extensions;
-using Roslyn.Utilities;
namespace Microsoft.CodeAnalysis.UseExplicitTupleName;
diff --git a/src/Analyzers/Core/CodeFixes/UseInferredMemberName/AbstractUseInferredMemberNameCodeFixProvider.cs b/src/Analyzers/Core/CodeFixes/UseInferredMemberName/AbstractUseInferredMemberNameCodeFixProvider.cs
index c6cd72ba08ebd..8d95c70a6f730 100644
--- a/src/Analyzers/Core/CodeFixes/UseInferredMemberName/AbstractUseInferredMemberNameCodeFixProvider.cs
+++ b/src/Analyzers/Core/CodeFixes/UseInferredMemberName/AbstractUseInferredMemberNameCodeFixProvider.cs
@@ -2,16 +2,12 @@
// 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;
using System.Collections.Immutable;
-using System.Linq;
using System.Threading;
using System.Threading.Tasks;
-using Microsoft.CodeAnalysis.CodeActions;
using Microsoft.CodeAnalysis.CodeFixes;
using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.CodeAnalysis.Editing;
-using Roslyn.Utilities;
namespace Microsoft.CodeAnalysis.UseInferredMemberName;
diff --git a/src/Analyzers/Core/CodeFixes/UseIsNullCheck/AbstractUseIsNullForReferenceEqualsCodeFixProvider.cs b/src/Analyzers/Core/CodeFixes/UseIsNullCheck/AbstractUseIsNullForReferenceEqualsCodeFixProvider.cs
index 1c2bf9963d409..2919279a5a0ff 100644
--- a/src/Analyzers/Core/CodeFixes/UseIsNullCheck/AbstractUseIsNullForReferenceEqualsCodeFixProvider.cs
+++ b/src/Analyzers/Core/CodeFixes/UseIsNullCheck/AbstractUseIsNullForReferenceEqualsCodeFixProvider.cs
@@ -2,7 +2,6 @@
// 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;
using System.Collections.Immutable;
using System.Linq;
using System.Threading;
diff --git a/src/Analyzers/Core/CodeFixes/UseNullPropagation/AbstractUseNullPropagationCodeFixProvider.cs b/src/Analyzers/Core/CodeFixes/UseNullPropagation/AbstractUseNullPropagationCodeFixProvider.cs
index 050540dbf5037..c1e6714f1e0ac 100644
--- a/src/Analyzers/Core/CodeFixes/UseNullPropagation/AbstractUseNullPropagationCodeFixProvider.cs
+++ b/src/Analyzers/Core/CodeFixes/UseNullPropagation/AbstractUseNullPropagationCodeFixProvider.cs
@@ -9,7 +9,6 @@
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
-using Microsoft.CodeAnalysis.CodeActions;
using Microsoft.CodeAnalysis.CodeFixes;
using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.CodeAnalysis.Editing;
diff --git a/src/Analyzers/Core/CodeFixes/UseObjectInitializer/AbstractUseObjectInitializerCodeFixProvider.cs b/src/Analyzers/Core/CodeFixes/UseObjectInitializer/AbstractUseObjectInitializerCodeFixProvider.cs
index baec58480a98e..43b6681743bbb 100644
--- a/src/Analyzers/Core/CodeFixes/UseObjectInitializer/AbstractUseObjectInitializerCodeFixProvider.cs
+++ b/src/Analyzers/Core/CodeFixes/UseObjectInitializer/AbstractUseObjectInitializerCodeFixProvider.cs
@@ -11,7 +11,6 @@
using Microsoft.CodeAnalysis.Formatting;
using Microsoft.CodeAnalysis.LanguageService;
using Microsoft.CodeAnalysis.Shared.Extensions;
-using Roslyn.Utilities;
namespace Microsoft.CodeAnalysis.UseObjectInitializer;
diff --git a/src/Analyzers/Core/CodeFixes/UseSystemHashCode/UseSystemHashCodeCodeFixProvider.cs b/src/Analyzers/Core/CodeFixes/UseSystemHashCode/UseSystemHashCodeCodeFixProvider.cs
index ff27c1ab4a616..38340365c24dd 100644
--- a/src/Analyzers/Core/CodeFixes/UseSystemHashCode/UseSystemHashCodeCodeFixProvider.cs
+++ b/src/Analyzers/Core/CodeFixes/UseSystemHashCode/UseSystemHashCodeCodeFixProvider.cs
@@ -8,7 +8,6 @@
using System.Diagnostics.CodeAnalysis;
using System.Threading;
using System.Threading.Tasks;
-using Microsoft.CodeAnalysis.CodeActions;
using Microsoft.CodeAnalysis.CodeFixes;
using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.CodeAnalysis.Editing;
diff --git a/src/Analyzers/VisualBasic/Analyzers/UseCollectionInitializer/VisualBasicCollectionInitializerAnalyzer.vb b/src/Analyzers/VisualBasic/Analyzers/UseCollectionInitializer/VisualBasicCollectionInitializerAnalyzer.vb
index f93006673927f..6d7b23598ee9f 100644
--- a/src/Analyzers/VisualBasic/Analyzers/UseCollectionInitializer/VisualBasicCollectionInitializerAnalyzer.vb
+++ b/src/Analyzers/VisualBasic/Analyzers/UseCollectionInitializer/VisualBasicCollectionInitializerAnalyzer.vb
@@ -41,6 +41,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.UseCollectionInitializer
Protected Overrides Function AnalyzeMatchesAndCollectionConstructorForCollectionExpression(
preMatches As ArrayBuilder(Of CollectionMatch(Of SyntaxNode)),
postMatches As ArrayBuilder(Of CollectionMatch(Of SyntaxNode)),
+ ByRef changesSemantics As Boolean,
cancellationToken As CancellationToken) As Boolean
' Only called for collection expressions, which VB does not support
Throw ExceptionUtilities.Unreachable()
diff --git a/src/Analyzers/VisualBasic/CodeFixes/GenerateParameterizedMember/VisualBasicGenerateParameterizedMemberService.vb b/src/Analyzers/VisualBasic/CodeFixes/GenerateParameterizedMember/VisualBasicGenerateParameterizedMemberService.vb
index 2a69484ac46c2..7ac08d83fd613 100644
--- a/src/Analyzers/VisualBasic/CodeFixes/GenerateParameterizedMember/VisualBasicGenerateParameterizedMemberService.vb
+++ b/src/Analyzers/VisualBasic/CodeFixes/GenerateParameterizedMember/VisualBasicGenerateParameterizedMemberService.vb
@@ -62,15 +62,15 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.GenerateMember.GenerateMethod
End Function
Protected Overrides Function GetCapturedTypeParameters(cancellationToken As CancellationToken) As ImmutableArray(Of ITypeParameterSymbol)
- Dim result = New List(Of ITypeParameterSymbol)()
+ Dim result = ArrayBuilder(Of ITypeParameterSymbol).GetInstance()
If Me.InvocationExpression.ArgumentList IsNot Nothing Then
For Each argument In Me.InvocationExpression.ArgumentList.Arguments
Dim type = DetermineParameterType(argument, cancellationToken)
- type.GetReferencedTypeParameters(result)
+ type.AddReferencedTypeParameters(result)
Next
End If
- Return result.ToImmutableArray()
+ Return result.ToImmutableAndFree()
End Function
Protected Overrides Function GenerateTypeParameters(cancellationToken As CancellationToken) As ImmutableArray(Of ITypeParameterSymbol)
diff --git a/src/Compilers/CSharp/CSharpAnalyzerDriver/CSharpDeclarationComputer.cs b/src/Compilers/CSharp/CSharpAnalyzerDriver/CSharpDeclarationComputer.cs
index d267b9abf3878..b422629ed39d0 100644
--- a/src/Compilers/CSharp/CSharpAnalyzerDriver/CSharpDeclarationComputer.cs
+++ b/src/Compilers/CSharp/CSharpAnalyzerDriver/CSharpDeclarationComputer.cs
@@ -102,6 +102,7 @@ private static void ComputeDeclarations(
case SyntaxKind.StructDeclaration:
case SyntaxKind.RecordDeclaration:
case SyntaxKind.RecordStructDeclaration:
+ // Tracked by https://github.com/dotnet/roslyn/issues/76130 : likely needs work for analyzers
{
if (associatedSymbol is IMethodSymbol ctor)
{
diff --git a/src/Compilers/CSharp/Portable/Binder/Binder.ValueChecks.cs b/src/Compilers/CSharp/Portable/Binder/Binder.ValueChecks.cs
index 45caa7bd6b90d..1bf76dd56b127 100644
--- a/src/Compilers/CSharp/Portable/Binder/Binder.ValueChecks.cs
+++ b/src/Compilers/CSharp/Portable/Binder/Binder.ValueChecks.cs
@@ -591,6 +591,7 @@ private BoundExpression CheckValue(BoundExpression expr, BindValueKind valueKind
var methodGroup = (BoundMethodGroup)expr;
CompoundUseSiteInfo useSiteInfo = GetNewCompoundUseSiteInfo(diagnostics);
var resolution = this.ResolveMethodGroup(methodGroup, analyzedArguments: null, useSiteInfo: ref useSiteInfo, options: OverloadResolution.Options.None);
+ Debug.Assert(!resolution.IsNonMethodExtensionMember(out _));
diagnostics.Add(expr.Syntax, useSiteInfo);
Symbol otherSymbol = null;
bool resolvedToMethodGroup = resolution.MethodGroup != null;
@@ -2447,7 +2448,7 @@ static void getArgList(
///
/// Returns the set of arguments to be considered for escape analysis of a method
- /// invocation. Each argument is returned with the correponding parameter and
+ /// invocation. Each argument is returned with the corresponding parameter and
/// whether analysis should consider value or ref escape. Not all method arguments
/// are included, and some arguments may be included twice - once for value, once for ref.
///
@@ -4071,7 +4072,7 @@ internal SafeContext GetValEscape(BoundExpression expr, SafeContext localScopeDe
case BoundKind.MakeRefOperator:
case BoundKind.RefValueOperator:
// for compat reasons
- // NB: it also means can`t assign stackalloc spans to a __refvalue
+ // NB: it also means can't assign stackalloc spans to a __refvalue
// we are ok with that.
return SafeContext.CallingMethod;
diff --git a/src/Compilers/CSharp/Portable/Binder/Binder.cs b/src/Compilers/CSharp/Portable/Binder/Binder.cs
index 3805868f85f4f..4411b2b1e45ea 100644
--- a/src/Compilers/CSharp/Portable/Binder/Binder.cs
+++ b/src/Compilers/CSharp/Portable/Binder/Binder.cs
@@ -893,7 +893,7 @@ internal BoundStatement WrapWithVariablesAndLocalFunctionsIfAny(CSharpSyntaxNode
return statement;
}
- return new BoundBlock(statement.Syntax, locals, localFunctions, hasUnsafeModifier: false, instrumentation: null,
+ return new BoundBlock(statement.Syntax, locals, ImmutableArray.CastUp(localFunctions), hasUnsafeModifier: false, instrumentation: null,
ImmutableArray.Create(statement))
{ WasCompilerGenerated = true };
}
diff --git a/src/Compilers/CSharp/Portable/Binder/BinderFactory.BinderFactoryVisitor.cs b/src/Compilers/CSharp/Portable/Binder/BinderFactory.BinderFactoryVisitor.cs
index 84dd51c1cd3b0..2e82ab6e0a8b5 100644
--- a/src/Compilers/CSharp/Portable/Binder/BinderFactory.BinderFactoryVisitor.cs
+++ b/src/Compilers/CSharp/Portable/Binder/BinderFactory.BinderFactoryVisitor.cs
@@ -598,25 +598,16 @@ bool checkSymbol(Symbol sym, TextSpan memberSpan, SymbolKind kind, out Symbol re
return false;
}
- if (kind is SymbolKind.Method or SymbolKind.Property)
+ if (kind is SymbolKind.Method or SymbolKind.Property or SymbolKind.Event)
{
if (InSpan(sym.GetFirstLocation(), this.syntaxTree, memberSpan))
{
return true;
}
- // If this is a partial member, the member represents the defining part,
- // not the implementation (member.Locations includes both parts). If the
- // span is in fact in the implementation, return that member instead.
- if (sym switch
-#pragma warning disable format
- {
- MethodSymbol method => (Symbol)method.PartialImplementationPart,
- SourcePropertySymbol property => property.PartialImplementationPart,
- _ => throw ExceptionUtilities.UnexpectedValue(sym)
- }
-#pragma warning restore format
- is { } implementation)
+ // If this is a partial member, the member represents the defining part, not the implementation.
+ // If the span is in fact in the implementation, return that member instead.
+ if (sym.GetPartialImplementationPart() is { } implementation)
{
if (InSpan(implementation.GetFirstLocation(), this.syntaxTree, memberSpan))
{
@@ -790,6 +781,11 @@ internal Binder VisitTypeDeclarationCore(TypeDeclarationSyntax parent, NodeUsage
{
resultBinder = new WithClassTypeParametersBinder(typeSymbol, resultBinder);
}
+
+ if (typeSymbol.IsExtension)
+ {
+ resultBinder = new WithExtensionParameterBinder(typeSymbol, resultBinder);
+ }
}
}
@@ -819,6 +815,9 @@ public override Binder VisitInterfaceDeclaration(InterfaceDeclarationSyntax node
public override Binder VisitRecordDeclaration(RecordDeclarationSyntax node)
=> VisitTypeDeclarationCore(node);
+ public override Binder VisitExtensionDeclaration(ExtensionDeclarationSyntax node)
+ => VisitTypeDeclarationCore(node);
+
public sealed override Binder VisitNamespaceDeclaration(NamespaceDeclarationSyntax parent)
{
if (!LookupPosition.IsInNamespaceDeclaration(_position, parent))
diff --git a/src/Compilers/CSharp/Portable/Binder/Binder_Await.cs b/src/Compilers/CSharp/Portable/Binder/Binder_Await.cs
index 10d853d3ea371..ce13976db5419 100644
--- a/src/Compilers/CSharp/Portable/Binder/Binder_Await.cs
+++ b/src/Compilers/CSharp/Portable/Binder/Binder_Await.cs
@@ -376,14 +376,14 @@ private bool GetIsCompletedProperty(TypeSymbol awaiterType, SyntaxNode node, Typ
return false;
}
- if (qualified.Kind != BoundKind.PropertyAccess)
+ if (qualified is not BoundPropertyAccess { PropertySymbol: { } propertySymbol } || propertySymbol.GetIsNewExtensionMember())
{
Error(diagnostics, ErrorCode.ERR_NoSuchMember, node, awaiterType, WellKnownMemberNames.IsCompleted);
isCompletedProperty = null;
return false;
}
- isCompletedProperty = ((BoundPropertyAccess)qualified).PropertySymbol;
+ isCompletedProperty = propertySymbol;
if (isCompletedProperty.IsWriteOnly)
{
Error(diagnostics, ErrorCode.ERR_PropertyLacksGet, node, isCompletedProperty);
@@ -454,7 +454,7 @@ private bool GetGetResultMethod(BoundExpression awaiterExpression, SyntaxNode no
var call = (BoundCall)getAwaiterGetResultCall;
getResultMethod = call.Method;
- if (getResultMethod.IsExtensionMethod)
+ if (getResultMethod.IsExtensionMethod || getResultMethod.GetIsNewExtensionMember())
{
Error(diagnostics, ErrorCode.ERR_NoSuchMember, node, awaiterType, WellKnownMemberNames.GetResult);
getResultMethod = null;
diff --git a/src/Compilers/CSharp/Portable/Binder/Binder_Conversions.cs b/src/Compilers/CSharp/Portable/Binder/Binder_Conversions.cs
index bcb7c815a2a07..ee80c9724963b 100644
--- a/src/Compilers/CSharp/Portable/Binder/Binder_Conversions.cs
+++ b/src/Compilers/CSharp/Portable/Binder/Binder_Conversions.cs
@@ -1301,7 +1301,7 @@ static bool makeInvocationExpression(
node, node, receiver, WellKnownMemberNames.CollectionInitializerAddMethodName, rightArity: 0,
typeArgumentsSyntax: default(SeparatedSyntaxList),
typeArgumentsWithAnnotations: default(ImmutableArray),
- invoked: true, indexed: false, diagnostics, searchExtensionMethodsIfNecessary: true);
+ invoked: true, indexed: false, diagnostics, searchExtensionsIfNecessary: true);
// require the target member to be a method.
if (boundExpression.Kind == BoundKind.FieldAccess || boundExpression.Kind == BoundKind.PropertyAccess)
@@ -1361,13 +1361,21 @@ static bool bindMethodGroupInvocation(
var resolution = addMethodBinder.ResolveMethodGroup(
methodGroup, expression, WellKnownMemberNames.CollectionInitializerAddMethodName, analyzedArguments,
useSiteInfo: ref useSiteInfo,
- options: OverloadResolution.Options.DynamicResolution | OverloadResolution.Options.DynamicConvertsToAnything);
+ options: OverloadResolution.Options.DynamicResolution | OverloadResolution.Options.DynamicConvertsToAnything,
+ acceptOnlyMethods: true);
diagnostics.Add(expression, useSiteInfo);
if (!methodGroup.HasAnyErrors) diagnostics.AddRange(resolution.Diagnostics); // Suppress cascading.
- if (resolution.HasAnyErrors)
+ if (resolution.IsNonMethodExtensionMember(out Symbol? extensionMember))
+ {
+ Debug.Assert(false); // Should not get here given the 'acceptOnlyMethods' argument value used in 'ResolveMethodGroup' call above
+ ReportMakeInvocationExpressionBadMemberKind(syntax, WellKnownMemberNames.CollectionInitializerAddMethodName, methodGroup, diagnostics);
+ addMethods = [];
+ result = false;
+ }
+ else if (resolution.HasAnyErrors)
{
addMethods = [];
result = false;
@@ -1399,7 +1407,7 @@ static bool bindMethodGroupInvocation(
var finalApplicableCandidates = addMethodBinder.GetCandidatesPassingFinalValidation(syntax, resolution.OverloadResolutionResult,
methodGroup.ReceiverOpt,
methodGroup.TypeArgumentsOpt,
- invokedAsExtensionMethod: resolution.IsExtensionMethodGroup,
+ isExtensionMethodGroup: resolution.IsExtensionMethodGroup,
diagnostics);
Debug.Assert(finalApplicableCandidates.Length != 1 || finalApplicableCandidates[0].IsApplicable);
@@ -1459,7 +1467,7 @@ static ImmutableArray filterOutBadGenericMethods(
if (!typeParameters.IsEmpty)
{
- if (resolution.IsExtensionMethodGroup)
+ if (resolution.IsExtensionMethodGroup) // Tracked by https://github.com/dotnet/roslyn/issues/76130 : we need to handle new extension methods
{
// We need to validate an ability to infer type arguments as well as check conversion to 'this' parameter.
// Overload resolution doesn't check the conversion when 'this' type refers to a type parameter
@@ -1510,7 +1518,7 @@ static ImmutableArray filterOutBadGenericMethods(
parameterTypes,
parameterRefKinds,
ImmutableArray.Create(methodGroup.ReceiverOpt, new BoundValuePlaceholder(syntax, secondArgumentType) { WasCompilerGenerated = true }),
- ref useSiteInfo);
+ ref useSiteInfo); // Tracked by https://github.com/dotnet/roslyn/issues/76130 : we may need to override ordinals here
if (!inferenceResult.Success)
{
@@ -1593,6 +1601,10 @@ static bool bindInvocationExpressionContinued(
var methodResult = result.ValidResult;
var method = methodResult.Member;
+ // Tracked by https://github.com/dotnet/roslyn/issues/76130: It looks like we added a bunch of code in BindInvocationExpressionContinued at this position
+ // that specifically deals with new extension methods. It adjusts analyzedArguments, etc.
+ // It is very likely we need to do the same here.
+
// It is possible that overload resolution succeeded, but we have chosen an
// instance method and we're in a static method. A careful reading of the
// overload resolution spec shows that the "final validation" stage allows an
@@ -1651,7 +1663,7 @@ internal static BoundExpression GetUnderlyingCollectionExpressionElement(BoundCo
// Add methods. This case can be hit for spreads and non-spread elements.
Debug.Assert(call.HasErrors);
Debug.Assert(call.Method.Name == "Add");
- return call.Arguments[call.InvokedAsExtensionMethod ? 1 : 0];
+ return call.Arguments[call.InvokedAsExtensionMethod ? 1 : 0]; // Tracked by https://github.com/dotnet/roslyn/issues/76130: Add test coverage for new extensions
case BoundBadExpression badExpression:
Debug.Assert(false); // Add test if we hit this assert.
return badExpression;
@@ -1700,7 +1712,7 @@ internal bool TryGetCollectionIterationType(SyntaxNode syntax, TypeSymbol collec
out iterationType,
builder: out var builder);
// Collection expression target types require instance method GetEnumerator.
- if (result && builder.ViaExtensionMethod)
+ if (result && builder.ViaExtensionMethod) // Tracked by https://github.com/dotnet/roslyn/issues/76130: Add test coverage for new extensions
{
iterationType = default;
return false;
@@ -2223,7 +2235,7 @@ private BoundExpression CreateAnonymousFunctionConversion(SyntaxNode syntax, Bou
diagnostics.AddRange(boundLambda.Diagnostics);
CheckParameterModifierMismatchMethodConversion(syntax, boundLambda.Symbol, destination, invokedAsExtensionMethod: false, diagnostics);
- CheckLambdaConversion(boundLambda.Symbol, destination, diagnostics);
+ CheckLambdaConversion((LambdaSymbol)boundLambda.Symbol, destination, diagnostics);
return new BoundConversion(
syntax,
boundLambda,
@@ -2826,20 +2838,14 @@ internal bool MethodIsCompatibleWithDelegateOrFunctionPointer(BoundExpression? r
var methodParameters = method.Parameters;
int numParams = delegateOrFuncPtrParameters.Length;
- if (methodParameters.Length != numParams + (isExtensionMethod ? 1 : 0))
- {
- // This can happen if "method" has optional parameters.
- Debug.Assert(methodParameters.Length > numParams + (isExtensionMethod ? 1 : 0));
- Error(diagnostics, getMethodMismatchErrorCode(delegateType.TypeKind), errorLocation, method, delegateType);
- return false;
- }
+ Debug.Assert(methodParameters.Length == numParams + (isExtensionMethod ? 1 : 0));
CompoundUseSiteInfo useSiteInfo = GetNewCompoundUseSiteInfo(diagnostics);
// If this is an extension method delegate, the caller should have verified the
// receiver is compatible with the "this" parameter of the extension method.
- Debug.Assert(!isExtensionMethod ||
- (Conversions.ConvertExtensionMethodThisArg(methodParameters[0].Type, receiverOpt!.Type, ref useSiteInfo, isMethodGroupConversion: true).Exists && useSiteInfo.Diagnostics.IsNullOrEmpty()));
+ Debug.Assert(!(isExtensionMethod || (method.GetIsNewExtensionMember() && !method.IsStatic)) ||
+ (Conversions.ConvertExtensionMethodThisArg(GetReceiverParameter(method)!.Type, receiverOpt!.Type, ref useSiteInfo, isMethodGroupConversion: true).Exists && useSiteInfo.Diagnostics.IsNullOrEmpty()));
useSiteInfo = new CompoundUseSiteInfo(useSiteInfo);
@@ -2974,6 +2980,17 @@ static ErrorCode getRefMismatchErrorCode(TypeKind type)
};
}
+ internal static ParameterSymbol? GetReceiverParameter(MethodSymbol method)
+ {
+ if (method.IsExtensionMethod)
+ {
+ return method.Parameters[0];
+ }
+
+ Debug.Assert(method.GetIsNewExtensionMember());
+ return method.ContainingType.ExtensionParameter;
+ }
+
///
/// This method combines final validation (section 7.6.5.1) and delegate compatibility (section 15.2).
///
diff --git a/src/Compilers/CSharp/Portable/Binder/Binder_Deconstruct.cs b/src/Compilers/CSharp/Portable/Binder/Binder_Deconstruct.cs
index b8ead0eef4f39..06a853b99f712 100644
--- a/src/Compilers/CSharp/Portable/Binder/Binder_Deconstruct.cs
+++ b/src/Compilers/CSharp/Portable/Binder/Binder_Deconstruct.cs
@@ -669,7 +669,8 @@ private BoundExpression MakeDeconstructInvocationExpression(
// Those placeholders are also recorded in the outVar for easy access below, by the `SetInferredType` call on the outVar nodes.
BoundExpression result = BindMethodGroupInvocation(
rightSyntax, rightSyntax, methodName, (BoundMethodGroup)memberAccess, analyzedArguments, diagnostics, queryClause: null,
- ignoreNormalFormIfHasValidParamsParameter: false, anyApplicableCandidates: out anyApplicableCandidates);
+ ignoreNormalFormIfHasValidParamsParameter: false, anyApplicableCandidates: out anyApplicableCandidates,
+ disallowExpandedNonArrayParams: false, acceptOnlyMethods: true);
result.WasCompilerGenerated = true;
@@ -682,7 +683,7 @@ private BoundExpression MakeDeconstructInvocationExpression(
// This prevents, for example, an unused params parameter after the out parameters.
var deconstructMethod = ((BoundCall)result).Method;
var parameters = deconstructMethod.Parameters;
- for (int i = (deconstructMethod.IsExtensionMethod ? 1 : 0); i < parameters.Length; i++)
+ for (int i = (deconstructMethod.IsExtensionMethod ? 1 : 0); i < parameters.Length; i++) // Tracked by https://github.com/dotnet/roslyn/issues/76130: Test this code path with new extensions
{
if (parameters[i].RefKind != RefKind.Out)
{
diff --git a/src/Compilers/CSharp/Portable/Binder/Binder_Expressions.cs b/src/Compilers/CSharp/Portable/Binder/Binder_Expressions.cs
index f4f3d1b54026a..feedd901d17fc 100644
--- a/src/Compilers/CSharp/Portable/Binder/Binder_Expressions.cs
+++ b/src/Compilers/CSharp/Portable/Binder/Binder_Expressions.cs
@@ -48,6 +48,11 @@ internal bool HasThis(bool isExplicit, out bool inStaticContext)
return false;
}
+ if (memberOpt?.GetIsNewExtensionMember() == true)
+ {
+ return false;
+ }
+
var containingType = memberOpt?.ContainingType;
bool inTopLevelScriptMember = (object)containingType != null && containingType.IsScriptClass;
@@ -497,7 +502,9 @@ internal BoundParameterEqualsValue BindParameterDefaultValue(
out BoundExpression valueBeforeConversion)
{
Debug.Assert(this.InParameterDefaultValue);
- Debug.Assert(this.ContainingMemberOrLambda.Kind == SymbolKind.Method || this.ContainingMemberOrLambda.Kind == SymbolKind.Property);
+ Debug.Assert(this.ContainingMemberOrLambda.Kind == SymbolKind.Method
+ || this.ContainingMemberOrLambda.Kind == SymbolKind.Property
+ || this.ContainingMemberOrLambda is TypeSymbol { IsExtension: true });
// UNDONE: The binding and conversion has to be executed in a checked context.
Binder defaultValueBinder = this.GetBinder(defaultValueSyntax);
@@ -2114,6 +2121,14 @@ private BoundExpression BindNonMethod(SimpleNameSyntax node, Symbol symbol, Bind
{
Error(diagnostics, ErrorCode.ERR_InvalidPrimaryConstructorParameterReference, node, parameter);
}
+ else if (parameter.ContainingSymbol is NamedTypeSymbol { IsExtension: true } &&
+ (InParameterDefaultValue || InAttributeArgument ||
+ this.ContainingMember() is not { Kind: not SymbolKind.NamedType, IsStatic: false } || // We are not in an instance member
+ (object)this.ContainingMember().ContainingSymbol != parameter.ContainingSymbol) &&
+ !IsInsideNameof)
+ {
+ Error(diagnostics, ErrorCode.ERR_InvalidExtensionParameterReference, node, parameter);
+ }
else
{
// Records never capture parameters within the type
@@ -3435,75 +3450,8 @@ private void CheckAndCoerceArguments(
continue;
}
- if (!argument.HasAnyErrors)
- {
- var argRefKind = analyzedArguments.RefKind(arg);
-
- if (!Compilation.IsFeatureEnabled(MessageID.IDS_FeatureRefReadonlyParameters))
- {
- // Disallow using `ref readonly` parameters with no or `in` argument modifier,
- // same as older versions of the compiler would (since they would see the parameter as `ref`).
- if (argRefKind is RefKind.None or RefKind.In &&
- getCorrespondingParameter(in result, parameters, arg).RefKind == RefKind.RefReadOnlyParameter)
- {
- var available = CheckFeatureAvailability(argument.Syntax, MessageID.IDS_FeatureRefReadonlyParameters, diagnostics);
- Debug.Assert(!available);
- }
- }
- else
- {
- var argNumber = invokedAsExtensionMethod ? arg : arg + 1;
-
- // Warn for `ref`/`in` or None/`ref readonly` mismatch.
- if (argRefKind == RefKind.Ref)
- {
- if (getCorrespondingParameter(in result, parameters, arg).RefKind == RefKind.In)
- {
- Debug.Assert(argNumber > 0);
- // The 'ref' modifier for argument {0} corresponding to 'in' parameter is equivalent to 'in'. Consider using 'in' instead.
- diagnostics.Add(
- ErrorCode.WRN_BadArgRef,
- argument.Syntax,
- argNumber);
- }
- }
- else if (argRefKind == RefKind.None &&
- getCorrespondingParameter(in result, parameters, arg).RefKind == RefKind.RefReadOnlyParameter)
- {
- if (!this.CheckValueKind(argument.Syntax, argument, BindValueKind.RefersToLocation, checkingReceiver: false, BindingDiagnosticBag.Discarded))
- {
- Debug.Assert(argNumber >= 0); // can be 0 for receiver of extension method
- // Argument {0} should be a variable because it is passed to a 'ref readonly' parameter
- diagnostics.Add(
- ErrorCode.WRN_RefReadonlyNotVariable,
- argument.Syntax,
- argNumber);
- }
- else if (!invokedAsExtensionMethod || arg != 0)
- {
- Debug.Assert(argNumber > 0);
- if (this.CheckValueKind(argument.Syntax, argument, BindValueKind.Assignable, checkingReceiver: false, BindingDiagnosticBag.Discarded))
- {
- // Argument {0} should be passed with 'ref' or 'in' keyword
- diagnostics.Add(
- ErrorCode.WRN_ArgExpectedRefOrIn,
- argument.Syntax,
- argNumber);
- }
- else
- {
- // Argument {0} should be passed with the 'in' keyword
- diagnostics.Add(
- ErrorCode.WRN_ArgExpectedIn,
- argument.Syntax,
- argNumber);
- }
- }
- }
- }
- }
-
int paramNum = result.ParameterFromArgument(arg);
+ CheckArgumentRefKind(analyzedArguments.RefKind(arg), argument, arg, parameters[paramNum], invokedAsExtensionMethod, diagnostics);
if (expanded && paramNum == parameters.Length - 1)
{
@@ -3936,6 +3884,77 @@ BoundExpression bindInterpolatedStringHandlerInMemberCall(
hasErrors || interpolatedString.HasErrors);
}
}
+
+ private void CheckArgumentRefKind(RefKind argRefKind, BoundExpression argument, int arg, ParameterSymbol parameter,
+ bool invokedAsExtensionMethod, BindingDiagnosticBag diagnostics)
+ {
+ if (argument.HasAnyErrors)
+ {
+ return;
+ }
+
+ if (!Compilation.IsFeatureEnabled(MessageID.IDS_FeatureRefReadonlyParameters))
+ {
+ // Disallow using `ref readonly` parameters with no or `in` argument modifier,
+ // same as older versions of the compiler would (since they would see the parameter as `ref`).
+ if (argRefKind is RefKind.None or RefKind.In && parameter.RefKind == RefKind.RefReadOnlyParameter)
+ {
+ var available = CheckFeatureAvailability(argument.Syntax, MessageID.IDS_FeatureRefReadonlyParameters, diagnostics);
+ Debug.Assert(!available);
+ }
+ }
+ else
+ {
+ // Tracked by https://github.com/dotnet/roslyn/issues/76130 : consider removing or adjusting the reported argument position
+ var argNumber = invokedAsExtensionMethod ? arg : arg + 1;
+
+ // Warn for `ref`/`in` or None/`ref readonly` mismatch.
+ if (argRefKind == RefKind.Ref)
+ {
+ if (parameter.RefKind == RefKind.In)
+ {
+ Debug.Assert(argNumber > 0);
+ // The 'ref' modifier for argument {0} corresponding to 'in' parameter is equivalent to 'in'. Consider using 'in' instead.
+ diagnostics.Add(
+ ErrorCode.WRN_BadArgRef,
+ argument.Syntax,
+ argNumber);
+ }
+ }
+ else if (argRefKind == RefKind.None && parameter.RefKind == RefKind.RefReadOnlyParameter)
+ {
+ if (!this.CheckValueKind(argument.Syntax, argument, BindValueKind.RefersToLocation, checkingReceiver: false, BindingDiagnosticBag.Discarded))
+ {
+ Debug.Assert(argNumber >= 0); // can be 0 for receiver of extension method
+ // Argument {0} should be a variable because it is passed to a 'ref readonly' parameter
+ diagnostics.Add(
+ ErrorCode.WRN_RefReadonlyNotVariable,
+ argument.Syntax,
+ argNumber);
+ }
+ else if (!invokedAsExtensionMethod || arg != 0)
+ {
+ Debug.Assert(argNumber > 0);
+ if (this.CheckValueKind(argument.Syntax, argument, BindValueKind.Assignable, checkingReceiver: false, BindingDiagnosticBag.Discarded))
+ {
+ // Argument {0} should be passed with 'ref' or 'in' keyword
+ diagnostics.Add(
+ ErrorCode.WRN_ArgExpectedRefOrIn,
+ argument.Syntax,
+ argNumber);
+ }
+ else
+ {
+ // Argument {0} should be passed with the 'in' keyword
+ diagnostics.Add(
+ ErrorCode.WRN_ArgExpectedIn,
+ argument.Syntax,
+ argNumber);
+ }
+ }
+ }
+ }
+ }
#nullable disable
private BoundExpression BindArrayCreationExpression(ArrayCreationExpressionSyntax node, BindingDiagnosticBag diagnostics)
@@ -5393,7 +5412,7 @@ private BoundExpression BindDelegateCreationExpression(SyntaxNode node, NamedTyp
if (!hasErrors)
{
CheckParameterModifierMismatchMethodConversion(unboundLambda.Syntax, boundLambda.Symbol, type, invokedAsExtensionMethod: false, diagnostics);
- CheckLambdaConversion(boundLambda.Symbol, type, diagnostics);
+ CheckLambdaConversion((LambdaSymbol)boundLambda.Symbol, type, diagnostics);
}
// Just stuff the bound lambda into the delegate creation expression. When we lower the lambda to
@@ -6683,7 +6702,7 @@ protected BoundExpression BindClassCreationExpression(
if (overloadResolutionResult.HasAnyApplicableMember)
{
- var finalApplicableCandidates = GetCandidatesPassingFinalValidation(node, overloadResolutionResult, receiverOpt: null, default(ImmutableArray), invokedAsExtensionMethod: false, diagnostics);
+ var finalApplicableCandidates = GetCandidatesPassingFinalValidation(node, overloadResolutionResult, receiverOpt: null, default(ImmutableArray), isExtensionMethodGroup: false, diagnostics);
if (finalApplicableCandidates.Length == 1)
{
@@ -7835,7 +7854,7 @@ BoundExpression tryBindMemberAccessWithBoundNamespaceLeft(
Error(diagnostics, lookupResult.Error, right);
return new BoundTypeExpression(node, null,
- new ExtendedErrorTypeSymbol(GetContainingNamespaceOrType(symbols[0]), symbols.ToImmutable(), lookupResult.Kind, lookupResult.Error, rightArity));
+ new ExtendedErrorTypeSymbol(GetContainingNamespaceOrNonExtensionType(symbols[0]), symbols.ToImmutable(), lookupResult.Kind, lookupResult.Error, rightArity));
}
else if (lookupResult.Kind == LookupResultKind.Empty)
{
@@ -7865,6 +7884,7 @@ BoundExpression tryBindMemberAccessWithBoundTypeLeft(
string rightName,
int rightArity)
{
+ Debug.Assert(boundLeft is BoundTypeExpression);
Debug.Assert((object)leftType != null);
if (leftType.TypeKind == TypeKind.TypeParameter)
{
@@ -7892,10 +7912,25 @@ BoundExpression tryBindMemberAccessWithBoundTypeLeft(
CompoundUseSiteInfo useSiteInfo = GetNewCompoundUseSiteInfo(diagnostics);
this.LookupMembersWithFallback(lookupResult, leftType, rightName, rightArity, ref useSiteInfo, basesBeingResolved: null, options: options);
diagnostics.Add(right, useSiteInfo);
+
if (lookupResult.IsMultiViable)
{
- return BindMemberOfType(node, right, rightName, rightArity, indexed, boundLeft, typeArgumentsSyntax, typeArguments, lookupResult, BoundMethodGroupFlags.None, diagnostics: diagnostics);
+ return BindMemberOfType(node, right, rightName, rightArity, indexed, boundLeft, typeArgumentsSyntax, typeArguments, lookupResult, BoundMethodGroupFlags.SearchExtensions, diagnostics: diagnostics);
}
+
+ if (!invoked)
+ {
+ var nonMethodExtensionMember = ResolveExtensionMemberAccessIfResultIsNonMethod(node, boundLeft, rightName,
+ typeArguments, diagnostics);
+
+ if (nonMethodExtensionMember is not null)
+ {
+ return nonMethodExtensionMember;
+ }
+ }
+
+ return MakeBoundMethodGroupAndCheckOmittedTypeArguments(boundLeft, rightName, typeArguments, lookupResult,
+ flags: BoundMethodGroupFlags.SearchExtensions, node, typeArgumentsSyntax, diagnostics);
}
return null;
@@ -7925,6 +7960,7 @@ private BoundExpression MakeMemberAccessValue(BoundExpression expr, BindingDiagn
var methodGroup = (BoundMethodGroup)expr;
CompoundUseSiteInfo useSiteInfo = GetNewCompoundUseSiteInfo(diagnostics);
var resolution = this.ResolveMethodGroup(methodGroup, analyzedArguments: null, useSiteInfo: ref useSiteInfo, options: OverloadResolution.Options.None);
+ Debug.Assert(!resolution.IsNonMethodExtensionMember(out _));
diagnostics.Add(expr.Syntax, useSiteInfo);
if (!expr.HasAnyErrors)
{
@@ -7950,6 +7986,74 @@ private BoundExpression MakeMemberAccessValue(BoundExpression expr, BindingDiagn
}
}
+#nullable enable
+ // When we're binding a member access that is not invoked and the member lookup yielded no result:
+ // - if an extension member lookup finds a non-method extension member, then that's the member being accessed.
+ //
+ // - if the extension member lookup finds a method (classic extension method compatible with the receiver or method in extension declaration;
+ // closer than any non-method extension member), then we return nothing and let the caller represent the failed member lookup with a BoundMethodGroup.
+ // Note: Such method group will be resolved specially in scenarios that can handle method groups
+ // (such as inferred local `var x = A.B;`, conversion to a delegate type `System.Action a = A.B;`).
+ // It will be an error in other scenarios.
+ //
+ // - if the extension member lookup is ambiguous, then we'll use an error symbol as the result of the member access.
+ //
+ // - if the extension member lookup finds nothing, then we return nothing and let the caller represent the failed member lookup with a BoundMethodGroup.
+ internal BoundExpression? ResolveExtensionMemberAccessIfResultIsNonMethod(SyntaxNode syntax, BoundExpression receiver, string name,
+ ImmutableArray typeArgumentsOpt, BindingDiagnosticBag diagnostics)
+ {
+ CompoundUseSiteInfo useSiteInfo = this.GetNewCompoundUseSiteInfo(diagnostics);
+
+ // Note: we're resolving without arguments, which means we're not treating the member access as invoked
+ var resolution = this.ResolveExtension(
+ syntax, name, analyzedArguments: null, receiver, typeArgumentsOpt, options: OverloadResolution.Options.None,
+ returnRefKind: default, returnType: null, ref useSiteInfo, acceptOnlyMethods: false);
+
+ diagnostics.Add(syntax, useSiteInfo);
+
+ if (resolution.IsNonMethodExtensionMember(out Symbol? extensionMember))
+ {
+ Debug.Assert(typeArgumentsOpt.IsDefault);
+ if (!receiver.HasErrors)
+ {
+ diagnostics.AddRange(resolution.Diagnostics); // Tracked by https://github.com/dotnet/roslyn/issues/76130 : test dependencies/diagnostics
+ }
+
+ resolution.Free();
+
+ return GetExtensionMemberAccess(syntax, receiver, extensionMember, diagnostics);
+ }
+
+ resolution.Free();
+ return null;
+ }
+
+ private BoundExpression GetExtensionMemberAccess(SyntaxNode syntax, BoundExpression? receiver, Symbol extensionMember, BindingDiagnosticBag diagnostics)
+ {
+ receiver = ReplaceTypeOrValueReceiver(receiver, useType: extensionMember.IsStatic, diagnostics);
+
+ switch (extensionMember)
+ {
+ case PropertySymbol propertySymbol:
+ Debug.Assert(propertySymbol.ContainingType.ExtensionParameter is not null);
+
+ if (receiver is not BoundTypeExpression)
+ {
+ receiver = CheckAndConvertExtensionReceiver(receiver, propertySymbol.ContainingType.ExtensionParameter, diagnostics);
+ }
+
+ return BindPropertyAccess(syntax, receiver, propertySymbol, diagnostics, LookupResultKind.Viable, hasErrors: false);
+
+ case ExtendedErrorTypeSymbol errorTypeSymbol:
+ // Tracked by https://github.com/dotnet/roslyn/issues/76130 : we should likely reduce (ie. do type inference and substitute) the candidates (like ToBadExpression)
+ return new BoundBadExpression(syntax, LookupResultKind.Viable, errorTypeSymbol.CandidateSymbols!, [receiver], CreateErrorType());
+
+ default:
+ throw ExceptionUtilities.UnexpectedValue(extensionMember.Kind);
+ }
+ }
+#nullable disable
+
private BoundExpression BindInstanceMemberAccess(
SyntaxNode node,
SyntaxNode right,
@@ -7961,7 +8065,7 @@ private BoundExpression BindInstanceMemberAccess(
bool invoked,
bool indexed,
BindingDiagnosticBag diagnostics,
- bool searchExtensionMethodsIfNecessary = true)
+ bool searchExtensionsIfNecessary = true)
{
Debug.Assert(rightArity == (typeArgumentsWithAnnotations.IsDefault ? 0 : typeArgumentsWithAnnotations.Length));
var leftType = boundLeft.Type;
@@ -7982,12 +8086,12 @@ private BoundExpression BindInstanceMemberAccess(
// SPEC: Otherwise, an attempt is made to process E.I as an extension method invocation.
// SPEC: If this fails, E.I is an invalid member reference, and a binding-time error occurs.
- searchExtensionMethodsIfNecessary = searchExtensionMethodsIfNecessary && !leftIsBaseReference;
+ searchExtensionsIfNecessary = searchExtensionsIfNecessary && !leftIsBaseReference;
- BoundMethodGroupFlags flags = 0;
- if (searchExtensionMethodsIfNecessary)
+ BoundMethodGroupFlags flags = BoundMethodGroupFlags.None;
+ if (searchExtensionsIfNecessary)
{
- flags |= BoundMethodGroupFlags.SearchExtensionMethods;
+ flags |= BoundMethodGroupFlags.SearchExtensions;
}
if (lookupResult.IsMultiViable)
@@ -7995,7 +8099,7 @@ private BoundExpression BindInstanceMemberAccess(
return BindMemberOfType(node, right, rightName, rightArity, indexed, boundLeft, typeArgumentsSyntax, typeArgumentsWithAnnotations, lookupResult, flags, diagnostics);
}
- if (searchExtensionMethodsIfNecessary)
+ if (searchExtensionsIfNecessary)
{
BoundExpression colorColorValueReceiver = GetValueExpressionIfTypeOrValueReceiver(boundLeft);
@@ -8004,22 +8108,19 @@ private BoundExpression BindInstanceMemberAccess(
boundLeft = ReplaceTypeOrValueReceiver(boundLeft, useType: false, diagnostics);
}
- var boundMethodGroup = new BoundMethodGroup(
- node,
- typeArgumentsWithAnnotations,
- boundLeft,
- rightName,
- lookupResult.Symbols.All(s => s.Kind == SymbolKind.Method) ? lookupResult.Symbols.SelectAsArray(s_toMethodSymbolFunc) : ImmutableArray.Empty,
- lookupResult,
- flags,
- this);
-
- if (!boundMethodGroup.HasErrors && typeArgumentsSyntax.Any(SyntaxKind.OmittedTypeArgument))
+ if (!invoked)
{
- Error(diagnostics, ErrorCode.ERR_OmittedTypeArgument, node);
+ var nonMethodExtensionMember = ResolveExtensionMemberAccessIfResultIsNonMethod(node, boundLeft, rightName,
+ typeArgumentsWithAnnotations, diagnostics);
+
+ if (nonMethodExtensionMember is not null)
+ {
+ return nonMethodExtensionMember;
+ }
}
- return boundMethodGroup;
+ return MakeBoundMethodGroupAndCheckOmittedTypeArguments(boundLeft, rightName, typeArgumentsWithAnnotations, lookupResult,
+ flags, node, typeArgumentsSyntax, diagnostics);
}
this.BindMemberAccessReportError(node, right, rightName, boundLeft, lookupResult.Error, diagnostics);
@@ -8031,6 +8132,28 @@ private BoundExpression BindInstanceMemberAccess(
}
}
+ private BoundMethodGroup MakeBoundMethodGroupAndCheckOmittedTypeArguments(BoundExpression boundLeft, string rightName,
+ ImmutableArray typeArgumentsWithAnnotations, LookupResult lookupResult, BoundMethodGroupFlags flags, SyntaxNode node,
+ SeparatedSyntaxList typeArgumentsSyntax, BindingDiagnosticBag diagnostics)
+ {
+ var boundMethodGroup = new BoundMethodGroup(
+ node,
+ typeArgumentsWithAnnotations,
+ boundLeft,
+ rightName,
+ lookupResult.Symbols.All(s => s.Kind == SymbolKind.Method) ? lookupResult.Symbols.SelectAsArray(s_toMethodSymbolFunc) : ImmutableArray.Empty,
+ lookupResult,
+ flags,
+ this);
+
+ if (!boundMethodGroup.HasErrors && typeArgumentsSyntax.Any(SyntaxKind.OmittedTypeArgument))
+ {
+ Error(diagnostics, ErrorCode.ERR_OmittedTypeArgument, node);
+ }
+
+ return boundMethodGroup;
+ }
+
private void LookupInstanceMember(LookupResult lookupResult, TypeSymbol leftType, bool leftIsBaseReference, string rightName, int rightArity, bool invoked, ref CompoundUseSiteInfo useSiteInfo)
{
LookupOptions options = LookupOptions.AllMethodsOnArityZero;
@@ -8083,7 +8206,6 @@ private void BindMemberAccessReportError(
}
else
{
-
if ((object)boundLeft.Type == null)
{
Error(diagnostics, ErrorCode.ERR_NoSuchMember, name, boundLeft.Display, plainName);
@@ -8227,7 +8349,7 @@ private static void CombineExtensionMethodArguments(BoundExpression receiver, An
Debug.Assert(extensionMethodArguments.Names.Count == 0);
Debug.Assert(extensionMethodArguments.RefKinds.Count == 0);
- extensionMethodArguments.IsExtensionMethodInvocation = true;
+ extensionMethodArguments.IncludesReceiverAsArgument = true;
extensionMethodArguments.Arguments.Add(receiver);
extensionMethodArguments.Arguments.AddRange(originalArguments.Arguments);
@@ -8244,6 +8366,17 @@ private static void CombineExtensionMethodArguments(BoundExpression receiver, An
}
}
+ private static void InitializeExtensionPropertyArguments(BoundExpression receiver, AnalyzedArguments extensionPropertyArguments)
+ {
+ Debug.Assert(receiver != null);
+ Debug.Assert(extensionPropertyArguments.Arguments.Count == 0);
+ Debug.Assert(extensionPropertyArguments.Names.Count == 0);
+ Debug.Assert(extensionPropertyArguments.RefKinds.Count == 0);
+
+ extensionPropertyArguments.IncludesReceiverAsArgument = true;
+ extensionPropertyArguments.Arguments.Add(receiver);
+ }
+
///
/// Binds a static or instance member access.
///
@@ -8366,18 +8499,22 @@ private BoundExpression BindMemberOfType(
return result;
}
- protected MethodGroupResolution BindExtensionMethod(
+#nullable enable
+ protected MethodGroupResolution ResolveExtension(
SyntaxNode expression,
- string methodName,
- AnalyzedArguments analyzedArguments,
+ string memberName,
+ AnalyzedArguments? analyzedArguments,
BoundExpression left,
ImmutableArray typeArgumentsWithAnnotations,
OverloadResolution.Options options,
RefKind returnRefKind,
- TypeSymbol returnType,
- bool withDependencies,
+ TypeSymbol? returnType,
+ ref CompoundUseSiteInfo useSiteInfo,
+ bool acceptOnlyMethods,
in CallingConventionInfo callingConvention = default)
{
+ Debug.Assert(left.Type is not null);
+ Debug.Assert(!left.Type.IsDynamic());
Debug.Assert((options & ~(OverloadResolution.Options.IsMethodGroupConversion |
OverloadResolution.Options.IsFunctionPointerResolution |
OverloadResolution.Options.InferWithDynamic |
@@ -8387,107 +8524,316 @@ protected MethodGroupResolution BindExtensionMethod(
OverloadResolution.Options.DynamicConvertsToAnything)) == 0);
var firstResult = new MethodGroupResolution();
- AnalyzedArguments actualArguments = null;
+ var lookupResult = LookupResult.GetInstance();
+ var classicExtensionLookupResult = LookupResult.GetInstance();
+ var diagnostics = BindingDiagnosticBag.GetInstance(withDiagnostics: true, useSiteInfo.AccumulatesDependencies);
+ AnalyzedArguments? actualMethodArguments = null;
+ AnalyzedArguments? actualReceiverArguments = null;
- foreach (var scope in new ExtensionMethodScopes(this))
+ int arity = typeArgumentsWithAnnotations.IsDefault ? 0 : typeArgumentsWithAnnotations.Length;
+ var lookupOptions = (arity == 0) ? LookupOptions.AllMethodsOnArityZero : LookupOptions.Default;
+ if (analyzedArguments is not null)
{
- var methodGroup = MethodGroup.GetInstance();
- var diagnostics = BindingDiagnosticBag.GetInstance(withDiagnostics: true, withDependencies);
+ lookupOptions |= LookupOptions.MustBeInvocableIfMember;
+ }
- this.PopulateExtensionMethodsFromSingleBinder(scope, methodGroup, expression, left, methodName, typeArgumentsWithAnnotations, diagnostics);
+ if (this.AllowRefOmittedArguments(left))
+ {
+ options |= OverloadResolution.Options.AllowRefOmittedArguments;
+ }
+
+ foreach (var scope in new ExtensionScopes(this))
+ {
+ lookupResult.Clear();
+ classicExtensionLookupResult.Clear();
+ diagnostics.Clear();
+
+ if (tryResolveExtensionInScope(
+ expression, left, memberName, arity,
+ typeArgumentsWithAnnotations, returnType, returnRefKind, lookupResult,
+ analyzedArguments, ref actualMethodArguments, ref actualReceiverArguments, ref useSiteInfo, ref firstResult,
+ options, callingConvention, classicExtensionLookupResult, lookupOptions, binder: this, scope: scope, diagnostics: diagnostics,
+ acceptOnlyMethods: acceptOnlyMethods,
+ result: out MethodGroupResolution result))
+ {
+ lookupResult.Free();
+ classicExtensionLookupResult.Free();
+ diagnostics.Free();
+ actualReceiverArguments?.Free();
+
+ if (result.AnalyzedArguments != actualMethodArguments)
+ {
+ actualMethodArguments?.Free();
+ }
+
+ return result;
+ }
+ }
+
+ lookupResult.Free();
+ classicExtensionLookupResult.Free();
+ diagnostics.Free();
+ actualReceiverArguments?.Free();
+
+ if (firstResult.AnalyzedArguments != actualMethodArguments)
+ {
+ actualMethodArguments?.Free();
+ }
+
+ return firstResult;
+
+ static bool tryResolveExtensionInScope(
+ SyntaxNode expression,
+ BoundExpression left,
+ string memberName,
+ int arity,
+ ImmutableArray typeArgumentsWithAnnotations,
+ TypeSymbol? returnType,
+ RefKind returnRefKind,
+ LookupResult lookupResult,
+ AnalyzedArguments? analyzedArguments,
+ ref AnalyzedArguments? actualMethodArguments,
+ ref AnalyzedArguments? actualReceiverArguments,
+ ref CompoundUseSiteInfo useSiteInfo,
+ ref MethodGroupResolution firstResult,
+ OverloadResolution.Options options,
+ CallingConventionInfo callingConvention,
+ LookupResult classicExtensionLookupResult,
+ LookupOptions lookupOptions,
+ Binder binder,
+ ExtensionScope scope,
+ bool acceptOnlyMethods,
+ BindingDiagnosticBag diagnostics,
+ out MethodGroupResolution result)
+ {
+ Debug.Assert(left.Type is not null);
+ result = default;
+
+ // 1. gather candidates
+ CompoundUseSiteInfo classicExtensionUseSiteInfo = binder.GetNewCompoundUseSiteInfo(diagnostics);
+ scope.Binder.LookupAllExtensionMembersInSingleBinder(
+ lookupResult, memberName, arity, lookupOptions,
+ originalBinder: binder, useSiteInfo: ref useSiteInfo, classicExtensionUseSiteInfo: ref classicExtensionUseSiteInfo);
+
+ diagnostics.Add(expression, classicExtensionUseSiteInfo);
+
+ if (!lookupResult.IsMultiViable)
+ {
+ return false;
+ }
+
+ // 2. resolve methods
+ MethodGroupResolution methodResult = resolveMethods(expression, left, typeArgumentsWithAnnotations, returnType, returnRefKind,
+ lookupResult, analyzedArguments, ref actualMethodArguments, options, in callingConvention, binder, diagnostics);
+
+ // 3. resolve properties
+ Debug.Assert(arity == 0 || lookupResult.Symbols.All(s => s.Kind != SymbolKind.Property));
+
+ // Tracked by https://github.com/dotnet/roslyn/issues/76130 : Regarding 'acceptOnlyMethods', consider if it would be better to add a special 'LookupOptions' value to filter out properties during lookup
+ OverloadResolutionResult? propertyResult = arity != 0 || acceptOnlyMethods ? null : resolveProperties(left, lookupResult, binder, ref actualReceiverArguments, ref useSiteInfo);
+
+ // 4. determine member kind
+ if (!methodResult.HasAnyApplicableMethod && propertyResult?.HasAnyApplicableMember != true)
+ {
+ // Found nothing applicable. Store aside the first non-applicable result and continue searching for an applicable result.
+ if (firstResult.IsEmpty)
+ {
+ if (propertyResult != null)
+ {
+ methodResult.Free(keepArguments: true);
+ propertyResult.Free();
+ firstResult = makeErrorResult(left.Type, memberName, arity, lookupResult, expression, diagnostics);
+ }
+ else
+ {
+ firstResult = methodResult;
+ }
+ }
+
+ return false;
+ }
+
+ if (methodResult.HasAnyApplicableMethod)
+ {
+ // If the search in the current scope resulted in any applicable method (regardless of whether a best
+ // applicable method could be determined) then our search is complete.
+ if (propertyResult?.HasAnyApplicableMember != true)
+ {
+ // methods win
+ propertyResult?.Free();
+ result = methodResult;
+ return true;
+ }
+
+ // ambiguous between methods and properties
+ methodResult.Free(keepArguments: true);
+ propertyResult?.Free();
+ result = makeErrorResult(left.Type, memberName, arity, lookupResult, expression, diagnostics);
+ return true;
+ }
+
+ // If the search in the current scope resulted in any applicable property (regardless of whether a best
+ // applicable property could be determined) then our search is complete.
+ Debug.Assert(propertyResult?.HasAnyApplicableMember == true);
+ methodResult.Free(keepArguments: true);
+ if (propertyResult.Succeeded && propertyResult.BestResult.Member is { } bestProperty)
+ {
+ // property wins
+ propertyResult.Free();
+ result = new MethodGroupResolution(bestProperty, LookupResultKind.Viable, diagnostics.ToReadOnly());
+ return true;
+ }
+
+ // ambiguous between multiple applicable properties
+ propertyResult.Free();
+ // Tracked by https://github.com/dotnet/roslyn/issues/76130 : consider using the property overload resolution result in the result to improve reported diagnostics
+ result = makeErrorResult(left.Type, memberName, arity, lookupResult, expression, diagnostics);
+ return true;
+ }
+
+ static MethodGroupResolution resolveMethods(
+ SyntaxNode expression,
+ BoundExpression left,
+ ImmutableArray typeArgumentsWithAnnotations,
+ TypeSymbol? returnType,
+ RefKind returnRefKind,
+ LookupResult lookupResult,
+ AnalyzedArguments? analyzedArguments,
+ ref AnalyzedArguments? actualMethodArguments,
+ OverloadResolution.Options options,
+ in CallingConventionInfo callingConvention,
+ Binder binder,
+ BindingDiagnosticBag diagnostics)
+ {
+ var methodGroup = MethodGroup.GetInstance();
+ methodGroup.PopulateWithExtensionMethods(left, lookupResult.Symbols, typeArgumentsWithAnnotations, resultKind: lookupResult.Kind);
- // analyzedArguments will be null if the caller is resolving for error recovery to the first method group
- // that can accept that receiver, regardless of arguments, when the signature cannot be inferred.
- // (In the error case of nameof(o.M) or the error case of o.M = null; for instance.)
if (analyzedArguments == null)
{
- if (expression == EnclosingNameofArgument)
+ // Without arguments (for scenarios such as `nameof` or conversion to non-delegate/dynamic type)
+ // we can still prune the inapplicable extension methods using the receiver type
+ for (int i = methodGroup.Methods.Count - 1; i >= 0; i--)
{
- for (int i = methodGroup.Methods.Count - 1; i >= 0; i--)
+ MethodSymbol method = methodGroup.Methods[i];
+ TypeSymbol? receiverType = left.Type;
+ Debug.Assert(receiverType is not null);
+
+ bool inapplicable = false;
+ if (method.IsExtensionMethod
+ && (object)method.ReduceExtensionMethod(receiverType, binder.Compilation) == null)
{
- if ((object)methodGroup.Methods[i].ReduceExtensionMethod(left.Type, this.Compilation) == null)
- methodGroup.Methods.RemoveAt(i);
+ inapplicable = true;
+ }
+ else if (method.GetIsNewExtensionMember()
+ && SourceNamedTypeSymbol.GetCompatibleSubstitutedMember(binder.Compilation, method, receiverType) == null)
+ {
+ inapplicable = true;
+ }
+
+ if (inapplicable)
+ {
+ methodGroup.Methods.RemoveAt(i);
}
}
if (methodGroup.Methods.Count != 0)
{
- return new MethodGroupResolution(methodGroup, diagnostics.ToReadOnlyAndFree());
+ return new MethodGroupResolution(methodGroup, diagnostics.ToReadOnly());
}
}
if (methodGroup.Methods.Count == 0)
{
methodGroup.Free();
- diagnostics.Free();
- continue;
+ return default;
}
- if (actualArguments == null)
+ if (actualMethodArguments == null)
{
- // Create a set of arguments for overload resolution of the
- // extension methods that includes the "this" parameter.
- actualArguments = AnalyzedArguments.GetInstance();
- CombineExtensionMethodArguments(left, analyzedArguments, actualArguments);
+ // Create a set of arguments for overload resolution including the receiver.
+ actualMethodArguments = AnalyzedArguments.GetInstance();
+ CombineExtensionMethodArguments(left, analyzedArguments, actualMethodArguments);
}
var overloadResolutionResult = OverloadResolutionResult.GetInstance();
- // If we're in a parameter default value or attribute argument, this is an error scenario, so avoid checking
- // for COM imported types to avoid a binding cycle.
- if (!InParameterDefaultValue && !InAttributeArgument && methodGroup.Receiver.IsExpressionOfComImportType())
- {
- options |= OverloadResolution.Options.AllowRefOmittedArguments;
- }
-
- CompoundUseSiteInfo useSiteInfo = GetNewCompoundUseSiteInfo(diagnostics);
- OverloadResolution.MethodInvocationOverloadResolution(
+ CompoundUseSiteInfo overloadResolutionUseSiteInfo = binder.GetNewCompoundUseSiteInfo(diagnostics);
+ binder.OverloadResolution.MethodInvocationOverloadResolution(
methods: methodGroup.Methods,
typeArguments: methodGroup.TypeArguments,
receiver: methodGroup.Receiver,
- arguments: actualArguments,
+ arguments: actualMethodArguments,
result: overloadResolutionResult,
- useSiteInfo: ref useSiteInfo,
+ ref overloadResolutionUseSiteInfo,
options: options | OverloadResolution.Options.IsExtensionMethodResolution,
returnRefKind: returnRefKind,
returnType: returnType,
in callingConvention);
- diagnostics.Add(expression, useSiteInfo);
- var sealedDiagnostics = diagnostics.ToReadOnlyAndFree();
- // Note: the MethodGroupResolution instance is responsible for freeing its copy of actual arguments
- var result = new MethodGroupResolution(methodGroup, null, overloadResolutionResult, AnalyzedArguments.GetInstance(actualArguments), methodGroup.ResultKind, sealedDiagnostics);
+ diagnostics.Add(expression, overloadResolutionUseSiteInfo);
+
+ // Note: the MethodGroupResolution instance is responsible for freeing the method group,
+ // the overload resolution result and the arguments
+ return new MethodGroupResolution(methodGroup, null, overloadResolutionResult, actualMethodArguments, methodGroup.ResultKind, diagnostics.ToReadOnly());
+ }
- // If the search in the current scope resulted in any applicable method (regardless of whether a best
- // applicable method could be determined) then our search is complete. Otherwise, store aside the
- // first non-applicable result and continue searching for an applicable result.
- if (result.HasAnyApplicableMethod)
+ // The caller is responsible for freeing the result
+ static OverloadResolutionResult? resolveProperties(
+ BoundExpression left,
+ LookupResult lookupResult,
+ Binder binder,
+ ref AnalyzedArguments? actualReceiverArguments,
+ ref CompoundUseSiteInfo useSiteInfo)
+ {
+ ArrayBuilder? properties = null;
+ foreach (var member in lookupResult.Symbols)
{
- if (!firstResult.IsEmpty)
+ if (member is PropertySymbol property)
{
- firstResult.MethodGroup.Free();
- firstResult.OverloadResolutionResult.Free();
+ properties ??= ArrayBuilder.GetInstance();
+ properties.Add(property);
}
- return result;
}
- else if (firstResult.IsEmpty)
+
+ if (properties is null)
{
- firstResult = result;
+ return null;
}
- else
+
+ if (actualReceiverArguments == null)
{
- // Neither the first result, nor applicable. No need to save result.
- overloadResolutionResult.Free();
- methodGroup.Free();
+ actualReceiverArguments = AnalyzedArguments.GetInstance();
+ InitializeExtensionPropertyArguments(left, actualReceiverArguments);
}
+
+ OverloadResolutionResult overloadResolutionResult = OverloadResolutionResult.GetInstance();
+
+ binder.OverloadResolution.PropertyOverloadResolution(properties, left, actualReceiverArguments, overloadResolutionResult,
+ allowRefOmittedArguments: binder.AllowRefOmittedArguments(left), dynamicResolution: actualReceiverArguments.HasDynamicArgument, ref useSiteInfo);
+
+ properties.Free();
+ return overloadResolutionResult;
}
- Debug.Assert((actualArguments == null) || !firstResult.IsEmpty);
- actualArguments?.Free();
- return firstResult;
+ static MethodGroupResolution makeErrorResult(TypeSymbol receiverType, string memberName, int arity, LookupResult lookupResult, SyntaxNode expression, BindingDiagnosticBag diagnostics)
+ {
+ // Tracked by https://github.com/dotnet/roslyn/issues/76130 : we'll want to describe what went wrong in a useful way (see OverloadResolutionResult.ReportDiagnostics)
+ var errorInfo = new CSDiagnosticInfo(ErrorCode.ERR_ExtensionResolutionFailed, receiverType, memberName);
+ diagnostics.Add(errorInfo, expression.Location);
+ var resultSymbol = new ExtendedErrorTypeSymbol(containingSymbol: null, lookupResult.Symbols.ToImmutable(), LookupResultKind.OverloadResolutionFailure, errorInfo, arity);
+ return new MethodGroupResolution(resultSymbol, LookupResultKind.Viable, diagnostics.ToReadOnly());
+ }
+ }
+
+ private bool AllowRefOmittedArguments(BoundExpression receiver)
+ {
+ // We don't consider when we're in default parameter values or attribute arguments so that we avoid cycles. This is an error scenario,
+ // so we don't care if we accidentally miss a parameter being applicable.
+ return !InParameterDefaultValue && !InAttributeArgument && receiver.IsExpressionOfComImportType();
}
+#nullable disable
private void PopulateExtensionMethodsFromSingleBinder(
- ExtensionMethodScope scope,
+ ExtensionScope scope,
MethodGroup methodGroup,
SyntaxNode node,
BoundExpression left,
@@ -8525,7 +8871,7 @@ private void PopulateExtensionMethodsFromSingleBinder(
lookupResult.Free();
}
- private void LookupExtensionMethods(LookupResult lookupResult, ExtensionMethodScope scope, string rightName, int arity, ref CompoundUseSiteInfo useSiteInfo)
+ private void LookupExtensionMethods(LookupResult lookupResult, ExtensionScope scope, string rightName, int arity, ref CompoundUseSiteInfo useSiteInfo)
{
LookupOptions options;
if (arity == 0)
@@ -9790,7 +10136,7 @@ private BoundExpression BindIndexerOrIndexedPropertyAccess(
// and an ambiguity error may be reported. Also additional checks are performed in runtime final validation
// that are not performed at compile-time.
// Only if the set of final applicable candidates is empty we know for sure the call will fail at runtime.
- var finalApplicableCandidates = GetCandidatesPassingFinalValidation(syntax, overloadResolutionResult, receiver, default(ImmutableArray), invokedAsExtensionMethod: false, diagnostics);
+ var finalApplicableCandidates = GetCandidatesPassingFinalValidation(syntax, overloadResolutionResult, receiver, default(ImmutableArray), isExtensionMethodGroup: false, diagnostics);
if (finalApplicableCandidates.Length == 1)
{
@@ -10153,7 +10499,9 @@ void makeCall(SyntaxNode syntax, BoundExpression receiver, MethodSymbol method,
{ WasCompilerGenerated = true };
indexerOrSliceAccess = BindMethodGroupInvocation(syntax, syntax, method.Name, boundMethodGroup, analyzedArguments,
- diagnostics, queryClause: null, ignoreNormalFormIfHasValidParamsParameter: true, anyApplicableCandidates: out bool _).MakeCompilerGenerated();
+ diagnostics, queryClause: null, ignoreNormalFormIfHasValidParamsParameter: true, anyApplicableCandidates: out bool _,
+ disallowExpandedNonArrayParams: false,
+ acceptOnlyMethods: true).MakeCompilerGenerated(); // Tracked by https://github.com/dotnet/roslyn/issues/76130 : Test effect of acceptOnlyMethods value
analyzedArguments.Free();
}
@@ -10281,24 +10629,28 @@ internal MethodGroupResolution ResolveMethodGroup(
return ResolveMethodGroup(
node, node.Syntax, node.Name, analyzedArguments, ref useSiteInfo,
- options, returnRefKind: returnRefKind, returnType: returnType,
+ options,
+ acceptOnlyMethods: true, // Tracked by https://github.com/dotnet/roslyn/issues/76130 : Confirm this value is appropriate for all consumers of the enclosing method and test effect of this value for all of them
+ returnRefKind: returnRefKind, returnType: returnType,
callingConventionInfo: callingConventionInfo);
}
internal MethodGroupResolution ResolveMethodGroup(
BoundMethodGroup node,
SyntaxNode expression,
- string methodName,
+ string memberName,
AnalyzedArguments analyzedArguments,
ref CompoundUseSiteInfo useSiteInfo,
OverloadResolution.Options options,
+ bool acceptOnlyMethods,
RefKind returnRefKind = default,
TypeSymbol returnType = null,
in CallingConventionInfo callingConventionInfo = default)
{
var methodResolution = ResolveMethodGroupInternal(
- node, expression, methodName, analyzedArguments, ref useSiteInfo,
+ node, expression, memberName, analyzedArguments, ref useSiteInfo,
options,
+ acceptOnlyMethods: acceptOnlyMethods,
returnRefKind: returnRefKind, returnType: returnType,
callingConvention: callingConventionInfo);
if (methodResolution.IsEmpty && !methodResolution.HasAnyErrors)
@@ -10315,31 +10667,14 @@ internal MethodGroupResolution ResolveMethodGroup(
return methodResolution;
}
- internal MethodGroupResolution ResolveMethodGroupForFunctionPointer(
- BoundMethodGroup methodGroup,
- AnalyzedArguments analyzedArguments,
- TypeSymbol returnType,
- RefKind returnRefKind,
- in CallingConventionInfo callingConventionInfo,
- ref CompoundUseSiteInfo useSiteInfo)
- {
- return ResolveDefaultMethodGroup(
- methodGroup,
- analyzedArguments,
- ref useSiteInfo,
- options: OverloadResolution.Options.IsMethodGroupConversion | OverloadResolution.Options.IsFunctionPointerResolution,
- returnRefKind,
- returnType,
- callingConventionInfo);
- }
-
private MethodGroupResolution ResolveMethodGroupInternal(
BoundMethodGroup methodGroup,
SyntaxNode expression,
- string methodName,
+ string memberName,
AnalyzedArguments analyzedArguments,
ref CompoundUseSiteInfo useSiteInfo,
OverloadResolution.Options options,
+ bool acceptOnlyMethods,
RefKind returnRefKind = default,
TypeSymbol returnType = null,
in CallingConventionInfo callingConvention = default)
@@ -10351,14 +10686,15 @@ private MethodGroupResolution ResolveMethodGroupInternal(
// If the method group's receiver is dynamic then there is no point in looking for extension methods;
// it's going to be a dynamic invocation.
- if (!methodGroup.SearchExtensionMethods || methodResolution.HasAnyApplicableMethod || methodGroup.MethodGroupReceiverIsDynamic())
+ if (!methodGroup.SearchExtensions || methodResolution.HasAnyApplicableMethod || methodGroup.MethodGroupReceiverIsDynamic())
{
return methodResolution;
}
- var extensionMethodResolution = BindExtensionMethod(
- expression, methodName, analyzedArguments, methodGroup.ReceiverOpt, methodGroup.TypeArgumentsOpt, options,
- returnRefKind: returnRefKind, returnType: returnType, withDependencies: useSiteInfo.AccumulatesDependencies,
+ var extensionMethodResolution = ResolveExtension(
+ expression, memberName, analyzedArguments, methodGroup.ReceiverOpt, methodGroup.TypeArgumentsOpt, options,
+ returnRefKind: returnRefKind, returnType: returnType, ref useSiteInfo,
+ acceptOnlyMethods: acceptOnlyMethods,
in callingConvention);
bool preferExtensionMethodResolution = false;
@@ -10464,10 +10800,7 @@ private MethodGroupResolution ResolveDefaultMethodGroup(
else
{
var result = OverloadResolutionResult.GetInstance();
- // We check for being in a default parameter value or attribute to avoid a cycle. If we're binding these,
- // this entire expression is bad, so we don't care whether this is a COM import type and we can safely
- // just pass false here.
- if (!InParameterDefaultValue && !InAttributeArgument && methodGroup.Receiver.IsExpressionOfComImportType())
+ if (AllowRefOmittedArguments(methodGroup.Receiver))
{
options |= OverloadResolution.Options.AllowRefOmittedArguments;
}
@@ -10548,10 +10881,10 @@ private MethodGroupResolution ResolveDefaultMethodGroup(
}
}
- if (node.SearchExtensionMethods)
+ if (node.ReceiverOpt is not BoundTypeExpression && node.SearchExtensions)
{
var receiver = node.ReceiverOpt!;
- foreach (var scope in new ExtensionMethodScopes(this))
+ foreach (var scope in new ExtensionScopes(this))
{
methods.Clear();
var methodGroup = MethodGroup.GetInstance();
@@ -10655,6 +10988,9 @@ static bool isCandidateUnique(ref MethodSymbol? method, MethodSymbol candidate)
useParams = false;
MethodSymbol? foundMethod = null;
var typeArguments = node.TypeArgumentsOpt;
+ int arity = typeArguments.IsDefaultOrEmpty ? 0 : typeArguments.Length;
+
+ // 1. instance methods
if (node.ResultKind == LookupResultKind.Viable)
{
var methods = ArrayBuilder.GetInstance(capacity: node.Methods.Length);
@@ -10662,6 +10998,8 @@ static bool isCandidateUnique(ref MethodSymbol? method, MethodSymbol candidate)
{
switch (node.ReceiverOpt)
{
+ case BoundTypeOrValueExpression:
+ break;
case BoundTypeExpression:
case null: // if `using static Class` is in effect, the receiver is missing
if (!memberMethod.IsStatic) continue;
@@ -10673,7 +11011,6 @@ static bool isCandidateUnique(ref MethodSymbol? method, MethodSymbol candidate)
break;
}
- int arity = typeArguments.IsDefaultOrEmpty ? 0 : typeArguments.Length;
if (memberMethod.Arity != arity)
{
// We have no way of inferring type arguments, so if the given type arguments
@@ -10714,52 +11051,63 @@ static bool isCandidateUnique(ref MethodSymbol? method, MethodSymbol candidate)
}
}
- if (node.SearchExtensionMethods)
+ // 2. extensions
+ if (node.SearchExtensions)
{
- var receiver = node.ReceiverOpt!;
- var methodGroup = MethodGroup.GetInstance();
- foreach (var scope in new ExtensionMethodScopes(this))
- {
- methodGroup.Clear();
- PopulateExtensionMethodsFromSingleBinder(scope, methodGroup, node.Syntax, receiver, node.Name, typeArguments, BindingDiagnosticBag.Discarded);
- var methods = ArrayBuilder.GetInstance(capacity: methodGroup.Methods.Count);
- foreach (var extensionMethod in methodGroup.Methods)
- {
- var substituted = typeArguments.IsDefaultOrEmpty ? extensionMethod : extensionMethod.Construct(typeArguments);
+ Debug.Assert(node.ReceiverOpt!.Type is not null); // extensions are only considered on member access
- var reduced = substituted.ReduceExtensionMethod(receiver.Type, Compilation, out bool wasFullyInferred);
- if (reduced is null)
- {
- // Extension method was not applicable
- continue;
- }
+ BoundExpression receiver = node.ReceiverOpt;
+ LookupOptions options = arity == 0 ? LookupOptions.AllMethodsOnArityZero : LookupOptions.Default;
+ var singleLookupResults = ArrayBuilder.GetInstance();
+ CompoundUseSiteInfo discardedUseSiteInfo = CompoundUseSiteInfo.Discarded;
+
+ foreach (var scope in new ExtensionScopes(this))
+ {
+ singleLookupResults.Clear();
+ scope.Binder.EnumerateAllExtensionMembersInSingleBinder(singleLookupResults, node.Name, arity, options, originalBinder: this, ref discardedUseSiteInfo, ref discardedUseSiteInfo);
- if (!wasFullyInferred)
+ var methods = ArrayBuilder.GetInstance(capacity: singleLookupResults.Count);
+ foreach (SingleLookupResult singleLookupResult in singleLookupResults)
+ {
+ // Remove static/instance mismatches
+ Symbol extensionMember = singleLookupResult.Symbol;
+ bool memberCountsAsStatic = extensionMember is MethodSymbol { IsExtensionMethod: true } ? false : extensionMember.IsStatic;
+ switch (node.ReceiverOpt)
{
- continue;
+ case BoundTypeOrValueExpression:
+ break;
+ case BoundTypeExpression:
+ if (!memberCountsAsStatic) continue;
+ break;
+ default:
+ if (memberCountsAsStatic) continue;
+ break;
}
- if (!satisfiesConstraintChecks(reduced))
+ // Note: we only care about methods since we're already decided this is a method group (ie. not resolving to some other kind of extension member)
+ if (extensionMember is MethodSymbol method)
{
- continue;
+ var substituted = (MethodSymbol?)extensionMember.GetReducedAndFilteredSymbol(typeArguments, receiver.Type, Compilation, checkFullyInferred: true);
+ if (substituted is not null)
+ {
+ methods.Add(substituted);
+ }
}
-
- methods.Add(reduced);
}
if (!OverloadResolution.FilterMethodsForUniqueSignature(methods, out useParams))
{
+ singleLookupResults.Free();
methods.Free();
- methodGroup.Free();
return null;
}
- foreach (var reduced in methods)
+ foreach (var method in methods)
{
- if (!isCandidateUnique(ref foundMethod, reduced))
+ if (!isCandidateUnique(ref foundMethod, method))
{
+ singleLookupResults.Free();
methods.Free();
- methodGroup.Free();
useParams = false;
return null;
}
@@ -10769,11 +11117,12 @@ static bool isCandidateUnique(ref MethodSymbol? method, MethodSymbol candidate)
if (foundMethod is not null)
{
- methodGroup.Free();
+ singleLookupResults.Free();
return foundMethod;
}
}
- methodGroup.Free();
+
+ singleLookupResults.Free();
}
useParams = false;
@@ -10977,6 +11326,10 @@ private BoundConditionalAccess BindConditionalAccessExpression(ConditionalAccess
var conditionalAccessBinder = new BinderWithConditionalReceiver(this, receiver);
var access = conditionalAccessBinder.BindValue(node.WhenNotNull, diagnostics, BindValueKind.RValue);
+ if (access.Syntax is AssignmentExpressionSyntax assignment)
+ {
+ MessageID.IDS_FeatureNullConditionalAssignment.CheckFeatureAvailability(diagnostics, assignment.OperatorToken);
+ }
if (receiver.HasAnyErrors || access.HasAnyErrors)
{
diff --git a/src/Compilers/CSharp/Portable/Binder/Binder_InterpolatedString.cs b/src/Compilers/CSharp/Portable/Binder/Binder_InterpolatedString.cs
index 2e1a9223a5d40..2fe795e8b504f 100644
--- a/src/Compilers/CSharp/Portable/Binder/Binder_InterpolatedString.cs
+++ b/src/Compilers/CSharp/Portable/Binder/Binder_InterpolatedString.cs
@@ -972,7 +972,7 @@ private ImmutableArray BindInterpolatedStringParts(BoundUnconve
parameterNamesAndLocationsBuilder.Clear();
}
- var call = MakeInvocationExpression(part.Syntax, implicitBuilderReceiver, methodName, arguments, diagnostics, names: parameterNamesAndLocations, searchExtensionMethodsIfNecessary: false);
+ var call = MakeInvocationExpression(part.Syntax, implicitBuilderReceiver, methodName, arguments, diagnostics, names: parameterNamesAndLocations, searchExtensionsIfNecessary: false);
builderAppendCalls.Add(call);
positionInfo.Add((isLiteral, hasAlignment, hasFormat));
diff --git a/src/Compilers/CSharp/Portable/Binder/Binder_Invocation.cs b/src/Compilers/CSharp/Portable/Binder/Binder_Invocation.cs
index fcf522526898d..ba3fd176a2680 100644
--- a/src/Compilers/CSharp/Portable/Binder/Binder_Invocation.cs
+++ b/src/Compilers/CSharp/Portable/Binder/Binder_Invocation.cs
@@ -86,7 +86,7 @@ internal BoundExpression MakeInvocationExpression(
CSharpSyntaxNode? queryClause = null,
bool allowFieldsAndProperties = false,
bool ignoreNormalFormIfHasValidParamsParameter = false,
- bool searchExtensionMethodsIfNecessary = true,
+ bool searchExtensionsIfNecessary = true,
bool disallowExpandedNonArrayParams = false)
{
//
@@ -101,7 +101,7 @@ internal BoundExpression MakeInvocationExpression(
Debug.Assert(names.IsDefault || names.Length == args.Length);
receiver = BindToNaturalType(receiver, diagnostics);
- var boundExpression = BindInstanceMemberAccess(node, node, receiver, methodName, typeArgs.NullToEmpty().Length, typeArgsSyntax, typeArgs, invoked: true, indexed: false, diagnostics, searchExtensionMethodsIfNecessary);
+ var boundExpression = BindInstanceMemberAccess(node, node, receiver, methodName, typeArgs.NullToEmpty().Length, typeArgsSyntax, typeArgs, invoked: true, indexed: false, diagnostics, searchExtensionsIfNecessary);
// The other consumers of this helper (await and collection initializers) require the target member to be a method.
if (!allowFieldsAndProperties && (boundExpression.Kind == BoundKind.FieldAccess || boundExpression.Kind == BoundKind.PropertyAccess))
@@ -355,7 +355,8 @@ private BoundExpression BindInvocationExpression(
diagnostics, queryClause,
ignoreNormalFormIfHasValidParamsParameter: ignoreNormalFormIfHasValidParamsParameter,
disallowExpandedNonArrayParams: disallowExpandedNonArrayParams,
- anyApplicableCandidates: out _);
+ anyApplicableCandidates: out _,
+ acceptOnlyMethods: false);
}
else if ((object)(delegateType = GetDelegateType(boundExpression)) != null)
{
@@ -696,7 +697,8 @@ private BoundExpression BindMethodGroupInvocation(
CSharpSyntaxNode queryClause,
bool ignoreNormalFormIfHasValidParamsParameter,
out bool anyApplicableCandidates,
- bool disallowExpandedNonArrayParams = false)
+ bool disallowExpandedNonArrayParams,
+ bool acceptOnlyMethods) // For example, do not accept extension property value invocations (delegates returned by a property can be invoked, etc.)
{
//
// !!! ATTENTION !!!
@@ -713,8 +715,23 @@ private BoundExpression BindMethodGroupInvocation(
useSiteInfo: ref useSiteInfo,
options: (ignoreNormalFormIfHasValidParamsParameter ? OverloadResolution.Options.IgnoreNormalFormIfHasValidParamsParameter : OverloadResolution.Options.None) |
(disallowExpandedNonArrayParams ? OverloadResolution.Options.DisallowExpandedNonArrayParams : OverloadResolution.Options.None) |
- (analyzedArguments.HasDynamicArgument ? OverloadResolution.Options.DynamicResolution : OverloadResolution.Options.None));
+ (analyzedArguments.HasDynamicArgument ? OverloadResolution.Options.DynamicResolution : OverloadResolution.Options.None),
+ acceptOnlyMethods: acceptOnlyMethods);
diagnostics.Add(expression, useSiteInfo);
+
+ if (resolution.IsNonMethodExtensionMember(out Symbol extensionMember))
+ {
+ diagnostics.AddRange(resolution.Diagnostics);
+ BoundExpression extensionMemberAccess = GetExtensionMemberAccess(expression, methodGroup.ReceiverOpt, extensionMember, diagnostics);
+
+ Debug.Assert(extensionMemberAccess.Kind != BoundKind.MethodGroup);
+
+ extensionMemberAccess = CheckValue(extensionMemberAccess, BindValueKind.RValue, diagnostics);
+ BoundExpression extensionMemberInvocation = BindInvocationExpression(syntax, expression, methodName: null, extensionMemberAccess, analyzedArguments, diagnostics);
+ anyApplicableCandidates = !extensionMemberInvocation.HasAnyErrors;
+ return extensionMemberInvocation;
+ }
+
anyApplicableCandidates = resolution.ResultKind == LookupResultKind.Viable && resolution.OverloadResolutionResult.HasAnyApplicableMember;
if (!methodGroup.HasAnyErrors) diagnostics.AddRange(resolution.Diagnostics); // Suppress cascading.
@@ -782,7 +799,7 @@ private BoundExpression BindMethodGroupInvocation(
var finalApplicableCandidates = GetCandidatesPassingFinalValidation(syntax, resolution.OverloadResolutionResult,
methodGroup.ReceiverOpt,
methodGroup.TypeArgumentsOpt,
- invokedAsExtensionMethod: resolution.IsExtensionMethodGroup,
+ isExtensionMethodGroup: resolution.IsExtensionMethodGroup,
diagnostics);
if (finalApplicableCandidates.Length == 0)
@@ -812,11 +829,9 @@ private BoundExpression BindMethodGroupInvocation(
// casting the dynamic arguments or calling the extension method without the extension method
// syntax.
- // We found an extension method, so the instance associated with the method group must have
- // existed and had a type.
- Debug.Assert(methodGroup.InstanceOpt != null && (object)methodGroup.InstanceOpt.Type != null);
+ Debug.Assert(methodGroup.ReceiverOpt != null && (object)methodGroup.ReceiverOpt.Type != null);
- Error(diagnostics, ErrorCode.ERR_BadArgTypeDynamicExtension, syntax, methodGroup.InstanceOpt.Type, methodGroup.Name);
+ Error(diagnostics, ErrorCode.ERR_BadArgTypeDynamicExtension, syntax, methodGroup.ReceiverOpt.Type, methodGroup.Name);
result = CreateBadCall(syntax, methodGroup, methodGroup.ResultKind, analyzedArguments);
}
else
@@ -972,7 +987,7 @@ private ImmutableArray> GetCandi
OverloadResolutionResult overloadResolutionResult,
BoundExpression receiverOpt,
ImmutableArray typeArgumentsOpt,
- bool invokedAsExtensionMethod,
+ bool isExtensionMethodGroup,
BindingDiagnosticBag diagnostics) where TMethodOrPropertySymbol : Symbol
{
Debug.Assert(overloadResolutionResult.HasAnyApplicableMember);
@@ -994,7 +1009,8 @@ private ImmutableArray> GetCandi
// * If F is an instance method, the method group must have resulted from a simple-name, a member-access through a variable or value,
// or a member-access whose receiver can't be classified as a type or value until after overload resolution (see §7.6.4.1).
- if (!MemberGroupFinalValidationAccessibilityChecks(receiverOpt, result.Member, syntax, candidateDiagnostics, invokedAsExtensionMethod: invokedAsExtensionMethod) &&
+ TMethodOrPropertySymbol member = result.Member;
+ if (!MemberGroupFinalValidationAccessibilityChecks(receiverOpt, member, syntax, candidateDiagnostics, invokedAsExtensionMethod: isExtensionMethodGroup && !member.GetIsNewExtensionMember()) &&
(typeArgumentsOpt.IsDefault || ((MethodSymbol)(object)result.Member).CheckConstraints(new ConstraintsHelper.CheckConstraintsArgs(this.Compilation, this.Conversions, includeNullability: false, syntax.Location, candidateDiagnostics))))
{
finalCandidates.Add(result);
@@ -1042,7 +1058,7 @@ private void CheckRestrictedTypeReceiver(BoundExpression expression, CSharpCompi
case BoundKind.Call:
{
var call = (BoundCall)expression;
- if (!call.HasAnyErrors && call.ReceiverOpt != null && (object)call.ReceiverOpt.Type != null)
+ if (!call.HasAnyErrors && call.ReceiverOpt != null && (object)call.ReceiverOpt.Type != null && !call.Method.GetIsNewExtensionMember())
{
// error CS0029: Cannot implicitly convert type 'A' to 'B'
@@ -1120,7 +1136,7 @@ private BoundCall BindInvocationExpressionContinued(
Debug.Assert(methodGroup.Methods.Count > 0);
Debug.Assert(((object)delegateTypeOpt == null) || (methodGroup.Methods.Count == 1));
- var invokedAsExtensionMethod = methodGroup.IsExtensionMethodGroup;
+ bool invokedAsExtensionMethod = methodGroup.IsExtensionMethodGroup;
// Delegate invocations should never be considered extension method
// invocations (even though the delegate may refer to an extension method).
@@ -1184,6 +1200,28 @@ private BoundCall BindInvocationExpressionContinued(
var methodResult = result.ValidResult;
var returnType = methodResult.Member.ReturnType;
var method = methodResult.Member;
+ bool isNewExtensionMethod = method.GetIsNewExtensionMember();
+
+ if (isNewExtensionMethod)
+ {
+ // For new extension methods, we performed overload resolution giving the receiver as one of the arguments.
+ // We now restore the arguments to their original state and update the result accordingly.
+ invokedAsExtensionMethod = false;
+ analyzedArguments.Arguments.RemoveAt(0);
+
+ if (analyzedArguments.Names is { Count: > 0 })
+ {
+ analyzedArguments.Names.RemoveAt(0);
+ }
+
+ if (analyzedArguments.RefKinds is { Count: > 0 })
+ {
+ analyzedArguments.RefKinds.RemoveAt(0);
+ }
+
+ Debug.Assert(methodResult.Result.ConversionForArg(0).Exists);
+ methodResult = methodResult.WithResult(methodResult.Result.WithoutReceiverArgument());
+ }
// It is possible that overload resolution succeeded, but we have chosen an
// instance method and we're in a static method. A careful reading of the
@@ -1248,9 +1286,13 @@ private BoundCall BindInvocationExpressionContinued(
analyzedArguments.Arguments[0] = receiverArgument;
}
+ else if (isNewExtensionMethod && receiver is not BoundTypeExpression)
+ {
+ receiver = CheckAndConvertExtensionReceiver(receiver, method.ContainingType.ExtensionParameter, diagnostics);
+ }
// This will be the receiver of the BoundCall node that we create.
- // For extension methods, there is no receiver because the receiver in source was actually the first argument.
+ // For classic extension methods, there is no receiver because the receiver in source was actually the first argument.
// For instance methods, we may have synthesized an implicit this node. We'll keep it for the emitter.
// For static methods, we may have synthesized a type expression. It serves no purpose, so we'll drop it.
if (invokedAsExtensionMethod || (!method.RequiresInstanceReceiver && receiver != null && receiver.WasCompilerGenerated))
@@ -1317,6 +1359,20 @@ private BoundCall BindInvocationExpressionContinued(
}
#nullable enable
+ private BoundExpression CheckAndConvertExtensionReceiver(BoundExpression receiver, ParameterSymbol extensionParameter, BindingDiagnosticBag diagnostics)
+ {
+ CheckArgumentRefKind(RefKind.None, receiver, arg: 0, extensionParameter, invokedAsExtensionMethod: true, diagnostics);
+
+ if (extensionParameter.RefKind == RefKind.Ref)
+ {
+ // If this was a ref extension method, the receiver must be checked for L-value constraints.
+ // This helper method will also replace it with a BoundBadExpression if it was invalid.
+ receiver = CheckValue(receiver, BindValueKind.RefOrOut, diagnostics);
+ }
+
+ receiver = CreateConversion(receiver, extensionParameter.Type, diagnostics);
+ return receiver;
+ }
internal ThreeState ReceiverIsSubjectToCloning(BoundExpression? receiver, PropertySymbol property)
{
@@ -1711,7 +1767,6 @@ static int getArgumentIndex(int parameterIndex, ImmutableArray argsToParams
? parameterIndex
: argsToParamsOpt.IndexOf(parameterIndex);
}
-
}
private BoundExpression CreateParamsCollection(SyntaxNode node, ParameterSymbol paramsParameter, ImmutableArray collectionArgs, BindingDiagnosticBag diagnostics)
@@ -2252,6 +2307,8 @@ private void EnsureNameofExpressionSymbols(BoundMethodGroup methodGroup, Binding
// Check that the method group contains something applicable. Otherwise error.
CompoundUseSiteInfo useSiteInfo = GetNewCompoundUseSiteInfo(diagnostics);
var resolution = ResolveMethodGroup(methodGroup, analyzedArguments: null, useSiteInfo: ref useSiteInfo, options: OverloadResolution.Options.None);
+ Debug.Assert(!resolution.IsNonMethodExtensionMember(out _));
+
diagnostics.Add(methodGroup.Syntax, useSiteInfo);
diagnostics.AddRange(resolution.Diagnostics);
if (resolution.IsExtensionMethodGroup)
@@ -2341,6 +2398,7 @@ internal bool InvocableNameofInScope()
#nullable enable
private BoundFunctionPointerInvocation BindFunctionPointerInvocation(SyntaxNode node, BoundExpression boundExpression, AnalyzedArguments analyzedArguments, BindingDiagnosticBag diagnostics)
{
+ // Tracked by https://github.com/dotnet/roslyn/issues/76130 : this function will probably need an adjustment to deal with static extensions
boundExpression = BindToNaturalType(boundExpression, diagnostics);
RoslynDebug.Assert(boundExpression.Type is FunctionPointerTypeSymbol);
diff --git a/src/Compilers/CSharp/Portable/Binder/Binder_Lambda.cs b/src/Compilers/CSharp/Portable/Binder/Binder_Lambda.cs
index 09a442e1d1869..da85570b65b95 100644
--- a/src/Compilers/CSharp/Portable/Binder/Binder_Lambda.cs
+++ b/src/Compilers/CSharp/Portable/Binder/Binder_Lambda.cs
@@ -9,6 +9,7 @@
using Microsoft.CodeAnalysis.CSharp.Symbols;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.PooledObjects;
+using static Microsoft.CodeAnalysis.CSharp.Symbols.ParameterHelpers;
namespace Microsoft.CodeAnalysis.CSharp
{
@@ -177,16 +178,14 @@ private UnboundLambda AnalyzeAnonymousFunction(
var typeOpt = p.Type is not null ? BindType(p.Type, diagnostics) : default;
- var refKind = ParameterHelpers.GetModifiers(p.Modifiers, out _, out var paramsKeyword, out _, out var scope);
+ var refKind = ParameterHelpers.GetModifiers(p.Modifiers, ignoreParams: false, out _, out var paramsKeyword, out _, out var scope);
var isParams = paramsKeyword.Kind() != SyntaxKind.None;
- ParameterHelpers.CheckParameterModifiers(p, diagnostics, parsingFunctionPointerParams: false,
- parsingLambdaParams: !isAnonymousMethod,
- parsingAnonymousMethodParams: isAnonymousMethod);
+ ParameterHelpers.CheckParameterModifiers(p, diagnostics, isAnonymousMethod ? ParameterContext.AnonymousMethod : ParameterContext.Lambda);
ParameterHelpers.ReportParameterErrors(
- owner: null, p, ordinal: i, lastParameterIndex: n - 1, isParams: isParams, typeOpt,
- refKind, containingSymbol: null, thisKeyword: default, paramsKeyword: paramsKeyword, firstDefault, diagnostics);
+ owner: null, syntax: p, ordinal: i, lastParameterIndex: n - 1, isParams: isParams, typeWithAnnotations: typeOpt,
+ refKind: refKind, containingSymbol: null, thisKeyword: default, paramsKeyword: paramsKeyword, firstDefault: firstDefault, diagnostics: diagnostics);
if (parameterCount == parameterSyntaxList.Count &&
paramsKeyword.Kind() != SyntaxKind.None &&
diff --git a/src/Compilers/CSharp/Portable/Binder/Binder_Lookup.cs b/src/Compilers/CSharp/Portable/Binder/Binder_Lookup.cs
index 764423d3d7b8a..7c0fede4e5119 100644
--- a/src/Compilers/CSharp/Portable/Binder/Binder_Lookup.cs
+++ b/src/Compilers/CSharp/Portable/Binder/Binder_Lookup.cs
@@ -44,13 +44,19 @@ internal void LookupSymbolsSimpleName(
}
}
- internal void LookupExtensionMethods(LookupResult result, string name, int arity, LookupOptions options, ref CompoundUseSiteInfo useSiteInfo)
+#nullable enable
+ internal void LookupAllExtensions(LookupResult result, string? name, LookupOptions options)
{
- foreach (var scope in new ExtensionMethodScopes(this))
+ var discardedUseSiteInfo = CompoundUseSiteInfo.Discarded;
+
+ foreach (var scope in new ExtensionScopes(this))
{
- this.LookupExtensionMethodsInSingleBinder(scope, result, name, arity, options, ref useSiteInfo);
+ scope.Binder.LookupAllExtensionMembersInSingleBinder(
+ result, name, arity: 0, options: options,
+ originalBinder: this, useSiteInfo: ref discardedUseSiteInfo, classicExtensionUseSiteInfo: ref discardedUseSiteInfo);
}
}
+#nullable disable
///
/// Look for any symbols in scope with the given name and arity.
@@ -176,6 +182,71 @@ protected void LookupMembersInternal(LookupResult result, NamespaceOrTypeSymbol
}
}
+#nullable enable
+ private void LookupAllExtensionMembersInSingleBinder(LookupResult result, string? name,
+ int arity, LookupOptions options, Binder originalBinder, ref CompoundUseSiteInfo useSiteInfo, ref CompoundUseSiteInfo classicExtensionUseSiteInfo)
+ {
+ var singleLookupResults = ArrayBuilder.GetInstance();
+ EnumerateAllExtensionMembersInSingleBinder(singleLookupResults, name, arity, options, originalBinder, ref useSiteInfo, ref classicExtensionUseSiteInfo);
+ foreach (var singleLookupResult in singleLookupResults)
+ {
+ result.MergeEqual(singleLookupResult);
+ }
+
+ singleLookupResults.Free();
+ }
+
+ internal void EnumerateAllExtensionMembersInSingleBinder(ArrayBuilder result,
+ string? name, int arity, LookupOptions options, Binder originalBinder, ref CompoundUseSiteInfo useSiteInfo, ref CompoundUseSiteInfo classicExtensionUseSiteInfo)
+ {
+ PooledHashSet? implementationsToShadow = null;
+
+ // 1. Collect new extension members
+ if (this.Compilation.LanguageVersion.AllowNewExtensions())
+ {
+ var extensionDeclarations = ArrayBuilder.GetInstance();
+ this.GetExtensionDeclarations(extensionDeclarations, originalBinder);
+
+ foreach (NamedTypeSymbol extensionDeclaration in extensionDeclarations)
+ {
+ var candidates = name is null ? extensionDeclaration.GetMembers() : extensionDeclaration.GetMembers(name);
+
+ foreach (var candidate in candidates)
+ {
+ SingleLookupResult resultOfThisMember = originalBinder.CheckViability(candidate, arity, options, null, diagnose: true, useSiteInfo: ref useSiteInfo);
+ result.Add(resultOfThisMember);
+
+ if (candidate is MethodSymbol { IsStatic: false } shadows &&
+ shadows.OriginalDefinition.TryGetCorrespondingExtensionImplementationMethod() is { } toShadow)
+ {
+ implementationsToShadow ??= PooledHashSet.GetInstance();
+ implementationsToShadow.Add(toShadow);
+ }
+ }
+ }
+
+ extensionDeclarations.Free();
+ }
+
+ // 2. Collect classic extension methods
+ var extensionMethods = ArrayBuilder.GetInstance();
+ this.GetCandidateExtensionMethods(extensionMethods, name, arity, options, originalBinder: originalBinder);
+
+ foreach (var method in extensionMethods)
+ {
+ // Prefer instance extension declarations vs. their implementations
+ if (implementationsToShadow is null || !implementationsToShadow.Remove(method.OriginalDefinition))
+ {
+ SingleLookupResult resultOfThisMember = originalBinder.CheckViability(method, arity, options, null, diagnose: true, useSiteInfo: ref classicExtensionUseSiteInfo);
+ result.Add(resultOfThisMember);
+ }
+ }
+
+ extensionMethods.Free();
+ implementationsToShadow?.Free();
+ }
+#nullable disable
+
// Looks up a member of given name and arity in a particular type.
protected void LookupMembersInType(LookupResult result, TypeSymbol type, string name, int arity, ConsList basesBeingResolved, LookupOptions options, Binder originalBinder, bool diagnose, ref CompoundUseSiteInfo useSiteInfo)
{
@@ -205,6 +276,7 @@ protected void LookupMembersInType(LookupResult result, TypeSymbol type, string
case TypeKind.Pointer:
case TypeKind.FunctionPointer:
+ case TypeKind.Extension:
result.Clear();
break;
@@ -451,13 +523,14 @@ private static void LookupMembersInNamespace(LookupResult result, NamespaceSymbo
}
}
+ // Tracked by https://github.com/dotnet/roslyn/issues/76130 : we should be able to remove this method once all the callers are updated to account for new extension members
///
/// Lookup extension methods by name and arity in the given binder and
/// check viability in this binder. The lookup is performed on a single
/// binder because extension method search stops at the first applicable
/// method group from the nearest enclosing namespace.
///
- private void LookupExtensionMethodsInSingleBinder(ExtensionMethodScope scope, LookupResult result, string name, int arity, LookupOptions options, ref CompoundUseSiteInfo useSiteInfo)
+ private void LookupExtensionMethodsInSingleBinder(ExtensionScope scope, LookupResult result, string name, int arity, LookupOptions options, ref CompoundUseSiteInfo useSiteInfo)
{
var methods = ArrayBuilder.GetInstance();
var binder = scope.Binder;
@@ -738,7 +811,7 @@ private bool CheckAttributeTypeViability(Symbol symbol, bool diagnose, ref Diagn
#endregion
- internal virtual bool SupportsExtensionMethods
+ internal virtual bool SupportsExtensions
{
get { return false; }
}
@@ -759,6 +832,19 @@ internal virtual void GetCandidateExtensionMethods(
{
}
+#nullable enable
+ ///
+ /// Return the extension declarations from this specific binding scope
+ /// Since the lookup of extension members is iterative, proceeding one binding scope at a time,
+ /// GetExtensionDeclarations should not defer to the next binding scope. Instead, the caller is
+ /// responsible for walking the nested binding scopes from innermost to outermost. This method is overridden
+ /// to search the available members list in binding types that represent types, namespaces, and usings.
+ ///
+ internal virtual void GetExtensionDeclarations(ArrayBuilder extensions, Binder originalBinder)
+ {
+ }
+#nullable disable
+
// Does a member lookup in a single type, without considering inheritance.
protected static void LookupMembersWithoutInheritance(LookupResult result, TypeSymbol type, string name, int arity,
LookupOptions options, Binder originalBinder, TypeSymbol accessThroughType, bool diagnose, ref CompoundUseSiteInfo useSiteInfo, ConsList basesBeingResolved)
@@ -1793,7 +1879,7 @@ private static bool WrongArity(Symbol symbol, int arity, bool diagnose, LookupOp
if (arity != 0 || (options & LookupOptions.AllMethodsOnArityZero) == 0)
{
MethodSymbol method = (MethodSymbol)symbol;
- if (method.Arity != arity)
+ if (method.GetMemberArityIncludingExtension() != arity)
{
if (method.Arity == 0)
{
diff --git a/src/Compilers/CSharp/Portable/Binder/Binder_NameConflicts.cs b/src/Compilers/CSharp/Portable/Binder/Binder_NameConflicts.cs
index a4bb61a86fcff..26733eb3a9949 100644
--- a/src/Compilers/CSharp/Portable/Binder/Binder_NameConflicts.cs
+++ b/src/Compilers/CSharp/Portable/Binder/Binder_NameConflicts.cs
@@ -30,10 +30,10 @@ internal void ValidateParameterNameConflicts(
bool allowShadowingNames,
BindingDiagnosticBag diagnostics)
{
- PooledHashSet? tpNames = null;
+ PooledDictionary? tpNames = null;
if (!typeParameters.IsDefaultOrEmpty)
{
- tpNames = PooledHashSet.GetInstance();
+ tpNames = PooledDictionary.GetInstance();
foreach (var tp in typeParameters)
{
var name = tp.Name;
@@ -42,7 +42,7 @@ internal void ValidateParameterNameConflicts(
continue;
}
- if (!tpNames.Add(name))
+ if (!tpNames.TryAdd(name, tp))
{
// Type parameter declaration name conflicts are detected elsewhere
}
@@ -65,16 +65,37 @@ internal void ValidateParameterNameConflicts(
continue;
}
- if (tpNames != null && tpNames.Contains(name))
+ if (tpNames != null && tpNames.TryGetValue(name, out TypeParameterSymbol? tp))
{
- // CS0412: 'X': a parameter or local variable cannot have the same name as a method type parameter
- diagnostics.Add(ErrorCode.ERR_LocalSameNameAsTypeParam, GetLocation(p), name);
+ if (tp.ContainingSymbol is NamedTypeSymbol { IsExtension: true })
+ {
+ if (p.ContainingSymbol != (object)tp.ContainingSymbol) // Otherwise, SynthesizedExtensionMarker is going to report an error about this conflict
+ {
+ diagnostics.Add(ErrorCode.ERR_LocalSameNameAsExtensionTypeParameter, GetLocation(p), name);
+ }
+ }
+ else if (p.ContainingSymbol is NamedTypeSymbol { IsExtension: true })
+ {
+ diagnostics.Add(ErrorCode.ERR_TypeParameterSameNameAsExtensionParameter, tp.GetFirstLocationOrNone(), name);
+ }
+ else
+ {
+ // CS0412: 'X': a parameter or local variable cannot have the same name as a method type parameter
+ diagnostics.Add(ErrorCode.ERR_LocalSameNameAsTypeParam, GetLocation(p), name);
+ }
}
if (!pNames.Add(name))
{
- // The parameter name '{0}' is a duplicate
- diagnostics.Add(ErrorCode.ERR_DuplicateParamName, GetLocation(p), name);
+ if (parameters[0] is { ContainingSymbol: NamedTypeSymbol { IsExtension: true }, Name: var receiverName } && receiverName == name)
+ {
+ diagnostics.Add(ErrorCode.ERR_LocalSameNameAsExtensionParameter, GetLocation(p), name);
+ }
+ else
+ {
+ // The parameter name '{0}' is a duplicate
+ diagnostics.Add(ErrorCode.ERR_DuplicateParamName, GetLocation(p), name);
+ }
}
else if (!allowShadowingNames)
{
diff --git a/src/Compilers/CSharp/Portable/Binder/Binder_Patterns.cs b/src/Compilers/CSharp/Portable/Binder/Binder_Patterns.cs
index 860fbe3e56536..ce3304eef8da0 100644
--- a/src/Compilers/CSharp/Portable/Binder/Binder_Patterns.cs
+++ b/src/Compilers/CSharp/Portable/Binder/Binder_Patterns.cs
@@ -1058,7 +1058,7 @@ deconstructMethod is null &&
if (deconstructMethod is null)
hasErrors = true;
- int skippedExtensionParameters = deconstructMethod?.IsExtensionMethod == true ? 1 : 0;
+ int skippedExtensionParameters = deconstructMethod?.IsExtensionMethod == true ? 1 : 0; // Tracked by https://github.com/dotnet/roslyn/issues/76130: Test this code path with new extensions
for (int i = 0; i < node.Subpatterns.Count; i++)
{
var subPattern = node.Subpatterns[i];
diff --git a/src/Compilers/CSharp/Portable/Binder/Binder_Query.cs b/src/Compilers/CSharp/Portable/Binder/Binder_Query.cs
index 491a87033364c..d2cc0ca03080e 100644
--- a/src/Compilers/CSharp/Portable/Binder/Binder_Query.cs
+++ b/src/Compilers/CSharp/Portable/Binder/Binder_Query.cs
@@ -676,7 +676,7 @@ private void ReduceFrom(FromClauseSyntax from, QueryTranslationState state, Bind
private static BoundExpression? ExtractCastInvocation(BoundCall invocation)
{
- int index = invocation.InvokedAsExtensionMethod ? 1 : 0;
+ int index = invocation.InvokedAsExtensionMethod ? 1 : 0; // Tracked by https://github.com/dotnet/roslyn/issues/76130: Add test coverage for his code path
var c1 = invocation.Arguments[index] as BoundConversion;
var l1 = c1 != null ? c1.Operand as BoundLambda : null;
var r1 = l1 != null ? l1.Body.Statements[0] as BoundReturnStatement : null;
@@ -928,6 +928,8 @@ protected BoundCall MakeQueryInvocation(CSharpSyntaxNode node, BoundExpression r
Debug.Assert(receiver.Type is object || ultimateReceiver.Type is null);
if ((object?)ultimateReceiver.Type == null)
{
+ Debug.Assert(ultimateReceiver.Kind != BoundKind.MethodGroup || ultimateReceiver.HasAnyErrors);
+
if (ultimateReceiver.HasAnyErrors || node.HasErrors)
{
// report no additional errors
@@ -953,24 +955,6 @@ protected BoundCall MakeQueryInvocation(CSharpSyntaxNode node, BoundExpression r
// Could not find an implementation of the query pattern for source type '{0}'. '{1}' not found.
diagnostics.Add(ErrorCode.ERR_QueryNoProvider, node.Location, MessageID.IDS_AnonMethod.Localize(), methodName);
}
- else if (ultimateReceiver.Kind == BoundKind.MethodGroup)
- {
- var methodGroup = (BoundMethodGroup)ultimateReceiver;
- CompoundUseSiteInfo useSiteInfo = GetNewCompoundUseSiteInfo(diagnostics);
- var resolution = this.ResolveMethodGroup(methodGroup, analyzedArguments: null, useSiteInfo: ref useSiteInfo, options: OverloadResolution.Options.None);
- diagnostics.Add(node, useSiteInfo);
- diagnostics.AddRange(resolution.Diagnostics);
- if (resolution.HasAnyErrors)
- {
- receiver = this.BindMemberAccessBadResult(methodGroup);
- }
- else
- {
- Debug.Assert(!resolution.IsEmpty);
- diagnostics.Add(ErrorCode.ERR_QueryNoProvider, node.Location, MessageID.IDS_SK_METHOD.Localize(), methodName);
- }
- resolution.Free();
- }
receiver = new BoundBadExpression(receiver.Syntax, LookupResultKind.NotAValue, ImmutableArray.Empty, ImmutableArray.Create(receiver), CreateErrorType());
}
diff --git a/src/Compilers/CSharp/Portable/Binder/Binder_QueryErrors.cs b/src/Compilers/CSharp/Portable/Binder/Binder_QueryErrors.cs
index 9c61b375c3c41..f2b27b44c7a11 100644
--- a/src/Compilers/CSharp/Portable/Binder/Binder_QueryErrors.cs
+++ b/src/Compilers/CSharp/Portable/Binder/Binder_QueryErrors.cs
@@ -215,7 +215,7 @@ private static bool ReportQueryInferenceFailedSelectMany(FromClauseSyntax fromCl
Debug.Assert(methodName == "SelectMany");
// Estimate the return type of Select's lambda argument
- BoundExpression arg = arguments.Argument(arguments.IsExtensionMethodInvocation ? 1 : 0);
+ BoundExpression arg = arguments.Argument(arguments.IncludesReceiverAsArgument ? 1 : 0); // Tracked by https://github.com/dotnet/roslyn/issues/76130 : test this code path for new extensions
TypeSymbol type = null;
if (arg.Kind == BoundKind.UnboundLambda)
{
diff --git a/src/Compilers/CSharp/Portable/Binder/Binder_Statements.cs b/src/Compilers/CSharp/Portable/Binder/Binder_Statements.cs
index cb1dbf25bbba8..535959ca12a0a 100644
--- a/src/Compilers/CSharp/Portable/Binder/Binder_Statements.cs
+++ b/src/Compilers/CSharp/Portable/Binder/Binder_Statements.cs
@@ -766,7 +766,7 @@ internal MethodSymbol TryFindDisposePatternMethod(BoundExpression expr, SyntaxNo
out var disposeMethod,
out isExpanded);
- if (disposeMethod?.IsExtensionMethod == true)
+ if (disposeMethod is not null && (disposeMethod.IsExtensionMethod || disposeMethod.GetIsNewExtensionMember()))
{
// Extension methods should just be ignored, rather than rejected after-the-fact
// Tracked by https://github.com/dotnet/roslyn/issues/32767
@@ -1911,7 +1911,7 @@ private BoundBlock FinishBindBlockParts(CSharpSyntaxNode node, ImmutableArray.CastUp(GetDeclaredLocalFunctionsForScope(node)),
hasUnsafeModifier: node.Parent?.Kind() == SyntaxKind.UnsafeStatement,
instrumentation: null,
boundStatements);
@@ -3855,7 +3855,7 @@ internal virtual BoundExpressionStatement BindConstructorInitializer(Constructor
}
}
- if (containingType.IsStructType() || containingType.IsEnumType())
+ if (containingType.IsStructType() || containingType.IsEnumType() || containingType.IsExtension)
{
return null;
}
@@ -4153,7 +4153,9 @@ internal PatternLookupResult PerformPatternMethodLookup(BoundExpression receiver
bindingDiagnostics,
queryClause: null,
ignoreNormalFormIfHasValidParamsParameter: true,
- anyApplicableCandidates: out _);
+ anyApplicableCandidates: out _,
+ disallowExpandedNonArrayParams: false,
+ acceptOnlyMethods: true);
analyzedArguments.Free();
diff --git a/src/Compilers/CSharp/Portable/Binder/Binder_Symbols.cs b/src/Compilers/CSharp/Portable/Binder/Binder_Symbols.cs
index 0961c7d0493c1..4dfb348e9845a 100644
--- a/src/Compilers/CSharp/Portable/Binder/Binder_Symbols.cs
+++ b/src/Compilers/CSharp/Portable/Binder/Binder_Symbols.cs
@@ -338,16 +338,24 @@ internal NamespaceOrTypeOrAliasSymbolWithAnnotations BindTypeOrAlias(ExpressionS
}
var diagnosticInfo = diagnostics.Add(ErrorCode.ERR_BadSKknown, syntax.Location, syntax, symbol.Symbol.GetKindText(), MessageID.IDS_SK_TYPE.Localize());
- return TypeWithAnnotations.Create(new ExtendedErrorTypeSymbol(GetContainingNamespaceOrType(symbol.Symbol), symbol.Symbol, LookupResultKind.NotATypeOrNamespace, diagnosticInfo));
+ return TypeWithAnnotations.Create(new ExtendedErrorTypeSymbol(GetContainingNamespaceOrNonExtensionType(symbol.Symbol), symbol.Symbol, LookupResultKind.NotATypeOrNamespace, diagnosticInfo));
}
///
/// The immediately containing namespace or named type, or the global
/// namespace if containing symbol is neither a namespace or named type.
+ /// We don't want to use an extension declaration as the containing type
+ /// for error type symbols, as that causes cycles during symbol display.
///
- private NamespaceOrTypeSymbol GetContainingNamespaceOrType(Symbol symbol)
+ private NamespaceOrTypeSymbol GetContainingNamespaceOrNonExtensionType(Symbol symbol)
{
- return symbol.ContainingNamespaceOrType() ?? this.Compilation.Assembly.GlobalNamespace;
+ if (symbol.ContainingNamespaceOrType() is { } containing
+ && containing is not TypeSymbol { IsExtension: true })
+ {
+ return containing;
+ }
+
+ return this.Compilation.Assembly.GlobalNamespace;
}
internal Symbol BindNamespaceAliasSymbol(IdentifierNameSyntax node, BindingDiagnosticBag diagnostics)
@@ -1305,7 +1313,7 @@ private NamedTypeSymbol LookupGenericTypeName(
// for us.
Debug.Assert(lookupResult.Error != null);
type = new ExtendedErrorTypeSymbol(
- GetContainingNamespaceOrType(lookupResultSymbol),
+ GetContainingNamespaceOrNonExtensionType(lookupResultSymbol),
ImmutableArray.Create(lookupResultSymbol),
lookupResult.Kind,
lookupResult.Error,
@@ -1436,7 +1444,7 @@ private BoundMethodOrPropertyGroup ConstructBoundMemberGroupAndReportOmittedType
BoundExpression colorColorValueReceiver = GetValueExpressionIfTypeOrValueReceiver(receiver);
- Debug.Assert(colorColorValueReceiver is null || (methodGroupFlags & BoundMethodGroupFlags.SearchExtensionMethods) != 0);
+ Debug.Assert(colorColorValueReceiver is null || (methodGroupFlags & BoundMethodGroupFlags.SearchExtensions) != 0);
if (IsPossiblyCapturingPrimaryConstructorParameterReference(colorColorValueReceiver, out ParameterSymbol parameter))
{
@@ -1534,10 +1542,10 @@ private void CheckWhatCandidatesWeHave(
if (!haveInstanceCandidates && members[0].Kind == SymbolKind.Method)
{
// See if there could be extension methods in scope
- foreach (var scope in new ExtensionMethodScopes(this))
+ foreach (var scope in new ExtensionScopes(this))
{
lookupResult ??= LookupResult.GetInstance();
- LookupExtensionMethods(lookupResult, scope, plainName, arity, ref useSiteInfo);
+ LookupExtensionMethods(lookupResult, scope, plainName, arity, ref useSiteInfo); // Tracked by https://github.com/dotnet/roslyn/issues/76130 : account for new extension members
if (lookupResult.IsMultiViable)
{
@@ -2234,7 +2242,7 @@ Symbol resultSymbol(
}
return new ExtendedErrorTypeSymbol(
- GetContainingNamespaceOrType(originalSymbols[0]),
+ GetContainingNamespaceOrNonExtensionType(originalSymbols[0]),
originalSymbols,
LookupResultKind.Ambiguous,
info,
@@ -2252,7 +2260,7 @@ Symbol resultSymbol(
wasError = true;
var errorInfo = new CSDiagnosticInfo(ErrorCode.ERR_SystemVoid);
diagnostics.Add(errorInfo, where.Location);
- singleResult = new ExtendedErrorTypeSymbol(GetContainingNamespaceOrType(singleResult), singleResult, LookupResultKind.NotReferencable, errorInfo); // UNDONE: Review resultkind.
+ singleResult = new ExtendedErrorTypeSymbol(GetContainingNamespaceOrNonExtensionType(singleResult), singleResult, LookupResultKind.NotReferencable, errorInfo); // UNDONE: Review resultkind.
}
// Check for bad symbol.
else
@@ -2285,7 +2293,7 @@ Symbol resultSymbol(
{
wasError = true;
diagnostics.Add(errorInfo, where.Location);
- singleResult = new ExtendedErrorTypeSymbol(GetContainingNamespaceOrType(errorType), errorType.Name, errorType.Arity, errorInfo, unreported: false);
+ singleResult = new ExtendedErrorTypeSymbol(GetContainingNamespaceOrNonExtensionType(errorType), errorType.Name, errorType.Arity, errorInfo, unreported: false);
}
}
}
@@ -2341,7 +2349,7 @@ Symbol resultSymbol(
// Bad type or namespace (or things expected as types/namespaces) are packaged up as error types, preserving the symbols and the result kind.
// We do this if there are multiple symbols too, because just returning one would be losing important information, and they might
// be of different kinds.
- return new ExtendedErrorTypeSymbol(GetContainingNamespaceOrType(symbols[0]), symbols.ToImmutable(), result.Kind, result.Error, arity);
+ return new ExtendedErrorTypeSymbol(GetContainingNamespaceOrNonExtensionType(symbols[0]), symbols.ToImmutable(), result.Kind, result.Error, arity);
}
else
{
diff --git a/src/Compilers/CSharp/Portable/Binder/ExtensionMethodScope.cs b/src/Compilers/CSharp/Portable/Binder/ExtensionScope.cs
similarity index 60%
rename from src/Compilers/CSharp/Portable/Binder/ExtensionMethodScope.cs
rename to src/Compilers/CSharp/Portable/Binder/ExtensionScope.cs
index 68057cd4b0406..8fa6adb3db599 100644
--- a/src/Compilers/CSharp/Portable/Binder/ExtensionMethodScope.cs
+++ b/src/Compilers/CSharp/Portable/Binder/ExtensionScope.cs
@@ -7,54 +7,54 @@
namespace Microsoft.CodeAnalysis.CSharp
{
///
- /// A distinct scope that may expose extension methods. For a particular Binder, there
+ /// A distinct scope that may expose extensions. For a particular Binder, there
/// are two possible scopes: one for the namespace, and another for any using statements
/// in the namespace. The namespace scope is searched before the using scope.
///
- internal readonly struct ExtensionMethodScope
+ internal readonly struct ExtensionScope
{
public readonly Binder Binder;
- public ExtensionMethodScope(Binder binder)
+ public ExtensionScope(Binder binder)
{
this.Binder = binder;
}
}
///
- /// An enumerable collection of extension method scopes in search
+ /// An enumerable collection of extension scopes in search
/// order, from the given Binder, out through containing Binders.
///
- internal readonly struct ExtensionMethodScopes
+ internal readonly struct ExtensionScopes
{
private readonly Binder _binder;
- public ExtensionMethodScopes(Binder binder)
+ public ExtensionScopes(Binder binder)
{
_binder = binder;
}
- public ExtensionMethodScopeEnumerator GetEnumerator()
+ public ExtensionScopeEnumerator GetEnumerator()
{
- return new ExtensionMethodScopeEnumerator(_binder);
+ return new ExtensionScopeEnumerator(_binder);
}
}
///
- /// An enumerator over ExtensionMethodScopes.
+ /// An enumerator over ExtensionScopes.
///
- internal struct ExtensionMethodScopeEnumerator
+ internal struct ExtensionScopeEnumerator
{
private readonly Binder _binder;
- private ExtensionMethodScope _current;
+ private ExtensionScope _current;
- public ExtensionMethodScopeEnumerator(Binder binder)
+ public ExtensionScopeEnumerator(Binder binder)
{
_binder = binder;
- _current = new ExtensionMethodScope();
+ _current = new ExtensionScope();
}
- public ExtensionMethodScope Current
+ public ExtensionScope Current
{
get { return _current; }
}
@@ -68,24 +68,24 @@ public bool MoveNext()
else
{
var binder = _current.Binder;
- // Return a scope for the next Binder that supports extension methods.
+ // Return a scope for the next Binder that supports extensions.
_current = GetNextScope(binder.Next);
}
return (_current.Binder != null);
}
- private static ExtensionMethodScope GetNextScope(Binder binder)
+ private static ExtensionScope GetNextScope(Binder binder)
{
for (var scope = binder; scope != null; scope = scope.Next)
{
- if (scope.SupportsExtensionMethods)
+ if (scope.SupportsExtensions)
{
- return new ExtensionMethodScope(scope);
+ return new ExtensionScope(scope);
}
}
- return new ExtensionMethodScope();
+ return new ExtensionScope();
}
}
}
diff --git a/src/Compilers/CSharp/Portable/Binder/ForEachLoopBinder.cs b/src/Compilers/CSharp/Portable/Binder/ForEachLoopBinder.cs
index 368065f181463..aa73b0ff7ec40 100644
--- a/src/Compilers/CSharp/Portable/Binder/ForEachLoopBinder.cs
+++ b/src/Compilers/CSharp/Portable/Binder/ForEachLoopBinder.cs
@@ -236,12 +236,20 @@ private BoundForEachStatement BindForEachPartsWorker(BindingDiagnosticBag diagno
{
originalBinder.CheckImplicitThisCopyInReadOnlyMember(collectionExpr, getEnumeratorMethod, diagnostics);
- if (getEnumeratorMethod.IsExtensionMethod && !hasErrors)
+ if (!hasErrors)
{
- var messageId = IsAsync ? MessageID.IDS_FeatureExtensionGetAsyncEnumerator : MessageID.IDS_FeatureExtensionGetEnumerator;
- messageId.CheckFeatureAvailability(diagnostics, Compilation, collectionExpr.Syntax.Location);
+ if (getEnumeratorMethod.IsExtensionMethod)
+ {
+ var messageId = IsAsync ? MessageID.IDS_FeatureExtensionGetAsyncEnumerator : MessageID.IDS_FeatureExtensionGetEnumerator;
+ messageId.CheckFeatureAvailability(diagnostics, Compilation, collectionExpr.Syntax.Location);
- if (getEnumeratorMethod.ParameterRefKinds is { IsDefault: false } refKinds && refKinds[0] == RefKind.Ref)
+ if (getEnumeratorMethod.ParameterRefKinds is { IsDefault: false } refKinds && refKinds[0] == RefKind.Ref)
+ {
+ Error(diagnostics, ErrorCode.ERR_RefLvalueExpected, collectionExpr.Syntax);
+ hasErrors = true;
+ }
+ }
+ else if (getEnumeratorMethod.GetIsNewExtensionMember() && getEnumeratorMethod.ContainingType.ExtensionParameter.RefKind == RefKind.Ref) // Tracked by https://github.com/dotnet/roslyn/issues/76130: add test coverage for 'ref readonly' and 'in'
{
Error(diagnostics, ErrorCode.ERR_RefLvalueExpected, collectionExpr.Syntax);
hasErrors = true;
@@ -570,7 +578,8 @@ private BoundForEachStatement BindForEachPartsWorker(BindingDiagnosticBag diagno
(collectionConversionClassification.IsImplicit &&
(IsIEnumerable(builder.CollectionType) ||
IsIEnumerableT(builder.CollectionType.OriginalDefinition, IsAsync, Compilation) ||
- builder.GetEnumeratorInfo.Method.IsExtensionMethod)) ||
+ builder.GetEnumeratorInfo.Method.IsExtensionMethod ||
+ builder.GetEnumeratorInfo.Method.GetIsNewExtensionMember())) ||
// For compat behavior, we can enumerate over System.String even if it's not IEnumerable. That will
// result in an explicit reference conversion in the bound nodes, but that conversion won't be emitted.
(collectionConversionClassification.Kind == ConversionKind.ExplicitReference && collectionExpr.Type.SpecialType == SpecialType.System_String));
@@ -861,9 +870,9 @@ private EnumeratorResult GetEnumeratorInfoCore(SyntaxNode syntax, SyntaxNode col
#if DEBUG
Debug.Assert(span == originalSpan);
- Debug.Assert(!builder.ViaExtensionMethod || builder.GetEnumeratorInfo.Method.IsExtensionMethod);
+ Debug.Assert(!builder.ViaExtensionMethod || builder.GetEnumeratorInfo.Method.IsExtensionMethod || builder.GetEnumeratorInfo.Method.GetIsNewExtensionMember());
#endif
- if (!builder.ViaExtensionMethod &&
+ if (!builder.ViaExtensionMethod && // Tracked by https://github.com/dotnet/roslyn/issues/76130: Add test coverage for new extensions
((result is EnumeratorResult.Succeeded && builder.ElementTypeWithAnnotations.Equals(elementField.TypeWithAnnotations, TypeCompareKind.AllIgnoreOptions) &&
builder.CurrentPropertyGetter?.RefKind == (wellKnownSpan == WellKnownType.System_ReadOnlySpan_T ? RefKind.RefReadOnly : RefKind.Ref)) ||
result is EnumeratorResult.FailedAndReported))
@@ -908,7 +917,7 @@ private EnumeratorResult GetEnumeratorInfoCore(SyntaxNode syntax, SyntaxNode col
#if DEBUG
Debug.Assert(collectionExpr == originalCollectionExpr ||
(originalCollectionExpr.Type?.IsNullableType() == true && originalCollectionExpr.Type.StrippedType().Equals(collectionExpr.Type, TypeCompareKind.AllIgnoreOptions)));
- Debug.Assert(!builder.ViaExtensionMethod || builder.GetEnumeratorInfo.Method.IsExtensionMethod);
+ Debug.Assert(!builder.ViaExtensionMethod || builder.GetEnumeratorInfo.Method.IsExtensionMethod || builder.GetEnumeratorInfo.Method.GetIsNewExtensionMember());
#endif
return result;
@@ -1019,12 +1028,26 @@ EnumeratorResult createPatternBasedEnumeratorResult(ref ForEachEnumeratorInfo.Bu
{
Debug.Assert((object)builder.GetEnumeratorInfo != null);
- Debug.Assert(!(viaExtensionMethod && builder.GetEnumeratorInfo.Method.Parameters.IsDefaultOrEmpty));
+ Debug.Assert(!(viaExtensionMethod && builder.GetEnumeratorInfo.Method.IsExtensionMethod && builder.GetEnumeratorInfo.Method.Parameters.IsDefaultOrEmpty));
+ Debug.Assert(!(viaExtensionMethod && !builder.GetEnumeratorInfo.Method.IsExtensionMethod && !builder.GetEnumeratorInfo.Method.GetIsNewExtensionMember()));
builder.ViaExtensionMethod = viaExtensionMethod;
- builder.CollectionType = viaExtensionMethod
- ? builder.GetEnumeratorInfo.Method.Parameters[0].Type
- : collectionExpr.Type;
+
+ if (viaExtensionMethod)
+ {
+ if (builder.GetEnumeratorInfo.Method.IsExtensionMethod)
+ {
+ builder.CollectionType = builder.GetEnumeratorInfo.Method.Parameters[0].Type;
+ }
+ else
+ {
+ builder.CollectionType = builder.GetEnumeratorInfo.Method.ContainingType.ExtensionParameter.Type;
+ }
+ }
+ else
+ {
+ builder.CollectionType = collectionExpr.Type;
+ }
if (SatisfiesForEachPattern(syntax, collectionSyntax, ref builder, isAsync, diagnostics))
{
@@ -1200,7 +1223,7 @@ private void GetDisposalInfoForEnumerator(SyntaxNode syntax, ref ForEachEnumerat
MethodSymbol patternDisposeMethod = TryFindDisposePatternMethod(receiver, syntax, isAsync, patternDiagnostics, out bool expanded);
if (patternDisposeMethod is object)
{
- Debug.Assert(!patternDisposeMethod.IsExtensionMethod);
+ Debug.Assert(!patternDisposeMethod.IsExtensionMethod && !patternDisposeMethod.GetIsNewExtensionMember());
Debug.Assert(patternDisposeMethod.ParameterRefKinds.IsDefaultOrEmpty ||
patternDisposeMethod.ParameterRefKinds.All(static refKind => refKind is RefKind.None or RefKind.In or RefKind.RefReadOnlyParameter));
@@ -1500,7 +1523,9 @@ private MethodArgumentInfo FindForEachPatternMethodViaExtension(SyntaxNode synta
{
var analyzedArguments = AnalyzedArguments.GetInstance();
- var methodGroupResolutionResult = this.BindExtensionMethod(
+ CompoundUseSiteInfo extensionUseSiteInfo = this.GetNewCompoundUseSiteInfo(diagnostics);
+
+ var methodGroupResolutionResult = this.ResolveExtension(
collectionSyntax,
methodName,
analyzedArguments,
@@ -1509,8 +1534,10 @@ private MethodArgumentInfo FindForEachPatternMethodViaExtension(SyntaxNode synta
options: OverloadResolution.Options.None,
returnRefKind: default,
returnType: null,
- withDependencies: diagnostics.AccumulatesDependencies);
+ ref extensionUseSiteInfo,
+ acceptOnlyMethods: true); // Tracked by https://github.com/dotnet/roslyn/issues/76130 : Test effect of acceptOnlyMethods value
+ diagnostics.Add(syntax, extensionUseSiteInfo);
diagnostics.AddRange(methodGroupResolutionResult.Diagnostics);
var overloadResolutionResult = methodGroupResolutionResult.OverloadResolutionResult;
@@ -1518,6 +1545,8 @@ private MethodArgumentInfo FindForEachPatternMethodViaExtension(SyntaxNode synta
{
var result = overloadResolutionResult.ValidResult.Member;
+ Debug.Assert(result.IsExtensionMethod || result.GetIsNewExtensionMember());
+
if (result.CallsAreOmitted(syntax.SyntaxTree))
{
// Calls to this method are omitted in the current syntax tree, i.e it is either a partial method with no implementation part OR a conditional method whose condition is not true in this source file.
@@ -1527,28 +1556,44 @@ private MethodArgumentInfo FindForEachPatternMethodViaExtension(SyntaxNode synta
return null;
}
- CompoundUseSiteInfo useSiteInfo = GetNewCompoundUseSiteInfo(diagnostics);
- var collectionConversion = this.Conversions.ClassifyConversionFromExpression(collectionExpr, result.Parameters[0].Type, isChecked: CheckOverflowAtRuntime, ref useSiteInfo);
- diagnostics.Add(syntax, useSiteInfo);
+ MethodArgumentInfo info;
+ bool expanded = overloadResolutionResult.ValidResult.Result.Kind == MemberResolutionKind.ApplicableInExpandedForm;
- // Unconditionally convert here, to match what we set the ConvertedExpression to in the main BoundForEachStatement node.
- Debug.Assert(!collectionConversion.IsUserDefined);
- collectionExpr = new BoundConversion(
- collectionExpr.Syntax,
- collectionExpr,
- collectionConversion,
- @checked: CheckOverflowAtRuntime,
- explicitCastInCode: false,
- conversionGroupOpt: null,
- ConstantValue.NotAvailable,
- result.Parameters[0].Type);
+ if (result.IsExtensionMethod)
+ {
+ CompoundUseSiteInfo useSiteInfo = GetNewCompoundUseSiteInfo(diagnostics);
+ var collectionConversion = this.Conversions.ClassifyConversionFromExpression(collectionExpr, result.Parameters[0].Type, isChecked: CheckOverflowAtRuntime, ref useSiteInfo);
+ diagnostics.Add(syntax, useSiteInfo);
+
+ // Unconditionally convert here, to match what we set the ConvertedExpression to in the main BoundForEachStatement node.
+ Debug.Assert(!collectionConversion.IsUserDefined);
+ collectionExpr = new BoundConversion(
+ collectionExpr.Syntax,
+ collectionExpr,
+ collectionConversion,
+ @checked: CheckOverflowAtRuntime,
+ explicitCastInCode: false,
+ conversionGroupOpt: null,
+ ConstantValue.NotAvailable,
+ result.Parameters[0].Type);
+
+ info = BindDefaultArguments(
+ result,
+ collectionExpr,
+ expanded: expanded,
+ collectionExpr.Syntax,
+ diagnostics);
+ }
+ else
+ {
+ info = BindDefaultArguments(
+ result,
+ extensionReceiverOpt: null,
+ expanded: expanded,
+ collectionExpr.Syntax,
+ diagnostics);
+ }
- var info = BindDefaultArguments(
- result,
- collectionExpr,
- expanded: overloadResolutionResult.ValidResult.Result.Kind == MemberResolutionKind.ApplicableInExpandedForm,
- collectionExpr.Syntax,
- diagnostics);
methodGroupResolutionResult.Free();
analyzedArguments.Free();
return info;
diff --git a/src/Compilers/CSharp/Portable/Binder/InContainerBinder.cs b/src/Compilers/CSharp/Portable/Binder/InContainerBinder.cs
index d5f45168cd481..6e23054365498 100644
--- a/src/Compilers/CSharp/Portable/Binder/InContainerBinder.cs
+++ b/src/Compilers/CSharp/Portable/Binder/InContainerBinder.cs
@@ -67,7 +67,7 @@ internal override bool IsAccessibleHelper(Symbol symbol, TypeSymbol accessThroug
}
}
- internal override bool SupportsExtensionMethods
+ internal override bool SupportsExtensions
{
get { return true; }
}
@@ -85,6 +85,14 @@ internal override void GetCandidateExtensionMethods(
}
}
+ internal override void GetExtensionDeclarations(ArrayBuilder extensions, Binder originalBinder)
+ {
+ if (_container is NamespaceSymbol ns)
+ {
+ ns.GetExtensionContainers(extensions);
+ }
+ }
+
internal override TypeWithAnnotations GetIteratorElementType()
{
if (IsScriptClass)
diff --git a/src/Compilers/CSharp/Portable/Binder/InMethodBinder.cs b/src/Compilers/CSharp/Portable/Binder/InMethodBinder.cs
index c2e47a7daeadd..b835e700c620f 100644
--- a/src/Compilers/CSharp/Portable/Binder/InMethodBinder.cs
+++ b/src/Compilers/CSharp/Portable/Binder/InMethodBinder.cs
@@ -292,8 +292,16 @@ private static bool ReportConflictWithParameter(Symbol parameter, Symbol newSymb
{
case SymbolKind.Parameter:
case SymbolKind.Local:
- // CS0412: '{0}': a parameter, local variable, or local function cannot have the same name as a method type parameter
- diagnostics.Add(ErrorCode.ERR_LocalSameNameAsTypeParam, newLocation, name);
+ if (parameter.ContainingSymbol is NamedTypeSymbol { IsExtension: true })
+ {
+ diagnostics.Add(ErrorCode.ERR_LocalSameNameAsExtensionTypeParameter, newLocation, name);
+ }
+ else
+ {
+ // CS0412: '{0}': a parameter, local variable, or local function cannot have the same name as a method type parameter
+ diagnostics.Add(ErrorCode.ERR_LocalSameNameAsTypeParam, newLocation, name);
+ }
+
return true;
case SymbolKind.Method:
@@ -324,6 +332,16 @@ internal override bool EnsureSingleDefinition(Symbol symbol, string name, Locati
var parameters = _methodSymbol.Parameters;
var typeParameters = _methodSymbol.TypeParameters;
+ if (_methodSymbol.GetIsNewExtensionMember())
+ {
+ typeParameters = _methodSymbol.ContainingType.TypeParameters.Concat(typeParameters);
+
+ if (_methodSymbol.ContainingType.ExtensionParameter is { Name: not "" } receiver)
+ {
+ parameters = parameters.Insert(0, receiver);
+ }
+ }
+
if (parameters.IsEmpty && typeParameters.IsEmpty)
{
return false;
diff --git a/src/Compilers/CSharp/Portable/Binder/LookupOptions.cs b/src/Compilers/CSharp/Portable/Binder/LookupOptions.cs
index e85082a4068e2..1334d27dd953d 100644
--- a/src/Compilers/CSharp/Portable/Binder/LookupOptions.cs
+++ b/src/Compilers/CSharp/Portable/Binder/LookupOptions.cs
@@ -75,9 +75,9 @@ internal enum LookupOptions
UseBaseReferenceAccessibility = 1 << 9,
///
- /// Include extension methods.
+ /// Include extension members.
///
- IncludeExtensionMethods = 1 << 10,
+ IncludeExtensionMembers = 1 << 10,
///
/// Consider only attribute types.
diff --git a/src/Compilers/CSharp/Portable/Binder/MethodGroupResolution.cs b/src/Compilers/CSharp/Portable/Binder/MethodGroupResolution.cs
index de0be66599870..4735b08633d50 100644
--- a/src/Compilers/CSharp/Portable/Binder/MethodGroupResolution.cs
+++ b/src/Compilers/CSharp/Portable/Binder/MethodGroupResolution.cs
@@ -6,6 +6,7 @@
using System.Collections.Immutable;
using System.Diagnostics;
+using System.Diagnostics.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp.Symbols;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.Text;
@@ -42,6 +43,7 @@ public MethodGroupResolution(
LookupResultKind resultKind,
ReadOnlyBindingDiagnostic diagnostics)
{
+ Debug.Assert((methodGroup != null) || ((object)otherSymbol != null) || analyzedArguments == null); // analyzedArguments is only set if we have some result
Debug.Assert((methodGroup == null) || (methodGroup.Methods.Count > 0));
Debug.Assert((methodGroup == null) || ((object)otherSymbol == null));
// Methods should be represented in the method group.
@@ -83,13 +85,31 @@ public bool IsExtensionMethodGroup
get { return (this.MethodGroup != null) && this.MethodGroup.IsExtensionMethodGroup; }
}
+#nullable enable
+ ///
+ /// Indicates that we have a viable result that is a non-method extension member.
+ ///
+ public bool IsNonMethodExtensionMember([NotNullWhen(true)] out Symbol? extensionMember)
+ {
+ bool isExtensionMember = ResultKind == LookupResultKind.Viable && MethodGroup is null;
+ extensionMember = isExtensionMember ? OtherSymbol : null;
+ Debug.Assert((extensionMember is not null) || !isExtensionMember);
+
+ return isExtensionMember;
+ }
+#nullable disable
+
public bool IsLocalFunctionInvocation =>
MethodGroup?.Methods.Count == 1 && // Local functions cannot be overloaded
MethodGroup.Methods[0].MethodKind == MethodKind.LocalFunction;
- public void Free()
+ public void Free(bool keepArguments = false)
{
- this.AnalyzedArguments?.Free();
+ if (!keepArguments)
+ {
+ this.AnalyzedArguments?.Free();
+ }
+
this.MethodGroup?.Free();
this.OverloadResolutionResult?.Free();
}
diff --git a/src/Compilers/CSharp/Portable/Binder/RefSafetyAnalysis.cs b/src/Compilers/CSharp/Portable/Binder/RefSafetyAnalysis.cs
index 18f4e327cb9ea..e43b21e2619a0 100644
--- a/src/Compilers/CSharp/Portable/Binder/RefSafetyAnalysis.cs
+++ b/src/Compilers/CSharp/Portable/Binder/RefSafetyAnalysis.cs
@@ -308,7 +308,7 @@ private void AssertVisited(BoundExpression expr)
public override BoundNode? VisitLocalFunctionStatement(BoundLocalFunctionStatement node)
{
- var localFunction = node.Symbol;
+ var localFunction = (LocalFunctionSymbol)node.Symbol;
var analysis = new RefSafetyAnalysis(_compilation, localFunction, _inUnsafeRegion || localFunction.IsUnsafe, _useUpdatedEscapeRules, _diagnostics);
analysis.Visit(node.BlockBody);
analysis.Visit(node.ExpressionBody);
@@ -604,7 +604,7 @@ static SafeContext getDeclarationValEscape(BoundTypeExpression typeExpression, S
static ParameterSymbol? tryGetThisParameter(MethodSymbol method)
{
- if (method.IsExtensionMethod)
+ if (method.IsExtensionMethod) // Tracked by https://github.com/dotnet/roslyn/issues/76130: Test this code path with new extensions
{
return method.Parameters is [{ } firstParameter, ..] ? firstParameter : null;
}
diff --git a/src/Compilers/CSharp/Portable/Binder/Semantics/AccessCheck.cs b/src/Compilers/CSharp/Portable/Binder/Semantics/AccessCheck.cs
index 2715fc9adefe4..1aaa9522d014d 100644
--- a/src/Compilers/CSharp/Portable/Binder/Semantics/AccessCheck.cs
+++ b/src/Compilers/CSharp/Portable/Binder/Semantics/AccessCheck.cs
@@ -327,8 +327,9 @@ private static bool IsMemberAccessible(
return true;
}
+ // For the purpose of accessibility checks, extension members are considered to be declared within the enclosing static type
return IsNonPublicMemberAccessible(
- containingType,
+ containingType.IsExtension && containingType.ContainingType is { } extensionEnclosingType ? extensionEnclosingType : containingType,
declaredAccessibility,
within,
throughTypeOpt,
diff --git a/src/Compilers/CSharp/Portable/Binder/Semantics/Conversions/Conversions.cs b/src/Compilers/CSharp/Portable/Binder/Semantics/Conversions/Conversions.cs
index abb608ffe3b20..54b21617e4c99 100644
--- a/src/Compilers/CSharp/Portable/Binder/Semantics/Conversions/Conversions.cs
+++ b/src/Compilers/CSharp/Portable/Binder/Semantics/Conversions/Conversions.cs
@@ -102,6 +102,8 @@ public override Conversion GetMethodGroupDelegateConversion(BoundMethodGroup sou
}
var resolution = ResolveDelegateOrFunctionPointerMethodGroup(_binder, source, methodSymbol, isFunctionPointer, callingConventionInfo, ref useSiteInfo);
+ Debug.Assert(!resolution.IsNonMethodExtensionMember(out _));
+
var conversion = (resolution.IsEmpty || resolution.HasAnyErrors) ?
Conversion.NoConversion :
ToConversion(resolution.OverloadResolutionResult, resolution.MethodGroup, methodSymbol.ParameterCount);
@@ -248,22 +250,25 @@ internal Conversion GetCollectionExpressionSpreadElementConversion(
///
private static MethodGroupResolution ResolveDelegateOrFunctionPointerMethodGroup(Binder binder, BoundMethodGroup source, MethodSymbol delegateInvokeMethodOpt, bool isFunctionPointer, in CallingConventionInfo callingConventionInfo, ref CompoundUseSiteInfo useSiteInfo)
{
+ MethodGroupResolution resolution;
if ((object)delegateInvokeMethodOpt != null)
{
var analyzedArguments = AnalyzedArguments.GetInstance();
GetDelegateOrFunctionPointerArguments(source.Syntax, analyzedArguments, delegateInvokeMethodOpt.Parameters, binder.Compilation);
- var resolution = binder.ResolveMethodGroup(source, analyzedArguments, useSiteInfo: ref useSiteInfo,
+ resolution = binder.ResolveMethodGroup(source, analyzedArguments, useSiteInfo: ref useSiteInfo,
options: OverloadResolution.Options.InferWithDynamic | OverloadResolution.Options.IsMethodGroupConversion |
(isFunctionPointer ? OverloadResolution.Options.IsFunctionPointerResolution : OverloadResolution.Options.None),
returnRefKind: delegateInvokeMethodOpt.RefKind, returnType: delegateInvokeMethodOpt.ReturnType,
callingConventionInfo: callingConventionInfo);
analyzedArguments.Free();
- return resolution;
}
else
{
- return binder.ResolveMethodGroup(source, analyzedArguments: null, ref useSiteInfo, options: OverloadResolution.Options.IsMethodGroupConversion);
+ resolution = binder.ResolveMethodGroup(source, analyzedArguments: null, ref useSiteInfo, options: OverloadResolution.Options.IsMethodGroupConversion);
}
+
+ Debug.Assert(!resolution.IsNonMethodExtensionMember(out _));
+ return resolution;
}
///
@@ -325,10 +330,24 @@ public static bool ReportDelegateOrFunctionPointerMethodGroupDiagnostics(Binder
Debug.Assert((object)method != null);
if (resolution.MethodGroup.IsExtensionMethodGroup)
{
- Debug.Assert(method.IsExtensionMethod);
+ Debug.Assert(method.IsExtensionMethod || method.GetIsNewExtensionMember());
+
+ ParameterSymbol thisParameter;
+
+ if (method.IsExtensionMethod)
+ {
+ thisParameter = method.Parameters[0];
+ }
+ else if (method.IsStatic)
+ {
+ thisParameter = null;
+ }
+ else
+ {
+ thisParameter = method.ContainingType.ExtensionParameter;
+ }
- var thisParameter = method.Parameters[0];
- if (!thisParameter.Type.IsReferenceType)
+ if (thisParameter?.Type.IsReferenceType == false)
{
// Extension method '{0}' defined on value type '{1}' cannot be used to create delegates
diagnostics.Add(
@@ -449,9 +468,12 @@ private static Conversion ToConversion(OverloadResolutionResult re
MethodSymbol method = result.BestResult.Member;
- if (methodGroup.IsExtensionMethodGroup && !method.Parameters[0].Type.IsReferenceType)
+ if (methodGroup.IsExtensionMethodGroup)
{
- return Conversion.NoConversion;
+ if (!(method.GetIsNewExtensionMember() && method.IsStatic) && !Binder.GetReceiverParameter(method).Type.IsReferenceType)
+ {
+ return Conversion.NoConversion;
+ }
}
//cannot capture stack-only types.
@@ -476,9 +498,10 @@ private static Conversion ToConversion(OverloadResolutionResult re
// NOTE: Delegate type compatibility is important, but is not part of the existence check.
- Debug.Assert(method.ParameterCount == parameterCount + (methodGroup.IsExtensionMethodGroup ? 1 : 0));
+ bool isExtensionMethod = methodGroup.IsExtensionMethodGroup && !method.GetIsNewExtensionMember();
+ Debug.Assert(method.ParameterCount == parameterCount + (isExtensionMethod ? 1 : 0));
- return new Conversion(ConversionKind.MethodGroup, method, methodGroup.IsExtensionMethodGroup);
+ return new Conversion(ConversionKind.MethodGroup, method, isExtensionMethod: isExtensionMethod);
}
public override Conversion GetStackAllocConversion(BoundStackAllocArrayCreation sourceExpression, TypeSymbol destination, ref CompoundUseSiteInfo useSiteInfo)
diff --git a/src/Compilers/CSharp/Portable/Binder/Semantics/OverloadResolution/AnalyzedArguments.cs b/src/Compilers/CSharp/Portable/Binder/Semantics/OverloadResolution/AnalyzedArguments.cs
index 84cfad7da7317..14d5796dfbdfb 100644
--- a/src/Compilers/CSharp/Portable/Binder/Semantics/OverloadResolution/AnalyzedArguments.cs
+++ b/src/Compilers/CSharp/Portable/Binder/Semantics/OverloadResolution/AnalyzedArguments.cs
@@ -15,7 +15,7 @@ internal sealed class AnalyzedArguments
public readonly ArrayBuilder Arguments;
public readonly ArrayBuilder<(string Name, Location Location)?> Names;
public readonly ArrayBuilder RefKinds;
- public bool IsExtensionMethodInvocation;
+ public bool IncludesReceiverAsArgument;
private ThreeState _lazyHasDynamicArgument;
internal AnalyzedArguments()
@@ -30,7 +30,7 @@ public void Clear()
this.Arguments.Clear();
this.Names.Clear();
this.RefKinds.Clear();
- this.IsExtensionMethodInvocation = false;
+ this.IncludesReceiverAsArgument = false;
_lazyHasDynamicArgument = ThreeState.Unknown;
}
@@ -78,9 +78,9 @@ public RefKind RefKind(int i)
return RefKinds.Count > 0 ? RefKinds[i] : Microsoft.CodeAnalysis.RefKind.None;
}
- public bool IsExtensionMethodThisArgument(int i)
+ public bool IsExtensionMethodReceiverArgument(int i)
{
- return (i == 0) && this.IsExtensionMethodInvocation;
+ return (i == 0) && this.IncludesReceiverAsArgument;
}
public bool HasDynamicArgument
@@ -139,7 +139,7 @@ public static AnalyzedArguments GetInstance(AnalyzedArguments original)
instance.Arguments.AddRange(original.Arguments);
instance.Names.AddRange(original.Names);
instance.RefKinds.AddRange(original.RefKinds);
- instance.IsExtensionMethodInvocation = original.IsExtensionMethodInvocation;
+ instance.IncludesReceiverAsArgument = original.IncludesReceiverAsArgument;
instance._lazyHasDynamicArgument = original._lazyHasDynamicArgument;
return instance;
}
diff --git a/src/Compilers/CSharp/Portable/Binder/Semantics/OverloadResolution/MemberAnalysisResult.cs b/src/Compilers/CSharp/Portable/Binder/Semantics/OverloadResolution/MemberAnalysisResult.cs
index d60aa1ae31254..3ee43e4999231 100644
--- a/src/Compilers/CSharp/Portable/Binder/Semantics/OverloadResolution/MemberAnalysisResult.cs
+++ b/src/Compilers/CSharp/Portable/Binder/Semantics/OverloadResolution/MemberAnalysisResult.cs
@@ -4,11 +4,13 @@
#nullable disable
+using System;
using System.Collections.Immutable;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using Microsoft.CodeAnalysis.CSharp.Symbols;
+using Microsoft.CodeAnalysis.PooledObjects;
using Roslyn.Utilities;
namespace Microsoft.CodeAnalysis.CSharp
@@ -412,5 +414,54 @@ public void ArgumentsWereCoerced()
_argumentsCoerced = true;
#endif
}
+
+ internal MemberAnalysisResult WithoutReceiverArgument()
+ {
+ var badArguments = shift(BadArgumentsOpt);
+ var argsToParams = adjustArgsToParams(ArgsToParamsOpt);
+ var conversions = adjustConversions(ConversionsOpt);
+
+ // We only need HasAnyRefOmittedArgument as part of overload resolution, so we don't need to adjust it post-overload resolution.
+ return new MemberAnalysisResult(Kind, badArguments, argsToParams, conversions, BadParameter - 1, HasAnyRefOmittedArgument,
+ ConstraintFailureDiagnostics, DefinitionParamsElementTypeOpt, ParamsElementTypeOpt);
+
+ static BitVector shift(BitVector badArguments)
+ {
+ if (badArguments.IsNull)
+ {
+ return badArguments;
+ }
+
+ var result = BitVector.Create(badArguments.Capacity);
+ foreach (int setIndex in badArguments.TrueBits())
+ {
+ result[setIndex] = true;
+ }
+
+ return result;
+ }
+
+ static ImmutableArray adjustArgsToParams(ImmutableArray argsToParams)
+ {
+ if (argsToParams.IsDefault)
+ {
+ return argsToParams;
+ }
+
+ var builder = ArrayBuilder.GetInstance();
+ builder.AddRange(argsToParams, 1, argsToParams.Length - 1);
+ for (int i = 0; i < builder.Count; i++)
+ {
+ builder[i]--;
+ }
+
+ return builder.ToImmutableAndFree();
+ }
+
+ static ImmutableArray adjustConversions(ImmutableArray conversions)
+ {
+ return conversions.IsDefaultOrEmpty ? conversions : conversions.RemoveAt(0);
+ }
+ }
}
}
diff --git a/src/Compilers/CSharp/Portable/Binder/Semantics/OverloadResolution/MethodGroup.cs b/src/Compilers/CSharp/Portable/Binder/Semantics/OverloadResolution/MethodGroup.cs
index 21be92c0c74ad..a174f27288b11 100644
--- a/src/Compilers/CSharp/Portable/Binder/Semantics/OverloadResolution/MethodGroup.cs
+++ b/src/Compilers/CSharp/Portable/Binder/Semantics/OverloadResolution/MethodGroup.cs
@@ -8,7 +8,6 @@
using System.Diagnostics;
using Microsoft.CodeAnalysis.CSharp.Symbols;
using Microsoft.CodeAnalysis.PooledObjects;
-using Roslyn.Utilities;
namespace Microsoft.CodeAnalysis.CSharp
{
@@ -47,10 +46,16 @@ internal void PopulateWithExtensionMethods(
{
this.PopulateHelper(receiverOpt, resultKind, error);
this.IsExtensionMethodGroup = true;
+
foreach (var member in members)
{
- this.Methods.Add((MethodSymbol)member);
+ if (member is MethodSymbol method)
+ {
+ Debug.Assert(method.IsExtensionMethod || method.GetIsNewExtensionMember());
+ this.Methods.Add(method);
+ }
}
+
if (!typeArguments.IsDefault)
{
this.TypeArguments.AddRange(typeArguments);
diff --git a/src/Compilers/CSharp/Portable/Binder/Semantics/OverloadResolution/MethodTypeInference.cs b/src/Compilers/CSharp/Portable/Binder/Semantics/OverloadResolution/MethodTypeInference.cs
index 0d151943476d8..7d463db11cca4 100644
--- a/src/Compilers/CSharp/Portable/Binder/Semantics/OverloadResolution/MethodTypeInference.cs
+++ b/src/Compilers/CSharp/Portable/Binder/Semantics/OverloadResolution/MethodTypeInference.cs
@@ -138,6 +138,10 @@ private enum Dependency
private readonly ImmutableArray _arguments;
private readonly Extensions _extensions;
+ // When doing type inference on a new extension method, we combine the type parameters
+ // from the extension declaration and from the method, so we cannot rely on the ordinals from the type parameters.
+ private readonly Dictionary _ordinals;
+
private readonly (TypeWithAnnotations Type, bool FromFunctionType)[] _fixedResults;
private readonly HashSet[] _exactBounds;
private readonly HashSet[] _upperBounds;
@@ -272,7 +276,8 @@ public static MethodTypeInferenceResult Infer(
ImmutableArray arguments,// Required; in scenarios like method group conversions where there are
// no arguments per se we cons up some fake arguments.
ref CompoundUseSiteInfo useSiteInfo,
- Extensions extensions = null)
+ Extensions extensions = null,
+ Dictionary ordinals = null)
{
Debug.Assert(!methodTypeParameters.IsDefault);
Debug.Assert(methodTypeParameters.Length > 0);
@@ -298,7 +303,8 @@ public static MethodTypeInferenceResult Infer(
formalParameterTypes,
formalParameterRefKinds,
arguments,
- extensions);
+ extensions,
+ ordinals);
return inferrer.InferTypeArgs(binder, ref useSiteInfo);
}
@@ -311,6 +317,7 @@ public static MethodTypeInferenceResult Infer(
// SPEC: the bounds is of some type T. Initially each type parameter is unfixed
// SPEC: with an empty set of bounds.
+#nullable enable
private MethodTypeInferrer(
CSharpCompilation compilation,
ConversionsBase conversions,
@@ -319,7 +326,8 @@ private MethodTypeInferrer(
ImmutableArray formalParameterTypes,
ImmutableArray formalParameterRefKinds,
ImmutableArray arguments,
- Extensions extensions)
+ Extensions extensions,
+ Dictionary? ordinals)
{
_compilation = compilation;
_conversions = conversions;
@@ -329,6 +337,12 @@ private MethodTypeInferrer(
_formalParameterRefKinds = formalParameterRefKinds;
_arguments = arguments;
_extensions = extensions ?? Extensions.Default;
+
+ // For extension members, we do inference across all the type parameters (from the extension declaration and the member)
+ Debug.Assert(ordinals is null || ordinals.Values.Count() == ordinals.Values.Distinct().Count());
+ Debug.Assert(ordinals is null || methodTypeParameters.All(tp => ordinals.ContainsKey(tp)));
+
+ _ordinals = ordinals;
_fixedResults = new (TypeWithAnnotations, bool)[methodTypeParameters.Length];
_exactBounds = new HashSet[methodTypeParameters.Length];
_upperBounds = new HashSet[methodTypeParameters.Length];
@@ -338,6 +352,7 @@ private MethodTypeInferrer(
_dependencies = null;
_dependenciesDirty = false;
}
+#nullable enable
#if DEBUG
@@ -488,12 +503,22 @@ private bool IsUnfixedTypeParameter(TypeWithAnnotations type)
if (type.TypeKind != TypeKind.TypeParameter) return false;
TypeParameterSymbol typeParameter = (TypeParameterSymbol)type.Type;
- int ordinal = typeParameter.Ordinal;
+ int ordinal = GetOrdinal(typeParameter);
return ValidIndex(ordinal) &&
TypeSymbol.Equals(typeParameter, _methodTypeParameters[ordinal], TypeCompareKind.ConsiderEverything2) &&
IsUnfixed(ordinal);
}
+ private int GetOrdinal(TypeParameterSymbol typeParameter)
+ {
+ if (_ordinals != null)
+ {
+ return _ordinals[typeParameter];
+ }
+
+ return typeParameter.Ordinal;
+ }
+
private bool AllFixed()
{
for (int methodTypeParameterIndex = 0; methodTypeParameterIndex < _methodTypeParameters.Length; ++methodTypeParameterIndex)
@@ -511,7 +536,7 @@ private void AddBound(TypeWithAnnotations addedBound, HashSet
+ /// We apply type inference to an extension type, using the receiver as argument against the
+ /// extension parameter.
+ /// This lets us infer the type arguments of the extension type given this receiver.
+ ///
+ public static ImmutableArray InferTypeArgumentsFromReceiverType(
+ NamedTypeSymbol extension,
+ BoundExpression receiver,
+ CSharpCompilation compilation,
+ ConversionsBase conversions,
+ ref CompoundUseSiteInfo useSiteInfo)
+ {
+ Debug.Assert(extension is not null);
+ Debug.Assert(extension.Arity > 0);
+ Debug.Assert(extension.ExtensionParameter is not null);
+ Debug.Assert(!extension.ExtensionParameter.Type.IsDynamic());
+ Debug.Assert(extension.IsDefinition);
+ Debug.Assert(receiver is not null);
+
+ var inferrer = new MethodTypeInferrer(
+ compilation,
+ conversions,
+ extension.TypeParameters,
+ extension.ContainingType,
+ [extension.ExtensionParameter.TypeWithAnnotations],
+ [extension.ExtensionParameter.RefKind],
+ [receiver],
+ extensions: null,
+ ordinals: null);
+
+ if (!inferrer.InferTypeArgumentsFromFirstArgument(ref useSiteInfo))
+ {
+ return default;
+ }
+
+ return inferrer.GetInferredTypeArguments(out _);
+ }
+
////////////////////////////////////////////////////////////////////////////////
//
// In error recovery and reporting scenarios we sometimes end up in a situation
@@ -3216,7 +3281,8 @@ public static bool CanInferTypeArgumentsFromFirstArgument(
constructedFromMethod.GetParameterTypes(),
constructedFromMethod.ParameterRefKinds,
arguments,
- extensions: null);
+ extensions: null,
+ ordinals: null);
if (!inferrer.InferTypeArgumentsFromFirstArgument(ref useSiteInfo))
{
diff --git a/src/Compilers/CSharp/Portable/Binder/Semantics/OverloadResolution/OverloadResolution.cs b/src/Compilers/CSharp/Portable/Binder/Semantics/OverloadResolution/OverloadResolution.cs
index 0a9030c48f85d..bfb102af0fbe7 100644
--- a/src/Compilers/CSharp/Portable/Binder/Semantics/OverloadResolution/OverloadResolution.cs
+++ b/src/Compilers/CSharp/Portable/Binder/Semantics/OverloadResolution/OverloadResolution.cs
@@ -446,7 +446,7 @@ private void PerformMemberOverloadResolution(
if (Compilation.LanguageVersion.AllowImprovedOverloadCandidates())
{
- RemoveStaticInstanceMismatches(results, arguments, receiver);
+ RemoveStaticInstanceMismatches(results, receiver);
RemoveConstraintViolations(results, template: new CompoundUseSiteInfo(useSiteInfo));
@@ -578,15 +578,13 @@ internal void FunctionPointerOverloadResolution(
private void RemoveStaticInstanceMismatches(
ArrayBuilder> results,
- AnalyzedArguments arguments,
BoundExpression receiverOpt) where TMember : Symbol
{
// When the feature 'ImprovedOverloadCandidates' is enabled, we do not include instance members when the receiver
- // is a type, or static members when the receiver is an instance. This does not apply to extension method invocations,
- // because extension methods are only considered when the receiver is an instance. It also does not apply when the
+ // is a type, or static members when the receiver is an instance. This does not apply when the
// receiver is a TypeOrValueExpression, which is used to handle the receiver of a Color-Color ambiguity, where either
// an instance or a static member would be acceptable.
- if (arguments.IsExtensionMethodInvocation || Binder.IsTypeOrValueExpression(receiverOpt))
+ if (Binder.IsTypeOrValueExpression(receiverOpt))
{
return;
}
@@ -612,6 +610,11 @@ private static void RemoveStaticInstanceMismatches(ArrayBuilder(ArrayBuilder(ArrayBuilder> results, CompoundUseSiteInfo template) where TMember : Symbol
{
// When the feature 'ImprovedOverloadCandidates' is enabled, we do not include methods for which the type arguments
- // violate the constraints of the method's type parameters.
-
- // Constraint violations apply to method in a method group, not to properties in a "property group".
- if (typeof(TMember) != typeof(MethodSymbol))
- {
- return;
- }
+ // violate the constraints of the member's type parameters.
for (int f = 0; f < results.Count; ++f)
{
var result = results[f];
- var member = (MethodSymbol)(Symbol)result.Member;
+ var member = result.Member;
// a constraint failure on the method trumps (for reporting purposes) a previously-detected
// constraint failure on the constructed type of a parameter
if ((result.Result.IsValid || result.Result.Kind == MemberResolutionKind.ConstructedParameterFailedConstraintCheck) &&
@@ -791,9 +788,10 @@ static MemberResolutionResult makeWrongCallingConvention(MemberResoluti
}
#nullable disable
- private bool FailsConstraintChecks(MethodSymbol method, out ArrayBuilder constraintFailureDiagnosticsOpt, CompoundUseSiteInfo template)
+ private bool FailsConstraintChecks(TMember member, out ArrayBuilder constraintFailureDiagnosticsOpt, CompoundUseSiteInfo template) where TMember : Symbol
{
- if (method.Arity == 0 || method.OriginalDefinition == (object)method)
+ int arity = member.GetMemberArityIncludingExtension();
+ if (arity == 0 || member.OriginalDefinition == (object)member)
{
constraintFailureDiagnosticsOpt = null;
return false;
@@ -801,12 +799,25 @@ private bool FailsConstraintChecks(MethodSymbol method, out ArrayBuilder.GetInstance();
ArrayBuilder useSiteDiagnosticsBuilder = null;
- bool constraintsSatisfied = ConstraintsHelper.CheckMethodConstraints(
- method,
- new ConstraintsHelper.CheckConstraintsArgs(this.Compilation, this.Conversions, includeNullability: false, location: NoLocation.Singleton, diagnostics: null, template),
- diagnosticsBuilder,
- nullabilityDiagnosticsBuilderOpt: null,
- ref useSiteDiagnosticsBuilder);
+ var constraintsArgs = new ConstraintsHelper.CheckConstraintsArgs(this.Compilation, this.Conversions, includeNullability: false, location: NoLocation.Singleton, diagnostics: null, template);
+
+ bool constraintsSatisfied = true;
+ if (member is MethodSymbol method && method.Arity > 0)
+ {
+ constraintsSatisfied &= ConstraintsHelper.CheckMethodConstraints(
+ method,
+ constraintsArgs,
+ diagnosticsBuilder,
+ nullabilityDiagnosticsBuilderOpt: null,
+ ref useSiteDiagnosticsBuilder);
+ }
+
+ if (member.GetIsNewExtensionMember() && member.ContainingType is { } extension && ConstraintsHelper.RequiresChecking(extension))
+ {
+ constraintsSatisfied &= ConstraintsHelper.CheckConstraints(extension, in constraintsArgs,
+ extension.TypeSubstitution, extension.TypeParameters, extension.TypeArgumentsWithAnnotationsNoUseSiteDiagnostics,
+ diagnosticsBuilder, nullabilityDiagnosticsBuilderOpt: null, ref useSiteDiagnosticsBuilder);
+ }
if (!constraintsSatisfied)
{
@@ -1157,7 +1168,7 @@ private void AddMemberToCandidateSet(
// This is specifying an impossible condition; the member lookup algorithm has already filtered
// out methods from the method group that have the wrong generic arity.
- Debug.Assert(typeArguments.Count == 0 || typeArguments.Count == member.GetMemberArity());
+ Debug.Assert(typeArguments.Count == 0 || typeArguments.Count == member.GetMemberArityIncludingExtension());
// Second, we need to determine if the method is applicable in its normal form or its expanded form.
bool disallowExpandedNonArrayParams = (options & Options.DisallowExpandedNonArrayParams) != 0;
@@ -1462,20 +1473,24 @@ private void RemoveInaccessibleTypeArguments(ArrayBuilder typeArguments, ref CompoundUseSiteInfo useSiteInfo)
- {
- foreach (TypeSymbol arg in typeArguments)
+ bool typeArgumentsAccessible(ImmutableArray typeArguments, ref CompoundUseSiteInfo useSiteInfo)
{
- if (!_binder.IsAccessible(arg, ref useSiteInfo)) return false;
+ foreach (TypeSymbol arg in typeArguments)
+ {
+ if (!_binder.IsAccessible(arg, ref useSiteInfo)) return false;
+ }
+ return true;
}
- return true;
}
private static void RemoveLessDerivedMembers(ArrayBuilder> results, ref CompoundUseSiteInfo useSiteInfo)
@@ -1874,7 +1889,7 @@ private void RemoveLowerPriorityMembers(ArrayBuilder
continue;
}
- var containingType = result.MemberWithPriority.ContainingType;
+ var containingType = result.MemberWithPriority.ContainingType; // Tracked by https://github.com/dotnet/roslyn/issues/76130 : how should ORPA apply to new extension methods?
if (resultsByContainingType.TryGetValue(containingType, out var previousResults))
{
var previousPriority = previousResults.First().MemberWithPriority.GetOverloadResolutionPriority();
@@ -2065,16 +2080,29 @@ private void RemoveWorseMembers(ArrayBuilder
/// Returns the parameter corresponding to the given argument index.
///
- private static ParameterSymbol GetParameter(int argIndex, MemberAnalysisResult result, ImmutableArray parameters)
+ private static ParameterSymbol GetParameterOrExtensionParameter(int argIndex, MemberAnalysisResult result, ImmutableArray parameters, TMember member)
+ where TMember : Symbol
{
+ if (member.GetIsNewExtensionMember())
+ {
+ if (argIndex == 0)
+ {
+ ParameterSymbol? extensionParameter = member.ContainingType.ExtensionParameter;
+ Debug.Assert(extensionParameter is not null);
+ return extensionParameter;
+ }
+
+ argIndex--;
+ }
+
int paramIndex = result.ParameterFromArgument(argIndex);
return parameters[paramIndex];
}
-#nullable enable
private BetterResult BetterFunctionMember(
MemberResolutionResult m1,
MemberResolutionResult m2,
@@ -2164,9 +2192,9 @@ private BetterResult BetterFunctionMember(
continue;
}
- var type1 = getParameterTypeAndRefKind(i, m1.Result, m1LeastOverriddenParameters, m1.Result.ParamsElementTypeOpt, out RefKind parameter1RefKind);
+ var type1 = getParameterTypeAndRefKind(i, m1.Result, m1LeastOverriddenParameters, m1.Result.ParamsElementTypeOpt, m1.LeastOverriddenMember, out RefKind parameter1RefKind);
- var type2 = getParameterTypeAndRefKind(i, m2.Result, m2LeastOverriddenParameters, m2.Result.ParamsElementTypeOpt, out RefKind parameter2RefKind);
+ var type2 = getParameterTypeAndRefKind(i, m2.Result, m2LeastOverriddenParameters, m2.Result.ParamsElementTypeOpt, m2.LeastOverriddenMember, out RefKind parameter2RefKind);
bool okToDowngradeToNeither;
BetterResult r;
@@ -2306,9 +2334,9 @@ private BetterResult BetterFunctionMember(
continue;
}
- var type1 = getParameterTypeAndRefKind(i, m1.Result, m1LeastOverriddenParameters, m1.Result.ParamsElementTypeOpt, out _);
+ var type1 = getParameterTypeAndRefKind(i, m1.Result, m1LeastOverriddenParameters, m1.Result.ParamsElementTypeOpt, m1.LeastOverriddenMember, out _);
- var type2 = getParameterTypeAndRefKind(i, m2.Result, m2LeastOverriddenParameters, m2.Result.ParamsElementTypeOpt, out _);
+ var type2 = getParameterTypeAndRefKind(i, m2.Result, m2LeastOverriddenParameters, m2.Result.ParamsElementTypeOpt, m2.LeastOverriddenMember, out _);
var type1Normalized = type1;
var type2Normalized = type2;
@@ -2376,14 +2404,14 @@ private BetterResult BetterFunctionMember(
}
// If MP is a non-generic method and MQ is a generic method, then MP is better than MQ.
- if (m1.Member.GetMemberArity() == 0)
+ if (m1.Member.GetMemberArityIncludingExtension() == 0)
{
- if (m2.Member.GetMemberArity() > 0)
+ if (m2.Member.GetMemberArityIncludingExtension() > 0)
{
return BetterResult.Left;
}
}
- else if (m2.Member.GetMemberArity() == 0)
+ else if (m2.Member.GetMemberArityIncludingExtension() == 0)
{
return BetterResult.Right;
}
@@ -2466,9 +2494,9 @@ private BetterResult BetterFunctionMember(
continue;
}
- uninst1.Add(getParameterTypeAndRefKind(i, m1.Result, m1DefinitionParameters, m1.Result.DefinitionParamsElementTypeOpt, out _));
+ uninst1.Add(getParameterTypeAndRefKind(i, m1.Result, m1DefinitionParameters, m1.Result.DefinitionParamsElementTypeOpt, (TMember)m1.LeastOverriddenMember.OriginalDefinition, out _));
- uninst2.Add(getParameterTypeAndRefKind(i, m2.Result, m2DefinitionParameters, m2.Result.DefinitionParamsElementTypeOpt, out _));
+ uninst2.Add(getParameterTypeAndRefKind(i, m2.Result, m2DefinitionParameters, m2.Result.DefinitionParamsElementTypeOpt, (TMember)m2.LeastOverriddenMember.OriginalDefinition, out _));
}
result = MoreSpecificType(ref uninst1.AsRef(), ref uninst2.AsRef(), ref useSiteInfo);
@@ -2526,8 +2554,8 @@ private BetterResult BetterFunctionMember(
for (i = 0; i < arguments.Count; ++i)
{
- var parameter1 = GetParameter(i, m1.Result, m1LeastOverriddenParameters);
- var parameter2 = GetParameter(i, m2.Result, m2LeastOverriddenParameters);
+ var parameter1 = GetParameterOrExtensionParameter(i, m1.Result, m1LeastOverriddenParameters, m1.LeastOverriddenMember);
+ var parameter2 = GetParameterOrExtensionParameter(i, m2.Result, m2LeastOverriddenParameters, m2.LeastOverriddenMember);
if ((parameter1.Ordinal == m1ParamsOrdinal) != (parameter2.Ordinal == m2ParamsOrdinal))
{
@@ -2555,13 +2583,15 @@ private BetterResult BetterFunctionMember(
return BetterResult.Neither;
// Returns the parameter type (considering params).
- static TypeSymbol getParameterTypeAndRefKind(int i, MemberAnalysisResult result, ImmutableArray parameters, TypeWithAnnotations paramsElementTypeOpt, out RefKind parameter1RefKind)
+ static TypeSymbol getParameterTypeAndRefKind(int i, MemberAnalysisResult memberResolutionResult, ImmutableArray parameters,
+ TypeWithAnnotations paramsElementTypeOpt, TMember member, out RefKind parameter1RefKind)
{
- var parameter = GetParameter(i, result, parameters);
+ ParameterSymbol parameter = GetParameterOrExtensionParameter(i, memberResolutionResult, parameters, member);
+
parameter1RefKind = parameter.RefKind;
var type = parameter.Type;
- if (result.Kind == MemberResolutionKind.ApplicableInExpandedForm &&
+ if (memberResolutionResult.Kind == MemberResolutionKind.ApplicableInExpandedForm &&
parameter.Ordinal == parameters.Length - 1)
{
Debug.Assert(paramsElementTypeOpt.HasType);
@@ -2612,8 +2642,8 @@ private static BetterResult PreferValOverInOrRefInterpolatedHandlerParameters(MemberResolutionResult m, ArrayBuilder arguments, out int declaredParameterCount, out int parametersUsedIncludingExpansionAndOptional) where TMember : Symbol
{
- declaredParameterCount = m.Member.GetParameterCount();
+ declaredParameterCount = m.Member.GetParameterCount() + (m.Member.GetIsNewExtensionMember() ? 1 : 0);
if (m.Result.Kind == MemberResolutionKind.ApplicableInExpandedForm)
{
@@ -3846,17 +3877,26 @@ private static EffectiveParameters GetEffectiveParametersInNormalForm(
Debug.Assert(argumentRefKinds != null);
hasAnyRefOmittedArgument = false;
- ImmutableArray parameters = member.GetParameters();
- // We simulate an extra parameter for vararg methods
- int parameterCount = member.GetParameterCount() + (member.GetIsVararg() ? 1 : 0);
+ bool isNewExtensionMember = member.GetIsNewExtensionMember();
+ ImmutableArray parameters = isNewExtensionMember ? GetParametersIncludingReceiver(member) : member.GetParameters();
+
+ // We simulate an extra parameter for vararg methods
+ int parameterCount = parameters.Length + (member.GetIsVararg() ? 1 : 0);
if (argumentCount == parameterCount && argToParamMap.IsDefaultOrEmpty)
{
- ImmutableArray parameterRefKinds = member.GetParameterRefKinds();
- if (parameterRefKinds.IsDefaultOrEmpty)
+ bool hasSomeRefKinds = !member.GetParameterRefKinds().IsDefaultOrEmpty;
+ if (member.GetIsNewExtensionMember())
+ {
+ Debug.Assert(member.ContainingType.ExtensionParameter is not null);
+ hasSomeRefKinds |= member.ContainingType.ExtensionParameter.RefKind != RefKind.None;
+ }
+
+ if (!hasSomeRefKinds)
{
- return new EffectiveParameters(member.GetParameterTypes(), parameterRefKinds, firstParamsElementIndex: -1);
+ var parameterTypes = isNewExtensionMember ? GetParameterTypesIncludingReceiver(member) : member.GetParameterTypes();
+ return new EffectiveParameters(parameterTypes, refKinds: default, firstParamsElementIndex: -1);
}
}
@@ -4000,7 +4040,7 @@ private static EffectiveParameters GetEffectiveParametersInExpandedForm
var types = ArrayBuilder.GetInstance();
var refs = ArrayBuilder.GetInstance();
bool anyRef = false;
- var parameters = member.GetParameters();
+ var parameters = member.GetIsNewExtensionMember() ? GetParametersIncludingReceiver(member) : member.GetParameters();
bool hasAnyRefArg = argumentRefKinds.Any();
hasAnyRefOmittedArgument = false;
TypeWithAnnotations paramsIterationType = default;
@@ -4205,14 +4245,13 @@ private MemberResolutionResult IsApplicable(
Debug.Assert(GetConstructedFrom(leastOverriddenMember) == (object)leastOverriddenMember);
bool ignoreOpenTypes;
- MethodSymbol method;
EffectiveParameters constructedEffectiveParameters;
bool hasTypeArgumentsInferredFromFunctionType = false;
if ((options & Options.InferringUniqueMethodGroupSignature) == 0 &&
- member.Kind == SymbolKind.Method && (method = (MethodSymbol)(Symbol)member).Arity > 0)
+ member.GetMemberArityIncludingExtension() > 0)
{
- MethodSymbol leastOverriddenMethod = (MethodSymbol)(Symbol)leastOverriddenMember;
ImmutableArray typeArguments;
+ bool isNewExtensionMember = member.GetIsNewExtensionMember();
if (typeArgumentsBuilder.Count == 0 && arguments.HasDynamicArgument && !inferWithDynamic)
{
@@ -4226,7 +4265,7 @@ private MemberResolutionResult IsApplicable(
// We don't need to check constraints of types of the non-elided parameters since they
// have no effect on applicability of this candidate.
ignoreOpenTypes = true;
- typeArguments = method.TypeArgumentsWithAnnotations;
+ typeArguments = getAllTypeArguments(member, isNewExtensionMember);
}
else
{
@@ -4239,8 +4278,10 @@ private MemberResolutionResult IsApplicable(
{
// infer generic type arguments:
MemberAnalysisResult inferenceError;
- typeArguments = InferMethodTypeArguments(method,
- leastOverriddenMethod.ConstructedFrom.TypeParameters,
+ ImmutableArray typeParameters = GetTypeParametersIncludingExtension(leastOverriddenMember);
+
+ typeArguments = InferMethodTypeArguments(member,
+ typeParameters,
arguments,
constructedFromEffectiveParameters,
out hasTypeArgumentsInferredFromFunctionType,
@@ -4252,8 +4293,8 @@ private MemberResolutionResult IsApplicable(
}
}
- member = (TMember)(Symbol)method.Construct(typeArguments);
- leastOverriddenMember = (TMember)(Symbol)leastOverriddenMethod.ConstructedFrom.Construct(typeArguments);
+ member = member.ConstructIncludingExtension(typeArguments);
+ leastOverriddenMember = GetConstructedFrom(leastOverriddenMember).ConstructIncludingExtension(typeArguments);
// Spec (§7.6.5.1)
// Once the (inferred) type arguments are substituted for the corresponding method type parameters,
@@ -4283,7 +4324,10 @@ private MemberResolutionResult IsApplicable(
// the generic method still needs to be discarded, even though type inference
// never saw the second formal parameter.
- var parameterTypes = leastOverriddenMember.GetParameterTypes();
+ var parameterTypes = isNewExtensionMember
+ ? GetParameterTypesIncludingReceiver(leastOverriddenMember)
+ : leastOverriddenMember.GetParameterTypes();
+
for (int i = 0; i < parameterTypes.Length; i++)
{
if (!parameterTypes[i].Type.CheckAllConstraints(Compilation, Conversions))
@@ -4295,7 +4339,7 @@ private MemberResolutionResult IsApplicable(
ignoreOpenTypes = false;
}
- var map = new TypeMap(leastOverriddenMethod.TypeParameters, typeArguments, allowAlpha: true);
+ var map = new TypeMap(GetTypeParametersIncludingExtension(isNewExtensionMember ? leastOverriddenMember.OriginalDefinition : leastOverriddenMember), typeArguments, allowAlpha: true);
constructedEffectiveParameters = new EffectiveParameters(
map.SubstituteTypes(constructedFromEffectiveParameters.ParameterTypes),
@@ -4323,16 +4367,54 @@ private MemberResolutionResult IsApplicable(
isMethodGroupConversion: isMethodGroupConversion,
useSiteInfo: ref useSiteInfo);
return new MemberResolutionResult(member, leastOverriddenMember, applicableResult, hasTypeArgumentsInferredFromFunctionType);
+
+ static ImmutableArray getAllTypeArguments(TMember member, bool isNewExtensionMember)
+ {
+ if (member is MethodSymbol method)
+ {
+ return isNewExtensionMember
+ ? method.ContainingType.TypeArgumentsWithAnnotationsNoUseSiteDiagnostics.Concat(method.TypeArgumentsWithAnnotations)
+ : method.TypeArgumentsWithAnnotations;
+ }
+ else if (member is PropertySymbol property)
+ {
+ Debug.Assert(isNewExtensionMember);
+ var result = property.ContainingType.TypeArgumentsWithAnnotationsNoUseSiteDiagnostics;
+ Debug.Assert(!result.IsDefaultOrEmpty);
+ return result;
+ }
+
+ throw ExceptionUtilities.UnexpectedValue(member);
+ }
}
- private ImmutableArray InferMethodTypeArguments(
- MethodSymbol method,
+ internal static ImmutableArray GetTypeParametersIncludingExtension(TMember member) where TMember : Symbol
+ {
+ if (member is MethodSymbol method)
+ {
+ return method.GetIsNewExtensionMember()
+ ? method.ContainingType.TypeParameters.Concat(method.TypeParameters)
+ : method.ConstructedFrom.TypeParameters;
+ }
+
+ if (member is PropertySymbol property)
+ {
+ Debug.Assert(property.GetIsNewExtensionMember());
+ return property.ContainingType.TypeParameters;
+ }
+
+ throw ExceptionUtilities.UnexpectedValue(member);
+ }
+
+ private ImmutableArray InferMethodTypeArguments(
+ TMember member,
ImmutableArray originalTypeParameters,
AnalyzedArguments arguments,
EffectiveParameters originalEffectiveParameters,
out bool hasTypeArgumentsInferredFromFunctionType,
out MemberAnalysisResult error,
ref CompoundUseSiteInfo useSiteInfo)
+ where TMember : Symbol
{
var args = arguments.Arguments.ToImmutable();
@@ -4341,15 +4423,20 @@ private ImmutableArray InferMethodTypeArguments(
// a possibly constructed generic type, is exceedingly subtle. See the comments
// in "Infer" for details.
+ PooledDictionary ordinals = makeOrdinalsIfNeeded(member, originalTypeParameters);
+
var inferenceResult = MethodTypeInferrer.Infer(
_binder,
_binder.Conversions,
originalTypeParameters,
- method.ContainingType,
+ member.ContainingType,
originalEffectiveParameters.ParameterTypes,
originalEffectiveParameters.ParameterRefKinds,
args,
- ref useSiteInfo);
+ ref useSiteInfo,
+ ordinals: ordinals);
+
+ ordinals?.Free();
if (inferenceResult.Success)
{
@@ -4358,15 +4445,32 @@ private ImmutableArray InferMethodTypeArguments(
return inferenceResult.InferredTypeArguments;
}
- if (arguments.IsExtensionMethodInvocation)
+ if (arguments.IncludesReceiverAsArgument)
{
- var canInfer = MethodTypeInferrer.CanInferTypeArgumentsFromFirstArgument(
- _binder.Compilation,
- _binder.Conversions,
- method,
- args,
- useSiteInfo: ref useSiteInfo,
- out _);
+ bool canInfer;
+ if (member.GetIsNewExtensionMember())
+ {
+ if (member.ContainingType.Arity > 0)
+ {
+ var extensionTypeArguments = MethodTypeInferrer.InferTypeArgumentsFromReceiverType(member.ContainingType, args[0], _binder.Compilation, _binder.Conversions, ref useSiteInfo);
+ canInfer = !extensionTypeArguments.IsDefault && !extensionTypeArguments.Any(t => !t.HasType);
+ }
+ else
+ {
+ canInfer = true;
+ }
+ }
+ else
+ {
+ canInfer = MethodTypeInferrer.CanInferTypeArgumentsFromFirstArgument(
+ _binder.Compilation,
+ _binder.Conversions,
+ (MethodSymbol)(Symbol)member,
+ args,
+ useSiteInfo: ref useSiteInfo,
+ out _);
+ }
+
if (!canInfer)
{
hasTypeArgumentsInferredFromFunctionType = false;
@@ -4378,7 +4482,38 @@ private ImmutableArray InferMethodTypeArguments(
hasTypeArgumentsInferredFromFunctionType = false;
error = MemberAnalysisResult.TypeInferenceFailed();
return default(ImmutableArray);
+
+#nullable enable
+ static PooledDictionary? makeOrdinalsIfNeeded(TMember member, ImmutableArray originalTypeParameters)
+ {
+ if (member is MethodSymbol method)
+ {
+ PooledDictionary? ordinals = null;
+ if (method.GetIsNewExtensionMember() && method.Arity > 0 && method.ContainingType.Arity > 0)
+ {
+ Debug.Assert(originalTypeParameters.Length == method.Arity + method.ContainingType.Arity);
+
+ // Since we're concatenating type parameters from the extension and from the method together
+ // we need to control the ordinals that are used
+ ordinals = PooledDictionary.GetInstance();
+ for (int i = 0; i < originalTypeParameters.Length; i++)
+ {
+ ordinals.Add(originalTypeParameters[i], i);
+ }
+ }
+
+ return ordinals;
+ }
+
+ if (member is PropertySymbol)
+ {
+ return null;
+ }
+
+ throw ExceptionUtilities.UnexpectedValue(member);
+ }
}
+#nullable disable
private MemberAnalysisResult IsApplicable(
Symbol candidate, // method or property
@@ -4467,7 +4602,7 @@ private MemberAnalysisResult IsApplicable(
{
RefKind argumentRefKind = arguments.RefKind(argumentPosition);
RefKind parameterRefKind = parameters.ParameterRefKinds.IsDefault ? RefKind.None : parameters.ParameterRefKinds[argumentPosition];
- bool forExtensionMethodThisArg = arguments.IsExtensionMethodThisArgument(argumentPosition);
+ bool forExtensionMethodThisArg = arguments.IsExtensionMethodReceiverArgument(argumentPosition);
if (forExtensionMethodThisArg)
{
diff --git a/src/Compilers/CSharp/Portable/Binder/Semantics/OverloadResolution/OverloadResolutionResult.cs b/src/Compilers/CSharp/Portable/Binder/Semantics/OverloadResolution/OverloadResolutionResult.cs
index d260b5ba8ebe3..945927818063a 100644
--- a/src/Compilers/CSharp/Portable/Binder/Semantics/OverloadResolution/OverloadResolutionResult.cs
+++ b/src/Compilers/CSharp/Portable/Binder/Semantics/OverloadResolution/OverloadResolutionResult.cs
@@ -895,7 +895,7 @@ private static void ReportMissingRequiredParameter(
// to required formal parameter 'y'.
TMember badMember = bad.Member;
- ImmutableArray parameters = badMember.GetParameters();
+ ImmutableArray parameters = badMember.GetIsNewExtensionMember() ? OverloadResolution.GetParametersIncludingReceiver(badMember) : badMember.GetParameters();
int badParamIndex = bad.Result.BadParameter;
string badParamName;
if (badParamIndex == parameters.Length)
@@ -946,7 +946,7 @@ private static void ReportBadParameterCount(
};
int argCount = arguments.Arguments.Count;
- if (arguments.IsExtensionMethodInvocation)
+ if (arguments.IncludesReceiverAsArgument)
{
argCount--;
}
@@ -1114,8 +1114,8 @@ private bool HadBadArguments(
// ErrorCode.ERR_BadArgTypesForCollectionAdd or ErrorCode.ERR_InitializerAddHasParamModifiers
// as there is no explicit call to Add method.
- int argumentOffset = arguments.IsExtensionMethodInvocation ? 1 : 0;
- var parameters = method.GetParameters();
+ int argumentOffset = arguments.IncludesReceiverAsArgument ? 1 : 0;
+ var parameters = method.GetIsNewExtensionMember() ? OverloadResolution.GetParametersIncludingReceiver(method) : method.GetParameters();
for (int i = argumentOffset; i < parameters.Length; i++)
{
@@ -1156,6 +1156,7 @@ private static void ReportBadArgumentError(
TMember method,
int arg)
{
+ // Tracked by https://github.com/dotnet/roslyn/issues/76130 : consider adjusting or removing the argument index for displaying in diagnostic
BoundExpression argument = arguments.Argument(arg);
if (argument.HasAnyErrors)
{
@@ -1169,7 +1170,8 @@ private static void ReportBadArgumentError(
// Early out: if the bad argument is an __arglist parameter then simply report that:
- if (method.GetIsVararg() && parm == method.GetParameterCount())
+ var parameters = method.GetIsNewExtensionMember() ? OverloadResolution.GetParametersIncludingReceiver(method) : method.GetParameters();
+ if (method.GetIsVararg() && parm == parameters.Length)
{
// NOTE: No SymbolDistinguisher required, since one of the arguments is "__arglist".
@@ -1184,12 +1186,12 @@ private static void ReportBadArgumentError(
return;
}
- ParameterSymbol parameter = method.GetParameters()[parm];
- bool isLastParameter = method.GetParameterCount() == parm + 1; // This is used to later decide if we need to try to unwrap a params collection
+ ParameterSymbol parameter = parameters[parm];
+ bool isLastParameter = parameters.Length == parm + 1; // This is used to later decide if we need to try to unwrap a params collection
RefKind refArg = arguments.RefKind(arg);
RefKind refParameter = parameter.RefKind;
- if (arguments.IsExtensionMethodThisArgument(arg))
+ if (arguments.IsExtensionMethodReceiverArgument(arg))
{
Debug.Assert(refArg == RefKind.None);
if (refParameter == RefKind.Ref || refParameter == RefKind.In)
@@ -1301,7 +1303,7 @@ private static void ReportBadArgumentError(
Debug.Assert(argument.Kind != BoundKind.DiscardExpression || argument.HasExpressionType());
Debug.Assert(argument.Display != null);
- if (arguments.IsExtensionMethodThisArgument(arg))
+ if (arguments.IsExtensionMethodReceiverArgument(arg))
{
Debug.Assert((arg == 0) && (parm == arg));
Debug.Assert(!badArg.Result.ConversionForArg(parm).IsImplicit);
diff --git a/src/Compilers/CSharp/Portable/Binder/Semantics/OverloadResolution/OverloadResolution_ArgsToParameters.cs b/src/Compilers/CSharp/Portable/Binder/Semantics/OverloadResolution/OverloadResolution_ArgsToParameters.cs
index 3da8c76c13371..15e4f55d5b914 100644
--- a/src/Compilers/CSharp/Portable/Binder/Semantics/OverloadResolution/OverloadResolution_ArgsToParameters.cs
+++ b/src/Compilers/CSharp/Portable/Binder/Semantics/OverloadResolution/OverloadResolution_ArgsToParameters.cs
@@ -55,6 +55,20 @@ public ImmutableArray ToImmutableArray()
}
}
+ internal static ImmutableArray GetParametersIncludingReceiver(Symbol symbol)
+ {
+ Debug.Assert(symbol.GetIsNewExtensionMember());
+ // Tracked by https://github.com/dotnet/roslyn/issues/76130 : consider optimizing
+ return [symbol.ContainingType.ExtensionParameter, .. symbol.GetParameters()];
+ }
+
+ private static ImmutableArray GetParameterTypesIncludingReceiver(Symbol symbol)
+ {
+ Debug.Assert(symbol.GetIsNewExtensionMember());
+ // Tracked by https://github.com/dotnet/roslyn/issues/76130 : consider optimizing
+ return [symbol.ContainingType.ExtensionParameter.TypeWithAnnotations, .. symbol.GetParameterTypes()];
+ }
+
private static ArgumentAnalysisResult AnalyzeArguments(
Symbol symbol,
AnalyzedArguments arguments,
@@ -64,7 +78,8 @@ private static ArgumentAnalysisResult AnalyzeArguments(
Debug.Assert((object)symbol != null);
Debug.Assert(arguments != null);
- ImmutableArray parameters = symbol.GetParameters();
+ bool isNewExtensionMember = symbol.GetIsNewExtensionMember();
+ ImmutableArray parameters = isNewExtensionMember ? GetParametersIncludingReceiver(symbol) : symbol.GetParameters();
bool isVararg = symbol.GetIsVararg();
// The easy out is that we have no named arguments and are in normal form.
diff --git a/src/Compilers/CSharp/Portable/Binder/SwitchBinder_Patterns.cs b/src/Compilers/CSharp/Portable/Binder/SwitchBinder_Patterns.cs
index 3dcf824ff86db..c5dabbb02b759 100644
--- a/src/Compilers/CSharp/Portable/Binder/SwitchBinder_Patterns.cs
+++ b/src/Compilers/CSharp/Portable/Binder/SwitchBinder_Patterns.cs
@@ -62,7 +62,7 @@ internal override BoundStatement BindSwitchStatementCore(SwitchStatementSyntax n
syntax: node,
expression: boundSwitchGoverningExpression,
innerLocals: locals,
- innerLocalFunctions: functions,
+ innerLocalFunctions: ImmutableArray.CastUp(functions),
switchSections: switchSections,
defaultLabel: defaultLabel,
breakLabel: this.BreakLabel,
diff --git a/src/Compilers/CSharp/Portable/Binder/WithClassTypeParametersBinder.cs b/src/Compilers/CSharp/Portable/Binder/WithClassTypeParametersBinder.cs
index a073d882d9a94..fd1a7d0f2c3aa 100644
--- a/src/Compilers/CSharp/Portable/Binder/WithClassTypeParametersBinder.cs
+++ b/src/Compilers/CSharp/Portable/Binder/WithClassTypeParametersBinder.cs
@@ -62,5 +62,19 @@ internal override void AddLookupSymbolsInfoInSingleBinder(LookupSymbolsInfo resu
}
}
}
+
+ protected override LookupOptions LookupMask
+ {
+ get
+ {
+ if (_namedType.IsExtension)
+ {
+ // Extension type parameters should get the same treatment as method type parameters
+ return WithMethodTypeParametersBinder.MethodTypeParameterLookupMask;
+ }
+
+ return base.LookupMask;
+ }
+ }
}
}
diff --git a/src/Compilers/CSharp/Portable/Binder/WithExtensionParameterBinder.cs b/src/Compilers/CSharp/Portable/Binder/WithExtensionParameterBinder.cs
new file mode 100644
index 0000000000000..870e610d0f1b2
--- /dev/null
+++ b/src/Compilers/CSharp/Portable/Binder/WithExtensionParameterBinder.cs
@@ -0,0 +1,52 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// 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.Diagnostics;
+using Microsoft.CodeAnalysis.CSharp.Symbols;
+using Roslyn.Utilities;
+
+namespace Microsoft.CodeAnalysis.CSharp
+{
+ ///
+ /// Binder used to place extension parameter, if any, in scope.
+ ///
+ internal sealed class WithExtensionParameterBinder : Binder
+ {
+ private readonly NamedTypeSymbol _type;
+
+ internal WithExtensionParameterBinder(NamedTypeSymbol type, Binder next)
+ : base(next)
+ {
+ _type = type;
+ }
+
+ internal override void AddLookupSymbolsInfoInSingleBinder(LookupSymbolsInfo result, LookupOptions options, Binder originalBinder)
+ {
+ if (options.CanConsiderMembers())
+ {
+ if (_type.ExtensionParameter is { Name: not "" } parameter &&
+ originalBinder.CanAddLookupSymbolInfo(parameter, options, result, null))
+ {
+ result.AddSymbol(parameter, parameter.Name, 0);
+ }
+ }
+ }
+
+ internal override void LookupSymbolsInSingleBinder(
+ LookupResult result, string name, int arity, ConsList basesBeingResolved, LookupOptions options, Binder originalBinder, bool diagnose, ref CompoundUseSiteInfo useSiteInfo)
+ {
+ Debug.Assert(result.IsClear);
+
+ if ((options & (LookupOptions.NamespaceAliasesOnly | LookupOptions.NamespacesOrTypesOnly)) != 0)
+ {
+ return;
+ }
+
+ if (_type.ExtensionParameter is { Name: not "" } parameter && parameter.Name == name)
+ {
+ result.MergeEqual(originalBinder.CheckViability(parameter, arity, options, null, diagnose, ref useSiteInfo));
+ }
+ }
+ }
+}
diff --git a/src/Compilers/CSharp/Portable/Binder/WithMethodTypeParametersBinder.cs b/src/Compilers/CSharp/Portable/Binder/WithMethodTypeParametersBinder.cs
index f72176050939d..5d3142da798a1 100644
--- a/src/Compilers/CSharp/Portable/Binder/WithMethodTypeParametersBinder.cs
+++ b/src/Compilers/CSharp/Portable/Binder/WithMethodTypeParametersBinder.cs
@@ -15,6 +15,7 @@ namespace Microsoft.CodeAnalysis.CSharp
///
internal sealed class WithMethodTypeParametersBinder : WithTypeParametersBinder
{
+ internal const LookupOptions MethodTypeParameterLookupMask = LookupOptions.NamespaceAliasesOnly | LookupOptions.MustNotBeMethodTypeParameter;
private readonly MethodSymbol _methodSymbol;
private MultiDictionary _lazyTypeParameterMap;
@@ -57,7 +58,7 @@ protected override LookupOptions LookupMask
{
get
{
- return LookupOptions.NamespaceAliasesOnly | LookupOptions.MustNotBeMethodTypeParameter;
+ return MethodTypeParameterLookupMask;
}
}
diff --git a/src/Compilers/CSharp/Portable/Binder/WithTypeParametersBinder.cs b/src/Compilers/CSharp/Portable/Binder/WithTypeParametersBinder.cs
index f44ecf90aa85e..62e6cb17b378b 100644
--- a/src/Compilers/CSharp/Portable/Binder/WithTypeParametersBinder.cs
+++ b/src/Compilers/CSharp/Portable/Binder/WithTypeParametersBinder.cs
@@ -21,7 +21,6 @@ internal WithTypeParametersBinder(Binder next)
// TODO: Change this to a data structure that won't allocate enumerators
protected abstract MultiDictionary TypeParameterMap { get; }
- // This is only overridden by WithMethodTypeParametersBinder.
protected virtual LookupOptions LookupMask
{
get
diff --git a/src/Compilers/CSharp/Portable/Binder/WithUsingNamespacesAndTypesBinder.cs b/src/Compilers/CSharp/Portable/Binder/WithUsingNamespacesAndTypesBinder.cs
index 05c22fab771c0..107d440659f1b 100644
--- a/src/Compilers/CSharp/Portable/Binder/WithUsingNamespacesAndTypesBinder.cs
+++ b/src/Compilers/CSharp/Portable/Binder/WithUsingNamespacesAndTypesBinder.cs
@@ -66,7 +66,7 @@ protected WithUsingNamespacesAndTypesBinder(Binder next, bool withImportChainEnt
return base.GetForwardedToAssemblyInUsingNamespaces(name, ref qualifierOpt, diagnostics, location);
}
- internal override bool SupportsExtensionMethods
+ internal override bool SupportsExtensions
{
get { return true; }
}
@@ -129,6 +129,31 @@ internal override void GetCandidateExtensionMethods(
}
}
+ internal override void GetExtensionDeclarations(ArrayBuilder extensions, Binder originalBinder)
+ {
+ Debug.Assert(extensions.Count == 0);
+
+ // Tracked by https://github.com/dotnet/roslyn/issues/76130 : test this flag (see TestUnusedExtensionMarksImportsAsUsed)
+ bool callerIsSemanticModel = originalBinder.IsSemanticModelBinder;
+
+ foreach (var nsOrType in this.GetUsings(basesBeingResolved: null))
+ {
+ if (nsOrType.NamespaceOrType is NamespaceSymbol ns)
+ {
+ var count = extensions.Count;
+ ns.GetExtensionContainers(extensions);
+ // If we found any extension declarations, then consider this using as used.
+ // Tracked by https://github.com/dotnet/roslyn/issues/76130 : consider refining this logic
+ if (extensions.Count != count)
+ {
+ MarkImportDirective(nsOrType.UsingDirectiveReference, callerIsSemanticModel);
+ }
+ }
+ // Tracked by https://github.com/dotnet/roslyn/issues/76130 : clarify expected behavior for `using Extension;` or `using static Extension;`.
+ // If/when we do such a scenario, we have to remove duplicates (see GetCandidateExtensionMethods).
+ }
+ }
+
internal override void LookupSymbolsInSingleBinder(
LookupResult result, string name, int arity, ConsList? basesBeingResolved, LookupOptions options, Binder originalBinder, bool diagnose, ref CompoundUseSiteInfo useSiteInfo)
{
@@ -170,7 +195,7 @@ private static bool IsValidLookupCandidateInUsings(Symbol symbol)
// lookup via "using static" ignores extension methods and non-static methods
case SymbolKind.Method:
- if (!symbol.IsStatic || ((MethodSymbol)symbol).IsExtensionMethod)
+ if (!symbol.IsStatic || ((MethodSymbol)symbol).IsExtensionMethod) // Tracked by https://github.com/dotnet/roslyn/issues/76130: Test this code path with new extensions
{
return false;
}
diff --git a/src/Compilers/CSharp/Portable/BoundTree/BoundExpression.cs b/src/Compilers/CSharp/Portable/BoundTree/BoundExpression.cs
index 9fff5020e041f..06204dd5e723a 100644
--- a/src/Compilers/CSharp/Portable/BoundTree/BoundExpression.cs
+++ b/src/Compilers/CSharp/Portable/BoundTree/BoundExpression.cs
@@ -477,7 +477,7 @@ public override bool SuppressVirtualCalls
public BoundConversion UpdateOperand(BoundExpression operand)
{
- return this.Update(operand: operand, this.Conversion, this.IsBaseConversion, this.Checked, this.ExplicitCastInCode, this.ConstantValueOpt, this.ConversionGroupOpt, this.OriginalUserDefinedConversionsOpt, this.Type);
+ return this.Update(operand: operand, this.Conversion, this.IsBaseConversion, this.Checked, this.ExplicitCastInCode, this.ConstantValueOpt, this.ConversionGroupOpt, this.Type);
}
///
diff --git a/src/Compilers/CSharp/Portable/BoundTree/BoundMethodGroup.cs b/src/Compilers/CSharp/Portable/BoundTree/BoundMethodGroup.cs
index 01b94d33dbbef..f414e204313c2 100644
--- a/src/Compilers/CSharp/Portable/BoundTree/BoundMethodGroup.cs
+++ b/src/Compilers/CSharp/Portable/BoundTree/BoundMethodGroup.cs
@@ -69,11 +69,11 @@ public BoundExpression? InstanceOpt
}
}
- public bool SearchExtensionMethods
+ public bool SearchExtensions
{
get
{
- return (this.Flags & BoundMethodGroupFlags.SearchExtensionMethods) != 0;
+ return (this.Flags & BoundMethodGroupFlags.SearchExtensions) != 0;
}
}
}
diff --git a/src/Compilers/CSharp/Portable/BoundTree/BoundMethodGroupFlags.cs b/src/Compilers/CSharp/Portable/BoundTree/BoundMethodGroupFlags.cs
index 46727e00cee3f..ee1aa490768ca 100644
--- a/src/Compilers/CSharp/Portable/BoundTree/BoundMethodGroupFlags.cs
+++ b/src/Compilers/CSharp/Portable/BoundTree/BoundMethodGroupFlags.cs
@@ -10,7 +10,7 @@ namespace Microsoft.CodeAnalysis.CSharp
internal enum BoundMethodGroupFlags
{
None = 0,
- SearchExtensionMethods = 1,
+ SearchExtensions = 1,
///
/// Set if the group has a receiver but one was not specified in syntax.
diff --git a/src/Compilers/CSharp/Portable/BoundTree/BoundNodes.xml b/src/Compilers/CSharp/Portable/BoundTree/BoundNodes.xml
index 5a227e6297a93..663c321f9aada 100644
--- a/src/Compilers/CSharp/Portable/BoundTree/BoundNodes.xml
+++ b/src/Compilers/CSharp/Portable/BoundTree/BoundNodes.xml
@@ -902,10 +902,6 @@
Conversion is represented by a single BoundConversion.
-->
-
-
-
+
@@ -1121,7 +1117,8 @@
void Foo() { }
-->
-
+
+
@@ -1165,11 +1162,11 @@
-
+
-
+
@@ -1177,11 +1174,11 @@
-
+
-
+
-
+
diff --git a/src/Compilers/CSharp/Portable/BoundTree/BoundTreeRewriter.cs b/src/Compilers/CSharp/Portable/BoundTree/BoundTreeRewriter.cs
index e55fc8af21250..bf47f1f5062bd 100644
--- a/src/Compilers/CSharp/Portable/BoundTree/BoundTreeRewriter.cs
+++ b/src/Compilers/CSharp/Portable/BoundTree/BoundTreeRewriter.cs
@@ -7,6 +7,7 @@
using Microsoft.CodeAnalysis.PooledObjects;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
+using Roslyn.Utilities;
namespace Microsoft.CodeAnalysis.CSharp
{
@@ -59,6 +60,142 @@ private ImmutableArray DoVisitList(ImmutableArray list) where T : Bound
return list;
}
+
+ [return: NotNullIfNotNull(nameof(symbol))]
+ public virtual AliasSymbol? VisitAliasSymbol(AliasSymbol? symbol) => symbol;
+
+ public virtual DiscardSymbol VisitDiscardSymbol(DiscardSymbol symbol)
+ {
+ Debug.Assert(symbol is not null);
+ return symbol;
+ }
+
+ public virtual EventSymbol VisitEventSymbol(EventSymbol symbol)
+ {
+ Debug.Assert(symbol is not null);
+ return symbol;
+ }
+
+ [return: NotNullIfNotNull(nameof(symbol))]
+ public virtual LabelSymbol? VisitLabelSymbol(LabelSymbol? symbol) => symbol;
+
+ public virtual LocalSymbol VisitLocalSymbol(LocalSymbol symbol)
+ {
+ Debug.Assert(symbol is not null);
+ return symbol;
+ }
+
+ public virtual NamespaceSymbol VisitNamespaceSymbol(NamespaceSymbol symbol)
+ {
+ Debug.Assert(symbol is not null);
+ return symbol;
+ }
+
+ [return: NotNullIfNotNull(nameof(symbol))]
+ public virtual RangeVariableSymbol? VisitRangeVariableSymbol(RangeVariableSymbol? symbol) => symbol;
+
+ [return: NotNullIfNotNull(nameof(symbol))]
+ public virtual FieldSymbol? VisitFieldSymbol(FieldSymbol? symbol) => symbol;
+
+ public virtual ParameterSymbol VisitParameterSymbol(ParameterSymbol symbol)
+ {
+ Debug.Assert(symbol is not null);
+ return symbol;
+ }
+
+ [return: NotNullIfNotNull(nameof(symbol))]
+ public virtual PropertySymbol? VisitPropertySymbol(PropertySymbol? symbol) => symbol;
+
+ [return: NotNullIfNotNull(nameof(symbol))]
+ public virtual MethodSymbol? VisitMethodSymbol(MethodSymbol? symbol) => symbol;
+
+ [return: NotNullIfNotNull(nameof(symbol))]
+ public Symbol? VisitSymbol(Symbol? symbol)
+ {
+ if (symbol is null)
+ {
+ return null;
+ }
+
+ switch (symbol.Kind)
+ {
+ case SymbolKind.Alias:
+ return VisitAliasSymbol((AliasSymbol)symbol);
+ case SymbolKind.Discard:
+ return VisitDiscardSymbol((DiscardSymbol)symbol);
+ case SymbolKind.Event:
+ return VisitEventSymbol((EventSymbol)symbol);
+ case SymbolKind.Label:
+ return VisitLabelSymbol((LabelSymbol)symbol);
+ case SymbolKind.Local:
+ return VisitLocalSymbol((LocalSymbol)symbol);
+ case SymbolKind.Namespace:
+ return VisitNamespaceSymbol((NamespaceSymbol)symbol);
+ case SymbolKind.RangeVariable:
+ return VisitRangeVariableSymbol((RangeVariableSymbol)symbol);
+ case SymbolKind.Field:
+ return VisitFieldSymbol((FieldSymbol)symbol);
+ case SymbolKind.Parameter:
+ return VisitParameterSymbol((ParameterSymbol)symbol);
+ case SymbolKind.Property:
+ return VisitPropertySymbol((PropertySymbol)symbol);
+ case SymbolKind.Method:
+ return VisitMethodSymbol((MethodSymbol)symbol);
+
+ default:
+ if (symbol is TypeSymbol type)
+ {
+ return VisitType(type);
+ }
+
+ throw ExceptionUtilities.UnexpectedValue(symbol.Kind);
+ }
+ }
+
+ [return: NotNullIfNotNull(nameof(symbol))]
+ protected FunctionTypeSymbol? VisitFunctionTypeSymbol(FunctionTypeSymbol? symbol)
+ {
+ return (FunctionTypeSymbol?)VisitType(symbol);
+ }
+
+ public ImmutableArray VisitSymbols(ImmutableArray symbols) where T : Symbol?
+ {
+ if (symbols.IsDefault)
+ {
+ return symbols;
+ }
+
+ ArrayBuilder? builder = null;
+
+ for (int i = 0; i < symbols.Length; i++)
+ {
+ T symbol = symbols[i];
+
+ var newSymbol = (T?)VisitSymbol(symbol);
+ if (newSymbol != (object?)symbol)
+ {
+ Debug.Assert(newSymbol is not null);
+
+ if (builder is null)
+ {
+ builder = ArrayBuilder.GetInstance(symbols.Length);
+ builder.AddRange(symbols, i);
+ }
+
+ builder.Add(newSymbol);
+ }
+ else if (builder is not null)
+ {
+ builder.Add(symbol);
+ }
+ }
+
+ return builder is null ? symbols : builder.ToImmutableAndFree();
+ }
+
+ protected virtual ImmutableArray VisitLocals(ImmutableArray locals) => locals;
+
+ protected virtual ImmutableArray VisitDeclaredLocalFunctions(ImmutableArray localFunctions) => localFunctions;
}
internal abstract class BoundTreeRewriterWithStackGuard : BoundTreeRewriter
@@ -112,7 +249,7 @@ protected BoundTreeRewriterWithStackGuardWithoutRecursionOnTheLeftOfBinaryOperat
if (child.Kind != BoundKind.BinaryOperator)
{
- return base.VisitBinaryOperator(node);
+ return node.Update(node.OperatorKind, VisitBinaryOperatorData(node), node.ResultKind, (BoundExpression)this.Visit(node.Left), (BoundExpression)this.Visit(node.Right), this.VisitType(node.Type));
}
var stack = ArrayBuilder.GetInstance();
@@ -142,7 +279,7 @@ protected BoundTreeRewriterWithStackGuardWithoutRecursionOnTheLeftOfBinaryOperat
var right = (BoundExpression?)this.Visit(binary.Right);
Debug.Assert(right is { });
var type = this.VisitType(binary.Type);
- left = binary.Update(binary.OperatorKind, binary.Data, binary.ResultKind, left, right, type);
+ left = binary.Update(binary.OperatorKind, VisitBinaryOperatorData(binary), binary.ResultKind, left, right, type);
}
while (stack.Count > 0);
@@ -152,6 +289,11 @@ protected BoundTreeRewriterWithStackGuardWithoutRecursionOnTheLeftOfBinaryOperat
return left;
}
+ protected virtual BoundBinaryOperator.UncommonData? VisitBinaryOperatorData(BoundBinaryOperator node)
+ {
+ return node.Data;
+ }
+
public sealed override BoundNode? VisitIfStatement(BoundIfStatement node)
{
if (node.AlternativeOpt is not BoundIfStatement ifStatement)
diff --git a/src/Compilers/CSharp/Portable/BoundTree/Constructors.cs b/src/Compilers/CSharp/Portable/BoundTree/Constructors.cs
index 259af1aa8fdf1..3aa692af65ad8 100644
--- a/src/Compilers/CSharp/Portable/BoundTree/Constructors.cs
+++ b/src/Compilers/CSharp/Portable/BoundTree/Constructors.cs
@@ -336,7 +336,6 @@ public static BoundConversion SynthesizedNonUserDefined(SyntaxNode syntax, Bound
explicitCastInCode: false,
conversionGroupOpt: null,
constantValueOpt: constantValueOpt,
- originalUserDefinedConversionsOpt: default,
type: type)
{ WasCompilerGenerated = true };
}
@@ -391,35 +390,9 @@ public BoundConversion(
explicitCastInCode: explicitCastInCode,
constantValueOpt: constantValueOpt,
conversionGroupOpt,
- conversion.OriginalUserDefinedConversions,
type: type,
hasErrors: hasErrors || !conversion.IsValid)
{ }
-
- public BoundConversion(
- SyntaxNode syntax,
- BoundExpression operand,
- Conversion conversion,
- bool isBaseConversion,
- bool @checked,
- bool explicitCastInCode,
- ConstantValue? constantValueOpt,
- ConversionGroup? conversionGroupOpt,
- TypeSymbol type,
- bool hasErrors = false) :
- this(syntax, operand, conversion, isBaseConversion, @checked, explicitCastInCode, constantValueOpt, conversionGroupOpt, originalUserDefinedConversionsOpt: default, type, hasErrors)
- {
- }
-
- public BoundConversion Update(BoundExpression operand,
- Conversion conversion,
- bool isBaseConversion,
- bool @checked,
- bool explicitCastInCode,
- ConstantValue? constantValueOpt,
- ConversionGroup? conversionGroupOpt,
- TypeSymbol type)
- => Update(operand, conversion, isBaseConversion, @checked, explicitCastInCode, constantValueOpt, conversionGroupOpt, this.OriginalUserDefinedConversionsOpt, type);
}
internal sealed partial class BoundBinaryOperator
@@ -512,17 +485,6 @@ public BoundUserDefinedConditionalLogicalOperator(
{
Debug.Assert(operatorKind.IsUserDefined() && operatorKind.IsLogical());
}
-
- public BoundUserDefinedConditionalLogicalOperator Update(BinaryOperatorKind operatorKind,
- MethodSymbol logicalOperator,
- MethodSymbol trueOperator,
- MethodSymbol falseOperator,
- TypeSymbol? constrainedToTypeOpt,
- LookupResultKind resultKind,
- BoundExpression left,
- BoundExpression right,
- TypeSymbol type)
- => Update(operatorKind, logicalOperator, trueOperator, falseOperator, constrainedToTypeOpt, resultKind, this.OriginalUserDefinedOperatorsOpt, left, right, type);
}
internal sealed partial class BoundParameter
@@ -653,7 +615,7 @@ public BoundGotoStatement(SyntaxNode syntax, LabelSymbol label, bool hasErrors =
internal partial class BoundBlock
{
public BoundBlock(SyntaxNode syntax, ImmutableArray locals, ImmutableArray statements, bool hasErrors = false)
- : this(syntax, locals, ImmutableArray.Empty, hasUnsafeModifier: false, instrumentation: null, statements, hasErrors)
+ : this(syntax, locals, ImmutableArray.Empty, hasUnsafeModifier: false, instrumentation: null, statements, hasErrors)
{
}
diff --git a/src/Compilers/CSharp/Portable/BoundTree/UnboundLambda.cs b/src/Compilers/CSharp/Portable/BoundTree/UnboundLambda.cs
index 27d00fddb1c63..b1fba6ed796dc 100644
--- a/src/Compilers/CSharp/Portable/BoundTree/UnboundLambda.cs
+++ b/src/Compilers/CSharp/Portable/BoundTree/UnboundLambda.cs
@@ -819,7 +819,7 @@ private BoundLambda ReallyBind(NamedTypeSymbol delegateType, bool inExpressionTr
refKind == CodeAnalysis.RefKind.None &&
_returnInferenceCache!.TryGetValue(cacheKey, out BoundLambda? returnInferenceLambda) &&
GetLambdaExpressionBody(returnInferenceLambda.Body) is BoundExpression expression &&
- (lambdaSymbol = returnInferenceLambda.Symbol).RefKind == refKind &&
+ (lambdaSymbol = (LambdaSymbol)returnInferenceLambda.Symbol).RefKind == refKind &&
(object)LambdaSymbol.InferenceFailureReturnType != lambdaSymbol.ReturnType &&
lambdaSymbol.ReturnTypeWithAnnotations.Equals(returnType, TypeCompareKind.ConsiderEverything))
{
@@ -1273,7 +1273,7 @@ private BoundLambda ReallyBindForErrorRecovery(
// If multiple candidates have the same number of diagnostics, order them by delegate type name.
// It's not great, but it should be stable.
return minDiagnosticsGroup
- .OrderBy(lambda => GetLambdaSortString(lambda.Value.Symbol))
+ .OrderBy(lambda => GetLambdaSortString((LambdaSymbol)lambda.Value.Symbol))
.FirstOrDefault()
.Value;
}
diff --git a/src/Compilers/CSharp/Portable/CSharpParseOptions.cs b/src/Compilers/CSharp/Portable/CSharpParseOptions.cs
index 8ae7033ac2fd0..650f5b27cf0ad 100644
--- a/src/Compilers/CSharp/Portable/CSharpParseOptions.cs
+++ b/src/Compilers/CSharp/Portable/CSharpParseOptions.cs
@@ -230,6 +230,14 @@ static void addSingleNamespaceParts(ArrayBuilder> namespa
}
}
+ ///
+ /// Used for parsing .cs file-based programs.
+ ///
+ ///
+ /// In this mode, ignored directives #: are allowed.
+ ///
+ internal bool FileBasedProgram => Features.ContainsKey("FileBasedProgram");
+
internal override void ValidateOptions(ArrayBuilder builder)
{
ValidateOptions(builder, MessageProvider.Instance);
diff --git a/src/Compilers/CSharp/Portable/CSharpResources.resx b/src/Compilers/CSharp/Portable/CSharpResources.resx
index bdb7325e53256..611416fe327f8 100644
--- a/src/Compilers/CSharp/Portable/CSharpResources.resx
+++ b/src/Compilers/CSharp/Portable/CSharpResources.resx
@@ -1171,7 +1171,7 @@
Cannot implicitly convert type '{0}' to '{1}'. An explicit conversion exists (are you missing a cast?)
- The 'partial' modifier can only appear immediately before 'class', 'record', 'struct', 'interface', or a method or property return type.
+ The 'partial' modifier can only appear immediately before 'class', 'record', 'struct', 'interface', 'event', an instance constructor name, or a method or property return type.Imported type '{0}' is invalid. It contains a circular base type dependency.
@@ -2543,7 +2543,7 @@ A catch() block after a catch (System.Exception e) block can catch non-CLS excep
Extension methods must be defined in a top level static class; {0} is a nested class
- Cannot define a new extension method because the compiler required type '{0}' cannot be found. Are you missing a reference to System.Core.dll?
+ Cannot define a new extension because the compiler required type '{0}' cannot be found. Are you missing a reference to System.Core.dll?Do not use 'System.Runtime.CompilerServices.ExtensionAttribute'. Use the 'this' keyword instead.
@@ -2600,7 +2600,7 @@ A catch() block after a catch (System.Exception e) block can catch non-CLS excep
Invalid preprocessor expression
- Invalid token '{0}' in class, record, struct, or interface member declaration
+ Invalid token '{0}' in a member declarationMethod must have a return type
@@ -6900,10 +6900,10 @@ To remove the warning, you can use /reference instead (set the Embed Interop Typ
The loaded assembly references .NET Framework, which is not supported.
- The analyzer assembly '{0}' references version '{1}' of the compiler, which is newer than the currently running version '{2}'.
+ Analyzer assembly '{0}' cannot be used because it references version '{1}' of the compiler, which is newer than the currently running version '{2}'.
- The analyzer assembly references a newer version of the compiler than the currently running version.
+ Analyzer assembly cannot be used because it references a newer version of the compiler than the currently running version.The type '{0}' may not be used for a field of a record.
@@ -7483,7 +7483,7 @@ To remove the warning, you can use /reference instead (set the Embed Interop Typ
file types
- Cannot use a numeric constant or relational pattern on '{0}' because it inherits from or extends 'INumberBase<T>'. Consider using a type pattern to narrow to a specifc numeric type.
+ Cannot use a numeric constant or relational pattern on '{0}' because it inherits from or extends 'INumberBase<T>'. Consider using a type pattern to narrow to a specific numeric type.array access
@@ -7983,14 +7983,14 @@ To remove the warning, you can use /reference instead (set the Embed Interop Typ
Property accessor '{0}' must be '{1}' to match the definition part
-
- Both partial property declarations must have the same type.
+
+ Both partial member declarations must have the same type.
-
- Partial property declarations '{0}' and '{1}' have signature differences.
+
+ Partial member declarations '{0}' and '{1}' have signature differences.
-
- Partial property declarations have signature differences.
+
+ Partial member declarations have signature differences.Both partial property declarations must be required or neither may be required
@@ -8014,11 +8014,11 @@ To remove the warning, you can use /reference instead (set the Embed Interop Typ
Attribute 'System.Runtime.CompilerServices.InlineArray' cannot be applied to a record struct.
- Non-nullable {0} '{1}' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier, or declaring the {0} as nullable, or adding '[field: MaybeNull, AllowNull]' attributes.
+ Non-nullable {0} '{1}' must contain a non-null value when exiting constructor. Consider adding the 'required' modifier, or declaring the {0} as nullable, or safely handling the case where 'field' is null in the 'get' accessor.Similar diagnostic message as 'WRN_UninitializedNonNullableField'
- Non-nullable property must contain a non-null value when exiting constructor. Consider adding the 'required' modifier, or declaring the property as nullable, or adding '[field: MaybeNull, AllowNull]' attributes.
+ Non-nullable property must contain a non-null value when exiting constructor. Consider adding the 'required' modifier, or declaring the property as nullable, or safely handling the case where 'field' is null in the 'get' accessor.first-class Span types
@@ -8050,4 +8050,88 @@ To remove the warning, you can use /reference instead (set the Embed Interop Typ
Cannot emit this string literal into the data section because it has XXHash128 collision with another string literal: {0}
+
+ partial events and constructors
+
+
+ Partial member '{0}' must have an implementation part.
+
+
+ Partial member '{0}' must have a definition part.
+
+
+ Partial member '{0}' may not have multiple defining declarations.
+
+
+ Partial member '{0}' may not have multiple implementing declarations.
+
+
+ '{0}': partial event cannot have initializer
+
+
+ '{0}': only the implementing declaration of a partial constructor can have an initializer
+
+
+ null conditional assignment
+
+
+ extensions
+
+
+ Extension declarations may not have a name.
+
+
+ Extension declarations can include only methods or properties
+
+
+ Extensions must be declared in a top-level, non-generic, static class
+
+
+ The receiver parameter of an extension cannot have a default value
+
+
+ An extension container can have only one receiver parameter
+
+
+ '{0}' does not contain a definition for '{1}' and no accessible extension member '{1}' for receiver of type '{0}' could be found (are you missing a using directive or an assembly reference?)
+
+
+ '{0}': a receiver parameter cannot have the same name as an extension container type parameter
+
+
+ '{0}': a parameter, local variable, or local function cannot have the same name as an extension container type parameter
+
+
+ Type parameter '{0}' has the same name as an extension container type parameter
+
+
+ '{0}': a parameter, local variable, or local function cannot have the same name as an extension parameter
+
+
+ 'value': an automatically-generated parameter name conflicts with an extension parameter name
+
+
+ Type parameter '{0}' has the same name as an extension parameter
+
+
+ Cannot use extension parameter '{0}' in this context.
+
+
+ 'value': an automatically-generated parameter name conflicts with an extension type parameter name
+
+
+ The extended type '{0}' must reference all the type parameters declared by the extension, but type parameter '{1}' is not referenced.
+
+
+ An expression tree may not contain an extension property access
+
+
+ '#:' directives cannot be after first token in file
+
+
+ '#:' directives can be only used in file-based programs ('/feature:FileBasedProgram')
+
+
+ '#:' directives cannot be after '#if' directive
+
diff --git a/src/Compilers/CSharp/Portable/CodeGen/EmitExpression.cs b/src/Compilers/CSharp/Portable/CodeGen/EmitExpression.cs
index 26f9586b15fc1..0b8cfbc2f54b7 100644
--- a/src/Compilers/CSharp/Portable/CodeGen/EmitExpression.cs
+++ b/src/Compilers/CSharp/Portable/CodeGen/EmitExpression.cs
@@ -596,7 +596,7 @@ private void EmitLoweredConditionalAccessExpression(BoundLoweredConditionalAcces
///
/// We must use a temp when there is a chance that evaluation of the call arguments
- /// could actually modify value of the reference type reciever. The call must use
+ /// could actually modify value of the reference type receiver. The call must use
/// the original (unmodified) receiver.
///
private sealed class IsConditionalConstrainedCallThatMustUseTempForReferenceTypeReceiverWalker : BoundTreeWalkerWithStackGuardWithoutRecursionOnTheLeftOfBinaryOperator
@@ -3588,7 +3588,7 @@ private void EmitParameterIdExpression(BoundParameterId node)
if (node.HoistedField is null)
{
- _builder.EmitIntConstant(node.Parameter.Ordinal);
+ _builder.EmitIntConstant(node.Parameter.Ordinal); // Tracked by https://github.com/dotnet/roslyn/issues/76130 : Follow up
}
else
{
diff --git a/src/Compilers/CSharp/Portable/Compilation/CSharpSemanticModel.cs b/src/Compilers/CSharp/Portable/Compilation/CSharpSemanticModel.cs
index 49c2ebda77ec0..4aa31399de20c 100644
--- a/src/Compilers/CSharp/Portable/Compilation/CSharpSemanticModel.cs
+++ b/src/Compilers/CSharp/Portable/Compilation/CSharpSemanticModel.cs
@@ -1399,7 +1399,7 @@ private void CheckModelAndSyntaxNodeToSpeculate(CSharpSyntaxNode syntax)
/// scope around position is used.
/// The name of the symbol to find. If null is specified then symbols
/// with any names are returned.
- /// Consider (reduced) extension methods.
+ /// Consider extension members. Classic extension methods will be returned in reduced form.
/// A list of symbols that were found. If no symbols were found, an empty list is returned.
///
/// The "position" is used to determine what variables are visible and accessible. Even if "container" is
@@ -1408,15 +1408,15 @@ private void CheckModelAndSyntaxNodeToSpeculate(CSharpSyntaxNode syntax)
///
/// Labels are not considered (see ).
///
- /// Non-reduced extension methods are considered regardless of the value of .
+ /// Non-reduced extension methods are considered regardless of the value of .
///
public ImmutableArray LookupSymbols(
int position,
NamespaceOrTypeSymbol container = null,
string name = null,
- bool includeReducedExtensionMethods = false)
+ bool includeExtensions = false)
{
- var options = includeReducedExtensionMethods ? LookupOptions.IncludeExtensionMethods : LookupOptions.Default;
+ var options = includeExtensions ? LookupOptions.IncludeExtensionMembers : LookupOptions.Default;
return LookupSymbolsInternal(position, container, name, options, useBaseReferenceAccessibility: false);
}
@@ -1576,7 +1576,7 @@ private ImmutableArray LookupSymbolsInternal(
if ((object)container == null || container.Kind == SymbolKind.Namespace)
{
- options &= ~LookupOptions.IncludeExtensionMethods;
+ options &= ~LookupOptions.IncludeExtensionMembers;
}
var binder = GetEnclosingBinder(position);
@@ -1652,25 +1652,33 @@ private ImmutableArray LookupSymbolsInternal(
info.Free();
- if ((options & LookupOptions.IncludeExtensionMethods) != 0)
+ if ((options & LookupOptions.IncludeExtensionMembers) != 0 && container is TypeSymbol receiverType)
{
var lookupResult = LookupResult.GetInstance();
options |= LookupOptions.AllMethodsOnArityZero;
options &= ~LookupOptions.MustBeInstance;
- var discardedUseSiteInfo = CompoundUseSiteInfo.Discarded;
- binder.LookupExtensionMethods(lookupResult, name, 0, options, ref discardedUseSiteInfo);
+ binder.LookupAllExtensions(lookupResult, name, options);
if (lookupResult.IsMultiViable)
{
- TypeSymbol containingType = (TypeSymbol)container;
- foreach (MethodSymbol extensionMethod in lookupResult.Symbols)
+ foreach (Symbol symbol in lookupResult.Symbols)
{
- var reduced = extensionMethod.ReduceExtensionMethod(containingType, Compilation);
- if ((object)reduced != null)
+ if (symbol is MethodSymbol { IsExtensionMethod: true } extensionMethod)
+ {
+ if (extensionMethod.ReduceExtensionMethod(receiverType, Compilation) is { } reduced)
+ {
+ results.Add(reduced.GetPublicSymbol());
+ }
+ }
+ else
{
- results.Add(reduced.GetPublicSymbol());
+ Debug.Assert(symbol.GetIsNewExtensionMember());
+ if (SourceNamedTypeSymbol.GetCompatibleSubstitutedMember(binder.Compilation, symbol, receiverType) is { } compatibleSubstitutedMember)
+ {
+ results.Add(compatibleSubstitutedMember.GetPublicSymbol());
+ }
}
}
}
@@ -1739,7 +1747,7 @@ private void AppendSymbolsWithNameAndArity(
name,
arity,
basesBeingResolved: null,
- options: options & ~LookupOptions.IncludeExtensionMethods,
+ options: options & ~LookupOptions.IncludeExtensionMembers,
diagnose: false,
useSiteInfo: ref discardedUseSiteInfo);
@@ -3361,6 +3369,7 @@ private OneOrMany GetSemanticSymbols(
case BoundKind.PropertyGroup:
symbols = GetPropertyGroupSemanticSymbols((BoundPropertyGroup)boundNode, boundNodeForSyntacticParent, binderOpt, out resultKind, out memberGroup);
break;
+ // Tracked by https://github.com/dotnet/roslyn/issues/76130 : handle BoundPropertyAccess (which now may have a member group)
case BoundKind.BadExpression:
{
@@ -3446,7 +3455,7 @@ private OneOrMany GetSemanticSymbols(
}
else
{
- symbols = StaticCast.From(CreateReducedExtensionMethodsFromOriginalsIfNecessary(call, Compilation));
+ symbols = CreateReducedAndFilteredSymbolsFromOriginals(call, Compilation);
resultKind = call.ResultKind;
}
}
@@ -3470,7 +3479,7 @@ private OneOrMany GetSemanticSymbols(
// group result in the call below.
symbols = GetMethodGroupSemanticSymbols(
((BoundUnconvertedAddressOfOperator)boundNode).Operand,
- boundNodeForSyntacticParent, binderOpt, out resultKind, out isDynamic, methodGroup: out _);
+ boundNodeForSyntacticParent, binderOpt, out resultKind, out isDynamic, memberGroup: out _);
break;
}
@@ -3534,7 +3543,7 @@ boundNode.ExpressionSymbol is Symbol accessSymbol &&
}
else if (conversion.ConversionKind.IsUserDefinedConversion())
{
- GetSymbolsAndResultKind(conversion, conversion.SymbolOpt, conversion.OriginalUserDefinedConversionsOpt, out symbols, out resultKind);
+ GetSymbolsAndResultKind(conversion, conversion.SymbolOpt, conversion.Conversion.OriginalUserDefinedConversions, out symbols, out resultKind);
}
else
{
@@ -4235,7 +4244,7 @@ private OneOrMany GetMethodGroupSemanticSymbols(
Binder binderOpt,
out LookupResultKind resultKind,
out bool isDynamic,
- out ImmutableArray methodGroup)
+ out ImmutableArray memberGroup)
{
Debug.Assert(binderOpt != null || IsInTree(boundNode.Syntax));
@@ -4251,7 +4260,7 @@ private OneOrMany GetMethodGroupSemanticSymbols(
// The method group needs filtering.
Binder binder = binderOpt ?? GetEnclosingBinder(GetAdjustedNodePosition(boundNode.Syntax));
- methodGroup = GetReducedAndFilteredMethodGroupSymbols(binder, boundNode).Cast();
+ memberGroup = GetReducedAndFilteredMethodGroupSymbols(binder, boundNode);
// We want to get the actual node chosen by overload resolution, if possible.
if (boundNodeForSyntacticParent != null)
@@ -4274,7 +4283,7 @@ private OneOrMany GetMethodGroupSemanticSymbols(
else
{
resultKind = call.ResultKind.WorseResultKind(LookupResultKind.OverloadResolutionFailure);
- symbols = StaticCast.From(CreateReducedExtensionMethodsFromOriginalsIfNecessary(call, Compilation));
+ symbols = CreateReducedAndFilteredSymbolsFromOriginals(call, Compilation);
}
}
break;
@@ -4329,7 +4338,7 @@ private OneOrMany GetMethodGroupSemanticSymbols(
case BoundKind.BadExpression:
// If the bad expression has symbol(s) from this method group, it better indicates any problems.
- ImmutableArray myMethodGroup = methodGroup;
+ ImmutableArray myMethodGroup = memberGroup;
symbols = OneOrMany.Create(((BoundBadExpression)boundNodeForSyntacticParent).Symbols.WhereAsArray((sym, myMethodGroup) => myMethodGroup.Contains(sym), myMethodGroup));
if (symbols.Any())
@@ -4339,12 +4348,12 @@ private OneOrMany GetMethodGroupSemanticSymbols(
break;
case BoundKind.NameOfOperator:
- symbols = OneOrMany.Create(methodGroup);
+ symbols = OneOrMany.Create(memberGroup);
resultKind = resultKind.WorseResultKind(LookupResultKind.MemberGroup);
break;
default:
- symbols = OneOrMany.Create(methodGroup);
+ symbols = OneOrMany.Create(memberGroup);
if (symbols.Count > 0)
{
resultKind = resultKind.WorseResultKind(LookupResultKind.OverloadResolutionFailure);
@@ -4352,14 +4361,14 @@ private OneOrMany GetMethodGroupSemanticSymbols(
break;
}
}
- else if (methodGroup.Length == 1 && !boundNode.HasAnyErrors)
+ else if (memberGroup.Length == 1 && !boundNode.HasAnyErrors)
{
// During speculative binding, there won't be a parent bound node. The parent bound
// node may also be absent if the syntactic parent has errors or if one is simply
// not specified (see SemanticModel.GetSymbolInfoForNode). However, if there's exactly
// one candidate, then we should probably succeed.
- symbols = OneOrMany.Create(methodGroup);
+ symbols = OneOrMany.Create(memberGroup);
if (symbols.Count > 0)
{
resultKind = resultKind.WorseResultKind(LookupResultKind.OverloadResolutionFailure);
@@ -4371,7 +4380,7 @@ private OneOrMany GetMethodGroupSemanticSymbols(
// If we didn't find a better set of symbols, then assume this is a method group that didn't
// get resolved. Return all members of the method group, with a resultKind of OverloadResolutionFailure
// (unless the method group already has a worse result kind).
- symbols = OneOrMany.Create(methodGroup);
+ symbols = OneOrMany.Create(memberGroup);
if (!isDynamic && resultKind > LookupResultKind.OverloadResolutionFailure)
{
resultKind = LookupResultKind.OverloadResolutionFailure;
@@ -4558,10 +4567,10 @@ private static ParameterSymbol FindNamedParameter(ImmutableArray GetReducedAndFilteredMethodGroupSymbols(Binder binder, BoundMethodGroup node)
+ internal static ImmutableArray GetReducedAndFilteredMethodGroupSymbols(Binder binder, BoundMethodGroup node)
{
- var methods = ArrayBuilder.GetInstance();
- var filteredMethods = ArrayBuilder.GetInstance();
+ var members = ArrayBuilder.GetInstance();
+ var filteredMembers = ArrayBuilder.GetInstance();
var resultKind = LookupResultKind.Empty;
var typeArguments = node.TypeArgumentsOpt;
@@ -4576,12 +4585,12 @@ internal static ImmutableArray GetReducedAndFilteredMethodGroupSym
foreach (var method in nonHiddenMethods)
{
- MergeReducedAndFilteredMethodGroupSymbol(
- methods,
- filteredMethods,
+ MergeReducedAndFilteredSymbol(
+ members,
+ filteredMembers,
new SingleLookupResult(node.ResultKind, method, node.LookupError),
typeArguments,
- null,
+ receiverType: null,
ref resultKind,
binder.Compilation);
}
@@ -4591,12 +4600,12 @@ internal static ImmutableArray