Skip to content

Commit b8d5932

Browse files
author
msftbot[bot]
authored
Merge pull request #45911 from dotnet/merges/master-to-features/target-typing
Merge master to features/target-typing
2 parents fdc0298 + c0b0187 commit b8d5932

File tree

484 files changed

+2280
-2622
lines changed

Some content is hidden

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

484 files changed

+2280
-2622
lines changed

.editorconfig

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,8 @@ dotnet_diagnostic.RS0037.severity = none
225225
# warning RS0005: Do not use generic CodeAction.Create to create CodeAction
226226
dotnet_diagnostic.RS0005.severity = none
227227

228-
[src/{Analyzers,CodeStyle,Features,Workspaces}/**/*.{cs,vb}]
228+
[src/{Analyzers,CodeStyle,Features,Workspaces,EditorFeatures}/**/*.{cs,vb}]
229+
229230
# IDE0011: Add braces
230231
csharp_prefer_braces = when_multiline:warning
231232
# NOTE: We need the below severity entry for Add Braces due to https://github.com/dotnet/roslyn/issues/44201
@@ -266,4 +267,4 @@ dotnet_diagnostic.CA1822.severity = warning
266267
dotnet_diagnostic.IDE0007.severity = warning
267268
csharp_style_var_for_built_in_types = true:warning
268269
csharp_style_var_when_type_is_apparent = true:warning
269-
csharp_style_var_elsewhere = true:warning
270+
csharp_style_var_elsewhere = true:warning

NuGet.config

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77
<add key="dotnet-tools" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-tools/nuget/v3/index.json" />
88
<add key="dotnet5" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet5/nuget/v3/index.json" />
99
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
10-
<!-- Microsoft.VisualStudio.* packages (e.g. Microsoft.VisualStudio.LanguageServer.Protocol.Extensions): https://github.com/dotnet/roslyn/issues/43242 -->
11-
<add key="experimental-vs-packages" value="https://dotnet.myget.org/F/experimental-vs-packages/api/v3/index.json" />
1210
<!-- Microsoft.CodeAnalysis.Test.Resource.Proprietary -->
1311
<add key="roslyn-tools" value="https://dotnet.myget.org/F/roslyn-tools/api/v3/index.json" />
1412
<add key="roslyn-analyzers" value="https://dotnet.myget.org/F/roslyn-analyzers/api/v3/index.json" />

eng/Versions.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
<CodeStyleAnalyzerVersion>3.7.0-3.20271.4</CodeStyleAnalyzerVersion>
3535
<VisualStudioEditorPackagesVersion>16.4.248</VisualStudioEditorPackagesVersion>
3636
<ILToolsPackageVersion>5.0.0-alpha1.19409.1</ILToolsPackageVersion>
37-
<MicrosoftVisualStudioLanguageServerProtocolPackagesVersion>16.7.29</MicrosoftVisualStudioLanguageServerProtocolPackagesVersion>
37+
<MicrosoftVisualStudioLanguageServerProtocolPackagesVersion>16.8.5</MicrosoftVisualStudioLanguageServerProtocolPackagesVersion>
3838
</PropertyGroup>
3939
<!--
4040
Dependency versions

src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenInParametersTests.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1178,10 +1178,10 @@ static ref int M2(in int arg1, in (int Alice, int Bob) arg2)
11781178

11791179
var comp = CreateCompilationWithMscorlib45(text, new[] { ValueTupleRef, SystemRuntimeFacadeRef });
11801180
comp.VerifyDiagnostics(
1181-
// (18,20): error CS8410: Cannot return variable 'in int' by writable reference because it is a readonly variable
1181+
// (18,20): error CS8333: Cannot return variable 'in int' by writable reference because it is a readonly variable
11821182
// return ref arg1;
11831183
Diagnostic(ErrorCode.ERR_RefReturnReadonlyNotField, "arg1").WithArguments("variable", "in int").WithLocation(18, 20),
1184-
// (23,20): error CS8411: Members of variable 'in (int Alice, int Bob)' cannot be returned by writable reference because it is a readonly variable
1184+
// (23,20): error CS8334: Members of variable 'in (int Alice, int Bob)' cannot be returned by writable reference because it is a readonly variable
11851185
// return ref arg2.Alice;
11861186
Diagnostic(ErrorCode.ERR_RefReturnReadonlyNotField2, "arg2.Alice").WithArguments("variable", "in (int Alice, int Bob)").WithLocation(23, 20)
11871187
);
@@ -1269,10 +1269,10 @@ static ref int M(in int arg1, in (int Alice, int Bob) arg2)
12691269

