Skip to content

Commit 3e6246b

Browse files
Merge branch 'release/dev17.15' into makeSealed
2 parents 54938c5 + bf74164 commit 3e6246b

File tree

57 files changed

+232
-292
lines changed

Some content is hidden

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

57 files changed

+232
-292
lines changed

azure-pipelines.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,9 @@ variables:
6868

6969
- name: UbuntuQueueName
7070
${{ if eq(variables['System.TeamProject'], 'public') }}:
71-
value: Build.Ubuntu.2004.Amd64.Open
71+
value: Build.Ubuntu.2204.Amd64.Open
7272
${{ else }}:
73-
value: Build.Ubuntu.2004.Amd64
73+
value: Build.Ubuntu.2204.Amd64
7474

7575
- name: WindowsQueueName
7676
${{ if eq(variables['System.TeamProject'], 'public') }}:
@@ -92,15 +92,15 @@ variables:
9292

9393
- name: HelixUbuntuQueueName
9494
${{ if eq(variables['System.TeamProject'], 'public') }}:
95-
value: Ubuntu.2004.Amd64.Open
95+
value: Ubuntu.2204.Amd64.Open
9696
${{ else }}:
97-
value: Ubuntu.2004.Amd64
97+
value: Ubuntu.2204.Amd64
9898

9999
- name: HelixMacOsQueueName
100100
${{ if eq(variables['System.TeamProject'], 'public') }}:
101-
value: OSX.13.Amd64.Open
101+
value: OSX.15.Amd64.Open
102102
${{ else }}:
103-
value: OSX.13.Amd64
103+
value: OSX.15.Amd64
104104

105105
parameters:
106106
# These pools allow us to configure the pools once for multiple jobs.

eng/Version.Details.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
<SourceBuild RepoName="source-build-externals" ManagedOnly="true" />
99
</Dependency>
1010
<!-- Intermediate is necessary for source build. -->
11-
<Dependency Name="Microsoft.SourceBuild.Intermediate.source-build-reference-packages" Version="10.0.617402">
11+
<Dependency Name="Microsoft.SourceBuild.Intermediate.source-build-reference-packages" Version="10.0.617501">
1212
<Uri>https://github.com/dotnet/source-build-reference-packages</Uri>
13-
<Sha>4a8b5826baa291797b6df7deed227b509b05142b</Sha>
13+
<Sha>d2fc98192bb9780acbe2ad3df284da19203cc26d</Sha>
1414
<SourceBuild RepoName="source-build-reference-packages" ManagedOnly="true" />
1515
</Dependency>
1616
<Dependency Name="System.CommandLine" Version="2.0.0-beta4.24528.1">

src/Analyzers/CSharp/Analyzers/RemoveUnusedParametersAndValues/CSharpRemoveUnusedParametersAndValuesDiagnosticAnalyzer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ protected override bool MethodHasHandlesClause(IMethodSymbol method)
3535
protected override bool IsIfConditionalDirective(SyntaxNode node)
3636
=> node is IfDirectiveTriviaSyntax;
3737

