Skip to content

Commit bac019e

Browse files
Merge remote-tracking branch 'upstream/main' into useExtension
2 parents d409041 + 2d01ce7 commit bac019e

File tree

308 files changed

+7761
-17399
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

308 files changed

+7761
-17399
lines changed

eng/Directory.Packages.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@
117117
<!--
118118
VS Debugger
119119
-->
120-
<PackageVersion Include="Microsoft.VisualStudio.Debugger.Contracts" Version="17.13.0-beta.25105.1" />
120+
<PackageVersion Include="Microsoft.VisualStudio.Debugger.Contracts" Version="18.0.0-beta.25359.1" />
121121
<PackageVersion Include="Microsoft.VisualStudio.Debugger.Engine-implementation" Version="17.13.1121201-preview" />
122122
<PackageVersion Include="Microsoft.VisualStudio.Debugger.Metadata-implementation" Version="17.13.1121201-preview" />
123123

eng/Publishing.props

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,14 @@
1717
<!--
1818
During PR Validation we only need to publish symbols with Arcade,
1919
since our packages are published separately to the CoreXT feed.
20+
21+
Also, do not publish any symbols packages in source-only builds.
2022
-->
2123
<Target Name="_ResolvePublishRoslynNuGetPackages"
2224
DependsOnTargets="BeforePublish"
2325
BeforeTargets="PublishToAzureDevOpsArtifacts"
24-
Condition=" '$(PreReleaseVersionLabel)' == 'pr-validation' ">
26+
Condition=" '$(PreReleaseVersionLabel)' == 'pr-validation' or '$(DotNetBuildSourceOnly)' == 'true' ">
27+
2528
<ItemGroup>
2629
<!-- Determine all NuGet packages being published -->
2730
<_NuGetPackagesToPush Include="@(ItemsToPushToBlobFeed)"
@@ -30,13 +33,25 @@
3033
<!-- Determine all symbol packages being published -->
3134
<_SymbolPackagesToPush Include="@(_NuGetPackagesToPush)"
3235
Condition="$([System.String]::Copy(%(FullPath)).EndsWith('.symbols.nupkg'))" />
36+
<_SymbolPackagesToPush Include="@(_NuGetPackagesToPush)"
37+
Condition="$([System.String]::Copy(%(FullPath)).Contains('.Symbols.'))" />
38+
</ItemGroup>
3339

40+
<ItemGroup Condition=" '$(PreReleaseVersionLabel)' == 'pr-validation' ">
3441
<!-- Remove all NuGet packages from being published -->
3542
<ItemsToPushToBlobFeed Remove="@(_NuGetPackagesToPush)" />
43+
</ItemGroup>
44+
45+
<ItemGroup Condition=" '$(DotNetBuildSourceOnly)' == 'true' ">
46+
<!-- Remove all symbols packages from being published -->
47+
<ItemsToPushToBlobFeed Remove="@(_SymbolPackagesToPush)" />
48+
</ItemGroup>
3649

37-
<!-- Include symbol packages for publishing -->
50+
<ItemGroup Condition=" '$(PreReleaseVersionLabel)' == 'pr-validation' and '$(DotNetBuildSourceOnly)' != 'true' ">
51+
<!-- Include symbol packages for publishing-->
3852
<ItemsToPushToBlobFeed Include="@(_SymbolPackagesToPush)" />
3953
</ItemGroup>
54+
4055
</Target>
4156

4257
</Project>