12701270
var comp = CreateCompilationWithMscorlib45(text, new[] { ValueTupleRef, SystemRuntimeFacadeRef });
12711271
comp.VerifyDiagnostics(
1272-
// (10,24): error CS8410: Cannot return variable 'in int' by writable reference because it is a readonly variable
1272+
// (10,24): error CS8333: Cannot return variable 'in int' by writable reference because it is a readonly variable
12731273
// return ref arg1;
12741274
Diagnostic(ErrorCode.ERR_RefReturnReadonlyNotField, "arg1").WithArguments("variable", "in int").WithLocation(10, 24),
1275-
// (14,24): error CS8411: Members of variable 'in (int Alice, int Bob)' cannot be returned by writable reference because it is a readonly variable
1275+
// (14,24): error CS8334: Members of variable 'in (int Alice, int Bob)' cannot be returned by writable reference because it is a readonly variable
12761276
// return ref arg2.Alice;
12771277
Diagnostic(ErrorCode.ERR_RefReturnReadonlyNotField2, "arg2.Alice").WithArguments("variable", "in (int Alice, int Bob)").WithLocation(14, 24)
12781278
);
@@ -1388,10 +1388,10 @@ ref int M1(in int arg11, in (int Alice, int Bob) arg21)
13881388

13891389
var comp = CreateCompilationWithMscorlib45(text, new[] { ValueTupleRef, SystemRuntimeFacadeRef });
13901390
comp.VerifyDiagnostics(
1391-
// (12,28): error CS8410: Cannot return variable 'in int' by writable reference because it is a readonly variable
1391+
// (12,28): error CS8333: Cannot return variable 'in int' by writable reference because it is a readonly variable
13921392
// return ref arg11;
13931393
Diagnostic(ErrorCode.ERR_RefReturnReadonlyNotField, "arg11").WithArguments("variable", "in int").WithLocation(12, 28),
1394-
// (16,28): error CS8411: Members of variable 'in (int Alice, int Bob)' cannot be returned by writable reference because it is a readonly variable
1394+
// (16,28): error CS8334: Members of variable 'in (int Alice, int Bob)' cannot be returned by writable reference because it is a readonly variable
13951395
// return ref arg21.Alice;
13961396
Diagnostic(ErrorCode.ERR_RefReturnReadonlyNotField2, "arg21.Alice").WithArguments("variable", "in (int Alice, int Bob)").WithLocation(16, 28)
13971397
);

src/EditorFeatures/CSharp.Wpf/Completion/CompletionProviders/CSharpReplCommandCompletionProvider.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ protected override string GetCompletionString(string commandName)
4646
private static readonly Regex s_referenceRegex = new Regex(@"\s*#\s*r\s+", RegexOptions.Compiled);
4747
private static readonly Regex s_loadCommandRegex = new Regex(@"#load\s+", RegexOptions.Compiled);
4848

