diff --git a/.github/policies/resourceManagement.yml b/.github/policies/resourceManagement.yml
index a2e463c345e88..9d054bd460d2d 100644
--- a/.github/policies/resourceManagement.yml
+++ b/.github/policies/resourceManagement.yml
@@ -8,6 +8,7 @@ where:
configuration:
resourceManagementConfiguration:
scheduledSearches:
+
- description: Close "Need More Info" Issues
frequencies:
- hourly:
@@ -23,8 +24,12 @@ configuration:
- closeIssue
- addReply:
reply: "Closing this issue as we've seen no reply to the request for more information. If you are able to get the requested information, please add it to the issue and we will retriage it. "
+
eventResponderTasks:
- - if:
+
+ - description: Auto-approve auto-merge PRs
+ triggerOnOwnActions: false
+ if:
- payloadType: Pull_Request
- isPullRequest
- labelAdded:
@@ -38,9 +43,10 @@ configuration:
then:
- approvePullRequest:
comment: Auto-approval
- description: Auto-approve auto-merge PRs
+
+ - description: Auto-approve maestro PRs
triggerOnOwnActions: false
- - if:
+ if:
- payloadType: Pull_Request
- isPullRequest
- isActivitySender:
@@ -55,9 +61,10 @@ configuration:
then:
- approvePullRequest:
comment: Auto-approve
- description: Auto-approve maestro PRs
- triggerOnOwnActions: false
- - if:
+
+ - description: Milestone tracking
+ triggerOnOwnActions: true
+ if:
- payloadType: Pull_Request
- isPullRequest
- or:
@@ -72,9 +79,10 @@ configuration:
then:
- addMilestone:
milestone: Next
- description: Milestone tracking
- triggerOnOwnActions: true
- - if:
+
+ - description: Auto-approve OneLoc PRs
+ triggerOnOwnActions: false
+ if:
- payloadType: Pull_Request
- isPullRequest
- isActivitySender:
@@ -88,9 +96,10 @@ configuration:
then:
- addLabel:
label: auto-merge
- description: Auto-approve OneLoc PRs
+
+ - description: Remove "Need More Info" on comment
triggerOnOwnActions: false
- - if:
+ if:
- payloadType: Issue_Comment
- isIssue
- isOpen
@@ -101,9 +110,10 @@ configuration:
label: untriaged
- removeLabel:
label: Need More Info
- description: Remove "Need More Info" on comment
+
+ - description: Label Community Pull Requests
triggerOnOwnActions: false
- - if:
+ if:
- payloadType: Pull_Request
- isPullRequest
- isAction:
@@ -142,13 +152,45 @@ configuration:
then:
- addLabel:
label: Community
- description: Label Community Pull Requests
+
+ - description: Adds "VSCode" tag on PRs which may affect C# extension.
+ triggerOnOwnActions: false
+ if:
+ - payloadType: Pull_Request
+ - isPullRequest
+ - filesMatchPattern:
+ pattern: 'src/(Analyzers|CodeStyle|Features|LanguageServer|Workspaces)/.*\.(cs|vb)$'
+ matchAny: true
+ - and:
+ - not:
+ isActivitySender:
+ user: dotnet-bot
+ issueAuthor: False
+ - not:
+ isActivitySender:
+ user: github-actions
+ issueAuthor: False
+ - or:
+ - isAction:
+ action: Opened
+ - isAction:
+ action: Synchronize
+ - and:
+ - not:
+ hasLabel:
+ label: VSCode
+ then:
+ - addLabel:
+ label: VSCode
+
+ - description: Add "Needs UX Triage" on PRs
triggerOnOwnActions: false
- - if:
+ if:
- payloadType: Pull_Request
- isPullRequest
- filesMatchPattern:
- pattern: '[xX][aA][mM][lL]$'
+ pattern: '.*\.[xX][aA][mM][lL]$'
+ matchAny: true
- and:
- not:
hasLabel:
@@ -187,12 +229,15 @@ configuration:
then:
- addLabel:
label: Needs UX Triage
- description: Add "Needs UX Triage" on PRs
+
+ - description: Adds "Needs API Review" on PRs that touch public APIs
triggerOnOwnActions: false
- - if:
+ if:
- payloadType: Pull_Request
+ - isPullRequest
- filesMatchPattern:
- pattern: .*/PublicAPI\.(Shipped|Unshipped)\.txt
+ pattern: '.*/PublicAPI\.(Shipped|Unshipped)\.txt'
+ matchAny: true
- not:
isActivitySender:
user: dotnet-bot
@@ -214,9 +259,10 @@ configuration:
label: Needs API Review
- addReply:
reply: This PR modifies public API files. Please follow the instructions at https://github.com/dotnet/roslyn/blob/main/docs/contributing/API%20Review%20Process.md for ensuring all public APIs are reviewed before merging.
- description: Adds "Needs API Review" on PRs that touch public APIs
+
+ - description: Close automatically generated PR tagger issues
triggerOnOwnActions: false
- - if:
+ if:
- payloadType: Issues
- isIssue
- hasLabel:
@@ -226,7 +272,6 @@ configuration:
isRegex: False
then:
- closeIssue
- description: Close automatically generated PR tagger issues
- triggerOnOwnActions: false
+
onFailure:
onSuccess:
diff --git a/.gitignore b/.gitignore
index bf020ffa52ad3..496f18e070dfe 100644
--- a/.gitignore
+++ b/.gitignore
@@ -22,6 +22,7 @@
.packages/
.nuget/
.complog/
+/MSBuild_Logs/
# Enable "build/" folder in the NuGet Packages folder since NuGet packages use it for MSBuild targets
!packages/*/build/
diff --git a/.vscode/settings.json b/.vscode/settings.json
index 2b4dc7d689aeb..17ea7c3b29a62 100644
--- a/.vscode/settings.json
+++ b/.vscode/settings.json
@@ -35,5 +35,13 @@
"azure-pipelines.customSchemaFile": ".vscode/dnceng-schema.json",
"dotnet.defaultSolution": "Roslyn.sln",
"dotnet.completion.showCompletionItemsFromUnimportedNamespaces": true,
- "dotnet.testWindow.disableAutoDiscovery": true
+ "dotnet.testWindow.disableAutoDiscovery": true,
+ "dotnet.testWindow.disableBuildOnRefresh": true,
+ "cSpell.words": [
+ "Nerdbank",
+ "NETCOREAPP",
+ "Unregistration",
+ "Unregistrations",
+ "Xunit"
+ ]
}
diff --git a/.vscode/tasks.json b/.vscode/tasks.json
index 73dd695a2e492..a16eb6aa6b04a 100644
--- a/.vscode/tasks.json
+++ b/.vscode/tasks.json
@@ -49,6 +49,7 @@
"msbuild",
"-p:RunAnalyzersDuringBuild=false",
"-p:GenerateFullPaths=true",
+ "-tl:off",
"src/Compilers/CSharp/csc/AnyCpu/csc.csproj"
],
"problemMatcher": "$msCompile",
@@ -62,6 +63,7 @@
"build",
"-p:RunAnalyzersDuringBuild=false",
"-p:GenerateFullPaths=true",
+ "-tl:off",
"Compilers.slnf"
],
"problemMatcher": "$msCompile",
@@ -75,6 +77,7 @@
"build",
"-p:RunAnalyzersDuringBuild=false",
"-p:GenerateFullPaths=true",
+ "-tl:off",
"Roslyn.sln"
],
"problemMatcher": "$msCompile",
@@ -145,7 +148,7 @@
"build",
"-c",
"Debug",
- "src/Features/LanguageServer/Microsoft.CodeAnalysis.LanguageServer/Microsoft.CodeAnalysis.LanguageServer.csproj"
+ "src/LanguageServer/Microsoft.CodeAnalysis.LanguageServer/Microsoft.CodeAnalysis.LanguageServer.csproj"
],
"problemMatcher": "$msCompile",
"group": "build"
diff --git a/Directory.Build.rsp b/Directory.Build.rsp
index 37bf61d3487f8..d2d2d1d2f4e8e 100644
--- a/Directory.Build.rsp
+++ b/Directory.Build.rsp
@@ -1,2 +1 @@
-# Workaround for https://github.com/dotnet/sdk/issues/41791
--p:_IsDisjointMSBuildVersion=false
+# This file intentionally left blank to avoid accidental import during build.
diff --git a/README.md b/README.md
index 8210dcff68ea6..ca941c7038165 100644
--- a/README.md
+++ b/README.md
@@ -4,7 +4,7 @@
The .NET Compiler Platform
-

+
Roslyn is the open-source implementation of both the C# and Visual Basic compilers with an API surface for building code analysis tools.
@@ -32,7 +32,7 @@ If you are interested in fixing issues and contributing directly to the code bas
The Roslyn community can be found on [GitHub Discussions](https://github.com/dotnet/roslyn/discussions), where you can ask questions, voice ideas, and share your projects.
-To chat with other community members, you can join the Roslyn [Discord](https://discord.com/invite/tGJvv88) or [Gitter](https://gitter.im/dotnet/roslyn).
+To chat with other community members, you can join the Roslyn channel on the [CSharp Community Discord](https://discord.com/invite/tGJvv88).
Our [Code of Conduct](CODE-OF-CONDUCT.md) applies to all Roslyn community channels and has adopted the [.NET Foundation Code of Conduct](https://dotnetfoundation.org/code-of-conduct).
@@ -55,39 +55,34 @@ Visit [Roslyn Architecture Overview](https://docs.microsoft.com/en-us/dotnet/csh
|Branch|Windows Debug|Windows Release|Unix Debug|
|:--:|:--:|:--:|:--:|
**main**|[](https://dev.azure.com/dnceng-public/public/_build/latest?definitionId=95&branchname=main&view=logs)|[](https://dev.azure.com/dnceng-public/public/_build/latest?definitionId=95&branchname=main&view=logs)|[](https://dev.azure.com/dnceng-public/public/_build/latest?definitionId=95&branchname=main&view=logs)|
-**main-vs-deps**|[](https://dev.azure.com/dnceng-public/public/_build/latest?definitionId=95&branchname=main-vs-deps&view=logs)|[](https://dev.azure.com/dnceng-public/public/_build/latest?definitionId=95&branchname=main-vs-deps&view=logs)|[](https://dev.azure.com/dnceng-public/public/_build/latest?definitionId=95&branchname=main-vs-deps&view=logs)|
#### Desktop Unit Tests
|Branch|Debug x86|Debug x64|Release x86|Release x64|
|:--:|:--:|:--:|:--:|:--:|
**main**|[](https://dev.azure.com/dnceng-public/public/_build/latest?definitionId=95&branchname=main&view=logs)|[](https://dev.azure.com/dnceng-public/public/_build/latest?definitionId=95&branchname=main&view=logs)|[](https://dev.azure.com/dnceng-public/public/_build/latest?definitionId=95&branchname=main&view=logs)|[](https://dev.azure.com/dnceng-public/public/_build/latest?definitionId=95&branchname=main&view=logs)|
-**main-vs-deps**|[](https://dev.azure.com/dnceng-public/public/_build/latest?definitionId=95&branchname=main-vs-deps&view=logs)|[](https://dev.azure.com/dnceng-public/public/_build/latest?definitionId=95&branchname=main-vs-deps&view=logs)|[](https://dev.azure.com/dnceng-public/public/_build/latest?definitionId=95&branchname=main-vs-deps&view=logs)|[](https://dev.azure.com/dnceng-public/public/_build/latest?definitionId=95&branchname=main-vs-deps&view=logs)|
#### CoreClr Unit Tests
|Branch|Windows Debug|Windows Release|Linux|
|:--:|:--:|:--:|:--:|
**main**|[](https://dev.azure.com/dnceng-public/public/_build/latest?definitionId=95&branchname=main&view=logs)|[](https://dev.azure.com/dnceng-public/public/_build/latest?definitionId=95&branchname=main&view=logs)|[](https://dev.azure.com/dnceng-public/public/_build/latest?definitionId=95&branchname=main&view=logs)|
-**main-vs-deps**|[](https://dev.azure.com/dnceng-public/public/_build/latest?definitionId=95&branchname=main-vs-deps&view=logs)|[](https://dev.azure.com/dnceng-public/public/_build/latest?definitionId=95&branchname=main-vs-deps&view=logs)|[](https://dev.azure.com/dnceng-public/public/_build/latest?definitionId=95&branchname=main-vs-deps&view=logs)|
#### Integration Tests
|Branch|Debug x86|Debug x64|Release x86|Release x64
|:--:|:--:|:--:|:--:|:--:|
**main**|[](https://dev.azure.com/dnceng-public/public/_build/latest?definitionId=96&branchname=main&view=logs)|[](https://dev.azure.com/dnceng-public/public/_build/latest?definitionId=96&branchname=main&view=logs)|[](https://dev.azure.com/dnceng-public/public/_build/latest?definitionId=96&branchname=main&view=logs)|[](https://dev.azure.com/dnceng-public/public/_build/latest?definitionId=96&branchname=main&view=logs)|
-**main-vs-deps**|[](https://dev.azure.com/dnceng-public/public/_build/latest?definitionId=96&branchname=main-vs-deps&view=logs)|[](https://dev.azure.com/dnceng-public/public/_build/latest?definitionId=96&branchname=main-vs-deps&view=logs)|[](https://dev.azure.com/dnceng-public/public/_build/latest?definitionId=96&branchname=main-vs-deps&view=logs)|[](https://dev.azure.com/dnceng-public/public/_build/latest?definitionId=96&branchname=main-vs-deps&view=logs)|
#### Misc Tests
|Branch|Determinism|Analyzers|Build Correctness|Source build|TODO/Prototype|Spanish|MacOS|
|:--:|:--:|:--:|:--:|:--:|:--:|:--:|:--:|
**main**|[](https://dev.azure.com/dnceng-public/public/_build/latest?definitionId=95&branchname=main&view=logs)|[](https://dev.azure.com/dnceng-public/public/_build/latest?definitionId=95&branchname=main&view=logs)|[](https://dev.azure.com/dnceng-public/public/_build/latest?definitionId=95&branchname=main&view=logs)|[&configuration=Source-Build+(Managed)&label=build)](https://dev.azure.com/dnceng-public/public/_build/latest?definitionId=95&branchname=main&view=logs)|[](https://dev.azure.com/dnceng-public/public/_build/latest?definitionId=95&branchname=main&view=logs)|[](https://dev.azure.com/dnceng-public/public/_build/latest?definitionId=95&branchname=main&view=logs)|[](https://dev.azure.com/dnceng-public/public/_build/latest?definitionId=95&branchname=main&view=logs)|
-**main-vs-deps**|[](https://dev.azure.com/dnceng-public/public/_build/latest?definitionId=95&branchname=main-vs-deps&view=logs)|[](https://dev.azure.com/dnceng-public/public/_build/latest?definitionId=95&branchname=main-vs-deps&view=logs)|[](https://dev.azure.com/dnceng-public/public/_build/latest?definitionId=95&branchname=main-vs-deps&view=logs)|[&configuration=Source-Build+(Managed)&label=build)](https://dev.azure.com/dnceng-public/public/_build/latest?definitionId=95&branchname=main-vs-deps&view=logs)|[](https://dev.azure.com/dnceng-public/public/_build/latest?definitionId=95&branchname=main-vs-deps&view=logs)|[](https://dev.azure.com/dnceng-public/public/_build/latest?definitionId=95&branchname=main-vs-deps&view=logs)|[](https://dev.azure.com/dnceng-public/public/_build/latest?definitionId=95&branchname=main-vs-deps&view=logs)|
+
[//]: # (End current test results)
### .NET Foundation
-This project is part of the [.NET Foundation](http://www.dotnetfoundation.org/projects) along with other
-projects like [the .NET Runtime](https://github.com/dotnet/runtime/).
+This project is part of the [.NET Foundation](http://www.dotnetfoundation.org/projects) along with other projects like [the .NET Runtime](https://github.com/dotnet/runtime/).
diff --git a/azure-pipelines-integration-dartlab.yml b/azure-pipelines-integration-dartlab.yml
index 1f6926648b39f..cad48a4dc4438 100644
--- a/azure-pipelines-integration-dartlab.yml
+++ b/azure-pipelines-integration-dartlab.yml
@@ -24,6 +24,14 @@ resources:
trigger:
- main
+parameters:
+ - name: prNumber
+ type: string
+ default: ''
+ - name: sha
+ type: string
+ default: ''
+
variables:
- name: XUNIT_LOGS
value: $(Build.SourcesDirectory)\artifacts\log\$(_configuration)
@@ -33,8 +41,22 @@ variables:
value: true
stages:
+- ${{ if ne(parameters.prNumber, '') }}:
+ - stage: GitHubCommentFirst
+ jobs:
+ - job: GitHubCommentFirstJob
+ steps:
+ - checkout: none
+ - task: GitHubComment@0
+ inputs:
+ gitHubConnection: 'dotnet-comment-bot-service-connection'
+ repositoryName: '$(Build.Repository.Name)'
+ id: ${{ parameters.prNumber }}
+ comment: 'Started DartLab pipeline [run]($(System.TeamFoundationCollectionUri)$(System.TeamProject)/_build/results?buildId=$(Build.BuildId)) for ${{ parameters.sha }}'
+
- template: \stages\visual-studio\agent.yml@DartLabTemplates
parameters:
+ name: VSIntegration
displayName: VS Integration
testLabPoolName: VS-Platform
visualStudioBootstrapperURI: https://vsdrop.corp.microsoft.com/file/v1/$(VisualStudio.BuildUnderTest.ProductsDropName);bootstrappers/Enterprise/vs_enterprise.exe
@@ -67,9 +89,37 @@ stages:
arguments: -DropNamePrefix 'Products' -VstsDropUrlsJson '$(Pipeline.Workspace)\VisualStudioBuildUnderTest\BuildArtifacts\VstsDropUrls.json' -OutVariableName 'VisualStudio.BuildUnderTest.ProductsDropName'
deployAndRunTestsStepList:
- checkout: RoslynMirror
+ fetchDepth: 1
+ fetchTags: false
- template: eng/pipelines/test-integration-job.yml
parameters:
configuration: $(_configuration)
oop64bit: $(_oop64bit)
lspEditor: false
skipCheckout: true
+
+- ${{ if ne(parameters.prNumber, '') }}:
+ - stage: GitHubCommentCompleted
+ condition: always()
+ dependsOn: VSIntegration
+ jobs:
+ - job: GitHubCommentCompletedSuccessfullyJob
+ condition: eq(stageDependencies.VSIntegration.result, 'Succeeded')
+ steps:
+ - checkout: none
+ - task: GitHubComment@0
+ inputs:
+ gitHubConnection: 'dotnet-comment-bot-service-connection'
+ repositoryName: '$(Build.Repository.Name)'
+ id: ${{ parameters.prNumber }}
+ comment: 'DartLab pipeline [run]($(System.TeamFoundationCollectionUri)$(System.TeamProject)/_build/results?buildId=$(Build.BuildId)) completed successfully for ${{ parameters.sha }}'
+ - job: GitHubCommentCompletedUnsuccessfullyJob
+ condition: ne(stageDependencies.VSIntegration.result, 'Succeeded')
+ steps:
+ - checkout: none
+ - task: GitHubComment@0
+ inputs:
+ gitHubConnection: 'dotnet-comment-bot-service-connection'
+ repositoryName: '$(Build.Repository.Name)'
+ id: ${{ parameters.prNumber }}
+ comment: 'DartLab pipeline [run]($(System.TeamFoundationCollectionUri)$(System.TeamProject)/_build/results?buildId=$(Build.BuildId)) did not complete successfully for ${{ parameters.sha }}'
\ No newline at end of file
diff --git a/azure-pipelines-official.yml b/azure-pipelines-official.yml
index 4ff514dfeec51..981528e441d68 100644
--- a/azure-pipelines-official.yml
+++ b/azure-pipelines-official.yml
@@ -37,6 +37,18 @@ parameters:
type: boolean
default: true
+schedules:
+ - cron: "0 8 23-29 * 0"
+ displayName: "Monthly smoke test"
+ branches:
+ include:
+ - main
+ - release/*
+ exclude:
+ - ""
+ always: true # Run even if there have been no source code changes since the last successful scheduled run
+ batch: false # Do not run the pipeline if the previously scheduled run is in-progress
+
# The variables `_DotNetArtifactsCategory` and `_DotNetValidationArtifactsCategory` are required for proper publishing of build artifacts. See https://github.com/dotnet/roslyn/pull/38259
variables:
- name: _DotNetArtifactsCategory
@@ -53,6 +65,7 @@ variables:
- group: DotNet-Versions-Publish
- group: DotNet-VSTS-Infra-Access
- group: DotNet-DevDiv-Insertion-Workflow-Variables
+ - group: AzureDevOps-Artifact-Feeds-Pats
- name: _DevDivDropAccessToken
value: $(dn-bot-devdiv-drop-rw-code-rw)
- name: ArtifactServices.Drop.PAT
@@ -78,6 +91,10 @@ variables:
- name: Insertion.TitleSuffix
value: ''
+ - ${{ if and(notin(variables['Build.Reason'], 'PullRequest'), eq(variables['Build.SourceBranch'], 'refs/heads/main')) }}:
+ - name: enableSourceIndex
+ value: true
+
extends:
template: v1/1ES.Official.PipelineTemplate.yml@1ESPipelineTemplates
parameters:
@@ -339,6 +356,15 @@ extends:
name: NetCore1ESPool-Svc-Internal
demands: ImageOverride -equals windows.vs2022.amd64
+ - ${{ if eq(variables.enableSourceIndex, 'true') }}:
+ - template: /eng/common/templates-official/job/source-index-stage1.yml@self
+ parameters:
+ sourceIndexBuildCommand: powershell -NoLogo -NoProfile -ExecutionPolicy Bypass -Command "eng\build.ps1 -configuration Release -prepareMachine -ci -restore -build -binaryLogName Build.binlog -skipDocumentation -msbuildEngine dotnet /p:UsingToolVSSDK=false /p:GenerateSatelliteAssemblies=false /p:PublishReadyToRun=false"
+ binlogPath: artifacts/log/$(BuildConfiguration)/Build.binlog
+ pool:
+ name: $(DncEngInternalBuildPool)
+ demands: ImageOverride -equals 1es-windows-2022
+
- stage: insert
dependsOn:
- publish_using_darc
diff --git a/docs/Language Feature Status.md b/docs/Language Feature Status.md
index 0981e775649e0..4037d257257a6 100644
--- a/docs/Language Feature Status.md
+++ b/docs/Language Feature Status.md
@@ -10,12 +10,10 @@ efforts behind them.
| Feature | Branch | State | Developer | Reviewer | IDE Buddy | LDM Champ |
| ------- | ------ | ----- | --------- | -------- | --------- | --------- |
-| [Overload Resolution Priority](https://github.com/dotnet/csharplang/issues/7706) | PR not yet available | [In Progress](https://github.com/dotnet/roslyn/issues/74131) | [333fred](https://github.com/333fred) | [jcouv](https://github.com/jcouv), [cston](https://github.com/cston) | Not yet assigned | [333fred](https://github.com/333fred) |
| [First-class Span Types](https://github.com/dotnet/csharplang/issues/7905) | [FirstClassSpan](https://github.com/dotnet/roslyn/tree/features/FirstClassSpan) | [In Progress](https://github.com/dotnet/roslyn/issues/73445) | [jjonescz](https://github.com/jjonescz) | [cston](https://github.com/cston), [333fred](https://github.com/333fred) | | [333fred](https://github.com/333fred), [stephentoub](https://github.com/stephentoub) |
-| [Semi-auto-properties](https://github.com/dotnet/csharplang/issues/140) | [semi-auto-props](https://github.com/dotnet/roslyn/tree/features/semi-auto-props) | [In Progress](https://github.com/dotnet/roslyn/issues/57012) | [Youssef1313](https://github.com/Youssef1313) | [333fred](https://github.com/333fred), [RikkiGibson](https://github.com/RikkiGibson) | [CyrusNajmabadi](https://github.com/CyrusNajmabadi) | [CyrusNajmabadi](https://github.com/CyrusNajmabadi) |
+| [`field` keyword in properties](https://github.com/dotnet/csharplang/issues/140) | [field-keyword](https://github.com/dotnet/roslyn/tree/features/field-keyword) | [In Progress](https://github.com/dotnet/roslyn/issues/57012) | [Youssef1313](https://github.com/Youssef1313), [cston](https://github.com/cston) | [333fred](https://github.com/333fred), [RikkiGibson](https://github.com/RikkiGibson) | [CyrusNajmabadi](https://github.com/CyrusNajmabadi) | [CyrusNajmabadi](https://github.com/CyrusNajmabadi) |
| [Default in deconstruction](https://github.com/dotnet/roslyn/pull/25562) | [decon-default](https://github.com/dotnet/roslyn/tree/features/decon-default) | [In Progress](https://github.com/dotnet/roslyn/issues/25559) | [jcouv](https://github.com/jcouv) | [gafter](https://github.com/gafter) | | [jcouv](https://github.com/jcouv) |
| [Roles/Extensions](https://github.com/dotnet/csharplang/issues/5497) | [roles](https://github.com/dotnet/roslyn/tree/features/roles) | [In Progress](https://github.com/dotnet/roslyn/issues/66722) | [jcouv](https://github.com/jcouv) | [AlekseyTs](https://github.com/AlekseyTs), [jjonescz](https://github.com/jjonescz) | [CyrusNajmabadi](https://github.com/CyrusNajmabadi) | [MadsTorgersen](https://github.com/MadsTorgersen) |
-| [Ref Struct Interfaces](https://github.com/dotnet/csharplang/issues/7608) | [RefStructInterfaces](https://github.com/dotnet/roslyn/tree/features/RefStructInterfaces) | [Merged into 17.11p2](https://github.com/dotnet/roslyn/issues/72124) | [AlekseyTs](https://github.com/AlekseyTs) | [cston](https://github.com/cston), [jjonescz](https://github.com/jjonescz) | [ToddGrun](https://github.com/ToddGrun) | [agocke](https://github.com/agocke), [jaredpar](https://github.com/jaredpar) |
# C# 13.0
@@ -30,6 +28,7 @@ efforts behind them.
| [`allows ref struct` constraint](https://github.com/dotnet/csharplang/issues/7608) | [RefStructInterfaces](https://github.com/dotnet/roslyn/tree/features/RefStructInterfaces) | [Merged into 17.11p2](https://github.com/dotnet/roslyn/issues/72124) | [AlekseyTs](https://github.com/AlekseyTs) | [cston](https://github.com/cston), [jjonescz](https://github.com/jjonescz) | [ToddGrun](https://github.com/ToddGrun) | [agocke](https://github.com/agocke), [jaredpar](https://github.com/jaredpar) |
| [Overload Resolution Priority](https://github.com/dotnet/csharplang/issues/7706) | main | [Merged to 17.12p1](https://github.com/dotnet/roslyn/issues/74131) | [333fred](https://github.com/333fred) | [jcouv](https://github.com/jcouv), [cston](https://github.com/cston) | Not yet assigned | [333fred](https://github.com/333fred) |
| [Partial properties](https://github.com/dotnet/csharplang/issues/6420) | [partial-properties](https://github.com/dotnet/roslyn/tree/features/partial-properties) | [Merged into 17.11p3](https://github.com/dotnet/roslyn/issues/73090) | [RikkiGibson](https://github.com/RikkiGibson) | [jcouv](https://github.com/jcouv), [333fred](https://github.com/333fred) | [Cosifne](https://github.com/Cosifne) | [333fred](https://github.com/333fred), [RikkiGibson](https://github.com/RikkiGibson) |
+| [Ref Struct Interfaces](https://github.com/dotnet/csharplang/issues/7608) | [RefStructInterfaces](https://github.com/dotnet/roslyn/tree/features/RefStructInterfaces) | [Merged into 17.11p2](https://github.com/dotnet/roslyn/issues/72124) | [AlekseyTs](https://github.com/AlekseyTs) | [cston](https://github.com/cston), [jjonescz](https://github.com/jjonescz) | [ToddGrun](https://github.com/ToddGrun) | [agocke](https://github.com/agocke), [jaredpar](https://github.com/jaredpar) |
# C# 12.0
diff --git a/docs/contributing/Building, Debugging, and Testing on Unix.md b/docs/contributing/Building, Debugging, and Testing on Unix.md
index 0690730630dd6..5d1d326a4d610 100644
--- a/docs/contributing/Building, Debugging, and Testing on Unix.md
+++ b/docs/contributing/Building, Debugging, and Testing on Unix.md
@@ -12,7 +12,7 @@ Particularly for developers who aren't experienced with .NET Core development on
1. Install [VS Code](https://code.visualstudio.com/Download)
- After you install VS Code, install the [C# extension](https://marketplace.visualstudio.com/items?itemName=ms-dotnettools.csharp)
- Important tip: You can look up editor commands by name by hitting *Ctrl+Shift+P*, or by hitting *Ctrl+P* and typing a `>` character. This will help you get familiar with editor commands mentioned below. On a Mac, use *⌘* instead of *Ctrl*.
-1. Install the [.NET 8.0 SDK](https://dotnet.microsoft.com/en-us/download/dotnet/8.0) which matches the `sdk.version` property in [global.json](../../global.json#L3)
+1. Install the [.NET 9.0 SDK](https://dotnet.microsoft.com/en-us/download/dotnet/9.0) which matches the `sdk.version` property in [global.json](../../global.json#L3)
3. You can build from VS Code by running the *Run Build Task* command, then selecting an appropriate task such as *build* or *build current project* (the latter builds the containing project for the current file you're viewing in the editor).
4. You can run tests from VS Code by opening a test class in the editor, then using the *Run Tests in Context* and *Debug Tests in Context* editor commands. You may want to bind these commands to keyboard shortcuts that match their Visual Studio equivalents (**Ctrl+R, T** for *Run Tests in Context* and **Ctrl+R, Ctrl+T** for *Debug Tests in Context*).
5. You can launch a new VS Code instance with the language server from your current code by running the "launch vscode with language server" task.
diff --git a/docs/contributing/Building, Debugging, and Testing on Windows.md b/docs/contributing/Building, Debugging, and Testing on Windows.md
index 0482960a9d56c..87a3722a7adb5 100644
--- a/docs/contributing/Building, Debugging, and Testing on Windows.md
+++ b/docs/contributing/Building, Debugging, and Testing on Windows.md
@@ -20,7 +20,7 @@ The minimal required version of .NET Framework is 4.7.2.
- Ensure C# and Visual Basic, MSBuild, and .NET Core are included in the selected individual components
- Ensure "Use previews of the .NET Core SDK" is checked in Tools -> Options -> Environment -> Preview Features
- Restart Visual Studio
-1. Install the [.NET 8.0 SDK](https://dotnet.microsoft.com/en-us/download/dotnet/8.0) which matches the `sdk.version` property in [global.json](../../global.json#L3)
+1. Install the [.NET 9.0 SDK](https://dotnet.microsoft.com/en-us/download/dotnet/9.0) which matches the `sdk.version` property in [global.json](../../global.json#L3)
1. [PowerShell 5.0 or newer](https://docs.microsoft.com/en-us/powershell/scripting/setup/installing-windows-powershell). If you are on Windows 10, you are fine; you'll only need to upgrade if you're on earlier versions of Windows. The download link is under the ["Upgrading existing Windows PowerShell"](https://docs.microsoft.com/en-us/powershell/scripting/install/installing-windows-powershell?view=powershell-6#upgrading-existing-windows-powershell) heading.
1. Run Restore.cmd
1. Open Roslyn.sln
diff --git a/docs/features/incremental-generators.cookbook.md b/docs/features/incremental-generators.cookbook.md
index 275c3fa6ad02b..599f0f32f5dcc 100644
--- a/docs/features/incremental-generators.cookbook.md
+++ b/docs/features/incremental-generators.cookbook.md
@@ -544,7 +544,7 @@ Now, consider that the generator author wants to optionally allow opting in/out
This value of `MyGenerator_EnableLogging` will be emitted to a generated analyzer config file, for each of the additional files in the compilation, with an item name of `build_metadata.AdditionalFiles.MyGenerator_EnableLogging`. The generator can read this value in the context of each additional file:
```cs
-context.AdditionalFilesProvider
+context.AdditionalTextsProvider
.Combine(context.AnalyzerConfigOptionsProvider)
.Select((pair, ctx) =>
pair.Right.GetOptions(pair.Left).TryGetValue("build_metadata.AdditionalFiles.MyGenerator_EnableLogging", out var perFileLoggingSwitch)
diff --git a/docs/features/interceptors.md b/docs/features/interceptors.md
index f93209462b994..c34d5294446b0 100644
--- a/docs/features/interceptors.md
+++ b/docs/features/interceptors.md
@@ -179,6 +179,37 @@ This allows generator authors to avoid *polluting lookup* with interceptors, hel
We may also want to consider adjusting behavior of `[EditorBrowsable]` to work in the same compilation.
+### Struct receiver capture
+
+An interceptor whose `this` parameter takes a struct by-reference can generally be used to intercept a struct instance method call, assuming the methods are compatible per [Signature matching](#signature-matching). This includes situations where the receiver must be implicitly captured to temp before the invocation, even if such capture is not permitted when the interceptor is called directly. See also [12.8.9.3 Extension method invocations](https://github.com/dotnet/csharpstandard/blob/standard-v7/standard/expressions.md#12893-extension-method-invocations) in the standard.
+
+
+```cs
+using System.Runtime.CompilerServices;
+
+struct S
+{
+ public void Original() { }
+}
+
+static class Program
+{
+ public static void Main()
+ {
+ new S().Original(); // L1: interception is valid, no errors.
+ new S().Interceptor(); // error CS1510: A ref or out value must be an assignable variable
+ }
+}
+
+static class D
+{
+ [InterceptsLocation(1, "..(refers to call to 'Original()' at L1)")]
+ public static void Interceptor(this ref S s)
+}
+```
+
+The reason we permit implicit receiver capture for the above intercepted call is: we want intercepting to be possible even when the interceptor author doesn't own the original receiver type. If we didn't do this, then intercepting `Original()` in the above example would only be possible by adding instance members to `struct S`.
+
### Editor experience
Interceptors are treated like a post-compilation step in this design. Diagnostics are given for misuse of interceptors, but some diagnostics are only given in the command-line build and not in the IDE. There is limited traceability in the editor for which calls in a compilation are actually being intercepted. If this feature is brought forward past the experimental stage, this limitation will need to be re-examined.
@@ -187,12 +218,14 @@ There is an experimental public API `GetInterceptorMethod(this SemanticModel, In
### User opt-in
-To use interceptors, the user project must specify the property ``. This is a list of namespaces which are allowed to contain interceptors.
+To use interceptors, the user project must specify the property ``. This is a list of namespaces which are allowed to contain interceptors.
```xml
-$(InterceptorsPreviewNamespaces);Microsoft.AspNetCore.Http.Generated;MyLibrary.Generated
+$(InterceptorsNamespaces);Microsoft.AspNetCore.Http.Generated;MyLibrary.Generated
```
-It's expected that each entry in the `InterceptorsPreviewNamespaces` list roughly corresponds to one source generator. Well-behaved components are expected to not insert interceptors into namespaces they do not own.
+It's expected that each entry in the `InterceptorsNamespaces` list roughly corresponds to one source generator. Well-behaved components are expected to not insert interceptors into namespaces they do not own.
+
+For compatibility, the property `` can be used as an alias for ``. If both properties have non-empty values, they will be concatenated together in the order `$(InterceptorsNamespaces);$(InterceptorsPreviewNamespaces)` when passed to the compiler.
### Implementation strategy
diff --git a/docs/img/discord-mark-white.png b/docs/img/discord-mark-white.png
new file mode 100644
index 0000000000000..f9f8df0dd1fe3
Binary files /dev/null and b/docs/img/discord-mark-white.png differ
diff --git a/eng/Directory.Packages.props b/eng/Directory.Packages.props
index bf84a2aaa4ee1..43df945a6417a 100644
--- a/eng/Directory.Packages.props
+++ b/eng/Directory.Packages.props
@@ -5,7 +5,7 @@
8.0.0-preview.23468.1
1.1.3-beta1.24319.1
0.1.187-beta
- <_BasicReferenceAssembliesVersion>1.7.2
+ <_BasicReferenceAssembliesVersion>1.7.8
4.8.0-3.final
17.10.191
@@ -111,8 +111,8 @@
-
-
+
+
@@ -121,7 +121,7 @@
-
+
@@ -144,7 +144,7 @@
-
+
+
@@ -255,14 +255,11 @@
-
-
-
@@ -290,13 +287,17 @@
+
+
+
+
diff --git a/eng/Version.Details.xml b/eng/Version.Details.xml
index 49e3252e73c0a..c384a1ae5cb66 100644
--- a/eng/Version.Details.xml
+++ b/eng/Version.Details.xml
@@ -2,15 +2,15 @@
-
+
https://github.com/dotnet/source-build-externals
- 311ef7fef52828f4a70a94d13e32c394fd3292ee
+ ee22054b44ec9615dc3481c4decc1b007a83a2b0
-
+
https://github.com/dotnet/source-build-reference-packages
- 0b53e839fa2f09a5994cc6006533dcc3d45a4226
+ c818c3cf018e7aa9fd31f6aed5d14e9b59f03e4f
@@ -122,14 +122,14 @@
-
+
https://github.com/dotnet/arcade
- 4a7d983f833d6b86365ea1b2b4d6ee72fbdbf944
+ 65260b148c869ada772a5843863c54737cd2361e
-
+
https://github.com/dotnet/arcade
- 4a7d983f833d6b86365ea1b2b4d6ee72fbdbf944
+ 65260b148c869ada772a5843863c54737cd2361e
@@ -156,9 +156,9 @@
https://github.com/dotnet/roslyn
5d10d428050c0d6afef30a072c4ae68776621877
-
+
https://github.com/dotnet/arcade
- 4a7d983f833d6b86365ea1b2b4d6ee72fbdbf944
+ 65260b148c869ada772a5843863c54737cd2361e
https://github.com/dotnet/roslyn-analyzers
diff --git a/eng/Versions.props b/eng/Versions.props
index 758c3cfac1136..43472e1a059d4 100644
--- a/eng/Versions.props
+++ b/eng/Versions.props
@@ -8,7 +8,7 @@
4
12
0
- 1
+ 3
$(MajorVersion).$(MinorVersion).$(PatchVersion)
8.0.0
- 8.0.0
+ 8.0.4
8.0.0
8.0.0
8.0.0
@@ -59,7 +59,7 @@
So it's not affected by our central package management
-->
4.61.3
- 1.0.803
+ 1.0.865
6.34.0
13.0.3
6.34.0
@@ -83,5 +83,7 @@
-->
true
true
+
+ true
diff --git a/eng/build.ps1 b/eng/build.ps1
index edbcc77f9ec0e..c8d54142a6e71 100644
--- a/eng/build.ps1
+++ b/eng/build.ps1
@@ -318,6 +318,11 @@ function GetIbcSourceBranchName() {
}
function GetIbcDropName() {
+ [Diagnostics.CodeAnalysis.SuppressMessageAttribute(
+ 'PSAvoidUsingConvertToSecureStringWithPlainText',
+ '',
+ Justification='$officialVisualStudioDropAccessToken is a script parameter so it needs to be plain text')]
+ param()
if ($officialIbcDrop -and $officialIbcDrop -ne "default"){
return $officialIbcDrop
@@ -627,6 +632,13 @@ function Deploy-VsixViaTool() {
# Configure RemoteHostOptions.OOP64Bit for testing
$oop64bitValue = [int]$oop64bit.ToBool()
&$vsRegEdit set "$vsDir" $hive HKCU "Roslyn\Internal\OnOff\Features" OOP64Bit dword $oop64bitValue
+
+ # Disable targeted notifications
+ if ($ci) {
+ # Currently does not work via vsregedit, so only apply this setting in CI
+ #&$vsRegEdit set "$vsDir" $hive HKCU "RemoteSettings" TurnOffSwitch dword 1
+ reg add hkcu\Software\Microsoft\VisualStudio\RemoteSettings /f /t REG_DWORD /v TurnOffSwitch /d 1
+ }
}
# Ensure that procdump is available on the machine. Returns the path to the directory that contains
diff --git a/eng/common/SetupNugetSources.ps1 b/eng/common/SetupNugetSources.ps1
index 2b0a5c9e6655e..5db4ad71ee2f3 100644
--- a/eng/common/SetupNugetSources.ps1
+++ b/eng/common/SetupNugetSources.ps1
@@ -157,7 +157,7 @@ if ($dotnet31Source -ne $null) {
AddPackageSource -Sources $sources -SourceName "dotnet3.1-internal-transport" -SourceEndPoint "https://pkgs.dev.azure.com/dnceng/_packaging/dotnet3.1-internal-transport/nuget/v2" -Creds $creds -Username $userName -pwd $Password
}
-$dotnetVersions = @('5','6','7','8')
+$dotnetVersions = @('5','6','7','8','9')
foreach ($dotnetVersion in $dotnetVersions) {
$feedPrefix = "dotnet" + $dotnetVersion;
diff --git a/eng/common/SetupNugetSources.sh b/eng/common/SetupNugetSources.sh
index b493479a1daf0..4604b61b0323a 100644
--- a/eng/common/SetupNugetSources.sh
+++ b/eng/common/SetupNugetSources.sh
@@ -99,7 +99,7 @@ if [ "$?" == "0" ]; then
PackageSources+=('dotnet3.1-internal-transport')
fi
-DotNetVersions=('5' '6' '7' '8')
+DotNetVersions=('5' '6' '7' '8' '9')
for DotNetVersion in ${DotNetVersions[@]} ; do
FeedPrefix="dotnet${DotNetVersion}";
diff --git a/eng/common/core-templates/job/job.yml b/eng/common/core-templates/job/job.yml
index c732bee9f4a6f..ba53ebfbd5133 100644
--- a/eng/common/core-templates/job/job.yml
+++ b/eng/common/core-templates/job/job.yml
@@ -33,11 +33,6 @@ parameters:
artifactPublishSteps: []
runAsPublic: false
-# Sbom related params
- enableSbom: true
- PackageVersion: 9.0.0
- BuildDropPath: '$(Build.SourcesDirectory)/artifacts'
-
# 1es specific parameters
is1ESPipeline: ''
diff --git a/eng/common/core-templates/job/publish-build-assets.yml b/eng/common/core-templates/job/publish-build-assets.yml
index d99a1a3b2840e..3d3356e319672 100644
--- a/eng/common/core-templates/job/publish-build-assets.yml
+++ b/eng/common/core-templates/job/publish-build-assets.yml
@@ -113,38 +113,19 @@ jobs:
Add-Content -Path $filePath -Value "$(DefaultChannels)"
Add-Content -Path $filePath -Value $(IsStableBuild)
- - template: /eng/common/core-templates/steps/publish-build-artifacts.yml
- parameters:
- is1ESPipeline: ${{ parameters.is1ESPipeline }}
- args:
- displayName: Publish ReleaseConfigs Artifact
- pathToPublish: '$(Build.StagingDirectory)/ReleaseConfigs'
- publishLocation: Container
- artifactName: ReleaseConfigs
-
- - task: powershell@2
- displayName: Check if SymbolPublishingExclusionsFile.txt exists
- inputs:
- targetType: inline
- script: |
$symbolExclusionfile = "$(Build.SourcesDirectory)/eng/SymbolPublishingExclusionsFile.txt"
- if(Test-Path -Path $symbolExclusionfile)
+ if (Test-Path -Path $symbolExclusionfile)
{
Write-Host "SymbolExclusionFile exists"
- Write-Host "##vso[task.setvariable variable=SymbolExclusionFile]true"
- }
- else{
- Write-Host "Symbols Exclusion file does not exist"
- Write-Host "##vso[task.setvariable variable=SymbolExclusionFile]false"
+ Copy-Item -Path $symbolExclusionfile -Destination "$(Build.StagingDirectory)/ReleaseConfigs"
}
- template: /eng/common/core-templates/steps/publish-build-artifacts.yml
parameters:
is1ESPipeline: ${{ parameters.is1ESPipeline }}
args:
- displayName: Publish SymbolPublishingExclusionsFile Artifact
- condition: eq(variables['SymbolExclusionFile'], 'true')
- pathToPublish: '$(Build.SourcesDirectory)/eng/SymbolPublishingExclusionsFile.txt'
+ displayName: Publish ReleaseConfigs Artifact
+ pathToPublish: '$(Build.StagingDirectory)/ReleaseConfigs'
publishLocation: Container
artifactName: ReleaseConfigs
@@ -162,9 +143,10 @@ jobs:
scriptType: ps
scriptLocation: scriptPath
scriptPath: $(Build.SourcesDirectory)/eng/common/post-build/publish-using-darc.ps1
- arguments: -BuildId $(BARBuildId)
+ arguments: >
+ -BuildId $(BARBuildId)
-PublishingInfraVersion 3
- -AzdoToken '$(publishing-dnceng-devdiv-code-r-build-re)'
+ -AzdoToken '$(System.AccessToken)'
-WaitPublishingFinish true
-ArtifactsPublishingAdditionalParameters '${{ parameters.artifactsPublishingAdditionalParameters }}'
-SymbolPublishingAdditionalParameters '${{ parameters.symbolPublishingAdditionalParameters }}'
diff --git a/eng/common/core-templates/job/source-index-stage1.yml b/eng/common/core-templates/job/source-index-stage1.yml
index 945c1c19e8249..205fb5b3a3956 100644
--- a/eng/common/core-templates/job/source-index-stage1.yml
+++ b/eng/common/core-templates/job/source-index-stage1.yml
@@ -34,10 +34,12 @@ jobs:
pool:
${{ if eq(variables['System.TeamProject'], 'public') }}:
name: $(DncEngPublicBuildPool)
- image: windows.vs2022.amd64.open
+ image: 1es-windows-2022-open
+ os: windows
${{ if eq(variables['System.TeamProject'], 'internal') }}:
name: $(DncEngInternalBuildPool)
- image: windows.vs2022.amd64
+ image: 1es-windows-2022
+ os: windows
steps:
- ${{ if eq(parameters.is1ESPipeline, '') }}:
diff --git a/eng/common/core-templates/post-build/post-build.yml b/eng/common/core-templates/post-build/post-build.yml
index 20924366b8a43..454fd75c7aff1 100644
--- a/eng/common/core-templates/post-build/post-build.yml
+++ b/eng/common/core-templates/post-build/post-build.yml
@@ -307,9 +307,10 @@ stages:
scriptType: ps
scriptLocation: scriptPath
scriptPath: $(Build.SourcesDirectory)/eng/common/post-build/publish-using-darc.ps1
- arguments: -BuildId $(BARBuildId)
+ arguments: >
+ -BuildId $(BARBuildId)
-PublishingInfraVersion ${{ parameters.publishingInfraVersion }}
- -AzdoToken '$(publishing-dnceng-devdiv-code-r-build-re)'
+ -AzdoToken '$(System.AccessToken)'
-WaitPublishingFinish true
-ArtifactsPublishingAdditionalParameters '${{ parameters.artifactsPublishingAdditionalParameters }}'
-SymbolPublishingAdditionalParameters '${{ parameters.symbolPublishingAdditionalParameters }}'
diff --git a/eng/common/core-templates/steps/get-federated-access-token.yml b/eng/common/core-templates/steps/get-federated-access-token.yml
index c8c49cc0e8f0f..3a4d4410c4829 100644
--- a/eng/common/core-templates/steps/get-federated-access-token.yml
+++ b/eng/common/core-templates/steps/get-federated-access-token.yml
@@ -3,6 +3,14 @@ parameters:
type: string
- name: outputVariableName
type: string
+- name: is1ESPipeline
+ type: boolean
+- name: stepName
+ type: string
+ default: 'getFederatedAccessToken'
+- name: condition
+ type: string
+ default: ''
# Resource to get a token for. Common values include:
# - '499b84ac-1321-427f-aa17-267ca6975798' for Azure DevOps
# - 'https://storage.azure.com/' for storage
@@ -10,10 +18,16 @@ parameters:
- name: resource
type: string
default: '499b84ac-1321-427f-aa17-267ca6975798'
+- name: isStepOutputVariable
+ type: boolean
+ default: false
steps:
- task: AzureCLI@2
displayName: 'Getting federated access token for feeds'
+ name: ${{ parameters.stepName }}
+ ${{ if ne(parameters.condition, '') }}:
+ condition: ${{ parameters.condition }}
inputs:
azureSubscription: ${{ parameters.federatedServiceConnection }}
scriptType: 'pscore'
@@ -25,4 +39,4 @@ steps:
exit 1
}
Write-Host "Setting '${{ parameters.outputVariableName }}' with the access token value"
- Write-Host "##vso[task.setvariable variable=${{ parameters.outputVariableName }};issecret=true]$accessToken"
\ No newline at end of file
+ Write-Host "##vso[task.setvariable variable=${{ parameters.outputVariableName }};issecret=true;isOutput=${{ parameters.isStepOutputVariable }}]$accessToken"
\ No newline at end of file
diff --git a/eng/common/core-templates/steps/publish-logs.yml b/eng/common/core-templates/steps/publish-logs.yml
index 8c5ea77b586d2..80788c5231912 100644
--- a/eng/common/core-templates/steps/publish-logs.yml
+++ b/eng/common/core-templates/steps/publish-logs.yml
@@ -32,7 +32,6 @@ steps:
'$(MaestroAccessToken)'
'$(dn-bot-all-orgs-artifact-feeds-rw)'
'$(akams-client-id)'
- '$(akams-client-secret)'
'$(microsoft-symbol-server-pat)'
'$(symweb-symbol-server-pat)'
'$(dn-bot-all-orgs-build-rw-code-rw)'
diff --git a/eng/common/cross/build-rootfs.sh b/eng/common/cross/build-rootfs.sh
index eb1a908046483..4b5e8d7166bd9 100755
--- a/eng/common/cross/build-rootfs.sh
+++ b/eng/common/cross/build-rootfs.sh
@@ -72,7 +72,7 @@ __AlpinePackages+=" krb5-dev"
__AlpinePackages+=" openssl-dev"
__AlpinePackages+=" zlib-dev"
-__FreeBSDBase="13.2-RELEASE"
+__FreeBSDBase="13.3-RELEASE"
__FreeBSDPkg="1.17.0"
__FreeBSDABI="13"
__FreeBSDPackages="libunwind"
@@ -605,18 +605,18 @@ elif [[ "$__CodeName" == "illumos" ]]; then
fi
echo "Building binutils. Please wait.."
if [[ "$__hasWget" == 1 ]]; then
- wget -O- https://ftp.gnu.org/gnu/binutils/binutils-2.33.1.tar.bz2 | tar -xjf -
+ wget -O- https://ftp.gnu.org/gnu/binutils/binutils-2.42.tar.xz | tar -xJf -
else
- curl -SL https://ftp.gnu.org/gnu/binutils/binutils-2.33.1.tar.bz2 | tar -xjf -
+ curl -SL https://ftp.gnu.org/gnu/binutils/binutils-2.42.tar.xz | tar -xJf -
fi
mkdir build-binutils && cd build-binutils
- ../binutils-2.33.1/configure --prefix="$__RootfsDir" --target="${__illumosArch}-sun-solaris2.10" --program-prefix="${__illumosArch}-illumos-" --with-sysroot="$__RootfsDir"
+ ../binutils-2.42/configure --prefix="$__RootfsDir" --target="${__illumosArch}-sun-solaris2.11" --program-prefix="${__illumosArch}-illumos-" --with-sysroot="$__RootfsDir"
make -j "$JOBS" && make install && cd ..
echo "Building gcc. Please wait.."
if [[ "$__hasWget" == 1 ]]; then
- wget -O- https://ftp.gnu.org/gnu/gcc/gcc-8.4.0/gcc-8.4.0.tar.xz | tar -xJf -
+ wget -O- https://ftp.gnu.org/gnu/gcc/gcc-13.3.0/gcc-13.3.0.tar.xz | tar -xJf -
else
- curl -SL https://ftp.gnu.org/gnu/gcc/gcc-8.4.0/gcc-8.4.0.tar.xz | tar -xJf -
+ curl -SL https://ftp.gnu.org/gnu/gcc/gcc-13.3.0/gcc-13.3.0.tar.xz | tar -xJf -
fi
CFLAGS="-fPIC"
CXXFLAGS="-fPIC"
@@ -624,7 +624,7 @@ elif [[ "$__CodeName" == "illumos" ]]; then
CFLAGS_FOR_TARGET="-fPIC"
export CFLAGS CXXFLAGS CXXFLAGS_FOR_TARGET CFLAGS_FOR_TARGET
mkdir build-gcc && cd build-gcc
- ../gcc-8.4.0/configure --prefix="$__RootfsDir" --target="${__illumosArch}-sun-solaris2.10" --program-prefix="${__illumosArch}-illumos-" --with-sysroot="$__RootfsDir" --with-gnu-as \
+ ../gcc-13.3.0/configure --prefix="$__RootfsDir" --target="${__illumosArch}-sun-solaris2.11" --program-prefix="${__illumosArch}-illumos-" --with-sysroot="$__RootfsDir" --with-gnu-as \
--with-gnu-ld --disable-nls --disable-libgomp --disable-libquadmath --disable-libssp --disable-libvtv --disable-libcilkrts --disable-libada --disable-libsanitizer \
--disable-libquadmath-support --disable-shared --enable-tls
make -j "$JOBS" && make install && cd ..
@@ -632,7 +632,7 @@ elif [[ "$__CodeName" == "illumos" ]]; then
if [[ "$__UseMirror" == 1 ]]; then
BaseUrl=https://pkgsrc.smartos.skylime.net
fi
- BaseUrl="$BaseUrl/packages/SmartOS/trunk/${__illumosArch}/All"
+ BaseUrl="$BaseUrl/packages/SmartOS/2019Q4/${__illumosArch}/All"
echo "Downloading manifest"
if [[ "$__hasWget" == 1 ]]; then
wget "$BaseUrl"
diff --git a/eng/common/darc-init.ps1 b/eng/common/darc-init.ps1
index 8fda30bdce2b0..e337431056354 100644
--- a/eng/common/darc-init.ps1
+++ b/eng/common/darc-init.ps1
@@ -1,6 +1,6 @@
param (
$darcVersion = $null,
- $versionEndpoint = 'https://maestro.dot.net/api/assets/darc-version?api-version=2019-01-16',
+ $versionEndpoint = 'https://maestro.dot.net/api/assets/darc-version?api-version=2020-02-20',
$verbosity = 'minimal',
$toolpath = $null
)
diff --git a/eng/common/darc-init.sh b/eng/common/darc-init.sh
index c305ae6bd771e..36dbd45e1ce86 100755
--- a/eng/common/darc-init.sh
+++ b/eng/common/darc-init.sh
@@ -2,7 +2,7 @@
source="${BASH_SOURCE[0]}"
darcVersion=''
-versionEndpoint='https://maestro.dot.net/api/assets/darc-version?api-version=2019-01-16'
+versionEndpoint='https://maestro.dot.net/api/assets/darc-version?api-version=2020-02-20'
verbosity='minimal'
while [[ $# > 0 ]]; do
diff --git a/eng/common/internal/Tools.csproj b/eng/common/internal/Tools.csproj
index e925952d56664..32f79dfb3402c 100644
--- a/eng/common/internal/Tools.csproj
+++ b/eng/common/internal/Tools.csproj
@@ -4,6 +4,7 @@
net472
false
+ false
diff --git a/eng/common/native/init-compiler.sh b/eng/common/native/init-compiler.sh
index 62900e12b21c1..9a0e1f2b4567b 100644
--- a/eng/common/native/init-compiler.sh
+++ b/eng/common/native/init-compiler.sh
@@ -19,11 +19,9 @@ case "$compiler" in
# clangx.y or clang-x.y
version="$(echo "$compiler" | tr -d '[:alpha:]-=')"
majorVersion="${version%%.*}"
- [ -z "${version##*.*}" ] && minorVersion="${version#*.}"
- if [ -z "$minorVersion" ] && [ -n "$majorVersion" ] && [ "$majorVersion" -le 6 ]; then
- minorVersion=0;
- fi
+ # LLVM based on v18 released in early 2024, with two releases per year
+ maxVersion="$((18 + ((($(date +%Y) - 2024) * 12 + $(date +%-m) - 3) / 6)))"
compiler=clang
;;
@@ -31,7 +29,9 @@ case "$compiler" in
# gccx.y or gcc-x.y
version="$(echo "$compiler" | tr -d '[:alpha:]-=')"
majorVersion="${version%%.*}"
- [ -z "${version##*.*}" ] && minorVersion="${version#*.}"
+
+ # GCC based on v14 released in early 2024, with one release per year
+ maxVersion="$((14 + ((($(date +%Y) - 2024) * 12 + $(date +%-m) - 3) / 12)))"
compiler=gcc
;;
esac
@@ -49,12 +49,10 @@ check_version_exists() {
desired_version=-1
# Set up the environment to be used for building with the desired compiler.
- if command -v "$compiler-$1.$2" > /dev/null; then
- desired_version="-$1.$2"
- elif command -v "$compiler$1$2" > /dev/null; then
- desired_version="$1$2"
- elif command -v "$compiler-$1$2" > /dev/null; then
- desired_version="-$1$2"
+ if command -v "$compiler-$1" > /dev/null; then
+ desired_version="-$1"
+ elif command -v "$compiler$1" > /dev/null; then
+ desired_version="$1"
fi
echo "$desired_version"
@@ -75,7 +73,7 @@ set_compiler_version_from_CC() {
fi
# gcc and clang often display 3 part versions. However, gcc can show only 1 part in some environments.
- IFS=. read -r majorVersion minorVersion _ < /dev/null; then
- echo "Error: No usable version of $compiler found."
+ echo "Error: No compatible version of $compiler was found within the range of $minVersion to $maxVersion. Please upgrade your toolchain or specify the compiler explicitly using CLR_CC and CLR_CXX environment variables."
exit 1
fi
CC="$(command -v "$compiler" 2> /dev/null)"
CXX="$(command -v "$cxxCompiler" 2> /dev/null)"
set_compiler_version_from_CC
- else
- if [ "$compiler" = "clang" ] && [ "$majorVersion" -lt 5 ] && { [ "$build_arch" = "arm" ] || [ "$build_arch" = "armel" ]; }; then
- # If a major version was provided explicitly, and it was too old, find a newer compiler instead
- if ! command -v "$compiler" > /dev/null; then
- echo "Error: Found clang version $majorVersion which is not supported on arm/armel architectures, and there is no clang in PATH."
- exit 1
- fi
-
- CC="$(command -v "$compiler" 2> /dev/null)"
- CXX="$(command -v "$cxxCompiler" 2> /dev/null)"
- set_compiler_version_from_CC
- fi
fi
else
- desired_version="$(check_version_exists "$majorVersion" "$minorVersion")"
+ desired_version="$(check_version_exists "$majorVersion")"
if [ "$desired_version" = "-1" ]; then
- echo "Error: Could not find specific version of $compiler: $majorVersion $minorVersion."
+ echo "Error: Could not find specific version of $compiler: $majorVersion."
exit 1
fi
fi
diff --git a/eng/common/post-build/publish-using-darc.ps1 b/eng/common/post-build/publish-using-darc.ps1
index 4ff587ca46a99..90b58e32a87bf 100644
--- a/eng/common/post-build/publish-using-darc.ps1
+++ b/eng/common/post-build/publish-using-darc.ps1
@@ -42,6 +42,7 @@ try {
--azdev-pat "$AzdoToken" `
--bar-uri "$MaestroApiEndPoint" `
--ci `
+ --verbose `
@optionalParams
if ($LastExitCode -ne 0) {
diff --git a/eng/common/templates-official/job/job.yml b/eng/common/templates-official/job/job.yml
index 0c2928d5c799e..3d16b41c78c18 100644
--- a/eng/common/templates-official/job/job.yml
+++ b/eng/common/templates-official/job/job.yml
@@ -1,8 +1,22 @@
+parameters:
+# Sbom related params
+ enableSbom: true
+ PackageVersion: 9.0.0
+ BuildDropPath: '$(Build.SourcesDirectory)/artifacts'
+
jobs:
- template: /eng/common/core-templates/job/job.yml
parameters:
is1ESPipeline: true
+ componentGovernanceSteps:
+ - ${{ if and(eq(parameters.runAsPublic, 'false'), ne(variables['System.TeamProject'], 'public'), notin(variables['Build.Reason'], 'PullRequest'), eq(parameters.enableSbom, 'true')) }}:
+ - template: /eng/common/templates/steps/generate-sbom.yml
+ parameters:
+ PackageVersion: ${{ parameters.packageVersion }}
+ BuildDropPath: ${{ parameters.buildDropPath }}
+ publishArtifacts: false
+
# publish artifacts
# for 1ES managed templates, use the templateContext.output to handle multiple outputs.
templateContext:
diff --git a/eng/common/templates/job/job.yml b/eng/common/templates/job/job.yml
index 8da477dd69f06..07d317bf8f9a4 100644
--- a/eng/common/templates/job/job.yml
+++ b/eng/common/templates/job/job.yml
@@ -19,71 +19,63 @@ jobs:
steps:
- ${{ each step in parameters.steps }}:
- ${{ step }}
-
+
componentGovernanceSteps:
- - template: /eng/common/templates/steps/component-governance.yml
- parameters:
- ${{ if eq(parameters.disableComponentGovernance, '') }}:
- ${{ if and(ne(variables['System.TeamProject'], 'public'), notin(variables['Build.Reason'], 'PullRequest'), eq(parameters.runAsPublic, 'false'), or(startsWith(variables['Build.SourceBranch'], 'refs/heads/release/'), startsWith(variables['Build.SourceBranch'], 'refs/heads/dotnet/'), startsWith(variables['Build.SourceBranch'], 'refs/heads/microsoft/'), eq(variables['Build.SourceBranch'], 'refs/heads/main'))) }}:
- disableComponentGovernance: false
- ${{ else }}:
- disableComponentGovernance: true
+ - template: /eng/common/templates/steps/component-governance.yml
+ parameters:
+ ${{ if eq(parameters.disableComponentGovernance, '') }}:
+ ${{ if and(ne(variables['System.TeamProject'], 'public'), notin(variables['Build.Reason'], 'PullRequest'), eq(parameters.runAsPublic, 'false'), or(startsWith(variables['Build.SourceBranch'], 'refs/heads/release/'), startsWith(variables['Build.SourceBranch'], 'refs/heads/dotnet/'), startsWith(variables['Build.SourceBranch'], 'refs/heads/microsoft/'), eq(variables['Build.SourceBranch'], 'refs/heads/main'))) }}:
+ disableComponentGovernance: false
${{ else }}:
- disableComponentGovernance: ${{ parameters.disableComponentGovernance }}
- componentGovernanceIgnoreDirectories: ${{ parameters.componentGovernanceIgnoreDirectories }}
-
- - ${{ if and(eq(parameters.runAsPublic, 'false'), ne(variables['System.TeamProject'], 'public'), notin(variables['Build.Reason'], 'PullRequest'), eq(parameters.enableSbom, 'true')) }}:
- - template: /eng/common/templates/steps/generate-sbom.yml
- parameters:
- PackageVersion: ${{ parameters.packageVersion }}
- BuildDropPath: ${{ parameters.buildDropPath }}
- publishArtifacts: false
-
+ disableComponentGovernance: true
+ ${{ else }}:
+ disableComponentGovernance: ${{ parameters.disableComponentGovernance }}
+ componentGovernanceIgnoreDirectories: ${{ parameters.componentGovernanceIgnoreDirectories }}
artifactPublishSteps:
- - ${{ if ne(parameters.artifacts.publish, '') }}:
- - ${{ if and(ne(parameters.artifacts.publish.artifacts, 'false'), ne(parameters.artifacts.publish.artifacts, '')) }}:
- - template: /eng/common/core-templates/steps/publish-build-artifacts.yml
- parameters:
- is1ESPipeline: false
- args:
- displayName: Publish pipeline artifacts
- pathToPublish: '$(Build.ArtifactStagingDirectory)/artifacts'
- publishLocation: Container
- artifactName: ${{ coalesce(parameters.artifacts.publish.artifacts.name , 'Artifacts_$(Agent.Os)_$(_BuildConfig)') }}
- continueOnError: true
- condition: always()
- - ${{ if and(ne(parameters.artifacts.publish.logs, 'false'), ne(parameters.artifacts.publish.logs, '')) }}:
- - template: /eng/common/core-templates/steps/publish-pipeline-artifacts.yml
- parameters:
- is1ESPipeline: false
- args:
- targetPath: '$(Build.ArtifactStagingDirectory)/artifacts/log'
- artifactName: ${{ coalesce(parameters.artifacts.publish.logs.name, 'Logs_Build_$(Agent.Os)_$(_BuildConfig)') }}
- displayName: 'Publish logs'
- continueOnError: true
- condition: always()
- sbomEnabled: false # we don't need SBOM for logs
-
- - ${{ if ne(parameters.enablePublishBuildArtifacts, 'false') }}:
+ - ${{ if ne(parameters.artifacts.publish, '') }}:
+ - ${{ if and(ne(parameters.artifacts.publish.artifacts, 'false'), ne(parameters.artifacts.publish.artifacts, '')) }}:
- template: /eng/common/core-templates/steps/publish-build-artifacts.yml
parameters:
is1ESPipeline: false
args:
- displayName: Publish Logs
- pathToPublish: '$(Build.ArtifactStagingDirectory)/artifacts/log/$(_BuildConfig)'
+ displayName: Publish pipeline artifacts
+ pathToPublish: '$(Build.ArtifactStagingDirectory)/artifacts'
publishLocation: Container
- artifactName: ${{ coalesce(parameters.enablePublishBuildArtifacts.artifactName, '$(Agent.Os)_$(Agent.JobName)' ) }}
+ artifactName: ${{ coalesce(parameters.artifacts.publish.artifacts.name , 'Artifacts_$(Agent.Os)_$(_BuildConfig)') }}
continueOnError: true
condition: always()
-
- - ${{ if eq(parameters.enableBuildRetry, 'true') }}:
+ - ${{ if and(ne(parameters.artifacts.publish.logs, 'false'), ne(parameters.artifacts.publish.logs, '')) }}:
- template: /eng/common/core-templates/steps/publish-pipeline-artifacts.yml
parameters:
is1ESPipeline: false
args:
- targetPath: '$(Build.SourcesDirectory)\eng\common\BuildConfiguration'
- artifactName: 'BuildConfiguration'
- displayName: 'Publish build retry configuration'
+ targetPath: '$(Build.ArtifactStagingDirectory)/artifacts/log'
+ artifactName: ${{ coalesce(parameters.artifacts.publish.logs.name, 'Logs_Build_$(Agent.Os)_$(_BuildConfig)') }}
+ displayName: 'Publish logs'
continueOnError: true
- sbomEnabled: false # we don't need SBOM for BuildConfiguration
+ condition: always()
+ sbomEnabled: false # we don't need SBOM for logs
+
+ - ${{ if ne(parameters.enablePublishBuildArtifacts, 'false') }}:
+ - template: /eng/common/core-templates/steps/publish-build-artifacts.yml
+ parameters:
+ is1ESPipeline: false
+ args:
+ displayName: Publish Logs
+ pathToPublish: '$(Build.ArtifactStagingDirectory)/artifacts/log/$(_BuildConfig)'
+ publishLocation: Container
+ artifactName: ${{ coalesce(parameters.enablePublishBuildArtifacts.artifactName, '$(Agent.Os)_$(Agent.JobName)' ) }}
+ continueOnError: true
+ condition: always()
+
+ - ${{ if eq(parameters.enableBuildRetry, 'true') }}:
+ - template: /eng/common/core-templates/steps/publish-pipeline-artifacts.yml
+ parameters:
+ is1ESPipeline: false
+ args:
+ targetPath: '$(Build.SourcesDirectory)\eng\common\BuildConfiguration'
+ artifactName: 'BuildConfiguration'
+ displayName: 'Publish build retry configuration'
+ continueOnError: true
+ sbomEnabled: false # we don't need SBOM for BuildConfiguration
diff --git a/eng/config/PublishData.json b/eng/config/PublishData.json
index bdff2ce9f662e..79d444bd6f09e 100644
--- a/eng/config/PublishData.json
+++ b/eng/config/PublishData.json
@@ -94,6 +94,15 @@
},
"comment-about-servicing-branches": "For a list of VS versions under servicing, see https://docs.microsoft.com/en-us/visualstudio/releases/2019/servicing#support-options-for-enterprise-and-professional-customers",
"branches": {
+ "release/vscode": {
+ "nugetKind": [
+ "Shipping",
+ "NonShipping"
+ ],
+ "vsBranch": "main",
+ "insertionCreateDraftPR": true,
+ "insertionTitlePrefix": "[Validation]"
+ },
"dev15.9.x-vs-deps": {
"nugetKind": "PerBuildPreRelease",
"vsBranch": "rel/d15.9",
@@ -143,24 +152,6 @@
"vsMajorVersion": 17,
"insertionTitlePrefix": "[d17.3]"
},
- "release/dev17.4": {
- "nugetKind": [
- "Shipping",
- "NonShipping"
- ],
- "vsBranch": "rel/d17.4",
- "vsMajorVersion": 17,
- "insertionTitlePrefix": "[d17.4]"
- },
- "release/dev17.5-vs-deps": {
- "nugetKind": [
- "Shipping",
- "NonShipping"
- ],
- "vsBranch": "rel/d17.5",
- "vsMajorVersion": 17,
- "insertionTitlePrefix": "[d17.5]"
- },
"release/dev17.6": {
"nugetKind": [
"Shipping",
@@ -215,6 +206,16 @@
"vsMajorVersion": 17,
"insertionTitlePrefix": "[d17.11]"
},
+ "release/dev17.12": {
+ "nugetKind": [
+ "Shipping",
+ "NonShipping"
+ ],
+ "vsBranch": "rel/d17.12",
+ "vsMajorVersion": 17,
+ "insertionCreateDraftPR": false,
+ "insertionTitlePrefix": "[d17.12 P2]"
+ },
"main": {
"nugetKind": [
"Shipping",
@@ -223,7 +224,7 @@
"vsBranch": "main",
"vsMajorVersion": 17,
"insertionCreateDraftPR": false,
- "insertionTitlePrefix": "[d17.12 P1]"
+ "insertionTitlePrefix": "[d17.12 P3]"
},
"dev/andrha/telemetry": {
"nugetKind": [
diff --git a/eng/config/app.manifest b/eng/config/app.manifest
index 6000b933d37ea..e57d652ba650e 100644
--- a/eng/config/app.manifest
+++ b/eng/config/app.manifest
@@ -14,6 +14,7 @@
true
+ amd64 arm64
-
\ No newline at end of file
+
diff --git a/eng/config/guardian/.gdnsuppress b/eng/config/guardian/.gdnsuppress
deleted file mode 100644
index 9ccb486a7ae08..0000000000000
--- a/eng/config/guardian/.gdnsuppress
+++ /dev/null
@@ -1,41 +0,0 @@
-{
- "properties": {
- "helpUri": "https://eng.ms/docs/microsoft-security/security/azure-security/cloudai-security-fundamentals-engineering/security-integration/guardian-wiki/microsoft-guardian/general/suppressions"
- },
- "version": "1.0.0",
- "suppressionSets": {
- "default": {
- "name": "default",
- "createdDate": "2024-03-21 01:38:07Z",
- "lastUpdatedDate": "2024-03-21 01:38:07Z"
- }
- },
- "results": {
- "847ed085b811316467ddba6a5f31a5084c27c4bb1c4a7d584dc0e857018dc898": {
- "signature": "847ed085b811316467ddba6a5f31a5084c27c4bb1c4a7d584dc0e857018dc898",
- "alternativeSignatures": [
- "3e868456152947a1ac244bf80f7f116223d51ec35a46334f64b621b35255a1aa"
- ],
- "target": "eng/build.ps1",
- "line": 340,
- "memberOf": [
- "default"
- ],
- "tool": "psscriptanalyzer",
- "ruleId": "PSAvoidUsingConvertToSecureStringWithPlainText",
- "createdDate": "2024-03-21 01:38:07Z"
- },
- "ec3b30de7f7c5fca72d402bd7f34279d378700b16d98b2f3da9922fa8db3546f": {
- "signature": "ec3b30de7f7c5fca72d402bd7f34279d378700b16d98b2f3da9922fa8db3546f",
- "alternativeSignatures": [],
- "target": "src/EditorFeatures/CSharpTest2/EmbeddedLanguages/Json/CSharpJsonParserTests_BasicTests.cs",
- "line": 4207,
- "memberOf": [
- "default"
- ],
- "tool": "credscan",
- "ruleId": "CSCAN-GENERAL0060",
- "createdDate": "2024-03-21 01:38:07Z"
- }
- }
-}
\ No newline at end of file
diff --git a/eng/targets/ILAsm.targets b/eng/targets/ILAsm.targets
index edc2368e0ebad..9fa6580b2ce56 100644
--- a/eng/targets/ILAsm.targets
+++ b/eng/targets/ILAsm.targets
@@ -12,6 +12,12 @@
false
false
+
+ PreserveNewest
+ runtimes
+ false
+ false
+
PreserveNewest
runtimes
@@ -26,7 +32,8 @@
+
-
\ No newline at end of file
+
diff --git a/eng/targets/ILDAsm.targets b/eng/targets/ILDAsm.targets
index 9e94a720804b8..2992ece5a1d44 100644
--- a/eng/targets/ILDAsm.targets
+++ b/eng/targets/ILDAsm.targets
@@ -11,6 +11,12 @@
false
false
+
+ PreserveNewest
+ runtimes
+ false
+ false
+
PreserveNewest
runtimes
@@ -25,7 +31,8 @@
+
-
\ No newline at end of file
+
diff --git a/eng/targets/Imports.targets b/eng/targets/Imports.targets
index 46eb0380702c3..ba2a9ac4f8433 100644
--- a/eng/targets/Imports.targets
+++ b/eng/targets/Imports.targets
@@ -4,6 +4,7 @@
+
+
+
+
+
+
diff --git a/eng/targets/Services.props b/eng/targets/Services.props
index 7a1dd4ad79358..590cd0c2a1518 100644
--- a/eng/targets/Services.props
+++ b/eng/targets/Services.props
@@ -13,38 +13,39 @@
+
+
+
+
+
-
+
-
-
-
-
+
+
+
+
+
+
-
-
-
-
-
-
+
-
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
+
+
<_SkipUpgradeNetAnalyzersNuGetWarning>true
-
- false
-
$(CoreCompileDependsOn);ResolveKeySource
diff --git a/eng/targets/VisualStudio.targets b/eng/targets/VisualStudio.targets
index 9d5b9b3fc2818..64e8116ca4adf 100644
--- a/eng/targets/VisualStudio.targets
+++ b/eng/targets/VisualStudio.targets
@@ -143,4 +143,35 @@
+
+
+
+
+
+
+
+ $(CreateVsixContainerDependsOn);PublishProjectReferencesForVsixCreation
+
+
+
+
+ <_ProjectsToPublish Include="@(ProjectReference)" Condition="$([MSBuild]::ValueOrDefault('%(ProjectReference.IncludeOutputGroupsInVSIX)', '').Contains('PublishedProjectOutputGroup'))"/>
+
+
+
+
diff --git a/eng/targets/WpfWorkarounds.targets b/eng/targets/WpfWorkarounds.targets
new file mode 100644
index 0000000000000..4bc46a00f1ccb
--- /dev/null
+++ b/eng/targets/WpfWorkarounds.targets
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+ <_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/test-build-correctness.ps1 b/eng/test-build-correctness.ps1
index 9c131c1d189c4..aab81e9a89b6c 100644
--- a/eng/test-build-correctness.ps1
+++ b/eng/test-build-correctness.ps1
@@ -75,7 +75,7 @@ catch {
Write-Host $_
Write-Host $_.Exception
Write-Host $_.ScriptStackTrace
- Write-Host "##vso[task.logissue type=error]How to investigate bootstrap failures: https://github.com/dotnet/roslyn/blob/main/docs/compilers/Bootstrap%20Builds.md#Investigating"
+ Write-Host "##vso[task.logissue type=error]How to investigate bootstrap failures: https://github.com/dotnet/roslyn/blob/main/docs/contributing/Bootstrap%20Builds.md#Investigating"
ExitWithExitCode 1
}
finally {
diff --git a/global.json b/global.json
index 2cd32c6ddbf19..2e5746985615d 100644
--- a/global.json
+++ b/global.json
@@ -1,18 +1,18 @@
{
"sdk": {
- "version": "9.0.100-preview.5.24307.3",
+ "version": "9.0.100-preview.7.24407.12",
"allowPrerelease": false,
"rollForward": "patch"
},
"tools": {
- "dotnet": "9.0.100-preview.5.24307.3",
+ "dotnet": "9.0.100-preview.7.24407.12",
"vs": {
"version": "17.8.0"
}
},
"msbuild-sdks": {
- "Microsoft.DotNet.Arcade.Sdk": "9.0.0-beta.24352.2",
- "Microsoft.DotNet.Helix.Sdk": "9.0.0-beta.24352.2",
+ "Microsoft.DotNet.Arcade.Sdk": "9.0.0-beta.24459.6",
+ "Microsoft.DotNet.Helix.Sdk": "9.0.0-beta.24459.6",
"Microsoft.Build.Traversal": "3.4.0"
}
}
diff --git a/scripts/vscode-build.ps1 b/scripts/vscode-build.ps1
index 42f3c0475b9c1..4c1722c6fa927 100644
--- a/scripts/vscode-build.ps1
+++ b/scripts/vscode-build.ps1
@@ -14,7 +14,7 @@ $projectFileInfo = Get-ProjectFile $fileInfo
if ($projectFileInfo) {
$buildTool = InitializeBuildTool
$frameworkArg = if ($framework -ne "") { " -p:TargetFramework=$framework" } else { "" }
- $buildArgs = "$($buildTool.Command) -v:m -m -p:RunAnalyzersDuringBuild=false -p:GenerateFullPaths=true$frameworkArg $($projectFileInfo.FullName)"
+ $buildArgs = "$($buildTool.Command) -v:m -tl:off -m -p:RunAnalyzersDuringBuild=false -p:GenerateFullPaths=true$frameworkArg $($projectFileInfo.FullName)"
Exec-Command $buildTool.Path $buildArgs
exit 0
diff --git a/src/Analyzers/CSharp/Analyzers/RemoveUnusedMembers/CSharpRemoveUnusedMembersDiagnosticAnalyzer.cs b/src/Analyzers/CSharp/Analyzers/RemoveUnusedMembers/CSharpRemoveUnusedMembersDiagnosticAnalyzer.cs
index 2bb616b174829..55ed47da767b2 100644
--- a/src/Analyzers/CSharp/Analyzers/RemoveUnusedMembers/CSharpRemoveUnusedMembersDiagnosticAnalyzer.cs
+++ b/src/Analyzers/CSharp/Analyzers/RemoveUnusedMembers/CSharpRemoveUnusedMembersDiagnosticAnalyzer.cs
@@ -8,11 +8,12 @@
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.CodeAnalysis.RemoveUnusedMembers;
+using Microsoft.CodeAnalysis.Shared.Extensions;
namespace Microsoft.CodeAnalysis.CSharp.RemoveUnusedMembers;
[DiagnosticAnalyzer(LanguageNames.CSharp)]
-internal class CSharpRemoveUnusedMembersDiagnosticAnalyzer
+internal sealed class CSharpRemoveUnusedMembersDiagnosticAnalyzer
: AbstractRemoveUnusedMembersDiagnosticAnalyzer<
DocumentationCommentTriviaSyntax,
IdentifierNameSyntax,
@@ -28,4 +29,18 @@ protected override IEnumerable GetTypeDeclarations(INamed
protected override SyntaxList GetMembers(TypeDeclarationSyntax typeDeclaration)
=> typeDeclaration.Members;
+
+ protected override SyntaxNode GetParentIfSoleDeclarator(SyntaxNode node)
+ {
+ return node switch
+ {
+ VariableDeclaratorSyntax variableDeclarator
+ => variableDeclarator.Parent is VariableDeclarationSyntax
+ {
+ Parent: FieldDeclarationSyntax { Declaration.Variables.Count: 0 } or
+ EventFieldDeclarationSyntax { Declaration.Variables.Count: 0 }
+ } declaration ? declaration.GetRequiredParent() : node,
+ _ => node,
+ };
+ }
}
diff --git a/src/Analyzers/CSharp/Analyzers/UseCollectionExpression/CSharpUseCollectionExpressionForArrayDiagnosticAnalyzer.cs b/src/Analyzers/CSharp/Analyzers/UseCollectionExpression/CSharpUseCollectionExpressionForArrayDiagnosticAnalyzer.cs
index 887b530668f8c..eacc1e33f9758 100644
--- a/src/Analyzers/CSharp/Analyzers/UseCollectionExpression/CSharpUseCollectionExpressionForArrayDiagnosticAnalyzer.cs
+++ b/src/Analyzers/CSharp/Analyzers/UseCollectionExpression/CSharpUseCollectionExpressionForArrayDiagnosticAnalyzer.cs
@@ -17,7 +17,7 @@
namespace Microsoft.CodeAnalysis.CSharp.UseCollectionExpression;
-using static SyntaxFactory;
+using static UseCollectionExpressionHelpers;
[DiagnosticAnalyzer(LanguageNames.CSharp)]
internal sealed partial class CSharpUseCollectionExpressionForArrayDiagnosticAnalyzer()
@@ -49,7 +49,8 @@ private void AnalyzeArrayCreationExpression(SyntaxNodeAnalysisContext context, I
// Analyze the statements that follow to see if they can initialize this array.
var allowSemanticsChange = option.Value is CollectionExpressionPreference.WhenTypesLooselyMatch;
- var matches = TryGetMatches(semanticModel, arrayCreationExpression, expressionType, allowSemanticsChange, cancellationToken, out var changesSemantics);
+ var replacementExpression = CreateReplacementCollectionExpressionForAnalysis(arrayCreationExpression.Initializer);
+ var matches = TryGetMatches(semanticModel, arrayCreationExpression, replacementExpression, expressionType, allowSemanticsChange, cancellationToken, out var changesSemantics);
if (matches.IsDefault)
return;
@@ -59,6 +60,7 @@ private void AnalyzeArrayCreationExpression(SyntaxNodeAnalysisContext context, I
public static ImmutableArray> TryGetMatches(
SemanticModel semanticModel,
ArrayCreationExpressionSyntax expression,
+ CollectionExpressionSyntax replacementExpression,
INamedTypeSymbol? expressionType,
bool allowSemanticsChange,
CancellationToken cancellationToken,
@@ -69,6 +71,7 @@ public static ImmutableArray> TryGetM
var matches = UseCollectionExpressionHelpers.TryGetMatches(
semanticModel,
expression,
+ replacementExpression,
expressionType,
isSingletonInstance: false,
allowSemanticsChange,
@@ -79,8 +82,8 @@ public static ImmutableArray> TryGetM
if (matches.IsDefault)
return default;
- if (!UseCollectionExpressionHelpers.CanReplaceWithCollectionExpression(
- semanticModel, expression, expressionType, isSingletonInstance: false, allowSemanticsChange, skipVerificationForReplacedNode: true, cancellationToken, out changesSemantics))
+ if (!CanReplaceWithCollectionExpression(
+ semanticModel, expression, replacementExpression, expressionType, isSingletonInstance: false, allowSemanticsChange, skipVerificationForReplacedNode: true, cancellationToken, out changesSemantics))
{
return default;
}
@@ -101,7 +104,7 @@ public static ImmutableArray> TryGetM
if (ienumerableType is null)
return default;
- if (!UseCollectionExpressionHelpers.IsConstructibleCollectionType(
+ if (!IsConstructibleCollectionType(
semanticModel.Compilation, ienumerableType.TypeArguments.Single()))
{
return default;
@@ -114,6 +117,7 @@ public static ImmutableArray> TryGetM
public static ImmutableArray> TryGetMatches(
SemanticModel semanticModel,
ImplicitArrayCreationExpressionSyntax expression,
+ CollectionExpressionSyntax replacementExpression,
INamedTypeSymbol? expressionType,
bool allowSemanticsChange,
CancellationToken cancellationToken,
@@ -121,8 +125,8 @@ public static ImmutableArray> TryGetM
{
// if we have `new[] { ... }` we have no subsequent matches to add to the collection. All values come
// from within the initializer.
- if (!UseCollectionExpressionHelpers.CanReplaceWithCollectionExpression(
- semanticModel, expression, expressionType, isSingletonInstance: false, allowSemanticsChange, skipVerificationForReplacedNode: true, cancellationToken, out changesSemantics))
+ if (!CanReplaceWithCollectionExpression(
+ semanticModel, expression, replacementExpression, expressionType, isSingletonInstance: false, allowSemanticsChange, skipVerificationForReplacedNode: true, cancellationToken, out changesSemantics))
{
return default;
}
@@ -154,11 +158,10 @@ private void AnalyzeArrayInitializerExpression(SyntaxNodeAnalysisContext context
// Have to actually examine what would happen when we do the replacement, as the replaced value may interact
// with inference based on the values within.
- var replacementCollectionExpression = CollectionExpression(
- [.. initializer.Expressions.Select(ExpressionElement)]);
+ var replacementCollectionExpression = CreateReplacementCollectionExpressionForAnalysis(initializer);
var allowSemanticsChange = option.Value is CollectionExpressionPreference.WhenTypesLooselyMatch;
- if (!UseCollectionExpressionHelpers.CanReplaceWithCollectionExpression(
+ if (!CanReplaceWithCollectionExpression(
semanticModel, arrayCreationExpression, replacementCollectionExpression,
expressionType, isSingletonInstance: false, allowSemanticsChange, skipVerificationForReplacedNode: true, cancellationToken,
out var changesSemantics))
@@ -170,8 +173,8 @@ private void AnalyzeArrayInitializerExpression(SyntaxNodeAnalysisContext context
{
var matches = initializer.Parent switch
{
- ArrayCreationExpressionSyntax arrayCreation => TryGetMatches(semanticModel, arrayCreation, expressionType, allowSemanticsChange, cancellationToken, out _),
- ImplicitArrayCreationExpressionSyntax arrayCreation => TryGetMatches(semanticModel, arrayCreation, expressionType, allowSemanticsChange, cancellationToken, out _),
+ ArrayCreationExpressionSyntax arrayCreation => TryGetMatches(semanticModel, arrayCreation, replacementCollectionExpression, expressionType, allowSemanticsChange, cancellationToken, out _),
+ ImplicitArrayCreationExpressionSyntax arrayCreation => TryGetMatches(semanticModel, arrayCreation, replacementCollectionExpression, expressionType, allowSemanticsChange, cancellationToken, out _),
_ => throw ExceptionUtilities.Unreachable(),
};
diff --git a/src/Analyzers/CSharp/Analyzers/UseCollectionExpression/CSharpUseCollectionExpressionForStackAllocDiagnosticAnalyzer.cs b/src/Analyzers/CSharp/Analyzers/UseCollectionExpression/CSharpUseCollectionExpressionForStackAllocDiagnosticAnalyzer.cs
index dc8fc2a87fc37..607899dd00c26 100644
--- a/src/Analyzers/CSharp/Analyzers/UseCollectionExpression/CSharpUseCollectionExpressionForStackAllocDiagnosticAnalyzer.cs
+++ b/src/Analyzers/CSharp/Analyzers/UseCollectionExpression/CSharpUseCollectionExpressionForStackAllocDiagnosticAnalyzer.cs
@@ -12,6 +12,8 @@
namespace Microsoft.CodeAnalysis.CSharp.UseCollectionExpression;
+using static UseCollectionExpressionHelpers;
+
[DiagnosticAnalyzer(LanguageNames.CSharp)]
internal sealed partial class CSharpUseCollectionExpressionForStackAllocDiagnosticAnalyzer
: AbstractCSharpUseCollectionExpressionDiagnosticAnalyzer
@@ -127,6 +129,7 @@ public static ImmutableArray> TryGetM
return UseCollectionExpressionHelpers.TryGetMatches(
semanticModel,
expression,
+ CreateReplacementCollectionExpressionForAnalysis(expression.Initializer),
expressionType,
isSingletonInstance: false,
allowSemanticsChange,
diff --git a/src/Analyzers/CSharp/Analyzers/UseCollectionExpression/UseCollectionExpressionHelpers.cs b/src/Analyzers/CSharp/Analyzers/UseCollectionExpression/UseCollectionExpressionHelpers.cs
index 15d93e2106889..bedba7efb662a 100644
--- a/src/Analyzers/CSharp/Analyzers/UseCollectionExpression/UseCollectionExpressionHelpers.cs
+++ b/src/Analyzers/CSharp/Analyzers/UseCollectionExpression/UseCollectionExpressionHelpers.cs
@@ -33,11 +33,15 @@ internal static class UseCollectionExpressionHelpers
distinguishRefFromOut: true,
// Not relevant. We are not comparing method signatures.
objectAndDynamicCompareEqually: false,
+ // Not relevant. We are not comparing method signatures.
+ arrayAndReadOnlySpanCompareEqually: false,
// The value we're tweaking.
tupleNamesMustMatch: false,
// We do not want to ignore this. `ImmutableArray` should not be convertible to `ImmutableArray`
ignoreNullableAnnotations: false);
+ private static readonly SymbolEquivalenceComparer s_arrayAndReadOnlySpanCompareEquallyComparer = s_tupleNamesCanDifferComparer.With(arrayAndReadOnlySpanCompareEqually: true);
+
public static bool CanReplaceWithCollectionExpression(
SemanticModel semanticModel,
ExpressionSyntax expression,
@@ -147,9 +151,17 @@ public static bool CanReplaceWithCollectionExpression(
// The new expression's converted type has to equal the old expressions as well. Otherwise, we're now
// converting this to some different collection type unintentionally.
+ //
+ // Note: it's acceptable to be originally converting to an array, and now converting to a ROS. This occurs with
+ // APIs that started out just taking an array, but which now have an overload that takes a span. APIs should
+ // only do this when the new api has the same semantics (outside of perf), and the language and runtime strongly
+ // want code to call the new api. So it's desirable to change here.
var replacedTypeInfo = speculationAnalyzer.SpeculativeSemanticModel.GetTypeInfo(speculationAnalyzer.ReplacedExpression, cancellationToken);
- if (!originalTypeInfo.ConvertedType.Equals(replacedTypeInfo.ConvertedType))
+ if (!originalTypeInfo.ConvertedType.Equals(replacedTypeInfo.ConvertedType) &&
+ !s_arrayAndReadOnlySpanCompareEquallyComparer.Equals(originalTypeInfo.ConvertedType, replacedTypeInfo.ConvertedType))
+ {
return false;
+ }
return true;
@@ -805,6 +817,7 @@ private static bool ShouldReplaceExistingExpressionEntirely(
public static ImmutableArray> TryGetMatches(
SemanticModel semanticModel,
TArrayCreationExpressionSyntax expression,
+ CollectionExpressionSyntax replacementExpression,
INamedTypeSymbol? expressionType,
bool isSingletonInstance,
bool allowSemanticsChange,
@@ -914,7 +927,7 @@ public static ImmutableArray> TryGetM
}
if (!CanReplaceWithCollectionExpression(
- semanticModel, expression, expressionType, isSingletonInstance, allowSemanticsChange, skipVerificationForReplacedNode: true, cancellationToken, out changesSemantics))
+ semanticModel, expression, replacementExpression, expressionType, isSingletonInstance, allowSemanticsChange, skipVerificationForReplacedNode: true, cancellationToken, out changesSemantics))
{
return default;
}
@@ -1222,4 +1235,7 @@ public static SeparatedSyntaxList GetArguments(InvocationExpress
: SeparatedList(initializer.Expressions.GetWithSeparators().Select(
nodeOrToken => nodeOrToken.IsToken ? nodeOrToken : Argument((ExpressionSyntax)nodeOrToken.AsNode()!)));
}
+
+ public static CollectionExpressionSyntax CreateReplacementCollectionExpressionForAnalysis(InitializerExpressionSyntax? initializer)
+ => initializer is null ? s_emptyCollectionExpression : CollectionExpression([.. initializer.Expressions.Select(ExpressionElement)]);
}
diff --git a/src/Analyzers/CSharp/CodeFixes/AddInheritdoc/AddInheritdocCodeFixProvider.cs b/src/Analyzers/CSharp/CodeFixes/AddInheritdoc/AddInheritdocCodeFixProvider.cs
index c835f9f901206..eab69a511fc47 100644
--- a/src/Analyzers/CSharp/CodeFixes/AddInheritdoc/AddInheritdocCodeFixProvider.cs
+++ b/src/Analyzers/CSharp/CodeFixes/AddInheritdoc/AddInheritdocCodeFixProvider.cs
@@ -11,6 +11,7 @@
using Microsoft.CodeAnalysis.CodeActions;
using Microsoft.CodeAnalysis.CodeFixes;
using Microsoft.CodeAnalysis.Editing;
+using Microsoft.CodeAnalysis.Formatting;
using Microsoft.CodeAnalysis.Host.Mef;
using Microsoft.CodeAnalysis.Shared.Extensions;
using Microsoft.CodeAnalysis.Text;
@@ -89,8 +90,8 @@ protected override async Task FixAllAsync(Document document, ImmutableArray
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -77,6 +95,7 @@
+
diff --git a/src/Analyzers/CSharp/CodeFixes/ConvertNamespace/ConvertNamespaceCodeFixProvider.cs b/src/Analyzers/CSharp/CodeFixes/ConvertNamespace/ConvertNamespaceCodeFixProvider.cs
index b39e9e57791f8..7bcd0962149a7 100644
--- a/src/Analyzers/CSharp/CodeFixes/ConvertNamespace/ConvertNamespaceCodeFixProvider.cs
+++ b/src/Analyzers/CSharp/CodeFixes/ConvertNamespace/ConvertNamespaceCodeFixProvider.cs
@@ -11,6 +11,7 @@
using Microsoft.CodeAnalysis.CodeActions;
using Microsoft.CodeAnalysis.CodeFixes;
using Microsoft.CodeAnalysis.CodeStyle;
+using Microsoft.CodeAnalysis.CSharp.Formatting;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.CodeAnalysis.Editing;
@@ -55,8 +56,8 @@ protected override async Task FixAllAsync(
var namespaceDecl = (BaseNamespaceDeclarationSyntax)diagnostic.AdditionalLocations[0].FindNode(cancellationToken);
- var options = await document.GetCSharpCodeFixOptionsProviderAsync(cancellationToken).ConfigureAwait(false);
- var converted = await ConvertNamespaceTransform.ConvertAsync(document, namespaceDecl, options.GetFormattingOptions(), cancellationToken).ConfigureAwait(false);
+ var options = await document.GetCSharpSyntaxFormattingOptionsAsync(cancellationToken).ConfigureAwait(false);
+ var converted = await ConvertNamespaceTransform.ConvertAsync(document, namespaceDecl, options, cancellationToken).ConfigureAwait(false);
editor.ReplaceNode(
editor.OriginalRoot,
diff --git a/src/Analyzers/CSharp/CodeFixes/ConvertNamespace/ConvertNamespaceTransform.cs b/src/Analyzers/CSharp/CodeFixes/ConvertNamespace/ConvertNamespaceTransform.cs
index e4476ae00ee0a..4b628007a97d0 100644
--- a/src/Analyzers/CSharp/CodeFixes/ConvertNamespace/ConvertNamespaceTransform.cs
+++ b/src/Analyzers/CSharp/CodeFixes/ConvertNamespace/ConvertNamespaceTransform.cs
@@ -291,9 +291,9 @@ private static SyntaxNode ReplaceWithBlockScopedNamespace(
}
return document.Root.ReplaceSyntax(
- new SyntaxNode[] { namespaceDeclaration },
+ [namespaceDeclaration],
(_, _) => converted.WithAdditionalAnnotations(annotation),
- new SyntaxToken[] { tokenAfterNamespace },
+ [tokenAfterNamespace],
(_, _) => tokenAfterNamespace.WithLeadingTrivia(triviaAfterSplit),
[],
(_, _) => throw ExceptionUtilities.Unreachable());
diff --git a/src/Analyzers/CSharp/CodeFixes/ConvertToRecord/ConvertToRecordEngine.cs b/src/Analyzers/CSharp/CodeFixes/ConvertToRecord/ConvertToRecordEngine.cs
index 6efd82df26bf0..452531f32dac9 100644
--- a/src/Analyzers/CSharp/CodeFixes/ConvertToRecord/ConvertToRecordEngine.cs
+++ b/src/Analyzers/CSharp/CodeFixes/ConvertToRecord/ConvertToRecordEngine.cs
@@ -239,8 +239,7 @@ await RefactorInitializersAsync(type, solutionEditor, propertiesToAssign, cancel
}
}
- var optionsProvider = await document.GetCodeFixOptionsAsync(cancellationToken).ConfigureAwait(false);
- var lineFormattingOptions = optionsProvider.GetLineFormattingOptions();
+ var lineFormattingOptions = await document.GetLineFormattingOptionsAsync(cancellationToken).ConfigureAwait(false);
var modifiedClassTrivia = GetModifiedClassTrivia(
positionalParameterInfos, typeDeclaration, lineFormattingOptions);
diff --git a/src/Features/CSharp/Portable/GenerateConstructor/CSharpGenerateConstructorService.cs b/src/Analyzers/CSharp/CodeFixes/GenerateConstructor/CSharpGenerateConstructorService.cs
similarity index 100%
rename from src/Features/CSharp/Portable/GenerateConstructor/CSharpGenerateConstructorService.cs
rename to src/Analyzers/CSharp/CodeFixes/GenerateConstructor/CSharpGenerateConstructorService.cs
diff --git a/src/Features/CSharp/Portable/GenerateConstructor/GenerateConstructorCodeFixProvider.cs b/src/Analyzers/CSharp/CodeFixes/GenerateConstructor/GenerateConstructorCodeFixProvider.cs
similarity index 88%
rename from src/Features/CSharp/Portable/GenerateConstructor/GenerateConstructorCodeFixProvider.cs
rename to src/Analyzers/CSharp/CodeFixes/GenerateConstructor/GenerateConstructorCodeFixProvider.cs
index ec7933d35312d..e2b20ae46539f 100644
--- a/src/Features/CSharp/Portable/GenerateConstructor/GenerateConstructorCodeFixProvider.cs
+++ b/src/Analyzers/CSharp/CodeFixes/GenerateConstructor/GenerateConstructorCodeFixProvider.cs
@@ -34,14 +34,10 @@ namespace Microsoft.CodeAnalysis.CSharp.GenerateConstructor;
///
[ExportCodeFixProvider(LanguageNames.CSharp, Name = PredefinedCodeFixProviderNames.GenerateConstructor), Shared]
[ExtensionOrder(After = PredefinedCodeFixProviderNames.FullyQualify)]
-internal class GenerateConstructorCodeFixProvider : AbstractGenerateMemberCodeFixProvider
+[method: ImportingConstructor]
+[method: SuppressMessage("RoslynDiagnosticsReliability", "RS0033:Importing constructor should be [Obsolete]", Justification = "Used in test code: https://github.com/dotnet/roslyn/issues/42814")]
+internal sealed class GenerateConstructorCodeFixProvider() : AbstractGenerateMemberCodeFixProvider
{
- [ImportingConstructor]
- [SuppressMessage("RoslynDiagnosticsReliability", "RS0033:Importing constructor should be [Obsolete]", Justification = "Used in test code: https://github.com/dotnet/roslyn/issues/42814")]
- public GenerateConstructorCodeFixProvider()
- {
- }
-
public override ImmutableArray FixableDiagnosticIds => GenerateConstructorDiagnosticIds.AllDiagnosticIds;
protected override Task> GetCodeActionsAsync(
diff --git a/src/Features/CSharp/Portable/GenerateDefaultConstructors/CSharpGenerateDefaultConstructorsCodeFixProvider.cs b/src/Analyzers/CSharp/CodeFixes/GenerateDefaultConstructors/CSharpGenerateDefaultConstructorsCodeFixProvider.cs
similarity index 83%
rename from src/Features/CSharp/Portable/GenerateDefaultConstructors/CSharpGenerateDefaultConstructorsCodeFixProvider.cs
rename to src/Analyzers/CSharp/CodeFixes/GenerateDefaultConstructors/CSharpGenerateDefaultConstructorsCodeFixProvider.cs
index c650876bd8a11..65a8d18ad1354 100644
--- a/src/Features/CSharp/Portable/GenerateDefaultConstructors/CSharpGenerateDefaultConstructorsCodeFixProvider.cs
+++ b/src/Analyzers/CSharp/CodeFixes/GenerateDefaultConstructors/CSharpGenerateDefaultConstructorsCodeFixProvider.cs
@@ -13,18 +13,15 @@
namespace Microsoft.CodeAnalysis.CSharp.GenerateDefaultConstructors;
[ExportCodeFixProvider(LanguageNames.CSharp, Name = PredefinedCodeFixProviderNames.GenerateDefaultConstructors), Shared]
-internal class CSharpGenerateDefaultConstructorsCodeFixProvider : AbstractGenerateDefaultConstructorCodeFixProvider
+[method: ImportingConstructor]
+[method: Obsolete(MefConstruction.ImportingConstructorMessage, error: true)]
+internal sealed class CSharpGenerateDefaultConstructorsCodeFixProvider()
+ : AbstractGenerateDefaultConstructorCodeFixProvider
{
private const string CS1729 = nameof(CS1729); // 'B' does not contain a constructor that takes 0 arguments CSharpConsoleApp3 C:\Users\cyrusn\source\repos\CSharpConsoleApp3\CSharpConsoleApp3\Program.cs 1 Active
private const string CS7036 = nameof(CS7036); // There is no argument given that corresponds to the required parameter 's' of 'B.B(string)'
private const string CS8983 = nameof(CS8983); // CS8983: A 'struct' with field initializers must include an explicitly declared constructor.
- [ImportingConstructor]
- [Obsolete(MefConstruction.ImportingConstructorMessage, error: true)]
- public CSharpGenerateDefaultConstructorsCodeFixProvider()
- {
- }
-
public override ImmutableArray FixableDiagnosticIds { get; } =
[CS1729, CS7036, CS8983];
diff --git a/src/Features/CSharp/Portable/GenerateDefaultConstructors/CSharpGenerateDefaultConstructorsService.cs b/src/Analyzers/CSharp/CodeFixes/GenerateDefaultConstructors/CSharpGenerateDefaultConstructorsService.cs
similarity index 89%
rename from src/Features/CSharp/Portable/GenerateDefaultConstructors/CSharpGenerateDefaultConstructorsService.cs
rename to src/Analyzers/CSharp/CodeFixes/GenerateDefaultConstructors/CSharpGenerateDefaultConstructorsService.cs
index 23fe06ecf003e..4f10d1692a870 100644
--- a/src/Features/CSharp/Portable/GenerateDefaultConstructors/CSharpGenerateDefaultConstructorsService.cs
+++ b/src/Analyzers/CSharp/CodeFixes/GenerateDefaultConstructors/CSharpGenerateDefaultConstructorsService.cs
@@ -18,14 +18,10 @@
namespace Microsoft.CodeAnalysis.CSharp.GenerateDefaultConstructors;
[ExportLanguageService(typeof(IGenerateDefaultConstructorsService), LanguageNames.CSharp), Shared]
-internal class CSharpGenerateDefaultConstructorsService : AbstractGenerateDefaultConstructorsService
+[method: ImportingConstructor]
+[method: Obsolete(MefConstruction.ImportingConstructorMessage, error: true)]
+internal sealed class CSharpGenerateDefaultConstructorsService() : AbstractGenerateDefaultConstructorsService
{
- [ImportingConstructor]
- [Obsolete(MefConstruction.ImportingConstructorMessage, error: true)]
- public CSharpGenerateDefaultConstructorsService()
- {
- }
-
protected override bool TryInitializeState(
SemanticDocument semanticDocument, TextSpan textSpan, CancellationToken cancellationToken,
[NotNullWhen(true)] out INamedTypeSymbol? classType)
diff --git a/src/Features/CSharp/Portable/GenerateMember/GenerateEnumMember/CSharpGenerateEnumMemberService.cs b/src/Analyzers/CSharp/CodeFixes/GenerateEnumMember/CSharpGenerateEnumMemberService.cs
similarity index 91%
rename from src/Features/CSharp/Portable/GenerateMember/GenerateEnumMember/CSharpGenerateEnumMemberService.cs
rename to src/Analyzers/CSharp/CodeFixes/GenerateEnumMember/CSharpGenerateEnumMemberService.cs
index 10d3a4fd5598c..25785bb31454f 100644
--- a/src/Features/CSharp/Portable/GenerateMember/GenerateEnumMember/CSharpGenerateEnumMemberService.cs
+++ b/src/Analyzers/CSharp/CodeFixes/GenerateEnumMember/CSharpGenerateEnumMemberService.cs
@@ -14,15 +14,11 @@
namespace Microsoft.CodeAnalysis.CSharp.GenerateMember.GenerateEnumMember;
[ExportLanguageService(typeof(IGenerateEnumMemberService), LanguageNames.CSharp), Shared]
-internal partial class CSharpGenerateEnumMemberService :
+[method: ImportingConstructor]
+[method: Obsolete(MefConstruction.ImportingConstructorMessage, error: true)]
+internal sealed partial class CSharpGenerateEnumMemberService() :
AbstractGenerateEnumMemberService
{
- [ImportingConstructor]
- [Obsolete(MefConstruction.ImportingConstructorMessage, error: true)]
- public CSharpGenerateEnumMemberService()
- {
- }
-
protected override bool IsIdentifierNameGeneration(SyntaxNode node)
=> node is IdentifierNameSyntax;
diff --git a/src/Features/CSharp/Portable/CodeFixes/GenerateEnumMember/GenerateEnumMemberCodeFixProvider.cs b/src/Analyzers/CSharp/CodeFixes/GenerateEnumMember/GenerateEnumMemberCodeFixProvider.cs
similarity index 83%
rename from src/Features/CSharp/Portable/CodeFixes/GenerateEnumMember/GenerateEnumMemberCodeFixProvider.cs
rename to src/Analyzers/CSharp/CodeFixes/GenerateEnumMember/GenerateEnumMemberCodeFixProvider.cs
index 9c8da121dba61..0c6119fbe7905 100644
--- a/src/Features/CSharp/Portable/CodeFixes/GenerateEnumMember/GenerateEnumMemberCodeFixProvider.cs
+++ b/src/Analyzers/CSharp/CodeFixes/GenerateEnumMember/GenerateEnumMemberCodeFixProvider.cs
@@ -19,17 +19,13 @@ namespace Microsoft.CodeAnalysis.CSharp.CodeFixes.GenerateEnumMember;
[ExportCodeFixProvider(LanguageNames.CSharp, Name = PredefinedCodeFixProviderNames.GenerateEnumMember), Shared]
[ExtensionOrder(After = PredefinedCodeFixProviderNames.GenerateConstructor)]
-internal class GenerateEnumMemberCodeFixProvider : AbstractGenerateMemberCodeFixProvider
+[method: ImportingConstructor]
+[method: SuppressMessage("RoslynDiagnosticsReliability", "RS0033:Importing constructor should be [Obsolete]", Justification = "Used in test code: https://github.com/dotnet/roslyn/issues/42814")]
+internal sealed class GenerateEnumMemberCodeFixProvider() : AbstractGenerateMemberCodeFixProvider
{
private const string CS0117 = nameof(CS0117); // error CS0117: 'Color' does not contain a definition for 'Red'
private const string CS1061 = nameof(CS1061); // error CS1061: 'Color' does not contain a definition for 'Red' and no accessible extension method 'Red' accepting a first argument of type 'Color' could be found
- [ImportingConstructor]
- [SuppressMessage("RoslynDiagnosticsReliability", "RS0033:Importing constructor should be [Obsolete]", Justification = "Used in test code: https://github.com/dotnet/roslyn/issues/42814")]
- public GenerateEnumMemberCodeFixProvider()
- {
- }
-
public override ImmutableArray FixableDiagnosticIds { get; } =
[CS0117, CS1061];
diff --git a/src/Features/CSharp/Portable/CodeFixes/GenerateMethod/GenerateConversionCodeFixProvider.cs b/src/Analyzers/CSharp/CodeFixes/GenerateMethod/GenerateConversionCodeFixProvider.cs
similarity index 87%
rename from src/Features/CSharp/Portable/CodeFixes/GenerateMethod/GenerateConversionCodeFixProvider.cs
rename to src/Analyzers/CSharp/CodeFixes/GenerateMethod/GenerateConversionCodeFixProvider.cs
index 4bfacf947f333..af47c46976f2f 100644
--- a/src/Features/CSharp/Portable/CodeFixes/GenerateMethod/GenerateConversionCodeFixProvider.cs
+++ b/src/Analyzers/CSharp/CodeFixes/GenerateMethod/GenerateConversionCodeFixProvider.cs
@@ -20,17 +20,13 @@ namespace Microsoft.CodeAnalysis.CSharp.CodeFixes.GenerateMethod;
[ExportCodeFixProvider(LanguageNames.CSharp, Name = PredefinedCodeFixProviderNames.GenerateConversion), Shared]
[ExtensionOrder(After = PredefinedCodeFixProviderNames.GenerateEnumMember)]
-internal class GenerateConversionCodeFixProvider : AbstractGenerateMemberCodeFixProvider
+[method: ImportingConstructor]
+[method: SuppressMessage("RoslynDiagnosticsReliability", "RS0033:Importing constructor should be [Obsolete]", Justification = "Used in test code: https://github.com/dotnet/roslyn/issues/42814")]
+internal sealed class GenerateConversionCodeFixProvider() : AbstractGenerateMemberCodeFixProvider
{
private const string CS0029 = nameof(CS0029); // error CS0029: Cannot implicitly convert type 'type' to 'type'
private const string CS0030 = nameof(CS0030); // error CS0030: Cannot convert type 'type' to 'type'
- [ImportingConstructor]
- [SuppressMessage("RoslynDiagnosticsReliability", "RS0033:Importing constructor should be [Obsolete]", Justification = "Used in test code: https://github.com/dotnet/roslyn/issues/42814")]
- public GenerateConversionCodeFixProvider()
- {
- }
-
public override ImmutableArray FixableDiagnosticIds
{
get { return [CS0029, CS0030]; }
diff --git a/src/Features/CSharp/Portable/CodeFixes/GenerateMethod/GenerateDeconstructMethodCodeFixProvider.cs b/src/Analyzers/CSharp/CodeFixes/GenerateMethod/GenerateDeconstructMethodCodeFixProvider.cs
similarity index 100%
rename from src/Features/CSharp/Portable/CodeFixes/GenerateMethod/GenerateDeconstructMethodCodeFixProvider.cs
rename to src/Analyzers/CSharp/CodeFixes/GenerateMethod/GenerateDeconstructMethodCodeFixProvider.cs
diff --git a/src/Features/CSharp/Portable/CodeFixes/GenerateMethod/GenerateMethodCodeFixProvider.cs b/src/Analyzers/CSharp/CodeFixes/GenerateMethod/GenerateMethodCodeFixProvider.cs
similarity index 92%
rename from src/Features/CSharp/Portable/CodeFixes/GenerateMethod/GenerateMethodCodeFixProvider.cs
rename to src/Analyzers/CSharp/CodeFixes/GenerateMethod/GenerateMethodCodeFixProvider.cs
index 5c30027be904c..ebdc100c1d1a4 100644
--- a/src/Features/CSharp/Portable/CodeFixes/GenerateMethod/GenerateMethodCodeFixProvider.cs
+++ b/src/Analyzers/CSharp/CodeFixes/GenerateMethod/GenerateMethodCodeFixProvider.cs
@@ -44,14 +44,10 @@ internal static class GenerateMethodDiagnosticIds
[ExtensionOrder(After = PredefinedCodeFixProviderNames.GenerateEnumMember)]
[ExtensionOrder(Before = PredefinedCodeFixProviderNames.PopulateSwitch)]
[ExtensionOrder(Before = PredefinedCodeFixProviderNames.GenerateVariable)]
-internal sealed class GenerateMethodCodeFixProvider : AbstractGenerateMemberCodeFixProvider
+[method: ImportingConstructor]
+[method: SuppressMessage("RoslynDiagnosticsReliability", "RS0033:Importing constructor should be [Obsolete]", Justification = "Used in test code: https://github.com/dotnet/roslyn/issues/42814")]
+internal sealed class GenerateMethodCodeFixProvider() : AbstractGenerateMemberCodeFixProvider
{
- [ImportingConstructor]
- [SuppressMessage("RoslynDiagnosticsReliability", "RS0033:Importing constructor should be [Obsolete]", Justification = "Used in test code: https://github.com/dotnet/roslyn/issues/42814")]
- public GenerateMethodCodeFixProvider()
- {
- }
-
public override ImmutableArray FixableDiagnosticIds { get; } =
GenerateMethodDiagnosticIds.FixableDiagnosticIds;
diff --git a/src/Features/CSharp/Portable/GenerateMember/GenerateParameterizedMember/CSharpCommonGenerationServiceMethods.cs b/src/Analyzers/CSharp/CodeFixes/GenerateParameterizedMember/CSharpCommonGenerationServiceMethods.cs
similarity index 100%
rename from src/Features/CSharp/Portable/GenerateMember/GenerateParameterizedMember/CSharpCommonGenerationServiceMethods.cs
rename to src/Analyzers/CSharp/CodeFixes/GenerateParameterizedMember/CSharpCommonGenerationServiceMethods.cs
diff --git a/src/Features/CSharp/Portable/GenerateMember/GenerateParameterizedMember/CSharpGenerateConversionService.cs b/src/Analyzers/CSharp/CodeFixes/GenerateParameterizedMember/CSharpGenerateConversionService.cs
similarity index 95%
rename from src/Features/CSharp/Portable/GenerateMember/GenerateParameterizedMember/CSharpGenerateConversionService.cs
rename to src/Analyzers/CSharp/CodeFixes/GenerateParameterizedMember/CSharpGenerateConversionService.cs
index 674f5b2dab83b..084ccf0323348 100644
--- a/src/Features/CSharp/Portable/GenerateMember/GenerateParameterizedMember/CSharpGenerateConversionService.cs
+++ b/src/Analyzers/CSharp/CodeFixes/GenerateParameterizedMember/CSharpGenerateConversionService.cs
@@ -20,15 +20,11 @@
namespace Microsoft.CodeAnalysis.CSharp.GenerateMember.GenerateParameterizedMember;
[ExportLanguageService(typeof(IGenerateConversionService), LanguageNames.CSharp), Shared]
-internal partial class CSharpGenerateConversionService :
+[method: ImportingConstructor]
+[method: Obsolete(MefConstruction.ImportingConstructorMessage, error: true)]
+internal sealed partial class CSharpGenerateConversionService() :
AbstractGenerateConversionService
{
- [ImportingConstructor]
- [Obsolete(MefConstruction.ImportingConstructorMessage, error: true)]
- public CSharpGenerateConversionService()
- {
- }
-
protected override bool IsImplicitConversionGeneration(SyntaxNode node)
{
return node is ExpressionSyntax &&
@@ -220,8 +216,8 @@ private static IMethodSymbol GenerateMethodSymbol(
}
protected override string GetImplicitConversionDisplayText(AbstractGenerateParameterizedMemberService.State state)
- => string.Format(CSharpFeaturesResources.Generate_implicit_conversion_operator_in_0, state.TypeToGenerateIn.Name);
+ => string.Format(CodeFixesResources.Generate_implicit_conversion_operator_in_0, state.TypeToGenerateIn.Name);
protected override string GetExplicitConversionDisplayText(AbstractGenerateParameterizedMemberService.State state)
- => string.Format(CSharpFeaturesResources.Generate_explicit_conversion_operator_in_0, state.TypeToGenerateIn.Name);
+ => string.Format(CodeFixesResources.Generate_explicit_conversion_operator_in_0, state.TypeToGenerateIn.Name);
}
diff --git a/src/Features/CSharp/Portable/GenerateMember/GenerateParameterizedMember/CSharpGenerateDeconstructMethodService.cs b/src/Analyzers/CSharp/CodeFixes/GenerateParameterizedMember/CSharpGenerateDeconstructMethodService.cs
similarity index 94%
rename from src/Features/CSharp/Portable/GenerateMember/GenerateParameterizedMember/CSharpGenerateDeconstructMethodService.cs
rename to src/Analyzers/CSharp/CodeFixes/GenerateParameterizedMember/CSharpGenerateDeconstructMethodService.cs
index 92cb73480134c..862f7db6e3f54 100644
--- a/src/Features/CSharp/Portable/GenerateMember/GenerateParameterizedMember/CSharpGenerateDeconstructMethodService.cs
+++ b/src/Analyzers/CSharp/CodeFixes/GenerateParameterizedMember/CSharpGenerateDeconstructMethodService.cs
@@ -20,15 +20,11 @@
namespace Microsoft.CodeAnalysis.CSharp.GenerateMember.GenerateMethod;
[ExportLanguageService(typeof(IGenerateDeconstructMemberService), LanguageNames.CSharp), Shared]
-internal sealed class CSharpGenerateDeconstructMethodService :
+[method: ImportingConstructor]
+[method: Obsolete(MefConstruction.ImportingConstructorMessage, error: true)]
+internal sealed class CSharpGenerateDeconstructMethodService() :
AbstractGenerateDeconstructMethodService
{
- [ImportingConstructor]
- [Obsolete(MefConstruction.ImportingConstructorMessage, error: true)]
- public CSharpGenerateDeconstructMethodService()
- {
- }
-
protected override bool ContainingTypesOrSelfHasUnsafeKeyword(INamedTypeSymbol containingType)
=> containingType.ContainingTypesOrSelfHasUnsafeKeyword();
diff --git a/src/Features/CSharp/Portable/GenerateMember/GenerateParameterizedMember/CSharpGenerateMethodService.cs b/src/Analyzers/CSharp/CodeFixes/GenerateParameterizedMember/CSharpGenerateMethodService.cs
similarity index 97%
rename from src/Features/CSharp/Portable/GenerateMember/GenerateParameterizedMember/CSharpGenerateMethodService.cs
rename to src/Analyzers/CSharp/CodeFixes/GenerateParameterizedMember/CSharpGenerateMethodService.cs
index 9fa97b3e47cb2..f6986582d93d0 100644
--- a/src/Features/CSharp/Portable/GenerateMember/GenerateParameterizedMember/CSharpGenerateMethodService.cs
+++ b/src/Analyzers/CSharp/CodeFixes/GenerateParameterizedMember/CSharpGenerateMethodService.cs
@@ -21,15 +21,11 @@
namespace Microsoft.CodeAnalysis.CSharp.GenerateMember.GenerateMethod;
[ExportLanguageService(typeof(IGenerateParameterizedMemberService), LanguageNames.CSharp), Shared]
-internal sealed class CSharpGenerateMethodService :
+[method: ImportingConstructor]
+[method: Obsolete(MefConstruction.ImportingConstructorMessage, error: true)]
+internal sealed class CSharpGenerateMethodService() :
AbstractGenerateMethodService
{
- [ImportingConstructor]
- [Obsolete(MefConstruction.ImportingConstructorMessage, error: true)]
- public CSharpGenerateMethodService()
- {
- }
-
protected override bool IsExplicitInterfaceGeneration(SyntaxNode node)
=> node is MethodDeclarationSyntax;
diff --git a/src/Features/CSharp/Portable/GenerateMember/GenerateParameterizedMember/CSharpGenerateParameterizedMemberService.cs b/src/Analyzers/CSharp/CodeFixes/GenerateParameterizedMember/CSharpGenerateParameterizedMemberService.cs
similarity index 100%
rename from src/Features/CSharp/Portable/GenerateMember/GenerateParameterizedMember/CSharpGenerateParameterizedMemberService.cs
rename to src/Analyzers/CSharp/CodeFixes/GenerateParameterizedMember/CSharpGenerateParameterizedMemberService.cs
diff --git a/src/Features/CSharp/Portable/GenerateVariable/CSharpGenerateVariableCodeFixProvider.cs b/src/Analyzers/CSharp/CodeFixes/GenerateVariable/CSharpGenerateVariableCodeFixProvider.cs
similarity index 88%
rename from src/Features/CSharp/Portable/GenerateVariable/CSharpGenerateVariableCodeFixProvider.cs
rename to src/Analyzers/CSharp/CodeFixes/GenerateVariable/CSharpGenerateVariableCodeFixProvider.cs
index 5c496ede5cd18..1d263364de048 100644
--- a/src/Features/CSharp/Portable/GenerateVariable/CSharpGenerateVariableCodeFixProvider.cs
+++ b/src/Analyzers/CSharp/CodeFixes/GenerateVariable/CSharpGenerateVariableCodeFixProvider.cs
@@ -22,7 +22,9 @@ namespace Microsoft.CodeAnalysis.CSharp.GenerateVariable;
[ExportCodeFixProvider(LanguageNames.CSharp, Name = PredefinedCodeFixProviderNames.GenerateVariable), Shared]
[ExtensionOrder(After = PredefinedCodeFixProviderNames.GenerateMethod)]
-internal class CSharpGenerateVariableCodeFixProvider : AbstractGenerateMemberCodeFixProvider
+[method: ImportingConstructor]
+[method: SuppressMessage("RoslynDiagnosticsReliability", "RS0033:Importing constructor should be [Obsolete]", Justification = "Used in test code: https://github.com/dotnet/roslyn/issues/42814")]
+internal sealed class CSharpGenerateVariableCodeFixProvider() : AbstractGenerateMemberCodeFixProvider
{
private const string CS1061 = nameof(CS1061); // error CS1061: 'C' does not contain a definition for 'Goo' and no extension method 'Goo' accepting a first argument of type 'C' could be found
private const string CS0103 = nameof(CS0103); // error CS0103: The name 'Goo' does not exist in the current context
@@ -32,12 +34,6 @@ internal class CSharpGenerateVariableCodeFixProvider : AbstractGenerateMemberCod
private const string CS0120 = nameof(CS0120); // error CS0120: An object reference is required for the non-static field, method, or property 'A'
private const string CS0118 = nameof(CS0118); // error CS0118: 'C' is a type but is used like a variable
- [ImportingConstructor]
- [SuppressMessage("RoslynDiagnosticsReliability", "RS0033:Importing constructor should be [Obsolete]", Justification = "Used in test code: https://github.com/dotnet/roslyn/issues/42814")]
- public CSharpGenerateVariableCodeFixProvider()
- {
- }
-
public override ImmutableArray FixableDiagnosticIds
=> [CS1061, CS0103, CS0117, CS0539, CS0246, CS0120, CS0118];
diff --git a/src/Analyzers/CSharp/CodeFixes/HideBase/HideBaseCodeFixProvider.AddNewKeywordAction.cs b/src/Analyzers/CSharp/CodeFixes/HideBase/HideBaseCodeFixProvider.AddNewKeywordAction.cs
index c6c2aa4a1bcfe..a2de070884f44 100644
--- a/src/Analyzers/CSharp/CodeFixes/HideBase/HideBaseCodeFixProvider.AddNewKeywordAction.cs
+++ b/src/Analyzers/CSharp/CodeFixes/HideBase/HideBaseCodeFixProvider.AddNewKeywordAction.cs
@@ -6,8 +6,10 @@
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.CodeActions;
+using Microsoft.CodeAnalysis.CSharp.CodeStyle;
using Microsoft.CodeAnalysis.CSharp.LanguageService;
using Microsoft.CodeAnalysis.CSharp.OrderModifiers;
+using Microsoft.CodeAnalysis.Options;
using Microsoft.CodeAnalysis.OrderModifiers;
using Microsoft.CodeAnalysis.Shared.Extensions;
using Roslyn.Utilities;
@@ -28,9 +30,9 @@ private class AddNewKeywordAction(Document document, SyntaxNode node) : CodeActi
protected override async Task GetChangedDocumentAsync(CancellationToken cancellationToken)
{
var root = await _document.GetRequiredSyntaxRootAsync(cancellationToken).ConfigureAwait(false);
- var options = await _document.GetCSharpCodeFixOptionsProviderAsync(cancellationToken).ConfigureAwait(false);
+ var configOptions = await _document.GetAnalyzerConfigOptionsAsync(cancellationToken).ConfigureAwait(false);
- var newNode = GetNewNode(_node, options.PreferredModifierOrder.Value);
+ var newNode = GetNewNode(_node, configOptions.GetOption(CSharpCodeStyleOptions.PreferredModifierOrder).Value);
var newRoot = root.ReplaceNode(_node, newNode);
return _document.WithSyntaxRoot(newRoot);
diff --git a/src/Features/CSharp/Portable/ImplementAbstractClass/CSharpImplementAbstractClassCodeFixProvider.cs b/src/Analyzers/CSharp/CodeFixes/ImplementAbstractClass/CSharpImplementAbstractClassCodeFixProvider.cs
similarity index 94%
rename from src/Features/CSharp/Portable/ImplementAbstractClass/CSharpImplementAbstractClassCodeFixProvider.cs
rename to src/Analyzers/CSharp/CodeFixes/ImplementAbstractClass/CSharpImplementAbstractClassCodeFixProvider.cs
index 89d58bf473ab2..aa7db53519afc 100644
--- a/src/Features/CSharp/Portable/ImplementAbstractClass/CSharpImplementAbstractClassCodeFixProvider.cs
+++ b/src/Analyzers/CSharp/CodeFixes/ImplementAbstractClass/CSharpImplementAbstractClassCodeFixProvider.cs
@@ -12,7 +12,7 @@ namespace Microsoft.CodeAnalysis.CSharp.ImplementAbstractClass;
[ExportCodeFixProvider(LanguageNames.CSharp, Name = PredefinedCodeFixProviderNames.ImplementAbstractClass), Shared]
[ExtensionOrder(After = PredefinedCodeFixProviderNames.GenerateType)]
-internal class CSharpImplementAbstractClassCodeFixProvider :
+internal sealed class CSharpImplementAbstractClassCodeFixProvider :
AbstractImplementAbstractClassCodeFixProvider
{
private const string CS0534 = nameof(CS0534); // 'Program' does not implement inherited abstract member 'Goo.bar()'
diff --git a/src/Features/CSharp/Portable/ImplementInterface/CSharpImplementInterfaceCodeFixProvider.cs b/src/Analyzers/CSharp/CodeFixes/ImplementInterface/CSharpImplementInterfaceCodeFixProvider.cs
similarity index 100%
rename from src/Features/CSharp/Portable/ImplementInterface/CSharpImplementInterfaceCodeFixProvider.cs
rename to src/Analyzers/CSharp/CodeFixes/ImplementInterface/CSharpImplementInterfaceCodeFixProvider.cs
diff --git a/src/Features/CSharp/Portable/ImplementInterface/CSharpImplementInterfaceService.cs b/src/Analyzers/CSharp/CodeFixes/ImplementInterface/CSharpImplementInterfaceService.cs
similarity index 81%
rename from src/Features/CSharp/Portable/ImplementInterface/CSharpImplementInterfaceService.cs
rename to src/Analyzers/CSharp/CodeFixes/ImplementInterface/CSharpImplementInterfaceService.cs
index c1d9811c90da9..8605be36ee10c 100644
--- a/src/Features/CSharp/Portable/ImplementInterface/CSharpImplementInterfaceService.cs
+++ b/src/Analyzers/CSharp/CodeFixes/ImplementInterface/CSharpImplementInterfaceService.cs
@@ -5,14 +5,16 @@
#nullable disable
using System;
-using System.Collections.Generic;
using System.Collections.Immutable;
using System.Composition;
using System.Threading;
using Microsoft.CodeAnalysis;
+using Microsoft.CodeAnalysis.CSharp.CodeGeneration;
using Microsoft.CodeAnalysis.CSharp.Extensions;
+using Microsoft.CodeAnalysis.CSharp.Formatting;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.Editing;
+using Microsoft.CodeAnalysis.Formatting;
using Microsoft.CodeAnalysis.Host.Mef;
using Microsoft.CodeAnalysis.ImplementInterface;
using Microsoft.CodeAnalysis.Shared.Extensions;
@@ -20,13 +22,15 @@
namespace Microsoft.CodeAnalysis.CSharp.ImplementInterface;
[ExportLanguageService(typeof(IImplementInterfaceService), LanguageNames.CSharp), Shared]
-internal class CSharpImplementInterfaceService : AbstractImplementInterfaceService
+[method: ImportingConstructor]
+[method: Obsolete(MefConstruction.ImportingConstructorMessage, error: true)]
+internal sealed class CSharpImplementInterfaceService() : AbstractImplementInterfaceService
{
- [ImportingConstructor]
- [Obsolete(MefConstruction.ImportingConstructorMessage, error: true)]
- public CSharpImplementInterfaceService()
- {
- }
+ protected override ISyntaxFormatting SyntaxFormatting
+ => CSharpSyntaxFormatting.Instance;
+
+ protected override SyntaxGeneratorInternal SyntaxGeneratorInternal
+ => CSharpSyntaxGeneratorInternal.Instance;
protected override string ToDisplayString(IMethodSymbol disposeImplMethod, SymbolDisplayFormat format)
=> SymbolDisplay.ToDisplayString(disposeImplMethod, format);
@@ -90,16 +94,16 @@ protected override SyntaxNode CreateFinalizer(
{
// ' Do not change this code...
// Dispose(false)
- var disposeStatement = (StatementSyntax)AddComment(g,
- string.Format(FeaturesResources.Do_not_change_this_code_Put_cleanup_code_in_0_method, disposeMethodDisplayString),
+ var disposeStatement = (StatementSyntax)AddComment(
+ string.Format(CodeFixesResources.Do_not_change_this_code_Put_cleanup_code_in_0_method, disposeMethodDisplayString),
g.ExpressionStatement(g.InvocationExpression(
g.IdentifierName(nameof(IDisposable.Dispose)),
g.Argument(DisposingName, RefKind.None, g.FalseLiteralExpression()))));
var methodDecl = SyntaxFactory.DestructorDeclaration(classType.Name).AddBodyStatements(disposeStatement);
- return AddComment(g,
- string.Format(FeaturesResources.TODO_colon_override_finalizer_only_if_0_has_code_to_free_unmanaged_resources, disposeMethodDisplayString),
+ return AddComment(
+ string.Format(CodeFixesResources.TODO_colon_override_finalizer_only_if_0_has_code_to_free_unmanaged_resources, disposeMethodDisplayString),
methodDecl);
}
}
diff --git a/src/Analyzers/CSharp/CodeFixes/InlineDeclaration/CSharpInlineDeclarationCodeFixProvider.cs b/src/Analyzers/CSharp/CodeFixes/InlineDeclaration/CSharpInlineDeclarationCodeFixProvider.cs
index 526ca834a7acd..106b78d3d4ca1 100644
--- a/src/Analyzers/CSharp/CodeFixes/InlineDeclaration/CSharpInlineDeclarationCodeFixProvider.cs
+++ b/src/Analyzers/CSharp/CodeFixes/InlineDeclaration/CSharpInlineDeclarationCodeFixProvider.cs
@@ -14,6 +14,7 @@
using Microsoft.CodeAnalysis.CodeActions;
using Microsoft.CodeAnalysis.CodeFixes;
using Microsoft.CodeAnalysis.CSharp.Extensions;
+using Microsoft.CodeAnalysis.CSharp.Simplification;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.CodeAnalysis.Editing;
@@ -44,7 +45,7 @@ protected override async Task FixAllAsync(
Document document, ImmutableArray diagnostics,
SyntaxEditor editor, CancellationToken cancellationToken)
{
- var options = await document.GetCSharpCodeFixOptionsProviderAsync(cancellationToken).ConfigureAwait(false);
+ var options = await document.GetCSharpSimplifierOptionsAsync(cancellationToken).ConfigureAwait(false);
// Gather all statements to be removed
// We need this to find the statements we can safely attach trivia to
@@ -92,7 +93,7 @@ private static (VariableDeclaratorSyntax declarator, IdentifierNameSyntax identi
private static SyntaxNode ReplaceIdentifierWithInlineDeclaration(
Document document,
- CSharpCodeFixOptionsProvider options, SemanticModel semanticModel,
+ CSharpSimplifierOptions options, SemanticModel semanticModel,
SyntaxNode currentRoot, VariableDeclaratorSyntax declarator,
IdentifierNameSyntax identifier, SyntaxNode currentNode,
HashSet declarationsToRemove,
@@ -238,7 +239,7 @@ private static SyntaxNode ReplaceIdentifierWithInlineDeclaration(
}
public static TypeSyntax GenerateTypeSyntaxOrVar(
- ITypeSymbol symbol, CSharpCodeFixOptionsProvider options)
+ ITypeSymbol symbol, CSharpSimplifierOptions options)
{
var useVar = IsVarDesired(symbol, options);
@@ -251,7 +252,7 @@ public static TypeSyntax GenerateTypeSyntaxOrVar(
: symbol.GenerateTypeSyntax();
}
- private static bool IsVarDesired(ITypeSymbol type, CSharpCodeFixOptionsProvider options)
+ private static bool IsVarDesired(ITypeSymbol type, CSharpSimplifierOptions options)
{
// If they want it for intrinsics, and this is an intrinsic, then use var.
if (type.IsSpecialType() == true)
diff --git a/src/Analyzers/CSharp/CodeFixes/MakeLocalFunctionStatic/MakeLocalFunctionStaticCodeFixHelper.cs b/src/Analyzers/CSharp/CodeFixes/MakeLocalFunctionStatic/MakeLocalFunctionStaticCodeFixHelper.cs
index adfd18228e12b..bdea1f83c6eb7 100644
--- a/src/Analyzers/CSharp/CodeFixes/MakeLocalFunctionStatic/MakeLocalFunctionStaticCodeFixHelper.cs
+++ b/src/Analyzers/CSharp/CodeFixes/MakeLocalFunctionStatic/MakeLocalFunctionStaticCodeFixHelper.cs
@@ -165,12 +165,7 @@ public static async Task MakeLocalFunctionStaticAsync(
}
}
-#if CODE_STYLE
- var info = new CSharpCodeGenerationContextInfo(
- CodeGenerationContext.Default, CSharpCodeGenerationOptions.Default, new CSharpCodeGenerationService(document.Project.GetExtendedLanguageServices().LanguageServices), root.SyntaxTree.Options.LanguageVersion());
-#else
var info = await document.GetCodeGenerationInfoAsync(CodeGenerationContext.Default, cancellationToken).ConfigureAwait(false);
-#endif
// Updates the local function declaration with variables passed in as parameters
syntaxEditor.ReplaceNode(
diff --git a/src/Analyzers/CSharp/CodeFixes/MisplacedUsingDirectives/MisplacedUsingDirectivesCodeFixProvider.cs b/src/Analyzers/CSharp/CodeFixes/MisplacedUsingDirectives/MisplacedUsingDirectivesCodeFixProvider.cs
index 6657044d72b52..706341426bd6c 100644
--- a/src/Analyzers/CSharp/CodeFixes/MisplacedUsingDirectives/MisplacedUsingDirectivesCodeFixProvider.cs
+++ b/src/Analyzers/CSharp/CodeFixes/MisplacedUsingDirectives/MisplacedUsingDirectivesCodeFixProvider.cs
@@ -13,15 +13,18 @@
using Microsoft.CodeAnalysis.CodeActions;
using Microsoft.CodeAnalysis.CodeFixes;
using Microsoft.CodeAnalysis.CodeStyle;
+using Microsoft.CodeAnalysis.CSharp.Simplification;
using Microsoft.CodeAnalysis.CSharp.Extensions;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.CodeAnalysis.Formatting;
using Microsoft.CodeAnalysis.LanguageService;
+using Microsoft.CodeAnalysis.Options;
using Microsoft.CodeAnalysis.PooledObjects;
using Microsoft.CodeAnalysis.Shared.Extensions;
using Microsoft.CodeAnalysis.Simplification;
using Roslyn.Utilities;
+using Microsoft.CodeAnalysis.CSharp.CodeStyle;
namespace Microsoft.CodeAnalysis.CSharp.MisplacedUsingDirectives;
@@ -57,12 +60,12 @@ public override async Task RegisterCodeFixesAsync(CodeFixContext context)
var syntaxRoot = await document.GetRequiredSyntaxRootAsync(cancellationToken).ConfigureAwait(false);
var compilationUnit = (CompilationUnitSyntax)syntaxRoot;
- var options = await document.GetCSharpCodeFixOptionsProviderAsync(cancellationToken).ConfigureAwait(false);
- var simplifierOptions = options.GetSimplifierOptions();
+ var configOptions = await document.GetAnalyzerConfigOptionsAsync(cancellationToken).ConfigureAwait(false);
+ var simplifierOptions = new CSharpSimplifierOptions(configOptions);
// Read the preferred placement option and verify if it can be applied to this code file. There are cases
// where we will not be able to fix the diagnostic and the user will need to resolve it manually.
- var (placement, preferPreservation) = DeterminePlacement(compilationUnit, options.UsingDirectivePlacement);
+ var (placement, preferPreservation) = DeterminePlacement(compilationUnit, configOptions.GetOption(CSharpCodeStyleOptions.PreferredUsingDirectivePlacement));
if (preferPreservation)
return;
diff --git a/src/Analyzers/CSharp/CodeFixes/NewLines/EmbeddedStatementPlacement/EmbeddedStatementPlacementCodeFixProvider.cs b/src/Analyzers/CSharp/CodeFixes/NewLines/EmbeddedStatementPlacement/EmbeddedStatementPlacementCodeFixProvider.cs
index bf6a8be42bb2e..2cb1247d4ee5b 100644
--- a/src/Analyzers/CSharp/CodeFixes/NewLines/EmbeddedStatementPlacement/EmbeddedStatementPlacementCodeFixProvider.cs
+++ b/src/Analyzers/CSharp/CodeFixes/NewLines/EmbeddedStatementPlacement/EmbeddedStatementPlacementCodeFixProvider.cs
@@ -11,6 +11,7 @@
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.CodeActions;
using Microsoft.CodeAnalysis.CodeFixes;
+using Microsoft.CodeAnalysis.CSharp.Formatting;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.CodeAnalysis.Editing;
@@ -47,7 +48,7 @@ public static async Task FixAllAsync(Document document, ImmutableArray
var root = await document.GetRequiredSyntaxRootAsync(cancellationToken).ConfigureAwait(false);
var editor = new SyntaxEditor(root, document.Project.Solution.Services);
- var options = await document.GetCSharpCodeFixOptionsProviderAsync(cancellationToken).ConfigureAwait(false);
+ var options = await document.GetCSharpSyntaxFormattingOptionsAsync(cancellationToken).ConfigureAwait(false);
var endOfLineTrivia = ElasticEndOfLine(options.NewLine);
diff --git a/src/Analyzers/CSharp/CodeFixes/RemoveUnusedParametersAndValues/CSharpRemoveUnusedValuesCodeFixProvider.cs b/src/Analyzers/CSharp/CodeFixes/RemoveUnusedParametersAndValues/CSharpRemoveUnusedValuesCodeFixProvider.cs
index 434d14f295da9..b459db309e58d 100644
--- a/src/Analyzers/CSharp/CodeFixes/RemoveUnusedParametersAndValues/CSharpRemoveUnusedValuesCodeFixProvider.cs
+++ b/src/Analyzers/CSharp/CodeFixes/RemoveUnusedParametersAndValues/CSharpRemoveUnusedValuesCodeFixProvider.cs
@@ -30,7 +30,7 @@ internal sealed class CSharpRemoveUnusedValuesCodeFixProvider()
ExpressionStatementSyntax, LocalDeclarationStatementSyntax, VariableDeclaratorSyntax,
ForEachStatementSyntax, SwitchSectionSyntax, SwitchLabelSyntax, CatchClauseSyntax, CatchClauseSyntax>
{
- protected override ISyntaxFormatting GetSyntaxFormatting()
+ protected override ISyntaxFormatting SyntaxFormatting
=> CSharpSyntaxFormatting.Instance;
protected override BlockSyntax WrapWithBlockIfNecessary(IEnumerable statements)
diff --git a/src/Analyzers/CSharp/CodeFixes/UseCoalesceExpression/CSharpUseCoalesceExpressionForIfNullStatementCheckCodeFixProvider.cs b/src/Analyzers/CSharp/CodeFixes/UseCoalesceExpression/CSharpUseCoalesceExpressionForIfNullStatementCheckCodeFixProvider.cs
new file mode 100644
index 0000000000000..ebb1f88d3d23a
--- /dev/null
+++ b/src/Analyzers/CSharp/CodeFixes/UseCoalesceExpression/CSharpUseCoalesceExpressionForIfNullStatementCheckCodeFixProvider.cs
@@ -0,0 +1,45 @@
+// 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;
+using System.Composition;
+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;
+
+[ExtensionOrder(Before = PredefinedCodeFixProviderNames.AddBraces)]
+[ExportCodeFixProvider(LanguageNames.CSharp, Name = PredefinedCodeFixProviderNames.UseCoalesceExpressionForIfNullStatementCheck), Shared]
+[method: ImportingConstructor]
+[method: Obsolete(MefConstruction.ImportingConstructorMessage, error: true)]
+internal sealed class CSharpUseCoalesceExpressionForIfNullStatementCheckCodeFixProvider()
+ : AbstractUseCoalesceExpressionForIfNullStatementCheckCodeFixProvider
+{
+ protected override ITypeSymbol? TryGetExplicitCast(
+ SemanticModel semanticModel, SyntaxNode expressionToCoalesce,
+ SyntaxNode leftAssignmentPart, SyntaxNode rightAssignmentPart,
+ CancellationToken cancellationToken)
+ {
+ var leftPartTypeSymbol = semanticModel.GetTypeInfo(expressionToCoalesce, cancellationToken).Type;
+ var rightPartTypeSymbol = semanticModel.GetTypeInfo(rightAssignmentPart, cancellationToken).Type;
+ var finalDestinationTypeSymbol = semanticModel.GetTypeInfo(leftAssignmentPart, cancellationToken).Type;
+
+ if (leftPartTypeSymbol == null || rightPartTypeSymbol == null || finalDestinationTypeSymbol == null)
+ return null;
+
+ if (leftPartTypeSymbol.Equals(rightPartTypeSymbol))
+ return null;
+
+ if (semanticModel.Compilation.HasImplicitConversion(leftPartTypeSymbol, rightPartTypeSymbol) ||
+ semanticModel.Compilation.HasImplicitConversion(rightPartTypeSymbol, leftPartTypeSymbol))
+ {
+ return null;
+ }
+
+ return finalDestinationTypeSymbol;
+ }
+}
diff --git a/src/Analyzers/CSharp/CodeFixes/UseCollectionExpression/CSharpCollectionExpressionRewriter.cs b/src/Analyzers/CSharp/CodeFixes/UseCollectionExpression/CSharpCollectionExpressionRewriter.cs
index 3912db017c814..c5f2083c7c2a7 100644
--- a/src/Analyzers/CSharp/CodeFixes/UseCollectionExpression/CSharpCollectionExpressionRewriter.cs
+++ b/src/Analyzers/CSharp/CodeFixes/UseCollectionExpression/CSharpCollectionExpressionRewriter.cs
@@ -46,12 +46,7 @@ public static async Task CreateCollectionExpressionA
var document = await ParsedDocument.CreateAsync(workspaceDocument, cancellationToken).ConfigureAwait(false);
-#if CODE_STYLE
- var formattingOptions = CSharpSyntaxFormattingOptions.Default;
-#else
- var formattingOptions = (CSharpSyntaxFormattingOptions)await workspaceDocument.GetSyntaxFormattingOptionsAsync(cancellationToken).ConfigureAwait(false);
-#endif
-
+ var formattingOptions = await workspaceDocument.GetCSharpSyntaxFormattingOptionsAsync(cancellationToken).ConfigureAwait(false);
var indentationOptions = new IndentationOptions(formattingOptions);
var wrappingLength = formattingOptions.CollectionExpressionWrappingLength;
diff --git a/src/Analyzers/CSharp/CodeFixes/UseCollectionExpression/CSharpUseCollectionExpressionForArrayCodeFixProvider.cs b/src/Analyzers/CSharp/CodeFixes/UseCollectionExpression/CSharpUseCollectionExpressionForArrayCodeFixProvider.cs
index 6131ccff3191a..3ca81464e419a 100644
--- a/src/Analyzers/CSharp/CodeFixes/UseCollectionExpression/CSharpUseCollectionExpressionForArrayCodeFixProvider.cs
+++ b/src/Analyzers/CSharp/CodeFixes/UseCollectionExpression/CSharpUseCollectionExpressionForArrayCodeFixProvider.cs
@@ -103,11 +103,11 @@ ImmutableArray> GetMatches(
{
ImplicitArrayCreationExpressionSyntax arrayCreation
=> CSharpUseCollectionExpressionForArrayDiagnosticAnalyzer.TryGetMatches(
- semanticModel, arrayCreation, expressionType, allowSemanticsChange: true, cancellationToken, out _),
+ semanticModel, arrayCreation, CreateReplacementCollectionExpressionForAnalysis(arrayCreation.Initializer), expressionType, allowSemanticsChange: true, cancellationToken, out _),
ArrayCreationExpressionSyntax arrayCreation
=> CSharpUseCollectionExpressionForArrayDiagnosticAnalyzer.TryGetMatches(
- semanticModel, arrayCreation, expressionType, allowSemanticsChange: true, cancellationToken, out _),
+ semanticModel, arrayCreation, CreateReplacementCollectionExpressionForAnalysis(arrayCreation.Initializer), expressionType, allowSemanticsChange: true, cancellationToken, out _),
// We validated this is unreachable in the caller.
_ => throw ExceptionUtilities.Unreachable(),
diff --git a/src/Analyzers/CSharp/CodeFixes/UseCollectionExpression/CSharpUseCollectionExpressionForFluentCodeFixProvider.cs b/src/Analyzers/CSharp/CodeFixes/UseCollectionExpression/CSharpUseCollectionExpressionForFluentCodeFixProvider.cs
index e6d5670884c6b..09314809aa588 100644
--- a/src/Analyzers/CSharp/CodeFixes/UseCollectionExpression/CSharpUseCollectionExpressionForFluentCodeFixProvider.cs
+++ b/src/Analyzers/CSharp/CodeFixes/UseCollectionExpression/CSharpUseCollectionExpressionForFluentCodeFixProvider.cs
@@ -10,6 +10,7 @@
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.CodeActions;
using Microsoft.CodeAnalysis.CodeFixes;
+using Microsoft.CodeAnalysis.CSharp.Formatting;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.CodeAnalysis.Editing;
@@ -144,11 +145,8 @@ static async Task> GetArgumentsAsync(
return default;
var text = await document.GetTextAsync(cancellationToken).ConfigureAwait(false);
-#if CODE_STYLE
- var formattingOptions = SyntaxFormattingOptions.CommonDefaults;
-#else
- var formattingOptions = await document.GetSyntaxFormattingOptionsAsync(cancellationToken).ConfigureAwait(false);
-#endif
+ var formattingOptions = await document.GetSyntaxFormattingOptionsAsync(
+ CSharpSyntaxFormatting.Instance, cancellationToken).ConfigureAwait(false);
using var _ = ArrayBuilder.GetInstance(out var nodesAndTokens);
diff --git a/src/Analyzers/CSharp/CodeFixes/UseCollectionExpression/CSharpUseCollectionExpressionForStackAllocCodeFixProvider.cs b/src/Analyzers/CSharp/CodeFixes/UseCollectionExpression/CSharpUseCollectionExpressionForStackAllocCodeFixProvider.cs
index 7774bb8c9acd4..da987b48b87d4 100644
--- a/src/Analyzers/CSharp/CodeFixes/UseCollectionExpression/CSharpUseCollectionExpressionForStackAllocCodeFixProvider.cs
+++ b/src/Analyzers/CSharp/CodeFixes/UseCollectionExpression/CSharpUseCollectionExpressionForStackAllocCodeFixProvider.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/UseConditionalExpression/CSharpUseConditionalExpressionForAssignmentCodeFixProvider.cs b/src/Analyzers/CSharp/CodeFixes/UseConditionalExpression/CSharpUseConditionalExpressionForAssignmentCodeFixProvider.cs
index 39bcf0dc146c5..8fb28e7def2a0 100644
--- a/src/Analyzers/CSharp/CodeFixes/UseConditionalExpression/CSharpUseConditionalExpressionForAssignmentCodeFixProvider.cs
+++ b/src/Analyzers/CSharp/CodeFixes/UseConditionalExpression/CSharpUseConditionalExpressionForAssignmentCodeFixProvider.cs
@@ -57,6 +57,6 @@ protected override StatementSyntax WrapWithBlockIfAppropriate(
protected override ExpressionSyntax ConvertToExpression(IThrowOperation throwOperation)
=> CSharpUseConditionalExpressionHelpers.ConvertToExpression(throwOperation);
- protected override ISyntaxFormatting GetSyntaxFormatting()
+ protected override ISyntaxFormatting SyntaxFormatting
=> CSharpSyntaxFormatting.Instance;
}
diff --git a/src/Analyzers/CSharp/CodeFixes/UseConditionalExpression/CSharpUseConditionalExpressionForReturnCodeFixProvider.cs b/src/Analyzers/CSharp/CodeFixes/UseConditionalExpression/CSharpUseConditionalExpressionForReturnCodeFixProvider.cs
index ba4a932007522..e1dca2d1db1ae 100644
--- a/src/Analyzers/CSharp/CodeFixes/UseConditionalExpression/CSharpUseConditionalExpressionForReturnCodeFixProvider.cs
+++ b/src/Analyzers/CSharp/CodeFixes/UseConditionalExpression/CSharpUseConditionalExpressionForReturnCodeFixProvider.cs
@@ -60,6 +60,6 @@ protected override ExpressionSyntax WrapReturnExpressionIfNecessary(ExpressionSy
protected override ExpressionSyntax ConvertToExpression(IThrowOperation throwOperation)
=> CSharpUseConditionalExpressionHelpers.ConvertToExpression(throwOperation);
- protected override ISyntaxFormatting GetSyntaxFormatting()
+ protected override ISyntaxFormatting SyntaxFormatting
=> CSharpSyntaxFormatting.Instance;
}
diff --git a/src/Analyzers/CSharp/CodeFixes/UseImplicitObjectCreation/CSharpUseImplicitObjectCreationCodeFixProvider.cs b/src/Analyzers/CSharp/CodeFixes/UseImplicitObjectCreation/CSharpUseImplicitObjectCreationCodeFixProvider.cs
index 6bc18e8e3d139..576f76620d1cb 100644
--- a/src/Analyzers/CSharp/CodeFixes/UseImplicitObjectCreation/CSharpUseImplicitObjectCreationCodeFixProvider.cs
+++ b/src/Analyzers/CSharp/CodeFixes/UseImplicitObjectCreation/CSharpUseImplicitObjectCreationCodeFixProvider.cs
@@ -50,11 +50,8 @@ protected override async Task FixAllAsync(
.OrderBy(d => d.Location.SourceSpan.End)
.SelectAsArray(d => (ObjectCreationExpressionSyntax)d.AdditionalLocations[0].FindNode(getInnermostNodeForTie: true, cancellationToken));
-#if CODE_STYLE
- var options = CSharpSimplifierOptions.Default;
-#else
- var options = (CSharpSimplifierOptions)await document.GetSimplifierOptionsAsync(cancellationToken).ConfigureAwait(false);
-#endif
+ var options = (CSharpSimplifierOptions)await document.GetSimplifierOptionsAsync(
+ CSharpSimplification.Instance, cancellationToken).ConfigureAwait(false);
// Bulk apply these, except at the expression level. One fix at the expression level may prevent another fix
// from being valid. For example: `new List { new C() }`. If we apply the fix to the outer `List`, we
diff --git a/src/Analyzers/CSharp/CodeFixes/UseLocalFunction/CSharpUseLocalFunctionCodeFixProvider.cs b/src/Analyzers/CSharp/CodeFixes/UseLocalFunction/CSharpUseLocalFunctionCodeFixProvider.cs
index 931722e8eb838..8f731bb6e81a3 100644
--- a/src/Analyzers/CSharp/CodeFixes/UseLocalFunction/CSharpUseLocalFunctionCodeFixProvider.cs
+++ b/src/Analyzers/CSharp/CodeFixes/UseLocalFunction/CSharpUseLocalFunctionCodeFixProvider.cs
@@ -88,12 +88,7 @@ protected override async Task FixAllAsync(
if (languageVersion >= LanguageVersion.CSharp8)
{
-#if CODE_STYLE
- var info = new CSharpCodeGenerationContextInfo(
- CodeGenerationContext.Default, CSharpCodeGenerationOptions.Default, new CSharpCodeGenerationService(document.Project.GetExtendedLanguageServices().LanguageServices), root.SyntaxTree.Options.LanguageVersion());
-#else
var info = await document.GetCodeGenerationInfoAsync(CodeGenerationContext.Default, cancellationToken).ConfigureAwait(false);
-#endif
var options = (CSharpCodeGenerationOptions)info.Options;
makeStaticIfPossible = options.PreferStaticLocalFunction.Value;
diff --git a/src/Analyzers/CSharp/Tests/CSharpAnalyzers.UnitTests.projitems b/src/Analyzers/CSharp/Tests/CSharpAnalyzers.UnitTests.projitems
index 4cb24a2e90359..43978f21d34d9 100644
--- a/src/Analyzers/CSharp/Tests/CSharpAnalyzers.UnitTests.projitems
+++ b/src/Analyzers/CSharp/Tests/CSharpAnalyzers.UnitTests.projitems
@@ -33,7 +33,18 @@
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/Features/CSharpTest/GenerateConstructor/GenerateConstructorTests.cs b/src/Analyzers/CSharp/Tests/GenerateConstructor/GenerateConstructorTests.cs
similarity index 99%
rename from src/Features/CSharpTest/GenerateConstructor/GenerateConstructorTests.cs
rename to src/Analyzers/CSharp/Tests/GenerateConstructor/GenerateConstructorTests.cs
index 3fa80c6c96c1b..2d3bdb24c3f20 100644
--- a/src/Features/CSharpTest/GenerateConstructor/GenerateConstructorTests.cs
+++ b/src/Analyzers/CSharp/Tests/GenerateConstructor/GenerateConstructorTests.cs
@@ -19,13 +19,9 @@
namespace Microsoft.CodeAnalysis.Editor.CSharp.UnitTests.GenerateConstructor;
[Trait(Traits.Feature, Traits.Features.CodeActionsGenerateConstructor)]
-public class GenerateConstructorTests : AbstractCSharpDiagnosticProviderBasedUserDiagnosticTest_NoEditor
+public sealed class GenerateConstructorTests(ITestOutputHelper logger)
+ : AbstractCSharpDiagnosticProviderBasedUserDiagnosticTest_NoEditor(logger)
{
- public GenerateConstructorTests(ITestOutputHelper logger)
- : base(logger)
- {
- }
-
internal override (DiagnosticAnalyzer?, CodeFixProvider) CreateDiagnosticProviderAndFixer(Workspace workspace)
=> (null, new GenerateConstructorCodeFixProvider());
@@ -2788,74 +2784,6 @@ class D
""");
}
- [Fact, WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/530003")]
- public async Task TestAttributesWithAllValidParameters()
- {
- await TestInRegularAndScriptAsync(
- """
- using System;
-
- enum A
- {
- A1
- }
-
- [AttributeUsage(AttributeTargets.Class)]
- class MyAttrAttribute : Attribute
- {
- }
-
- [|[MyAttrAttribute(new int[] { 1, 2, 3 }, A.A1, true, (byte)1, 'a', (short)12, (int)1, (long)5L, 5D, 3.5F, "hello")]|]
- class D
- {
- }
- """,
- """
- using System;
-
- enum A
- {
- A1
- }
-
- [AttributeUsage(AttributeTargets.Class)]
- class MyAttrAttribute : Attribute
- {
- private int[] ints;
- private A a1;
- private bool v1;
- private byte v2;
- private char v3;
- private short v4;
- private int v5;
- private long v6;
- private double v7;
- private float v8;
- private string v9;
-
- public MyAttrAttribute(int[] ints, A a1, bool v1, byte v2, char v3, short v4, int v5, long v6, double v7, float v8, string v9)
- {
- this.ints = ints;
- this.a1 = a1;
- this.v1 = v1;
- this.v2 = v2;
- this.v3 = v3;
- this.v4 = v4;
- this.v5 = v5;
- this.v6 = v6;
- this.v7 = v7;
- this.v8 = v8;
- this.v9 = v9;
- }
- }
-
- [MyAttrAttribute(new int[] { 1, 2, 3 }, A.A1, true, (byte)1, 'a', (short)12, (int)1, (long)5L, 5D, 3.5F, "hello")]
- class D
- {
- }
- """);
- }
-
[Fact, WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/530003")]
public async Task TestAttributesWithDelegation()
{
@@ -4575,39 +4503,6 @@ public A(int* a, int b, int c) : this(a, b) { }
""");
}
- [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/44708")]
- public async Task TestGenerateNameFromTypeArgument()
- {
- await TestInRegularAndScriptAsync(
-"""
- using System.Collections.Generic;
-
- class Frog { }
-
- class C
- {
- C M() => new [||]C(new List());
- }
- """,
-"""
- using System.Collections.Generic;
-
- class Frog { }
-
- class C
- {
- private List frogs;
-
- public C(List frogs)
- {
- this.frogs = frogs;
- }
-
- C M() => new C(new List());
- }
- """);
- }
-
[Fact, WorkItem("https://github.com/dotnet/roslyn/issues/44708")]
public async Task TestDoNotGenerateNameFromTypeArgumentIfNotEnumerable()
{
@@ -4643,39 +4538,6 @@ C M()
""");
}
- [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/44708")]
- public async Task TestGenerateNameFromTypeArgumentForErrorType()
- {
- await TestInRegularAndScriptAsync(
-"""
- using System.Collections.Generic;
-
- class Frog { }
-
- class C
- {
- C M() => new [||]C(new List<>());
- }
- """,
-"""
- using System.Collections.Generic;
-
- class Frog { }
-
- class C
- {
- private List ts;
-
- public C(List ts)
- {
- this.ts = ts;
- }
-
- C M() => new C(new List<>());
- }
- """);
- }
-
[Fact, WorkItem("https://github.com/dotnet/roslyn/issues/44708")]
public async Task TestGenerateNameFromTypeArgumentForTupleType()
{
@@ -4709,43 +4571,6 @@ public C(List<(int, string)> list)
""");
}
- [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/44708")]
- public async Task TestGenerateNameFromTypeArgumentInNamespace()
- {
- await TestInRegularAndScriptAsync(
-"""
- using System.Collections.Generic;
-
- namespace N {
- class Frog { }
-
- class C
- {
- C M() => new [||]C(new List());
- }
- }
- """,
-"""
- using System.Collections.Generic;
-
- namespace N {
- class Frog { }
-
- class C
- {
- private List frogs;
-
- public C(List frogs)
- {
- this.frogs = frogs;
- }
-
- C M() => new C(new List());
- }
- }
- """);
- }
-
[Fact, WorkItem("https://github.com/dotnet/roslyn/issues/47928")]
public async Task TestGenerateConstructorFromImplicitObjectCreation()
{
@@ -5144,4 +4969,179 @@ public static void Test()
}
""");
}
+
+#if !CODE_STYLE
+
+ [Fact, WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/530003")]
+ public async Task TestAttributesWithAllValidParameters()
+ {
+ await TestInRegularAndScriptAsync(
+ """
+ using System;
+
+ enum A
+ {
+ A1
+ }
+
+ [AttributeUsage(AttributeTargets.Class)]
+ class MyAttrAttribute : Attribute
+ {
+ }
+
+ [|[MyAttrAttribute(new int[] { 1, 2, 3 }, A.A1, true, (byte)1, 'a', (short)12, (int)1, (long)5L, 5D, 3.5F, "hello")]|]
+ class D
+ {
+ }
+ """,
+ """
+ using System;
+
+ enum A
+ {
+ A1
+ }
+
+ [AttributeUsage(AttributeTargets.Class)]
+ class MyAttrAttribute : Attribute
+ {
+ private int[] ints;
+ private A a1;
+ private bool v1;
+ private byte v2;
+ private char v3;
+ private short v4;
+ private int v5;
+ private long v6;
+ private double v7;
+ private float v8;
+ private string v9;
+
+ public MyAttrAttribute(int[] ints, A a1, bool v1, byte v2, char v3, short v4, int v5, long v6, double v7, float v8, string v9)
+ {
+ this.ints = ints;
+ this.a1 = a1;
+ this.v1 = v1;
+ this.v2 = v2;
+ this.v3 = v3;
+ this.v4 = v4;
+ this.v5 = v5;
+ this.v6 = v6;
+ this.v7 = v7;
+ this.v8 = v8;
+ this.v9 = v9;
+ }
+ }
+
+ [MyAttrAttribute(new int[] { 1, 2, 3 }, A.A1, true, (byte)1, 'a', (short)12, (int)1, (long)5L, 5D, 3.5F, "hello")]
+ class D
+ {
+ }
+ """);
+ }
+
+ [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/44708")]
+ public async Task TestGenerateNameFromTypeArgument()
+ {
+ await TestInRegularAndScriptAsync(
+"""
+ using System.Collections.Generic;
+
+ class Frog { }
+
+ class C
+ {
+ C M() => new [||]C(new List());
+ }
+ """,
+"""
+ using System.Collections.Generic;
+
+ class Frog { }
+
+ class C
+ {
+ private List frogs;
+
+ public C(List frogs)
+ {
+ this.frogs = frogs;
+ }
+
+ C M() => new C(new List());
+ }
+ """);
+ }
+
+ [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/44708")]
+ public async Task TestGenerateNameFromTypeArgumentForErrorType()
+ {
+ await TestInRegularAndScriptAsync(
+"""
+ using System.Collections.Generic;
+
+ class Frog { }
+
+ class C
+ {
+ C M() => new [||]C(new List<>());
+ }
+ """,
+"""
+ using System.Collections.Generic;
+
+ class Frog { }
+
+ class C
+ {
+ private List ts;
+
+ public C(List ts)
+ {
+ this.ts = ts;
+ }
+
+ C M() => new C(new List<>());
+ }
+ """);
+ }
+
+ [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/44708")]
+ public async Task TestGenerateNameFromTypeArgumentInNamespace()
+ {
+ await TestInRegularAndScriptAsync(
+"""
+ using System.Collections.Generic;
+
+ namespace N {
+ class Frog { }
+
+ class C
+ {
+ C M() => new [||]C(new List());
+ }
+ }
+ """,
+"""
+ using System.Collections.Generic;
+
+ namespace N {
+ class Frog { }
+
+ class C
+ {
+ private List frogs;
+
+ public C(List frogs)
+ {
+ this.frogs = frogs;
+ }
+
+ C M() => new C(new List());
+ }
+ }
+ """);
+ }
+
+#endif
}
diff --git a/src/Features/CSharpTest/GenerateDefaultConstructors/GenerateDefaultConstructorsTests.cs b/src/Analyzers/CSharp/Tests/GenerateDefaultConstructors/GenerateDefaultConstructorsTests.cs
similarity index 99%
rename from src/Features/CSharpTest/GenerateDefaultConstructors/GenerateDefaultConstructorsTests.cs
rename to src/Analyzers/CSharp/Tests/GenerateDefaultConstructors/GenerateDefaultConstructorsTests.cs
index d2cbb3b3b2f76..8eec2a263228e 100644
--- a/src/Features/CSharpTest/GenerateDefaultConstructors/GenerateDefaultConstructorsTests.cs
+++ b/src/Analyzers/CSharp/Tests/GenerateDefaultConstructors/GenerateDefaultConstructorsTests.cs
@@ -18,12 +18,15 @@ namespace Microsoft.CodeAnalysis.Editor.CSharp.UnitTests.GenerateDefaultConstruc
EmptyDiagnosticAnalyzer,
CSharpGenerateDefaultConstructorsCodeFixProvider>;
+#if !CODE_STYLE
using VerifyRefactoring = CSharpCodeRefactoringVerifier<
GenerateDefaultConstructorsCodeRefactoringProvider>;
+#endif
[UseExportProvider]
public class GenerateDefaultConstructorsTests
{
+#if !CODE_STYLE
private static async Task TestRefactoringAsync(string source, string fixedSource, int index = 0)
{
await TestRefactoringOnlyAsync(source, fixedSource, index);
@@ -40,6 +43,7 @@ private static async Task TestRefactoringOnlyAsync(string source, string fixedSo
LanguageVersion = LanguageVersion.CSharp10,
}.RunAsync();
}
+#endif
private static async Task TestCodeFixAsync(string source, string fixedSource, int index = 0)
{
@@ -51,9 +55,12 @@ private static async Task TestCodeFixAsync(string source, string fixedSource, in
LanguageVersion = LanguageVersion.CSharp10,
}.RunAsync();
+#if !CODE_STYLE
await TestRefactoringMissingAsync(source);
+#endif
}
+#if !CODE_STYLE
private static async Task TestRefactoringMissingAsync(string source)
{
await new VerifyRefactoring.Test
@@ -63,6 +70,7 @@ private static async Task TestRefactoringMissingAsync(string source)
LanguageVersion = LanguageVersion.CSharp10,
}.RunAsync();
}
+#endif
private static async Task TestCodeFixMissingAsync(string source)
{
@@ -174,24 +182,6 @@ internal B(int x)
""");
}
- [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsGenerateDefaultConstructors)]
- public async Task TestPrivateBase()
- {
- await TestRefactoringMissingAsync(
- """
- class {|CS1729:C|} : [||]B
- {
- }
-
- class B
- {
- private B(int x)
- {
- }
- }
- """);
- }
-
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsGenerateDefaultConstructors)]
public async Task TestRefOutParams()
{
@@ -434,29 +424,18 @@ public B(bool x)
index: 3);
}
- [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsGenerateDefaultConstructors)]
- public async Task TestFixAll2()
+ [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsGenerateDefaultConstructors), CompilerTrait(CompilerFeature.Tuples)]
+ public async Task Tuple()
{
- await TestRefactoringAsync(
+ await TestCodeFixAsync(
"""
- class C : [||]B
+ class {|CS7036:C|} : [||]B
{
- public {|CS1729:C|}(bool x)
- {
- }
}
class B
{
- internal B(int x)
- {
- }
-
- protected B(string x)
- {
- }
-
- public B(bool x)
+ public B((int, string) x)
{
}
}
@@ -464,60 +443,32 @@ public B(bool x)
"""
class C : B
{
- public {|CS1729:C|}(bool x)
- {
- }
-
- protected C(string x) : base(x)
- {
- }
-
- internal C(int x) : base(x)
+ public C((int, string) x) : base(x)
{
}
}
class B
{
- internal B(int x)
- {
- }
-
- protected B(string x)
- {
- }
-
- public B(bool x)
+ public B((int, string) x)
{
}
}
- """,
-index: 2);
+ """);
}
- [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsGenerateDefaultConstructors)]
- public async Task TestFixAll_WithTuples()
+ [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsGenerateDefaultConstructors), CompilerTrait(CompilerFeature.Tuples)]
+ public async Task TupleWithNames()
{
- await TestRefactoringAsync(
+ await TestCodeFixAsync(
"""
- class C : [||]B
+ class {|CS7036:C|} : [||]B
{
- public {|CS1729:C|}((bool, bool) x)
- {
- }
}
class B
{
- internal B((int, int) x)
- {
- }
-
- protected B((string, string) x)
- {
- }
-
- public B((bool, bool) x)
+ public B((int a, string b) x)
{
}
}
@@ -525,52 +476,82 @@ public B((bool, bool) x)
"""
class C : B
{
- public {|CS1729:C|}((bool, bool) x)
+ public C((int a, string b) x) : base(x)
{
}
+ }
- protected C((string, string) x) : base(x)
+ class B
+ {
+ public B((int a, string b) x)
{
}
+ }
+ """);
+ }
- internal C((int, int) x) : base(x)
+ [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsGenerateConstructor)]
+ [WorkItem("https://github.com/dotnet/Roslyn/issues/6541")]
+ public async Task TestGenerateFromDerivedClass()
+ {
+ await TestCodeFixAsync(
+ """
+ class Base
+ {
+ public Base(string value)
{
}
}
- class B
+ class [||]{|CS7036:Derived|} : Base
{
- internal B((int, int) x)
+ }
+ """,
+ """
+ class Base
+ {
+ public Base(string value)
{
}
+ }
- protected B((string, string) x)
+ class Derived : Base
+ {
+ public Derived(string value) : base(value)
{
}
+ }
+ """);
+ }
- public B((bool, bool) x)
+ [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsGenerateConstructor)]
+ [WorkItem("https://github.com/dotnet/Roslyn/issues/6541")]
+ public async Task TestGenerateFromDerivedClass2()
+ {
+ await TestCodeFixAsync(
+ """
+ class Base
+ {
+ public Base(int a, string value = null)
{
}
}
- """,
-index: 2);
- }
- [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsGenerateDefaultConstructors)]
- public async Task TestMissing1()
- {
- await TestRefactoringMissingAsync(
+ class [||]{|CS7036:Derived|} : Base
+ {
+ }
+ """,
"""
- class C : [||]B
+ class Base
{
- public {|CS7036:C|}(int x)
+ public Base(int a, string value = null)
{
}
}
- class B
+ class Derived : Base
{
- internal B(int x)
+ public Derived(int a, string value = null) : base(a, value)
{
}
}
@@ -578,40 +559,33 @@ internal B(int x)
}
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsGenerateDefaultConstructors)]
- [WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/889349")]
- public async Task TestDefaultConstructorGeneration_1()
+ [WorkItem("https://github.com/dotnet/roslyn/issues/25238")]
+ public async Task TestGenerateConstructorFromProtectedConstructor()
{
- await TestRefactoringAsync(
+ await TestCodeFixAsync(
"""
- class C : [||]B
+ abstract class {|CS7036:C|} : [||]B
{
- public {|CS7036:C|}(int y)
- {
- }
}
- class B
+ abstract class B
{
- internal B(int x)
+ protected B(int x)
{
}
}
""",
"""
- class C : B
+ abstract class C : B
{
- public {|CS7036:C|}(int y)
- {
- }
-
- internal {|CS0111:C|}(int x) : base(x)
+ protected C(int x) : base(x)
{
}
}
- class B
+ abstract class B
{
- internal B(int x)
+ protected B(int x)
{
}
}
@@ -619,21 +593,18 @@ internal B(int x)
}
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsGenerateDefaultConstructors)]
- [WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/889349")]
- public async Task TestDefaultConstructorGeneration_2()
+ [WorkItem("https://github.com/dotnet/roslyn/issues/25238")]
+ public async Task TestGenerateConstructorFromProtectedConstructor2()
{
- await TestRefactoringAsync(
+ await TestCodeFixAsync(
"""
- class C : [||]B
+ class {|CS7036:C|} : [||]B
{
- private {|CS7036:C|}(int y)
- {
- }
}
- class B
+ abstract class B
{
- internal B(int x)
+ protected B(int x)
{
}
}
@@ -641,18 +612,14 @@ internal B(int x)
"""
class C : B
{
- internal C(int x) : base(x)
- {
- }
-
- private {|CS0111:{|CS7036:C|}|}(int y)
+ public C(int x) : base(x)
{
}
}
- class B
+ abstract class B
{
- internal B(int x)
+ protected B(int x)
{
}
}
@@ -660,145 +627,68 @@ internal B(int x)
}
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsGenerateDefaultConstructors)]
- [WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/544070")]
- public async Task TestException1()
+ [WorkItem("https://github.com/dotnet/roslyn/issues/35208")]
+ [WorkItem("https://github.com/dotnet/roslyn/issues/25238")]
+ public async Task TestGenerateConstructorInAbstractClassFromPublicConstructor()
{
- await TestRefactoringAsync(
+ await TestCodeFixAsync(
"""
- using System;
- class Program : Excep[||]tion
+ abstract class {|CS7036:C|} : [||]B
{
}
- """,
- """
- using System;
- using System.Runtime.Serialization;
- class Program : Exception
- {
- public Program()
- {
- }
- public Program(string message) : base(message)
+ abstract class B
+ {
+ public B(int x)
{
}
-
- public Program(string message, Exception innerException) : base(message, innerException)
+ }
+ """,
+ """
+ abstract class C : B
+ {
+ protected C(int x) : base(x)
{
}
+ }
- protected Program(SerializationInfo info, StreamingContext context) : base(info, context)
+ abstract class B
+ {
+ public B(int x)
{
}
}
- """,
-index: 4);
+ """);
}
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsGenerateDefaultConstructors)]
- public async Task TestException2()
+ [WorkItem("https://github.com/dotnet/roslyn/issues/25238")]
+ public async Task TestGenerateConstructorFromPublicConstructor2()
{
- await TestRefactoringAsync(
+ await TestCodeFixAsync(
"""
- using System;
- using System.Collections.Generic;
- using System.Linq;
+ class {|CS7036:C|} : [||]B
+ {
+ }
- class Program : [||]Exception
+ abstract class B
{
- public Program()
- {
- }
-
- static void Main(string[] args)
- {
- }
- }
- """,
- """
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Runtime.Serialization;
-
- class Program : Exception
- {
- public Program()
- {
- }
-
- public Program(string message) : base(message)
- {
- }
-
- public Program(string message, Exception innerException) : base(message, innerException)
- {
- }
-
- protected Program(SerializationInfo info, StreamingContext context) : base(info, context)
- {
- }
-
- static void Main(string[] args)
+ public B(int x)
{
}
}
""",
-index: 3);
- }
-
- [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsGenerateDefaultConstructors)]
- public async Task TestException3()
- {
- await TestRefactoringAsync(
"""
- using System;
- using System.Collections.Generic;
- using System.Linq;
-
- class Program : [||]Exception
+ class C : B
{
- public Program(string message) : base(message)
- {
- }
-
- public Program(string message, Exception innerException) : base(message, innerException)
- {
- }
-
- protected Program(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) : base(info, context)
- {
- }
-
- static void Main(string[] args)
+ public C(int x) : base(x)
{
}
}
- """,
- """
- using System;
- using System.Collections.Generic;
- using System.Linq;
- class Program : Exception
+ abstract class B
{
- public Program()
- {
- }
-
- public Program(string message) : base(message)
- {
- }
-
- public Program(string message, Exception innerException) : base(message, innerException)
- {
- }
-
- protected Program(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) : base(info, context)
- {
- }
-
- static void Main(string[] args)
+ public B(int x)
{
}
}
@@ -806,62 +696,42 @@ static void Main(string[] args)
}
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsGenerateDefaultConstructors)]
- public async Task TestException4()
+ [WorkItem("https://github.com/dotnet/roslyn/issues/25238")]
+ public async Task TestGenerateConstructorFromInternalConstructor()
{
- await TestRefactoringAsync(
+ await TestCodeFixAsync(
"""
- using System;
- using System.Collections.Generic;
- using System.Linq;
-
- class Program : [||]Exception
+ abstract class {|CS7036:C|} : [||]B
{
- public Program(string message, Exception innerException) : base(message, innerException)
- {
- }
-
- protected Program(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) : base(info, context)
- {
- }
+ }
- static void Main(string[] args)
+ abstract class B
+ {
+ internal B(int x)
{
}
}
""",
"""
- using System;
- using System.Collections.Generic;
- using System.Linq;
-
- class Program : Exception
+ abstract class C : B
{
- public Program()
- {
- }
-
- public Program(string message) : base(message)
- {
- }
-
- public Program(string message, Exception innerException) : base(message, innerException)
- {
- }
-
- protected Program(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) : base(info, context)
+ internal C(int x) : base(x)
{
}
+ }
- static void Main(string[] args)
+ abstract class B
+ {
+ internal B(int x)
{
}
}
- """,
-index: 2);
+ """);
}
- [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsGenerateDefaultConstructors), CompilerTrait(CompilerFeature.Tuples)]
- public async Task Tuple()
+ [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsGenerateDefaultConstructors)]
+ [WorkItem("https://github.com/dotnet/roslyn/issues/25238")]
+ public async Task TestGenerateConstructorFromInternalConstructor2()
{
await TestCodeFixAsync(
"""
@@ -869,9 +739,9 @@ class {|CS7036:C|} : [||]B
{
}
- class B
+ abstract class B
{
- public B((int, string) x)
+ internal B(int x)
{
}
}
@@ -879,161 +749,150 @@ public B((int, string) x)
"""
class C : B
{
- public C((int, string) x) : base(x)
+ public C(int x) : base(x)
{
}
}
- class B
+ abstract class B
{
- public B((int, string) x)
+ internal B(int x)
{
}
}
""");
}
- [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsGenerateDefaultConstructors), CompilerTrait(CompilerFeature.Tuples)]
- public async Task TupleWithNames()
+ [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsGenerateDefaultConstructors)]
+ [WorkItem("https://github.com/dotnet/roslyn/issues/25238")]
+ public async Task TestGenerateConstructorFromProtectedInternalConstructor()
{
await TestCodeFixAsync(
"""
- class {|CS7036:C|} : [||]B
+ abstract class {|CS7036:C|} : [||]B
{
}
- class B
+ abstract class B
{
- public B((int a, string b) x)
+ protected internal B(int x)
{
}
}
""",
"""
- class C : B
+ abstract class C : B
{
- public C((int a, string b) x) : base(x)
+ protected internal C(int x) : base(x)
{
}
}
- class B
+ abstract class B
{
- public B((int a, string b) x)
+ protected internal B(int x)
{
}
}
""");
}
- [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsGenerateConstructor)]
- [WorkItem("https://github.com/dotnet/Roslyn/issues/6541")]
- public async Task TestGenerateFromDerivedClass()
+ [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsGenerateDefaultConstructors)]
+ [WorkItem("https://github.com/dotnet/roslyn/issues/25238")]
+ public async Task TestGenerateConstructorFromProtectedInternalConstructor2()
{
await TestCodeFixAsync(
"""
- class Base
+ class {|CS7036:C|} : [||]B
{
- public Base(string value)
- {
- }
}
- class [||]{|CS7036:Derived|} : Base
+ abstract class B
{
+ protected internal B(int x)
+ {
+ }
}
""",
"""
- class Base
+ class C : B
{
- public Base(string value)
+ public C(int x) : base(x)
{
}
}
- class Derived : Base
+ abstract class B
{
- public Derived(string value) : base(value)
+ protected internal B(int x)
{
}
}
""");
}
- [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsGenerateConstructor)]
- [WorkItem("https://github.com/dotnet/Roslyn/issues/6541")]
- public async Task TestGenerateFromDerivedClass2()
+ [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsGenerateDefaultConstructors)]
+ [WorkItem("https://github.com/dotnet/roslyn/issues/25238")]
+ public async Task TestGenerateConstructorFromPrivateProtectedConstructor()
{
await TestCodeFixAsync(
"""
- class Base
+ abstract class {|CS7036:C|} : [||]B
{
- public Base(int a, string value = null)
- {
- }
}
- class [||]{|CS7036:Derived|} : Base
+ abstract class B
{
+ private protected B(int x)
+ {
+ }
}
""",
"""
- class Base
+ abstract class C : B
{
- public Base(int a, string value = null)
+ private protected C(int x) : base(x)
{
}
}
- class Derived : Base
+ abstract class B
{
- public Derived(int a, string value = null) : base(a, value)
+ private protected B(int x)
{
}
}
""");
}
- [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsGenerateDefaultConstructors)]
- [WorkItem("https://github.com/dotnet/roslyn/issues/19953")]
- public async Task TestNotOnEnum()
- {
- await TestRefactoringMissingAsync(
- """
- enum [||]E
- {
- }
- """);
- }
-
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsGenerateDefaultConstructors)]
[WorkItem("https://github.com/dotnet/roslyn/issues/25238")]
- public async Task TestGenerateConstructorFromProtectedConstructor()
+ public async Task TestGenerateConstructorFromPrivateProtectedConstructor2()
{
await TestCodeFixAsync(
"""
- abstract class {|CS7036:C|} : [||]B
+ class {|CS7036:C|} : [||]B
{
}
abstract class B
{
- protected B(int x)
+ private protected internal {|CS0107:B|}(int x)
{
}
}
""",
"""
- abstract class C : B
+ class C : B
{
- protected C(int x) : base(x)
+ public C(int x) : base(x)
{
}
}
abstract class B
{
- protected B(int x)
+ private protected internal {|CS0107:B|}(int x)
{
}
}
@@ -1041,70 +900,103 @@ protected B(int x)
}
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsGenerateDefaultConstructors)]
- [WorkItem("https://github.com/dotnet/roslyn/issues/25238")]
- public async Task TestGenerateConstructorFromProtectedConstructor2()
+ public async Task TestRecord()
{
await TestCodeFixAsync(
"""
- class {|CS7036:C|} : [||]B
+ record {|CS1729:C|} : [||]B
{
}
- abstract class B
+ record B
{
- protected B(int x)
+ public B(int x)
{
}
}
""",
"""
- class C : B
+ record C : B
{
public C(int x) : base(x)
{
}
}
- abstract class B
+ record B
{
- protected B(int x)
+ public B(int x)
{
}
}
- """);
+ """, index: 1);
}
- [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsGenerateDefaultConstructors)]
- [WorkItem("https://github.com/dotnet/roslyn/issues/48318")]
- public async Task TestGenerateConstructorFromProtectedConstructorCursorAtTypeOpening()
+ [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsGenerateConstructor)]
+ [WorkItem("https://github.com/dotnet/roslyn/issues/58593")]
+ public async Task TestStructWithFieldInitializer()
{
- await TestRefactoringOnlyAsync(
- """
- class {|CS7036:C|} : B
+ var source = """
+ struct [||]{|CS8983:S|}
{
-
- [||]
-
+ object X = 1;
}
-
- abstract class B
+ """;
+ var fixedSource = """
+ struct S
{
- protected B(int x)
+ object X = 1;
+
+ public S()
{
}
}
- """,
+ """;
+
+ await new VerifyCodeFix.Test
+ {
+ TestCode = source.Replace("[||]", ""),
+ FixedCode = fixedSource,
+ LanguageVersion = LanguageVersion.CSharp12,
+ }.RunAsync();
+
+#if !CODE_STYLE
+ await TestRefactoringMissingAsync(source);
+#endif
+ }
+
+ [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsGenerateConstructor)]
+ [WorkItem("https://github.com/dotnet/roslyn/issues/58593")]
+ public async Task TestMissingInStructWithoutFieldInitializer()
+ {
+ var source = """
+ struct [||]S
+ {
+ object X;
+ }
+ """;
+
+ await TestCodeFixMissingAsync(source);
+
+#if !CODE_STYLE
+ await TestRefactoringMissingAsync(source);
+#endif
+ }
+
+#if !CODE_STYLE
+
+ [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsGenerateDefaultConstructors)]
+ public async Task TestPrivateBase()
+ {
+ await TestRefactoringMissingAsync(
"""
- class C : B
+ class {|CS1729:C|} : [||]B
{
- public C(int x) : base(x)
- {
- }
}
- abstract class B
+ class B
{
- protected B(int x)
+ private B(int x)
{
}
}
@@ -1112,21 +1004,28 @@ protected B(int x)
}
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsGenerateDefaultConstructors)]
- [WorkItem("https://github.com/dotnet/roslyn/issues/48318")]
- public async Task TestGenerateConstructorFromProtectedConstructorCursorBetweenTypeMembers()
+ public async Task TestFixAll2()
{
- await TestRefactoringOnlyAsync(
+ await TestRefactoringAsync(
"""
- class {|CS7036:C|} : B
+ class C : [||]B
{
- int X;
- [||]
- int Y;
+ public {|CS1729:C|}(bool x)
+ {
+ }
}
- abstract class B
+ class B
{
- protected B(int x)
+ internal B(int x)
+ {
+ }
+
+ protected B(string x)
+ {
+ }
+
+ public B(bool x)
{
}
}
@@ -1134,53 +1033,113 @@ protected B(int x)
"""
class C : B
{
- int X;
+ public {|CS1729:C|}(bool x)
+ {
+ }
- int Y;
+ protected C(string x) : base(x)
+ {
+ }
- public C(int x) : base(x)
+ internal C(int x) : base(x)
{
}
}
- abstract class B
+ class B
{
- protected B(int x)
+ internal B(int x)
+ {
+ }
+
+ protected B(string x)
+ {
+ }
+
+ public B(bool x)
{
}
}
- """);
+ """,
+index: 2);
}
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsGenerateDefaultConstructors)]
- [WorkItem("https://github.com/dotnet/roslyn/issues/35208")]
- [WorkItem("https://github.com/dotnet/roslyn/issues/25238")]
- public async Task TestGenerateConstructorInAbstractClassFromPublicConstructor()
+ public async Task TestFixAll_WithTuples()
{
- await TestCodeFixAsync(
+ await TestRefactoringAsync(
"""
- abstract class {|CS7036:C|} : [||]B
+ class C : [||]B
{
+ public {|CS1729:C|}((bool, bool) x)
+ {
+ }
}
- abstract class B
+ class B
{
- public B(int x)
+ internal B((int, int) x)
+ {
+ }
+
+ protected B((string, string) x)
+ {
+ }
+
+ public B((bool, bool) x)
{
}
}
""",
"""
- abstract class C : B
+ class C : B
{
- protected C(int x) : base(x)
+ public {|CS1729:C|}((bool, bool) x)
+ {
+ }
+
+ protected C((string, string) x) : base(x)
+ {
+ }
+
+ internal C((int, int) x) : base(x)
{
}
}
- abstract class B
+ class B
{
- public B(int x)
+ internal B((int, int) x)
+ {
+ }
+
+ protected B((string, string) x)
+ {
+ }
+
+ public B((bool, bool) x)
+ {
+ }
+ }
+ """,
+index: 2);
+ }
+
+ [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsGenerateDefaultConstructors)]
+ public async Task TestMissing1()
+ {
+ await TestRefactoringMissingAsync(
+ """
+ class C : [||]B
+ {
+ public {|CS7036:C|}(int x)
+ {
+ }
+ }
+
+ class B
+ {
+ internal B(int x)
{
}
}
@@ -1188,18 +1147,21 @@ public B(int x)
}
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsGenerateDefaultConstructors)]
- [WorkItem("https://github.com/dotnet/roslyn/issues/25238")]
- public async Task TestGenerateConstructorFromPublicConstructor2()
+ [WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/889349")]
+ public async Task TestDefaultConstructorGeneration_1()
{
- await TestCodeFixAsync(
+ await TestRefactoringAsync(
"""
- class {|CS7036:C|} : [||]B
+ class C : [||]B
{
+ public {|CS7036:C|}(int y)
+ {
+ }
}
- abstract class B
+ class B
{
- public B(int x)
+ internal B(int x)
{
}
}
@@ -1207,14 +1169,18 @@ public B(int x)
"""
class C : B
{
- public C(int x) : base(x)
+ public {|CS7036:C|}(int y)
+ {
+ }
+
+ internal {|CS0111:C|}(int x) : base(x)
{
}
}
- abstract class B
+ class B
{
- public B(int x)
+ internal B(int x)
{
}
}
@@ -1222,16 +1188,19 @@ public B(int x)
}
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsGenerateDefaultConstructors)]
- [WorkItem("https://github.com/dotnet/roslyn/issues/25238")]
- public async Task TestGenerateConstructorFromInternalConstructor()
+ [WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/889349")]
+ public async Task TestDefaultConstructorGeneration_2()
{
- await TestCodeFixAsync(
+ await TestRefactoringAsync(
"""
- abstract class {|CS7036:C|} : [||]B
+ class C : [||]B
{
+ private {|CS7036:C|}(int y)
+ {
+ }
}
- abstract class B
+ class B
{
internal B(int x)
{
@@ -1239,14 +1208,18 @@ internal B(int x)
}
""",
"""
- abstract class C : B
+ class C : B
{
internal C(int x) : base(x)
{
}
+
+ private {|CS0111:{|CS7036:C|}|}(int y)
+ {
+ }
}
- abstract class B
+ class B
{
internal B(int x)
{
@@ -1256,67 +1229,145 @@ internal B(int x)
}
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsGenerateDefaultConstructors)]
- [WorkItem("https://github.com/dotnet/roslyn/issues/25238")]
- public async Task TestGenerateConstructorFromInternalConstructor2()
+ [WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/544070")]
+ public async Task TestException1()
{
- await TestCodeFixAsync(
+ await TestRefactoringAsync(
"""
- class {|CS7036:C|} : [||]B
+ using System;
+ class Program : Excep[||]tion
{
}
+ """,
+ """
+ using System;
+ using System.Runtime.Serialization;
+ class Program : Exception
+ {
+ public Program()
+ {
+ }
- abstract class B
+ public Program(string message) : base(message)
+ {
+ }
+
+ public Program(string message, Exception innerException) : base(message, innerException)
+ {
+ }
+
+ protected Program(SerializationInfo info, StreamingContext context) : base(info, context)
+ {
+ }
+ }
+ """,
+index: 4);
+ }
+
+ [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsGenerateDefaultConstructors)]
+ public async Task TestException2()
+ {
+ await TestRefactoringAsync(
+ """
+ using System;
+ using System.Collections.Generic;
+ using System.Linq;
+
+ class Program : [||]Exception
{
- internal B(int x)
+ public Program()
+ {
+ }
+
+ static void Main(string[] args)
{
}
}
""",
"""
- class C : B
+ using System;
+ using System.Collections.Generic;
+ using System.Linq;
+ using System.Runtime.Serialization;
+
+ class Program : Exception
{
- public C(int x) : base(x)
+ public Program()
+ {
+ }
+
+ public Program(string message) : base(message)
+ {
+ }
+
+ public Program(string message, Exception innerException) : base(message, innerException)
+ {
+ }
+
+ protected Program(SerializationInfo info, StreamingContext context) : base(info, context)
{
}
- }
- abstract class B
- {
- internal B(int x)
+ static void Main(string[] args)
{
}
}
- """);
+ """,
+index: 3);
}
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsGenerateDefaultConstructors)]
- [WorkItem("https://github.com/dotnet/roslyn/issues/25238")]
- public async Task TestGenerateConstructorFromProtectedInternalConstructor()
+ public async Task TestException3()
{
- await TestCodeFixAsync(
+ await TestRefactoringAsync(
"""
- abstract class {|CS7036:C|} : [||]B
- {
- }
+ using System;
+ using System.Collections.Generic;
+ using System.Linq;
- abstract class B
+ class Program : [||]Exception
{
- protected internal B(int x)
+ public Program(string message) : base(message)
+ {
+ }
+
+ public Program(string message, Exception innerException) : base(message, innerException)
+ {
+ }
+
+ protected Program(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) : base(info, context)
+ {
+ }
+
+ static void Main(string[] args)
{
}
}
""",
"""
- abstract class C : B
+ using System;
+ using System.Collections.Generic;
+ using System.Linq;
+
+ class Program : Exception
{
- protected internal C(int x) : base(x)
+ public Program()
{
}
- }
- abstract class B
- {
- protected internal B(int x)
+ public Program(string message) : base(message)
+ {
+ }
+
+ public Program(string message, Exception innerException) : base(message, innerException)
+ {
+ }
+
+ protected Program(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) : base(info, context)
+ {
+ }
+
+ static void Main(string[] args)
{
}
}
@@ -1324,86 +1375,88 @@ protected internal B(int x)
}
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsGenerateDefaultConstructors)]
- [WorkItem("https://github.com/dotnet/roslyn/issues/25238")]
- public async Task TestGenerateConstructorFromProtectedInternalConstructor2()
+ public async Task TestException4()
{
- await TestCodeFixAsync(
+ await TestRefactoringAsync(
"""
- class {|CS7036:C|} : [||]B
- {
- }
+ using System;
+ using System.Collections.Generic;
+ using System.Linq;
- abstract class B
+ class Program : [||]Exception
{
- protected internal B(int x)
+ public Program(string message, Exception innerException) : base(message, innerException)
+ {
+ }
+
+ protected Program(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) : base(info, context)
+ {
+ }
+
+ static void Main(string[] args)
{
}
}
""",
"""
- class C : B
+ using System;
+ using System.Collections.Generic;
+ using System.Linq;
+
+ class Program : Exception
{
- public C(int x) : base(x)
+ public Program()
{
}
- }
- abstract class B
- {
- protected internal B(int x)
+ public Program(string message) : base(message)
{
}
- }
- """);
- }
- [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsGenerateDefaultConstructors)]
- [WorkItem("https://github.com/dotnet/roslyn/issues/25238")]
- public async Task TestGenerateConstructorFromPrivateProtectedConstructor()
- {
- await TestCodeFixAsync(
- """
- abstract class {|CS7036:C|} : [||]B
- {
- }
+ public Program(string message, Exception innerException) : base(message, innerException)
+ {
+ }
- abstract class B
- {
- private protected B(int x)
+ protected Program(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) : base(info, context)
{
}
- }
- """,
- """
- abstract class C : B
- {
- private protected C(int x) : base(x)
+
+ static void Main(string[] args)
{
}
}
+ """,
+index: 2);
+ }
- abstract class B
+ [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsGenerateDefaultConstructors)]
+ [WorkItem("https://github.com/dotnet/roslyn/issues/19953")]
+ public async Task TestNotOnEnum()
+ {
+ await TestRefactoringMissingAsync(
+ """
+ enum [||]E
{
- private protected B(int x)
- {
- }
}
""");
}
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsGenerateDefaultConstructors)]
- [WorkItem("https://github.com/dotnet/roslyn/issues/25238")]
- public async Task TestGenerateConstructorFromPrivateProtectedConstructor2()
+ [WorkItem("https://github.com/dotnet/roslyn/issues/48318")]
+ public async Task TestGenerateConstructorFromProtectedConstructorCursorAtTypeOpening()
{
- await TestCodeFixAsync(
+ await TestRefactoringOnlyAsync(
"""
- class {|CS7036:C|} : [||]B
+ class {|CS7036:C|} : B
{
+
+ [||]
+
}
abstract class B
{
- private protected internal {|CS0107:B|}(int x)
+ protected B(int x)
{
}
}
@@ -1418,7 +1471,7 @@ public C(int x) : base(x)
abstract class B
{
- private protected internal {|CS0107:B|}(int x)
+ protected B(int x)
{
}
}
@@ -1426,33 +1479,40 @@ abstract class B
}
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsGenerateDefaultConstructors)]
- [WorkItem("https://github.com/dotnet/roslyn/issues/40586")]
- public async Task TestGeneratePublicConstructorInSealedClassForProtectedBase()
+ [WorkItem("https://github.com/dotnet/roslyn/issues/48318")]
+ public async Task TestGenerateConstructorFromProtectedConstructorCursorBetweenTypeMembers()
{
- await TestRefactoringAsync(
+ await TestRefactoringOnlyAsync(
"""
- class Base
+ class {|CS7036:C|} : B
{
- protected Base()
- {
- }
+ int X;
+ [||]
+ int Y;
}
- sealed class Program : [||]Base
+ abstract class B
{
+ protected B(int x)
+ {
+ }
}
""",
"""
- class Base
+ class C : B
{
- protected Base()
+ int X;
+
+ int Y;
+
+ public C(int x) : base(x)
{
}
}
- sealed class Program : Base
+ abstract class B
{
- public Program()
+ protected B(int x)
{
}
}
@@ -1528,81 +1588,38 @@ internal Program()
}
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsGenerateDefaultConstructors)]
- public async Task TestRecord()
+ [WorkItem("https://github.com/dotnet/roslyn/issues/40586")]
+ public async Task TestGeneratePublicConstructorInSealedClassForProtectedBase()
{
- await TestCodeFixAsync(
+ await TestRefactoringAsync(
"""
- record {|CS1729:C|} : [||]B
+ class Base
{
+ protected Base()
+ {
+ }
}
- record B
+ sealed class Program : [||]Base
{
- public B(int x)
- {
- }
}
""",
"""
- record C : B
- {
- public C(int x) : base(x)
- {
- }
- }
-
- record B
+ class Base
{
- public B(int x)
+ protected Base()
{
}
}
- """, index: 1);
- }
- [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsGenerateConstructor)]
- [WorkItem("https://github.com/dotnet/roslyn/issues/58593")]
- public async Task TestStructWithFieldInitializer()
- {
- var source = """
- struct [||]{|CS8983:S|}
- {
- object X = 1;
- }
- """;
- var fixedSource = """
- struct S
+ sealed class Program : Base
{
- object X = 1;
-
- public S()
+ public Program()
{
}
}
- """;
-
- await new VerifyCodeFix.Test
- {
- TestCode = source.Replace("[||]", ""),
- FixedCode = fixedSource,
- LanguageVersion = LanguageVersion.CSharp12,
- }.RunAsync();
-
- await TestRefactoringMissingAsync(source);
+ """);
}
- [Fact, Trait(Traits.Feature, Traits.Features.CodeActionsGenerateConstructor)]
- [WorkItem("https://github.com/dotnet/roslyn/issues/58593")]
- public async Task TestMissingInStructWithoutFieldInitializer()
- {
- var source = """
- struct [||]S
- {
- object X;
- }
- """;
-
- await TestCodeFixMissingAsync(source);
- await TestRefactoringMissingAsync(source);
- }
+#endif
}
diff --git a/src/Features/CSharpTest/GenerateEnumMember/GenerateEnumMemberTests.cs b/src/Analyzers/CSharp/Tests/GenerateEnumMember/GenerateEnumMemberTests.cs
similarity index 99%
rename from src/Features/CSharpTest/GenerateEnumMember/GenerateEnumMemberTests.cs
rename to src/Analyzers/CSharp/Tests/GenerateEnumMember/GenerateEnumMemberTests.cs
index 8434f60dd792c..ef4531bb9b3f2 100644
--- a/src/Features/CSharpTest/GenerateEnumMember/GenerateEnumMemberTests.cs
+++ b/src/Analyzers/CSharp/Tests/GenerateEnumMember/GenerateEnumMemberTests.cs
@@ -16,13 +16,9 @@
namespace Microsoft.CodeAnalysis.Editor.CSharp.UnitTests.Diagnostics.GenerateEnumMember;
[Trait(Traits.Feature, Traits.Features.CodeActionsGenerateEnumMember)]
-public class GenerateEnumMemberTests : AbstractCSharpDiagnosticProviderBasedUserDiagnosticTest_NoEditor
+public sealed class GenerateEnumMemberTests(ITestOutputHelper logger)
+ : AbstractCSharpDiagnosticProviderBasedUserDiagnosticTest_NoEditor(logger)
{
- public GenerateEnumMemberTests(ITestOutputHelper logger)
- : base(logger)
- {
- }
-
internal override (DiagnosticAnalyzer, CodeFixProvider) CreateDiagnosticProviderAndFixer(Workspace workspace)
=> (null, new GenerateEnumMemberCodeFixProvider());
diff --git a/src/Features/CSharpTest/GenerateMethod/GenerateConversionTests.cs b/src/Analyzers/CSharp/Tests/GenerateMethod/GenerateConversionTests.cs
similarity index 96%
rename from src/Features/CSharpTest/GenerateMethod/GenerateConversionTests.cs
rename to src/Analyzers/CSharp/Tests/GenerateMethod/GenerateConversionTests.cs
index de2ec8843bf82..65a5634332887 100644
--- a/src/Features/CSharpTest/GenerateMethod/GenerateConversionTests.cs
+++ b/src/Analyzers/CSharp/Tests/GenerateMethod/GenerateConversionTests.cs
@@ -17,13 +17,9 @@
namespace Microsoft.CodeAnalysis.Editor.CSharp.UnitTests.Diagnostics.GenerateMethod;
[Trait(Traits.Feature, Traits.Features.CodeActionsGenerateMethod)]
-public class GenerateConversionTest : AbstractCSharpDiagnosticProviderBasedUserDiagnosticTest_NoEditor
+public sealed class GenerateConversionTests(ITestOutputHelper logger)
+ : AbstractCSharpDiagnosticProviderBasedUserDiagnosticTest_NoEditor(logger)
{
- public GenerateConversionTest(ITestOutputHelper logger)
- : base(logger)
- {
- }
-
internal override (DiagnosticAnalyzer, CodeFixProvider) CreateDiagnosticProviderAndFixer(Workspace workspace)
=> (null, new GenerateConversionCodeFixProvider());
diff --git a/src/Features/CSharpTest/GenerateMethod/GenerateDeconstructMethodTests.cs b/src/Analyzers/CSharp/Tests/GenerateMethod/GenerateDeconstructMethodTests.cs
similarity index 97%
rename from src/Features/CSharpTest/GenerateMethod/GenerateDeconstructMethodTests.cs
rename to src/Analyzers/CSharp/Tests/GenerateMethod/GenerateDeconstructMethodTests.cs
index 0462179ffd750..ea95b0f287d11 100644
--- a/src/Features/CSharpTest/GenerateMethod/GenerateDeconstructMethodTests.cs
+++ b/src/Analyzers/CSharp/Tests/GenerateMethod/GenerateDeconstructMethodTests.cs
@@ -16,13 +16,9 @@
namespace Microsoft.CodeAnalysis.Editor.CSharp.UnitTests.Diagnostics.GenerateDeconstructMethod;
[Trait(Traits.Feature, Traits.Features.CodeActionsGenerateMethod)]
-public class GenerateDeconstructMethodTests : AbstractCSharpDiagnosticProviderBasedUserDiagnosticTest_NoEditor
+public sealed class GenerateDeconstructMethodTests(ITestOutputHelper logger)
+ : AbstractCSharpDiagnosticProviderBasedUserDiagnosticTest_NoEditor(logger)
{
- public GenerateDeconstructMethodTests(ITestOutputHelper logger)
- : base(logger)
- {
- }
-
internal override (DiagnosticAnalyzer, CodeFixProvider) CreateDiagnosticProviderAndFixer(Workspace workspace)
=> (null, new GenerateDeconstructMethodCodeFixProvider());
diff --git a/src/Features/CSharpTest/GenerateMethod/GenerateMethodTests.cs b/src/Analyzers/CSharp/Tests/GenerateMethod/GenerateMethodTests.cs
similarity index 99%
rename from src/Features/CSharpTest/GenerateMethod/GenerateMethodTests.cs
rename to src/Analyzers/CSharp/Tests/GenerateMethod/GenerateMethodTests.cs
index 8ca11d1c34efc..11377189c98f5 100644
--- a/src/Features/CSharpTest/GenerateMethod/GenerateMethodTests.cs
+++ b/src/Analyzers/CSharp/Tests/GenerateMethod/GenerateMethodTests.cs
@@ -4,6 +4,7 @@
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.CodeFixes;
+using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.CSharp.CodeFixes.GenerateMethod;
using Microsoft.CodeAnalysis.CSharp.CodeStyle;
using Microsoft.CodeAnalysis.CSharp.Test.Utilities;
@@ -5300,7 +5301,7 @@ internal static void Test(global::Outer.Inner inner)
}
}
""",
-new TestParameters(Options.Regular));
+new TestParameters(new CSharpParseOptions(kind: SourceCodeKind.Regular)));
}
[Theory]
diff --git a/src/Features/CSharpTest/ImplementAbstractClass/ImplementAbstractClassTests.cs b/src/Analyzers/CSharp/Tests/ImplementAbstractClass/ImplementAbstractClassTests.cs
similarity index 100%
rename from src/Features/CSharpTest/ImplementAbstractClass/ImplementAbstractClassTests.cs
rename to src/Analyzers/CSharp/Tests/ImplementAbstractClass/ImplementAbstractClassTests.cs
diff --git a/src/Features/CSharpTest/ImplementAbstractClass/ImplementAbstractClassTests_FixAllTests.cs b/src/Analyzers/CSharp/Tests/ImplementAbstractClass/ImplementAbstractClassTests_FixAllTests.cs
similarity index 100%
rename from src/Features/CSharpTest/ImplementAbstractClass/ImplementAbstractClassTests_FixAllTests.cs
rename to src/Analyzers/CSharp/Tests/ImplementAbstractClass/ImplementAbstractClassTests_FixAllTests.cs
diff --git a/src/Features/CSharpTest/ImplementAbstractClass/ImplementAbstractClassTests_ThroughMember.cs b/src/Analyzers/CSharp/Tests/ImplementAbstractClass/ImplementAbstractClassTests_ThroughMember.cs
similarity index 90%
rename from src/Features/CSharpTest/ImplementAbstractClass/ImplementAbstractClassTests_ThroughMember.cs
rename to src/Analyzers/CSharp/Tests/ImplementAbstractClass/ImplementAbstractClassTests_ThroughMember.cs
index 72af868c1c1a3..8a4ed151f3ccc 100644
--- a/src/Features/CSharpTest/ImplementAbstractClass/ImplementAbstractClassTests_ThroughMember.cs
+++ b/src/Analyzers/CSharp/Tests/ImplementAbstractClass/ImplementAbstractClassTests_ThroughMember.cs
@@ -72,7 +72,7 @@ abstract class Base
class [|Derived|] : Base
{
}
- """, [FeaturesResources.Implement_abstract_class]);
+ """, [AnalyzersResources.Implement_abstract_class]);
}
[Fact, WorkItem("https://github.com/dotnet/roslyn/issues/41420")]
@@ -93,7 +93,7 @@ abstract class Middle : Base
class [|Derived|] : Base
{
}
- """, [FeaturesResources.Implement_abstract_class]);
+ """, [AnalyzersResources.Implement_abstract_class]);
}
[Fact, WorkItem("https://github.com/dotnet/roslyn/issues/41420")]
@@ -126,7 +126,7 @@ public override void Method()
inner.Method();
}
}
- """, index: 1, title: string.Format(FeaturesResources.Implement_through_0, "inner"));
+ """, index: 1, title: string.Format(AnalyzersResources.Implement_through_0, "inner"));
}
[Fact]
@@ -159,7 +159,7 @@ public override void Method(int a, ref int b, in int c, ref readonly int d, out
inner.Method(a, ref b, c, in d, out e);
}
}
- """, index: 1, title: string.Format(FeaturesResources.Implement_through_0, "inner"));
+ """, index: 1, title: string.Format(AnalyzersResources.Implement_through_0, "inner"));
}
[Fact]
@@ -189,7 +189,7 @@ class Derived : Base
public override int this[int a, in int b, ref readonly int c, out int d] => inner[a, b, in c, out d];
}
- """, index: 1, title: string.Format(FeaturesResources.Implement_through_0, "inner"));
+ """, index: 1, title: string.Format(AnalyzersResources.Implement_through_0, "inner"));
}
[Fact, WorkItem("https://github.com/dotnet/roslyn/issues/41420")]
@@ -224,7 +224,7 @@ public override void Method1()
inner.Method1();
}
}
- """, index: 1, title: string.Format(FeaturesResources.Implement_through_0, "inner"));
+ """, index: 1, title: string.Format(AnalyzersResources.Implement_through_0, "inner"));
}
[Fact, WorkItem("https://github.com/dotnet/roslyn/issues/41420")]
@@ -247,7 +247,7 @@ public override void Method1()
inner.Method1();
}
}
- """, new string[] { FeaturesResources.Implement_abstract_class });
+ """, [AnalyzersResources.Implement_abstract_class]);
}
[Fact, WorkItem("https://github.com/dotnet/roslyn/issues/41420")]
@@ -288,7 +288,7 @@ public override void Method()
class DerivedAgain : Derived
{
}
- """, index: 1, title: string.Format(FeaturesResources.Implement_through_0, "inner"));
+ """, index: 1, title: string.Format(AnalyzersResources.Implement_through_0, "inner"));
}
[Fact, WorkItem("https://github.com/dotnet/roslyn/issues/41420")]
@@ -321,7 +321,7 @@ public override void Method()
inner.Method();
}
}
- """, index: 1, title: string.Format(FeaturesResources.Implement_through_0, "inner"));
+ """, index: 1, title: string.Format(AnalyzersResources.Implement_through_0, "inner"));
}
[Fact, WorkItem("https://github.com/dotnet/roslyn/issues/41420")]
@@ -347,9 +347,9 @@ class [|Derived|] : Base, IInterface
}
""",
[
- FeaturesResources.Implement_abstract_class,
- string.Format(FeaturesResources.Implement_through_0, "Inner"),
- string.Format(FeaturesResources.Implement_through_0, "IInterface.Inner"),
+ AnalyzersResources.Implement_abstract_class,
+ string.Format(AnalyzersResources.Implement_through_0, "Inner"),
+ string.Format(AnalyzersResources.Implement_through_0, "IInterface.Inner"),
]);
}
@@ -367,7 +367,7 @@ class [|Derived|] : Base
{
dynamic inner;
}
- """, [FeaturesResources.Implement_abstract_class]);
+ """, [AnalyzersResources.Implement_abstract_class]);
}
[Fact, WorkItem("https://github.com/dotnet/roslyn/issues/41420")]
@@ -400,7 +400,7 @@ public override void Method()
inner.Method();
}
}
- """, index: 1, title: string.Format(FeaturesResources.Implement_through_0, "inner"));
+ """, index: 1, title: string.Format(AnalyzersResources.Implement_through_0, "inner"));
}
[Fact, WorkItem("https://github.com/dotnet/roslyn/issues/41420")]
@@ -430,7 +430,7 @@ class Derived : Base
public override int Property { get => inner.Property; set => inner.Property = value; }
}
- """, index: 1, title: string.Format(FeaturesResources.Implement_through_0, "inner"));
+ """, index: 1, title: string.Format(AnalyzersResources.Implement_through_0, "inner"));
}
[Fact, WorkItem("https://github.com/dotnet/roslyn/issues/41420")]
@@ -505,7 +505,7 @@ class Derived : Base
public override int SetOnly { set => inner.SetOnly = value; }
}
- """, index: 1, title: string.Format(FeaturesResources.Implement_through_0, "inner"));
+ """, index: 1, title: string.Format(AnalyzersResources.Implement_through_0, "inner"));
}
[Fact, WorkItem("https://github.com/dotnet/roslyn/issues/41420")]
@@ -596,7 +596,7 @@ public override event Action Event
}
}
}
- """, index: 1, title: string.Format(FeaturesResources.Implement_through_0, "inner"));
+ """, index: 1, title: string.Format(AnalyzersResources.Implement_through_0, "inner"));
}
[Fact, WorkItem("https://github.com/dotnet/roslyn/issues/41420")]
@@ -633,7 +633,7 @@ public override void Method()
inner.Method();
}
}
- """, index: 1, title: string.Format(FeaturesResources.Implement_through_0, "inner"));
+ """, index: 1, title: string.Format(AnalyzersResources.Implement_through_0, "inner"));
}
[Fact, WorkItem("https://github.com/dotnet/roslyn/issues/41420")]
@@ -650,7 +650,7 @@ class [|Derived|] : Base
{
Base inner;
}
- """, [FeaturesResources.Implement_abstract_class]);
+ """, [AnalyzersResources.Implement_abstract_class]);
}
[Fact, WorkItem("https://github.com/dotnet/roslyn/issues/41420")]
@@ -683,7 +683,7 @@ protected override void Method()
inner.Method();
}
}
- """, index: 1, title: string.Format(FeaturesResources.Implement_through_0, "inner"));
+ """, index: 1, title: string.Format(AnalyzersResources.Implement_through_0, "inner"));
}
[Fact, WorkItem("https://github.com/dotnet/roslyn/issues/41420")]
@@ -716,7 +716,7 @@ protected internal override void Method()
inner.Method();
}
}
- """, index: 1, title: string.Format(FeaturesResources.Implement_through_0, "inner"));
+ """, index: 1, title: string.Format(AnalyzersResources.Implement_through_0, "inner"));
}
[Fact, WorkItem("https://github.com/dotnet/roslyn/issues/41420")]
@@ -749,7 +749,7 @@ internal override void Method()
inner.Method();
}
}
- """, index: 1, title: string.Format(FeaturesResources.Implement_through_0, "inner"));
+ """, index: 1, title: string.Format(AnalyzersResources.Implement_through_0, "inner"));
}
[Fact, WorkItem("https://github.com/dotnet/roslyn/issues/41420")]
@@ -766,7 +766,7 @@ class [|Derived|] : Base
{
Base inner;
}
- """, [FeaturesResources.Implement_abstract_class]);
+ """, [AnalyzersResources.Implement_abstract_class]);
}
[Fact, WorkItem("https://github.com/dotnet/roslyn/issues/41420")]
@@ -799,7 +799,7 @@ private protected override void Method()
inner.Method();
}
}
- """, index: 1, title: string.Format(FeaturesResources.Implement_through_0, "inner"));
+ """, index: 1, title: string.Format(AnalyzersResources.Implement_through_0, "inner"));
}
[Fact, WorkItem("https://github.com/dotnet/roslyn/issues/41420")]
@@ -832,7 +832,7 @@ class Derived : Base
public override int InternalGet { internal get => inner.InternalGet; set => inner.InternalGet = value; }
public override int InternalSet { get => inner.InternalSet; internal set => inner.InternalSet = value; }
}
- """, index: 1, title: string.Format(FeaturesResources.Implement_through_0, "inner"));
+ """, index: 1, title: string.Format(AnalyzersResources.Implement_through_0, "inner"));
}
[Fact]
@@ -935,7 +935,7 @@ class [|Program|](Base base1) : Base
{
private Base _base = base1;
}
- """, [FeaturesResources.Implement_abstract_class, string.Format(FeaturesResources.Implement_through_0, "_base")]);
+ """, [AnalyzersResources.Implement_abstract_class, string.Format(AnalyzersResources.Implement_through_0, "_base")]);
}
[Fact, WorkItem("https://github.com/dotnet/roslyn/issues/69177")]
@@ -953,7 +953,7 @@ class [|Program|](Base base1) : Base
{
private Base _base = (base1);
}
- """, [FeaturesResources.Implement_abstract_class, string.Format(FeaturesResources.Implement_through_0, "_base")]);
+ """, [AnalyzersResources.Implement_abstract_class, string.Format(AnalyzersResources.Implement_through_0, "_base")]);
}
[Fact, WorkItem("https://github.com/dotnet/roslyn/issues/69177")]
@@ -971,7 +971,7 @@ class [|Program|](Base base1) : Base
{
private Base B { get; } = base1;
}
- """, [FeaturesResources.Implement_abstract_class, string.Format(FeaturesResources.Implement_through_0, "B")]);
+ """, [AnalyzersResources.Implement_abstract_class, string.Format(AnalyzersResources.Implement_through_0, "B")]);
}
[Fact, WorkItem("https://github.com/dotnet/roslyn/issues/69177")]
@@ -989,7 +989,7 @@ class [|Program|](Base base1) : Base
{
private Base B { get; } = (base1);
}
- """, [FeaturesResources.Implement_abstract_class, string.Format(FeaturesResources.Implement_through_0, "B")]);
+ """, [AnalyzersResources.Implement_abstract_class, string.Format(AnalyzersResources.Implement_through_0, "B")]);
}
[Fact, WorkItem("https://github.com/dotnet/roslyn/issues/69177")]
diff --git a/src/EditorFeatures/CSharpTest/CodeActions/ImplementInterface/ImplementInterfaceTests.cs b/src/Analyzers/CSharp/Tests/ImplementInterface/ImplementInterfaceTests.cs
similarity index 93%
rename from src/EditorFeatures/CSharpTest/CodeActions/ImplementInterface/ImplementInterfaceTests.cs
rename to src/Analyzers/CSharp/Tests/ImplementInterface/ImplementInterfaceTests.cs
index cf28711a00bfa..1fcfb16183639 100644
--- a/src/EditorFeatures/CSharpTest/CodeActions/ImplementInterface/ImplementInterfaceTests.cs
+++ b/src/Analyzers/CSharp/Tests/ImplementInterface/ImplementInterfaceTests.cs
@@ -377,7 +377,7 @@ class Class : IInterface
}
}
""",
-codeAction: ("True;False;False:global::IInterface;TestProject;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;", 1));
+codeAction: ("True;False;False:global::IInterface;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;", 1));
}
[Fact, CompilerTrait(CompilerFeature.Tuples)]
@@ -560,7 +560,7 @@ public void M(string? s1, string s2)
""",
},
},
- CodeActionEquivalenceKey = "False;False;True:global::IInterface;Assembly1;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;",
+ CodeActionEquivalenceKey = "False;False;True:global::IInterface;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;",
CodeActionIndex = 0,
};
@@ -1017,7 +1017,7 @@ public void Method1()
}
}
""",
-codeAction: ("False;False;False:global::I;TestProject;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;i", 1));
+codeAction: ("False;False;False:global::I;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;i", 1));
}
[Fact, WorkItem("https://github.com/dotnet/roslyn/issues/69177")]
@@ -1048,7 +1048,7 @@ public void Method1()
}
}
""",
-codeAction: ("False;False;False:global::I;TestProject;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;i", 1));
+codeAction: ("False;False;False:global::I;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;i", 1));
}
[Fact]
@@ -1097,7 +1097,7 @@ public void Method1()
}
}
""",
-codeAction: ("False;False;False:global::I;TestProject;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;i", 1));
+codeAction: ("False;False;False:global::I;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;i", 1));
}
[Fact]
@@ -1146,7 +1146,7 @@ public void Method1()
}
}
""",
-codeAction: ("False;False;False:global::I;TestProject;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;i", 1));
+codeAction: ("False;False;False:global::I;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;i", 1));
}
[Fact]
@@ -1199,7 +1199,7 @@ class D : {|CS0535:I|}
MarkupHandling = MarkupMode.Allow,
},
CodeFixTestBehaviors = CodeFixTestBehaviors.FixOne,
- CodeActionEquivalenceKey = "False;False;False:global::I;TestProject;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;i",
+ CodeActionEquivalenceKey = "False;False;False:global::I;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;i",
CodeActionIndex = 1,
};
@@ -1246,7 +1246,7 @@ public int this[int x]
}
}
""",
-codeAction: ("False;False;False:global::IGoo;TestProject;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;f", 1));
+codeAction: ("False;False;False:global::IGoo;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;f", 1));
}
[Fact, WorkItem("https://github.com/dotnet/roslyn/issues/472")]
@@ -1274,7 +1274,7 @@ public int Compare(object x, object y)
}
}
""",
-codeAction: ("False;False;False:global::System.Collections.IComparer;mscorlib;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;x", 1));
+codeAction: ("False;False;False:global::System.Collections.IComparer;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;x", 1));
}
[Fact, WorkItem("https://github.com/dotnet/roslyn/issues/472")]
@@ -1302,7 +1302,7 @@ public int Compare(object x, object y)
}
}
""",
-codeAction: ("False;False;False:global::System.Collections.IComparer;mscorlib;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;a", 1));
+codeAction: ("False;False;False:global::System.Collections.IComparer;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;a", 1));
}
[Fact]
@@ -1330,7 +1330,7 @@ abstract class C : I
public abstract void Method1();
}
""",
-codeAction: ("False;True;True:global::I;TestProject;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;", 1));
+codeAction: ("False;True;True:global::I;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;", 1));
}
[Fact]
@@ -1371,7 +1371,7 @@ interface I
int Method2();
}
""",
-codeAction: ("False;False;False:global::I;TestProject;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;goo", 1));
+codeAction: ("False;False;False:global::I;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;goo", 1));
}
[Fact]
@@ -2180,7 +2180,7 @@ int i1.p
}
}
""",
-codeAction: ("True;False;False:global::i1;TestProject;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;", 1));
+codeAction: ("True;False;False:global::i1;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;", 1));
}
[Fact, WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/541981")]
@@ -2220,7 +2220,7 @@ public void Method1()
""",
Options = { AllOptionsOff },
CodeActionsVerifier = codeActions => Assert.Equal(3, codeActions.Length),
- CodeActionEquivalenceKey = "False;False;True:global::I;TestProject;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;",
+ CodeActionEquivalenceKey = "False;False;True:global::I;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;",
CodeActionIndex = 0,
}.RunAsync();
@@ -2245,7 +2245,7 @@ public void Method1()
""",
Options = { AllOptionsOff },
CodeActionsVerifier = codeActions => Assert.Equal(3, codeActions.Length),
- CodeActionEquivalenceKey = "False;False;False:global::I;TestProject;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;i",
+ CodeActionEquivalenceKey = "False;False;False:global::I;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;i",
CodeActionIndex = 1,
}.RunAsync();
@@ -2270,7 +2270,7 @@ void I.Method1()
""",
Options = { AllOptionsOff },
CodeActionsVerifier = codeActions => Assert.Equal(3, codeActions.Length),
- CodeActionEquivalenceKey = "True;False;False:global::I;TestProject;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;",
+ CodeActionEquivalenceKey = "True;False;False:global::I;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;",
CodeActionIndex = 2,
}.RunAsync();
}
@@ -2322,7 +2322,7 @@ IEnumerator IEnumerable.GetEnumerator()
}
}
""",
-codeAction: ("False;False;False:global::System.Collections.Generic.IReadOnlyList;mscorlib;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;field", 1));
+codeAction: ("False;False;False:global::System.Collections.Generic.IReadOnlyList;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;field", 1));
}
[Fact, WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/768799")]
@@ -2372,7 +2372,7 @@ IEnumerator IEnumerable.GetEnumerator()
}
}
""",
-codeAction: ("False;False;False:global::System.Collections.Generic.IReadOnlyList;mscorlib;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;field", 1));
+codeAction: ("False;False;False:global::System.Collections.Generic.IReadOnlyList;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;field", 1));
}
[Fact, WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/768799")]
@@ -2422,7 +2422,7 @@ public int M()
}
}
""",
-codeAction: ("False;False;False:global::I;TestProject;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;a", 1));
+codeAction: ("False;False;False:global::I;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;a", 1));
}
[Fact, WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/768799")]
@@ -2504,7 +2504,7 @@ public int M()
CodeActionsVerifier = codeActions => Assert.Equal(3, codeActions.Length),
DiagnosticSelector = diagnostics => diagnostics[0],
CodeFixTestBehaviors = CodeFixTestBehaviors.FixOne,
- CodeActionEquivalenceKey = "False;False;False:global::I;TestProject;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;a",
+ CodeActionEquivalenceKey = "False;False;False:global::I;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;a",
CodeActionIndex = 1,
}.RunAsync();
@@ -2584,7 +2584,7 @@ public int M2()
CodeActionsVerifier = codeActions => Assert.Equal(3, codeActions.Length),
DiagnosticSelector = diagnostics => diagnostics[1],
CodeFixTestBehaviors = CodeFixTestBehaviors.FixOne,
- CodeActionEquivalenceKey = "False;False;False:global::I2;TestProject;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;a",
+ CodeActionEquivalenceKey = "False;False;False:global::I2;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;a",
CodeActionIndex = 1,
}.RunAsync();
}
@@ -2648,7 +2648,7 @@ public int M()
},
Options = { AllOptionsOff },
CodeActionsVerifier = codeActions => Assert.Equal(4, codeActions.Length),
- CodeActionEquivalenceKey = "False;False;False:global::I;TestProject;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;a",
+ CodeActionEquivalenceKey = "False;False;False:global::I;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;a",
CodeActionIndex = 1,
}.RunAsync();
@@ -2708,7 +2708,7 @@ public int M()
},
Options = { AllOptionsOff },
CodeActionsVerifier = codeActions => Assert.Equal(4, codeActions.Length),
- CodeActionEquivalenceKey = "False;False;False:global::I;TestProject;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;aa",
+ CodeActionEquivalenceKey = "False;False;False:global::I;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;aa",
CodeActionIndex = 2,
}.RunAsync();
}
@@ -2800,7 +2800,7 @@ public int M()
CodeActionsVerifier = codeActions => Assert.Equal(3, codeActions.Length),
DiagnosticSelector = diagnostics => diagnostics[0],
CodeFixTestBehaviors = CodeFixTestBehaviors.FixOne,
- CodeActionEquivalenceKey = "False;False;False:global::I;TestProject;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;a",
+ CodeActionEquivalenceKey = "False;False;False:global::I;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;a",
CodeActionIndex = 1,
}.RunAsync();
@@ -2888,7 +2888,7 @@ public int M2()
CodeActionsVerifier = codeActions => Assert.Equal(3, codeActions.Length),
DiagnosticSelector = diagnostics => diagnostics[1],
CodeFixTestBehaviors = CodeFixTestBehaviors.FixOne,
- CodeActionEquivalenceKey = "False;False;False:global::I2;TestProject;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;b",
+ CodeActionEquivalenceKey = "False;False;False:global::I2;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;b",
CodeActionIndex = 1,
}.RunAsync();
}
@@ -2933,7 +2933,7 @@ public int M()
""",
Options = { AllOptionsOff },
CodeActionsVerifier = codeActions => Assert.Equal(3, codeActions.Length),
- CodeActionEquivalenceKey = "False;False;False:global::IB;TestProject;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;IA.B",
+ CodeActionEquivalenceKey = "False;False;False:global::IB;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;IA.B",
CodeActionIndex = 1,
}.RunAsync();
}
@@ -3113,7 +3113,7 @@ public event EventHandler E
}
}
}
- """, codeAction: ("False;False;False:global::IGoo;TestProject;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;canGoo", 1));
+ """, codeAction: ("False;False;False:global::IGoo;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;canGoo", 1));
}
[Fact]
@@ -3140,7 +3140,7 @@ public event EventHandler E
}
}
""",
-codeAction: ("False;False;False:global::IGoo;TestProject;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;canGoo", 1));
+codeAction: ("False;False;False:global::IGoo;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;canGoo", 1));
}
[Fact]
@@ -3170,7 +3170,7 @@ abstract class Goo : IGoo
public event EventHandler E;
}
""",
-codeAction: ("False;False;True:global::IGoo;TestProject;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;", 0));
+codeAction: ("False;False;True:global::IGoo;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;", 0));
}
[Fact]
@@ -3200,7 +3200,7 @@ abstract class Goo : IGoo
public abstract event EventHandler E;
}
""",
-codeAction: ("False;True;True:global::IGoo;TestProject;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;", 1));
+codeAction: ("False;True;True:global::IGoo;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;", 1));
}
[Fact]
@@ -3241,7 +3241,7 @@ event EventHandler IGoo.E
}
}
""",
-codeAction: ("True;False;False:global::IGoo;TestProject;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;", 2));
+codeAction: ("True;False;False:global::IGoo;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;", 2));
}
[Fact]
@@ -3427,7 +3427,7 @@ int ISomeInterface.this[int index]
}
}
""",
-codeAction: ("True;False;False:global::ISomeInterface;TestProject;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;", 1));
+codeAction: ("True;False;False:global::ISomeInterface;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;", 1));
}
[Fact]
@@ -3521,7 +3521,7 @@ void I.Goo()
}
}
""",
-codeAction: ("True;False;False:global::I;TestProject;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;", 1));
+codeAction: ("True;False;False:global::I;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;", 1));
}
[Fact, WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/542357")]
@@ -3660,7 +3660,7 @@ void I.Goo()
}
}
""",
-codeAction: ("True;False;False:global::I;TestProject;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;", 1));
+codeAction: ("True;False;False:global::I;Microsoft.CodeAnalysis.ImplementInterface.AbstractImplementInterfaceService+ImplementInterfaceCodeAction;", 1));
}
[Fact, WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/542587")]
@@ -3751,7 +3751,7 @@ void I