38-
protected override bool ReturnsThrow(SyntaxNode node)
38+
protected override bool ReturnsThrow(SyntaxNode? node)
3939
{
4040
if (node is not BaseMethodDeclarationSyntax methodSyntax)
4141
{

src/Analyzers/CSharp/CodeFixes/ConvertToAsync/CSharpConvertToAsyncMethodCodeFixProvider.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ internal sealed class CSharpConvertToAsyncMethodCodeFixProvider() : AbstractConv
2525
/// </summary>
2626
private const string CS4008 = nameof(CS4008);
2727

28+
public override FixAllProvider? GetFixAllProvider() => base.GetFixAllProvider();
29+
2830
public override ImmutableArray<string> FixableDiagnosticIds => [CS4008];
2931

3032
protected override async Task<string> GetDescriptionAsync(
@@ -40,21 +42,19 @@ protected override async Task<string> GetDescriptionAsync(
4042
return string.Format(CSharpCodeFixesResources.Make_0_return_Task_instead_of_void, methodNode!.WithBody(null));
4143
}
4244

43-
protected override async Task<Tuple<SyntaxTree, SyntaxNode>?> GetRootInOtherSyntaxTreeAsync(
45+
protected override async Task<(SyntaxTree syntaxTree, SyntaxNode root)?> GetRootInOtherSyntaxTreeAsync(
4446
SyntaxNode node,
4547
SemanticModel semanticModel,
4648
Diagnostic diagnostic,
4749
CancellationToken cancellationToken)
4850
{
4951
var methodDeclaration = await GetMethodDeclarationAsync(node, semanticModel, cancellationToken).ConfigureAwait(false);
5052
if (methodDeclaration == null)
51-
{
5253
return null;
53-
}
5454

5555
var oldRoot = await methodDeclaration.SyntaxTree.GetRootAsync(cancellationToken).ConfigureAwait(false);
5656
var newRoot = oldRoot.ReplaceNode(methodDeclaration, ConvertToAsyncFunction(methodDeclaration));
57-
return Tuple.Create(oldRoot.SyntaxTree, newRoot);
57+
return (oldRoot.SyntaxTree, newRoot);
5858
}
5959

6060
private static async Task<MethodDeclarationSyntax?> GetMethodDeclarationAsync(

src/Analyzers/CSharp/CodeFixes/GenerateConstructor/CSharpGenerateConstructorService.cs

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,10 @@
22
// The .NET Foundation licenses this file to you under the MIT license.
33
// See the LICENSE file in the project root for more information.
44

5-
#nullable disable
6-
75
using System;
86
using System.Collections.Immutable;
97
using System.Composition;
8+
using System.Diagnostics.CodeAnalysis;
109
using System.Linq;
1110
using System.Threading;
1211
using Microsoft.CodeAnalysis.CodeGeneration;
@@ -44,7 +43,7 @@ protected override bool TryInitializeConstructorInitializerGeneration(
4443
CancellationToken cancellationToken,
4544
out SyntaxToken token,
4645
out ImmutableArray<Argument<ExpressionSyntax>> arguments,
47-
out INamedTypeSymbol typeToGenerateIn)
46+
[NotNullWhen(true)] out INamedTypeSymbol? typeToGenerateIn)
4847
{
4948
var constructorInitializer = (ConstructorInitializerSyntax)node;
5049

@@ -57,7 +56,7 @@ protected override bool TryInitializeConstructorInitializerGeneration(
5756
var currentType = semanticModel.GetEnclosingNamedType(constructorInitializer.SpanStart, cancellationToken);
5857
typeToGenerateIn = constructorInitializer.IsKind(SyntaxKind.ThisConstructorInitializer)
5958
? currentType
60-
: currentType.BaseType.OriginalDefinition;
59+
: currentType?.BaseType?.OriginalDefinition;
6160
return typeToGenerateIn != null;
6261
}
6362

@@ -82,11 +81,11 @@ protected override bool TryInitializeSimpleNameGenerationState(
8281
CancellationToken cancellationToken,
8382
out SyntaxToken token,
8483
out ImmutableArray<Argument<ExpressionSyntax>> arguments,
85-
out INamedTypeSymbol typeToGenerateIn)
84+
[NotNullWhen(true)] out INamedTypeSymbol? typeToGenerateIn)
8685
{
8786
var simpleName = (SimpleNameSyntax)node;
8887
var fullName = simpleName.IsRightSideOfQualifiedName()
89-
? (NameSyntax)simpleName.Parent
88+
? (NameSyntax)simpleName.GetRequiredParent()
9089
: simpleName;
9190

9291
if (fullName.Parent is ObjectCreationExpressionSyntax objectCreationExpression)
@@ -114,11 +113,11 @@ protected override bool TryInitializeSimpleAttributeNameGenerationState(
114113
CancellationToken cancellationToken,
115114
out SyntaxToken token,
116115
out ImmutableArray<Argument<ExpressionSyntax>> arguments,
117-
out INamedTypeSymbol typeToGenerateIn)
116+
[NotNullWhen(true)] out INamedTypeSymbol? typeToGenerateIn)
118117
{
119118
var simpleName = (SimpleNameSyntax)node;
120119
var fullName = simpleName.IsRightSideOfQualifiedName()
121-
? (NameSyntax)simpleName.Parent
120+
? (NameSyntax)simpleName.GetRequiredParent()
122121
: simpleName;
123122

124123
if (fullName.Parent is AttributeSyntax attribute)
@@ -132,7 +131,7 @@ protected override bool TryInitializeSimpleAttributeNameGenerationState(
132131
token = simpleName.Identifier;
133132
arguments = GetArguments(attribute.ArgumentList.Arguments);
134133

135-
typeToGenerateIn = symbolInfo.CandidateSymbols.FirstOrDefault().ContainingSymbol as INamedTypeSymbol;
134+
typeToGenerateIn = symbolInfo.CandidateSymbols.FirstOrDefault()?.ContainingSymbol as INamedTypeSymbol;
136135
return typeToGenerateIn != null;
137136
}
138137
}
@@ -149,7 +148,7 @@ protected override bool TryInitializeImplicitObjectCreation(SemanticDocument doc
149148
CancellationToken cancellationToken,
150149
out SyntaxToken token,
151150
out ImmutableArray<Argument<ExpressionSyntax>> arguments,
152-
out INamedTypeSymbol typeToGenerateIn)
151+
[NotNullWhen(true)] out INamedTypeSymbol? typeToGenerateIn)
153152
{
154153
var implicitObjectCreation = (ImplicitObjectCreationExpressionSyntax)node;
155154
if (implicitObjectCreation.ArgumentList != null &&
@@ -175,15 +174,15 @@ protected override string GenerateNameForExpression(SemanticModel semanticModel,
175174
=> semanticModel.GenerateNameForExpression(expression, capitalize: false, cancellationToken: cancellationToken);
176175

177176
protected override ITypeSymbol GetArgumentType(SemanticModel semanticModel, Argument<ExpressionSyntax> argument, CancellationToken cancellationToken)
178-
=> InternalExtensions.DetermineParameterType(argument.Expression, semanticModel, cancellationToken);
177+
=> InternalExtensions.DetermineParameterType(argument.Expression!, semanticModel, cancellationToken);
179178

180179
protected override bool IsConversionImplicit(Compilation compilation, ITypeSymbol sourceType, ITypeSymbol targetType)
181180
=> compilation.ClassifyConversion(sourceType, targetType).IsImplicit;
182181

183-
protected override IMethodSymbol GetCurrentConstructor(SemanticModel semanticModel, SyntaxToken token, CancellationToken cancellationToken)
182+
protected override IMethodSymbol? GetCurrentConstructor(SemanticModel semanticModel, SyntaxToken token, CancellationToken cancellationToken)
184183
=> token.GetAncestor<ConstructorDeclarationSyntax>() is { } constructor ? semanticModel.GetDeclaredSymbol(constructor, cancellationToken) : null;
185184

186-
protected override IMethodSymbol GetDelegatedConstructor(SemanticModel semanticModel, IMethodSymbol constructor, CancellationToken cancellationToken)
185+
protected override IMethodSymbol? GetDelegatedConstructor(SemanticModel semanticModel, IMethodSymbol constructor, CancellationToken cancellationToken)
187186
{
188187
if (constructor.DeclaringSyntaxReferences[0].GetSyntax(cancellationToken) is ConstructorDeclarationSyntax constructorDeclarationSyntax &&
189188
constructorDeclarationSyntax.Initializer.IsKind(SyntaxKind.ThisConstructorInitializer))

src/Analyzers/CSharp/CodeFixes/GenerateConstructor/GenerateConstructorCodeFixProvider.cs

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
// The .NET Foundation licenses this file to you under the MIT license.
33
// See the LICENSE file in the project root for more information.
44

5-
#nullable disable
6-
75
using System.Collections.Immutable;
86
using System.Composition;
97
using System.Diagnostics.CodeAnalysis;
@@ -42,27 +40,18 @@ internal sealed class GenerateConstructorCodeFixProvider() : AbstractGenerateMem
4240
protected override Task<ImmutableArray<CodeAction>> GetCodeActionsAsync(
4341
Document document, SyntaxNode node, CancellationToken cancellationToken)
4442
{
45-
var service = document.GetLanguageService<IGenerateConstructorService>();
43+
var service = document.GetRequiredLanguageService<IGenerateConstructorService>();
4644
return service.GenerateConstructorAsync(document, node, cancellationToken);
4745
}
4846

4947
protected override bool IsCandidate(SyntaxNode node, SyntaxToken token, Diagnostic diagnostic)
50-
{
51-
return node is BaseObjectCreationExpressionSyntax or
52-
ConstructorInitializerSyntax or
53-
AttributeSyntax;
54-
}
48+
=> node is BaseObjectCreationExpressionSyntax or ConstructorInitializerSyntax or AttributeSyntax;
5549

56-
protected override SyntaxNode GetTargetNode(SyntaxNode node)
57-
{
58-
switch (node)
50+
protected override SyntaxNode? GetTargetNode(SyntaxNode node)
51+
=> node switch
5952
{
60-
case ObjectCreationExpressionSyntax objectCreationNode:
61-
return objectCreationNode.Type.GetRightmostName();
62-
case AttributeSyntax attributeNode:
63-
return attributeNode.Name;
64-
}
65-
66-
return node;
67-
}
53+
ObjectCreationExpressionSyntax objectCreationNode => objectCreationNode.Type.GetRightmostName(),
54+
AttributeSyntax attributeNode => attributeNode.Name,
55+
_ => node,
56+
};
6857
}

src/Analyzers/CSharp/CodeFixes/GenerateEnumMember/CSharpGenerateEnumMemberService.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22
// The .NET Foundation licenses this file to you under the MIT license.
33
// See the LICENSE file in the project root for more information.
44

5-
#nullable disable
6-
75
using System;
86
using System.Composition;
7+
using System.Diagnostics.CodeAnalysis;
98
using System.Threading;
109
using Microsoft.CodeAnalysis.CSharp.Syntax;
1110
using Microsoft.CodeAnalysis.GenerateMember.GenerateEnumMember;
1211
using Microsoft.CodeAnalysis.Host.Mef;
12+
using Microsoft.CodeAnalysis.Shared.Extensions;
1313

1414
namespace Microsoft.CodeAnalysis.CSharp.GenerateMember.GenerateEnumMember;
1515

@@ -24,7 +24,8 @@ protected override bool IsIdentifierNameGeneration(SyntaxNode node)
2424

2525
protected override bool TryInitializeIdentifierNameState(
2626
SemanticDocument document, SimpleNameSyntax identifierName, CancellationToken cancellationToken,
27-
out SyntaxToken identifierToken, out ExpressionSyntax simpleNameOrMemberAccessExpression)
27+
out SyntaxToken identifierToken,
28+
[NotNullWhen(true)] out ExpressionSyntax? simpleNameOrMemberAccessExpression)
2829
{
2930
identifierToken = identifierName.Identifier;
3031
if (identifierToken.ValueText != string.Empty &&
@@ -37,7 +38,7 @@ protected override bool TryInitializeIdentifierNameState(
3738
// If we're being invoked, then don't offer this, offer generate method instead.
3839
// Note: we could offer to generate a field with a delegate type. However, that's
3940
// very esoteric and probably not what most users want.
40-
if (simpleNameOrMemberAccessExpression.Parent.Kind()
41+
if (simpleNameOrMemberAccessExpression.GetRequiredParent().Kind()
4142
is SyntaxKind.InvocationExpression
4243
or SyntaxKind.ObjectCreationExpression
4344
or SyntaxKind.GotoStatement

src/Analyzers/CSharp/CodeFixes/GenerateMethod/GenerateDeconstructMethodCodeFixProvider.cs

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
// The .NET Foundation licenses this file to you under the MIT license.
33
// See the LICENSE file in the project root for more information.
44

5-
#nullable disable
6-
75
using System.Collections.Immutable;
86
using System.Composition;
97
using System.Diagnostics;
@@ -20,24 +18,16 @@ namespace Microsoft.CodeAnalysis.CSharp.CodeFixes.GenerateDeconstructMethod;
2018

2119
[ExportCodeFixProvider(LanguageNames.CSharp, Name = PredefinedCodeFixProviderNames.GenerateDeconstructMethod), Shared]
2220
[ExtensionOrder(After = PredefinedCodeFixProviderNames.GenerateEnumMember)]
23-
internal sealed class GenerateDeconstructMethodCodeFixProvider : CodeFixProvider
21+
[method: ImportingConstructor]
22+
[method: SuppressMessage("RoslynDiagnosticsReliability", "RS0033:Importing constructor should be [Obsolete]", Justification = "Used in test code: https://github.com/dotnet/roslyn/issues/42814")]
23+
internal sealed class GenerateDeconstructMethodCodeFixProvider() : CodeFixProvider
2424
{
2525
private const string CS8129 = nameof(CS8129); // No suitable Deconstruct instance or extension method was found...
2626

27-
[ImportingConstructor]
28-
[SuppressMessage("RoslynDiagnosticsReliability", "RS0033:Importing constructor should be [Obsolete]", Justification = "Used in test code: https://github.com/dotnet/roslyn/issues/42814")]
29-
public GenerateDeconstructMethodCodeFixProvider()
30-
{
31-
}
27+
public override FixAllProvider? GetFixAllProvider() => base.GetFixAllProvider();
3228

3329
public sealed override ImmutableArray<string> FixableDiagnosticIds => [CS8129];
3430

35-
public override FixAllProvider GetFixAllProvider()
36-
{
37-
// Fix All is not supported by this code fix
38-
return null;
39-
}
40-
4131
public sealed override async Task RegisterCodeFixesAsync(CodeFixContext context)
4232
{
4333
// Not supported in REPL
@@ -48,7 +38,7 @@ public sealed override async Task RegisterCodeFixesAsync(CodeFixContext context)
4838

4939
var document = context.Document;
5040
var cancellationToken = context.CancellationToken;
51-
var root = await document.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false);
41+
var root = await document.GetRequiredSyntaxRootAsync(cancellationToken).ConfigureAwait(false);
5242
var span = context.Span;
5343
var token = root.FindToken(span.Start);
5444

@@ -61,10 +51,10 @@ public sealed override async Task RegisterCodeFixesAsync(CodeFixContext context)
6151
return;
6252
}
6353

64-
var model = await document.GetSemanticModelAsync(cancellationToken).ConfigureAwait(false);
54+
var model = await document.GetRequiredSemanticModelAsync(cancellationToken).ConfigureAwait(false);
6555

6656
DeconstructionInfo info;
67-
ITypeSymbol type;
57+
ITypeSymbol? type;
6858
SyntaxNode target;
6959
switch (deconstruction)
7060
{
@@ -80,7 +70,7 @@ public sealed override async Task RegisterCodeFixesAsync(CodeFixContext context)
8070
break;
8171
case PositionalPatternClauseSyntax positionalPattern:
8272
info = default;
83-
type = model.GetTypeInfo(deconstruction.Parent).Type;
73+
type = model.GetTypeInfo(deconstruction.GetRequiredParent()).Type;
8474
target = deconstruction;
8575
break;
8676
default:
@@ -105,7 +95,7 @@ public sealed override async Task RegisterCodeFixesAsync(CodeFixContext context)
10595
return;
10696
}
10797

108-
var service = document.GetLanguageService<IGenerateDeconstructMemberService>();
98+
var service = document.GetRequiredLanguageService<IGenerateDeconstructMemberService>();
10999
var codeActions = await service.GenerateDeconstructMethodAsync(document, target, (INamedTypeSymbol)type, cancellationToken).ConfigureAwait(false);
110100

111101
Debug.Assert(!codeActions.IsDefault);

0 commit comments

Comments
 (0)