49-
private bool IsReplCommandLocation(SnapshotPoint characterPoint)
49+
private static bool IsReplCommandLocation(SnapshotPoint characterPoint)
5050
{
5151
// TODO(cyrusn): We don't need to do this textually. We could just defer this to
5252
// IsTriggerCharacter and just check the syntax tree.

src/EditorFeatures/CSharp.Wpf/Interactive/CSharpSendToInteractiveSubmissionProvider.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,14 @@ public CSharpSendToInteractiveSubmissionProvider()
2828
protected override bool CanParseSubmission(string code)
2929
{
3030
ParseOptions options = CSharpParseOptions.Default.WithKind(SourceCodeKind.Script);
31-
SyntaxTree tree = SyntaxFactory.ParseSyntaxTree(code, options);
31+
var tree = SyntaxFactory.ParseSyntaxTree(code, options);
3232
return tree.HasCompilationUnitRoot &&
3333
!tree.GetDiagnostics().Any(diagnostic => diagnostic.Severity == DiagnosticSeverity.Error);
3434
}
3535

3636
protected override IEnumerable<TextSpan> GetExecutableSyntaxTreeNodeSelection(TextSpan selectionSpan, SyntaxNode root)
3737
{
38-
SyntaxNode expandedNode = GetSyntaxNodeForSubmission(selectionSpan, root);
38+
var expandedNode = GetSyntaxNodeForSubmission(selectionSpan, root);
3939
return expandedNode != null
4040
? new TextSpan[] { expandedNode.Span }
4141
: Array.Empty<TextSpan>();
@@ -46,7 +46,7 @@ protected override IEnumerable<TextSpan> GetExecutableSyntaxTreeNodeSelection(Te
4646
/// </summary>
4747
/// <param name="selectionSpan">Selection that user has originally made.</param>
4848
/// <param name="root">Root of the syntax tree.</param>
49-
private SyntaxNode GetSyntaxNodeForSubmission(TextSpan selectionSpan, SyntaxNode root)
49+
private static SyntaxNode GetSyntaxNodeForSubmission(TextSpan selectionSpan, SyntaxNode root)
5050
{
5151
GetSelectedTokens(selectionSpan, root, out var startToken, out var endToken);
5252

@@ -117,7 +117,7 @@ private static bool IsSubmissionNode(SyntaxNode node)
117117
|| node.IsKind(SyntaxKind.UsingDirective);
118118
}
119119

120-
private void GetSelectedTokens(
120+
private static void GetSelectedTokens(
121121
TextSpan selectionSpan,
122122
SyntaxNode root,
123123
out SyntaxToken startToken,

src/EditorFeatures/CSharp/AutomaticCompletion/AutomaticLineEnderCommandHandler.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -151,22 +151,22 @@ protected override string GetEndingString(Document document, int position, Cance
151151
return null;
152152
}
153153

154-
private SyntaxNode ParseNode(SyntaxTree tree, SyntaxNode owningNode, string textToParse)
154+
private static SyntaxNode ParseNode(SyntaxTree tree, SyntaxNode owningNode, string textToParse)
155155
=> owningNode switch
156156
{
157-
BaseFieldDeclarationSyntax n => SyntaxFactory.ParseCompilationUnit(WrapInType(textToParse), options: (CSharpParseOptions)tree.Options),
158-
BaseMethodDeclarationSyntax n => SyntaxFactory.ParseCompilationUnit(WrapInType(textToParse), options: (CSharpParseOptions)tree.Options),
159-
BasePropertyDeclarationSyntax n => SyntaxFactory.ParseCompilationUnit(WrapInType(textToParse), options: (CSharpParseOptions)tree.Options),
160-
StatementSyntax n => SyntaxFactory.ParseStatement(textToParse, options: (CSharpParseOptions)tree.Options),
161-
UsingDirectiveSyntax n => SyntaxFactory.ParseCompilationUnit(textToParse, options: (CSharpParseOptions)tree.Options),
157+
BaseFieldDeclarationSyntax _ => SyntaxFactory.ParseCompilationUnit(WrapInType(textToParse), options: (CSharpParseOptions)tree.Options),
158+
BaseMethodDeclarationSyntax _ => SyntaxFactory.ParseCompilationUnit(WrapInType(textToParse), options: (CSharpParseOptions)tree.Options),
159+
BasePropertyDeclarationSyntax _ => SyntaxFactory.ParseCompilationUnit(WrapInType(textToParse), options: (CSharpParseOptions)tree.Options),
160+
StatementSyntax _ => SyntaxFactory.ParseStatement(textToParse, options: (CSharpParseOptions)tree.Options),
161+
UsingDirectiveSyntax _ => SyntaxFactory.ParseCompilationUnit(textToParse, options: (CSharpParseOptions)tree.Options),
162162

163163
_ => (SyntaxNode)null,
164164
};
165165

166166
/// <summary>
167167
/// wrap field in type
168168
/// </summary>
169-
private string WrapInType(string textToParse)
169+
private static string WrapInType(string textToParse)
170170
=> "class C { " + textToParse + " }";
171171

172172
/// <summary>

src/EditorFeatures/CSharp/AutomaticCompletion/Sessions/CurlyBraceCompletionSession.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,13 +107,13 @@ private static bool ContainsOnlyWhitespace(IBraceCompletionSession session)
107107
return true;
108108
}
109109

110-
private IEnumerable<AbstractFormattingRule> GetFormattingRules(Document document)
110+
private static IEnumerable<AbstractFormattingRule> GetFormattingRules(Document document)
111111
{
112112
var indentStyle = document.GetOptionsAsync(CancellationToken.None).WaitAndGetResult_CanCallOnBackground(CancellationToken.None).GetOption(FormattingOptions.SmartIndent);
113113
return SpecializedCollections.SingletonEnumerable<AbstractFormattingRule>(BraceCompletionFormattingRule.ForIndentStyle(indentStyle)).Concat(Formatter.GetDefaultFormattingRules(document));
114114
}
115115

116-
private void FormatTrackingSpan(IBraceCompletionSession session, bool shouldHonorAutoFormattingOnCloseBraceOption, IEnumerable<AbstractFormattingRule> rules = null)
116+
private static void FormatTrackingSpan(IBraceCompletionSession session, bool shouldHonorAutoFormattingOnCloseBraceOption, IEnumerable<AbstractFormattingRule> rules = null)
117117
{
118118
if (!session.SubjectBuffer.GetFeatureOnOffOption(FeatureOnOffOptions.AutoFormattingOnCloseBrace) && shouldHonorAutoFormattingOnCloseBraceOption)
119119
{

src/EditorFeatures/CSharp/AutomaticCompletion/Sessions/LessAndGreaterThanCompletionSession.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public override bool CheckOpeningPoint(IBraceCompletionSession session, Cancella
4444
return true;
4545
}
4646

47-
private bool PossibleTypeArgument(ITextSnapshot snapshot, SyntaxToken token, CancellationToken cancellationToken)
47+
private static bool PossibleTypeArgument(ITextSnapshot snapshot, SyntaxToken token, CancellationToken cancellationToken)
4848
{
4949
// type argument can be easily ambiguous with normal < operations
5050
if (!(token.Parent is BinaryExpressionSyntax node) || node.Kind() != SyntaxKind.LessThanExpression || node.OperatorToken != token)

src/EditorFeatures/CSharp/BlockCommentEditing/BlockCommentEditingCommandHandler.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ private bool TryHandleReturnKey(ITextBuffer subjectBuffer, ITextView textView)
7979
return true;
8080
}
8181

82-
private Span GetReplacementSpan(SnapshotPoint caretPosition)
82+
private static Span GetReplacementSpan(SnapshotPoint caretPosition)
8383
{
8484
// We want to replace all the whitespace following the caret. This is standard <enter> behavior in VS that
8585
// we want to mimic.
@@ -92,7 +92,7 @@ private Span GetReplacementSpan(SnapshotPoint caretPosition)
9292
return Span.FromBounds(start, end);
9393
}
9494

95-
private string? GetTextToInsert(SnapshotPoint caretPosition)
95+
private static string? GetTextToInsert(SnapshotPoint caretPosition)
9696
{
9797
var currentLine = caretPosition.GetContainingLine();
9898
var firstNonWhitespacePosition = currentLine.GetFirstNonWhitespacePosition() ?? -1;

0 commit comments

Comments
 (0)