diff --git a/eng/Directory.Packages.props b/eng/Directory.Packages.props
index 9395a5fb4c942..4b1707551e3af 100644
--- a/eng/Directory.Packages.props
+++ b/eng/Directory.Packages.props
@@ -8,7 +8,7 @@
<_BasicReferenceAssembliesVersion>1.7.9
4.8.0-3.final
- 17.10.191
+ 17.12.145-preview
9.0.0-rc.2.24462.10
6.0.0-rtm.21518.12
7.0.0-alpha.1.22060.1
@@ -46,10 +46,10 @@
-
-
-
-
+
+
+
+
@@ -58,7 +58,7 @@
-
+
@@ -91,32 +91,33 @@
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
diff --git a/eng/Versions.props b/eng/Versions.props
index e4dc164395e31..5ce59ad87b5fb 100644
--- a/eng/Versions.props
+++ b/eng/Versions.props
@@ -26,7 +26,7 @@
8.0.0
8.0.0
8.0.0
- 8.0.0
+ 8.0.1
8.0.0
8.0.0
8.0.0
diff --git a/src/Analyzers/CSharp/CodeFixes/CSharpCodeFixes.projitems b/src/Analyzers/CSharp/CodeFixes/CSharpCodeFixes.projitems
index 8eccdc1a5e084..0dcf3b255450c 100644
--- a/src/Analyzers/CSharp/CodeFixes/CSharpCodeFixes.projitems
+++ b/src/Analyzers/CSharp/CodeFixes/CSharpCodeFixes.projitems
@@ -137,7 +137,6 @@
-
diff --git a/src/Analyzers/CSharp/CodeFixes/SimplifyLinqExpression/CSharpSimplifyLinqExpressionCodeFixProvider.cs b/src/Analyzers/CSharp/CodeFixes/SimplifyLinqExpression/CSharpSimplifyLinqExpressionCodeFixProvider.cs
deleted file mode 100644
index ea9061d1df6eb..0000000000000
--- a/src/Analyzers/CSharp/CodeFixes/SimplifyLinqExpression/CSharpSimplifyLinqExpressionCodeFixProvider.cs
+++ /dev/null
@@ -1,21 +0,0 @@
-// 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.Composition;
-using System.Diagnostics.CodeAnalysis;
-using Microsoft.CodeAnalysis.CodeFixes;
-using Microsoft.CodeAnalysis.CSharp.LanguageService;
-using Microsoft.CodeAnalysis.CSharp.Syntax;
-using Microsoft.CodeAnalysis.LanguageService;
-using Microsoft.CodeAnalysis.SimplifyLinqExpression;
-
-namespace Microsoft.CodeAnalysis.CSharp.SimplifyLinqExpression;
-
-[ExportCodeFixProvider(LanguageNames.CSharp, Name = PredefinedCodeFixProviderNames.SimplifyLinqExpression), Shared]
-[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 CSharpSimplifyLinqExpressionCodeFixProvider() : AbstractSimplifyLinqExpressionCodeFixProvider
-{
- protected override ISyntaxFacts SyntaxFacts => CSharpSyntaxFacts.Instance;
-}
diff --git a/src/Analyzers/CSharp/Tests/SimplifyLinqExpression/CSharpSimplifyLinqExpressionFixAllTests.cs b/src/Analyzers/CSharp/Tests/SimplifyLinqExpression/CSharpSimplifyLinqExpressionFixAllTests.cs
index 774562e8c2c98..4cd70149a36e7 100644
--- a/src/Analyzers/CSharp/Tests/SimplifyLinqExpression/CSharpSimplifyLinqExpressionFixAllTests.cs
+++ b/src/Analyzers/CSharp/Tests/SimplifyLinqExpression/CSharpSimplifyLinqExpressionFixAllTests.cs
@@ -5,6 +5,7 @@
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.CSharp.SimplifyLinqExpression;
using Microsoft.CodeAnalysis.Editor.UnitTests.CodeActions;
+using Microsoft.CodeAnalysis.SimplifyLinqExpression;
using Microsoft.CodeAnalysis.Test.Utilities;
using Xunit;
@@ -12,7 +13,7 @@ namespace Microsoft.CodeAnalysis.CSharp.Analyzers.UnitTests.SimplifyLinqExpressi
using VerifyCS = CSharpCodeFixVerifier<
CSharpSimplifyLinqExpressionDiagnosticAnalyzer,
- CSharpSimplifyLinqExpressionCodeFixProvider>;
+ SimplifyLinqExpressionCodeFixProvider>;
[Trait(Traits.Feature, Traits.Features.CodeActionsInlineDeclaration)]
public partial class CSharpSimplifyLinqExpressionTests
diff --git a/src/Analyzers/CSharp/Tests/SimplifyLinqExpression/CSharpSimplifyLinqExpressionTests.cs b/src/Analyzers/CSharp/Tests/SimplifyLinqExpression/CSharpSimplifyLinqExpressionTests.cs
index 6e5d611754ff4..7d340c5d7f1ce 100644
--- a/src/Analyzers/CSharp/Tests/SimplifyLinqExpression/CSharpSimplifyLinqExpressionTests.cs
+++ b/src/Analyzers/CSharp/Tests/SimplifyLinqExpression/CSharpSimplifyLinqExpressionTests.cs
@@ -5,17 +5,19 @@
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.CSharp.SimplifyLinqExpression;
using Microsoft.CodeAnalysis.Editor.UnitTests.CodeActions;
+using Microsoft.CodeAnalysis.SimplifyLinqExpression;
using Microsoft.CodeAnalysis.Test.Utilities;
+using Roslyn.Test.Utilities;
using Xunit;
namespace Microsoft.CodeAnalysis.CSharp.Analyzers.UnitTests.SimplifyLinqExpression;
using VerifyCS = CSharpCodeFixVerifier<
CSharpSimplifyLinqExpressionDiagnosticAnalyzer,
- CSharpSimplifyLinqExpressionCodeFixProvider>;
+ SimplifyLinqExpressionCodeFixProvider>;
[Trait(Traits.Feature, Traits.Features.CodeActionsSimplifyLinqExpression)]
-public partial class CSharpSimplifyLinqExpressionTests
+public sealed partial class CSharpSimplifyLinqExpressionTests
{
[Theory, CombinatorialData]
public static async Task TestAllowedMethodTypes(
@@ -525,4 +527,40 @@ void Main()
""";
await VerifyCS.VerifyAnalyzerAsync(source);
}
+
+ [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/52283")]
+ public static async Task TestTrivia1()
+ {
+ await new VerifyCS.Test
+ {
+ TestCode = """
+ using System;
+ using System.Linq;
+ using System.Collections.Generic;
+
+ class C
+ {
+ static void Main(string[] args)
+ {
+ var v = [|args.Skip(1)
+ .Where(a => a.Length == 1).Count()|];
+ }
+ }
+ """,
+ FixedCode = """
+ using System;
+ using System.Linq;
+ using System.Collections.Generic;
+
+ class C
+ {
+ static void Main(string[] args)
+ {
+ var v = args.Skip(1)
+ .Count(a => a.Length == 1);
+ }
+ }
+ """
+ }.RunAsync();
+ }
}
diff --git a/src/Analyzers/Core/Analyzers/Analyzers.projitems b/src/Analyzers/Core/Analyzers/Analyzers.projitems
index ea81bd2ba5653..45e0c4005a393 100644
--- a/src/Analyzers/Core/Analyzers/Analyzers.projitems
+++ b/src/Analyzers/Core/Analyzers/Analyzers.projitems
@@ -10,7 +10,9 @@
-
+
+ Designer
+
diff --git a/src/Analyzers/Core/CodeFixes/CodeFixes.projitems b/src/Analyzers/Core/CodeFixes/CodeFixes.projitems
index 4bd44bf11c75d..a2c57739a682d 100644
--- a/src/Analyzers/Core/CodeFixes/CodeFixes.projitems
+++ b/src/Analyzers/Core/CodeFixes/CodeFixes.projitems
@@ -129,7 +129,7 @@
-
+
diff --git a/src/Analyzers/Core/CodeFixes/SimplifyLinqExpression/AbstractSimplifyLinqExpressionCodeFixProvider`3.cs b/src/Analyzers/Core/CodeFixes/SimplifyLinqExpression/AbstractSimplifyLinqExpressionCodeFixProvider`3.cs
deleted file mode 100644
index fd404a25cbadf..0000000000000
--- a/src/Analyzers/Core/CodeFixes/SimplifyLinqExpression/AbstractSimplifyLinqExpressionCodeFixProvider`3.cs
+++ /dev/null
@@ -1,70 +0,0 @@
-// 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.Collections.Immutable;
-using System.Linq;
-using System.Threading;
-using System.Threading.Tasks;
-using Microsoft.CodeAnalysis.CodeActions;
-using Microsoft.CodeAnalysis.CodeFixes;
-using Microsoft.CodeAnalysis.Diagnostics;
-using Microsoft.CodeAnalysis.Editing;
-using Microsoft.CodeAnalysis.LanguageService;
-
-namespace Microsoft.CodeAnalysis.SimplifyLinqExpression;
-
-internal abstract class AbstractSimplifyLinqExpressionCodeFixProvider : SyntaxEditorBasedCodeFixProvider
- where TExpressionSyntax : SyntaxNode
- where TInvocationExpressionSyntax : TExpressionSyntax
- where TSimpleNameSyntax : TExpressionSyntax
-{
- protected abstract ISyntaxFacts SyntaxFacts { get; }
-
- public sealed override ImmutableArray FixableDiagnosticIds
- => [IDEDiagnosticIds.SimplifyLinqExpressionDiagnosticId];
-
- public override Task RegisterCodeFixesAsync(CodeFixContext context)
- {
- RegisterCodeFix(context, AnalyzersResources.Simplify_LINQ_expression, nameof(AnalyzersResources.Simplify_LINQ_expression));
- return Task.CompletedTask;
- }
-
- protected override Task FixAllAsync(Document document,
- ImmutableArray diagnostics,
- SyntaxEditor editor,
- CancellationToken cancellationToken)
- {
- var root = editor.OriginalRoot;
- var expressionsToReWrite = diagnostics.Select(d => GetInvocation(root, d)).OrderByDescending(i => i.SpanStart);
- foreach (var original in expressionsToReWrite)
- {
- editor.ReplaceNode(original, (current, generator) =>
- {
- var invocation = (TInvocationExpressionSyntax)current;
- var (expression, name, arguments) = FindNodes(invocation);
- return generator.InvocationExpression(
- generator.MemberAccessExpression(expression, name),
- arguments);
- });
- }
-
- return Task.CompletedTask;
-
- static TInvocationExpressionSyntax GetInvocation(SyntaxNode root, Diagnostic diagnostic)
- {
- return (TInvocationExpressionSyntax)root.FindNode(diagnostic.Location.SourceSpan, getInnermostNodeForTie: true);
- }
-
- (TExpressionSyntax Expression, TSimpleNameSyntax Name, SeparatedSyntaxList Arguments) FindNodes(TInvocationExpressionSyntax current)
- {
- var memberAccess = SyntaxFacts.GetExpressionOfInvocationExpression(current);
- var name = (TSimpleNameSyntax)SyntaxFacts.GetNameOfMemberAccessExpression(memberAccess);
- var whereExpression = (TInvocationExpressionSyntax)SyntaxFacts.GetExpressionOfMemberAccessExpression(memberAccess)!;
- var arguments = SyntaxFacts.GetArgumentsOfInvocationExpression(whereExpression);
- var expression = (TExpressionSyntax)SyntaxFacts.GetExpressionOfMemberAccessExpression(SyntaxFacts.GetExpressionOfInvocationExpression(whereExpression))!;
- return (expression, name, arguments);
- }
- }
-}
diff --git a/src/Analyzers/Core/CodeFixes/SimplifyLinqExpression/SimplifyLinqExpressionCodeFixProvider.cs b/src/Analyzers/Core/CodeFixes/SimplifyLinqExpression/SimplifyLinqExpressionCodeFixProvider.cs
new file mode 100644
index 0000000000000..d75e75c4921c7
--- /dev/null
+++ b/src/Analyzers/Core/CodeFixes/SimplifyLinqExpression/SimplifyLinqExpressionCodeFixProvider.cs
@@ -0,0 +1,72 @@
+// 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.Collections.Immutable;
+using System.Composition;
+using System.Diagnostics.CodeAnalysis;
+using System.Linq;
+using System.Threading;
+using System.Threading.Tasks;
+using Microsoft.CodeAnalysis.CodeFixes;
+using Microsoft.CodeAnalysis.Diagnostics;
+using Microsoft.CodeAnalysis.Editing;
+using Microsoft.CodeAnalysis.LanguageService;
+using Microsoft.CodeAnalysis.Shared.Extensions;
+
+namespace Microsoft.CodeAnalysis.SimplifyLinqExpression;
+
+[ExportCodeFixProvider(LanguageNames.CSharp, LanguageNames.VisualBasic, Name = PredefinedCodeFixProviderNames.SimplifyLinqExpression), Shared]
+[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 SimplifyLinqExpressionCodeFixProvider() : SyntaxEditorBasedCodeFixProvider
+{
+ public sealed override ImmutableArray FixableDiagnosticIds
+ => [IDEDiagnosticIds.SimplifyLinqExpressionDiagnosticId];
+
+ public sealed override Task RegisterCodeFixesAsync(CodeFixContext context)
+ {
+ RegisterCodeFix(context, AnalyzersResources.Simplify_LINQ_expression, nameof(AnalyzersResources.Simplify_LINQ_expression));
+ return Task.CompletedTask;
+ }
+
+ protected override Task FixAllAsync(
+ Document document,
+ ImmutableArray diagnostics,
+ SyntaxEditor editor,
+ CancellationToken cancellationToken)
+ {
+ var syntaxFacts = document.GetRequiredLanguageService();
+ var root = editor.OriginalRoot;
+
+ foreach (var diagnostic in diagnostics.OrderByDescending(diagnostics => diagnostics.Location.SourceSpan.Start))
+ {
+ var invocation = root.FindNode(diagnostic.Location.SourceSpan, getInnermostNodeForTie: true);
+
+ editor.ReplaceNode(invocation, (current, generator) =>
+ {
+ // 'current' is the original full expression. like x.Where(...).Count();
+
+ // 'x.Where(...).Count' in the above expression
+ var memberAccess = syntaxFacts.GetExpressionOfInvocationExpression(current);
+
+ // 'Count' in the above expression
+ var outerName = syntaxFacts.GetNameOfMemberAccessExpression(memberAccess);
+
+ // 'x.Where(...)' in the above expression.
+ var innerInvocationExpression = syntaxFacts.GetExpressionOfMemberAccessExpression(memberAccess)!;
+
+ // 'x.Where' in the above expression.
+ var innerMemberAccessExpression = syntaxFacts.GetExpressionOfInvocationExpression(innerInvocationExpression);
+
+ // 'Where' in the above expression.
+ var innerName = syntaxFacts.GetNameOfMemberAccessExpression(innerMemberAccessExpression);
+
+ // trim down to the 'x.Where(...)', except with 'Where' replaced with 'Count'.
+ return innerInvocationExpression.ReplaceNode(innerName, outerName.WithTriviaFrom(innerName)).WithTrailingTrivia(current.GetTrailingTrivia());
+ });
+ }
+
+ return Task.CompletedTask;
+ }
+}
diff --git a/src/Analyzers/VisualBasic/CodeFixes/SimplifyLinqExpression/VisualBasicSimplifyLinqExpressionCodeFixProvider.vb b/src/Analyzers/VisualBasic/CodeFixes/SimplifyLinqExpression/VisualBasicSimplifyLinqExpressionCodeFixProvider.vb
deleted file mode 100644
index b2317a224cf4f..0000000000000
--- a/src/Analyzers/VisualBasic/CodeFixes/SimplifyLinqExpression/VisualBasicSimplifyLinqExpressionCodeFixProvider.vb
+++ /dev/null
@@ -1,26 +0,0 @@
-' 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.
-
-Imports System.Composition
-Imports System.Diagnostics.CodeAnalysis
-Imports Microsoft.CodeAnalysis.CodeFixes
-Imports Microsoft.CodeAnalysis.LanguageService
-Imports Microsoft.CodeAnalysis.SimplifyLinqExpression
-Imports Microsoft.CodeAnalysis.VisualBasic.LanguageService
-Imports Microsoft.CodeAnalysis.VisualBasic.Syntax
-
-Namespace Microsoft.CodeAnalysis.VisualBasic.SimplifyLinqExpression
-
- Friend Class VisualBasicSimplifyLinqExpressionCodeFixProvider
- Inherits AbstractSimplifyLinqExpressionCodeFixProvider(Of
- InvocationExpressionSyntax, SimpleNameSyntax, ExpressionSyntax)
-
-
-
- Public Sub New()
- End Sub
-
- Protected Overrides ReadOnly Property SyntaxFacts As ISyntaxFacts = VisualBasicSyntaxFacts.Instance
- End Class
-End Namespace
diff --git a/src/Analyzers/VisualBasic/CodeFixes/VisualBasicCodeFixes.projitems b/src/Analyzers/VisualBasic/CodeFixes/VisualBasicCodeFixes.projitems
index a25a0e527ed83..dcdf21dec4791 100644
--- a/src/Analyzers/VisualBasic/CodeFixes/VisualBasicCodeFixes.projitems
+++ b/src/Analyzers/VisualBasic/CodeFixes/VisualBasicCodeFixes.projitems
@@ -63,7 +63,6 @@
-
diff --git a/src/Analyzers/VisualBasic/Tests/SimplifyLinqExpression/VisualBasicSimplifyLinqExpressionFixAllTests.vb b/src/Analyzers/VisualBasic/Tests/SimplifyLinqExpression/VisualBasicSimplifyLinqExpressionFixAllTests.vb
index 4288e2004cb24..ca5f9856e7799 100644
--- a/src/Analyzers/VisualBasic/Tests/SimplifyLinqExpression/VisualBasicSimplifyLinqExpressionFixAllTests.vb
+++ b/src/Analyzers/VisualBasic/Tests/SimplifyLinqExpression/VisualBasicSimplifyLinqExpressionFixAllTests.vb
@@ -3,6 +3,7 @@
' See the LICENSE file in the project root for more information.
Imports Microsoft.CodeAnalysis.Editor.UnitTests.CodeActions
+Imports Microsoft.CodeAnalysis.SimplifyLinqExpression
Namespace Microsoft.CodeAnalysis.VisualBasic.SimplifyLinqExpression
@@ -41,7 +42,7 @@ Module T
Dim test5 = test.FirstOrDefault(Function(x) x.Equals(""!""))
End Sub
End Module"
- Await VisualBasicCodeFixVerifier(Of VisualBasicSimplifyLinqExpressionDiagnosticAnalyzer, VisualBasicSimplifyLinqExpressionCodeFixProvider).VerifyCodeFixAsync(testCode, fixedCode)
+ Await VisualBasicCodeFixVerifier(Of VisualBasicSimplifyLinqExpressionDiagnosticAnalyzer, SimplifyLinqExpressionCodeFixProvider).VerifyCodeFixAsync(testCode, fixedCode)
End Function
@@ -78,7 +79,7 @@ Module T
Dim test5 = Enumerable.FirstOrDefault(test, Function(x) x.Equals(""!""))
End Sub
End Module"
- Await VisualBasicCodeFixVerifier(Of VisualBasicSimplifyLinqExpressionDiagnosticAnalyzer, VisualBasicSimplifyLinqExpressionCodeFixProvider).VerifyCodeFixAsync(testCode, fixedCode)
+ Await VisualBasicCodeFixVerifier(Of VisualBasicSimplifyLinqExpressionDiagnosticAnalyzer, SimplifyLinqExpressionCodeFixProvider).VerifyCodeFixAsync(testCode, fixedCode)
End Function
@@ -115,7 +116,7 @@ Module T
Dim test5 = test.FirstOrDefault(Function(x) x.FirstOrDefault(Function(s) s.Equals(""!"")).Equals(""!""))
End Sub
End Module"
- Await VisualBasicCodeFixVerifier(Of VisualBasicSimplifyLinqExpressionDiagnosticAnalyzer, VisualBasicSimplifyLinqExpressionCodeFixProvider).VerifyCodeFixAsync(testCode, fixedCode)
+ Await VisualBasicCodeFixVerifier(Of VisualBasicSimplifyLinqExpressionDiagnosticAnalyzer, SimplifyLinqExpressionCodeFixProvider).VerifyCodeFixAsync(testCode, fixedCode)
End Function
End Class
End Namespace
diff --git a/src/Analyzers/VisualBasic/Tests/SimplifyLinqExpression/VisualBasicSimplifyLinqExpressionTests.vb b/src/Analyzers/VisualBasic/Tests/SimplifyLinqExpression/VisualBasicSimplifyLinqExpressionTests.vb
index 816e9b43d9e25..c4fc3b266cf4a 100644
--- a/src/Analyzers/VisualBasic/Tests/SimplifyLinqExpression/VisualBasicSimplifyLinqExpressionTests.vb
+++ b/src/Analyzers/VisualBasic/Tests/SimplifyLinqExpression/VisualBasicSimplifyLinqExpressionTests.vb
@@ -3,6 +3,7 @@
' See the LICENSE file in the project root for more information.
Imports Microsoft.CodeAnalysis.Editor.UnitTests.CodeActions
+Imports Microsoft.CodeAnalysis.SimplifyLinqExpression
Namespace Microsoft.CodeAnalysis.VisualBasic.SimplifyLinqExpression
@@ -40,7 +41,7 @@ Module T
End Sub
End Module"
- Await VisualBasicCodeFixVerifier(Of VisualBasicSimplifyLinqExpressionDiagnosticAnalyzer, VisualBasicSimplifyLinqExpressionCodeFixProvider).VerifyCodeFixAsync(testCode, fixedCode)
+ Await VisualBasicCodeFixVerifier(Of VisualBasicSimplifyLinqExpressionDiagnosticAnalyzer, SimplifyLinqExpressionCodeFixProvider).VerifyCodeFixAsync(testCode, fixedCode)
End Function
@@ -65,7 +66,7 @@ Module T
End Sub
End Module"
- Await VisualBasicCodeFixVerifier(Of VisualBasicSimplifyLinqExpressionDiagnosticAnalyzer, VisualBasicSimplifyLinqExpressionCodeFixProvider).VerifyAnalyzerAsync(testCode)
+ Await VisualBasicCodeFixVerifier(Of VisualBasicSimplifyLinqExpressionDiagnosticAnalyzer, SimplifyLinqExpressionCodeFixProvider).VerifyAnalyzerAsync(testCode)
End Function
@@ -100,7 +101,7 @@ Module T
Dim test = (From x In data).{methodName}(Function(x) x = 1)
End Sub
End Module"
- Await VisualBasicCodeFixVerifier(Of VisualBasicSimplifyLinqExpressionDiagnosticAnalyzer, VisualBasicSimplifyLinqExpressionCodeFixProvider).VerifyCodeFixAsync(testCode, fixedCode)
+ Await VisualBasicCodeFixVerifier(Of VisualBasicSimplifyLinqExpressionDiagnosticAnalyzer, SimplifyLinqExpressionCodeFixProvider).VerifyCodeFixAsync(testCode, fixedCode)
End Function
@@ -125,7 +126,7 @@ Module T
End Sub
End Module"
- Await VisualBasicCodeFixVerifier(Of VisualBasicSimplifyLinqExpressionDiagnosticAnalyzer, VisualBasicSimplifyLinqExpressionCodeFixProvider).VerifyAnalyzerAsync(testCode)
+ Await VisualBasicCodeFixVerifier(Of VisualBasicSimplifyLinqExpressionDiagnosticAnalyzer, SimplifyLinqExpressionCodeFixProvider).VerifyAnalyzerAsync(testCode)
End Function
@@ -166,7 +167,7 @@ Module T
End Function)
End Sub
End Module"
- Await VisualBasicCodeFixVerifier(Of VisualBasicSimplifyLinqExpressionDiagnosticAnalyzer, VisualBasicSimplifyLinqExpressionCodeFixProvider).VerifyCodeFixAsync(testCode, fixedCode)
+ Await VisualBasicCodeFixVerifier(Of VisualBasicSimplifyLinqExpressionDiagnosticAnalyzer, SimplifyLinqExpressionCodeFixProvider).VerifyCodeFixAsync(testCode, fixedCode)
End Function
@@ -191,7 +192,7 @@ Module T
Dim output = testvar2.Where(Function(x) x = 4).{methodName}()
End Sub
End Module"
- Await VisualBasicCodeFixVerifier(Of VisualBasicSimplifyLinqExpressionDiagnosticAnalyzer, VisualBasicSimplifyLinqExpressionCodeFixProvider).VerifyAnalyzerAsync(testCode)
+ Await VisualBasicCodeFixVerifier(Of VisualBasicSimplifyLinqExpressionDiagnosticAnalyzer, SimplifyLinqExpressionCodeFixProvider).VerifyAnalyzerAsync(testCode)
End Function
@@ -236,7 +237,7 @@ Module T
Dim test1 = test.{firstMethod}(Function(x) x.{secondMethod}(Function(c) c.Equals(""!"")).Equals(""!""))
End Sub
End Module"
- Await VisualBasicCodeFixVerifier(Of VisualBasicSimplifyLinqExpressionDiagnosticAnalyzer, VisualBasicSimplifyLinqExpressionCodeFixProvider).VerifyCodeFixAsync(testCode, fixedCode)
+ Await VisualBasicCodeFixVerifier(Of VisualBasicSimplifyLinqExpressionDiagnosticAnalyzer, SimplifyLinqExpressionCodeFixProvider).VerifyCodeFixAsync(testCode, fixedCode)
End Function
@@ -272,7 +273,7 @@ Module T
End Sub
End Module"
- Await VisualBasicCodeFixVerifier(Of VisualBasicSimplifyLinqExpressionDiagnosticAnalyzer, VisualBasicSimplifyLinqExpressionCodeFixProvider).VerifyCodeFixAsync(testCode, fixedCode)
+ Await VisualBasicCodeFixVerifier(Of VisualBasicSimplifyLinqExpressionDiagnosticAnalyzer, SimplifyLinqExpressionCodeFixProvider).VerifyCodeFixAsync(testCode, fixedCode)
End Function
@@ -296,7 +297,7 @@ Module T
Dim output = testvar1.Where(Function(x) x = 4).{methodName}(Function(x) x <> 1)
End Sub
End Module"
- Await VisualBasicCodeFixVerifier(Of VisualBasicSimplifyLinqExpressionDiagnosticAnalyzer, VisualBasicSimplifyLinqExpressionCodeFixProvider).VerifyAnalyzerAsync(testCode)
+ Await VisualBasicCodeFixVerifier(Of VisualBasicSimplifyLinqExpressionDiagnosticAnalyzer, SimplifyLinqExpressionCodeFixProvider).VerifyAnalyzerAsync(testCode)
End Function
@@ -312,7 +313,7 @@ Module T
Dim output = testvar1.Where(Function(x) x = 4).Count()
End Sub
End Module"
- Await VisualBasicCodeFixVerifier(Of VisualBasicSimplifyLinqExpressionDiagnosticAnalyzer, VisualBasicSimplifyLinqExpressionCodeFixProvider).VerifyAnalyzerAsync(testCode)
+ Await VisualBasicCodeFixVerifier(Of VisualBasicSimplifyLinqExpressionDiagnosticAnalyzer, SimplifyLinqExpressionCodeFixProvider).VerifyAnalyzerAsync(testCode)
End Function
@@ -341,7 +342,7 @@ Module T
Dim result = queryableData.Where(Expression.Lambda(Of Func(Of String, Boolean))(predicateBody, pe)).First()
End Sub
End Module"
- Await VisualBasicCodeFixVerifier(Of VisualBasicSimplifyLinqExpressionDiagnosticAnalyzer, VisualBasicSimplifyLinqExpressionCodeFixProvider).VerifyAnalyzerAsync(testCode)
+ Await VisualBasicCodeFixVerifier(Of VisualBasicSimplifyLinqExpressionDiagnosticAnalyzer, SimplifyLinqExpressionCodeFixProvider).VerifyAnalyzerAsync(testCode)
End Function
End Class
End Namespace
diff --git a/src/Compilers/CSharp/Portable/Binder/Binder.ValueChecks.cs b/src/Compilers/CSharp/Portable/Binder/Binder.ValueChecks.cs
index d69e82a701800..a69dfe3c04d33 100644
--- a/src/Compilers/CSharp/Portable/Binder/Binder.ValueChecks.cs
+++ b/src/Compilers/CSharp/Portable/Binder/Binder.ValueChecks.cs
@@ -5662,250 +5662,4 @@ void getParts(BoundInterpolatedString interpolatedString)
}
}
}
-
- internal partial class Binder
- {
- internal enum AddressKind
- {
- // reference may be written to
- Writeable,
-
- // reference itself will not be written to, but may be used for call, callvirt.
- // for all purposes it is the same as Writeable, except when fetching an address of an array element
- // where it results in a ".readonly" prefix to deal with array covariance.
- Constrained,
-
- // reference itself will not be written to, nor it will be used to modify fields.
- ReadOnly,
-
- // same as ReadOnly, but we are not supposed to get a reference to a clone
- // regardless of compat settings.
- ReadOnlyStrict,
- }
-
- internal static bool IsAnyReadOnly(AddressKind addressKind) => addressKind >= AddressKind.ReadOnly;
-
- ///
- /// Checks if expression directly or indirectly represents a value with its own home. In
- /// such cases it is possible to get a reference without loading into a temporary.
- ///
- internal static bool HasHome(
- BoundExpression expression,
- AddressKind addressKind,
- Symbol containingSymbol,
- bool peVerifyCompatEnabled,
- HashSet stackLocalsOpt)
- {
- Debug.Assert(containingSymbol is object);
-
- switch (expression.Kind)
- {
- case BoundKind.ArrayAccess:
- if (addressKind == AddressKind.ReadOnly && !expression.Type.IsValueType && peVerifyCompatEnabled)
- {
- // due to array covariance getting a reference may throw ArrayTypeMismatch when element is not a struct,
- // passing "readonly." prefix would prevent that, but it is unverifiable, so will make a copy in compat case
- return false;
- }
-
- return true;
-
- case BoundKind.PointerIndirectionOperator:
- case BoundKind.RefValueOperator:
- return true;
-
- case BoundKind.ThisReference:
- var type = expression.Type;
- if (type.IsReferenceType)
- {
- Debug.Assert(IsAnyReadOnly(addressKind), "`this` is readonly in classes");
- return true;
- }
-
- if (!IsAnyReadOnly(addressKind) && containingSymbol is MethodSymbol { ContainingSymbol: NamedTypeSymbol, IsEffectivelyReadOnly: true })
- {
- return false;
- }
-
- return true;
-
- case BoundKind.ThrowExpression:
- // vacuously this is true, we can take address of throw without temps
- return true;
-
- case BoundKind.Parameter:
- return IsAnyReadOnly(addressKind) ||
- ((BoundParameter)expression).ParameterSymbol.RefKind is not (RefKind.In or RefKind.RefReadOnlyParameter);
-
- case BoundKind.Local:
- // locals have home unless they are byval stack locals or ref-readonly
- // locals in a mutating call
- var local = ((BoundLocal)expression).LocalSymbol;
- return !((CodeGenerator.IsStackLocal(local, stackLocalsOpt) && local.RefKind == RefKind.None) ||
- (!IsAnyReadOnly(addressKind) && local.RefKind == RefKind.RefReadOnly));
-
- case BoundKind.Call:
- var methodRefKind = ((BoundCall)expression).Method.RefKind;
- return methodRefKind == RefKind.Ref ||
- (IsAnyReadOnly(addressKind) && methodRefKind == RefKind.RefReadOnly);
-
- case BoundKind.Dup:
- //NB: Dup represents locals that do not need IL slot
- var dupRefKind = ((BoundDup)expression).RefKind;
- return dupRefKind == RefKind.Ref ||
- (IsAnyReadOnly(addressKind) && dupRefKind == RefKind.RefReadOnly);
-
- case BoundKind.FieldAccess:
- return FieldAccessHasHome((BoundFieldAccess)expression, addressKind, containingSymbol, peVerifyCompatEnabled, stackLocalsOpt);
-
- case BoundKind.Sequence:
- return HasHome(((BoundSequence)expression).Value, addressKind, containingSymbol, peVerifyCompatEnabled, stackLocalsOpt);
-
- case BoundKind.AssignmentOperator:
- var assignment = (BoundAssignmentOperator)expression;
- if (!assignment.IsRef)
- {
- return false;
- }
- var lhsRefKind = assignment.Left.GetRefKind();
- return lhsRefKind == RefKind.Ref ||
- (IsAnyReadOnly(addressKind) && lhsRefKind is RefKind.RefReadOnly or RefKind.RefReadOnlyParameter);
-
- case BoundKind.ComplexConditionalReceiver:
- Debug.Assert(HasHome(
- ((BoundComplexConditionalReceiver)expression).ValueTypeReceiver,
- addressKind,
- containingSymbol,
- peVerifyCompatEnabled,
- stackLocalsOpt));
- Debug.Assert(HasHome(
- ((BoundComplexConditionalReceiver)expression).ReferenceTypeReceiver,
- addressKind,
- containingSymbol,
- peVerifyCompatEnabled,
- stackLocalsOpt));
- goto case BoundKind.ConditionalReceiver;
-
- case BoundKind.ConditionalReceiver:
- //ConditionalReceiver is a noop from Emit point of view. - it represents something that has already been pushed.
- //We should never need a temp for it.
- return true;
-
- case BoundKind.ConditionalOperator:
- var conditional = (BoundConditionalOperator)expression;
-
- // only ref conditional may be referenced as a variable
- if (!conditional.IsRef)
- {
- return false;
- }
-
- // branch that has no home will need a temporary
- // if both have no home, just say whole expression has no home
- // so we could just use one temp for the whole thing
- return HasHome(conditional.Consequence, addressKind, containingSymbol, peVerifyCompatEnabled, stackLocalsOpt)
- && HasHome(conditional.Alternative, addressKind, containingSymbol, peVerifyCompatEnabled, stackLocalsOpt);
-
- default:
- return false;
- }
- }
-
- ///
- /// Special HasHome for fields.
- /// A field has a readable home unless the field is a constant.
- /// A ref readonly field doesn't have a writable home.
- /// Other fields have a writable home unless the field is a readonly value
- /// and is used outside of a constructor or init method.
- ///
- private static bool FieldAccessHasHome(
- BoundFieldAccess fieldAccess,
- AddressKind addressKind,
- Symbol containingSymbol,
- bool peVerifyCompatEnabled,
- HashSet stackLocalsOpt)
- {
- Debug.Assert(containingSymbol is object);
-
- FieldSymbol field = fieldAccess.FieldSymbol;
-
- // const fields are literal values with no homes. (ex: decimal.Zero)
- if (field.IsConst)
- {
- return false;
- }
-
- if (field.RefKind is RefKind.Ref)
- {
- return true;
- }
-
- // in readonly situations where ref to a copy is not allowed, consider fields as addressable
- if (addressKind == AddressKind.ReadOnlyStrict)
- {
- return true;
- }
-
- // ReadOnly references can always be taken unless we are in peverify compat mode
- if (addressKind == AddressKind.ReadOnly && !peVerifyCompatEnabled)
- {
- return true;
- }
-
- // Some field accesses must be values; values do not have homes.
- if (fieldAccess.IsByValue)
- {
- return false;
- }
-
- if (field.RefKind == RefKind.RefReadOnly)
- {
- return false;
- }
-
- Debug.Assert(field.RefKind == RefKind.None);
-
- if (!field.IsReadOnly)
- {
- // in a case if we have a writeable struct field with a receiver that only has a readable home we would need to pass it via a temp.
- // it would be advantageous to make a temp for the field, not for the outer struct, since the field is smaller and we can get to is by fetching references.
- // NOTE: this would not be profitable if we have to satisfy verifier, since for verifiability
- // we would not be able to dig for the inner field using references and the outer struct will have to be copied to a temp anyways.
- if (!peVerifyCompatEnabled)
- {
- Debug.Assert(!IsAnyReadOnly(addressKind));
-
- var receiver = fieldAccess.ReceiverOpt;
- if (receiver?.Type.IsValueType == true)
- {
- // Check receiver:
- // has writeable home -> return true - the whole chain has writeable home (also a more common case)
- // has readable home -> return false - we need to copy the field
- // otherwise -> return true - the copy will be made at higher level so the leaf field can have writeable home
-
- return HasHome(receiver, addressKind, containingSymbol, peVerifyCompatEnabled, stackLocalsOpt)
- || !HasHome(receiver, AddressKind.ReadOnly, containingSymbol, peVerifyCompatEnabled, stackLocalsOpt);
- }
- }
-
- return true;
- }
-
- // while readonly fields have home it is not valid to refer to it when not constructing.
- if (!TypeSymbol.Equals(field.ContainingType, containingSymbol.ContainingSymbol as NamedTypeSymbol, TypeCompareKind.AllIgnoreOptions))
- {
- return false;
- }
-
- if (field.IsStatic)
- {
- return containingSymbol is MethodSymbol { MethodKind: MethodKind.StaticConstructor } or FieldSymbol { IsStatic: true };
- }
- else
- {
- return (containingSymbol is MethodSymbol { MethodKind: MethodKind.Constructor } or FieldSymbol { IsStatic: false } or MethodSymbol { IsInitOnly: true }) &&
- fieldAccess.ReceiverOpt.Kind == BoundKind.ThisReference;
- }
- }
- }
}
diff --git a/src/Compilers/CSharp/Portable/CodeGen/CodeGenerator_HasHome.cs b/src/Compilers/CSharp/Portable/CodeGen/CodeGenerator_HasHome.cs
new file mode 100644
index 0000000000000..d54002c481560
--- /dev/null
+++ b/src/Compilers/CSharp/Portable/CodeGen/CodeGenerator_HasHome.cs
@@ -0,0 +1,260 @@
+// 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.
+
+#nullable disable
+
+using System.Collections.Generic;
+using System.Diagnostics;
+using Microsoft.CodeAnalysis.CSharp.Symbols;
+
+namespace Microsoft.CodeAnalysis.CSharp.CodeGen;
+
+internal partial class CodeGenerator
+{
+ internal enum AddressKind
+ {
+ // reference may be written to
+ Writeable,
+
+ // reference itself will not be written to, but may be used for call, callvirt.
+ // for all purposes it is the same as Writeable, except when fetching an address of an array element
+ // where it results in a ".readonly" prefix to deal with array covariance.
+ Constrained,
+
+ // reference itself will not be written to, nor it will be used to modify fields.
+ ReadOnly,
+
+ // same as ReadOnly, but we are not supposed to get a reference to a clone
+ // regardless of compat settings.
+ ReadOnlyStrict,
+ }
+
+ internal static bool IsAnyReadOnly(AddressKind addressKind) => addressKind >= AddressKind.ReadOnly;
+
+ ///
+ /// Checks if expression directly or indirectly represents a value with its own home. In
+ /// such cases it is possible to get a reference without loading into a temporary.
+ ///
+ ///
+ /// This should be a lowered node. This method does NOT expect nodes from initial binding.
+ ///
+ internal static bool HasHome(
+ BoundExpression expression,
+ AddressKind addressKind,
+ Symbol containingSymbol,
+ bool peVerifyCompatEnabled,
+ HashSet stackLocalsOpt)
+ {
+ Debug.Assert(containingSymbol is object);
+
+ switch (expression.Kind)
+ {
+ case BoundKind.ArrayAccess:
+ if (addressKind == AddressKind.ReadOnly && !expression.Type.IsValueType && peVerifyCompatEnabled)
+ {
+ // due to array covariance getting a reference may throw ArrayTypeMismatch when element is not a struct,
+ // passing "readonly." prefix would prevent that, but it is unverifiable, so will make a copy in compat case
+ return false;
+ }
+
+ return true;
+
+ case BoundKind.PointerIndirectionOperator:
+ case BoundKind.RefValueOperator:
+ return true;
+
+ case BoundKind.ThisReference:
+ var type = expression.Type;
+ if (type.IsReferenceType)
+ {
+ Debug.Assert(IsAnyReadOnly(addressKind), "`this` is readonly in classes");
+ return true;
+ }
+
+ if (!IsAnyReadOnly(addressKind) && containingSymbol is MethodSymbol { ContainingSymbol: NamedTypeSymbol, IsEffectivelyReadOnly: true })
+ {
+ return false;
+ }
+
+ return true;
+
+ case BoundKind.ThrowExpression:
+ // vacuously this is true, we can take address of throw without temps
+ return true;
+
+ case BoundKind.Parameter:
+ return IsAnyReadOnly(addressKind) ||
+ ((BoundParameter)expression).ParameterSymbol.RefKind is not (RefKind.In or RefKind.RefReadOnlyParameter);
+
+ case BoundKind.Local:
+ // locals have home unless they are byval stack locals or ref-readonly
+ // locals in a mutating call
+ var local = ((BoundLocal)expression).LocalSymbol;
+ return !((CodeGenerator.IsStackLocal(local, stackLocalsOpt) && local.RefKind == RefKind.None) ||
+ (!IsAnyReadOnly(addressKind) && local.RefKind == RefKind.RefReadOnly));
+
+ case BoundKind.Call:
+ var methodRefKind = ((BoundCall)expression).Method.RefKind;
+ return methodRefKind == RefKind.Ref ||
+ (IsAnyReadOnly(addressKind) && methodRefKind == RefKind.RefReadOnly);
+
+ case BoundKind.Dup:
+ //NB: Dup represents locals that do not need IL slot
+ var dupRefKind = ((BoundDup)expression).RefKind;
+ return dupRefKind == RefKind.Ref ||
+ (IsAnyReadOnly(addressKind) && dupRefKind == RefKind.RefReadOnly);
+
+ case BoundKind.FieldAccess:
+ return FieldAccessHasHome((BoundFieldAccess)expression, addressKind, containingSymbol, peVerifyCompatEnabled, stackLocalsOpt);
+
+ case BoundKind.Sequence:
+ return HasHome(((BoundSequence)expression).Value, addressKind, containingSymbol, peVerifyCompatEnabled, stackLocalsOpt);
+
+ case BoundKind.AssignmentOperator:
+ var assignment = (BoundAssignmentOperator)expression;
+ if (!assignment.IsRef)
+ {
+ return false;
+ }
+ var lhsRefKind = assignment.Left.GetRefKind();
+ return lhsRefKind == RefKind.Ref ||
+ (IsAnyReadOnly(addressKind) && lhsRefKind is RefKind.RefReadOnly or RefKind.RefReadOnlyParameter);
+
+ case BoundKind.ComplexConditionalReceiver:
+ Debug.Assert(HasHome(
+ ((BoundComplexConditionalReceiver)expression).ValueTypeReceiver,
+ addressKind,
+ containingSymbol,
+ peVerifyCompatEnabled,
+ stackLocalsOpt));
+ Debug.Assert(HasHome(
+ ((BoundComplexConditionalReceiver)expression).ReferenceTypeReceiver,
+ addressKind,
+ containingSymbol,
+ peVerifyCompatEnabled,
+ stackLocalsOpt));
+ goto case BoundKind.ConditionalReceiver;
+
+ case BoundKind.ConditionalReceiver:
+ //ConditionalReceiver is a noop from Emit point of view. - it represents something that has already been pushed.
+ //We should never need a temp for it.
+ return true;
+
+ case BoundKind.ConditionalOperator:
+ var conditional = (BoundConditionalOperator)expression;
+
+ // only ref conditional may be referenced as a variable
+ if (!conditional.IsRef)
+ {
+ return false;
+ }
+
+ // branch that has no home will need a temporary
+ // if both have no home, just say whole expression has no home
+ // so we could just use one temp for the whole thing
+ return HasHome(conditional.Consequence, addressKind, containingSymbol, peVerifyCompatEnabled, stackLocalsOpt)
+ && HasHome(conditional.Alternative, addressKind, containingSymbol, peVerifyCompatEnabled, stackLocalsOpt);
+
+ default:
+ return false;
+ }
+ }
+
+ ///
+ /// Special HasHome for fields.
+ /// A field has a readable home unless the field is a constant.
+ /// A ref readonly field doesn't have a writable home.
+ /// Other fields have a writable home unless the field is a readonly value
+ /// and is used outside of a constructor or init method.
+ ///
+ private static bool FieldAccessHasHome(
+ BoundFieldAccess fieldAccess,
+ AddressKind addressKind,
+ Symbol containingSymbol,
+ bool peVerifyCompatEnabled,
+ HashSet stackLocalsOpt)
+ {
+ Debug.Assert(containingSymbol is object);
+
+ FieldSymbol field = fieldAccess.FieldSymbol;
+
+ // const fields are literal values with no homes. (ex: decimal.Zero)
+ if (field.IsConst)
+ {
+ return false;
+ }
+
+ if (field.RefKind is RefKind.Ref)
+ {
+ return true;
+ }
+
+ // in readonly situations where ref to a copy is not allowed, consider fields as addressable
+ if (addressKind == AddressKind.ReadOnlyStrict)
+ {
+ return true;
+ }
+
+ // ReadOnly references can always be taken unless we are in peverify compat mode
+ if (addressKind == AddressKind.ReadOnly && !peVerifyCompatEnabled)
+ {
+ return true;
+ }
+
+ // Some field accesses must be values; values do not have homes.
+ if (fieldAccess.IsByValue)
+ {
+ return false;
+ }
+
+ if (field.RefKind == RefKind.RefReadOnly)
+ {
+ return false;
+ }
+
+ Debug.Assert(field.RefKind == RefKind.None);
+
+ if (!field.IsReadOnly)
+ {
+ // in a case if we have a writeable struct field with a receiver that only has a readable home we would need to pass it via a temp.
+ // it would be advantageous to make a temp for the field, not for the outer struct, since the field is smaller and we can get to is by fetching references.
+ // NOTE: this would not be profitable if we have to satisfy verifier, since for verifiability
+ // we would not be able to dig for the inner field using references and the outer struct will have to be copied to a temp anyways.
+ if (!peVerifyCompatEnabled)
+ {
+ Debug.Assert(!IsAnyReadOnly(addressKind));
+
+ var receiver = fieldAccess.ReceiverOpt;
+ if (receiver?.Type.IsValueType == true)
+ {
+ // Check receiver:
+ // has writeable home -> return true - the whole chain has writeable home (also a more common case)
+ // has readable home -> return false - we need to copy the field
+ // otherwise -> return true - the copy will be made at higher level so the leaf field can have writeable home
+
+ return HasHome(receiver, addressKind, containingSymbol, peVerifyCompatEnabled, stackLocalsOpt)
+ || !HasHome(receiver, AddressKind.ReadOnly, containingSymbol, peVerifyCompatEnabled, stackLocalsOpt);
+ }
+ }
+
+ return true;
+ }
+
+ // while readonly fields have home it is not valid to refer to it when not constructing.
+ if (!TypeSymbol.Equals(field.ContainingType, containingSymbol.ContainingSymbol as NamedTypeSymbol, TypeCompareKind.AllIgnoreOptions))
+ {
+ return false;
+ }
+
+ if (field.IsStatic)
+ {
+ return containingSymbol is MethodSymbol { MethodKind: MethodKind.StaticConstructor } or FieldSymbol { IsStatic: true };
+ }
+ else
+ {
+ return (containingSymbol is MethodSymbol { MethodKind: MethodKind.Constructor } or FieldSymbol { IsStatic: false } or MethodSymbol { IsInitOnly: true }) &&
+ fieldAccess.ReceiverOpt.Kind == BoundKind.ThisReference;
+ }
+ }
+}
diff --git a/src/Compilers/CSharp/Portable/CodeGen/EmitAddress.cs b/src/Compilers/CSharp/Portable/CodeGen/EmitAddress.cs
index 3cc5453d326c9..f6358956bf7d4 100644
--- a/src/Compilers/CSharp/Portable/CodeGen/EmitAddress.cs
+++ b/src/Compilers/CSharp/Portable/CodeGen/EmitAddress.cs
@@ -5,14 +5,12 @@
#nullable disable
using System;
-using System.Collections.Generic;
using System.Collections.Immutable;
using System.Diagnostics;
using System.Reflection.Metadata;
using Microsoft.CodeAnalysis.CodeGen;
using Microsoft.CodeAnalysis.CSharp.Symbols;
using Roslyn.Utilities;
-using static Microsoft.CodeAnalysis.CSharp.Binder;
namespace Microsoft.CodeAnalysis.CSharp.CodeGen
{
@@ -466,7 +464,7 @@ private void EmitStaticFieldAddress(FieldSymbol field, SyntaxNode syntaxNode)
/// such cases it is possible to get a reference without loading into a temporary.
///
private bool HasHome(BoundExpression expression, AddressKind addressKind)
- => Binder.HasHome(expression, addressKind, _method, IsPeVerifyCompatEnabled(), _stackLocals);
+ => HasHome(expression, addressKind, _method, IsPeVerifyCompatEnabled(), _stackLocals);
private LocalDefinition EmitParameterAddress(BoundParameter parameter, AddressKind addressKind)
{
diff --git a/src/Compilers/CSharp/Portable/CodeGen/EmitArrayInitializer.cs b/src/Compilers/CSharp/Portable/CodeGen/EmitArrayInitializer.cs
index 0635d237c63a1..e35d326e09bb6 100644
--- a/src/Compilers/CSharp/Portable/CodeGen/EmitArrayInitializer.cs
+++ b/src/Compilers/CSharp/Portable/CodeGen/EmitArrayInitializer.cs
@@ -550,7 +550,7 @@ private bool TryEmitOptimizedReadonlySpanCreation(NamedTypeSymbol spanType, Boun
if (inPlaceTarget is not null)
{
- EmitAddress(inPlaceTarget, Binder.AddressKind.Writeable);
+ EmitAddress(inPlaceTarget, AddressKind.Writeable);
}
// Map a field to the block (that makes it addressable).
@@ -702,7 +702,7 @@ bool tryEmitAsCachedArrayOfConstants(BoundArrayCreation arrayCreation, ArrayType
if (inPlaceTarget is not null)
{
- EmitAddress(inPlaceTarget, Binder.AddressKind.Writeable);
+ EmitAddress(inPlaceTarget, AddressKind.Writeable);
}
ImmutableArray constants = initializers.SelectAsArray(static init => init.ConstantValueOpt!);
@@ -758,7 +758,7 @@ void emitEmptyReadonlySpan(NamedTypeSymbol spanType, BoundExpression wrappedExpr
// If this is in-place initialization, call the default ctor.
if (inPlaceTarget is not null)
{
- EmitAddress(inPlaceTarget, Binder.AddressKind.Writeable);
+ EmitAddress(inPlaceTarget, AddressKind.Writeable);
_builder.EmitOpCode(ILOpCode.Initobj);
EmitSymbolToken(spanType, wrappedExpression.Syntax);
if (used)
diff --git a/src/Compilers/CSharp/Portable/Lowering/LocalRewriter/LocalRewriter_Call.cs b/src/Compilers/CSharp/Portable/Lowering/LocalRewriter/LocalRewriter_Call.cs
index 82fe7099eb900..021a5509ae2d7 100644
--- a/src/Compilers/CSharp/Portable/Lowering/LocalRewriter/LocalRewriter_Call.cs
+++ b/src/Compilers/CSharp/Portable/Lowering/LocalRewriter/LocalRewriter_Call.cs
@@ -3,14 +3,13 @@
// See the LICENSE file in the project root for more information.
using System.Collections.Immutable;
-using System.Diagnostics.CodeAnalysis;
using System.Diagnostics;
+using System.Diagnostics.CodeAnalysis;
using System.Linq;
+using Microsoft.CodeAnalysis.CSharp.CodeGen;
using Microsoft.CodeAnalysis.CSharp.Symbols;
using Microsoft.CodeAnalysis.PooledObjects;
-using Microsoft.CodeAnalysis.Operations;
using Roslyn.Utilities;
-using Microsoft.CodeAnalysis.CSharp.CodeGen;
namespace Microsoft.CodeAnalysis.CSharp
{
@@ -286,9 +285,9 @@ private void InterceptCallAndAdjustArguments(
// Instance call receivers can be implicitly captured to temps in the emit layer, but not static call arguments
// Therefore we may need to explicitly store the receiver to temp here.
if (thisRefKind != RefKind.None
- && !Binder.HasHome(
+ && !CodeGenerator.HasHome(
receiverOpt,
- thisRefKind == RefKind.Ref ? Binder.AddressKind.Writeable : Binder.AddressKind.ReadOnlyStrict,
+ thisRefKind == RefKind.Ref ? CodeGenerator.AddressKind.Writeable : CodeGenerator.AddressKind.ReadOnlyStrict,
_factory.CurrentFunction,
peVerifyCompatEnabled: false,
stackLocalsOpt: null))
@@ -702,8 +701,8 @@ private ImmutableArray VisitArgumentsAndCaptureReceiverIfNeeded
refKind = rewrittenReceiver.GetRefKind();
if (refKind == RefKind.None &&
- Binder.HasHome(rewrittenReceiver,
- Binder.AddressKind.Constrained,
+ CodeGenerator.HasHome(rewrittenReceiver,
+ CodeGenerator.AddressKind.Constrained,
_factory.CurrentFunction,
peVerifyCompatEnabled: false,
stackLocalsOpt: null))
diff --git a/src/Compilers/CSharp/Portable/Lowering/LocalRewriter/LoweredDynamicOperationFactory.cs b/src/Compilers/CSharp/Portable/Lowering/LocalRewriter/LoweredDynamicOperationFactory.cs
index 0a264ac61f155..d2543a5cbf121 100644
--- a/src/Compilers/CSharp/Portable/Lowering/LocalRewriter/LoweredDynamicOperationFactory.cs
+++ b/src/Compilers/CSharp/Portable/Lowering/LocalRewriter/LoweredDynamicOperationFactory.cs
@@ -5,9 +5,9 @@
using System;
using System.Collections.Immutable;
using System.Diagnostics;
+using Microsoft.CodeAnalysis.CSharp.CodeGen;
using Microsoft.CodeAnalysis.CSharp.Symbols;
using Microsoft.CodeAnalysis.PooledObjects;
-using Roslyn.Utilities;
namespace Microsoft.CodeAnalysis.CSharp
{
@@ -547,8 +547,8 @@ internal RefKind GetReceiverRefKind(BoundExpression loweredReceiver)
return RefKind.None;
}
- var hasHome = Binder.HasHome(loweredReceiver,
- Binder.AddressKind.Writeable,
+ var hasHome = CodeGenerator.HasHome(loweredReceiver,
+ CodeGenerator.AddressKind.Writeable,
_factory.CurrentFunction,
peVerifyCompatEnabled: false,
stackLocalsOpt: null);
diff --git a/src/Compilers/CSharp/Portable/Lowering/SyntheticBoundNodeFactory.cs b/src/Compilers/CSharp/Portable/Lowering/SyntheticBoundNodeFactory.cs
index 3df1fe92edc03..637a3a8da0e85 100644
--- a/src/Compilers/CSharp/Portable/Lowering/SyntheticBoundNodeFactory.cs
+++ b/src/Compilers/CSharp/Portable/Lowering/SyntheticBoundNodeFactory.cs
@@ -1652,8 +1652,8 @@ public BoundLocal StoreToTemp(
break;
case RefKind.In:
- if (!Binder.HasHome(argument,
- Binder.AddressKind.ReadOnly,
+ if (!CodeGenerator.HasHome(argument,
+ CodeGenerator.AddressKind.ReadOnly,
containingMethod,
Compilation.IsPeVerifyCompatEnabled,
stackLocalsOpt: null))
diff --git a/src/Compilers/Server/VBCSCompilerTests/BuildClientTests.cs b/src/Compilers/Server/VBCSCompilerTests/BuildClientTests.cs
index bca3ced3dcea0..53c327be7866a 100644
--- a/src/Compilers/Server/VBCSCompilerTests/BuildClientTests.cs
+++ b/src/Compilers/Server/VBCSCompilerTests/BuildClientTests.cs
@@ -344,6 +344,14 @@ public void GetPipeNameForPathOptLength()
// We only have ~50 total bytes to work with on mac, so the base path must be small
Assert.Equal(43, name.Length);
}
+
+ [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/75714")]
+ public void GetPipeNameForPath_Casing()
+ {
+ var path1 = string.Format(@"q:{0}the{0}path", Path.DirectorySeparatorChar);
+ var path2 = string.Format(@"Q:{0}The{0}Path", Path.DirectorySeparatorChar);
+ Assert.Equal(BuildServerConnection.GetPipeName(path1), BuildServerConnection.GetPipeName(path2));
+ }
}
}
}
diff --git a/src/Compilers/Shared/BuildServerConnection.cs b/src/Compilers/Shared/BuildServerConnection.cs
index 2803cd46929ce..c8596ba8b7dc1 100644
--- a/src/Compilers/Shared/BuildServerConnection.cs
+++ b/src/Compilers/Shared/BuildServerConnection.cs
@@ -564,6 +564,9 @@ internal static string GetPipeName(
// of this method.
clientDirectory = clientDirectory.TrimEnd(Path.DirectorySeparatorChar);
+ // Similarly, we don't want multiple servers if the provided launch path differs in casing.
+ clientDirectory = clientDirectory.ToLowerInvariant();
+
var pipeNameInput = $"{userName}.{isAdmin}.{clientDirectory}";
using (var sha = SHA256.Create())
{
diff --git a/src/EditorFeatures/CSharpTest/QuickInfo/SemanticQuickInfoSourceTests.cs b/src/EditorFeatures/CSharpTest/QuickInfo/SemanticQuickInfoSourceTests.cs
index f65586109000d..8b0dc9a91d517 100644
--- a/src/EditorFeatures/CSharpTest/QuickInfo/SemanticQuickInfoSourceTests.cs
+++ b/src/EditorFeatures/CSharpTest/QuickInfo/SemanticQuickInfoSourceTests.cs
@@ -3,6 +3,7 @@
// See the LICENSE file in the project root for more information.
using System;
+using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Security;
using System.Threading;
@@ -23,15 +24,21 @@
namespace Microsoft.CodeAnalysis.Editor.CSharp.UnitTests.QuickInfo;
[Trait(Traits.Feature, Traits.Features.QuickInfo)]
-public class SemanticQuickInfoSourceTests : AbstractSemanticQuickInfoSourceTests
+public sealed class SemanticQuickInfoSourceTests : AbstractSemanticQuickInfoSourceTests
{
- private static async Task TestWithOptionsAsync(CSharpParseOptions options, string markup, params Action[] expectedResults)
+ private static async Task TestWithOptionsAsync(
+ CSharpParseOptions options,
+ [StringSyntax(PredefinedEmbeddedLanguageNames.CSharpTest)] string markup,
+ params Action[] expectedResults)
{
using var workspace = EditorTestWorkspace.CreateCSharp(markup, options);
await TestWithOptionsAsync(workspace, expectedResults);
}
- private static async Task TestWithOptionsAsync(CSharpCompilationOptions options, string markup, params Action[] expectedResults)
+ private static async Task TestWithOptionsAsync(
+ CSharpCompilationOptions options,
+ [StringSyntax(PredefinedEmbeddedLanguageNames.CSharpTest)] string markup,
+ params Action[] expectedResults)
{
using var workspace = EditorTestWorkspace.CreateCSharp(markup, compilationOptions: options);
await TestWithOptionsAsync(workspace, expectedResults);
@@ -83,7 +90,9 @@ private static async Task TestWithOptionsAsync(Document document, QuickInfoServi
}
}
- private static async Task VerifyWithMscorlib45Async(string markup, params Action[] expectedResults)
+ private static async Task VerifyWithMscorlib45Async(
+ [StringSyntax(PredefinedEmbeddedLanguageNames.CSharpTest)] string markup,
+ params Action[] expectedResults)
{
var xmlString = string.Format("""
@@ -98,7 +107,9 @@ private static async Task VerifyWithMscorlib45Async(string markup, params Action
await VerifyWithMarkupAsync(xmlString, expectedResults);
}
- private static async Task VerifyWithNet8Async(string markup, params Action[] expectedResults)
+ private static async Task VerifyWithNet8Async(
+ [StringSyntax(PredefinedEmbeddedLanguageNames.CSharpTest)] string markup,
+ params Action[] expectedResults)
{
var xmlString = string.Format("""
@@ -141,42 +152,56 @@ private static async Task VerifyWithMarkupAsync(string xmlString, Action[] expectedResults)
+ protected override async Task TestAsync(
+ [StringSyntax(PredefinedEmbeddedLanguageNames.CSharpTest)] string markup,
+ params Action[] expectedResults)
{
await TestWithOptionsAsync(Options.Regular, markup, expectedResults);
await TestWithOptionsAsync(Options.Script, markup, expectedResults);
}
- private async Task TestWithUsingsAsync(string markup, params Action[] expectedResults)
+ private async Task TestWithUsingsAsync(
+ [StringSyntax(PredefinedEmbeddedLanguageNames.CSharpTest)] string markup,
+ params Action[] expectedResults)
{
var markupWithUsings =
-@"using System;
-using System.Collections.Generic;
-using System.Linq;
-" + markup;
+ """
+ using System;
+ using System.Collections.Generic;
+ using System.Linq;
+
+ """ + markup;
await TestAsync(markupWithUsings, expectedResults);
}
- private Task TestInClassAsync(string markup, params Action[] expectedResults)
+ private Task TestInClassAsync(
+ [StringSyntax(PredefinedEmbeddedLanguageNames.CSharpTest)] string markup,
+ params Action[] expectedResults)
{
var markupInClass = "class C { " + markup + " }";
return TestWithUsingsAsync(markupInClass, expectedResults);
}
- private Task TestInMethodAsync(string markup, params Action[] expectedResults)
+ private Task TestInMethodAsync(
+ [StringSyntax(PredefinedEmbeddedLanguageNames.CSharpTest)] string markup,
+ params Action[] expectedResults)
{
var markupInMethod = "class C { void M() { " + markup + " } }";
return TestWithUsingsAsync(markupInMethod, expectedResults);
}
- private Task TestInMethodAsync(string markup, string extraSource, params Action[] expectedResults)
+ private Task TestInMethodAsync(
+ [StringSyntax(PredefinedEmbeddedLanguageNames.CSharpTest)] string markup,
+ [StringSyntax(PredefinedEmbeddedLanguageNames.CSharpTest)] string extraSource,
+ params Action[] expectedResults)
{
var markupInMethod = "class C { void M() { " + markup + " } }" + extraSource;
return TestWithUsingsAsync(markupInMethod, expectedResults);
}
- private static async Task TestWithReferenceAsync(string sourceCode,
+ private static async Task TestWithReferenceAsync(
+ string sourceCode,
string referencedCode,
string sourceLanguage,
string referencedLanguage,
@@ -199,19 +224,20 @@ private static async Task TestWithMetadataReferenceHelperAsync(
string referencedLanguage,
params Action[] expectedResults)
{
- var xmlString = string.Format(@"
-
-
-
-{1}
-
-
-
-{3}
-
-
-
-", sourceLanguage, SecurityElement.Escape(sourceCode),
+ var xmlString = string.Format("""
+
+
+
+ {1}
+
+
+
+ {3}
+
+
+
+
+ """, sourceLanguage, SecurityElement.Escape(sourceCode),
referencedLanguage, SecurityElement.Escape(referencedCode));
await VerifyWithReferenceWorkerAsync(xmlString, expectedResults);
@@ -224,21 +250,22 @@ private static async Task TestWithProjectReferenceHelperAsync(
string referencedLanguage,
params Action[] expectedResults)
{
- var xmlString = string.Format(@"
-
-
- ReferencedProject
-
-{1}
-
-
-
-
-{3}
-
-
-
-", sourceLanguage, SecurityElement.Escape(sourceCode),
+ var xmlString = string.Format("""
+
+
+ ReferencedProject
+
+ {1}
+
+
+
+
+ {3}
+
+
+
+
+ """, sourceLanguage, SecurityElement.Escape(sourceCode),
referencedLanguage, SecurityElement.Escape(referencedCode));
await VerifyWithReferenceWorkerAsync(xmlString, expectedResults);
@@ -250,17 +277,18 @@ private static async Task TestInSameProjectHelperAsync(
string sourceLanguage,
params Action[] expectedResults)
{
- var xmlString = string.Format(@"
-
-
-
-{1}
-
-
-{2}
-
-
-", sourceLanguage, SecurityElement.Escape(sourceCode), SecurityElement.Escape(referencedCode));
+ var xmlString = string.Format("""
+
+
+
+ {1}
+
+
+ {2}
+
+
+
+ """, sourceLanguage, SecurityElement.Escape(sourceCode), SecurityElement.Escape(referencedCode));
await VerifyWithReferenceWorkerAsync(xmlString, expectedResults);
}
@@ -293,7 +321,7 @@ private static async Task VerifyWithReferenceWorkerAsync(string xmlString, param
}
}
- protected async Task TestInvalidTypeInClassAsync(string code)
+ private async Task TestInvalidTypeInClassAsync(string code)
{
var codeInClass = "class C { " + code + " }";
await TestAsync(codeInClass);
@@ -303,7 +331,7 @@ protected async Task TestInvalidTypeInClassAsync(string code)
public async Task TestNamespaceInUsingDirective()
{
await TestAsync(
-@"using $$System;",
+ @"using $$System;",
MainDescription("namespace System"));
}
@@ -311,7 +339,7 @@ await TestAsync(
public async Task TestNamespaceInUsingDirective2()
{
await TestAsync(
-@"using System.Coll$$ections.Generic;",
+ @"using System.Coll$$ections.Generic;",
MainDescription("namespace System.Collections"));
}
@@ -319,7 +347,7 @@ await TestAsync(
public async Task TestNamespaceInUsingDirective3()
{
await TestAsync(
-@"using System.L$$inq;",
+ @"using System.L$$inq;",
MainDescription("namespace System.Linq"));
}
@@ -327,7 +355,7 @@ await TestAsync(
public async Task TestNamespaceInUsingDirectiveWithAlias()
{
await TestAsync(
-@"using Goo = Sys$$tem.Console;",
+ @"using Goo = Sys$$tem.Console;",
MainDescription("namespace System"));
}
@@ -335,7 +363,7 @@ await TestAsync(
public async Task TestTypeInUsingDirectiveWithAlias()
{
await TestAsync(
-@"using Goo = System.Con$$sole;",
+ @"using Goo = System.Con$$sole;",
MainDescription("class System.Console"));
}
@@ -343,9 +371,11 @@ await TestAsync(
public async Task TestDocumentationInUsingDirectiveWithAlias()
{
var markup =
-@"using I$$ = IGoo;
-///summary for interface IGoo
-interface IGoo { }";
+ """
+ using I$$ = IGoo;
+ ///summary for interface IGoo
+ interface IGoo { }
+ """;
await TestAsync(markup,
MainDescription("interface IGoo"),
@@ -356,10 +386,12 @@ await TestAsync(markup,
public async Task TestDocumentationInUsingDirectiveWithAlias2()
{
var markup =
-@"using I = IGoo;
-///summary for interface IGoo
-interface IGoo { }
-class C : I$$ { }";
+ """
+ using I = IGoo;
+ ///summary for interface IGoo
+ interface IGoo { }
+ class C : I$$ { }
+ """;
await TestAsync(markup,
MainDescription("interface IGoo"),
@@ -370,13 +402,15 @@ await TestAsync(markup,
public async Task TestDocumentationInUsingDirectiveWithAlias3()
{
var markup =
-@"using I = IGoo;
-///summary for interface IGoo
-interface IGoo
-{
- void Goo();
-}
-class C : I$$ { }";
+ """
+ using I = IGoo;
+ ///summary for interface IGoo
+ interface IGoo
+ {
+ void Goo();
+ }
+ class C : I$$ { }
+ """;
await TestAsync(markup,
MainDescription("interface IGoo"),
@@ -387,9 +421,11 @@ await TestAsync(markup,
public async Task TestThis()
{
var markup =
-@"
-///summary for Class C
-class C { string M() { return thi$$s.ToString(); } }";
+ """
+
+ ///summary for Class C
+ class C { string M() { return thi$$s.ToString(); } }
+ """;
await TestWithUsingsAsync(markup,
MainDescription("class C"),
@@ -400,9 +436,11 @@ await TestWithUsingsAsync(markup,
public async Task TestClassWithDocComment()
{
var markup =
-@"
-///Hello!
-class C { void M() { $$C obj; } }";
+ """
+
+ ///Hello!
+ class C { void M() { $$C obj; } }
+ """;
await TestAsync(markup,
MainDescription("class C"),
@@ -416,60 +454,70 @@ public async Task TestSingleLineDocComments()
// SingleLine doc comment with leading whitespace
await TestAsync(
-@"///Hello!
-class C
-{
- void M()
- {
- $$C obj;
- }
-}",
+ """
+ ///Hello!
+ class C
+ {
+ void M()
+ {
+ $$C obj;
+ }
+ }
+ """,
MainDescription("class C"),
Documentation("Hello!"));
// SingleLine doc comment with space before opening tag
await TestAsync(
-@"/// Hello!
-class C
-{
- void M()
- {
- $$C obj;
- }
-}",
+ """
+ /// Hello!
+ class C
+ {
+ void M()
+ {
+ $$C obj;
+ }
+ }
+ """,
MainDescription("class C"),
Documentation("Hello!"));
// SingleLine doc comment with space before opening tag and leading whitespace
await TestAsync(
-@"/// Hello!
-class C
-{
- void M()
- {
- $$C obj;
- }
-}",
+ """
+ /// Hello!
+ class C
+ {
+ void M()
+ {
+ $$C obj;
+ }
+ }
+ """,
MainDescription("class C"),
Documentation("Hello!"));
// SingleLine doc comment with leading whitespace and blank line
await TestAsync(
-@"///Hello!
-///
+ """
+ ///Hello!
+ ///
-class C
-{
- void M()
- {
- $$C obj;
- }
-}",
+ class C
+ {
+ void M()
+ {
+ $$C obj;
+ }
+ }
+ """,
MainDescription("class C"),
Documentation("Hello!"));
// SingleLine doc comment with '\r' line separators
- await TestAsync("///Hello!\r///\rclass C { void M() { $$C obj; } }",
+ await TestAsync("""
+ ///Hello!
///
class C { void M() { $$C obj; } }
+ """,
MainDescription("class C"),
Documentation("Hello!"));
}
@@ -481,97 +529,111 @@ public async Task TestMultiLineDocComments()
// Multiline doc comment with leading whitespace
await TestAsync(
-@"/**Hello!*/
-class C
-{
- void M()
- {
- $$C obj;
- }
-}",
+ """
+ /**Hello!*/
+ class C
+ {
+ void M()
+ {
+ $$C obj;
+ }
+ }
+ """,
MainDescription("class C"),
Documentation("Hello!"));
// Multiline doc comment with space before opening tag
await TestAsync(
-@"/** Hello!
- **/
-class C
-{
- void M()
- {
- $$C obj;
- }
-}",
+ """
+ /** Hello!
+ **/
+ class C
+ {
+ void M()
+ {
+ $$C obj;
+ }
+ }
+ """,
MainDescription("class C"),
Documentation("Hello!"));
// Multiline doc comment with space before opening tag and leading whitespace
await TestAsync(
-@"/**
- ** Hello!
- **/
-class C
-{
- void M()
- {
- $$C obj;
- }
-}",
+ """
+ /**
+ ** Hello!
+ **/
+ class C
+ {
+ void M()
+ {
+ $$C obj;
+ }
+ }
+ """,
MainDescription("class C"),
Documentation("Hello!"));
// Multiline doc comment with no per-line prefix
await TestAsync(
-@"/**
-
- Hello!
-
-*/
-class C
-{
- void M()
- {
- $$C obj;
- }
-}",
+ """
+ /**
+
+ Hello!
+
+ */
+ class C
+ {
+ void M()
+ {
+ $$C obj;
+ }
+ }
+ """,
MainDescription("class C"),
Documentation("Hello!"));
// Multiline doc comment with inconsistent per-line prefix
await TestAsync(
-@"/**
- **
- Hello!
- **
- **/
-class C
-{
- void M()
- {
- $$C obj;
- }
-}",
+ """
+ /**
+ **
+ Hello!
+ **
+ **/
+ class C
+ {
+ void M()
+ {
+ $$C obj;
+ }
+ }
+ """,
MainDescription("class C"),
Documentation("Hello!"));
// Multiline doc comment with closing comment on final line
await TestAsync(
-@"/**
-Hello!
-*/
-class C
-{
- void M()
- {
- $$C obj;
- }
-}",
+ """
+ /**
+ Hello!
+ */
+ class C
+ {
+ void M()
+ {
+ $$C obj;
+ }
+ }
+ """,
MainDescription("class C"),
Documentation("Hello!"));
// Multiline doc comment with '\r' line separators
- await TestAsync("/**\r* \r* Hello!\r* \r*/\rclass C { void M() { $$C obj; } }",
+ await TestAsync("""
+ /**
*
* Hello!
*
*/
class C { void M() { $$C obj; } }
+ """,
MainDescription("class C"),
Documentation("Hello!"));
}
@@ -580,9 +642,11 @@ void M()
public async Task TestMethodWithDocComment()
{
var markup =
-@"
-///Hello!
-void M() { M$$() }";
+ """
+
+ ///Hello!
+ void M() { M$$() }
+ """;
await TestInClassAsync(markup,
MainDescription("void C.M()"),
@@ -593,7 +657,7 @@ await TestInClassAsync(markup,
public async Task TestInt32()
{
await TestInClassAsync(
-@"$$Int32 i;",
+ @"$$Int32 i;",
MainDescription("struct System.Int32"));
}
@@ -601,7 +665,7 @@ await TestInClassAsync(
public async Task TestBuiltInInt()
{
await TestInClassAsync(
-@"$$int i;",
+ @"$$int i;",
MainDescription("struct System.Int32"));
}
@@ -609,7 +673,7 @@ await TestInClassAsync(
public async Task TestString()
{
await TestInClassAsync(
-@"$$String s;",
+ @"$$String s;",
MainDescription("class System.String"));
}
@@ -617,7 +681,7 @@ await TestInClassAsync(
public async Task TestBuiltInString()
{
await TestInClassAsync(
-@"$$string s;",
+ @"$$string s;",
MainDescription("class System.String"));
}
@@ -625,7 +689,7 @@ await TestInClassAsync(
public async Task TestBuiltInStringAtEndOfToken()
{
await TestInClassAsync(
-@"string$$ s;",
+ @"string$$ s;",
MainDescription("class System.String"));
}
@@ -633,7 +697,7 @@ await TestInClassAsync(
public async Task TestBoolean()
{
await TestInClassAsync(
-@"$$Boolean b;",
+ @"$$Boolean b;",
MainDescription("struct System.Boolean"));
}
@@ -641,7 +705,7 @@ await TestInClassAsync(
public async Task TestBuiltInBool()
{
await TestInClassAsync(
-@"$$bool b;",
+ @"$$bool b;",
MainDescription("struct System.Boolean"));
}
@@ -649,7 +713,7 @@ await TestInClassAsync(
public async Task TestSingle()
{
await TestInClassAsync(
-@"$$Single s;",
+ @"$$Single s;",
MainDescription("struct System.Single"));
}
@@ -657,7 +721,7 @@ await TestInClassAsync(
public async Task TestBuiltInFloat()
{
await TestInClassAsync(
-@"$$float f;",
+ @"$$float f;",
MainDescription("struct System.Single"));
}
@@ -665,63 +729,75 @@ await TestInClassAsync(
public async Task TestVoidIsInvalid()
{
await TestInvalidTypeInClassAsync(
-@"$$void M()
-{
-}");
+ """
+ $$void M()
+ {
+ }
+ """);
}
[Fact]
public async Task TestInvalidPointer1_931958()
{
await TestInvalidTypeInClassAsync(
-@"$$T* i;");
+ @"$$T* i;");
}
[Fact]
public async Task TestInvalidPointer2_931958()
{
await TestInvalidTypeInClassAsync(
-@"T$$* i;");
+ @"T$$* i;");
}
[Fact]
public async Task TestInvalidPointer3_931958()
{
await TestInvalidTypeInClassAsync(
-@"T*$$ i;");
+ @"T*$$ i;");
}
[Fact]
public async Task TestListOfString()
{
await TestInClassAsync(
-@"$$List l;",
+ @"$$List l;",
MainDescription("class System.Collections.Generic.List"),
- TypeParameterMap($"\r\nT {FeaturesResources.is_} string"));
+ TypeParameterMap($"""
+
+ T {FeaturesResources.is_} string
+ """));
}
[Fact]
public async Task TestListOfSomethingFromSource()
{
var markup =
-@"
-///Generic List
-public class GenericList { Generic$$List t; }";
+ """
+
+ ///Generic List
+ public class GenericList { Generic$$List t; }
+ """;
await TestAsync(markup,
MainDescription("class GenericList"),
Documentation("Generic List"),
- TypeParameterMap($"\r\nT {FeaturesResources.is_} int"));
+ TypeParameterMap($"""
+
+ T {FeaturesResources.is_} int
+ """));
}
[Fact]
public async Task TestListOfT()
{
await TestInMethodAsync(
-@"class C
-{
- $$List l;
-}",
+ """
+ class C
+ {
+ $$List l;
+ }
+ """,
MainDescription("class System.Collections.Generic.List"));
}
@@ -729,10 +805,13 @@ await TestInMethodAsync(
public async Task TestDictionaryOfIntAndString()
{
await TestInClassAsync(
-@"$$Dictionary d;",
+ @"$$Dictionary d;",
MainDescription("class System.Collections.Generic.Dictionary"),
TypeParameterMap(
- Lines($"\r\nTKey {FeaturesResources.is_} int",
+ Lines($"""
+
+ TKey {FeaturesResources.is_} int
+ """,
$"TValue {FeaturesResources.is_} string")));
}
@@ -740,13 +819,18 @@ await TestInClassAsync(
public async Task TestDictionaryOfTAndU()
{
await TestInMethodAsync(
-@"class C
-{
- $$Dictionary d;
-}",
+ """
+ class C
+ {
+ $$Dictionary d;
+ }
+ """,
MainDescription("class System.Collections.Generic.Dictionary"),
TypeParameterMap(
- Lines($"\r\nTKey {FeaturesResources.is_} T",
+ Lines($"""
+
+ TKey {FeaturesResources.is_} T
+ """,
$"TValue {FeaturesResources.is_} U")));
}
@@ -754,19 +838,24 @@ await TestInMethodAsync(
public async Task TestIEnumerableOfInt()
{
await TestInClassAsync(
-@"$$IEnumerable M()
-{
- yield break;
-}",
+ """
+ $$IEnumerable M()
+ {
+ yield break;
+ }
+ """,
MainDescription("interface System.Collections.Generic.IEnumerable"),
- TypeParameterMap($"\r\nT {FeaturesResources.is_} int"));
+ TypeParameterMap($"""
+
+ T {FeaturesResources.is_} int
+ """));
}
[Fact]
public async Task TestEventHandler()
{
await TestInClassAsync(
-@"event $$EventHandler e;",
+ @"event $$EventHandler e;",
MainDescription("delegate void System.EventHandler(object sender, System.EventArgs e)"));
}
@@ -774,10 +863,12 @@ await TestInClassAsync(
public async Task TestTypeParameter()
{
await TestAsync(
-@"class C
-{
- $$T t;
-}",
+ """
+ class C
+ {
+ $$T t;
+ }
+ """,
MainDescription($"T {FeaturesResources.in_} C"));
}
@@ -785,10 +876,12 @@ await TestAsync(
public async Task TestTypeParameterWithDocComment()
{
var markup =
-@"
-///Hello!
-///T is Type Parameter
-class C { $$T t; }";
+ """
+
+ ///Hello!
+ ///T is Type Parameter
+ class C { $$T t; }
+ """;
await TestAsync(markup,
MainDescription($"T {FeaturesResources.in_} C"),
@@ -799,10 +892,12 @@ await TestAsync(markup,
public async Task TestTypeParameter1_Bug931949()
{
await TestAsync(
-@"class T1
-{
- $$T11 t;
-}",
+ """
+ class T1
+ {
+ $$T11 t;
+ }
+ """,
MainDescription($"T11 {FeaturesResources.in_} T1"));
}
@@ -810,10 +905,12 @@ await TestAsync(
public async Task TestTypeParameter2_Bug931949()
{
await TestAsync(
-@"class T1
-{
- T$$11 t;
-}",
+ """
+ class T1
+ {
+ T$$11 t;
+ }
+ """,
MainDescription($"T11 {FeaturesResources.in_} T1"));
}
@@ -821,10 +918,12 @@ await TestAsync(
public async Task TestTypeParameter3_Bug931949()
{
await TestAsync(
-@"class T1
-{
- T1$$1 t;
-}",
+ """
+ class T1
+ {
+ T1$$1 t;
+ }
+ """,
MainDescription($"T11 {FeaturesResources.in_} T1"));
}
@@ -832,10 +931,12 @@ await TestAsync(
public async Task TestTypeParameter4_Bug931949()
{
await TestAsync(
-@"class T1
-{
- T11$$ t;
-}",
+ """
+ class T1
+ {
+ T11$$ t;
+ }
+ """,
MainDescription($"T11 {FeaturesResources.in_} T1"));
}
@@ -844,20 +945,25 @@ public async Task TestNullableOfInt()
{
await TestInClassAsync(@"$$Nullable i; }",
MainDescription("struct System.Nullable where T : struct"),
- TypeParameterMap($"\r\nT {FeaturesResources.is_} int"));
+ TypeParameterMap($"""
+
+ T {FeaturesResources.is_} int
+ """));
}
[Fact]
public async Task TestGenericTypeDeclaredOnMethod1_Bug1946()
{
await TestAsync(
-@"class C
-{
- static void Meth1($$T1 i) where T1 : struct
- {
- T1 i;
- }
-}",
+ """
+ class C
+ {
+ static void Meth1($$T1 i) where T1 : struct
+ {
+ T1 i;
+ }
+ }
+ """,
MainDescription($"T1 {FeaturesResources.in_} C.Meth1 where T1 : struct"));
}
@@ -865,13 +971,15 @@ static void Meth1($$T1 i) where T1 : struct
public async Task TestGenericTypeDeclaredOnMethod2_Bug1946()
{
await TestAsync(
-@"class C
-{
- static void Meth1(T1 i) where $$T1 : struct
- {
- T1 i;
- }
-}",
+ """
+ class C
+ {
+ static void Meth1(T1 i) where $$T1 : struct
+ {
+ T1 i;
+ }
+ }
+ """,
MainDescription($"T1 {FeaturesResources.in_} C.Meth1 where T1 : struct"));
}
@@ -879,13 +987,15 @@ static void Meth1(T1 i) where $$T1 : struct
public async Task TestGenericTypeDeclaredOnMethod3_Bug1946()
{
await TestAsync(
-@"class C
-{
- static void Meth1(T1 i) where T1 : struct
- {
- $$T1 i;
- }
-}",
+ """
+ class C
+ {
+ static void Meth1(T1 i) where T1 : struct
+ {
+ $$T1 i;
+ }
+ }
+ """,
MainDescription($"T1 {FeaturesResources.in_} C.Meth1 where T1 : struct"));
}
@@ -893,19 +1003,23 @@ static void Meth1(T1 i) where T1 : struct
public async Task TestGenericTypeParameterConstraint_Class()
{
await TestAsync(
-@"class C where $$T : class
-{
-}",
- MainDescription($"T {FeaturesResources.in_} C where T : class"));
- }
+ """
+ class C where $$T : class
+ {
+ }
+ """,
+ MainDescription($"T {FeaturesResources.in_} C where T : class"));
+ }
[Fact]
public async Task TestGenericTypeParameterConstraint_Struct()
{
await TestAsync(
-@"struct S where $$T : class
-{
-}",
+ """
+ struct S where $$T : class
+ {
+ }
+ """,
MainDescription($"T {FeaturesResources.in_} S where T : class"));
}
@@ -913,9 +1027,11 @@ await TestAsync(
public async Task TestGenericTypeParameterConstraint_Interface()
{
await TestAsync(
-@"interface I where $$T : class
-{
-}",
+ """
+ interface I where $$T : class
+ {
+ }
+ """,
MainDescription($"T {FeaturesResources.in_} I where T : class"));
}
@@ -923,7 +1039,7 @@ await TestAsync(
public async Task TestGenericTypeParameterConstraint_Delegate()
{
await TestAsync(
-@"delegate void D() where $$T : class;",
+ @"delegate void D() where $$T : class;",
MainDescription($"T {FeaturesResources.in_} D where T : class"));
}
@@ -945,13 +1061,15 @@ await TestAsync(@"class C where $$T : System.Collections.Generic.IEnumerable<
public async Task TestMethodReferenceInSameMethod()
{
await TestAsync(
-@"class C
-{
- void M()
- {
- M$$();
- }
-}",
+ """
+ class C
+ {
+ void M()
+ {
+ M$$();
+ }
+ }
+ """,
MainDescription("void C.M()"));
}
@@ -959,9 +1077,11 @@ void M()
public async Task TestMethodReferenceInSameMethodWithDocComment()
{
var markup =
-@"
-///Hello World
-void M() { M$$(); }";
+ """
+
+ ///Hello World
+ void M() { M$$(); }
+ """;
await TestInClassAsync(markup,
MainDescription("void C.M()"),
@@ -972,12 +1092,14 @@ await TestInClassAsync(markup,
public async Task TestFieldInMethodBuiltIn()
{
var markup =
-@"int field;
+ """
+ int field;
-void M()
-{
- field$$
-}";
+ void M()
+ {
+ field$$
+ }
+ """;
await TestInClassAsync(markup,
MainDescription($"({FeaturesResources.field}) int C.field"));
@@ -987,12 +1109,14 @@ await TestInClassAsync(markup,
public async Task TestFieldInMethodBuiltIn2()
{
await TestInClassAsync(
-@"int field;
+ """
+ int field;
-void M()
-{
- int f = field$$;
-}",
+ void M()
+ {
+ int f = field$$;
+ }
+ """,
MainDescription($"({FeaturesResources.field}) int C.field"));
}
@@ -1000,21 +1124,25 @@ void M()
public async Task TestFieldInMethodBuiltInWithFieldInitializer()
{
await TestInClassAsync(
-@"int field = 1;
+ """
+ int field = 1;
-void M()
-{
- int f = field $$;
-}");
+ void M()
+ {
+ int f = field $$;
+ }
+ """);
}
[Fact]
public async Task TestOperatorBuiltIn()
{
await TestInMethodAsync(
-@"int x;
+ """
+ int x;
-x = x$$+1;",
+ x = x$$+1;
+ """,
MainDescription("int int.operator +(int left, int right)"));
}
@@ -1022,9 +1150,11 @@ await TestInMethodAsync(
public async Task TestOperatorBuiltIn1()
{
await TestInMethodAsync(
-@"int x;
+ """
+ int x;
-x = x$$ + 1;",
+ x = x$$ + 1;
+ """,
MainDescription($"({FeaturesResources.local_variable}) int x"));
}
@@ -1032,9 +1162,11 @@ await TestInMethodAsync(
public async Task TestOperatorBuiltIn2()
{
await TestInMethodAsync(
-@"int x;
+ """
+ int x;
-x = x+$$x;",
+ x = x+$$x;
+ """,
MainDescription($"({FeaturesResources.local_variable}) int x"));
}
@@ -1042,9 +1174,11 @@ await TestInMethodAsync(
public async Task TestOperatorBuiltIn3()
{
await TestInMethodAsync(
-@"int x;
+ """
+ int x;
-x = x +$$ x;",
+ x = x +$$ x;
+ """,
MainDescription("int int.operator +(int left, int right)"));
}
@@ -1052,9 +1186,11 @@ await TestInMethodAsync(
public async Task TestOperatorBuiltIn4()
{
await TestInMethodAsync(
-@"int x;
+ """
+ int x;
-x = x + $$x;",
+ x = x + $$x;
+ """,
MainDescription($"({FeaturesResources.local_variable}) int x"));
}
@@ -1062,9 +1198,11 @@ await TestInMethodAsync(
public async Task TestOperatorBuiltIn5()
{
await TestInMethodAsync(
-@"int x;
+ """
+ int x;
-x = unchecked (x$$+1);",
+ x = unchecked (x$$+1);
+ """,
MainDescription("int int.operator +(int left, int right)"));
}
@@ -1072,9 +1210,11 @@ await TestInMethodAsync(
public async Task TestOperatorBuiltIn6()
{
await TestInMethodAsync(
-@"int x;
+ """
+ int x;
-x = checked (x$$+1);",
+ x = checked (x$$+1);
+ """,
MainDescription("int int.operator checked +(int left, int right)"));
}
@@ -1082,9 +1222,11 @@ await TestInMethodAsync(
public async Task TestOperatorBuiltIn7()
{
await TestInMethodAsync(
-@"int x;
+ """
+ int x;
-x = unchecked (x +$$ x);",
+ x = unchecked (x +$$ x);
+ """,
MainDescription("int int.operator +(int left, int right)"));
}
@@ -1092,9 +1234,11 @@ await TestInMethodAsync(
public async Task TestOperatorBuiltIn8()
{
await TestInMethodAsync(
-@"int x;
+ """
+ int x;
-x = checked (x +$$ x);",
+ x = checked (x +$$ x);
+ """,
MainDescription("int int.operator checked +(int left, int right)"));
}
@@ -1102,9 +1246,11 @@ await TestInMethodAsync(
public async Task TestOperatorBuiltIn9()
{
await TestInMethodAsync(
-@"int x;
+ """
+ int x;
-x = $$-x;",
+ x = $$-x;
+ """,
MainDescription("int int.operator -(int value)"));
}
@@ -1112,9 +1258,11 @@ await TestInMethodAsync(
public async Task TestOperatorBuiltIn10()
{
await TestInMethodAsync(
-@"int x;
+ """
+ int x;
-x = unchecked ($$-x);",
+ x = unchecked ($$-x);
+ """,
MainDescription("int int.operator -(int value)"));
}
@@ -1122,9 +1270,11 @@ await TestInMethodAsync(
public async Task TestOperatorBuiltIn11()
{
await TestInMethodAsync(
-@"int x;
+ """
+ int x;
-x = checked ($$-x);",
+ x = checked ($$-x);
+ """,
MainDescription("int int.operator checked -(int value)"));
}
@@ -1132,9 +1282,11 @@ await TestInMethodAsync(
public async Task TestOperatorBuiltIn12()
{
await TestInMethodAsync(
-@"int x;
+ """
+ int x;
-x = x >>>$$ x;",
+ x = x >>>$$ x;
+ """,
MainDescription("int int.operator >>>(int left, int right)"));
}
@@ -1142,9 +1294,11 @@ await TestInMethodAsync(
public async Task TestOperatorBuiltIn13()
{
await TestInMethodAsync(
-@"int x;
+ """
+ int x;
-x >>>=$$ x;",
+ x >>>=$$ x;
+ """,
MainDescription("int int.operator >>>(int left, int right)"));
}
@@ -1152,10 +1306,12 @@ await TestInMethodAsync(
public async Task TestOperatorCustomTypeBuiltIn_01()
{
var markup =
-@"class C
-{
- static void M() { C c; c = c +$$ c; }
-}";
+ """
+ class C
+ {
+ static void M() { C c; c = c +$$ c; }
+ }
+ """;
await TestAsync(markup);
}
@@ -1164,10 +1320,12 @@ public async Task TestOperatorCustomTypeBuiltIn_01()
public async Task TestOperatorCustomTypeBuiltIn_02()
{
var markup =
-@"class C
-{
- static void M() { C c; c = c >>>$$ c; }
-}";
+ """
+ class C
+ {
+ static void M() { C c; c = c >>>$$ c; }
+ }
+ """;
await TestAsync(markup);
}
@@ -1176,11 +1334,13 @@ public async Task TestOperatorCustomTypeBuiltIn_02()
public async Task TestOperatorCustomTypeOverload_01()
{
var markup =
-@"class C
-{
- static void M() { C c; c = c +$$ c; }
- static C operator+(C a, C b) { return a; }
-}";
+ """
+ class C
+ {
+ static void M() { C c; c = c +$$ c; }
+ static C operator+(C a, C b) { return a; }
+ }
+ """;
await TestAsync(markup,
MainDescription("C C.operator +(C a, C b)"));
@@ -1190,11 +1350,13 @@ await TestAsync(markup,
public async Task TestOperatorCustomTypeOverload_02()
{
var markup =
-@"class C
-{
- static void M() { C c; c = unchecked (c +$$ c); }
- static C operator+(C a, C b) { return a; }
-}";
+ """
+ class C
+ {
+ static void M() { C c; c = unchecked (c +$$ c); }
+ static C operator+(C a, C b) { return a; }
+ }
+ """;
await TestAsync(markup,
MainDescription("C C.operator +(C a, C b)"));
@@ -1204,12 +1366,14 @@ await TestAsync(markup,
public async Task TestOperatorCustomTypeOverload_03()
{
var markup =
-@"class C
-{
- static void M() { C c; c = unchecked (c +$$ c); }
- static C operator+(C a, C b) { return a; }
- static C operator checked +(C a, C b) { return a; }
-}";
+ """
+ class C
+ {
+ static void M() { C c; c = unchecked (c +$$ c); }
+ static C operator+(C a, C b) { return a; }
+ static C operator checked +(C a, C b) { return a; }
+ }
+ """;
await TestAsync(markup,
MainDescription("C C.operator +(C a, C b)"));
@@ -1219,12 +1383,14 @@ await TestAsync(markup,
public async Task TestOperatorCustomTypeOverload_04()
{
var markup =
-@"class C
-{
- static void M() { C c; c = checked (c +$$ c); }
- static C operator+(C a, C b) { return a; }
- static C operator checked +(C a, C b) { return a; }
-}";
+ """
+ class C
+ {
+ static void M() { C c; c = checked (c +$$ c); }
+ static C operator+(C a, C b) { return a; }
+ static C operator checked +(C a, C b) { return a; }
+ }
+ """;
await TestAsync(markup,
MainDescription("C C.operator checked +(C a, C b)"));
@@ -1234,11 +1400,13 @@ await TestAsync(markup,
public async Task TestOperatorCustomTypeOverload_05()
{
var markup =
-@"class C
-{
- static void M() { C c; c = $$-c; }
- static C operator-(C a) { return a; }
-}";
+ """
+ class C
+ {
+ static void M() { C c; c = $$-c; }
+ static C operator-(C a) { return a; }
+ }
+ """;
await TestAsync(markup,
MainDescription("C C.operator -(C a)"));
@@ -1248,11 +1416,13 @@ await TestAsync(markup,
public async Task TestOperatorCustomTypeOverload_06()
{
var markup =
-@"class C
-{
- static void M() { C c; c = unchecked ($$-c); }
- static C operator-(C a) { return a; }
-}";
+ """
+ class C
+ {
+ static void M() { C c; c = unchecked ($$-c); }
+ static C operator-(C a) { return a; }
+ }
+ """;
await TestAsync(markup,
MainDescription("C C.operator -(C a)"));
@@ -1262,12 +1432,14 @@ await TestAsync(markup,
public async Task TestOperatorCustomTypeOverload_07()
{
var markup =
-@"class C
-{
- static void M() { C c; c = unchecked ($$-c); }
- static C operator-(C a) { return a; }
- static C operator checked -(C a) { return a; }
-}";
+ """
+ class C
+ {
+ static void M() { C c; c = unchecked ($$-c); }
+ static C operator-(C a) { return a; }
+ static C operator checked -(C a) { return a; }
+ }
+ """;
await TestAsync(markup,
MainDescription("C C.operator -(C a)"));
@@ -1277,12 +1449,14 @@ await TestAsync(markup,
public async Task TestOperatorCustomTypeOverload_08()
{
var markup =
-@"class C
-{
- static void M() { C c; c = checked ($$-c); }
- static C operator-(C a) { return a; }
- static C operator checked -(C a) { return a; }
-}";
+ """
+ class C
+ {
+ static void M() { C c; c = checked ($$-c); }
+ static C operator-(C a) { return a; }
+ static C operator checked -(C a) { return a; }
+ }
+ """;
await TestAsync(markup,
MainDescription("C C.operator checked -(C a)"));
@@ -1292,11 +1466,13 @@ await TestAsync(markup,
public async Task TestOperatorCustomTypeOverload_09()
{
var markup =
-@"class C
-{
- static void M() { C c; c = c >>>$$ c; }
- static C operator>>>(C a, C b) { return a; }
-}";
+ """
+ class C
+ {
+ static void M() { C c; c = c >>>$$ c; }
+ static C operator>>>(C a, C b) { return a; }
+ }
+ """;
await TestAsync(markup,
MainDescription("C C.operator >>>(C a, C b)"));
@@ -1306,11 +1482,13 @@ await TestAsync(markup,
public async Task TestOperatorCustomTypeOverload_10()
{
var markup =
-@"class C
-{
- static void M() { C c; c >>>=$$ c; }
- static C operator>>>(C a, C b) { return a; }
-}";
+ """
+ class C
+ {
+ static void M() { C c; c >>>=$$ c; }
+ static C operator>>>(C a, C b) { return a; }
+ }
+ """;
await TestAsync(markup,
MainDescription("C C.operator >>>(C a, C b)"));
@@ -1320,12 +1498,14 @@ await TestAsync(markup,
public async Task TestFieldInMethodMinimal()
{
var markup =
-@"DateTime field;
+ """
+ DateTime field;
-void M()
-{
- field$$
-}";
+ void M()
+ {
+ field$$
+ }
+ """;
await TestInClassAsync(markup,
MainDescription($"({FeaturesResources.field}) DateTime C.field"));
@@ -1335,12 +1515,14 @@ await TestInClassAsync(markup,
public async Task TestFieldInMethodQualified()
{
var markup =
-@"System.IO.FileInfo file;
+ """
+ System.IO.FileInfo file;
-void M()
-{
- file$$
-}";
+ void M()
+ {
+ file$$
+ }
+ """;
await TestInClassAsync(markup,
MainDescription($"({FeaturesResources.field}) System.IO.FileInfo C.file"));
@@ -1350,9 +1532,11 @@ await TestInClassAsync(markup,
public async Task TestMemberOfStructFromSource()
{
var markup =
-@"struct MyStruct {
-public static int SomeField; }
-static class Test { int a = MyStruct.Some$$Field; }";
+ """
+ struct MyStruct {
+ public static int SomeField; }
+ static class Test { int a = MyStruct.Some$$Field; }
+ """;
await TestAsync(markup,
MainDescription($"({FeaturesResources.field}) static int MyStruct.SomeField"));
@@ -1362,10 +1546,12 @@ await TestAsync(markup,
public async Task TestMemberOfStructFromSourceWithDocComment()
{
var markup =
-@"struct MyStruct {
-///My Field
-public static int SomeField; }
-static class Test { int a = MyStruct.Some$$Field; }";
+ """
+ struct MyStruct {
+ ///My Field
+ public static int SomeField; }
+ static class Test { int a = MyStruct.Some$$Field; }
+ """;
await TestAsync(markup,
MainDescription($"({FeaturesResources.field}) static int MyStruct.SomeField"),
@@ -1376,9 +1562,11 @@ await TestAsync(markup,
public async Task TestMemberOfStructInsideMethodFromSource()
{
var markup =
-@"struct MyStruct {
-public static int SomeField; }
-static class Test { static void Method() { int a = MyStruct.Some$$Field; } }";
+ """
+ struct MyStruct {
+ public static int SomeField; }
+ static class Test { static void Method() { int a = MyStruct.Some$$Field; } }
+ """;
await TestAsync(markup,
MainDescription($"({FeaturesResources.field}) static int MyStruct.SomeField"));
@@ -1388,10 +1576,12 @@ await TestAsync(markup,
public async Task TestMemberOfStructInsideMethodFromSourceWithDocComment()
{
var markup =
-@"struct MyStruct {
-///My Field
-public static int SomeField; }
-static class Test { static void Method() { int a = MyStruct.Some$$Field; } }";
+ """
+ struct MyStruct {
+ ///My Field
+ public static int SomeField; }
+ static class Test { static void Method() { int a = MyStruct.Some$$Field; } }
+ """;
await TestAsync(markup,
MainDescription($"({FeaturesResources.field}) static int MyStruct.SomeField"),
@@ -1402,17 +1592,19 @@ await TestAsync(markup,
public async Task TestPartialMethodDocComment_01()
{
var markup =
-@"partial class MyClass
-{
- ///My Method Definition
- public partial void MyMethod();
+ """
+ partial class MyClass
+ {
+ ///My Method Definition
+ public partial void MyMethod();
- ///My Method Implementation
- public partial void MyMethod()
- {
- }
-}
-static class Test { static void Method() { MyClass.My$$Method(); } }";
+ ///My Method Implementation
+ public partial void MyMethod()
+ {
+ }
+ }
+ static class Test { static void Method() { MyClass.My$$Method(); } }
+ """;
await TestAsync(markup,
MainDescription($"void MyClass.MyMethod()"),
@@ -1423,16 +1615,18 @@ await TestAsync(markup,
public async Task TestPartialMethodDocComment_02()
{
var markup =
-@"partial class MyClass
-{
- ///My Method Definition
- public partial void MyMethod();
+ """
+ partial class MyClass
+ {
+ ///My Method Definition
+ public partial void MyMethod();
- public partial void MyMethod()
- {
- }
-}
-static class Test { static void Method() { MyClass.My$$Method(); } }";
+ public partial void MyMethod()
+ {
+ }
+ }
+ static class Test { static void Method() { MyClass.My$$Method(); } }
+ """;
await TestAsync(markup,
MainDescription($"void MyClass.MyMethod()"),
@@ -1443,16 +1637,18 @@ await TestAsync(markup,
public async Task TestPartialMethodDocComment_03()
{
var markup =
-@"partial class MyClass
-{
- public partial void MyMethod();
+ """
+ partial class MyClass
+ {
+ public partial void MyMethod();
- ///My Method Implementation
- public partial void MyMethod()
- {
- }
-}
-static class Test { static void Method() { MyClass.My$$Method(); } }";
+ ///My Method Implementation
+ public partial void MyMethod()
+ {
+ }
+ }
+ static class Test { static void Method() { MyClass.My$$Method(); } }
+ """;
await TestAsync(markup,
MainDescription($"void MyClass.MyMethod()"),
@@ -1463,12 +1659,14 @@ await TestAsync(markup,
public async Task TestPartialMethodDocComment_04()
{
var markup =
-@"partial class MyClass
-{
- ///My Method Definition
- public partial void MyMethod();
-}
-static class Test { static void Method() { MyClass.My$$Method(); } }";
+ """
+ partial class MyClass
+ {
+ ///My Method Definition
+ public partial void MyMethod();
+ }
+ static class Test { static void Method() { MyClass.My$$Method(); } }
+ """;
await TestAsync(markup,
MainDescription($"void MyClass.MyMethod()"),
@@ -1479,12 +1677,14 @@ await TestAsync(markup,
public async Task TestPartialMethodDocComment_05()
{
var markup =
-@"partial class MyClass
-{
- ///My Method Implementation
- public partial void MyMethod() { }
-}
-static class Test { static void Method() { MyClass.My$$Method(); } }";
+ """
+ partial class MyClass
+ {
+ ///My Method Implementation
+ public partial void MyMethod() { }
+ }
+ static class Test { static void Method() { MyClass.My$$Method(); } }
+ """;
await TestAsync(markup,
MainDescription($"void MyClass.MyMethod()"),
@@ -1495,14 +1695,16 @@ await TestAsync(markup,
public async Task TestPartialMethodDocComment_06()
{
var markup =
-@"partial class MyClass
-{
- ///My Method Definition
- partial void MyMethod();
+ """
+ partial class MyClass
+ {
+ ///My Method Definition
+ partial void MyMethod();
- partial void MyMethod() { }
-}
-static class Test { static void Method() { MyClass.My$$Method(); } }";
+ partial void MyMethod() { }
+ }
+ static class Test { static void Method() { MyClass.My$$Method(); } }
+ """;
await TestAsync(markup,
MainDescription($"void MyClass.MyMethod()"),
@@ -1521,12 +1723,14 @@ public async Task TestMetadataFieldQualified1()
{
// NOTE: we qualify the field type, but not the type that contains the field in Dev10
var markup =
-@"class C {
- void M()
- {
- DateTime dt = System.DateTime.MaxValue$$
- }
-}";
+ """
+ class C {
+ void M()
+ {
+ DateTime dt = System.DateTime.MaxValue$$
+ }
+ }
+ """;
await TestAsync(markup,
MainDescription($"({FeaturesResources.field}) static readonly System.DateTime System.DateTime.MaxValue"));
}
@@ -1535,13 +1739,15 @@ await TestAsync(markup,
public async Task TestMetadataFieldQualified2()
{
await TestAsync(
-@"class C
-{
- void M()
- {
- DateTime dt = System.DateTime.MaxValue$$
- }
-}",
+ """
+ class C
+ {
+ void M()
+ {
+ DateTime dt = System.DateTime.MaxValue$$
+ }
+ }
+ """,
MainDescription($"({FeaturesResources.field}) static readonly System.DateTime System.DateTime.MaxValue"));
}
@@ -1549,15 +1755,17 @@ void M()
public async Task TestMetadataFieldQualified3()
{
await TestAsync(
-@"using System;
+ """
+ using System;
-class C
-{
- void M()
- {
- DateTime dt = System.DateTime.MaxValue$$
- }
-}",
+ class C
+ {
+ void M()
+ {
+ DateTime dt = System.DateTime.MaxValue$$
+ }
+ }
+ """,
MainDescription($"({FeaturesResources.field}) static readonly DateTime DateTime.MaxValue"));
}
@@ -1565,34 +1773,38 @@ void M()
public async Task ConstructedGenericField()
{
await TestAsync(
-@"class C
-{
- public T Field;
-}
+ """
+ class C
+ {
+ public T Field;
+ }
-class D
-{
- void M()
- {
- new C().Fi$$eld.ToString();
- }
-}",
- MainDescription($"({FeaturesResources.field}) int C.Field"));
+ class D
+ {
+ void M()
+ {
+ new C().Fi$$eld.ToString();
+ }
+ }
+ """,
+ MainDescription($"({FeaturesResources.field}) int C.Field"));
}
[Fact]
public async Task UnconstructedGenericField()
{
await TestAsync(
-@"class C
-{
- public T Field;
+ """
+ class C
+ {
+ public T Field;
- void M()
- {
- Fi$$eld.ToString();
- }
-}",
+ void M()
+ {
+ Fi$$eld.ToString();
+ }
+ }
+ """,
MainDescription($"({FeaturesResources.field}) T C.Field"));
}
@@ -1638,185 +1850,209 @@ await TestInMethodAsync(@"string f = default$$",
[Fact, WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/756226")]
public async Task TestAwaitKeywordOnGenericTaskReturningAsync()
{
- var markup = @"using System.Threading.Tasks;
-class C
-{
- public async Task Calc()
- {
- aw$$ait Calc();
- return 5;
- }
-}";
+ var markup = """
+ using System.Threading.Tasks;
+ class C
+ {
+ public async Task Calc()
+ {
+ aw$$ait Calc();
+ return 5;
+ }
+ }
+ """;
await TestAsync(markup, MainDescription(string.Format(FeaturesResources.Awaited_task_returns_0, "struct System.Int32")));
}
[Fact, WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/756226")]
public async Task TestAwaitKeywordInDeclarationStatement()
{
- var markup = @"using System.Threading.Tasks;
-class C
-{
- public async Task Calc()
- {
- var x = $$await Calc();
- return 5;
- }
-}";
+ var markup = """
+ using System.Threading.Tasks;
+ class C
+ {
+ public async Task Calc()
+ {
+ var x = $$await Calc();
+ return 5;
+ }
+ }
+ """;
await TestAsync(markup, MainDescription(string.Format(FeaturesResources.Awaited_task_returns_0, "struct System.Int32")));
}
[Fact, WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/756226")]
public async Task TestAwaitKeywordOnTaskReturningAsync()
{
- var markup = @"using System.Threading.Tasks;
-class C
-{
- public async void Calc()
- {
- aw$$ait Task.Delay(100);
- }
-}";
+ var markup = """
+ using System.Threading.Tasks;
+ class C
+ {
+ public async void Calc()
+ {
+ aw$$ait Task.Delay(100);
+ }
+ }
+ """;
await TestAsync(markup, MainDescription(FeaturesResources.Awaited_task_returns_no_value));
}
[Fact, WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/756226"), WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/756337")]
public async Task TestNestedAwaitKeywords1()
{
- var markup = @"using System;
-using System.Threading.Tasks;
-class AsyncExample2
-{
- async Task> AsyncMethod()
- {
- return NewMethod();
- }
+ var markup = """
+ using System;
+ using System.Threading.Tasks;
+ class AsyncExample2
+ {
+ async Task> AsyncMethod()
+ {
+ return NewMethod();
+ }
- private static Task NewMethod()
- {
- int hours = 24;
- return hours;
- }
+ private static Task NewMethod()
+ {
+ int hours = 24;
+ return hours;
+ }
- async Task UseAsync()
- {
- Func> lambda = async () =>
- {
- return await await AsyncMethod();
- };
+ async Task UseAsync()
+ {
+ Func> lambda = async () =>
+ {
+ return await await AsyncMethod();
+ };
- int result = await await AsyncMethod();
- Task> resultTask = AsyncMethod();
- result = await awa$$it resultTask;
- result = await lambda();
- }
-}";
+ int result = await await AsyncMethod();
+ Task> resultTask = AsyncMethod();
+ result = await awa$$it resultTask;
+ result = await lambda();
+ }
+ }
+ """;
await TestAsync(markup, MainDescription(string.Format(FeaturesResources.Awaited_task_returns_0, $"({CSharpFeaturesResources.awaitable}) class System.Threading.Tasks.Task")),
- TypeParameterMap($"\r\nTResult {FeaturesResources.is_} int"));
+ TypeParameterMap($"""
+
+ TResult {FeaturesResources.is_} int
+ """));
}
[Fact, WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/756226")]
public async Task TestNestedAwaitKeywords2()
{
- var markup = @"using System;
-using System.Threading.Tasks;
-class AsyncExample2
-{
- async Task> AsyncMethod()
- {
- return NewMethod();
- }
+ var markup = """
+ using System;
+ using System.Threading.Tasks;
+ class AsyncExample2
+ {
+ async Task> AsyncMethod()
+ {
+ return NewMethod();
+ }
- private static Task NewMethod()
- {
- int hours = 24;
- return hours;
- }
+ private static Task NewMethod()
+ {
+ int hours = 24;
+ return hours;
+ }
- async Task UseAsync()
- {
- Func> lambda = async () =>
- {
- return await await AsyncMethod();
- };
+ async Task UseAsync()
+ {
+ Func> lambda = async () =>
+ {
+ return await await AsyncMethod();
+ };
- int result = await await AsyncMethod();
- Task> resultTask = AsyncMethod();
- result = awa$$it await resultTask;
- result = await lambda();
- }
-}";
+ int result = await await AsyncMethod();
+ Task> resultTask = AsyncMethod();
+ result = awa$$it await resultTask;
+ result = await lambda();
+ }
+ }
+ """;
await TestAsync(markup, MainDescription(string.Format(FeaturesResources.Awaited_task_returns_0, "struct System.Int32")));
}
[Fact, WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/756226"), WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/756337")]
public async Task TestAwaitablePrefixOnCustomAwaiter()
{
- var markup = @"using System;
-using System.Runtime.CompilerServices;
-using System.Threading.Tasks;
-using Z = $$C;
+ var markup = """
+ using System;
+ using System.Runtime.CompilerServices;
+ using System.Threading.Tasks;
+ using Z = $$C;
-class C
-{
- public MyAwaiter GetAwaiter() { throw new NotImplementedException(); }
-}
+ class C
+ {
+ public MyAwaiter GetAwaiter() { throw new NotImplementedException(); }
+ }
-class MyAwaiter : INotifyCompletion
-{
- public void OnCompleted(Action continuation)
- {
- throw new NotImplementedException();
- }
+ class MyAwaiter : INotifyCompletion
+ {
+ public void OnCompleted(Action continuation)
+ {
+ throw new NotImplementedException();
+ }
- public bool IsCompleted { get { throw new NotImplementedException(); } }
- public void GetResult() { }
-}";
+ public bool IsCompleted { get { throw new NotImplementedException(); } }
+ public void GetResult() { }
+ }
+ """;
await TestAsync(markup, MainDescription($"({CSharpFeaturesResources.awaitable}) class C"));
}
[Fact, WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/756226"), WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/756337")]
public async Task TestTaskType()
{
- var markup = @"using System.Threading.Tasks;
-class C
-{
- public void Calc()
- {
- Task$$ v1;
- }
-}";
+ var markup = """
+ using System.Threading.Tasks;
+ class C
+ {
+ public void Calc()
+ {
+ Task$$ v1;
+ }
+ }
+ """;
await TestAsync(markup, MainDescription($"({CSharpFeaturesResources.awaitable}) class System.Threading.Tasks.Task"));
}
[Fact, WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/756226"), WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/756337")]
public async Task TestTaskOfTType()
{
- var markup = @"using System;
-using System.Threading.Tasks;
-class C
-{
- public void Calc()
- {
- Task$$ v1;
- }
-}";
+ var markup = """
+ using System;
+ using System.Threading.Tasks;
+ class C
+ {
+ public void Calc()
+ {
+ Task$$ v1;
+ }
+ }
+ """;
await TestAsync(markup, MainDescription($"({CSharpFeaturesResources.awaitable}) class System.Threading.Tasks.Task"),
- TypeParameterMap($"\r\nTResult {FeaturesResources.is_} int"));
+ TypeParameterMap($"""
+
+ TResult {FeaturesResources.is_} int
+ """));
}
[Fact, WorkItem("https://github.com/dotnet/roslyn/issues/7100")]
public async Task TestDynamicIsntAwaitable()
{
- var markup = @"
-class C
-{
- dynamic D() { return null; }
- void M()
- {
- D$$();
- }
-}
-";
+ var markup = """
+
+ class C
+ {
+ dynamic D() { return null; }
+ void M()
+ {
+ D$$();
+ }
+ }
+
+ """;
await TestAsync(markup, MainDescription("dynamic C.D()"));
}
@@ -1833,7 +2069,10 @@ public async Task TestStringLiteralUtf8_01()
await TestInMethodAsync(@"var f = ""Goo""u8$$",
TestSources.Span,
MainDescription("readonly ref struct System.ReadOnlySpan"),
- TypeParameterMap($"\r\nT {FeaturesResources.is_} byte"));
+ TypeParameterMap($"""
+
+ T {FeaturesResources.is_} byte
+ """));
}
[Fact]
@@ -1842,7 +2081,10 @@ public async Task TestStringLiteralUtf8_02()
await TestInMethodAsync(@"var f = ""Goo""U8$$",
TestSources.Span,
MainDescription("readonly ref struct System.ReadOnlySpan"),
- TypeParameterMap($"\r\nT {FeaturesResources.is_} byte"));
+ TypeParameterMap($"""
+
+ T {FeaturesResources.is_} byte
+ """));
}
[Fact, WorkItem("https://github.com/dotnet/roslyn/issues/1280")]
@@ -1858,7 +2100,10 @@ public async Task TestVerbatimStringLiteralUtf8_01()
await TestInMethodAsync(@"string f = @""cat""u8$$",
TestSources.Span,
MainDescription("readonly ref struct System.ReadOnlySpan"),
- TypeParameterMap($"\r\nT {FeaturesResources.is_} byte"));
+ TypeParameterMap($"""
+
+ T {FeaturesResources.is_} byte
+ """));
}
[Fact]
@@ -1867,7 +2112,10 @@ public async Task TestVerbatimStringLiteralUtf8_02()
await TestInMethodAsync(@"string f = @""cat""U8$$",
TestSources.Span,
MainDescription("readonly ref struct System.ReadOnlySpan"),
- TypeParameterMap($"\r\nT {FeaturesResources.is_} byte"));
+ TypeParameterMap($"""
+
+ T {FeaturesResources.is_} byte
+ """));
}
[Fact]
@@ -1883,7 +2131,10 @@ public async Task TestRawStringLiteralUtf8_01()
await TestInMethodAsync(@"string f = """"""Goo""""""u8$$",
TestSources.Span,
MainDescription("readonly ref struct System.ReadOnlySpan"),
- TypeParameterMap($"\r\nT {FeaturesResources.is_} byte"));
+ TypeParameterMap($"""
+
+ T {FeaturesResources.is_} byte
+ """));
}
[Fact]
@@ -1892,56 +2143,83 @@ public async Task TestRawStringLiteralUtf8_02()
await TestInMethodAsync(@"string f = """"""Goo""""""U8$$",
TestSources.Span,
MainDescription("readonly ref struct System.ReadOnlySpan"),
- TypeParameterMap($"\r\nT {FeaturesResources.is_} byte"));
+ TypeParameterMap($"""
+
+ T {FeaturesResources.is_} byte
+ """));
}
[Fact]
public async Task TestRawStringLiteralMultiline()
{
- await TestInMethodAsync(@"string f = """"""
- Goo
- """"""$$",
+ await TestInMethodAsync(""""
+ string f = """
+ Goo
+ """$$
+ """",
MainDescription("class System.String"));
}
[Fact]
public async Task TestRawStringLiteralMultilineUtf8_01()
{
- await TestInMethodAsync(@"string f = """"""
- Goo
- """"""u8$$",
+ await TestInMethodAsync(""""
+ string f = """
+ Goo
+ """u8$$
+ """",
TestSources.Span,
MainDescription("readonly ref struct System.ReadOnlySpan"),
- TypeParameterMap($"\r\nT {FeaturesResources.is_} byte"));
+ TypeParameterMap($"""
+
+ T {FeaturesResources.is_} byte
+ """));
}
[Fact]
public async Task TestRawStringLiteralMultilineUtf8_02()
{
- await TestInMethodAsync(@"string f = """"""
- Goo
- """"""U8$$",
+ await TestInMethodAsync(""""
+ string f = """
+ Goo
+ """U8$$
+ """",
TestSources.Span,
MainDescription("readonly ref struct System.ReadOnlySpan"),
- TypeParameterMap($"\r\nT {FeaturesResources.is_} byte"));
+ TypeParameterMap($"""
+
+ T {FeaturesResources.is_} byte
+ """));
}
[Fact, WorkItem("https://github.com/dotnet/roslyn/issues/1280")]
public async Task TestInterpolatedStringLiteral()
{
await TestInMethodAsync(@"string f = $""cat""$$", MainDescription("class System.String"));
- await TestInMethodAsync(@"string f = $""c$$at""", MainDescription("class System.String"));
- await TestInMethodAsync(@"string f = $""$$cat""", MainDescription("class System.String"));
- await TestInMethodAsync(@"string f = $""cat {1$$ + 2} dog""", MainDescription("struct System.Int32"));
+ await TestInMethodAsync("""
+ string f = $"c$$at"
+ """, MainDescription("class System.String"));
+ await TestInMethodAsync("""
+ string f = $"$$cat"
+ """, MainDescription("class System.String"));
+ await TestInMethodAsync("""
+ string f = $"cat {1$$ + 2} dog"
+ """, MainDescription("struct System.Int32"));
}
[Fact, WorkItem("https://github.com/dotnet/roslyn/issues/1280")]
public async Task TestVerbatimInterpolatedStringLiteral()
{
await TestInMethodAsync(@"string f = $@""cat""$$", MainDescription("class System.String"));
- await TestInMethodAsync(@"string f = $@""c$$at""", MainDescription("class System.String"));
- await TestInMethodAsync(@"string f = $@""$$cat""", MainDescription("class System.String"));
- await TestInMethodAsync(@"string f = $@""cat {1$$ + 2} dog""", MainDescription("struct System.Int32"));
+ await TestInMethodAsync("""
+ string f = $@"c$$at"
+ """, MainDescription("class System.String"));
+ await TestInMethodAsync("""
+ string f = $@"$$cat"
+ """, MainDescription("class System.String"));
+ await TestInMethodAsync("""
+ string f = $@"cat {1$$ + 2} dog"
+ """, MainDescription("struct System.Int32"));
}
[Fact]
@@ -1955,7 +2233,7 @@ await TestInMethodAsync(@"string f = 'x'$$",
public async Task DynamicKeyword()
{
await TestInMethodAsync(
-@"dyn$$amic dyn;",
+ @"dyn$$amic dyn;",
MainDescription("dynamic"),
Documentation(FeaturesResources.Represents_an_object_whose_operations_will_be_resolved_at_runtime));
}
@@ -1964,12 +2242,14 @@ await TestInMethodAsync(
public async Task DynamicField()
{
await TestInClassAsync(
-@"dynamic dyn;
+ """
+ dynamic dyn;
-void M()
-{
- d$$yn.Goo();
-}",
+ void M()
+ {
+ d$$yn.Goo();
+ }
+ """,
MainDescription($"({FeaturesResources.field}) dynamic C.dyn"));
}
@@ -1977,12 +2257,14 @@ void M()
public async Task LocalProperty_Minimal()
{
await TestInClassAsync(
-@"DateTime Prop { get; set; }
+ """
+ DateTime Prop { get; set; }
-void M()
-{
- P$$rop.ToString();
-}",
+ void M()
+ {
+ P$$rop.ToString();
+ }
+ """,
MainDescription("DateTime C.Prop { get; set; }"));
}
@@ -1990,12 +2272,14 @@ void M()
public async Task LocalProperty_Minimal_PrivateSet()
{
await TestInClassAsync(
-@"public DateTime Prop { get; private set; }
+ """
+ public DateTime Prop { get; private set; }
-void M()
-{
- P$$rop.ToString();
-}",
+ void M()
+ {
+ P$$rop.ToString();
+ }
+ """,
MainDescription("DateTime C.Prop { get; private set; }"));
}
@@ -2003,12 +2287,14 @@ void M()
public async Task LocalProperty_Minimal_PrivateSet1()
{
await TestInClassAsync(
-@"protected internal int Prop { get; private set; }
+ """
+ protected internal int Prop { get; private set; }
-void M()
-{
- P$$rop.ToString();
-}",
+ void M()
+ {
+ P$$rop.ToString();
+ }
+ """,
MainDescription("int C.Prop { get; private set; }"));
}
@@ -2016,12 +2302,14 @@ void M()
public async Task LocalProperty_Qualified()
{
await TestInClassAsync(
-@"System.IO.FileInfo Prop { get; set; }
+ """
+ System.IO.FileInfo Prop { get; set; }
-void M()
-{
- P$$rop.ToString();
-}",
+ void M()
+ {
+ P$$rop.ToString();
+ }
+ """,
MainDescription("System.IO.FileInfo C.Prop { get; set; }"));
}
@@ -2036,9 +2324,11 @@ public async Task NonLocalProperty_Minimal()
public async Task NonLocalProperty_Qualified()
{
await TestInMethodAsync(
-@"System.IO.FileInfo f;
+ """
+ System.IO.FileInfo f;
-f.Att$$ributes.ToString();",
+ f.Att$$ributes.ToString();
+ """,
MainDescription("System.IO.FileAttributes System.IO.FileSystemInfo.Attributes { get; set; }"));
}
@@ -2046,18 +2336,20 @@ await TestInMethodAsync(
public async Task ConstructedGenericProperty()
{
await TestAsync(
-@"class C
-{
- public T Property { get; set }
-}
+ """
+ class C
+ {
+ public T Property { get; set }
+ }
-class D
-{
- void M()
- {
- new C().Pro$$perty.ToString();
- }
-}",
+ class D
+ {
+ void M()
+ {
+ new C().Pro$$perty.ToString();
+ }
+ }
+ """,
MainDescription("int C.Property { get; set; }"));
}
@@ -2065,15 +2357,17 @@ void M()
public async Task UnconstructedGenericProperty()
{
await TestAsync(
-@"class C
-{
- public T Property { get; set}
+ """
+ class C
+ {
+ public T Property { get; set}
- void M()
- {
- Pro$$perty.ToString();
- }
-}",
+ void M()
+ {
+ Pro$$perty.ToString();
+ }
+ }
+ """,
MainDescription("T C.Property { get; set; }"));
}
@@ -2081,13 +2375,15 @@ void M()
public async Task ValueInProperty()
{
await TestInClassAsync(
-@"public DateTime Property
-{
- set
- {
- goo = val$$ue;
- }
-}",
+ """
+ public DateTime Property
+ {
+ set
+ {
+ goo = val$$ue;
+ }
+ }
+ """,
MainDescription($"({FeaturesResources.parameter}) DateTime value"));
}
@@ -2108,100 +2404,116 @@ await TestInClassAsync(@"enum E$$ : byte { A, B }",
[Fact, WorkItem("https://github.com/dotnet/roslyn/issues/52490")]
public async Task EnumNonDefaultUnderlyingType_AsField()
{
- await TestInClassAsync(@"
-enum E : byte { A, B }
+ await TestInClassAsync("""
-private E$$ _E;
-",
+ enum E : byte { A, B }
+
+ private E$$ _E;
+
+ """,
MainDescription("enum C.E : byte"));
}
[Fact, WorkItem("https://github.com/dotnet/roslyn/issues/52490")]
public async Task EnumNonDefaultUnderlyingType_AsProperty()
{
- await TestInClassAsync(@"
-enum E : byte { A, B }
+ await TestInClassAsync("""
+
+ enum E : byte { A, B }
-private E$$ E{ get; set; };
-",
+ private E$$ E{ get; set; };
+
+ """,
MainDescription("enum C.E : byte"));
}
[Fact, WorkItem("https://github.com/dotnet/roslyn/issues/52490")]
public async Task EnumNonDefaultUnderlyingType_AsParameter()
{
- await TestInClassAsync(@"
-enum E : byte { A, B }
+ await TestInClassAsync("""
+
+ enum E : byte { A, B }
+
+ private void M(E$$ e) { }
-private void M(E$$ e) { }
-",
+ """,
MainDescription("enum C.E : byte"));
}
[Fact, WorkItem("https://github.com/dotnet/roslyn/issues/52490")]
public async Task EnumNonDefaultUnderlyingType_AsReturnType()
{
- await TestInClassAsync(@"
-enum E : byte { A, B }
+ await TestInClassAsync("""
+
+ enum E : byte { A, B }
-private E$$ M() { }
-",
+ private E$$ M() { }
+
+ """,
MainDescription("enum C.E : byte"));
}
[Fact, WorkItem("https://github.com/dotnet/roslyn/issues/52490")]
public async Task EnumNonDefaultUnderlyingType_AsLocal()
{
- await TestInClassAsync(@"
-enum E : byte { A, B }
+ await TestInClassAsync("""
-private void M()
-{
- E$$ e = default;
-}
-",
+ enum E : byte { A, B }
+
+ private void M()
+ {
+ E$$ e = default;
+ }
+
+ """,
MainDescription("enum C.E : byte"));
}
[Fact, WorkItem("https://github.com/dotnet/roslyn/issues/52490")]
public async Task EnumNonDefaultUnderlyingType_OnMemberAccessOnType()
{
- await TestInClassAsync(@"
-enum EN : byte { A, B }
+ await TestInClassAsync("""
-private void M()
-{
- var ea = E$$N.A;
-}
-",
+ enum EN : byte { A, B }
+
+ private void M()
+ {
+ var ea = E$$N.A;
+ }
+
+ """,
MainDescription("enum C.EN : byte"));
}
[Fact, WorkItem("https://github.com/dotnet/roslyn/issues/52490")]
public async Task EnumNonDefaultUnderlyingType_OnMemberAccessOnType_OnDot()
{
- await TestInClassAsync(@"
-enum E : byte { A, B }
+ await TestInClassAsync("""
-private void M()
-{
- var ea = E$$.A;
-}
-",
- MainDescription("E.A = 0"));
- }
+ enum E : byte { A, B }
- [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/52490")]
- public async Task EnumNonDefaultUnderlyingType_NotOnMemberAccessOnMember()
+ private void M()
+ {
+ var ea = E$$.A;
+ }
+
+ """,
+ MainDescription("E.A = 0"));
+ }
+
+ [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/52490")]
+ public async Task EnumNonDefaultUnderlyingType_NotOnMemberAccessOnMember()
{
- await TestInClassAsync(@"
-enum E : byte { A, B }
+ await TestInClassAsync("""
-private void M()
-{
- var ea = E.A$$;
-}
-",
+ enum E : byte { A, B }
+
+ private void M()
+ {
+ var ea = E.A$$;
+ }
+
+ """,
MainDescription("E.A = 0"));
}
@@ -2223,11 +2535,13 @@ private void M()
[InlineData("ulong", "System.UInt64")]
public async Task EnumNonDefaultUnderlyingType_ShowForNonDefaultTypes(string displayTypeName, string underlyingTypeName)
{
- await TestInClassAsync(@$"
-enum E$$ : {underlyingTypeName}
-{{
- A, B
-}}",
+ await TestInClassAsync($$"""
+
+ enum E$$ : {{underlyingTypeName}}
+ {
+ A, B
+ }
+ """,
MainDescription($"enum C.E : {displayTypeName}"));
}
@@ -2237,11 +2551,13 @@ enum E$$ : {underlyingTypeName}
[InlineData(": System.Int32")]
public async Task EnumNonDefaultUnderlyingType_DoNotShowForDefaultType(string defaultType)
{
- await TestInClassAsync(@$"
-enum E$$ {defaultType}
-{{
- A, B
-}}",
+ await TestInClassAsync($$"""
+
+ enum E$$ {{defaultType}}
+ {
+ A, B
+ }
+ """,
MainDescription("enum C.E"));
}
@@ -2270,20 +2586,22 @@ await TestInMethodAsync(@"AttributeTargets a = AttributeTargets.A$$ll",
public async Task EnumMemberNameFromSource1()
{
await TestAsync(
-@"enum E
-{
- A = 1 << 0,
- B = 1 << 1,
- C = 1 << 2
-}
+ """
+ enum E
+ {
+ A = 1 << 0,
+ B = 1 << 1,
+ C = 1 << 2
+ }
-class C
-{
- void M()
- {
- var e = E.B$$;
- }
-}",
+ class C
+ {
+ void M()
+ {
+ var e = E.B$$;
+ }
+ }
+ """,
MainDescription("E.B = 1 << 1"));
}
@@ -2291,20 +2609,22 @@ void M()
public async Task EnumMemberNameFromSource2()
{
await TestAsync(
-@"enum E
-{
- A,
- B,
- C
-}
+ """
+ enum E
+ {
+ A,
+ B,
+ C
+ }
-class C
-{
- void M()
- {
- var e = E.B$$;
- }
-}",
+ class C
+ {
+ void M()
+ {
+ var e = E.B$$;
+ }
+ }
+ """,
MainDescription("E.B = 1"));
}
@@ -2312,9 +2632,11 @@ void M()
public async Task Parameter_InMethod_Minimal()
{
await TestInClassAsync(
-@"void M(DateTime dt)
-{
- d$$t.ToString();",
+ """
+ void M(DateTime dt)
+ {
+ d$$t.ToString();
+ """,
MainDescription($"({FeaturesResources.parameter}) DateTime dt"));
}
@@ -2322,9 +2644,11 @@ await TestInClassAsync(
public async Task Parameter_InMethod_Qualified()
{
await TestInClassAsync(
-@"void M(System.IO.FileInfo fileInfo)
-{
- file$$Info.ToString();",
+ """
+ void M(System.IO.FileInfo fileInfo)
+ {
+ file$$Info.ToString();
+ """,
MainDescription($"({FeaturesResources.parameter}) System.IO.FileInfo fileInfo"));
}
@@ -2341,10 +2665,12 @@ public async Task Parameter_DefaultValue()
// NOTE: Dev10 doesn't show the default value, but it would be nice if we did.
// NOTE: The "DefaultValue" property isn't implemented yet.
await TestInClassAsync(
-@"void M(int param = 42)
-{
- para$$m.ToString();
-}",
+ """
+ void M(int param = 42)
+ {
+ para$$m.ToString();
+ }
+ """,
MainDescription($"({FeaturesResources.parameter}) int param = 42"));
}
@@ -2352,9 +2678,11 @@ await TestInClassAsync(
public async Task Lambda_Parameter_DefaultValue_01()
{
await TestInMethodAsync(
-@"(int param = 42) => {
- return para$$m + 1;
-}",
+ """
+ (int param = 42) => {
+ return para$$m + 1;
+ }
+ """,
MainDescription($"({FeaturesResources.parameter}) int param = 42"));
}
@@ -2362,9 +2690,11 @@ await TestInMethodAsync(
public async Task Lambda_Parameter_DefaultValue_02()
{
await TestInMethodAsync(
-@"(int param = $$int.MaxValue) => {
- return param + 1;
-}",
+ """
+ (int param = $$int.MaxValue) => {
+ return param + 1;
+ }
+ """,
MainDescription($"{FeaturesResources.struct_} System.Int32"));
}
@@ -2372,9 +2702,11 @@ await TestInMethodAsync(
public async Task Lambda_Parameter_DefaultValue_03()
{
await TestInMethodAsync(
-@"(int param = int.$$MaxValue) => {
- return param + 1;
-}",
+ """
+ (int param = int.$$MaxValue) => {
+ return param + 1;
+ }
+ """,
MainDescription($"({FeaturesResources.constant}) const int int.MaxValue = 2147483647"));
}
@@ -2382,9 +2714,11 @@ await TestInMethodAsync(
public async Task Lambda_Parameter_ParamsArray()
{
await TestInMethodAsync(
-@"(params int[] xs) => {
- return x$$s.Length;
-}",
+ """
+ (params int[] xs) => {
+ return x$$s.Length;
+ }
+ """,
MainDescription($"({FeaturesResources.parameter}) params int[] xs"));
}
@@ -2392,10 +2726,12 @@ await TestInMethodAsync(
public async Task Parameter_Params()
{
await TestInClassAsync(
-@"void M(params DateTime[] arg)
-{
- ar$$g.ToString();
-}",
+ """
+ void M(params DateTime[] arg)
+ {
+ ar$$g.ToString();
+ }
+ """,
MainDescription($"({FeaturesResources.parameter}) params DateTime[] arg"));
}
@@ -2403,10 +2739,12 @@ await TestInClassAsync(
public async Task Parameter_Ref()
{
await TestInClassAsync(
-@"void M(ref DateTime arg)
-{
- ar$$g.ToString();
-}",
+ """
+ void M(ref DateTime arg)
+ {
+ ar$$g.ToString();
+ }
+ """,
MainDescription($"({FeaturesResources.parameter}) ref DateTime arg"));
}
@@ -2414,10 +2752,12 @@ await TestInClassAsync(
public async Task Parameter_Out()
{
await TestInClassAsync(
-@"void M(out DateTime arg)
-{
- ar$$g.ToString();
-}",
+ """
+ void M(out DateTime arg)
+ {
+ ar$$g.ToString();
+ }
+ """,
MainDescription($"({FeaturesResources.parameter}) out DateTime arg"));
}
@@ -2425,9 +2765,11 @@ await TestInClassAsync(
public async Task Local_Minimal()
{
await TestInMethodAsync(
-@"DateTime dt;
+ """
+ DateTime dt;
-d$$t.ToString();",
+ d$$t.ToString();
+ """,
MainDescription($"({FeaturesResources.local_variable}) DateTime dt"));
}
@@ -2435,9 +2777,11 @@ await TestInMethodAsync(
public async Task Local_Qualified()
{
await TestInMethodAsync(
-@"System.IO.FileInfo fileInfo;
+ """
+ System.IO.FileInfo fileInfo;
-file$$Info.ToString();",
+ file$$Info.ToString();
+ """,
MainDescription($"({FeaturesResources.local_variable}) System.IO.FileInfo fileInfo"));
}
@@ -2452,14 +2796,16 @@ public async Task Method_MetadataOverload()
public async Task Method_SimpleWithOverload()
{
await TestInClassAsync(
-@"void Method()
-{
- Met$$hod();
-}
+ """
+ void Method()
+ {
+ Met$$hod();
+ }
-void Method(int i)
-{
-}",
+ void Method(int i)
+ {
+ }
+ """,
MainDescription($"void C.Method() (+ 1 {FeaturesResources.overload})"));
}
@@ -2467,22 +2813,24 @@ void Method(int i)
public async Task Method_MoreOverloads()
{
await TestInClassAsync(
-@"void Method()
-{
- Met$$hod(null);
-}
+ """
+ void Method()
+ {
+ Met$$hod(null);
+ }
-void Method(int i)
-{
-}
+ void Method(int i)
+ {
+ }
-void Method(DateTime dt)
-{
-}
+ void Method(DateTime dt)
+ {
+ }
-void Method(System.IO.FileInfo fileInfo)
-{
-}",
+ void Method(System.IO.FileInfo fileInfo)
+ {
+ }
+ """,
MainDescription($"void C.Method(System.IO.FileInfo fileInfo) (+ 3 {FeaturesResources.overloads_})"));
}
@@ -2490,10 +2838,12 @@ void Method(System.IO.FileInfo fileInfo)
public async Task Method_SimpleInSameClass()
{
await TestInClassAsync(
-@"DateTime GetDate(System.IO.FileInfo ft)
-{
- Get$$Date(null);
-}",
+ """
+ DateTime GetDate(System.IO.FileInfo ft)
+ {
+ Get$$Date(null);
+ }
+ """,
MainDescription("DateTime C.GetDate(System.IO.FileInfo ft)"));
}
@@ -2501,14 +2851,16 @@ await TestInClassAsync(
public async Task Method_OptionalParameter()
{
await TestInClassAsync(
-@"void M()
-{
- Met$$hod();
-}
+ """
+ void M()
+ {
+ Met$$hod();
+ }
-void Method(int i = 0)
-{
-}",
+ void Method(int i = 0)
+ {
+ }
+ """,
MainDescription("void C.Method([int i = 0])"));
}
@@ -2516,9 +2868,11 @@ void Method(int i = 0)
public async Task Method_OptionalDecimalParameter()
{
await TestInClassAsync(
-@"void Goo(decimal x$$yz = 10)
-{
-}",
+ """
+ void Goo(decimal x$$yz = 10)
+ {
+ }
+ """,
MainDescription($"({FeaturesResources.parameter}) decimal xyz = 10"));
}
@@ -2528,10 +2882,12 @@ public async Task Method_Generic()
// Generic method don't get the instantiation info yet. NOTE: We don't display
// constraint info in Dev10. Should we?
await TestInClassAsync(
-@"TOut Goo(TIn arg) where TIn : IEquatable
-{
- Go$$o(37);
-}",
+ """
+ TOut Goo(TIn arg) where TIn : IEquatable
+ {
+ Go$$o(37);
+ }
+ """,
MainDescription("DateTime C.Goo(int arg)"));
}
@@ -2540,10 +2896,12 @@ await TestInClassAsync(
public async Task Method_UnconstructedGeneric()
{
await TestInClassAsync(
-@"TOut Goo(TIn arg)
-{
- Go$$o(default(TIn);
-}",
+ """
+ TOut Goo(TIn arg)
+ {
+ Go$$o(default(TIn);
+ }
+ """,
MainDescription("TOut C.Goo(TIn arg)"));
}
@@ -2552,10 +2910,12 @@ await TestInClassAsync(
public async Task Method_Inferred()
{
await TestInClassAsync(
-@"void Goo(TIn arg)
-{
- Go$$o(42);
-}",
+ """
+ void Goo(TIn arg)
+ {
+ Go$$o(42);
+ }
+ """,
MainDescription("void C.Goo(int arg)"));
}
@@ -2563,10 +2923,12 @@ await TestInClassAsync(
public async Task Method_MultipleParams()
{
await TestInClassAsync(
-@"void Goo(DateTime dt, System.IO.FileInfo fi, int number)
-{
- Go$$o(DateTime.Now, null, 32);
-}",
+ """
+ void Goo(DateTime dt, System.IO.FileInfo fi, int number)
+ {
+ Go$$o(DateTime.Now, null, 32);
+ }
+ """,
MainDescription("void C.Goo(DateTime dt, System.IO.FileInfo fi, int number)"));
}
@@ -2575,10 +2937,12 @@ public async Task Method_OptionalParam()
{
// NOTE - Default values aren't actually returned by symbols yet.
await TestInClassAsync(
-@"void Goo(int num = 42)
-{
- Go$$o();
-}",
+ """
+ void Goo(int num = 42)
+ {
+ Go$$o();
+ }
+ """,
MainDescription("void C.Goo([int num = 42])"));
}
@@ -2587,10 +2951,12 @@ public async Task Method_ParameterModifiers()
{
// NOTE - Default values aren't actually returned by symbols yet.
await TestInClassAsync(
-@"void Goo(ref DateTime dt, out System.IO.FileInfo fi, params int[] numbers)
-{
- Go$$o(DateTime.Now, null, 32);
-}",
+ """
+ void Goo(ref DateTime dt, out System.IO.FileInfo fi, params int[] numbers)
+ {
+ Go$$o(DateTime.Now, null, 32);
+ }
+ """,
MainDescription("void C.Goo(ref DateTime dt, out System.IO.FileInfo fi, params int[] numbers)"));
}
@@ -2611,14 +2977,16 @@ void Goo(ref readonly DateTime dt, ref readonly System.IO.FileInfo fi, params in
public async Task Constructor()
{
await TestInClassAsync(
-@"public C()
-{
-}
+ """
+ public C()
+ {
+ }
-void M()
-{
- new C$$().ToString();
-}",
+ void M()
+ {
+ new C$$().ToString();
+ }
+ """,
MainDescription("C.C()"));
}
@@ -2626,22 +2994,24 @@ void M()
public async Task Constructor_Overloads()
{
await TestInClassAsync(
-@"public C()
-{
-}
+ """
+ public C()
+ {
+ }
-public C(DateTime dt)
-{
-}
+ public C(DateTime dt)
+ {
+ }
-public C(int i)
-{
-}
+ public C(int i)
+ {
+ }
-void M()
-{
- new C$$(DateTime.MaxValue).ToString();
-}",
+ void M()
+ {
+ new C$$(DateTime.MaxValue).ToString();
+ }
+ """,
MainDescription($"C.C(DateTime dt) (+ 2 {FeaturesResources.overloads_})"));
}
@@ -2652,7 +3022,7 @@ void M()
public async Task Constructor_OverloadFromStringLiteral()
{
await TestInMethodAsync(
-@"new InvalidOperatio$$nException("""");",
+ @"new InvalidOperatio$$nException("""");",
MainDescription($"InvalidOperationException.InvalidOperationException(string message) (+ 2 {FeaturesResources.overloads_})"));
}
@@ -2663,10 +3033,12 @@ await TestInMethodAsync(
public async Task Constructor_UnknownType()
{
await TestInvalidTypeInClassAsync(
-@"void M()
-{
- new G$$oo();
-}");
+ """
+ void M()
+ {
+ new G$$oo();
+ }
+ """);
}
///
@@ -2676,7 +3048,7 @@ await TestInvalidTypeInClassAsync(
public async Task Constructor_OverloadFromProperty()
{
await TestInMethodAsync(
-@"new InvalidOperatio$$nException(this.GetType().Name);",
+ @"new InvalidOperatio$$nException(this.GetType().Name);",
MainDescription($"InvalidOperationException.InvalidOperationException(string message) (+ 2 {FeaturesResources.overloads_})"));
}
@@ -2684,7 +3056,7 @@ await TestInMethodAsync(
public async Task Constructor_Metadata()
{
await TestInMethodAsync(
-@"new Argument$$NullException();",
+ @"new Argument$$NullException();",
MainDescription($"ArgumentNullException.ArgumentNullException() (+ 3 {FeaturesResources.overloads_})"));
}
@@ -2699,10 +3071,12 @@ public async Task Constructor_MetadataQualified()
public async Task InterfaceProperty()
{
await TestInMethodAsync(
-@"interface I
-{
- string Name$$ { get; set; }
-}",
+ """
+ interface I
+ {
+ string Name$$ { get; set; }
+ }
+ """,
MainDescription("string I.Name { get; set; }"));
}
@@ -2710,25 +3084,27 @@ await TestInMethodAsync(
public async Task ExplicitInterfacePropertyImplementation()
{
await TestInMethodAsync(
-@"interface I
-{
- string Name { get; set; }
-}
+ """
+ interface I
+ {
+ string Name { get; set; }
+ }
-class C : I
-{
- string IEmployee.Name$$
- {
- get
- {
- return """";
- }
+ class C : I
+ {
+ string IEmployee.Name$$
+ {
+ get
+ {
+ return "";
+ }
- set
- {
- }
- }
-}",
+ set
+ {
+ }
+ }
+ }
+ """,
MainDescription("string C.Name { get; set; }"));
}
@@ -2736,15 +3112,17 @@ string IEmployee.Name$$
public async Task Operator()
{
await TestInClassAsync(
-@"public static C operator +(C left, C right)
-{
- return null;
-}
+ """
+ public static C operator +(C left, C right)
+ {
+ return null;
+ }
-void M(C left, C right)
-{
- return left +$$ right;
-}",
+ void M(C left, C right)
+ {
+ return left +$$ right;
+ }
+ """,
MainDescription("C C.operator +(C left, C right)"));
}
@@ -2755,9 +3133,11 @@ void M(C left, C right)
public async Task GenericMethodWithConstraintsAtDeclaration()
{
await TestInClassAsync(
-@"TOut G$$oo(TIn arg) where TIn : IEquatable
-{
-}",
+ """
+ TOut G$$oo(TIn arg) where TIn : IEquatable
+ {
+ }
+ """,
MainDescription("TOut C.Goo(TIn arg) where TIn : IEquatable"));
}
@@ -2769,10 +3149,12 @@ await TestInClassAsync(
public async Task GenericMethodWithMultipleConstraintsAtDeclaration()
{
await TestInClassAsync(
-@"TOut Goo(TIn arg) where TIn : Employee, new()
-{
- Go$$o(default(TIn);
-}",
+ """
+ TOut Goo(TIn arg) where TIn : Employee, new()
+ {
+ Go$$o(default(TIn);
+ }
+ """,
MainDescription("TOut C.Goo(TIn arg) where TIn : Employee, new()"));
}
@@ -2784,29 +3166,33 @@ await TestInClassAsync(
public async Task UnConstructedGenericMethodWithConstraintsAtInvocation()
{
await TestInClassAsync(
-@"TOut Goo(TIn arg) where TIn : Employee
-{
- Go$$o(default(TIn);
-}",
-
- MainDescription("TOut C.Goo(TIn arg) where TIn : Employee"));
+ """
+ TOut Goo(TIn arg) where TIn : Employee
+ {
+ Go$$o(default(TIn);
+ }
+ """,
+
+ MainDescription("TOut C.Goo(TIn arg) where TIn : Employee"));
}
[Fact]
public async Task GenericTypeWithConstraintsAtDeclaration()
{
await TestAsync(
-@"public class Employee : IComparable
-{
- public int CompareTo(Employee other)
- {
- throw new NotImplementedException();
- }
-}
+ """
+ public class Employee : IComparable
+ {
+ public int CompareTo(Employee other)
+ {
+ throw new NotImplementedException();
+ }
+ }
-class Emplo$$yeeList : IEnumerable where T : Employee, System.IComparable, new()
-{
-}",
+ class Emplo$$yeeList : IEnumerable where T : Employee, System.IComparable, new()
+ {
+ }
+ """,
MainDescription("class EmployeeList where T : Employee, System.IComparable, new()"));
}
@@ -2815,10 +3201,12 @@ public int CompareTo(Employee other)
public async Task GenericType()
{
await TestAsync(
-@"class T1
-{
- $$T11 i;
-}",
+ """
+ class T1
+ {
+ $$T11 i;
+ }
+ """,
MainDescription($"T11 {FeaturesResources.in_} T1"));
}
@@ -2826,10 +3214,12 @@ await TestAsync(
public async Task GenericMethod()
{
await TestInClassAsync(
-@"static void Meth1(T1 i) where T1 : struct
-{
- $$T1 i;
-}",
+ """
+ static void Meth1(T1 i) where T1 : struct
+ {
+ $$T1 i;
+ }
+ """,
MainDescription($"T1 {FeaturesResources.in_} C.Meth1 where T1 : struct"));
}
@@ -2837,8 +3227,10 @@ await TestInClassAsync(
public async Task Var()
{
await TestInMethodAsync(
-@"var x = new Exception();
-var y = $$x;",
+ """
+ var x = new Exception();
+ var y = $$x;
+ """,
MainDescription($"({FeaturesResources.local_variable}) Exception x"));
}
@@ -2847,18 +3239,20 @@ public async Task NullableReference()
{
await TestWithOptionsAsync(
Options.Regular.WithLanguageVersion(LanguageVersion.CSharp8),
-@"class A
-{
-}
-class B
-{
- static void M()
- {
- A? x = null!;
- var y = x;
- $$y.ToString();
- }
-}",
+ """
+ class A
+ {
+ }
+ class B
+ {
+ static void M()
+ {
+ A? x = null!;
+ var y = x;
+ $$y.ToString();
+ }
+ }
+ """,
// https://github.com/dotnet/roslyn/issues/26198 public API should show inferred nullability
MainDescription($"({FeaturesResources.local_variable}) A y"));
}
@@ -2866,21 +3260,23 @@ static void M()
[Fact, WorkItem("https://github.com/dotnet/roslyn/issues/26648")]
public async Task NullableReference_InMethod()
{
- var code = @"
-class G
-{
- void M()
- {
- C c;
- c.Go$$o();
- }
-}
-public class C
-{
- public string? Goo(IEnumerable