eng/Version.Details.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<Dependencies>
3-
<Source Uri="https://github.com/dotnet/dotnet" Mapping="roslyn" Sha="f451e5d3036a4f140a989e0a7f3f1ae432420e71" BarId="274568" />
3+
<Source Uri="https://github.com/dotnet/dotnet" Mapping="roslyn" Sha="87e4c823cc62a13a3e8afbddc78bf718971f376c" BarId="276628" />
44
<ProductDependencies>
55
<!-- RoslynAnalyzers reference older builds of Roslyn and this is necessary for SourceBuild. -->
66
<Dependency Name="Microsoft.CodeAnalysis" Version="3.11.0">
77
<Uri>https://github.com/dotnet/roslyn</Uri>
88
<Sha>ae1fff344d46976624e68ae17164e0607ab68b10</Sha>
99
</Dependency>
10-
<Dependency Name="System.CommandLine" Version="2.0.0-beta5.25210.1">
11-
<Uri>https://github.com/dotnet/command-line-api</Uri>
12-
<Sha>e9b0511d7f1128e2bc3be7a658a2a4ea977e602d</Sha>
10+
<Dependency Name="System.CommandLine" Version="2.0.0-beta7.25374.102">
11+
<Uri>https://github.com/dotnet/dotnet</Uri>
12+
<Sha>87e4c823cc62a13a3e8afbddc78bf718971f376c</Sha>
1313
</Dependency>
1414
<!-- Necessary for source-build. This allows the live version of the package to be used by source-build. -->
1515
<Dependency Name="Microsoft.Bcl.AsyncInterfaces" Version="9.0.0">

eng/Versions.props

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
-->
4040
<SystemDataSqlClientVersion>4.8.6</SystemDataSqlClientVersion>
4141
<SystemMemoryVersion>4.6.0</SystemMemoryVersion>
42-
<SystemNumericsVectorsVersion>4.6.1</SystemNumericsVectorsVersion>
42+
<SystemNumericsVectorsVersion>4.6.0</SystemNumericsVectorsVersion>
4343
<SystemRuntimeCompilerServicesUnsafeVersion>6.1.0</SystemRuntimeCompilerServicesUnsafeVersion>
4444
<SystemThreadingTasksExtensionsVersion>4.6.0</SystemThreadingTasksExtensionsVersion>
4545
<SystemValueTupleVersion>4.5.0</SystemValueTupleVersion>
@@ -48,7 +48,7 @@
4848
Versions managed by Arcade (see Versions.Details.xml)
4949
-->
5050
<PropertyGroup>
51-
<SystemCommandLineVersion>2.0.0-beta5.25210.1</SystemCommandLineVersion>
51+
<SystemCommandLineVersion>2.0.0-beta7.25374.102</SystemCommandLineVersion>
5252
<SystemCompositionVersion>9.0.0</SystemCompositionVersion>
5353
<SystemConfigurationConfigurationManagerVersion>9.0.0</SystemConfigurationConfigurationManagerVersion>
5454
<SystemDiagnosticsEventLogVersion>9.0.0</SystemDiagnosticsEventLogVersion>

src/Analyzers/CSharp/CodeFixes/MisplacedUsingDirectives/MisplacedUsingDirectivesCodeFixProvider.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ namespace Microsoft.CodeAnalysis.CSharp.MisplacedUsingDirectives;
3636
[ExportCodeFixProvider(LanguageNames.CSharp, Name = PredefinedCodeFixProviderNames.MoveMisplacedUsingDirectives), Shared]
3737
[method: ImportingConstructor]
3838
[method: SuppressMessage("RoslynDiagnosticsReliability", "RS0033:Importing constructor should be [Obsolete]", Justification = "Used in test code: https://github.com/dotnet/roslyn/issues/42814")]
39-
internal sealed partial class MisplacedUsingDirectivesCodeFixProvider() : CodeFixProvider
39+
internal sealed class MisplacedUsingDirectivesCodeFixProvider() : CodeFixProvider
4040
{
4141
private static readonly SyntaxAnnotation s_usingPlacementCodeFixAnnotation = new(nameof(s_usingPlacementCodeFixAnnotation));
4242

@@ -73,10 +73,9 @@ public override async Task RegisterCodeFixesAsync(CodeFixContext context)
7373

7474
foreach (var diagnostic in context.Diagnostics)
7575
{
76-
context.RegisterCodeFix(
77-
CodeAction.Create(
76+
context.RegisterCodeFix(CodeAction.Create(
7877
CSharpAnalyzersResources.Move_misplaced_using_directives,
79-
token => GetTransformedDocumentAsync(document, compilationUnit, GetAllUsingDirectives(compilationUnit), placement, simplifierOptions, token),
78+
cancellationToken => GetTransformedDocumentAsync(document, compilationUnit, placement, simplifierOptions, cancellationToken),
8079
nameof(CSharpAnalyzersResources.Move_misplaced_using_directives)),
8180
diagnostic);
8281
}
@@ -101,7 +100,7 @@ internal static async Task<Document> TransformDocumentIfRequiredAsync(
101100
return document;
102101

103102
return await GetTransformedDocumentAsync(
104-
document, compilationUnit, allUsingDirectives, placement, simplifierOptions, cancellationToken).ConfigureAwait(false);
103+
document, compilationUnit, placement, simplifierOptions, cancellationToken).ConfigureAwait(false);
105104
}
106105

107106
private static ImmutableArray<UsingDirectiveSyntax> GetAllUsingDirectives(CompilationUnitSyntax compilationUnit)
@@ -123,7 +122,7 @@ void Recurse(SyntaxList<MemberDeclarationSyntax> members)
123122
{
124123
foreach (var member in members)
125124
{
126-
if (member is NamespaceDeclarationSyntax namespaceDeclaration)
125+
if (member is BaseNamespaceDeclarationSyntax namespaceDeclaration)
127126
{
128127
result.AddRange(namespaceDeclaration.Usings);
129128
Recurse(namespaceDeclaration.Members);
@@ -135,13 +134,14 @@ void Recurse(SyntaxList<MemberDeclarationSyntax> members)
135134
private static async Task<Document> GetTransformedDocumentAsync(
136135
Document document,
137136
CompilationUnitSyntax compilationUnit,
138-
ImmutableArray<UsingDirectiveSyntax> allUsingDirectives,
139137
AddImportPlacement placement,
140138
SimplifierOptions simplifierOptions,
141139
CancellationToken cancellationToken)
142140
{
143141
var bannerService = document.GetRequiredLanguageService<IFileBannerFactsService>();
144142

143+
var allUsingDirectives = GetAllUsingDirectives(compilationUnit);
144+
145145
// Expand usings so that they can be properly simplified after they are relocated.
146146
var compilationUnitWithExpandedUsings = await ExpandUsingDirectivesAsync(
147147
document, compilationUnit, allUsingDirectives, cancellationToken).ConfigureAwait(false);

src/Analyzers/CSharp/CodeFixes/UseImplicitOrExplicitType/UseExplicitTypeCodeFixProvider.cs

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
using Microsoft.CodeAnalysis.LanguageService;
1818
using Microsoft.CodeAnalysis.PooledObjects;
1919
using Microsoft.CodeAnalysis.Shared.Extensions;
20+
using Microsoft.CodeAnalysis.Simplification;
2021
using Roslyn.Utilities;
2122

2223
namespace Microsoft.CodeAnalysis.CSharp.TypeStyle;
@@ -96,7 +97,8 @@ private static async Task HandleDeclarationExpressionAsync(Document document, Sy
9697
var leadingTrivia = declarationExpression.GetLeadingTrivia()
9798
.Concat(variableDesignation.GetAllPrecedingTriviaToPreviousToken().Where(t => !t.IsWhitespace()).Select(t => t.WithoutAnnotations(SyntaxAnnotation.ElasticAnnotation)));
9899

99-
var tupleDeclaration = GenerateTupleDeclaration(tupleTypeSymbol, variableDesignation).WithLeadingTrivia(leadingTrivia);
100+
var tupleDeclaration = GenerateTupleDeclaration(
101+
semanticModel, tupleTypeSymbol, variableDesignation, cancellationToken).WithLeadingTrivia(leadingTrivia);
100102

101103
editor.ReplaceNode(declarationExpression, tupleDeclaration);
102104
}
@@ -171,7 +173,11 @@ private static ITypeSymbol AdjustNullabilityOfTypeSymbol(
171173
return typeSymbol;
172174
}
173175

174-
private static ExpressionSyntax GenerateTupleDeclaration(ITypeSymbol typeSymbol, ParenthesizedVariableDesignationSyntax parensDesignation)
176+
private static ExpressionSyntax GenerateTupleDeclaration(
177+
SemanticModel semanticModel,
178+
ITypeSymbol typeSymbol,
179+
ParenthesizedVariableDesignationSyntax parensDesignation,
180+
CancellationToken cancellationToken)
175181
{
176182
Debug.Assert(typeSymbol.IsTupleType);
177183
var elements = ((INamedTypeSymbol)typeSymbol).TupleElements;
@@ -186,12 +192,18 @@ private static ExpressionSyntax GenerateTupleDeclaration(ITypeSymbol typeSymbol,
186192
switch (designation.Kind())
187193
{
188194
case SyntaxKind.SingleVariableDesignation:
195+
var singleVariableDesignation = (SingleVariableDesignationSyntax)designation;
196+
var localSymbol = semanticModel.GetDeclaredSymbol(singleVariableDesignation, cancellationToken);
197+
var symbolType = localSymbol.GetSymbolType() ?? type;
198+
newDeclaration = DeclarationExpression(symbolType.GenerateTypeSyntax(allowVar: false), singleVariableDesignation);
199+
break;
189200
case SyntaxKind.DiscardDesignation:
190201
var typeName = type.GenerateTypeSyntax(allowVar: false);
191202
newDeclaration = DeclarationExpression(typeName, designation);
192203
break;
193204
case SyntaxKind.ParenthesizedVariableDesignation:
194-
newDeclaration = GenerateTupleDeclaration(type, (ParenthesizedVariableDesignationSyntax)designation);
205+
newDeclaration = GenerateTupleDeclaration(
206+
semanticModel, type, (ParenthesizedVariableDesignationSyntax)designation, cancellationToken);
195207
break;
196208
default:
197209
throw ExceptionUtilities.UnexpectedValue(designation.Kind());
@@ -213,13 +225,14 @@ private static ExpressionSyntax GenerateTupleDeclaration(ITypeSymbol typeSymbol,
213225
.WithTrailingTrivia(parensDesignation.GetTrailingTrivia());
214226
}
215227

216-
private static SyntaxNode GenerateTypeDeclaration(TypeSyntax typeSyntax, ITypeSymbol newTypeSymbol)
228+
private static TypeSyntax GenerateTypeDeclaration(TypeSyntax typeSyntax, ITypeSymbol newTypeSymbol)
217229
{
218230
// We're going to be passed through the simplifier. Tell it to not just convert this back to var (as
219231
// that would defeat the purpose of this refactoring entirely).
220232
var newTypeSyntax = newTypeSymbol
221-
.GenerateTypeSyntax(allowVar: false)
222-
.WithTriviaFrom(typeSyntax);
233+
.GenerateTypeSyntax(allowVar: false)
234+
.WithAdditionalAnnotations(Simplifier.AddImportsAnnotation)
235+
.WithTriviaFrom(typeSyntax);
223236

224237
return newTypeSyntax;
225238
}

src/Analyzers/CSharp/Tests/AddRequiredParentheses/AddRequiredExpressionParenthesesTests.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -427,9 +427,8 @@ void M()
427427
""", RequireAllParenthesesForClarity);
428428

429429
[Fact, WorkItem("https://github.com/dotnet/roslyn/issues/79286")]
430-
public async Task TestCoalescePrecedence4()
431-
{
432-
await TestMissingAsync(
430+
public Task TestCoalescePrecedence4()
431+
=> TestMissingAsync(
433432
"""
434433
class C
435434
{
@@ -439,7 +438,6 @@ void M()
439438
}
440439
}
441440
""", RequireAllParenthesesForClarity);
442-
}
443441

444442
[Fact]
445443
public Task TestBitwisePrecedence1()

0 commit comments

Comments
 (0)