diff --git a/azure-pipelines-pr-validation.yml b/azure-pipelines-pr-validation.yml index 12b91f142340..0afa702c1f38 100644 --- a/azure-pipelines-pr-validation.yml +++ b/azure-pipelines-pr-validation.yml @@ -165,28 +165,6 @@ extends: displayName: Setting SourceBranchName variable condition: succeeded() - - task: Powershell@2 - name: FancyBuild - displayName: Setting FancyBuild.BuildNumber - inputs: - targetType: inline - script: | - $pull_request = Invoke-RestMethod -Uri "https://api.github.com/repos/dotnet/roslyn/pulls/${{ parameters.PRNumber }}" ` - -Headers @{ - "Accept" = "application/vnd.github+json"; - "X-GitHub-Api-Version" = "2022-11-28" - } - $buildNumberName = "$(OriginalBuildNumber) - $($pull_request.user.login) - '$($pull_request.title)'" - $buildNumberName = $buildNumberName -replace '["/:<>\|?@*]','_' - # Maximum buildnumber length is 255 chars and we are going to append to the end to ensure we have space. - if ($buildNumberName.Length -GT 253) { - $buildNumberName = $buildNumberName.Substring(0, 253) - } - # Avoid ever ending the BuildNumber with a `.` by always appending to it. - $buildNumberName += ' #' - Write-Host "##vso[task.setvariable variable=BuildNumber;isoutput=true;isreadonly=true]$buildNumberName" - Write-Host "##vso[build.updatebuildnumber]$buildNumberName" - - task: Powershell@2 displayName: Tag PR validation build inputs: @@ -204,6 +182,25 @@ extends: arguments: "-sourceBranchName $(SourceBranchName) -prNumber ${{ parameters.PRNumber }} -commitSHA ${{ parameters.CommitSHA }} -enforceLatestCommit ${{ iif(parameters.EnforceLatestCommit, '1', '0') }}" condition: succeeded() + - task: Powershell@2 + name: FancyBuild + displayName: Setting FancyBuild.BuildNumber + inputs: + targetType: inline + script: | + $authorName = git log -1 --pretty=format:"%an" ${{ parameters.CommitSHA }} + + $buildNumberName = "$(OriginalBuildNumber) - $($authorName) - '${{ parameters.PRNumber }}'" + $buildNumberName = $buildNumberName -replace '["/:<>\|?@*]','_' + # Maximum buildnumber length is 255 chars and we are going to append to the end to ensure we have space. + if ($buildNumberName.Length -GT 253) { + $buildNumberName = $buildNumberName.Substring(0, 253) + } + # Avoid ever ending the BuildNumber with a `.` by always appending to it. + $buildNumberName += ' #' + Write-Host "##vso[task.setvariable variable=BuildNumber;isoutput=true;isreadonly=true]$buildNumberName" + Write-Host "##vso[build.updatebuildnumber]$buildNumberName" + - powershell: Write-Host "##vso[task.setvariable variable=VisualStudio.DropName]Products/$(System.TeamProject)/$(Build.Repository.Name)/$(SourceBranchName)/$(OriginalBuildNumber)" displayName: Setting VisualStudio.DropName variable diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 494714e8fde8..509fcd0367c1 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -400,13 +400,19 @@ stages: configuration: Release - name: compilerChange value: $[dependencies.Determine_Changes.outputs['SetPathVars_compilers.containsChange']] + # Set NUGET_PACKAGES to fix issues with package Restore when building with `-ci`. + # Workaround for https://github.com/dotnet/arcade/issues/15970 + - name: NUGET_PACKAGES + value: $(Build.SourcesDirectory)\.packages steps: - template: eng/pipelines/checkout-windows-task.yml - powershell: eng/build.ps1 -configuration Release -prepareMachine -ci -restore -binaryLogName Restore.binlog displayName: Restore - - powershell: eng/build.ps1 -configuration Release -prepareMachine -ci -build -pack -publish -sign -binaryLogName Build.binlog /p:DotnetPublishUsingPipelines=true /p:ContinuousIntegrationBuildCorrectness=true + # We additionally restore during the build because the Microsoft.DotNet.Build.Tasks.Feed package only restores when we pass `-publish`. See https://github.com/dotnet/arcade/blob/37ccfd66358af6a37a0ec385ec31d1d71bdd8723/src/Microsoft.DotNet.Arcade.Sdk/tools/Tools.proj#L61-L66 + # Passing `-publish` during the restore step above fails due to no items needing published. + - powershell: eng/build.ps1 -configuration Release -prepareMachine -ci -restore -build -pack -publish -sign -binaryLogName Build.binlog /p:DotnetPublishUsingPipelines=true /p:ContinuousIntegrationBuildCorrectness=true displayName: Build # While this task is not executed in the official build, this serves as a PR check for whether symbol exclusions diff --git a/docs/contributing/Building, Debugging, and Testing on Unix.md b/docs/contributing/Building, Debugging, and Testing on Unix.md index 5d1d326a4d61..6f224b39f758 100644 --- a/docs/contributing/Building, Debugging, and Testing on Unix.md +++ b/docs/contributing/Building, Debugging, and Testing on Unix.md @@ -12,7 +12,7 @@ Particularly for developers who aren't experienced with .NET Core development on 1. Install [VS Code](https://code.visualstudio.com/Download) - After you install VS Code, install the [C# extension](https://marketplace.visualstudio.com/items?itemName=ms-dotnettools.csharp) - Important tip: You can look up editor commands by name by hitting *Ctrl+Shift+P*, or by hitting *Ctrl+P* and typing a `>` character. This will help you get familiar with editor commands mentioned below. On a Mac, use *⌘* instead of *Ctrl*. -1. Install the [.NET 9.0 SDK](https://dotnet.microsoft.com/en-us/download/dotnet/9.0) which matches the `sdk.version` property in [global.json](../../global.json#L3) +1. Install the [.NET 10.0 SDK](https://dotnet.microsoft.com/en-us/download/dotnet/10.0) which matches the `sdk.version` property in [global.json](../../global.json#L3) 3. You can build from VS Code by running the *Run Build Task* command, then selecting an appropriate task such as *build* or *build current project* (the latter builds the containing project for the current file you're viewing in the editor). 4. You can run tests from VS Code by opening a test class in the editor, then using the *Run Tests in Context* and *Debug Tests in Context* editor commands. You may want to bind these commands to keyboard shortcuts that match their Visual Studio equivalents (**Ctrl+R, T** for *Run Tests in Context* and **Ctrl+R, Ctrl+T** for *Debug Tests in Context*). 5. You can launch a new VS Code instance with the language server from your current code by running the "launch vscode with language server" task. diff --git a/docs/contributing/Building, Debugging, and Testing on Windows.md b/docs/contributing/Building, Debugging, and Testing on Windows.md index 235ae3e82854..cd3d77670b08 100644 --- a/docs/contributing/Building, Debugging, and Testing on Windows.md +++ b/docs/contributing/Building, Debugging, and Testing on Windows.md @@ -20,7 +20,7 @@ The minimal required version of .NET Framework is 4.7.2. - Ensure C# and Visual Basic, MSBuild, and .NET Core are included in the selected individual components - Ensure "Use previews of the .NET Core SDK" is checked in Tools -> Options -> Environment -> Preview Features - Restart Visual Studio -1. Install the [.NET 9.0 SDK](https://dotnet.microsoft.com/en-us/download/dotnet/9.0) which matches the `sdk.version` property in [global.json](../../global.json#L3) +1. Install the [.NET 10.0 SDK](https://dotnet.microsoft.com/en-us/download/dotnet/10.0) which matches the `sdk.version` property in [global.json](../../global.json#L3) 1. [PowerShell 5.0 or newer](https://docs.microsoft.com/en-us/powershell/scripting/setup/installing-windows-powershell). If you are on Windows 10, you are fine; you'll only need to upgrade if you're on earlier versions of Windows. The download link is under the ["Upgrading existing Windows PowerShell"](https://docs.microsoft.com/en-us/powershell/scripting/install/installing-windows-powershell?view=powershell-6#upgrading-existing-windows-powershell) heading. 1. Run Restore.cmd 1. Open Roslyn.sln diff --git a/docs/contributing/Compiler Test Plan.md b/docs/contributing/Compiler Test Plan.md index c9f0f5ea2a3c..8c2303a1709d 100644 --- a/docs/contributing/Compiler Test Plan.md +++ b/docs/contributing/Compiler Test Plan.md @@ -55,7 +55,7 @@ This document provides guidance for thinking about language interactions and tes - Compiler-recognized attributes should not have any effect in earlier LangVersions, except a LangVersion error should be reported when functionality depending on the attribute is used (for example, InlineArray conversion to Span). -- Generics (type arguments, variance, constraints including `class`, `struct`, `new()`, `unmanaged`, `notnull`, types and interfaces with nullability) +- Generics (type arguments, variance, constraints including `class`, `struct`, `new()`, `unmanaged`, `notnull`, `allows ref struct`, types and interfaces with nullability) - Default and constant values - Partial classes - Literals diff --git a/eng/Directory.Packages.props b/eng/Directory.Packages.props index aa611b4cbb49..8b0c5a473de7 100644 --- a/eng/Directory.Packages.props +++ b/eng/Directory.Packages.props @@ -4,8 +4,8 @@ 3.11.0-beta1.24081.1 8.0.0-preview.23468.1 1.1.3-beta1.24319.1 - 0.1.785-beta - <_BasicReferenceAssembliesVersion>1.7.9 + 0.1.796-beta + <_BasicReferenceAssembliesVersion>1.8.3 4.8.0-3.final 17.13.226 @@ -273,7 +273,7 @@ - + @@ -297,6 +297,7 @@ + diff --git a/eng/Publishing.props b/eng/Publishing.props index 2a0c88ef1b25..a0e65bf33255 100644 --- a/eng/Publishing.props +++ b/eng/Publishing.props @@ -17,11 +17,14 @@ + Condition=" '$(PreReleaseVersionLabel)' == 'pr-validation' or '$(DotNetBuildSourceOnly)' == 'true' "> + <_NuGetPackagesToPush Include="@(ItemsToPushToBlobFeed)" @@ -30,13 +33,25 @@ <_SymbolPackagesToPush Include="@(_NuGetPackagesToPush)" Condition="$([System.String]::Copy(%(FullPath)).EndsWith('.symbols.nupkg'))" /> + <_SymbolPackagesToPush Include="@(_NuGetPackagesToPush)" + Condition="$([System.String]::Copy(%(FullPath)).Contains('.Symbols.'))" /> + + + + + + + + - + + + diff --git a/eng/Version.Details.props b/eng/Version.Details.props new file mode 100644 index 000000000000..aa1fc141196d --- /dev/null +++ b/eng/Version.Details.props @@ -0,0 +1 @@ + diff --git a/eng/Version.Details.xml b/eng/Version.Details.xml index a1e403bfb422..68107c2ef0d6 100644 --- a/eng/Version.Details.xml +++ b/eng/Version.Details.xml @@ -1,15 +1,15 @@ - + https://github.com/dotnet/roslyn ae1fff344d46976624e68ae17164e0607ab68b10 - - https://github.com/dotnet/command-line-api - e9b0511d7f1128e2bc3be7a658a2a4ea977e602d + + https://github.com/dotnet/dotnet + c0e325f90fb79db0da6be5128dc292f2aabb264f @@ -110,13 +110,13 @@ - + https://github.com/dotnet/arcade - 80c4e4d26cb85c86f7e1be77d2d9eceeef0f3493 + d777c20040bdc2e52b372fa98dcb84141ed692d3 - + https://github.com/dotnet/arcade - 80c4e4d26cb85c86f7e1be77d2d9eceeef0f3493 + d777c20040bdc2e52b372fa98dcb84141ed692d3 https://github.com/dotnet/symreader @@ -126,9 +126,9 @@ https://github.com/dotnet/roslyn 5d10d428050c0d6afef30a072c4ae68776621877 - + https://github.com/dotnet/arcade - 80c4e4d26cb85c86f7e1be77d2d9eceeef0f3493 + d777c20040bdc2e52b372fa98dcb84141ed692d3 https://github.com/dotnet/roslyn-analyzers diff --git a/eng/Versions.props b/eng/Versions.props index a70c92287985..540580b3c22d 100644 --- a/eng/Versions.props +++ b/eng/Versions.props @@ -32,23 +32,23 @@ 6.0.1 - 4.5.1 + 4.6.0 4.8.6 - 4.5.5 - 4.5.0 - 6.0.0 - 4.5.4 + 4.6.0 + 4.6.0 + 6.1.0 + 4.6.0 4.5.0 - 2.0.0-beta5.25210.1 + 2.0.0-beta7.25373.104 9.0.0 9.0.0 9.0.0 @@ -147,7 +147,7 @@ false true - true + true - - netstandard2.0 + $(NetRoslyn);netstandard2.0 false none false @@ -21,7 +21,9 @@ + + diff --git a/src/Dependencies/Threading/Microsoft.CodeAnalysis.Threading.projitems b/src/Dependencies/Threading/Microsoft.CodeAnalysis.Threading.projitems index 1e6df1704531..a4c16e94e050 100644 --- a/src/Dependencies/Threading/Microsoft.CodeAnalysis.Threading.projitems +++ b/src/Dependencies/Threading/Microsoft.CodeAnalysis.Threading.projitems @@ -10,19 +10,7 @@ Microsoft.CodeAnalysis.Threading - - - - - - - - - - - - - + diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Utilities/RoslynParallel.NetFramework.cs b/src/Dependencies/Threading/ParallelExtensions.NetFramework.cs similarity index 99% rename from src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Utilities/RoslynParallel.NetFramework.cs rename to src/Dependencies/Threading/ParallelExtensions.NetFramework.cs index 75da6a60c1c1..23a86095528c 100644 --- a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Utilities/RoslynParallel.NetFramework.cs +++ b/src/Dependencies/Threading/ParallelExtensions.NetFramework.cs @@ -17,17 +17,13 @@ // With only changes to make the code work on NetFx. Where changes have been made, the original code is kept around in // an ifdef'ed block to see what it was doing. -using System; using System.Collections.Generic; using System.Diagnostics; -using System.Threading; -using System.Threading.Tasks; using Microsoft.CodeAnalysis.Threading; -using Roslyn.Utilities; -namespace Microsoft.CodeAnalysis.Shared.Utilities; +namespace System.Threading.Tasks; -internal static partial class RoslynParallel +internal static partial class RoslynParallelExtensions { private static class NetFramework { diff --git a/src/Dependencies/Threading/ParallelExtensions.cs b/src/Dependencies/Threading/ParallelExtensions.cs new file mode 100644 index 000000000000..5eec9ccdbefb --- /dev/null +++ b/src/Dependencies/Threading/ParallelExtensions.cs @@ -0,0 +1,43 @@ +// 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 enable + +#pragma warning disable CA1068 // CancellationToken parameters must come last + +using System.Collections.Generic; + +namespace System.Threading.Tasks; + +internal static partial class RoslynParallelExtensions +{ +#if NET // binary compatibility + public static Task ForEachAsync(IEnumerable source, CancellationToken cancellationToken, Func body) + => Parallel.ForEachAsync(source, cancellationToken, body); + + public static Task ForEachAsync(IEnumerable source, ParallelOptions parallelOptions, Func body) + => Parallel.ForEachAsync(source, parallelOptions, body); + + public static Task ForEachAsync(IAsyncEnumerable source, CancellationToken cancellationToken, Func body) + => Parallel.ForEachAsync(source, cancellationToken, body); + + public static Task ForEachAsync(IAsyncEnumerable source, ParallelOptions parallelOptions, Func body) + => Parallel.ForEachAsync(source, parallelOptions, body); +#else + extension(Parallel) + { + public static Task ForEachAsync(IEnumerable source, CancellationToken cancellationToken, Func body) + => NetFramework.ForEachAsync(source, cancellationToken, body); + + public static Task ForEachAsync(IEnumerable source, ParallelOptions parallelOptions, Func body) + => NetFramework.ForEachAsync(source, parallelOptions, body); + + public static Task ForEachAsync(IAsyncEnumerable source, CancellationToken cancellationToken, Func body) + => NetFramework.ForEachAsync(source, cancellationToken, body); + + public static Task ForEachAsync(IAsyncEnumerable source, ParallelOptions parallelOptions, Func body) + => NetFramework.ForEachAsync(source, parallelOptions, body); + } +#endif +} diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Utilities/ProducerConsumer.cs b/src/Dependencies/Threading/ProducerConsumer.cs similarity index 94% rename from src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Utilities/ProducerConsumer.cs rename to src/Dependencies/Threading/ProducerConsumer.cs index 82eb56d9089c..6ea0da9b20c4 100644 --- a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Utilities/ProducerConsumer.cs +++ b/src/Dependencies/Threading/ProducerConsumer.cs @@ -2,6 +2,8 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. +#nullable enable + using System; using System.Collections.Generic; using System.Collections.Immutable; @@ -9,31 +11,10 @@ using System.Threading.Channels; using System.Threading.Tasks; using Microsoft.CodeAnalysis.PooledObjects; -using Microsoft.CodeAnalysis.Shared.Extensions; using Microsoft.CodeAnalysis.Threading; +using Roslyn.Utilities; -namespace Microsoft.CodeAnalysis.Shared.Utilities; - -internal readonly record struct ProducerConsumerOptions -{ - /// - /// Used when the consumeItems routine will only pull items on a single thread (never concurrently). produceItems - /// can be called concurrently on many threads. - /// - public static readonly ProducerConsumerOptions SingleReaderOptions = new() { SingleReader = true }; - - /// - /// Used when the consumeItems routine will only pull items on a single thread (never concurrently). produceItems - /// can be called on a single thread as well (never concurrently). - /// - public static readonly ProducerConsumerOptions SingleReaderWriterOptions = new() { SingleReader = true, SingleWriter = true }; - - /// - public bool SingleWriter { get; init; } - - /// - public bool SingleReader { get; init; } -} +namespace Microsoft.CodeAnalysis.Threading; internal static class ProducerConsumer { @@ -248,7 +229,7 @@ private static Task RunParallelChannelAsync( // We're running in parallel, so we def have multiple writers ProducerConsumerOptions.SingleReaderOptions, produceItems: static (callback, args, cancellationToken) => - RoslynParallel.ForEachAsync( + Parallel.ForEachAsync( args.source, cancellationToken, async (source, cancellationToken) => @@ -310,7 +291,7 @@ public static IAsyncEnumerable RunParallelStreamAsync( { return RunAsync( static (callback, args, cancellationToken) => - RoslynParallel.ForEachAsync( + Parallel.ForEachAsync( args.source, cancellationToken, async (source, cancellationToken) => await args.produceItems( source, callback, args.args, cancellationToken).ConfigureAwait(false)), diff --git a/src/Dependencies/Threading/ProducerConsumerOptions.cs b/src/Dependencies/Threading/ProducerConsumerOptions.cs new file mode 100644 index 000000000000..99aa23ac6efe --- /dev/null +++ b/src/Dependencies/Threading/ProducerConsumerOptions.cs @@ -0,0 +1,34 @@ +// 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 enable + +using System.Threading.Channels; + +namespace Microsoft.CodeAnalysis.Threading; + +internal readonly record struct ProducerConsumerOptions +{ + /// + /// Used when the consumeItems routine will only pull items on a single thread (never concurrently). produceItems + /// can be called concurrently on many threads. + /// + public static readonly ProducerConsumerOptions SingleReaderOptions = new() { SingleReader = true }; + + /// + /// Used when the consumeItems routine will only pull items on a single thread (never concurrently). produceItems + /// can be called on a single thread as well (never concurrently). + /// + public static readonly ProducerConsumerOptions SingleReaderWriterOptions = new() { SingleReader = true, SingleWriter = true }; + +#if NET + /// +#endif + public bool SingleWriter { get; init; } + +#if NET + /// +#endif + public bool SingleReader { get; init; } +} diff --git a/src/EditorFeatures/CSharp/StringCopyPaste/StringCopyPasteHelpers.cs b/src/EditorFeatures/CSharp/StringCopyPaste/StringCopyPasteHelpers.cs index f2805572e35a..fdf6ae572836 100644 --- a/src/EditorFeatures/CSharp/StringCopyPaste/StringCopyPasteHelpers.cs +++ b/src/EditorFeatures/CSharp/StringCopyPaste/StringCopyPasteHelpers.cs @@ -7,12 +7,14 @@ using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Linq; +using Microsoft.CodeAnalysis.Collections; using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp.Syntax; using Microsoft.CodeAnalysis.Editor.Shared.Extensions; using Microsoft.CodeAnalysis.PooledObjects; using Microsoft.CodeAnalysis.Text; using Microsoft.CodeAnalysis.Text.Shared.Extensions; +using Microsoft.VisualStudio.Debugger.Contracts.EditAndContinue.VsdbgIntegration; using Microsoft.VisualStudio.Text; namespace Microsoft.CodeAnalysis.Editor.CSharp.StringCopyPaste; @@ -497,19 +499,39 @@ static bool WillEscapeAnyCharacters(bool isInterpolated, string value) string? commonIndentPrefix = null; var first = true; + using var allLines = TemporaryArray.Empty; + foreach (var change in textChanges) { var text = SourceText.From(change.NewText); foreach (var line in text.Lines) { - if (first) - { - first = false; - continue; - } - var nonWhitespaceIndex = GetFirstNonWhitespaceIndex(text, line); - if (nonWhitespaceIndex >= 0) + + // For the first line, we only want to consider its indentation if it *has* any. That's because + // people often copy by avoiding indentation on the first line and starting their selection on the + // first real construct. e.g.: + // + // [|Goo + // Bar + // Baz|] + // + // In this case, we don't want to say that there is no common indentation to trim since there is + // no indentation on the selection's first line. However, we do want to trim if the user selected + // whitespace a-la: + // + // [|Goo + // Bar + // Baz|] + // + // In this case, we really only want to trim the common whitespace of all three lines, not the whitespace + // of the second/third lines. If we do the latter, we'd end up with Goo and Bar being aligned, which + // doesn't match the original intent. + + var minimumStartColumn = first ? 1 : 0; + first = false; + + if (nonWhitespaceIndex >= minimumStartColumn) commonIndentPrefix = GetCommonIndentationPrefix(commonIndentPrefix, text, TextSpan.FromBounds(line.Start, nonWhitespaceIndex)); } } @@ -554,6 +576,11 @@ public static bool RawContentMustBeMultiLine(SourceText text, ImmutableArray spans) + { foreach (var span in spans) { for (var i = span.Start; i < span.End; i++) diff --git a/src/EditorFeatures/CSharp/StringCopyPaste/UnknownSourcePasteProcessor.cs b/src/EditorFeatures/CSharp/StringCopyPaste/UnknownSourcePasteProcessor.cs index 8e5611ff9494..e72ba8aeba5a 100644 --- a/src/EditorFeatures/CSharp/StringCopyPaste/UnknownSourcePasteProcessor.cs +++ b/src/EditorFeatures/CSharp/StringCopyPaste/UnknownSourcePasteProcessor.cs @@ -168,9 +168,15 @@ private void AdjustWhitespaceAndAddTextChangesForSingleLineRawStringLiteral(Arra if (mustBeMultiLine) edits.Add(new TextChange(new TextSpan(StringExpressionBeforePasteInfo.StartDelimiterSpan.End, 0), NewLine + IndentationWhitespace)); - SourceText? textOfCurrentChange = null; - var commonIndentationPrefix = GetCommonIndentationPrefix(Changes) ?? ""; + // Only if we're ending with a multi-line raw string do we want to consider the first line when determining + // the common indentation prefix to trim out. If we don't have a multi-line raw string, then that means we + // pasted a boring single-line string into a single-line raw string, and in that case, we don't want to touch + // the contents at all. + var commonIndentationPrefix = SpansContainsNewLine(TextAfterPaste, TextContentsSpansAfterPaste) + ? GetCommonIndentationPrefix(Changes) ?? "" + : ""; + SourceText? textOfCurrentChange = null; foreach (var change in Changes) { // Create a text object around the change text we're making. This is a very simple way to get diff --git a/src/EditorFeatures/CSharpTest/AddMissingImports/CSharpAddMissingImportsRefactoringProviderTests.cs b/src/EditorFeatures/CSharpTest/AddMissingImports/CSharpAddMissingImportsRefactoringProviderTests.cs index 93ceaedbf573..8eaa7aa5b169 100644 --- a/src/EditorFeatures/CSharpTest/AddMissingImports/CSharpAddMissingImportsRefactoringProviderTests.cs +++ b/src/EditorFeatures/CSharpTest/AddMissingImports/CSharpAddMissingImportsRefactoringProviderTests.cs @@ -64,7 +64,7 @@ private Task TestInRegularAndScriptAsync( { GenerationOptions.SeparateImportDirectiveGroups, separateImportDirectiveGroups }, { CSharpCodeStyleOptions.PreferredUsingDirectivePlacement, placeInsideNamespace ? InsideNamespaceOption : OutsideNamespaceOption }, }; - return TestInRegularAndScriptAsync(initialMarkup, expectedMarkup, options: options); + return TestInRegularAndScriptAsync(initialMarkup, expectedMarkup, new(options: options)); } [WpfFact] diff --git a/src/EditorFeatures/CSharpTest/AutomaticCompletion/AutomaticLineEnderTests.cs b/src/EditorFeatures/CSharpTest/AutomaticCompletion/AutomaticLineEnderTests.cs index 2cc2573ac233..80410311e65a 100644 --- a/src/EditorFeatures/CSharpTest/AutomaticCompletion/AutomaticLineEnderTests.cs +++ b/src/EditorFeatures/CSharpTest/AutomaticCompletion/AutomaticLineEnderTests.cs @@ -18,44 +18,35 @@ public sealed class AutomaticLineEnderTests : AbstractAutomaticLineEnderTests { [WpfFact] public void Creation() - { - Test(""" + => Test(""" $$ """, "$$"); - } [WpfFact] public void Usings() - { - Test(""" + => Test(""" using System; $$ """, @"using System$$"); - } [WpfFact] public void Namespace() - { - Test(""" + => Test(""" namespace {} $$ """, @"namespace {$$}"); - } [WpfFact] public void Class() - { - Test(""" + => Test(""" class {} $$ """, "class {$$}"); - } [WpfFact] public void Method() - { - Test(""" + => Test(""" class C { void Method() {$$} @@ -66,12 +57,10 @@ class C void Method() {$$} } """, assertNextHandlerInvoked: true); - } [WpfFact] public void Field() - { - Test(""" + => Test(""" class C { private readonly int i = 3; @@ -83,12 +72,10 @@ class C pri$$vate re$$adonly i$$nt i = 3$$ } """); - } [WpfFact] public void EventField() - { - Test(""" + => Test(""" class C { event System.EventHandler e = null; @@ -100,12 +87,10 @@ class C e$$vent System.Even$$tHandler e$$ = null$$ } """); - } [WpfFact] public void Field2() - { - Test(""" + => Test(""" class C { private readonly int i; @@ -117,12 +102,10 @@ class C private readonly int i$$ } """); - } [WpfFact] public void EventField2() - { - Test(""" + => Test(""" class C { event System.EventHandler e @@ -136,12 +119,10 @@ class C eve$$nt System.E$$ventHandler e$$ } """); - } [WpfFact] public void Field3() - { - Test(""" + => Test(""" class C { private readonly int @@ -153,12 +134,10 @@ class C private readonly int$$ } """); - } [WpfFact] public void EventField3() - { - Test(""" + => Test(""" class C { event System.EventHandler @@ -170,12 +149,10 @@ class C event System.EventHandler$$ } """); - } [WpfFact] public void EmbeddedStatement() - { - Test(""" + => Test(""" class C { void Method() @@ -195,12 +172,10 @@ void Method() } } """); - } [WpfFact] public void EmbeddedStatement1() - { - Test(""" + => Test(""" class C { void Method() @@ -220,12 +195,10 @@ void Method() } } """); - } [WpfFact] public void EmbeddedStatement2() - { - Test(""" + => Test(""" class C { void Method() @@ -245,12 +218,10 @@ void Method() } } """); - } [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/57323")] public void EmbeddedStatementFollowedByStatement() - { - Test(""" + => Test(""" class C { void Method() @@ -282,12 +253,10 @@ void Method() } } """); - } [WpfFact] public void Statement() - { - Test(""" + => Test(""" class C { void Method() @@ -305,12 +274,10 @@ int i$$ } } """); - } [WpfFact] public void Statement1() - { - Test(""" + => Test(""" class C { void Method() @@ -328,12 +295,10 @@ void Method() } } """); - } [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/3944")] public void ExpressionBodiedMethod() - { - Test(""" + => Test(""" class T { int M() => 1 + 2; @@ -345,12 +310,10 @@ class T int M() => 1 + 2$$ } """); - } [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/3944")] public void ExpressionBodiedOperator() - { - Test(""" + => Test(""" class Complex { int real; int imaginary; @@ -366,12 +329,10 @@ class Complex private Complex Add(int b) => null; } """); - } [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/3944")] public void ExpressionBodiedConversionOperator() - { - Test(""" + => Test(""" using System; public struct DBBool { @@ -401,12 +362,10 @@ public struct DBBool public static implicit operator DBBool(bool x) => x ? new DBBool(1) : dbFalse$$ } """); - } [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/3944")] public void ExpressionBodiedProperty() - { - Test(""" + => Test(""" class T { int P1 => 1 + 2; @@ -418,12 +377,10 @@ class T int P1 => 1 + 2$$ } """); - } [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/3944")] public void ExpressionBodiedIndexer() - { - Test(""" + => Test(""" using System; class SampleCollection { @@ -439,12 +396,10 @@ class SampleCollection public T this[int i] => i > 0 ? arr[i + 1] : arr[i + 2]$$ } """); - } [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/3944")] public void ExpressionBodiedMethodWithBlockBodiedAnonymousMethodExpression() - { - Test(""" + => Test(""" using System; class TestClass { @@ -464,12 +419,10 @@ Func Y() => delegate (int x) }$$ } """); - } [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/3944")] public void ExpressionBodiedMethodWithSingleLineBlockBodiedAnonymousMethodExpression() - { - Test(""" + => Test(""" using System; class TestClass { @@ -483,12 +436,10 @@ class TestClass Func Y() => delegate (int x) { return 9; }$$ } """); - } [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/3944")] public void ExpressionBodiedMethodWithBlockBodiedSimpleLambdaExpression() - { - Test(""" + => Test(""" using System; class TestClass { @@ -508,12 +459,10 @@ Func Y() => f => }$$ } """); - } [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/3944")] public void ExpressionBodiedMethodWithExpressionBodiedSimpleLambdaExpression() - { - Test(""" + => Test(""" using System; class TestClass { @@ -527,12 +476,10 @@ class TestClass Func Y() => f => f * 9$$ } """); - } [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/3944")] public void ExpressionBodiedMethodWithBlockBodiedAnonymousMethodExpressionInMethodArgs() - { - Test(""" + => Test(""" using System; class TestClass { @@ -556,12 +503,10 @@ class TestClass private int Method1(Func p) => null; } """); - } [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/3944")] public void Format_SimpleExpressionBodiedMember() - { - Test(""" + => Test(""" class T { int M() => 1 + 2; @@ -573,12 +518,10 @@ class T int M() => 1 + 2$$ } """); - } [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/3944")] public void Format_ExpressionBodiedMemberWithSingleLineBlock() - { - Test(""" + => Test(""" using System; class TestClass { @@ -592,12 +535,10 @@ class TestClass Func Y () => delegate(int x) { return 9 ; }$$ } """); - } [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/3944")] public void Format_ExpressionBodiedMemberWithMultiLineBlock() - { - Test(""" + => Test(""" using System; class TestClass { @@ -617,12 +558,10 @@ Func Y() => delegate(int x) }$$ } """); - } [WpfFact] public void Format_Statement() - { - Test(""" + => Test(""" class C { void Method() @@ -640,21 +579,17 @@ void Method() } } """); - } [WpfFact] public void Format_Using() - { - Test(""" + => Test(""" using System.Linq; $$ """, @" using System . Linq $$"); - } [WpfFact] public void Format_Using2() - { - Test(""" + => Test(""" using System.Linq; $$ @@ -662,12 +597,10 @@ public void Format_Using2() using System . Linq $$ """); - } [WpfFact] public void Format_Field() - { - Test(""" + => Test(""" class C { int i = 1; @@ -679,12 +612,10 @@ class C int i = 1 $$ } """); - } [WpfFact] public void Statement_Trivia() - { - Test(""" + => Test(""" class C { void goo() @@ -702,12 +633,10 @@ void goo() } } """); - } [WpfFact] public void TrailingText_Negative() - { - Test(""" + => Test(""" class C { event System.EventHandler e = null int i = 2; @@ -719,12 +648,10 @@ class C event System.EventHandler e = null$$ int i = 2; } """); - } [WpfFact] public void CompletionSetUp() - { - Test(""" + => Test(""" class Program { object goo(object o) @@ -742,12 +669,10 @@ object goo(object o) } } """, completionActive: true); - } [WpfFact, WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/530352")] public void EmbeddedStatement3() - { - Test(""" + => Test(""" class Program { void Method() @@ -767,12 +692,10 @@ void Method() } } """); - } [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/66102")] public void EmbeddedStatement4() - { - Test(""" + => Test(""" class Program { void Method() @@ -792,12 +715,10 @@ void Method() } } """); - } [WpfFact, WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/530716")] public void DoNotAssertOnMultilineToken() - { - Test("""" + => Test("""" interface I { void M(string s = @""" @@ -809,12 +730,10 @@ interface I void M(string s = @"""$$ } """"); - } [WpfFact, WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/530718")] public void AutomaticLineFormat() - { - Test(""" + => Test(""" class C { public string P { set; get; } @@ -826,12 +745,10 @@ class C public string P {set;get;$$} } """); - } [WpfFact] public void NotAfterExisitingSemicolon() - { - Test(""" + => Test(""" class TestClass { private int i; @@ -843,12 +760,10 @@ class TestClass private int i;$$ } """); - } [WpfFact] public void NotAfterCloseBraceInMethod() - { - Test(""" + => Test(""" class TestClass { void Test() { } @@ -860,12 +775,10 @@ class TestClass void Test() { }$$ } """); - } [WpfFact] public void NotAfterCloseBraceInStatement() - { - Test(""" + => Test(""" class TestClass { void Test() @@ -883,12 +796,10 @@ void Test() } } """); - } [WpfFact] public void NotAfterAutoPropertyAccessor() - { - Test(""" + => Test(""" class TestClass { public int A { get; set } @@ -900,12 +811,10 @@ class TestClass public int A { get; set$$ } } """); - } [WpfFact] public void NotAfterAutoPropertyDeclaration() - { - Test(""" + => Test(""" class TestClass { public int A { get; set; } @@ -917,12 +826,10 @@ class TestClass public int A { get; set; }$$ } """); - } [WpfFact, WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/150480")] public void DelegatedInEmptyBlock() - { - Test(""" + => Test(""" class TestClass { void Method() @@ -939,12 +846,10 @@ void Method() } } """, assertNextHandlerInvoked: true); - } [WpfFact, WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/150480")] public void DelegatedInEmptyBlock2() - { - Test(""" + => Test(""" class TestClass { void Method() @@ -961,12 +866,10 @@ void Method() } } """, assertNextHandlerInvoked: true); - } [WpfFact, WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/150480")] public void NotDelegatedOutsideEmptyBlock() - { - Test(""" + => Test(""" class TestClass { void Method() @@ -984,12 +887,10 @@ void Method() } } """); - } [WpfFact, WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/150480")] public void NotDelegatedAfterOpenBraceAndMissingCloseBrace() - { - Test(""" + => Test(""" class TestClass { void Method() @@ -1007,12 +908,10 @@ void Method() } } """); - } [WpfFact, WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/150480")] public void NotDelegatedInNonEmptyBlock() - { - Test(""" + => Test(""" class TestClass { void Method() @@ -1030,12 +929,10 @@ void Method() } } """); - } [WpfFact, WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/150480")] public void NotDelegatedAfterOpenBraceInAnonymousObjectCreationExpression() - { - Test(""" + => Test(""" class TestClass { void Method() @@ -1053,12 +950,10 @@ void Method() } } """); - } [WpfFact, WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/150480")] public void NotDelegatedAfterOpenBraceObjectCreationExpression() - { - Test(""" + => Test(""" class TestClass { void Method() @@ -1076,12 +971,10 @@ void Method() } } """); - } [WpfFact] public void TestMultipleNamespace() - { - Test($$""" + => Test($$""" namespace Bar2 { $$ @@ -1095,7 +988,6 @@ namespace Bar { } """); - } [WpfTheory] [InlineData("namespace")] @@ -1105,8 +997,7 @@ namespace Bar [InlineData("enum")] [InlineData("interface")] public void TestEmptyBaseTypeDeclarationAndNamespace(string typeKeyword) - { - Test($$""" + => Test($$""" public {{typeKeyword}} Bar { $$ @@ -1114,7 +1005,6 @@ public void TestEmptyBaseTypeDeclarationAndNamespace(string typeKeyword) """, $""" pu$$blic {typeKeyword} $$Bar$$ """); - } [WpfTheory] [InlineData("class")] @@ -1123,8 +1013,7 @@ public void TestEmptyBaseTypeDeclarationAndNamespace(string typeKeyword) [InlineData("enum")] [InlineData("interface")] public void TestMultipleBaseTypeDeclaration(string typeKeyword) - { - Test($$""" + => Test($$""" public {{typeKeyword}} Bar2 { $$ @@ -1139,12 +1028,10 @@ public void TestMultipleBaseTypeDeclaration(string typeKeyword) { } """); - } [WpfFact] public void TestNestedTypeDeclaration() - { - Test(""" + => Test(""" public class Bar1 { public class Bar2 @@ -1159,12 +1046,10 @@ public class Bar1 pu$$blic cla$$ss B$$ar2$$ } """); - } [WpfFact] public void TestNestedNamespace() - { - Test(""" + => Test(""" namespace Bar1 { namespace Bar2 @@ -1179,7 +1064,6 @@ namespace Bar1 namespa$$ce $$B$$ar2$$ } """); - } [WpfTheory] [InlineData("namespace")] @@ -1189,14 +1073,12 @@ namespace Bar1 [InlineData("enum")] [InlineData("interface")] public void TestBaseTypeDeclarationAndNamespaceWithOpenBrace(string typeKeyword) - { - Test($$""" + => Test($$""" public {{typeKeyword}} Bar { $$ """, $$""" pub$$lic {{typeKeyword}} B$$ar {$$ """); - } [WpfTheory] [InlineData("namespace")] @@ -1206,18 +1088,15 @@ public void TestBaseTypeDeclarationAndNamespaceWithOpenBrace(string typeKeyword) [InlineData("enum")] [InlineData("interface")] public void TestValidTypeDeclarationAndNamespace(string typeKeyword) - { - Test($$""" + => Test($$""" public {{typeKeyword}} Bar {} $$ """, $@"public {typeKeyword}$$ Ba$$r {{}}$$"); - } [WpfFact] public void TestMethod() - { - Test(""" + => Test(""" public class Bar { void Main() @@ -1231,12 +1110,10 @@ public class Bar v$$oid Ma$$in($$)$$ } """); - } [WpfFact] public void TestConstructor() - { - Test(""" + => Test(""" public class Bar { void Bar() @@ -1250,12 +1127,10 @@ public class Bar v$$oid Ba$$r($$)$$ } """); - } [WpfFact] public void TestValidMethodInInterface() - { - Test(""" + => Test(""" public interface Bar { void Main(); @@ -1267,12 +1142,10 @@ public interface Bar v$$oid Mai$$n($$)$$; } """); - } [WpfFact] public void TestMissingSemicolonMethodInInterface() - { - Test(""" + => Test(""" public interface Bar { void Main() @@ -1284,12 +1157,10 @@ public interface Bar v$$oid Mai$$n($$)$$ } """); - } [WpfFact] public void TestValidLocalFunction() - { - Test(""" + => Test(""" public class Bar { void Main() @@ -1311,12 +1182,10 @@ void Main() } } """); - } [WpfFact] public void TestLocalFunction() - { - Test(""" + => Test(""" public class Bar { void Main() @@ -1336,12 +1205,10 @@ void Main() } } """); - } [WpfFact] public void TestIndexerAsLastElementInClass() - { - Test(""" + => Test(""" public class Bar { public int this[int i] @@ -1355,12 +1222,10 @@ public class Bar p$$ublic in$$t thi$$s[in$$t i]$$ } """); - } [WpfFact] public void TestIndexerNotAsLastElementInClass() - { - Test(""" + => Test(""" public class Bar { public int this[int i] @@ -1376,12 +1241,10 @@ public class Bar void Main() {} } """); - } [WpfFact] public void TestValidIndexer() - { - Test(""" + => Test(""" public class Bar { public int this[int i] @@ -1397,7 +1260,6 @@ public class Bar } } """); - } [WpfFact] public void TestGetAccessorOfProperty() @@ -1473,8 +1335,7 @@ public int P [WpfFact] public void TestGetAccessorOfIndexer() - { - Test(""" + => Test(""" public class Bar { public int this[int i] @@ -1494,12 +1355,10 @@ public int this[int i] } } """); - } [WpfFact] public void TestValidGetAccessorOfIndexer() - { - Test(""" + => Test(""" public class Bar { public int this[int i] @@ -1523,12 +1382,10 @@ public int this[int i] } } """); - } [WpfFact] public void TestNonEmptyGetAccessor() - { - Test(""" + => Test(""" public Class Bar { public int P @@ -1559,12 +1416,10 @@ public int P } } """); - } [WpfFact] public void TestNonEmptySetAccessor() - { - Test(""" + => Test(""" public Class Bar { public int P @@ -1595,12 +1450,10 @@ public int P } } """); - } [WpfFact] public void TestSetAccessorOfIndexer() - { - Test(""" + => Test(""" public class Bar { public int this[int i] @@ -1622,12 +1475,10 @@ public int this[int i] } } """); - } [WpfFact] public void TestValidSetAccessorOfIndexer() - { - Test(""" + => Test(""" public class Bar { public int this[int i] @@ -1653,12 +1504,10 @@ public int this[int i] } } """); - } [WpfFact] public void TestAddAccessorInEventDeclaration() - { - Test(""" + => Test(""" using System; public class Bar { @@ -1682,12 +1531,10 @@ public event EventHandler e } } """); - } [WpfFact] public void TestValidAddAccessorInEventDeclaration() - { - Test(""" + => Test(""" using System; public class Bar { @@ -1715,12 +1562,10 @@ public event EventHandler e } } """); - } [WpfFact] public void TestRemoveAccessor() - { - Test(""" + => Test(""" using System; public class Bar { @@ -1744,12 +1589,10 @@ public event EventHandler e } } """); - } [WpfFact] public void TestValidRemoveAccessor() - { - Test(""" + => Test(""" using System; public class Bar { @@ -1777,7 +1620,6 @@ public event EventHandler e } } """); - } [WpfFact] public void TestField() @@ -1808,8 +1650,7 @@ public class Bar [WpfFact] public void TestReadonlyField() - { - Test(""" + => Test(""" public class Bar { public readonly int iii; @@ -1821,12 +1662,10 @@ public class Bar p$$ublic reado$$nly i$$nt i$$ii$$ } """); - } [WpfFact] public void TestNonEmptyProperty() - { - Test(""" + => Test(""" public class Bar { public int Foo @@ -1844,12 +1683,10 @@ public int Foo } } """); - } [WpfFact] public void TestMultipleFields() - { - Test(""" + => Test(""" public class Bar { public int apple, banana; @@ -1861,12 +1698,10 @@ public class Bar p$$ublic i$$nt ap$$ple$$, ba$$nana;$$ } """); - } [WpfFact] public void TestMultipleEvents() - { - Test(""" + => Test(""" using System; public class Bar { @@ -1880,7 +1715,6 @@ public class Bar p$$ublic event EventHandler ap$$ple$$, ba$$nana$$;$$ } """); - } [WpfFact] public void TestEvent() @@ -1914,8 +1748,7 @@ public class Bar [WpfFact] public void TestNonEmptyEvent() - { - Test(""" + => Test(""" using System; public class Bar { @@ -1935,7 +1768,6 @@ public event EventHandler Foo } } """); - } [WpfFact] public void TestObjectCreationExpressionWithParenthesis() @@ -2206,8 +2038,7 @@ public class Foo [WpfFact] public void TestObjectCreationExpressionWithNonEmptyInitializer() - { - Test( + => Test( """ public class Bar { @@ -2238,12 +2069,9 @@ public class Foo } """); - } - [WpfFact] public void TestArrayInitializer1() - { - Test( + => Test( """ using System.Collections.Generic; public class Bar @@ -2265,12 +2093,10 @@ public void M() } } """); - } [WpfFact] public void TestArrayInitializer2() - { - Test( + => Test( """ using System.Collections.Generic; public class Bar @@ -2292,12 +2118,10 @@ public void M() } } """); - } [WpfFact] public void TestCollectionInitializerWithNonEmptyInitializer() - { - Test( + => Test( """ using System.Collections.Generic; public class Bar @@ -2319,12 +2143,10 @@ public void M() } } """); - } [WpfFact] public void TestCollectionExpression() - { - Test( + => Test( """ using System.Collections.Generic; public class Bar @@ -2346,12 +2168,10 @@ public void M() } } """); - } [WpfFact] public void TestIfStatementWithInnerStatement() - { - Test(""" + => Test(""" public class Bar { public void Main(bool x) @@ -2373,12 +2193,10 @@ public void Main(bool x) } } """); - } [WpfFact] public void TestIfStatementWithFollowingElseClause() - { - Test(""" + => Test(""" public class Bar { public void Main(bool x) @@ -2402,12 +2220,10 @@ public void Main(bool x) } } """); - } [WpfFact] public void TestIfStatementWithoutStatement() - { - Test(""" + => Test(""" public class Bar { public void Main(bool x) @@ -2427,12 +2243,10 @@ public void Main(bool x) } } """); - } [WpfFact] public void TestNestIfStatementWithInnerStatement() - { - Test(""" + => Test(""" public class Bar { public void Main(int x) @@ -2460,12 +2274,10 @@ public void Main(int x) } } """); - } [WpfFact] public void TestNestIfStatementWithoutInnerStatement() - { - Test(""" + => Test(""" public class Bar { public void Main(int x) @@ -2491,12 +2303,10 @@ public void Main(int x) } } """); - } [WpfFact] public void TestNestedElseIfStatementWithInnerStatement() - { - Test(""" + => Test(""" public class Bar { public void Fo(int i) @@ -2532,12 +2342,10 @@ public void Fo(int i) } } """); - } [WpfFact] public void TestNestIfElseStatementWithBlockWithInnerStatement() - { - Test(""" + => Test(""" public class Bar { public void Main(int x) @@ -2575,12 +2383,10 @@ public void Main(int x) } } """); - } [WpfFact] public void TestEmptyDoStatement() - { - Test(""" + => Test(""" public class Bar { public void Main() @@ -2600,12 +2406,10 @@ public void Main() } } """); - } [WpfFact] public void TestDoStatementWithInnerStatement() - { - Test(""" + => Test(""" public class Bar { public void Main() @@ -2627,12 +2431,10 @@ public void Main() } } """); - } [WpfFact] public void TestDoStatementWithWhileClause() - { - Test(""" + => Test(""" public class Bar { public void Main() @@ -2656,12 +2458,10 @@ public void Main() } } """); - } [WpfFact] public void TestSingleElseStatement() - { - Test(""" + => Test(""" public class Bar { public void Fo() @@ -2687,12 +2487,10 @@ public void Fo() } } """); - } [WpfFact] public void TestElseStatementWithInnerStatement() - { - Test(""" + => Test(""" public class Bar { public void Fo() @@ -2720,12 +2518,10 @@ public void Fo() } } """); - } [WpfFact] public void TestElseIfStatement() - { - Test(""" + => Test(""" public class Bar { public void Fo() @@ -2751,12 +2547,10 @@ public void Fo() } } """); - } [WpfFact] public void TestElseIfInTheMiddleWithInnerStatement() - { - Test(""" + => Test(""" public class Bar { public void Fo() @@ -2790,12 +2584,10 @@ public void Fo() } } """); - } [WpfFact] public void TestElseClauseInNestedIfStatement() - { - Test(""" + => Test(""" public class Bar { public void Fo(int i) @@ -2827,12 +2619,10 @@ public void Fo(int i) } } """); - } [WpfFact] public void TestForStatementWithoutStatement() - { - Test(""" + => Test(""" public class Bar { public void Fo() @@ -2852,12 +2642,10 @@ public void Fo() } } """); - } [WpfFact] public void TestForStatementWithInnerStatement() - { - Test(""" + => Test(""" public class Bar { public void Fo() @@ -2879,12 +2667,10 @@ public void Fo() } } """); - } [WpfFact] public void TestForEachStatementWithoutInnerStatement() - { - Test(""" + => Test(""" public class Bar { public void Fo() @@ -2906,12 +2692,10 @@ public void Fo() } } """); - } [WpfFact] public void TestLockStatementWithoutInnerStatement() - { - Test(""" + => Test(""" public class Bar { object o = new object(); @@ -2933,12 +2717,10 @@ public void Fo() } } """); - } [WpfFact] public void TestLockStatementWithInnerStatement() - { - Test(""" + => Test(""" public class Bar { object o = new object(); @@ -2962,12 +2744,10 @@ public void Fo() } } """); - } [WpfFact] public void TestUsingStatementWithoutInnerStatement() - { - Test(""" + => Test(""" using System; public class Bar { @@ -2999,12 +2779,10 @@ public void Dispose() {} } """); - } [WpfFact] public void TestUsingStatementWithInnerStatement() - { - Test(""" + => Test(""" using System; public class Bar { @@ -3038,12 +2816,10 @@ public void Dispose() {} } """); - } [WpfFact] public void TestUsingInLocalDeclarationStatement() - { - Test(""" + => Test(""" using System; public class Bar { @@ -3073,12 +2849,10 @@ public void Dispose() {} } """); - } [WpfFact] public void TestWhileStatementWithoutInnerStatement() - { - Test(""" + => Test(""" public class Bar { public void Fo() @@ -3098,12 +2872,10 @@ public void Fo() } } """); - } [WpfFact] public void TestWhileStatementWithInnerStatement() - { - Test(""" + => Test(""" public class Bar { public void Fo() @@ -3125,12 +2897,10 @@ public void Fo() } } """); - } [WpfFact] public void TestSwitchExpression1() - { - Test(""" + => Test(""" public class Bar { public void Goo(int c) @@ -3152,12 +2922,9 @@ public void Goo(int c) } """); - } - [WpfFact] public void TestSwitchExpression2() - { - Test(""" + => Test(""" public class Bar { public void Goo(int c) @@ -3179,8 +2946,6 @@ public void Goo(int c) } """); - } - [WpfFact] public void TestSwitchStatementWithOnlyOpenParenthesis() { @@ -3211,8 +2976,7 @@ public void TT() [WpfFact] public void TestSwitchStatement() - { - Test(""" + => Test(""" public class bar { public void TT() @@ -3234,12 +2998,10 @@ public void TT() } } """); - } [WpfFact] public void TestValidSwitchStatement() - { - Test(""" + => Test(""" public class bar { public void TT() @@ -3263,12 +3025,10 @@ public void TT() } } """); - } [WpfFact] public void TestValidTryStatement() - { - Test(""" + => Test(""" public class bar { public void TT() @@ -3290,12 +3050,10 @@ public void TT() } } """); - } [WpfFact] public void TestTryStatement() - { - Test(""" + => Test(""" public class bar { public void TT() @@ -3315,12 +3073,10 @@ public void TT() } } """); - } [WpfFact] public void TestValidCatchClause() - { - Test(""" + => Test(""" public class Bar { public void TT() @@ -3348,12 +3104,10 @@ public void TT() } } """); - } [WpfFact] public void TestCatchClauseWithException() - { - Test(""" + => Test(""" public class Bar { public void TT() @@ -3379,12 +3133,10 @@ public void TT() } } """); - } [WpfFact] public void TestSingleCatchClause() - { - Test(""" + => Test(""" public class bar { public void TT() @@ -3410,12 +3162,10 @@ public void TT() } } """); - } [WpfFact] public void TestCatchClauseWithWhenClause() - { - Test(""" + => Test(""" public class bar { public void TT() @@ -3441,12 +3191,10 @@ public void TT() } } """); - } [WpfFact] public void TestFinallyClause() - { - Test(""" + => Test(""" public class Bar { public void Bar2() @@ -3478,12 +3226,10 @@ public void Bar2() } } """); - } [WpfFact] public void TestValidFinallyClause() - { - Test(""" + => Test(""" public class Bar { public void Bar2() @@ -3517,12 +3263,10 @@ public void Bar2() } } """); - } [WpfFact] public void TestObjectCreationExpressionWithMissingType() - { - Test(""" + => Test(""" public class Bar { public void Bar2() @@ -3543,12 +3287,10 @@ public void Bar2() } } """); - } [WpfFact] public void TestRemoveInitializerForImplicitObjectCreationExpression() - { - Test(""" + => Test(""" public class Bar { public void Bar2() @@ -3570,14 +3312,12 @@ public void Bar2() } } """); - } [WpfTheory] [InlineData("checked")] [InlineData("unchecked")] public void TestCheckedStatement(string keywordToken) - { - Test($$""" + => Test($$""" public class Bar { public void Bar2() @@ -3598,14 +3338,12 @@ public void Bar2() } } """); - } [WpfTheory] [InlineData("checked")] [InlineData("unchecked")] public void TextCheckedExpression(string keywordToken) - { - Test($$""" + => Test($$""" public class Bar { public void Bar2() @@ -3624,12 +3362,10 @@ public void Bar2() } } """); - } [WpfFact] public void TestConvertFieldToPropertyWithAttributeAndComment() - { - Test(""" + => Test(""" public class Bar { public int Property @@ -3654,12 +3390,10 @@ public int Property$$ public void Method() { } } """); - } [WpfFact] public void TestConvertEventFieldToPropertyWithAttributeAndComment() - { - Test(""" + => Test(""" public class Bar { public event EventHandler MyEvent @@ -3684,7 +3418,6 @@ public event EventHandler MyEvent$$ public void Method() { } } """); - } protected override string Language => LanguageNames.CSharp; diff --git a/src/EditorFeatures/CSharpTest/BlockCommentEditing/BlockCommentEditingTests.cs b/src/EditorFeatures/CSharpTest/BlockCommentEditing/BlockCommentEditingTests.cs index eb7ea406f9f9..cb0121ff3490 100644 --- a/src/EditorFeatures/CSharpTest/BlockCommentEditing/BlockCommentEditingTests.cs +++ b/src/EditorFeatures/CSharpTest/BlockCommentEditing/BlockCommentEditingTests.cs @@ -21,112 +21,91 @@ public sealed class BlockCommentEditingTests : AbstractTypingCommandHandlerTest< { [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/11057")] public void EdgeCase0() - { - Verify(@" + => Verify(@" $$/**/ ", @" $$/**/ "); - } [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/11057")] public void EdgeCase1() - { - Verify(@" + => Verify(@" /**/$$ ", @" /**/ $$ "); - } [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/11056")] public void EdgeCase2() - { - Verify(@" + => Verify(@" $$/* */ ", @" $$/* */ "); - } [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/11056")] public void EdgeCase3() - { - Verify(@" + => Verify(@" /* */$$ ", @" /* */ $$ "); - } [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/16128")] public void EofCase0() - { - Verify(@" + => Verify(@" /* */$$", @" /* */ $$"); - } [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/16128")] public void EofCase1() - { - Verify(@" + => Verify(@" /*$$", @" /* * $$"); - } [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/16128")] public void EofCase2() - { - Verify(@" + => Verify(@" /***$$", @" /*** * $$"); - } [WpfFact] public void InsertOnStartLine0() - { - Verify(@" + => Verify(@" /*$$ ", @" /* * $$ "); - } [WpfFact] public void InsertOnStartLine1() - { - Verify(@" + => Verify(@" /*$$*/ ", @" /* $$*/ "); - } [WpfFact] public void InsertOnStartLine2() - { - Verify(@" + => Verify(@" /*$$ */ ", @" /* * $$*/ "); - } [WpfFact] public void InsertOnStartLine3() - { - Verify(@" + => Verify(@" /* $$ 1. */ ", @" @@ -134,12 +113,10 @@ public void InsertOnStartLine3() * $$1. */ "); - } [WpfFact] public void InsertOnStartLine4() - { - Verify(@" + => Verify(@" /* 1.$$ */ ", @" @@ -147,45 +124,37 @@ public void InsertOnStartLine4() * $$ */ "); - } [WpfFact] public void InsertOnStartLine5() - { - Verify(@" + => Verify(@" /********$$ ", @" /******** * $$ "); - } [WpfFact] public void InsertOnStartLine6() - { - Verify(@" + => Verify(@" /**$$ ", @" /** * $$ "); - } [WpfFact] public void InsertOnStartLine7() - { - Verify(@" + => Verify(@" /* $$ ", @" /* * $$ "); - } [WpfFact] public void NotInsertOnStartLine0() - { - Verify(@" + => Verify(@" /$$* */ ", @" @@ -193,12 +162,10 @@ public void NotInsertOnStartLine0() $$* */ "); - } [WpfFact] public void InsertOnMiddleLine0() - { - Verify(@" + => Verify(@" /* *$$ ", @" @@ -206,12 +173,10 @@ public void InsertOnMiddleLine0() * *$$ "); - } [WpfFact] public void InsertOnMiddleLine1() - { - Verify(@" + => Verify(@" /* *$$*/ ", @" @@ -219,12 +184,10 @@ public void InsertOnMiddleLine1() * $$*/ "); - } [WpfFact] public void InsertOnMiddleLine2() - { - Verify(@" + => Verify(@" /* *$$ */ ", @" @@ -232,12 +195,10 @@ public void InsertOnMiddleLine2() * *$$*/ "); - } [WpfFact] public void InsertOnMiddleLine3() - { - Verify(@" + => Verify(@" /* * $$ 1. */ @@ -247,12 +208,10 @@ public void InsertOnMiddleLine3() * $$1. */ "); - } [WpfFact] public void InsertOnMiddleLine4() - { - Verify(@" + => Verify(@" /* * 1.$$ */ @@ -262,12 +221,10 @@ public void InsertOnMiddleLine4() * $$ */ "); - } [WpfFact] public void InsertOnMiddleLine5() - { - Verify(@" + => Verify(@" /* * 1. * $$ @@ -279,12 +236,10 @@ public void InsertOnMiddleLine5() * $$ */ "); - } [WpfFact] public void InsertOnMiddleLine6() - { - Verify(@" + => Verify(@" /* $$ * */ @@ -294,12 +249,10 @@ public void InsertOnMiddleLine6() $$* */ "); - } [WpfFact] public void InsertOnMiddleLine7() - { - Verify(@" + => Verify(@" /* *************$$ */ @@ -309,12 +262,10 @@ public void InsertOnMiddleLine7() *$$ */ "); - } [WpfFact] public void InsertOnMiddleLine8() - { - Verify(@" + => Verify(@" /** *$$ */ @@ -324,12 +275,10 @@ public void InsertOnMiddleLine8() *$$ */ "); - } [WpfFact] public void InsertOnMiddleLine9() - { - Verify(@" + => Verify(@" /** *$$ ", @" @@ -337,12 +286,10 @@ public void InsertOnMiddleLine9() * *$$ "); - } [WpfFact] public void InsertOnEndLine0() - { - Verify(@" + => Verify(@" /* *$$/ ", @" @@ -350,12 +297,10 @@ public void InsertOnEndLine0() * *$$/ "); - } [WpfFact] public void InsertOnEndLine1() - { - Verify(@" + => Verify(@" /** *$$/ ", @" @@ -363,12 +308,10 @@ public void InsertOnEndLine1() * *$$/ "); - } [WpfFact] public void InsertOnEndLine2() - { - Verify(@" + => Verify(@" /** * *$$/ @@ -378,12 +321,10 @@ public void InsertOnEndLine2() * *$$/ "); - } [WpfFact] public void InsertOnEndLine3() - { - Verify(@" + => Verify(@" /* $$ */ ", @" @@ -391,12 +332,10 @@ public void InsertOnEndLine3() $$*/ "); - } [WpfFact] public void InsertOnEndLine4() - { - Verify(@" + => Verify(@" /* $$*/ ", @" @@ -404,12 +343,10 @@ public void InsertOnEndLine4() $$*/ "); - } [WpfFact] public void NotInsertInVerbatimString0() - { - Verify(@" + => Verify(@" var code = @"" /*$$ ""; @@ -419,12 +356,10 @@ public void NotInsertInVerbatimString0() $$ ""; "); - } [WpfFact] public void NotInsertInVerbatimString1() - { - Verify(@" + => Verify(@" var code = @"" /* *$$ @@ -436,63 +371,51 @@ public void NotInsertInVerbatimString1() $$ ""; "); - } [WpfFact] public void BoundCheckInsertOnStartLine0() - { - Verify(@" + => Verify(@" /$$*", @" / $$*"); - } [WpfFact] public void BoundCheckInsertOnStartLine1() - { - Verify(@" + => Verify(@" /*$$ ", @" /* * $$"); - } [WpfFact] public void BoundCheckInsertOnMiddleLine() - { - Verify(@" + => Verify(@" /* *$$ ", @" /* * *$$"); - } [WpfFact] public void BoundCheckInsertOnEndLine() - { - Verify(@" + => Verify(@" /* *$$/", @" /* * *$$/"); - } [WpfFact] public void InsertOnStartLine2_Tab() - { - VerifyTabs(@" + => VerifyTabs(@" /*$$*/ ", @" /* * $$*/ "); - } [WpfFact] public void InsertOnStartLine3_Tab() - { - VerifyTabs(@" + => VerifyTabs(@" /*$$1. */ ", @" @@ -500,12 +423,10 @@ public void InsertOnStartLine3_Tab() *$$1. */ "); - } [WpfFact] public void InsertOnStartLine4_Tab() - { - VerifyTabs(@" + => VerifyTabs(@" /* 1.$$ */ ", @" @@ -513,23 +434,19 @@ public void InsertOnStartLine4_Tab() * $$ */ "); - } [WpfFact] public void InsertOnStartLine6_Tab() - { - VerifyTabs(@" + => VerifyTabs(@" /*$$ ", @" /* *$$ "); - } [WpfFact] public void InsertOnMiddleLine2_Tab() - { - VerifyTabs(@" + => VerifyTabs(@" /* *$$*/ ", @" @@ -537,12 +454,10 @@ public void InsertOnMiddleLine2_Tab() * *$$*/ "); - } [WpfFact] public void InsertOnMiddleLine3_Tab() - { - VerifyTabs(@" + => VerifyTabs(@" /* * $$1. */ @@ -552,12 +467,10 @@ public void InsertOnMiddleLine3_Tab() * $$1. */ "); - } [WpfFact] public void InsertOnMiddleLine4_Tab() - { - VerifyTabs(@" + => VerifyTabs(@" /* * 1.$$ */ @@ -567,12 +480,10 @@ public void InsertOnMiddleLine4_Tab() * $$ */ "); - } [WpfFact] public void InsertOnMiddleLine5_Tab() - { - VerifyTabs(@" + => VerifyTabs(@" /* * 1. * $$ @@ -584,12 +495,10 @@ public void InsertOnMiddleLine5_Tab() * $$ */ "); - } [WpfFact] public void InLanguageConstructTrailingTrivia() - { - Verify(@" + => Verify(@" class C { int i; /*$$ @@ -601,12 +510,10 @@ class C * $$ } "); - } [WpfFact] public void InLanguageConstructTrailingTrivia_Tabs() - { - VerifyTabs(@" + => VerifyTabs(@" class C { int i; /*$$ @@ -618,7 +525,6 @@ class C * $$ } "); - } protected override EditorTestWorkspace CreateTestWorkspace(string initialMarkup) => EditorTestWorkspace.CreateCSharp(initialMarkup); diff --git a/src/EditorFeatures/CSharpTest/BlockCommentEditing/CloseBlockCommentTests.cs b/src/EditorFeatures/CSharpTest/BlockCommentEditing/CloseBlockCommentTests.cs index 562945aaaefd..92fcd6a93bb4 100644 --- a/src/EditorFeatures/CSharpTest/BlockCommentEditing/CloseBlockCommentTests.cs +++ b/src/EditorFeatures/CSharpTest/BlockCommentEditing/CloseBlockCommentTests.cs @@ -22,8 +22,7 @@ public sealed class CloseBlockCommentTests : AbstractTypingCommandHandlerTest Verify(""" /* * *$$ @@ -32,12 +31,10 @@ public void ClosedRegularlyAfterAsterisk() * */$$ """); - } [WpfFact] public void ClosedAfterAsteriskSpace1() - { - Verify(""" + => Verify(""" /* * * $$ @@ -46,44 +43,36 @@ public void ClosedAfterAsteriskSpace1() * */$$ """); - } [WpfFact] public void ClosedAfterAsteriskSpace2() - { - Verify(""" + => Verify(""" /* * $$ """, """ /* */$$ """); - } [WpfFact] public void NotClosedAfterSlashAsteriskSpace() - { - Verify(""" + => Verify(""" /* $$ """, """ /* /$$ """); - } [WpfFact] public void NotClosedAfterSlashDoubleAsteriskSpace() - { - Verify(""" + => Verify(""" /** $$ """, """ /** /$$ """); - } [WpfFact] public void NotClosedAfterSpaceWithoutAsterisk() - { - Verify(""" + => Verify(""" /* * $$ @@ -92,12 +81,10 @@ public void NotClosedAfterSpaceWithoutAsterisk() * /$$ """); - } [WpfFact] public void NotClosedAfterAsteriskSpaceWithNonWhitespaceBeforeAsterisk1() - { - Verify(""" + => Verify(""" /* * ** $$ @@ -106,12 +93,10 @@ public void NotClosedAfterAsteriskSpaceWithNonWhitespaceBeforeAsterisk1() * ** /$$ """); - } [WpfFact] public void NotClosedAfterAsteriskSpaceWithNonWhitespaceBeforeAsterisk2() - { - Verify(""" + => Verify(""" /* * /* $$ @@ -120,12 +105,10 @@ public void NotClosedAfterAsteriskSpaceWithNonWhitespaceBeforeAsterisk2() * /* /$$ """); - } [WpfFact] public void NotClosedAfterAsteriskSpaceWithNonWhitespaceBeforeAsterisk3() - { - Verify(""" + => Verify(""" /* * a * $$ @@ -134,12 +117,10 @@ public void NotClosedAfterAsteriskSpaceWithNonWhitespaceBeforeAsterisk3() * a * /$$ """); - } [WpfFact] public void NotClosedAfterAsteriskSpaceWithNonWhitespaceAfterCursor1() - { - Verify(""" + => Verify(""" /* * * $$/ @@ -148,12 +129,10 @@ public void NotClosedAfterAsteriskSpaceWithNonWhitespaceAfterCursor1() * * /$$/ """); - } [WpfFact] public void NotClosedAfterAsteriskSpaceWithNonWhitespaceAfterCursor2() - { - Verify(""" + => Verify(""" /* * * $$* @@ -162,12 +141,10 @@ public void NotClosedAfterAsteriskSpaceWithNonWhitespaceAfterCursor2() * * /$$* """); - } [WpfFact] public void NotClosedAfterAsteriskSpaceWithNonWhitespaceAfterCursor3() - { - Verify(""" + => Verify(""" /* * * $$ a @@ -176,12 +153,10 @@ public void NotClosedAfterAsteriskSpaceWithNonWhitespaceAfterCursor3() * * /$$ a """); - } [WpfFact] public void NotClosedAfterAsteriskSpaceWithWhitespaceAfterCursor() - { - Verify(""" + => Verify(""" /* * * $$ @@ -190,12 +165,10 @@ public void NotClosedAfterAsteriskSpaceWithWhitespaceAfterCursor() * * /$$ """); - } [WpfFact] public void NotClosedAfterAsteriskDoubleSpace() - { - Verify(""" + => Verify(""" /* * * $$ @@ -204,12 +177,10 @@ public void NotClosedAfterAsteriskDoubleSpace() * * /$$ """); - } [WpfFact] public void ClosedAfterAsteriskSpaceWithNothingBeforeAsterisk() - { - Verify(""" + => Verify(""" /* * * $$ @@ -218,12 +189,10 @@ public void ClosedAfterAsteriskSpaceWithNothingBeforeAsterisk() * */$$ """); - } [WpfFact] public void ClosedAfterAsteriskSpaceWithTabsBeforeAsterisk() - { - VerifyTabs(""" + => VerifyTabs(""" /* * * $$ @@ -232,12 +201,10 @@ public void ClosedAfterAsteriskSpaceWithTabsBeforeAsterisk() * */$$ """); - } [WpfFact] public void NotClosedAfterAsteriskSpaceWithOptionOff() - { - Verify(""" + => Verify(""" /* * * $$ @@ -250,12 +217,10 @@ public void NotClosedAfterAsteriskSpaceWithOptionOff() var globalOptions = workspace.GetService(); globalOptions.SetGlobalOption(BlockCommentEditingOptionsStorage.AutoInsertBlockCommentStartString, LanguageNames.CSharp, false); }); - } [WpfFact] public void NotClosedAfterAsteriskSpaceOutsideComment() - { - Verify(""" + => Verify(""" / * * * $$ @@ -264,12 +229,10 @@ public void NotClosedAfterAsteriskSpaceOutsideComment() * * /$$ """); - } [WpfFact] public void NotClosedAfterAsteriskSpaceInsideString() - { - Verify(""" + => Verify(""" class C { string s = @" @@ -284,37 +247,28 @@ class C * * /$$ """); - } [WpfFact] public void ClosedAfterAsteriskSpaceEndOfFile() - { - Verify(""" + => Verify(""" /* * $$ """, """ /* */$$ """); - } [WpfFact] public void NotClosedAfterAsteriskSpaceStartOfFile() - { - Verify(@"* $$", @"* /$$"); - } + => Verify(@"* $$", @"* /$$"); [WpfFact] public void NotClosedAfterSpaceStartOfFile() - { - Verify(@" $$", @" /$$"); - } + => Verify(@" $$", @" /$$"); [WpfFact] public void NotClosedAtStartOfFile() - { - Verify(@"$$", @"/$$"); - } + => Verify(@"$$", @"/$$"); protected override EditorTestWorkspace CreateTestWorkspace(string initialMarkup) => EditorTestWorkspace.CreateCSharp(initialMarkup); diff --git a/src/EditorFeatures/CSharpTest/Classification/SyntacticClassifierTests_Preprocessor.cs b/src/EditorFeatures/CSharpTest/Classification/SyntacticClassifierTests_Preprocessor.cs index 55337dc95879..7c8279ecb752 100644 --- a/src/EditorFeatures/CSharpTest/Classification/SyntacticClassifierTests_Preprocessor.cs +++ b/src/EditorFeatures/CSharpTest/Classification/SyntacticClassifierTests_Preprocessor.cs @@ -1087,7 +1087,7 @@ public Task ShortDiscardInAssignment(TestHost testHost) => TestInMethodAsync( code: @"_ = 1;", testHost: testHost, -expected: Classifications(Identifier("_"), Operators.Equals, Number("1"), Punctuation.Semicolon)); + expected: Classifications(Identifier("_"), Operators.Equals, Number("1"), Punctuation.Semicolon)); [Theory, CombinatorialData] public Task UnderscoreInLambda(TestHost testHost) diff --git a/src/EditorFeatures/CSharpTest/CodeActions/AddUsing/AbstractAddUsingTests.cs b/src/EditorFeatures/CSharpTest/CodeActions/AddUsing/AbstractAddUsingTests.cs index d6cb4ae26b9c..5b8234ed6af2 100644 --- a/src/EditorFeatures/CSharpTest/CodeActions/AddUsing/AbstractAddUsingTests.cs +++ b/src/EditorFeatures/CSharpTest/CodeActions/AddUsing/AbstractAddUsingTests.cs @@ -31,7 +31,7 @@ internal Task TestAsync( int index = 0, CodeActionPriority? priority = null, OptionsCollection? options = null) - => TestInRegularAndScript1Async( + => TestInRegularAndScriptAsync( initialMarkup, expectedMarkup, index, diff --git a/src/EditorFeatures/CSharpTest/CodeActions/AddUsing/AddUsingNuGetTests.cs b/src/EditorFeatures/CSharpTest/CodeActions/AddUsing/AddUsingNuGetTests.cs index 3fce72eccca9..eef6fe5e746b 100644 --- a/src/EditorFeatures/CSharpTest/CodeActions/AddUsing/AddUsingNuGetTests.cs +++ b/src/EditorFeatures/CSharpTest/CodeActions/AddUsing/AddUsingNuGetTests.cs @@ -62,7 +62,7 @@ public async Task TestSearchPackageCustomFeedName() var packageServiceMock = new Mock(MockBehavior.Strict); packageServiceMock.Setup(s => s.FindReferenceAssembliesAsync(new TypeQuery("NuGetType", 0), It.IsAny(), It.IsAny())) - .Returns(() => ValueTaskFactory.FromResult(ImmutableArray.Empty)); + .Returns(() => ValueTask.FromResult(ImmutableArray.Empty)); packageServiceMock.Setup(s => s.FindPackagesAsync( PackageSourceHelper.NugetOrgSourceName, new TypeQuery("NuGetType", 0), It.IsAny(), It.IsAny())) .Returns(() => CreateSearchResult("NuGetPackage", "NuGetType", CreateNameParts("NuGetNamespace"))); @@ -81,7 +81,7 @@ class C { NuGetType n; } - """, fixProviderData: new FixProviderData(installerServiceMock.Object, packageServiceMock.Object)); + """, new TestParameters(fixProviderData: new FixProviderData(installerServiceMock.Object, packageServiceMock.Object))); } [Fact] @@ -99,7 +99,7 @@ public async Task TestSearchPackageFakeNugetFeed() var packageServiceMock = new Mock(MockBehavior.Strict); packageServiceMock.Setup(s => s.FindReferenceAssembliesAsync(new TypeQuery("NuGetType", 0), It.IsAny(), It.IsAny())) - .Returns(() => ValueTaskFactory.FromResult(ImmutableArray.Empty)); + .Returns(() => ValueTask.FromResult(ImmutableArray.Empty)); packageServiceMock.Setup(s => s.FindPackagesAsync( "nuget.org", new TypeQuery("NuGetType", 0), It.IsAny(), It.IsAny())) .Returns(() => CreateSearchResult("NuGetPackage", "NuGetType", CreateNameParts("NuGetNamespace"))); @@ -118,7 +118,7 @@ class C { NuGetType n; } - """, fixProviderData: new FixProviderData(installerServiceMock.Object, packageServiceMock.Object)); + """, new TestParameters(fixProviderData: new FixProviderData(installerServiceMock.Object, packageServiceMock.Object))); } [Fact] @@ -134,7 +134,7 @@ public async Task TestSearchPackageSingleName() var packageServiceMock = new Mock(MockBehavior.Strict); packageServiceMock.Setup(s => s.FindReferenceAssembliesAsync(new TypeQuery("NuGetType", 0), It.IsAny(), It.IsAny())) - .Returns(() => ValueTaskFactory.FromResult(ImmutableArray.Empty)); + .Returns(() => ValueTask.FromResult(ImmutableArray.Empty)); packageServiceMock.Setup(s => s.FindPackagesAsync( PackageSourceHelper.NugetOrgSourceName, new TypeQuery("NuGetType", 0), It.IsAny(), It.IsAny())) .Returns(() => CreateSearchResult("NuGetPackage", "NuGetType", CreateNameParts("NuGetNamespace"))); @@ -153,7 +153,7 @@ class C { NuGetType n; } - """, fixProviderData: new FixProviderData(installerServiceMock.Object, packageServiceMock.Object)); + """, new TestParameters(fixProviderData: new FixProviderData(installerServiceMock.Object, packageServiceMock.Object))); } [Fact] @@ -169,7 +169,7 @@ public async Task TestSearchPackageMultipleNames() var packageServiceMock = new Mock(MockBehavior.Strict); packageServiceMock.Setup(s => s.FindReferenceAssembliesAsync(new TypeQuery("NuGetType", 0), It.IsAny(), It.IsAny())) - .Returns(() => ValueTaskFactory.FromResult(ImmutableArray.Empty)); + .Returns(() => ValueTask.FromResult(ImmutableArray.Empty)); packageServiceMock.Setup(s => s.FindPackagesAsync( PackageSourceHelper.NugetOrgSourceName, new TypeQuery("NuGetType", 0), It.IsAny(), It.IsAny())) .Returns(() => CreateSearchResult("NuGetPackage", "NuGetType", CreateNameParts("NS1", "NS2"))); @@ -188,7 +188,7 @@ class C { NuGetType n; } - """, fixProviderData: new FixProviderData(installerServiceMock.Object, packageServiceMock.Object)); + """, new TestParameters(fixProviderData: new FixProviderData(installerServiceMock.Object, packageServiceMock.Object))); } [Fact] @@ -202,7 +202,7 @@ public async Task TestMissingIfPackageAlreadyInstalled() var packageServiceMock = new Mock(MockBehavior.Strict); packageServiceMock.Setup(s => s.FindReferenceAssembliesAsync(new TypeQuery("NuGetType", 0), It.IsAny(), It.IsAny())) - .Returns(() => ValueTaskFactory.FromResult(ImmutableArray.Empty)); + .Returns(() => ValueTask.FromResult(ImmutableArray.Empty)); packageServiceMock.Setup(s => s.FindPackagesAsync( PackageSourceHelper.NugetOrgSourceName, new TypeQuery("NuGetType", 0), It.IsAny(), It.IsAny())) .Returns(() => CreateSearchResult("NuGetPackage", "NuGetType", CreateNameParts("NS1", "NS2"))); @@ -230,7 +230,7 @@ public async Task TestOptionsOffered() var packageServiceMock = new Mock(MockBehavior.Strict); packageServiceMock.Setup(s => s.FindReferenceAssembliesAsync(new TypeQuery("NuGetType", 0), It.IsAny(), It.IsAny())) - .Returns(() => ValueTaskFactory.FromResult(ImmutableArray.Empty)); + .Returns(() => ValueTask.FromResult(ImmutableArray.Empty)); packageServiceMock.Setup(s => s.FindPackagesAsync( PackageSourceHelper.NugetOrgSourceName, new TypeQuery("NuGetType", 0), It.IsAny(), It.IsAny())) .Returns(() => CreateSearchResult("NuGetPackage", "NuGetType", CreateNameParts("NS1", "NS2"))); @@ -280,7 +280,7 @@ public async Task TestInstallGetsCalledNoVersion() var packageServiceMock = new Mock(MockBehavior.Strict); packageServiceMock.Setup(s => s.FindReferenceAssembliesAsync(new TypeQuery("NuGetType", 0), It.IsAny(), It.IsAny())) - .Returns(() => ValueTaskFactory.FromResult(ImmutableArray.Empty)); + .Returns(() => ValueTask.FromResult(ImmutableArray.Empty)); packageServiceMock.Setup(s => s.FindPackagesAsync( PackageSourceHelper.NugetOrgSourceName, new TypeQuery("NuGetType", 0), It.IsAny(), It.IsAny())) .Returns(() => CreateSearchResult("NuGetPackage", "NuGetType", CreateNameParts("NuGetNamespace"))); @@ -299,7 +299,7 @@ class C { NuGetType n; } - """, fixProviderData: new FixProviderData(installerServiceMock.Object, packageServiceMock.Object)); + """, new TestParameters(fixProviderData: new FixProviderData(installerServiceMock.Object, packageServiceMock.Object))); installerServiceMock.Verify(); } @@ -318,7 +318,7 @@ public async Task TestInstallGetsCalledWithVersion() var packageServiceMock = new Mock(MockBehavior.Strict); packageServiceMock.Setup(s => s.FindReferenceAssembliesAsync(new TypeQuery("NuGetType", 0), It.IsAny(), It.IsAny())) - .Returns(() => ValueTaskFactory.FromResult(ImmutableArray.Empty)); + .Returns(() => ValueTask.FromResult(ImmutableArray.Empty)); packageServiceMock.Setup(s => s.FindPackagesAsync(PackageSourceHelper.NugetOrgSourceName, new TypeQuery("NuGetType", 0), It.IsAny(), It.IsAny())) .Returns(() => CreateSearchResult("NuGetPackage", "NuGetType", CreateNameParts("NuGetNamespace"))); @@ -336,7 +336,7 @@ class C { NuGetType n; } - """, fixProviderData: new FixProviderData(installerServiceMock.Object, packageServiceMock.Object)); + """, new TestParameters(fixProviderData: new FixProviderData(installerServiceMock.Object, packageServiceMock.Object))); installerServiceMock.Verify(); } @@ -355,7 +355,7 @@ public async Task TestFailedInstallRollsBackFile() var packageServiceMock = new Mock(MockBehavior.Strict); packageServiceMock.Setup(s => s.FindReferenceAssembliesAsync(new TypeQuery("NuGetType", 0), It.IsAny(), It.IsAny())) - .Returns(() => ValueTaskFactory.FromResult(ImmutableArray.Empty)); + .Returns(() => ValueTask.FromResult(ImmutableArray.Empty)); packageServiceMock.Setup(s => s.FindPackagesAsync(PackageSourceHelper.NugetOrgSourceName, new TypeQuery("NuGetType", 0), It.IsAny(), It.IsAny())) .Returns(() => CreateSearchResult("NuGetPackage", "NuGetType", CreateNameParts("NuGetNamespace"))); @@ -371,7 +371,7 @@ class C { NuGetType n; } - """, fixProviderData: new FixProviderData(installerServiceMock.Object, packageServiceMock.Object)); + """, new TestParameters(fixProviderData: new FixProviderData(installerServiceMock.Object, packageServiceMock.Object))); installerServiceMock.Verify(); } diff --git a/src/EditorFeatures/CSharpTest/CodeActions/AddUsing/AddUsingTests.cs b/src/EditorFeatures/CSharpTest/CodeActions/AddUsing/AddUsingTests.cs index a9f79963b3c5..72e24acbe728 100644 --- a/src/EditorFeatures/CSharpTest/CodeActions/AddUsing/AddUsingTests.cs +++ b/src/EditorFeatures/CSharpTest/CodeActions/AddUsing/AddUsingTests.cs @@ -158,7 +158,7 @@ IDictionary Method() } } """, -testHost, index: 1); + testHost, index: 1); [Theory, CombinatorialData] public Task TestGenericWithNoArgs(TestHost testHost) @@ -383,7 +383,7 @@ class Class } } """, -count: 1); + count: 1); [Theory, CombinatorialData] public Task TestExistingUsing(TestHost testHost) @@ -479,7 +479,7 @@ public static void Where(this Class c) } } """, -parseOptions: Options.Regular); + new TestParameters(parseOptions: Options.Regular)); [Theory, CombinatorialData] public Task TestOnEnum(TestHost testHost) @@ -1434,7 +1434,7 @@ public static void Bar() } } """, -testHost); + testHost); [Theory, CombinatorialData] public Task TestSimpleSystemSortedUsings2(TestHost testHost) @@ -1486,7 +1486,7 @@ public static void Bar() } } """, -testHost); + testHost); [Theory, CombinatorialData] public Task TestSimpleSystemSortedUsings3(TestHost testHost) @@ -1516,7 +1516,7 @@ void Method() } } """, -testHost); + testHost); [Theory, CombinatorialData] public Task TestSimpleSystemUnsortedUsings1(TestHost testHost) @@ -1568,7 +1568,7 @@ public static void Bar() } } """, -testHost); + testHost); [Theory, CombinatorialData] public Task TestSimpleSystemUnsortedUsings2(TestHost testHost) @@ -1620,7 +1620,7 @@ public static void Bar() } } """, -testHost); + testHost); [Theory, CombinatorialData] public Task TestSimpleSystemUnsortedUsings3(TestHost testHost) @@ -1650,7 +1650,7 @@ void Method() } } """, -testHost); + testHost); [Theory, CombinatorialData] public Task TestSimpleBogusSystemUsings1(TestHost testHost) @@ -1678,7 +1678,7 @@ void Method() } } """, -testHost); + testHost); [Theory, CombinatorialData] public Task TestSimpleBogusSystemUsings2(TestHost testHost) @@ -1706,7 +1706,7 @@ void Method() } } """, -testHost); + testHost); [Theory, CombinatorialData] public Task TestUsingsWithComments(TestHost testHost) @@ -1734,7 +1734,7 @@ void Method() } } """, -testHost); + testHost); // System Not on top cases [Theory, CombinatorialData] @@ -1787,7 +1787,7 @@ public static void Bar() } } """, -testHost); + testHost); [Theory, CombinatorialData] public Task TestSimpleSystemSortedUsings5(TestHost testHost) @@ -1837,7 +1837,7 @@ public static void Bar() } } """, -testHost); + testHost); [Theory, CombinatorialData] public Task TestSimpleSystemSortedUsings4(TestHost testHost) @@ -1867,7 +1867,7 @@ void Method() } } """, -testHost, options: Option(GenerationOptions.PlaceSystemNamespaceFirst, false)); + testHost, options: Option(GenerationOptions.PlaceSystemNamespaceFirst, false)); [Fact, WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/538136")] [WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/538763")] @@ -1925,7 +1925,7 @@ public Task BugFix5950() WriteLine(Expression.Constant(123)); """, -parseOptions: GetScriptOptions()); +new TestParameters(parseOptions: GetScriptOptions())); [Theory, CombinatorialData] [WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/540339")] @@ -2166,8 +2166,8 @@ await TestAsync( Expression """, -GetScriptOptions(), -TestOptions.ReleaseDll.WithMetadataReferenceResolver(resolver)); + new TestParameters(GetScriptOptions(), + TestOptions.ReleaseDll.WithMetadataReferenceResolver(resolver))); } [Theory, CombinatorialData] @@ -2399,7 +2399,7 @@ static void Main(string[] args) Log } } """, -testHost); + testHost); [Theory, CombinatorialData] [WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/858085")] @@ -2516,9 +2516,8 @@ [ class Class [Theory, CombinatorialData] [WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/875899")] - public async Task TestAddUsingsWithExternAlias(TestHost testHost) - { - const string InitialWorkspace = """ + public Task TestAddUsingsWithExternAlias(TestHost testHost) + => TestAsync(""" namespace ProjectLib @@ -2542,9 +2541,7 @@ static void Main(string[] args) } - """; - - const string ExpectedDocumentText = """ + """, """ extern alias P; using P::ProjectLib; @@ -2559,15 +2556,12 @@ static void Main(string[] args) } } } - """; - await TestAsync(InitialWorkspace, ExpectedDocumentText, testHost); - } + """, testHost); [Theory, CombinatorialData] [WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/875899")] - public async Task TestAddUsingsWithPreExistingExternAlias(TestHost testHost) - { - const string InitialWorkspace = """ + public Task TestAddUsingsWithPreExistingExternAlias(TestHost testHost) + => TestAsync(""" namespace ProjectLib @@ -2601,9 +2595,7 @@ static void Main(string[] args) } - """; - - const string ExpectedDocumentText = """ + """, """ extern alias P; using P::AnotherNS; @@ -2619,15 +2611,12 @@ static void Main(string[] args) } } } - """; - await TestAsync(InitialWorkspace, ExpectedDocumentText, testHost); - } + """, testHost); [Theory, CombinatorialData] [WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/875899")] - public async Task TestAddUsingsWithPreExistingExternAlias_FileScopedNamespace(TestHost testHost) - { - const string InitialWorkspace = """ + public Task TestAddUsingsWithPreExistingExternAlias_FileScopedNamespace(TestHost testHost) + => TestAsync(""" namespace ProjectLib; @@ -2660,9 +2649,7 @@ static void Main(string[] args) } - """; - - const string ExpectedDocumentText = """ + """, """ extern alias P; using P::AnotherNS; @@ -2677,15 +2664,12 @@ static void Main(string[] args) var x = new [|AnotherClass()|]; } } - """; - await TestAsync(InitialWorkspace, ExpectedDocumentText, testHost); - } + """, testHost); [Theory, CombinatorialData] [WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/875899")] - public async Task TestAddUsingsNoExtern(TestHost testHost) - { - const string InitialWorkspace = """ + public Task TestAddUsingsNoExtern(TestHost testHost) + => TestAsync(""" namespace AnotherNS @@ -2710,9 +2694,7 @@ static void Main(string[] args) } - """; - - const string ExpectedDocumentText = """ + """, """ extern alias P; using P::AnotherNS; @@ -2726,15 +2708,12 @@ static void Main(string[] args) } } } - """; - await TestAsync(InitialWorkspace, ExpectedDocumentText, testHost); - } + """, testHost); [Theory, CombinatorialData] [WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/875899")] - public async Task TestAddUsingsNoExtern_FileScopedNamespace(TestHost testHost) - { - const string InitialWorkspace = """ + public Task TestAddUsingsNoExtern_FileScopedNamespace(TestHost testHost) + => TestAsync(""" namespace AnotherNS; @@ -2757,9 +2736,7 @@ static void Main(string[] args) } - """; - - const string ExpectedDocumentText = """ + """, """ extern alias P; using P::AnotherNS; @@ -2772,9 +2749,7 @@ static void Main(string[] args) var x = new AnotherClass(); } } - """; - await TestAsync(InitialWorkspace, ExpectedDocumentText, testHost); - } + """, testHost); [Theory, CombinatorialData] [WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/875899")] @@ -2818,7 +2793,7 @@ interface MyNotifyPropertyChanged { } /// This is just like , but this one is mine. /// interface MyNotifyPropertyChanged { } - """, parseOptions: options); + """, new TestParameters(parseOptions: options)); } [Fact, WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/916368")] @@ -2838,7 +2813,7 @@ interface MyNotifyPropertyChanged { } /// This is just like , but this one is mine. /// interface MyNotifyPropertyChanged { } - """, parseOptions: options); + """, new TestParameters(parseOptions: options)); } [Fact, WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/916368")] @@ -2884,7 +2859,7 @@ public static explicit operator N1.D (MyClass f) public class MyClass2 { } - """, parseOptions: options); + """, new TestParameters(parseOptions: options)); } [Fact, WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/916368")] @@ -2920,7 +2895,7 @@ public void Test(N1.D i) { } } - """, parseOptions: options); + """, new TestParameters(parseOptions: options)); } [Theory, CombinatorialData] @@ -3514,9 +3489,8 @@ class Program { static void Main ( string [ ] args ) { var a = File . OpenRead ( """, testHost); [Fact] - public async Task TestInaccessibleExtensionMethod() - { - const string initial = """ + public Task TestInaccessibleExtensionMethod() + => TestMissingInRegularAndScriptAsync(""" namespace N1 { public static class C @@ -3538,9 +3512,7 @@ static void Main(string[] args) } } } - """; - await TestMissingInRegularAndScriptAsync(initial); - } + """); [Theory, CombinatorialData] [WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/1116011")] @@ -4963,7 +4935,7 @@ public static void Bar() } } """, -testHost); + testHost); [Theory, CombinatorialData] [WorkItem("https://github.com/dotnet/roslyn/issues/19796")] @@ -6296,9 +6268,8 @@ static void Main(string[] args) [Theory, CombinatorialData] [WorkItem("https://devdiv.visualstudio.com/DevDiv/_workitems/edit/1266354")] - public async Task TestAddUsingsEditorBrowsableNeverSameProject(TestHost testHost) - { - const string InitialWorkspace = """ + public Task TestAddUsingsEditorBrowsableNeverSameProject(TestHost testHost) + => TestAsync(""" using System.ComponentModel; @@ -6318,9 +6289,7 @@ static void Main(string[] args) } - """; - - const string ExpectedDocumentText = """ + """, """ using ProjectLib; class Program @@ -6330,16 +6299,12 @@ static void Main(string[] args) Project p = new [|Project()|]; } } - """; - - await TestAsync(InitialWorkspace, ExpectedDocumentText, testHost); - } + """, testHost); [Theory, CombinatorialData] [WorkItem("https://devdiv.visualstudio.com/DevDiv/_workitems/edit/1266354")] - public async Task TestAddUsingsEditorBrowsableNeverDifferentProject(TestHost testHost) - { - const string InitialWorkspace = """ + public Task TestAddUsingsEditorBrowsableNeverDifferentProject(TestHost testHost) + => TestMissingAsync(""" @@ -6364,15 +6329,12 @@ static void Main(string[] args) - """; - await TestMissingAsync(InitialWorkspace, new TestParameters(testHost: testHost)); - } + """, new TestParameters(testHost: testHost)); [Theory, CombinatorialData] [WorkItem("https://devdiv.visualstudio.com/DevDiv/_workitems/edit/1266354")] - public async Task TestAddUsingsEditorBrowsableAdvancedDifferentProjectOptionOn(TestHost testHost) - { - const string InitialWorkspace = """ + public Task TestAddUsingsEditorBrowsableAdvancedDifferentProjectOptionOn(TestHost testHost) + => TestAsync(""" imports System.ComponentModel @@ -6393,9 +6355,7 @@ static void Main(string[] args) } - """; - - const string ExpectedDocumentText = """ + """, """ using ProjectLib; class Program @@ -6405,9 +6365,7 @@ static void Main(string[] args) Project p = new [|Project()|]; } } - """; - await TestAsync(InitialWorkspace, ExpectedDocumentText, testHost); - } + """, testHost); [Theory, CombinatorialData] [WorkItem("https://devdiv.visualstudio.com/DevDiv/_workitems/edit/1266354")] @@ -6448,7 +6406,7 @@ static void Main(string[] args) [Theory, CombinatorialData] [WorkItem("https://github.com/dotnet/roslyn/issues/62976")] public Task TestAddUsingPreservesNewlines1(TestHost testHost, [CombinatorialValues("\n", "\r\n")] string sourceNewLine, [CombinatorialValues("\n", "\r\n")] string configuredNewLine) - => TestInRegularAndScript1Async( + => TestInRegularAndScriptAsync( """ namespace ANamespace { @@ -6489,7 +6447,7 @@ class Class [Theory, CombinatorialData] [WorkItem("https://github.com/dotnet/roslyn/issues/62976")] public Task TestAddUsingPreservesNewlines2(TestHost testHost, [CombinatorialValues("\n", "\r\n")] string sourceNewLine, [CombinatorialValues("\n", "\r\n")] string configuredNewLine) - => TestInRegularAndScript1Async( + => TestInRegularAndScriptAsync( """ using BNamespace; @@ -6541,7 +6499,7 @@ class Class [Theory, CombinatorialData] [WorkItem("https://github.com/dotnet/roslyn/issues/62976")] public Task TestAddUsingPreservesNewlines3(TestHost testHost, [CombinatorialValues("\n", "\r\n")] string sourceNewLine, [CombinatorialValues("\n", "\r\n")] string configuredNewLine) - => TestInRegularAndScript1Async( + => TestInRegularAndScriptAsync( """ using ANamespace; @@ -6593,7 +6551,7 @@ class Class [Theory, CombinatorialData] [WorkItem("https://github.com/dotnet/roslyn/issues/24642")] public Task TestAddUsingWithMalformedGeneric(TestHost testHost) - => TestInRegularAndScript1Async( + => TestInRegularAndScriptAsync( """ class Class { @@ -6613,7 +6571,7 @@ class Class [Theory, CombinatorialData] public Task TestOutsideOfMethodWithMalformedGenericParameters(TestHost testHost) - => TestInRegularAndScript1Async( + => TestInRegularAndScriptAsync( """ using System; @@ -6646,4 +6604,41 @@ public Task TestAssemblyLevelAttribute(TestHost testHost) [assembly: NeutralResourcesLanguage("en")] """, testHost); + + [Theory, CombinatorialData, WorkItem("https://github.com/dotnet/roslyn/issues/79462")] + public Task TestAddUsingsWithSourceGeneratedFile(TestHost testHost) + => TestAsync(""" + + + using Goo; + + Something a; + [|PInvoke|].GetMessage(); + + namespace Goo + { + class Something { } + } + + namespace Win32 + { + public class PInvoke + { + } + } + + + + """, """ + using Goo; + using Win32; + + Something a; + PInvoke.GetMessage(); + + namespace Goo + { + class Something { } + } + """, testHost); } diff --git a/src/EditorFeatures/CSharpTest/CodeActions/AddUsing/AddUsingTestsWithAddImportDiagnosticProvider.cs b/src/EditorFeatures/CSharpTest/CodeActions/AddUsing/AddUsingTestsWithAddImportDiagnosticProvider.cs index 859fa77e0e08..d44a411c348c 100644 --- a/src/EditorFeatures/CSharpTest/CodeActions/AddUsing/AddUsingTestsWithAddImportDiagnosticProvider.cs +++ b/src/EditorFeatures/CSharpTest/CodeActions/AddUsing/AddUsingTestsWithAddImportDiagnosticProvider.cs @@ -18,13 +18,9 @@ namespace Microsoft.CodeAnalysis.Editor.CSharp.UnitTests.AddUsing; [Trait(Traits.Feature, Traits.Features.CodeActionsAddImport)] -public sealed partial class AddUsingTestsWithAddImportDiagnosticProvider : AbstractCSharpDiagnosticProviderBasedUserDiagnosticTest +public sealed partial class AddUsingTestsWithAddImportDiagnosticProvider(ITestOutputHelper logger) + : AbstractCSharpDiagnosticProviderBasedUserDiagnosticTest(logger) { - public AddUsingTestsWithAddImportDiagnosticProvider(ITestOutputHelper logger) - : base(logger) - { - } - internal override (DiagnosticAnalyzer, CodeFixProvider) CreateDiagnosticProviderAndFixer(Workspace workspace) => (new CSharpUnboundIdentifiersDiagnosticAnalyzer(), new CSharpAddImportCodeFixProvider()); diff --git a/src/EditorFeatures/CSharpTest/CodeActions/AddUsing/AddUsingTests_ExtensionMethods.cs b/src/EditorFeatures/CSharpTest/CodeActions/AddUsing/AddUsingTests_ExtensionMethods.cs index 2c27f2d9e0ef..49ebd1d6c6ef 100644 --- a/src/EditorFeatures/CSharpTest/CodeActions/AddUsing/AddUsingTests_ExtensionMethods.cs +++ b/src/EditorFeatures/CSharpTest/CodeActions/AddUsing/AddUsingTests_ExtensionMethods.cs @@ -395,7 +395,7 @@ public static void Add(this X x, int i) } } """, -parseOptions: null); + new TestParameters(parseOptions: null)); [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/269")] public Task TestAddUsingForAddExtensionMethod2() @@ -447,7 +447,7 @@ public static void Add(this X x, int i) } } """, -parseOptions: null); + new TestParameters(parseOptions: null)); [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/269")] public Task TestAddUsingForAddExtensionMethod3() @@ -499,7 +499,7 @@ public static void Add(this X x, int i) } } """, -parseOptions: null); + new TestParameters(parseOptions: null)); [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/269")] public Task TestAddUsingForAddExtensionMethod4() @@ -551,7 +551,7 @@ public static void Add(this X x, int i) } } """, -parseOptions: null); + new TestParameters(parseOptions: null)); [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/269")] public Task TestAddUsingForAddExtensionMethod5() @@ -603,7 +603,7 @@ public static void Add(this X x, int i) } } """, -parseOptions: null); + new TestParameters(parseOptions: null)); [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/269")] public Task TestAddUsingForAddExtensionMethod6() @@ -655,7 +655,7 @@ public static void Add(this X x, int i) } } """, -parseOptions: null); + new TestParameters(parseOptions: null)); [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/269")] public Task TestAddUsingForAddExtensionMethod7() @@ -707,7 +707,7 @@ public static void Add(this X x, int i) } } """, -parseOptions: null); + new TestParameters(parseOptions: null)); [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/269")] public Task TestAddUsingForAddExtensionMethod8() @@ -759,7 +759,7 @@ public static void Add(this X x, int i) } } """, -parseOptions: null); + new TestParameters(parseOptions: null)); [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/269")] public Task TestAddUsingForAddExtensionMethod9() @@ -811,7 +811,7 @@ public static void Add(this X x, int i) } } """, -parseOptions: null); + new TestParameters(parseOptions: null)); [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/269")] public Task TestAddUsingForAddExtensionMethod10() @@ -883,7 +883,7 @@ public static void Add(this X x, object[] i) } } """, -parseOptions: null); + new TestParameters(parseOptions: null)); [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/269")] public Task TestAddUsingForAddExtensionMethod11() @@ -955,8 +955,7 @@ public static void Add(this X x, object[] i) } } """, -index: 1, -parseOptions: null); + new TestParameters(index: 1, parseOptions: null)); [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/3818")] public Task InExtensionMethodUnderConditionalAccessExpression() @@ -1113,7 +1112,7 @@ public static void Deconstruct(this Program p, out int x, out int y) { } } } """, -parseOptions: null); + new TestParameters(parseOptions: null)); [Theory, CombinatorialData] [WorkItem("https://github.com/dotnet/roslyn/issues/16547")] @@ -1388,7 +1387,7 @@ public static class FooExtensions } } """, -parseOptions: null); + new TestParameters(parseOptions: null)); [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/55117")] public Task TestMethodConflictWithGenericExtension() diff --git a/src/EditorFeatures/CSharpTest/CodeActions/GenerateType/GenerateTypeTests.cs b/src/EditorFeatures/CSharpTest/CodeActions/GenerateType/GenerateTypeTests.cs index d42de6fa6e5d..d895d7cd27e5 100644 --- a/src/EditorFeatures/CSharpTest/CodeActions/GenerateType/GenerateTypeTests.cs +++ b/src/EditorFeatures/CSharpTest/CodeActions/GenerateType/GenerateTypeTests.cs @@ -1371,8 +1371,7 @@ internal class C : A { } """, - index: 1, - parseOptions: null); + new(index: 1, parseOptions: null)); [Fact, WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/538069")] public Task GenerateTypeFromArrayCreation2() @@ -1399,8 +1398,7 @@ internal class C : A { } """, - index: 1, - parseOptions: null); + new(index: 1, parseOptions: null)); [Fact, WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/538069")] public Task GenerateTypeFromArrayCreation3() @@ -1427,8 +1425,7 @@ internal class C { } """, - index: 1, - parseOptions: null); + new(index: 1, parseOptions: null)); [Fact, WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/539329")] public async Task NegativeTestNotInUsingDirective() @@ -1787,8 +1784,7 @@ public T(out DateTime d) } } """, - index: 1, - parseOptions: TestOptions.Regular7); + new TestParameters(index: 1, parseOptions: TestOptions.Regular7)); [Fact] public Task GenerateWithOutParameters2() @@ -1951,8 +1947,7 @@ public T(out X d) } } """, - index: 2, - parseOptions: TestOptions.Regular7); + new TestParameters(index: 2, parseOptions: TestOptions.Regular7)); [Fact] public Task GenerateWithOutParameters6() @@ -2945,8 +2940,7 @@ class Base protected int I; } """, - index: 1, - options: Option(CodeStyleOptions2.QualifyFieldAccess, true, NotificationOption2.Error)); + new TestParameters(index: 1, options: Option(CodeStyleOptions2.QualifyFieldAccess, true, NotificationOption2.Error))); [Fact] public Task GenerateWithCallToField8() @@ -3117,7 +3111,7 @@ public D(int i) } } """, - index: 1, options: options.FieldNamesAreCamelCaseWithUnderscorePrefix); + new TestParameters(index: 1, options: options.FieldNamesAreCamelCaseWithUnderscorePrefix)); } [Fact] @@ -3243,8 +3237,7 @@ class Base public int I { get; protected set; } } """, - index: 1, - options: Option(CodeStyleOptions2.QualifyPropertyAccess, true, NotificationOption2.Error)); + new TestParameters(index: 1, options: Option(CodeStyleOptions2.QualifyPropertyAccess, true, NotificationOption2.Error))); [Fact] public Task GenerateWithCallToProperty3() @@ -3327,7 +3320,7 @@ class Base } """, index: 1, - options: Option(CodeStyleOptions2.QualifyPropertyAccess, true, NotificationOption2.Error)); + new TestParameters(options: Option(CodeStyleOptions2.QualifyPropertyAccess, true, NotificationOption2.Error))); [Fact, WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/942568")] public Task GenerateTypeWithPreferIntrinsicPredefinedKeywordFalse() @@ -3359,7 +3352,7 @@ public T(System.Int32 i) } """, index: 1, - options: Option(CodeStyleOptions2.PreferIntrinsicPredefinedTypeKeywordInDeclaration, false, NotificationOption2.Error)); + new TestParameters(options: Option(CodeStyleOptions2.PreferIntrinsicPredefinedTypeKeywordInDeclaration, false, NotificationOption2.Error))); #endregion diff --git a/src/EditorFeatures/CSharpTest/CodeActions/GenerateType/GenerateTypeWithUnboundAnalyzerTests.cs b/src/EditorFeatures/CSharpTest/CodeActions/GenerateType/GenerateTypeWithUnboundAnalyzerTests.cs index 0112fd0ef97d..abe543cea0cb 100644 --- a/src/EditorFeatures/CSharpTest/CodeActions/GenerateType/GenerateTypeWithUnboundAnalyzerTests.cs +++ b/src/EditorFeatures/CSharpTest/CodeActions/GenerateType/GenerateTypeWithUnboundAnalyzerTests.cs @@ -51,5 +51,5 @@ internal class Goo { } """, -index: 1); + index: 1); } diff --git a/src/EditorFeatures/CSharpTest/CodeActions/InitializeParameter/InitializeMemberFromParameterTests.cs b/src/EditorFeatures/CSharpTest/CodeActions/InitializeParameter/InitializeMemberFromParameterTests.cs index 88c95de68112..ad2dab6115af 100644 --- a/src/EditorFeatures/CSharpTest/CodeActions/InitializeParameter/InitializeMemberFromParameterTests.cs +++ b/src/EditorFeatures/CSharpTest/CodeActions/InitializeParameter/InitializeMemberFromParameterTests.cs @@ -25,7 +25,7 @@ protected override CodeRefactoringProvider CreateCodeRefactoringProvider(EditorT [Fact] public Task TestInitializeFieldWithSameName() - => TestInRegularAndScript1Async( + => TestInRegularAndScriptAsync( """ class C { @@ -50,7 +50,7 @@ public C(string s) [Fact] public Task TestEndOfParameter1() - => TestInRegularAndScript1Async( + => TestInRegularAndScriptAsync( """ class C { @@ -75,7 +75,7 @@ public C(string s) [Fact] public Task TestEndOfParameter2() - => TestInRegularAndScript1Async( + => TestInRegularAndScriptAsync( """ class C { @@ -100,7 +100,7 @@ public C(string s, string t) [Fact] public Task TestInitializeFieldWithUnderscoreName() - => TestInRegularAndScript1Async( + => TestInRegularAndScriptAsync( """ class C { @@ -125,7 +125,7 @@ public C(string s) [Fact] public Task TestInitializeWritableProperty() - => TestInRegularAndScript1Async( + => TestInRegularAndScriptAsync( """ class C { @@ -177,7 +177,7 @@ public C(string s) [Fact] public Task TestInitializeNonWritableProperty() - => TestInRegularAndScript1Async( + => TestInRegularAndScriptAsync( """ class C { @@ -230,7 +230,7 @@ public C(string s) [Fact] public Task TestInitializeFieldWithWrongType1() - => TestInRegularAndScript1Async( + => TestInRegularAndScriptAsync( """ class C { @@ -257,7 +257,7 @@ public C(string s) [Fact] public Task TestInitializeFieldWithWrongType2() - => TestInRegularAndScript1Async( + => TestInRegularAndScriptAsync( """ class C { @@ -340,7 +340,7 @@ public C([||]string s) [Fact] public Task TestWhenAlreadyInitialized3() - => TestInRegularAndScript1Async( + => TestInRegularAndScriptAsync( """ class C { @@ -370,7 +370,7 @@ public C([||]string s) [Fact] public Task TestInsertionLocation1() - => TestInRegularAndScript1Async( + => TestInRegularAndScriptAsync( """ class C { @@ -399,7 +399,7 @@ public C(string s, string t) [Fact] public Task TestInsertionLocation2() - => TestInRegularAndScript1Async( + => TestInRegularAndScriptAsync( """ class C { @@ -428,7 +428,7 @@ public C(string s, string t) [Fact] public Task TestInsertionLocation3() - => TestInRegularAndScript1Async( + => TestInRegularAndScriptAsync( """ class C { @@ -470,7 +470,7 @@ public void M([||]string s) [Fact] public Task TestInsertionLocation4() - => TestInRegularAndScript1Async( + => TestInRegularAndScriptAsync( """ class C { @@ -497,7 +497,7 @@ public C(string s, string t) [Fact] public Task TestInsertionLocation5() - => TestInRegularAndScript1Async( + => TestInRegularAndScriptAsync( """ class C { @@ -524,7 +524,7 @@ public C(string s, string t) [Fact] public Task TestInsertionLocation6() - => TestInRegularAndScript1Async( + => TestInRegularAndScriptAsync( """ class C { @@ -552,7 +552,7 @@ public C(string s, string t) [Fact] public Task TestInsertionLocation7() - => TestInRegularAndScript1Async( + => TestInRegularAndScriptAsync( """ class C { @@ -580,7 +580,7 @@ public C(string s, string t) [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/19956")] public Task TestNoBlock() - => TestInRegularAndScript1Async( + => TestInRegularAndScriptAsync( """ class C { @@ -603,7 +603,7 @@ public C(string s) [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/29190")] public Task TestInitializeFieldWithParameterNameSelected1() - => TestInRegularAndScript1Async( + => TestInRegularAndScriptAsync( """ class C { @@ -628,7 +628,7 @@ public C(string s) [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/29190")] public Task TestInitializeField_ParameterNameSelected2() - => TestInRegularAndScript1Async( + => TestInRegularAndScriptAsync( """ class C { @@ -653,7 +653,7 @@ public C(string s, int i) [Fact] public Task TestInitializeClassProperty_RequiredAccessibilityOmitIfDefault() - => TestInRegularAndScript1Async( + => TestInRegularAndScriptAsync( """ class C { @@ -680,7 +680,7 @@ public C(int test, int test2) [Fact] public Task TestInitializeClassProperty_RequiredAccessibilityNever() - => TestInRegularAndScript1Async( + => TestInRegularAndScriptAsync( """ class C { @@ -707,7 +707,7 @@ public C(int test, int test2) [Fact] public Task TestInitializeClassProperty_RequiredAccessibilityAlways() - => TestInRegularAndScript1Async( + => TestInRegularAndScriptAsync( """ class C { @@ -734,7 +734,7 @@ public C(int test, int test2) [Fact] public Task TestInitializeClassField_RequiredAccessibilityOmitIfDefault() - => TestInRegularAndScript1Async( + => TestInRegularAndScriptAsync( """ class C { @@ -760,7 +760,7 @@ public C(int test, int test2) [Fact] public Task TestInitializeClassField_RequiredAccessibilityNever() - => TestInRegularAndScript1Async( + => TestInRegularAndScriptAsync( """ class C { @@ -786,7 +786,7 @@ public C(int test, int test2) [Fact] public Task TestInitializeClassField_RequiredAccessibilityAlways() - => TestInRegularAndScript1Async( + => TestInRegularAndScriptAsync( """ class C { @@ -812,7 +812,7 @@ public C(int test, int test2) [Fact] public Task TestInitializeStructProperty_RequiredAccessibilityOmitIfDefault() - => TestInRegularAndScript1Async( + => TestInRegularAndScriptAsync( """ struct S { @@ -835,7 +835,7 @@ public Test(int test) [Fact] public Task TestInitializeStructProperty_RequiredAccessibilityNever() - => TestInRegularAndScript1Async( + => TestInRegularAndScriptAsync( """ struct S { @@ -858,7 +858,7 @@ public Test(int test) [Fact] public Task TestInitializeStructProperty_RequiredAccessibilityAlways() - => TestInRegularAndScript1Async( + => TestInRegularAndScriptAsync( """ struct S { @@ -881,7 +881,7 @@ public Test(int test) [Fact] public Task TestInitializeStructField_RequiredAccessibilityOmitIfDefault() - => TestInRegularAndScript1Async( + => TestInRegularAndScriptAsync( """ struct S { @@ -904,7 +904,7 @@ public Test(int test) [Fact] public Task TestInitializeStructField_RequiredAccessibilityNever() - => TestInRegularAndScript1Async( + => TestInRegularAndScriptAsync( """ struct S { @@ -927,7 +927,7 @@ public Test(int test) [Fact] public Task TestInitializeStructField_RequiredAccessibilityAlways() - => TestInRegularAndScript1Async( + => TestInRegularAndScriptAsync( """ struct S { @@ -950,7 +950,7 @@ public Test(int test) [Fact] public Task TestNoParameterNamingStyle_CreateAndInitField() - => TestInRegularAndScript1Async( + => TestInRegularAndScriptAsync( """ class C { @@ -973,7 +973,7 @@ public C(string s) [Fact] public Task TestCommonParameterNamingStyle_CreateAndInitField() - => TestInRegularAndScript1Async( + => TestInRegularAndScriptAsync( """ class C { @@ -996,7 +996,7 @@ public C(string t_s) [Fact] public Task TestSpecifiedParameterNamingStyle_CreateAndInitField() - => TestInRegularAndScript1Async( + => TestInRegularAndScriptAsync( """ class C { @@ -1019,7 +1019,7 @@ public C(string p_s_End) [Fact] public Task TestCommonAndSpecifiedParameterNamingStyle_CreateAndInitField() - => TestInRegularAndScript1Async( + => TestInRegularAndScriptAsync( """ class C { @@ -1042,7 +1042,7 @@ public C(string t_p_s_End) [Fact] public Task TestCommonAndSpecifiedParameterNamingStyle2_CreateAndInitField() - => TestInRegularAndScript1Async( + => TestInRegularAndScriptAsync( """ class C { @@ -1065,7 +1065,7 @@ public C([||]string p_t_s) [Fact] public Task TestNoParameterNamingStyle_CreateAndInitProperty() - => TestInRegularAndScript1Async( + => TestInRegularAndScriptAsync( """ class C { @@ -1088,7 +1088,7 @@ public C(string s) [Fact] public Task TestCommonParameterNamingStyle_CreateAndInitProperty() - => TestInRegularAndScript1Async( + => TestInRegularAndScriptAsync( """ class C { @@ -1111,7 +1111,7 @@ public C(string t_s) [Fact] public Task TestSpecifiedParameterNamingStyle_CreateAndInitProperty() - => TestInRegularAndScript1Async( + => TestInRegularAndScriptAsync( """ class C { @@ -1134,7 +1134,7 @@ public C(string p_s_End) [Fact] public Task TestCommonAndSpecifiedParameterNamingStyle_CreateAndInitProperty() - => TestInRegularAndScript1Async( + => TestInRegularAndScriptAsync( """ class C { @@ -1157,7 +1157,7 @@ public C(string t_p_s_End) [Fact] public Task TestCommonAndSpecifiedParameterNamingStyle2_CreateAndInitProperty() - => TestInRegularAndScript1Async( + => TestInRegularAndScriptAsync( """ class C { @@ -1180,7 +1180,7 @@ public C([||]string p_t_s_End) [Fact] public Task TestNoParameterNamingStyle_InitializeField() - => TestInRegularAndScript1Async( + => TestInRegularAndScriptAsync( """ class C { @@ -1205,7 +1205,7 @@ public C(string s) [Fact] public Task TestCommonParameterNamingStyle_InitializeField() - => TestInRegularAndScript1Async( + => TestInRegularAndScriptAsync( """ class C { @@ -1230,7 +1230,7 @@ public C(string t_s) [Fact] public Task TestSpecifiedParameterNamingStyle_InitializeField() - => TestInRegularAndScript1Async( + => TestInRegularAndScriptAsync( """ class C { @@ -1255,7 +1255,7 @@ public C(string p_s_End) [Fact] public Task TestCommonAndSpecifiedParameterNamingStyle_InitializeField() - => TestInRegularAndScript1Async( + => TestInRegularAndScriptAsync( """ class C { @@ -1280,17 +1280,17 @@ public C(string t_p_s_End) [Fact] public Task TestCommonAndSpecifiedParameterNamingStyle2_InitializeField() - => TestInRegularAndScript1Async( -""" -class C -{ - private readonly string _s; - - public C([||]string p_t_s_End) + => TestInRegularAndScriptAsync( + """ + class C { + private readonly string _s; + + public C([||]string p_t_s_End) + { + } } -} -""", + """, """ class C { @@ -1305,7 +1305,7 @@ public C([||]string p_t_s_End) [Fact] public Task TestNoParameterNamingStyle_InitializeProperty() - => TestInRegularAndScript1Async( + => TestInRegularAndScriptAsync( """ class C { @@ -1330,7 +1330,7 @@ public C(string s) [Fact] public Task TestCommonParameterNamingStyle_InitializeProperty() - => TestInRegularAndScript1Async( + => TestInRegularAndScriptAsync( """ class C { @@ -1355,7 +1355,7 @@ public C(string t_s) [Fact] public Task TestSpecifiedParameterNamingStyle_InitializeProperty() - => TestInRegularAndScript1Async( + => TestInRegularAndScriptAsync( """ class C { @@ -1380,7 +1380,7 @@ public C(string p_s_End) [Fact] public Task TestCommonAndSpecifiedParameterNamingStyle_InitializeProperty() - => TestInRegularAndScript1Async( + => TestInRegularAndScriptAsync( """ class C { @@ -1405,17 +1405,17 @@ public C(string t_p_s_End) [Fact] public Task TestCommonAndSpecifiedParameterNamingStyle2_InitializeProperty() - => TestInRegularAndScript1Async( -""" -class C -{ - public C([||]string p_t_s_End) + => TestInRegularAndScriptAsync( + """ + class C { - } + public C([||]string p_t_s_End) + { + } - public string S { get; } -} -""", + public string S { get; } + } + """, """ class C { @@ -1460,7 +1460,7 @@ public C([|string p__End, string p_test_t|]) [Fact] public Task TestCreateFieldWithTopLevelNullability() - => TestInRegularAndScript1Async( + => TestInRegularAndScriptAsync( """ #nullable enable class C @@ -1485,7 +1485,7 @@ public C(string? s) [Fact] public Task TestCreatePropertyWithTopLevelNullability() - => TestInRegularAndScript1Async( + => TestInRegularAndScriptAsync( """ #nullable enable class C @@ -1510,7 +1510,7 @@ public C(string? s) [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/24526")] public Task TestSingleLineBlock_BraceOnNextLine() - => TestInRegularAndScript1Async( + => TestInRegularAndScriptAsync( """ class C { @@ -1547,11 +1547,11 @@ public C(string s) { public string S { get; } } - """, options: this.Option(CSharpFormattingOptions2.NewLineBeforeOpenBrace, NewLineBeforeOpenBracePlacement.All & ~NewLineBeforeOpenBracePlacement.Methods)); + """, new(options: this.Option(CSharpFormattingOptions2.NewLineBeforeOpenBrace, NewLineBeforeOpenBracePlacement.All & ~NewLineBeforeOpenBracePlacement.Methods))); [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/23308")] public Task TestGenerateFieldIfParameterFollowsExistingFieldAssignment() - => TestInRegularAndScript1Async( + => TestInRegularAndScriptAsync( """ class C { @@ -1579,7 +1579,7 @@ public C(string s, int i) [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/23308")] public Task TestGenerateFieldIfParameterPrecedesExistingFieldAssignment() - => TestInRegularAndScript1Async( + => TestInRegularAndScriptAsync( """ class C { @@ -1607,7 +1607,7 @@ public C(int i, string s) [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/23308")] public Task TestGenerateFieldIfParameterFollowsExistingFieldAssignment_TupleAssignment1() - => TestInRegularAndScript1Async( + => TestInRegularAndScriptAsync( """ class C { @@ -1636,7 +1636,7 @@ public C(string s, string t, int i) [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/23308")] public Task TestGenerateFieldIfParameterFollowsExistingFieldAssignment_TupleAssignment2() - => TestInRegularAndScript1Async( + => TestInRegularAndScriptAsync( """ class C { @@ -1661,7 +1661,7 @@ public C(string s, string t, int i) => [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/23308")] public Task TestGenerateFieldIfParameterFollowsExistingFieldAssignment_TupleAssignment3() - => TestInRegularAndScript1Async( + => TestInRegularAndScriptAsync( """ class C { @@ -1692,7 +1692,7 @@ public C(string s, string t, int i) [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/23308")] public Task TestGenerateFieldIfParameterPrecedesExistingFieldAssignment_TupleAssignment1() - => TestInRegularAndScript1Async( + => TestInRegularAndScriptAsync( """ class C { @@ -1721,7 +1721,7 @@ public C(int i, string s, string t) [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/23308")] public Task TestGenerateFieldIfParameterPrecedesExistingFieldAssignment_TupleAssignment2() - => TestInRegularAndScript1Async( + => TestInRegularAndScriptAsync( """ class C { @@ -1746,7 +1746,7 @@ public C(int i, string s, string t) => [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/23308")] public Task TestGenerateFieldIfParameterInMiddleOfExistingFieldAssignment_TupleAssignment1() - => TestInRegularAndScript1Async( + => TestInRegularAndScriptAsync( """ class C { @@ -1775,7 +1775,7 @@ public C(string s, int i, string t) [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/23308")] public Task TestGenerateFieldIfParameterInMiddleOfExistingFieldAssignment_TupleAssignment2() - => TestInRegularAndScript1Async( + => TestInRegularAndScriptAsync( """ class C { @@ -1800,7 +1800,7 @@ public C(string s, int i, string t) => [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/23308")] public Task TestGeneratePropertyIfParameterFollowsExistingPropertyAssignment_TupleAssignment1() - => TestInRegularAndScript1Async( + => TestInRegularAndScriptAsync( """ class C { @@ -1846,7 +1846,7 @@ public static void M2([||]__arglist) [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/35665")] public Task TestGenerateRemainingFields1() - => TestInRegularAndScript1Async( + => TestInRegularAndScriptAsync( """ class C { @@ -1873,7 +1873,7 @@ public C(int i, int j, int k) [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/35665")] public Task TestGenerateRemainingFields2() - => TestInRegularAndScript1Async( + => TestInRegularAndScriptAsync( """ class C { @@ -1903,7 +1903,7 @@ public C(int i, int j, int k) [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/35665")] public Task TestGenerateRemainingFields3() - => TestInRegularAndScript1Async( + => TestInRegularAndScriptAsync( """ class C { @@ -1933,7 +1933,7 @@ public C(int i, int j, int k) [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/35665")] public Task TestGenerateRemainingFields4() - => TestInRegularAndScript1Async( + => TestInRegularAndScriptAsync( """ class C { @@ -1963,7 +1963,7 @@ public C(int i, int j, int k) [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/35665")] public Task TestGenerateRemainingProperties1() - => TestInRegularAndScript1Async( + => TestInRegularAndScriptAsync( """ class C { @@ -1990,7 +1990,7 @@ public C(int i, int j, int k) [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/35665")] public Task TestGenerateRemainingProperties2() - => TestInRegularAndScript1Async( + => TestInRegularAndScriptAsync( """ class C { @@ -2021,7 +2021,7 @@ public C(int i, int j, int k) [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/35665")] public Task TestGenerateRemainingProperties3() - => TestInRegularAndScript1Async( + => TestInRegularAndScriptAsync( """ class C { @@ -2052,7 +2052,7 @@ public C(int i, int j, int k) [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/35665")] public Task TestGenerateRemainingProperties4() - => TestInRegularAndScript1Async( + => TestInRegularAndScriptAsync( """ class C { @@ -2109,7 +2109,7 @@ public Bar(int prop1, int [||]prop2) : base(prop1) { } [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/36998")] public Task TestInitializeThrowingProperty1() - => TestInRegularAndScript1Async( + => TestInRegularAndScriptAsync( """ using System; @@ -2138,7 +2138,7 @@ public C(string s) [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/36998")] public Task TestInitializeThrowingProperty2() - => TestInRegularAndScript1Async( + => TestInRegularAndScriptAsync( """ using System; @@ -2173,7 +2173,7 @@ public C(string s) [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/36998")] public Task TestInitializeThrowingProperty3() - => TestInRegularAndScript1Async( + => TestInRegularAndScriptAsync( """ using System; @@ -2208,7 +2208,7 @@ public C(string s) [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/36998")] public Task TestInitializeThrowingProperty4() - => TestInRegularAndScript1Async( + => TestInRegularAndScriptAsync( """ using System; @@ -2245,7 +2245,7 @@ public C(string s) [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/36998")] public Task TestInitializeThrowingProperty5() - => TestInRegularAndScript1Async( + => TestInRegularAndScriptAsync( """ using System; @@ -2282,7 +2282,7 @@ public C(string s) [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/36998")] public Task TestInitializeThrowingProperty6() - => TestInRegularAndScript1Async( + => TestInRegularAndScriptAsync( """ using System; diff --git a/src/EditorFeatures/CSharpTest/CodeActions/InitializeParameter/InitializeMemberFromPrimaryConstructorParameterTests.cs b/src/EditorFeatures/CSharpTest/CodeActions/InitializeParameter/InitializeMemberFromPrimaryConstructorParameterTests.cs index 8f3cab891e6c..221cb1910ebe 100644 --- a/src/EditorFeatures/CSharpTest/CodeActions/InitializeParameter/InitializeMemberFromPrimaryConstructorParameterTests.cs +++ b/src/EditorFeatures/CSharpTest/CodeActions/InitializeParameter/InitializeMemberFromPrimaryConstructorParameterTests.cs @@ -29,7 +29,7 @@ protected override CodeRefactoringProvider CreateCodeRefactoringProvider(EditorT [Fact] public Task TestInitializeFieldWithSameName() - => TestInRegularAndScript1Async( + => TestInRegularAndScriptAsync( """ class C([||]string s) { @@ -45,7 +45,7 @@ class C(string s) [Fact] public Task TestEndOfParameter1() - => TestInRegularAndScript1Async( + => TestInRegularAndScriptAsync( """ class C(string s[||]) { @@ -61,7 +61,7 @@ class C(string s) [Fact] public Task TestEndOfParameter2() - => TestInRegularAndScript1Async( + => TestInRegularAndScriptAsync( """ class C(string s[||], string t) { @@ -77,7 +77,7 @@ class C(string s, string t) [Fact] public Task TestInitializeFieldWithUnderscoreName() - => TestInRegularAndScript1Async( + => TestInRegularAndScriptAsync( """ class C([||]string s) { @@ -93,7 +93,7 @@ class C(string s) [Fact] public Task TestInitializeWritableProperty() - => TestInRegularAndScript1Async( + => TestInRegularAndScriptAsync( """ class C([||]string s) { @@ -127,7 +127,7 @@ class C(string s) [Fact] public Task TestInitializeNonWritableProperty() - => TestInRegularAndScript1Async( + => TestInRegularAndScriptAsync( """ class C([||]string s) { @@ -162,7 +162,7 @@ class C(string s) [Fact] public Task TestInitializeFieldWithWrongType1() - => TestInRegularAndScript1Async( + => TestInRegularAndScriptAsync( """ class C([||]string s) { @@ -180,7 +180,7 @@ class C(string s) [Fact] public Task TestInitializeFieldWithWrongType2() - => TestInRegularAndScript1Async( + => TestInRegularAndScriptAsync( """ class C([||]string s) { @@ -235,7 +235,7 @@ class C([||]string s) [Fact] public Task TestWhenAlreadyInitialized3() - => TestInRegularAndScript1Async( + => TestInRegularAndScriptAsync( """ class C([||]string s) { @@ -254,7 +254,7 @@ class C([||]string s) [Fact] public Task TestInsertionLocation1() - => TestInRegularAndScript1Async( + => TestInRegularAndScriptAsync( """ class C([||]string s, string t) { @@ -272,7 +272,7 @@ class C(string s, string t) [Fact] public Task TestInsertionLocation2() - => TestInRegularAndScript1Async( + => TestInRegularAndScriptAsync( """ class C(string s, [||]string t) { @@ -304,7 +304,7 @@ public void M([||]string s) [Fact] public Task TestInsertionLocation6() - => TestInRegularAndScript1Async( + => TestInRegularAndScriptAsync( """ class C(string s, [||]string t) { @@ -321,7 +321,7 @@ class C(string s, string t) [Fact] public Task TestInsertionLocation7() - => TestInRegularAndScript1Async( + => TestInRegularAndScriptAsync( """ class C([||]string s, string t) { @@ -338,7 +338,7 @@ class C(string s, string t) [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/19956")] public Task TestNoBlock1() - => TestInRegularAndScript1Async( + => TestInRegularAndScriptAsync( """ class C(string s[||]) """, @@ -352,7 +352,7 @@ class C(string s) [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/19956")] public Task TestNoBlock2() - => TestInRegularAndScript1Async( + => TestInRegularAndScriptAsync( """ class C(string s[||]) """, @@ -367,7 +367,7 @@ class C(string s) [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/29190")] public Task TestInitializeFieldWithParameterNameSelected1() - => TestInRegularAndScript1Async( + => TestInRegularAndScriptAsync( """ class C(string [|s|]) { @@ -383,7 +383,7 @@ class C(string s) [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/29190")] public Task TestInitializeField_ParameterNameSelected2() - => TestInRegularAndScript1Async( + => TestInRegularAndScriptAsync( """ class C(string [|s|], int i) { @@ -399,7 +399,7 @@ class C(string s, int i) [Fact] public Task TestInitializeClassProperty_RequiredAccessibilityOmitIfDefault() - => TestInRegularAndScript1Async( + => TestInRegularAndScriptAsync( """ class C(int test, int [|test2|]) { @@ -417,7 +417,7 @@ class C(int test, int test2) [Fact] public Task TestInitializeClassProperty_RequiredAccessibilityNever() - => TestInRegularAndScript1Async( + => TestInRegularAndScriptAsync( """ class C(int test, int [|test2|]) { @@ -435,7 +435,7 @@ class C(int test, int test2) [Fact] public Task TestInitializeClassProperty_RequiredAccessibilityAlways() - => TestInRegularAndScript1Async( + => TestInRegularAndScriptAsync( """ class C(int test, int [|test2|]) { @@ -453,7 +453,7 @@ class C(int test, int test2) [Fact] public Task TestInitializeClassField_RequiredAccessibilityOmitIfDefault() - => TestInRegularAndScript1Async( + => TestInRegularAndScriptAsync( """ class C(int test, int [|test2|]) { @@ -470,7 +470,7 @@ class C(int test, int test2) [Fact] public Task TestInitializeClassField_RequiredAccessibilityNever() - => TestInRegularAndScript1Async( + => TestInRegularAndScriptAsync( """ class C(int test, int [|test2|]) { @@ -487,7 +487,7 @@ class C(int test, int test2) [Fact] public Task TestInitializeClassField_RequiredAccessibilityAlways() - => TestInRegularAndScript1Async( + => TestInRegularAndScriptAsync( """ class C(int test, int [|test2|]) { @@ -504,7 +504,7 @@ class C(int test, int test2) [Fact] public Task TestInitializeStructProperty_RequiredAccessibilityOmitIfDefault() - => TestInRegularAndScript1Async( + => TestInRegularAndScriptAsync( """ struct S(int [|test|]) { @@ -519,7 +519,7 @@ struct S(int test) [Fact] public Task TestInitializeStructProperty_RequiredAccessibilityNever() - => TestInRegularAndScript1Async( + => TestInRegularAndScriptAsync( """ struct S(int [|test|]) { @@ -534,7 +534,7 @@ struct S(int test) [Fact] public Task TestInitializeStructProperty_RequiredAccessibilityAlways() - => TestInRegularAndScript1Async( + => TestInRegularAndScriptAsync( """ struct S(int [|test|]) { @@ -549,7 +549,7 @@ struct S(int test) [Fact] public Task TestInitializeStructField_RequiredAccessibilityOmitIfDefault() - => TestInRegularAndScript1Async( + => TestInRegularAndScriptAsync( """ struct S(int [|test|]) { @@ -564,7 +564,7 @@ struct S(int test) [Fact] public Task TestInitializeStructField_RequiredAccessibilityNever() - => TestInRegularAndScript1Async( + => TestInRegularAndScriptAsync( """ struct S(int [|test|]) { @@ -579,7 +579,7 @@ struct S(int test) [Fact] public Task TestInitializeStructField_RequiredAccessibilityAlways() - => TestInRegularAndScript1Async( + => TestInRegularAndScriptAsync( """ struct S(int [|test|]) { @@ -594,7 +594,7 @@ struct S(int test) [Fact] public Task TestNoParameterNamingStyle_CreateAndInitField() - => TestInRegularAndScript1Async( + => TestInRegularAndScriptAsync( """ class C([||]string s) { @@ -609,7 +609,7 @@ class C(string s) [Fact] public Task TestCommonParameterNamingStyle_CreateAndInitField() - => TestInRegularAndScript1Async( + => TestInRegularAndScriptAsync( """ class C([||]string t_s) { @@ -624,7 +624,7 @@ class C(string t_s) [Fact] public Task TestSpecifiedParameterNamingStyle_CreateAndInitField() - => TestInRegularAndScript1Async( + => TestInRegularAndScriptAsync( """ class C([||]string p_s_End) { @@ -639,7 +639,7 @@ class C(string p_s_End) [Fact] public Task TestCommonAndSpecifiedParameterNamingStyle_CreateAndInitField() - => TestInRegularAndScript1Async( + => TestInRegularAndScriptAsync( """ class C([||]string t_p_s_End) { @@ -654,7 +654,7 @@ class C(string t_p_s_End) [Fact] public Task TestCommonAndSpecifiedParameterNamingStyle2_CreateAndInitField() - => TestInRegularAndScript1Async( + => TestInRegularAndScriptAsync( """ class C([||]string p_t_s) { @@ -669,7 +669,7 @@ class C([||]string p_t_s) [Fact] public Task TestNoParameterNamingStyle_CreateAndInitProperty() - => TestInRegularAndScript1Async( + => TestInRegularAndScriptAsync( """ class C([||]string s) { @@ -684,7 +684,7 @@ class C(string s) [Fact] public Task TestCommonParameterNamingStyle_CreateAndInitProperty() - => TestInRegularAndScript1Async( + => TestInRegularAndScriptAsync( """ class C([||]string t_s) { @@ -699,7 +699,7 @@ class C(string t_s) [Fact] public Task TestSpecifiedParameterNamingStyle_CreateAndInitProperty() - => TestInRegularAndScript1Async( + => TestInRegularAndScriptAsync( """ class C([||]string p_s_End) { @@ -714,7 +714,7 @@ class C(string p_s_End) [Fact] public Task TestCommonAndSpecifiedParameterNamingStyle_CreateAndInitProperty() - => TestInRegularAndScript1Async( + => TestInRegularAndScriptAsync( """ class C([||]string t_p_s_End) { @@ -729,7 +729,7 @@ class C(string t_p_s_End) [Fact] public Task TestCommonAndSpecifiedParameterNamingStyle2_CreateAndInitProperty() - => TestInRegularAndScript1Async( + => TestInRegularAndScriptAsync( """ class C([||]string p_t_s_End) { @@ -744,7 +744,7 @@ class C(string p_t_s_End) [Fact] public Task TestNoParameterNamingStyle_InitializeField() - => TestInRegularAndScript1Async( + => TestInRegularAndScriptAsync( """ class C([||]string s) { @@ -760,7 +760,7 @@ class C(string s) [Fact] public Task TestCommonParameterNamingStyle_InitializeField() - => TestInRegularAndScript1Async( + => TestInRegularAndScriptAsync( """ class C([||]string t_s) { @@ -776,7 +776,7 @@ class C(string t_s) [Fact] public Task TestSpecifiedParameterNamingStyle_InitializeField() - => TestInRegularAndScript1Async( + => TestInRegularAndScriptAsync( """ class C([||]string p_s_End) { @@ -792,7 +792,7 @@ class C(string p_s_End) [Fact] public Task TestCommonAndSpecifiedParameterNamingStyle_InitializeField() - => TestInRegularAndScript1Async( + => TestInRegularAndScriptAsync( """ class C([||]string t_p_s_End) { @@ -808,7 +808,7 @@ class C(string t_p_s_End) [Fact] public Task TestCommonAndSpecifiedParameterNamingStyle2_InitializeField() - => TestInRegularAndScript1Async( + => TestInRegularAndScriptAsync( """ class C([||]string p_t_s_End) { @@ -824,7 +824,7 @@ class C([||]string p_t_s_End) [Fact] public Task TestNoParameterNamingStyle_InitializeProperty() - => TestInRegularAndScript1Async( + => TestInRegularAndScriptAsync( """ class C([||]string s) { @@ -840,7 +840,7 @@ class C(string s) [Fact] public Task TestCommonParameterNamingStyle_InitializeProperty() - => TestInRegularAndScript1Async( + => TestInRegularAndScriptAsync( """ class C([||]string t_s) { @@ -856,7 +856,7 @@ class C(string t_s) [Fact] public Task TestSpecifiedParameterNamingStyle_InitializeProperty() - => TestInRegularAndScript1Async( + => TestInRegularAndScriptAsync( """ class C([||]string p_s_End) { @@ -872,7 +872,7 @@ class C(string p_s_End) [Fact] public Task TestCommonAndSpecifiedParameterNamingStyle_InitializeProperty() - => TestInRegularAndScript1Async( + => TestInRegularAndScriptAsync( """ class C([||]string t_p_s_End) { @@ -888,7 +888,7 @@ class C(string t_p_s_End) [Fact] public Task TestCommonAndSpecifiedParameterNamingStyle2_InitializeProperty() - => TestInRegularAndScript1Async( + => TestInRegularAndScriptAsync( """ class C([||]string p_t_s_End) { @@ -923,7 +923,7 @@ class C([|string p__End, string p_test_t|]) [Fact] public Task TestCreateFieldWithTopLevelNullability() - => TestInRegularAndScript1Async( + => TestInRegularAndScriptAsync( """ #nullable enable class C([||]string? s) @@ -940,7 +940,7 @@ class C(string? s) [Fact] public Task TestCreatePropertyWithTopLevelNullability() - => TestInRegularAndScript1Async( + => TestInRegularAndScriptAsync( """ #nullable enable class C([||]string? s) @@ -957,7 +957,7 @@ class C(string? s) [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/24526")] public Task TestSingleLineBlock_BraceOnNextLine() - => TestInRegularAndScript1Async( + => TestInRegularAndScriptAsync( """ class C([||]string s) { } """, @@ -978,11 +978,11 @@ class C([||]string s) { } class C(string s) { public string S { get; } = s; } - """, options: this.Option(CSharpFormattingOptions2.NewLineBeforeOpenBrace, NewLineBeforeOpenBracePlacement.All & ~NewLineBeforeOpenBracePlacement.Types)); + """, new(options: this.Option(CSharpFormattingOptions2.NewLineBeforeOpenBrace, NewLineBeforeOpenBracePlacement.All & ~NewLineBeforeOpenBracePlacement.Types))); [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/23308")] public Task TestGenerateFieldIfParameterFollowsExistingFieldAssignment() - => TestInRegularAndScript1Async( + => TestInRegularAndScriptAsync( """ class C(string s, [||]int i) { @@ -999,7 +999,7 @@ class C(string s, int i) [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/23308")] public Task TestGenerateFieldIfParameterPrecedesExistingFieldAssignment() - => TestInRegularAndScript1Async( + => TestInRegularAndScriptAsync( """ class C([||]int i, string s) { @@ -1016,7 +1016,7 @@ class C(int i, string s) [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/35665")] public Task TestGenerateRemainingFields1() - => TestInRegularAndScript1Async( + => TestInRegularAndScriptAsync( """ class C([||]int i, int j, int k) { @@ -1033,7 +1033,7 @@ class C(int i, int j, int k) [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/35665")] public Task TestGenerateRemainingFields2() - => TestInRegularAndScript1Async( + => TestInRegularAndScriptAsync( """ class C(int i, [||]int j, int k) { @@ -1051,7 +1051,7 @@ class C(int i, int j, int k) [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/35665")] public Task TestGenerateRemainingFields3() - => TestInRegularAndScript1Async( + => TestInRegularAndScriptAsync( """ class C([||]int i, int j, int k) { @@ -1069,7 +1069,7 @@ class C(int i, int j, int k) [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/35665")] public Task TestGenerateRemainingFields4() - => TestInRegularAndScript1Async( + => TestInRegularAndScriptAsync( """ class C([||]int i, int j, int k) { @@ -1087,7 +1087,7 @@ class C(int i, int j, int k) [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/35665")] public Task TestGenerateRemainingProperties1() - => TestInRegularAndScript1Async( + => TestInRegularAndScriptAsync( """ class C([||]int i, int j, int k) { @@ -1104,7 +1104,7 @@ class C(int i, int j, int k) [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/35665")] public Task TestGenerateRemainingProperties2() - => TestInRegularAndScript1Async( + => TestInRegularAndScriptAsync( """ class C(int i, [||]int j, int k) { @@ -1123,7 +1123,7 @@ class C(int i, int j, int k) [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/35665")] public Task TestGenerateRemainingProperties3() - => TestInRegularAndScript1Async( + => TestInRegularAndScriptAsync( """ class C([||]int i, int j, int k) { @@ -1142,7 +1142,7 @@ class C(int i, int j, int k) [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/35665")] public Task TestGenerateRemainingProperties4() - => TestInRegularAndScript1Async( + => TestInRegularAndScriptAsync( """ class C([||]int i, int j, int k) { @@ -1161,7 +1161,7 @@ class C(int i, int j, int k) [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/36998")] public Task TestInitializeThrowingProperty1() - => TestInRegularAndScript1Async( + => TestInRegularAndScriptAsync( """ using System; @@ -1181,7 +1181,7 @@ class C(string s) [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/36998")] public Task TestInitializeThrowingProperty2() - => TestInRegularAndScript1Async( + => TestInRegularAndScriptAsync( """ using System; @@ -1207,7 +1207,7 @@ private string S [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/36998")] public Task TestInitializeThrowingProperty3() - => TestInRegularAndScript1Async( + => TestInRegularAndScriptAsync( """ using System; @@ -1233,7 +1233,7 @@ private string S [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/36998")] public Task TestInitializeThrowingProperty4() - => TestInRegularAndScript1Async( + => TestInRegularAndScriptAsync( """ using System; @@ -1261,7 +1261,7 @@ private string S [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/36998")] public Task TestInitializeThrowingProperty5() - => TestInRegularAndScript1Async( + => TestInRegularAndScriptAsync( """ using System; @@ -1289,7 +1289,7 @@ private string S [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/36998")] public Task TestInitializeThrowingProperty6() - => TestInRegularAndScript1Async( + => TestInRegularAndScriptAsync( """ using System; @@ -1351,7 +1351,7 @@ public partial class Goo [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/76565")] public Task TestCouldInitializeThrowingProperty_ButGeneratePropertyInstead() - => TestInRegularAndScript1Async( + => TestInRegularAndScriptAsync( """ using System; @@ -1373,7 +1373,7 @@ class C(string s) [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/76565")] public Task TestCouldInitializeThrowingProperty_ButGenerateFieldInstead() - => TestInRegularAndScript1Async( + => TestInRegularAndScriptAsync( """ using System; @@ -1395,7 +1395,7 @@ class C(string s) [Fact] public Task TestUpdateCodeToReferenceExistingField1() - => TestInRegularAndScript1Async( + => TestInRegularAndScriptAsync( """ using System; @@ -1427,7 +1427,7 @@ private void M() [Fact] public Task TestUpdateCodeToReferenceExistingField2() - => TestInRegularAndScript1Async( + => TestInRegularAndScriptAsync( """ using System; @@ -1459,7 +1459,7 @@ private void M() [Fact] public Task TestUpdateCodeToReferenceExistingProperty() - => TestInRegularAndScript1Async( + => TestInRegularAndScriptAsync( """ using System; @@ -1491,7 +1491,7 @@ private void M() [Fact] public Task TestUpdateCodeToReferenceExistingProperty2() - => TestInRegularAndScript1Async( + => TestInRegularAndScriptAsync( """ using System; @@ -1523,7 +1523,7 @@ private void M() [Fact] public Task TestUpdateCodeToReferenceNewProperty1() - => TestInRegularAndScript1Async( + => TestInRegularAndScriptAsync( """ using System; @@ -1553,7 +1553,7 @@ private void M() [Fact] public Task TestUpdateCodeToReferenceNewField1() - => TestInRegularAndScript1Async( + => TestInRegularAndScriptAsync( """ using System; @@ -1583,7 +1583,7 @@ private void M() [Fact] public Task TestInitializeIntoFieldInDifferentPart() - => TestInRegularAndScript1Async( + => TestInRegularAndScriptAsync( """ partial class C([||]string s) { @@ -1607,7 +1607,7 @@ partial class C [Fact] public Task TestInitializeIntoPropertyInDifferentPart() - => TestInRegularAndScript1Async( + => TestInRegularAndScriptAsync( """ partial class C([||]string s) { diff --git a/src/EditorFeatures/CSharpTest/CodeActions/MoveType/MoveTypeTests.MoveScope.cs b/src/EditorFeatures/CSharpTest/CodeActions/MoveType/MoveTypeTests.MoveScope.cs index 0f2d0407493a..f8dbeb9ac52f 100644 --- a/src/EditorFeatures/CSharpTest/CodeActions/MoveType/MoveTypeTests.MoveScope.cs +++ b/src/EditorFeatures/CSharpTest/CodeActions/MoveType/MoveTypeTests.MoveScope.cs @@ -20,8 +20,7 @@ public partial class MoveTypeTests : CSharpMoveTypeTestsBase { [Fact] public Task MoveType_NamespaceScope_SingleItem() - { - return TestNamespaceMove(""" + => TestNamespaceMove(""" namespace N1 { class [||]Class1 @@ -36,12 +35,10 @@ class Class1 } } """, expectOperation: false); - } [Fact] public Task MoveType_NamespaceScope_SingleItemNamespaceComment() - { - return TestNamespaceMove(""" + => TestNamespaceMove(""" // Comment on the namespace namespace N1 { @@ -58,12 +55,10 @@ class Class1 } } """, expectOperation: false); - } [Fact] public Task MoveType_NamespaceScope_ItemAtTop() - { - return TestNamespaceMove(""" + => TestNamespaceMove(""" namespace N1 { class [||]Class1 @@ -89,12 +84,10 @@ class Class2 } } """); - } [Fact] public Task MoveType_NamespaceScope_ItemAtTopNamespaceComment() - { - return TestNamespaceMove(""" + => TestNamespaceMove(""" // Comment on the namespace namespace N1 { @@ -122,12 +115,10 @@ class Class2 } } """); - } [Fact] public Task MoveType_NamespaceScope_ItemAtTopWithComments() - { - return TestNamespaceMove(""" + => TestNamespaceMove(""" namespace N1 { // Class1 Comment @@ -157,12 +148,10 @@ class Class2 } } """); - } [Fact] public Task MoveType_NamespaceScope_ItemAtTopWithXmlComments() - { - return TestNamespaceMove(""" + => TestNamespaceMove(""" namespace N1 { /// @@ -200,12 +189,10 @@ class Class2 } } """); - } [Fact] public Task MoveType_NamespaceScope_ItemAtBottom() - { - return TestNamespaceMove(""" + => TestNamespaceMove(""" namespace N1 { class Class1 @@ -231,12 +218,10 @@ class Class2 } } """); - } [Fact] public Task MoveType_NamespaceScope_ItemAtBottomNamespaceComments() - { - return TestNamespaceMove(""" + => TestNamespaceMove(""" // Comment on the namespace namespace N1 { @@ -264,12 +249,10 @@ class Class2 } } """); - } [Fact] public Task MoveType_NamespaceScope_ItemAtBottomWithComments() - { - return TestNamespaceMove(""" + => TestNamespaceMove(""" namespace N1 { // Class1 comment @@ -299,12 +282,10 @@ class Class2 } } """); - } [Fact] public Task MoveType_NamespaceScope_ItemAtBottomWithXmlComments() - { - return TestNamespaceMove(""" + => TestNamespaceMove(""" namespace N1 { /// @@ -342,12 +323,10 @@ class Class2 } } """); - } [Fact] public Task MoveType_NamespaceScope_ItemInMiddle() - { - return TestNamespaceMove(""" + => TestNamespaceMove(""" namespace N1 { class Class1 @@ -400,12 +379,10 @@ class Class5 } } """); - } [Fact] public Task MoveType_NamespaceScope_ItemInMiddleNamespaceComment() - { - return TestNamespaceMove(""" + => TestNamespaceMove(""" // Comment on the namespace namespace N1 { @@ -460,12 +437,10 @@ class Class5 } } """); - } [Fact] public Task MoveType_NamespaceScope_ItemInMiddleWithComments() - { - return TestNamespaceMove(""" + => TestNamespaceMove(""" namespace N1 { // Class1 comment @@ -528,12 +503,10 @@ class Class5 } } """); - } [Fact] public Task MoveType_NamespaceScope_ItemInMiddleWithXmlComments() - { - return TestNamespaceMove(""" + => TestNamespaceMove(""" namespace N1 { /// @@ -616,12 +589,10 @@ class Class5 } } """); - } [Fact] public Task MoveType_NamespaceScope_ItemInMiddleWithInterface() - { - return TestNamespaceMove(""" + => TestNamespaceMove(""" namespace N1 { // Class1 comment @@ -688,12 +659,10 @@ class Class5 } } """); - } [Fact] public Task MoveType_NamespaceScope_TwoItemsInDifferentNamespace() - { - return TestNamespaceMove(""" + => TestNamespaceMove(""" namespace N1 { class [||]Class1 @@ -722,12 +691,10 @@ class Class2 } } """, expectOperation: false); - } [Fact] public Task MoveType_NamespaceScope_ItemsInDifferentNamespace() - { - return TestNamespaceMove(""" + => TestNamespaceMove(""" namespace N1 { interface IClass1 @@ -767,12 +734,10 @@ class Class2 } } """); - } [Fact] public Task MoveType_NamespaceScope_NestedNamespaces() - { - return TestNamespaceMove(""" + => TestNamespaceMove(""" namespace N1 { namespace N2 @@ -812,12 +777,10 @@ class C3 } } """); - } [Fact] public Task MoveType_NamespaceScope_NestedNamespaces2() - { - return TestNamespaceMove(""" + => TestNamespaceMove(""" namespace N1 { namespace N2 @@ -874,7 +837,6 @@ class C4 } } """); - } private async Task TestNamespaceMove(string originalCode, string expectedCode, bool expectOperation = true) { diff --git a/src/EditorFeatures/CSharpTest/CodeActions/PreviewExceptionTests.cs b/src/EditorFeatures/CSharpTest/CodeActions/PreviewExceptionTests.cs index ad5cbb59f472..7a9ced1875ec 100644 --- a/src/EditorFeatures/CSharpTest/CodeActions/PreviewExceptionTests.cs +++ b/src/EditorFeatures/CSharpTest/CodeActions/PreviewExceptionTests.cs @@ -25,7 +25,7 @@ public sealed partial class PreviewTests [WpfFact] public async Task TestExceptionInComputePreview() { - using var workspace = CreateWorkspaceFromOptions("class D {}", new TestParameters()); + using var workspace = CreateWorkspaceFromOptions("class D {}", TestParameters.Default); var errorReportingService = (TestErrorReportingService)workspace.Services.GetRequiredService(); var errorReported = false; @@ -38,7 +38,7 @@ public async Task TestExceptionInComputePreview() [WpfFact] public void TestExceptionInDisplayText() { - using var workspace = CreateWorkspaceFromOptions("class D {}", new TestParameters()); + using var workspace = CreateWorkspaceFromOptions("class D {}", TestParameters.Default); var errorReportingService = (TestErrorReportingService)workspace.Services.GetRequiredService(); var errorReported = false; @@ -51,7 +51,7 @@ public void TestExceptionInDisplayText() [WpfFact] public async Task TestExceptionInActionSets() { - using var workspace = CreateWorkspaceFromOptions("class D {}", new TestParameters()); + using var workspace = CreateWorkspaceFromOptions("class D {}", TestParameters.Default); var errorReportingService = (TestErrorReportingService)workspace.Services.GetRequiredService(); var errorReported = false; diff --git a/src/EditorFeatures/CSharpTest/CodeActions/PreviewTests.cs b/src/EditorFeatures/CSharpTest/CodeActions/PreviewTests.cs index 8ca877748d2f..abb67d2e918a 100644 --- a/src/EditorFeatures/CSharpTest/CodeActions/PreviewTests.cs +++ b/src/EditorFeatures/CSharpTest/CodeActions/PreviewTests.cs @@ -106,7 +106,7 @@ protected override Task GetChangedSolutionAsync( [WpfFact] public async Task TestPickTheRightPreview_NoPreference() { - var parameters = new TestParameters(); + var parameters = TestParameters.Default; using var workspace = CreateWorkspaceFromOptions("class D {}", parameters); var (document, previews) = await GetMainDocumentAndPreviewsAsync(parameters, workspace); diff --git a/src/EditorFeatures/CSharpTest/CodeActions/PullMemberUp/CSharpPullMemberUpTests.cs b/src/EditorFeatures/CSharpTest/CodeActions/PullMemberUp/CSharpPullMemberUpTests.cs index 7fbbb97bc092..88f61b443467 100644 --- a/src/EditorFeatures/CSharpTest/CodeActions/PullMemberUp/CSharpPullMemberUpTests.cs +++ b/src/EditorFeatures/CSharpTest/CodeActions/PullMemberUp/CSharpPullMemberUpTests.cs @@ -3704,8 +3704,7 @@ public Goo(String s) [Fact, WorkItem(55746, "https://github.com/dotnet/roslyn/issues/51531")] public Task TestPullMethodToClassWithDirective() - { - return TestWithPullMemberDialogAsync(""" + => TestWithPullMemberDialogAsync(""" public class BaseClass { } @@ -3729,12 +3728,10 @@ public class Bar : BaseClass #endregion } """); - } [Fact, WorkItem(55746, "https://github.com/dotnet/roslyn/issues/51531")] public Task TestPullMethodToClassBeforeDirective() - { - return TestWithPullMemberDialogAsync(""" + => TestWithPullMemberDialogAsync(""" public class BaseClass { } @@ -3759,12 +3756,10 @@ public void Goo() { } #endregion } """); - } [Fact, WorkItem(55746, "https://github.com/dotnet/roslyn/issues/51531")] public Task TestPullMethodToClassBeforeDirective2() - { - return TestWithPullMemberDialogAsync(""" + => TestWithPullMemberDialogAsync(""" public class BaseClass { } @@ -3792,12 +3787,10 @@ public void Hello() { } #endregion } """); - } [Fact, WorkItem(55746, "https://github.com/dotnet/roslyn/issues/51531")] public Task TestPullFieldToClassBeforeDirective1() - { - return TestWithPullMemberDialogAsync(""" + => TestWithPullMemberDialogAsync(""" public class BaseClass { } @@ -3822,12 +3815,10 @@ public class Bar : BaseClass #endregion } """); - } [Fact, WorkItem(55746, "https://github.com/dotnet/roslyn/issues/51531")] public Task TestPullFieldToClassBeforeDirective2() - { - return TestWithPullMemberDialogAsync(""" + => TestWithPullMemberDialogAsync(""" public class BaseClass { } @@ -3853,12 +3844,10 @@ public class Bar : BaseClass #endregion } """); - } [Fact, WorkItem(55746, "https://github.com/dotnet/roslyn/issues/51531")] public Task TestPullFieldToClassBeforeDirective() - { - return TestWithPullMemberDialogAsync(""" + => TestWithPullMemberDialogAsync(""" public class BaseClass { } @@ -3882,12 +3871,10 @@ public class Bar : BaseClass #endregion } """); - } [Fact, WorkItem(55746, "https://github.com/dotnet/roslyn/issues/51531")] public Task TestPullEventToClassBeforeDirective() - { - return TestWithPullMemberDialogAsync(""" + => TestWithPullMemberDialogAsync(""" using System; public class BaseClass { @@ -3913,12 +3900,10 @@ public class Bar : BaseClass #endregion } """); - } [Fact, WorkItem(55746, "https://github.com/dotnet/roslyn/issues/51531")] public Task TestPullPropertyToClassBeforeDirective() - { - return TestWithPullMemberDialogAsync(""" + => TestWithPullMemberDialogAsync(""" public class BaseClass { } @@ -3942,12 +3927,10 @@ public class Bar : BaseClass #endregion } """); - } [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/55402")] public Task TestPullPropertyToClassOnKeyword() - { - return TestWithPullMemberDialogAsync(""" + => TestWithPullMemberDialogAsync(""" public class BaseClass { } @@ -3966,7 +3949,6 @@ public class Derived : BaseClass { } """); - } #endregion Quick Action @@ -3983,7 +3965,7 @@ internal Task TestWithPullMemberDialogAsync( { var service = new TestPullMemberUpService(selection, destinationName); - return TestInRegularAndScript1Async( + return TestInRegularAndScriptAsync( initialMarkUp, expectedResult, (parameters ?? TestParameters.Default).WithFixProviderData(service).WithOptions(options).WithIndex(index)); } diff --git a/src/EditorFeatures/CSharpTest/CodeActions/SyncNamespace/CSharpSyncNamespaceTestsBase.cs b/src/EditorFeatures/CSharpTest/CodeActions/SyncNamespace/CSharpSyncNamespaceTestsBase.cs index 52708bf17e7d..1502807b2c5e 100644 --- a/src/EditorFeatures/CSharpTest/CodeActions/SyncNamespace/CSharpSyncNamespaceTestsBase.cs +++ b/src/EditorFeatures/CSharpTest/CodeActions/SyncNamespace/CSharpSyncNamespaceTestsBase.cs @@ -58,7 +58,7 @@ protected static string CreateFolderPath(params string[] folders) protected async Task TestMoveFileToMatchNamespace(string initialMarkup, List expectedFolders = null) { - var testOptions = new TestParameters(); + var testOptions = TestParameters.Default; using (var workspace = (EditorTestWorkspace)CreateWorkspaceFromOptions(initialMarkup, testOptions)) { if (expectedFolders?.Count > 0) @@ -136,7 +136,7 @@ protected async Task TestChangeNamespaceAsync( string expectedSourceOriginal, string expectedSourceReference = null) { - var testOptions = new TestParameters(); + var testOptions = TestParameters.Default; using (var workspace = CreateWorkspaceFromOptions(initialMarkUp, testOptions)) { if (workspace.Projects.Count == 2) diff --git a/src/EditorFeatures/CSharpTest/CodeLens/CSharpCodeLensTests.cs b/src/EditorFeatures/CSharpTest/CodeLens/CSharpCodeLensTests.cs index dca07b4e0215..ae383dd7bc91 100644 --- a/src/EditorFeatures/CSharpTest/CodeLens/CSharpCodeLensTests.cs +++ b/src/EditorFeatures/CSharpTest/CodeLens/CSharpCodeLensTests.cs @@ -16,9 +16,8 @@ namespace Microsoft.CodeAnalysis.Editor.CSharp.UnitTests.CodeLens; public sealed class CSharpCodeLensTests : AbstractCodeLensTest { [Fact] - public async Task TestCount() - { - const string input = """ + public Task TestCount() + => RunCountTest(""" - """; - await RunCountTest(input); - } + """); [Fact] - public async Task TestCapping() - { - const string input = """ + public Task TestCapping() + => RunCountTest(""" - """; - - await RunCountTest(input, 1); - } + """, 1); [Fact] - public async Task TestLinkedFiles() - { - const string input = """ + public Task TestLinkedFiles() + => RunReferenceTest(""" - """; - - await RunReferenceTest(input); - } + """); [Fact] - public async Task TestDisplay() - { - const string input = """ + public Task TestDisplay() + => RunReferenceTest(""" - """; - - await RunReferenceTest(input); - } + """); [Fact] - public async Task TestMethodReferences() - { - const string input = """ + public Task TestMethodReferences() + => RunMethodReferenceTest(""" - """; - await RunMethodReferenceTest(input); - } + """); [Fact] - public async Task TestMethodReferencesWithDocstrings() - { - const string input = """ + public Task TestMethodReferencesWithDocstrings() + => RunMethodReferenceTest(""" - """; - await RunMethodReferenceTest(input); - } + """); [Theory] [InlineData("class")] @@ -267,9 +246,8 @@ public Task TestFullyQualifiedName(string typeKind) """); [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/49636")] - public async Task TestExplicitParameterlessConstructor() - { - const string input = """ + public Task TestExplicitParameterlessConstructor() + => RunReferenceTest(""" - """; - await RunReferenceTest(input); - } + """); [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/49636")] - public async Task TestExplicitParameterlessConstructor_TwoCalls() - { - const string input = """ + public Task TestExplicitParameterlessConstructor_TwoCalls() + => RunReferenceTest(""" - """; - await RunReferenceTest(input); - } + """); [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/49636")] - public async Task TestImplicitParameterlessConstructor() - { - const string input = """ + public Task TestImplicitParameterlessConstructor() + => RunReferenceTest(""" - """; - await RunReferenceTest(input); - } + """); [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/49636")] - public async Task TestImplicitParameterlessConstructor_TwoCalls() - { - const string input = """ + public Task TestImplicitParameterlessConstructor_TwoCalls() + => RunReferenceTest(""" - """; - await RunReferenceTest(input); - } + """); [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/51633")] - public async Task TestMethodRefSourceGeneratedDocument() - { - const string input = """ + public Task TestMethodRefSourceGeneratedDocument() + => RunMethodReferenceTest(""" - """; - await RunMethodReferenceTest(input); - } + """); [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/64592")] - public async Task TestFileScopedTypes() - { - const string input = """ + public Task TestFileScopedTypes() + => RunReferenceTest(""" - """; - await RunReferenceTest(input); - } + """); [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/67956")] - public async Task TestConstructorReferencesInOtherProject() - { - const string input = """ + public Task TestConstructorReferencesInOtherProject() + => RunReferenceTest(""" - """; - await RunReferenceTest(input); - } + """); } diff --git a/src/EditorFeatures/CSharpTest/CommentSelection/CSharpCommentSelectionTests.cs b/src/EditorFeatures/CSharpTest/CommentSelection/CSharpCommentSelectionTests.cs index 2e4973741f2e..e7a694242a26 100644 --- a/src/EditorFeatures/CSharpTest/CommentSelection/CSharpCommentSelectionTests.cs +++ b/src/EditorFeatures/CSharpTest/CommentSelection/CSharpCommentSelectionTests.cs @@ -25,8 +25,7 @@ public sealed class CSharpCommentSelectionTests { [WpfFact] public void UncommentAndFormat1() - { - UncommentSelection(""" + => UncommentSelection(""" class A { [| // void Method ( ) @@ -43,12 +42,10 @@ void Method() } } """); - } [WpfFact] public void UncommentAndFormat2() - { - UncommentSelection(""" + => UncommentSelection(""" class A { [| /* void Method ( ) @@ -65,12 +62,10 @@ void Method() } } """); - } [WpfFact] public void UncommentSingleLineCommentInPseudoBlockComment() - { - UncommentSelection(""" + => UncommentSelection(""" class C { /// @@ -91,12 +86,10 @@ protected void RtlTranslateAlignment2() /* Hello world */ } """); - } [WpfFact] public void UncommentAndFormat3() - { - UncommentSelection(""" + => UncommentSelection(""" class A { [| // void Method ( ) |] @@ -113,7 +106,6 @@ void Method() } } """); - } private static void UncommentSelection(string markup, string expected) { diff --git a/src/EditorFeatures/CSharpTest/CommentSelection/CSharpToggleBlockCommentCommandHandlerTests.cs b/src/EditorFeatures/CSharpTest/CommentSelection/CSharpToggleBlockCommentCommandHandlerTests.cs index 428a97e70189..b7e2f08026e0 100644 --- a/src/EditorFeatures/CSharpTest/CommentSelection/CSharpToggleBlockCommentCommandHandlerTests.cs +++ b/src/EditorFeatures/CSharpTest/CommentSelection/CSharpToggleBlockCommentCommandHandlerTests.cs @@ -22,8 +22,7 @@ public sealed class CSharpToggleBlockCommentCommandHandlerTests : AbstractToggle { [WpfFact] public void AddComment_CommentMarkerStringBeforeSelection() - { - ToggleComment(""" + => ToggleComment(""" class C { void M() @@ -44,12 +43,10 @@ void M() } } """); - } [WpfFact] public void AddComment_DirectiveWithCommentInsideSelection() - { - ToggleComment(""" + => ToggleComment(""" class C { void M() @@ -74,12 +71,10 @@ void M() } } """); - } [WpfFact] public void AddComment_MarkerInsideSelection() - { - ToggleComment(""" + => ToggleComment(""" class C { void M() @@ -100,12 +95,10 @@ void M() } } """); - } [WpfFact] public void AddComment_CloseCommentMarkerStringInSelection() - { - ToggleComment(""" + => ToggleComment(""" class C { void M() @@ -126,12 +119,10 @@ void M() } } """); - } [WpfFact] public void AddComment_CommentMarkerStringAfterSelection() - { - ToggleComment(""" + => ToggleComment(""" class C { void M() @@ -152,12 +143,10 @@ void M() } } """); - } [WpfFact] public void RemoveComment_CommentMarkerStringNearSelection() - { - ToggleComment(""" + => ToggleComment(""" class C { void M() @@ -180,12 +169,10 @@ void M() } } """); - } [WpfFact] public void RemoveComment_CommentMarkerStringInSelection() - { - ToggleComment(""" + => ToggleComment(""" class C { void M() @@ -202,7 +189,6 @@ void M() } } """); - } internal override AbstractCommentSelectionBase GetToggleCommentCommandHandler(EditorTestWorkspace workspace) { diff --git a/src/EditorFeatures/CSharpTest/CommentSelection/CSharpToggleLineCommentCommandHandlerTests.cs b/src/EditorFeatures/CSharpTest/CommentSelection/CSharpToggleLineCommentCommandHandlerTests.cs index 8612d90b926b..dd7bdc365c19 100644 --- a/src/EditorFeatures/CSharpTest/CommentSelection/CSharpToggleLineCommentCommandHandlerTests.cs +++ b/src/EditorFeatures/CSharpTest/CommentSelection/CSharpToggleLineCommentCommandHandlerTests.cs @@ -21,20 +21,15 @@ public sealed class CSharpToggleLineCommentCommandHandlerTests : AbstractToggleC { [WpfFact] public void AddComment_EmptyCaret() - { - ToggleComment(@"$$", @"[||]"); - } + => ToggleComment(@"$$", @"[||]"); [WpfFact] public void AddComment_EmptySelection() - { - ToggleComment(@"[| |]", @"[||]"); - } + => ToggleComment(@"[| |]", @"[||]"); [WpfFact] public void AddComment_CaretInUncommentedLine() - { - ToggleComment(""" + => ToggleComment(""" class C { void M() @@ -51,12 +46,10 @@ void M() } } """); - } [WpfFact] public void AddComment_CaretBeforeUncommentedLine() - { - ToggleComment(""" + => ToggleComment(""" class C { void M() @@ -73,12 +66,10 @@ void M() } } """); - } [WpfFact] public void AddComment_SingleLineSelected() - { - ToggleComment(""" + => ToggleComment(""" class C { void M() @@ -95,12 +86,10 @@ void M() } } """); - } [WpfFact] public void AddComment_PartialSingleLineSelected() - { - ToggleComment(""" + => ToggleComment(""" class C { void M() @@ -117,12 +106,10 @@ void M() } } """); - } [WpfFact] public void AddComment_SingleLineWithWhitespaceSelected() - { - ToggleComment(""" + => ToggleComment(""" class C { void M() @@ -143,12 +130,10 @@ void M() } } """); - } [WpfFact] public void AddComment_SelectionInsideCommentAtEndOfLine() - { - ToggleComment(""" + => ToggleComment(""" class C { void M() @@ -165,12 +150,10 @@ void M() } } """); - } [WpfFact] public void AddComment_SelectionAroundCommentAtEndOfLine() - { - ToggleComment(""" + => ToggleComment(""" class C { void M() @@ -187,12 +170,10 @@ void M() } } """); - } [WpfFact] public void AddComment_SelectionOutsideCommentAtEndOfLine() - { - ToggleComment(""" + => ToggleComment(""" class C { void M() @@ -209,12 +190,10 @@ void M() } } """); - } [WpfFact] public void AddComment_CaretOutsideCommentAtEndOfLine() - { - ToggleComment(""" + => ToggleComment(""" class C { void M() @@ -231,12 +210,10 @@ void M() } } """); - } [WpfFact] public void AddComment_CaretInsideCommentAtEndOfLine() - { - ToggleComment(""" + => ToggleComment(""" class C { void M() @@ -253,12 +230,10 @@ void M() } } """); - } [WpfFact] public void AddComment_CommentMarkerInString() - { - ToggleComment(""" + => ToggleComment(""" class C { void M() @@ -275,12 +250,10 @@ void M() } } """); - } [WpfFact] public void AddComment_MultipleLinesSelected() - { - ToggleComment(""" + => ToggleComment(""" class C { void M() @@ -299,12 +272,10 @@ void M() } } """); - } [WpfFact] public void AddComment_MultipleLinesWithWhitespaceSelected() - { - ToggleComment(""" + => ToggleComment(""" class C { void M() @@ -329,12 +300,10 @@ void M() } } """); - } [WpfFact] public void AddComment_MultipleLinesPartiallyCommentedSelected() - { - ToggleComment(""" + => ToggleComment(""" class C { void M() @@ -353,12 +322,10 @@ void M() } } """); - } [WpfFact] public void AddComment_MultipleLinesWithCommentsInLineSelected() - { - ToggleComment(""" + => ToggleComment(""" class C { void M() @@ -377,12 +344,10 @@ void M() } } """); - } [WpfFact] public void AddComment_MultipleLinesWithDifferentIndentationsSelected() - { - ToggleComment(""" + => ToggleComment(""" class C { [| void M() @@ -403,12 +368,10 @@ class C //}|] } """); - } [WpfFact] public void AddComment_MultiCaret() - { - ToggleComment(""" + => ToggleComment(""" class C { void M() @@ -427,12 +390,10 @@ void M() } } """); - } [WpfFact] public void AddComment_MultiSeletion() - { - ToggleComment(""" + => ToggleComment(""" class C { void M() @@ -451,12 +412,10 @@ void M() } } """); - } [WpfFact] public void AddComment_MultiSeletionPartiallyCommented() - { - ToggleComment(""" + => ToggleComment(""" class C { void M() @@ -475,12 +434,10 @@ void M() } } """); - } [WpfFact] public void AddComment_WithProjectionBuffer() - { - ToggleCommentWithProjectionBuffer(@"< html >@{|S1:|}", """ + => ToggleCommentWithProjectionBuffer(@"< html >@{|S1:|}", """ {|S1:class C { void M() @@ -497,12 +454,10 @@ void M() } } """); - } [WpfFact] public void RemoveComment_CaretInCommentedLine() - { - ToggleComment(""" + => ToggleComment(""" class C { void M() @@ -519,12 +474,10 @@ void M() } } """); - } [WpfFact] public void RemoveComment_CaretBeforeCommentedLine() - { - ToggleComment(""" + => ToggleComment(""" class C { void M() @@ -541,12 +494,10 @@ void M() } } """); - } [WpfFact] public void RemoveComment_CaretInCommentedLineWithEndComment() - { - ToggleComment(""" + => ToggleComment(""" class C { void M() @@ -563,12 +514,10 @@ void M() } } """); - } [WpfFact] public void RemoveComment_CaretInDoubleCommentedLine() - { - ToggleComment(""" + => ToggleComment(""" class C { void M() @@ -585,12 +534,10 @@ void M() } } """); - } [WpfFact] public void RemoveComment_CommentedLineSelected() - { - ToggleComment(""" + => ToggleComment(""" class C { void M() @@ -607,12 +554,10 @@ void M() } } """); - } [WpfFact] public void RemoveComment_InsideCommentSelected() - { - ToggleComment(""" + => ToggleComment(""" class C { void M() @@ -629,12 +574,10 @@ void M() } } """); - } [WpfFact] public void RemoveComment_CommentedLineWithWhitespaceSelected() - { - ToggleComment(""" + => ToggleComment(""" class C { void M() @@ -655,12 +598,10 @@ void M() } } """); - } [WpfFact] public void RemoveComment_CommentMarkerInString() - { - ToggleComment(""" + => ToggleComment(""" class C { void M() @@ -677,12 +618,10 @@ void M() } } """); - } [WpfFact] public void RemoveComment_MultipleCommentedLinesSelected() - { - ToggleComment(""" + => ToggleComment(""" class C { void M() @@ -701,12 +640,10 @@ void M() } } """); - } [WpfFact] public void RemoveComment_MultipleCommentedLinesAndWhitespaceSelected() - { - ToggleComment(""" + => ToggleComment(""" class C { void M() @@ -731,12 +668,10 @@ void M() } } """); - } [WpfFact] public void RemoveComment_MultipleCommentedLinesWithEndCommentSelected() - { - ToggleComment(""" + => ToggleComment(""" class C { void M() @@ -755,12 +690,10 @@ void M() } } """); - } [WpfFact] public void RemoveComment_MultipleLinesWithDifferentIndentationsSelected() - { - ToggleComment(""" + => ToggleComment(""" class C { [| //void M() @@ -781,12 +714,10 @@ class C }|] } """); - } [WpfFact] public void RemoveComment_MultiCaret() - { - ToggleComment(""" + => ToggleComment(""" class C { void M() @@ -807,12 +738,10 @@ void M() } } """); - } [WpfFact] public void RemoveComment_MultiSeletion() - { - ToggleComment(""" + => ToggleComment(""" class C { void M() @@ -833,12 +762,10 @@ void M() } } """); - } [WpfFact] public void RemoveComment_WithProjectionBuffer() - { - ToggleCommentWithProjectionBuffer(@"< html >@{|S1:|}", """ + => ToggleCommentWithProjectionBuffer(@"< html >@{|S1:|}", """ {|S1:class C { void M() @@ -855,7 +782,6 @@ void M() } } """); - } [WpfFact] public void ToggleComment_MultipleLinesSelected() diff --git a/src/EditorFeatures/CSharpTest/CompleteStatement/CSharpCompleteStatementCommandHandlerTests.cs b/src/EditorFeatures/CSharpTest/CompleteStatement/CSharpCompleteStatementCommandHandlerTests.cs index 4f5666a30a46..416e7b2bad44 100644 --- a/src/EditorFeatures/CSharpTest/CompleteStatement/CSharpCompleteStatementCommandHandlerTests.cs +++ b/src/EditorFeatures/CSharpTest/CompleteStatement/CSharpCompleteStatementCommandHandlerTests.cs @@ -66,8 +66,7 @@ internal static int MethodM(int a, int b) [InlineData("public interface C(int X, int$$ Y)", "public interface C(int X, int Y)")] [InlineData("public interface C(int X, int Y$$)", "public interface C(int X, int Y)")] public void ParameterList_CouldBeHandled(string signature, string expectedSignature) - { - VerifyTypingSemicolon($$""" + => VerifyTypingSemicolon($$""" public class Class1 { {{signature}} @@ -78,12 +77,10 @@ public class Class1 {{expectedSignature}};$$ } """); - } [WpfFact] public void ParameterList_InterfaceMethod() - { - VerifyTypingSemicolon(""" + => VerifyTypingSemicolon(""" public interface I { public void M(object o$$) @@ -94,7 +91,6 @@ public interface I public void M(object o);$$ } """); - } [WpfTheory] [InlineData("void M$$(object o)")] @@ -103,14 +99,12 @@ public interface I [InlineData("void Method($$object o")] [InlineData("partial void Method($$object o) { }")] public void ParameterList_NotHandled(string signature) - { - VerifyNoSpecialSemicolonHandling($$""" + => VerifyNoSpecialSemicolonHandling($$""" public class Class1 { {{signature}} } """); - } #endregion @@ -731,19 +725,16 @@ public void ArgumentList_Array_MissingInner() [WpfFact] public void FieldInitializer_NoParens() - { - VerifyNoSpecialSemicolonHandling(""" + => VerifyNoSpecialSemicolonHandling(""" class C { int i = 4$$ int j = 5; """); - } [WpfFact] public void FieldInitializer2() - { - VerifyTypingSemicolon(""" + => VerifyTypingSemicolon(""" class C { int i = Min(2$$,3) @@ -754,23 +745,19 @@ class C int i = Min(2,3);$$ int j = 5; """); - } [WpfFact] public void FieldInitializer2b_MissingParen() - { - VerifyNoSpecialSemicolonHandling(""" + => VerifyNoSpecialSemicolonHandling(""" class C { int i = Min(2$$,3 int j = 5; """); - } [WpfFact] public void FieldInitializer3() - { - VerifyTypingSemicolon(""" + => VerifyTypingSemicolon(""" class C { int i = Min(Max(4,5$$),3) @@ -781,18 +768,15 @@ class C int i = Min(Max(4,5),3);$$ int j = 5; """); - } [WpfFact] public void FieldInitializer3b_MissingInner() - { - VerifyNoSpecialSemicolonHandling(""" + => VerifyNoSpecialSemicolonHandling(""" class C { int i = Min(Max(4,5$$,3) int j = 5; """); - } #endregion @@ -800,8 +784,7 @@ class C [WpfFact] public void ForLoopSingleInitializer1() - { - VerifyNoSpecialSemicolonHandling(""" + => VerifyNoSpecialSemicolonHandling(""" class C { static void Main() @@ -809,12 +792,10 @@ static void Main() for (int i = 0$$ ) int j; """); - } [WpfFact] public void ForLoopSingleInitializer2() - { - VerifyNoSpecialSemicolonHandling(""" + => VerifyNoSpecialSemicolonHandling(""" class C { static void Main() @@ -822,12 +803,10 @@ static void Main() for (int i = 0$$ i < 5; i++) int j; """); - } [WpfFact] public void ForLoopSingleInitializer3() - { - VerifyNoSpecialSemicolonHandling(""" + => VerifyNoSpecialSemicolonHandling(""" class C { static void Main() @@ -840,12 +819,10 @@ static void Main() } } """); - } [WpfFact] public void ForLoopSingleInitializer_MissingParen() - { - VerifyNoSpecialSemicolonHandling(""" + => VerifyNoSpecialSemicolonHandling(""" class C { static void Main() @@ -853,12 +830,10 @@ static void Main() for (int i = 0$$ int j; """); - } [WpfFact] public void ForLoopNoStatements() - { - VerifyNoSpecialSemicolonHandling(""" + => VerifyNoSpecialSemicolonHandling(""" class C { static void Main() @@ -866,12 +841,10 @@ static void Main() for ($$ int j; """); - } [WpfFact] public void ForLoopNoStatements2() - { - VerifyNoSpecialSemicolonHandling(""" + => VerifyNoSpecialSemicolonHandling(""" class C { static void Main() @@ -879,12 +852,10 @@ static void Main() for ( $$ int j; """); - } [WpfFact] public void ForLoopNoStatements3() - { - VerifyNoSpecialSemicolonHandling(""" + => VerifyNoSpecialSemicolonHandling(""" class C { static void Main() @@ -892,12 +863,10 @@ static void Main() for ( ; $$ int j; """); - } [WpfFact] public void ForLoopNoStatements4() - { - VerifyNoSpecialSemicolonHandling(""" + => VerifyNoSpecialSemicolonHandling(""" class C { static void Main() @@ -905,12 +874,10 @@ static void Main() for ( ; ;$$ int j; """); - } [WpfFact] public void ForLoopNoStatements5() - { - VerifyNoSpecialSemicolonHandling(""" + => VerifyNoSpecialSemicolonHandling(""" class C { static void Main() @@ -918,12 +885,10 @@ static void Main() for ( $$ ;) int j; """); - } [WpfFact] public void ForLoopMultistatementInitializer1() - { - VerifyNoSpecialSemicolonHandling(""" + => VerifyNoSpecialSemicolonHandling(""" class C { static void Main() @@ -931,12 +896,10 @@ static void Main() for ( $$int i = 0, int j = 0) int j; """); - } [WpfFact] public void ForLoopMultistatementInitializer2() - { - VerifyNoSpecialSemicolonHandling(""" + => VerifyNoSpecialSemicolonHandling(""" class C { static void Main() @@ -944,12 +907,10 @@ static void Main() for ( int$$ i = 0, int j = 0) int j; """); - } [WpfFact] public void ForLoopMultistatementInitializer3() - { - VerifyNoSpecialSemicolonHandling(""" + => VerifyNoSpecialSemicolonHandling(""" class C { static void Main() @@ -957,12 +918,10 @@ static void Main() for ( int i$$ = 0, int j = 0) int j; """); - } [WpfFact] public void ForLoopMultistatementInitializer4() - { - VerifyNoSpecialSemicolonHandling(""" + => VerifyNoSpecialSemicolonHandling(""" class C { static void Main() @@ -970,12 +929,10 @@ static void Main() for ( int i = 0, $$int j = 0) int j; """); - } [WpfFact] public void ForLoopMultistatementInitializer5() - { - VerifyNoSpecialSemicolonHandling(""" + => VerifyNoSpecialSemicolonHandling(""" class C { static void Main() @@ -983,12 +940,10 @@ static void Main() for ( int i = 0, int j =$$ 0) int j; """); - } [WpfFact] public void ForLoopMultistatementInitializer6() - { - VerifyNoSpecialSemicolonHandling(""" + => VerifyNoSpecialSemicolonHandling(""" class C { static void Main() @@ -996,12 +951,10 @@ static void Main() for ( int i = 0, int j = 0$$) int j; """); - } [WpfFact] public void ForLoopMultistatementInitializer7() - { - VerifyNoSpecialSemicolonHandling(""" + => VerifyNoSpecialSemicolonHandling(""" class C { static void Main() @@ -1009,12 +962,10 @@ static void Main() for ( int i = 0, int j = 0$$) int j; """); - } [WpfFact] public void ForLoopNewInInitializer1() - { - VerifyTypingSemicolon(""" + => VerifyTypingSemicolon(""" class C { static void Main(string[] args) @@ -1047,12 +998,10 @@ public class C1 } } """); - } [WpfFact] public void ForLoopNewInInitializer_MissingOneParen() - { - VerifyNoSpecialSemicolonHandling(""" + => VerifyNoSpecialSemicolonHandling(""" class C { static void Main(string[] args) @@ -1069,7 +1018,6 @@ public class C1 } } """); - } [WpfFact] public void ForLoopNewInInitializer2_MissingBothParens() @@ -1097,8 +1045,7 @@ public class C1 [WpfFact] public void ForLoopDeclaration() - { - VerifyTypingSemicolon(""" + => VerifyTypingSemicolon(""" class C { static void Main(string[] args) @@ -1113,12 +1060,10 @@ static void Main(string[] args) string s = "abcdefghij"; for (int i = s.IndexOf("bcd");$$ i < 10; i++) """); - } [WpfFact] public void ForLoopDeclaration2() - { - VerifyTypingSemicolon(""" + => VerifyTypingSemicolon(""" class C { static void Main(string[] args) @@ -1133,12 +1078,10 @@ static void Main(string[] args) string s = "abcdefghij"; for (int i = s.IndexOf("bcd"), j=1;$$ i < 10; i++) """); - } [WpfFact] public void ForLoopDeclaration3() - { - VerifyTypingSemicolon(""" + => VerifyTypingSemicolon(""" class C { static void Main(string[] args) @@ -1153,12 +1096,10 @@ static void Main(string[] args) string s = "abcdefghij"; for (int i = s.IndexOf("bcd");$$ i < 10; i++) """); - } [WpfFact] public void ForLoopDeclaration4() - { - VerifyTypingSemicolon(""" + => VerifyTypingSemicolon(""" class C { static void Main(string[] args) @@ -1173,12 +1114,10 @@ static void Main(string[] args) string s = "abcdefghij"; for (int i = s.IndexOf("bcd"), j=1;$$ i < 10; i++) """); - } [WpfFact] public void ForLoopDeclaration_MissingParen() - { - VerifyTypingSemicolon(""" + => VerifyTypingSemicolon(""" class C { static void Main(string[] args) @@ -1193,12 +1132,10 @@ static void Main(string[] args) string s = "abcdefghij"; for (int i = s.IndexOf("bcd";$$ i < 10; i++) """); - } [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/32250")] public void ForLoopInitializers() - { - VerifyTypingSemicolon(""" + => VerifyTypingSemicolon(""" class C { static void Main(string[] args) @@ -1215,12 +1152,10 @@ static void Main(string[] args) int i; for (i = s.IndexOf("bcd");$$ i < 10; i++) """); - } [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/32250")] public void ForLoopInitializers2() - { - VerifyTypingSemicolon(""" + => VerifyTypingSemicolon(""" class C { static void Main(string[] args) @@ -1239,12 +1174,10 @@ static void Main(string[] args) int j; for (i = s.IndexOf("bcd"), j=1;$$ i < 10; i++) """); - } [WpfFact] public void ForLoopInitializers3() - { - VerifyTypingSemicolon(""" + => VerifyTypingSemicolon(""" class C { static void Main(string[] args) @@ -1261,12 +1194,10 @@ static void Main(string[] args) int i; for (i = s.IndexOf("bcd");$$ i < 10; i++) """); - } [WpfFact] public void ForLoopInitializers4() - { - VerifyTypingSemicolon(""" + => VerifyTypingSemicolon(""" class C { static void Main(string[] args) @@ -1285,11 +1216,9 @@ static void Main(string[] args) int j; for (i = s.IndexOf("bcd"), j=1;$$ i < 10; i++) """); - } [WpfFact] public void ForLoopInitializers_MissingParen() - { - VerifyTypingSemicolon(""" + => VerifyTypingSemicolon(""" class C { static void Main(string[] args) @@ -1306,12 +1235,10 @@ static void Main(string[] args) int i; for (i = s.IndexOf("bcd";$$ i < 10; i++) """); - } [WpfFact] public void ForLoopCondition() - { - VerifyTypingSemicolon(""" + => VerifyTypingSemicolon(""" class C { static void Main(string[] args) @@ -1326,12 +1253,10 @@ static void Main(string[] args) string s = "abcdefghij"; for (int i = s.IndexOf("bcd"); i < s.IndexOf("x");$$ i++) """); - } [WpfFact] public void ForLoopConditionIsNull() - { - VerifyNoSpecialSemicolonHandling(""" + => VerifyNoSpecialSemicolonHandling(""" class C { static void Main(string[] args) @@ -1341,12 +1266,10 @@ static void Main(string[] args) Console.WriteLine("test"); } """); - } [WpfFact] public void ForLoopConditionIsNull2() - { - VerifyTypingSemicolon(""" + => VerifyTypingSemicolon(""" class C { static void Main(string[] args) @@ -1365,12 +1288,10 @@ static void Main(string[] args) Console.WriteLine("test"); } """); - } [WpfFact] public void ForLoopIncrement() - { - VerifyTypingSemicolon(""" + => VerifyTypingSemicolon(""" class C { static void Main(string[] args) @@ -1385,12 +1306,10 @@ static void Main(string[] args) string s = "abcdefghij"; for (int i = s.IndexOf("bcd"); i < s.IndexOf("x"); i = i.IndexOf("x";$$)) """); - } [WpfFact] public void ForLoopBody() - { - VerifyTypingSemicolon(""" + => VerifyTypingSemicolon(""" class C { static void Main(string[] args) @@ -1411,12 +1330,10 @@ static void Main(string[] args) i.ToString();$$ } """); - } [WpfFact] public void ForLoopObjectInitializer_MissingParen() - { - VerifyNoSpecialSemicolonHandling(""" + => VerifyNoSpecialSemicolonHandling(""" class C { static void Main(string[] args) @@ -1430,12 +1347,10 @@ public class Goo public string s; } """); - } [WpfFact] public void ForLoopObjectInitializer() - { - VerifyTypingSemicolon(""" + => VerifyTypingSemicolon(""" class C { static void Main(string[] args) @@ -1462,12 +1377,10 @@ public class Goo public string s; } """); - } [WpfFact] public void ForLoopObjectInitializer_MissingBrace() - { - VerifyNoSpecialSemicolonHandling(""" + => VerifyNoSpecialSemicolonHandling(""" class C { static void Main(string[] args) @@ -1481,7 +1394,6 @@ public class Goo public string s; } """); - } #endregion @@ -1489,8 +1401,7 @@ public class Goo [WpfFact] public void Indexer() - { - VerifyTypingSemicolon(""" + => VerifyTypingSemicolon(""" class SampleCollection { private T[] arr = new T[100]; @@ -1513,12 +1424,10 @@ public int Property } } """); - } [WpfFact] public void Indexer2() - { - VerifyTypingSemicolon(""" + => VerifyTypingSemicolon(""" class test { int[] array = { 1, 2, 3 }; @@ -1539,12 +1448,10 @@ void M() } } """); - } [WpfFact] public void Indexer3() - { - VerifyTypingSemicolon(""" + => VerifyTypingSemicolon(""" class C { int[] array = { 1, 2, 3 }; @@ -1565,12 +1472,10 @@ void M() } } """); - } [WpfFact] public void Indexer4() - { - VerifyTypingSemicolon(""" + => VerifyTypingSemicolon(""" class C { int[] array = { 1, 2, 3 }; @@ -1591,7 +1496,6 @@ void M() } } """); - } #endregion @@ -1599,8 +1503,7 @@ void M() [WpfFact] public void ArrayInitializer() - { - VerifyNoSpecialSemicolonHandling(""" + => VerifyNoSpecialSemicolonHandling(""" class C { static void Main(string[] args) @@ -1610,12 +1513,10 @@ static void Main(string[] args) } """); - } [WpfFact] public void ArrayInitializer2() - { - VerifyTypingSemicolon(""" + => VerifyTypingSemicolon(""" class C { static void Main(string[] args) @@ -1634,12 +1535,10 @@ static void Main(string[] args) } """); - } [WpfFact] public void ArrayInitializer3() - { - VerifyTypingSemicolon(""" + => VerifyTypingSemicolon(""" class C { static void Main(string[] args) @@ -1658,12 +1557,10 @@ static void Main(string[] args) } """); - } [WpfFact] public void ArrayInitializer4() - { - VerifyTypingSemicolon(""" + => VerifyTypingSemicolon(""" class C { static void Main(string[] args) @@ -1682,12 +1579,10 @@ static void Main(string[] args) } """); - } [WpfFact] public void ArrayInitializer_MissingBrace() - { - VerifyNoSpecialSemicolonHandling(""" + => VerifyNoSpecialSemicolonHandling(""" class C { static void Main(string[] args) @@ -1697,7 +1592,6 @@ static void Main(string[] args) } """); - } #endregion @@ -1705,8 +1599,7 @@ static void Main(string[] args) [WpfFact] public void ImplicitTypeArrayInitializer() - { - VerifyNoSpecialSemicolonHandling(""" + => VerifyNoSpecialSemicolonHandling(""" class C { static void Main(string[] args) @@ -1716,12 +1609,10 @@ static void Main(string[] args) } """); - } [WpfFact] public void ImplicitTypeArrayInitializer2() - { - VerifyTypingSemicolon(""" + => VerifyTypingSemicolon(""" class C { static void Main(string[] args) @@ -1740,12 +1631,10 @@ static void Main(string[] args) } """); - } [WpfFact] public void ImplicitTypeArrayInitializer3() - { - VerifyTypingSemicolon(""" + => VerifyTypingSemicolon(""" class C { static void Main(string[] args) @@ -1764,12 +1653,10 @@ static void Main(string[] args) } """); - } [WpfFact] public void ImplicitTypeArrayInitializer4() - { - VerifyTypingSemicolon(""" + => VerifyTypingSemicolon(""" class C { static void Main(string[] args) @@ -1788,12 +1675,10 @@ static void Main(string[] args) } """); - } [WpfFact] public void ImplicitTypeArrayInitializer_MissingBrace() - { - VerifyNoSpecialSemicolonHandling(""" + => VerifyNoSpecialSemicolonHandling(""" class C { static void Main(string[] args) @@ -1803,7 +1688,6 @@ static void Main(string[] args) } """); - } #endregion @@ -1811,8 +1695,7 @@ static void Main(string[] args) [WpfFact] public void CollectionExpression() - { - VerifyNoSpecialSemicolonHandling(""" + => VerifyNoSpecialSemicolonHandling(""" class C { static void Main(string[] args) @@ -1822,12 +1705,10 @@ static void Main(string[] args) } """); - } [WpfFact] public void CollectionExpression2() - { - VerifyTypingSemicolon(""" + => VerifyTypingSemicolon(""" class C { static void Main(string[] args) @@ -1846,12 +1727,10 @@ static void Main(string[] args) } """); - } [WpfFact] public void CollectionExpression3() - { - VerifyTypingSemicolon(""" + => VerifyTypingSemicolon(""" class C { static void Main(string[] args) @@ -1870,12 +1749,10 @@ static void Main(string[] args) } """); - } [WpfFact] public void CollectionExpression4() - { - VerifyTypingSemicolon(""" + => VerifyTypingSemicolon(""" class C { static void Main(string[] args) @@ -1894,12 +1771,10 @@ static void Main(string[] args) } """); - } [WpfFact] public void CollectionExpression_MissingBrace() - { - VerifyNoSpecialSemicolonHandling(""" + => VerifyNoSpecialSemicolonHandling(""" class C { static void Main(string[] args) @@ -1909,7 +1784,6 @@ static void Main(string[] args) } """); - } #endregion @@ -1917,8 +1791,7 @@ static void Main(string[] args) [WpfFact] public void CollectionInitializer() - { - VerifyNoSpecialSemicolonHandling(""" + => VerifyNoSpecialSemicolonHandling(""" using System.Collections.Generic; class C { @@ -1929,12 +1802,10 @@ static void Main(string[] args) } """); - } [WpfFact] public void CollectionInitializer2() - { - VerifyTypingSemicolon(""" + => VerifyTypingSemicolon(""" using System.Collections.Generic; class C { @@ -1955,12 +1826,10 @@ static void Main(string[] args) } """); - } [WpfFact] public void CollectionInitializer3() - { - VerifyTypingSemicolon(""" + => VerifyTypingSemicolon(""" using System.Collections.Generic; class C { @@ -1981,12 +1850,10 @@ static void Main(string[] args) } """); - } [WpfFact] public void CollectionInitializer4() - { - VerifyTypingSemicolon(""" + => VerifyTypingSemicolon(""" using System.Collections.Generic; class C { @@ -2007,12 +1874,10 @@ static void Main(string[] args) } """); - } [WpfFact] public void CollectionInitializer_MissingBrace() - { - VerifyNoSpecialSemicolonHandling(""" + => VerifyNoSpecialSemicolonHandling(""" using System.Collections.Generic; class C { @@ -2023,7 +1888,6 @@ static void Main(string[] args) } """); - } #endregion @@ -2031,8 +1895,7 @@ static void Main(string[] args) [WpfFact] public void ObjectInitializer() - { - VerifyNoSpecialSemicolonHandling(""" + => VerifyNoSpecialSemicolonHandling(""" class C { static void Main(string[] args) @@ -2047,12 +1910,10 @@ public class Goo public string s; } """); - } [WpfFact] public void ObjectInitializer2() - { - VerifyTypingSemicolon(""" + => VerifyTypingSemicolon(""" class C { static void Main(string[] args) @@ -2081,12 +1942,10 @@ public class Goo public string s; } """); - } [WpfFact] public void ObjectInitializer3() - { - VerifyTypingSemicolon(""" + => VerifyTypingSemicolon(""" class C { static void Main(string[] args) @@ -2115,12 +1974,10 @@ public class Goo public string s; } """); - } [WpfFact] public void ObjectInitializer4() - { - VerifyTypingSemicolon(""" + => VerifyTypingSemicolon(""" class C { static void Main(string[] args) @@ -2149,12 +2006,10 @@ public class Goo public string s; } """); - } [WpfFact] public void ObjectInitializer_MissingBrace() - { - VerifyTypingSemicolon(""" + => VerifyTypingSemicolon(""" class C { static void Main(string[] args) @@ -2183,7 +2038,6 @@ public class Goo public string s; } """); - } #endregion @@ -2191,8 +2045,7 @@ public class Goo [WpfFact] public void PropertyAccessors1() - { - VerifyTypingSemicolon(""" + => VerifyTypingSemicolon(""" public class ClassC { private int xValue = 7; @@ -2217,12 +2070,10 @@ public int XValue } } """); - } [WpfFact] public void PropertyAccessors2() - { - VerifyTypingSemicolon(""" + => VerifyTypingSemicolon(""" public class ClassC { private int xValue = 7; @@ -2247,12 +2098,10 @@ public int XValue } } """); - } [WpfFact] public void PropertyAccessors3() - { - VerifyNoSpecialSemicolonHandling(""" + => VerifyNoSpecialSemicolonHandling(""" public class Person { private string firstName; @@ -2267,12 +2116,10 @@ public Person(string first, string last) public string Name => $"{firstName} {lastName}"$$ } """); - } [WpfFact] public void PropertyAccessors4() - { - VerifyNoSpecialSemicolonHandling(""" + => VerifyNoSpecialSemicolonHandling(""" public class SaleItem { string name; @@ -2283,12 +2130,10 @@ public string Name } } """); - } [WpfFact] public void PropertyAccessors5() - { - VerifyNoSpecialSemicolonHandling(""" + => VerifyNoSpecialSemicolonHandling(""" public class SaleItem { string name; @@ -2299,12 +2144,10 @@ public string Name } } """); - } [WpfFact] public void PropertyAccessors6() - { - VerifyTypingSemicolon(""" + => VerifyTypingSemicolon(""" public class SaleItem { string name; @@ -2325,24 +2168,20 @@ public string Name } } """); - } [WpfFact] public void PropertyAccessors7() - { - VerifyNoSpecialSemicolonHandling(""" + => VerifyNoSpecialSemicolonHandling(""" public class SaleItem { public string Name { get$$ set; } } """); - } [WpfFact] public void PropertyInitializer1() - { - VerifyTypingSemicolon(""" + => VerifyTypingSemicolon(""" public class C { public static C MyProp { get; } = new C($$) @@ -2353,12 +2192,10 @@ public class C public static C MyProp { get; } = new C();$$ } """); - } [WpfFact] public void PropertyAttribute1() - { - VerifyNoSpecialSemicolonHandling(""" + => VerifyNoSpecialSemicolonHandling(""" public class C { public int P @@ -2371,7 +2208,6 @@ public int P } } """); - } #endregion @@ -2379,8 +2215,7 @@ public int P [WpfFact] public void ParenthesizedExpression_Assignment1() - { - VerifyTypingSemicolon(""" + => VerifyTypingSemicolon(""" public class Class1 { void M() @@ -2397,12 +2232,10 @@ void M() } } """); - } [WpfFact] public void ParenthesizedExpression_Assignment2() - { - VerifyTypingSemicolon(""" + => VerifyTypingSemicolon(""" public class Class1 { void M() @@ -2419,12 +2252,10 @@ void M() } } """); - } [WpfFact] public void ParenthesizedExpression_Assignment3() - { - VerifyTypingSemicolon(""" + => VerifyTypingSemicolon(""" public class Class1 { void M() @@ -2443,12 +2274,10 @@ void M() } } """); - } [WpfFact] public void ParenthesizedExpression_ForLoop() - { - VerifyTypingSemicolon(""" + => VerifyTypingSemicolon(""" public class Class1 { void M() @@ -2471,12 +2300,10 @@ void M() } } """); - } [WpfFact] public void ParenthesizedExpression_ForLoop2() - { - VerifyTypingSemicolon(""" + => VerifyTypingSemicolon(""" public class Class1 { void M() @@ -2499,12 +2326,10 @@ void M() } } """); - } [WpfFact] public void ParenthesizedExpression_ForLoop3() - { - VerifyTypingSemicolon(""" + => VerifyTypingSemicolon(""" public class Class1 { void M() @@ -2527,12 +2352,10 @@ void M() } } """); - } [WpfFact] public void ParenthesizedExpression_ForEach() - { - VerifyNoSpecialSemicolonHandling(""" + => VerifyNoSpecialSemicolonHandling(""" public class Class1 { static void Main(string[] args) @@ -2550,12 +2373,10 @@ private static int[] M(int i) } } """); - } [WpfFact] public void ParenthesizedExpression_GoTo2() - { - VerifyTypingSemicolon(""" + => VerifyTypingSemicolon(""" static void Main() { int n = 1; @@ -2584,12 +2405,10 @@ static void Main() } } """); - } [WpfFact] public void ParenthesizedExpression_Switch() - { - VerifyNoSpecialSemicolonHandling(""" + => VerifyNoSpecialSemicolonHandling(""" class Program { static void Main() @@ -2605,12 +2424,10 @@ static void Main() } } """); - } [WpfFact] public void ParenthesizedExpression_Switch2() - { - VerifyNoSpecialSemicolonHandling(""" + => VerifyNoSpecialSemicolonHandling(""" class Program { static void Main() @@ -2626,12 +2443,10 @@ static void Main() } } """); - } [WpfFact] public void ParenthesizedExpression_Switch3() - { - VerifyTypingSemicolon(""" + => VerifyTypingSemicolon(""" class Program { static void Main() @@ -2664,12 +2479,10 @@ static void Main() } } """); - } [WpfFact] public void ParenthesizedExpression_While() - { - VerifyNoSpecialSemicolonHandling(""" + => VerifyNoSpecialSemicolonHandling(""" using System; class Program { @@ -2683,12 +2496,10 @@ static void Main() } } """); - } [WpfFact] public void ParenthesizedExpression_While2() - { - VerifyNoSpecialSemicolonHandling(""" + => VerifyNoSpecialSemicolonHandling(""" using System; class Program { @@ -2702,12 +2513,10 @@ static void Main() } } """); - } [WpfFact] public void ParenthesizedExpression_While3() - { - VerifyTypingSemicolon(""" + => VerifyTypingSemicolon(""" using System; class Program { @@ -2734,7 +2543,6 @@ static void Main() } } """); - } #endregion @@ -2742,8 +2550,7 @@ static void Main() [InlineData("default(object$$)", "default(object)")] [InlineData("default($$object)", "default(object)")] public void DefaultExpression_Handled(string expression, string expectedExpression) - { - VerifyTypingSemicolon($$""" + => VerifyTypingSemicolon($$""" public class Class1 { void M() @@ -2760,14 +2567,12 @@ void M() } } """); - } [WpfTheory, WorkItem("https://github.com/dotnet/roslyn/issues/52137")] [InlineData("typeof(object$$)", "typeof(object)")] [InlineData("typeof($$object)", "typeof(object)")] public void TypeOfExpression_Handled(string expression, string expectedExpression) - { - VerifyTypingSemicolon($$""" + => VerifyTypingSemicolon($$""" public class Class1 { void M() @@ -2784,12 +2589,10 @@ void M() } } """); - } [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/52365")] public void TupleExpression_Handled() - { - VerifyTypingSemicolon(""" + => VerifyTypingSemicolon(""" public class Class1 { void M() @@ -2806,7 +2609,6 @@ void M() } } """); - } [WpfTheory] [InlineData("default$$(object)")] @@ -2814,8 +2616,7 @@ void M() [InlineData("default(object$$")] [InlineData("default($$object")] public void DefaultExpression_NotHandled(string expression) - { - VerifyNoSpecialSemicolonHandling($$""" + => VerifyNoSpecialSemicolonHandling($$""" public class Class1 { void M() @@ -2824,7 +2625,6 @@ void M() } } """); - } [WpfTheory] [InlineData("checked(3 + 3$$)", "checked(3 + 3)")] @@ -2832,8 +2632,7 @@ void M() [InlineData("unchecked(3 + 3$$)", "unchecked(3 + 3)")] [InlineData("unchecked($$3 + 3)", "unchecked(3 + 3)")] public void CheckedExpression_Handled(string expression, string expectedExpression) - { - VerifyTypingSemicolon($$""" + => VerifyTypingSemicolon($$""" public class Class1 { void M() @@ -2850,7 +2649,6 @@ void M() } } """); - } [WpfTheory] [InlineData("checked$$(3 + 3)")] @@ -2862,8 +2660,7 @@ void M() [InlineData("unchecked(3 + 3$$")] [InlineData("unchecked($$3 + 3")] public void CheckedExpression_NotHandled(string expression) - { - VerifyNoSpecialSemicolonHandling($$""" + => VerifyNoSpecialSemicolonHandling($$""" public class Class1 { void M() @@ -2872,12 +2669,10 @@ void M() } } """); - } [WpfFact] public void ThrowStatement_MissingBoth() - { - VerifyNoSpecialSemicolonHandling(""" + => VerifyNoSpecialSemicolonHandling(""" public class Class1 { void M() @@ -2888,12 +2683,10 @@ void M() } } """); - } [WpfFact] public void ThrowStatement() - { - VerifyTypingSemicolon(""" + => VerifyTypingSemicolon(""" public class Class1 { void M() @@ -2914,34 +2707,28 @@ void M() } } """); - } [WpfFact] public void DoNotComplete_SemicolonBeforeClassDeclaration() - { - VerifyNoSpecialSemicolonHandling(""" + => VerifyNoSpecialSemicolonHandling(""" $$ class C { } """); - } [WpfFact] public void DoNotCompleteStatment_DocComments() - { - VerifyNoSpecialSemicolonHandling(""" + => VerifyNoSpecialSemicolonHandling(""" /// Testing $$ class C { } """); - } [WpfFact] public void DoNotComplete_FormatString() - { - VerifyNoSpecialSemicolonHandling(""" + => VerifyNoSpecialSemicolonHandling(""" class C { void Main() @@ -2950,12 +2737,10 @@ void Main() } } """); - } [WpfFact] public void DoNotComplete_EmptyStatement() - { - VerifyNoSpecialSemicolonHandling(""" + => VerifyNoSpecialSemicolonHandling(""" class C { void Main() @@ -2964,12 +2749,10 @@ void Main() } } """); - } [WpfFact] public void DoNotComplete_EmptyStatement2() - { - VerifyNoSpecialSemicolonHandling(""" + => VerifyNoSpecialSemicolonHandling(""" class C { void Main() @@ -2978,12 +2761,10 @@ void Main() } } """); - } [WpfFact] public void DoWhile() - { - VerifyTypingSemicolon(""" + => VerifyTypingSemicolon(""" public class C { void M() @@ -3010,12 +2791,10 @@ void M() } } """); - } [WpfFact] public void DoWhile2() - { - VerifyNoSpecialSemicolonHandling(""" + => VerifyNoSpecialSemicolonHandling(""" public class C { void M() @@ -3029,12 +2808,10 @@ void M() } } """); - } [WpfFact] public void DoWhile3() - { - VerifyNoSpecialSemicolonHandling(""" + => VerifyNoSpecialSemicolonHandling(""" public class C { void M() @@ -3048,12 +2825,10 @@ void M() } } """); - } [WpfFact] public void DoWhile4() - { - VerifyTypingSemicolon(""" + => VerifyTypingSemicolon(""" public class C { void M() @@ -3080,12 +2855,10 @@ void M() } } """); - } [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/35260")] public void DoWhile5() - { - VerifyTypingSemicolon(""" + => VerifyTypingSemicolon(""" public class C { void M() @@ -3112,12 +2885,10 @@ void M() } } """); - } [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/35260")] public void DoWhile6() - { - VerifyTypingSemicolon(""" + => VerifyTypingSemicolon(""" public class C { void M() @@ -3144,12 +2915,10 @@ void M() } } """); - } [WpfFact] public void DoWhile_MissingParen() - { - VerifyTypingSemicolon(""" + => VerifyTypingSemicolon(""" public class C { void M() @@ -3176,12 +2945,10 @@ void M() } } """); - } [WpfFact] public void DoNotComplete_Break() - { - VerifyNoSpecialSemicolonHandling(""" + => VerifyNoSpecialSemicolonHandling(""" public class C { void M() @@ -3196,12 +2963,10 @@ void M() } } """); - } [WpfFact] public void DoNotComplete_Break2() - { - VerifyNoSpecialSemicolonHandling(""" + => VerifyNoSpecialSemicolonHandling(""" public class C { void M() @@ -3216,12 +2981,10 @@ void M() } } """); - } [WpfFact] public void DoNotComplete_Break3() - { - VerifyNoSpecialSemicolonHandling(""" + => VerifyNoSpecialSemicolonHandling(""" public class C { void M() @@ -3236,12 +2999,10 @@ void M() } } """); - } [WpfFact] public void DoNotComplete_Checked() - { - VerifyNoSpecialSemicolonHandling(""" + => VerifyNoSpecialSemicolonHandling(""" class Program { static void Main(string[] args) @@ -3265,12 +3026,10 @@ static void Main(string[] args) } } """); - } [WpfFact] public void DoNotComplete_Unchecked() - { - VerifyNoSpecialSemicolonHandling(""" + => VerifyNoSpecialSemicolonHandling(""" class Program { static void Main(string[] args) @@ -3294,12 +3053,10 @@ static void Main(string[] args) } } """); - } [WpfFact] public void DoNotComplete_Fixed() - { - VerifyNoSpecialSemicolonHandling(""" + => VerifyNoSpecialSemicolonHandling(""" class Program { static void Main() @@ -3321,12 +3078,10 @@ unsafe static string Transform() } } """); - } [WpfFact] public void DoNotComplete_Continue() - { - VerifyNoSpecialSemicolonHandling(""" + => VerifyNoSpecialSemicolonHandling(""" class ContinueTest { static void Main() @@ -3342,12 +3097,10 @@ static void Main() } } """); - } [WpfFact] public void DoNotComplete_Continue2() - { - VerifyNoSpecialSemicolonHandling(""" + => VerifyNoSpecialSemicolonHandling(""" class ContinueTest { static void Main() @@ -3363,12 +3116,10 @@ static void Main() } } """); - } [WpfFact] public void DoNotComplete_Continue3() - { - VerifyNoSpecialSemicolonHandling(""" + => VerifyNoSpecialSemicolonHandling(""" class ContinueTest { static void Main() @@ -3384,12 +3135,10 @@ static void Main() } } """); - } [WpfFact] public void DoNotComplete_GoTo() - { - VerifyNoSpecialSemicolonHandling(""" + => VerifyNoSpecialSemicolonHandling(""" static void Main() { int n = 1; @@ -3405,12 +3154,10 @@ static void Main() } } """); - } [WpfFact] public void DoNotComplete_IfStatement() - { - VerifyNoSpecialSemicolonHandling(""" + => VerifyNoSpecialSemicolonHandling(""" class Program { void M() @@ -3423,12 +3170,10 @@ void M() } } """); - } [WpfFact] public void DoNotComplete_Labeled() - { - VerifyNoSpecialSemicolonHandling(""" + => VerifyNoSpecialSemicolonHandling(""" class Program { static void Main() @@ -3439,12 +3184,10 @@ static void Main() } } """); - } [WpfFact] public void DoNotComplete_IfStatement2() - { - VerifyNoSpecialSemicolonHandling(""" + => VerifyNoSpecialSemicolonHandling(""" class Program { void M() @@ -3457,7 +3200,6 @@ void M() } } """); - } [WpfFact] public void DoNotComplete_ClassNameOfMethodInvocation1() @@ -3631,21 +3373,17 @@ public void DoNotComplete_UnterminatedCharLiteral(string literal) [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/34176")] public void DoNotComplete_VerbatimStringAsMethodArgument_EndOfLine_NotEndOfString() - { - VerifyNoSpecialSemicolonHandling(""" + => VerifyNoSpecialSemicolonHandling(""" var code = Foo(@"$$ ") ; """); - } [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/34176")] public void DoNotComplete_VerbatimStringAsMethodArgument_EndOfString_NotEndOfLine() - { - VerifyNoSpecialSemicolonHandling(""" + => VerifyNoSpecialSemicolonHandling(""" var code = Foo(@" $$" //comments ); """); - } [WpfFact] public void DoNotComplete_InterpolatedString() @@ -3659,8 +3397,7 @@ public void DoNotComplete_InterpolatedString() [WpfFact] public void DoNotComplete_Attribute() - { - VerifyNoSpecialSemicolonHandling(""" + => VerifyNoSpecialSemicolonHandling(""" using System; class Program @@ -3677,23 +3414,19 @@ static void Test() } } """); - } [WpfFact] public void DoNotComplete_Attribute2() - { - VerifyNoSpecialSemicolonHandling(""" + => VerifyNoSpecialSemicolonHandling(""" [assembly: System.Reflection.AssemblyVersionAttribute(null$$)] class Program { } """); - } [WpfFact] public void DoNotComplete_Attribute3() - { - VerifyNoSpecialSemicolonHandling(""" + => VerifyNoSpecialSemicolonHandling(""" using System.Runtime.CompilerServices; using System; @@ -3712,12 +3445,10 @@ public void MyMethod() { } } """); - } [WpfFact] public void DoNotComplete_Attribute4() - { - VerifyNoSpecialSemicolonHandling(""" + => VerifyNoSpecialSemicolonHandling(""" using System; using System.Reflection; @@ -3740,12 +3471,10 @@ public static void Main() } } """); - } [WpfFact] public void DoNotComplete_Attribute5() - { - VerifyNoSpecialSemicolonHandling(""" + => VerifyNoSpecialSemicolonHandling(""" using System; using System.Reflection; @@ -3768,12 +3497,10 @@ public static void Main() } } """); - } [WpfFact] public void DoNotComplete_Attribute6() - { - VerifyNoSpecialSemicolonHandling(""" + => VerifyNoSpecialSemicolonHandling(""" using System; class Program @@ -3790,37 +3517,29 @@ static void Test() } } """); - } [WpfFact] public void DoNotComplete_Using() - { - VerifyNoSpecialSemicolonHandling(""" + => VerifyNoSpecialSemicolonHandling(""" using System.Linq$$ """); - } [WpfFact] public void DoNotComplete_Using2() - { - VerifyNoSpecialSemicolonHandling(""" + => VerifyNoSpecialSemicolonHandling(""" using System.Linq$$; """); - } [WpfFact] public void DoNotComplete_Using3() - { - VerifyNoSpecialSemicolonHandling(""" + => VerifyNoSpecialSemicolonHandling(""" using System.$$Linq """); - } [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/33851")] public void AtEndOfLineOutsideParens() - { - VerifyNoSpecialSemicolonHandling(""" + => VerifyNoSpecialSemicolonHandling(""" public class Class1 { void M() @@ -3832,12 +3551,10 @@ void M() } } """); - } [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/33851")] public void OutsideParensBeforeSpaceDot() - { - VerifyNoSpecialSemicolonHandling(""" + => VerifyNoSpecialSemicolonHandling(""" public class Class1 { void M() @@ -3848,12 +3565,10 @@ void M() } } """); - } [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/34666")] public void BeforeAttribute() - { - VerifyNoSpecialSemicolonHandling(""" + => VerifyNoSpecialSemicolonHandling(""" public class C { private const string s = @@ -3865,12 +3580,10 @@ public void M() } } """); - } [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/34666")] public void ElementBindingExpression() - { - VerifyTypingSemicolon(""" + => VerifyTypingSemicolon(""" class C { void M() @@ -3889,12 +3602,10 @@ void M() } } """); - } [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/34666")] public void BeforeElementBindingExpression() - { - VerifyNoSpecialSemicolonHandling(""" + => VerifyNoSpecialSemicolonHandling(""" class C { void M() @@ -3904,12 +3615,10 @@ void M() } } """); - } [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/34666")] public void AfterElementBindingExpression() - { - VerifyNoSpecialSemicolonHandling(""" + => VerifyNoSpecialSemicolonHandling(""" class C { void M() @@ -3919,13 +3628,11 @@ void M() } } """); - } [WorkItem("https://github.com/dotnet/roslyn/issues/34666")] [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/34983")] public void ImplicitElementAccessSyntax() - { - VerifyTypingSemicolon(""" + => VerifyTypingSemicolon(""" class C { void M() @@ -3948,12 +3655,10 @@ void M() } } """); - } [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/34666")] public void BeforeImplicitElementAccessSyntax() - { - VerifyTypingSemicolon(""" + => VerifyTypingSemicolon(""" class C { void M() @@ -3976,12 +3681,10 @@ void M() } } """); - } [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/34666")] public void AfterImplicitElementAccessSyntax() - { - VerifyTypingSemicolon(""" + => VerifyTypingSemicolon(""" class C { void M() @@ -4004,12 +3707,10 @@ void M() } } """); - } [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/34983")] public void AttributeParsedAsElementAccessExpression() - { - VerifyTypingSemicolon(""" + => VerifyTypingSemicolon(""" using System; internal class TestMethodAttribute : Attribute { @@ -4026,12 +3727,10 @@ internal class TestMethodAttribute : Attribute [Test] } """); - } [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/34983")] public void MemberAccessOffOfMethod() - { - VerifyTypingSemicolon(""" + => VerifyTypingSemicolon(""" class Program { static void Main(string[] args) @@ -4050,12 +3749,10 @@ static void Main(string[] args) } } """); - } [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/34983")] public void LinqQuery() - { - VerifyTypingSemicolon(""" + => VerifyTypingSemicolon(""" using System.Collections.Generic; using System.Linq; class Query @@ -4084,12 +3781,10 @@ void Main(string[] args) } } """); - } [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/34983")] public void LinqQuery2() - { - VerifyTypingSemicolon(""" + => VerifyTypingSemicolon(""" using System.Collections.Generic; using System.Linq; class Query @@ -4116,12 +3811,10 @@ void Main(string[] args) } } """); - } [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/34983")] public void BinaryExpression() - { - VerifyTypingSemicolon(""" + => VerifyTypingSemicolon(""" class D { void M() @@ -4148,12 +3841,10 @@ private int Foo(int v) } } """); - } [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/34983")] public void BinaryExpression2() - { - VerifyTypingSemicolon(""" + => VerifyTypingSemicolon(""" class D { void M() @@ -4180,12 +3871,10 @@ private int Foo(int v) } } """); - } [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/34983")] public void AsOperator() - { - VerifyTypingSemicolon(""" + => VerifyTypingSemicolon(""" class D { void M() @@ -4212,12 +3901,10 @@ object Foo(int v) } } """); - } [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/34983")] public void TernaryOperator() - { - VerifyTypingSemicolon(""" + => VerifyTypingSemicolon(""" class Query { void Main(string[] args) @@ -4246,12 +3933,10 @@ private int Foo(int j) return j; } """); - } [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/34983")] public void SemicolonInCharacterLiteral() - { - VerifyTypingSemicolon(""" + => VerifyTypingSemicolon(""" class D { void Main(string[]args) @@ -4276,12 +3961,10 @@ void M(char c) } } """); - } [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/35260")] public void IncompleteLambda() - { - VerifyTypingSemicolon(""" + => VerifyTypingSemicolon(""" using System; class C @@ -4312,7 +3995,6 @@ public void Test() private void M(Func p) { } } """); - } internal override ICommandHandler GetCommandHandler(EditorTestWorkspace workspace) => workspace.ExportProvider.GetExportedValues().OfType().Single(); @@ -4327,8 +4009,7 @@ public void ArgumentList_MultipleCharsSelected() [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/34051")] public void ParameterList_DelegateDeclaration() - { - VerifyTypingSemicolon(""" + => VerifyTypingSemicolon(""" class C { delegate void Del(string str$$) @@ -4339,23 +4020,19 @@ class C delegate void Del(string str);$$ } """); - } [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/34051")] public void ParameterList_DelegateDeclaration2() - { - VerifyNoSpecialSemicolonHandling(""" + => VerifyNoSpecialSemicolonHandling(""" class C { public delegate TResult Blah(T arg) } """); - } [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/34051")] public void ParameterList_DelegateDeclaration3() - { - VerifyTypingSemicolon(""" + => VerifyTypingSemicolon(""" class C { public delegate TResult Blah(T arg$$) @@ -4366,12 +4043,10 @@ class C public delegate TResult Blah(T arg);$$ } """); - } [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/34051")] public void ParameterList_MultilineDelegateDeclaration() - { - VerifyTypingSemicolon(""" + => VerifyTypingSemicolon(""" class C { delegate void Del(string str$$, @@ -4386,12 +4061,10 @@ delegate void Del(string str, string str2);$$ } """); - } [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/34051")] public void ParameterList_Constructor() - { - VerifyNoSpecialSemicolonHandling(""" + => VerifyNoSpecialSemicolonHandling(""" class D { public D($$) @@ -4399,12 +4072,10 @@ public D($$) } } """); - } [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/34051")] public void ParameterList_Destructor() - { - VerifyNoSpecialSemicolonHandling(""" + => VerifyNoSpecialSemicolonHandling(""" class D { public D() @@ -4416,12 +4087,10 @@ public D() } } """); - } [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/34051")] public void ParameterList_MethodDeclaration() - { - VerifyNoSpecialSemicolonHandling(""" + => VerifyNoSpecialSemicolonHandling(""" class D { void M($$) @@ -4429,12 +4098,10 @@ void M($$) } } """); - } [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/54709")] public void YieldReturn() - { - VerifyTypingSemicolon(""" + => VerifyTypingSemicolon(""" class D { private static IEnumerable M() @@ -4451,7 +4118,6 @@ private static IEnumerable M() } } """); - } [WorkItem("https://github.com/dotnet/roslyn/issues/71933")] [WpfFact] @@ -4510,14 +4176,12 @@ public void NearComments(string argument) [WpfFact, WorkItem("https://devdiv.visualstudio.com/DevDiv/_workitems/edit/923157")] public void BrokenCode_ReturnIfCaretDoesNotMove() - { - VerifyNoSpecialSemicolonHandling(""" + => VerifyNoSpecialSemicolonHandling(""" class D { public Delegate Task Handles(int num)$$ } """); - } [WpfFact, WorkItem("https://github.com/dotnet/roslyn/pull/37874")] public void TestWithSettingTurnedOff() @@ -4547,8 +4211,7 @@ public int XValue [WpfFact] public void TestSwitchExpression() - { - VerifyTypingSemicolon(""" + => VerifyTypingSemicolon(""" public class Bar { public void Test(string myString) @@ -4575,12 +4238,10 @@ public void Test(string myString) } } """); - } [WpfFact] public void TestNotInBracesSwitchExpression() - { - VerifyNoSpecialSemicolonHandling(""" + => VerifyNoSpecialSemicolonHandling(""" public class Bar { public void Test(string myString) @@ -4594,12 +4255,10 @@ public void Test(string myString) } } """); - } [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/70224")] public void TestNotBeforeKeywordInSwitchExpression() - { - VerifyNoSpecialSemicolonHandling(""" + => VerifyNoSpecialSemicolonHandling(""" public class Bar { public void Test(string myString) @@ -4613,12 +4272,10 @@ public void Test(string myString) } } """); - } [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/54213")] public void AfterNewInField1() - { - VerifyTypingSemicolon(""" + => VerifyTypingSemicolon(""" public class C { public List list = new$$ @@ -4629,12 +4286,10 @@ public class C public List list = new();$$ } """); - } [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/54213")] public void AfterNewInField2() - { - VerifyTypingSemicolon(""" + => VerifyTypingSemicolon(""" public class C { List list1 = new$$ @@ -4647,12 +4302,10 @@ public class C List list2; } """); - } [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/54213")] public void AfterNewInLocalDeclaration1() - { - VerifyTypingSemicolon(""" + => VerifyTypingSemicolon(""" public class C { void M() @@ -4669,12 +4322,10 @@ void M() } } """); - } [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/54213")] public void AfterNewInLocalDeclaration2() - { - VerifyTypingSemicolon(""" + => VerifyTypingSemicolon(""" public class C { void M() @@ -4693,7 +4344,6 @@ void M() } } """); - } protected override EditorTestWorkspace CreateTestWorkspace(string code) => EditorTestWorkspace.CreateCSharp(code); diff --git a/src/EditorFeatures/CSharpTest/Completion/CompletionProviders/AttributeNamedParameterCompletionProviderTests.cs b/src/EditorFeatures/CSharpTest/Completion/CompletionProviders/AttributeNamedParameterCompletionProviderTests.cs index e335564b79f0..2578c134dc51 100644 --- a/src/EditorFeatures/CSharpTest/Completion/CompletionProviders/AttributeNamedParameterCompletionProviderTests.cs +++ b/src/EditorFeatures/CSharpTest/Completion/CompletionProviders/AttributeNamedParameterCompletionProviderTests.cs @@ -46,9 +46,8 @@ public class TestAttribute : Attribute } [Fact] - public async Task CommitCharacterTest() - { - const string markup = """ + public Task CommitCharacterTest() + => VerifyCommonCommitCharactersAsync(""" using System; class class1 { @@ -62,10 +61,7 @@ public class TestAttribute : Attribute { public ConsoleColor Color { get; set; } } - """; - - await VerifyCommonCommitCharactersAsync(markup, textTypedSoFar: ""); - } + """, textTypedSoFar: ""); [Fact] public Task SimpleAttributeUsage() diff --git a/src/EditorFeatures/CSharpTest/Completion/CompletionProviders/ConversionCompletionProviderTests.cs b/src/EditorFeatures/CSharpTest/Completion/CompletionProviders/ConversionCompletionProviderTests.cs index 2acfa783ddb1..0473e80233c2 100644 --- a/src/EditorFeatures/CSharpTest/Completion/CompletionProviders/ConversionCompletionProviderTests.cs +++ b/src/EditorFeatures/CSharpTest/Completion/CompletionProviders/ConversionCompletionProviderTests.cs @@ -343,9 +343,8 @@ public static void Main() """, "int?", displayTextPrefix: "(", displayTextSuffix: ")", glyph: Glyph.OperatorPublic, matchingFilters: [FilterSet.OperatorFilter]); [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/47511")] - public async Task ExplicitConversionDescriptionIsIsGiven() - { - const string Markup = """ + public Task ExplicitConversionDescriptionIsIsGiven() + => VerifyItemExistsAsync(""" public struct S { /// /// Explicit conversion of to . @@ -362,8 +361,7 @@ public static void Main() s.$$ } } - """; - await VerifyItemExistsAsync(Markup, "int", displayTextPrefix: "(", displayTextSuffix: ")", + """, "int", displayTextPrefix: "(", displayTextSuffix: ")", glyph: Glyph.OperatorPublic, matchingFilters: [FilterSet.OperatorFilter], expectedDescriptionOrNull: @@ -371,12 +369,10 @@ await VerifyItemExistsAsync(Markup, "int", displayTextPrefix: "(", displayTextSu S.explicit operator int(S value) Explicit conversion of S to int. """); - } [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/47511")] - public async Task ExplicitConversionDescriptionIsIsGivenLifted() - { - const string Markup = """ + public Task ExplicitConversionDescriptionIsIsGivenLifted() + => VerifyItemExistsAsync(""" public struct S { /// /// Explicit conversion of to . @@ -393,8 +389,7 @@ public static void Main() s.$$ } } - """; - await VerifyItemExistsAsync(Markup, "int?", displayTextPrefix: "(", displayTextSuffix: ")", + """, "int?", displayTextPrefix: "(", displayTextSuffix: ")", glyph: Glyph.OperatorPublic, matchingFilters: [FilterSet.OperatorFilter], expectedDescriptionOrNull: @@ -402,7 +397,6 @@ await VerifyItemExistsAsync(Markup, "int?", displayTextPrefix: "(", displayTextS S.explicit operator int?(S? value) Explicit conversion of S to int. """); - } [WpfTheory, WorkItem("https://github.com/dotnet/roslyn/issues/47511")] [InlineData("sbyte", "byte", "char", "uint", "ulong", "ushort")] @@ -435,9 +429,8 @@ public static void Main() } [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/47511")] - public async Task ExplicitBuiltInNumericConversionDescriptionIsLikeAConversionOperatorDescription() - { - const string Markup = """ + public Task ExplicitBuiltInNumericConversionDescriptionIsLikeAConversionOperatorDescription() + => VerifyItemExistsAsync(""" public class Program { public static void Main() @@ -446,8 +439,7 @@ public static void Main() i.$$ } } - """; - await VerifyItemExistsAsync(Markup, "byte", displayTextPrefix: "(", displayTextSuffix: ")", + """, "byte", displayTextPrefix: "(", displayTextSuffix: ")", glyph: Glyph.OperatorPublic, matchingFilters: [FilterSet.OperatorFilter], expectedDescriptionOrNull: @@ -455,12 +447,10 @@ await VerifyItemExistsAsync(Markup, "byte", displayTextPrefix: "(", displayTextS int.explicit operator byte(int value) {(FormatExplicitConversionDescription(fromType: "int", toType: "byte"))} """); - } [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/47511")] - public async Task ExplicitBuiltInNumericConversionDescriptionIsLikeAConversionOperatorDescriptionLifted() - { - const string Markup = """ + public Task ExplicitBuiltInNumericConversionDescriptionIsLikeAConversionOperatorDescriptionLifted() + => VerifyItemExistsAsync(""" public class Program { public static void Main() @@ -469,8 +459,7 @@ public static void Main() i.$$ } } - """; - await VerifyItemExistsAsync(Markup, "byte?", displayTextPrefix: "(", displayTextSuffix: ")", + """, "byte?", displayTextPrefix: "(", displayTextSuffix: ")", glyph: Glyph.OperatorPublic, matchingFilters: [FilterSet.OperatorFilter], expectedDescriptionOrNull: @@ -478,7 +467,6 @@ await VerifyItemExistsAsync(Markup, "byte?", displayTextPrefix: "(", displayText int.explicit operator byte?(int? value) {(FormatExplicitConversionDescription(fromType: "int", toType: "byte"))} """); - } [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/47511")] public async Task ExplicitBuiltInEnumConversionsAreSortedAndComplete() @@ -501,9 +489,8 @@ public static void Main() } [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/47511")] - public async Task ExplicitBuiltInEnumConversionDescriptionIsLikeAConversionOperatorDescription() - { - const string Markup = """ + public Task ExplicitBuiltInEnumConversionDescriptionIsLikeAConversionOperatorDescription() + => VerifyItemExistsAsync(""" public enum E { One } public class Program { @@ -513,8 +500,7 @@ public static void Main() e.$$ } } - """; - await VerifyItemExistsAsync(Markup, "int", displayTextPrefix: "(", displayTextSuffix: ")", + """, "int", displayTextPrefix: "(", displayTextSuffix: ")", glyph: Glyph.OperatorPublic, matchingFilters: [FilterSet.OperatorFilter], expectedDescriptionOrNull: @@ -522,12 +508,10 @@ await VerifyItemExistsAsync(Markup, "int", displayTextPrefix: "(", displayTextSu E.explicit operator int(E value) {FormatExplicitConversionDescription("E", "int")} """); - } [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/47511")] - public async Task ExplicitBuiltInEnumConversionDescriptionIsLikeAConversionOperatorDescriptionLifted() - { - const string Markup = """ + public Task ExplicitBuiltInEnumConversionDescriptionIsLikeAConversionOperatorDescriptionLifted() + => VerifyItemExistsAsync(""" public enum E { One } public class Program { @@ -537,8 +521,7 @@ public static void Main() e.$$ } } - """; - await VerifyItemExistsAsync(Markup, "int?", displayTextPrefix: "(", displayTextSuffix: ")", + """, "int?", displayTextPrefix: "(", displayTextSuffix: ")", glyph: Glyph.OperatorPublic, matchingFilters: [FilterSet.OperatorFilter], expectedDescriptionOrNull: @@ -546,12 +529,10 @@ await VerifyItemExistsAsync(Markup, "int?", displayTextPrefix: "(", displayTextS E.explicit operator int?(E? value) {(FormatExplicitConversionDescription(fromType: "E", toType: "int"))} """); - } [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/47511")] - public async Task ExplicitBuiltInEnumConversionDescriptionIsLikeAConversionOperatorDescriptionUnimportedNamespaceMinimalName() - { - const string Markup = """ + public Task ExplicitBuiltInEnumConversionDescriptionIsLikeAConversionOperatorDescriptionUnimportedNamespaceMinimalName() + => VerifyItemExistsAsync(""" namespace A.B { public enum E { One } @@ -567,8 +548,7 @@ public static void Main() } } } - """; - await VerifyItemExistsAsync(Markup, "int", displayTextPrefix: "(", displayTextSuffix: ")", + """, "int", displayTextPrefix: "(", displayTextSuffix: ")", glyph: Glyph.OperatorPublic, matchingFilters: [FilterSet.OperatorFilter], expectedDescriptionOrNull: @@ -576,7 +556,6 @@ await VerifyItemExistsAsync(Markup, "int", displayTextPrefix: "(", displayTextSu B.E.explicit operator int(B.E value) {FormatExplicitConversionDescription("B.E", "int")} """); - } [WpfTheory, WorkItem("https://github.com/dotnet/roslyn/issues/47511")] [InlineData("e.$$", true)] diff --git a/src/EditorFeatures/CSharpTest/Completion/CompletionProviders/DeclarationNameCompletionProviderTests.cs b/src/EditorFeatures/CSharpTest/Completion/CompletionProviders/DeclarationNameCompletionProviderTests.cs index e4464bfd1b29..3f54ce40b2bc 100644 --- a/src/EditorFeatures/CSharpTest/Completion/CompletionProviders/DeclarationNameCompletionProviderTests.cs +++ b/src/EditorFeatures/CSharpTest/Completion/CompletionProviders/DeclarationNameCompletionProviderTests.cs @@ -380,9 +380,10 @@ async Task $$ } """, "GetCAsync"); - [Fact(Skip = "not yet implemented")] + [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/17989")] public Task NonAsyncTaskOfT() => VerifyItemExistsAsync(""" + using System.Threading.Tasks; public class C { Task $$ @@ -2606,6 +2607,32 @@ void M(object o) } """, "customers"); + [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/79417")] + public Task TestNestedParameter1() + => VerifyItemExistsAsync(""" + class C + { + void M(MyWidget myWidget) + { + void LocalFunction(MyWidget $$) { } + } + } + """, "myWidget"); + + [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/79417")] + public Task TestNestedParameter2() + => VerifyItemExistsAsync(""" + class MyWidget { } + class C(MyWidget myWidget) + { + class D(MyWidget $$) { } + } + """, "myWidget"); + +#if false + +#endif + private static NamingStylePreferences MultipleCamelCaseLocalRules() { var styles = new[] diff --git a/src/EditorFeatures/CSharpTest/Completion/CompletionProviders/ExtensionMethodImportCompletionProviderTests.cs b/src/EditorFeatures/CSharpTest/Completion/CompletionProviders/ExtensionMethodImportCompletionProviderTests.cs index 7367d4c1b7e8..ee2a95af102b 100644 --- a/src/EditorFeatures/CSharpTest/Completion/CompletionProviders/ExtensionMethodImportCompletionProviderTests.cs +++ b/src/EditorFeatures/CSharpTest/Completion/CompletionProviders/ExtensionMethodImportCompletionProviderTests.cs @@ -40,7 +40,7 @@ public enum ReferenceType private static IEnumerable CombineWithReferenceTypeData(IEnumerable> data) { - foreach (var refKind in Enum.GetValues(typeof(ReferenceType))) + foreach (var refKind in Enum.GetValues()) { foreach (var d in data) { diff --git a/src/EditorFeatures/CSharpTest/Completion/CompletionProviders/NamedParameterCompletionProviderTests.cs b/src/EditorFeatures/CSharpTest/Completion/CompletionProviders/NamedParameterCompletionProviderTests.cs index aeeecc6ddd53..b1c27256dd7f 100644 --- a/src/EditorFeatures/CSharpTest/Completion/CompletionProviders/NamedParameterCompletionProviderTests.cs +++ b/src/EditorFeatures/CSharpTest/Completion/CompletionProviders/NamedParameterCompletionProviderTests.cs @@ -41,9 +41,8 @@ void Bar() } [Fact] - public async Task CommitCharacterTest() - { - const string markup = """ + public Task CommitCharacterTest() + => VerifyCommonCommitCharactersAsync(""" class Goo { public Goo(int a = 42) @@ -54,10 +53,7 @@ void Bar() var b = new Goo($$ } } - """; - - await VerifyCommonCommitCharactersAsync(markup, textTypedSoFar: ""); - } + """, textTypedSoFar: ""); [Fact] public Task InObjectCreation() diff --git a/src/EditorFeatures/CSharpTest/Completion/CompletionProviders/ObjectCreationCompletionProviderTests.cs b/src/EditorFeatures/CSharpTest/Completion/CompletionProviders/ObjectCreationCompletionProviderTests.cs index 67c4961b7838..e14101dee2ad 100644 --- a/src/EditorFeatures/CSharpTest/Completion/CompletionProviders/ObjectCreationCompletionProviderTests.cs +++ b/src/EditorFeatures/CSharpTest/Completion/CompletionProviders/ObjectCreationCompletionProviderTests.cs @@ -102,9 +102,8 @@ class Program """), "string"); [Fact] - public async Task IsCommitCharacterTest() - { - const string markup = """ + public Task IsCommitCharacterTest() + => VerifyCommitCharactersAsync(""" using D = System.Globalization.DigitShapes; class Program { @@ -113,12 +112,9 @@ static void Main(string[] args) D d = new $$ } } - """; - - await VerifyCommitCharactersAsync(markup, textTypedSoFar: "", + """, textTypedSoFar: "", validChars: [' ', '(', '{', '['], invalidChars: ['x', ',', '#']); - } [Fact] public void IsTextualTriggerCharacterTest() diff --git a/src/EditorFeatures/CSharpTest/Completion/CompletionProviders/ObjectInitializerCompletionProviderTests.cs b/src/EditorFeatures/CSharpTest/Completion/CompletionProviders/ObjectInitializerCompletionProviderTests.cs index 7d9156b26d15..63781d52ca31 100644 --- a/src/EditorFeatures/CSharpTest/Completion/CompletionProviders/ObjectInitializerCompletionProviderTests.cs +++ b/src/EditorFeatures/CSharpTest/Completion/CompletionProviders/ObjectInitializerCompletionProviderTests.cs @@ -626,9 +626,8 @@ await VerifyItemInEditorBrowsableContextsAsync( } [Fact] - public async Task TestCommitCharacter() - { - const string markup = """ + public Task TestCommitCharacter() + => VerifyCommonCommitCharactersAsync(""" class C { public int value {set; get; }} class D @@ -638,10 +637,7 @@ void goo() C goo = new C { v$$ } } - """; - - await VerifyCommonCommitCharactersAsync(markup, textTypedSoFar: "v"); - } + """, textTypedSoFar: "v"); [Fact] public async Task TestEnter() diff --git a/src/EditorFeatures/CSharpTest/Completion/CompletionProviders/PartialMethodCompletionProviderTests.cs b/src/EditorFeatures/CSharpTest/Completion/CompletionProviders/PartialMethodCompletionProviderTests.cs index 996ecc27e042..ee712963bef6 100644 --- a/src/EditorFeatures/CSharpTest/Completion/CompletionProviders/PartialMethodCompletionProviderTests.cs +++ b/src/EditorFeatures/CSharpTest/Completion/CompletionProviders/PartialMethodCompletionProviderTests.cs @@ -2,8 +2,6 @@ // 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; using System.Threading.Tasks; using Microsoft.CodeAnalysis.CodeStyle; @@ -757,6 +755,33 @@ partial class Bar """); } + [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/68805")] + public Task TestUnsafePartial() + => VerifyCustomCommitProviderAsync(""" + unsafe partial class A + { + partial void Goo(void* p); + } + + partial class A + { + partial $$ + } + """, "Goo(void* p)", """ + unsafe partial class A + { + partial void Goo(void* p); + } + + partial class A + { + unsafe partial void Goo(void* p) + { + [|throw new System.NotImplementedException();|] + } + } + """); + private Task VerifyItemExistsAsync(string markup, string expectedItem) { return VerifyItemExistsAsync(markup, expectedItem, isComplexTextEdit: true); diff --git a/src/EditorFeatures/CSharpTest/Completion/CompletionProviders/SpeculativeTCompletionProviderTests.cs b/src/EditorFeatures/CSharpTest/Completion/CompletionProviders/SpeculativeTCompletionProviderTests.cs index e7632aec4e47..935aa98546e0 100644 --- a/src/EditorFeatures/CSharpTest/Completion/CompletionProviders/SpeculativeTCompletionProviderTests.cs +++ b/src/EditorFeatures/CSharpTest/Completion/CompletionProviders/SpeculativeTCompletionProviderTests.cs @@ -20,17 +20,13 @@ internal override Type GetCompletionProviderType() => typeof(SpeculativeTCompletionProvider); [Fact, Trait(Traits.Feature, Traits.Features.Completion)] - public async Task IsCommitCharacterTest() - { - const string markup = """ + public Task IsCommitCharacterTest() + => VerifyCommonCommitCharactersAsync(""" class C { $$ } - """; - - await VerifyCommonCommitCharactersAsync(markup, textTypedSoFar: ""); - } + """, textTypedSoFar: ""); [Fact, Trait(Traits.Feature, Traits.Features.Completion)] public void IsTextualTriggerCharacterTest() diff --git a/src/EditorFeatures/CSharpTest/Completion/CompletionProviders/SymbolCompletionProviderTests.cs b/src/EditorFeatures/CSharpTest/Completion/CompletionProviders/SymbolCompletionProviderTests.cs index 60063fe34c07..c469fc7f9578 100644 --- a/src/EditorFeatures/CSharpTest/Completion/CompletionProviders/SymbolCompletionProviderTests.cs +++ b/src/EditorFeatures/CSharpTest/Completion/CompletionProviders/SymbolCompletionProviderTests.cs @@ -12904,7 +12904,7 @@ public static T Method(this T s) public async Task SwitchExpressionEnumColorColor_01() { //lang=c#-test - const string source = """ + await VerifyExpectedItemsAsync(""" public sealed record OrderModel(int Id, Status Status) { public string StatusDisplay @@ -12925,8 +12925,7 @@ public enum Status Open, Closed, } - """; - await VerifyExpectedItemsAsync(source, [ + """, [ ItemExpectation.Exists("Undisclosed"), ItemExpectation.Absent("ToString"), ]); @@ -12936,7 +12935,7 @@ await VerifyExpectedItemsAsync(source, [ public async Task SwitchExpressionEnumColorColor_02() { //lang=c#-test - const string source = """ + await VerifyExpectedItemsAsync(""" public sealed record OrderModel(int Id, Status Status) { public string StatusDisplay @@ -12957,8 +12956,7 @@ public enum Status Open, Closed, } - """; - await VerifyExpectedItemsAsync(source, [ + """, [ ItemExpectation.Exists("Undisclosed"), ItemExpectation.Absent("ToString"), ]); @@ -12968,7 +12966,7 @@ await VerifyExpectedItemsAsync(source, [ public async Task SwitchExpressionEnumColorColor_03() { //lang=c#-test - const string source = """ + await VerifyExpectedItemsAsync(""" namespace Status; public sealed record OrderModel(int Id, StatusEn Status) @@ -12991,8 +12989,7 @@ public enum StatusEn Open, Closed, } - """; - await VerifyExpectedItemsAsync(source, [ + """, [ ItemExpectation.Exists("StatusEn"), ItemExpectation.Absent("ToString"), ]); @@ -13002,7 +12999,7 @@ await VerifyExpectedItemsAsync(source, [ public async Task SwitchExpressionEnumColorColor_04() { //lang=c#-test - const string source = """ + await VerifyExpectedItemsAsync(""" using Status = StatusEn; public sealed record OrderModel(int Id, StatusEn Status) @@ -13025,8 +13022,7 @@ public enum StatusEn Open, Closed, } - """; - await VerifyExpectedItemsAsync(source, [ + """, [ ItemExpectation.Exists("Undisclosed"), ItemExpectation.Absent("ToString"), ]); @@ -13036,7 +13032,7 @@ await VerifyExpectedItemsAsync(source, [ public async Task SwitchExpressionEnumColorColor_05() { //lang=c#-test - const string source = """ + await VerifyExpectedItemsAsync(""" using Status = StatusEn; public sealed record OrderModel(int Id, StatusEn Status) @@ -13060,8 +13056,7 @@ public enum StatusEn Open, Closed, } - """; - await VerifyExpectedItemsAsync(source, [ + """, [ ItemExpectation.Exists("Undisclosed"), ItemExpectation.Absent("ToString"), ]); @@ -13071,7 +13066,7 @@ await VerifyExpectedItemsAsync(source, [ public async Task ConstantPatternExpressionEnumColorColor_01() { //lang=c#-test - const string source = """ + await VerifyExpectedItemsAsync(""" public sealed record OrderModel(int Id, Status Status) { public string StatusDisplay @@ -13090,8 +13085,7 @@ public enum Status Open, Closed, } - """; - await VerifyExpectedItemsAsync(source, [ + """, [ ItemExpectation.Exists("Undisclosed"), ItemExpectation.Absent("ToString"), ]); @@ -13101,7 +13095,7 @@ await VerifyExpectedItemsAsync(source, [ public async Task ConstantPatternExpressionEnumColorColor_02() { //lang=c#-test - const string source = """ + await VerifyExpectedItemsAsync(""" public sealed record OrderModel(int Id, Status Status) { public string StatusDisplay @@ -13120,8 +13114,7 @@ public enum Status Open, Closed, } - """; - await VerifyExpectedItemsAsync(source, [ + """, [ ItemExpectation.Exists("Undisclosed"), ItemExpectation.Absent("ToString"), ]); @@ -13131,7 +13124,7 @@ await VerifyExpectedItemsAsync(source, [ public async Task ConstantPatternExpressionEnumColorColor_03() { //lang=c#-test - const string source = """ + await VerifyExpectedItemsAsync(""" namespace Status; public sealed record OrderModel(int Id, StatusEn Status) @@ -13152,8 +13145,7 @@ public enum StatusEn Open, Closed, } - """; - await VerifyExpectedItemsAsync(source, [ + """, [ ItemExpectation.Exists("StatusEn"), ItemExpectation.Absent("ToString"), ]); @@ -13163,7 +13155,7 @@ await VerifyExpectedItemsAsync(source, [ public async Task ConstantPatternExpressionEnumColorColor_04() { //lang=c#-test - const string source = """ + await VerifyExpectedItemsAsync(""" using Status = StatusEn; public sealed record OrderModel(int Id, StatusEn Status) @@ -13184,8 +13176,7 @@ public enum StatusEn Open, Closed, } - """; - await VerifyExpectedItemsAsync(source, [ + """, [ ItemExpectation.Exists("Undisclosed"), ItemExpectation.Absent("ToString"), ]); @@ -13195,7 +13186,7 @@ await VerifyExpectedItemsAsync(source, [ public async Task ConstantPatternExpressionEnumColorColor_05() { //lang=c#-test - const string source = """ + await VerifyExpectedItemsAsync(""" using Status = StatusEn; public sealed record OrderModel(int Id, StatusEn Status) @@ -13217,8 +13208,7 @@ public enum StatusEn Open, Closed, } - """; - await VerifyExpectedItemsAsync(source, [ + """, [ ItemExpectation.Exists("Undisclosed"), ItemExpectation.Absent("ToString"), ]); diff --git a/src/EditorFeatures/CSharpTest/Diagnostics/AbstractCSharpDiagnosticProviderBasedUserDiagnosticTest.cs b/src/EditorFeatures/CSharpTest/Diagnostics/AbstractCSharpDiagnosticProviderBasedUserDiagnosticTest.cs index 9ea1e21c7bfc..d5a8ca833e74 100644 --- a/src/EditorFeatures/CSharpTest/Diagnostics/AbstractCSharpDiagnosticProviderBasedUserDiagnosticTest.cs +++ b/src/EditorFeatures/CSharpTest/Diagnostics/AbstractCSharpDiagnosticProviderBasedUserDiagnosticTest.cs @@ -160,28 +160,28 @@ public interface IAsyncEnumerator : IAsyncDisposable internal OptionsCollection RemoveAllUnnecessaryParentheses => ParenthesesOptionsProvider.RemoveAllUnnecessaryParentheses; internal OptionsCollection RequireAllParenthesesForClarity => ParenthesesOptionsProvider.RequireAllParenthesesForClarity; - internal new Task TestInRegularAndScript1Async( + internal new Task TestInRegularAndScriptAsync( [StringSyntax(PredefinedEmbeddedLanguageNames.CSharpTest)] string initialMarkup, [StringSyntax(PredefinedEmbeddedLanguageNames.CSharpTest)] string expectedMarkup, int index = 0, TestParameters? parameters = null) { - return base.TestInRegularAndScript1Async(initialMarkup, expectedMarkup, index, parameters); + return base.TestInRegularAndScriptAsync(initialMarkup, expectedMarkup, index, parameters); } - internal new Task TestInRegularAndScriptAsync( - [StringSyntax(PredefinedEmbeddedLanguageNames.CSharpTest)] string initialMarkup, - [StringSyntax(PredefinedEmbeddedLanguageNames.CSharpTest)] string expectedMarkup, - int index = 0, - CodeActionPriority? priority = null, - CompilationOptions? compilationOptions = null, - OptionsCollectionAlias? options = null, - object? fixProviderData = null, - ParseOptions? parseOptions = null, - string? title = null, - TestHost testHost = TestHost.OutOfProcess) - { - return base.TestInRegularAndScriptAsync( - initialMarkup, expectedMarkup, index, priority, compilationOptions, options, fixProviderData, parseOptions, title, testHost); - } + //internal new Task TestInRegularAndScriptAsync( + // [StringSyntax(PredefinedEmbeddedLanguageNames.CSharpTest)] string initialMarkup, + // [StringSyntax(PredefinedEmbeddedLanguageNames.CSharpTest)] string expectedMarkup, + // int index = 0, + // CodeActionPriority? priority = null, + // CompilationOptions? compilationOptions = null, + // OptionsCollectionAlias? options = null, + // object? fixProviderData = null, + // ParseOptions? parseOptions = null, + // string? title = null, + // TestHost testHost = TestHost.OutOfProcess) + //{ + // return base.TestInRegularAndScriptAsync( + // initialMarkup, expectedMarkup, index, priority, compilationOptions, options, fixProviderData, parseOptions, title, testHost); + //} } diff --git a/src/EditorFeatures/CSharpTest/Diagnostics/MockDiagnosticAnalyzerTests.cs b/src/EditorFeatures/CSharpTest/Diagnostics/MockDiagnosticAnalyzerTests.cs index d37d975ea987..ce3d0e8006ca 100644 --- a/src/EditorFeatures/CSharpTest/Diagnostics/MockDiagnosticAnalyzerTests.cs +++ b/src/EditorFeatures/CSharpTest/Diagnostics/MockDiagnosticAnalyzerTests.cs @@ -54,7 +54,7 @@ private async Task VerifyDiagnosticsAsync( params DiagnosticDescription[] expectedDiagnostics) { using var workspace = EditorTestWorkspace.CreateCSharp(source, composition: GetComposition()); - var actualDiagnostics = await this.GetDiagnosticsAsync(workspace, new TestParameters()); + var actualDiagnostics = await this.GetDiagnosticsAsync(workspace, TestParameters.Default); actualDiagnostics.Verify(expectedDiagnostics); } diff --git a/src/EditorFeatures/CSharpTest/DocumentationComments/DocumentationCommentTests.cs b/src/EditorFeatures/CSharpTest/DocumentationComments/DocumentationCommentTests.cs index 6becc2a439fe..2817c3cdb331 100644 --- a/src/EditorFeatures/CSharpTest/DocumentationComments/DocumentationCommentTests.cs +++ b/src/EditorFeatures/CSharpTest/DocumentationComments/DocumentationCommentTests.cs @@ -19,8 +19,7 @@ public sealed class DocumentationCommentTests : AbstractDocumentationCommentTest { [WpfFact] public void TypingCharacter_Class() - { - VerifyTypingCharacter(""" + => VerifyTypingCharacter(""" //$$ class C { @@ -33,12 +32,10 @@ class C { } """); - } [WpfFact] public void TypingCharacter_Record() - { - VerifyTypingCharacter(""" + => VerifyTypingCharacter(""" //$$ record R; """, """ @@ -47,12 +44,10 @@ record R; /// record R; """); - } [WpfFact] public void TypingCharacter_RecordStruct() - { - VerifyTypingCharacter(""" + => VerifyTypingCharacter(""" //$$ record struct R; """, """ @@ -61,12 +56,10 @@ record struct R; /// record struct R; """); - } [WpfFact] public void TypingCharacter_RecordWithPositionalParameters() - { - VerifyTypingCharacter(""" + => VerifyTypingCharacter(""" //$$ record R(string S, int I); """, """ @@ -77,12 +70,10 @@ record R(string S, int I); /// record R(string S, int I); """); - } [WpfFact] public void TypingCharacter_ClassParameters() - { - VerifyTypingCharacter(""" + => VerifyTypingCharacter(""" //$$ class R(string S, int I); """, """ @@ -93,12 +84,10 @@ class R(string S, int I); /// class R(string S, int I); """); - } [WpfFact] public void TypingCharacter_RecordStructWithPositionalParameters() - { - VerifyTypingCharacter(""" + => VerifyTypingCharacter(""" //$$ record struct R(string S, int I); """, """ @@ -109,12 +98,10 @@ record struct R(string S, int I); /// record struct R(string S, int I); """); - } [WpfFact] public void TypingCharacter_StructParameters() - { - VerifyTypingCharacter(""" + => VerifyTypingCharacter(""" //$$ struct R(string S, int I); """, """ @@ -125,7 +112,6 @@ struct R(string S, int I); /// struct R(string S, int I); """); - } [WpfFact] public void TypingCharacter_Class_NewLine() @@ -175,8 +161,7 @@ class C [WpfFact] public void TypingCharacter_Class_AutoGenerateXmlDocCommentsOff() - { - VerifyTypingCharacter(""" + => VerifyTypingCharacter(""" //$$ class C { @@ -190,12 +175,10 @@ class C { { DocumentationCommentOptionsStorage.AutoXmlDocCommentGeneration, false } }); - } [WpfFact] public void TypingCharacter_Method() - { - VerifyTypingCharacter(""" + => VerifyTypingCharacter(""" class C { //$$ @@ -213,12 +196,10 @@ class C int M(int goo) { return 0; } } """); - } [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/54245")] public void TypingCharacter_Method_WithExceptions() - { - VerifyTypingCharacter(""" + => VerifyTypingCharacter(""" class C { //$$ @@ -245,12 +226,10 @@ int M(int goo) } } """); - } [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/54245")] public void TypingCharacter_Constructor_WithExceptions() - { - VerifyTypingCharacter(""" + => VerifyTypingCharacter(""" class C { //$$ @@ -278,12 +257,10 @@ public C(int goo) } } """); - } [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/54245")] public void TypingCharacter_Constructor_WithExceptions_Caught() - { - VerifyTypingCharacter(""" + => VerifyTypingCharacter(""" using System; @@ -338,12 +315,10 @@ public C(int goo) } } """); - } [WpfFact] public void TypingCharacter_Method_WithVerbatimParams() - { - VerifyTypingCharacter(""" + => VerifyTypingCharacter(""" class C { //$$ @@ -361,12 +336,10 @@ class C int M<@int>(int @goo) { return 0; } } """); - } [WpfFact] public void TypingCharacter_AutoProperty() - { - VerifyTypingCharacter(""" + => VerifyTypingCharacter(""" class C { //$$ @@ -381,12 +354,10 @@ class C int P { get; set; } } """); - } [WpfFact] public void TypingCharacter_Property() - { - VerifyTypingCharacter(""" + => VerifyTypingCharacter(""" class C { //$$ @@ -409,12 +380,10 @@ int P } } """); - } [WpfFact] public void TypingCharacter_Indexer() - { - VerifyTypingCharacter(""" + => VerifyTypingCharacter(""" class C { //$$ @@ -439,12 +408,10 @@ int this[int index] } } """); - } [WpfFact] public void TypingCharacter_VoidMethod1() - { - VerifyTypingCharacter(""" + => VerifyTypingCharacter(""" class C { //$$ @@ -461,12 +428,10 @@ class C void M(int goo) { } } """); - } [WpfFact] public void TypingCharacter_VoidMethod_WithVerbatimParams() - { - VerifyTypingCharacter(""" + => VerifyTypingCharacter(""" class C { //$$ @@ -483,12 +448,10 @@ class C void M<@T>(int @int) { } } """); - } [WpfFact, WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/538699")] public void TypingCharacter_VoidMethod2() - { - VerifyTypingCharacter(""" + => VerifyTypingCharacter(""" class C { //$$ @@ -503,12 +466,10 @@ class C void Method() { } } """); - } [WpfFact] public void TypingCharacter_NotWhenDocCommentExists1() - { - VerifyTypingCharacter(""" + => VerifyTypingCharacter(""" /// //$$ @@ -523,12 +484,10 @@ class C { } """); - } [WpfFact] public void TypingCharacter_NotWhenDocCommentExists2() - { - VerifyTypingCharacter(""" + => VerifyTypingCharacter(""" /// @@ -545,12 +504,10 @@ class C { } """); - } [WpfFact] public void TypingCharacter_NotWhenDocCommentExists3() - { - VerifyTypingCharacter(""" + => VerifyTypingCharacter(""" class B { } /// @@ -567,12 +524,10 @@ class C { } """); - } [WpfFact] public void TypingCharacter_NotWhenDocCommentExists4() - { - VerifyTypingCharacter(""" + => VerifyTypingCharacter(""" //$$ /// class C @@ -585,12 +540,10 @@ class C { } """); - } [WpfFact] public void TypingCharacter_NotWhenDocCommentExists5() - { - VerifyTypingCharacter(""" + => VerifyTypingCharacter(""" class C { //$$ @@ -605,12 +558,10 @@ class C int M(int goo) { return 0; } } """); - } [WpfFact] public void TypingCharacter_NotInsideMethodBody1() - { - VerifyTypingCharacter(""" + => VerifyTypingCharacter(""" class C { void M(int goo) @@ -627,12 +578,10 @@ void M(int goo) } } """); - } [WpfFact] public void TypingCharacter_NotInsideMethodBody2() - { - VerifyTypingCharacter(""" + => VerifyTypingCharacter(""" class C { /// @@ -651,12 +600,10 @@ void M(int goo) } } """); - } [WpfFact] public void TypingCharacter_NotAfterClassName() - { - VerifyTypingCharacter(""" + => VerifyTypingCharacter(""" class C//$$ { } @@ -665,12 +612,10 @@ class C///$$ { } """); - } [WpfFact] public void TypingCharacter_NotAfterOpenBrace() - { - VerifyTypingCharacter(""" + => VerifyTypingCharacter(""" class C {//$$ } @@ -679,12 +624,10 @@ class C {///$$ } """); - } [WpfFact] public void TypingCharacter_NotAfterCtorName() - { - VerifyTypingCharacter(""" + => VerifyTypingCharacter(""" class C { C() //$$ @@ -695,12 +638,10 @@ class C C() ///$$ } """); - } [WpfFact] public void TypingCharacter_NotInsideCtor() - { - VerifyTypingCharacter(""" + => VerifyTypingCharacter(""" class C { C() @@ -717,12 +658,10 @@ class C } } """); - } [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/59081")] public void TypingCharacter_NotInTopLevel() - { - VerifyTypingCharacter(""" + => VerifyTypingCharacter(""" using System; @@ -737,12 +676,10 @@ public void TypingCharacter_NotInTopLevel() Console.WriteLine(); """); - } [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/59081")] public void TypingCharacter_NotInNamespace() - { - VerifyTypingCharacter(""" + => VerifyTypingCharacter(""" using System; @@ -757,12 +694,10 @@ namespace NS { } namespace NS { } """); - } [WpfFact] public void PressingEnter_InsertComment_Class1() - { - VerifyPressingEnter(""" + => VerifyPressingEnter(""" ///$$ class C { @@ -775,12 +710,10 @@ class C { } """); - } [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/4817")] public void PressingEnter_InsertComment_Class1_AutoGenerateXmlDocCommentsOff() - { - VerifyPressingEnter(""" + => VerifyPressingEnter(""" ///$$ class C { @@ -795,12 +728,10 @@ class C { { DocumentationCommentOptionsStorage.AutoXmlDocCommentGeneration, false } }); - } [WpfFact] public void PressingEnter_InsertComment_Class2() - { - VerifyPressingEnter(""" + => VerifyPressingEnter(""" ///$$class C { } @@ -812,12 +743,10 @@ class C { } """); - } [WpfFact] public void PressingEnter_InsertComment_Class3() - { - VerifyPressingEnter(""" + => VerifyPressingEnter(""" ///$$[Goo] class C { } @@ -829,12 +758,10 @@ [Goo] class C { } """); - } [WpfFact] public void PressingEnter_InsertComment_NotAfterWhitespace() - { - VerifyPressingEnter(""" + => VerifyPressingEnter(""" /// $$class C { } @@ -844,12 +771,10 @@ public void PressingEnter_InsertComment_NotAfterWhitespace() { } """); - } [WpfFact] public void PressingEnter_InsertComment_Method1() - { - VerifyPressingEnter(""" + => VerifyPressingEnter(""" class C { ///$$ @@ -867,12 +792,10 @@ class C int M(int goo) { return 0; } } """); - } [WpfFact] public void PressingEnter_InsertComment_Method2() - { - VerifyPressingEnter(""" + => VerifyPressingEnter(""" class C { ///$$int M(int goo) { return 0; } @@ -889,12 +812,10 @@ class C int M(int goo) { return 0; } } """); - } [WpfFact] public void PressingEnter_NotInMethodBody1() - { - VerifyPressingEnter(""" + => VerifyPressingEnter(""" class C { void Goo() @@ -912,12 +833,10 @@ void Goo() } } """); - } [WpfFact, WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/537513")] public void PressingEnter_NotInterleavedInClassName1() - { - VerifyPressingEnter(""" + => VerifyPressingEnter(""" class///$$ C { } @@ -927,12 +846,10 @@ public void PressingEnter_NotInterleavedInClassName1() { } """); - } [WpfFact, WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/537513")] public void PressingEnter_NotInterleavedInClassName2() - { - VerifyPressingEnter(""" + => VerifyPressingEnter(""" class ///$$C { } @@ -942,12 +859,10 @@ class /// { } """); - } [WpfFact, WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/537513")] public void PressingEnter_NotInterleavedInClassName3() - { - VerifyPressingEnter(""" + => VerifyPressingEnter(""" class /// $$C { } @@ -957,13 +872,11 @@ class /// { } """); - } [WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/537514")] [WpfFact, WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/537532")] public void PressingEnter_NotAfterClassName1() - { - VerifyPressingEnter(""" + => VerifyPressingEnter(""" class C ///$$ { } @@ -973,12 +886,10 @@ class C /// { } """); - } [WpfFact, WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/537552")] public void PressingEnter_NotAfterClassName2() - { - VerifyPressingEnter(""" + => VerifyPressingEnter(""" class C /** $$ { } @@ -988,12 +899,10 @@ class C /** { } """); - } [WpfFact, WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/537535")] public void PressingEnter_NotAfterCtorName() - { - VerifyPressingEnter(""" + => VerifyPressingEnter(""" class C { C() ///$$ @@ -1005,12 +914,10 @@ class C $$ } """); - } [WpfFact, WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/537511")] public void PressingEnter_NotInsideCtor() - { - VerifyPressingEnter(""" + => VerifyPressingEnter(""" class C { C() @@ -1028,12 +935,10 @@ class C } } """); - } [WpfFact, WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/537550")] public void PressingEnter_NotBeforeDocComment() - { - VerifyPressingEnter(""" + => VerifyPressingEnter(""" class c1 { $$/// @@ -1059,12 +964,10 @@ public async Task goo() } } """); - } [WpfFact] public void PressingEnter_InsertSlashes1() - { - VerifyPressingEnter(""" + => VerifyPressingEnter(""" ///$$ /// class C @@ -1078,12 +981,10 @@ class C { } """); - } [WpfFact] public void PressingEnter_InsertSlashes2() - { - VerifyPressingEnter(""" + => VerifyPressingEnter(""" /// /// $$ /// @@ -1099,12 +1000,10 @@ class C { } """); - } [WpfFact] public void PressingEnter_InsertSlashes3() - { - VerifyPressingEnter(""" + => VerifyPressingEnter(""" /// /// $$ /// @@ -1120,12 +1019,10 @@ class C { } """); - } [WpfFact] public void PressingEnter_InsertSlashes4() - { - VerifyPressingEnter(""" + => VerifyPressingEnter(""" /// $$ class C { @@ -1137,12 +1034,10 @@ class C { } """); - } [WpfFact] public void PressingEnter_InsertSlashes5() - { - VerifyPressingEnter(""" + => VerifyPressingEnter(""" /// /// $$ /// @@ -1158,12 +1053,10 @@ class C { } """); - } [WpfFact] public void PressingEnter_InsertSlashes6() - { - VerifyPressingEnter(""" + => VerifyPressingEnter(""" /// $$ class C { @@ -1175,12 +1068,10 @@ class C { } """); - } [WpfFact] public void PressingEnter_InsertSlashes7() - { - VerifyPressingEnter(""" + => VerifyPressingEnter(""" /// $$ class C { @@ -1192,12 +1083,10 @@ class C { } """); - } [WpfFact, WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/538702")] public void PressingEnter_InsertSlashes8() - { - VerifyPressingEnter(""" + => VerifyPressingEnter(""" /// /// /// @@ -1209,12 +1098,10 @@ public void PressingEnter_InsertSlashes8() /// /// $$class C {} """); - } [WpfFact] public void PressingEnter_InsertSlashes9() - { - VerifyPressingEnter(""" + => VerifyPressingEnter(""" class C { ///$$ @@ -1230,12 +1117,10 @@ class C int M(int goo) { return 0; } } """); - } [WpfFact] public void PressingEnter_InsertSlashes10() - { - VerifyPressingEnter(""" + => VerifyPressingEnter(""" /// /// /// @@ -1247,12 +1132,10 @@ public void PressingEnter_InsertSlashes10() /// /// $$Go ahead and add some slashes """); - } [WpfFact] public void PressingEnter_InsertSlashes11() - { - VerifyPressingEnter(""" + => VerifyPressingEnter(""" class C { /// @@ -1276,12 +1159,10 @@ void Goo(int i) } } """); - } [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/4817")] public void PressingEnter_InsertSlashes12_AutoGenerateXmlDocCommentsOff() - { - VerifyPressingEnter(""" + => VerifyPressingEnter(""" ///$$ /// class C @@ -1298,12 +1179,10 @@ class C { { DocumentationCommentOptionsStorage.AutoXmlDocCommentGeneration, false } }); - } [WpfFact] public void PressingEnter_DoNotInsertSlashes1() - { - VerifyPressingEnter(""" + => VerifyPressingEnter(""" /// /// $$ class C @@ -1317,12 +1196,10 @@ class C { } """); - } [WpfFact, WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/538701")] public void PressingEnter_DoNotInsertSlashes2() - { - VerifyPressingEnter(""" + => VerifyPressingEnter(""" /// ///$$ @@ -1334,12 +1211,10 @@ class C{} $$ class C{} """); - } [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/25746")] public void PressingEnter_ExtraSlashesAfterExteriorTrivia() - { - VerifyPressingEnter(""" + => VerifyPressingEnter(""" class C { C() @@ -1357,12 +1232,10 @@ class C } } """); - } [WpfFact, WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/542426")] public void PressingEnter_PreserveParams() - { - VerifyPressingEnter(""" + => VerifyPressingEnter(""" /// /// /// @@ -1378,13 +1251,10 @@ static void Main(string[] args) static void Main(string[] args) { } """); - } [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/2091")] public void PressingEnter_InTextBeforeSpace() - { - const string code = - """ + => VerifyPressingEnter(""" class C { /// @@ -1394,10 +1264,7 @@ void M() { } } - """; - - const string expected = - """ + """, """ class C { /// @@ -1408,16 +1275,11 @@ void M() { } } - """; - - VerifyPressingEnter(code, expected); - } + """); [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/2108")] public void PressingEnter_Indentation1() - { - const string code = - """ + => VerifyPressingEnter(""" class C { /// @@ -1427,10 +1289,7 @@ void M() { } } - """; - - const string expected = - """ + """, """ class C { /// @@ -1441,16 +1300,11 @@ void M() { } } - """; - - VerifyPressingEnter(code, expected); - } + """); [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/2108")] public void PressingEnter_Indentation2() - { - const string code = - """ + => VerifyPressingEnter(""" class C { /// @@ -1460,10 +1314,7 @@ void M() { } } - """; - - const string expected = - """ + """, """ class C { /// @@ -1474,16 +1325,11 @@ void M() { } } - """; - - VerifyPressingEnter(code, expected); - } + """); [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/2108")] public void PressingEnter_Indentation3() - { - const string code = - """ + => VerifyPressingEnter(""" class C { /// @@ -1493,10 +1339,7 @@ void M() { } } - """; - - const string expected = - """ + """, """ class C { /// @@ -1507,16 +1350,11 @@ void M() { } } - """; - - VerifyPressingEnter(code, expected); - } + """); [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/2108")] public void PressingEnter_Indentation4() - { - const string code = - """ + => VerifyPressingEnter(""" class C { /// @@ -1526,10 +1364,7 @@ void M() { } } - """; - - const string expected = - """ + """, """ class C { /// @@ -1540,16 +1375,11 @@ void M() { } } - """; - - VerifyPressingEnter(code, expected); - } + """); [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/2108")] public void PressingEnter_Indentation5_UseTabs() - { - const string code = - """ + => VerifyPressingEnter(""" class C { /// @@ -1559,10 +1389,7 @@ void M() { } } - """; - - const string expected = - """ + """, """ class C { /// @@ -1573,15 +1400,11 @@ void M() { } } - """; - - VerifyPressingEnter(code, expected, useTabs: true); - } + """, useTabs: true); [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/5486")] public void PressingEnter_Selection1() - { - VerifyPressingEnter(""" + => VerifyPressingEnter(""" /// /// Hello [|World|]$$! /// @@ -1597,12 +1420,10 @@ class C { } """); - } [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/5486")] public void PressingEnter_Selection2() - { - VerifyPressingEnter(""" + => VerifyPressingEnter(""" /// /// Hello $$[|World|]! /// @@ -1618,14 +1439,12 @@ class C { } """); - } [WpfFact] [WorkItem("https://github.com/dotnet/roslyn/issues/27223")] [WorkItem("https://github.com/dotnet/roslyn/issues/49564")] public void PressingEnter_XmlDocCommentInStringLiteral() - { - VerifyPressingEnter(""" + => VerifyPressingEnter(""" class C { C() @@ -1647,12 +1466,10 @@ void M() {}" } } """); - } [WpfFact] public void Command_Class() - { - VerifyInsertCommentCommand(""" + => VerifyInsertCommentCommand(""" class C {$$ } @@ -1664,34 +1481,28 @@ class C { } """); - } [WpfFact] public void Command_Record() - { - VerifyInsertCommentCommand("record R$$;", """ + => VerifyInsertCommentCommand("record R$$;", """ /// /// $$ /// record R; """); - } [WpfFact] public void Command_RecordStruct() - { - VerifyInsertCommentCommand("record struct R$$;", """ + => VerifyInsertCommentCommand("record struct R$$;", """ /// /// $$ /// record struct R; """); - } [WpfFact] public void Command_RecordWithPositionalParameters() - { - VerifyInsertCommentCommand("record R$$(string S, int I);", """ + => VerifyInsertCommentCommand("record R$$(string S, int I);", """ /// /// $$ /// @@ -1699,12 +1510,10 @@ public void Command_RecordWithPositionalParameters() /// record R(string S, int I); """); - } [WpfFact] public void Command_ClassParameters() - { - VerifyInsertCommentCommand("class R$$(string S, int I);", """ + => VerifyInsertCommentCommand("class R$$(string S, int I);", """ /// /// $$ /// @@ -1712,12 +1521,10 @@ public void Command_ClassParameters() /// class R(string S, int I); """); - } [WpfFact] public void Command_RecordStructWithPositionalParameters() - { - VerifyInsertCommentCommand("record struct R$$(string S, int I);", """ + => VerifyInsertCommentCommand("record struct R$$(string S, int I);", """ /// /// $$ /// @@ -1725,12 +1532,10 @@ public void Command_RecordStructWithPositionalParameters() /// record struct R(string S, int I); """); - } [WpfFact] public void Command_StructParameters() - { - VerifyInsertCommentCommand("struct R$$(string S, int I);", """ + => VerifyInsertCommentCommand("struct R$$(string S, int I);", """ /// /// $$ /// @@ -1738,12 +1543,10 @@ public void Command_StructParameters() /// struct R(string S, int I); """); - } [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/4817")] public void Command_Class_AutoGenerateXmlDocCommentsOff() - { - VerifyInsertCommentCommand(""" + => VerifyInsertCommentCommand(""" class C {$$ } @@ -1758,12 +1561,10 @@ class C { { DocumentationCommentOptionsStorage.AutoXmlDocCommentGeneration, false } }); - } [WpfFact, WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/538714")] public void Command_BeforeClass1() - { - VerifyInsertCommentCommand(""" + => VerifyInsertCommentCommand(""" $$ class C { } """, """ @@ -1773,12 +1574,10 @@ class C { } /// class C { } """); - } [WpfFact, WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/538714")] public void Command_BeforeClass2() - { - VerifyInsertCommentCommand(""" + => VerifyInsertCommentCommand(""" class B { } $$ class C { } @@ -1790,12 +1589,10 @@ class B { } /// class C { } """); - } [WpfFact, WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/538714")] public void Command_BeforeClass3() - { - VerifyInsertCommentCommand(""" + => VerifyInsertCommentCommand(""" class B { $$ @@ -1811,12 +1608,10 @@ class B class C { } } """); - } [WpfFact, WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/527604")] public void Command_Class_NotIfMultilineDocCommentExists() - { - VerifyInsertCommentCommand(""" + => VerifyInsertCommentCommand(""" /** */ class C { $$ } @@ -1825,12 +1620,10 @@ class C { $$ } */ class C { $$ } """); - } [WpfFact] public void Command_Method() - { - VerifyInsertCommentCommand(""" + => VerifyInsertCommentCommand(""" class C { int M(int goo) { $$return 0; } @@ -1847,12 +1640,10 @@ class C int M(int goo) { return 0; } } """); - } [WpfFact] public void Command_Class_NotIfCommentExists() - { - VerifyInsertCommentCommand(""" + => VerifyInsertCommentCommand(""" /// class C {$$ @@ -1863,12 +1654,10 @@ class C {$$ } """); - } [WpfFact] public void Command_Method_NotIfCommentExists() - { - VerifyInsertCommentCommand(""" + => VerifyInsertCommentCommand(""" class C { /// @@ -1881,29 +1670,23 @@ class C int M(int goo) { $$return 0; } } """); - } [WpfFact, WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/538482")] public void Command_FirstClassOnLine() - { - VerifyInsertCommentCommand(@"$$class C { } class D { }", """ + => VerifyInsertCommentCommand(@"$$class C { } class D { }", """ /// /// $$ /// class C { } class D { } """); - } [WpfFact, WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/538482")] public void Command_NotOnSecondClassOnLine() - { - VerifyInsertCommentCommand(@"class C { } $$class D { }", @"class C { } $$class D { }"); - } + => VerifyInsertCommentCommand(@"class C { } $$class D { }", @"class C { } $$class D { }"); [WpfFact, WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/538482")] public void Command_FirstMethodOnLine() - { - VerifyInsertCommentCommand(""" + => VerifyInsertCommentCommand(""" class C { protected abstract void $$Goo(); protected abstract void Bar(); @@ -1917,12 +1700,10 @@ class C protected abstract void Goo(); protected abstract void Bar(); } """); - } [WpfFact, WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/538482")] public void Command_NotOnSecondMethodOnLine() - { - VerifyInsertCommentCommand(""" + => VerifyInsertCommentCommand(""" class C { protected abstract void Goo(); protected abstract void $$Bar(); @@ -1933,12 +1714,10 @@ class C protected abstract void Goo(); protected abstract void $$Bar(); } """); - } [WpfFact, WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/917904")] public void TestUseTab() - { - VerifyTypingCharacter(""" + => VerifyTypingCharacter(""" using System; public class Class1 @@ -1961,13 +1740,10 @@ public Class1() } } """, useTabs: true); - } [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/2090")] public void TestOpenLineAbove1() - { - const string code = - """ + => VerifyOpenLineAbove(""" class C { /// @@ -1977,8 +1753,7 @@ void M() { } } - """; - VerifyOpenLineAbove(code, """ + """, """ class C { /// @@ -1990,13 +1765,10 @@ void M() } } """); - } [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/2090")] public void TestOpenLineAbove2() - { - const string code = - """ + => VerifyOpenLineAbove(""" class C { /// @@ -2006,10 +1778,7 @@ void M() { } } - """; - - const string expected = - """ + """, """ class C { /// @@ -2020,16 +1789,16 @@ void M() { } } - """; - - VerifyOpenLineAbove(code, expected); - } + """); [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/2090")] public void TestOpenLineAbove3() { - const string code = - """ + + // Note that the caret position specified below does not look correct because + // it is in virtual space in this case. + + VerifyOpenLineAbove(""" class C { /// $$ @@ -2039,12 +1808,7 @@ void M() { } } - """; - - // Note that the caret position specified below does not look correct because - // it is in virtual space in this case. - const string expected = - """ + """, """ class C { $$ @@ -2055,16 +1819,12 @@ void M() { } } - """; - - VerifyOpenLineAbove(code, expected); + """); } [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/2090")] public void TestOpenLineAbove4_Tabs() - { - const string code = - """ + => VerifyOpenLineAbove(""" class C { /// @@ -2074,10 +1834,7 @@ void M() { } } - """; - - const string expected = - """ + """, """ class C { /// @@ -2088,16 +1845,11 @@ void M() { } } - """; - - VerifyOpenLineAbove(code, expected, useTabs: true); - } + """, useTabs: true); [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/2090")] public void TestOpenLineBelow1() - { - const string code = - """ + => VerifyOpenLineBelow(""" class C { /// @@ -2107,10 +1859,7 @@ void M() { } } - """; - - const string expected = - """ + """, """ class C { /// @@ -2121,16 +1870,11 @@ void M() { } } - """; - - VerifyOpenLineBelow(code, expected); - } + """); [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/2090")] public void TestOpenLineBelow2() - { - const string code = - """ + => VerifyOpenLineBelow(""" class C { /// @@ -2140,10 +1884,7 @@ void M() { } } - """; - - const string expected = - """ + """, """ class C { /// @@ -2154,39 +1895,26 @@ void M() { } } - """; - - VerifyOpenLineBelow(code, expected); - } + """); [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/2090")] public void TestOpenLineBelow3() - { - const string code = - """ + => VerifyOpenLineBelow(""" /// /// stuff /// $$ - """; - - const string expected = - """ + """, """ /// /// stuff /// /// $$ - """; - - VerifyOpenLineBelow(code, expected); - } + """); [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/2090")] public void TestOpenLineBelow4_Tabs() - { - const string code = - """ + => VerifyOpenLineBelow(""" class C { /// @@ -2196,10 +1924,7 @@ void M() { } } - """; - - const string expected = - """ + """, """ class C { /// @@ -2210,38 +1935,26 @@ void M() { } } - """; - - VerifyOpenLineBelow(code, expected, useTabs: true); - } + """, useTabs: true); [WpfFact, WorkItem(468638, @"https://devdiv.visualstudio.com/DevDiv/NET%20Developer%20Experience%20IDE/_workitems/edit/468638")] public void VerifyEnterWithTrimNewLineEditorConfigOption() - { - const string code = - """ + => VerifyPressingEnter(""" /// /// $$ /// class C { } - """; - - const string expected = - """ + """, """ /// /// /// $$ /// class C { } - """; - - VerifyPressingEnter(code, expected, useTabs: true, trimTrailingWhiteSpace: true); - } + """, useTabs: true, trimTrailingWhiteSpace: true); [WpfFact] public void TypingCharacter_Class_WithComment() - { - VerifyTypingCharacter(""" + => VerifyTypingCharacter(""" //$$ This is my class and it does great things. class C { @@ -2254,12 +1967,10 @@ class C { } """); - } [WpfFact] public void TypingCharacter_Class_WithComment_NoSpace() - { - VerifyTypingCharacter(""" + => VerifyTypingCharacter(""" //$$This is my class and it does great things. class C { @@ -2272,12 +1983,10 @@ class C { } """); - } [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/75838")] public void TypingCharacter_ExistingText1() - { - VerifyTypingCharacter(""" + => VerifyTypingCharacter(""" /// foo$$ class C { @@ -2288,12 +1997,10 @@ class C { } """); - } [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/75838")] public void TypingCharacter_ExistingText2() - { - VerifyTypingCharacter(""" + => VerifyTypingCharacter(""" namespace N { /// foo$$ @@ -2310,12 +2017,10 @@ class C } } """); - } [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/75838")] public void PressingEnter_ExistingText1() - { - VerifyPressingEnter(""" + => VerifyPressingEnter(""" /// foo$$ class C { @@ -2327,12 +2032,10 @@ class C { } """); - } [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/75838")] public void PressingEnter_ExistingText2() - { - VerifyPressingEnter(""" + => VerifyPressingEnter(""" namespace N { /// foo$$ @@ -2350,7 +2053,6 @@ class C } } """); - } protected override char DocumentationCommentCharacter { diff --git a/src/EditorFeatures/CSharpTest/DocumentationComments/XmlTagCompletionTests.cs b/src/EditorFeatures/CSharpTest/DocumentationComments/XmlTagCompletionTests.cs index fa517fa3e828..986fe8e7e495 100644 --- a/src/EditorFeatures/CSharpTest/DocumentationComments/XmlTagCompletionTests.cs +++ b/src/EditorFeatures/CSharpTest/DocumentationComments/XmlTagCompletionTests.cs @@ -24,20 +24,17 @@ private protected override EditorTestWorkspace CreateTestWorkspace(string initia [WpfFact] public void SimpleTagCompletion() - { - Verify(""" + => Verify(""" /// $$ class c { } """, '>'); - } [WpfFact] public void NestedTagCompletion() - { - Verify(""" + => Verify(""" /// /// @@ -48,12 +45,10 @@ class c { } /// class c { } """, '>'); - } [WpfFact] public void CompleteBeforeIncompleteTag() - { - Verify(""" + => Verify(""" /// class c { } @@ -62,36 +57,30 @@ class c { } /// class c { } """, '>'); - } [WpfFact] public void NotEmptyElement() - { - Verify(""" + => Verify(""" /// <$$ class c { } """, """ /// <>$$ class c { } """, '>'); - } [WpfFact] public void NotAlreadyCompleteTag() - { - Verify(""" + => Verify(""" /// class c { } """, """ /// $$ class c { } """, '>'); - } [WpfFact] public void NotAlreadyCompleteTag2() - { - Verify(""" + => Verify(""" /// @@ -102,24 +91,20 @@ class c { } /// class c { } """, '>'); - } [WpfFact] public void SimpleSlashCompletion() - { - Verify(""" + => Verify(""" /// <$$ class c { } """, """ /// $$ class c { } """, '/'); - } [WpfFact] public void NestedSlashTagCompletion() - { - Verify(""" + => Verify(""" /// /// <$$ /// @@ -130,12 +115,10 @@ class c { } /// class c { } """, '/'); - } [WpfFact] public void SlashCompleteBeforeIncompleteTag() - { - Verify(""" + => Verify(""" /// <$$ /// class c { } @@ -144,36 +127,30 @@ class c { } /// class c { } """, '/'); - } [WpfFact] public void SlashNotEmptyElement() - { - Verify(""" + => Verify(""" /// <><$$ class c { } """, """ /// <> Verify(""" /// <$$goo> class c { } """, """ /// class c { } """, '/'); - } [WpfFact] public void SlashNotAlreadyCompleteTag2() - { - Verify(""" + => Verify(""" /// /// /// <$$goo> @@ -184,36 +161,30 @@ class c { } /// class c { } """, '/'); - } [WpfFact, WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/638800")] public void NestedIdenticalTags() - { - Verify(""" + => Verify(""" /// class c { } """, """ /// $$ class c { } """, '>'); - } [WpfFact, WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/638800")] public void MultipleNestedIdenticalTags() - { - Verify(""" + => Verify(""" /// class c { } """, """ /// $$ class c { } """, '>'); - } [WpfFact, WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/638235")] public void SlashNotIfCloseTagFollows() - { - Verify(""" + => Verify(""" /// /// <$$ /// @@ -224,24 +195,20 @@ class c { } /// class c { } """, '/'); - } [WpfFact] public void TestSimpleTagCompletion() - { - Verify(""" + => Verify(""" /// $$ class C {} """, '>'); - } [WpfFact] public void TestNestedTagCompletion() - { - Verify(""" + => Verify(""" /// /// @@ -252,12 +219,10 @@ class C {} /// class C {} """, '>'); - } [WpfFact] public void TestCompleteBeforeIncompleteTag() - { - Verify(""" + => Verify(""" /// class C {} @@ -266,36 +231,30 @@ class C {} /// class C {} """, '>'); - } [WpfFact] public void TestNotEmptyElement() - { - Verify(""" + => Verify(""" /// <$$ class C {} """, """ /// <>$$ class C {} """, '>'); - } [WpfFact] public void TestNotAlreadyCompleteTag() - { - Verify(""" + => Verify(""" /// class C {} """, """ /// $$ class C {} """, '>'); - } [WpfFact] public void TestNotAlreadyCompleteTag2() - { - Verify(""" + => Verify(""" /// @@ -306,12 +265,10 @@ class C {} /// class C {} """, '>'); - } [WpfFact] public void TestNotOutsideDocComment() - { - Verify(""" + => Verify(""" class C { private int z = $$ } """, '>'); - } [WpfFact, WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/638235")] public void TestNotCloseClosedTag() - { - Verify(""" + => Verify(""" /// /// <$$ /// @@ -338,5 +293,4 @@ class C {} /// class C {} """, '/'); - } } diff --git a/src/EditorFeatures/CSharpTest/Extensions/ContextQuery/NamespaceContextTests.cs b/src/EditorFeatures/CSharpTest/Extensions/ContextQuery/NamespaceContextTests.cs index f48934ad730e..8ecdf1e80455 100644 --- a/src/EditorFeatures/CSharpTest/Extensions/ContextQuery/NamespaceContextTests.cs +++ b/src/EditorFeatures/CSharpTest/Extensions/ContextQuery/NamespaceContextTests.cs @@ -27,13 +27,11 @@ public void UsingDirective() [Fact] public void InactiveRegion() - { - VerifyFalse(""" + => VerifyFalse(""" #if false $$ #endif """); - } [Fact] public void SingleLineComment1() @@ -41,13 +39,11 @@ public void SingleLineComment1() [Fact] public void SingleLineComment2() - { - VerifyTrue(""" + => VerifyTrue(""" class C { // $$ """); - } [Fact] public void MultiLineComment() @@ -79,12 +75,10 @@ public void AssemblyAttribute() [Fact] public void TypeAttribute() - { - VerifyTrue(""" + => VerifyTrue(""" [$$] class CL {} """); - } [Fact] public void TypeParamAttribute() @@ -92,34 +86,28 @@ public void TypeParamAttribute() [Fact] public void MethodAttribute() - { - VerifyTrue(""" + => VerifyTrue(""" class CL { [$$] void Method() {} } """); - } [Fact] public void MethodTypeParamAttribute() - { - VerifyTrue(""" + => VerifyTrue(""" class CL{ void Method<[A$$]T> () {} } """); - } [Fact] public void MethodParamAttribute() - { - VerifyTrue(""" + => VerifyTrue(""" class CL{ void Method ([$$]int i) {} } """); - } [Fact] public void NamespaceName() @@ -131,13 +119,11 @@ public void UnderNamespace() [Fact] public void OutsideOfType() - { - VerifyFalse(""" + => VerifyFalse(""" namespace NS { class CL {} $$ """); - } [Fact] public void AfterDot() @@ -153,21 +139,17 @@ public void UsingAlias2() [Fact] public void IncompleteMember() - { - VerifyTrue(""" + => VerifyTrue(""" class CL { $$ """); - } [Fact] public void IncompleteMemberAccessibility() - { - VerifyTrue(""" + => VerifyTrue(""" class CL { public $$ """); - } [Fact] public void BadStatement() @@ -227,129 +209,101 @@ public void CatchDeclaration() [Fact] public void FieldDeclaration() - { - VerifyTrue(""" + => VerifyTrue(""" class CL { $$ i """); - } [Fact] public void EventFieldDeclaration() - { - VerifyTrue(""" + => VerifyTrue(""" class CL { event $$ """); - } [Fact] public void ConversionOperatorDeclaration() - { - VerifyTrue(""" + => VerifyTrue(""" class CL { explicit operator $$ """); - } [Fact] public void ConversionOperatorDeclarationNoToken() - { - VerifyFalse(""" + => VerifyFalse(""" class CL { explicit $$ """); - } [Fact] public void PropertyDeclaration() - { - VerifyTrue(""" + => VerifyTrue(""" class CL { $$ Prop { """); - } [Fact] public void EventDeclaration() - { - VerifyTrue(""" + => VerifyTrue(""" class CL { event $$ Event { """); - } [Fact] public void IndexerDeclaration() - { - VerifyTrue(""" + => VerifyTrue(""" class CL { $$ this """); - } [Fact] public void Parameter() - { - VerifyTrue(""" + => VerifyTrue(""" class CL { void Method($$ """); - } [Fact] public void ArrayType() - { - VerifyTrue(""" + => VerifyTrue(""" class CL { $$ [ """); - } [Fact] public void PointerType() - { - VerifyTrue(""" + => VerifyTrue(""" class CL { $$ * """); - } [Fact] public void NullableType() - { - VerifyTrue(""" + => VerifyTrue(""" class CL { $$ ? """); - } [Fact] public void DelegateDeclaration() - { - VerifyTrue(""" + => VerifyTrue(""" class CL { delegate $$ """); - } [Fact] public void MethodDeclaration() - { - VerifyTrue(""" + => VerifyTrue(""" class CL { $$ M( """); - } [Fact] public void OperatorDeclaration() - { - VerifyTrue(""" + => VerifyTrue(""" class CL { $$ operator """); - } [Fact] public void ParenthesizedExpression() @@ -513,13 +467,11 @@ public void SwitchStatement() [Fact] public void SwitchLabelCase() - { - VerifyTrue(AddInsideMethod(""" + => VerifyTrue(AddInsideMethod(""" switch(i) { case $$ """)); - } [Fact] public void InitializerExpression() diff --git a/src/EditorFeatures/CSharpTest/Extensions/ContextQuery/TypeContextTests.cs b/src/EditorFeatures/CSharpTest/Extensions/ContextQuery/TypeContextTests.cs index 0d4c10cf95f3..5389451020f3 100644 --- a/src/EditorFeatures/CSharpTest/Extensions/ContextQuery/TypeContextTests.cs +++ b/src/EditorFeatures/CSharpTest/Extensions/ContextQuery/TypeContextTests.cs @@ -27,13 +27,11 @@ public void UsingDirective() [Fact] public void InactiveRegion() - { - VerifyFalse(""" + => VerifyFalse(""" #if false $$ #endif """); - } [Fact] public void SingleLineComment1() @@ -41,13 +39,11 @@ public void SingleLineComment1() [Fact] public void SingleLineComment2() - { - VerifyTrue(""" + => VerifyTrue(""" class C { // $$ """); - } [Fact] public void MultiLineComment() @@ -79,12 +75,10 @@ public void AssemblyAttribute() [Fact] public void TypeAttribute() - { - VerifyTrue(""" + => VerifyTrue(""" [$$] class CL {} """); - } [Fact] public void TypeParamAttribute() @@ -92,34 +86,28 @@ public void TypeParamAttribute() [Fact] public void MethodAttribute() - { - VerifyTrue(""" + => VerifyTrue(""" class CL { [$$] void Method() {} } """); - } [Fact] public void MethodTypeParamAttribute() - { - VerifyTrue(""" + => VerifyTrue(""" class CL{ void Method<[A$$]T> () {} } """); - } [Fact] public void MethodParamAttribute() - { - VerifyTrue(""" + => VerifyTrue(""" class CL{ void Method ([$$]int i) {} } """); - } [Fact] public void NamespaceName() @@ -131,13 +119,11 @@ public void UnderNamespace() [Fact] public void OutsideOfType() - { - VerifyFalse(""" + => VerifyFalse(""" namespace NS { class CL {} $$ """); - } [Fact] public void AfterDot() @@ -149,21 +135,17 @@ public void UsingAlias() [Fact] public void IncompleteMember() - { - VerifyTrue(""" + => VerifyTrue(""" class CL { $$ """); - } [Fact] public void IncompleteMemberAccessibility() - { - VerifyTrue(""" + => VerifyTrue(""" class CL { public $$ """); - } [Fact] public void BadStatement() @@ -223,129 +205,101 @@ public void CatchDeclaration() [Fact] public void FieldDeclaration() - { - VerifyTrue(""" + => VerifyTrue(""" class CL { $$ i """); - } [Fact] public void EventFieldDeclaration() - { - VerifyTrue(""" + => VerifyTrue(""" class CL { event $$ """); - } [Fact] public void ConversionOperatorDeclaration() - { - VerifyTrue(""" + => VerifyTrue(""" class CL { explicit operator $$ """); - } [Fact] public void ConversionOperatorDeclarationNoToken() - { - VerifyFalse(""" + => VerifyFalse(""" class CL { explicit $$ """); - } [Fact] public void PropertyDeclaration() - { - VerifyTrue(""" + => VerifyTrue(""" class CL { $$ Prop { """); - } [Fact] public void EventDeclaration() - { - VerifyTrue(""" + => VerifyTrue(""" class CL { event $$ Event { """); - } [Fact] public void IndexerDeclaration() - { - VerifyTrue(""" + => VerifyTrue(""" class CL { $$ this """); - } [Fact] public void Parameter() - { - VerifyTrue(""" + => VerifyTrue(""" class CL { void Method($$ """); - } [Fact] public void ArrayType() - { - VerifyTrue(""" + => VerifyTrue(""" class CL { $$ [ """); - } [Fact] public void PointerType() - { - VerifyTrue(""" + => VerifyTrue(""" class CL { $$ * """); - } [Fact] public void NullableType() - { - VerifyTrue(""" + => VerifyTrue(""" class CL { $$ ? """); - } [Fact] public void DelegateDeclaration() - { - VerifyTrue(""" + => VerifyTrue(""" class CL { delegate $$ """); - } [Fact] public void MethodDeclaration() - { - VerifyTrue(""" + => VerifyTrue(""" class CL { $$ M( """); - } [Fact] public void OperatorDeclaration() - { - VerifyTrue(""" + => VerifyTrue(""" class CL { $$ operator """); - } [Fact] public void ParenthesizedExpression() @@ -509,13 +463,11 @@ public void SwitchStatement() [Fact] public void SwitchLabelCase() - { - VerifyTrue(AddInsideMethod(""" + => VerifyTrue(AddInsideMethod(""" switch(i) { case $$ """)); - } [Fact] public void InitializerExpression() diff --git a/src/EditorFeatures/CSharpTest/ExtractMethod/ExtractMethodTests.LanguageInteraction.cs b/src/EditorFeatures/CSharpTest/ExtractMethod/ExtractMethodTests.LanguageInteraction.cs index b60dc3e1c6aa..087182392776 100644 --- a/src/EditorFeatures/CSharpTest/ExtractMethod/ExtractMethodTests.LanguageInteraction.cs +++ b/src/EditorFeatures/CSharpTest/ExtractMethod/ExtractMethodTests.LanguageInteraction.cs @@ -2002,8 +2002,7 @@ private static void NewMethod(C c) [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/39329")] public Task SimpleUsingStatement() - { - return TestExtractMethodAsync(""" + => TestExtractMethodAsync(""" public class Goo : IDisposable { void M2() { } @@ -2049,7 +2048,6 @@ public void Dispose() } } """); - } [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/24136")] public Task WhenClause_SwitchStatement() diff --git a/src/EditorFeatures/CSharpTest/FixInterpolatedVerbatimString/FixInterpolatedVerbatimStringCommandHandlerTests.cs b/src/EditorFeatures/CSharpTest/FixInterpolatedVerbatimString/FixInterpolatedVerbatimStringCommandHandlerTests.cs index 4dd8a5f5c6b6..60e91c6f1901 100644 --- a/src/EditorFeatures/CSharpTest/FixInterpolatedVerbatimString/FixInterpolatedVerbatimStringCommandHandlerTests.cs +++ b/src/EditorFeatures/CSharpTest/FixInterpolatedVerbatimString/FixInterpolatedVerbatimStringCommandHandlerTests.cs @@ -97,8 +97,7 @@ private static void TestNotHandled(string inputMarkup) [WpfFact] public void TestAfterAtSignDollarSign() - { - TestHandled( + => TestHandled( """ class C { @@ -117,12 +116,10 @@ void M() } } """); - } [WpfFact] public void TestMissingAfterDollarSignAtSign() - { - TestNotHandled( + => TestNotHandled( """ class C { @@ -132,12 +129,10 @@ void M() } } """); - } [WpfFact] public void TestMissingAfterAtSign() - { - TestNotHandled( + => TestNotHandled( """ class C { @@ -147,12 +142,10 @@ void M() } } """); - } [WpfFact] public void TestMissingAfterDollarSign() - { - TestNotHandled( + => TestNotHandled( """ class C { @@ -162,7 +155,6 @@ void M() } } """); - } [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/44423")] public void TestMissingInEmptyFileAfterAtSignDollarSign() @@ -178,8 +170,7 @@ public void TestMissingInEmptyFile() [WpfFact] public void TestAfterAtSignDollarSignEndOfFile() - { - TestHandled( + => TestHandled( """ class C { @@ -194,24 +185,20 @@ void M() { var v = $@"[||] """); - } [WpfFact] public void TestMissingInClassDeclaration() - { - TestNotHandled( + => TestNotHandled( """ class C { @$[||] } """); - } [WpfFact] public void TestMissingInComment1() - { - TestNotHandled( + => TestNotHandled( """ class C { @@ -221,12 +208,10 @@ void M() } } """); - } [WpfFact] public void TestMissingInComment2() - { - TestNotHandled( + => TestNotHandled( """ class C { @@ -236,12 +221,10 @@ void M() } } """); - } [WpfFact] public void TestMissingInString() - { - TestNotHandled( + => TestNotHandled( """ class C { @@ -251,12 +234,10 @@ void M() } } """); - } [WpfFact] public void TestMissingInVerbatimString() - { - TestNotHandled( + => TestNotHandled( """ class C { @@ -266,12 +247,10 @@ void M() } } """); - } [WpfFact] public void TestMissingInInterpolatedString() - { - TestNotHandled( + => TestNotHandled( """ class C { @@ -281,12 +260,10 @@ void M() } } """); - } [WpfFact] public void TestMissingInInterpolatedVerbatimString1() - { - TestNotHandled( + => TestNotHandled( """ class C { @@ -296,12 +273,10 @@ void M() } } """); - } [WpfFact] public void TestMissingInInterpolatedVerbatimString2() - { - TestNotHandled( + => TestNotHandled( """ class C { @@ -311,12 +286,10 @@ void M() } } """); - } [WpfFact] public void TestTrivia() - { - TestHandled( + => TestHandled( """ class C { @@ -337,5 +310,4 @@ void M() } } """); - } } diff --git a/src/EditorFeatures/CSharpTest/Formatting/CodeCleanupTests.cs b/src/EditorFeatures/CSharpTest/Formatting/CodeCleanupTests.cs index 6e0adae5cab7..10d6743608cc 100644 --- a/src/EditorFeatures/CSharpTest/Formatting/CodeCleanupTests.cs +++ b/src/EditorFeatures/CSharpTest/Formatting/CodeCleanupTests.cs @@ -2,11 +2,10 @@ // 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; using System.Collections.Generic; using System.Collections.Immutable; +using System.Diagnostics.CodeAnalysis; using System.Linq; using System.Threading; using System.Threading.Tasks; @@ -36,8 +35,7 @@ public sealed partial class CodeCleanupTests { [Fact] public Task RemoveUsings() - { - return AssertCodeCleanupResult(""" + => AssertCodeCleanupResult(""" using System; internal class Program { @@ -57,12 +55,112 @@ static void Main(string[] args) } } """); - } + + [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/79463")] + public Task RemoveUsings_NotWithSyntaxError() + => AssertCodeCleanupResult(""" + using System; + using System.Collections.Generic; + internal class Program + { + private static void Main(string[] args) + { + Console.WriteLine() + } + } + """, """ + using System; + using System.Collections.Generic; + class Program + { + static void Main(string[] args) + { + Console.WriteLine() + } + } + """); + + [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/79463")] + public Task RemoveUsings_WithSemanticError() + => AssertCodeCleanupResult(""" + using System; + internal class Program + { + private static void Main(string[] args) + { + Console.WriteLine1(); + } + } + """, """ + using System; + using System.Collections.Generic; + class Program + { + static void Main(string[] args) + { + Console.WriteLine1(); + } + } + """); + + [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/79463")] + public Task RemoveUsings_WithMergeMarker_NoSyntaxError() + => AssertCodeCleanupResult(""" + using System; + internal class Program + { + private static void Main(string[] args) + { + Console.WriteLine(); + } + } + """, """ + using System; + using System.Collections.Generic; + internal class Program + { + static void Main(string[] args) + { + <<<<<<< + Console.WriteLine(); + ======= + List list = []; + >>>>>>> + } + } + """); + + [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/79463")] + public Task RemoveUsings_WithMergeMarker_SyntaxError() + => AssertCodeCleanupResult(""" + using System; + using System.Collections.Generic; + internal class Program + { + private static void Main(string[] args) + { + Console.WriteLine() + } + } + """, """ + using System; + using System.Collections.Generic; + internal class Program + { + static void Main(string[] args) + { + <<<<<<< + Console.WriteLine() + ======= + List list = []; + >>>>>>> + } + } + """); [Fact] public Task SortUsings() - { - return AssertCodeCleanupResult(""" + => AssertCodeCleanupResult(""" using System; using System.Collections.Generic; internal class Program @@ -85,12 +183,10 @@ static void Main(string[] args) } } """); - } [Fact] public Task SortGlobalUsings() - { - return AssertCodeCleanupResult(""" + => AssertCodeCleanupResult(""" global using System; global using System.Collections.Generic; using System.Threading; @@ -121,12 +217,10 @@ static Task Main(string[] args) } } """); - } [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/36984")] public Task GroupUsings() - { - return AssertCodeCleanupResult(""" + => AssertCodeCleanupResult(""" using M; using System; @@ -164,12 +258,10 @@ namespace M public class Goo { } } """, systemUsingsFirst: false, separateUsingGroups: true); - } [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/36984")] public Task SortAndGroupUsings() - { - return AssertCodeCleanupResult(""" + => AssertCodeCleanupResult(""" using System; using M; @@ -207,12 +299,10 @@ namespace M public class Goo { } } """, systemUsingsFirst: true, separateUsingGroups: true); - } [Fact] public Task FixAddRemoveBraces() - { - return AssertCodeCleanupResult(""" + => AssertCodeCleanupResult(""" internal class Program { private int Method() @@ -239,12 +329,10 @@ int Method() } } """); - } [Fact] public Task RemoveUnusedVariable() - { - return AssertCodeCleanupResult(""" + => AssertCodeCleanupResult(""" internal class Program { private void Method() @@ -260,12 +348,10 @@ void Method() } } """); - } [Fact] public Task FixAccessibilityModifiers() - { - return AssertCodeCleanupResult(""" + => AssertCodeCleanupResult(""" internal class Program { private void Method() @@ -281,12 +367,10 @@ void Method() } } """); - } [Fact] public Task FixUsingPlacementPreferOutside() - { - return AssertCodeCleanupResult(""" + => AssertCodeCleanupResult(""" using System; namespace A @@ -313,12 +397,10 @@ private void Method() } } """); - } [Fact] public Task FixUsingPlacementPreferInside() - { - return AssertCodeCleanupResult(""" + => AssertCodeCleanupResult(""" namespace A { using System; @@ -345,7 +427,6 @@ private void Method() } } """, InsideNamespaceOption); - } [Fact] public Task FixUsingPlacementPreferInsidePreserve() @@ -395,8 +476,7 @@ private void Method() [Fact] public Task FixUsingPlacementMixedPreferOutside() - { - return AssertCodeCleanupResult(""" + => AssertCodeCleanupResult(""" using System; using System.Collections.Generic; @@ -430,12 +510,10 @@ private void Method() } } """, OutsideNamespaceOption); - } [Fact] public Task FixUsingPlacementMixedPreferInside() - { - return AssertCodeCleanupResult(""" + => AssertCodeCleanupResult(""" namespace A { using System; @@ -469,7 +547,6 @@ private void Method() } } """, InsideNamespaceOption); - } [Fact] public Task FixUsingPlacementMixedPreferInsidePreserve() @@ -728,7 +805,7 @@ private static Task TestThirdPartyCodeFixerApplied(string c return TestThirdPartyCodeFixer(code, expected, severity); } - private static async Task TestThirdPartyCodeFixer(string code = null, string expected = null, DiagnosticSeverity severity = DiagnosticSeverity.Warning) + private static async Task TestThirdPartyCodeFixer(string? code = null, string? expected = null, DiagnosticSeverity severity = DiagnosticSeverity.Warning) where TAnalyzer : DiagnosticAnalyzer, new() where TCodefix : CodeFixProvider, new() { @@ -750,14 +827,14 @@ private static async Task TestThirdPartyCodeFixer(string co }; project = project.AddAnalyzerReference(new TestAnalyzerReferenceByLanguage(map)); - project = project.Solution.WithProjectFilePath(project.Id, @$"z:\\{project.FilePath}").GetProject(project.Id); + project = project.Solution.WithProjectFilePath(project.Id, @$"z:\\{project.FilePath}").GetRequiredProject(project.Id); project = project.AddAnalyzerConfigDocument(".editorconfig", SourceText.From(editorconfigText), filePath: @"z:\\.editorconfig").Project; workspace.TryApplyChanges(project.Solution); var hostdoc = workspace.Documents.Single(); - var document = workspace.CurrentSolution.GetDocument(hostdoc.Id); + var document = workspace.CurrentSolution.GetRequiredDocument(hostdoc.Id); - var codeCleanupService = document.GetLanguageService(); + var codeCleanupService = document.GetRequiredLanguageService(); var enabledDiagnostics = codeCleanupService.GetAllDiagnostics(); @@ -772,28 +849,21 @@ private static string[] GetSupportedDiagnosticIdsForCodeCleanupService(string la { using var workspace = GetTestWorkspaceForLanguage(language); var hostdoc = workspace.Documents.Single(); - var document = workspace.CurrentSolution.GetDocument(hostdoc.Id); + var document = workspace.CurrentSolution.GetRequiredDocument(hostdoc.Id); - var codeCleanupService = document.GetLanguageService(); + var codeCleanupService = document.GetRequiredLanguageService(); var enabledDiagnostics = codeCleanupService.GetAllDiagnostics(); var supportedDiagnostics = enabledDiagnostics.Diagnostics.SelectMany(x => x.DiagnosticIds).ToArray(); return supportedDiagnostics; static EditorTestWorkspace GetTestWorkspaceForLanguage(string language) - { - if (language == LanguageNames.CSharp) + => language switch { - return EditorTestWorkspace.CreateCSharp(string.Empty, composition: EditorTestCompositions.EditorFeatures); - } - - if (language == LanguageNames.VisualBasic) - { - return EditorTestWorkspace.CreateVisualBasic(string.Empty, composition: EditorTestCompositions.EditorFeatures); - } - - return null; - } + LanguageNames.CSharp => EditorTestWorkspace.CreateCSharp(string.Empty, composition: EditorTestCompositions.EditorFeatures), + LanguageNames.VisualBasic => EditorTestWorkspace.CreateVisualBasic(string.Empty, composition: EditorTestCompositions.EditorFeatures), + _ => throw ExceptionUtilities.Unreachable() + }; } /// @@ -806,7 +876,13 @@ static EditorTestWorkspace GetTestWorkspaceForLanguage(string language) /// Optional filter to determine if a specific fix ID is explicitly enabled for cleanup. /// Optional list of diagnostic IDs with effective severities to be configured in editorconfig. /// The to test code cleanup. - private static Task AssertCodeCleanupResult(string expected, string code, bool systemUsingsFirst = true, bool separateUsingGroups = false, Func enabledFixIdsFilter = null, (string, DiagnosticSeverity)[] diagnosticIdsWithSeverity = null) + private static Task AssertCodeCleanupResult( + [StringSyntax(PredefinedEmbeddedLanguageNames.CSharpTest)] string expected, + [StringSyntax(PredefinedEmbeddedLanguageNames.CSharpTest)] string code, + bool systemUsingsFirst = true, + bool separateUsingGroups = false, + Func? enabledFixIdsFilter = null, + (string, DiagnosticSeverity)[]? diagnosticIdsWithSeverity = null) => AssertCodeCleanupResult(expected, code, new(AddImportPlacement.OutsideNamespace, NotificationOption2.Silent), systemUsingsFirst, separateUsingGroups, enabledFixIdsFilter, diagnosticIdsWithSeverity); /// @@ -820,7 +896,14 @@ private static Task AssertCodeCleanupResult(string expected, string code, bool s /// Optional filter to determine if a specific fix ID is explicitly enabled for cleanup. /// Optional list of diagnostic IDs with effective severities to be configured in editorconfig. /// The to test code cleanup. - private static async Task AssertCodeCleanupResult(string expected, string code, CodeStyleOption2 preferredImportPlacement, bool systemUsingsFirst = true, bool separateUsingGroups = false, Func enabledFixIdsFilter = null, (string, DiagnosticSeverity)[] diagnosticIdsWithSeverity = null) + private static async Task AssertCodeCleanupResult( + [StringSyntax(PredefinedEmbeddedLanguageNames.CSharpTest)] string expected, + [StringSyntax(PredefinedEmbeddedLanguageNames.CSharpTest)] string code, + CodeStyleOption2 preferredImportPlacement, + bool systemUsingsFirst = true, + bool separateUsingGroups = false, + Func? enabledFixIdsFilter = null, + (string, DiagnosticSeverity)[]? diagnosticIdsWithSeverity = null) { using var workspace = EditorTestWorkspace.CreateCSharp(code, composition: EditorTestCompositions.EditorFeatures); @@ -854,9 +937,9 @@ private static async Task AssertCodeCleanupResult(string expected, string code, workspace.TryApplyChanges(solution); var hostdoc = workspace.Documents.Single(); - var document = workspace.CurrentSolution.GetDocument(hostdoc.Id); + var document = workspace.CurrentSolution.GetRequiredDocument(hostdoc.Id); - var codeCleanupService = document.GetLanguageService(); + var codeCleanupService = document.GetRequiredLanguageService(); var enabledDiagnostics = codeCleanupService.GetAllDiagnostics(); @@ -868,18 +951,18 @@ private static async Task AssertCodeCleanupResult(string expected, string code, var actual = await newDoc.GetTextAsync(); - Assert.Equal(expected, actual.ToString()); + AssertEx.Equal(expected, actual.ToString()); } private static readonly CodeStyleOption2 InsideNamespaceOption = - new CodeStyleOption2(AddImportPlacement.InsideNamespace, NotificationOption2.Error); + new(AddImportPlacement.InsideNamespace, NotificationOption2.Error); private static readonly CodeStyleOption2 OutsideNamespaceOption = - new CodeStyleOption2(AddImportPlacement.OutsideNamespace, NotificationOption2.Error); + new(AddImportPlacement.OutsideNamespace, NotificationOption2.Error); private static readonly CodeStyleOption2 InsidePreferPreservationOption = - new CodeStyleOption2(AddImportPlacement.InsideNamespace, NotificationOption2.None); + new(AddImportPlacement.InsideNamespace, NotificationOption2.None); private static readonly CodeStyleOption2 OutsidePreferPreservationOption = - new CodeStyleOption2(AddImportPlacement.OutsideNamespace, NotificationOption2.None); + new(AddImportPlacement.OutsideNamespace, NotificationOption2.None); } diff --git a/src/EditorFeatures/CSharpTest/Formatting/FormattingEngineTests.cs b/src/EditorFeatures/CSharpTest/Formatting/FormattingEngineTests.cs index ee57dfa19d97..ee5782e527d2 100644 --- a/src/EditorFeatures/CSharpTest/Formatting/FormattingEngineTests.cs +++ b/src/EditorFeatures/CSharpTest/Formatting/FormattingEngineTests.cs @@ -37,8 +37,7 @@ private static OptionsCollection SmartIndentButDoNotFormatWhileTyping() [WpfFact, WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/539682")] public void FormatDocumentCommandHandler() - { - AssertFormatWithView(""" + => AssertFormatWithView(""" class Program { static void Main(string[] args) @@ -57,12 +56,10 @@ static void Main(string[] args) } } """); - } [WpfFact, WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/539682")] public void FormatDocumentPasteCommandHandler() - { - AssertFormatWithPasteOrReturn(""" + => AssertFormatWithPasteOrReturn(""" class Program { static void Main(string[] args) @@ -81,12 +78,10 @@ static void Main(string[] args) } } """, allowDocumentChanges: true); - } [WpfFact, WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/547261")] public void FormatDocumentReadOnlyWorkspacePasteCommandHandler() - { - AssertFormatWithPasteOrReturn(""" + => AssertFormatWithPasteOrReturn(""" class Program { static void Main(string[] args) @@ -105,12 +100,10 @@ static void Main(string[] args) } } """, allowDocumentChanges: false); - } [WpfFact, WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/912965")] public void DoNotFormatUsingStatementOnReturn() - { - AssertFormatWithPasteOrReturn(""" + => AssertFormatWithPasteOrReturn(""" class Program { static void Main(string[] args) @@ -129,12 +122,10 @@ static void Main(string[] args) } } """, allowDocumentChanges: true, isPaste: false); - } [WpfFact, WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/912965")] public void FormatUsingStatementWhenTypingCloseParen() - { - AssertFormatAfterTypeChar(""" + => AssertFormatAfterTypeChar(""" class Program { static void Main(string[] args) @@ -153,12 +144,10 @@ static void Main(string[] args) } } """); - } [WpfFact, WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/912965")] public void FormatNotUsingStatementOnReturn() - { - AssertFormatWithPasteOrReturn(""" + => AssertFormatWithPasteOrReturn(""" class Program { static void Main(string[] args) @@ -177,12 +166,10 @@ static void Main(string[] args) } } """, allowDocumentChanges: true, isPaste: false); - } [WpfFact, WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/977133")] public void DoNotFormatRangeOrFormatTokenOnOpenBraceOnSameLine() - { - AssertFormatAfterTypeChar(""" + => AssertFormatAfterTypeChar(""" class C { public void M() @@ -199,12 +186,10 @@ public void M() } } """); - } [WpfFact, WorkItem("https://github.com/dotnet/roslyn/pull/14491")] public void DoNotFormatRangeButFormatTokenOnOpenBraceOnNextLine() - { - AssertFormatAfterTypeChar(""" + => AssertFormatAfterTypeChar(""" class C { public void M() @@ -223,12 +208,10 @@ public void M() } } """); - } [WpfFact, WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/1007071")] public void FormatPragmaWarningInbetweenDelegateDeclarationStatement() - { - AssertFormatAfterTypeChar(""" + => AssertFormatAfterTypeChar(""" using System; class Program @@ -257,12 +240,10 @@ static void Main(string[] args) } } """); - } [WpfFact, WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/771761")] public void FormatHashRegion() - { - AssertFormatAfterTypeChar(""" + => AssertFormatAfterTypeChar(""" using System; class Program @@ -283,12 +264,10 @@ static void Main(string[] args) } } """); - } [WpfFact, WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/771761")] public void FormatHashEndRegion() - { - AssertFormatAfterTypeChar(""" + => AssertFormatAfterTypeChar(""" using System; class Program @@ -311,7 +290,6 @@ static void Main(string[] args) } } """); - } [WpfFact, WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/987373")] public async Task FormatSpansIndividuallyWithoutCollapsing() @@ -410,8 +388,7 @@ public void M() [WpfFact, WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/1044118")] public void SemicolonInCommentOnLastLineDoesNotFormat() - { - AssertFormatAfterTypeChar(""" + => AssertFormatAfterTypeChar(""" using System; class Program @@ -432,13 +409,11 @@ static void Main(string[] args) } // ; """); - } [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/449")] [WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/1077103")] public void NoFormattingInsideSingleLineRegularComment_1() - { - AssertFormatAfterTypeChar(""" + => AssertFormatAfterTypeChar(""" class Program { // {$$ @@ -457,13 +432,11 @@ static void Main(int a, int b) } } """); - } [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/449")] [WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/1077103")] public void NoFormattingInsideSingleLineRegularComment_2() - { - AssertFormatAfterTypeChar(""" + => AssertFormatAfterTypeChar(""" class Program { // {$$ @@ -482,13 +455,11 @@ static void Main(int a, int b) } } """); - } [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/449")] [WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/1077103")] public void NoFormattingInsideMultiLineRegularComment_1() - { - AssertFormatAfterTypeChar(""" + => AssertFormatAfterTypeChar(""" class Program { static void Main(int a/* {$$ */, int b) @@ -505,13 +476,11 @@ static void Main(int a/* { */, int b) } } """); - } [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/449")] [WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/1077103")] public void NoFormattingInsideMultiLineRegularComment_2() - { - AssertFormatAfterTypeChar(""" + => AssertFormatAfterTypeChar(""" class Program { static void Main(int a/* {$$ @@ -530,13 +499,11 @@ static void Main(int a/* { } } """); - } [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/449")] [WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/1077103")] public void NoFormattingInsideMultiLineRegularComment_3() - { - AssertFormatAfterTypeChar(""" + => AssertFormatAfterTypeChar(""" class Program { static void Main(int a/* {$$ @@ -555,13 +522,11 @@ static void Main(int a/* { } } """); - } [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/449")] [WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/1077103")] public void NoFormattingInsideSingleLineDocComment_1() - { - AssertFormatAfterTypeChar(""" + => AssertFormatAfterTypeChar(""" class Program { /// {$$ @@ -580,13 +545,11 @@ static void Main(int a, int b) } } """); - } [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/449")] [WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/1077103")] public void NoFormattingInsideSingleLineDocComment_2() - { - AssertFormatAfterTypeChar(""" + => AssertFormatAfterTypeChar(""" class Program { /// {$$ @@ -605,13 +568,11 @@ static void Main(int a, int b) } } """); - } [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/449")] [WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/1077103")] public void NoFormattingInsideMultiLineDocComment_1() - { - AssertFormatAfterTypeChar(""" + => AssertFormatAfterTypeChar(""" class Program { /** {$$ **/ @@ -630,13 +591,11 @@ static void Main(int a, int b) } } """); - } [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/449")] [WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/1077103")] public void NoFormattingInsideMultiLineDocComment_2() - { - AssertFormatAfterTypeChar(""" + => AssertFormatAfterTypeChar(""" class Program { /** {$$ @@ -657,13 +616,11 @@ static void Main(int a, int b) } } """); - } [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/449")] [WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/1077103")] public void NoFormattingInsideMultiLineDocComment_3() - { - AssertFormatAfterTypeChar(""" + => AssertFormatAfterTypeChar(""" class Program { /** {$$ @@ -684,13 +641,11 @@ static void Main(int a, int b) } } """); - } [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/449")] [WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/1077103")] public void NoFormattingInsideInactiveCode() - { - AssertFormatAfterTypeChar(""" + => AssertFormatAfterTypeChar(""" class Program { #if false @@ -715,13 +670,11 @@ static void Main(string[] args) } } """); - } [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/449")] [WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/1077103")] public void NoFormattingInsideStringLiteral() - { - AssertFormatAfterTypeChar(""" + => AssertFormatAfterTypeChar(""" class Program { static void Main(string[] args) @@ -738,13 +691,11 @@ static void Main(string[] args) } } """); - } [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/449")] [WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/1077103")] public void NoFormattingInsideCharLiteral() - { - AssertFormatAfterTypeChar(""" + => AssertFormatAfterTypeChar(""" class Program { static void Main(string[] args) @@ -761,13 +712,11 @@ static void Main(string[] args) } } """); - } [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/449")] [WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/1077103")] public void NoFormattingInsideCommentsOfPreprocessorDirectives() - { - AssertFormatAfterTypeChar(""" + => AssertFormatAfterTypeChar(""" class Program { #region @@ -788,13 +737,11 @@ static void Main(string[] args) } } """); - } [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/464")] [WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/908729")] public void ColonInSwitchCase() - { - AssertFormatAfterTypeChar(""" + => AssertFormatAfterTypeChar(""" class Program { static void Main(string[] args) @@ -819,13 +766,11 @@ static void Main(string[] args) } } """); - } [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/464")] [WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/908729")] public void ColonInDefaultSwitchCase() - { - AssertFormatAfterTypeChar(""" + => AssertFormatAfterTypeChar(""" class Program { static void Main(string[] args) @@ -852,12 +797,10 @@ static void Main(string[] args) } } """); - } [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/9097")] public void ColonInPatternSwitchCase01() - { - AssertFormatAfterTypeChar(""" + => AssertFormatAfterTypeChar(""" class Program { static void Main() @@ -880,13 +823,11 @@ static void Main() } } """); - } [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/464")] [WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/908729")] public void ColonInLabeledStatement() - { - AssertFormatAfterTypeChar(""" + => AssertFormatAfterTypeChar(""" class Program { static void Main(string[] args) @@ -903,13 +844,11 @@ static void Main(string[] args) } } """); - } [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/464")] [WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/908729")] public void DoNotFormatColonInTargetAttribute() - { - AssertFormatAfterTypeChar(""" + => AssertFormatAfterTypeChar(""" using System; [method :$$ C] class C : Attribute @@ -922,13 +861,11 @@ class C : Attribute { } """); - } [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/464")] [WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/908729")] public void DoNotFormatColonInBaseList() - { - AssertFormatAfterTypeChar(""" + => AssertFormatAfterTypeChar(""" class C :$$ Attribute { } @@ -937,13 +874,11 @@ class C : Attribute { } """); - } [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/464")] [WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/908729")] public void DoNotFormatColonInThisConstructor() - { - AssertFormatAfterTypeChar(""" + => AssertFormatAfterTypeChar(""" class Goo { Goo(int s) :$$ this() @@ -966,13 +901,11 @@ class Goo } } """); - } [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/464")] [WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/908729")] public void DoNotFormatColonInConditionalOperator() - { - AssertFormatAfterTypeChar(""" + => AssertFormatAfterTypeChar(""" class Program { static void Main(string[] args) @@ -989,13 +922,11 @@ static void Main(string[] args) } } """); - } [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/464")] [WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/908729")] public void DoNotFormatColonInArgument() - { - AssertFormatAfterTypeChar(""" + => AssertFormatAfterTypeChar(""" class Program { static void Main(string[] args) @@ -1012,13 +943,11 @@ static void Main(string[] args) } } """); - } [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/464")] [WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/908729")] public void DoNotFormatColonInTypeParameter() - { - AssertFormatAfterTypeChar(""" + => AssertFormatAfterTypeChar(""" class Program { class C1 @@ -1037,7 +966,6 @@ class C1 } } """); - } [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/2224")] public void DoNotSmartFormatBracesOnSmartIndentNone() @@ -1152,8 +1080,7 @@ static void Main() [WpfFact, Trait(Traits.Feature, Traits.Features.SmartTokenFormatting)] [WorkItem("https://github.com/dotnet/roslyn/issues/5873")] public void DoNotKeepTabsInCommentsWhenFormattingIsOn() - { - AssertFormatAfterTypeChar(""" + => AssertFormatAfterTypeChar(""" class Program { static void Main() @@ -1170,7 +1097,6 @@ static void Main() } } """); - } [WpfFact] [Trait(Traits.Feature, Traits.Features.SmartTokenFormatting)] @@ -1231,8 +1157,7 @@ class C [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/4435")] [Trait(Traits.Feature, Traits.Features.SmartTokenFormatting)] public void OpenCurlyNotFormattedIfNotAtStartOfLine() - { - AssertFormatAfterTypeChar(""" + => AssertFormatAfterTypeChar(""" class C { public int P {$$ @@ -1243,13 +1168,11 @@ class C public int P { } """); - } [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/4435")] [Trait(Traits.Feature, Traits.Features.SmartTokenFormatting)] public void OpenCurlyFormattedIfAtStartOfLine() - { - AssertFormatAfterTypeChar(""" + => AssertFormatAfterTypeChar(""" class C { public int P @@ -1262,12 +1185,10 @@ public int P { } """); - } [WpfFact] public void DoNotFormatIncompleteBlockOnSingleLineIfNotTypingCloseCurly1() - { - AssertFormatAfterTypeChar(""" + => AssertFormatAfterTypeChar(""" namespace ConsoleApplication1 { class Program @@ -1288,12 +1209,10 @@ static bool Property } } """); - } [WpfFact] public void DoNotFormatIncompleteBlockOnSingleLineIfNotTypingCloseCurly2() - { - AssertFormatAfterTypeChar(""" + => AssertFormatAfterTypeChar(""" namespace ConsoleApplication1 { class Program @@ -1310,12 +1229,10 @@ class Program } } """); - } [WpfFact] public void DoNotFormatIncompleteBlockOnSingleLineIfNotTypingCloseCurly3() - { - AssertFormatAfterTypeChar(""" + => AssertFormatAfterTypeChar(""" namespace ConsoleApplication1 { class Program @@ -1332,12 +1249,10 @@ class Program } } """); - } [WpfFact] public void DoNotFormatCompleteBlockOnSingleLineIfTypingCloseCurly1() - { - AssertFormatAfterTypeChar(""" + => AssertFormatAfterTypeChar(""" namespace ConsoleApplication1 { class Program @@ -1356,12 +1271,10 @@ static bool Property get { return true; } } """); - } [WpfFact] public void DoNotFormatCompleteBlockOnSingleLineIfTypingCloseCurly2() - { - AssertFormatAfterTypeChar(""" + => AssertFormatAfterTypeChar(""" namespace ConsoleApplication1 { class Program @@ -1376,12 +1289,10 @@ class Program static bool Property { get { return true; } } """); - } [WpfFact] public void FormatIncompleteBlockOnMultipleLinesIfTypingCloseCurly1() - { - AssertFormatAfterTypeChar(""" + => AssertFormatAfterTypeChar(""" namespace ConsoleApplication1 { class Program @@ -1404,12 +1315,10 @@ static bool Property } } """); - } [WpfFact] public void FormatIncompleteBlockOnMultipleLinesIfTypingCloseCurly2() - { - AssertFormatAfterTypeChar(""" + => AssertFormatAfterTypeChar(""" namespace ConsoleApplication1 { class Program @@ -1432,12 +1341,10 @@ static bool Property } } """); - } [WpfFact] public void DoNotFormatCompleteBlockOnSingleLineIfTypingSemicolon() - { - AssertFormatAfterTypeChar(""" + => AssertFormatAfterTypeChar(""" public class Class1 { void M() @@ -1458,12 +1365,10 @@ void M() } } """); - } [WpfFact] public void FormatCompleteBlockOnSingleLineIfTypingCloseCurlyOnLaterLine() - { - AssertFormatAfterTypeChar(""" + => AssertFormatAfterTypeChar(""" public class Class1 { void M() @@ -1488,12 +1393,10 @@ void M() } } """); - } [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/7900")] public void FormatLockStatementWithEmbeddedStatementOnSemicolonDifferentLine() - { - AssertFormatAfterTypeChar(""" + => AssertFormatAfterTypeChar(""" class C { private object _l = new object(); @@ -1514,12 +1417,10 @@ public void M() } } """); - } [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/7900")] public void FormatLockStatementWithEmbeddedStatementOnSemicolonSameLine() - { - AssertFormatAfterTypeChar(""" + => AssertFormatAfterTypeChar(""" class C { private object _l = new object(); @@ -1538,7 +1439,6 @@ public void M() } } """); - } [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/11642")] public void FormatArbitraryNodeParenthesizedLambdaExpression() @@ -1662,8 +1562,7 @@ await AssertFormatAsync(expected, $""" [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/30787")] public void DoSmartIndentOpenBraceEvenWithFormatWhileTypingOff1() - { - AssertFormatAfterTypeChar(""" + => AssertFormatAfterTypeChar(""" class Program { void M() @@ -1682,12 +1581,10 @@ void M() } } """, SmartIndentButDoNotFormatWhileTyping()); - } [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/30787")] public void DoSmartIndentOpenBraceEvenWithFormatWhileTypingOff2() - { - AssertFormatAfterTypeChar(""" + => AssertFormatAfterTypeChar(""" class Program { void M() @@ -1706,12 +1603,10 @@ void M() } } """, SmartIndentButDoNotFormatWhileTyping()); - } [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/30787")] public void DoSmartIndentOpenBraceEvenWithFormatWhileTypingOff3() - { - AssertFormatAfterTypeChar(""" + => AssertFormatAfterTypeChar(""" class Program { void M() @@ -1728,12 +1623,10 @@ void M() } } """, SmartIndentButDoNotFormatWhileTyping()); - } [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/30787")] public void DoSmartIndentOpenBraceEvenWithFormatWhileTypingOff4() - { - AssertFormatAfterTypeChar(""" + => AssertFormatAfterTypeChar(""" class Program { void M() @@ -1750,12 +1643,10 @@ void M() } } """, SmartIndentButDoNotFormatWhileTyping()); - } [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/30787")] public void DoSmartIndentOpenBraceEvenWithFormatWhileTypingOff5() - { - AssertFormatAfterTypeChar(""" + => AssertFormatAfterTypeChar(""" class Program { void M() @@ -1774,12 +1665,10 @@ void M() } } """, SmartIndentButDoNotFormatWhileTyping()); - } [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/30787")] public void DoSmartIndentOpenBraceEvenWithFormatWhileTypingOff6() - { - AssertFormatAfterTypeChar(""" + => AssertFormatAfterTypeChar(""" class Program { void M() @@ -1796,12 +1685,10 @@ void M() } } """, SmartIndentButDoNotFormatWhileTyping()); - } [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/30787")] public void DoSmartIndentOpenBraceEvenWithFormatWhileTypingOff7() - { - AssertFormatAfterTypeChar(""" + => AssertFormatAfterTypeChar(""" class Program { void M() @@ -1814,12 +1701,10 @@ void M() { } """, SmartIndentButDoNotFormatWhileTyping()); - } [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/30787")] public void DoSmartIndentCloseBraceEvenWithFormatWhileTypingOff1() - { - AssertFormatAfterTypeChar(""" + => AssertFormatAfterTypeChar(""" class Program { void M() @@ -1840,12 +1725,10 @@ void M() } } """, SmartIndentButDoNotFormatWhileTyping()); - } [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/30787")] public void DoSmartIndentCloseBraceEvenWithFormatWhileTypingOff2() - { - AssertFormatAfterTypeChar(""" + => AssertFormatAfterTypeChar(""" class Program { void M() @@ -1864,12 +1747,10 @@ void M() } } """, SmartIndentButDoNotFormatWhileTyping()); - } [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/30787")] public void DoSmartIndentCloseBraceEvenWithFormatWhileTypingOff3() - { - AssertFormatAfterTypeChar(""" + => AssertFormatAfterTypeChar(""" class Program { void M() @@ -1884,12 +1765,10 @@ void M() } } """, SmartIndentButDoNotFormatWhileTyping()); - } [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/30787")] public void DoSmartIndentCloseBraceEvenWithFormatWhileTypingOff4() - { - AssertFormatAfterTypeChar(""" + => AssertFormatAfterTypeChar(""" class Program { void M() { @@ -1902,7 +1781,6 @@ void M() { } } """, SmartIndentButDoNotFormatWhileTyping()); - } [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/31907")] public Task NullableReferenceTypes() @@ -2072,8 +1950,7 @@ void M() [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/25003")] public void SeparateGroups_KeepMultipleLinesBetweenGroups() - { - AssertFormatWithView(""" + => AssertFormatWithView(""" $$ using System.A; using System.B; @@ -2090,12 +1967,10 @@ public void SeparateGroups_KeepMultipleLinesBetweenGroups() using MS.A; using MS.B; """, new OptionsCollection(LanguageNames.CSharp) { { GenerationOptions.SeparateImportDirectiveGroups, true } }); - } [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/25003")] public void SeparateGroups_KeepMultipleLinesBetweenGroups_FileScopedNamespace() - { - AssertFormatWithView(""" + => AssertFormatWithView(""" $$ namespace N; @@ -2116,12 +1991,10 @@ namespace N; using MS.A; using MS.B; """, new OptionsCollection(LanguageNames.CSharp) { { GenerationOptions.SeparateImportDirectiveGroups, true } }); - } [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/25003")] public void SeparateGroups_DoNotGroupIfNotSorted() - { - AssertFormatWithView(""" + => AssertFormatWithView(""" $$ using System.B; using System.A; @@ -2134,12 +2007,10 @@ public void SeparateGroups_DoNotGroupIfNotSorted() using MS.B; using MS.A; """, new OptionsCollection(LanguageNames.CSharp) { { GenerationOptions.SeparateImportDirectiveGroups, true } }); - } [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/25003")] public void SeparateGroups_GroupIfSorted() - { - AssertFormatWithView(""" + => AssertFormatWithView(""" $$ using System.A; using System.B; @@ -2153,12 +2024,10 @@ public void SeparateGroups_GroupIfSorted() using MS.A; using MS.B; """, new OptionsCollection(LanguageNames.CSharp) { { GenerationOptions.SeparateImportDirectiveGroups, true } }); - } [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/25003")] public void SeparateGroups_GroupIfSorted_RecognizeSystemNotFirst() - { - AssertFormatWithView(""" + => AssertFormatWithView(""" $$ using MS.A; using MS.B; @@ -2172,12 +2041,10 @@ public void SeparateGroups_GroupIfSorted_RecognizeSystemNotFirst() using System.A; using System.B; """, new OptionsCollection(LanguageNames.CSharp) { { GenerationOptions.SeparateImportDirectiveGroups, true } }); - } [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/58157")] public void FormatImplicitObjectCollection() - { - AssertFormatWithView(""" + => AssertFormatWithView(""" class Program { static void Main(string[] args) @@ -2200,7 +2067,6 @@ static void Main(string[] args) } } """); - } [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/49492")] public void PreserveAnnotationsOnMultiLineTrivia() @@ -2236,8 +2102,7 @@ class Test [WpfFact] public void FormatUserDefinedOperator() - { - AssertFormatWithView(""" + => AssertFormatWithView(""" $$ class C { @@ -2253,12 +2118,10 @@ class C } } """); - } [WpfFact] public void FormatUserDefinedUnaryOperator() - { - AssertFormatWithView(""" + => AssertFormatWithView(""" $$ class C { @@ -2274,12 +2137,10 @@ class C } } """); - } [WpfFact] public void FormatUserDefinedExplicitCastOperator() - { - AssertFormatWithView(""" + => AssertFormatWithView(""" $$ class C { @@ -2295,12 +2156,10 @@ public static explicit operator C ( int x){ } } """); - } [WpfFact] public void FormatUserDefinedOperatorOnType() - { - AssertFormatAfterTypeChar(""" + => AssertFormatAfterTypeChar(""" interface I1 { abstract static I1 operator + ( I1 x, I1 y);$$ @@ -2311,12 +2170,10 @@ interface I1 abstract static I1 operator +(I1 x, I1 y); } """); - } [WpfFact] public void FormatUserDefinedUnaryOperatorOnType() - { - AssertFormatAfterTypeChar(""" + => AssertFormatAfterTypeChar(""" interface I1 { abstract static I1 operator ++ ( I1 x);$$ @@ -2327,12 +2184,10 @@ interface I1 abstract static I1 operator ++(I1 x); } """); - } [WpfFact] public void FormatUserDefinedExplicitCastOperatorOnType() - { - AssertFormatAfterTypeChar(""" + => AssertFormatAfterTypeChar(""" interface I1 where T : I1 { abstract static explicit operator string ( T x);$$ @@ -2343,12 +2198,10 @@ interface I1 where T : I1 abstract static explicit operator string(T x); } """); - } [WpfFact] public void FormatUserDefinedCheckedOperator() - { - AssertFormatWithView(""" + => AssertFormatWithView(""" $$ class C { @@ -2364,12 +2217,10 @@ class C } } """, parseOptions: CSharpParseOptions.Default.WithLanguageVersion(LanguageVersion.CSharp12)); - } [WpfFact] public void FormatUserDefinedCheckedUnaryOperator() - { - AssertFormatWithView(""" + => AssertFormatWithView(""" $$ class C { @@ -2385,12 +2236,10 @@ class C } } """, parseOptions: CSharpParseOptions.Default.WithLanguageVersion(LanguageVersion.CSharp12)); - } [WpfFact] public void FormatUserDefinedExplicitCheckedCastOperator() - { - AssertFormatWithView(""" + => AssertFormatWithView(""" $$ class C { @@ -2406,12 +2255,10 @@ public static explicit operator checked C ( int x){ } } """, parseOptions: CSharpParseOptions.Default.WithLanguageVersion(LanguageVersion.CSharp12)); - } [WpfFact] public void FormatUserDefinedCheckedOperatorOnType() - { - AssertFormatAfterTypeChar(""" + => AssertFormatAfterTypeChar(""" interface I1 { abstract static I1 operator checked + ( I1 x, I1 y);$$ @@ -2422,12 +2269,10 @@ interface I1 abstract static I1 operator checked +(I1 x, I1 y); } """, parseOptions: CSharpParseOptions.Default.WithLanguageVersion(LanguageVersion.CSharp12)); - } [WpfFact] public void FormatUserDefinedCheckedUnaryOperatorOnType() - { - AssertFormatAfterTypeChar(""" + => AssertFormatAfterTypeChar(""" interface I1 { abstract static I1 operator checked ++ ( I1 x);$$ @@ -2438,12 +2283,10 @@ interface I1 abstract static I1 operator checked ++(I1 x); } """, parseOptions: CSharpParseOptions.Default.WithLanguageVersion(LanguageVersion.CSharp12)); - } [WpfFact] public void FormatUserDefinedExplicitCheckedCastOperatorOnType() - { - AssertFormatAfterTypeChar(""" + => AssertFormatAfterTypeChar(""" interface I1 where T : I1 { abstract static explicit operator checked string ( T x);$$ @@ -2454,12 +2297,10 @@ interface I1 where T : I1 abstract static explicit operator checked string(T x); } """, parseOptions: CSharpParseOptions.Default.WithLanguageVersion(LanguageVersion.CSharp12)); - } [WpfFact] public void FormatUnsignedRightShift() - { - AssertFormatWithView(""" + => AssertFormatWithView(""" $$ class C { @@ -2475,13 +2316,11 @@ class C } } """); - } [WpfTheory] [CombinatorialData] public void FormatInstanceIncrementOperator([CombinatorialValues("++", "--")] string op) - { - AssertFormatWithView($$$""" + => AssertFormatWithView($$$""" $$ class C { @@ -2497,13 +2336,11 @@ class C } } """); - } [WpfTheory] [CombinatorialData] public void FormatInstanceIncrementOperator_Checked([CombinatorialValues("++", "--")] string op) - { - AssertFormatWithView($$$""" + => AssertFormatWithView($$$""" $$ class C { @@ -2519,13 +2356,11 @@ class C } } """); - } [WpfTheory] [CombinatorialData] public void FormatInstanceCompoundAssignmentOperator([CombinatorialValues("+=", "-=", "*=", "/=", "%=", "&=", "|=", "^=", "<<=", ">>=", ">>>=")] string op) - { - AssertFormatWithView($$$""" + => AssertFormatWithView($$$""" $$ class C { @@ -2541,13 +2376,11 @@ class C } } """); - } [WpfTheory] [CombinatorialData] public void FormatInstanceCompoundAssignmentOperator_Checked([CombinatorialValues("+=", "-=", "*=", "/=", "%=", "&=", "|=", "^=", "<<=", ">>=", ">>>=")] string op) - { - AssertFormatWithView($$$""" + => AssertFormatWithView($$$""" $$ class C { @@ -2563,24 +2396,20 @@ class C } } """); - } [WpfFact] public void FormatCollectionExpressionAfterEquals() - { - AssertFormatWithView(""" + => AssertFormatWithView(""" $$ var v = [1, 2, 3]; """, """ $$ var v = [ 1 , 2 , 3 ] ; """); - } [WpfFact] public void FormatCollectionExpressionAfterEquals2() - { - AssertFormatWithView(""" + => AssertFormatWithView(""" class C { void M() @@ -2597,12 +2426,10 @@ void M() } } """); - } [WpfFact] public void FormatUnsignedRightShiftOnType() - { - AssertFormatAfterTypeChar(""" + => AssertFormatAfterTypeChar(""" interface I1 { abstract static I1 operator >>> ( I1 x, I1 y);$$ @@ -2613,13 +2440,11 @@ interface I1 abstract static I1 operator >>>(I1 x, I1 y); } """); - } [WpfTheory] [CombinatorialData] public void FormatInstanceIncrementOperatorOnType([CombinatorialValues("++", "--")] string op) - { - AssertFormatAfterTypeChar($$$""" + => AssertFormatAfterTypeChar($$$""" interface I1 { abstract void operator{{{op}}} ( );$$ @@ -2630,13 +2455,11 @@ interface I1 abstract void operator {{{op}}}(); } """); - } [WpfTheory] [CombinatorialData] public void FormatInstanceIncrementOperatorOnType_Checked([CombinatorialValues("++", "--")] string op) - { - AssertFormatAfterTypeChar($$$""" + => AssertFormatAfterTypeChar($$$""" interface I1 { abstract void operator checked{{{op}}} ( );$$ @@ -2647,13 +2470,11 @@ interface I1 abstract void operator checked {{{op}}}(); } """); - } [WpfTheory] [CombinatorialData] public void FormatInstanceCompoundAssignmentOperatorOnType([CombinatorialValues("+=", "-=", "*=", "/=", "%=", "&=", "|=", "^=", "<<=", ">>=", ">>>=")] string op) - { - AssertFormatAfterTypeChar($$$""" + => AssertFormatAfterTypeChar($$$""" interface I1 { abstract void operator{{{op}}} ( I1 x );$$ @@ -2664,13 +2485,11 @@ interface I1 abstract void operator {{{op}}}(I1 x); } """); - } [WpfTheory] [CombinatorialData] public void FormatInstanceCompoundAssignmentOperatorOnType_Checked([CombinatorialValues("+=", "-=", "*=", "/=", "%=", "&=", "|=", "^=", "<<=", ">>=", ">>>=")] string op) - { - AssertFormatAfterTypeChar($$$""" + => AssertFormatAfterTypeChar($$$""" interface I1 { abstract void operator checked{{{op}}} ( I1 x );$$ @@ -2681,12 +2500,10 @@ interface I1 abstract void operator checked {{{op}}}(I1 x); } """); - } [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/13981")] public void FormatLabeledStatementAfterColon() - { - AssertFormatAfterTypeChar(""" + => AssertFormatAfterTypeChar(""" class C { void M() @@ -2703,7 +2520,6 @@ void M() } } """); - } private static void AssertFormatAfterTypeChar( [StringSyntax(PredefinedEmbeddedLanguageNames.CSharpTest)] string code, diff --git a/src/EditorFeatures/CSharpTest/Formatting/Indentation/SmartIndenterTests.cs b/src/EditorFeatures/CSharpTest/Formatting/Indentation/SmartIndenterTests.cs index 914af6048341..c7918f646b2a 100644 --- a/src/EditorFeatures/CSharpTest/Formatting/Indentation/SmartIndenterTests.cs +++ b/src/EditorFeatures/CSharpTest/Formatting/Indentation/SmartIndenterTests.cs @@ -31,17 +31,14 @@ public SmartIndenterTests(ITestOutputHelper output) : base(output) { } [WpfFact] public void EmptyFile() - { - AssertSmartIndent( + => AssertSmartIndent( code: string.Empty, indentationLine: 0, expectedIndentation: 0); - } [WpfFact] public void NoPreviousLine() - { - AssertSmartIndent( + => AssertSmartIndent( """ #region Test @@ -61,12 +58,10 @@ public void NoPreviousLine() """, indentationLine: 13, expectedIndentation: 0); - } [WpfFact] public void EndOfFileInactive() - { - AssertSmartIndent( + => AssertSmartIndent( """ // Line 1 @@ -77,12 +72,10 @@ public void EndOfFileInactive() """, indentationLine: 4, expectedIndentation: 0); - } [WpfFact] public void EndOfFileInactive2() - { - AssertSmartIndent( + => AssertSmartIndent( """ // Line 1 @@ -94,12 +87,10 @@ public void EndOfFileInactive2() """, indentationLine: 5, expectedIndentation: 0); - } [WpfFact] public void Comments() - { - AssertSmartIndent( + => AssertSmartIndent( """ using System; @@ -112,12 +103,10 @@ class Class """, indentationLine: 6, expectedIndentation: 4); - } [WpfFact] public void TestExplicitNoneIndentStyle() - { - AssertSmartIndent( + => AssertSmartIndent( """ using System; @@ -131,12 +120,10 @@ class Class indentationLine: 6, expectedIndentation: 0, indentStyle: IndentStyle.None); - } [WpfFact] public void UsingDirective() - { - AssertSmartIndent( + => AssertSmartIndent( """ using System; @@ -144,12 +131,10 @@ public void UsingDirective() """, indentationLine: 1, expectedIndentation: 0); - } [WpfFact] public void DottedName() - { - AssertSmartIndent( + => AssertSmartIndent( """ using System. @@ -157,7 +142,6 @@ public void DottedName() """, indentationLine: 1, expectedIndentation: 4); - } [WpfFact] public void Namespace() @@ -182,8 +166,7 @@ namespace NS [WpfFact] public void NamespaceDottedName() - { - AssertSmartIndent( + => AssertSmartIndent( """ using System; @@ -193,12 +176,10 @@ namespace NS. """, indentationLine: 3, expectedIndentation: 4); - } [WpfFact] public void NamespaceBody() - { - AssertSmartIndent( + => AssertSmartIndent( """ using System; @@ -209,7 +190,6 @@ namespace NS """, indentationLine: 4, expectedIndentation: 4); - } [WpfFact] public void FileScopedNamespace() @@ -240,8 +220,7 @@ namespace NS; [WpfFact] public void Class() - { - AssertSmartIndent( + => AssertSmartIndent( """ using System; @@ -253,12 +232,10 @@ class Class """, indentationLine: 5, expectedIndentation: 8); - } [WpfFact] public void ClassBody() - { - AssertSmartIndent( + => AssertSmartIndent( """ using System; @@ -271,12 +248,10 @@ class Class """, indentationLine: 6, expectedIndentation: 8); - } [WpfFact] public void Method() - { - AssertSmartIndent( + => AssertSmartIndent( """ using System; @@ -290,12 +265,10 @@ void Method() """, indentationLine: 7, expectedIndentation: 12); - } [WpfFact] public void MethodBody() - { - AssertSmartIndent( + => AssertSmartIndent( """ using System; @@ -310,12 +283,10 @@ void Method() """, indentationLine: 8, expectedIndentation: 12); - } [WpfFact] public void Property() - { - AssertSmartIndent( + => AssertSmartIndent( """ using System; @@ -329,12 +300,10 @@ public static string Name """, indentationLine: 7, expectedIndentation: 12); - } [WpfFact] public void PropertyGetBody() - { - AssertSmartIndent( + => AssertSmartIndent( """ using System; @@ -351,12 +320,10 @@ public string Names """, indentationLine: 10, expectedIndentation: 16); - } [WpfFact] public void PropertySetBody() - { - AssertSmartIndent( + => AssertSmartIndent( """ using System; @@ -373,12 +340,10 @@ public static string Names """, indentationLine: 10, expectedIndentation: 16); - } [WpfFact] public void Statement() - { - AssertSmartIndent( + => AssertSmartIndent( """ using System; @@ -394,12 +359,10 @@ void Method() """, indentationLine: 9, expectedIndentation: 12); - } [WpfFact] public void FieldInitializer() - { - AssertSmartIndent( + => AssertSmartIndent( """ class C { @@ -408,12 +371,10 @@ class C """, indentationLine: 3, expectedIndentation: 4); - } [WpfFact] public void FieldInitializerWithNamespace() - { - AssertSmartIndent( + => AssertSmartIndent( """ namespace NS { @@ -425,7 +386,6 @@ class C """, indentationLine: 5, expectedIndentation: 8); - } [WpfFact] public void MethodCall() @@ -458,8 +418,7 @@ void Method() [WpfFact] public void Switch() - { - AssertSmartIndent( + => AssertSmartIndent( """ using System; @@ -475,12 +434,10 @@ void Method() """, indentationLine: 9, expectedIndentation: 16); - } [WpfFact] public void SwitchBody() - { - AssertSmartIndent( + => AssertSmartIndent( """ using System; @@ -497,12 +454,10 @@ void Method() """, indentationLine: 10, expectedIndentation: 16); - } [WpfFact] public void SwitchCase() - { - AssertSmartIndent( + => AssertSmartIndent( """ using System; @@ -520,12 +475,10 @@ void Method() """, indentationLine: 11, expectedIndentation: 20); - } [WpfFact] public void ExtendedPropertyPattern() - { - AssertSmartIndent( + => AssertSmartIndent( """ class C @@ -539,7 +492,6 @@ void M() """, indentationLine: 7, expectedIndentation: 12); - } [WpfFact] public void ExtendedPropertyPattern_WithPattern() @@ -569,8 +521,7 @@ void M() [WpfFact] public void Block() - { - AssertSmartIndent( + => AssertSmartIndent( """ using System; @@ -589,12 +540,10 @@ void Method() """, indentationLine: 12, expectedIndentation: 24); - } [WpfFact] public void MultilineStatement1() - { - AssertSmartIndent( + => AssertSmartIndent( """ using System; @@ -610,12 +559,10 @@ void Method() """, indentationLine: 9, expectedIndentation: 16); - } [WpfFact] public void MultilineStatement2() - { - AssertSmartIndent( + => AssertSmartIndent( """ using System; @@ -632,13 +579,11 @@ void Method() """, indentationLine: 10, expectedIndentation: 20); - } // Bug number 902477 [WpfFact] public void Comments2() - { - AssertSmartIndent( + => AssertSmartIndent( """ class Class { @@ -652,12 +597,10 @@ void Method() """, indentationLine: 5, expectedIndentation: 12); - } [WpfFact] public void AfterCompletedBlock() - { - AssertSmartIndent( + => AssertSmartIndent( """ class Program { @@ -672,12 +615,10 @@ static void Main(string[] args) """, indentationLine: 5, expectedIndentation: 8); - } [WpfFact] public void AfterCompletedBlockNestedInOtherBlock() - { - AssertSmartIndent( + => AssertSmartIndent( """ class Program { @@ -693,12 +634,10 @@ static void Main(string[] args) """, indentationLine: 5, expectedIndentation: 12); - } [WpfFact] public void AfterTopLevelAttribute() - { - AssertSmartIndent( + => AssertSmartIndent( """ class Program { @@ -710,12 +649,10 @@ class Program """, indentationLine: 3, expectedIndentation: 4); - } [WpfFact, WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/537802")] public void EmbeddedStatement() - { - AssertSmartIndent( + => AssertSmartIndent( """ class Program { @@ -731,7 +668,6 @@ static void Main(string[] args) """, indentationLine: 6, expectedIndentation: 8); - } [WpfTheory(Skip = "https://github.com/dotnet/roslyn/issues/50063")] [WorkItem("https://github.com/dotnet/roslyn/issues/50063")] @@ -741,8 +677,7 @@ static void Main(string[] args) [InlineData("void localFunction()")] [InlineData("static void localFunction()")] public void EmbeddedStatement2(string statement) - { - AssertSmartIndent( + => AssertSmartIndent( $$""" class Program { @@ -757,12 +692,10 @@ static void Main(string[] args) """, indentationLine: 5, expectedIndentation: 4); - } [WpfFact, WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/537883")] public void EnterAfterComment() - { - AssertSmartIndent( + => AssertSmartIndent( """ class Program { @@ -777,12 +710,10 @@ static void Main(string[] args) """, indentationLine: 5, expectedIndentation: 8); - } [WpfFact, WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/538121")] public void NestedBlock1() - { - AssertSmartIndent( + => AssertSmartIndent( """ class Program { @@ -797,12 +728,10 @@ static void Main(string[] args) """, indentationLine: 5, expectedIndentation: 12); - } [WpfFact] public void NestedEmbeddedStatement1() - { - AssertSmartIndent( + => AssertSmartIndent( """ class Program { @@ -819,12 +748,10 @@ static void Main(string[] args) """, indentationLine: 8, expectedIndentation: 8); - } [WpfFact] public void NestedEmbeddedStatement2() - { - AssertSmartIndent( + => AssertSmartIndent( """ class Program { @@ -841,12 +768,10 @@ static void Main(string[] args) """, indentationLine: 8, expectedIndentation: 8); - } [WpfFact] public void NestedEmbeddedStatement3() - { - AssertSmartIndent( + => AssertSmartIndent( """ class Program { @@ -863,12 +788,10 @@ static void Main(string[] args) """, indentationLine: 8, expectedIndentation: 8); - } [WpfFact] public void NestedEmbeddedStatement4() - { - AssertSmartIndent( + => AssertSmartIndent( """ class Program { @@ -883,12 +806,10 @@ static void Main(string[] args) """, indentationLine: 8, expectedIndentation: 8); - } [WpfFact] public void NestedEmbeddedStatement5() - { - AssertSmartIndent( + => AssertSmartIndent( """ class Program { @@ -903,12 +824,10 @@ static void Main(string[] args) """, indentationLine: 8, expectedIndentation: 8); - } [WpfFact] public void NestedEmbeddedStatement6() - { - AssertSmartIndent( + => AssertSmartIndent( """ class Program { @@ -923,12 +842,10 @@ static void Main(string[] args) """, indentationLine: 8, expectedIndentation: 8); - } [WpfFact] public void NestedEmbeddedStatement7() - { - AssertSmartIndent( + => AssertSmartIndent( """ class Program { @@ -945,12 +862,10 @@ static void Main(string[] args) """, indentationLine: 10, expectedIndentation: 8); - } [WpfFact] public void NestedEmbeddedStatement8() - { - AssertSmartIndent( + => AssertSmartIndent( """ class Program { @@ -968,12 +883,10 @@ static void Main(string[] args) """, indentationLine: 10, expectedIndentation: 8); - } [WpfFact] public void Label1() - { - AssertSmartIndent( + => AssertSmartIndent( """ class Program { @@ -989,12 +902,10 @@ static void Main(string[] args) """, indentationLine: 6, expectedIndentation: 8); - } [WpfFact] public void Label2() - { - AssertSmartIndent( + => AssertSmartIndent( """ class Program { @@ -1009,12 +920,10 @@ static void Main(string[] args) """, indentationLine: 5, expectedIndentation: 8); - } [WpfFact] public void Label3() - { - AssertSmartIndent( + => AssertSmartIndent( """ class Program { @@ -1032,12 +941,10 @@ static void Main(string[] args) """, indentationLine: 8, expectedIndentation: 16); - } [WpfFact] public void Label4() - { - AssertSmartIndent( + => AssertSmartIndent( """ class Program { @@ -1054,12 +961,10 @@ static void Main(string[] args) """, indentationLine: 7, expectedIndentation: 16); - } [WpfFact] public void Label5() - { - AssertSmartIndent( + => AssertSmartIndent( """ class Program { @@ -1076,12 +981,10 @@ static void Main(string[] args) """, indentationLine: 7, expectedIndentation: 16); - } [WpfFact] public void Label6() - { - AssertSmartIndent( + => AssertSmartIndent( """ class Program { @@ -1096,12 +999,10 @@ static void Main(string[] args) """, indentationLine: 5, expectedIndentation: 8); - } [WpfFact] public void QueryExpression1() - { - AssertSmartIndent( + => AssertSmartIndent( """ class Program { @@ -1116,12 +1017,10 @@ static void Main(string[] args) """, indentationLine: 5, expectedIndentation: 20); - } [WpfFact] public void QueryExpression2() - { - AssertSmartIndent( + => AssertSmartIndent( """ class Program { @@ -1136,12 +1035,10 @@ static void Main(string[] args) """, indentationLine: 5, expectedIndentation: 16); - } [WpfFact] public void QueryExpression3() - { - AssertSmartIndent( + => AssertSmartIndent( """ class Program { @@ -1156,12 +1053,10 @@ static void Main(string[] args) """, indentationLine: 5, expectedIndentation: 16); - } [WpfFact] public void QueryExpression4() - { - AssertSmartIndent( + => AssertSmartIndent( """ class Program { @@ -1176,12 +1071,10 @@ static void Main(string[] args) """, indentationLine: 5, expectedIndentation: 16); - } [WpfFact] public void QueryExpression5() - { - AssertSmartIndent( + => AssertSmartIndent( """ class Program { @@ -1197,12 +1090,10 @@ from b in G """, indentationLine: 6, expectedIndentation: 20); - } [WpfFact] public void QueryExpression6() - { - AssertSmartIndent( + => AssertSmartIndent( """ class Program { @@ -1219,12 +1110,10 @@ select b """, indentationLine: 7, expectedIndentation: 20); - } [WpfFact, WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/538779")] public void QueryExpression7() - { - AssertSmartIndent( + => AssertSmartIndent( """ class Program { @@ -1241,12 +1130,10 @@ static void Main(string[] args) """, indentationLine: 5, expectedIndentation: 16); - } [WpfFact, WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/538779")] public void QueryExpression8() - { - AssertSmartIndent( + => AssertSmartIndent( """ class Program { @@ -1264,12 +1151,10 @@ static void Main(string[] args) """, indentationLine: 6, expectedIndentation: 30); - } [WpfFact, WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/538780")] public void QueryExpression9() - { - AssertSmartIndent( + => AssertSmartIndent( """ class Program { @@ -1286,12 +1171,10 @@ static void Main(string[] args) """, indentationLine: 6, expectedIndentation: 16); - } [WpfFact, WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/538780")] public void QueryExpression10() - { - AssertSmartIndent( + => AssertSmartIndent( """ class Program { @@ -1309,12 +1192,10 @@ static void Main(string[] args) """, indentationLine: 7, expectedIndentation: 24); - } [WpfFact, WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/538333")] public void Statement1() - { - AssertSmartIndent( + => AssertSmartIndent( """ class Program { @@ -1324,12 +1205,10 @@ void Test() { } """, indentationLine: 3, expectedIndentation: 4); - } [WpfFact, WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/538933")] public void EndOfFile1() - { - AssertSmartIndent( + => AssertSmartIndent( """ class Program { @@ -1342,12 +1221,10 @@ void Test() """, indentationLine: 6, expectedIndentation: 8); - } [WpfFact, WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/539059")] public void VerbatimString() - { - AssertSmartIndent( + => AssertSmartIndent( """ class Program { @@ -1359,12 +1236,10 @@ void Test() """, indentationLine: 5, expectedIndentation: 0); - } [WpfFact] public void RawString1() - { - AssertSmartIndent( + => AssertSmartIndent( """" class Program { @@ -1379,12 +1254,10 @@ void Test() """", indentationLine: 5, expectedIndentation: 12); - } [WpfFact] public void RawString2() - { - AssertSmartIndent( + => AssertSmartIndent( """" class Program { @@ -1399,12 +1272,10 @@ void Test() """", indentationLine: 6, expectedIndentation: 12); - } [WpfFact] public void RawString3() - { - AssertSmartIndent( + => AssertSmartIndent( """" class Program { @@ -1419,12 +1290,10 @@ void Test() """", indentationLine: 6, expectedIndentation: 12); - } [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/60946")] public void RawString4() - { - AssertSmartIndent( + => AssertSmartIndent( """" class Program { @@ -1439,12 +1308,10 @@ void Test() """", indentationLine: 6, expectedIndentation: 16); - } [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/60946")] public void RawString5() - { - AssertSmartIndent( + => AssertSmartIndent( """" class Program { @@ -1460,7 +1327,6 @@ void Test() """", indentationLine: 7, expectedIndentation: 16); - } [WpfFact] public void RawString6() @@ -1484,8 +1350,7 @@ public void RawString6() [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/66368")] public void UnterminatedRawString1() - { - AssertSmartIndent( + => AssertSmartIndent( """"""" var x = """""" 1 @@ -1498,12 +1363,10 @@ public void UnterminatedRawString1() """"""", indentationLine: 3, expectedIndentation: 4); - } [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/66368")] public void UnterminatedInterpolatedRawString1() - { - AssertSmartIndent( + => AssertSmartIndent( """"""" var x = $"""""" 1 @@ -1516,12 +1379,10 @@ public void UnterminatedInterpolatedRawString1() """"""", indentationLine: 3, expectedIndentation: 4); - } [WpfFact] public void InterpolatedRawString1() - { - AssertSmartIndent( + => AssertSmartIndent( """" class Program { @@ -1536,12 +1397,10 @@ void Test() """", indentationLine: 5, expectedIndentation: 12); - } [WpfFact] public void InterpolatedRawString2() - { - AssertSmartIndent( + => AssertSmartIndent( """" class Program { @@ -1556,12 +1415,10 @@ void Test() """", indentationLine: 6, expectedIndentation: 12); - } [WpfFact] public void InterpolatedRawString3() - { - AssertSmartIndent( + => AssertSmartIndent( """" class Program { @@ -1576,12 +1433,10 @@ void Test() """", indentationLine: 6, expectedIndentation: 12); - } [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/60946")] public void InterpolatedRawString4() - { - AssertSmartIndent( + => AssertSmartIndent( """" class Program { @@ -1596,12 +1451,10 @@ void Test() """", indentationLine: 6, expectedIndentation: 16); - } [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/60946")] public void InterpolatedRawString5() - { - AssertSmartIndent( + => AssertSmartIndent( """" class Program { @@ -1617,7 +1470,6 @@ void Test() """", indentationLine: 7, expectedIndentation: 16); - } [WpfFact] public void InterpolatedRawString6() @@ -1696,8 +1548,7 @@ void Test() [WpfFact, WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/539892")] public void Bug5994() - { - AssertSmartIndent( + => AssertSmartIndent( """ using System; using System.Collections.Generic; @@ -1718,12 +1569,10 @@ group student by (avg == 0 ? 0 : avg / 10) into g """, indentationLine: 11, expectedIndentation: 15); - } [WpfFact, WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/539990")] public void Bug6124() - { - AssertSmartIndent( + => AssertSmartIndent( """ class Program { @@ -1743,12 +1592,10 @@ void Main() """, indentationLine: 11, expectedIndentation: 12); - } [WpfFact, WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/539990")] public void Bug6124_1() - { - AssertSmartIndent( + => AssertSmartIndent( """ class Program { @@ -1769,12 +1616,10 @@ void Main() """, indentationLine: 11, expectedIndentation: 16); - } [WpfFact] public void AfterIfWithSingleStatementInTopLevelMethod_Bug7291_1() - { - AssertSmartIndent( + => AssertSmartIndent( """ int fact(int x) { @@ -1786,12 +1631,10 @@ int fact(int x) indentationLine: 4, expectedIndentation: 4, options: TestOptions.Script); - } [WpfFact] public void AfterIfWithSingleStatementInTopLevelMethod_Bug7291_2() - { - AssertSmartIndent( + => AssertSmartIndent( """ int fact(int x) { @@ -1804,13 +1647,11 @@ int fact(int x) indentationLine: 4, expectedIndentation: 4, options: TestOptions.Script); - } [WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/540634")] [WpfFact, WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/544268")] public void FirstArgumentInArgumentList() - { - AssertSmartIndent( + => AssertSmartIndent( """ class Program { @@ -1833,12 +1674,10 @@ public Program( """, indentationLine: 9, expectedIndentation: 16); - } [WpfFact] public void ForLoop() - { - AssertSmartIndent( + => AssertSmartIndent( """ class Program { @@ -1851,12 +1690,10 @@ static void Main(string[] args) """, indentationLine: 5, expectedIndentation: 12); - } [WpfFact] public void CallBaseCtor() - { - AssertSmartIndent( + => AssertSmartIndent( """ class Program { @@ -1866,12 +1703,10 @@ public Program() : """, indentationLine: 3, expectedIndentation: 8); - } [WpfFact] public void MultipleDeclarations() - { - AssertSmartIndent( + => AssertSmartIndent( """ class Program { @@ -1884,12 +1719,10 @@ static void Main(string[] args) """, indentationLine: 5, expectedIndentation: 12); - } [WpfFact] public void CloseBracket() - { - AssertSmartIndent( + => AssertSmartIndent( """ class Program { @@ -1902,12 +1735,10 @@ static void Main(string[] args) """, indentationLine: 5, expectedIndentation: 12); - } [WpfFact] public void SwitchLabel() - { - AssertSmartIndent( + => AssertSmartIndent( """ class Program { @@ -1925,12 +1756,10 @@ static void Main(string[] args) """, indentationLine: 7, expectedIndentation: 16); - } [WpfFact] public void TypeParameters() - { - AssertSmartIndent( + => AssertSmartIndent( """ class Program { @@ -1940,12 +1769,10 @@ class Program """, indentationLine: 3, expectedIndentation: 8); - } [WpfFact, WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/542428")] public void TypeArguments() - { - AssertSmartIndent( + => AssertSmartIndent( """ class Program { @@ -1960,12 +1787,10 @@ static void Main(string[] args) """, indentationLine: 7, expectedIndentation: 16); - } [WpfFact, WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/542983")] public void ConstructorInitializer1() - { - AssertSmartIndent( + => AssertSmartIndent( """ public class Asset { @@ -1975,12 +1800,10 @@ public Asset() : this( """, indentationLine: 3, expectedIndentation: 8); - } [WpfFact, WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/542983")] public void ConstructorInitializer2() - { - AssertSmartIndent( + => AssertSmartIndent( """ public class Asset { @@ -1991,12 +1814,10 @@ public Asset() """, indentationLine: 4, expectedIndentation: 14); - } [WpfFact, WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/542983")] public void ConstructorInitializer3() - { - AssertSmartIndent( + => AssertSmartIndent( """ public class Asset { @@ -2007,12 +1828,10 @@ public Asset() : """, indentationLine: 4, expectedIndentation: 12); - } [WpfFact, WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/543131")] public void LockStatement1() - { - AssertSmartIndent( + => AssertSmartIndent( """ using System; class Program @@ -2031,12 +1850,10 @@ static int Main() """, indentationLine: 10, expectedIndentation: 12); - } [WpfFact, WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/543533")] public void ConstructorInitializer() - { - AssertSmartIndent( + => AssertSmartIndent( """ public class Asset { @@ -2046,12 +1863,10 @@ public Asset() : """, indentationLine: 3, expectedIndentation: 8); - } [WpfFact, WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/952803")] public void ArrayInitializer() - { - AssertSmartIndent( + => AssertSmartIndent( """ using System.Collections.ObjectModel; @@ -2069,12 +1884,10 @@ static void Main(string[] args) """, indentationLine: 8, expectedIndentation: 12); - } [WpfFact, WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/543563")] public void LambdaEmbededInExpression() - { - AssertSmartIndent( + => AssertSmartIndent( """ using System; using System.Collections.Generic; @@ -2108,12 +1921,10 @@ public void Dispose() """, indentationLine: 10, expectedIndentation: 12); - } [WpfFact, WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/543563")] public void LambdaEmbededInExpression_1() - { - AssertSmartIndent( + => AssertSmartIndent( """ class Program { @@ -2126,12 +1937,10 @@ static void Main(string[] args) """, indentationLine: 5, expectedIndentation: 16); - } [WpfFact, WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/543563")] public void LambdaEmbededInExpression_3() - { - AssertSmartIndent( + => AssertSmartIndent( """ using System; @@ -2163,12 +1972,10 @@ public void Dispose() """, indentationLine: 8, expectedIndentation: 12); - } [WpfFact, WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/543563")] public void LambdaEmbededInExpression_2() - { - AssertSmartIndent( + => AssertSmartIndent( """ class Program { @@ -2182,12 +1989,10 @@ static void Main(string[] args) """, indentationLine: 6, expectedIndentation: 16); - } [WpfFact, WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/543563")] public void LambdaEmbededInExpression_4() - { - AssertSmartIndent( + => AssertSmartIndent( """ using System; class Class @@ -2208,12 +2013,10 @@ private void OtherMethod(Action action) { } """, indentationLine: 10, expectedIndentation: 16); - } [WpfFact] public void LambdaDefaultParameter_EnterAfterParamList() - { - AssertSmartIndent( + => AssertSmartIndent( """ class Program { @@ -2226,12 +2029,10 @@ public void Main() """, indentationLine: 5, expectedIndentation: 8); - } [WpfFact] public void LambdaDefaultParameter_EnterAfterEquals() - { - AssertSmartIndent( + => AssertSmartIndent( """ class Program { @@ -2243,7 +2044,6 @@ public void Main() """, indentationLine: 5, expectedIndentation: 12); - } [WpfFact] public void LambdaDefaultParameter_EnterBeforeEquals() @@ -2278,8 +2078,7 @@ int y [WpfFact, WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/530074")] public void EnterInArgumentList1() - { - AssertSmartIndent( + => AssertSmartIndent( """ class Program { @@ -2292,12 +2091,10 @@ static void Main(string[] args) """, indentationLine: 5, expectedIndentation: 12); - } [WpfFact, WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/530074")] public void EnterInArgumentList2() - { - AssertSmartIndent( + => AssertSmartIndent( """ class Program { @@ -2310,12 +2107,10 @@ static void Main(string[] args) """, indentationLine: 5, expectedIndentation: 12); - } [WpfFact, WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/806266")] public void EnterInArgumentList3() - { - AssertSmartIndent( + => AssertSmartIndent( """ class Program { @@ -2328,12 +2123,10 @@ static void Main(string[] args) """, indentationLine: 5, expectedIndentation: 12); - } [WpfFact, WorkItem(9216, "DevDiv_Projects/Roslyn")] public void FollowPreviousLineInMultilineStatements() - { - AssertSmartIndent(""" + => AssertSmartIndent(""" class Program { static void Main(string[] args) @@ -2345,14 +2138,12 @@ static void Main(string[] args) } } """, indentationLine: 7, expectedIndentation: 39); - } [WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/648068")] [WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/674611")] [WpfFact, Trait(Traits.Feature, Traits.Features.Venus)] public void AtBeginningOfSpanInNugget() - { - AssertSmartIndentInProjection( + => AssertSmartIndentInProjection( """ class Program { @@ -2366,12 +2157,10 @@ static void Main(string[] args) } } """, BaseIndentationOfNugget + 4); - } [WpfFact, Trait(Traits.Feature, Traits.Features.Venus)] public void AtEndOfSpanInNugget() - { - AssertSmartIndentInProjection( + => AssertSmartIndentInProjection( """ class Program { @@ -2385,7 +2174,6 @@ static void Main(string[] args) } } """, BaseIndentationOfNugget + 4); - } [WpfFact, Trait(Traits.Feature, Traits.Features.Venus)] public void InMiddleOfSpanAtStartOfNugget() @@ -2438,8 +2226,7 @@ static void Main(string[] args) [WpfFact, Trait(Traits.Feature, Traits.Features.Venus)] public void AfterStatementInNugget() - { - AssertSmartIndentInProjection( + => AssertSmartIndentInProjection( """ class Program { @@ -2455,7 +2242,6 @@ static void Main(string[] args) } } """, BaseIndentationOfNugget + 4); - } [WpfFact, Trait(Traits.Feature, Traits.Features.Venus)] public void AfterStatementOnFirstLineOfNugget() @@ -2490,8 +2276,7 @@ static void Main(string[] args) [WpfFact, Trait(Traits.Feature, Traits.Features.Venus)] public void InQueryOnFistLineOfNugget() - { - AssertSmartIndentInProjection( + => AssertSmartIndentInProjection( """ class Program { @@ -2506,12 +2291,10 @@ static void Main(string[] args) } } """, BaseIndentationOfNugget + 8); - } [WpfFact, Trait(Traits.Feature, Traits.Features.Venus)] public void InQueryInNugget() - { - AssertSmartIndentInProjection( + => AssertSmartIndentInProjection( """ class Program { @@ -2527,13 +2310,11 @@ static void Main(string[] args) } } """, BaseIndentationOfNugget + 8); - } [WorkItem(9216, "DevDiv_Projects/Roslyn")] [WpfFact, Trait(Traits.Feature, Traits.Features.Venus)] public void InsideBracesInNugget() - { - AssertSmartIndentInProjection(""" + => AssertSmartIndentInProjection(""" class Program { static void Main(string[] args) @@ -2548,7 +2329,6 @@ static void Main(string[] args) } } """, BaseIndentationOfNugget + 8); - } [WorkItem(9216, "DevDiv_Projects/Roslyn")] [WpfFact, Trait(Traits.Feature, Traits.Features.Venus)] @@ -2634,8 +2414,7 @@ static void Main(string[] args) // aligns with the base or base + 4th position. [WpfFact, Trait(Traits.Feature, Traits.Features.Venus)] public void AfterSwitchStatementInNugget() - { - AssertSmartIndentInProjection(""" + => AssertSmartIndentInProjection(""" class Program { @@ -2654,12 +2433,10 @@ static void Main(string[] args) } """, expectedIndentation: BaseIndentationOfNugget + 12); - } [WpfFact, WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/529876"), Trait(Traits.Feature, Traits.Features.SmartIndent), Trait(Traits.Feature, Traits.Features.Venus)] public void InEmptyNugget() - { - AssertSmartIndentInProjection(""" + => AssertSmartIndentInProjection(""" class Program { static void Main(string[] args) @@ -2673,13 +2450,11 @@ static void Main(string[] args) } """, expectedIndentation: BaseIndentationOfNugget + 4); - } [WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/1190278")] [WpfFact, Trait(Traits.Feature, Traits.Features.Venus)] public void GetNextTokenForFormattingSpanCalculationIncludesZeroWidthToken_CS() - { - AssertSmartIndentInProjection(""" + => AssertSmartIndentInProjection(""" //------------------------------------------------------------------------------ // // This code was generated by a tool. @@ -2747,12 +2522,10 @@ public override void Execute() { } """, expectedIndentation: 24); - } [WpfFact, WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/530948"), Trait(Traits.Feature, Traits.Features.SmartIndent)] public void CommaSeparatedListEnumMembers() - { - AssertSmartIndent( + => AssertSmartIndent( """ enum MyEnum { @@ -2762,12 +2535,10 @@ enum MyEnum """, indentationLine: 3, expectedIndentation: 4); - } [WpfFact, WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/530796"), Trait(Traits.Feature, Traits.Features.SmartIndent)] public void RelativeIndentationForBracesInExpression() - { - AssertSmartIndent( + => AssertSmartIndent( """ class C { @@ -2783,7 +2554,6 @@ void M(C c) """, indentationLine: 6, expectedIndentation: 12); - } [WpfFact, WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/584599"), Trait(Traits.Feature, Traits.Features.SmartIndent)] public void SwitchSection() @@ -2986,8 +2756,7 @@ static void Main(string[] args) [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/5495")] public void AfterBadQueryContinuationWithSelectOrGroupClause() - { - AssertSmartIndent( + => AssertSmartIndent( """ using System.Collections.Generic; using System.Linq; @@ -3031,12 +2800,10 @@ class UserViewModel """, indentationLine: 13, expectedIndentation: 25); - } [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/5495")] public void AfterPartialFromClause() - { - AssertSmartIndent( + => AssertSmartIndent( """ using System.Linq; @@ -3053,12 +2820,10 @@ void M() """, indentationLine: 8, expectedIndentation: 16); - } [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/5635")] public void ConstructorInitializerMissingBaseOrThisKeyword() - { - AssertSmartIndent( + => AssertSmartIndent( """ class C @@ -3071,12 +2836,10 @@ class C """, indentationLine: 5, expectedIndentation: 8); - } [WpfFact] public void CreateIndentOperationForBrokenBracketedArgumentList() - { - AssertSmartIndent( + => AssertSmartIndent( """ class Program @@ -3091,12 +2854,10 @@ static void M() """, indentationLine: 6, expectedIndentation: 12); - } [WpfFact] public void PatternPropertyIndentFirst() - { - AssertSmartIndent( + => AssertSmartIndent( """ class C @@ -3112,12 +2873,10 @@ void M(object o) """, indentationLine: 7, expectedIndentation: 12); - } [WpfFact] public void PatternPropertyIndentSecond() - { - AssertSmartIndent( + => AssertSmartIndent( """ class C @@ -3134,12 +2893,10 @@ void M(object o) """, indentationLine: 8, expectedIndentation: 12); - } [WpfFact] public void PatternPropertyIndentNestedFirst() - { - AssertSmartIndent( + => AssertSmartIndent( """ class C @@ -3159,12 +2916,10 @@ X is Widget """, indentationLine: 9, expectedIndentation: 16); - } [WpfFact] public void PatternPropertyIndentNestedSecond() - { - AssertSmartIndent( + => AssertSmartIndent( """ class C @@ -3184,7 +2939,6 @@ X is Widget """, indentationLine: 10, expectedIndentation: 16); - } [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/33253")] public void EnterAfterFluentSequences_1() @@ -3360,8 +3114,7 @@ public void Test(object session) [WpfFact] public void Operator() - { - AssertSmartIndent( + => AssertSmartIndent( """ using System; @@ -3375,12 +3128,10 @@ class Class """, indentationLine: 7, expectedIndentation: 12); - } [WpfFact] public void CastOperator() - { - AssertSmartIndent( + => AssertSmartIndent( """ using System; @@ -3394,12 +3145,10 @@ public static explicit operator Class(int x) """, indentationLine: 7, expectedIndentation: 12); - } [WpfFact] public void OperatorBody() - { - AssertSmartIndent( + => AssertSmartIndent( """ using System; @@ -3414,12 +3163,10 @@ class Class """, indentationLine: 8, expectedIndentation: 12); - } [WpfFact] public void CastOperatorBody() - { - AssertSmartIndent( + => AssertSmartIndent( """ using System; @@ -3434,12 +3181,10 @@ public static explicit operator Class(int x) """, indentationLine: 8, expectedIndentation: 12); - } [WpfFact] public void CheckedOperator() - { - AssertSmartIndent( + => AssertSmartIndent( """ using System; @@ -3454,12 +3199,10 @@ class Class indentationLine: 7, expectedIndentation: 12, options: CSharpParseOptions.Default.WithLanguageVersion(LanguageVersion.CSharp12)); - } [WpfFact] public void ExplicitCastCheckedOperator() - { - AssertSmartIndent( + => AssertSmartIndent( """ using System; @@ -3474,12 +3217,10 @@ public static explicit operator checked Class(int x) indentationLine: 7, expectedIndentation: 12, options: CSharpParseOptions.Default.WithLanguageVersion(LanguageVersion.CSharp12)); - } [WpfFact] public void CheckedOperatorBody() - { - AssertSmartIndent( + => AssertSmartIndent( """ using System; @@ -3495,12 +3236,10 @@ class Class indentationLine: 8, expectedIndentation: 12, options: CSharpParseOptions.Default.WithLanguageVersion(LanguageVersion.CSharp12)); - } [WpfFact] public void ExplicitCastCheckedOperatorBody() - { - AssertSmartIndent( + => AssertSmartIndent( """ using System; @@ -3516,12 +3255,10 @@ public static explicit operator checked Class(int x) indentationLine: 8, expectedIndentation: 12, options: CSharpParseOptions.Default.WithLanguageVersion(LanguageVersion.CSharp12)); - } [WpfFact] public void UnsignedRightShift() - { - AssertSmartIndent( + => AssertSmartIndent( """ using System; @@ -3535,12 +3272,10 @@ class Class """, indentationLine: 7, expectedIndentation: 12); - } [WpfFact] public void UnsignedRightShiftBody() - { - AssertSmartIndent( + => AssertSmartIndent( """ using System; @@ -3555,7 +3290,6 @@ class Class """, indentationLine: 8, expectedIndentation: 12); - } [WpfTheory] [CombinatorialData] diff --git a/src/EditorFeatures/CSharpTest/Formatting/Indentation/SmartTokenFormatterFormatRangeTests.cs b/src/EditorFeatures/CSharpTest/Formatting/Indentation/SmartTokenFormatterFormatRangeTests.cs index a11b96c1e83a..a5245275e3cf 100644 --- a/src/EditorFeatures/CSharpTest/Formatting/Indentation/SmartTokenFormatterFormatRangeTests.cs +++ b/src/EditorFeatures/CSharpTest/Formatting/Indentation/SmartTokenFormatterFormatRangeTests.cs @@ -2514,16 +2514,13 @@ void Main() [CombinatorialData] [WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/620568")] public void SkippedTokens1(bool useTabs) - { - AutoFormatToken(@";$$*", @";*", useTabs); - } + => AutoFormatToken(@";$$*", @";*", useTabs); [WpfTheory] [CombinatorialData] [WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/530830")] public void AutoPropertyAccessor(bool useTabs) - { - AutoFormatToken(""" + => AutoFormatToken(""" class C { int Prop { get ;$$ @@ -2534,14 +2531,12 @@ class C int Prop { get; } """, useTabs); - } [WpfTheory] [CombinatorialData] [WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/530830")] public void AutoPropertyAccessor2(bool useTabs) - { - AutoFormatToken(""" + => AutoFormatToken(""" class C { int Prop { get; set ;$$ @@ -2552,14 +2547,12 @@ class C int Prop { get; set; } """, useTabs); - } [WpfTheory] [CombinatorialData] [WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/530830")] public void AutoPropertyAccessor3(bool useTabs) - { - AutoFormatToken(""" + => AutoFormatToken(""" class C { int Prop { get; set ; }$$ @@ -2570,14 +2563,12 @@ class C int Prop { get; set; } } """, useTabs); - } [WpfTheory] [CombinatorialData] [WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/784674")] public void AutoPropertyAccessor4(bool useTabs) - { - AutoFormatToken(""" + => AutoFormatToken(""" class C { int Prop { get;$$ } @@ -2588,14 +2579,12 @@ class C int Prop { get; } } """, useTabs); - } [WpfTheory] [CombinatorialData] [WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/924469")] public void AutoPropertyAccessor5(bool useTabs) - { - AutoFormatToken(""" + => AutoFormatToken(""" class C { int Prop { get; set ;$$ } @@ -2606,14 +2595,12 @@ class C int Prop { get; set; } } """, useTabs); - } [WpfTheory] [CombinatorialData] [WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/924469")] public void AutoPropertyAccessor6(bool useTabs) - { - AutoFormatToken(""" + => AutoFormatToken(""" class C { int Prop { get;set;$$} @@ -2624,14 +2611,12 @@ class C int Prop { get; set; } } """, useTabs); - } [WpfTheory] [CombinatorialData] [WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/924469")] public void AutoPropertyAccessor7(bool useTabs) - { - AutoFormatToken(""" + => AutoFormatToken(""" class C { int Prop { get;set;$$} @@ -2642,14 +2627,12 @@ class C int Prop { get; set; } } """, useTabs); - } [WpfTheory] [CombinatorialData] [WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/912965")] public void NestedUsingStatement(bool useTabs) - { - AutoFormatToken(""" + => AutoFormatToken(""" class C { public void M() @@ -2668,14 +2651,12 @@ public void M() } } """, useTabs); - } [WpfTheory] [CombinatorialData] [WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/912965")] public void NestedNotUsingStatement(bool useTabs) - { - AutoFormatToken(""" + => AutoFormatToken(""" class C { public void M() @@ -2694,13 +2675,11 @@ public void M() } } """, useTabs); - } [WpfTheory] [CombinatorialData] public void UsingStatementWithNestedFixedStatement(bool useTabs) - { - AutoFormatToken(""" + => AutoFormatToken(""" class C { public void M() @@ -2723,13 +2702,11 @@ public void M() } } """, useTabs); - } [WpfTheory] [CombinatorialData] public void UsingStatementWithNestedCheckedStatement(bool useTabs) - { - AutoFormatToken(""" + => AutoFormatToken(""" class C { public void M() @@ -2752,13 +2729,11 @@ public void M() } } """, useTabs); - } [WpfTheory] [CombinatorialData] public void UsingStatementWithNestedUncheckedStatement(bool useTabs) - { - AutoFormatToken(""" + => AutoFormatToken(""" class C { public void M() @@ -2781,13 +2756,11 @@ public void M() } } """, useTabs); - } [WpfTheory] [CombinatorialData] public void FixedStatementWithNestedUsingStatement(bool useTabs) - { - AutoFormatToken(""" + => AutoFormatToken(""" class C { public void M() @@ -2806,13 +2779,11 @@ public void M() } } """, useTabs); - } [WpfTheory] [CombinatorialData] public void FixedStatementWithNestedFixedStatement(bool useTabs) - { - AutoFormatToken(""" + => AutoFormatToken(""" class C { public void M() @@ -2835,13 +2806,11 @@ public void M() } } """, useTabs); - } [WpfTheory] [CombinatorialData] public void FixedStatementWithNestedNotFixedStatement(bool useTabs) - { - AutoFormatToken(""" + => AutoFormatToken(""" class C { public void M() @@ -2864,13 +2833,11 @@ public void M() } } """, useTabs); - } [WpfTheory] [CombinatorialData] public void NotFixedStatementWithNestedFixedStatement(bool useTabs) - { - AutoFormatToken(""" + => AutoFormatToken(""" class C { public void M() @@ -2893,14 +2860,12 @@ public void M() } } """, useTabs); - } [WpfTheory] [CombinatorialData] [WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/954386")] public void FormattingRangeForFirstStatementOfBlock(bool useTabs) - { - AutoFormatToken(""" + => AutoFormatToken(""" class C { public void M() @@ -2916,14 +2881,12 @@ public void M() } } """, useTabs); - } [WpfTheory] [CombinatorialData] [WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/954386")] public void FormattingRangeForFirstMemberofType(bool useTabs) - { - AutoFormatToken(""" + => AutoFormatToken(""" class C {int s;$$ public void M() @@ -2939,14 +2902,12 @@ public void M() } } """, useTabs); - } [WpfTheory] [CombinatorialData] [WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/954386")] public void FormattingRangeForFirstMethodMemberofType(bool useTabs) - { - AutoFormatToken(""" + => AutoFormatToken(""" interface C {void s();$$ } @@ -2956,14 +2917,12 @@ interface C void s(); } """, useTabs); - } [WpfTheory] [CombinatorialData] [WorkItem("https://github.com/dotnet/roslyn/issues/17257")] public void FormattingRangeForConstructor(bool useTabs) - { - AutoFormatToken(""" + => AutoFormatToken(""" class C {public C()=>f=1;$$ } @@ -2973,14 +2932,12 @@ class C public C() => f = 1; } """, useTabs); - } [WpfTheory] [CombinatorialData] [WorkItem("https://github.com/dotnet/roslyn/issues/17257")] public void FormattingRangeForDestructor(bool useTabs) - { - AutoFormatToken(""" + => AutoFormatToken(""" class C {~C()=>f=1;$$ } @@ -2990,14 +2947,12 @@ class C ~C() => f = 1; } """, useTabs); - } [WpfTheory] [CombinatorialData] [WorkItem("https://github.com/dotnet/roslyn/issues/17257")] public void FormattingRangeForOperator(bool useTabs) - { - AutoFormatToken(""" + => AutoFormatToken(""" class C {public static C operator +(C left, C right)=>field=1;$$ static int field; @@ -3009,14 +2964,12 @@ class C static int field; } """, useTabs); - } [WpfTheory] [CombinatorialData] [WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/954386")] public void FormattingRangeForFirstMemberOfNamespace(bool useTabs) - { - AutoFormatToken(""" + => AutoFormatToken(""" namespace C {delegate void s();$$ } @@ -3026,14 +2979,12 @@ namespace C delegate void s(); } """, useTabs); - } [WpfTheory] [CombinatorialData] [WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/981821")] public void FormatDirectiveTriviaAlwaysToColumnZero(bool useTabs) - { - AutoFormatToken(""" + => AutoFormatToken(""" class Program { static void Main(string[] args) @@ -3054,14 +3005,12 @@ static void Main(string[] args) } """, useTabs); - } [WpfTheory] [CombinatorialData] [WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/981821")] public void FormatDirectiveTriviaAlwaysToColumnZeroWithCode(bool useTabs) - { - AutoFormatToken(""" + => AutoFormatToken(""" class Program { static void Main(string[] args) @@ -3084,14 +3033,12 @@ static void Main(string[] args) } """, useTabs); - } [WpfTheory] [CombinatorialData] [WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/981821")] public void FormatDirectiveTriviaAlwaysToColumnZeroWithBrokenElseDirective(bool useTabs) - { - AutoFormatToken(""" + => AutoFormatToken(""" class Program { static void Main(string[] args) @@ -3112,7 +3059,6 @@ static void Main(string[] args) } """, useTabs); - } internal static void AutoFormatToken(string markup, string expected, bool useTabs) { diff --git a/src/EditorFeatures/CSharpTest/GenerateConstructors/GenerateConstructorsTests.cs b/src/EditorFeatures/CSharpTest/GenerateConstructors/GenerateConstructorsTests.cs index 2d8b07336a2f..9a296c0e236f 100644 --- a/src/EditorFeatures/CSharpTest/GenerateConstructors/GenerateConstructorsTests.cs +++ b/src/EditorFeatures/CSharpTest/GenerateConstructors/GenerateConstructorsTests.cs @@ -71,7 +71,7 @@ class Z public Z(int a{|Navigation:)|} => this.a = a; } """, - options: Option(CSharpCodeStyleOptions.PreferExpressionBodiedConstructors, CSharpCodeStyleOptions.WhenPossibleWithSilentEnforcement)); + new TestParameters(options: Option(CSharpCodeStyleOptions.PreferExpressionBodiedConstructors, CSharpCodeStyleOptions.WhenPossibleWithSilentEnforcement))); [Fact] public Task TestUseExpressionBodyWhenOnSingleLine_AndIsSingleLine() @@ -94,7 +94,7 @@ class Z public Z(int a{|Navigation:)|} => this.a = a; } """, - options: Option(CSharpCodeStyleOptions.PreferExpressionBodiedConstructors, CSharpCodeStyleOptions.WhenOnSingleLineWithSilentEnforcement)); + new TestParameters(options: Option(CSharpCodeStyleOptions.PreferExpressionBodiedConstructors, CSharpCodeStyleOptions.WhenOnSingleLineWithSilentEnforcement))); [Fact] public Task TestUseExpressionBodyWhenOnSingleLine_AndIsNotSingleLine() @@ -123,7 +123,7 @@ public Z(int a, int b{|Navigation:)|} } } """, - options: Option(CSharpCodeStyleOptions.PreferExpressionBodiedConstructors, CSharpCodeStyleOptions.WhenOnSingleLineWithSilentEnforcement)); + new TestParameters(options: Option(CSharpCodeStyleOptions.PreferExpressionBodiedConstructors, CSharpCodeStyleOptions.WhenOnSingleLineWithSilentEnforcement))); [Fact] public Task TestMultipleFields() @@ -517,7 +517,7 @@ public Z(int a, string b{|Navigation:)|} public int A { get; private set; } public string B { get; private set; } } - """, options: Option(CodeStyleOptions2.QualifyPropertyAccess, true, NotificationOption2.Error)); + """, new TestParameters(options: Option(CodeStyleOptions2.QualifyPropertyAccess, true, NotificationOption2.Error))); [Fact] public Task TestStruct() @@ -908,7 +908,7 @@ public Program(int field{|Navigation:)|} } } """, - options: Option(CodeStyleOptions2.QualifyFieldAccess, CodeStyleOption2.TrueWithSuggestionEnforcement)); + new TestParameters(options: Option(CodeStyleOptions2.QualifyFieldAccess, CodeStyleOption2.TrueWithSuggestionEnforcement))); [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/13944")] public Task TestGetter_Only_Auto_Props() @@ -933,7 +933,7 @@ protected Contribution(string title, int number{|Navigation:)|} public int Number { get; } } """, - options: Option(CodeStyleOptions2.QualifyFieldAccess, CodeStyleOption2.TrueWithSuggestionEnforcement)); + new TestParameters(options: Option(CodeStyleOptions2.QualifyFieldAccess, CodeStyleOption2.TrueWithSuggestionEnforcement))); [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/13944")] public Task TestAbstract_Getter_Only_Auto_Props() @@ -1390,7 +1390,7 @@ protected C(int prop{|Navigation:)|} public int Prop { get; set; } } """, - options: Option(CodeStyleOptions2.QualifyFieldAccess, CodeStyleOption2.TrueWithSuggestionEnforcement)); + new TestParameters(options: Option(CodeStyleOptions2.QualifyFieldAccess, CodeStyleOption2.TrueWithSuggestionEnforcement))); [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/17643")] public Task TestWithDialogNoBackingField() @@ -1531,7 +1531,7 @@ public Z(int abcdefg{|Navigation:)|} [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/33601")] public Task TestPartialFieldSelectionBeforeIdentifier() - => TestInRegularAndScript1Async( + => TestInRegularAndScriptAsync( """ class Z { @@ -1552,7 +1552,7 @@ public Z(int a{|Navigation:)|} [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/33601")] public Task TestPartialFieldSelectionAfterIdentifier() - => TestInRegularAndScript1Async( + => TestInRegularAndScriptAsync( """ class Z { @@ -1710,7 +1710,7 @@ public Z(int p_a{|Navigation:)|} a = p_a; } } - """, options: options.ParameterNamesAreCamelCaseWithPUnderscorePrefix); + """, new TestParameters(options: options.ParameterNamesAreCamelCaseWithPUnderscorePrefix)); [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/36741")] public Task TestCommonFieldNamingStyle() @@ -1731,7 +1731,7 @@ public Z(int p_a{|Navigation:)|} s_a = p_a; } } - """, options: options.ParameterNamesAreCamelCaseWithPUnderscorePrefix); + """, new TestParameters(options: options.ParameterNamesAreCamelCaseWithPUnderscorePrefix)); [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/36741")] public Task TestSpecifiedNamingStyle() @@ -1752,7 +1752,7 @@ public Z(int p_a_End{|Navigation:)|} field_a = p_a_End; } } - """, options: options.MergeStyles(options.FieldNamesAreCamelCaseWithFieldUnderscorePrefix, options.ParameterNamesAreCamelCaseWithPUnderscorePrefixAndUnderscoreEndSuffix)); + """, new TestParameters(options: options.MergeStyles(options.FieldNamesAreCamelCaseWithFieldUnderscorePrefix, options.ParameterNamesAreCamelCaseWithPUnderscorePrefixAndUnderscoreEndSuffix))); [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/36741")] public Task TestSpecifiedAndCommonFieldNamingStyle() @@ -1773,7 +1773,7 @@ public Z(int p_a_End{|Navigation:)|} field_s_a = p_a_End; } } - """, options: options.MergeStyles(options.FieldNamesAreCamelCaseWithFieldUnderscorePrefix, options.ParameterNamesAreCamelCaseWithPUnderscorePrefixAndUnderscoreEndSuffix)); + """, new TestParameters(options: options.MergeStyles(options.FieldNamesAreCamelCaseWithFieldUnderscorePrefix, options.ParameterNamesAreCamelCaseWithPUnderscorePrefixAndUnderscoreEndSuffix))); [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/36741")] public Task TestSpecifiedAndCommonFieldNamingStyle2() @@ -1794,7 +1794,7 @@ public Z(int p_a_End{|Navigation:)|} s_field_a = p_a_End; } } - """, options: options.MergeStyles(options.FieldNamesAreCamelCaseWithFieldUnderscorePrefix, options.ParameterNamesAreCamelCaseWithPUnderscorePrefixAndUnderscoreEndSuffix)); + """, new TestParameters(options: options.MergeStyles(options.FieldNamesAreCamelCaseWithFieldUnderscorePrefix, options.ParameterNamesAreCamelCaseWithPUnderscorePrefixAndUnderscoreEndSuffix))); [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/36741")] public Task TestBaseNameEmpty() @@ -1827,7 +1827,7 @@ public Z(int p_a{|Navigation:)|} s_field_a = p_a; } } - """, options: options.MergeStyles(options.FieldNamesAreCamelCaseWithFieldUnderscorePrefixAndUnderscoreEndSuffix, options.ParameterNamesAreCamelCaseWithPUnderscorePrefix)); + """, new TestParameters(options: options.MergeStyles(options.FieldNamesAreCamelCaseWithFieldUnderscorePrefixAndUnderscoreEndSuffix, options.ParameterNamesAreCamelCaseWithPUnderscorePrefix))); [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/45808")] public Task TestUnsafeField() @@ -1848,7 +1848,7 @@ public unsafe Z(int* a{|Navigation:)|} this.a = a; } } - """, compilationOptions: new CSharpCompilationOptions(OutputKind.DynamicallyLinkedLibrary, allowUnsafe: true)); + """, new TestParameters(compilationOptions: new CSharpCompilationOptions(OutputKind.DynamicallyLinkedLibrary, allowUnsafe: true))); [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/45808")] public Task TestUnsafeFieldInUnsafeClass() @@ -1869,7 +1869,7 @@ public Z(int* a{|Navigation:)|} this.a = a; } } - """, compilationOptions: new CSharpCompilationOptions(OutputKind.DynamicallyLinkedLibrary, allowUnsafe: true)); + """, new TestParameters(compilationOptions: new CSharpCompilationOptions(OutputKind.DynamicallyLinkedLibrary, allowUnsafe: true))); [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/53467")] public Task TestMissingWhenTypeNotInCompilation() diff --git a/src/EditorFeatures/CSharpTest/LanguageServer/CSharpLspBuildOnlyDiagnosticsTests.cs b/src/EditorFeatures/CSharpTest/LanguageServer/CSharpLspBuildOnlyDiagnosticsTests.cs index e9eadcd43526..18ecc18a13c9 100644 --- a/src/EditorFeatures/CSharpTest/LanguageServer/CSharpLspBuildOnlyDiagnosticsTests.cs +++ b/src/EditorFeatures/CSharpTest/LanguageServer/CSharpLspBuildOnlyDiagnosticsTests.cs @@ -21,7 +21,7 @@ protected override ImmutableArray ExpectedDiagnosticCodes { get { - var errorCodes = Enum.GetValues(typeof(ErrorCode)); + var errorCodes = Enum.GetValues(); var supported = new CSharpCompilerDiagnosticAnalyzer().GetSupportedErrorCodes(); var builder = ImmutableArray.CreateBuilder(); foreach (int errorCode in errorCodes) diff --git a/src/EditorFeatures/CSharpTest/MoveToNamespace/MoveToNamespaceTests.cs b/src/EditorFeatures/CSharpTest/MoveToNamespace/MoveToNamespaceTests.cs index 6802398386b2..8833fb388119 100644 --- a/src/EditorFeatures/CSharpTest/MoveToNamespace/MoveToNamespaceTests.cs +++ b/src/EditorFeatures/CSharpTest/MoveToNamespace/MoveToNamespaceTests.cs @@ -174,7 +174,7 @@ void Method() { } } } """, - expectedMarkup: """ + expectedMarkup: """ namespace {|Warning:B|} { class MyClass @@ -730,7 +730,7 @@ namespace A } } """, - expectedMarkup: $$""" + expectedMarkup: $$""" namespace A { {{typeKeyword}} MyType @@ -1295,7 +1295,7 @@ public Task MoveToNamespace_MoveOnlyTypeInGlobalNamespace(string typeKeyword) { } """, - expectedMarkup: $$""" + expectedMarkup: $$""" namespace {|Warning:A|} { {{typeKeyword}} MyType diff --git a/src/EditorFeatures/CSharpTest/ObsoleteSymbol/CSharpObsoleteSymbolTests.cs b/src/EditorFeatures/CSharpTest/ObsoleteSymbol/CSharpObsoleteSymbolTests.cs index c2fc40c10221..0320ccf60e73 100644 --- a/src/EditorFeatures/CSharpTest/ObsoleteSymbol/CSharpObsoleteSymbolTests.cs +++ b/src/EditorFeatures/CSharpTest/ObsoleteSymbol/CSharpObsoleteSymbolTests.cs @@ -2,9 +2,11 @@ // 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.Diagnostics.CodeAnalysis; using System.Threading.Tasks; using Microsoft.CodeAnalysis.Editor.UnitTests.ObsoleteSymbol; using Microsoft.CodeAnalysis.Test.Utilities; +using Roslyn.Test.Utilities; using Xunit; namespace Microsoft.CodeAnalysis.Editor.CSharp.UnitTests.ObsoleteSymbol; @@ -14,6 +16,9 @@ public sealed class CSharpObsoleteSymbolTests : AbstractObsoleteSymbolTests protected override EditorTestWorkspace CreateWorkspace(string markup) => EditorTestWorkspace.CreateCSharp(markup); + private new Task TestAsync([StringSyntax(PredefinedEmbeddedLanguageNames.CSharpTest)] string markup) + => base.TestAsync(markup); + [Theory] [InlineData("class")] [InlineData("struct")] @@ -183,4 +188,15 @@ void Method() } } """); + + [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/79413")] + public Task TestObsoleteFeatureAttribute() + => TestAsync( + """ + [System.Obsolete] + [System.Runtime.CompilerServices.CompilerFeatureRequiredAttribute("This is an obsolete feature.")] + static class ObsoleteType + { + } + """); } diff --git a/src/EditorFeatures/CSharpTest/QuickInfo/SyntacticQuickInfoSourceTests.cs b/src/EditorFeatures/CSharpTest/QuickInfo/SyntacticQuickInfoSourceTests.cs index 26e43ff569eb..e2252eba380c 100644 --- a/src/EditorFeatures/CSharpTest/QuickInfo/SyntacticQuickInfoSourceTests.cs +++ b/src/EditorFeatures/CSharpTest/QuickInfo/SyntacticQuickInfoSourceTests.cs @@ -84,7 +84,7 @@ public Task ScopeBrackets_0() }$$ } """, - "{"); + "{"); [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/325")] public Task ScopeBrackets_1() @@ -260,7 +260,7 @@ int Property } } """, - "{"); + "{"); [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/325")] public Task ScopeBrackets_10() diff --git a/src/EditorFeatures/CSharpTest/Rename/CSharpRenamerTests.cs b/src/EditorFeatures/CSharpTest/Rename/CSharpRenamerTests.cs index 2dd9c882de1d..75b92c850c87 100644 --- a/src/EditorFeatures/CSharpTest/Rename/CSharpRenamerTests.cs +++ b/src/EditorFeatures/CSharpTest/Rename/CSharpRenamerTests.cs @@ -406,10 +406,8 @@ class C2 [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/46580")] public Task CSharp_RenameDocument_MappedDocumentHasNoResults() - { - return TestRenameMappedFile(""" + => TestRenameMappedFile("""

Component1

@code {} """, "Component1.razor", newDocumentName: "MyComponent.razor"); - } } diff --git a/src/EditorFeatures/CSharpTest/Semantics/SpeculationAnalyzerTests.cs b/src/EditorFeatures/CSharpTest/Semantics/SpeculationAnalyzerTests.cs index 78ea0aafe17e..c392d960a922 100644 --- a/src/EditorFeatures/CSharpTest/Semantics/SpeculationAnalyzerTests.cs +++ b/src/EditorFeatures/CSharpTest/Semantics/SpeculationAnalyzerTests.cs @@ -23,8 +23,7 @@ public sealed class SpeculationAnalyzerTests : SpeculationAnalyzerTestsBase { [Fact] public void SpeculationAnalyzerDifferentOverloads() - { - Test(""" + => Test(""" class Program { void Vain(int arg = 3) { } @@ -35,7 +34,6 @@ void Main() } } """, "Vain(string.Empty)", true); - } [Fact, WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/672396")] public void SpeculationAnalyzerExtensionMethodExplicitInvocation() @@ -58,8 +56,7 @@ static void Main() [Fact] public void SpeculationAnalyzerImplicitBaseClassConversion() - { - Test(""" + => Test(""" using System; class Program { @@ -69,12 +66,10 @@ void Main() } } """, "new InvalidOperationException()", false); - } [Fact] public void SpeculationAnalyzerImplicitNumericConversion() - { - Test(""" + => Test(""" class Program { void Main() @@ -83,12 +78,10 @@ void Main() } } """, "5", false); - } [Fact] public void SpeculationAnalyzerImplicitUserConversion() - { - Test(""" + => Test(""" class From { public static implicit operator To(From from) { return new To(); } @@ -102,12 +95,10 @@ void Main() } } """, "new From()", true); - } [Fact] public void SpeculationAnalyzerExplicitConversion() - { - Test(""" + => Test(""" using System; class Program { @@ -118,12 +109,10 @@ void Main() } } """, "ex1", true); - } [Fact] public void SpeculationAnalyzerArrayImplementingNonGenericInterface() - { - Test(""" + => Test(""" using System.Collections; class Program { @@ -134,12 +123,10 @@ void Main() } } """, "a.GetEnumerator()", false); - } [Fact] public void SpeculationAnalyzerVirtualMethodWithBaseConversion() - { - Test(""" + => Test(""" using System; using System.IO; class Program @@ -151,12 +138,10 @@ void Main() } } """, "s.Flush()", false); - } [Fact] public void SpeculationAnalyzerNonVirtualMethodImplementingInterface() - { - Test(""" + => Test(""" using System; class Class : IComparable { @@ -172,12 +157,10 @@ static void Main() } } """, "c.CompareTo(d)", true); - } [Fact] public void SpeculationAnalyzerSealedClassImplementingInterface() - { - Test(""" + => Test(""" using System; sealed class Class : IComparable { @@ -193,12 +176,10 @@ static void Main() } } """, "((IComparable)c).CompareTo(d)", semanticChanges: false); - } [Fact] public void SpeculationAnalyzerValueTypeImplementingInterface() - { - Test(""" + => Test(""" using System; class Program { @@ -209,12 +190,10 @@ void Main() } } """, "d.CompareTo(6)", false); - } [Fact] public void SpeculationAnalyzerBinaryExpressionIntVsLong() - { - Test(""" + => Test(""" class Program { void Main() @@ -223,12 +202,10 @@ void Main() } } """, "1+1", true); - } [Fact] public void SpeculationAnalyzerQueryExpressionSelectType() - { - Test(""" + => Test(""" using System.Linq; class Program { @@ -238,12 +215,10 @@ static void Main(string[] args) } } """, "from i in Enumerable.Range(0, 3) select i", true); - } [Fact] public void SpeculationAnalyzerQueryExpressionFromType() - { - Test(""" + => Test(""" using System.Linq; class Program { @@ -253,12 +228,10 @@ static void Main(string[] args) } } """, "from i in new int[0] select i", true); - } [Fact] public void SpeculationAnalyzerQueryExpressionGroupByType() - { - Test(""" + => Test(""" using System.Linq; class Program { @@ -268,12 +241,10 @@ static void Main(string[] args) } } """, "from i in Enumerable.Range(0, 3) group i by i", true); - } [Fact] public void SpeculationAnalyzerQueryExpressionOrderByType() - { - Test(""" + => Test(""" using System.Linq; class Program { @@ -283,7 +254,6 @@ static void Main(string[] args) } } """, "i", true); - } [Fact] public void SpeculationAnalyzerDifferentAttributeConstructors() @@ -309,8 +279,7 @@ static void Main() { } [Fact] public void SpeculationAnalyzerCollectionInitializers() - { - Test(""" + => Test(""" using System.Collections; class Collection : IEnumerable { @@ -323,12 +292,10 @@ void Main() } } """, "5", true); - } [Fact, WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/1088815")] public void SpeculationAnalyzerBrokenCode() - { - Test(""" + => Test(""" public interface IRogueAction { public string Name { get; private set; } @@ -339,12 +306,10 @@ protected IRogueAction(string name) } } """, "Name", semanticChanges: false, isBrokenCode: true); - } [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/8111")] public void SpeculationAnalyzerAnonymousObjectMemberDeclaredWithNeededCast() - { - Test(""" + => Test(""" class Program { static void Main(string[] args) @@ -354,12 +319,10 @@ static void Main(string[] args) public enum Directions { North, East, South, West } } """, "Directions.South", semanticChanges: true); - } [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/8111")] public void SpeculationAnalyzerAnonymousObjectMemberDeclaredWithUnneededCast() - { - Test(""" + => Test(""" class Program { static void Main(string[] args) @@ -369,12 +332,10 @@ static void Main(string[] args) public enum Directions { North, East, South, West } } """, "Directions.South", semanticChanges: false); - } [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/19987")] public void SpeculationAnalyzerSwitchCaseWithRedundantCast() - { - Test(""" + => Test(""" class Program { static void Main(string[] arts) @@ -393,12 +354,10 @@ static void Main(string[] arts) } } """, "1", semanticChanges: false); - } [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/19987")] public void SpeculationAnalyzerSwitchCaseWithRequiredCast() - { - Test(""" + => Test(""" class Program { static void Main(string[] arts) @@ -417,12 +376,10 @@ static void Main(string[] arts) } } """, "1", semanticChanges: true); - } [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/28412")] public void SpeculationAnalyzerIndexerPropertyWithRedundantCast() - { - Test(code: """ + => Test(code: """ class Indexer { public int this[int x] { get { return x; } } @@ -443,12 +400,10 @@ static void Main(string[] args) } } """, replacementExpression: "b", semanticChanges: false); - } [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/28412")] public void SpeculationAnalyzerIndexerPropertyWithRequiredCast() - { - Test(code: """ + => Test(code: """ class Indexer { public int this[int x] { get { return x; } } @@ -470,12 +425,10 @@ static void Main(string[] args) } } """, replacementExpression: "b", semanticChanges: true); - } [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/28412")] public void SpeculationAnalyzerDelegatePropertyWithRedundantCast() - { - Test(code: """ + => Test(code: """ public delegate void MyDelegate(); class A { @@ -493,12 +446,10 @@ static void Main(string[] args) } } """, replacementExpression: "b", semanticChanges: false); - } [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/28412")] public void SpeculationAnalyzerDelegatePropertyWithRequiredCast() - { - Test(code: """ + => Test(code: """ public delegate void MyDelegate(); class A { @@ -517,7 +468,6 @@ static void Main(string[] args) } } """, replacementExpression: "b", semanticChanges: true); - } protected override SyntaxTree Parse(string text) => SyntaxFactory.ParseSyntaxTree(text); diff --git a/src/EditorFeatures/CSharpTest/SplitComment/SplitCommentCommandHandlerTests.cs b/src/EditorFeatures/CSharpTest/SplitComment/SplitCommentCommandHandlerTests.cs index 0d717ad8a3cd..056e94b8ffaf 100644 --- a/src/EditorFeatures/CSharpTest/SplitComment/SplitCommentCommandHandlerTests.cs +++ b/src/EditorFeatures/CSharpTest/SplitComment/SplitCommentCommandHandlerTests.cs @@ -18,8 +18,7 @@ protected override EditorTestWorkspace CreateWorkspace(string markup) [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/38516")] public void TestWithSelection() - { - TestHandled( + => TestHandled( """ public class Program { @@ -39,12 +38,10 @@ public static void Main(string[] args) } } """); - } [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/38516")] public void TestWithAllWhitespaceSelection() - { - TestHandled( + => TestHandled( """ public class Program { @@ -64,12 +61,10 @@ public static void Main(string[] args) } } """); - } [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/38516")] public void TestMissingInSlashes() - { - TestNotHandled( + => TestNotHandled( """ public class Program { @@ -79,12 +74,10 @@ public static void Main(string[] args) } } """); - } [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/38516")] public void TestMissingAtEndOfFile() - { - TestNotHandled( + => TestNotHandled( """ public class Program { @@ -92,12 +85,10 @@ public static void Main(string[] args) { //Test Comment[||] """); - } [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/38516")] public void TestMissingBeforeSlashes() - { - TestNotHandled( + => TestNotHandled( """ public class Program { @@ -107,12 +98,10 @@ public static void Main(string[] args) } } """); - } [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/38516")] public void TestMissingWithMultiSelection() - { - TestNotHandled( + => TestNotHandled( """ public class Program { @@ -122,12 +111,10 @@ public static void Main(string[] args) } } """); - } [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/38516")] public void TestSplitStartOfComment() - { - TestHandled( + => TestHandled( """ public class Program { @@ -147,12 +134,10 @@ public static void Main(string[] args) } } """); - } [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/38516")] public void TestSplitStartOfQuadComment() - { - TestHandled( + => TestHandled( """ public class Program { @@ -172,13 +157,11 @@ public static void Main(string[] args) } } """); - } [WorkItem("https://github.com/dotnet/roslyn/issues/38516")] [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/48547")] public void TestSplitMiddleOfQuadComment() - { - TestNotHandled( + => TestNotHandled( """ public class Program { @@ -188,12 +171,10 @@ public static void Main(string[] args) } } """); - } [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/48547")] public void TestSplitWithCommentAfterwards1() - { - TestNotHandled( + => TestNotHandled( """ public class Program { @@ -203,12 +184,10 @@ public static void Main(string[] args) } } """); - } [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/48547")] public void TestSplitWithCommentAfterwards2() - { - TestNotHandled( + => TestNotHandled( """ public class Program { @@ -218,12 +197,10 @@ public static void Main(string[] args) } } """); - } [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/48547")] public void TestSplitWithCommentAfterwards3() - { - TestNotHandled( + => TestNotHandled( """ public class Program { @@ -233,12 +210,10 @@ public static void Main(string[] args) } } """); - } [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/48547")] public void TestSplitWithCommentAfterwards4() - { - TestNotHandled( + => TestNotHandled( """ public class Program { @@ -248,12 +223,10 @@ public static void Main(string[] args) } } """); - } [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/38516")] public void TestSplitStartOfCommentWithLeadingSpace1() - { - TestHandled( + => TestHandled( """ public class Program { @@ -273,12 +246,10 @@ public static void Main(string[] args) } } """); - } [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/38516")] public void TestSplitStartOfCommentWithLeadingSpace2() - { - TestHandled( + => TestHandled( """ public class Program { @@ -298,7 +269,6 @@ public static void Main(string[] args) } } """); - } [WorkItem("https://github.com/dotnet/roslyn/issues/38516")] [WpfTheory] @@ -307,8 +277,7 @@ public static void Main(string[] args) [InlineData("X[||] Test Comment")] [InlineData("X [||] Test Comment")] public void TestCommentWithMultipleLeadingSpaces(string commentValue) - { - TestHandled( + => TestHandled( $$""" public class Program { @@ -318,17 +287,16 @@ public static void Main(string[] args) } } """, -""" -public class Program -{ - public static void Main(string[] args) - { - // X - // Test Comment - } -} -"""); - } + """ + public class Program + { + public static void Main(string[] args) + { + // X + // Test Comment + } + } + """); [WorkItem("https://github.com/dotnet/roslyn/issues/38516")] [WpfTheory] @@ -338,8 +306,7 @@ public static void Main(string[] args) [InlineData("X [||] Test Comment")] [InlineData("X[| |]Test Comment")] public void TestQuadCommentWithMultipleLeadingSpaces(string commentValue) - { - TestHandled( + => TestHandled( $$""" public class Program { @@ -349,22 +316,20 @@ public static void Main(string[] args) } } """, -""" -public class Program -{ - public static void Main(string[] args) - { - //// X - //// Test Comment - } -} -"""); - } + """ + public class Program + { + public static void Main(string[] args) + { + //// X + //// Test Comment + } + } + """); [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/38516")] public void TestSplitMiddleOfComment() - { - TestHandled( + => TestHandled( """ public class Program { @@ -384,12 +349,10 @@ public static void Main(string[] args) } } """); - } [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/38516")] public void TestSplitEndOfComment() - { - TestNotHandled( + => TestNotHandled( """ public class Program { @@ -399,12 +362,10 @@ public static void Main(string[] args) } } """); - } [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/38516")] public void TestSplitCommentEndOfLine1() - { - TestHandled( + => TestHandled( """ public class Program { @@ -422,12 +383,10 @@ public static void Main(string[] args) // Test } } """); - } [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/38516")] public void TestSplitCommentEndOfLine2() - { - TestHandled( + => TestHandled( """ public class Program { @@ -445,12 +404,10 @@ public static void Main(string[] args) // Test } } """); - } [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/38516")] public void TestUseTabs() - { - TestHandled( + => TestHandled( """ public class Program { @@ -470,12 +427,10 @@ public static void Main(string[] args) } } """, useTabs: true); - } [WpfFact] public void TestDoesNotHandleDocComments() - { - TestNotHandled( + => TestNotHandled( """ namespace TestNamespace { @@ -488,5 +443,4 @@ public static void Main(string[] args) } } """); - } } diff --git a/src/EditorFeatures/CSharpTest/SplitStringLiteral/SplitStringLiteralCommandHandlerTests.cs b/src/EditorFeatures/CSharpTest/SplitStringLiteral/SplitStringLiteralCommandHandlerTests.cs index a719c07fb9f0..8a11a9461177 100644 --- a/src/EditorFeatures/CSharpTest/SplitStringLiteral/SplitStringLiteralCommandHandlerTests.cs +++ b/src/EditorFeatures/CSharpTest/SplitStringLiteral/SplitStringLiteralCommandHandlerTests.cs @@ -150,8 +150,7 @@ private static void TestNotHandled(string inputMarkup) [WpfFact] public void TestMissingBeforeString() - { - TestNotHandled( + => TestNotHandled( """ class C { @@ -161,12 +160,10 @@ void M() } } """); - } [WpfFact] public void TestMissingBeforeUtf8String() - { - TestNotHandled( + => TestNotHandled( """ class C { @@ -176,12 +173,10 @@ void M() } } """); - } [WpfFact] public void TestMissingBeforeInterpolatedString() - { - TestNotHandled( + => TestNotHandled( """ class C { @@ -191,12 +186,10 @@ void M() } } """); - } [WpfFact] public void TestMissingAfterString_1() - { - TestNotHandled( + => TestNotHandled( """ class C { @@ -206,12 +199,10 @@ void M() } } """); - } [WpfFact] public void TestMissingAfterString_2() - { - TestNotHandled( + => TestNotHandled( """ class C { @@ -221,12 +212,10 @@ void M() } } """); - } [WpfFact] public void TestMissingAfterString_3() - { - TestNotHandled( + => TestNotHandled( """ class C { @@ -236,12 +225,10 @@ void M() } } """); - } [WpfFact] public void TestMissingAfterString_4() - { - TestNotHandled( + => TestNotHandled( """ class C { @@ -251,12 +238,10 @@ void M() } } """); - } [WpfFact] public void TestMissingAfterInterpolatedString_1() - { - TestNotHandled( + => TestNotHandled( """ class C { @@ -266,12 +251,10 @@ void M() } } """); - } [WpfFact] public void TestMissingAfterInterpolatedString_2() - { - TestNotHandled( + => TestNotHandled( """ class C { @@ -281,12 +264,10 @@ void M() } } """); - } [WpfFact] public void TestMissingAfterInterpolatedString_3() - { - TestNotHandled( + => TestNotHandled( """ class C { @@ -296,12 +277,10 @@ void M() } } """); - } [WpfFact] public void TestMissingAfterInterpolatedString_4() - { - TestNotHandled( + => TestNotHandled( """ class C { @@ -311,12 +290,10 @@ void M() } } """); - } [WpfFact] public void TestMissingAfterUtf8String_1() - { - TestNotHandled( + => TestNotHandled( """ class C { @@ -326,12 +303,10 @@ void M() } } """); - } [WpfFact] public void TestMissingAfterUtf8String_2() - { - TestNotHandled( + => TestNotHandled( """ class C { @@ -341,12 +316,10 @@ void M() } } """); - } [WpfFact] public void TestMissingAfterUtf8String_3() - { - TestNotHandled( + => TestNotHandled( """ class C { @@ -356,12 +329,10 @@ void M() } } """); - } [WpfFact] public void TestMissingAfterUtf8String_4() - { - TestNotHandled( + => TestNotHandled( """ class C { @@ -371,12 +342,10 @@ void M() } } """); - } [WpfFact] public void TestMissingAfterUtf8String_5() - { - TestNotHandled( + => TestNotHandled( """ class C { @@ -386,12 +355,10 @@ void M() } } """); - } [WpfFact] public void TestMissingInVerbatimString() - { - TestNotHandled( + => TestNotHandled( """ class C { @@ -401,12 +368,10 @@ void M() } } """); - } [WpfFact] public void TestMissingInUtf8VerbatimString() - { - TestNotHandled( + => TestNotHandled( """ class C { @@ -416,12 +381,10 @@ void M() } } """); - } [WpfFact] public void TestMissingInInterpolatedVerbatimString() - { - TestNotHandled( + => TestNotHandled( """ class C { @@ -431,7 +394,6 @@ void M() } } """); - } [WpfFact] public void TestInEmptyString() @@ -458,7 +420,7 @@ void M() } } """, - verifyUndo: false); + verifyUndo: false); } [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/41322")] @@ -467,8 +429,8 @@ public void TestInEmptyString_LF() // Do not verifyUndo because of https://github.com/dotnet/roslyn/issues/28033 // When that issue is fixed, we can reenable verifyUndo TestHandled( -"class C\n{\n void M()\n {\n var v = \"[||]\";\n }\n}", -"class C\n{\n void M()\n {\n var v = \"\" +\n \"[||]\";\n }\n}", + "class C\n{\n void M()\n {\n var v = \"[||]\";\n }\n}", + "class C\n{\n void M()\n {\n var v = \"\" +\n \"[||]\";\n }\n}", verifyUndo: false, endOfLine: "\n"); } @@ -498,8 +460,8 @@ void M() } } """, - verifyUndo: false, - IndentStyle.Block); + verifyUndo: false, + IndentStyle.Block); } [WpfFact] @@ -527,14 +489,13 @@ void M() } } """, - verifyUndo: false, - IndentStyle.None); + verifyUndo: false, + IndentStyle.None); } [WpfFact] public void TestInEmptyInterpolatedString() - { - TestHandled( + => TestHandled( """ class C { @@ -554,21 +515,17 @@ void M() } } """); - } [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/41322")] public void TestInEmptyInterpolatedString_LF() - { - TestHandled( + => TestHandled( "class C\n{\n void M()\n {\n var v = $\"[||]\";\n }\n}", "class C\n{\n void M()\n {\n var v = $\"\" +\n $\"[||]\";\n }\n}", endOfLine: "\n"); - } [WpfFact] public void TestInEmptyInterpolatedString_BlockIndent() - { - TestHandled( + => TestHandled( """ class C { @@ -588,12 +545,10 @@ void M() } } """, indentStyle: IndentStyle.Block); - } [WpfFact] public void TestInEmptyInterpolatedString_NoneIndent() - { - TestHandled( + => TestHandled( """ class C { @@ -613,12 +568,10 @@ void M() } } """, indentStyle: IndentStyle.None); - } [WpfFact] public void TestSimpleString1() - { - TestHandled( + => TestHandled( """ class C { @@ -638,12 +591,10 @@ void M() } } """); - } [WpfFact] public void TestUtf8String_1() - { - TestHandled( + => TestHandled( """ class C { @@ -663,12 +614,10 @@ void M() } } """); - } [WpfFact] public void TestUtf8String_2() - { - TestHandled( + => TestHandled( """ class C { @@ -688,12 +637,10 @@ void M() } } """); - } [WpfFact] public void TestInterpolatedString1() - { - TestHandled( + => TestHandled( """ class C { @@ -713,12 +660,10 @@ void M() } } """); - } [WpfFact] public void TestInterpolatedString2() - { - TestHandled( + => TestHandled( """ class C { @@ -738,12 +683,10 @@ void M() } } """); - } [WpfFact] public void TestInterpolatedString3() - { - TestHandled( + => TestHandled( """ class C { @@ -763,12 +706,10 @@ void M() } } """); - } [WpfFact] public void TestMissingInInterpolation1() - { - TestNotHandled( + => TestNotHandled( """ class C { @@ -778,12 +719,10 @@ void M() } } """); - } [WpfFact] public void TestMissingInInterpolation2() - { - TestNotHandled( + => TestNotHandled( """ class C { @@ -793,12 +732,10 @@ void M() } } """); - } [WpfFact] public void TestSelection() - { - TestNotHandled( + => TestNotHandled( """ class C { @@ -808,7 +745,6 @@ void M() } } """); - } [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/20258")] public void TestBeforeEndQuote1() @@ -847,7 +783,7 @@ static void Main(string[] args) } } """, - verifyUndo: false); + verifyUndo: false); } [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/20258")] @@ -887,7 +823,7 @@ static void Main(string[] args) } } """, - verifyUndo: false); + verifyUndo: false); } [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/20258")] @@ -927,7 +863,7 @@ static void Main(string[] args) } } """, - verifyUndo: false); + verifyUndo: false); } [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/20258")] @@ -967,7 +903,7 @@ static void Main(string[] args) } } """, - verifyUndo: false); + verifyUndo: false); } [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/20258")] @@ -1007,7 +943,7 @@ static void Main(string[] args) } } """, - verifyUndo: false); + verifyUndo: false); } [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/20258")] @@ -1047,13 +983,12 @@ static void Main(string[] args) } } """, - verifyUndo: false); + verifyUndo: false); } [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/39040")] public void TestMultiCaretSingleLine() - { - TestHandled( + => TestHandled( """ class C { @@ -1074,12 +1009,10 @@ void M() } } """); - } [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/39040")] public void TestMultiCaretMultiLines() - { - TestHandled( + => TestHandled( """ class C { @@ -1105,12 +1038,10 @@ void M() } } """); - } [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/39040")] public void TestMultiCaretInterpolatedString() - { - TestHandled( + => TestHandled( """ class C { @@ -1137,12 +1068,10 @@ void M() } } """); - } [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/40277")] public void TestInStringWithKeepTabsEnabled1() - { - TestHandled( + => TestHandled( """ class C { @@ -1162,13 +1091,11 @@ void M() } } """, - useTabs: true); - } + useTabs: true); [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/40277")] public void TestInStringWithKeepTabsEnabled2() - { - TestHandled( + => TestHandled( """ class C { @@ -1190,13 +1117,11 @@ void M() } } """, - useTabs: true); - } + useTabs: true); [WpfFact] public void TestMissingInRawStringLiteral() - { - TestNotHandled( + => TestNotHandled( """" class C { @@ -1208,12 +1133,10 @@ void M() } } """"); - } [WpfFact] public void TestMissingInRawStringLiteralInterpolation() - { - TestNotHandled( + => TestNotHandled( """" class C { @@ -1225,12 +1148,10 @@ void M() } } """"); - } [WpfFact] public void TestMissingInRawStringLiteralInterpolation_MultiBrace() - { - TestNotHandled( + => TestNotHandled( """" class C { @@ -1242,12 +1163,10 @@ void M() } } """"); - } [WpfFact] public void TestMissingInRawUtf8StringLiteral() - { - TestNotHandled( + => TestNotHandled( """" class C { @@ -1259,5 +1178,4 @@ void M() } } """"); - } } diff --git a/src/EditorFeatures/CSharpTest/StringCopyPaste/PasteKnownSourceIntoMultiLineRawInterpolatedStringTests.cs b/src/EditorFeatures/CSharpTest/StringCopyPaste/PasteKnownSourceIntoMultiLineRawInterpolatedStringTests.cs index 798e672b8eef..8fc5865c0213 100644 --- a/src/EditorFeatures/CSharpTest/StringCopyPaste/PasteKnownSourceIntoMultiLineRawInterpolatedStringTests.cs +++ b/src/EditorFeatures/CSharpTest/StringCopyPaste/PasteKnownSourceIntoMultiLineRawInterpolatedStringTests.cs @@ -14,8 +14,7 @@ public sealed class PasteKnownSourceIntoMultiLineRawInterpolatedStringTests : St [WpfFact] public void TestPasteSimpleNormalLiteralContent() - { - TestCopyPaste( + => TestCopyPaste( """var v = "{|Copy:goo|}";""", """" var dest = @@ -35,12 +34,10 @@ public void TestPasteSimpleNormalLiteralContent() [||] """; """"); - } [WpfFact] public void TestPasteOpenBraceNormalLiteralContent() - { - TestCopyPaste( + => TestCopyPaste( """var v = "{|Copy:{|}";""", """" var dest = @@ -60,12 +57,10 @@ public void TestPasteOpenBraceNormalLiteralContent() {[||] """; """"); - } [WpfFact] public void TestPasteOpenCloseBraceNormalLiteralContent() - { - TestCopyPaste( + => TestCopyPaste( """var v = "{|Copy:{}|}";""", """" var dest = @@ -85,12 +80,10 @@ public void TestPasteOpenCloseBraceNormalLiteralContent() {}[||] """; """"); - } [WpfFact] public void TestPasteLooksLikeInterpolationNormalLiteralContent() - { - TestCopyPaste( + => TestCopyPaste( """var v = "{|Copy:{0}|}";""", """" var dest = @@ -110,12 +103,10 @@ public void TestPasteLooksLikeInterpolationNormalLiteralContent() {0}[||] """; """"); - } [WpfFact] public void TestPasteSimpleSubstringNormalLiteralContent() - { - TestCopyPaste( + => TestCopyPaste( """var v = "g{|Copy:o|}o";""", """" var dest = @@ -135,12 +126,10 @@ public void TestPasteSimpleSubstringNormalLiteralContent() [||] """; """"); - } [WpfFact] public void TestPastePartiallySelectedEscapeNormalLiteralContent() - { - TestCopyPaste( + => TestCopyPaste( """var v = "\{|Copy:n|}";""", """" var dest = @@ -160,12 +149,10 @@ public void TestPastePartiallySelectedEscapeNormalLiteralContent() [||] """; """"); - } [WpfFact] public void TestPasteFullySelectedEscapeNormalLiteralContent() - { - TestCopyPaste( + => TestCopyPaste( @"var v = ""{|Copy:\n|}"";", """" var dest = @@ -180,12 +167,10 @@ public void TestPasteFullySelectedEscapeNormalLiteralContent() \n[||] """; """"); - } [WpfFact] public void TestPastePartiallySelectedQuoteNormalLiteralContent() - { - TestCopyPaste( + => TestCopyPaste( """var v = "\{|Copy:"|}";""", """" var dest = @@ -205,12 +190,10 @@ public void TestPastePartiallySelectedQuoteNormalLiteralContent() [||] """; """"); - } [WpfFact] public void TestPasteFullySelectedQuoteNormalLiteralContent() - { - TestCopyPaste( + => TestCopyPaste( """var v = "{|Copy:\"|}";""", """" var dest = @@ -230,12 +213,10 @@ public void TestPasteFullySelectedQuoteNormalLiteralContent() \"[||] """; """"); - } [WpfFact] public void TestPasteSimpleVerbatimLiteralContent() - { - TestCopyPaste( + => TestCopyPaste( """var v = @"{|Copy:goo|}";""", """" var dest = @@ -255,12 +236,10 @@ public void TestPasteSimpleVerbatimLiteralContent() [||] """; """"); - } [WpfFact] public void TestPasteSimpleSubstringVerbatimLiteralContent() - { - TestCopyPaste( + => TestCopyPaste( """var v = @"g{|Copy:o|}o";""", """" var dest = @@ -280,12 +259,10 @@ public void TestPasteSimpleSubstringVerbatimLiteralContent() [||] """; """"); - } [WpfFact] public void TestPasteSelectedVerbatimNewLineLiteralContent() - { - TestCopyPaste( + => TestCopyPaste( """ var v = @"{|Copy: |}"; @@ -310,12 +287,10 @@ public void TestPasteSelectedVerbatimNewLineLiteralContent() [||] """; """"); - } [WpfFact] public void TestPasteFullySelectedEscapeVerbatimLiteralContent() - { - TestCopyPaste( + => TestCopyPaste( """var v = @"{|Copy:""|}";""", """" var dest = @@ -335,12 +310,10 @@ public void TestPasteFullySelectedEscapeVerbatimLiteralContent() ""[||] """; """"); - } [WpfFact] public void TestPasteSimpleRawSingleLineLiteralContent() - { - TestCopyPaste( + => TestCopyPaste( """"var v = """{|Copy:goo|}""";"""", """" var dest = @@ -360,12 +333,10 @@ public void TestPasteSimpleRawSingleLineLiteralContent() [||] """; """"); - } [WpfFact] public void TestPasteQuotesRawSingleLineLiteralContent() - { - TestCopyPaste( + => TestCopyPaste( """"var v = """{|Copy: "" |}""";"""", """" var dest = @@ -385,12 +356,10 @@ public void TestPasteQuotesRawSingleLineLiteralContent() [||] """; """"); - } [WpfFact] public void TestPasteSimpleRawMultiLineLiteralContent1() - { - TestCopyPaste( + => TestCopyPaste( """" var v = """ {|Copy:goo|} @@ -414,12 +383,10 @@ public void TestPasteSimpleRawMultiLineLiteralContent1() [||] """; """"); - } [WpfFact] public void TestPasteSimpleRawMultiLineLiteralContent2() - { - TestCopyPaste( + => TestCopyPaste( """" var v = """ {|Copy:goo @@ -445,12 +412,10 @@ public void TestPasteSimpleRawMultiLineLiteralContent2() [||] """; """"); - } [WpfFact] public void TestPasteSimpleRawMultiLineLiteralContent3() - { - TestCopyPaste( + => TestCopyPaste( """" var v = """ {|Copy: goo @@ -477,12 +442,10 @@ public void TestPasteSimpleRawMultiLineLiteralContent3() bar[||] """; """"); - } [WpfFact] public void TestPasteInterpolationWithFormatClauseFromInterpolatedStringLiteralContent1() - { - TestCopyPaste( + => TestCopyPaste( """var v = $"{|Copy:{0:X}|}";""", """" var dest = @@ -502,12 +465,10 @@ public void TestPasteInterpolationWithFormatClauseFromInterpolatedStringLiteralC [||] """; """"); - } [WpfFact] public void TestPasteInterpolationWithFormatClauseFromInterpolatedStringLiteralContent2() - { - TestCopyPaste( + => TestCopyPaste( """var v = $"{|Copy:{0:\"X\"}|}";""", """" var dest = @@ -527,12 +488,10 @@ public void TestPasteInterpolationWithFormatClauseFromInterpolatedStringLiteralC {0:\"X\"}[||] """; """"); - } [WpfFact] public void TestPasteInterpolationWithFormatClauseFromVerbatimInterpolatedStringLiteralContent1() - { - TestCopyPaste( + => TestCopyPaste( """var v = $@"{|Copy:{0:X}|}";""", """" var dest = @@ -552,12 +511,10 @@ public void TestPasteInterpolationWithFormatClauseFromVerbatimInterpolatedString [||] """; """"); - } [WpfFact] public void TestPasteInterpolationWithFormatClauseFromVerbatimInterpolatedStringLiteralContent2() - { - TestCopyPaste( + => TestCopyPaste( """var v = $@"{|Copy:{0:""X""}|}";""", """" var dest = @@ -577,12 +534,10 @@ public void TestPasteInterpolationWithFormatClauseFromVerbatimInterpolatedString {0:""X""}[||] """; """"); - } [WpfFact] public void TestPasteInterpolationIntoSelection1() - { - TestCopyPaste( + => TestCopyPaste( """var v = $@"{|Copy:{0}|}";""", """" var dest = @@ -603,12 +558,10 @@ public void TestPasteInterpolationIntoSelection1() """; """"); - } [WpfFact] public void TestPasteInterpolationIntoSelection2() - { - TestCopyPaste( + => TestCopyPaste( """var v = $@"{|Copy:{0}|}";""", """" var dest = @@ -627,12 +580,10 @@ public void TestPasteInterpolationIntoSelection2() $"""{0}[||] """; """"); - } [WpfFact] public void TestPasteInterpolationIntoSelection3() - { - TestCopyPaste( + => TestCopyPaste( """var v = $@"{|Copy:{0}|}";""", """" var dest = @@ -651,12 +602,10 @@ public void TestPasteInterpolationIntoSelection3() $"""{0}[||] """; """"); - } [WpfFact] public void TestPasteInterpolationIntoSelection4() - { - TestCopyPaste( + => TestCopyPaste( """var v = $@"{|Copy:{0}|}";""", """" var dest = @@ -675,12 +624,10 @@ public void TestPasteInterpolationIntoSelection4() $"""{0}[||] """; """"); - } [WpfFact] public void TestPasteInterpolationIntoSelection5() - { - TestCopyPaste( + => TestCopyPaste( """var v = $@"{|Copy:{0}|}";""", """" var dest = @@ -698,12 +645,10 @@ public void TestPasteInterpolationIntoSelection5() var dest = $"""{0}[||] """; """"); - } [WpfFact] public void TestPasteInterpolationIntoSelection6() - { - TestCopyPaste( + => TestCopyPaste( """var v = $@"{|Copy:{0}|}";""", """" var dest = @@ -721,12 +666,10 @@ public void TestPasteInterpolationIntoSelection6() var dest = $"""{0}[||] """; """"); - } [WpfFact] public void TestPasteInterpolationIntoSelection7() - { - TestCopyPaste( + => TestCopyPaste( """var v = $@"{|Copy:{0}|}";""", """" var dest = @@ -744,12 +687,10 @@ public void TestPasteInterpolationIntoSelection7() var dest = $"""{0}[||]"""; """"); - } [WpfFact] public void TestPasteInterpolationIntoSelection8() - { - TestCopyPaste( + => TestCopyPaste( """var v = $@"{|Copy:{0}|}";""", """" var dest = @@ -769,12 +710,10 @@ public void TestPasteInterpolationIntoSelection8() {0}[||] """; """"); - } [WpfFact] public void TestPasteInterpolationIntoSelection9() - { - TestCopyPaste( + => TestCopyPaste( """var v = $@"{|Copy:{0}|}";""", """" var dest = @@ -794,12 +733,10 @@ public void TestPasteInterpolationIntoSelection9() {0}[||] """; """"); - } [WpfFact] public void TestPasteInterpolationIntoSelection10() - { - TestCopyPaste( + => TestCopyPaste( """var v = $@"{|Copy:{0}|}";""", """" var dest = @@ -819,12 +756,10 @@ public void TestPasteInterpolationIntoSelection10() {0}[||] """; """"); - } [WpfFact] public void TestPasteInterpolationIntoSelection11() - { - TestCopyPaste( + => TestCopyPaste( """var v = $@"{|Copy:{0}|}";""", """" var dest = @@ -843,12 +778,10 @@ public void TestPasteInterpolationIntoSelection11() $""" {0}[||] """; """"); - } [WpfFact] public void TestPasteInterpolationIntoSelection12() - { - TestCopyPaste( + => TestCopyPaste( """var v = $@"{|Copy:{0}|}";""", """" var dest = @@ -867,12 +800,10 @@ public void TestPasteInterpolationIntoSelection12() $""" {0}[||] """; """"); - } [WpfFact] public void TestPasteInterpolationIntoSelection13() - { - TestCopyPaste( + => TestCopyPaste( """var v = $@"{|Copy:{0}|}";""", """" var dest = @@ -891,7 +822,6 @@ public void TestPasteInterpolationIntoSelection13() $""" {0}[||]"""; """"); - } #endregion @@ -902,8 +832,7 @@ public void TestPasteInterpolationIntoSelection13() [WpfFact] public void TestPasteBracesWithExistingInterpolation1() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """{{{""", """" var dest = @@ -923,12 +852,10 @@ public void TestPasteBracesWithExistingInterpolation1() {{{[||]{0} """; """"); - } [WpfFact] public void TestPasteBracesWithExistingInterpolation2() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """{{{""", """" var dest = @@ -948,12 +875,10 @@ public void TestPasteBracesWithExistingInterpolation2() {0}{{{[||] """; """"); - } [WpfFact] public void TestPasteBracesWithExistingInterpolation3() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """{{{""", """" var dest = @@ -973,12 +898,10 @@ public void TestPasteBracesWithExistingInterpolation3() {0}{{{[||]{1} """; """"); - } [WpfFact] public void TestPasteBracesWithExistingInterpolation4() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """{{{""", """" var dest = @@ -998,1070 +921,985 @@ public void TestPasteBracesWithExistingInterpolation4() {0}{{{[||]{2} """; """"); - } [WpfFact] public void TestNewLineIntoSingleLineRawString1_A() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: "\n", -"""" -var x = $""" - [||] - """ -"""", -"var x = $\"\"\"\r\n \n [||]\r\n \"\"\"", + """" + var x = $""" + [||] + """ + """", + "var x = $\"\"\"\r\n \n [||]\r\n \"\"\"", afterUndo: -"var x = $\"\"\"\r\n \n[||]\r\n \"\"\""); - } + "var x = $\"\"\"\r\n \n[||]\r\n \"\"\""); [WpfFact] public void TestNewLineIntoSingleLineRawString2_A() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """ """, -"""" -var x = $""" - [||] - """ -"""", -"""" -var x = $""" - - [||] - """ -"""", + """" + var x = $""" + [||] + """ + """", + """" + var x = $""" + + [||] + """ + """", afterUndo: -"""" -var x = $""" - -[||] - """ -""""); - } + """" + var x = $""" + + [||] + """ + """"); [WpfFact] public void TestSpacesIntoSingleLineRawString1_A() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """ """, -"""" -var x = $""" - [||] - """ -"""", -"""" -var x = $""" - [||] - """ -"""", + """" + var x = $""" + [||] + """ + """", + """" + var x = $""" + [||] + """ + """", afterUndo: -"""" -var x = $""" - [||] - """ -""""); - } + """" + var x = $""" + [||] + """ + """"); [WpfFact] public void TestSpacesIntoSingleLineRawString2() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """ """, -"""" -var x = $""" - [||] - """ -"""", -"""" -var x = $""" - - [||] - """ -"""", + """" + var x = $""" + [||] + """ + """", + """" + var x = $""" + + [||] + """ + """", afterUndo: -"""" -var x = $""" - -[||] - """ -""""); - } + """" + var x = $""" + + [||] + """ + """"); [WpfFact] public void TestSingleQuoteIntoSingleLineRawString_A() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """'""", -"""" -var x = $""" - [||] - """ -"""", -"""" -var x = $""" - '[||] - """ -"""", + """" + var x = $""" + [||] + """ + """", + """" + var x = $""" + '[||] + """ + """", afterUndo: -"""" -var x = $""" - [||] - """ -""""); - } + """" + var x = $""" + [||] + """ + """"); [WpfFact] public void TestDoubleQuoteIntoSingleLineRawString_A() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """ " """, -"""" -var x = $"""[||] """ -"""", -"""" -var x = $""" - "[||] - """ -"""", + """" + var x = $"""[||] """ + """", + """" + var x = $""" + "[||] + """ + """", afterUndo: -""""" -var x = $""""[||] """ -"""""); - } + """"" + var x = $""""[||] """ + """""); [WpfFact] public void TestTripleQuoteIntoSingleLineRawString1_A() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """" """ """", -"""" -var x = $"""[||] """ -"""", -""""" -var x = $"""" - """[||] - """" -""""", + """" + var x = $"""[||] """ + """", + """"" + var x = $"""" + """[||] + """" + """"", afterUndo: -""""""" -var x = $""""""[||] """ -"""""""); - } + """"""" + var x = $""""""[||] """ + """""""); [WpfFact] public void TestTripleQuoteIntoSingleLineRawString3() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """" """ """", -"""" -var x = $""" - "[||] - """ -"""", -"""""" -var x = $""""" - """"[||] - """"" -"""""", + """" + var x = $""" + "[||] + """ + """", + """""" + var x = $""""" + """"[||] + """"" + """""", afterUndo: -""""" -var x = $""" - """"[||] - """ -"""""); - } + """"" + var x = $""" + """"[||] + """ + """""); [WpfFact] public void TestTripleQuoteIntoSingleLineRawString4() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """" """ """", -"""" -var x = $""" - "[||]" - """ -"""", -""""""" -var x = $"""""" - """"[||]" - """""" -""""""", + """" + var x = $""" + "[||]" + """ + """", + """"""" + var x = $"""""" + """"[||]" + """""" + """"""", afterUndo: -""""" -var x = $""" - """"[||]" - """ -"""""); - } + """"" + var x = $""" + """"[||]" + """ + """""); [WpfFact] public void TestTripleQuoteIntoSingleLineRawString5() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """" """ """", -"""" -var x = $""" - [||]" - """ -"""", -"""""" -var x = $""""" - """[||]" - """"" -"""""", + """" + var x = $""" + [||]" + """ + """", + """""" + var x = $""""" + """[||]" + """"" + """""", afterUndo: -"""" -var x = $""" - """[||]" - """ -""""); - } + """" + var x = $""" + """[||]" + """ + """"); [WpfFact] public void TestQuadrupleQuoteIntoSingleLineRawString() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """"" """" """"", -"""" -var x = $""" - [||] - """ -"""", -"""""" -var x = $""""" - """"[||] - """"" -"""""", + """" + var x = $""" + [||] + """ + """", + """""" + var x = $""""" + """"[||] + """"" + """""", afterUndo: -""""" -var x = $""" - """"[||] - """ -"""""); - } + """"" + var x = $""" + """"[||] + """ + """""); [WpfFact] public void TestOpenCurlyIntoSingleLineRawString_A() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """{""", -"""" -var x = $""" - [||] - """ -"""", -"""" -var x = $$""" - {[||] - """ -"""", + """" + var x = $""" + [||] + """ + """", + """" + var x = $$""" + {[||] + """ + """", afterUndo: -"""" -var x = $""" - {[||] - """ -""""); - } + """" + var x = $""" + {[||] + """ + """"); [WpfFact] public void TestOpenQuoteAndTripleOpenBraceIntoSingleLineRawString1() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """ "{{{ """, -"""" -var x = $""" - [||] - """ -"""", -"""" -var x = $$$$""" - "{{{[||] - """ -"""", + """" + var x = $""" + [||] + """ + """", + """" + var x = $$$$""" + "{{{[||] + """ + """", afterUndo: -"""" -var x = $""" - "{{{[||] - """ -""""); - } + """" + var x = $""" + "{{{[||] + """ + """"); [WpfFact] public void TestTripleOpenQuoteAndTripleOpenBraceIntoSingleLineRawString1() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """" """{{{ """", -"""" -var x = $""" - [||] - """ -"""", -""""" -var x = $$$$"""" - """{{{[||] - """" -""""", + """" + var x = $""" + [||] + """ + """", + """"" + var x = $$$$"""" + """{{{[||] + """" + """"", afterUndo: -"""" -var x = $""" - """{{{[||] - """ -""""); - } + """" + var x = $""" + """{{{[||] + """ + """"); [WpfFact] public void TestTripleOpenQuoteAndTripleOpenBraceIntoSingleLineRawString2() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """" """{{{"""", -"""" -var x = $""" - [||] - """ -"""", -""""" -var x = $$$$"""" - """{{{[||] - """" -""""", + """" + var x = $""" + [||] + """ + """", + """"" + var x = $$$$"""" + """{{{[||] + """" + """"", afterUndo: -"""" -var x = $""" - """{{{[||] - """ -""""); - } + """" + var x = $""" + """{{{[||] + """ + """"); [WpfFact] public void TestTripleOpenBraceIntoSingleLineRawString1_A() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """{{{""", -"""" -var x = $""" - [||] - """ -"""", -"""" -var x = $$$$""" - {{{[||] - """ -"""", + """" + var x = $""" + [||] + """ + """", + """" + var x = $$$$""" + {{{[||] + """ + """", afterUndo: -"""" -var x = $""" - {{{[||] - """ -""""); - } + """" + var x = $""" + {{{[||] + """ + """"); [WpfFact] public void TestTripleOpenBraceIntoSingleLineRawString3() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """{{{""", -"""" -var x = $""" - "[||] - """ -"""", -"""" -var x = $$$$""" - "{{{[||] - """ -"""", + """" + var x = $""" + "[||] + """ + """", + """" + var x = $$$$""" + "{{{[||] + """ + """", afterUndo: -"""" -var x = $""" - "{{{[||] - """ -""""); - } + """" + var x = $""" + "{{{[||] + """ + """"); [WpfFact] public void TestTripleOpenBraceIntoSingleLineRawString4() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """{{{""", -"""" -var x = $""" - "[||]" - """ -"""", -"""" -var x = $$$$""" - "{{{[||]" - """ -"""", + """" + var x = $""" + "[||]" + """ + """", + """" + var x = $$$$""" + "{{{[||]" + """ + """", afterUndo: -"""" -var x = $""" - "{{{[||]" - """ -""""); - } + """" + var x = $""" + "{{{[||]" + """ + """"); [WpfFact] public void TestTripleOpenBraceIntoSingleLineRawString5() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """{{{""", -"""" -var x = $""" - [||]" - """ -"""", -"""" -var x = $$$$""" - {{{[||]" - """ -"""", + """" + var x = $""" + [||]" + """ + """", + """" + var x = $$$$""" + {{{[||]" + """ + """", afterUndo: -"""" -var x = $""" - {{{[||]" - """ -""""); - } + """" + var x = $""" + {{{[||]" + """ + """"); [WpfFact] public void TestInterpolationIntoSingleLineRawString1() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """{0}""", -"""" -var x = $""" - [||] - """ -"""", -"""" -var x = $$""" - {0}[||] - """ -"""", + """" + var x = $""" + [||] + """ + """", + """" + var x = $$""" + {0}[||] + """ + """", afterUndo: -"""" -var x = $""" - {0}[||] - """ -""""); - } + """" + var x = $""" + {0}[||] + """ + """"); [WpfFact] public void TestOpenCloseBraceIntoSingleLineRawString1() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """{}""", -"""" -var x = $""" - [||] - """ -"""", -"""" -var x = $$""" - {}[||] - """ -"""", + """" + var x = $""" + [||] + """ + """", + """" + var x = $$""" + {}[||] + """ + """", afterUndo: -"""" -var x = $""" - {}[||] - """ -""""); - } + """" + var x = $""" + {}[||] + """ + """"); [WpfFact] public void TestOpenCloseBraceIntoSingleLineRawString2() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """{}""", -"""" -var x = $$""" - [||] - """ -"""", -"""" -var x = $$""" - {}[||] - """ -"""", + """" + var x = $$""" + [||] + """ + """", + """" + var x = $$""" + {}[||] + """ + """", afterUndo: -"""" -var x = $$""" - [||] - """ -""""); - } + """" + var x = $$""" + [||] + """ + """"); [WpfFact] public void TestOpenCloseBraceIntoSingleLineRawString3() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """{{}""", -"""" -var x = $$""" - [||] - """ -"""", -"""" -var x = $$$""" - {{}[||] - """ -"""", + """" + var x = $$""" + [||] + """ + """", + """" + var x = $$$""" + {{}[||] + """ + """", afterUndo: -"""" -var x = $$""" - {{}[||] - """ -""""); - } + """" + var x = $$""" + {{}[||] + """ + """"); [WpfFact] public void TestOpenCloseBraceIntoSingleLineRawString4() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """{}}""", -"""" -var x = $$""" - [||] - """ -"""", -"""" -var x = $$$""" - {}}[||] - """ -"""", + """" + var x = $$""" + [||] + """ + """", + """" + var x = $$$""" + {}}[||] + """ + """", afterUndo: -"""" -var x = $$""" - {}}[||] - """ -""""); - } + """" + var x = $$""" + {}}[||] + """ + """"); [WpfFact] public void TestOpenCloseBraceIntoSingleLineRawString5() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """{{}}""", -"""" -var x = $$""" - [||] - """ -"""", -"""" -var x = $$$""" - {{}}[||] - """ -"""", + """" + var x = $$""" + [||] + """ + """", + """" + var x = $$$""" + {{}}[||] + """ + """", afterUndo: -"""" -var x = $$""" - {{}}[||] - """ -""""); - } + """" + var x = $$""" + {{}}[||] + """ + """"); [WpfFact] public void TestComplexStringIntoSingleLineRawString() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """ "" """, -"""" -var x = $""" - [||] - """ -"""", -"""" -var x = $""" - "" [||] - """ -"""", + """" + var x = $""" + [||] + """ + """", + """" + var x = $""" + "" [||] + """ + """", afterUndo: -"""" -var x = $""" - [||] - """ -""""); - } + """" + var x = $""" + [||] + """ + """"); [WpfFact] public void TestNormalTextIntoSingleLineRawString_A() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """abc""", -"""" -var x = $""" - [||] - """ -"""", -"""" -var x = $""" - abc[||] - """ -"""", + """" + var x = $""" + [||] + """ + """", + """" + var x = $""" + abc[||] + """ + """", afterUndo: -"""" -var x = $""" - [||] - """ -""""); - } + """" + var x = $""" + [||] + """ + """"); [WpfFact] public void TestNormalTextIntoSingleLineRawStringSingleLine1_A() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """ abc def """, -"""" -var x = $""" - [||] - """ -"""", -"""" -var x = $""" - abc - def[||] - """ -"""", + """" + var x = $""" + [||] + """ + """", + """" + var x = $""" + abc + def[||] + """ + """", afterUndo: -"""" -var x = $""" - abc -def[||] - """ -""""); - } + """" + var x = $""" + abc + def[||] + """ + """"); [WpfFact] public void TestNormalTextIntoSingleLineRawStringSingleLine4() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """ abc def """, -"""" -var x = $""" - goo[||] - """ -"""", -"""" -var x = $""" - gooabc - def[||] - """ -"""", + """" + var x = $""" + goo[||] + """ + """", + """" + var x = $""" + gooabc + def[||] + """ + """", afterUndo: -"""" -var x = $""" - gooabc -def[||] - """ -""""); - } + """" + var x = $""" + gooabc + def[||] + """ + """"); [WpfFact] public void TestNormalTextIntoSingleLineRawStringSingleLine5() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """ abc def """, -"""" -var x = $""" - goo[||]bar - """ -"""", -"""" -var x = $""" - gooabc - def[||]bar - """ -"""", + """" + var x = $""" + goo[||]bar + """ + """", + """" + var x = $""" + gooabc + def[||]bar + """ + """", afterUndo: -"""" -var x = $""" - gooabc -def[||]bar - """ -""""); - } + """" + var x = $""" + gooabc + def[||]bar + """ + """"); [WpfFact] public void TestNormalTextIntoSingleLineRawStringSingleLine6() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """ abc def """, -"""" -var x = $""" - goo[||]bar - """ -"""", -"""" -var x = $""" - gooabc - def - [||]bar - """ -"""", + """" + var x = $""" + goo[||]bar + """ + """", + """" + var x = $""" + gooabc + def + [||]bar + """ + """", afterUndo: -"""" -var x = $""" - gooabc -def -[||]bar - """ -""""); - } + """" + var x = $""" + gooabc + def + [||]bar + """ + """"); [WpfFact] public void TestNormalTextIntoSingleLineRawStringSingleLine7_A() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """ abc def ghi """, -"""" -var x = $""" - [||] - """ -"""", -"""" -var x = $""" - abc - def - ghi[||] - """ -"""", + """" + var x = $""" + [||] + """ + """", + """" + var x = $""" + abc + def + ghi[||] + """ + """", afterUndo: -"""" -var x = $""" - abc - def -ghi[||] - """ -""""); - } + """" + var x = $""" + abc + def + ghi[||] + """ + """"); [WpfFact] public void TestNormalTextIntoSingleLineRawStringSingleLine7_B() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """ abc def ghi """, -"""" -var x = $""" - [||] - """ -"""", -"""" -var x = $""" - abc - def - ghi[||] - """ -"""", + """" + var x = $""" + [||] + """ + """", + """" + var x = $""" + abc + def + ghi[||] + """ + """", afterUndo: -"""" -var x = $""" - abc - def -ghi[||] - """ -""""); - } + """" + var x = $""" + abc + def + ghi[||] + """ + """"); [WpfFact] public void TestNormalTextIntoSingleLineRawStringSingleLine8_A() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """ abc def ghi """, -"""" -var x = $""" - [||] - """ -"""", -"""" -var x = $""" - abc - def - ghi[||] - """ -"""", + """" + var x = $""" + [||] + """ + """", + """" + var x = $""" + abc + def + ghi[||] + """ + """", afterUndo: -"""" -var x = $""" - abc - def - ghi[||] - """ -""""); - } + """" + var x = $""" + abc + def + ghi[||] + """ + """"); [WpfFact] public void TestNormalTextIntoSingleLineRawStringSingleLine9_A() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """ abc def ghi """, -"""" -var x = $""" - [||] - """ -"""", -"""" -var x = $""" - abc - def - ghi[||] - """ -"""", + """" + var x = $""" + [||] + """ + """", + """" + var x = $""" + abc + def + ghi[||] + """ + """", afterUndo: -"""" -var x = $""" - abc - def - ghi[||] - """ -""""); - } + """" + var x = $""" + abc + def + ghi[||] + """ + """"); [WpfFact] public void TestNormalTextIntoSingleLineRawStringSingleLine10_A() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """ abc def ghi """, -"""" -var x = $""" - [||] - """ -"""", -"""" -var x = $""" - abc - def - ghi[||] - """ -"""", + """" + var x = $""" + [||] + """ + """", + """" + var x = $""" + abc + def + ghi[||] + """ + """", afterUndo: -"""" -var x = $""" - abc - def - ghi[||] - """ -""""); - } + """" + var x = $""" + abc + def + ghi[||] + """ + """"); [WpfFact] public void TestNormalTextIntoSingleLineRawStringSingleLine11_A() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """ abc def """, -"""" -var x = $""" - [||]{|Selection: |} - """ -"""", -"""" -var x = $""" - abc - def[||] - """ -"""", + """" + var x = $""" + [||]{|Selection: |} + """ + """", + """" + var x = $""" + abc + def[||] + """ + """", afterUndo: -"""" -var x = $""" - abc -def[||] - """ -""""); - } + """" + var x = $""" + abc + def[||] + """ + """"); [WpfFact] public void TestNormalTextIntoSingleLineRawStringSingleLine12_A() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """ abc def """, -"""" -var x = $""" - [||]{|Selection: |} - """ -"""", -"""" -var x = $""" - abc - def - [||] - """ -"""", + """" + var x = $""" + [||]{|Selection: |} + """ + """", + """" + var x = $""" + abc + def + [||] + """ + """", afterUndo: -"""" -var x = $""" - abc -def -[||] - """ -""""); - } + """" + var x = $""" + abc + def + [||] + """ + """"); [WpfFact] public void TestNormalTextIntoSingleLineRawStringSingleLine13_A() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """ abc def """, -"""" -var x = $""" - [||]{|Selection: |} - """ -"""", -"""" -var x = $""" - abc - def[||] - """ -"""", + """" + var x = $""" + [||]{|Selection: |} + """ + """", + """" + var x = $""" + abc + def[||] + """ + """", afterUndo: -"""" -var x = $""" - abc -def[||] - """ -""""); - } + """" + var x = $""" + abc + def[||] + """ + """"); [WpfFact] public void TestNormalTextIntoSingleLineRawStringHeader1_A() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """ "bar """, -"""" -var x = $""" - [||]goo - """ -"""", -"""" -var x = $""" - "bar[||]goo - """ -"""", + """" + var x = $""" + [||]goo + """ + """", + """" + var x = $""" + "bar[||]goo + """ + """", afterUndo: -"""" -var x = $""" - [||]goo - """ -""""); - } + """" + var x = $""" + [||]goo + """ + """"); [WpfFact] public void TestQuotesIntoHeader1() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """ "" """, -"""" -var x = $""" - [||]{|Selection: |} - """ -"""", -"""" -var x = $""" - ""[||] - """ -"""", + """" + var x = $""" + [||]{|Selection: |} + """ + """", + """" + var x = $""" + ""[||] + """ + """", afterUndo: -"""" -var x = $""" - [||] - """ -""""); - } + """" + var x = $""" + [||] + """ + """"); [WpfFact] public void TestQuotesIntoHeader2() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """" """ """", -"""" -var x = $""" - [||]{|Selection: |} - """ -"""", -""""" -var x = $"""" - """[||] - """" -""""", + """" + var x = $""" + [||]{|Selection: |} + """ + """", + """"" + var x = $"""" + """[||] + """" + """"", afterUndo: -"""" -var x = $""" - """[||] - """ -""""); - } + """" + var x = $""" + """[||] + """ + """"); #endregion @@ -2069,1020 +1907,940 @@ public void TestQuotesIntoHeader2() [WpfFact] public void TestNewLineIntoMultiLineRawString1() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: "\n", -"""" -var x = $""" - [||] - """ -"""", -"var x = $\"\"\"\r\n \n [||]\r\n \"\"\"", + """" + var x = $""" + [||] + """ + """", + "var x = $\"\"\"\r\n \n [||]\r\n \"\"\"", afterUndo: -"var x = $\"\"\"\r\n \n[||]\r\n \"\"\""); - } + "var x = $\"\"\"\r\n \n[||]\r\n \"\"\""); [WpfFact] public void TestNewLineIntoMultiLineRawString2() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """ """, -"""" -var x = $""" - [||] - """ -"""", -"""" -var x = $""" - - [||] - """ -"""", + """" + var x = $""" + [||] + """ + """", + """" + var x = $""" + + [||] + """ + """", afterUndo: -"""" -var x = $""" - -[||] - """ -""""); - } + """" + var x = $""" + + [||] + """ + """"); [WpfFact] public void TestSpacesIntoMultiLineRawString1() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """ """, -"""" -var x = $""" - [||] - """ -"""", -"""" -var x = $""" - [||] - """ -"""", + """" + var x = $""" + [||] + """ + """", + """" + var x = $""" + [||] + """ + """", afterUndo: -"""" -var x = $""" - [||] - """ -""""); - } + """" + var x = $""" + [||] + """ + """"); [WpfFact] public void TestSpacesIntoMultiLineRawString2() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """ """, -"""" -var x = $""" - [||] - """ -"""", -"""" -var x = $""" - - [||] - """ -"""", + """" + var x = $""" + [||] + """ + """", + """" + var x = $""" + + [||] + """ + """", afterUndo: -"""" -var x = $""" - -[||] - """ -""""); - } + """" + var x = $""" + + [||] + """ + """"); [WpfFact] public void TestSingleQuoteIntoMultiLineRawString() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """'""", -"""" -var x = $""" - [||] - """ -"""", -"""" -var x = $""" - '[||] - """ -"""", + """" + var x = $""" + [||] + """ + """", + """" + var x = $""" + '[||] + """ + """", afterUndo: -"""" -var x = $""" - [||] - """ -""""); - } + """" + var x = $""" + [||] + """ + """"); [WpfFact] public void TestDoubleQuoteIntoMultiLineRawString() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """ " """, -"""" -var x = $""" - [||] - """ -"""", -"""" -var x = $""" - "[||] - """ -"""", + """" + var x = $""" + [||] + """ + """", + """" + var x = $""" + "[||] + """ + """", afterUndo: -"""" -var x = $""" - [||] - """ -""""); - } + """" + var x = $""" + [||] + """ + """"); [WpfFact] public void TestTripleQuoteIntoMultiLineRawString1() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """" """ """", -"""" -var x = $""" - [||] - """ -"""", -""""" -var x = $"""" - """[||] - """" -""""", + """" + var x = $""" + [||] + """ + """", + """"" + var x = $"""" + """[||] + """" + """"", afterUndo: -"""" -var x = $""" - """[||] - """ -""""); - } + """" + var x = $""" + """[||] + """ + """"); [WpfFact] public void TestTripleQuoteIntoMultiLineRawString2() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """" """ """", -"""" -var x = $""" - [||] - """ -"""", -""""" -var x = $"""" - """[||] - """" -""""", + """" + var x = $""" + [||] + """ + """", + """"" + var x = $"""" + """[||] + """" + """"", afterUndo: -"""" -var x = $""" - """[||] - """ -""""); - } + """" + var x = $""" + """[||] + """ + """"); [WpfFact] public void TestTripleQuoteIntoMultiLineRawString3() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """" """ """", -"""" -var x = $""" - "[||] - """ -"""", -"""""" -var x = $""""" - """"[||] - """"" -"""""", + """" + var x = $""" + "[||] + """ + """", + """""" + var x = $""""" + """"[||] + """"" + """""", afterUndo: -""""" -var x = $""" - """"[||] - """ -"""""); - } + """"" + var x = $""" + """"[||] + """ + """""); [WpfFact] public void TestTripleQuoteIntoMultiLineRawString4() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """" """ """", -"""" -var x = $""" - "[||]" - """ -"""", -""""""" -var x = $"""""" - """"[||]" - """""" -""""""", + """" + var x = $""" + "[||]" + """ + """", + """"""" + var x = $"""""" + """"[||]" + """""" + """"""", afterUndo: -""""" -var x = $""" - """"[||]" - """ -"""""); - } + """"" + var x = $""" + """"[||]" + """ + """""); [WpfFact] public void TestTripleQuoteIntoMultiLineRawString5() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """" """ """", -"""" -var x = $""" - [||]" - """ -"""", -"""""" -var x = $""""" - """[||]" - """"" -"""""", + """" + var x = $""" + [||]" + """ + """", + """""" + var x = $""""" + """[||]" + """"" + """""", afterUndo: -"""" -var x = $""" - """[||]" - """ -""""); - } + """" + var x = $""" + """[||]" + """ + """"); [WpfFact] public void TestQuadrupleQuoteIntoMultiLineRawString() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """"" """" """"", -"""" -var x = $""" - [||] - """ -"""", -"""""" -var x = $""""" - """"[||] - """"" -"""""", + """" + var x = $""" + [||] + """ + """", + """""" + var x = $""""" + """"[||] + """"" + """""", afterUndo: -""""" -var x = $""" - """"[||] - """ -"""""); - } + """"" + var x = $""" + """"[||] + """ + """""); [WpfFact] public void TestOpenBraceIntoMultiLineRawString() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """{""", -"""" -var x = $""" - [||] - """ -"""", -"""" -var x = $$""" - {[||] - """ -"""", + """" + var x = $""" + [||] + """ + """", + """" + var x = $$""" + {[||] + """ + """", afterUndo: -"""" -var x = $""" - {[||] - """ -""""); - } + """" + var x = $""" + {[||] + """ + """"); [WpfFact] public void TestTripleOpenBraceIntoMultiLineRawString() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """{{{""", -"""" -var x = $""" - [||] - """ -"""", -"""" -var x = $$$$""" - {{{[||] - """ -"""", + """" + var x = $""" + [||] + """ + """", + """" + var x = $$$$""" + {{{[||] + """ + """", afterUndo: -"""" -var x = $""" - {{{[||] - """ -""""); - } + """" + var x = $""" + {{{[||] + """ + """"); [WpfFact] public void TestTripleOpenBraceIntoMultiLineRawString2() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """{{{""", -"""" -var x = $$""" - [||] - """ -"""", -"""" -var x = $$$$""" - {{{[||] - """ -"""", + """" + var x = $$""" + [||] + """ + """", + """" + var x = $$$$""" + {{{[||] + """ + """", afterUndo: -"""" -var x = $$""" - {{{[||] - """ -""""); - } + """" + var x = $$""" + {{{[||] + """ + """"); [WpfFact] public void TestOpenBraceIntoMultiLineRawString2() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """{""", -"""" -var x = $$$""" - {[||]{ - """ -"""", -"""" -var x = $$$$""" - {{[||]{ - """ -"""", + """" + var x = $$$""" + {[||]{ + """ + """", + """" + var x = $$$$""" + {{[||]{ + """ + """", afterUndo: -"""" -var x = $$$""" - {{[||]{ - """ -""""); - } + """" + var x = $$$""" + {{[||]{ + """ + """"); [WpfFact] public void TestInterpolationIntoMultiLineRawString3() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """{0}""", -"""" -var x = $""" - [||] - """ -"""", -"""" -var x = $$""" - {0}[||] - """ -"""", + """" + var x = $""" + [||] + """ + """", + """" + var x = $$""" + {0}[||] + """ + """", afterUndo: -"""" -var x = $""" - {0}[||] - """ -""""); - } + """" + var x = $""" + {0}[||] + """ + """"); [WpfFact] public void TestOpenCloseIntoMultiLineRawString4() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """{}""", -"""" -var x = $""" - [||] - """ -"""", -"""" -var x = $$""" - {}[||] - """ -"""", + """" + var x = $""" + [||] + """ + """", + """" + var x = $$""" + {}[||] + """ + """", afterUndo: -"""" -var x = $""" - {}[||] - """ -""""); - } + """" + var x = $""" + {}[||] + """ + """"); [WpfFact] public void TestOpenCloseBraceIntoMultiLineRawString5() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """{{}""", -"""" -var x = $$""" - [||] - """ -"""", -"""" -var x = $$$""" - {{}[||] - """ -"""", + """" + var x = $$""" + [||] + """ + """", + """" + var x = $$$""" + {{}[||] + """ + """", afterUndo: -"""" -var x = $$""" - {{}[||] - """ -""""); - } + """" + var x = $$""" + {{}[||] + """ + """"); [WpfFact] public void TestOpenCloseBraceIntoMultiLineRawString() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """{}}""", -"""" -var x = $""" - [||] - """ -"""", -"""" -var x = $$$""" - {}}[||] - """ -"""", + """" + var x = $""" + [||] + """ + """", + """" + var x = $$$""" + {}}[||] + """ + """", afterUndo: -"""" -var x = $""" - {}}[||] - """ -""""); - } + """" + var x = $""" + {}}[||] + """ + """"); [WpfFact] public void TestOpenCloseBraceIntoMultiLineRawString2() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """{{}}""", -"""" -var x = $""" - [||] - """ -"""", -"""" -var x = $$$""" - {{}}[||] - """ -"""", + """" + var x = $""" + [||] + """ + """", + """" + var x = $$$""" + {{}}[||] + """ + """", afterUndo: -"""" -var x = $""" - {{}}[||] - """ -""""); - } + """" + var x = $""" + {{}}[||] + """ + """"); [WpfFact] public void TestTripleQuoteTripleOpenBraceIntoMultiLineRawString() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """" """{{{ """", -"""" -var x = $""" - [||] - """ -"""", -""""" -var x = $$$$"""" - """{{{[||] - """" -""""", + """" + var x = $""" + [||] + """ + """", + """"" + var x = $$$$"""" + """{{{[||] + """" + """"", afterUndo: -"""" -var x = $""" - """{{{[||] - """ -""""); - } + """" + var x = $""" + """{{{[||] + """ + """"); [WpfFact] public void TestComplexStringIntoMultiLineRawString() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """ "" """, -"""" -var x = $""" - [||] - """ -"""", -"""" -var x = $""" - "" [||] - """ -"""", + """" + var x = $""" + [||] + """ + """", + """" + var x = $""" + "" [||] + """ + """", afterUndo: -"""" -var x = $""" - [||] - """ -""""); - } + """" + var x = $""" + [||] + """ + """"); [WpfFact] public void TestNormalTextIntoMultiLineRawString() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """abc""", -"""" -var x = $""" - [||] - """ -"""", -"""" -var x = $""" - abc[||] - """ -"""", + """" + var x = $""" + [||] + """ + """", + """" + var x = $""" + abc[||] + """ + """", afterUndo: -"""" -var x = $""" - [||] - """ -""""); - } + """" + var x = $""" + [||] + """ + """"); [WpfFact] public void TestNormalTextIntoMultiLineRawStringMultiLine1() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """ abc def """, -"""" -var x = $""" - [||] - """ -"""", -"""" -var x = $""" - abc - def[||] - """ -"""", + """" + var x = $""" + [||] + """ + """", + """" + var x = $""" + abc + def[||] + """ + """", afterUndo: -"""" -var x = $""" - abc -def[||] - """ -""""); - } + """" + var x = $""" + abc + def[||] + """ + """"); [WpfFact] public void TestNormalTextIntoMultiLineRawStringMultiLine2() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """ abc def """, -"""" -var x = $""" -[||] - """ -"""", -"""" -var x = $""" - abc - def[||] - """ -"""", + """" + var x = $""" + [||] + """ + """", + """" + var x = $""" + abc + def[||] + """ + """", afterUndo: -"""" -var x = $""" -abc -def[||] - """ -""""); - } + """" + var x = $""" + abc + def[||] + """ + """"); [WpfFact] public void TestNormalTextIntoMultiLineRawStringMultiLine3() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """ abc def """, -"""" -var x = $"""[||] + """" + var x = $"""[||] - """ -"""", -"""" -var x = $""" - abc - def[||] + """ + """", + """" + var x = $""" + abc + def[||] - """ -"""", + """ + """", afterUndo: -"""" -var x = $"""abc -def[||] + """" + var x = $"""abc + def[||] - """ -""""); - } + """ + """"); [WpfFact] public void TestNormalTextIntoMultiLineRawStringMultiLine4() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """ abc def """, -"""" -var x = $""" - goo[||] - """ -"""", -"""" -var x = $""" - gooabc - def[||] - """ -"""", + """" + var x = $""" + goo[||] + """ + """", + """" + var x = $""" + gooabc + def[||] + """ + """", afterUndo: -"""" -var x = $""" - gooabc -def[||] - """ -""""); - } + """" + var x = $""" + gooabc + def[||] + """ + """"); [WpfFact] public void TestNormalTextIntoMultiLineRawStringMultiLine5() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """ abc def """, -"""" -var x = $""" - goo[||]bar - """ -"""", -"""" -var x = $""" - gooabc - def[||]bar - """ -"""", + """" + var x = $""" + goo[||]bar + """ + """", + """" + var x = $""" + gooabc + def[||]bar + """ + """", afterUndo: -"""" -var x = $""" - gooabc -def[||]bar - """ -""""); - } + """" + var x = $""" + gooabc + def[||]bar + """ + """"); [WpfFact] public void TestNormalTextIntoMultiLineRawStringMultiLine6() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """ abc def """, -"""" -var x = $""" - goo[||]bar - """ -"""", -"""" -var x = $""" - gooabc - def - [||]bar - """ -"""", + """" + var x = $""" + goo[||]bar + """ + """", + """" + var x = $""" + gooabc + def + [||]bar + """ + """", afterUndo: -"""" -var x = $""" - gooabc -def -[||]bar - """ -""""); - } + """" + var x = $""" + gooabc + def + [||]bar + """ + """"); [WpfFact] public void TestNormalTextIntoMultiLineRawStringMultiLine7() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """ abc def ghi """, -"""" -var x = $""" - [||] - """ -"""", -"""" -var x = $""" - abc - def - ghi[||] - """ -"""", + """" + var x = $""" + [||] + """ + """", + """" + var x = $""" + abc + def + ghi[||] + """ + """", afterUndo: -"""" -var x = $""" - abc - def -ghi[||] - """ -""""); - } + """" + var x = $""" + abc + def + ghi[||] + """ + """"); [WpfFact] public void TestNormalTextIntoMultiLineRawStringMultiLine8() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """ abc def ghi """, -"""" -var x = $""" - [||] - """ -"""", -"""" -var x = $""" - abc - def - ghi[||] - """ -"""", + """" + var x = $""" + [||] + """ + """", + """" + var x = $""" + abc + def + ghi[||] + """ + """", afterUndo: -"""" -var x = $""" - abc - def - ghi[||] - """ -""""); - } + """" + var x = $""" + abc + def + ghi[||] + """ + """"); [WpfFact] public void TestNormalTextIntoMultiLineRawStringMultiLine9() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """ abc def ghi """, -"""" -var x = $""" - [||] - """ -"""", -"""" -var x = $""" - abc - def - ghi[||] - """ -"""", + """" + var x = $""" + [||] + """ + """", + """" + var x = $""" + abc + def + ghi[||] + """ + """", afterUndo: -"""" -var x = $""" - abc - def - ghi[||] - """ -""""); - } + """" + var x = $""" + abc + def + ghi[||] + """ + """"); [WpfFact] public void TestNormalTextIntoMultiLineRawStringMultiLine10() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """ abc def ghi """, -"""" -var x = $""" - [||] - """ -"""", -"""" -var x = $""" - abc - def - ghi[||] - """ -"""", + """" + var x = $""" + [||] + """ + """", + """" + var x = $""" + abc + def + ghi[||] + """ + """", afterUndo: -"""" -var x = $""" - abc - def - ghi[||] - """ -""""); - } + """" + var x = $""" + abc + def + ghi[||] + """ + """"); [WpfFact] public void TestNormalTextIntoMultiLineRawStringMultiLine11() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """ abc def """, -"""" -var x = $"""[||]{|Selection: + """" + var x = $"""[||]{|Selection: - |}""" -"""", -"""" -var x = $""" - abc - def - [||]""" -"""", + |}""" + """", + """" + var x = $""" + abc + def + [||]""" + """", afterUndo: -"""" -var x = $"""abc -def[||]""" -""""); - } + """" + var x = $"""abc + def[||]""" + """"); [WpfFact] public void TestNormalTextIntoMultiLineRawStringMultiLine12() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """ abc def """, -"""" -var x = $"""[||]{|Selection: + """" + var x = $"""[||]{|Selection: - |}""" -"""", -"""" -var x = $""" - abc - def - - [||]""" -"""", + |}""" + """", + """" + var x = $""" + abc + def + + [||]""" + """", afterUndo: -"""" -var x = $"""abc -def -[||]""" -""""); - } + """" + var x = $"""abc + def + [||]""" + """"); [WpfFact] public void TestNormalTextIntoMultiLineRawStringMultiLine13() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """ abc def """, -"""" -var x = $"""[||]{|Selection: + """" + var x = $"""[||]{|Selection: - |} """ -"""", -"""" -var x = $""" - abc - def - [||] """ -"""", + |} """ + """", + """" + var x = $""" + abc + def + [||] """ + """", afterUndo: -"""" -var x = $"""abc -def[||] """ -""""); - } + """" + var x = $"""abc + def[||] """ + """"); [WpfFact] public void TestNormalTextIntoMultiLineRawStringHeader1() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """bar""", -"""" -var x = $"""[||] - goo - """ -"""", -"""" -var x = $""" - bar[||] - goo - """ -"""", + """" + var x = $"""[||] + goo + """ + """", + """" + var x = $""" + bar[||] + goo + """ + """", afterUndo: -"""" -var x = $"""bar[||] - goo - """ -""""); - } + """" + var x = $"""bar[||] + goo + """ + """"); [WpfFact] public void TestQuotesIntoHeader1_A() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """ "" """, -"""" -var x = $"""[||]{|Selection: + """" + var x = $"""[||]{|Selection: - |}""" -"""", -"""" -var x = $""" - "" - [||]""" -"""", + |}""" + """", + """" + var x = $""" + "" + [||]""" + """", afterUndo: -"""""" -var x = $"""""[||]""" -""""""); - } + """""" + var x = $"""""[||]""" + """"""); [WpfFact] public void TestQuotesIntoHeader2_B() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """" """ """", -"""" -var x = $"""[||]{|Selection: + """" + var x = $"""[||]{|Selection: - |}""" -"""", -""""" -var x = $"""" - """ - [||]"""" -""""", + |}""" + """", + """"" + var x = $"""" + """ + [||]"""" + """"", afterUndo: -""""""" -var x = $""""""[||]""" -"""""""); - } + """"""" + var x = $""""""[||]""" + """""""); #endregion } diff --git a/src/EditorFeatures/CSharpTest/StringCopyPaste/PasteKnownSourceIntoMultiLineRawStringTests.cs b/src/EditorFeatures/CSharpTest/StringCopyPaste/PasteKnownSourceIntoMultiLineRawStringTests.cs index fb5f0c143e25..a8694758ae3c 100644 --- a/src/EditorFeatures/CSharpTest/StringCopyPaste/PasteKnownSourceIntoMultiLineRawStringTests.cs +++ b/src/EditorFeatures/CSharpTest/StringCopyPaste/PasteKnownSourceIntoMultiLineRawStringTests.cs @@ -14,8 +14,7 @@ public sealed class PasteKnownSourceIntoMultiLineRawStringTests : StringCopyPast [WpfFact] public void TestPasteSimpleNormalLiteralContent() - { - TestCopyPaste( + => TestCopyPaste( """var v = "{|Copy:goo|}";""", """" var dest = @@ -35,12 +34,10 @@ public void TestPasteSimpleNormalLiteralContent() [||] """; """"); - } [WpfFact] public void TestPasteSimpleSubstringNormalLiteralContent() - { - TestCopyPaste( + => TestCopyPaste( """var v = "g{|Copy:o|}o";""", """" var dest = @@ -60,12 +57,10 @@ public void TestPasteSimpleSubstringNormalLiteralContent() [||] """; """"); - } [WpfFact] public void TestPastePartiallySelectedEscapeNormalLiteralContent() - { - TestCopyPaste( + => TestCopyPaste( """var v = "\{|Copy:n|}";""", """" var dest = @@ -85,12 +80,10 @@ public void TestPastePartiallySelectedEscapeNormalLiteralContent() [||] """; """"); - } [WpfFact] public void TestPasteFullySelectedEscapeNormalLiteralContent() - { - TestCopyPaste( + => TestCopyPaste( """var v = "{|Copy:\n|}";""", """" var dest = @@ -105,12 +98,10 @@ public void TestPasteFullySelectedEscapeNormalLiteralContent() \n[||] """; """"); - } [WpfFact] public void TestPastePartiallySelectedQuoteNormalLiteralContent() - { - TestCopyPaste( + => TestCopyPaste( """var v = "\{|Copy:"|}";""", """" var dest = @@ -130,12 +121,10 @@ public void TestPastePartiallySelectedQuoteNormalLiteralContent() [||] """; """"); - } [WpfFact] public void TestPasteFullySelectedQuoteNormalLiteralContent() - { - TestCopyPaste( + => TestCopyPaste( """var v = "{|Copy:\"|}";""", """" var dest = @@ -155,12 +144,10 @@ public void TestPasteFullySelectedQuoteNormalLiteralContent() \"[||] """; """"); - } [WpfFact] public void TestPasteSimpleVerbatimLiteralContent() - { - TestCopyPaste( + => TestCopyPaste( """var v = @"{|Copy:goo|}";""", """" var dest = @@ -180,12 +167,10 @@ public void TestPasteSimpleVerbatimLiteralContent() [||] """; """"); - } [WpfFact] public void TestPasteSimpleSubstringVerbatimLiteralContent() - { - TestCopyPaste( + => TestCopyPaste( """var v = @"g{|Copy:o|}o";""", """" var dest = @@ -205,12 +190,10 @@ public void TestPasteSimpleSubstringVerbatimLiteralContent() [||] """; """"); - } [WpfFact] public void TestPasteSelectedVerbatimNewLineLiteralContent() - { - TestCopyPaste( + => TestCopyPaste( """ var v = @"{|Copy: |}"; @@ -235,12 +218,10 @@ public void TestPasteSelectedVerbatimNewLineLiteralContent() [||] """; """"); - } [WpfFact] public void TestPasteFullySelectedEscapeVerbatimLiteralContent() - { - TestCopyPaste( + => TestCopyPaste( """var v = @"{|Copy:""|}";""", """" var dest = @@ -260,12 +241,10 @@ public void TestPasteFullySelectedEscapeVerbatimLiteralContent() ""[||] """; """"); - } [WpfFact] public void TestPasteSimpleRawSingleLineLiteralContent() - { - TestCopyPaste( + => TestCopyPaste( """"var v = """{|Copy:goo|}""";"""", """" var dest = @@ -285,12 +264,10 @@ public void TestPasteSimpleRawSingleLineLiteralContent() [||] """; """"); - } [WpfFact] public void TestPasteQuotesRawSingleLineLiteralContent() - { - TestCopyPaste( + => TestCopyPaste( """"var v = """{|Copy: "" |}""";"""", """" var dest = @@ -310,12 +287,10 @@ public void TestPasteQuotesRawSingleLineLiteralContent() [||] """; """"); - } [WpfFact] public void TestPasteSimpleRawMultiLineLiteralContent1() - { - TestCopyPaste( + => TestCopyPaste( """" var v = """ {|Copy:goo|} @@ -339,12 +314,10 @@ public void TestPasteSimpleRawMultiLineLiteralContent1() [||] """; """"); - } [WpfFact] public void TestPasteSimpleRawMultiLineLiteralContent2() - { - TestCopyPaste( + => TestCopyPaste( """" var v = """ {|Copy:goo @@ -370,12 +343,10 @@ public void TestPasteSimpleRawMultiLineLiteralContent2() [||] """; """"); - } [WpfFact] public void TestPasteSimpleRawMultiLineLiteralContent3() - { - TestCopyPaste( + => TestCopyPaste( """" var v = """ {|Copy: goo @@ -402,12 +373,10 @@ public void TestPasteSimpleRawMultiLineLiteralContent3() bar[||] """; """"); - } [WpfFact] public void TestPasteInterpolationFromInterpolatedStringLiteralContent() - { - TestCopyPaste( + => TestCopyPaste( """var v = $"{|Copy:{0}|}";""", """" var dest = @@ -427,12 +396,10 @@ public void TestPasteInterpolationFromInterpolatedStringLiteralContent() [||] """; """"); - } [WpfFact] public void TestPasteInterpolationWithFormatClauseFromInterpolatedStringLiteralContent1() - { - TestCopyPaste( + => TestCopyPaste( """var v = $"{|Copy:{0:X}|}";""", """" var dest = @@ -452,12 +419,10 @@ public void TestPasteInterpolationWithFormatClauseFromInterpolatedStringLiteralC [||] """; """"); - } [WpfFact] public void TestPasteInterpolationWithFormatClauseFromInterpolatedStringLiteralContent2() - { - TestCopyPaste( + => TestCopyPaste( """var v = $"{|Copy:{0:\"X\"}|}";""", """" var dest = @@ -477,12 +442,10 @@ public void TestPasteInterpolationWithFormatClauseFromInterpolatedStringLiteralC {0:\"X\"}[||] """; """"); - } [WpfFact] public void TestPasteInterpolationWithStringFromInterpolatedStringLiteralContent1() - { - TestCopyPaste( + => TestCopyPaste( """var v = $"{|Copy:{"goo"}|}";""", """" var dest = @@ -502,12 +465,10 @@ public void TestPasteInterpolationWithStringFromInterpolatedStringLiteralContent [||] """; """"); - } [WpfFact] public void TestPasteInterpolationWithStringFromInterpolatedStringLiteralContent2() - { - TestCopyPaste( + => TestCopyPaste( """var v = $"{|Copy:X{"goo"}Y|}";""", """" var dest = @@ -527,12 +488,10 @@ public void TestPasteInterpolationWithStringFromInterpolatedStringLiteralContent [||] """; """"); - } [WpfFact] public void TestPasteInterpolationWithStringFromInterpolatedStringLiteralContent3() - { - TestCopyPaste( + => TestCopyPaste( """var v = $"{|Copy:\"X{"goo"}Y\"|}";""", """" var dest = @@ -552,12 +511,10 @@ public void TestPasteInterpolationWithStringFromInterpolatedStringLiteralContent \"X{"goo"}Y\"[||] """; """"); - } [WpfFact] public void TestPasteInterpolationWithStringFromInterpolatedStringLiteralContent4() - { - TestCopyPaste( + => TestCopyPaste( """var v = $"{|Copy:\"X{@"goo"}Y\"|}";""", """" var dest = @@ -577,12 +534,10 @@ public void TestPasteInterpolationWithStringFromInterpolatedStringLiteralContent \"X{@"goo"}Y\"[||] """; """"); - } [WpfFact] public void TestPasteInterpolationFromVerbatimInterpolatedStringLiteralContent() - { - TestCopyPaste( + => TestCopyPaste( """var v = $@"{|Copy:{0}|}";""", """" var dest = @@ -602,12 +557,10 @@ public void TestPasteInterpolationFromVerbatimInterpolatedStringLiteralContent() [||] """; """"); - } [WpfFact] public void TestPasteInterpolationWithFormatClauseFromVerbatimInterpolatedStringLiteralContent1() - { - TestCopyPaste( + => TestCopyPaste( """var v = $@"{|Copy:{0:X}|}";""", """" var dest = @@ -627,12 +580,10 @@ public void TestPasteInterpolationWithFormatClauseFromVerbatimInterpolatedString [||] """; """"); - } [WpfFact] public void TestPasteInterpolationWithFormatClauseFromVerbatimInterpolatedStringLiteralContent2() - { - TestCopyPaste( + => TestCopyPaste( """var v = $@"{|Copy:{0:""X""}|}";""", """" var dest = @@ -652,12 +603,10 @@ public void TestPasteInterpolationWithFormatClauseFromVerbatimInterpolatedString {0:""X""}[||] """; """"); - } [WpfFact] public void TestPasteInterpolationWithStringFromVerbatimInterpolatedStringLiteralContent1() - { - TestCopyPaste( + => TestCopyPaste( """var v = $@"{|Copy:{"goo"}|}";""", """" var dest = @@ -677,12 +626,10 @@ public void TestPasteInterpolationWithStringFromVerbatimInterpolatedStringLitera [||] """; """"); - } [WpfFact] public void TestPasteInterpolationWithStringFromVerbatimInterpolatedStringLiteralContent2() - { - TestCopyPaste( + => TestCopyPaste( """var v = $@"{|Copy:X{"goo"}Y|}";""", """" var dest = @@ -702,12 +649,10 @@ public void TestPasteInterpolationWithStringFromVerbatimInterpolatedStringLitera [||] """; """"); - } [WpfFact] public void TestPasteInterpolationWithStringFromVerbatimInterpolatedStringLiteralContent3() - { - TestCopyPaste( + => TestCopyPaste( """var v = $@"{|Copy:""X{"goo"}Y""|}";""", """" var dest = @@ -727,12 +672,10 @@ public void TestPasteInterpolationWithStringFromVerbatimInterpolatedStringLitera ""X{"goo"}Y""[||] """; """"); - } [WpfFact] public void TestPasteInterpolationWithStringFromVerbatimInterpolatedStringLiteralContent4() - { - TestCopyPaste( + => TestCopyPaste( """var v = $@"{|Copy:""X{@"goo"}Y""|}";""", """" var dest = @@ -752,7 +695,6 @@ public void TestPasteInterpolationWithStringFromVerbatimInterpolatedStringLitera ""X{@"goo"}Y""[||] """; """"); - } #endregion @@ -763,773 +705,715 @@ public void TestPasteInterpolationWithStringFromVerbatimInterpolatedStringLitera [WpfFact] public void TestNewLineIntoSingleLineRawString1_A() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: "\n", -"""" -var x = """ - [||] - """ -"""", -"var x = \"\"\"\r\n \n [||]\r\n \"\"\"", + """" + var x = """ + [||] + """ + """", + "var x = \"\"\"\r\n \n [||]\r\n \"\"\"", afterUndo: -"var x = \"\"\"\r\n \n[||]\r\n \"\"\""); - } + "var x = \"\"\"\r\n \n[||]\r\n \"\"\""); [WpfFact] public void TestNewLineIntoSingleLineRawString2_A() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """ """, -"""" -var x = """ - [||] - """ -"""", -"""" -var x = """ - - [||] - """ -"""", + """" + var x = """ + [||] + """ + """", + """" + var x = """ + + [||] + """ + """", afterUndo: -"""" -var x = """ - -[||] - """ -""""); - } + """" + var x = """ + + [||] + """ + """"); [WpfFact] public void TestSpacesIntoSingleLineRawString1_A() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """ """, -"""" -var x = """ - [||] - """ -"""", -"""" -var x = """ - [||] - """ -"""", + """" + var x = """ + [||] + """ + """", + """" + var x = """ + [||] + """ + """", afterUndo: -"""" -var x = """ - [||] - """ -""""); - } + """" + var x = """ + [||] + """ + """"); [WpfFact] public void TestSpacesIntoSingleLineRawString2() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """ """, -"""" -var x = """ - [||] - """ -"""", -"""" -var x = """ - - [||] - """ -"""", + """" + var x = """ + [||] + """ + """", + """" + var x = """ + + [||] + """ + """", afterUndo: -"""" -var x = """ - -[||] - """ -""""); - } + """" + var x = """ + + [||] + """ + """"); [WpfFact] public void TestSingleQuoteIntoSingleLineRawString_A() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """'""", -"""" -var x = """ - [||] - """ -"""", -"""" -var x = """ - '[||] - """ -"""", + """" + var x = """ + [||] + """ + """", + """" + var x = """ + '[||] + """ + """", afterUndo: -"""" -var x = """ - [||] - """ -""""); - } + """" + var x = """ + [||] + """ + """"); [WpfFact] public void TestDoubleQuoteIntoSingleLineRawString_A() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """ " """, -"""" -var x = """ - [||] - """ -"""", -"""" -var x = """ - "[||] - """ -"""", + """" + var x = """ + [||] + """ + """", + """" + var x = """ + "[||] + """ + """", afterUndo: -"""" -var x = """ - [||] - """ -""""); - } + """" + var x = """ + [||] + """ + """"); [WpfFact] public void TestTripleQuoteIntoSingleLineRawString1_A() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """" """ """", -"""" -var x = """ - [||] - """ -"""", -""""" -var x = """" - """[||] - """" -""""", + """" + var x = """ + [||] + """ + """", + """"" + var x = """" + """[||] + """" + """"", afterUndo: -"""" -var x = """ - """[||] - """ -""""); - } + """" + var x = """ + """[||] + """ + """"); [WpfFact] public void TestTwoQuotesIntoSingleLineRawString3() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """ "" """, -"""" -var x = """ - "[||] - """ -"""", -""""" -var x = """" - """[||] - """" -""""", + """" + var x = """ + "[||] + """ + """", + """"" + var x = """" + """[||] + """" + """"", afterUndo: -"""" -var x = """ - """[||] - """ -""""); - } + """" + var x = """ + """[||] + """ + """"); [WpfFact] public void TestTripleQuoteIntoSingleLineRawString3() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """" """ """", -"""" -var x = """ - "[||] - """ -"""", -"""""" -var x = """"" - """"[||] - """"" -"""""", + """" + var x = """ + "[||] + """ + """", + """""" + var x = """"" + """"[||] + """"" + """""", afterUndo: -""""" -var x = """ - """"[||] - """ -"""""); - } + """"" + var x = """ + """"[||] + """ + """""); [WpfFact] public void TestTripleQuoteIntoSingleLineRawString4() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """" """ """", -"""" -var x = """ - "[||]" - """ -"""", -""""""" -var x = """""" - """"[||]" - """""" -""""""", + """" + var x = """ + "[||]" + """ + """", + """"""" + var x = """""" + """"[||]" + """""" + """"""", afterUndo: -""""" -var x = """ - """"[||]" - """ -"""""); - } + """"" + var x = """ + """"[||]" + """ + """""); [WpfFact] public void TestTripleQuoteIntoSingleLineRawString5() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """" """ """", -"""" -var x = """ - [||]" - """ -"""", -"""""" -var x = """"" - """[||]" - """"" -"""""", + """" + var x = """ + [||]" + """ + """", + """""" + var x = """"" + """[||]" + """"" + """""", afterUndo: -"""" -var x = """ - """[||]" - """ -""""); - } + """" + var x = """ + """[||]" + """ + """"); [WpfFact] public void TestQuadrupleQuoteIntoSingleLineRawString() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """"" """" """"", -"""" -var x = """ - [||] - """ -"""", -"""""" -var x = """"" - """"[||] - """"" -"""""", + """" + var x = """ + [||] + """ + """", + """""" + var x = """"" + """"[||] + """"" + """""", afterUndo: -""""" -var x = """ - """"[||] - """ -"""""); - } + """"" + var x = """ + """"[||] + """ + """""); [WpfFact] public void TestComplexStringIntoSingleLineRawString() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """ "" """, -"""" -var x = """ - [||] - """ -"""", -"""" -var x = """ - "" [||] - """ -"""", + """" + var x = """ + [||] + """ + """", + """" + var x = """ + "" [||] + """ + """", afterUndo: -"""" -var x = """ - [||] - """ -""""); - } + """" + var x = """ + [||] + """ + """"); [WpfFact] public void TestNormalTextIntoSingleLineRawString_A() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """abc""", -"""" -var x = """ - [||] - """ -"""", -"""" -var x = """ - abc[||] - """ -"""", + """" + var x = """ + [||] + """ + """", + """" + var x = """ + abc[||] + """ + """", afterUndo: -"""" -var x = """ - [||] - """ -""""); - } + """" + var x = """ + [||] + """ + """"); [WpfFact] public void TestNormalTextIntoSingleLineRawStringSingleLine1_A() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """ abc def """, -"""" -var x = """ - [||] - """ -"""", -"""" -var x = """ - abc - def[||] - """ -"""", + """" + var x = """ + [||] + """ + """", + """" + var x = """ + abc + def[||] + """ + """", afterUndo: -"""" -var x = """ - abc -def[||] - """ -""""); - } + """" + var x = """ + abc + def[||] + """ + """"); [WpfFact] public void TestNormalTextIntoSingleLineRawStringSingleLine4() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """ abc def """, -"""" -var x = """ - goo[||] - """ -"""", -"""" -var x = """ - gooabc - def[||] - """ -"""", + """" + var x = """ + goo[||] + """ + """", + """" + var x = """ + gooabc + def[||] + """ + """", afterUndo: -"""" -var x = """ - gooabc -def[||] - """ -""""); - } + """" + var x = """ + gooabc + def[||] + """ + """"); [WpfFact] public void TestNormalTextIntoSingleLineRawStringSingleLine5() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """ abc def """, -"""" -var x = """ - goo[||]bar - """ -"""", -"""" -var x = """ - gooabc - def[||]bar - """ -"""", + """" + var x = """ + goo[||]bar + """ + """", + """" + var x = """ + gooabc + def[||]bar + """ + """", afterUndo: -"""" -var x = """ - gooabc -def[||]bar - """ -""""); - } + """" + var x = """ + gooabc + def[||]bar + """ + """"); [WpfFact] public void TestNormalTextIntoSingleLineRawStringSingleLine6() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """ abc def """, -"""" -var x = """ - goo[||]bar - """ -"""", -"""" -var x = """ - gooabc - def - [||]bar - """ -"""", + """" + var x = """ + goo[||]bar + """ + """", + """" + var x = """ + gooabc + def + [||]bar + """ + """", afterUndo: -"""" -var x = """ - gooabc -def -[||]bar - """ -""""); - } + """" + var x = """ + gooabc + def + [||]bar + """ + """"); [WpfFact] public void TestNormalTextIntoSingleLineRawStringSingleLine7_A() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """ abc def ghi """, -"""" -var x = """ - [||] - """ -"""", -"""" -var x = """ - abc - def - ghi[||] - """ -"""", + """" + var x = """ + [||] + """ + """", + """" + var x = """ + abc + def + ghi[||] + """ + """", afterUndo: -"""" -var x = """ - abc - def -ghi[||] - """ -""""); - } + """" + var x = """ + abc + def + ghi[||] + """ + """"); [WpfFact] public void TestNormalTextIntoSingleLineRawStringSingleLine7_B() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """ abc def ghi """, -"""" -var x = """ - [||] - """ -"""", -"""" -var x = """ - abc - def - ghi[||] - """ -"""", + """" + var x = """ + [||] + """ + """", + """" + var x = """ + abc + def + ghi[||] + """ + """", afterUndo: -"""" -var x = """ - abc - def -ghi[||] - """ -""""); - } + """" + var x = """ + abc + def + ghi[||] + """ + """"); [WpfFact] public void TestNormalTextIntoSingleLineRawStringSingleLine8_A() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """ abc def ghi """, -"""" -var x = """ - [||] - """ -"""", -"""" -var x = """ - abc - def - ghi[||] - """ -"""", + """" + var x = """ + [||] + """ + """", + """" + var x = """ + abc + def + ghi[||] + """ + """", afterUndo: -"""" -var x = """ - abc - def - ghi[||] - """ -""""); - } + """" + var x = """ + abc + def + ghi[||] + """ + """"); [WpfFact] public void TestNormalTextIntoSingleLineRawStringSingleLine9_A() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """ abc def ghi """, -"""" -var x = """ - [||] - """ -"""", -"""" -var x = """ - abc - def - ghi[||] - """ -"""", + """" + var x = """ + [||] + """ + """", + """" + var x = """ + abc + def + ghi[||] + """ + """", afterUndo: -"""" -var x = """ - abc - def - ghi[||] - """ -""""); - } + """" + var x = """ + abc + def + ghi[||] + """ + """"); [WpfFact] public void TestNormalTextIntoSingleLineRawStringSingleLine10_A() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """ abc def ghi """, -"""" -var x = """ - [||] - """ -"""", -"""" -var x = """ - abc - def - ghi[||] - """ -"""", + """" + var x = """ + [||] + """ + """", + """" + var x = """ + abc + def + ghi[||] + """ + """", afterUndo: -"""" -var x = """ - abc - def - ghi[||] - """ -""""); - } + """" + var x = """ + abc + def + ghi[||] + """ + """"); [WpfFact] public void TestNormalTextIntoSingleLineRawStringSingleLine11_A() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """ abc def """, -"""" -var x = """ - [||]{|Selection: |} - """ -"""", -"""" -var x = """ - abc - def[||] - """ -"""", + """" + var x = """ + [||]{|Selection: |} + """ + """", + """" + var x = """ + abc + def[||] + """ + """", afterUndo: -"""" -var x = """ - abc -def[||] - """ -""""); - } + """" + var x = """ + abc + def[||] + """ + """"); [WpfFact] public void TestNormalTextIntoSingleLineRawStringSingleLine12_A() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """ abc def """, -"""" -var x = """ - [||]{|Selection: |} - """ -"""", -"""" -var x = """ - abc - def - [||] - """ -"""", + """" + var x = """ + [||]{|Selection: |} + """ + """", + """" + var x = """ + abc + def + [||] + """ + """", afterUndo: -"""" -var x = """ - abc -def -[||] - """ -""""); - } + """" + var x = """ + abc + def + [||] + """ + """"); [WpfFact] public void TestNormalTextIntoSingleLineRawStringSingleLine13_A() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """ abc def """, -"""" -var x = """ - [||]{|Selection: |} - """ -"""", -"""" -var x = """ - abc - def[||] - """ -"""", + """" + var x = """ + [||]{|Selection: |} + """ + """", + """" + var x = """ + abc + def[||] + """ + """", afterUndo: -"""" -var x = """ - abc -def[||] - """ -""""); - } + """" + var x = """ + abc + def[||] + """ + """"); [WpfFact] public void TestNormalTextIntoSingleLineRawStringHeader1_A() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """ "bar """, -"""" -var x = """ - [||]goo - """ -"""", -"""" -var x = """ - "bar[||]goo - """ -"""", + """" + var x = """ + [||]goo + """ + """", + """" + var x = """ + "bar[||]goo + """ + """", afterUndo: -"""" -var x = """ - [||]goo - """ -""""); - } + """" + var x = """ + [||]goo + """ + """"); [WpfFact] public void TestQuotesIntoHeader1() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """ "" """, -"""" -var x = """ - [||]{|Selection: |} - """ -"""", -"""" -var x = """ - ""[||] - """ -"""", + """" + var x = """ + [||]{|Selection: |} + """ + """", + """" + var x = """ + ""[||] + """ + """", afterUndo: -"""" -var x = """ - [||] - """ -""""); - } + """" + var x = """ + [||] + """ + """"); [WpfFact] public void TestQuotesIntoHeader2() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """" """ """", -"""" -var x = """ - [||]{|Selection: |} - """ -"""", -""""" -var x = """" - """[||] - """" -""""", + """" + var x = """ + [||]{|Selection: |} + """ + """", + """"" + var x = """" + """[||] + """" + """"", afterUndo: -"""" -var x = """ - """[||] - """ -""""); - } + """" + var x = """ + """[||] + """ + """"); #endregion } diff --git a/src/EditorFeatures/CSharpTest/StringCopyPaste/PasteKnownSourceIntoNormalInterpolatedStringTests.cs b/src/EditorFeatures/CSharpTest/StringCopyPaste/PasteKnownSourceIntoNormalInterpolatedStringTests.cs index d20bfbbe90e6..fe348c65060c 100644 --- a/src/EditorFeatures/CSharpTest/StringCopyPaste/PasteKnownSourceIntoNormalInterpolatedStringTests.cs +++ b/src/EditorFeatures/CSharpTest/StringCopyPaste/PasteKnownSourceIntoNormalInterpolatedStringTests.cs @@ -10,8 +10,7 @@ public sealed class PasteKnownSourceIntoNormalInterpolatedStringTests : StringCo { [WpfFact] public void TestPasteSimpleNormalLiteralContent() - { - TestCopyPaste( + => TestCopyPaste( """var v = "{|Copy:goo|}";""", """ var dest = @@ -25,12 +24,10 @@ public void TestPasteSimpleNormalLiteralContent() var dest = $"[||]"; """); - } [WpfFact] public void TestPasteOpenBraceNormalLiteralContent() - { - TestCopyPaste( + => TestCopyPaste( """var v = "{|Copy:{|}";""", """ var dest = @@ -44,12 +41,10 @@ public void TestPasteOpenBraceNormalLiteralContent() var dest = $"{[||]"; """); - } [WpfFact] public void TestPasteOpenCloseBraceNormalLiteralContent() - { - TestCopyPaste( + => TestCopyPaste( """var v = "{|Copy:{}|}";""", """ var dest = @@ -63,12 +58,10 @@ public void TestPasteOpenCloseBraceNormalLiteralContent() var dest = $"{}[||]"; """); - } [WpfFact] public void TestPasteLooksLikeInterpolationNormalLiteralContent() - { - TestCopyPaste( + => TestCopyPaste( """var v = "{|Copy:{0}|}";""", """ var dest = @@ -82,12 +75,10 @@ public void TestPasteLooksLikeInterpolationNormalLiteralContent() var dest = $"{0}[||]"; """); - } [WpfFact] public void TestPasteSimpleSubstringNormalLiteralContent() - { - TestCopyPaste( + => TestCopyPaste( """var v = "g{|Copy:o|}o";""", """ var dest = @@ -101,12 +92,10 @@ public void TestPasteSimpleSubstringNormalLiteralContent() var dest = $"[||]"; """); - } [WpfFact] public void TestPastePartiallySelectedEscapeNormalLiteralContent() - { - TestCopyPaste( + => TestCopyPaste( """var v = "\{|Copy:n|}";""", """ var dest = @@ -120,12 +109,10 @@ public void TestPastePartiallySelectedEscapeNormalLiteralContent() var dest = $"[||]"; """); - } [WpfFact] public void TestPasteFullySelectedEscapeNormalLiteralContent() - { - TestCopyPaste( + => TestCopyPaste( """var v = "{|Copy:\n|}";""", """ var dest = @@ -139,12 +126,10 @@ public void TestPasteFullySelectedEscapeNormalLiteralContent() var dest = $"[||]"; """); - } [WpfFact] public void TestPastePartiallySelectedQuoteNormalLiteralContent() - { - TestCopyPaste( + => TestCopyPaste( """var v = "\{|Copy:"|}";""", """ var dest = @@ -158,12 +143,10 @@ public void TestPastePartiallySelectedQuoteNormalLiteralContent() var dest = $""[||]"; """); - } [WpfFact] public void TestPasteFullySelectedQuoteNormalLiteralContent() - { - TestCopyPaste( + => TestCopyPaste( """var v = "{|Copy:\"|}";""", """ var dest = @@ -177,11 +160,9 @@ public void TestPasteFullySelectedQuoteNormalLiteralContent() var dest = $"[||]"; """); - } [WpfFact] public void TestPasteSimpleVerbatimLiteralContent() - { - TestCopyPaste( + => TestCopyPaste( """var v = @"{|Copy:goo|}";""", """ var dest = @@ -195,12 +176,10 @@ public void TestPasteSimpleVerbatimLiteralContent() var dest = $"[||]"; """); - } [WpfFact] public void TestPasteSimpleSubstringVerbatimLiteralContent() - { - TestCopyPaste( + => TestCopyPaste( """var v = @"g{|Copy:o|}o";""", """ var dest = @@ -214,12 +193,10 @@ public void TestPasteSimpleSubstringVerbatimLiteralContent() var dest = $"[||]"; """); - } [WpfFact] public void TestPasteSelectedVerbatimNewLineLiteralContent() - { - TestCopyPaste( + => TestCopyPaste( """ var v = @"{|Copy: |}"; @@ -237,12 +214,10 @@ public void TestPasteSelectedVerbatimNewLineLiteralContent() $" [||]"; """); - } [WpfFact] public void TestPasteFullySelectedEscapeVerbatimLiteralContent() - { - TestCopyPaste( + => TestCopyPaste( """var v = @"{|Copy:""|}";""", """ var dest = @@ -256,12 +231,10 @@ public void TestPasteFullySelectedEscapeVerbatimLiteralContent() var dest = $"""[||]"; """"); - } [WpfFact] public void TestPasteSimpleRawSingleLineLiteralContent() - { - TestCopyPaste( + => TestCopyPaste( """"var v = """{|Copy:goo|}""";"""", """ var dest = @@ -275,12 +248,10 @@ public void TestPasteSimpleRawSingleLineLiteralContent() var dest = $"[||]"; """); - } [WpfFact] public void TestPasteQuotesRawSingleLineLiteralContent() - { - TestCopyPaste( + => TestCopyPaste( """"var v = """{|Copy: "" |}""";"""", """ var dest = @@ -294,12 +265,10 @@ public void TestPasteQuotesRawSingleLineLiteralContent() var dest = $" "" [||]"; """); - } [WpfFact] public void TestPasteSimpleRawMultiLineLiteralContent1() - { - TestCopyPaste( + => TestCopyPaste( """" var v = """ {|Copy:goo|} @@ -317,12 +286,10 @@ public void TestPasteSimpleRawMultiLineLiteralContent1() var dest = $"[||]"; """); - } [WpfFact] public void TestPasteSimpleRawMultiLineLiteralContent2() - { - TestCopyPaste( + => TestCopyPaste( """" var v = """ {|Copy:goo @@ -342,12 +309,10 @@ public void TestPasteSimpleRawMultiLineLiteralContent2() $"goo bar[||]"; """); - } [WpfFact] public void TestPasteSimpleRawMultiLineLiteralContent3() - { - TestCopyPaste( + => TestCopyPaste( """" var v = """ {|Copy: goo @@ -367,12 +332,10 @@ public void TestPasteSimpleRawMultiLineLiteralContent3() $" goo bar[||]"; """); - } [WpfFact] public void TestPasteInterpolationWithFormatClauseFromInterpolatedStringLiteralContent1() - { - TestCopyPaste( + => TestCopyPaste( """var v = $"{|Copy:{0:X}|}";""", """ var dest = @@ -386,12 +349,10 @@ public void TestPasteInterpolationWithFormatClauseFromInterpolatedStringLiteralC var dest = $"[||]"; """); - } [WpfFact] public void TestPasteInterpolationWithFormatClauseFromInterpolatedStringLiteralContent2() - { - TestCopyPaste( + => TestCopyPaste( """var v = $"{|Copy:{0:\"X\"}|}";""", """ var dest = @@ -405,12 +366,10 @@ public void TestPasteInterpolationWithFormatClauseFromInterpolatedStringLiteralC var dest = $"[||]"; """); - } [WpfFact] public void TestPasteInterpolationWithFormatClauseFromVerbatimInterpolatedStringLiteralContent1() - { - TestCopyPaste( + => TestCopyPaste( """var v = $@"{|Copy:{0:X}|}";""", """ var dest = @@ -424,12 +383,10 @@ public void TestPasteInterpolationWithFormatClauseFromVerbatimInterpolatedString var dest = $"[||]"; """); - } [WpfFact] public void TestPasteInterpolationWithFormatClauseFromVerbatimInterpolatedStringLiteralContent2() - { - TestCopyPaste( + => TestCopyPaste( """var v = $@"{|Copy:{0:""X""}|}";""", """ var dest = @@ -443,5 +400,4 @@ public void TestPasteInterpolationWithFormatClauseFromVerbatimInterpolatedString var dest = $"{0:""X""}[||]"; """); - } } diff --git a/src/EditorFeatures/CSharpTest/StringCopyPaste/PasteKnownSourceIntoNormalStringTests.cs b/src/EditorFeatures/CSharpTest/StringCopyPaste/PasteKnownSourceIntoNormalStringTests.cs index 9d7530aea625..940e2fb1e664 100644 --- a/src/EditorFeatures/CSharpTest/StringCopyPaste/PasteKnownSourceIntoNormalStringTests.cs +++ b/src/EditorFeatures/CSharpTest/StringCopyPaste/PasteKnownSourceIntoNormalStringTests.cs @@ -10,8 +10,7 @@ public sealed class PasteKnownSourceIntoNormalStringTests : StringCopyPasteComma { [WpfFact] public void TestPasteSimpleNormalLiteralContent() - { - TestCopyPaste( + => TestCopyPaste( """var v = "{|Copy:goo|}";""", """ var dest = @@ -25,12 +24,10 @@ public void TestPasteSimpleNormalLiteralContent() var dest = "[||]"; """); - } [WpfFact] public void TestPasteSimpleSubstringNormalLiteralContent() - { - TestCopyPaste( + => TestCopyPaste( """var v = "g{|Copy:o|}o";""", """ var dest = @@ -44,12 +41,10 @@ public void TestPasteSimpleSubstringNormalLiteralContent() var dest = "[||]"; """); - } [WpfFact] public void TestPastePartiallySelectedEscapeNormalLiteralContent() - { - TestCopyPaste( + => TestCopyPaste( """var v = "\{|Copy:n|}";""", """ var dest = @@ -63,12 +58,10 @@ public void TestPastePartiallySelectedEscapeNormalLiteralContent() var dest = "[||]"; """); - } [WpfFact] public void TestPasteFullySelectedEscapeNormalLiteralContent() - { - TestCopyPaste( + => TestCopyPaste( """var v = "{|Copy:\n|}";""", """ var dest = @@ -82,12 +75,10 @@ public void TestPasteFullySelectedEscapeNormalLiteralContent() var dest = "[||]"; """); - } [WpfFact] public void TestPastePartiallySelectedQuoteNormalLiteralContent() - { - TestCopyPaste( + => TestCopyPaste( """var v = "\{|Copy:"|}";""", """ var dest = @@ -101,12 +92,10 @@ public void TestPastePartiallySelectedQuoteNormalLiteralContent() var dest = ""[||]"; """); - } [WpfFact] public void TestPasteFullySelectedQuoteNormalLiteralContent() - { - TestCopyPaste( + => TestCopyPaste( """var v = "{|Copy:\"|}";""", """ var dest = @@ -120,12 +109,10 @@ public void TestPasteFullySelectedQuoteNormalLiteralContent() var dest = "[||]"; """); - } [WpfFact] public void TestPasteSimpleVerbatimLiteralContent() - { - TestCopyPaste( + => TestCopyPaste( """var v = @"{|Copy:goo|}";""", """ var dest = @@ -139,12 +126,10 @@ public void TestPasteSimpleVerbatimLiteralContent() var dest = "[||]"; """); - } [WpfFact] public void TestPasteSimpleSubstringVerbatimLiteralContent() - { - TestCopyPaste( + => TestCopyPaste( """var v = @"g{|Copy:o|}o";""", """ var dest = @@ -158,12 +143,10 @@ public void TestPasteSimpleSubstringVerbatimLiteralContent() var dest = "[||]"; """); - } [WpfFact] public void TestPasteSelectedVerbatimNewLineLiteralContent() - { - TestCopyPaste( + => TestCopyPaste( """ var v = @"{|Copy: |}"; @@ -181,12 +164,10 @@ public void TestPasteSelectedVerbatimNewLineLiteralContent() " [||]"; """); - } [WpfFact] public void TestPasteFullySelectedEscapeVerbatimLiteralContent() - { - TestCopyPaste( + => TestCopyPaste( """var v = @"{|Copy:""|}";""", """ var dest = @@ -200,12 +181,10 @@ public void TestPasteFullySelectedEscapeVerbatimLiteralContent() var dest = """[||]"; """"); - } [WpfFact] public void TestPasteSimpleRawSingleLineLiteralContent() - { - TestCopyPaste( + => TestCopyPaste( """"var v = """{|Copy:goo|}""";"""", """ var dest = @@ -219,12 +198,10 @@ public void TestPasteSimpleRawSingleLineLiteralContent() var dest = "[||]"; """); - } [WpfFact] public void TestPasteQuotesRawSingleLineLiteralContent() - { - TestCopyPaste( + => TestCopyPaste( """"var v = """{|Copy: "" |}""";"""", """ var dest = @@ -238,12 +215,10 @@ public void TestPasteQuotesRawSingleLineLiteralContent() var dest = " "" [||]"; """); - } [WpfFact] public void TestPasteSimpleRawMultiLineLiteralContent1() - { - TestCopyPaste( + => TestCopyPaste( """" var v = """ {|Copy:goo|} @@ -261,12 +236,10 @@ public void TestPasteSimpleRawMultiLineLiteralContent1() var dest = "[||]"; """); - } [WpfFact] public void TestPasteSimpleRawMultiLineLiteralContent2() - { - TestCopyPaste( + => TestCopyPaste( """" var v = """ {|Copy:goo @@ -286,12 +259,10 @@ public void TestPasteSimpleRawMultiLineLiteralContent2() "goo bar[||]"; """); - } [WpfFact] public void TestPasteSimpleRawMultiLineLiteralContent3() - { - TestCopyPaste( + => TestCopyPaste( """" var v = """ {|Copy: goo @@ -311,12 +282,10 @@ public void TestPasteSimpleRawMultiLineLiteralContent3() " goo bar[||]"; """); - } [WpfFact] public void TestPasteInterpolationFromInterpolatedStringLiteralContent() - { - TestCopyPaste( + => TestCopyPaste( """var v = $"{|Copy:{0}|}";""", """ var dest = @@ -330,12 +299,10 @@ public void TestPasteInterpolationFromInterpolatedStringLiteralContent() var dest = "[||]"; """); - } [WpfFact] public void TestPasteInterpolationWithFormatClauseFromInterpolatedStringLiteralContent1() - { - TestCopyPaste( + => TestCopyPaste( """var v = $"{|Copy:{0:X}|}";""", """ var dest = @@ -349,12 +316,10 @@ public void TestPasteInterpolationWithFormatClauseFromInterpolatedStringLiteralC var dest = "[||]"; """); - } [WpfFact] public void TestPasteInterpolationWithFormatClauseFromInterpolatedStringLiteralContent2() - { - TestCopyPaste( + => TestCopyPaste( """var v = $"{|Copy:{0:\"X\"}|}";""", """ var dest = @@ -368,12 +333,10 @@ public void TestPasteInterpolationWithFormatClauseFromInterpolatedStringLiteralC var dest = "[||]"; """); - } [WpfFact] public void TestPasteInterpolationWithStringFromInterpolatedStringLiteralContent1() - { - TestCopyPaste( + => TestCopyPaste( """var v = $"{|Copy:{"goo"}|}";""", """ var dest = @@ -387,12 +350,10 @@ public void TestPasteInterpolationWithStringFromInterpolatedStringLiteralContent var dest = "{"goo"}[||]"; """); - } [WpfFact] public void TestPasteInterpolationWithStringFromInterpolatedStringLiteralContent2() - { - TestCopyPaste( + => TestCopyPaste( """var v = $"{|Copy:X{"goo"}Y|}";""", """ var dest = @@ -406,12 +367,10 @@ public void TestPasteInterpolationWithStringFromInterpolatedStringLiteralContent var dest = "X{"goo"}Y[||]"; """); - } [WpfFact] public void TestPasteInterpolationWithStringFromInterpolatedStringLiteralContent3() - { - TestCopyPaste( + => TestCopyPaste( """var v = $"{|Copy:\"X{"goo"}Y\"|}";""", """ var dest = @@ -425,12 +384,10 @@ public void TestPasteInterpolationWithStringFromInterpolatedStringLiteralContent var dest = "\"X{"goo"}Y\"[||]"; """); - } [WpfFact] public void TestPasteInterpolationWithStringFromInterpolatedStringLiteralContent4() - { - TestCopyPaste( + => TestCopyPaste( """var v = $"{|Copy:\"X{@"goo"}Y\"|}";""", """ var dest = @@ -444,12 +401,10 @@ public void TestPasteInterpolationWithStringFromInterpolatedStringLiteralContent var dest = "\"X{@"goo"}Y\"[||]"; """); - } [WpfFact] public void TestPasteInterpolationFromVerbatimInterpolatedStringLiteralContent() - { - TestCopyPaste( + => TestCopyPaste( """var v = $@"{|Copy:{0}|}";""", """ var dest = @@ -463,12 +418,10 @@ public void TestPasteInterpolationFromVerbatimInterpolatedStringLiteralContent() var dest = "[||]"; """); - } [WpfFact] public void TestPasteInterpolationWithFormatClauseFromVerbatimInterpolatedStringLiteralContent1() - { - TestCopyPaste( + => TestCopyPaste( """var v = $@"{|Copy:{0:X}|}";""", """ var dest = @@ -482,12 +435,10 @@ public void TestPasteInterpolationWithFormatClauseFromVerbatimInterpolatedString var dest = "[||]"; """); - } [WpfFact] public void TestPasteInterpolationWithFormatClauseFromVerbatimInterpolatedStringLiteralContent2() - { - TestCopyPaste( + => TestCopyPaste( """var v = $@"{|Copy:{0:""X""}|}";""", """ var dest = @@ -501,12 +452,10 @@ public void TestPasteInterpolationWithFormatClauseFromVerbatimInterpolatedString var dest = "{0:""X""}[||]"; """); - } [WpfFact] public void TestPasteInterpolationWithStringFromVerbatimInterpolatedStringLiteralContent1() - { - TestCopyPaste( + => TestCopyPaste( """var v = $@"{|Copy:{"goo"}|}";""", """ var dest = @@ -520,12 +469,10 @@ public void TestPasteInterpolationWithStringFromVerbatimInterpolatedStringLitera var dest = "{"goo"}[||]"; """); - } [WpfFact] public void TestPasteInterpolationWithStringFromVerbatimInterpolatedStringLiteralContent2() - { - TestCopyPaste( + => TestCopyPaste( """var v = $@"{|Copy:X{"goo"}Y|}";""", """ var dest = @@ -539,12 +486,10 @@ public void TestPasteInterpolationWithStringFromVerbatimInterpolatedStringLitera var dest = "X{"goo"}Y[||]"; """); - } [WpfFact] public void TestPasteInterpolationWithStringFromVerbatimInterpolatedStringLiteralContent3() - { - TestCopyPaste( + => TestCopyPaste( """var v = $@"{|Copy:""X{"goo"}Y""|}";""", """ var dest = @@ -558,12 +503,10 @@ public void TestPasteInterpolationWithStringFromVerbatimInterpolatedStringLitera var dest = """X{"goo"}Y""[||]"; """"); - } [WpfFact] public void TestPasteInterpolationWithStringFromVerbatimInterpolatedStringLiteralContent4() - { - TestCopyPaste( + => TestCopyPaste( """var v = $@"{|Copy:""X{@"goo"}Y""|}";""", """ var dest = @@ -577,5 +520,4 @@ public void TestPasteInterpolationWithStringFromVerbatimInterpolatedStringLitera var dest = """X{@"goo"}Y""[||]"; """"); - } } diff --git a/src/EditorFeatures/CSharpTest/StringCopyPaste/PasteKnownSourceIntoSingleLineRawInterpolatedStringTests.cs b/src/EditorFeatures/CSharpTest/StringCopyPaste/PasteKnownSourceIntoSingleLineRawInterpolatedStringTests.cs index 0b3ac3b94470..2a396aea4132 100644 --- a/src/EditorFeatures/CSharpTest/StringCopyPaste/PasteKnownSourceIntoSingleLineRawInterpolatedStringTests.cs +++ b/src/EditorFeatures/CSharpTest/StringCopyPaste/PasteKnownSourceIntoSingleLineRawInterpolatedStringTests.cs @@ -14,8 +14,7 @@ public sealed class PasteKnownSourceIntoSingleLineRawInterpolatedStringTests : S [WpfFact] public void TestPasteSimpleNormalLiteralContent() - { - TestCopyPaste( + => TestCopyPaste( """var v = "{|Copy:goo|}";""", """" var dest = @@ -29,12 +28,10 @@ public void TestPasteSimpleNormalLiteralContent() var dest = $"""[||] """; """"); - } [WpfFact] public void TestPasteSimpleNormalLiteralContent2() - { - TestCopyPaste( + => TestCopyPaste( """var v = "{|Copy:goo|}";""", """" var dest = @@ -48,12 +45,10 @@ public void TestPasteSimpleNormalLiteralContent2() var dest = $""" [||]"""; """"); - } [WpfFact] public void TestPasteOpenBraceNormalLiteralContent() - { - TestCopyPaste( + => TestCopyPaste( """var v = "{|Copy:{|}";""", """" var dest = @@ -67,12 +62,10 @@ public void TestPasteOpenBraceNormalLiteralContent() var dest = $"""{[||] """; """"); - } [WpfFact] public void TestPasteOpenBraceNormalLiteralContent2() - { - TestCopyPaste( + => TestCopyPaste( """var v = "{|Copy:{|}";""", """" var dest = @@ -86,12 +79,10 @@ public void TestPasteOpenBraceNormalLiteralContent2() var dest = $""" {[||]"""; """"); - } [WpfFact] public void TestPasteOpenCloseBraceNormalLiteralContent() - { - TestCopyPaste( + => TestCopyPaste( """var v = "{|Copy:{}|}";""", """" var dest = @@ -105,12 +96,10 @@ public void TestPasteOpenCloseBraceNormalLiteralContent() var dest = $"""{}[||] """; """"); - } [WpfFact] public void TestPasteOpenCloseBraceNormalLiteralContent2() - { - TestCopyPaste( + => TestCopyPaste( """var v = "{|Copy:{}|}";""", """" var dest = @@ -124,12 +113,10 @@ public void TestPasteOpenCloseBraceNormalLiteralContent2() var dest = $""" {}[||]"""; """"); - } [WpfFact] public void TestPasteLooksLikeInterpolationNormalLiteralContent() - { - TestCopyPaste( + => TestCopyPaste( """var v = "{|Copy:{0}|}";""", """" var dest = @@ -143,12 +130,10 @@ public void TestPasteLooksLikeInterpolationNormalLiteralContent() var dest = $"""{0}[||] """; """"); - } [WpfFact] public void TestPasteLooksLikeInterpolationNormalLiteralContent2() - { - TestCopyPaste( + => TestCopyPaste( """var v = "{|Copy:{0}|}";""", """" var dest = @@ -162,12 +147,10 @@ public void TestPasteLooksLikeInterpolationNormalLiteralContent2() var dest = $""" {0}[||]"""; """"); - } [WpfFact] public void TestPasteSimpleSubstringNormalLiteralContent() - { - TestCopyPaste( + => TestCopyPaste( """var v = "g{|Copy:o|}o";""", """" var dest = @@ -181,12 +164,10 @@ public void TestPasteSimpleSubstringNormalLiteralContent() var dest = $"""[||] """; """"); - } [WpfFact] public void TestPasteSimpleSubstringNormalLiteralContent2() - { - TestCopyPaste( + => TestCopyPaste( """var v = "g{|Copy:o|}o";""", """" var dest = @@ -200,12 +181,10 @@ public void TestPasteSimpleSubstringNormalLiteralContent2() var dest = $""" [||]"""; """"); - } [WpfFact] public void TestPastePartiallySelectedEscapeNormalLiteralContent() - { - TestCopyPaste( + => TestCopyPaste( """var v = "\{|Copy:n|}";""", """" var dest = @@ -219,12 +198,10 @@ public void TestPastePartiallySelectedEscapeNormalLiteralContent() var dest = $"""[||] """; """"); - } [WpfFact] public void TestPastePartiallySelectedEscapeNormalLiteralContent2() - { - TestCopyPaste( + => TestCopyPaste( """var v = "\{|Copy:n|}";""", """" var dest = @@ -238,12 +215,10 @@ public void TestPastePartiallySelectedEscapeNormalLiteralContent2() var dest = $""" [||]"""; """"); - } [WpfFact] public void TestPasteFullySelectedEscapeNormalLiteralContent() - { - TestCopyPaste( + => TestCopyPaste( """var v = "{|Copy:\n|}";""", """" var dest = @@ -254,12 +229,10 @@ public void TestPasteFullySelectedEscapeNormalLiteralContent() var dest = $"""\n[||] """; """"); - } [WpfFact(Skip = "Investigating")] public void TestPasteFullySelectedEscapeNormalLiteralContent2() - { - TestCopyPaste( + => TestCopyPaste( """var v = "{|Copy:\n|}";""", """" var dest = @@ -276,12 +249,10 @@ public void TestPasteFullySelectedEscapeNormalLiteralContent2() var dest = $""" \n[||]"""; """"); - } [WpfFact] public void TestPastePartiallySelectedQuoteNormalLiteralContent() - { - TestCopyPaste( + => TestCopyPaste( """var v = "\{|Copy:"|}";""", """" var dest = @@ -297,12 +268,10 @@ public void TestPastePartiallySelectedQuoteNormalLiteralContent() var dest = $""""[||] """; """""); - } [WpfFact] public void TestPastePartiallySelectedQuoteNormalLiteralContent2() - { - TestCopyPaste( + => TestCopyPaste( """var v = "\{|Copy:"|}";""", """" var dest = @@ -318,12 +287,10 @@ public void TestPastePartiallySelectedQuoteNormalLiteralContent2() var dest = $""" "[||]"""; """"); - } [WpfFact] public void TestPasteFullySelectedQuoteNormalLiteralContent() - { - TestCopyPaste( + => TestCopyPaste( """var v = "{|Copy:\"|}";""", """" var dest = @@ -339,12 +306,10 @@ public void TestPasteFullySelectedQuoteNormalLiteralContent() var dest = $"""\"[||] """; """"); - } [WpfFact] public void TestPasteFullySelectedQuoteNormalLiteralContent2() - { - TestCopyPaste( + => TestCopyPaste( """var v = "{|Copy:\"|}";""", """" var dest = @@ -360,12 +325,10 @@ public void TestPasteFullySelectedQuoteNormalLiteralContent2() var dest = $""" \"[||]"""; """"); - } [WpfFact] public void TestPasteSimpleVerbatimLiteralContent() - { - TestCopyPaste( + => TestCopyPaste( """var v = @"{|Copy:goo|}";""", """" var dest = @@ -379,12 +342,10 @@ public void TestPasteSimpleVerbatimLiteralContent() var dest = $"""[||] """; """"); - } [WpfFact] public void TestPasteSimpleVerbatimLiteralContent2() - { - TestCopyPaste( + => TestCopyPaste( """var v = @"{|Copy:goo|}";""", """" var dest = @@ -398,12 +359,10 @@ public void TestPasteSimpleVerbatimLiteralContent2() var dest = $""" [||]"""; """"); - } [WpfFact] public void TestPasteSimpleSubstringVerbatimLiteralContent() - { - TestCopyPaste( + => TestCopyPaste( """var v = @"g{|Copy:o|}o";""", """" var dest = @@ -417,12 +376,10 @@ public void TestPasteSimpleSubstringVerbatimLiteralContent() var dest = $"""[||] """; """"); - } [WpfFact] public void TestPasteSimpleSubstringVerbatimLiteralContent2() - { - TestCopyPaste( + => TestCopyPaste( """var v = @"g{|Copy:o|}o";""", """" var dest = @@ -436,12 +393,10 @@ public void TestPasteSimpleSubstringVerbatimLiteralContent2() var dest = $""" [||]"""; """"); - } [WpfFact] public void TestPasteSelectedVerbatimNewLineLiteralContent() - { - TestCopyPaste( + => TestCopyPaste( """ var v = @"{|Copy: |}"; @@ -462,12 +417,10 @@ public void TestPasteSelectedVerbatimNewLineLiteralContent() $""" [||] """; """"); - } [WpfFact] public void TestPasteSelectedVerbatimNewLineLiteralContent2() - { - TestCopyPaste( + => TestCopyPaste( """ var v = @"{|Copy: |}"; @@ -488,12 +441,10 @@ public void TestPasteSelectedVerbatimNewLineLiteralContent2() $""" [||]"""; """"); - } [WpfFact] public void TestPasteFullySelectedEscapeVerbatimLiteralContent() - { - TestCopyPaste( + => TestCopyPaste( """var v = @"{|Copy:""|}";""", """" var dest = @@ -509,12 +460,10 @@ public void TestPasteFullySelectedEscapeVerbatimLiteralContent() var dest = $"""""[||] """; """"""); - } [WpfFact] public void TestPasteFullySelectedEscapeVerbatimLiteralContent2() - { - TestCopyPaste( + => TestCopyPaste( """var v = @"{|Copy:""|}";""", """" var dest = @@ -530,12 +479,10 @@ public void TestPasteFullySelectedEscapeVerbatimLiteralContent2() var dest = $""" ""[||]"""; """"); - } [WpfFact] public void TestPasteSimpleRawSingleLineLiteralContent() - { - TestCopyPaste( + => TestCopyPaste( """"var v = """{|Copy:goo|}""";"""", """" var dest = @@ -549,12 +496,10 @@ public void TestPasteSimpleRawSingleLineLiteralContent() var dest = $"""[||] """; """"); - } [WpfFact] public void TestPasteSimpleRawSingleLineLiteralContent2() - { - TestCopyPaste( + => TestCopyPaste( """"var v = """{|Copy:goo|}""";"""", """" var dest = @@ -568,12 +513,10 @@ public void TestPasteSimpleRawSingleLineLiteralContent2() var dest = $""" [||]"""; """"); - } [WpfFact] public void TestPasteQuotesRawSingleLineLiteralContent() - { - TestCopyPaste( + => TestCopyPaste( """"var v = """{|Copy: "" |}""";"""", """" var dest = @@ -587,12 +530,10 @@ public void TestPasteQuotesRawSingleLineLiteralContent() var dest = $"""[||] """; """"); - } [WpfFact] public void TestPasteQuotesRawSingleLineLiteralContent2() - { - TestCopyPaste( + => TestCopyPaste( """"var v = """{|Copy: "" |}""";"""", """" var dest = @@ -606,12 +547,10 @@ public void TestPasteQuotesRawSingleLineLiteralContent2() var dest = $""" [||]"""; """"); - } [WpfFact] public void TestPasteSimpleRawMultiLineLiteralContent1() - { - TestCopyPaste( + => TestCopyPaste( """" var v = """ {|Copy:goo|} @@ -629,12 +568,10 @@ public void TestPasteSimpleRawMultiLineLiteralContent1() var dest = $"""[||] """; """"); - } [WpfFact] public void TestPasteSimpleRawMultiLineLiteralContent1B() - { - TestCopyPaste( + => TestCopyPaste( """" var v = """ {|Copy:goo|} @@ -652,12 +589,10 @@ public void TestPasteSimpleRawMultiLineLiteralContent1B() var dest = $""" [||]"""; """"); - } [WpfFact] public void TestPasteSimpleRawMultiLineLiteralContent2() - { - TestCopyPaste( + => TestCopyPaste( """" var v = """ {|Copy:goo @@ -680,12 +615,10 @@ public void TestPasteSimpleRawMultiLineLiteralContent2() $"""goo bar[||] """; """"); - } [WpfFact] public void TestPasteSimpleRawMultiLineLiteralContent2B() - { - TestCopyPaste( + => TestCopyPaste( """" var v = """ {|Copy:goo @@ -708,12 +641,10 @@ public void TestPasteSimpleRawMultiLineLiteralContent2B() $""" goo bar[||]"""; """"); - } [WpfFact] public void TestPasteSimpleRawMultiLineLiteralContent3() - { - TestCopyPaste( + => TestCopyPaste( """" var v = """ {|Copy: goo @@ -736,12 +667,10 @@ public void TestPasteSimpleRawMultiLineLiteralContent3() $""" goo bar[||] """; """"); - } [WpfFact] public void TestPasteSimpleRawMultiLineLiteralContent3B() - { - TestCopyPaste( + => TestCopyPaste( """" var v = """ {|Copy: goo @@ -764,12 +693,10 @@ public void TestPasteSimpleRawMultiLineLiteralContent3B() $""" goo bar[||]"""; """"); - } [WpfFact] public void TestPasteInterpolationWithFormatClauseFromInterpolatedStringLiteralContent1() - { - TestCopyPaste( + => TestCopyPaste( """var v = $"{|Copy:{0:X}|}";""", """" var dest = @@ -783,12 +710,10 @@ public void TestPasteInterpolationWithFormatClauseFromInterpolatedStringLiteralC var dest = $"""[||] """; """"); - } [WpfFact] public void TestPasteInterpolationWithFormatClauseFromInterpolatedStringLiteralContent1B() - { - TestCopyPaste( + => TestCopyPaste( """var v = $"{|Copy:{0:X}|}";""", """" var dest = @@ -802,12 +727,10 @@ public void TestPasteInterpolationWithFormatClauseFromInterpolatedStringLiteralC var dest = $""" [||]"""; """"); - } [WpfFact] public void TestPasteInterpolationWithFormatClauseFromInterpolatedStringLiteralContent2() - { - TestCopyPaste( + => TestCopyPaste( """var v = $"{|Copy:{0:\"X\"}|}";""", """" var dest = @@ -821,12 +744,10 @@ public void TestPasteInterpolationWithFormatClauseFromInterpolatedStringLiteralC var dest = $"""{0:\"X\"}[||] """; """"); - } [WpfFact] public void TestPasteInterpolationWithFormatClauseFromInterpolatedStringLiteralContent2B() - { - TestCopyPaste( + => TestCopyPaste( """var v = $"{|Copy:{0:\"X\"}|}";""", """" var dest = @@ -840,12 +761,10 @@ public void TestPasteInterpolationWithFormatClauseFromInterpolatedStringLiteralC var dest = $""" {0:\"X\"}[||]"""; """"); - } [WpfFact] public void TestPasteInterpolationWithFormatClauseFromVerbatimInterpolatedStringLiteralContent1() - { - TestCopyPaste( + => TestCopyPaste( """var v = $@"{|Copy:{0:X}|}";""", """" var dest = @@ -859,12 +778,10 @@ public void TestPasteInterpolationWithFormatClauseFromVerbatimInterpolatedString var dest = $"""[||] """; """"); - } [WpfFact] public void TestPasteInterpolationWithFormatClauseFromVerbatimInterpolatedStringLiteralContent1B() - { - TestCopyPaste( + => TestCopyPaste( """var v = $@"{|Copy:{0:X}|}";""", """" var dest = @@ -878,12 +795,10 @@ public void TestPasteInterpolationWithFormatClauseFromVerbatimInterpolatedString var dest = $""" [||]"""; """"); - } [WpfFact] public void TestPasteInterpolationWithFormatClauseFromVerbatimInterpolatedStringLiteralContent2() - { - TestCopyPaste( + => TestCopyPaste( """var v = $@"{|Copy:{0:""X""}|}";""", """" var dest = @@ -897,12 +812,10 @@ public void TestPasteInterpolationWithFormatClauseFromVerbatimInterpolatedString var dest = $"""{0:""X""}[||] """; """"); - } [WpfFact] public void TestPasteInterpolationWithFormatClauseFromVerbatimInterpolatedStringLiteralContent2B() - { - TestCopyPaste( + => TestCopyPaste( """var v = $@"{|Copy:{0:""X""}|}";""", """" var dest = @@ -916,7 +829,6 @@ public void TestPasteInterpolationWithFormatClauseFromVerbatimInterpolatedString var dest = $""" {0:""X""}[||]"""; """"); - } #endregion @@ -927,1243 +839,1125 @@ public void TestPasteInterpolationWithFormatClauseFromVerbatimInterpolatedString [WpfFact] public void TestNewLineIntoSingleLineRawString1_A() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: "\n", -"""" -var x = $"""[||] """ -"""", -"var x = $\"\"\"\r\n \n [||] \r\n \"\"\"", + """" + var x = $"""[||] """ + """", + "var x = $\"\"\"\r\n \n [||] \r\n \"\"\"", afterUndo: -"var x = $\"\"\"\n[||] \"\"\""); - } + "var x = $\"\"\"\n[||] \"\"\""); [WpfFact] public void TestNewLineIntoSingleLineRawString1_B() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: "\n", -"""" -var x = $""" [||]""" -"""", -"var x = $\"\"\"\r\n \n \r\n [||]\"\"\"", + """" + var x = $""" [||]""" + """", + "var x = $\"\"\"\r\n \n \r\n [||]\"\"\"", afterUndo: -"var x = $\"\"\" \n[||]\"\"\""); - } + "var x = $\"\"\" \n[||]\"\"\""); [WpfFact] public void TestNewLineIntoSingleLineRawString2_A() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """ """, -"""" -var x = $"""[||] """ -"""", -"""" -var x = $""" - - [||] - """ -"""", + """" + var x = $"""[||] """ + """", + """" + var x = $""" + + [||] + """ + """", afterUndo: -"""" -var x = $""" -[||] """ -""""); - } + """" + var x = $""" + [||] """ + """"); [WpfFact] public void TestNewLineIntoSingleLineRawString2_B() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """ """, -"""" -var x = $""" [||]""" -"""", -"""" -var x = $""" - - - [||]""" -"""", + """" + var x = $""" [||]""" + """", + """" + var x = $""" + + + [||]""" + """", afterUndo: -"""" -var x = $""" -[||]""" -""""); - } + """" + var x = $""" + [||]""" + """"); [WpfFact] public void TestSpacesIntoSingleLineRawString1_A() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """ """, -"""" -var x = $"""[||] """ -"""", -"""" -var x = $""" [||] """ -"""", + """" + var x = $"""[||] """ + """", + """" + var x = $""" [||] """ + """", afterUndo: -"""" -var x = $"""[||] """ -""""); - } + """" + var x = $"""[||] """ + """"); [WpfFact] public void TestSpacesIntoSingleLineRawString1_B() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """ """, -"""" -var x = $""" [||]""" -"""", -"""" -var x = $""" [||]""" -"""", + """" + var x = $""" [||]""" + """", + """" + var x = $""" [||]""" + """", afterUndo: -"""" -var x = $""" [||]""" -""""); - } + """" + var x = $""" [||]""" + """"); [WpfFact] public void TestSpacesIntoSingleLineRawString2() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """ """, -"""" -var x = $""" - [||] - """ -"""", -"""" -var x = $""" - - [||] - """ -"""", + """" + var x = $""" + [||] + """ + """", + """" + var x = $""" + + [||] + """ + """", afterUndo: -"""" -var x = $""" - -[||] - """ -""""); - } + """" + var x = $""" + + [||] + """ + """"); [WpfFact] public void TestSingleQuoteIntoSingleLineRawString_A() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """'""", -"""" -var x = $"""[||] """ -"""", -"""" -var x = $"""'[||] """ -"""", + """" + var x = $"""[||] """ + """", + """" + var x = $"""'[||] """ + """", afterUndo: -"""" -var x = $"""[||] """ -""""); - } + """" + var x = $"""[||] """ + """"); [WpfFact] public void TestSingleQuoteIntoSingleLineRawString_B() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """'""", -"""" -var x = $""" [||]""" -"""", -"""" -var x = $""" '[||]""" -"""", + """" + var x = $""" [||]""" + """", + """" + var x = $""" '[||]""" + """", afterUndo: -"""" -var x = $""" [||]""" -""""); - } + """" + var x = $""" [||]""" + """"); [WpfFact] public void TestDoubleQuoteIntoSingleLineRawString_A() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """ " """, -"""" -var x = $"""[||] """ -"""", -"""" -var x = $""" - "[||] - """ -"""", + """" + var x = $"""[||] """ + """", + """" + var x = $""" + "[||] + """ + """", afterUndo: -""""" -var x = $""""[||] """ -"""""); - } + """"" + var x = $""""[||] """ + """""); [WpfFact] public void TestDoubleQuoteIntoSingleLineRawString_B() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """ " """, -"""" -var x = $""" [||]""" -"""", -"""" -var x = $""" - " - [||]""" -"""", + """" + var x = $""" [||]""" + """", + """" + var x = $""" + " + [||]""" + """", afterUndo: -"""" -var x = $""" "[||]""" -""""); - } + """" + var x = $""" "[||]""" + """"); [WpfFact] public void TestTripleQuoteIntoSingleLineRawString1_A() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """" """ """", -"""" -var x = $"""[||] """ -"""", -""""" -var x = $"""" - """[||] - """" -""""", + """" + var x = $"""[||] """ + """", + """"" + var x = $"""" + """[||] + """" + """"", afterUndo: -""""""" -var x = $""""""[||] """ -"""""""); - } + """"""" + var x = $""""""[||] """ + """""""); [WpfFact] public void TestTripleQuoteIntoSingleLineRawString1_B() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """" """ """", -"""" -var x = $""" [||]""" -"""", -""""" -var x = $"""" - """ - [||]"""" -""""", + """" + var x = $""" [||]""" + """", + """"" + var x = $"""" + """ + [||]"""" + """"", afterUndo: -"""" -var x = $""" """[||]""" -""""); - } + """" + var x = $""" """[||]""" + """"); [WpfFact] public void TestTripleQuoteIntoSingleLineRawString3() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """" """ """", -"""" -var x = $""" "[||] """ -"""", -"""""" -var x = $""""" """"[||] """"" -"""""", + """" + var x = $""" "[||] """ + """", + """""" + var x = $""""" """"[||] """"" + """""", afterUndo: -""""" -var x = $""" """"[||] """ -"""""); - } + """"" + var x = $""" """"[||] """ + """""); [WpfFact] public void TestTripleQuoteIntoSingleLineRawString4() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """" """ """", -"""" -var x = $""" "[||]" """ -"""", -""""""" -var x = $"""""" """"[||]" """""" -""""""", + """" + var x = $""" "[||]" """ + """", + """"""" + var x = $"""""" """"[||]" """""" + """"""", afterUndo: -""""" -var x = $""" """"[||]" """ -"""""); - } + """"" + var x = $""" """"[||]" """ + """""); [WpfFact] public void TestTripleQuoteIntoSingleLineRawString5() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """" """ """", -"""" -var x = $""" [||]" """ -"""", -"""""" -var x = $""""" """[||]" """"" -"""""", + """" + var x = $""" [||]" """ + """", + """""" + var x = $""""" """[||]" """"" + """""", afterUndo: -"""" -var x = $""" """[||]" """ -""""); - } + """" + var x = $""" """[||]" """ + """"); [WpfFact] public void TestQuadrupleQuoteIntoSingleLineRawString() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """"" """" """"", -"""" -var x = $""" - [||] - """ -"""", -"""""" -var x = $""""" - """"[||] - """"" -"""""", + """" + var x = $""" + [||] + """ + """", + """""" + var x = $""""" + """"[||] + """"" + """""", afterUndo: -""""" -var x = $""" - """"[||] - """ -"""""); - } + """"" + var x = $""" + """"[||] + """ + """""); [WpfFact] public void TestOpenCurlyIntoSingleLineRawString_A() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """{""", -"""" -var x = $"""[||] """ -"""", -"""" -var x = $$"""{[||] """ -"""", + """" + var x = $"""[||] """ + """", + """" + var x = $$"""{[||] """ + """", afterUndo: -"""" -var x = $"""{[||] """ -""""); - } + """" + var x = $"""{[||] """ + """"); [WpfFact] public void TestOpenCurlyIntoSingleLineRawString_B() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """{""", -"""" -var x = $""" [||]""" -"""", -"""" -var x = $$""" {[||]""" -"""", + """" + var x = $""" [||]""" + """", + """" + var x = $$""" {[||]""" + """", afterUndo: -"""" -var x = $""" {[||]""" -""""); - } + """" + var x = $""" {[||]""" + """"); [WpfFact] public void TestOpenQuoteAndTripleOpenBraceIntoSingleLineRawString1() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """ "{{{ """, -"""" -var x = $"""[||] """ -"""", -"""" -var x = $$$$""" - "{{{[||] - """ -"""", + """" + var x = $"""[||] """ + """", + """" + var x = $$$$""" + "{{{[||] + """ + """", afterUndo: -""""" -var x = $""""{{{[||] """ -"""""); - } + """"" + var x = $""""{{{[||] """ + """""); [WpfFact] public void TestTripleOpenQuoteAndTripleOpenBraceIntoSingleLineRawString1() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """" """{{{ """", -"""" -var x = $"""[||] """ -"""", -""""" -var x = $$$$"""" - """{{{[||] - """" -""""", + """" + var x = $"""[||] """ + """", + """"" + var x = $$$$"""" + """{{{[||] + """" + """"", afterUndo: -""""""" -var x = $""""""{{{[||] """ -"""""""); - } + """"""" + var x = $""""""{{{[||] """ + """""""); [WpfFact] public void TestTripleOpenQuoteAndTripleOpenBraceIntoSingleLineRawString2() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """" """{{{"""", -"""" -var x = $"""[||] """ -"""", -""""" -var x = $$$$"""" """{{{[||] """" -""""", + """" + var x = $"""[||] """ + """", + """"" + var x = $$$$"""" """{{{[||] """" + """"", afterUndo: -"""" -var x = $""" """{{{[||] """ -""""); - } + """" + var x = $""" """{{{[||] """ + """"); [WpfFact] public void TestTripleOpenBraceIntoSingleLineRawString1_A() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """{{{""", -"""" -var x = $"""[||] """ -"""", -"""" -var x = $$$$"""{{{[||] """ -"""", + """" + var x = $"""[||] """ + """", + """" + var x = $$$$"""{{{[||] """ + """", afterUndo: -"""" -var x = $"""{{{[||] """ -""""); - } + """" + var x = $"""{{{[||] """ + """"); [WpfFact] public void TestTripleOpenBraceIntoSingleLineRawString1_B() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """{{{""", -"""" -var x = $""" [||]""" -"""", -"""" -var x = $$$$""" {{{[||]""" -"""", + """" + var x = $""" [||]""" + """", + """" + var x = $$$$""" {{{[||]""" + """", afterUndo: -"""" -var x = $""" {{{[||]""" -""""); - } + """" + var x = $""" {{{[||]""" + """"); [WpfFact] public void TestTripleOpenBraceIntoSingleLineRawString3() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """{{{""", -"""" -var x = $""" "[||] """ -"""", -"""" -var x = $$$$""" "{{{[||] """ -"""", + """" + var x = $""" "[||] """ + """", + """" + var x = $$$$""" "{{{[||] """ + """", afterUndo: -"""" -var x = $""" "{{{[||] """ -""""); - } + """" + var x = $""" "{{{[||] """ + """"); [WpfFact] public void TestTripleOpenBraceIntoSingleLineRawString4() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """{{{""", -"""" -var x = $""" "[||]" """ -"""", -"""" -var x = $$$$""" "{{{[||]" """ -"""", + """" + var x = $""" "[||]" """ + """", + """" + var x = $$$$""" "{{{[||]" """ + """", afterUndo: -"""" -var x = $""" "{{{[||]" """ -""""); - } + """" + var x = $""" "{{{[||]" """ + """"); [WpfFact] public void TestTripleOpenBraceIntoSingleLineRawString5() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """{{{""", -"""" -var x = $""" [||]" """ -"""", -"""" -var x = $$$$""" {{{[||]" """ -"""", + """" + var x = $""" [||]" """ + """", + """" + var x = $$$$""" {{{[||]" """ + """", afterUndo: -"""" -var x = $""" {{{[||]" """ -""""); - } + """" + var x = $""" {{{[||]" """ + """"); [WpfFact] public void TestInterpolationIntoSingleLineRawString1() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """{0}""", -"""" -var x = $""" [||] """ -"""", -"""" -var x = $$""" {0}[||] """ -"""", + """" + var x = $""" [||] """ + """", + """" + var x = $$""" {0}[||] """ + """", afterUndo: -"""" -var x = $""" {0}[||] """ -""""); - } + """" + var x = $""" {0}[||] """ + """"); [WpfFact] public void TestOpenCloseBraceIntoSingleLineRawString1() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """{}""", -"""" -var x = $""" [||] """ -"""", -"""" -var x = $$""" {}[||] """ -"""", + """" + var x = $""" [||] """ + """", + """" + var x = $$""" {}[||] """ + """", afterUndo: -"""" -var x = $""" {}[||] """ -""""); - } + """" + var x = $""" {}[||] """ + """"); [WpfFact] public void TestOpenCloseBraceIntoSingleLineRawString2() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """{}""", -"""" -var x = $$""" [||] """ -"""", -"""" -var x = $$""" {}[||] """ -"""", + """" + var x = $$""" [||] """ + """", + """" + var x = $$""" {}[||] """ + """", afterUndo: -"""" -var x = $$""" [||] """ -""""); - } + """" + var x = $$""" [||] """ + """"); [WpfFact] public void TestOpenCloseBraceIntoSingleLineRawString3() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """{{}""", -"""" -var x = $$""" [||] """ -"""", -"""" -var x = $$$""" {{}[||] """ -"""", + """" + var x = $$""" [||] """ + """", + """" + var x = $$$""" {{}[||] """ + """", afterUndo: -"""" -var x = $$""" {{}[||] """ -""""); - } + """" + var x = $$""" {{}[||] """ + """"); [WpfFact] public void TestOpenCloseBraceIntoSingleLineRawString4() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """{}}""", -"""" -var x = $$""" [||] """ -"""", -"""" -var x = $$$""" {}}[||] """ -"""", + """" + var x = $$""" [||] """ + """", + """" + var x = $$$""" {}}[||] """ + """", afterUndo: -"""" -var x = $$""" {}}[||] """ -""""); - } + """" + var x = $$""" {}}[||] """ + """"); [WpfFact] public void TestOpenCloseBraceIntoSingleLineRawString5() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """{{}}""", -"""" -var x = $$""" [||] """ -"""", -"""" -var x = $$$""" {{}}[||] """ -"""", + """" + var x = $$""" [||] """ + """", + """" + var x = $$$""" {{}}[||] """ + """", afterUndo: -"""" -var x = $$""" {{}}[||] """ -""""); - } + """" + var x = $$""" {{}}[||] """ + """"); [WpfFact] public void TestComplexStringIntoSingleLineRawString() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """ "" """, -"""" -var x = $"""[||] """ -"""", -"""" -var x = $""" "" [||] """ -"""", + """" + var x = $"""[||] """ + """", + """" + var x = $""" "" [||] """ + """", afterUndo: -"""" -var x = $"""[||] """ -""""); - } + """" + var x = $"""[||] """ + """"); [WpfFact] public void TestNormalTextIntoSingleLineRawString_A() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """abc""", -"""" -var x = $"""[||] """ -"""", -"""" -var x = $"""abc[||] """ -"""", + """" + var x = $"""[||] """ + """", + """" + var x = $"""abc[||] """ + """", afterUndo: -"""" -var x = $"""[||] """ -""""); - } + """" + var x = $"""[||] """ + """"); [WpfFact] public void TestNormalTextIntoSingleLineRawString_B() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """abc""", -"""" -var x = $""" [||]""" -"""", -"""" -var x = $""" abc[||]""" -"""", + """" + var x = $""" [||]""" + """", + """" + var x = $""" abc[||]""" + """", afterUndo: -"""" -var x = $""" [||]""" -""""); - } + """" + var x = $""" [||]""" + """"); [WpfFact] public void TestNormalTextIntoSingleLineRawStringSingleLine1_A() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """ abc def """, -"""" -var x = $"""[||] """ -"""", -"""" -var x = $""" - abc - def[||] - """ -"""", + """" + var x = $"""[||] """ + """", + """" + var x = $""" + abc + def[||] + """ + """", afterUndo: -"""" -var x = $"""abc -def[||] """ -""""); - } + """" + var x = $"""abc + def[||] """ + """"); [WpfFact] public void TestNormalTextIntoSingleLineRawStringSingleLine1_B() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """ abc def """, -"""" -var x = $""" [||]""" -"""", -"""" -var x = $""" - abc - def - [||]""" -"""", + """" + var x = $""" [||]""" + """", + """" + var x = $""" + abc + def + [||]""" + """", afterUndo: -"""" -var x = $""" abc -def[||]""" -""""); - } + """" + var x = $""" abc + def[||]""" + """"); [WpfFact] public void TestNormalTextIntoSingleLineRawStringSingleLine4() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """ abc def """, -"""" -var x = $"""goo[||]""" -"""", -"""" -var x = $""" - gooabc - def - [||]""" -"""", + """" + var x = $"""goo[||]""" + """", + """" + var x = $""" + gooabc + def + [||]""" + """", afterUndo: -"""" -var x = $"""gooabc -def[||]""" -""""); - } + """" + var x = $"""gooabc + def[||]""" + """"); [WpfFact] public void TestNormalTextIntoSingleLineRawStringSingleLine5() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """ abc def """, -"""" -var x = $"""goo[||]bar""" -"""", -"""" -var x = $""" - gooabc - def[||]bar - """ -"""", + """" + var x = $"""goo[||]bar""" + """", + """" + var x = $""" + gooabc + def[||]bar + """ + """", afterUndo: -"""" -var x = $"""gooabc -def[||]bar""" -""""); - } + """" + var x = $"""gooabc + def[||]bar""" + """"); [WpfFact] public void TestNormalTextIntoSingleLineRawStringSingleLine6() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """ abc def """, -"""" -var x = $"""goo[||]bar""" -"""", -"""" -var x = $""" - gooabc - def - [||]bar - """ -"""", + """" + var x = $"""goo[||]bar""" + """", + """" + var x = $""" + gooabc + def + [||]bar + """ + """", afterUndo: -"""" -var x = $"""gooabc -def -[||]bar""" -""""); - } + """" + var x = $"""gooabc + def + [||]bar""" + """"); [WpfFact] public void TestNormalTextIntoSingleLineRawStringSingleLine7_A() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """ abc def ghi """, -"""" -var x = $"""[||] """ -"""", -"""" -var x = $""" - abc - def - ghi[||] - """ -"""", + """" + var x = $"""[||] """ + """", + """" + var x = $""" + abc + def + ghi[||] + """ + """", afterUndo: -"""" -var x = $"""abc - def -ghi[||] """ -""""); - } + """" + var x = $"""abc + def + ghi[||] """ + """"); [WpfFact] public void TestNormalTextIntoSingleLineRawStringSingleLine7_B() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """ abc def ghi """, -"""" -var x = $""" [||]""" -"""", -"""" -var x = $""" - abc - def - ghi - [||]""" -"""", + """" + var x = $""" [||]""" + """", + """" + var x = $""" + abc + def + ghi + [||]""" + """", afterUndo: -"""" -var x = $""" abc - def -ghi[||]""" -""""); - } + """" + var x = $""" abc + def + ghi[||]""" + """"); [WpfFact] public void TestNormalTextIntoSingleLineRawStringSingleLine8_A() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """ abc def ghi """, -"""" -var x = $"""[||] """ -"""", -"""" -var x = $""" - abc - def - ghi[||] - """ -"""", + """" + var x = $"""[||] """ + """", + """" + var x = $""" + abc + def + ghi[||] + """ + """", afterUndo: -"""" -var x = $"""abc - def - ghi[||] """ -""""); - } + """" + var x = $"""abc + def + ghi[||] """ + """"); [WpfFact] public void TestNormalTextIntoSingleLineRawStringSingleLine8_B() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """ abc def ghi """, -"""" -var x = $"""[||] """ -"""", -"""" -var x = $""" - abc - def - ghi[||] - """ -"""", + """" + var x = $"""[||] """ + """", + """" + var x = $""" + abc + def + ghi[||] + """ + """", afterUndo: -"""" -var x = $"""abc - def - ghi[||] """ -""""); - } + """" + var x = $"""abc + def + ghi[||] """ + """"); [WpfFact] public void TestNormalTextIntoSingleLineRawStringSingleLine9_A() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """ abc def ghi """, -"""" -var x = $"""[||] """ -"""", -"""" -var x = $""" - abc - def - ghi[||] - """ -"""", + """" + var x = $"""[||] """ + """", + """" + var x = $""" + abc + def + ghi[||] + """ + """", afterUndo: -"""" -var x = $""" abc - def - ghi[||] """ -""""); - } + """" + var x = $""" abc + def + ghi[||] """ + """"); [WpfFact] public void TestNormalTextIntoSingleLineRawStringSingleLine9_B() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """ abc def ghi """, -"""" -var x = $""" [||]""" -"""", -"""" -var x = $""" - abc - def - ghi - [||]""" -"""", + """" + var x = $""" [||]""" + """", + """" + var x = $""" + abc + def + ghi + [||]""" + """", afterUndo: -"""" -var x = $""" abc - def - ghi[||]""" -""""); - } + """" + var x = $""" abc + def + ghi[||]""" + """"); [WpfFact] public void TestNormalTextIntoSingleLineRawStringSingleLine10_A() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """ abc def ghi """, -"""" -var x = $"""[||] """ -"""", -"""" -var x = $""" - abc - def - ghi[||] - """ -"""", + """" + var x = $"""[||] """ + """", + """" + var x = $""" + abc + def + ghi[||] + """ + """", afterUndo: -"""" -var x = $""" abc - def - ghi[||] """ -""""); - } + """" + var x = $""" abc + def + ghi[||] """ + """"); [WpfFact] public void TestNormalTextIntoSingleLineRawStringSingleLine10_B() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """ abc def ghi """, -"""" -var x = $""" [||]""" -"""", -"""" -var x = $""" - abc - def - ghi - [||]""" -"""", + """" + var x = $""" [||]""" + """", + """" + var x = $""" + abc + def + ghi + [||]""" + """", afterUndo: -"""" -var x = $""" abc - def - ghi[||]""" -""""); - } + """" + var x = $""" abc + def + ghi[||]""" + """"); [WpfFact] public void TestNormalTextIntoSingleLineRawStringSingleLine11_A() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """ abc def """, -"""" -var x = $"""[||]{|Selection: |}""" -"""", -"""" -var x = $""" - abc - def - [||]""" -"""", + """" + var x = $"""[||]{|Selection: |}""" + """", + """" + var x = $""" + abc + def + [||]""" + """", afterUndo: -"""" -var x = $"""abc -def[||]""" -""""); - } + """" + var x = $"""abc + def[||]""" + """"); [WpfFact] public void TestNormalTextIntoSingleLineRawStringSingleLine11_B() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """ abc def """, -"""" -var x = $""" [||]{|Selection: |} """ -"""", -"""" -var x = $""" - abc - def[||] - """ -"""", + """" + var x = $""" [||]{|Selection: |} """ + """", + """" + var x = $""" + abc + def[||] + """ + """", afterUndo: -"""" -var x = $""" abc -def[||] """ -""""); - } + """" + var x = $""" abc + def[||] """ + """"); [WpfFact] public void TestNormalTextIntoSingleLineRawStringSingleLine12_A() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """ abc def """, -"""" -var x = $"""[||]{|Selection: |}""" -"""", -"""" -var x = $""" - abc - def - - [||]""" -"""", + """" + var x = $"""[||]{|Selection: |}""" + """", + """" + var x = $""" + abc + def + + [||]""" + """", afterUndo: -"""" -var x = $"""abc -def -[||]""" -""""); - } + """" + var x = $"""abc + def + [||]""" + """"); [WpfFact] public void TestNormalTextIntoSingleLineRawStringSingleLine12_B() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """ abc def """, -"""" -var x = $""" [||]{|Selection: |} """ -"""", -"""" -var x = $""" - abc - def - [||] - """ -"""", + """" + var x = $""" [||]{|Selection: |} """ + """", + """" + var x = $""" + abc + def + [||] + """ + """", afterUndo: -"""" -var x = $""" abc -def -[||] """ -""""); - } + """" + var x = $""" abc + def + [||] """ + """"); [WpfFact] public void TestNormalTextIntoSingleLineRawStringSingleLine13_A() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """ abc def """, -"""" -var x = $"""[||]{|Selection: |} """ -"""", -"""" -var x = $""" - abc - def[||] - """ -"""", + """" + var x = $"""[||]{|Selection: |} """ + """", + """" + var x = $""" + abc + def[||] + """ + """", afterUndo: -"""" -var x = $"""abc -def[||] """ -""""); - } + """" + var x = $"""abc + def[||] """ + """"); [WpfFact] public void TestNormalTextIntoSingleLineRawStringSingleLine13_B() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """ abc def """, -"""" -var x = $""" [||]{|Selection: |}""" -"""", -"""" -var x = $""" - abc - def - [||]""" -"""", + """" + var x = $""" [||]{|Selection: |}""" + """", + """" + var x = $""" + abc + def + [||]""" + """", afterUndo: -"""" -var x = $""" abc -def[||]""" -""""); - } + """" + var x = $""" abc + def[||]""" + """"); [WpfFact] public void TestNormalTextIntoSingleLineRawStringHeader1_A() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """ "bar """, -"""" -var x = $"""[||]goo""" -"""", -"""" -var x = $""" - "bar[||]goo - """ -"""", + """" + var x = $"""[||]goo""" + """", + """" + var x = $""" + "bar[||]goo + """ + """", afterUndo: -""""" -var x = $""""bar[||]goo""" -"""""); - } + """"" + var x = $""""bar[||]goo""" + """""); [WpfFact] public void TestNormalTextIntoSingleLineRawStringHeader1_B() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """ bar" """, -"""" -var x = $"""goo[||]""" -"""", -"""" -var x = $""" - goobar" - [||]""" -"""", + """" + var x = $"""goo[||]""" + """", + """" + var x = $""" + goobar" + [||]""" + """", afterUndo: -"""" -var x = $"""goobar"[||]""" -""""); - } + """" + var x = $"""goobar"[||]""" + """"); [WpfFact] public void TestQuotesIntoHeader1() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """ "" """, -"""" -var x = $"""[||]{|Selection: |}""" -"""", -"""" -var x = $""" - "" - [||]""" -"""", + """" + var x = $"""[||]{|Selection: |}""" + """", + """" + var x = $""" + "" + [||]""" + """", afterUndo: -"""""" -var x = $"""""[||]""" -""""""); - } + """""" + var x = $"""""[||]""" + """"""); [WpfFact] public void TestQuotesIntoHeader2() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """" """ """", -"""" -var x = $"""[||]{|Selection: |}""" -"""", -""""" -var x = $"""" - """ - [||]"""" -""""", + """" + var x = $"""[||]{|Selection: |}""" + """", + """"" + var x = $"""" + """ + [||]"""" + """"", afterUndo: -""""""" -var x = $""""""[||]""" -"""""""); - } + """"""" + var x = $""""""[||]""" + """""""); #endregion } diff --git a/src/EditorFeatures/CSharpTest/StringCopyPaste/PasteKnownSourceIntoSingleLineRawStringTests.cs b/src/EditorFeatures/CSharpTest/StringCopyPaste/PasteKnownSourceIntoSingleLineRawStringTests.cs index 7a849ab49d61..95677de59d48 100644 --- a/src/EditorFeatures/CSharpTest/StringCopyPaste/PasteKnownSourceIntoSingleLineRawStringTests.cs +++ b/src/EditorFeatures/CSharpTest/StringCopyPaste/PasteKnownSourceIntoSingleLineRawStringTests.cs @@ -14,8 +14,7 @@ public sealed class PasteKnownSourceIntoSingleLineRawStringTests : StringCopyPas [WpfFact] public void TestPasteSimpleNormalLiteralContent() - { - TestCopyPaste( + => TestCopyPaste( """var v = "{|Copy:goo|}";""", """" var dest = @@ -29,12 +28,10 @@ public void TestPasteSimpleNormalLiteralContent() var dest = """[||] """; """"); - } [WpfFact] public void TestPasteSimpleNormalLiteralContent_2() - { - TestCopyPaste( + => TestCopyPaste( """var v = "{|Copy:goo|}";""", """" var dest = @@ -48,12 +45,10 @@ public void TestPasteSimpleNormalLiteralContent_2() var dest = """ [||]"""; """"); - } [WpfFact] public void TestPasteSimpleSubstringNormalLiteralContent() - { - TestCopyPaste( + => TestCopyPaste( """var v = "g{|Copy:o|}o";""", """" var dest = @@ -67,12 +62,10 @@ public void TestPasteSimpleSubstringNormalLiteralContent() var dest = """[||] """; """"); - } [WpfFact] public void TestPasteSimpleSubstringNormalLiteralContent_2() - { - TestCopyPaste( + => TestCopyPaste( """var v = "g{|Copy:o|}o";""", """" var dest = @@ -86,12 +79,10 @@ public void TestPasteSimpleSubstringNormalLiteralContent_2() var dest = """ [||]"""; """"); - } [WpfFact] public void TestPastePartiallySelectedEscapeNormalLiteralContent() - { - TestCopyPaste( + => TestCopyPaste( """var v = "\{|Copy:n|}";""", """" var dest = @@ -105,12 +96,10 @@ public void TestPastePartiallySelectedEscapeNormalLiteralContent() var dest = """[||] """; """"); - } [WpfFact] public void TestPastePartiallySelectedEscapeNormalLiteralContent_2() - { - TestCopyPaste( + => TestCopyPaste( """var v = "\{|Copy:n|}";""", """" var dest = @@ -124,12 +113,10 @@ public void TestPastePartiallySelectedEscapeNormalLiteralContent_2() var dest = """ [||]"""; """"); - } [WpfFact] public void TestPasteFullySelectedEscapeNormalLiteralContent() - { - TestCopyPaste( + => TestCopyPaste( """var v = "{|Copy:\n|}";""", """" var dest = @@ -137,12 +124,10 @@ public void TestPasteFullySelectedEscapeNormalLiteralContent() """", "var dest =\r\n \"\"\"\r\n \n [||] \r\n \"\"\";", "var dest =\r\n \"\"\"\\n[||] \"\"\";"); - } [WpfFact] public void TestPasteFullySelectedEscapeNormalLiteralContent_2() - { - TestCopyPaste( + => TestCopyPaste( """var v = "{|Copy:\n|}";""", """" var dest = @@ -150,12 +135,10 @@ public void TestPasteFullySelectedEscapeNormalLiteralContent_2() """", "var dest =\r\n \"\"\"\r\n \n \r\n [||]\"\"\";", "var dest =\r\n \"\"\" \\n[||]\"\"\";"); - } [WpfFact] public void TestPastePartiallySelectedQuoteNormalLiteralContent() - { - TestCopyPaste( + => TestCopyPaste( """var v = "\{|Copy:"|}";""", """" var dest = @@ -171,12 +154,10 @@ public void TestPastePartiallySelectedQuoteNormalLiteralContent() var dest = """"[||] """; """""); - } [WpfFact] public void TestPastePartiallySelectedQuoteNormalLiteralContent_2() - { - TestCopyPaste( + => TestCopyPaste( """var v = "\{|Copy:"|}";""", """" var dest = @@ -192,12 +173,10 @@ public void TestPastePartiallySelectedQuoteNormalLiteralContent_2() var dest = """ "[||]"""; """"); - } [WpfFact] public void TestPasteFullySelectedQuoteNormalLiteralContent() - { - TestCopyPaste( + => TestCopyPaste( """var v = "{|Copy:\"|}";""", """" var dest = @@ -213,12 +192,10 @@ public void TestPasteFullySelectedQuoteNormalLiteralContent() var dest = """\"[||] """; """"); - } [WpfFact] public void TestPasteFullySelectedQuoteNormalLiteralContent_2() - { - TestCopyPaste( + => TestCopyPaste( """var v = "{|Copy:\"|}";""", """" var dest = @@ -234,12 +211,10 @@ public void TestPasteFullySelectedQuoteNormalLiteralContent_2() var dest = """ \"[||]"""; """"); - } [WpfFact] public void TestPasteSimpleVerbatimLiteralContent() - { - TestCopyPaste( + => TestCopyPaste( """var v = @"{|Copy:goo|}";""", """" var dest = @@ -253,12 +228,10 @@ public void TestPasteSimpleVerbatimLiteralContent() var dest = """[||] """; """"); - } [WpfFact] public void TestPasteSimpleVerbatimLiteralContent_2() - { - TestCopyPaste( + => TestCopyPaste( """var v = @"{|Copy:goo|}";""", """" var dest = @@ -272,12 +245,10 @@ public void TestPasteSimpleVerbatimLiteralContent_2() var dest = """ [||]"""; """"); - } [WpfFact] public void TestPasteSimpleSubstringVerbatimLiteralContent() - { - TestCopyPaste( + => TestCopyPaste( """var v = @"g{|Copy:o|}o";""", """" var dest = @@ -291,12 +262,10 @@ public void TestPasteSimpleSubstringVerbatimLiteralContent() var dest = """[||] """; """"); - } [WpfFact] public void TestPasteSimpleSubstringVerbatimLiteralContent2() - { - TestCopyPaste( + => TestCopyPaste( """var v = @"g{|Copy:o|}o";""", """" var dest = @@ -310,12 +279,10 @@ public void TestPasteSimpleSubstringVerbatimLiteralContent2() var dest = """ [||]"""; """"); - } [WpfFact] public void TestPasteSelectedVerbatimNewLineLiteralContent() - { - TestCopyPaste( + => TestCopyPaste( """ var v = @"{|Copy: |}"; @@ -336,12 +303,10 @@ public void TestPasteSelectedVerbatimNewLineLiteralContent() """ [||] """; """"); - } [WpfFact] public void TestPasteSelectedVerbatimNewLineLiteralContent2() - { - TestCopyPaste( + => TestCopyPaste( """ var v = @"{|Copy: |}"; @@ -362,12 +327,10 @@ public void TestPasteSelectedVerbatimNewLineLiteralContent2() """ [||]"""; """"); - } [WpfFact] public void TestPasteFullySelectedEscapeVerbatimLiteralContent() - { - TestCopyPaste( + => TestCopyPaste( """var v = @"{|Copy:""|}";""", """" var dest = @@ -383,12 +346,10 @@ public void TestPasteFullySelectedEscapeVerbatimLiteralContent() var dest = """""[||] """; """"""); - } [WpfFact] public void TestPasteFullySelectedEscapeVerbatimLiteralContent2() - { - TestCopyPaste( + => TestCopyPaste( """var v = @"{|Copy:""|}";""", """" var dest = @@ -404,12 +365,10 @@ public void TestPasteFullySelectedEscapeVerbatimLiteralContent2() var dest = """ ""[||]"""; """"); - } [WpfFact] public void TestPasteSimpleRawSingleLineLiteralContent() - { - TestCopyPaste( + => TestCopyPaste( """"var v = """{|Copy:goo|}""";"""", """" var dest = @@ -423,12 +382,10 @@ public void TestPasteSimpleRawSingleLineLiteralContent() var dest = """[||] """; """"); - } [WpfFact] public void TestPasteSimpleRawSingleLineLiteralContent2() - { - TestCopyPaste( + => TestCopyPaste( """"var v = """{|Copy:goo|}""";"""", """" var dest = @@ -442,12 +399,10 @@ public void TestPasteSimpleRawSingleLineLiteralContent2() var dest = """ [||]"""; """"); - } [WpfFact] public void TestPasteQuotesRawSingleLineLiteralContent() - { - TestCopyPaste( + => TestCopyPaste( """"var v = """{|Copy: "" |}""";"""", """" var dest = @@ -461,12 +416,10 @@ public void TestPasteQuotesRawSingleLineLiteralContent() var dest = """[||] """; """"); - } [WpfFact] public void TestPasteQuotesRawSingleLineLiteralContent2() - { - TestCopyPaste( + => TestCopyPaste( """"var v = """{|Copy: "" |}""";"""", """" var dest = @@ -480,12 +433,10 @@ public void TestPasteQuotesRawSingleLineLiteralContent2() var dest = """ [||]"""; """"); - } [WpfFact] public void TestPasteSimpleRawMultiLineLiteralContent1() - { - TestCopyPaste( + => TestCopyPaste( """" var v = """ {|Copy:goo|} @@ -503,12 +454,10 @@ public void TestPasteSimpleRawMultiLineLiteralContent1() var dest = """[||] """; """"); - } [WpfFact] public void TestPasteSimpleRawMultiLineLiteralContent1b() - { - TestCopyPaste( + => TestCopyPaste( """" var v = """ {|Copy:goo|} @@ -526,12 +475,10 @@ public void TestPasteSimpleRawMultiLineLiteralContent1b() var dest = """ [||]"""; """"); - } [WpfFact] public void TestPasteSimpleRawMultiLineLiteralContent2() - { - TestCopyPaste( + => TestCopyPaste( """" var v = """ {|Copy:goo @@ -554,12 +501,10 @@ public void TestPasteSimpleRawMultiLineLiteralContent2() """goo bar[||] """; """"); - } [WpfFact] public void TestPasteSimpleRawMultiLineLiteralContent2b() - { - TestCopyPaste( + => TestCopyPaste( """" var v = """ {|Copy:goo @@ -582,12 +527,10 @@ public void TestPasteSimpleRawMultiLineLiteralContent2b() """ goo bar[||]"""; """"); - } [WpfFact] public void TestPasteSimpleRawMultiLineLiteralContent3() - { - TestCopyPaste( + => TestCopyPaste( """" var v = """ {|Copy: goo @@ -610,12 +553,10 @@ public void TestPasteSimpleRawMultiLineLiteralContent3() """ goo bar[||] """; """"); - } [WpfFact] public void TestPasteSimpleRawMultiLineLiteralContent3b() - { - TestCopyPaste( + => TestCopyPaste( """" var v = """ {|Copy: goo @@ -638,12 +579,10 @@ public void TestPasteSimpleRawMultiLineLiteralContent3b() """ goo bar[||]"""; """"); - } [WpfFact] public void TestPasteInterpolationFromInterpolatedStringLiteralContent() - { - TestCopyPaste( + => TestCopyPaste( """var v = $"{|Copy:{0}|}";""", """" var dest = @@ -657,12 +596,10 @@ public void TestPasteInterpolationFromInterpolatedStringLiteralContent() var dest = """[||] """; """"); - } [WpfFact] public void TestPasteInterpolationFromInterpolatedStringLiteralContentb() - { - TestCopyPaste( + => TestCopyPaste( """var v = $"{|Copy:{0}|}";""", """" var dest = @@ -676,12 +613,10 @@ public void TestPasteInterpolationFromInterpolatedStringLiteralContentb() var dest = """ [||]"""; """"); - } [WpfFact] public void TestPasteInterpolationWithFormatClauseFromInterpolatedStringLiteralContent1() - { - TestCopyPaste( + => TestCopyPaste( """var v = $"{|Copy:{0:X}|}";""", """" var dest = @@ -695,12 +630,10 @@ public void TestPasteInterpolationWithFormatClauseFromInterpolatedStringLiteralC var dest = """[||] """; """"); - } [WpfFact] public void TestPasteInterpolationWithFormatClauseFromInterpolatedStringLiteralContent1b() - { - TestCopyPaste( + => TestCopyPaste( """var v = $"{|Copy:{0:X}|}";""", """" var dest = @@ -714,12 +647,10 @@ public void TestPasteInterpolationWithFormatClauseFromInterpolatedStringLiteralC var dest = """ [||]"""; """"); - } [WpfFact] public void TestPasteInterpolationWithFormatClauseFromInterpolatedStringLiteralContent2() - { - TestCopyPaste( + => TestCopyPaste( """var v = $"{|Copy:{0:\"X\"}|}";""", """" var dest = @@ -733,12 +664,10 @@ public void TestPasteInterpolationWithFormatClauseFromInterpolatedStringLiteralC var dest = """{0:\"X\"}[||] """; """"); - } [WpfFact] public void TestPasteInterpolationWithFormatClauseFromInterpolatedStringLiteralContent2b() - { - TestCopyPaste( + => TestCopyPaste( """var v = $"{|Copy:{0:\"X\"}|}";""", """" var dest = @@ -752,12 +681,10 @@ public void TestPasteInterpolationWithFormatClauseFromInterpolatedStringLiteralC var dest = """ {0:\"X\"}[||]"""; """"); - } [WpfFact] public void TestPasteInterpolationWithStringFromInterpolatedStringLiteralContent1() - { - TestCopyPaste( + => TestCopyPaste( """var v = $"{|Copy:{"goo"}|}";""", """" var dest = @@ -771,12 +698,10 @@ public void TestPasteInterpolationWithStringFromInterpolatedStringLiteralContent var dest = """[||] """; """"); - } [WpfFact] public void TestPasteInterpolationWithStringFromInterpolatedStringLiteralContent1b() - { - TestCopyPaste( + => TestCopyPaste( """var v = $"{|Copy:{"goo"}|}";""", """" var dest = @@ -790,12 +715,10 @@ public void TestPasteInterpolationWithStringFromInterpolatedStringLiteralContent var dest = """ [||]"""; """"); - } [WpfFact] public void TestPasteInterpolationWithStringFromInterpolatedStringLiteralContent2() - { - TestCopyPaste( + => TestCopyPaste( """var v = $"{|Copy:X{"goo"}Y|}";""", """" var dest = @@ -809,12 +732,10 @@ public void TestPasteInterpolationWithStringFromInterpolatedStringLiteralContent var dest = """[||] """; """"); - } [WpfFact] public void TestPasteInterpolationWithStringFromInterpolatedStringLiteralContent2b() - { - TestCopyPaste( + => TestCopyPaste( """var v = $"{|Copy:X{"goo"}Y|}";""", """" var dest = @@ -828,12 +749,10 @@ public void TestPasteInterpolationWithStringFromInterpolatedStringLiteralContent var dest = """ [||]"""; """"); - } [WpfFact] public void TestPasteInterpolationWithStringFromInterpolatedStringLiteralContent3() - { - TestCopyPaste( + => TestCopyPaste( """var v = $"{|Copy:\"X{"goo"}Y\"|}";""", """" var dest = @@ -849,12 +768,10 @@ public void TestPasteInterpolationWithStringFromInterpolatedStringLiteralContent var dest = """\"X{"goo"}Y\"[||] """; """"); - } [WpfFact] public void TestPasteInterpolationWithStringFromInterpolatedStringLiteralContent3b() - { - TestCopyPaste( + => TestCopyPaste( """var v = $"{|Copy:\"X{"goo"}Y\"|}";""", """" var dest = @@ -870,12 +787,10 @@ public void TestPasteInterpolationWithStringFromInterpolatedStringLiteralContent var dest = """ \"X{"goo"}Y\"[||]"""; """"); - } [WpfFact] public void TestPasteInterpolationWithStringFromInterpolatedStringLiteralContent4() - { - TestCopyPaste( + => TestCopyPaste( """var v = $"{|Copy:\"X{@"goo"}Y\"|}";""", """" var dest = @@ -891,12 +806,10 @@ public void TestPasteInterpolationWithStringFromInterpolatedStringLiteralContent var dest = """\"X{@"goo"}Y\"[||] """; """"); - } [WpfFact] public void TestPasteInterpolationWithStringFromInterpolatedStringLiteralContent4b() - { - TestCopyPaste( + => TestCopyPaste( """var v = $"{|Copy:\"X{@"goo"}Y\"|}";""", """" var dest = @@ -912,12 +825,10 @@ public void TestPasteInterpolationWithStringFromInterpolatedStringLiteralContent var dest = """ \"X{@"goo"}Y\"[||]"""; """"); - } [WpfFact] public void TestPasteInterpolationFromVerbatimInterpolatedStringLiteralContent() - { - TestCopyPaste( + => TestCopyPaste( """var v = $@"{|Copy:{0}|}";""", """" var dest = @@ -931,12 +842,10 @@ public void TestPasteInterpolationFromVerbatimInterpolatedStringLiteralContent() var dest = """[||] """; """"); - } [WpfFact] public void TestPasteInterpolationFromVerbatimInterpolatedStringLiteralContentb() - { - TestCopyPaste( + => TestCopyPaste( """var v = $@"{|Copy:{0}|}";""", """" var dest = @@ -950,12 +859,10 @@ public void TestPasteInterpolationFromVerbatimInterpolatedStringLiteralContentb( var dest = """ [||]"""; """"); - } [WpfFact] public void TestPasteInterpolationWithFormatClauseFromVerbatimInterpolatedStringLiteralContent1() - { - TestCopyPaste( + => TestCopyPaste( """var v = $@"{|Copy:{0:X}|}";""", """" var dest = @@ -969,12 +876,10 @@ public void TestPasteInterpolationWithFormatClauseFromVerbatimInterpolatedString var dest = """[||] """; """"); - } [WpfFact] public void TestPasteInterpolationWithFormatClauseFromVerbatimInterpolatedStringLiteralContent1b() - { - TestCopyPaste( + => TestCopyPaste( """var v = $@"{|Copy:{0:X}|}";""", """" var dest = @@ -988,12 +893,10 @@ public void TestPasteInterpolationWithFormatClauseFromVerbatimInterpolatedString var dest = """ [||]"""; """"); - } [WpfFact] public void TestPasteInterpolationWithFormatClauseFromVerbatimInterpolatedStringLiteralContent2() - { - TestCopyPaste( + => TestCopyPaste( """var v = $@"{|Copy:{0:""X""}|}";""", """" var dest = @@ -1007,12 +910,10 @@ public void TestPasteInterpolationWithFormatClauseFromVerbatimInterpolatedString var dest = """{0:""X""}[||] """; """"); - } [WpfFact] public void TestPasteInterpolationWithFormatClauseFromVerbatimInterpolatedStringLiteralContent2b() - { - TestCopyPaste( + => TestCopyPaste( """var v = $@"{|Copy:{0:""X""}|}";""", """" var dest = @@ -1026,12 +927,10 @@ public void TestPasteInterpolationWithFormatClauseFromVerbatimInterpolatedString var dest = """ {0:""X""}[||]"""; """"); - } [WpfFact] public void TestPasteInterpolationWithStringFromVerbatimInterpolatedStringLiteralContent1() - { - TestCopyPaste( + => TestCopyPaste( """var v = $@"{|Copy:{"goo"}|}";""", """" var dest = @@ -1045,12 +944,10 @@ public void TestPasteInterpolationWithStringFromVerbatimInterpolatedStringLitera var dest = """[||] """; """"); - } [WpfFact] public void TestPasteInterpolationWithStringFromVerbatimInterpolatedStringLiteralContent1b() - { - TestCopyPaste( + => TestCopyPaste( """var v = $@"{|Copy:{"goo"}|}";""", """" var dest = @@ -1064,12 +961,10 @@ public void TestPasteInterpolationWithStringFromVerbatimInterpolatedStringLitera var dest = """ [||]"""; """"); - } [WpfFact] public void TestPasteInterpolationWithStringFromVerbatimInterpolatedStringLiteralContent2() - { - TestCopyPaste( + => TestCopyPaste( """var v = $@"{|Copy:X{"goo"}Y|}";""", """" var dest = @@ -1083,12 +978,10 @@ public void TestPasteInterpolationWithStringFromVerbatimInterpolatedStringLitera var dest = """[||] """; """"); - } [WpfFact] public void TestPasteInterpolationWithStringFromVerbatimInterpolatedStringLiteralContent2b() - { - TestCopyPaste( + => TestCopyPaste( """var v = $@"{|Copy:X{"goo"}Y|}";""", """" var dest = @@ -1102,12 +995,10 @@ public void TestPasteInterpolationWithStringFromVerbatimInterpolatedStringLitera var dest = """ [||]"""; """"); - } [WpfFact] public void TestPasteInterpolationWithStringFromVerbatimInterpolatedStringLiteralContent3() - { - TestCopyPaste( + => TestCopyPaste( """var v = $@"{|Copy:""X{"goo"}Y""|}";""", """" var dest = @@ -1123,12 +1014,10 @@ public void TestPasteInterpolationWithStringFromVerbatimInterpolatedStringLitera var dest = """""X{"goo"}Y""[||] """; """"""); - } [WpfFact] public void TestPasteInterpolationWithStringFromVerbatimInterpolatedStringLiteralContent3b() - { - TestCopyPaste( + => TestCopyPaste( """var v = $@"{|Copy:""X{"goo"}Y""|}";""", """" var dest = @@ -1144,12 +1033,10 @@ public void TestPasteInterpolationWithStringFromVerbatimInterpolatedStringLitera var dest = """ ""X{"goo"}Y""[||]"""; """"); - } [WpfFact] public void TestPasteInterpolationWithStringFromVerbatimInterpolatedStringLiteralContent4() - { - TestCopyPaste( + => TestCopyPaste( """var v = $@"{|Copy:""X{@"goo"}Y""|}";""", """" var dest = @@ -1165,12 +1052,10 @@ public void TestPasteInterpolationWithStringFromVerbatimInterpolatedStringLitera var dest = """""X{@"goo"}Y""[||] """; """"""); - } [WpfFact] public void TestPasteInterpolationWithStringFromVerbatimInterpolatedStringLiteralContent4b() - { - TestCopyPaste( + => TestCopyPaste( """var v = $@"{|Copy:""X{@"goo"}Y""|}";""", """" var dest = @@ -1186,7 +1071,6 @@ public void TestPasteInterpolationWithStringFromVerbatimInterpolatedStringLitera var dest = """ ""X{@"goo"}Y""[||]"""; """"); - } #endregion @@ -1197,982 +1081,894 @@ public void TestPasteInterpolationWithStringFromVerbatimInterpolatedStringLitera [WpfFact] public void TestNewLineIntoSingleLineRawString1_A() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: "\n", -"""" -var x = """[||] """ -"""", -"var x = \"\"\"\r\n \n [||] \r\n \"\"\"", + """" + var x = """[||] """ + """", + "var x = \"\"\"\r\n \n [||] \r\n \"\"\"", afterUndo: -"var x = \"\"\"\n[||] \"\"\""); - } + "var x = \"\"\"\n[||] \"\"\""); [WpfFact] public void TestNewLineIntoSingleLineRawString1_B() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: "\n", -"""" -var x = """ [||]""" -"""", -"var x = \"\"\"\r\n \n \r\n [||]\"\"\"", + """" + var x = """ [||]""" + """", + "var x = \"\"\"\r\n \n \r\n [||]\"\"\"", afterUndo: -"var x = \"\"\" \n[||]\"\"\""); - } + "var x = \"\"\" \n[||]\"\"\""); [WpfFact] public void TestNewLineIntoSingleLineRawString2_A() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """ """, -"""" -var x = """[||] """ -"""", -"""" -var x = """ - - [||] - """ -"""", + """" + var x = """[||] """ + """", + """" + var x = """ + + [||] + """ + """", afterUndo: -"""" -var x = """ -[||] """ -""""); - } + """" + var x = """ + [||] """ + """"); [WpfFact] public void TestNewLineIntoSingleLineRawString2_B() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """ """, -"""" -var x = """ [||]""" -"""", -"""" -var x = """ - - - [||]""" -"""", + """" + var x = """ [||]""" + """", + """" + var x = """ + + + [||]""" + """", afterUndo: -"""" -var x = """ -[||]""" -""""); - } + """" + var x = """ + [||]""" + """"); [WpfFact] public void TestSpacesIntoSingleLineRawString1_A() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """ """, -"""" -var x = """[||] """ -"""", -"""" -var x = """ [||] """ -"""", + """" + var x = """[||] """ + """", + """" + var x = """ [||] """ + """", afterUndo: -"""" -var x = """[||] """ -""""); - } + """" + var x = """[||] """ + """"); [WpfFact] public void TestSpacesIntoSingleLineRawString1_B() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """ """, -"""" -var x = """ [||]""" -"""", -"""" -var x = """ [||]""" -"""", + """" + var x = """ [||]""" + """", + """" + var x = """ [||]""" + """", afterUndo: -"""" -var x = """ [||]""" -""""); - } + """" + var x = """ [||]""" + """"); [WpfFact] public void TestSpacesIntoSingleLineRawString2() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """ """, -"""" -var x = """ - [||] - """ -"""", -"""" -var x = """ - - [||] - """ -"""", + """" + var x = """ + [||] + """ + """", + """" + var x = """ + + [||] + """ + """", afterUndo: -"""" -var x = """ - -[||] - """ -""""); - } + """" + var x = """ + + [||] + """ + """"); [WpfFact] public void TestSingleQuoteIntoSingleLineRawString_A() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """'""", -"""" -var x = """[||] """ -"""", -"""" -var x = """'[||] """ -"""", + """" + var x = """[||] """ + """", + """" + var x = """'[||] """ + """", afterUndo: -"""" -var x = """[||] """ -""""); - } + """" + var x = """[||] """ + """"); [WpfFact] public void TestSingleQuoteIntoSingleLineRawString_B() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """'""", -"""" -var x = """ [||]""" -"""", -"""" -var x = """ '[||]""" -"""", + """" + var x = """ [||]""" + """", + """" + var x = """ '[||]""" + """", afterUndo: -"""" -var x = """ [||]""" -""""); - } + """" + var x = """ [||]""" + """"); [WpfFact] public void TestDoubleQuoteIntoSingleLineRawString_A() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """ " """, -"""" -var x = """[||] """ -"""", -"""" -var x = """ - "[||] - """ -"""", + """" + var x = """[||] """ + """", + """" + var x = """ + "[||] + """ + """", afterUndo: -""""" -var x = """"[||] """ -"""""); - } + """"" + var x = """"[||] """ + """""); [WpfFact] public void TestDoubleQuoteIntoSingleLineRawString_B() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """ " """, -"""" -var x = """ [||]""" -"""", -"""" -var x = """ - " - [||]""" -"""", + """" + var x = """ [||]""" + """", + """" + var x = """ + " + [||]""" + """", afterUndo: -"""" -var x = """ "[||]""" -""""); - } + """" + var x = """ "[||]""" + """"); [WpfFact] public void TestTripleQuoteIntoSingleLineRawString1_A() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """" """ """", -"""" -var x = """[||] """ -"""", -""""" -var x = """" - """[||] - """" -""""", + """" + var x = """[||] """ + """", + """"" + var x = """" + """[||] + """" + """"", afterUndo: -""""""" -var x = """"""[||] """ -"""""""); - } + """"""" + var x = """"""[||] """ + """""""); [WpfFact] public void TestTripleQuoteIntoSingleLineRawString1_B() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """" """ """", -"""" -var x = """ [||]""" -"""", -""""" -var x = """" - """ - [||]"""" -""""", + """" + var x = """ [||]""" + """", + """"" + var x = """" + """ + [||]"""" + """"", afterUndo: -"""" -var x = """ """[||]""" -""""); - } + """" + var x = """ """[||]""" + """"); [WpfFact] public void TestTwoQuotesIntoSingleLineRawString3() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """ "" """, -"""" -var x = """ "[||] """ -"""", -""""" -var x = """" """[||] """" -""""", + """" + var x = """ "[||] """ + """", + """"" + var x = """" """[||] """" + """"", afterUndo: -"""" -var x = """ """[||] """ -""""); - } + """" + var x = """ """[||] """ + """"); [WpfFact] public void TestTripleQuoteIntoSingleLineRawString3() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """" """ """", -"""" -var x = """ "[||] """ -"""", -"""""" -var x = """"" """"[||] """"" -"""""", + """" + var x = """ "[||] """ + """", + """""" + var x = """"" """"[||] """"" + """""", afterUndo: -""""" -var x = """ """"[||] """ -"""""); - } + """"" + var x = """ """"[||] """ + """""); [WpfFact] public void TestTripleQuoteIntoSingleLineRawString4() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """" """ """", -"""" -var x = """ "[||]" """ -"""", -""""""" -var x = """""" """"[||]" """""" -""""""", + """" + var x = """ "[||]" """ + """", + """"""" + var x = """""" """"[||]" """""" + """"""", afterUndo: -""""" -var x = """ """"[||]" """ -"""""); - } + """"" + var x = """ """"[||]" """ + """""); [WpfFact] public void TestTripleQuoteIntoSingleLineRawString5() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """" """ """", -"""" -var x = """ [||]" """ -"""", -"""""" -var x = """"" """[||]" """"" -"""""", + """" + var x = """ [||]" """ + """", + """""" + var x = """"" """[||]" """"" + """""", afterUndo: -"""" -var x = """ """[||]" """ -""""); - } + """" + var x = """ """[||]" """ + """"); [WpfFact] public void TestQuadrupleQuoteIntoSingleLineRawString() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """"" """" """"", -"""" -var x = """ - [||] - """ -"""", -"""""" -var x = """"" - """"[||] - """"" -"""""", + """" + var x = """ + [||] + """ + """", + """""" + var x = """"" + """"[||] + """"" + """""", afterUndo: -""""" -var x = """ - """"[||] - """ -"""""); - } + """"" + var x = """ + """"[||] + """ + """""); [WpfFact] public void TestComplexStringIntoSingleLineRawString() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """ "" """, -"""" -var x = """[||] """ -"""", -"""" -var x = """ "" [||] """ -"""", + """" + var x = """[||] """ + """", + """" + var x = """ "" [||] """ + """", afterUndo: -"""" -var x = """[||] """ -""""); - } + """" + var x = """[||] """ + """"); [WpfFact] public void TestNormalTextIntoSingleLineRawString_A() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """abc""", -"""" -var x = """[||] """ -"""", -"""" -var x = """abc[||] """ -"""", + """" + var x = """[||] """ + """", + """" + var x = """abc[||] """ + """", afterUndo: -"""" -var x = """[||] """ -""""); - } + """" + var x = """[||] """ + """"); [WpfFact] public void TestNormalTextIntoSingleLineRawString_B() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """abc""", -"""" -var x = """ [||]""" -"""", -"""" -var x = """ abc[||]""" -"""", + """" + var x = """ [||]""" + """", + """" + var x = """ abc[||]""" + """", afterUndo: -"""" -var x = """ [||]""" -""""); - } + """" + var x = """ [||]""" + """"); [WpfFact] public void TestNormalTextIntoSingleLineRawStringSingleLine1_A() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """ abc def """, -"""" -var x = """[||] """ -"""", -"""" -var x = """ - abc - def[||] - """ -"""", + """" + var x = """[||] """ + """", + """" + var x = """ + abc + def[||] + """ + """", afterUndo: -"""" -var x = """abc -def[||] """ -""""); - } + """" + var x = """abc + def[||] """ + """"); [WpfFact] public void TestNormalTextIntoSingleLineRawStringSingleLine1_B() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """ abc def """, -"""" -var x = """ [||]""" -"""", -"""" -var x = """ - abc - def - [||]""" -"""", + """" + var x = """ [||]""" + """", + """" + var x = """ + abc + def + [||]""" + """", afterUndo: -"""" -var x = """ abc -def[||]""" -""""); - } + """" + var x = """ abc + def[||]""" + """"); [WpfFact] public void TestNormalTextIntoSingleLineRawStringSingleLine4() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """ abc def """, -"""" -var x = """goo[||]""" -"""", -"""" -var x = """ - gooabc - def - [||]""" -"""", + """" + var x = """goo[||]""" + """", + """" + var x = """ + gooabc + def + [||]""" + """", afterUndo: -"""" -var x = """gooabc -def[||]""" -""""); - } + """" + var x = """gooabc + def[||]""" + """"); [WpfFact] public void TestNormalTextIntoSingleLineRawStringSingleLine5() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """ abc def """, -"""" -var x = """goo[||]bar""" -"""", -"""" -var x = """ - gooabc - def[||]bar - """ -"""", + """" + var x = """goo[||]bar""" + """", + """" + var x = """ + gooabc + def[||]bar + """ + """", afterUndo: -"""" -var x = """gooabc -def[||]bar""" -""""); - } + """" + var x = """gooabc + def[||]bar""" + """"); [WpfFact] public void TestNormalTextIntoSingleLineRawStringSingleLine6() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """ abc def """, -"""" -var x = """goo[||]bar""" -"""", -"""" -var x = """ - gooabc - def - [||]bar - """ -"""", + """" + var x = """goo[||]bar""" + """", + """" + var x = """ + gooabc + def + [||]bar + """ + """", afterUndo: -"""" -var x = """gooabc -def -[||]bar""" -""""); - } + """" + var x = """gooabc + def + [||]bar""" + """"); [WpfFact] public void TestNormalTextIntoSingleLineRawStringSingleLine7_A() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """ abc def ghi """, -"""" -var x = """[||] """ -"""", -"""" -var x = """ - abc - def - ghi[||] - """ -"""", + """" + var x = """[||] """ + """", + """" + var x = """ + abc + def + ghi[||] + """ + """", afterUndo: -"""" -var x = """abc - def -ghi[||] """ -""""); - } + """" + var x = """abc + def + ghi[||] """ + """"); [WpfFact] public void TestNormalTextIntoSingleLineRawStringSingleLine7_B() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """ abc def ghi """, -"""" -var x = """ [||]""" -"""", -"""" -var x = """ - abc - def - ghi - [||]""" -"""", + """" + var x = """ [||]""" + """", + """" + var x = """ + abc + def + ghi + [||]""" + """", afterUndo: -"""" -var x = """ abc - def -ghi[||]""" -""""); - } + """" + var x = """ abc + def + ghi[||]""" + """"); [WpfFact] public void TestNormalTextIntoSingleLineRawStringSingleLine8_A() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """ abc def ghi """, -"""" -var x = """[||] """ -"""", -"""" -var x = """ - abc - def - ghi[||] - """ -"""", + """" + var x = """[||] """ + """", + """" + var x = """ + abc + def + ghi[||] + """ + """", afterUndo: -"""" -var x = """abc - def - ghi[||] """ -""""); - } + """" + var x = """abc + def + ghi[||] """ + """"); [WpfFact] public void TestNormalTextIntoSingleLineRawStringSingleLine8_B() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """ abc def ghi """, -"""" -var x = """[||] """ -"""", -"""" -var x = """ - abc - def - ghi[||] - """ -"""", + """" + var x = """[||] """ + """", + """" + var x = """ + abc + def + ghi[||] + """ + """", afterUndo: -"""" -var x = """abc - def - ghi[||] """ -""""); - } + """" + var x = """abc + def + ghi[||] """ + """"); [WpfFact] public void TestNormalTextIntoSingleLineRawStringSingleLine9_A() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """ abc def ghi """, -"""" -var x = """[||] """ -"""", -"""" -var x = """ - abc - def - ghi[||] - """ -"""", + """" + var x = """[||] """ + """", + """" + var x = """ + abc + def + ghi[||] + """ + """", afterUndo: -"""" -var x = """ abc - def - ghi[||] """ -""""); - } + """" + var x = """ abc + def + ghi[||] """ + """"); [WpfFact] public void TestNormalTextIntoSingleLineRawStringSingleLine9_B() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """ abc def ghi """, -"""" -var x = """ [||]""" -"""", -"""" -var x = """ - abc - def - ghi - [||]""" -"""", + """" + var x = """ [||]""" + """", + """" + var x = """ + abc + def + ghi + [||]""" + """", afterUndo: -"""" -var x = """ abc - def - ghi[||]""" -""""); - } + """" + var x = """ abc + def + ghi[||]""" + """"); [WpfFact] public void TestNormalTextIntoSingleLineRawStringSingleLine10_A() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """ abc def ghi """, -"""" -var x = """[||] """ -"""", -"""" -var x = """ - abc - def - ghi[||] - """ -"""", + """" + var x = """[||] """ + """", + """" + var x = """ + abc + def + ghi[||] + """ + """", afterUndo: -"""" -var x = """ abc - def - ghi[||] """ -""""); - } + """" + var x = """ abc + def + ghi[||] """ + """"); [WpfFact] public void TestNormalTextIntoSingleLineRawStringSingleLine10_B() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """ abc def ghi """, -"""" -var x = """ [||]""" -"""", -"""" -var x = """ - abc - def - ghi - [||]""" -"""", + """" + var x = """ [||]""" + """", + """" + var x = """ + abc + def + ghi + [||]""" + """", afterUndo: -"""" -var x = """ abc - def - ghi[||]""" -""""); - } + """" + var x = """ abc + def + ghi[||]""" + """"); [WpfFact] public void TestNormalTextIntoSingleLineRawStringSingleLine11_A() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """ abc def """, -"""" -var x = """[||]{|Selection: |}""" -"""", -"""" -var x = """ - abc - def - [||]""" -"""", + """" + var x = """[||]{|Selection: |}""" + """", + """" + var x = """ + abc + def + [||]""" + """", afterUndo: -"""" -var x = """abc -def[||]""" -""""); - } + """" + var x = """abc + def[||]""" + """"); [WpfFact] public void TestNormalTextIntoSingleLineRawStringSingleLine11_B() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """ abc def """, -"""" -var x = """ [||]{|Selection: |} """ -"""", -"""" -var x = """ - abc - def[||] - """ -"""", + """" + var x = """ [||]{|Selection: |} """ + """", + """" + var x = """ + abc + def[||] + """ + """", afterUndo: -"""" -var x = """ abc -def[||] """ -""""); - } + """" + var x = """ abc + def[||] """ + """"); [WpfFact] public void TestNormalTextIntoSingleLineRawStringSingleLine12_A() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """ abc def """, -"""" -var x = """[||]{|Selection: |}""" -"""", -"""" -var x = """ - abc - def - - [||]""" -"""", + """" + var x = """[||]{|Selection: |}""" + """", + """" + var x = """ + abc + def + + [||]""" + """", afterUndo: -"""" -var x = """abc -def -[||]""" -""""); - } + """" + var x = """abc + def + [||]""" + """"); [WpfFact] public void TestNormalTextIntoSingleLineRawStringSingleLine12_B() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """ abc def """, -"""" -var x = """ [||]{|Selection: |} """ -"""", -"""" -var x = """ - abc - def - [||] - """ -"""", + """" + var x = """ [||]{|Selection: |} """ + """", + """" + var x = """ + abc + def + [||] + """ + """", afterUndo: -"""" -var x = """ abc -def -[||] """ -""""); - } + """" + var x = """ abc + def + [||] """ + """"); [WpfFact] public void TestNormalTextIntoSingleLineRawStringSingleLine13_A() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """ abc def """, -"""" -var x = """[||]{|Selection: |} """ -"""", -"""" -var x = """ - abc - def[||] - """ -"""", + """" + var x = """[||]{|Selection: |} """ + """", + """" + var x = """ + abc + def[||] + """ + """", afterUndo: -"""" -var x = """abc -def[||] """ -""""); - } + """" + var x = """abc + def[||] """ + """"); [WpfFact] public void TestNormalTextIntoSingleLineRawStringSingleLine13_B() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """ abc def """, -"""" -var x = """ [||]{|Selection: |}""" -"""", -"""" -var x = """ - abc - def - [||]""" -"""", + """" + var x = """ [||]{|Selection: |}""" + """", + """" + var x = """ + abc + def + [||]""" + """", afterUndo: -"""" -var x = """ abc -def[||]""" -""""); - } + """" + var x = """ abc + def[||]""" + """"); [WpfFact] public void TestNormalTextIntoSingleLineRawStringHeader1_A() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """ "bar """, -"""" -var x = """[||]goo""" -"""", -"""" -var x = """ - "bar[||]goo - """ -"""", + """" + var x = """[||]goo""" + """", + """" + var x = """ + "bar[||]goo + """ + """", afterUndo: -""""" -var x = """"bar[||]goo""" -"""""); - } + """"" + var x = """"bar[||]goo""" + """""); [WpfFact] public void TestNormalTextIntoSingleLineRawStringHeader1_B() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """ bar" """, -"""" -var x = """goo[||]""" -"""", -"""" -var x = """ - goobar" - [||]""" -"""", + """" + var x = """goo[||]""" + """", + """" + var x = """ + goobar" + [||]""" + """", afterUndo: -"""" -var x = """goobar"[||]""" -""""); - } + """" + var x = """goobar"[||]""" + """"); [WpfFact] public void TestQuotesIntoHeader1() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """ "" """, -"""" -var x = """[||]{|Selection: |}""" -"""", -"""" -var x = """ - "" - [||]""" -"""", + """" + var x = """[||]{|Selection: |}""" + """", + """" + var x = """ + "" + [||]""" + """", afterUndo: -"""""" -var x = """""[||]""" -""""""); - } + """""" + var x = """""[||]""" + """"""); [WpfFact] public void TestQuotesIntoHeader2() - { - TestPasteKnownSource( + => TestPasteKnownSource( pasteText: """" """ """", -"""" -var x = """[||]{|Selection: |}""" -"""", -""""" -var x = """" - """ - [||]"""" -""""", + """" + var x = """[||]{|Selection: |}""" + """", + """"" + var x = """" + """ + [||]"""" + """"", afterUndo: -""""""" -var x = """"""[||]""" -"""""""); - } + """"""" + var x = """"""[||]""" + """""""); #endregion } diff --git a/src/EditorFeatures/CSharpTest/StringCopyPaste/PasteKnownSourceIntoVerbatimInterpolatedStringTests.cs b/src/EditorFeatures/CSharpTest/StringCopyPaste/PasteKnownSourceIntoVerbatimInterpolatedStringTests.cs index 26f2787ff10f..2548ba80c8b7 100644 --- a/src/EditorFeatures/CSharpTest/StringCopyPaste/PasteKnownSourceIntoVerbatimInterpolatedStringTests.cs +++ b/src/EditorFeatures/CSharpTest/StringCopyPaste/PasteKnownSourceIntoVerbatimInterpolatedStringTests.cs @@ -10,8 +10,7 @@ public sealed class PasteKnownSourceIntoVerbatimInterpolatedStringTests : String { [WpfFact] public void TestPasteSimpleNormalLiteralContent() - { - TestCopyPaste( + => TestCopyPaste( """var v = "{|Copy:goo|}";""", """ var dest = @@ -25,12 +24,10 @@ public void TestPasteSimpleNormalLiteralContent() var dest = $@"[||]"; """); - } [WpfFact] public void TestPasteOpenBraceNormalLiteralContent() - { - TestCopyPaste( + => TestCopyPaste( """var v = "{|Copy:{|}";""", """ var dest = @@ -44,12 +41,10 @@ public void TestPasteOpenBraceNormalLiteralContent() var dest = $@"{[||]"; """); - } [WpfFact] public void TestPasteOpenCloseBraceNormalLiteralContent() - { - TestCopyPaste( + => TestCopyPaste( """var v = "{|Copy:{}|}";""", """ var dest = @@ -63,12 +58,10 @@ public void TestPasteOpenCloseBraceNormalLiteralContent() var dest = $@"{}[||]"; """); - } [WpfFact] public void TestPasteLooksLikeInterpolationNormalLiteralContent() - { - TestCopyPaste( + => TestCopyPaste( """var v = "{|Copy:{0}|}";""", """ var dest = @@ -82,12 +75,10 @@ public void TestPasteLooksLikeInterpolationNormalLiteralContent() var dest = $@"{0}[||]"; """); - } [WpfFact] public void TestPasteSimpleSubstringNormalLiteralContent() - { - TestCopyPaste( + => TestCopyPaste( """var v = "g{|Copy:o|}o";""", """ var dest = @@ -101,12 +92,10 @@ public void TestPasteSimpleSubstringNormalLiteralContent() var dest = $@"[||]"; """); - } [WpfFact] public void TestPastePartiallySelectedEscapeNormalLiteralContent() - { - TestCopyPaste( + => TestCopyPaste( """var v = "\{|Copy:n|}";""", """ var dest = @@ -120,12 +109,10 @@ public void TestPastePartiallySelectedEscapeNormalLiteralContent() var dest = $@"[||]"; """); - } [WpfFact] public void TestPasteFullySelectedEscapeNormalLiteralContent() - { - TestCopyPaste( + => TestCopyPaste( """var v = "{|Copy:\r\n|}";""", """ var dest = @@ -140,12 +127,10 @@ public void TestPasteFullySelectedEscapeNormalLiteralContent() var dest = $@"\r\n[||]"; """); - } [WpfFact] public void TestPastePartiallySelectedQuoteNormalLiteralContent() - { - TestCopyPaste( + => TestCopyPaste( """var v = "\{|Copy:"|}";""", """ var dest = @@ -159,12 +144,10 @@ public void TestPastePartiallySelectedQuoteNormalLiteralContent() var dest = $@""[||]"; """); - } [WpfFact] public void TestPasteFullySelectedQuoteNormalLiteralContent() - { - TestCopyPaste( + => TestCopyPaste( """var v = "{|Copy:\"|}";""", """ var dest = @@ -178,12 +161,10 @@ public void TestPasteFullySelectedQuoteNormalLiteralContent() var dest = $@"\"[||]"; """); - } [WpfFact] public void TestPasteSimpleVerbatimLiteralContent() - { - TestCopyPaste( + => TestCopyPaste( """var v = @"{|Copy:goo|}";""", """ var dest = @@ -197,12 +178,10 @@ public void TestPasteSimpleVerbatimLiteralContent() var dest = $@"[||]"; """); - } [WpfFact] public void TestPasteSimpleSubstringVerbatimLiteralContent() - { - TestCopyPaste( + => TestCopyPaste( """var v = @"g{|Copy:o|}o";""", """ var dest = @@ -216,12 +195,10 @@ public void TestPasteSimpleSubstringVerbatimLiteralContent() var dest = $@"[||]"; """); - } [WpfFact] public void TestPasteSelectedVerbatimNewLineLiteralContent() - { - TestCopyPaste( + => TestCopyPaste( """ var v = @"{|Copy: |}"; @@ -239,12 +216,10 @@ public void TestPasteSelectedVerbatimNewLineLiteralContent() var dest = $@"[||]"; """); - } [WpfFact] public void TestPasteFullySelectedEscapeVerbatimLiteralContent() - { - TestCopyPaste( + => TestCopyPaste( """var v = @"{|Copy:""|}";""", """ var dest = @@ -258,12 +233,10 @@ public void TestPasteFullySelectedEscapeVerbatimLiteralContent() var dest = $@"[||]"; """); - } [WpfFact] public void TestPasteSimpleRawSingleLineLiteralContent() - { - TestCopyPaste( + => TestCopyPaste( """"var v = """{|Copy:goo|}""";"""", """ var dest = @@ -277,12 +250,10 @@ public void TestPasteSimpleRawSingleLineLiteralContent() var dest = $@"[||]"; """); - } [WpfFact] public void TestPasteQuotesRawSingleLineLiteralContent() - { - TestCopyPaste( + => TestCopyPaste( """"var v = """{|Copy: "" |}""";"""", """ var dest = @@ -296,12 +267,10 @@ public void TestPasteQuotesRawSingleLineLiteralContent() var dest = $@" "" [||]"; """); - } [WpfFact] public void TestPasteSimpleRawMultiLineLiteralContent1() - { - TestCopyPaste( + => TestCopyPaste( """" var v = """ {|Copy:goo|} @@ -319,12 +288,10 @@ public void TestPasteSimpleRawMultiLineLiteralContent1() var dest = $@"[||]"; """); - } [WpfFact] public void TestPasteSimpleRawMultiLineLiteralContent2() - { - TestCopyPaste( + => TestCopyPaste( """" var v = """ {|Copy:goo @@ -345,12 +312,10 @@ public void TestPasteSimpleRawMultiLineLiteralContent2() $@"goo bar[||]"; """); - } [WpfFact] public void TestPasteSimpleRawMultiLineLiteralContent3() - { - TestCopyPaste( + => TestCopyPaste( """" var v = """ {|Copy: goo @@ -371,12 +336,10 @@ public void TestPasteSimpleRawMultiLineLiteralContent3() $@" goo bar[||]"; """); - } [WpfFact] public void TestPasteInterpolationWithFormatClauseFromInterpolatedStringLiteralContent1() - { - TestCopyPaste( + => TestCopyPaste( """var v = $"{|Copy:{0:X}|}";""", """ var dest = @@ -390,12 +353,10 @@ public void TestPasteInterpolationWithFormatClauseFromInterpolatedStringLiteralC var dest = $@"[||]"; """); - } [WpfFact] public void TestPasteInterpolationWithFormatClauseFromInterpolatedStringLiteralContent2() - { - TestCopyPaste( + => TestCopyPaste( """var v = $"{|Copy:{0:\"X\"}|}";""", """ var dest = @@ -409,12 +370,10 @@ public void TestPasteInterpolationWithFormatClauseFromInterpolatedStringLiteralC var dest = $@"{0:\"X\"}[||]"; """); - } [WpfFact] public void TestPasteInterpolationWithFormatClauseFromVerbatimInterpolatedStringLiteralContent1() - { - TestCopyPaste( + => TestCopyPaste( """var v = $@"{|Copy:{0:X}|}";""", """ var dest = @@ -428,12 +387,10 @@ public void TestPasteInterpolationWithFormatClauseFromVerbatimInterpolatedString var dest = $@"[||]"; """); - } [WpfFact] public void TestPasteInterpolationWithFormatClauseFromVerbatimInterpolatedStringLiteralContent2() - { - TestCopyPaste( + => TestCopyPaste( """var v = $@"{|Copy:{0:""X""}|}";""", """ var dest = @@ -447,5 +404,4 @@ public void TestPasteInterpolationWithFormatClauseFromVerbatimInterpolatedString var dest = $@"[||]"; """); - } } diff --git a/src/EditorFeatures/CSharpTest/StringCopyPaste/PasteKnownSourceIntoVerbatimStringTests.cs b/src/EditorFeatures/CSharpTest/StringCopyPaste/PasteKnownSourceIntoVerbatimStringTests.cs index d6e630ceae82..dbe1650dafd7 100644 --- a/src/EditorFeatures/CSharpTest/StringCopyPaste/PasteKnownSourceIntoVerbatimStringTests.cs +++ b/src/EditorFeatures/CSharpTest/StringCopyPaste/PasteKnownSourceIntoVerbatimStringTests.cs @@ -10,8 +10,7 @@ public sealed class PasteKnownSourceIntoVerbatimStringTests : StringCopyPasteCom { [WpfFact] public void TestPasteSimpleNormalLiteralContent() - { - TestCopyPaste( + => TestCopyPaste( """var v = "{|Copy:goo|}";""", """ var dest = @@ -25,12 +24,10 @@ public void TestPasteSimpleNormalLiteralContent() var dest = @"[||]"; """); - } [WpfFact] public void TestPasteSimpleSubstringNormalLiteralContent() - { - TestCopyPaste( + => TestCopyPaste( """var v = "g{|Copy:o|}o";""", """ var dest = @@ -44,12 +41,10 @@ public void TestPasteSimpleSubstringNormalLiteralContent() var dest = @"[||]"; """); - } [WpfFact] public void TestPastePartiallySelectedEscapeNormalLiteralContent() - { - TestCopyPaste( + => TestCopyPaste( """var v = "\{|Copy:n|}";""", """ var dest = @@ -63,12 +58,10 @@ public void TestPastePartiallySelectedEscapeNormalLiteralContent() var dest = @"[||]"; """); - } [WpfFact] public void TestPasteFullySelectedEscapeNormalLiteralContent() - { - TestCopyPaste( + => TestCopyPaste( """var v = "{|Copy:\r\n|}";""", """ var dest = @@ -83,12 +76,10 @@ public void TestPasteFullySelectedEscapeNormalLiteralContent() var dest = @"\r\n[||]"; """); - } [WpfFact] public void TestPastePartiallySelectedQuoteNormalLiteralContent() - { - TestCopyPaste( + => TestCopyPaste( """var v = "\{|Copy:"|}";""", """ var dest = @@ -102,12 +93,10 @@ public void TestPastePartiallySelectedQuoteNormalLiteralContent() var dest = @""[||]"; """); - } [WpfFact] public void TestPasteFullySelectedQuoteNormalLiteralContent() - { - TestCopyPaste( + => TestCopyPaste( """var v = "{|Copy:\"|}";""", """ var dest = @@ -121,11 +110,9 @@ public void TestPasteFullySelectedQuoteNormalLiteralContent() var dest = @"\"[||]"; """); - } [WpfFact] public void TestPasteSimpleVerbatimLiteralContent() - { - TestCopyPaste( + => TestCopyPaste( """var v = @"{|Copy:goo|}";""", """ var dest = @@ -139,12 +126,10 @@ public void TestPasteSimpleVerbatimLiteralContent() var dest = @"[||]"; """); - } [WpfFact] public void TestPasteSimpleSubstringVerbatimLiteralContent() - { - TestCopyPaste( + => TestCopyPaste( """var v = @"g{|Copy:o|}o";""", """ var dest = @@ -158,12 +143,10 @@ public void TestPasteSimpleSubstringVerbatimLiteralContent() var dest = @"[||]"; """); - } [WpfFact] public void TestPasteSelectedVerbatimNewLineLiteralContent() - { - TestCopyPaste( + => TestCopyPaste( """ var v = @"{|Copy: |}"; @@ -181,12 +164,10 @@ public void TestPasteSelectedVerbatimNewLineLiteralContent() var dest = @"[||]"; """); - } [WpfFact] public void TestPasteFullySelectedEscapeVerbatimLiteralContent() - { - TestCopyPaste( + => TestCopyPaste( """var v = @"{|Copy:""|}";""", """ var dest = @@ -200,12 +181,10 @@ public void TestPasteFullySelectedEscapeVerbatimLiteralContent() var dest = @"[||]"; """); - } [WpfFact] public void TestPasteSimpleRawSingleLineLiteralContent() - { - TestCopyPaste( + => TestCopyPaste( """"var v = """{|Copy:goo|}""";"""", """ var dest = @@ -219,12 +198,10 @@ public void TestPasteSimpleRawSingleLineLiteralContent() var dest = @"[||]"; """); - } [WpfFact] public void TestPasteQuotesRawSingleLineLiteralContent() - { - TestCopyPaste( + => TestCopyPaste( """"var v = """{|Copy: "" |}""";"""", """ var dest = @@ -238,12 +215,10 @@ public void TestPasteQuotesRawSingleLineLiteralContent() var dest = @" "" [||]"; """); - } [WpfFact] public void TestPasteSimpleRawMultiLineLiteralContent1() - { - TestCopyPaste( + => TestCopyPaste( """" var v = """ {|Copy:goo|} @@ -261,12 +236,10 @@ public void TestPasteSimpleRawMultiLineLiteralContent1() var dest = @"[||]"; """); - } [WpfFact] public void TestPasteSimpleRawMultiLineLiteralContent2() - { - TestCopyPaste( + => TestCopyPaste( """" var v = """ {|Copy:goo @@ -287,12 +260,10 @@ public void TestPasteSimpleRawMultiLineLiteralContent2() @"goo bar[||]"; """); - } [WpfFact] public void TestPasteSimpleRawMultiLineLiteralContent3() - { - TestCopyPaste( + => TestCopyPaste( """" var v = """ {|Copy: goo @@ -313,12 +284,10 @@ public void TestPasteSimpleRawMultiLineLiteralContent3() @" goo bar[||]"; """); - } [WpfFact] public void TestPasteInterpolationFromInterpolatedStringLiteralContent() - { - TestCopyPaste( + => TestCopyPaste( """var v = $"{|Copy:{0}|}";""", """ var dest = @@ -332,12 +301,10 @@ public void TestPasteInterpolationFromInterpolatedStringLiteralContent() var dest = @"[||]"; """); - } [WpfFact] public void TestPasteInterpolationWithFormatClauseFromInterpolatedStringLiteralContent1() - { - TestCopyPaste( + => TestCopyPaste( """var v = $"{|Copy:{0:X}|}";""", """ var dest = @@ -351,12 +318,10 @@ public void TestPasteInterpolationWithFormatClauseFromInterpolatedStringLiteralC var dest = @"[||]"; """); - } [WpfFact] public void TestPasteInterpolationWithFormatClauseFromInterpolatedStringLiteralContent2() - { - TestCopyPaste( + => TestCopyPaste( """var v = $"{|Copy:{0:\"X\"}|}";""", """ var dest = @@ -370,12 +335,10 @@ public void TestPasteInterpolationWithFormatClauseFromInterpolatedStringLiteralC var dest = @"{0:\"X\"}[||]"; """); - } [WpfFact] public void TestPasteInterpolationWithStringFromInterpolatedStringLiteralContent1() - { - TestCopyPaste( + => TestCopyPaste( """var v = $"{|Copy:{"goo"}|}";""", """ var dest = @@ -389,12 +352,10 @@ public void TestPasteInterpolationWithStringFromInterpolatedStringLiteralContent var dest = @"{"goo"}[||]"; """); - } [WpfFact] public void TestPasteInterpolationWithStringFromInterpolatedStringLiteralContent2() - { - TestCopyPaste( + => TestCopyPaste( """var v = $"{|Copy:X{"goo"}Y|}";""", """ var dest = @@ -408,12 +369,10 @@ public void TestPasteInterpolationWithStringFromInterpolatedStringLiteralContent var dest = @"X{"goo"}Y[||]"; """); - } [WpfFact] public void TestPasteInterpolationWithStringFromInterpolatedStringLiteralContent3() - { - TestCopyPaste( + => TestCopyPaste( """var v = $"{|Copy:\"X{"goo"}Y\"|}";""", """ var dest = @@ -427,12 +386,10 @@ public void TestPasteInterpolationWithStringFromInterpolatedStringLiteralContent var dest = @"\"X{"goo"}Y\"[||]"; """); - } [WpfFact] public void TestPasteInterpolationWithStringFromInterpolatedStringLiteralContent4() - { - TestCopyPaste( + => TestCopyPaste( """var v = $"{|Copy:\"X{@"goo"}Y\"|}";""", """ var dest = @@ -446,12 +403,10 @@ public void TestPasteInterpolationWithStringFromInterpolatedStringLiteralContent var dest = @"\"X{@"goo"}Y\"[||]"; """); - } [WpfFact] public void TestPasteInterpolationFromVerbatimInterpolatedStringLiteralContent() - { - TestCopyPaste( + => TestCopyPaste( """var v = $@"{|Copy:{0}|}";""", """ var dest = @@ -465,12 +420,10 @@ public void TestPasteInterpolationFromVerbatimInterpolatedStringLiteralContent() var dest = @"[||]"; """); - } [WpfFact] public void TestPasteInterpolationWithFormatClauseFromVerbatimInterpolatedStringLiteralContent1() - { - TestCopyPaste( + => TestCopyPaste( """var v = $@"{|Copy:{0:X}|}";""", """ var dest = @@ -484,12 +437,10 @@ public void TestPasteInterpolationWithFormatClauseFromVerbatimInterpolatedString var dest = @"[||]"; """); - } [WpfFact] public void TestPasteInterpolationWithFormatClauseFromVerbatimInterpolatedStringLiteralContent2() - { - TestCopyPaste( + => TestCopyPaste( """var v = $@"{|Copy:{0:""X""}|}";""", """ var dest = @@ -503,12 +454,10 @@ public void TestPasteInterpolationWithFormatClauseFromVerbatimInterpolatedString var dest = @"[||]"; """); - } [WpfFact] public void TestPasteInterpolationWithStringFromVerbatimInterpolatedStringLiteralContent1() - { - TestCopyPaste( + => TestCopyPaste( """var v = $@"{|Copy:{"goo"}|}";""", """ var dest = @@ -522,12 +471,10 @@ public void TestPasteInterpolationWithStringFromVerbatimInterpolatedStringLitera var dest = @"{"goo"}[||]"; """); - } [WpfFact] public void TestPasteInterpolationWithStringFromVerbatimInterpolatedStringLiteralContent2() - { - TestCopyPaste( + => TestCopyPaste( """var v = $@"{|Copy:X{"goo"}Y|}";""", """ var dest = @@ -541,12 +488,10 @@ public void TestPasteInterpolationWithStringFromVerbatimInterpolatedStringLitera var dest = @"X{"goo"}Y[||]"; """); - } [WpfFact] public void TestPasteInterpolationWithStringFromVerbatimInterpolatedStringLiteralContent3() - { - TestCopyPaste( + => TestCopyPaste( """var v = $@"{|Copy:""X{"goo"}Y""|}";""", """ var dest = @@ -560,12 +505,10 @@ public void TestPasteInterpolationWithStringFromVerbatimInterpolatedStringLitera var dest = @"""X{"goo"}Y""[||]"; """"); - } [WpfFact] public void TestPasteInterpolationWithStringFromVerbatimInterpolatedStringLiteralContent4() - { - TestCopyPaste( + => TestCopyPaste( """var v = $@"{|Copy:""X{@"goo"}Y""|}";""", """ var dest = @@ -579,5 +522,4 @@ public void TestPasteInterpolationWithStringFromVerbatimInterpolatedStringLitera var dest = @"""X{@"goo"}Y""[||]"; """"); - } } diff --git a/src/EditorFeatures/CSharpTest/StringCopyPaste/PasteUnknownSourceIntoMultiLineInterpolatedRawStringTests.cs b/src/EditorFeatures/CSharpTest/StringCopyPaste/PasteUnknownSourceIntoMultiLineInterpolatedRawStringTests.cs index df8de473d025..f68990e940f5 100644 --- a/src/EditorFeatures/CSharpTest/StringCopyPaste/PasteUnknownSourceIntoMultiLineInterpolatedRawStringTests.cs +++ b/src/EditorFeatures/CSharpTest/StringCopyPaste/PasteUnknownSourceIntoMultiLineInterpolatedRawStringTests.cs @@ -11,1047 +11,965 @@ public sealed class PasteUnknownSourceIntoMultiLineInterpolatedRawStringTests { [WpfFact] public void TestNewLineIntoMultiLineRawString1() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: "\n", -"""" -var x = $""" - [||] - """ -"""", -"var x = $\"\"\"\r\n \n [||]\r\n \"\"\"", + """" + var x = $""" + [||] + """ + """", + "var x = $\"\"\"\r\n \n [||]\r\n \"\"\"", afterUndo: -"var x = $\"\"\"\r\n \n[||]\r\n \"\"\""); - } + "var x = $\"\"\"\r\n \n[||]\r\n \"\"\""); [WpfFact] public void TestNewLineIntoMultiLineRawString2() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """ """, -"""" -var x = $""" - [||] - """ -"""", -"""" -var x = $""" - - [||] - """ -"""", + """" + var x = $""" + [||] + """ + """", + """" + var x = $""" + + [||] + """ + """", afterUndo: -"""" -var x = $""" - -[||] - """ -""""); - } + """" + var x = $""" + + [||] + """ + """"); [WpfFact] public void TestSpacesIntoMultiLineRawString1() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """ """, -"""" -var x = $""" - [||] - """ -"""", -"""" -var x = $""" - [||] - """ -"""", + """" + var x = $""" + [||] + """ + """", + """" + var x = $""" + [||] + """ + """", afterUndo: -"""" -var x = $""" - [||] - """ -""""); - } + """" + var x = $""" + [||] + """ + """"); [WpfFact] public void TestSpacesIntoMultiLineRawString2() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """ """, -"""" -var x = $""" - [||] - """ -"""", -"""" -var x = $""" - - [||] - """ -"""", + """" + var x = $""" + [||] + """ + """", + """" + var x = $""" + + [||] + """ + """", afterUndo: -"""" -var x = $""" - -[||] - """ -""""); - } + """" + var x = $""" + + [||] + """ + """"); [WpfFact] public void TestSingleQuoteIntoMultiLineRawString() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """'""", -"""" -var x = $""" - [||] - """ -"""", -"""" -var x = $""" - '[||] - """ -"""", + """" + var x = $""" + [||] + """ + """", + """" + var x = $""" + '[||] + """ + """", afterUndo: -"""" -var x = $""" - [||] - """ -""""); - } + """" + var x = $""" + [||] + """ + """"); [WpfFact] public void TestDoubleQuoteIntoMultiLineRawString() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """ " """, -"""" -var x = $""" - [||] - """ -"""", -"""" -var x = $""" - "[||] - """ -"""", + """" + var x = $""" + [||] + """ + """", + """" + var x = $""" + "[||] + """ + """", afterUndo: -"""" -var x = $""" - [||] - """ -""""); - } + """" + var x = $""" + [||] + """ + """"); [WpfFact] public void TestTripleQuoteIntoMultiLineRawString1() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """" """ """", -"""" -var x = $""" - [||] - """ -"""", -""""" -var x = $"""" - """[||] - """" -""""", + """" + var x = $""" + [||] + """ + """", + """"" + var x = $"""" + """[||] + """" + """"", afterUndo: -"""" -var x = $""" - """[||] - """ -""""); - } + """" + var x = $""" + """[||] + """ + """"); [WpfFact] public void TestTripleQuoteIntoMultiLineRawString2() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """" """ """", -"""" -var x = $""" - [||] - """ -"""", -""""" -var x = $"""" - """[||] - """" -""""", + """" + var x = $""" + [||] + """ + """", + """"" + var x = $"""" + """[||] + """" + """"", afterUndo: -"""" -var x = $""" - """[||] - """ -""""); - } + """" + var x = $""" + """[||] + """ + """"); [WpfFact] public void TestTripleQuoteIntoMultiLineRawString3() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """" """ """", -"""" -var x = $""" - "[||] - """ -"""", -"""""" -var x = $""""" - """"[||] - """"" -"""""", + """" + var x = $""" + "[||] + """ + """", + """""" + var x = $""""" + """"[||] + """"" + """""", afterUndo: -""""" -var x = $""" - """"[||] - """ -"""""); - } + """"" + var x = $""" + """"[||] + """ + """""); [WpfFact] public void TestTripleQuoteIntoMultiLineRawString4() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """" """ """", -"""" -var x = $""" - "[||]" - """ -"""", -""""""" -var x = $"""""" - """"[||]" - """""" -""""""", + """" + var x = $""" + "[||]" + """ + """", + """"""" + var x = $"""""" + """"[||]" + """""" + """"""", afterUndo: -""""" -var x = $""" - """"[||]" - """ -"""""); - } + """"" + var x = $""" + """"[||]" + """ + """""); [WpfFact] public void TestTripleQuoteIntoMultiLineRawString5() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """" """ """", -"""" -var x = $""" - [||]" - """ -"""", -"""""" -var x = $""""" - """[||]" - """"" -"""""", + """" + var x = $""" + [||]" + """ + """", + """""" + var x = $""""" + """[||]" + """"" + """""", afterUndo: -"""" -var x = $""" - """[||]" - """ -""""); - } + """" + var x = $""" + """[||]" + """ + """"); [WpfFact] public void TestQuadrupleQuoteIntoMultiLineRawString() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """"" """" """"", -"""" -var x = $""" - [||] - """ -"""", -"""""" -var x = $""""" - """"[||] - """"" -"""""", + """" + var x = $""" + [||] + """ + """", + """""" + var x = $""""" + """"[||] + """"" + """""", afterUndo: -""""" -var x = $""" - """"[||] - """ -"""""); - } + """"" + var x = $""" + """"[||] + """ + """""); [WpfFact] public void TestOpenBraceIntoMultiLineRawString() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """{""", -"""" -var x = $""" - [||] - """ -"""", -"""" -var x = $$""" - {[||] - """ -"""", + """" + var x = $""" + [||] + """ + """", + """" + var x = $$""" + {[||] + """ + """", afterUndo: -"""" -var x = $""" - {[||] - """ -""""); - } + """" + var x = $""" + {[||] + """ + """"); [WpfFact] public void TestTripleOpenBraceIntoMultiLineRawString() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """{{{""", -"""" -var x = $""" - [||] - """ -"""", -"""" -var x = $$$$""" - {{{[||] - """ -"""", + """" + var x = $""" + [||] + """ + """", + """" + var x = $$$$""" + {{{[||] + """ + """", afterUndo: -"""" -var x = $""" - {{{[||] - """ -""""); - } + """" + var x = $""" + {{{[||] + """ + """"); [WpfFact] public void TestTripleOpenBraceIntoMultiLineRawString2() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """{{{""", -"""" -var x = $$""" - [||] - """ -"""", -"""" -var x = $$$$""" - {{{[||] - """ -"""", + """" + var x = $$""" + [||] + """ + """", + """" + var x = $$$$""" + {{{[||] + """ + """", afterUndo: -"""" -var x = $$""" - {{{[||] - """ -""""); - } + """" + var x = $$""" + {{{[||] + """ + """"); [WpfFact] public void TestOpenBraceIntoMultiLineRawString2() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """{""", -"""" -var x = $$$""" - {[||]{ - """ -"""", -"""" -var x = $$$$""" - {{[||]{ - """ -"""", + """" + var x = $$$""" + {[||]{ + """ + """", + """" + var x = $$$$""" + {{[||]{ + """ + """", afterUndo: -"""" -var x = $$$""" - {{[||]{ - """ -""""); - } + """" + var x = $$$""" + {{[||]{ + """ + """"); [WpfFact] public void TestInterpolationIntoMultiLineRawString3() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """{0}""", -"""" -var x = $""" - [||] - """ -"""", -"""" -var x = $""" - {0}[||] - """ -"""", + """" + var x = $""" + [||] + """ + """", + """" + var x = $""" + {0}[||] + """ + """", afterUndo: -"""" -var x = $""" - [||] - """ -""""); - } + """" + var x = $""" + [||] + """ + """"); [WpfFact] public void TestOpenCloseIntoMultiLineRawString4() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """{}""", -"""" -var x = $""" - [||] - """ -"""", -"""" -var x = $$""" - {}[||] - """ -"""", + """" + var x = $""" + [||] + """ + """", + """" + var x = $$""" + {}[||] + """ + """", afterUndo: -"""" -var x = $""" - {}[||] - """ -""""); - } + """" + var x = $""" + {}[||] + """ + """"); [WpfFact] public void TestOpenCloseBraceIntoMultiLineRawString5() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """{{}""", -"""" -var x = $$""" - [||] - """ -"""", -"""" -var x = $$$""" - {{}[||] - """ -"""", + """" + var x = $$""" + [||] + """ + """", + """" + var x = $$$""" + {{}[||] + """ + """", afterUndo: -"""" -var x = $$""" - {{}[||] - """ -""""); - } + """" + var x = $$""" + {{}[||] + """ + """"); [WpfFact] public void TestOpenCloseBraceIntoMultiLineRawString() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """{}}""", -"""" -var x = $""" - [||] - """ -"""", -"""" -var x = $$$""" - {}}[||] - """ -"""", + """" + var x = $""" + [||] + """ + """", + """" + var x = $$$""" + {}}[||] + """ + """", afterUndo: -"""" -var x = $""" - {}}[||] - """ -""""); - } + """" + var x = $""" + {}}[||] + """ + """"); [WpfFact] public void TestOpenCloseBraceIntoMultiLineRawString2() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """{{}}""", -"""" -var x = $""" - [||] - """ -"""", -"""" -var x = $$$""" - {{}}[||] - """ -"""", + """" + var x = $""" + [||] + """ + """", + """" + var x = $$$""" + {{}}[||] + """ + """", afterUndo: -"""" -var x = $""" - {{}}[||] - """ -""""); - } + """" + var x = $""" + {{}}[||] + """ + """"); [WpfFact] public void TestTripleQuoteTripleOpenBraceIntoMultiLineRawString() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """" """{{{ """", -"""" -var x = $""" - [||] - """ -"""", -""""" -var x = $$$$"""" - """{{{[||] - """" -""""", + """" + var x = $""" + [||] + """ + """", + """"" + var x = $$$$"""" + """{{{[||] + """" + """"", afterUndo: -"""" -var x = $""" - """{{{[||] - """ -""""); - } + """" + var x = $""" + """{{{[||] + """ + """"); [WpfFact] public void TestComplexStringIntoMultiLineRawString() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """ "" """, -"""" -var x = $""" - [||] - """ -"""", -"""" -var x = $""" - "" [||] - """ -"""", + """" + var x = $""" + [||] + """ + """", + """" + var x = $""" + "" [||] + """ + """", afterUndo: -"""" -var x = $""" - "" [||] - """ -""""); - } + """" + var x = $""" + "" [||] + """ + """"); [WpfFact] public void TestNormalTextIntoMultiLineRawString() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """abc""", -"""" -var x = $""" - [||] - """ -"""", -"""" -var x = $""" - abc[||] - """ -"""", + """" + var x = $""" + [||] + """ + """", + """" + var x = $""" + abc[||] + """ + """", afterUndo: -"""" -var x = $""" - [||] - """ -""""); - } + """" + var x = $""" + [||] + """ + """"); [WpfFact] public void TestNormalTextIntoMultiLineRawStringMultiLine1() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """ abc def """, -"""" -var x = $""" - [||] - """ -"""", -"""" -var x = $""" - abc - def[||] - """ -"""", + """" + var x = $""" + [||] + """ + """", + """" + var x = $""" + abc + def[||] + """ + """", afterUndo: -"""" -var x = $""" - abc -def[||] - """ -""""); - } + """" + var x = $""" + abc + def[||] + """ + """"); [WpfFact] public void TestNormalTextIntoMultiLineRawStringMultiLine2() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """ abc def """, -"""" -var x = $""" -[||] - """ -"""", -"""" -var x = $""" - abc - def[||] - """ -"""", + """" + var x = $""" + [||] + """ + """", + """" + var x = $""" + abc + def[||] + """ + """", afterUndo: -"""" -var x = $""" -abc -def[||] - """ -""""); - } + """" + var x = $""" + abc + def[||] + """ + """"); [WpfFact] public void TestNormalTextIntoMultiLineRawStringMultiLine3() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """ abc def """, -"""" -var x = $"""[||] + """" + var x = $"""[||] - """ -"""", -"""" -var x = $""" - abc - def[||] + """ + """", + """" + var x = $""" + abc + def[||] - """ -"""", + """ + """", afterUndo: -"""" -var x = $"""abc -def[||] + """" + var x = $"""abc + def[||] - """ -""""); - } + """ + """"); [WpfFact] public void TestNormalTextIntoMultiLineRawStringMultiLine4() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """ abc def """, -"""" -var x = $""" - goo[||] - """ -"""", -"""" -var x = $""" - gooabc - def[||] - """ -"""", + """" + var x = $""" + goo[||] + """ + """", + """" + var x = $""" + gooabc + def[||] + """ + """", afterUndo: -"""" -var x = $""" - gooabc -def[||] - """ -""""); - } + """" + var x = $""" + gooabc + def[||] + """ + """"); [WpfFact] public void TestNormalTextIntoMultiLineRawStringMultiLine5() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """ abc def """, -"""" -var x = $""" - goo[||]bar - """ -"""", -"""" -var x = $""" - gooabc - def[||]bar - """ -"""", + """" + var x = $""" + goo[||]bar + """ + """", + """" + var x = $""" + gooabc + def[||]bar + """ + """", afterUndo: -"""" -var x = $""" - gooabc -def[||]bar - """ -""""); - } + """" + var x = $""" + gooabc + def[||]bar + """ + """"); [WpfFact] public void TestNormalTextIntoMultiLineRawStringMultiLine6() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """ abc def """, -"""" -var x = $""" - goo[||]bar - """ -"""", -"""" -var x = $""" - gooabc - def - [||]bar - """ -"""", + """" + var x = $""" + goo[||]bar + """ + """", + """" + var x = $""" + gooabc + def + [||]bar + """ + """", afterUndo: -"""" -var x = $""" - gooabc -def -[||]bar - """ -""""); - } + """" + var x = $""" + gooabc + def + [||]bar + """ + """"); [WpfFact] public void TestNormalTextIntoMultiLineRawStringMultiLine7() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """ abc def ghi """, -"""" -var x = $""" - [||] - """ -"""", -"""" -var x = $""" - abc - def - ghi[||] - """ -"""", + """" + var x = $""" + [||] + """ + """", + """" + var x = $""" + abc + def + ghi[||] + """ + """", afterUndo: -"""" -var x = $""" - abc - def -ghi[||] - """ -""""); - } + """" + var x = $""" + abc + def + ghi[||] + """ + """"); [WpfFact] public void TestNormalTextIntoMultiLineRawStringMultiLine7_B() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """ abc def ghi """, -"""" -var x = $""" - [||] - """ -"""", -"""" -var x = $""" - abc - def - ghi[||] - """ -"""", + """" + var x = $""" + [||] + """ + """", + """" + var x = $""" + abc + def + ghi[||] + """ + """", afterUndo: -"""" -var x = $""" - abc - def -ghi[||] - """ -""""); - } + """" + var x = $""" + abc + def + ghi[||] + """ + """"); [WpfFact] public void TestNormalTextIntoMultiLineRawStringMultiLine8() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """ abc def ghi """, -"""" -var x = $""" - [||] - """ -"""", -"""" -var x = $""" - abc - def - ghi[||] - """ -"""", + """" + var x = $""" + [||] + """ + """", + """" + var x = $""" + abc + def + ghi[||] + """ + """", afterUndo: -"""" -var x = $""" - [||] - """ -""""); - } + """" + var x = $""" + [||] + """ + """"); [WpfFact] public void TestNormalTextIntoMultiLineRawStringMultiLine9() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """ abc def ghi """, -"""" -var x = $""" - [||] - """ -"""", -"""" -var x = $""" - abc - def - ghi[||] - """ -"""", + """" + var x = $""" + [||] + """ + """", + """" + var x = $""" + abc + def + ghi[||] + """ + """", afterUndo: -"""" -var x = $""" - abc - def - ghi[||] - """ -""""); - } + """" + var x = $""" + abc + def + ghi[||] + """ + """"); [WpfFact] public void TestNormalTextIntoMultiLineRawStringMultiLine10() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """ abc def ghi """, -"""" -var x = $""" - [||] - """ -"""", -"""" -var x = $""" - abc - def - ghi[||] - """ -"""", + """" + var x = $""" + [||] + """ + """", + """" + var x = $""" + abc + def + ghi[||] + """ + """", afterUndo: -"""" -var x = $""" - abc - def - ghi[||] - """ -""""); - } + """" + var x = $""" + abc + def + ghi[||] + """ + """"); [WpfFact] public void TestNormalTextIntoMultiLineRawStringMultiLine11() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """ abc def """, -"""" -var x = $"""[||]{|Selection: + """" + var x = $"""[||]{|Selection: - |}""" -"""", -"""" -var x = $""" - abc - def - [||]""" -"""", + |}""" + """", + """" + var x = $""" + abc + def + [||]""" + """", afterUndo: -"""" -var x = $"""abc -def[||]""" -""""); - } + """" + var x = $"""abc + def[||]""" + """"); [WpfFact] public void TestNormalTextIntoMultiLineRawStringMultiLine12() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """ abc def """, -"""" -var x = $"""[||]{|Selection: + """" + var x = $"""[||]{|Selection: - |}""" -"""", -"""" -var x = $""" - abc - def - - [||]""" -"""", + |}""" + """", + """" + var x = $""" + abc + def + + [||]""" + """", afterUndo: -"""" -var x = $"""abc -def -[||]""" -""""); - } + """" + var x = $"""abc + def + [||]""" + """"); [WpfFact] public void TestNormalTextIntoMultiLineRawStringMultiLine13() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """ abc def """, -"""" -var x = $"""[||]{|Selection: + """" + var x = $"""[||]{|Selection: - |} """ -"""", -"""" -var x = $""" - abc - def - [||] """ -"""", + |} """ + """", + """" + var x = $""" + abc + def + [||] """ + """", afterUndo: -"""" -var x = $"""abc -def[||] """ -""""); - } + """" + var x = $"""abc + def[||] """ + """"); [WpfFact] public void TestNormalTextIntoMultiLineRawStringHeader1() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """bar""", -"""" -var x = $"""[||] - goo - """ -"""", -"""" -var x = $""" - bar[||] - goo - """ -"""", + """" + var x = $"""[||] + goo + """ + """", + """" + var x = $""" + bar[||] + goo + """ + """", afterUndo: -"""" -var x = $"""bar[||] - goo - """ -""""); - } + """" + var x = $"""bar[||] + goo + """ + """"); [WpfFact] public void TestQuotesIntoHeader1() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """ "" """, -"""" -var x = $"""[||]{|Selection: + """" + var x = $"""[||]{|Selection: - |}""" -"""", -"""" -var x = $""" - "" - [||]""" -"""", + |}""" + """", + """" + var x = $""" + "" + [||]""" + """", afterUndo: -"""""" -var x = $"""""[||]""" -""""""); - } + """""" + var x = $"""""[||]""" + """"""); [WpfFact] public void TestQuotesIntoHeader2() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """" """ """", -"""" -var x = $"""[||]{|Selection: + """" + var x = $"""[||]{|Selection: - |}""" -"""", -""""" -var x = $"""" - """ - [||]"""" -""""", + |}""" + """", + """"" + var x = $"""" + """ + [||]"""" + """"", afterUndo: -""""""" -var x = $""""""[||]""" -"""""""); - } + """"""" + var x = $""""""[||]""" + """""""); } diff --git a/src/EditorFeatures/CSharpTest/StringCopyPaste/PasteUnknownSourceIntoMultiLineRawStringTests.cs b/src/EditorFeatures/CSharpTest/StringCopyPaste/PasteUnknownSourceIntoMultiLineRawStringTests.cs index 539eaca72c7b..8fae764f4e56 100644 --- a/src/EditorFeatures/CSharpTest/StringCopyPaste/PasteUnknownSourceIntoMultiLineRawStringTests.cs +++ b/src/EditorFeatures/CSharpTest/StringCopyPaste/PasteUnknownSourceIntoMultiLineRawStringTests.cs @@ -11,815 +11,782 @@ public sealed class PasteUnknownSourceIntoMultiLineRawStringTests { [WpfFact] public void TestNewLineIntoMultiLineRawString1() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: "\n", -"""" -var x = """ - [||] - """ -"""", -"var x = \"\"\"\r\n \n [||]\r\n \"\"\"", + """" + var x = """ + [||] + """ + """", + "var x = \"\"\"\r\n \n [||]\r\n \"\"\"", afterUndo: -"var x = \"\"\"\r\n \n[||]\r\n \"\"\""); - } + "var x = \"\"\"\r\n \n[||]\r\n \"\"\""); [WpfFact] public void TestNewLineIntoMultiLineRawString2() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """ """, -"""" -var x = """ - [||] - """ -"""", -"""" -var x = """ - - [||] - """ -"""", + """" + var x = """ + [||] + """ + """", + """" + var x = """ + + [||] + """ + """", afterUndo: -"""" -var x = """ - -[||] - """ -""""); - } + """" + var x = """ + + [||] + """ + """"); [WpfFact] public void TestSpacesIntoMultiLineRawString1() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """ """, -"""" -var x = """ - [||] - """ -"""", -"""" -var x = """ - [||] - """ -"""", + """" + var x = """ + [||] + """ + """", + """" + var x = """ + [||] + """ + """", afterUndo: -"""" -var x = """ - [||] - """ -""""); - } + """" + var x = """ + [||] + """ + """"); [WpfFact] public void TestSpacesIntoMultiLineRawString2() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """ """, -"""" -var x = """ - [||] - """ -"""", -"""" -var x = """ - - [||] - """ -"""", + """" + var x = """ + [||] + """ + """", + """" + var x = """ + + [||] + """ + """", afterUndo: -"""" -var x = """ - -[||] - """ -""""); - } + """" + var x = """ + + [||] + """ + """"); [WpfFact] public void TestSingleQuoteIntoMultiLineRawString() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """'""", -"""" -var x = """ - [||] - """ -"""", -"""" -var x = """ - '[||] - """ -"""", + """" + var x = """ + [||] + """ + """", + """" + var x = """ + '[||] + """ + """", afterUndo: -"""" -var x = """ - [||] - """ -""""); - } + """" + var x = """ + [||] + """ + """"); [WpfFact] public void TestDoubleQuoteIntoMultiLineRawString() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """ " """, -"""" -var x = """ - [||] - """ -"""", -"""" -var x = """ - "[||] - """ -"""", + """" + var x = """ + [||] + """ + """", + """" + var x = """ + "[||] + """ + """", afterUndo: -"""" -var x = """ - [||] - """ -""""); - } + """" + var x = """ + [||] + """ + """"); [WpfFact] public void TestTripleQuoteIntoMultiLineRawString1() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """" """ """", -"""" -var x = """ - [||] - """ -"""", -""""" -var x = """" - """[||] - """" -""""", + """" + var x = """ + [||] + """ + """", + """"" + var x = """" + """[||] + """" + """"", afterUndo: -"""" -var x = """ - """[||] - """ -""""); - } + """" + var x = """ + """[||] + """ + """"); [WpfFact] public void TestTripleQuoteIntoMultiLineRawString2() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """" """ """", -"""" -var x = """ - [||] - """ -"""", -""""" -var x = """" - """[||] - """" -""""", + """" + var x = """ + [||] + """ + """", + """"" + var x = """" + """[||] + """" + """"", afterUndo: -"""" -var x = """ - """[||] - """ -""""); - } + """" + var x = """ + """[||] + """ + """"); [WpfFact] public void TestTripleQuoteIntoMultiLineRawString3() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """" """ """", -"""" -var x = """ - "[||] - """ -"""", -"""""" -var x = """"" - """"[||] - """"" -"""""", + """" + var x = """ + "[||] + """ + """", + """""" + var x = """"" + """"[||] + """"" + """""", afterUndo: -""""" -var x = """ - """"[||] - """ -"""""); - } + """"" + var x = """ + """"[||] + """ + """""); [WpfFact] public void TestTripleQuoteIntoMultiLineRawString4() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """" """ """", -"""" -var x = """ - "[||]" - """ -"""", -""""""" -var x = """""" - """"[||]" - """""" -""""""", + """" + var x = """ + "[||]" + """ + """", + """"""" + var x = """""" + """"[||]" + """""" + """"""", afterUndo: -""""" -var x = """ - """"[||]" - """ -"""""); - } + """"" + var x = """ + """"[||]" + """ + """""); [WpfFact] public void TestTripleQuoteIntoMultiLineRawString5() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """" """ """", -"""" -var x = """ - [||]" - """ -"""", -"""""" -var x = """"" - """[||]" - """"" -"""""", + """" + var x = """ + [||]" + """ + """", + """""" + var x = """"" + """[||]" + """"" + """""", afterUndo: -"""" -var x = """ - """[||]" - """ -""""); - } + """" + var x = """ + """[||]" + """ + """"); [WpfFact] public void TestQuadrupleQuoteIntoMultiLineRawString() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """"" """" """"", -"""" -var x = """ - [||] - """ -"""", -"""""" -var x = """"" - """"[||] - """"" -"""""", + """" + var x = """ + [||] + """ + """", + """""" + var x = """"" + """"[||] + """"" + """""", afterUndo: -""""" -var x = """ - """"[||] - """ -"""""); - } + """"" + var x = """ + """"[||] + """ + """""); [WpfFact] public void TestComplexStringIntoMultiLineRawString() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """ "" """, -"""" -var x = """ - [||] - """ -"""", -"""" -var x = """ - "" [||] - """ -"""", + """" + var x = """ + [||] + """ + """", + """" + var x = """ + "" [||] + """ + """", afterUndo: -"""" -var x = """ - "" [||] - """ -""""); - } + """" + var x = """ + "" [||] + """ + """"); [WpfFact] public void TestNormalTextIntoMultiLineRawString() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """abc""", -"""" -var x = """ - [||] - """ -"""", -"""" -var x = """ - abc[||] - """ -"""", + """" + var x = """ + [||] + """ + """", + """" + var x = """ + abc[||] + """ + """", afterUndo: -"""" -var x = """ - [||] - """ -""""); - } + """" + var x = """ + [||] + """ + """"); [WpfFact] public void TestNormalTextIntoMultiLineRawStringMultiLine1() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """ abc def """, -"""" -var x = """ - [||] - """ -"""", -"""" -var x = """ - abc - def[||] - """ -"""", + """" + var x = """ + [||] + """ + """", + """" + var x = """ + abc + def[||] + """ + """", afterUndo: -"""" -var x = """ - abc -def[||] - """ -""""); - } + """" + var x = """ + abc + def[||] + """ + """"); [WpfFact] public void TestNormalTextIntoMultiLineRawStringMultiLine2() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """ abc def """, -"""" -var x = """ -[||] - """ -"""", -"""" -var x = """ - abc - def[||] - """ -"""", + """" + var x = """ + [||] + """ + """", + """" + var x = """ + abc + def[||] + """ + """", afterUndo: -"""" -var x = """ -abc -def[||] - """ -""""); - } + """" + var x = """ + abc + def[||] + """ + """"); [WpfFact] public void TestNormalTextIntoMultiLineRawStringMultiLine3() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """ abc def """, -"""" -var x = """[||] - - """ -"""", -"""" -var x = """ - abc - def[||] - - """ -"""", + """" + var x = """[||] + + """ + """", + """" + var x = """ + abc + def[||] + + """ + """", afterUndo: -"""" -var x = """abc -def[||] + """" + var x = """abc + def[||] - """ -""""); - } + """ + """"); [WpfFact] public void TestNormalTextIntoMultiLineRawStringMultiLine4() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """ abc def """, -"""" -var x = """ - goo[||] - """ -"""", -"""" -var x = """ - gooabc - def[||] - """ -"""", + """" + var x = """ + goo[||] + """ + """", + """" + var x = """ + gooabc + def[||] + """ + """", afterUndo: -"""" -var x = """ - gooabc -def[||] - """ -""""); - } + """" + var x = """ + gooabc + def[||] + """ + """"); [WpfFact] public void TestNormalTextIntoMultiLineRawStringMultiLine5() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """ abc def """, -"""" -var x = """ - goo[||]bar - """ -"""", -"""" -var x = """ - gooabc - def[||]bar - """ -"""", + """" + var x = """ + goo[||]bar + """ + """", + """" + var x = """ + gooabc + def[||]bar + """ + """", afterUndo: -"""" -var x = """ - gooabc -def[||]bar - """ -""""); - } + """" + var x = """ + gooabc + def[||]bar + """ + """"); [WpfFact] public void TestNormalTextIntoMultiLineRawStringMultiLine6() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """ abc def """, -"""" -var x = """ - goo[||]bar - """ -"""", -"""" -var x = """ - gooabc - def - [||]bar - """ -"""", + """" + var x = """ + goo[||]bar + """ + """", + """" + var x = """ + gooabc + def + [||]bar + """ + """", afterUndo: -"""" -var x = """ - gooabc -def -[||]bar - """ -""""); - } + """" + var x = """ + gooabc + def + [||]bar + """ + """"); [WpfFact] public void TestNormalTextIntoMultiLineRawStringMultiLine7() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """ abc def ghi """, -"""" -var x = """ - [||] - """ -"""", -"""" -var x = """ - abc - def - ghi[||] - """ -"""", + """" + var x = """ + [||] + """ + """", + """" + var x = """ + abc + def + ghi[||] + """ + """", afterUndo: -"""" -var x = """ - abc - def -ghi[||] - """ -""""); - } + """" + var x = """ + abc + def + ghi[||] + """ + """"); [WpfFact] public void TestNormalTextIntoMultiLineRawStringMultiLine7_B() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """ abc def ghi """, -"""" -var x = """ - [||] - """ -"""", -"""" -var x = """ - abc - def - ghi[||] - """ -"""", + """" + var x = """ + [||] + """ + """", + """" + var x = """ + abc + def + ghi[||] + """ + """", afterUndo: -"""" -var x = """ - abc - def -ghi[||] - """ -""""); - } + """" + var x = """ + abc + def + ghi[||] + """ + """"); [WpfFact] public void TestNormalTextIntoMultiLineRawStringMultiLine8() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """ abc def ghi """, -"""" -var x = """ - [||] - """ -"""", -"""" -var x = """ - abc - def - ghi[||] - """ -"""", + """" + var x = """ + [||] + """ + """", + """" + var x = """ + abc + def + ghi[||] + """ + """", afterUndo: -"""" -var x = """ - [||] - """ -""""); - } + """" + var x = """ + [||] + """ + """"); [WpfFact] public void TestNormalTextIntoMultiLineRawStringMultiLine9() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """ abc def ghi """, -"""" -var x = """ - [||] - """ -"""", -"""" -var x = """ - abc - def - ghi[||] - """ -"""", + """" + var x = """ + [||] + """ + """", + """" + var x = """ + abc + def + ghi[||] + """ + """", afterUndo: -"""" -var x = """ - abc - def - ghi[||] - """ -""""); - } + """" + var x = """ + abc + def + ghi[||] + """ + """"); [WpfFact] public void TestNormalTextIntoMultiLineRawStringMultiLine10() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """ abc def ghi """, -"""" -var x = """ - [||] - """ -"""", -"""" -var x = """ - abc - def - ghi[||] - """ -"""", + """" + var x = """ + [||] + """ + """", + """" + var x = """ + abc + def + ghi[||] + """ + """", afterUndo: -"""" -var x = """ - abc - def - ghi[||] - """ -""""); - } + """" + var x = """ + abc + def + ghi[||] + """ + """"); [WpfFact] public void TestNormalTextIntoMultiLineRawStringMultiLine11() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """ abc def """, -"""" -var x = """[||]{|Selection: - - |}""" -"""", -"""" -var x = """ - abc - def - [||]""" -"""", + """" + var x = """[||]{|Selection: + + |}""" + """", + """" + var x = """ + abc + def + [||]""" + """", afterUndo: -"""" -var x = """abc -def[||]""" -""""); - } + """" + var x = """abc + def[||]""" + """"); [WpfFact] public void TestNormalTextIntoMultiLineRawStringMultiLine12() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """ abc def """, -"""" -var x = """[||]{|Selection: - - |}""" -"""", -"""" -var x = """ - abc - def - - [||]""" -"""", + """" + var x = """[||]{|Selection: + + |}""" + """", + """" + var x = """ + abc + def + + [||]""" + """", afterUndo: -"""" -var x = """abc -def -[||]""" -""""); - } + """" + var x = """abc + def + [||]""" + """"); [WpfFact] public void TestNormalTextIntoMultiLineRawStringMultiLine13() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """ abc def """, -"""" -var x = """[||]{|Selection: - - |} """ -"""", -"""" -var x = """ - abc - def - [||] """ -"""", + """" + var x = """[||]{|Selection: + + |} """ + """", + """" + var x = """ + abc + def + [||] """ + """", afterUndo: -"""" -var x = """abc -def[||] """ -""""); - } + """" + var x = """abc + def[||] """ + """"); + + [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/74661")] + public void TestNormalTextIntoMultiLineRawStringMultiLine14() + => TestPasteUnknownSource( + pasteText: """ + abc + def + ghi + """, + """" + var x = """ + [||] + """ + """", + """" + var x = """ + abc + def + ghi[||] + """ + """", + afterUndo: + """" + var x = """ + abc + def + ghi[||] + """ + """"); [WpfFact] public void TestNormalTextIntoMultiLineRawStringHeader1() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """bar""", -"""" -var x = """[||] - goo - """ -"""", -"""" -var x = """ - bar[||] - goo - """ -"""", + """" + var x = """[||] + goo + """ + """", + """" + var x = """ + bar[||] + goo + """ + """", afterUndo: -"""" -var x = """bar[||] - goo - """ -""""); - } + """" + var x = """bar[||] + goo + """ + """"); [WpfFact] public void TestQuotesIntoHeader1() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """ "" """, -"""" -var x = """[||]{|Selection: - - |}""" -"""", -"""" -var x = """ - "" - [||]""" -"""", + """" + var x = """[||]{|Selection: + + |}""" + """", + """" + var x = """ + "" + [||]""" + """", afterUndo: -"""""" -var x = """""[||]""" -""""""); - } + """""" + var x = """""[||]""" + """"""); [WpfFact] public void TestQuotesIntoHeader2() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """" """ """", -"""" -var x = """[||]{|Selection: + """" + var x = """[||]{|Selection: - |}""" -"""", -""""" -var x = """" - """ - [||]"""" -""""", + |}""" + """", + """"" + var x = """" + """ + [||]"""" + """"", afterUndo: -""""""" -var x = """"""[||]""" -"""""""); - } + """"""" + var x = """"""[||]""" + """""""); } diff --git a/src/EditorFeatures/CSharpTest/StringCopyPaste/PasteUnknownSourceIntoNormalInterpolatedStringTests.cs b/src/EditorFeatures/CSharpTest/StringCopyPaste/PasteUnknownSourceIntoNormalInterpolatedStringTests.cs index dfbf41b60389..511430701c5a 100644 --- a/src/EditorFeatures/CSharpTest/StringCopyPaste/PasteUnknownSourceIntoNormalInterpolatedStringTests.cs +++ b/src/EditorFeatures/CSharpTest/StringCopyPaste/PasteUnknownSourceIntoNormalInterpolatedStringTests.cs @@ -13,8 +13,7 @@ public sealed class PasteUnknownSourceIntoNormalInterpolatedStringTests [WpfFact] public void TestNewLineIntoNormalInterpolatedString1() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: "\n", """ var x = $"[||]" @@ -23,12 +22,10 @@ public void TestNewLineIntoNormalInterpolatedString1() var x = $"\n[||]" """, afterUndo: "var x = $\"\n[||]\""); - } [WpfFact] public void TestNewLineIntoNormalInterpolatedString2() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """ @@ -43,12 +40,10 @@ public void TestNewLineIntoNormalInterpolatedString2() var x = $" [||]" """); - } [WpfFact] public void TestTabIntoNormalInterpolatedString1() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: "\t", """ var x = $"[||]" @@ -57,12 +52,10 @@ public void TestTabIntoNormalInterpolatedString1() var x = $"\t[||]" """, afterUndo: "var x = $\"\t[||]\""); - } [WpfFact] public void TestSingleQuoteIntoNormalInterpolatedString() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """'""", """ var x = $"[||]" @@ -73,12 +66,10 @@ public void TestSingleQuoteIntoNormalInterpolatedString() afterUndo: """ var x = $"[||]" """); - } [WpfFact] public void TestDoubleQuoteIntoNormalInterpolatedString() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """ " """, @@ -91,12 +82,10 @@ public void TestDoubleQuoteIntoNormalInterpolatedString() afterUndo: """ var x = $""[||]" """); - } [WpfFact] public void TestComplexStringIntoNormalInterpolatedString() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: "\t\"\"\t", """ var x = $"[||]" @@ -105,12 +94,10 @@ public void TestComplexStringIntoNormalInterpolatedString() var x = $"\t\"\"\t[||]" """, afterUndo: "var x = $\"\t\"\"\t[||]\""); - } [WpfFact] public void TestNormalTextIntoNormalInterpolatedString() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """abc""", """ var x = $"[||]" @@ -121,12 +108,10 @@ public void TestNormalTextIntoNormalInterpolatedString() afterUndo: """ var x = $"[||]" """); - } [WpfFact] public void TestOpenCurlyIntoNormalInterpolatedString1() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """{""", """ var x = $"[||]" @@ -137,12 +122,10 @@ public void TestOpenCurlyIntoNormalInterpolatedString1() afterUndo: """ var x = $"{[||]" """); - } [WpfFact] public void TestTwoOpenCurliesIntoNormalInterpolatedString1() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """{{""", """ var x = $"[||]" @@ -153,12 +136,10 @@ public void TestTwoOpenCurliesIntoNormalInterpolatedString1() afterUndo: """ var x = $"[||]" """); - } [WpfFact] public void TestTwoOpenCurliesAndContentIntoNormalInterpolatedString1() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """{{0""", """ var x = $"[||]" @@ -169,12 +150,10 @@ public void TestTwoOpenCurliesAndContentIntoNormalInterpolatedString1() afterUndo: """ var x = $"[||]" """); - } [WpfFact] public void TestCloseCurlyIntoNormalInterpolatedString1() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """}""", """ var x = $"[||]" @@ -185,12 +164,10 @@ public void TestCloseCurlyIntoNormalInterpolatedString1() afterUndo: """ var x = $"}[||]" """); - } [WpfFact] public void TestTwoCloseCurliesIntoNormalInterpolatedString1() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """}}""", """ var x = $"[||]" @@ -201,12 +178,10 @@ public void TestTwoCloseCurliesIntoNormalInterpolatedString1() afterUndo: """ var x = $"[||]" """); - } [WpfFact] public void TestTwoCloseCurliesAndContentIntoNormalInterpolatedString1() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """}}0""", """ var x = $"[||]" @@ -217,12 +192,10 @@ public void TestTwoCloseCurliesAndContentIntoNormalInterpolatedString1() afterUndo: """ var x = $"[||]" """); - } [WpfFact] public void TestCurlyWithContentIntoNormalInterpolatedString1() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """x{0}y""", """ var x = $"[||]" @@ -233,12 +206,10 @@ public void TestCurlyWithContentIntoNormalInterpolatedString1() afterUndo: """ var x = $"[||]" """); - } [WpfFact] public void TestCurliesWithContentIntoNormalInterpolatedString1() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """x{{0}}y""", """ var x = $"[||]" @@ -249,7 +220,6 @@ public void TestCurliesWithContentIntoNormalInterpolatedString1() afterUndo: """ var x = $"[||]" """); - } #endregion @@ -257,8 +227,7 @@ public void TestCurliesWithContentIntoNormalInterpolatedString1() [WpfFact] public void TestNewLineIntoNormalInterpolatedStringBeforeHole1() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: "\n", """ var x = $"[||]{0}" @@ -267,12 +236,10 @@ public void TestNewLineIntoNormalInterpolatedStringBeforeHole1() var x = $"\n[||]{0}" """, afterUndo: "var x = $\"\n[||]{0}\""); - } [WpfFact] public void TestNewLineIntoNormalInterpolatedStringBeforeHole2() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """ @@ -287,12 +254,10 @@ public void TestNewLineIntoNormalInterpolatedStringBeforeHole2() var x = $" [||]{0}" """); - } [WpfFact] public void TestTabIntoNormalInterpolatedStringBeforeHole1() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: "\t", """ var x = $"[||]{0}" @@ -301,12 +266,10 @@ public void TestTabIntoNormalInterpolatedStringBeforeHole1() var x = $"\t[||]{0}" """, afterUndo: "var x = $\"\t[||]{0}\""); - } [WpfFact] public void TestSingleQuoteIntoNormalInterpolatedStringBeforeHole() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """'""", """ var x = $"[||]{0}" @@ -317,12 +280,10 @@ public void TestSingleQuoteIntoNormalInterpolatedStringBeforeHole() afterUndo: """ var x = $"[||]{0}" """); - } [WpfFact] public void TestDoubleQuoteIntoNormalInterpolatedStringBeforeHole() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """ " """, @@ -335,12 +296,10 @@ public void TestDoubleQuoteIntoNormalInterpolatedStringBeforeHole() afterUndo: """ var x = $""[||]{0}" """); - } [WpfFact] public void TestComplexStringIntoNormalInterpolatedStringBeforeHole() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: "\t\"\"\t", """ var x = $"[||]{0}" @@ -349,12 +308,10 @@ public void TestComplexStringIntoNormalInterpolatedStringBeforeHole() var x = $"\t\"\"\t[||]{0}" """, afterUndo: "var x = $\"\t\"\"\t[||]{0}\""); - } [WpfFact] public void TestNormalTextIntoNormalInterpolatedStringBeforeHole() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """abc""", """ var x = $"[||]{0}" @@ -365,12 +322,10 @@ public void TestNormalTextIntoNormalInterpolatedStringBeforeHole() afterUndo: """ var x = $"[||]{0}" """); - } [WpfFact] public void TestOpenCurlyIntoNormalInterpolatedStringBeforeHole1() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """{""", """ var x = $"[||]{0}" @@ -381,12 +336,10 @@ public void TestOpenCurlyIntoNormalInterpolatedStringBeforeHole1() afterUndo: """ var x = $"{[||]{0}" """); - } [WpfFact] public void TestTwoOpenCurliesIntoNormalInterpolatedStringBeforeHole1() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """{{""", """ var x = $"[||]{0}" @@ -397,12 +350,10 @@ public void TestTwoOpenCurliesIntoNormalInterpolatedStringBeforeHole1() afterUndo: """ var x = $"[||]{0}" """); - } [WpfFact] public void TestTwoOpenCurliesAndContentIntoNormalInterpolatedStringBeforeHole1() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """{{0""", """ var x = $"[||]{0}" @@ -413,12 +364,10 @@ public void TestTwoOpenCurliesAndContentIntoNormalInterpolatedStringBeforeHole1( afterUndo: """ var x = $"[||]{0}" """); - } [WpfFact] public void TestCloseCurlyIntoNormalInterpolatedStringBeforeHole1() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """}""", """ var x = $"[||]{0}" @@ -429,12 +378,10 @@ public void TestCloseCurlyIntoNormalInterpolatedStringBeforeHole1() afterUndo: """ var x = $"}[||]{0}" """); - } [WpfFact] public void TestTwoCloseCurliesIntoNormalInterpolatedStringBeforeHole1() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """}}""", """ var x = $"[||]{0}" @@ -445,12 +392,10 @@ public void TestTwoCloseCurliesIntoNormalInterpolatedStringBeforeHole1() afterUndo: """ var x = $"[||]{0}" """); - } [WpfFact] public void TestTwoCloseCurliesAndContentIntoNormalInterpolatedStringBeforeHole1() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """}}0""", """ var x = $"[||]{0}" @@ -461,12 +406,10 @@ public void TestTwoCloseCurliesAndContentIntoNormalInterpolatedStringBeforeHole1 afterUndo: """ var x = $"[||]{0}" """); - } [WpfFact] public void TestCurlyWithContentIntoNormalInterpolatedStringBeforeHole1() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """x{0}y""", """ var x = $"[||]{0}" @@ -477,12 +420,10 @@ public void TestCurlyWithContentIntoNormalInterpolatedStringBeforeHole1() afterUndo: """ var x = $"[||]{0}" """); - } [WpfFact] public void TestCurliesWithContentIntoNormalInterpolatedStringBeforeHole1() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """x{{0}}y""", """ var x = $"[||]{0}" @@ -493,7 +434,6 @@ public void TestCurliesWithContentIntoNormalInterpolatedStringBeforeHole1() afterUndo: """ var x = $"[||]{0}" """); - } #endregion @@ -501,8 +441,7 @@ public void TestCurliesWithContentIntoNormalInterpolatedStringBeforeHole1() [WpfFact] public void TestNewLineIntoNormalInterpolatedStringAfterHole1() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: "\n", """ var x = $"{0}[||]" @@ -511,12 +450,10 @@ public void TestNewLineIntoNormalInterpolatedStringAfterHole1() var x = $"{0}\n[||]" """, afterUndo: "var x = $\"{0}\n[||]\""); - } [WpfFact] public void TestNewLineIntoNormalInterpolatedStringAfterHole2() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """ @@ -531,12 +468,10 @@ public void TestNewLineIntoNormalInterpolatedStringAfterHole2() var x = $"{0} [||]" """); - } [WpfFact] public void TestTabIntoNormalInterpolatedStringAfterHole1() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: "\t", """ var x = $"{0}[||]" @@ -545,12 +480,10 @@ public void TestTabIntoNormalInterpolatedStringAfterHole1() var x = $"{0}\t[||]" """, afterUndo: "var x = $\"{0}\t[||]\""); - } [WpfFact] public void TestSingleQuoteIntoNormalInterpolatedStringAfterHole() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """'""", """ var x = $"{0}[||]" @@ -561,12 +494,10 @@ public void TestSingleQuoteIntoNormalInterpolatedStringAfterHole() afterUndo: """ var x = $"{0}[||]" """); - } [WpfFact] public void TestDoubleQuoteIntoNormalInterpolatedStringAfterHole() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """ " """, @@ -579,12 +510,10 @@ public void TestDoubleQuoteIntoNormalInterpolatedStringAfterHole() afterUndo: """ var x = $"{0}"[||]" """); - } [WpfFact] public void TestComplexStringIntoNormalInterpolatedStringAfterHole() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: "\t\"\"\t", """ var x = $"{0}[||]" @@ -593,12 +522,10 @@ public void TestComplexStringIntoNormalInterpolatedStringAfterHole() var x = $"{0}\t\"\"\t[||]" """, afterUndo: "var x = $\"{0}\t\"\"\t[||]\""); - } [WpfFact] public void TestNormalTextIntoNormalInterpolatedStringAfterHole() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """abc""", """ var x = $"{0}[||]" @@ -609,12 +536,10 @@ public void TestNormalTextIntoNormalInterpolatedStringAfterHole() afterUndo: """ var x = $"{0}[||]" """); - } [WpfFact] public void TestOpenCurlyIntoNormalInterpolatedStringAfterHole1() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """{""", """ var x = $"{0}[||]" @@ -625,12 +550,10 @@ public void TestOpenCurlyIntoNormalInterpolatedStringAfterHole1() afterUndo: """ var x = $"{0}{[||]" """); - } [WpfFact] public void TestTwoOpenCurliesIntoNormalInterpolatedStringAfterHole1() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """{{""", """ var x = $"{0}[||]" @@ -641,12 +564,10 @@ public void TestTwoOpenCurliesIntoNormalInterpolatedStringAfterHole1() afterUndo: """ var x = $"{0}[||]" """); - } [WpfFact] public void TestTwoOpenCurliesAndContentIntoNormalInterpolatedStringAfterHole1() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """{{0""", """ var x = $"{0}[||]" @@ -657,12 +578,10 @@ public void TestTwoOpenCurliesAndContentIntoNormalInterpolatedStringAfterHole1() afterUndo: """ var x = $"{0}[||]" """); - } [WpfFact] public void TestCloseCurlyIntoNormalInterpolatedStringAfterHole1() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """}""", """ var x = $"{0}[||]" @@ -673,12 +592,10 @@ public void TestCloseCurlyIntoNormalInterpolatedStringAfterHole1() afterUndo: """ var x = $"{0}}[||]" """); - } [WpfFact] public void TestTwoCloseCurliesIntoNormalInterpolatedStringAfterHole1() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """}}""", """ var x = $"{0}[||]" @@ -689,12 +606,10 @@ public void TestTwoCloseCurliesIntoNormalInterpolatedStringAfterHole1() afterUndo: """ var x = $"{0}[||]" """); - } [WpfFact] public void TestTwoCloseCurliesAndContentIntoNormalInterpolatedStringAfterHole1() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """}}0""", """ var x = $"{0}[||]" @@ -705,12 +620,10 @@ public void TestTwoCloseCurliesAndContentIntoNormalInterpolatedStringAfterHole1( afterUndo: """ var x = $"{0}[||]" """); - } [WpfFact] public void TestCurlyWithContentIntoNormalInterpolatedStringAfterHole1() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """x{0}y""", """ var x = $"{0}[||]" @@ -721,12 +634,10 @@ public void TestCurlyWithContentIntoNormalInterpolatedStringAfterHole1() afterUndo: """ var x = $"{0}[||]" """); - } [WpfFact] public void TestCurliesWithContentIntoNormalInterpolatedStringAfterHole1() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """x{{0}}y""", """ var x = $"{0}[||]" @@ -737,7 +648,6 @@ public void TestCurliesWithContentIntoNormalInterpolatedStringAfterHole1() afterUndo: """ var x = $"{0}[||]" """); - } #endregion } diff --git a/src/EditorFeatures/CSharpTest/StringCopyPaste/PasteUnknownSourceIntoNormalStringTests.cs b/src/EditorFeatures/CSharpTest/StringCopyPaste/PasteUnknownSourceIntoNormalStringTests.cs index 21e71d945b09..3ad731e3518d 100644 --- a/src/EditorFeatures/CSharpTest/StringCopyPaste/PasteUnknownSourceIntoNormalStringTests.cs +++ b/src/EditorFeatures/CSharpTest/StringCopyPaste/PasteUnknownSourceIntoNormalStringTests.cs @@ -11,8 +11,7 @@ public sealed class PasteUnknownSourceIntoNormalStringTests { [WpfFact] public void TestNewLineIntoNormalString1() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: "\n", """ var x = "[||]" @@ -21,12 +20,10 @@ public void TestNewLineIntoNormalString1() var x = "\n[||]" """, afterUndo: "var x = \"\n[||]\""); - } [WpfFact] public void TestNewLineIntoNormalString2() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """ @@ -41,12 +38,10 @@ public void TestNewLineIntoNormalString2() var x = " [||]" """); - } [WpfFact] public void TestTabIntoNormalString1() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: "\t", """ var x = "[||]" @@ -55,12 +50,10 @@ public void TestTabIntoNormalString1() var x = "\t[||]" """, afterUndo: "var x = \"\t[||]\""); - } [WpfFact] public void TestBackslashTIntoNormalString1() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """\t""", """ var x = "[||]" @@ -71,12 +64,10 @@ public void TestBackslashTIntoNormalString1() afterUndo: """ var x = "[||]" """); - } [WpfFact] public void TestSingleQuoteIntoNormalString() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """'""", """ var x = "[||]" @@ -87,12 +78,10 @@ public void TestSingleQuoteIntoNormalString() afterUndo: """ var x = "[||]" """); - } [WpfFact] public void TestDoubleQuoteIntoNormalString() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """ " """, @@ -105,12 +94,10 @@ public void TestDoubleQuoteIntoNormalString() afterUndo: """ var x = ""[||]" """); - } [WpfFact] public void TestComplexStringIntoNormalString() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: "\t\"\"\t", """ var x = "[||]" @@ -119,12 +106,10 @@ public void TestComplexStringIntoNormalString() var x = "\t\"\"\t[||]" """, afterUndo: "var x = \"\t\"\"\t[||]\""); - } [WpfFact] public void TestNormalTextIntoNormalString() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """abc""", """ var x = "[||]" @@ -135,5 +120,4 @@ public void TestNormalTextIntoNormalString() afterUndo: """ var x = "[||]" """); - } } diff --git a/src/EditorFeatures/CSharpTest/StringCopyPaste/PasteUnknownSourceIntoSingleLineInterpolatedRawStringTests.cs b/src/EditorFeatures/CSharpTest/StringCopyPaste/PasteUnknownSourceIntoSingleLineInterpolatedRawStringTests.cs index b8521fa22438..30bc93472e2f 100644 --- a/src/EditorFeatures/CSharpTest/StringCopyPaste/PasteUnknownSourceIntoSingleLineInterpolatedRawStringTests.cs +++ b/src/EditorFeatures/CSharpTest/StringCopyPaste/PasteUnknownSourceIntoSingleLineInterpolatedRawStringTests.cs @@ -11,1241 +11,1123 @@ public sealed class PasteUnknownSourceIntoSingleLineInterpolatedRawStringTests { [WpfFact] public void TestNewLineIntoSingleLineRawString1_A() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: "\n", -"""" -var x = $"""[||] """ -"""", -"var x = $\"\"\"\r\n \n [||] \r\n \"\"\"", + """" + var x = $"""[||] """ + """", + "var x = $\"\"\"\r\n \n [||] \r\n \"\"\"", afterUndo: -"var x = $\"\"\"\n[||] \"\"\""); - } + "var x = $\"\"\"\n[||] \"\"\""); [WpfFact] public void TestNewLineIntoSingleLineRawString1_B() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: "\n", -"""" -var x = $""" [||]""" -"""", -"var x = $\"\"\"\r\n \n \r\n [||]\"\"\"", + """" + var x = $""" [||]""" + """", + "var x = $\"\"\"\r\n \n \r\n [||]\"\"\"", afterUndo: -"var x = $\"\"\" \n[||]\"\"\""); - } + "var x = $\"\"\" \n[||]\"\"\""); [WpfFact] public void TestNewLineIntoSingleLineRawString2_A() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """ """, -"""" -var x = $"""[||] """ -"""", -"""" -var x = $""" - - [||] - """ -"""", + """" + var x = $"""[||] """ + """", + """" + var x = $""" + + [||] + """ + """", afterUndo: -"""" -var x = $""" -[||] """ -""""); - } + """" + var x = $""" + [||] """ + """"); [WpfFact] public void TestNewLineIntoSingleLineRawString2_B() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """ """, -"""" -var x = $""" [||]""" -"""", -"""" -var x = $""" - - - [||]""" -"""", + """" + var x = $""" [||]""" + """", + """" + var x = $""" + + + [||]""" + """", afterUndo: -"""" -var x = $""" -[||]""" -""""); - } + """" + var x = $""" + [||]""" + """"); [WpfFact] public void TestSpacesIntoSingleLineRawString1_A() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """ """, -"""" -var x = $"""[||] """ -"""", -"""" -var x = $""" [||] """ -"""", + """" + var x = $"""[||] """ + """", + """" + var x = $""" [||] """ + """", afterUndo: -"""" -var x = $"""[||] """ -""""); - } + """" + var x = $"""[||] """ + """"); [WpfFact] public void TestSpacesIntoSingleLineRawString1_B() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """ """, -"""" -var x = $""" [||]""" -"""", -"""" -var x = $""" [||]""" -"""", + """" + var x = $""" [||]""" + """", + """" + var x = $""" [||]""" + """", afterUndo: -"""" -var x = $""" [||]""" -""""); - } + """" + var x = $""" [||]""" + """"); [WpfFact] public void TestSpacesIntoSingleLineRawString2() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """ """, -"""" -var x = $""" - [||] - """ -"""", -"""" -var x = $""" - - [||] - """ -"""", + """" + var x = $""" + [||] + """ + """", + """" + var x = $""" + + [||] + """ + """", afterUndo: -"""" -var x = $""" - -[||] - """ -""""); - } + """" + var x = $""" + + [||] + """ + """"); [WpfFact] public void TestSingleQuoteIntoSingleLineRawString_A() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """'""", -"""" -var x = $"""[||] """ -"""", -"""" -var x = $"""'[||] """ -"""", + """" + var x = $"""[||] """ + """", + """" + var x = $"""'[||] """ + """", afterUndo: -"""" -var x = $"""[||] """ -""""); - } + """" + var x = $"""[||] """ + """"); [WpfFact] public void TestSingleQuoteIntoSingleLineRawString_B() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """'""", -"""" -var x = $""" [||]""" -"""", -"""" -var x = $""" '[||]""" -"""", + """" + var x = $""" [||]""" + """", + """" + var x = $""" '[||]""" + """", afterUndo: -"""" -var x = $""" [||]""" -""""); - } + """" + var x = $""" [||]""" + """"); [WpfFact] public void TestDoubleQuoteIntoSingleLineRawString_A() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """ " """, -"""" -var x = $"""[||] """ -"""", -"""" -var x = $""" - "[||] - """ -"""", + """" + var x = $"""[||] """ + """", + """" + var x = $""" + "[||] + """ + """", afterUndo: -""""" -var x = $""""[||] """ -"""""); - } + """"" + var x = $""""[||] """ + """""); [WpfFact] public void TestDoubleQuoteIntoSingleLineRawString_B() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """ " """, -"""" -var x = $""" [||]""" -"""", -"""" -var x = $""" - " - [||]""" -"""", + """" + var x = $""" [||]""" + """", + """" + var x = $""" + " + [||]""" + """", afterUndo: -"""" -var x = $""" "[||]""" -""""); - } + """" + var x = $""" "[||]""" + """"); [WpfFact] public void TestTripleQuoteIntoSingleLineRawString1_A() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """" """ """", -"""" -var x = $"""[||] """ -"""", -""""" -var x = $"""" - """[||] - """" -""""", + """" + var x = $"""[||] """ + """", + """"" + var x = $"""" + """[||] + """" + """"", afterUndo: -""""""" -var x = $""""""[||] """ -"""""""); - } + """"""" + var x = $""""""[||] """ + """""""); [WpfFact] public void TestTripleQuoteIntoSingleLineRawString1_B() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """" """ """", -"""" -var x = $""" [||]""" -"""", -""""" -var x = $"""" - """ - [||]"""" -""""", + """" + var x = $""" [||]""" + """", + """"" + var x = $"""" + """ + [||]"""" + """"", afterUndo: -"""" -var x = $""" """[||]""" -""""); - } + """" + var x = $""" """[||]""" + """"); [WpfFact] public void TestTripleQuoteIntoSingleLineRawString3() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """" """ """", -"""" -var x = $""" "[||] """ -"""", -"""""" -var x = $""""" """"[||] """"" -"""""", + """" + var x = $""" "[||] """ + """", + """""" + var x = $""""" """"[||] """"" + """""", afterUndo: -""""" -var x = $""" """"[||] """ -"""""); - } + """"" + var x = $""" """"[||] """ + """""); [WpfFact] public void TestTripleQuoteIntoSingleLineRawString4() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """" """ """", -"""" -var x = $""" "[||]" """ -"""", -""""""" -var x = $"""""" """"[||]" """""" -""""""", + """" + var x = $""" "[||]" """ + """", + """"""" + var x = $"""""" """"[||]" """""" + """"""", afterUndo: -""""" -var x = $""" """"[||]" """ -"""""); - } + """"" + var x = $""" """"[||]" """ + """""); [WpfFact] public void TestTripleQuoteIntoSingleLineRawString5() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """" """ """", -"""" -var x = $""" [||]" """ -"""", -"""""" -var x = $""""" """[||]" """"" -"""""", + """" + var x = $""" [||]" """ + """", + """""" + var x = $""""" """[||]" """"" + """""", afterUndo: -"""" -var x = $""" """[||]" """ -""""); - } + """" + var x = $""" """[||]" """ + """"); [WpfFact] public void TestQuadrupleQuoteIntoSingleLineRawString() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """"" """" """"", -"""" -var x = $""" - [||] - """ -"""", -"""""" -var x = $""""" - """"[||] - """"" -"""""", + """" + var x = $""" + [||] + """ + """", + """""" + var x = $""""" + """"[||] + """"" + """""", afterUndo: -""""" -var x = $""" - """"[||] - """ -"""""); - } + """"" + var x = $""" + """"[||] + """ + """""); [WpfFact] public void TestOpenCurlyIntoSingleLineRawString_A() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """{""", -"""" -var x = $"""[||] """ -"""", -"""" -var x = $$"""{[||] """ -"""", + """" + var x = $"""[||] """ + """", + """" + var x = $$"""{[||] """ + """", afterUndo: -"""" -var x = $"""{[||] """ -""""); - } + """" + var x = $"""{[||] """ + """"); [WpfFact] public void TestOpenCurlyIntoSingleLineRawString_B() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """{""", -"""" -var x = $""" [||]""" -"""", -"""" -var x = $$""" {[||]""" -"""", + """" + var x = $""" [||]""" + """", + """" + var x = $$""" {[||]""" + """", afterUndo: -"""" -var x = $""" {[||]""" -""""); - } + """" + var x = $""" {[||]""" + """"); [WpfFact] public void TestOpenQuoteAndTripleOpenBraceIntoSingleLineRawString1() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """ "{{{ """, -"""" -var x = $"""[||] """ -"""", -"""" -var x = $$$$""" - "{{{[||] - """ -"""", + """" + var x = $"""[||] """ + """", + """" + var x = $$$$""" + "{{{[||] + """ + """", afterUndo: -""""" -var x = $""""{{{[||] """ -"""""); - } + """"" + var x = $""""{{{[||] """ + """""); [WpfFact] public void TestTripleOpenQuoteAndTripleOpenBraceIntoSingleLineRawString1() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """" """{{{ """", -"""" -var x = $"""[||] """ -"""", -""""" -var x = $$$$"""" - """{{{[||] - """" -""""", + """" + var x = $"""[||] """ + """", + """"" + var x = $$$$"""" + """{{{[||] + """" + """"", afterUndo: -""""""" -var x = $""""""{{{[||] """ -"""""""); - } + """"""" + var x = $""""""{{{[||] """ + """""""); [WpfFact] public void TestTripleOpenQuoteAndTripleOpenBraceIntoSingleLineRawString2() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """" """{{{"""", -"""" -var x = $"""[||] """ -"""", -""""" -var x = $$$$"""" """{{{[||] """" -""""", + """" + var x = $"""[||] """ + """", + """"" + var x = $$$$"""" """{{{[||] """" + """"", afterUndo: -"""" -var x = $""" """{{{[||] """ -""""); - } + """" + var x = $""" """{{{[||] """ + """"); [WpfFact] public void TestTripleOpenBraceIntoSingleLineRawString1_A() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """{{{""", -"""" -var x = $"""[||] """ -"""", -"""" -var x = $$$$"""{{{[||] """ -"""", + """" + var x = $"""[||] """ + """", + """" + var x = $$$$"""{{{[||] """ + """", afterUndo: -"""" -var x = $"""{{{[||] """ -""""); - } + """" + var x = $"""{{{[||] """ + """"); [WpfFact] public void TestTripleOpenBraceIntoSingleLineRawString1_B() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """{{{""", -"""" -var x = $""" [||]""" -"""", -"""" -var x = $$$$""" {{{[||]""" -"""", + """" + var x = $""" [||]""" + """", + """" + var x = $$$$""" {{{[||]""" + """", afterUndo: -"""" -var x = $""" {{{[||]""" -""""); - } + """" + var x = $""" {{{[||]""" + """"); [WpfFact] public void TestTripleOpenBraceIntoSingleLineRawString3() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """{{{""", -"""" -var x = $""" "[||] """ -"""", -"""" -var x = $$$$""" "{{{[||] """ -"""", + """" + var x = $""" "[||] """ + """", + """" + var x = $$$$""" "{{{[||] """ + """", afterUndo: -"""" -var x = $""" "{{{[||] """ -""""); - } + """" + var x = $""" "{{{[||] """ + """"); [WpfFact] public void TestTripleOpenBraceIntoSingleLineRawString4() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """{{{""", -"""" -var x = $""" "[||]" """ -"""", -"""" -var x = $$$$""" "{{{[||]" """ -"""", + """" + var x = $""" "[||]" """ + """", + """" + var x = $$$$""" "{{{[||]" """ + """", afterUndo: -"""" -var x = $""" "{{{[||]" """ -""""); - } + """" + var x = $""" "{{{[||]" """ + """"); [WpfFact] public void TestTripleOpenBraceIntoSingleLineRawString5() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """{{{""", -"""" -var x = $""" [||]" """ -"""", -"""" -var x = $$$$""" {{{[||]" """ -"""", + """" + var x = $""" [||]" """ + """", + """" + var x = $$$$""" {{{[||]" """ + """", afterUndo: -"""" -var x = $""" {{{[||]" """ -""""); - } + """" + var x = $""" {{{[||]" """ + """"); [WpfFact] public void TestInterpolationIntoSingleLineRawString1() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """{0}""", -"""" -var x = $""" [||] """ -"""", -"""" -var x = $""" {0}[||] """ -"""", + """" + var x = $""" [||] """ + """", + """" + var x = $""" {0}[||] """ + """", afterUndo: -"""" -var x = $""" [||] """ -""""); - } + """" + var x = $""" [||] """ + """"); [WpfFact] public void TestOpenCloseBraceIntoSingleLineRawString1() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """{}""", -"""" -var x = $""" [||] """ -"""", -"""" -var x = $$""" {}[||] """ -"""", + """" + var x = $""" [||] """ + """", + """" + var x = $$""" {}[||] """ + """", afterUndo: -"""" -var x = $""" {}[||] """ -""""); - } + """" + var x = $""" {}[||] """ + """"); [WpfFact] public void TestOpenCloseBraceIntoSingleLineRawString2() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """{}""", -"""" -var x = $$""" [||] """ -"""", -"""" -var x = $$""" {}[||] """ -"""", + """" + var x = $$""" [||] """ + """", + """" + var x = $$""" {}[||] """ + """", afterUndo: -"""" -var x = $$""" [||] """ -""""); - } + """" + var x = $$""" [||] """ + """"); [WpfFact] public void TestOpenCloseBraceIntoSingleLineRawString3() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """{{}""", -"""" -var x = $$""" [||] """ -"""", -"""" -var x = $$$""" {{}[||] """ -"""", + """" + var x = $$""" [||] """ + """", + """" + var x = $$$""" {{}[||] """ + """", afterUndo: -"""" -var x = $$""" {{}[||] """ -""""); - } + """" + var x = $$""" {{}[||] """ + """"); [WpfFact] public void TestOpenCloseBraceIntoSingleLineRawString4() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """{}}""", -"""" -var x = $$""" [||] """ -"""", -"""" -var x = $$$""" {}}[||] """ -"""", + """" + var x = $$""" [||] """ + """", + """" + var x = $$$""" {}}[||] """ + """", afterUndo: -"""" -var x = $$""" {}}[||] """ -""""); - } + """" + var x = $$""" {}}[||] """ + """"); [WpfFact] public void TestOpenCloseBraceIntoSingleLineRawString5() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """{{}}""", -"""" -var x = $$""" [||] """ -"""", -"""" -var x = $$$""" {{}}[||] """ -"""", + """" + var x = $$""" [||] """ + """", + """" + var x = $$$""" {{}}[||] """ + """", afterUndo: -"""" -var x = $$""" {{}}[||] """ -""""); - } + """" + var x = $$""" {{}}[||] """ + """"); [WpfFact] public void TestComplexStringIntoSingleLineRawString() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """ "" """, -"""" -var x = $"""[||] """ -"""", -"""" -var x = $""" "" [||] """ -"""", + """" + var x = $"""[||] """ + """", + """" + var x = $""" "" [||] """ + """", afterUndo: -"""" -var x = $"""[||] """ -""""); - } + """" + var x = $"""[||] """ + """"); [WpfFact] public void TestNormalTextIntoSingleLineRawString_A() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """abc""", -"""" -var x = $"""[||] """ -"""", -"""" -var x = $"""abc[||] """ -"""", + """" + var x = $"""[||] """ + """", + """" + var x = $"""abc[||] """ + """", afterUndo: -"""" -var x = $"""[||] """ -""""); - } + """" + var x = $"""[||] """ + """"); [WpfFact] public void TestNormalTextIntoSingleLineRawString_B() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """abc""", -"""" -var x = $""" [||]""" -"""", -"""" -var x = $""" abc[||]""" -"""", + """" + var x = $""" [||]""" + """", + """" + var x = $""" abc[||]""" + """", afterUndo: -"""" -var x = $""" [||]""" -""""); - } + """" + var x = $""" [||]""" + """"); [WpfFact] public void TestNormalTextIntoSingleLineRawStringSingleLine1_A() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """ abc def """, -"""" -var x = $"""[||] """ -"""", -"""" -var x = $""" - abc - def[||] - """ -"""", + """" + var x = $"""[||] """ + """", + """" + var x = $""" + abc + def[||] + """ + """", afterUndo: -"""" -var x = $"""abc -def[||] """ -""""); - } + """" + var x = $"""abc + def[||] """ + """"); [WpfFact] public void TestNormalTextIntoSingleLineRawStringSingleLine1_B() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """ abc def """, -"""" -var x = $""" [||]""" -"""", -"""" -var x = $""" - abc - def - [||]""" -"""", + """" + var x = $""" [||]""" + """", + """" + var x = $""" + abc + def + [||]""" + """", afterUndo: -"""" -var x = $""" abc -def[||]""" -""""); - } + """" + var x = $""" abc + def[||]""" + """"); [WpfFact] public void TestNormalTextIntoSingleLineRawStringSingleLine4() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """ abc def """, -"""" -var x = $"""goo[||]""" -"""", -"""" -var x = $""" - gooabc - def - [||]""" -"""", + """" + var x = $"""goo[||]""" + """", + """" + var x = $""" + gooabc + def + [||]""" + """", afterUndo: -"""" -var x = $"""gooabc -def[||]""" -""""); - } + """" + var x = $"""gooabc + def[||]""" + """"); [WpfFact] public void TestNormalTextIntoSingleLineRawStringSingleLine5() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """ abc def """, -"""" -var x = $"""goo[||]bar""" -"""", -"""" -var x = $""" - gooabc - def[||]bar - """ -"""", + """" + var x = $"""goo[||]bar""" + """", + """" + var x = $""" + gooabc + def[||]bar + """ + """", afterUndo: -"""" -var x = $"""gooabc -def[||]bar""" -""""); - } + """" + var x = $"""gooabc + def[||]bar""" + """"); [WpfFact] public void TestNormalTextIntoSingleLineRawStringSingleLine6() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """ abc def """, -"""" -var x = $"""goo[||]bar""" -"""", -"""" -var x = $""" - gooabc - def - [||]bar - """ -"""", + """" + var x = $"""goo[||]bar""" + """", + """" + var x = $""" + gooabc + def + [||]bar + """ + """", afterUndo: -"""" -var x = $"""gooabc -def -[||]bar""" -""""); - } + """" + var x = $"""gooabc + def + [||]bar""" + """"); [WpfFact] public void TestNormalTextIntoSingleLineRawStringSingleLine7_A() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """ abc def ghi """, -"""" -var x = $"""[||] """ -"""", -"""" -var x = $""" - abc - def - ghi[||] - """ -"""", + """" + var x = $"""[||] """ + """", + """" + var x = $""" + abc + def + ghi[||] + """ + """", afterUndo: -"""" -var x = $"""abc - def -ghi[||] """ -""""); - } + """" + var x = $"""abc + def + ghi[||] """ + """"); [WpfFact] public void TestNormalTextIntoSingleLineRawStringSingleLine7_B() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """ abc def ghi """, -"""" -var x = $""" [||]""" -"""", -"""" -var x = $""" - abc - def - ghi - [||]""" -"""", + """" + var x = $""" [||]""" + """", + """" + var x = $""" + abc + def + ghi + [||]""" + """", afterUndo: -"""" -var x = $""" abc - def -ghi[||]""" -""""); - } + """" + var x = $""" abc + def + ghi[||]""" + """"); [WpfFact] public void TestNormalTextIntoSingleLineRawStringSingleLine8_A() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """ abc def ghi """, -"""" -var x = $"""[||] """ -"""", -"""" -var x = $""" - abc - def - ghi[||] - """ -"""", + """" + var x = $"""[||] """ + """", + """" + var x = $""" + abc + def + ghi[||] + """ + """", afterUndo: -"""" -var x = $"""abc - def - ghi[||] """ -""""); - } + """" + var x = $"""abc + def + ghi[||] """ + """"); [WpfFact] public void TestNormalTextIntoSingleLineRawStringSingleLine8_B() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """ abc def ghi """, -"""" -var x = $"""[||] """ -"""", -"""" -var x = $""" - abc - def - ghi[||] - """ -"""", + """" + var x = $"""[||] """ + """", + """" + var x = $""" + abc + def + ghi[||] + """ + """", afterUndo: -"""" -var x = $"""abc - def - ghi[||] """ -""""); - } + """" + var x = $"""abc + def + ghi[||] """ + """"); [WpfFact] public void TestNormalTextIntoSingleLineRawStringSingleLine9_A() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """ abc def ghi """, -"""" -var x = $"""[||] """ -"""", -"""" -var x = $""" - abc - def - ghi[||] - """ -"""", + """" + var x = $"""[||] """ + """", + """" + var x = $""" + abc + def + ghi[||] + """ + """", afterUndo: -"""" -var x = $""" abc - def - ghi[||] """ -""""); - } + """" + var x = $""" abc + def + ghi[||] """ + """"); [WpfFact] public void TestNormalTextIntoSingleLineRawStringSingleLine9_B() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """ abc def ghi """, -"""" -var x = $""" [||]""" -"""", -"""" -var x = $""" - abc - def - ghi - [||]""" -"""", + """" + var x = $""" [||]""" + """", + """" + var x = $""" + abc + def + ghi + [||]""" + """", afterUndo: -"""" -var x = $""" abc - def - ghi[||]""" -""""); - } + """" + var x = $""" abc + def + ghi[||]""" + """"); [WpfFact] public void TestNormalTextIntoSingleLineRawStringSingleLine10_A() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """ abc def ghi """, -"""" -var x = $"""[||] """ -"""", -"""" -var x = $""" - abc - def - ghi[||] - """ -"""", + """" + var x = $"""[||] """ + """", + """" + var x = $""" + abc + def + ghi[||] + """ + """", afterUndo: -"""" -var x = $""" abc - def - ghi[||] """ -""""); - } + """" + var x = $""" abc + def + ghi[||] """ + """"); [WpfFact] public void TestNormalTextIntoSingleLineRawStringSingleLine10_B() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """ abc def ghi """, -"""" -var x = $""" [||]""" -"""", -"""" -var x = $""" - abc - def - ghi - [||]""" -"""", + """" + var x = $""" [||]""" + """", + """" + var x = $""" + abc + def + ghi + [||]""" + """", afterUndo: -"""" -var x = $""" abc - def - ghi[||]""" -""""); - } + """" + var x = $""" abc + def + ghi[||]""" + """"); [WpfFact] public void TestNormalTextIntoSingleLineRawStringSingleLine11_A() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """ abc def """, -"""" -var x = $"""[||]{|Selection: |}""" -"""", -"""" -var x = $""" - abc - def - [||]""" -"""", + """" + var x = $"""[||]{|Selection: |}""" + """", + """" + var x = $""" + abc + def + [||]""" + """", afterUndo: -"""" -var x = $"""abc -def[||]""" -""""); - } + """" + var x = $"""abc + def[||]""" + """"); [WpfFact] public void TestNormalTextIntoSingleLineRawStringSingleLine11_B() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """ abc def """, -"""" -var x = $""" [||]{|Selection: |} """ -"""", -"""" -var x = $""" - abc - def[||] - """ -"""", + """" + var x = $""" [||]{|Selection: |} """ + """", + """" + var x = $""" + abc + def[||] + """ + """", afterUndo: -"""" -var x = $""" abc -def[||] """ -""""); - } + """" + var x = $""" abc + def[||] """ + """"); [WpfFact] public void TestNormalTextIntoSingleLineRawStringSingleLine12_A() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """ abc def """, -"""" -var x = $"""[||]{|Selection: |}""" -"""", -"""" -var x = $""" - abc - def - - [||]""" -"""", + """" + var x = $"""[||]{|Selection: |}""" + """", + """" + var x = $""" + abc + def + + [||]""" + """", afterUndo: -"""" -var x = $"""abc -def -[||]""" -""""); - } + """" + var x = $"""abc + def + [||]""" + """"); [WpfFact] public void TestNormalTextIntoSingleLineRawStringSingleLine12_B() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """ abc def """, -"""" -var x = $""" [||]{|Selection: |} """ -"""", -"""" -var x = $""" - abc - def - [||] - """ -"""", + """" + var x = $""" [||]{|Selection: |} """ + """", + """" + var x = $""" + abc + def + [||] + """ + """", afterUndo: -"""" -var x = $""" abc -def -[||] """ -""""); - } + """" + var x = $""" abc + def + [||] """ + """"); [WpfFact] public void TestNormalTextIntoSingleLineRawStringSingleLine13_A() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """ abc def """, -"""" -var x = $"""[||]{|Selection: |} """ -"""", -"""" -var x = $""" - abc - def[||] - """ -"""", + """" + var x = $"""[||]{|Selection: |} """ + """", + """" + var x = $""" + abc + def[||] + """ + """", afterUndo: -"""" -var x = $"""abc -def[||] """ -""""); - } + """" + var x = $"""abc + def[||] """ + """"); [WpfFact] public void TestNormalTextIntoSingleLineRawStringSingleLine13_B() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """ abc def """, -"""" -var x = $""" [||]{|Selection: |}""" -"""", -"""" -var x = $""" - abc - def - [||]""" -"""", + """" + var x = $""" [||]{|Selection: |}""" + """", + """" + var x = $""" + abc + def + [||]""" + """", afterUndo: -"""" -var x = $""" abc -def[||]""" -""""); - } + """" + var x = $""" abc + def[||]""" + """"); [WpfFact] public void TestNormalTextIntoSingleLineRawStringHeader1_A() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """ "bar """, -"""" -var x = $"""[||]goo""" -"""", -"""" -var x = $""" - "bar[||]goo - """ -"""", + """" + var x = $"""[||]goo""" + """", + """" + var x = $""" + "bar[||]goo + """ + """", afterUndo: -""""" -var x = $""""bar[||]goo""" -"""""); - } + """"" + var x = $""""bar[||]goo""" + """""); [WpfFact] public void TestNormalTextIntoSingleLineRawStringHeader1_B() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """ bar" """, -"""" -var x = $"""goo[||]""" -"""", -"""" -var x = $""" - goobar" - [||]""" -"""", + """" + var x = $"""goo[||]""" + """", + """" + var x = $""" + goobar" + [||]""" + """", afterUndo: -"""" -var x = $"""goobar"[||]""" -""""); - } + """" + var x = $"""goobar"[||]""" + """"); [WpfFact] public void TestQuotesIntoHeader1() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """ "" """, -"""" -var x = $"""[||]{|Selection: |}""" -"""", -"""" -var x = $""" - "" - [||]""" -"""", + """" + var x = $"""[||]{|Selection: |}""" + """", + """" + var x = $""" + "" + [||]""" + """", afterUndo: -"""""" -var x = $"""""[||]""" -""""""); - } + """""" + var x = $"""""[||]""" + """"""); [WpfFact] public void TestQuotesIntoHeader2() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """" """ """", -"""" -var x = $"""[||]{|Selection: |}""" -"""", -""""" -var x = $"""" - """ - [||]"""" -""""", + """" + var x = $"""[||]{|Selection: |}""" + """", + """"" + var x = $"""" + """ + [||]"""" + """"", afterUndo: -""""""" -var x = $""""""[||]""" -"""""""); - } + """"""" + var x = $""""""[||]""" + """""""); } diff --git a/src/EditorFeatures/CSharpTest/StringCopyPaste/PasteUnknownSourceIntoSingleLineRawStringTests.cs b/src/EditorFeatures/CSharpTest/StringCopyPaste/PasteUnknownSourceIntoSingleLineRawStringTests.cs index d74b812a1dc4..879f1b548c4a 100644 --- a/src/EditorFeatures/CSharpTest/StringCopyPaste/PasteUnknownSourceIntoSingleLineRawStringTests.cs +++ b/src/EditorFeatures/CSharpTest/StringCopyPaste/PasteUnknownSourceIntoSingleLineRawStringTests.cs @@ -11,980 +11,892 @@ public sealed class PasteUnknownSourceIntoSingleLineRawStringTests { [WpfFact] public void TestNewLineIntoSingleLineRawString1_A() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: "\n", -"""" -var x = """[||] """ -"""", -"var x = \"\"\"\r\n \n [||] \r\n \"\"\"", + """" + var x = """[||] """ + """", + "var x = \"\"\"\r\n \n [||] \r\n \"\"\"", afterUndo: -"var x = \"\"\"\n[||] \"\"\""); - } + "var x = \"\"\"\n[||] \"\"\""); [WpfFact] public void TestNewLineIntoSingleLineRawString1_B() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: "\n", -"""" -var x = """ [||]""" -"""", -"var x = \"\"\"\r\n \n \r\n [||]\"\"\"", + """" + var x = """ [||]""" + """", + "var x = \"\"\"\r\n \n \r\n [||]\"\"\"", afterUndo: -"var x = \"\"\" \n[||]\"\"\""); - } + "var x = \"\"\" \n[||]\"\"\""); [WpfFact] public void TestNewLineIntoSingleLineRawString2_A() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """ """, -"""" -var x = """[||] """ -"""", -"""" -var x = """ - - [||] - """ -"""", - afterUndo: -"""" -var x = """ -[||] """ -""""); - } + """" + var x = """[||] """ + """", + """" + var x = """ + + [||] + """ + """", + afterUndo: + """" + var x = """ + [||] """ + """"); [WpfFact] public void TestNewLineIntoSingleLineRawString2_B() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """ """, -"""" -var x = """ [||]""" -"""", -"""" -var x = """ - - - [||]""" -"""", - afterUndo: -"""" -var x = """ -[||]""" -""""); - } + """" + var x = """ [||]""" + """", + """" + var x = """ + + + [||]""" + """", + afterUndo: + """" + var x = """ + [||]""" + """"); [WpfFact] public void TestSpacesIntoSingleLineRawString1_A() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """ """, -"""" -var x = """[||] """ -"""", -"""" -var x = """ [||] """ -"""", + """" + var x = """[||] """ + """", + """" + var x = """ [||] """ + """", afterUndo: -"""" -var x = """[||] """ -""""); - } + """" + var x = """[||] """ + """"); [WpfFact] public void TestSpacesIntoSingleLineRawString1_B() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """ """, -"""" -var x = """ [||]""" -"""", -"""" -var x = """ [||]""" -"""", + """" + var x = """ [||]""" + """", + """" + var x = """ [||]""" + """", afterUndo: -"""" -var x = """ [||]""" -""""); - } + """" + var x = """ [||]""" + """"); [WpfFact] public void TestSpacesIntoSingleLineRawString2() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """ """, -"""" -var x = """ - [||] - """ -"""", -"""" -var x = """ - - [||] - """ -"""", - afterUndo: -"""" -var x = """ - -[||] - """ -""""); - } + """" + var x = """ + [||] + """ + """", + """" + var x = """ + + [||] + """ + """", + afterUndo: + """" + var x = """ + + [||] + """ + """"); [WpfFact] public void TestSingleQuoteIntoSingleLineRawString_A() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """'""", -"""" -var x = """[||] """ -"""", -"""" -var x = """'[||] """ -"""", + """" + var x = """[||] """ + """", + """" + var x = """'[||] """ + """", afterUndo: -"""" -var x = """[||] """ -""""); - } + """" + var x = """[||] """ + """"); [WpfFact] public void TestSingleQuoteIntoSingleLineRawString_B() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """'""", -"""" -var x = """ [||]""" -"""", -"""" -var x = """ '[||]""" -"""", + """" + var x = """ [||]""" + """", + """" + var x = """ '[||]""" + """", afterUndo: -"""" -var x = """ [||]""" -""""); - } + """" + var x = """ [||]""" + """"); [WpfFact] public void TestDoubleQuoteIntoSingleLineRawString_A() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """ " """, -"""" -var x = """[||] """ -"""", -"""" -var x = """ - "[||] - """ -"""", + """" + var x = """[||] """ + """", + """" + var x = """ + "[||] + """ + """", afterUndo: -""""" -var x = """"[||] """ -"""""); - } + """"" + var x = """"[||] """ + """""); [WpfFact] public void TestDoubleQuoteIntoSingleLineRawString_B() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """ " """, -"""" -var x = """ [||]""" -"""", -"""" -var x = """ - " - [||]""" -"""", + """" + var x = """ [||]""" + """", + """" + var x = """ + " + [||]""" + """", afterUndo: -"""" -var x = """ "[||]""" -""""); - } + """" + var x = """ "[||]""" + """"); [WpfFact] public void TestTripleQuoteIntoSingleLineRawString1_A() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """" """ """", -"""" -var x = """[||] """ -"""", -""""" -var x = """" - """[||] - """" -""""", + """" + var x = """[||] """ + """", + """"" + var x = """" + """[||] + """" + """"", afterUndo: -""""""" -var x = """"""[||] """ -"""""""); - } + """"""" + var x = """"""[||] """ + """""""); [WpfFact] public void TestTripleQuoteIntoSingleLineRawString1_B() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """" """ """", -"""" -var x = """ [||]""" -"""", -""""" -var x = """" - """ - [||]"""" -""""", + """" + var x = """ [||]""" + """", + """"" + var x = """" + """ + [||]"""" + """"", afterUndo: -"""" -var x = """ """[||]""" -""""); - } + """" + var x = """ """[||]""" + """"); [WpfFact] public void TestTwoQuotesIntoSingleLineRawString3() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """ "" """, -"""" -var x = """ "[||] """ -"""", -""""" -var x = """" """[||] """" -""""", + """" + var x = """ "[||] """ + """", + """"" + var x = """" """[||] """" + """"", afterUndo: -"""" -var x = """ """[||] """ -""""); - } + """" + var x = """ """[||] """ + """"); [WpfFact] public void TestTripleQuoteIntoSingleLineRawString3() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """" """ """", -"""" -var x = """ "[||] """ -"""", -"""""" -var x = """"" """"[||] """"" -"""""", + """" + var x = """ "[||] """ + """", + """""" + var x = """"" """"[||] """"" + """""", afterUndo: -""""" -var x = """ """"[||] """ -"""""); - } + """"" + var x = """ """"[||] """ + """""); [WpfFact] public void TestTripleQuoteIntoSingleLineRawString4() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """" """ """", -"""" -var x = """ "[||]" """ -"""", -""""""" -var x = """""" """"[||]" """""" -""""""", + """" + var x = """ "[||]" """ + """", + """"""" + var x = """""" """"[||]" """""" + """"""", afterUndo: -""""" -var x = """ """"[||]" """ -"""""); - } + """"" + var x = """ """"[||]" """ + """""); [WpfFact] public void TestTripleQuoteIntoSingleLineRawString5() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """" """ """", -"""" -var x = """ [||]" """ -"""", -"""""" -var x = """"" """[||]" """"" -"""""", + """" + var x = """ [||]" """ + """", + """""" + var x = """"" """[||]" """"" + """""", afterUndo: -"""" -var x = """ """[||]" """ -""""); - } + """" + var x = """ """[||]" """ + """"); [WpfFact] public void TestQuadrupleQuoteIntoSingleLineRawString() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """"" """" """"", -"""" -var x = """ - [||] - """ -"""", -"""""" -var x = """"" - """"[||] - """"" -"""""", - afterUndo: -""""" -var x = """ - """"[||] - """ -"""""); - } + """" + var x = """ + [||] + """ + """", + """""" + var x = """"" + """"[||] + """"" + """""", + afterUndo: + """"" + var x = """ + """"[||] + """ + """""); [WpfFact] public void TestComplexStringIntoSingleLineRawString() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """ "" """, -"""" -var x = """[||] """ -"""", -"""" -var x = """ "" [||] """ -"""", + """" + var x = """[||] """ + """", + """" + var x = """ "" [||] """ + """", afterUndo: -"""" -var x = """[||] """ -""""); - } + """" + var x = """[||] """ + """"); [WpfFact] public void TestNormalTextIntoSingleLineRawString_A() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """abc""", -"""" -var x = """[||] """ -"""", -"""" -var x = """abc[||] """ -"""", + """" + var x = """[||] """ + """", + """" + var x = """abc[||] """ + """", afterUndo: -"""" -var x = """[||] """ -""""); - } + """" + var x = """[||] """ + """"); [WpfFact] public void TestNormalTextIntoSingleLineRawString_B() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """abc""", -"""" -var x = """ [||]""" -"""", -"""" -var x = """ abc[||]""" -"""", + """" + var x = """ [||]""" + """", + """" + var x = """ abc[||]""" + """", afterUndo: -"""" -var x = """ [||]""" -""""); - } + """" + var x = """ [||]""" + """"); [WpfFact] public void TestNormalTextIntoSingleLineRawStringSingleLine1_A() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """ abc def """, -"""" -var x = """[||] """ -"""", -"""" -var x = """ - abc - def[||] - """ -"""", - afterUndo: -"""" -var x = """abc -def[||] """ -""""); - } + """" + var x = """[||] """ + """", + """" + var x = """ + abc + def[||] + """ + """", + afterUndo: + """" + var x = """abc + def[||] """ + """"); [WpfFact] public void TestNormalTextIntoSingleLineRawStringSingleLine1_B() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """ abc def """, -"""" -var x = """ [||]""" -"""", -"""" -var x = """ - abc - def - [||]""" -"""", - afterUndo: -"""" -var x = """ abc -def[||]""" -""""); - } + """" + var x = """ [||]""" + """", + """" + var x = """ + abc + def + [||]""" + """", + afterUndo: + """" + var x = """ abc + def[||]""" + """"); [WpfFact] public void TestNormalTextIntoSingleLineRawStringSingleLine4() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """ abc def """, -"""" -var x = """goo[||]""" -"""", -"""" -var x = """ - gooabc - def - [||]""" -"""", - afterUndo: -"""" -var x = """gooabc -def[||]""" -""""); - } + """" + var x = """goo[||]""" + """", + """" + var x = """ + gooabc + def + [||]""" + """", + afterUndo: + """" + var x = """gooabc + def[||]""" + """"); [WpfFact] public void TestNormalTextIntoSingleLineRawStringSingleLine5() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """ abc def """, -"""" -var x = """goo[||]bar""" -"""", -"""" -var x = """ - gooabc - def[||]bar - """ -"""", - afterUndo: -"""" -var x = """gooabc -def[||]bar""" -""""); - } + """" + var x = """goo[||]bar""" + """", + """" + var x = """ + gooabc + def[||]bar + """ + """", + afterUndo: + """" + var x = """gooabc + def[||]bar""" + """"); [WpfFact] public void TestNormalTextIntoSingleLineRawStringSingleLine6() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """ abc def """, -"""" -var x = """goo[||]bar""" -"""", -"""" -var x = """ - gooabc - def - [||]bar - """ -"""", - afterUndo: -"""" -var x = """gooabc -def -[||]bar""" -""""); - } + """" + var x = """goo[||]bar""" + """", + """" + var x = """ + gooabc + def + [||]bar + """ + """", + afterUndo: + """" + var x = """gooabc + def + [||]bar""" + """"); [WpfFact] public void TestNormalTextIntoSingleLineRawStringSingleLine7_A() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """ abc def ghi """, -"""" -var x = """[||] """ -"""", -"""" -var x = """ - abc - def - ghi[||] - """ -"""", - afterUndo: -"""" -var x = """abc - def -ghi[||] """ -""""); - } + """" + var x = """[||] """ + """", + """" + var x = """ + abc + def + ghi[||] + """ + """", + afterUndo: + """" + var x = """abc + def + ghi[||] """ + """"); [WpfFact] public void TestNormalTextIntoSingleLineRawStringSingleLine7_B() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """ abc def ghi """, -"""" -var x = """ [||]""" -"""", -"""" -var x = """ - abc - def - ghi - [||]""" -"""", - afterUndo: -"""" -var x = """ abc - def -ghi[||]""" -""""); - } + """" + var x = """ [||]""" + """", + """" + var x = """ + abc + def + ghi + [||]""" + """", + afterUndo: + """" + var x = """ abc + def + ghi[||]""" + """"); [WpfFact] public void TestNormalTextIntoSingleLineRawStringSingleLine8_A() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """ abc def ghi """, -"""" -var x = """[||] """ -"""", -"""" -var x = """ - abc - def - ghi[||] - """ -"""", - afterUndo: -"""" -var x = """abc - def - ghi[||] """ -""""); - } + """" + var x = """[||] """ + """", + """" + var x = """ + abc + def + ghi[||] + """ + """", + afterUndo: + """" + var x = """abc + def + ghi[||] """ + """"); [WpfFact] public void TestNormalTextIntoSingleLineRawStringSingleLine8_B() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """ abc def ghi """, -"""" -var x = """[||] """ -"""", -"""" -var x = """ - abc - def - ghi[||] - """ -"""", - afterUndo: -"""" -var x = """abc - def - ghi[||] """ -""""); - } + """" + var x = """[||] """ + """", + """" + var x = """ + abc + def + ghi[||] + """ + """", + afterUndo: + """" + var x = """abc + def + ghi[||] """ + """"); [WpfFact] public void TestNormalTextIntoSingleLineRawStringSingleLine9_A() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """ abc def ghi """, -"""" -var x = """[||] """ -"""", -"""" -var x = """ - abc - def - ghi[||] - """ -"""", - afterUndo: -"""" -var x = """ abc - def - ghi[||] """ -""""); - } + """" + var x = """[||] """ + """", + """" + var x = """ + abc + def + ghi[||] + """ + """", + afterUndo: + """" + var x = """ abc + def + ghi[||] """ + """"); [WpfFact] public void TestNormalTextIntoSingleLineRawStringSingleLine9_B() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """ abc def ghi """, -"""" -var x = """ [||]""" -"""", -"""" -var x = """ - abc - def - ghi - [||]""" -"""", - afterUndo: -"""" -var x = """ abc - def - ghi[||]""" -""""); - } + """" + var x = """ [||]""" + """", + """" + var x = """ + abc + def + ghi + [||]""" + """", + afterUndo: + """" + var x = """ abc + def + ghi[||]""" + """"); [WpfFact] public void TestNormalTextIntoSingleLineRawStringSingleLine10_A() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """ abc def ghi """, -"""" -var x = """[||] """ -"""", -"""" -var x = """ - abc - def - ghi[||] - """ -"""", - afterUndo: -"""" -var x = """ abc - def - ghi[||] """ -""""); - } + """" + var x = """[||] """ + """", + """" + var x = """ + abc + def + ghi[||] + """ + """", + afterUndo: + """" + var x = """ abc + def + ghi[||] """ + """"); [WpfFact] public void TestNormalTextIntoSingleLineRawStringSingleLine10_B() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """ abc def ghi """, -"""" -var x = """ [||]""" -"""", -"""" -var x = """ - abc - def - ghi - [||]""" -"""", - afterUndo: -"""" -var x = """ abc - def - ghi[||]""" -""""); - } + """" + var x = """ [||]""" + """", + """" + var x = """ + abc + def + ghi + [||]""" + """", + afterUndo: + """" + var x = """ abc + def + ghi[||]""" + """"); [WpfFact] public void TestNormalTextIntoSingleLineRawStringSingleLine11_A() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """ abc def """, -"""" -var x = """[||]{|Selection: |}""" -"""", -"""" -var x = """ - abc - def - [||]""" -"""", - afterUndo: -"""" -var x = """abc -def[||]""" -""""); - } + """" + var x = """[||]{|Selection: |}""" + """", + """" + var x = """ + abc + def + [||]""" + """", + afterUndo: + """" + var x = """abc + def[||]""" + """"); [WpfFact] public void TestNormalTextIntoSingleLineRawStringSingleLine11_B() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """ abc def """, -"""" -var x = """ [||]{|Selection: |} """ -"""", -"""" -var x = """ - abc - def[||] - """ -"""", - afterUndo: -"""" -var x = """ abc -def[||] """ -""""); - } + """" + var x = """ [||]{|Selection: |} """ + """", + """" + var x = """ + abc + def[||] + """ + """", + afterUndo: + """" + var x = """ abc + def[||] """ + """"); [WpfFact] public void TestNormalTextIntoSingleLineRawStringSingleLine12_A() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """ abc def """, -"""" -var x = """[||]{|Selection: |}""" -"""", -"""" -var x = """ - abc - def - - [||]""" -"""", - afterUndo: -"""" -var x = """abc -def -[||]""" -""""); - } + """" + var x = """[||]{|Selection: |}""" + """", + """" + var x = """ + abc + def + + [||]""" + """", + afterUndo: + """" + var x = """abc + def + [||]""" + """"); [WpfFact] public void TestNormalTextIntoSingleLineRawStringSingleLine12_B() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """ abc def """, -"""" -var x = """ [||]{|Selection: |} """ -"""", -"""" -var x = """ - abc - def - [||] - """ -"""", - afterUndo: -"""" -var x = """ abc -def -[||] """ -""""); - } + """" + var x = """ [||]{|Selection: |} """ + """", + """" + var x = """ + abc + def + [||] + """ + """", + afterUndo: + """" + var x = """ abc + def + [||] """ + """"); [WpfFact] public void TestNormalTextIntoSingleLineRawStringSingleLine13_A() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """ abc def """, -"""" -var x = """[||]{|Selection: |} """ -"""", -"""" -var x = """ - abc - def[||] - """ -"""", - afterUndo: -"""" -var x = """abc -def[||] """ -""""); - } + """" + var x = """[||]{|Selection: |} """ + """", + """" + var x = """ + abc + def[||] + """ + """", + afterUndo: + """" + var x = """abc + def[||] """ + """"); [WpfFact] public void TestNormalTextIntoSingleLineRawStringSingleLine13_B() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """ abc def """, -"""" -var x = """ [||]{|Selection: |}""" -"""", -"""" -var x = """ - abc - def - [||]""" -"""", - afterUndo: -"""" -var x = """ abc -def[||]""" -""""); - } + """" + var x = """ [||]{|Selection: |}""" + """", + """" + var x = """ + abc + def + [||]""" + """", + afterUndo: + """" + var x = """ abc + def[||]""" + """"); [WpfFact] public void TestNormalTextIntoSingleLineRawStringHeader1_A() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """ "bar """, -"""" -var x = """[||]goo""" -"""", -"""" -var x = """ - "bar[||]goo - """ -"""", + """" + var x = """[||]goo""" + """", + """" + var x = """ + "bar[||]goo + """ + """", afterUndo: -""""" -var x = """"bar[||]goo""" -"""""); - } + """"" + var x = """"bar[||]goo""" + """""); [WpfFact] public void TestNormalTextIntoSingleLineRawStringHeader1_B() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """ bar" """, -"""" -var x = """goo[||]""" -"""", -"""" -var x = """ - goobar" - [||]""" -"""", + """" + var x = """goo[||]""" + """", + """" + var x = """ + goobar" + [||]""" + """", afterUndo: -"""" -var x = """goobar"[||]""" -""""); - } + """" + var x = """goobar"[||]""" + """"); [WpfFact] public void TestQuotesIntoHeader1() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """ "" """, -"""" -var x = """[||]{|Selection: |}""" -"""", -"""" -var x = """ - "" - [||]""" -"""", + """" + var x = """[||]{|Selection: |}""" + """", + """" + var x = """ + "" + [||]""" + """", afterUndo: -"""""" -var x = """""[||]""" -""""""); - } + """""" + var x = """""[||]""" + """"""); [WpfFact] public void TestQuotesIntoHeader2() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """" """ """", -"""" -var x = """[||]{|Selection: |}""" -"""", -""""" -var x = """" - """ - [||]"""" -""""", - afterUndo: -""""""" -var x = """"""[||]""" -"""""""); - } + """" + var x = """[||]{|Selection: |}""" + """", + """"" + var x = """" + """ + [||]"""" + """"", + afterUndo: + """"""" + var x = """"""[||]""" + """""""); } diff --git a/src/EditorFeatures/CSharpTest/StringCopyPaste/PasteUnknownSourceIntoVerbatimInterpolatedStringTests.cs b/src/EditorFeatures/CSharpTest/StringCopyPaste/PasteUnknownSourceIntoVerbatimInterpolatedStringTests.cs index 5e68e457cf92..b25eb0c9e56f 100644 --- a/src/EditorFeatures/CSharpTest/StringCopyPaste/PasteUnknownSourceIntoVerbatimInterpolatedStringTests.cs +++ b/src/EditorFeatures/CSharpTest/StringCopyPaste/PasteUnknownSourceIntoVerbatimInterpolatedStringTests.cs @@ -13,8 +13,7 @@ public sealed class PasteUnknownSourceIntoVerbatimInterpolatedStringTests [WpfFact] public void TestNewLineIntoVerbatimInterpolatedString1() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: "\n", """ var x = $@"[||]" @@ -23,12 +22,10 @@ public void TestNewLineIntoVerbatimInterpolatedString1() afterUndo: """ var x = $@"[||]" """); - } [WpfFact] public void TestNewLineIntoVerbatimInterpolatedString2() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """ @@ -43,12 +40,10 @@ public void TestNewLineIntoVerbatimInterpolatedString2() afterUndo: """ var x = $@"[||]" """); - } [WpfFact] public void TestTabIntoVerbatimInterpolatedString1() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: "\t", """ var x = $@"[||]" @@ -57,12 +52,10 @@ public void TestTabIntoVerbatimInterpolatedString1() afterUndo: """ var x = $@"[||]" """); - } [WpfFact] public void TestSingleQuoteIntoVerbatimInterpolatedString() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """'""", """ var x = $@"[||]" @@ -73,12 +66,10 @@ public void TestSingleQuoteIntoVerbatimInterpolatedString() afterUndo: """ var x = $@"[||]" """); - } [WpfFact] public void TestDoubleQuoteIntoVerbatimInterpolatedString() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """ " """, @@ -91,12 +82,10 @@ public void TestDoubleQuoteIntoVerbatimInterpolatedString() afterUndo: """ var x = $@""[||]" """); - } [WpfFact] public void TestComplexStringIntoVerbatimInterpolatedString() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: "\t\"\"\t", """ var x = $@"[||]" @@ -105,12 +94,10 @@ public void TestComplexStringIntoVerbatimInterpolatedString() afterUndo: """ var x = $@"[||]" """); - } [WpfFact] public void TestVerbatimTextIntoVerbatimInterpolatedString() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """abc""", """ var x = $@"[||]" @@ -121,12 +108,10 @@ public void TestVerbatimTextIntoVerbatimInterpolatedString() afterUndo: """ var x = $@"[||]" """); - } [WpfFact] public void TestOpenCurlyIntoVerbatimInterpolatedString1() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """{""", """ var x = $@"[||]" @@ -137,12 +122,10 @@ public void TestOpenCurlyIntoVerbatimInterpolatedString1() afterUndo: """ var x = $@"{[||]" """); - } [WpfFact] public void TestTwoOpenCurliesIntoVerbatimInterpolatedString1() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """{{""", """ var x = $@"[||]" @@ -153,12 +136,10 @@ public void TestTwoOpenCurliesIntoVerbatimInterpolatedString1() afterUndo: """ var x = $@"[||]" """); - } [WpfFact] public void TestTwoOpenCurliesAndContentIntoVerbatimInterpolatedString1() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """{{0""", """ var x = $@"[||]" @@ -169,12 +150,10 @@ public void TestTwoOpenCurliesAndContentIntoVerbatimInterpolatedString1() afterUndo: """ var x = $@"[||]" """); - } [WpfFact] public void TestCloseCurlyIntoVerbatimInterpolatedString1() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """}""", """ var x = $@"[||]" @@ -185,12 +164,10 @@ public void TestCloseCurlyIntoVerbatimInterpolatedString1() afterUndo: """ var x = $@"}[||]" """); - } [WpfFact] public void TestTwoCloseCurliesIntoVerbatimInterpolatedString1() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """}}""", """ var x = $@"[||]" @@ -201,12 +178,10 @@ public void TestTwoCloseCurliesIntoVerbatimInterpolatedString1() afterUndo: """ var x = $@"[||]" """); - } [WpfFact] public void TestTwoCloseCurliesAndContentIntoVerbatimInterpolatedString1() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """}}0""", """ var x = $@"[||]" @@ -217,12 +192,10 @@ public void TestTwoCloseCurliesAndContentIntoVerbatimInterpolatedString1() afterUndo: """ var x = $@"[||]" """); - } [WpfFact] public void TestCurlyWithContentIntoVerbatimInterpolatedString1() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """x{0}y""", """ var x = $@"[||]" @@ -233,12 +206,10 @@ public void TestCurlyWithContentIntoVerbatimInterpolatedString1() afterUndo: """ var x = $@"[||]" """); - } [WpfFact] public void TestCurliesWithContentIntoVerbatimInterpolatedString1() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """x{{0}}y""", """ var x = $@"[||]" @@ -249,7 +220,6 @@ public void TestCurliesWithContentIntoVerbatimInterpolatedString1() afterUndo: """ var x = $@"[||]" """); - } #endregion @@ -257,8 +227,7 @@ public void TestCurliesWithContentIntoVerbatimInterpolatedString1() [WpfFact] public void TestNewLineIntoVerbatimInterpolatedStringBeforeHole1() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: "\n", """ var x = $@"[||]{0}" @@ -267,12 +236,10 @@ public void TestNewLineIntoVerbatimInterpolatedStringBeforeHole1() afterUndo: """ var x = $@"[||]{0}" """); - } [WpfFact] public void TestNewLineIntoVerbatimInterpolatedStringBeforeHole2() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """ @@ -287,12 +254,10 @@ public void TestNewLineIntoVerbatimInterpolatedStringBeforeHole2() afterUndo: """ var x = $@"[||]{0}" """); - } [WpfFact] public void TestTabIntoVerbatimInterpolatedStringBeforeHole1() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: "\t", """ var x = $@"[||]{0}" @@ -301,12 +266,10 @@ public void TestTabIntoVerbatimInterpolatedStringBeforeHole1() afterUndo: """ var x = $@"[||]{0}" """); - } [WpfFact] public void TestSingleQuoteIntoVerbatimInterpolatedStringBeforeHole() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """'""", """ var x = $@"[||]{0}" @@ -317,12 +280,10 @@ public void TestSingleQuoteIntoVerbatimInterpolatedStringBeforeHole() afterUndo: """ var x = $@"[||]{0}" """); - } [WpfFact] public void TestDoubleQuoteIntoVerbatimInterpolatedStringBeforeHole() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """ " """, @@ -335,12 +296,10 @@ public void TestDoubleQuoteIntoVerbatimInterpolatedStringBeforeHole() afterUndo: """ var x = $@""[||]{0}" """); - } [WpfFact] public void TestComplexStringIntoVerbatimInterpolatedStringBeforeHole() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: "\t\"\"\t", """ var x = $@"[||]{0}" @@ -349,12 +308,10 @@ public void TestComplexStringIntoVerbatimInterpolatedStringBeforeHole() afterUndo: """ var x = $@"[||]{0}" """); - } [WpfFact] public void TestVerbatimTextIntoVerbatimInterpolatedStringBeforeHole() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """abc""", """ var x = $@"[||]{0}" @@ -365,12 +322,10 @@ public void TestVerbatimTextIntoVerbatimInterpolatedStringBeforeHole() afterUndo: """ var x = $@"[||]{0}" """); - } [WpfFact] public void TestOpenCurlyIntoVerbatimInterpolatedStringBeforeHole1() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """{""", """ var x = $@"[||]{0}" @@ -381,12 +336,10 @@ public void TestOpenCurlyIntoVerbatimInterpolatedStringBeforeHole1() afterUndo: """ var x = $@"{[||]{0}" """); - } [WpfFact] public void TestTwoOpenCurliesIntoVerbatimInterpolatedStringBeforeHole1() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """{{""", """ var x = $@"[||]{0}" @@ -397,12 +350,10 @@ public void TestTwoOpenCurliesIntoVerbatimInterpolatedStringBeforeHole1() afterUndo: """ var x = $@"[||]{0}" """); - } [WpfFact] public void TestTwoOpenCurliesAndContentIntoVerbatimInterpolatedStringBeforeHole1() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """{{0""", """ var x = $@"[||]{0}" @@ -413,12 +364,10 @@ public void TestTwoOpenCurliesAndContentIntoVerbatimInterpolatedStringBeforeHole afterUndo: """ var x = $@"[||]{0}" """); - } [WpfFact] public void TestCloseCurlyIntoVerbatimInterpolatedStringBeforeHole1() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """}""", """ var x = $@"[||]{0}" @@ -429,12 +378,10 @@ public void TestCloseCurlyIntoVerbatimInterpolatedStringBeforeHole1() afterUndo: """ var x = $@"}[||]{0}" """); - } [WpfFact] public void TestTwoCloseCurliesIntoVerbatimInterpolatedStringBeforeHole1() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """}}""", """ var x = $@"[||]{0}" @@ -445,12 +392,10 @@ public void TestTwoCloseCurliesIntoVerbatimInterpolatedStringBeforeHole1() afterUndo: """ var x = $@"[||]{0}" """); - } [WpfFact] public void TestTwoCloseCurliesAndContentIntoVerbatimInterpolatedStringBeforeHole1() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """}}0""", """ var x = $@"[||]{0}" @@ -461,12 +406,10 @@ public void TestTwoCloseCurliesAndContentIntoVerbatimInterpolatedStringBeforeHol afterUndo: """ var x = $@"[||]{0}" """); - } [WpfFact] public void TestCurlyWithContentIntoVerbatimInterpolatedStringBeforeHole1() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """x{0}y""", """ var x = $@"[||]{0}" @@ -477,12 +420,10 @@ public void TestCurlyWithContentIntoVerbatimInterpolatedStringBeforeHole1() afterUndo: """ var x = $@"[||]{0}" """); - } [WpfFact] public void TestCurliesWithContentIntoVerbatimInterpolatedStringBeforeHole1() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """x{{0}}y""", """ var x = $@"[||]{0}" @@ -493,7 +434,6 @@ public void TestCurliesWithContentIntoVerbatimInterpolatedStringBeforeHole1() afterUndo: """ var x = $@"[||]{0}" """); - } #endregion @@ -501,8 +441,7 @@ public void TestCurliesWithContentIntoVerbatimInterpolatedStringBeforeHole1() [WpfFact] public void TestNewLineIntoVerbatimInterpolatedStringAfterHole1() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: "\n", """ var x = $@"{0}[||]" @@ -511,12 +450,10 @@ public void TestNewLineIntoVerbatimInterpolatedStringAfterHole1() afterUndo: """ var x = $@"{0}[||]" """); - } [WpfFact] public void TestNewLineIntoVerbatimInterpolatedStringAfterHole2() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """ @@ -531,12 +468,10 @@ public void TestNewLineIntoVerbatimInterpolatedStringAfterHole2() afterUndo: """ var x = $@"{0}[||]" """); - } [WpfFact] public void TestTabIntoVerbatimInterpolatedStringAfterHole1() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: "\t", """ var x = $@"{0}[||]" @@ -545,12 +480,10 @@ public void TestTabIntoVerbatimInterpolatedStringAfterHole1() afterUndo: """ var x = $@"{0}[||]" """); - } [WpfFact] public void TestSingleQuoteIntoVerbatimInterpolatedStringAfterHole() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """'""", """ var x = $@"{0}[||]" @@ -561,12 +494,10 @@ public void TestSingleQuoteIntoVerbatimInterpolatedStringAfterHole() afterUndo: """ var x = $@"{0}[||]" """); - } [WpfFact] public void TestDoubleQuoteIntoVerbatimInterpolatedStringAfterHole() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """ " """, @@ -579,12 +510,10 @@ public void TestDoubleQuoteIntoVerbatimInterpolatedStringAfterHole() afterUndo: """ var x = $@"{0}"[||]" """); - } [WpfFact] public void TestComplexStringIntoVerbatimInterpolatedStringAfterHole() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: "\t\"\"\t", """ var x = $@"{0}[||]" @@ -593,12 +522,10 @@ public void TestComplexStringIntoVerbatimInterpolatedStringAfterHole() afterUndo: """ var x = $@"{0}[||]" """); - } [WpfFact] public void TestVerbatimTextIntoVerbatimInterpolatedStringAfterHole() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """abc""", """ var x = $@"{0}[||]" @@ -609,12 +536,10 @@ public void TestVerbatimTextIntoVerbatimInterpolatedStringAfterHole() afterUndo: """ var x = $@"{0}[||]" """); - } [WpfFact] public void TestOpenCurlyIntoVerbatimInterpolatedStringAfterHole1() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """{""", """ var x = $@"{0}[||]" @@ -625,12 +550,10 @@ public void TestOpenCurlyIntoVerbatimInterpolatedStringAfterHole1() afterUndo: """ var x = $@"{0}{[||]" """); - } [WpfFact] public void TestTwoOpenCurliesIntoVerbatimInterpolatedStringAfterHole1() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """{{""", """ var x = $@"{0}[||]" @@ -641,12 +564,10 @@ public void TestTwoOpenCurliesIntoVerbatimInterpolatedStringAfterHole1() afterUndo: """ var x = $@"{0}[||]" """); - } [WpfFact] public void TestTwoOpenCurliesAndContentIntoVerbatimInterpolatedStringAfterHole1() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """{{0""", """ var x = $@"{0}[||]" @@ -657,12 +578,10 @@ public void TestTwoOpenCurliesAndContentIntoVerbatimInterpolatedStringAfterHole1 afterUndo: """ var x = $@"{0}[||]" """); - } [WpfFact] public void TestCloseCurlyIntoVerbatimInterpolatedStringAfterHole1() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """}""", """ var x = $@"{0}[||]" @@ -673,12 +592,10 @@ public void TestCloseCurlyIntoVerbatimInterpolatedStringAfterHole1() afterUndo: """ var x = $@"{0}}[||]" """); - } [WpfFact] public void TestTwoCloseCurliesIntoVerbatimInterpolatedStringAfterHole1() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """}}""", """ var x = $@"{0}[||]" @@ -689,12 +606,10 @@ public void TestTwoCloseCurliesIntoVerbatimInterpolatedStringAfterHole1() afterUndo: """ var x = $@"{0}[||]" """); - } [WpfFact] public void TestTwoCloseCurliesAndContentIntoVerbatimInterpolatedStringAfterHole1() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """}}0""", """ var x = $@"{0}[||]" @@ -705,12 +620,10 @@ public void TestTwoCloseCurliesAndContentIntoVerbatimInterpolatedStringAfterHole afterUndo: """ var x = $@"{0}[||]" """); - } [WpfFact] public void TestCurlyWithContentIntoVerbatimInterpolatedStringAfterHole1() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """x{0}y""", """ var x = $@"{0}[||]" @@ -721,12 +634,10 @@ public void TestCurlyWithContentIntoVerbatimInterpolatedStringAfterHole1() afterUndo: """ var x = $@"{0}[||]" """); - } [WpfFact] public void TestCurliesWithContentIntoVerbatimInterpolatedStringAfterHole1() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """x{{0}}y""", """ var x = $@"{0}[||]" @@ -737,7 +648,6 @@ public void TestCurliesWithContentIntoVerbatimInterpolatedStringAfterHole1() afterUndo: """ var x = $@"{0}[||]" """); - } #endregion } diff --git a/src/EditorFeatures/CSharpTest/StringCopyPaste/PasteUnknownSourceIntoVerbatimStringTests.cs b/src/EditorFeatures/CSharpTest/StringCopyPaste/PasteUnknownSourceIntoVerbatimStringTests.cs index dc21bebf5d7d..992ca3b4e4f7 100644 --- a/src/EditorFeatures/CSharpTest/StringCopyPaste/PasteUnknownSourceIntoVerbatimStringTests.cs +++ b/src/EditorFeatures/CSharpTest/StringCopyPaste/PasteUnknownSourceIntoVerbatimStringTests.cs @@ -11,8 +11,7 @@ public sealed class PasteUnknownSourceIntoVerbatimStringTests { [WpfFact] public void TestNewLineIntoVerbatimString1() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: "\n", """ var x = @"[||]" @@ -21,12 +20,10 @@ public void TestNewLineIntoVerbatimString1() afterUndo: """ var x = @"[||]" """); - } [WpfFact] public void TestNewLineIntoVerbatimString2() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """ @@ -41,12 +38,10 @@ public void TestNewLineIntoVerbatimString2() afterUndo: """ var x = @"[||]" """); - } [WpfFact] public void TestTabIntoVerbatimString1() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: "\t", """ var x = @"[||]" @@ -55,12 +50,10 @@ public void TestTabIntoVerbatimString1() afterUndo: """ var x = @"[||]" """); - } [WpfFact] public void TestSingleQuoteIntoVerbatimString() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """'""", """ var x = @"[||]" @@ -71,12 +64,10 @@ public void TestSingleQuoteIntoVerbatimString() afterUndo: """ var x = @"[||]" """); - } [WpfFact] public void TestDoubleQuoteIntoVerbatimString() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """ " """, @@ -89,12 +80,10 @@ public void TestDoubleQuoteIntoVerbatimString() afterUndo: """ var x = @""[||]" """); - } [WpfFact] public void TestComplexStringIntoVerbatimString() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: "\t\"\"\t", """ var x = @"[||]" @@ -103,12 +92,10 @@ public void TestComplexStringIntoVerbatimString() afterUndo: """ var x = @"[||]" """); - } [WpfFact] public void TestNormalTextIntoVerbatimString() - { - TestPasteUnknownSource( + => TestPasteUnknownSource( pasteText: """abc""", """ var x = @"[||]" @@ -119,7 +106,6 @@ public void TestNormalTextIntoVerbatimString() afterUndo: """ var x = @"[||]" """); - } [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/62969")] public void TestNormalTextWithSomeQuotesToEscapeAndSomeToNotEscapeIntoVerbatimString() diff --git a/src/EditorFeatures/CSharpTest/StringCopyPaste/StringCopyPasteCommandHandlerKnownSourceTests.cs b/src/EditorFeatures/CSharpTest/StringCopyPaste/StringCopyPasteCommandHandlerKnownSourceTests.cs index 09e5eff309ab..f7195c93c290 100644 --- a/src/EditorFeatures/CSharpTest/StringCopyPaste/StringCopyPasteCommandHandlerKnownSourceTests.cs +++ b/src/EditorFeatures/CSharpTest/StringCopyPaste/StringCopyPasteCommandHandlerKnownSourceTests.cs @@ -27,8 +27,7 @@ protected static void TestPasteKnownSource(string pasteText, string markup, stri [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/61316")] public void TestLineCopyPaste() - { - TestCopyPaste( + => TestCopyPaste( """ Debug.Assert(adjustment != 0, $"Indentation with[||]{|Copy:|} no adjustment should be represented by {nameof(BaseIndentationData)} directly."); @@ -47,5 +46,4 @@ public void TestLineCopyPaste() """, mockCopyPasteService: false); - } } diff --git a/src/EditorFeatures/CSharpTest/Structure/MultilineCommentStructureTests.cs b/src/EditorFeatures/CSharpTest/Structure/MultilineCommentStructureTests.cs index 6db085ba5f95..145de0f09cda 100644 --- a/src/EditorFeatures/CSharpTest/Structure/MultilineCommentStructureTests.cs +++ b/src/EditorFeatures/CSharpTest/Structure/MultilineCommentStructureTests.cs @@ -264,11 +264,7 @@ class C Region("span1", "/* Comment in constructor ...", autoCollapse: true)); [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/16186")] - public async Task TestInvalidComment() - { - const string code = @"$${|span:/*/|}"; - - await VerifyBlockSpansAsync(code, + public Task TestInvalidComment() + => VerifyBlockSpansAsync(@"$${|span:/*/|}", Region("span", "/* / ...", autoCollapse: true)); - } } diff --git a/src/EditorFeatures/CSharpTest/Structure/TypeDeclarationStructureTests.cs b/src/EditorFeatures/CSharpTest/Structure/TypeDeclarationStructureTests.cs index 4ee2abe28d48..272b7e05f3b8 100644 --- a/src/EditorFeatures/CSharpTest/Structure/TypeDeclarationStructureTests.cs +++ b/src/EditorFeatures/CSharpTest/Structure/TypeDeclarationStructureTests.cs @@ -7,6 +7,7 @@ using Microsoft.CodeAnalysis.CSharp.Syntax; using Microsoft.CodeAnalysis.Structure; using Microsoft.CodeAnalysis.Test.Utilities; +using Roslyn.Test.Utilities; using Xunit; namespace Microsoft.CodeAnalysis.Editor.CSharp.UnitTests.Structure; @@ -231,4 +232,21 @@ public Task TestStructWithNestedComments() """, Region("textspan1", "hint1", CSharpStructureHelpers.Ellipsis, autoCollapse: false), Region("span2", "// Goo ...", autoCollapse: true)); + + [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/62506")] + public Task TestTypeDeclarationNoBraces1() + => VerifyBlockSpansAsync(""" + {|comment:// comment|} + $$struct S + """, + Region("comment", "// comment ...", autoCollapse: true)); + + [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/62506")] + public Task TestTypeDeclarationNoBraces2() + => VerifyBlockSpansAsync(""" + {|comment:// comment|} + {|hint1:$$struct S{|textspan1:;|}|} + """, + Region("comment", "// comment ...", autoCollapse: true), + Region("textspan1", "hint1", CSharpStructureHelpers.Ellipsis, autoCollapse: false)); } diff --git a/src/EditorFeatures/CSharpTest/SymbolKey/SymbolKeyErrorTypeTests.cs b/src/EditorFeatures/CSharpTest/SymbolKey/SymbolKeyErrorTypeTests.cs index 4d26e575e3e3..c6504003e157 100644 --- a/src/EditorFeatures/CSharpTest/SymbolKey/SymbolKeyErrorTypeTests.cs +++ b/src/EditorFeatures/CSharpTest/SymbolKey/SymbolKeyErrorTypeTests.cs @@ -15,8 +15,7 @@ public sealed class SymbolKeyErrorTypeTests : SymbolKeyTestBase { [Fact] public void GenericType_NotMissingWithMissingTypeArgument() - { - VerifyResolution(""" + => VerifyResolution(""" namespace N { public class C @@ -31,12 +30,10 @@ public class D } } """, c => c.GetMember("N.C.M")); - } [Fact] public void GenericType_MissingWithNonMissingTypeArgument() - { - VerifyResolution(""" + => VerifyResolution(""" using System.Collections.Generic; namespace N @@ -53,12 +50,10 @@ public class D } } """, c => c.GetMember("N.C.M")); - } [Fact] public void GenericType_MissingWithMissingTypeArgument() - { - VerifyResolution(""" + => VerifyResolution(""" using System.Collections.Generic; namespace N @@ -71,12 +66,10 @@ public void M(List x) } } """, c => c.GetMember("N.C.M")); - } [Fact] public void Tuple_MissingTypes() - { - VerifyResolution(""" + => VerifyResolution(""" namespace N { public class C @@ -87,12 +80,10 @@ public void M((string, int) x) } } """, c => c.GetMember("N.C.M")); - } [Fact] public void Tuple_NonMissingTypes() - { - VerifyResolution(""" + => VerifyResolution(""" namespace N { public class C @@ -107,12 +98,10 @@ public class D } } """, c => c.GetMember("N.C.M")); - } [Fact] public void Array_MissingElementType() - { - VerifyResolution(""" + => VerifyResolution(""" namespace N { public class C @@ -123,12 +112,10 @@ public void M(string[] x) } } """, c => c.GetMember("N.C.M")); - } [Fact] public void Array_NonMissingElementType() - { - VerifyResolution(""" + => VerifyResolution(""" namespace N { public class C @@ -143,12 +130,10 @@ public class D } } """, c => c.GetMember("N.C.M")); - } [Fact] public void Pointer_MissingType() - { - VerifyResolution(""" + => VerifyResolution(""" namespace N { public class C @@ -159,12 +144,10 @@ public unsafe void M(int *x) } } """, c => c.GetMember("N.C.M")); - } [Fact] public void Pointer_NonMissingType() - { - VerifyResolution(""" + => VerifyResolution(""" namespace N { public class C @@ -179,12 +162,10 @@ public struct S } } """, c => c.GetMember("N.C.M")); - } [Fact] public void NestedType_MissingInGenericContainer() - { - VerifyResolution(""" + => VerifyResolution(""" using System.Collections.Generic; namespace N @@ -197,12 +178,10 @@ public void M(List.Enumerator x) } } """, c => c.GetMember("N.C.M")); - } [Fact] public void NestedType_MissingInNonGenericContainer() - { - VerifyResolution(""" + => VerifyResolution(""" using System.Diagnostics; namespace N @@ -215,12 +194,10 @@ public void M(DebuggableAttribute.DebuggingModes x) } } """, c => c.GetMember("N.C.M")); - } [Fact] public void Method_MissingReturnType() - { - VerifyResolution(""" + => VerifyResolution(""" namespace N { public class C @@ -232,12 +209,10 @@ public string Create() } } """, c => c.GetMember("N.C.Create")); - } [Fact] public void Method_MissingParameterType() - { - VerifyResolution(""" + => VerifyResolution(""" namespace N { public class C @@ -249,12 +224,10 @@ public C Create(string x) } } """, c => c.GetMember("N.C.Create")); - } [Fact] public void Constructor_MissingParameterType() - { - VerifyResolution(""" + => VerifyResolution(""" public class C { public C(string x) @@ -262,12 +235,10 @@ public C(string x) } } """, c => c.GetMember("C..ctor")); - } [Fact] public void Indexer_MissingParameterType() - { - VerifyResolution(""" + => VerifyResolution(""" namespace N { public class C @@ -280,12 +251,10 @@ public C this[string x] } } """, c => c.GetMember("N.C.this[]")); - } [Fact] public void Indexer_MissingReturnType() - { - VerifyResolution(""" + => VerifyResolution(""" namespace N { public class C @@ -298,12 +267,10 @@ public string this[C x] } } """, c => c.GetMember("N.C.this[]")); - } [Fact] public void Property_MissingReturnType() - { - VerifyResolution(""" + => VerifyResolution(""" namespace N { public class C @@ -316,12 +283,10 @@ public string P } } """, c => c.GetMember("N.C.P")); - } [Fact] public void EventField_MissingReturnType() - { - VerifyResolution(""" + => VerifyResolution(""" namespace N { public class C @@ -330,7 +295,6 @@ public class C } } """, c => c.GetMember("N.C.E")); - } private static void VerifyResolution(string source, Func symbolToResolve) { diff --git a/src/EditorFeatures/CSharpTest/TextStructureNavigation/TextStructureNavigatorTests.cs b/src/EditorFeatures/CSharpTest/TextStructureNavigation/TextStructureNavigatorTests.cs index a89a6bbb6790..adc4bf2fa2d7 100644 --- a/src/EditorFeatures/CSharpTest/TextStructureNavigation/TextStructureNavigatorTests.cs +++ b/src/EditorFeatures/CSharpTest/TextStructureNavigation/TextStructureNavigatorTests.cs @@ -27,9 +27,7 @@ protected override EditorTestWorkspace CreateWorkspace(string code) [Fact] public void Empty() - { - AssertExtent("""$${|Insignificant:|}"""); - } + => AssertExtent("""$${|Insignificant:|}"""); [WpfFact] public void Whitespace() @@ -46,10 +44,8 @@ public void Whitespace() [WpfFact] public void EndOfFile() - { - AssertExtent( + => AssertExtent( """using System{|Significant:;|}$$"""); - } [Fact] public void NewLine() @@ -244,9 +240,7 @@ public void Number() [InlineData("""class Test { private string s1 = " () test {|Significant:$$"|}; }""")] [InlineData("""class Test { private string s1 = " () test "{|Significant:$$;|} }""")] public void String(string content) - { - AssertExtent(content); - } + => AssertExtent(content); [WpfTheory] [InlineData("""class Test { private string s1 = {|Significant:$$"|} () test "u8; }""")] @@ -256,9 +250,7 @@ public void String(string content) [InlineData("""class Test { private string s1 = " () test {|Significant:$$"u8|}; }""")] [InlineData("""class Test { private string s1 = " () test "u8{|Significant:$$;|} }""")] public void Utf8String(string content) - { - AssertExtent(content); - } + => AssertExtent(content); [WpfFact] public void InterpolatedString1() @@ -378,9 +370,7 @@ public void TestRawStringContent() """; """")] public void TestRawStringDelimiter1(string content) - { - AssertExtent(content); - } + => AssertExtent(content); [WpfTheory, WorkItem("""https://github.com/dotnet/roslyn/issues/59581""")] [InlineData( @@ -408,9 +398,7 @@ public void TestRawStringDelimiter1(string content) {|Significant:""$$"|}; """")] public void TestRawStringDelimiter2(string content) - { - AssertExtent(content); - } + => AssertExtent(content); [WpfTheory] [InlineData( @@ -454,9 +442,7 @@ public void TestRawStringDelimiter2(string content) {|Significant:"""u$$8|}; """")] public void TestUtf8RawStringDelimiter(string content) - { - AssertExtent(content); - } + => AssertExtent(content); private static void TestNavigator( string code, @@ -558,9 +544,7 @@ public void GetSpanOfPreviousSiblingTest() [InlineData(""""Console.WriteLine("""{|Significant:$$=============|}"""u8);"""")] [InlineData(""""Console.WriteLine("""{|Significant:=$$============|}"""u8);"""")] public void TestClampStringLiteral(string content) - { - AssertExtent(content); - } + => AssertExtent(content); [WpfTheory, WorkItem("https://github.com/dotnet/roslyn/issues/77401")] [InlineData(@"{|Significant:""|}$$")] @@ -569,7 +553,5 @@ public void TestClampStringLiteral(string content) """{|Significant:u8|}$$ """")] public void TestClampStringLiteral_Invalid(string content) - { - AssertExtent(content); - } + => AssertExtent(content); } diff --git a/src/EditorFeatures/CSharpTest2/EmbeddedLanguages/Json/CSharpJsonParserTests_BasicTests.cs b/src/EditorFeatures/CSharpTest2/EmbeddedLanguages/Json/CSharpJsonParserTests_BasicTests.cs index ccd654cf8c45..c6e919b38312 100644 --- a/src/EditorFeatures/CSharpTest2/EmbeddedLanguages/Json/CSharpJsonParserTests_BasicTests.cs +++ b/src/EditorFeatures/CSharpTest2/EmbeddedLanguages/Json/CSharpJsonParserTests_BasicTests.cs @@ -11,18 +11,15 @@ public sealed partial class CSharpJsonParserBasicTests : CSharpJsonParserTests { [Fact] public void TestEmpty() - { - Test(""" + => Test(""" "" """, expected: null, "", "", runLooseSubTreeCheck: false); - } [Fact] public void TestOneSpace() - { - Test(""" + => Test(""" " " """, """ @@ -46,12 +43,10 @@ public void TestOneSpace() """); - } [Fact] public void TestTwoSpaces() - { - Test(""" + => Test(""" " " """, """ @@ -75,12 +70,10 @@ public void TestTwoSpaces() """); - } [Fact] public void TestTabSpace() - { - Test(""" + => Test(""" "\t" """, """ @@ -104,12 +97,10 @@ public void TestTabSpace() """); - } [Fact] public void TestFormFeed() - { - Test(""" + => Test(""" "\f" """, """ @@ -133,12 +124,10 @@ public void TestFormFeed() """); - } [Fact] public void TestFormFeed2() - { - Test(""" + => Test(""" "[\f1,0]" """, """ @@ -170,7 +159,6 @@ public void TestFormFeed2() """); - } [Fact] public void TestFormFeed3() @@ -213,8 +201,7 @@ public void TestFormFeed3() [Fact] public void TestSingleLineComment() - { - Test(""" + => Test(""" "//" """, """ @@ -238,12 +225,10 @@ public void TestSingleLineComment() """); - } [Fact] public void TestSingleLineCommentWithContent() - { - Test(""" + => Test(""" "// " """, """ @@ -263,12 +248,10 @@ public void TestSingleLineCommentWithContent() """); - } [Fact] public void TestEmptyMultiLineComment() - { - Test(""" + => Test(""" "/**/" """, """ @@ -288,12 +271,10 @@ public void TestEmptyMultiLineComment() """); - } [Fact] public void TestMultiLineCommentWithStar() - { - Test(""" + => Test(""" "/***/" """, """ @@ -313,12 +294,10 @@ public void TestMultiLineCommentWithStar() """); - } [Fact] public void TestArray1() - { - Test(""" + => Test(""" "[]" """, """ @@ -336,12 +315,10 @@ public void TestArray1() """, "", ""); - } [Fact] public void TestArray2() - { - Test(""" + => Test(""" " [ ] " """, """ @@ -362,12 +339,10 @@ public void TestArray2() """, "", ""); - } [Fact] public void TestArray3() - { - Test(""" + => Test(""" "[" """, """ @@ -393,12 +368,10 @@ public void TestArray3() """); - } [Fact] public void TestArray4() - { - Test(""" + => Test(""" "]" """, """ @@ -422,12 +395,10 @@ public void TestArray4() """); - } [Fact] public void TestArray5() - { - Test(""" + => Test(""" "[,]" """, """ @@ -453,12 +424,10 @@ public void TestArray5() """); - } [Fact] public void TestArray6() - { - Test(""" + => Test(""" "[true,]" """, """ @@ -487,12 +456,10 @@ public void TestArray6() """); - } [Fact] public void TestArray7() - { - Test(""" + => Test(""" "[true]" """, """ @@ -514,12 +481,10 @@ public void TestArray7() """, "", ""); - } [Fact] public void TestArray8() - { - Test(""" + => Test(""" "[,,]" """, """ @@ -548,12 +513,10 @@ public void TestArray8() """); - } [Fact] public void TestArray9() - { - Test(""" + => Test(""" "[true,,]" """, """ @@ -585,12 +548,10 @@ public void TestArray9() """); - } [Fact] public void TestArray10() - { - Test(""" + => Test(""" "[,true,]" """, """ @@ -622,12 +583,10 @@ public void TestArray10() """); - } [Fact] public void TestArray11() - { - Test(""" + => Test(""" "[,,true]" """, """ @@ -659,12 +618,10 @@ public void TestArray11() """); - } [Fact] public void TestTrueLiteral1() - { - Test(""" + => Test(""" "true" """, """ @@ -680,12 +637,10 @@ public void TestTrueLiteral1() """, "", ""); - } [Fact] public void TestTrueLiteral2() - { - Test(""" + => Test(""" " true " """, """ @@ -704,12 +659,10 @@ public void TestTrueLiteral2() """, "", ""); - } [Fact] public void TestFalseLiteral1() - { - Test(""" + => Test(""" "false" """, """ @@ -725,12 +678,10 @@ public void TestFalseLiteral1() """, "", ""); - } [Fact] public void TestFalseLiteral2() - { - Test(""" + => Test(""" " false " """, """ @@ -749,12 +700,10 @@ public void TestFalseLiteral2() """, "", ""); - } [Fact] public void TestNullLiteral1() - { - Test(""" + => Test(""" "null" """, """ @@ -770,12 +719,10 @@ public void TestNullLiteral1() """, "", ""); - } [Fact] public void TestNullLiteral2() - { - Test(""" + => Test(""" " null " """, """ @@ -794,12 +741,10 @@ public void TestNullLiteral2() """, "", ""); - } [Fact] public void TestUndefinedLiteral1() - { - Test(""" + => Test(""" "undefined" """, """ @@ -819,12 +764,10 @@ public void TestUndefinedLiteral1() """); - } [Fact] public void TestNaNLiteral1() - { - Test(""" + => Test(""" "NaN" """, """ @@ -844,12 +787,10 @@ public void TestNaNLiteral1() """); - } [Fact] public void TestNaNLiteral2() - { - Test(""" + => Test(""" " NaN " """, """ @@ -872,12 +813,10 @@ public void TestNaNLiteral2() """); - } [Fact] public void TestNaNLiteral3() - { - Test(""" + => Test(""" "nan" """, """ @@ -901,12 +840,10 @@ public void TestNaNLiteral3() """); - } [Fact] public void TestInfinity1() - { - Test(""" + => Test(""" "Infinity" """, """ @@ -926,12 +863,10 @@ public void TestInfinity1() """); - } [Fact] public void TestNegativeInfinity1() - { - Test(""" + => Test(""" "-Infinity" """, """ @@ -952,12 +887,10 @@ public void TestNegativeInfinity1() """); - } [Fact] public void TestNegativeInfinity2() - { - Test(""" + => Test(""" "- Infinity" """, """ @@ -984,12 +917,10 @@ public void TestNegativeInfinity2() """); - } [Fact] public void TestArrayWithMissingCommas() - { - Test(""" + => Test(""" "[0 1 2]" """, """ @@ -1025,12 +956,10 @@ public void TestArrayWithMissingCommas() """); - } [Fact] public void TestIncompleteNull1() - { - Test(""" + => Test(""" "n" """, """ @@ -1054,12 +983,10 @@ public void TestIncompleteNull1() """); - } [Fact] public void TestIncompleteNull2() - { - Test(""" + => Test(""" "nu" """, """ @@ -1083,12 +1010,10 @@ public void TestIncompleteNull2() """); - } [Fact] public void TestIncompleteUnicode1() - { - Test(""" + => Test(""" @"'h\u123'" """, """ @@ -1112,12 +1037,10 @@ public void TestIncompleteUnicode1() """); - } [Fact] public void TestIncompleteEscape() - { - Test(""" + => Test(""" @"'h\u'" """, """ @@ -1141,12 +1064,10 @@ public void TestIncompleteEscape() """); - } [Fact] public void TestIncompleteUnicode2() - { - Test("""" + => Test("""" @"""h\u123""" """", """ @@ -1170,12 +1091,10 @@ public void TestIncompleteUnicode2() """); - } [Fact] public void TestIncompleteEscape2() - { - Test("""" + => Test("""" @"""h\u""" """", """ @@ -1199,12 +1118,10 @@ public void TestIncompleteEscape2() """); - } [Fact] public void TestInvalidNonBase10() - { - Test(""" + => Test(""" "0aq2dun13.hod" """, """ @@ -1228,12 +1145,10 @@ public void TestInvalidNonBase10() """); - } [Fact] public void TestUnterminatedString() - { - Test(""" + => Test(""" "'hi" """, """ @@ -1257,12 +1172,10 @@ public void TestUnterminatedString() """); - } [Fact] public void TestUnterminatedString2() - { - Test(""" + => Test(""" "\"hi" """, """ @@ -1286,12 +1199,10 @@ public void TestUnterminatedString2() """); - } [Fact] public void TestExtraEndToken() - { - Test(""" + => Test(""" "{}}" """, """ @@ -1320,12 +1231,10 @@ public void TestExtraEndToken() """); - } [Fact] public void TestMultiObject1() - { - Test(""" + => Test(""" "{'first':1,'second':2,'third':3}" """, """ @@ -1371,12 +1280,10 @@ public void TestMultiObject1() """); - } [Fact] public void TestMultiObject2() - { - Test(""" + => Test(""" "{\"first\":1,\"second\":2,\"third\":3}" """, """ @@ -1418,12 +1325,10 @@ public void TestMultiObject2() """, "", ""); - } [Fact] public void TestExtraChar() - { - Test(""" + => Test(""" "nullz" """, """ @@ -1447,12 +1352,10 @@ public void TestExtraChar() """); - } [Fact] public void TestMissingColon() - { - Test(""" + => Test(""" @"{ 'a': 0, 'b' 0 }" """, """ @@ -1494,12 +1397,10 @@ public void TestMissingColon() """); - } [Fact] public void TestNestedPropertyMissingColon() - { - Test(""" + => Test(""" @" { ""description"": ""A person"", @@ -1662,12 +1563,10 @@ public void TestNestedPropertyMissingColon() """); - } [Fact] public void TestMissingColon2() - { - Test(""" + => Test(""" @"{ ""a"": 0, ""b"" 0 }" """, """ @@ -1709,12 +1608,10 @@ public void TestMissingColon2() """); - } [Fact] public void TestAdditionalContentComma() - { - Test(""" + => Test(""" @"[ ""Small"", ""Medium"", @@ -1767,12 +1664,10 @@ public void TestAdditionalContentComma() """); - } [Fact] public void TestAdditionalContentText() - { - Test(""" + => Test(""" @"[ ""Small"", ""Medium"", @@ -1825,12 +1720,10 @@ public void TestAdditionalContentText() """); - } [Fact] public void TestAdditionalContentWhitespaceText() - { - Test(""" + => Test(""" @"'hi' a" """, """ @@ -1857,12 +1750,10 @@ public void TestAdditionalContentWhitespaceText() """); - } [Fact] public void TestAdditionalContentWhitespaceText2() - { - Test("""" + => Test("""" @"""hi"" a" """", """ @@ -1889,12 +1780,10 @@ public void TestAdditionalContentWhitespaceText2() """); - } [Fact] public void TestTrailingCommentStart() - { - Test(""" + => Test(""" @"true/" """, """ @@ -1918,12 +1807,10 @@ public void TestTrailingCommentStart() """); - } [Fact] public void TestBadCharInArray() - { - Test(""" + => Test(""" @"[}" """, """ @@ -1953,12 +1840,10 @@ public void TestBadCharInArray() """); - } [Fact] public void TestIncompleteObject() - { - Test(""" + => Test(""" @"{" """, """ @@ -1984,12 +1869,10 @@ public void TestIncompleteObject() """); - } [Fact] public void TestEmptyObject() - { - Test(""" + => Test(""" @"{}" """, """ @@ -2007,12 +1890,10 @@ public void TestEmptyObject() """, "", ""); - } [Fact] public void TestLargeInt() - { - Test(""" + => Test(""" @"3333333333333333333333333333333333333" """, """ @@ -2028,12 +1909,10 @@ public void TestLargeInt() """, "", ""); - } [Fact] public void TestIdentifierProperty() - { - Test(""" + => Test(""" @"{ a: 0 }" """, """ @@ -2063,12 +1942,10 @@ public void TestIdentifierProperty() """); - } [Fact] public void TestNumericProperty() - { - Test(""" + => Test(""" @"{ 1: 0 }" """, """ @@ -2098,12 +1975,10 @@ public void TestNumericProperty() """); - } [Fact] public void TestNegativeNumericProperty() - { - Test(""" + => Test(""" @"{ -1: 0 }" """, """ @@ -2137,12 +2012,10 @@ public void TestNegativeNumericProperty() """); - } [Fact] public void TestArrayPropertyName() - { - Test(""" + => Test(""" @"{ []: 0 }" """, """ @@ -2182,12 +2055,10 @@ public void TestArrayPropertyName() """); - } [Fact] public void TestNaNPropertyName() - { - Test(""" + => Test(""" @"{ NaN: 0 }" """, """ @@ -2217,12 +2088,10 @@ public void TestNaNPropertyName() """); - } [Fact] public void TestInfinityPropertyName() - { - Test(""" + => Test(""" @"{ Infinity: 0 }" """, """ @@ -2252,12 +2121,10 @@ public void TestInfinityPropertyName() """); - } [Fact] public void TestNullPropertyName() - { - Test(""" + => Test(""" @"{ null: 0 }" """, """ @@ -2287,12 +2154,10 @@ public void TestNullPropertyName() """); - } [Fact] public void TestUndefinedPropertyName() - { - Test(""" + => Test(""" @"{ undefined: 0 }" """, """ @@ -2322,12 +2187,10 @@ public void TestUndefinedPropertyName() """); - } [Fact] public void TestNameWithSpace() - { - Test(""" + => Test(""" @"{ a b : 0 }" """, """ @@ -2365,12 +2228,10 @@ public void TestNameWithSpace() """); - } [Fact] public void TestNameWithNumber() - { - Test(""" + => Test(""" @"{ a0 : 0 }" """, """ @@ -2400,12 +2261,10 @@ public void TestNameWithNumber() """); - } [Fact] public void TestNumberWithHexName() - { - Test(""" + => Test(""" @"{ 0a : 0 }" """, """ @@ -2435,12 +2294,10 @@ public void TestNumberWithHexName() """); - } [Fact] public void TestNumberWithNonHexName() - { - Test(""" + => Test(""" @"{ 0z : 0 }" """, """ @@ -2470,12 +2327,10 @@ public void TestNumberWithNonHexName() """); - } [Fact] public void TestDollarPropName() - { - Test(""" + => Test(""" @"{ $ : 0 }" """, """ @@ -2505,12 +2360,10 @@ public void TestDollarPropName() """); - } [Fact] public void TestUnderscorePropName() - { - Test(""" + => Test(""" @"{ _ : 0 }" """, """ @@ -2540,12 +2393,10 @@ public void TestUnderscorePropName() """); - } [Fact] public void TestStrangeLegalPropName() - { - Test(""" + => Test(""" @"{ 0$0 : 0 }" """, """ @@ -2575,12 +2426,10 @@ public void TestStrangeLegalPropName() """); - } [Fact] public void TestStrangeIllegalPropName() - { - Test(""" + => Test(""" @"{ 0(0 : 0 }" """, """ @@ -2622,12 +2471,10 @@ public void TestStrangeIllegalPropName() """); - } [Fact] public void TestStrangeIllegalPropName2() - { - Test(""" + => Test(""" @"{ 0%0 : 0 }" """, """ @@ -2661,12 +2508,10 @@ public void TestStrangeIllegalPropName2() """); - } [Fact] public void TestObjectWithEmptyPropValue1() - { - Test(""" + => Test(""" "{'first': , }" """, """ @@ -2697,12 +2542,10 @@ public void TestObjectWithEmptyPropValue1() """); - } [Fact] public void TestObjectWithEmptyPropValue2() - { - Test(""" + => Test(""" "{\"first\": , }" """, """ @@ -2733,12 +2576,10 @@ public void TestObjectWithEmptyPropValue2() """); - } [Fact] public void TestObjectWithEmptyPropValue3() - { - Test(""" + => Test(""" "{'first': }" """, """ @@ -2772,12 +2613,10 @@ public void TestObjectWithEmptyPropValue3() """); - } [Fact] public void TestObjectWithEmptyPropValue4() - { - Test(""" + => Test(""" "{\"first\": }" """, """ @@ -2811,12 +2650,10 @@ public void TestObjectWithEmptyPropValue4() """); - } [Fact] public void TestObjectWithEmptyPropValue5() - { - Test(""" + => Test(""" "{'first': " """, """ @@ -2850,12 +2687,10 @@ public void TestObjectWithEmptyPropValue5() """); - } [Fact] public void TestObjectWithEmptyPropValue6() - { - Test(""" + => Test(""" "{\"first\": " """, """ @@ -2889,12 +2724,10 @@ public void TestObjectWithEmptyPropValue6() """); - } [Fact] public void TestNestedProp1() - { - Test(""" + => Test(""" "{'first': 'second': 'third' }" """, """ @@ -2932,12 +2765,10 @@ public void TestNestedProp1() """); - } [Fact] public void TestNestedProp2() - { - Test(""" + => Test(""" "{\"first\": \"second\": \"third\" }" """, """ @@ -2975,12 +2806,10 @@ public void TestNestedProp2() """); - } [Fact] public void TestMultiItemList() - { - Test(""" + => Test(""" "[{ 'name': 'Admin' },{ 'name': 'Publisher' },1,null,[],,'string']" """, """ @@ -3061,12 +2890,10 @@ public void TestMultiItemList() """); - } [Fact] public void TestMultiItemList2() - { - Test(""" + => Test(""" "[{ \"name\": \"Admin\" },{ \"name\": \"Publisher\" },1,null,[],,\"string\"]" """, """ @@ -3147,12 +2974,10 @@ public void TestMultiItemList2() """); - } [Fact] public void TestMultiLine1() - { - Test(""" + => Test(""" @" {'a': 'bc','d':true @@ -3199,12 +3024,10 @@ public void TestMultiLine1() """); - } [Fact] public void TestMultiLine2() - { - Test(""" + => Test(""" @" {""a"": ""bc"",""d"":true @@ -3247,12 +3070,10 @@ public void TestMultiLine2() """, "", ""); - } [Fact] public void TestNestedObject() - { - Test(""" + => Test(""" @" { 'description': 'A person', @@ -3411,12 +3232,10 @@ public void TestNestedObject() """); - } [Fact] public void TestNestedObject1() - { - Test(""" + => Test(""" @" { ""description"": ""A person"", @@ -3571,12 +3390,10 @@ public void TestNestedObject1() """, "", ""); - } [Fact] public void TestLiterals1() - { - Test(""" + => Test(""" @"{ A: '', B: 1, C: , D: 1.23, E: 3.45, F: null }" """, """ @@ -3646,12 +3463,10 @@ public void TestLiterals1() """); - } [Fact] public void TestLiterals2() - { - Test(""""" + => Test(""""" @"{ ""A"": """", ""B"": 1, ""D"": 1.23, ""E"": 3.45, ""F"": null }" """"", """ @@ -3709,12 +3524,10 @@ public void TestLiterals2() """, "", ""); - } [Fact] public void TestLiterals3() - { - Test(""" + => Test(""" @"[ 1, 0, @@ -3911,12 +3724,10 @@ public void TestLiterals3() """, runLooseSubTreeCheck: false); - } [Fact] public void TestCommentsInArray() - { - Test(""" + => Test(""" @"[/*hi*/1/*hi*/,2/*hi*/]" """, """ @@ -3948,12 +3759,10 @@ public void TestCommentsInArray() """, runLooseSubTreeCheck: false); - } [Fact] public void TestUnicode2() - { - Test(""" + => Test(""" @"{'text':0xabcdef12345}" """, """ @@ -3983,12 +3792,10 @@ public void TestUnicode2() """); - } [Fact] public void TestUnicode3() - { - Test(""" + => Test(""" @"{""text"":0xabcdef12345}" """, """ @@ -4018,12 +3825,10 @@ public void TestUnicode3() """); - } [Fact] public void TestOctal1() - { - Test(""" + => Test(""" @"[0372, 0xFA, 0XFA]" """, """ @@ -4061,12 +3866,10 @@ public void TestOctal1() """); - } [Fact] public void TestOctal2() - { - Test(""" + => Test(""" @"[00]" """, """ @@ -4092,12 +3895,10 @@ public void TestOctal2() """); - } [Fact] public void TestOctal3() - { - Test(""" + => Test(""" @"[0F]" """, """ @@ -4127,12 +3928,10 @@ public void TestOctal3() """); - } [Fact] public void TestOctal4() - { - Test(""" + => Test(""" @"[07777777]" """, """ @@ -4158,12 +3957,10 @@ public void TestOctal4() """); - } [Fact] public void TestOctal5() - { - Test(""" + => Test(""" @"[0777777777777777]" """, """ @@ -4189,12 +3986,10 @@ public void TestOctal5() """); - } [Fact] public void TestOctal6() - { - Test(""" + => Test(""" @"[07777777777777777777777777777777]" """, """ @@ -4229,12 +4024,10 @@ public void TestOctal6() """); - } [Fact] public void TestOctal7() - { - Test(""" + => Test(""" @"[07]" """, """ @@ -4260,12 +4053,10 @@ public void TestOctal7() """); - } [Fact] public void TestOctal8() - { - Test(""" + => Test(""" @"[08]" """, """ @@ -4295,12 +4086,10 @@ public void TestOctal8() """); - } [Fact] public void TestObjectLiteralComments() - { - Test(""" + => Test(""" @"/*comment*/ { /*comment*/ 'Name': /*comment*/ 'Apple' /*comment*/, /*comment*/ 'ExpiryDate': '1', @@ -4425,12 +4214,10 @@ public void TestObjectLiteralComments() """, runLooseSubTreeCheck: false); - } [Fact] public void TestEmptyStrings() - { - Test(""" + => Test(""" @"['','','','','','','']" """, """ @@ -4492,12 +4279,10 @@ public void TestEmptyStrings() """); - } [Fact] public void TestEmptyStrings2() - { - Test(""""" + => Test(""""" @"["""","""","""","""","""","""",""""]" """"", """ @@ -4555,12 +4340,10 @@ public void TestEmptyStrings2() """, "", ""); - } [Fact] public void TestInvalidNumber() - { - Test(""" + => Test(""" @"0-10" """, """ @@ -4584,12 +4367,10 @@ public void TestInvalidNumber() """); - } [Fact] public void TestSimpleEscapes() - { - Test(""" + => Test(""" @"[false, true, true, false, 'test!', 1.11, 0e-10, 0E-10, 0.25e-5, 0.3e10, 6.0221418e23, 'Purple\r \n monkey\'s:\tdishwasher']" """, """ @@ -4681,12 +4462,10 @@ public void TestSimpleEscapes() """); - } [Fact] public void TestSimpleEscapes2() - { - Test(""" + => Test(""" @"[false, true, true, false, ""test!"", 1.11, 0e-10, 0E-10, 0.25e-5, 0.3e10, 6.0221418e23, ""Purple\r \n monkey\'s:\tdishwasher""]" """, """ @@ -4778,12 +4557,10 @@ public void TestSimpleEscapes2() """); - } [Fact] public void TestDoubleQuoteInSingleQuote() - { - Test(""" + => Test(""" @"'a""b'" """, """ @@ -4803,12 +4580,10 @@ public void TestDoubleQuoteInSingleQuote() """); - } [Fact] public void TestMultiLineString() - { - Test(""" + => Test(""" @"'a b'" """, """ @@ -4830,12 +4605,10 @@ public void TestMultiLineString() """); - } [Fact] public void TestMultiLineString2() - { - Test("""" + => Test("""" @"""a b""" """", """ @@ -4857,12 +4630,10 @@ public void TestMultiLineString2() """); - } [Fact] public void TestConstructor1() - { - Test(""" + => Test(""" @"new" """, """ @@ -4890,12 +4661,10 @@ public void TestConstructor1() """); - } [Fact] public void TestConstructor2() - { - Test(""" + => Test(""" @"new A" """, """ @@ -4923,12 +4692,10 @@ public void TestConstructor2() """); - } [Fact] public void TestConstructor3() - { - Test(""" + => Test(""" @"new A(" """, """ @@ -4956,12 +4723,10 @@ public void TestConstructor3() """); - } [Fact] public void TestConstructor4() - { - Test(""" + => Test(""" @"new A()" """, """ @@ -4985,12 +4750,10 @@ public void TestConstructor4() """); - } [Fact] public void TestConstructor5() - { - Test(""" + => Test(""" @"new A(1)" """, """ @@ -5018,12 +4781,10 @@ public void TestConstructor5() """); - } [Fact] public void TestConstructor6() - { - Test(""" + => Test(""" @"new A(1, 2)" """, """ @@ -5057,12 +4818,10 @@ public void TestConstructor6() """); - } [Fact] public void TestConstructor7() - { - Test(""" + => Test(""" @"new A([new B()])" """, """ @@ -5100,12 +4859,10 @@ public void TestConstructor7() """); - } [Fact] public void TestConstructor8() - { - Test(""" + => Test(""" @"new A(,)" """, """ @@ -5133,12 +4890,10 @@ public void TestConstructor8() """); - } [Fact] public void TestConstructor9() - { - Test(""" + => Test(""" @"new A(1,)" """, """ @@ -5169,12 +4924,10 @@ public void TestConstructor9() """); - } [Fact] public void TestConstructor10() - { - Test(""" + => Test(""" @"new A(,1)" """, """ @@ -5205,12 +4958,10 @@ public void TestConstructor10() """); - } [Fact] public void TestConstructor11() - { - Test(""" + => Test(""" @"new A(1,1)" """, """ @@ -5244,12 +4995,10 @@ public void TestConstructor11() """); - } [Fact] public void TestConstructor12() - { - Test(""" + => Test(""" @"new A(1,,1)" """, """ @@ -5286,12 +5035,10 @@ public void TestConstructor12() """); - } [Fact] public void TestConstructor13() - { - Test(""" + => Test(""" @"new %()" """, """ @@ -5319,12 +5066,10 @@ public void TestConstructor13() """); - } [Fact] public void TestConstructor14() - { - Test(""" + => Test(""" @"new A(1 2)" """, """ @@ -5359,12 +5104,10 @@ public void TestConstructor14() """); - } [Fact] public void TestMultipleCommasInObject() - { - Test(""" + => Test(""" @"{0:0,,1:1}" """, """ @@ -5410,12 +5153,10 @@ public void TestMultipleCommasInObject() """); - } [Fact] public void TestSimpleEscapes3() - { - Test(""" + => Test(""" @" ""\r\n\f\t\b"" " """, """ @@ -5434,12 +5175,10 @@ public void TestSimpleEscapes3() """, "", ""); - } [Fact] public void TestSimpleEscapes4() - { - Test(""" + => Test(""" @" ""\m"" " """, """ @@ -5466,12 +5205,10 @@ public void TestSimpleEscapes4() """); - } [Fact] public void TestSimpleEscapes5() - { - Test(""""" + => Test(""""" @" ""\\\/\"""" " """"", """ @@ -5490,12 +5227,10 @@ public void TestSimpleEscapes5() """, "", ""); - } [Fact] public void TestSimpleEscapes6() - { - Test(""" + => Test(""" @" ""\'"" " """, """ @@ -5518,12 +5253,10 @@ public void TestSimpleEscapes6() """); - } [Fact] public void TestSimpleEscapes7() - { - Test(""" + => Test(""" @" '\'' " """, """ @@ -5546,12 +5279,10 @@ public void TestSimpleEscapes7() """); - } [Fact] public void TestSimpleEscapes8() - { - Test(""" + => Test(""" @" '\""' " """, """ @@ -5574,12 +5305,10 @@ public void TestSimpleEscapes8() """); - } [Fact] public void TestPropertyInArray1() - { - Test(""" + => Test(""" @" [""a"": 0] " """, """ @@ -5616,12 +5345,10 @@ public void TestPropertyInArray1() """); - } [Fact] public void TestSimpleNumber1() - { - Test(""" + => Test(""" @"0.0" """, """ @@ -5637,12 +5364,10 @@ public void TestSimpleNumber1() """, "", ""); - } [Fact] public void TestSimpleNumber2() - { - Test(""" + => Test(""" @"-0.0" """, """ @@ -5658,12 +5383,10 @@ public void TestSimpleNumber2() """, "", ""); - } [Fact] public void TestSimpleNumber3() - { - Test(""" + => Test(""" @".0" """, """ @@ -5683,12 +5406,10 @@ public void TestSimpleNumber3() """); - } [Fact] public void TestSimpleNumber4() - { - Test(""" + => Test(""" @"-.0" """, """ @@ -5708,12 +5429,10 @@ public void TestSimpleNumber4() """); - } [Fact] public void TestStandaloneMinus() - { - Test(""" + => Test(""" @"-" """, """ @@ -5737,12 +5456,10 @@ public void TestStandaloneMinus() """); - } [Fact] public void TestMinusDot() - { - Test(""" + => Test(""" @"-." """, """ @@ -5766,12 +5483,10 @@ public void TestMinusDot() """); - } [Fact] public void TestNumber1() - { - Test(""" + => Test(""" @"0" """, """ @@ -5787,12 +5502,10 @@ public void TestNumber1() """, "", ""); - } [Fact] public void TestNumber2() - { - Test(""" + => Test(""" @"-0" """, """ @@ -5808,12 +5521,10 @@ public void TestNumber2() """, "", ""); - } [Fact] public void TestNumber3() - { - Test(""" + => Test(""" @"00" """, """ @@ -5833,12 +5544,10 @@ public void TestNumber3() """); - } [Fact] public void TestNumber4() - { - Test(""" + => Test(""" @"-00" """, """ @@ -5858,12 +5567,10 @@ public void TestNumber4() """); - } [Fact] public void TestNumber5() - { - Test(""" + => Test(""" @"0." """, """ @@ -5883,12 +5590,10 @@ public void TestNumber5() """); - } [Fact] public void TestNumber6() - { - Test(""" + => Test(""" @"-0." """, """ @@ -5908,12 +5613,10 @@ public void TestNumber6() """); - } [Fact] public void TestNumber7() - { - Test(""" + => Test(""" @"0e" """, """ @@ -5937,12 +5640,10 @@ public void TestNumber7() """); - } [Fact] public void TestNumber8() - { - Test(""" + => Test(""" @"-0e" """, """ @@ -5966,12 +5667,10 @@ public void TestNumber8() """); - } [Fact] public void TestNumber9() - { - Test(""" + => Test(""" @"0e0" """, """ @@ -5987,12 +5686,10 @@ public void TestNumber9() """, "", ""); - } [Fact] public void TestNumber10() - { - Test(""" + => Test(""" @"-0e0" """, """ @@ -6008,12 +5705,10 @@ public void TestNumber10() """, "", ""); - } [Fact] public void TestNumber11() - { - Test(""" + => Test(""" @"0e1" """, """ @@ -6029,12 +5724,10 @@ public void TestNumber11() """, "", ""); - } [Fact] public void TestNumber12() - { - Test(""" + => Test(""" @"-0e1" """, """ @@ -6050,12 +5743,10 @@ public void TestNumber12() """, "", ""); - } [Fact] public void TestNumber13() - { - Test(""" + => Test(""" @"0e-1" """, """ @@ -6071,12 +5762,10 @@ public void TestNumber13() """, "", ""); - } [Fact] public void TestNumber14() - { - Test(""" + => Test(""" @"-0e-1" """, """ @@ -6092,12 +5781,10 @@ public void TestNumber14() """, "", ""); - } [Fact] public void TestNumber15() - { - Test(""" + => Test(""" @"0e+1" """, """ @@ -6113,12 +5800,10 @@ public void TestNumber15() """, "", ""); - } [Fact] public void TestNumber16() - { - Test(""" + => Test(""" @"-0e+1" """, """ @@ -6134,12 +5819,10 @@ public void TestNumber16() """, "", ""); - } [Fact] public void TestNumber17() - { - Test(""" + => Test(""" @"--0" """, """ @@ -6163,12 +5846,10 @@ public void TestNumber17() """); - } [Fact] public void TestNumber18() - { - Test(""" + => Test(""" @"+0" """, """ @@ -6192,12 +5873,10 @@ public void TestNumber18() """); - } [Fact] public void TestNumber19() - { - Test(""" + => Test(""" @"0..0" """, """ @@ -6221,12 +5900,10 @@ public void TestNumber19() """); - } [Fact] public void TestNumber20() - { - Test(""" + => Test(""" @"0ee0" """, """ @@ -6250,12 +5927,10 @@ public void TestNumber20() """); - } [Fact] public void TestNumber21() - { - Test(""" + => Test(""" @"1e++1" """, """ @@ -6279,12 +5954,10 @@ public void TestNumber21() """); - } [Fact] public void TestNumber22() - { - Test(""" + => Test(""" @"1e--1" """, """ @@ -6308,12 +5981,10 @@ public void TestNumber22() """); - } [Fact] public void TestNumber23() - { - Test(""" + => Test(""" @"1e+-1" """, """ @@ -6337,12 +6008,10 @@ public void TestNumber23() """); - } [Fact] public void TestNumber24() - { - Test(""" + => Test(""" @"1e-+1" """, """ @@ -6366,12 +6035,10 @@ public void TestNumber24() """); - } [Fact] public void TestNumber25() - { - Test(""" + => Test(""" @"1e1.0" """, """ @@ -6395,12 +6062,10 @@ public void TestNumber25() """); - } [Fact] public void TestNumber26() - { - Test(""" + => Test(""" @"1e+1.1" """, """ @@ -6424,12 +6089,10 @@ public void TestNumber26() """); - } [Fact] public void TestNumber27() - { - Test(""" + => Test(""" @"1-1" """, """ @@ -6453,12 +6116,10 @@ public void TestNumber27() """); - } [Fact] public void TestNumber28() - { - Test(""" + => Test(""" @"1+1" """, """ @@ -6482,12 +6143,10 @@ public void TestNumber28() """); - } [Fact] public void TestIncompleteProperty() - { - Test(""" + => Test(""" "{ 'a': }" """, """ @@ -6521,12 +6180,10 @@ public void TestIncompleteProperty() """); - } [Fact] public void TestPropertyWithCommaFollowedByComma() - { - Test(""" + => Test(""" "{ 'a': , , }" """, """ @@ -6564,12 +6221,10 @@ public void TestPropertyWithCommaFollowedByComma() """); - } [Fact] public void TestTopLevelProperty() - { - Test(""" + => Test(""" "'a': 0" """, """ @@ -6597,12 +6252,10 @@ public void TestTopLevelProperty() """); - } [Fact] public void TestTopLevelConstructor() - { - Test(""" + => Test(""" "new Date()" """, """ @@ -6626,12 +6279,10 @@ public void TestTopLevelConstructor() """); - } [Fact] public void TestTopLevelText() - { - Test(""" + => Test(""" "Date" """, """ @@ -6655,12 +6306,10 @@ public void TestTopLevelText() """); - } [Fact] public void TestNestedArrays1() - { - Test(""" + => Test(""" "[1, [2, [3, [4]]]]" """, """ @@ -6718,12 +6367,10 @@ public void TestNestedArrays1() """, "", ""); - } [Fact] public void TestNestedArraysTrailingCommas1() - { - Test(""" + => Test(""" "[1, [2, [3, [4,],],],]" """, """ @@ -6797,12 +6444,10 @@ public void TestNestedArraysTrailingCommas1() """); - } [Fact] public void TestBogusNesting1() - { - Test(""" + => Test(""" "[1, [2, [3, [4}}}}" """, """ @@ -6880,12 +6525,10 @@ public void TestBogusNesting1() """); - } [Fact] public void TestBogusNesting2() - { - Test(""" + => Test(""" "[1, [2, [3, [4}]}]" """, """ @@ -6957,12 +6600,10 @@ public void TestBogusNesting2() """); - } [Fact] public void TestBogusNesting3() - { - Test(""" + => Test(""" "{1, {2, {3, {4]]]]" """, """ @@ -7038,12 +6679,10 @@ public void TestBogusNesting3() """); - } [Fact] public void TestBogusNesting4() - { - Test(""" + => Test(""" "[1, {2, [3, {4]]]]" """, """ @@ -7113,12 +6752,10 @@ public void TestBogusNesting4() """); - } [Fact] public void TestBogusNesting5() - { - Test(""" + => Test(""" "[1, {2, [3, {4]}]}" """, """ @@ -7185,12 +6822,10 @@ public void TestBogusNesting5() """); - } [Fact] public void TestBogusNesting6() - { - Test(""" + => Test(""" "[1, {2, [3, {4}]}]" """, """ @@ -7254,12 +6889,10 @@ public void TestBogusNesting6() """); - } [Fact] public void TestIntegerPropertyName() - { - Test(""" + => Test(""" "{ 0: true }" """, expected: """ @@ -7289,12 +6922,10 @@ public void TestIntegerPropertyName() """); - } [Fact] public void TestColonPropertyName() - { - Test(""" + => Test(""" "{ :: true }" """, expected: """ @@ -7328,12 +6959,10 @@ public void TestColonPropertyName() """); - } [Fact, WorkItem("https://devdiv.visualstudio.com/DevDiv/_queries/edit/1691963")] public void TestAllColons_BecomesNestedProperties() - { - Test(""" + => Test(""" "::::::::" """, expected: """ @@ -7373,5 +7002,4 @@ public void TestAllColons_BecomesNestedProperties() """); - } } diff --git a/src/EditorFeatures/CSharpTest2/EmbeddedLanguages/Json/CSharpJsonParserTests_NstTests.cs b/src/EditorFeatures/CSharpTest2/EmbeddedLanguages/Json/CSharpJsonParserTests_NstTests.cs index 680c428f8180..9498de0a5f4d 100644 --- a/src/EditorFeatures/CSharpTest2/EmbeddedLanguages/Json/CSharpJsonParserTests_NstTests.cs +++ b/src/EditorFeatures/CSharpTest2/EmbeddedLanguages/Json/CSharpJsonParserTests_NstTests.cs @@ -57,8 +57,7 @@ private void TestNST( [Fact] public void i_number_double_huge_neg_exp_json() - { - TestNST(""" + => TestNST(""" @"[123.456e-789]" """, """ @@ -80,12 +79,10 @@ public void i_number_double_huge_neg_exp_json() """, @"", @""); - } [Fact] public void i_number_huge_exp_json() - { - TestNST(""" + => TestNST(""" @"[0.4e00669999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999969999999006]" """, """ @@ -111,12 +108,10 @@ public void i_number_huge_exp_json() """, @""); - } [Fact] public void i_number_neg_int_huge_exp_json() - { - TestNST(""" + => TestNST(""" @"[-1e+9999]" """, """ @@ -142,12 +137,10 @@ public void i_number_neg_int_huge_exp_json() """, @""); - } [Fact] public void i_number_pos_double_huge_exp_json() - { - TestNST(""" + => TestNST(""" @"[1.5e+9999]" """, """ @@ -173,12 +166,10 @@ public void i_number_pos_double_huge_exp_json() """, @""); - } [Fact] public void i_number_real_neg_overflow_json() - { - TestNST(""" + => TestNST(""" @"[-123123e100000]" """, """ @@ -204,12 +195,10 @@ public void i_number_real_neg_overflow_json() """, @""); - } [Fact] public void i_number_real_pos_overflow_json() - { - TestNST(""" + => TestNST(""" @"[123123e100000]" """, """ @@ -235,12 +224,10 @@ public void i_number_real_pos_overflow_json() """, @""); - } [Fact] public void i_number_real_underflow_json() - { - TestNST(""" + => TestNST(""" @"[123e-10000000]" """, """ @@ -262,12 +249,10 @@ public void i_number_real_underflow_json() """, @"", @""); - } [Fact] public void i_number_too_big_neg_int_json() - { - TestNST(""" + => TestNST(""" @"[-123123123123123123123123123123]" """, """ @@ -289,12 +274,10 @@ public void i_number_too_big_neg_int_json() """, @"", @""); - } [Fact] public void i_number_too_big_pos_int_json() - { - TestNST(""" + => TestNST(""" @"[100000000000000000000]" """, """ @@ -316,12 +299,10 @@ public void i_number_too_big_pos_int_json() """, @"", @""); - } [Fact] public void i_number_very_big_negative_int_json() - { - TestNST(""" + => TestNST(""" @"[-237462374673276894279832749832423479823246327846]" """, """ @@ -343,12 +324,10 @@ public void i_number_very_big_negative_int_json() """, @"", @""); - } [Fact] public void i_object_key_lone_2nd_surrogate_json() - { - TestNST(""" + => TestNST(""" @"{""\uDFAA"":0}" """, """ @@ -374,12 +353,10 @@ public void i_object_key_lone_2nd_surrogate_json() """, @"", @""); - } [Fact] public void i_string_1st_surrogate_but_2nd_missing_json() - { - TestNST(""" + => TestNST(""" @"[""\uDADA""]" """, """ @@ -401,12 +378,10 @@ public void i_string_1st_surrogate_but_2nd_missing_json() """, @"", @""); - } [Fact] public void i_string_1st_valid_surrogate_2nd_invalid_json() - { - TestNST(""" + => TestNST(""" @"[""\uD888\u1234""]" """, """ @@ -428,12 +403,10 @@ public void i_string_1st_valid_surrogate_2nd_invalid_json() """, @"", @""); - } [Fact] public void i_string_incomplete_surrogates_escape_valid_json() - { - TestNST(""" + => TestNST(""" @"[""\uD800\uD800\n""]" """, """ @@ -455,12 +428,10 @@ public void i_string_incomplete_surrogates_escape_valid_json() """, @"", @""); - } [Fact] public void i_string_incomplete_surrogate_and_escape_valid_json() - { - TestNST(""" + => TestNST(""" @"[""\uD800\n""]" """, """ @@ -482,12 +453,10 @@ public void i_string_incomplete_surrogate_and_escape_valid_json() """, @"", @""); - } [Fact] public void i_string_incomplete_surrogate_pair_json() - { - TestNST(""" + => TestNST(""" @"[""\uDd1ea""]" """, """ @@ -509,12 +478,10 @@ public void i_string_incomplete_surrogate_pair_json() """, @"", @""); - } [Fact] public void i_string_invalid_lonely_surrogate_json() - { - TestNST(""" + => TestNST(""" @"[""\ud800""]" """, """ @@ -536,12 +503,10 @@ public void i_string_invalid_lonely_surrogate_json() """, @"", @""); - } [Fact] public void i_string_invalid_surrogate_json() - { - TestNST(""" + => TestNST(""" @"[""\ud800abc""]" """, """ @@ -563,12 +528,10 @@ public void i_string_invalid_surrogate_json() """, @"", @""); - } [Fact] public void i_string_invalid_utf_8_json() - { - TestNST(""" + => TestNST(""" @"[""�""]" """, """ @@ -590,12 +553,10 @@ public void i_string_invalid_utf_8_json() """, @"", @""); - } [Fact] public void i_string_inverted_surrogates_U_1D11E_json() - { - TestNST(""" + => TestNST(""" @"[""\uDd1e\uD834""]" """, """ @@ -617,12 +578,10 @@ public void i_string_inverted_surrogates_U_1D11E_json() """, @"", @""); - } [Fact] public void i_string_iso_latin_1_json() - { - TestNST(""" + => TestNST(""" @"[""�""]" """, """ @@ -644,12 +603,10 @@ public void i_string_iso_latin_1_json() """, @"", @""); - } [Fact] public void i_string_lone_second_surrogate_json() - { - TestNST(""" + => TestNST(""" @"[""\uDFAA""]" """, """ @@ -671,12 +628,10 @@ public void i_string_lone_second_surrogate_json() """, @"", @""); - } [Fact] public void i_string_lone_utf8_continuation_byte_json() - { - TestNST(""" + => TestNST(""" @"[""�""]" """, """ @@ -698,12 +653,10 @@ public void i_string_lone_utf8_continuation_byte_json() """, @"", @""); - } [Fact] public void i_string_not_in_unicode_range_json() - { - TestNST(""" + => TestNST(""" @"[""���""]" """, """ @@ -725,12 +678,10 @@ public void i_string_not_in_unicode_range_json() """, @"", @""); - } [Fact] public void i_string_overlong_sequence_2_bytes_json() - { - TestNST(""" + => TestNST(""" @"[""��""]" """, """ @@ -752,12 +703,10 @@ public void i_string_overlong_sequence_2_bytes_json() """, @"", @""); - } [Fact] public void i_string_overlong_sequence_6_bytes_json() - { - TestNST(""" + => TestNST(""" @"[""������""]" """, """ @@ -779,12 +728,10 @@ public void i_string_overlong_sequence_6_bytes_json() """, @"", @""); - } [Fact] public void i_string_overlong_sequence_6_bytes_null_json() - { - TestNST(""" + => TestNST(""" @"[""������""]" """, """ @@ -806,12 +753,10 @@ public void i_string_overlong_sequence_6_bytes_null_json() """, @"", @""); - } [Fact] public void i_string_truncated_utf_8_json() - { - TestNST(""" + => TestNST(""" @"[""��""]" """, """ @@ -833,12 +778,10 @@ public void i_string_truncated_utf_8_json() """, @"", @""); - } [Fact] public void i_string_UTF_16LE_with_BOM_json() - { - TestNST(""" + => TestNST(""" @"[""é""]" """, """ @@ -860,12 +803,10 @@ public void i_string_UTF_16LE_with_BOM_json() """, @"", @""); - } [Fact] public void i_string_UTF_8_invalid_sequence_json() - { - TestNST(""" + => TestNST(""" @"[""日ш�""]" """, """ @@ -887,12 +828,10 @@ public void i_string_UTF_8_invalid_sequence_json() """, @"", @""); - } [Fact] public void i_string_Utf8_surrogate_U_D800_json() - { - TestNST(""" + => TestNST(""" @"[""��""]" """, """ @@ -914,12 +853,10 @@ public void i_string_Utf8_surrogate_U_D800_json() """, @"", @""); - } [Fact] public void i_structure_UTF_8_BOM_empty_object_json() - { - TestNST(""" + => TestNST(""" @"{}" """, """ @@ -937,12 +874,10 @@ public void i_structure_UTF_8_BOM_empty_object_json() """, @"", @""); - } [Fact] public void n_array_1_true_without_comma_json() - { - TestNST(""" + => TestNST(""" @"[1 true]" """, """ @@ -975,12 +910,10 @@ public void n_array_1_true_without_comma_json() """); - } [Fact] public void n_array_a_invalid_utf8_json() - { - TestNST(""" + => TestNST(""" @"[a�]" """, """ @@ -1010,12 +943,10 @@ public void n_array_a_invalid_utf8_json() """); - } [Fact] public void n_array_colon_instead_of_comma_json() - { - TestNST(""""" + => TestNST(""""" @"["""": 1]" """"", """ @@ -1049,12 +980,10 @@ public void n_array_colon_instead_of_comma_json() """); - } [Fact] public void n_array_comma_after_close_json() - { - TestNST(""""" + => TestNST(""""" @"[""""]," """"", """ @@ -1087,12 +1016,10 @@ public void n_array_comma_after_close_json() """); - } [Fact] public void n_array_comma_and_number_json() - { - TestNST(""" + => TestNST(""" @"[,1]" """, """ @@ -1121,12 +1048,10 @@ public void n_array_comma_and_number_json() """); - } [Fact] public void n_array_double_comma_json() - { - TestNST(""" + => TestNST(""" @"[1,,2]" """, """ @@ -1161,12 +1086,10 @@ public void n_array_double_comma_json() """); - } [Fact] public void n_array_double_extra_comma_json() - { - TestNST(""" + => TestNST(""" @"[""x"",,]" """, """ @@ -1198,12 +1121,10 @@ public void n_array_double_extra_comma_json() """); - } [Fact] public void n_array_extra_close_json() - { - TestNST(""" + => TestNST(""" @"[""x""]]" """, """ @@ -1236,12 +1157,10 @@ public void n_array_extra_close_json() """); - } [Fact] public void n_array_extra_comma_json() - { - TestNST(""""" + => TestNST(""""" @"["""",]" """"", """ @@ -1270,12 +1189,10 @@ public void n_array_extra_comma_json() """); - } [Fact] public void n_array_incomplete_json() - { - TestNST("""" + => TestNST("""" @"[""x""" """", """ @@ -1305,12 +1222,10 @@ public void n_array_incomplete_json() """); - } [Fact] public void n_array_incomplete_invalid_value_json() - { - TestNST(""" + => TestNST(""" @"[x" """, """ @@ -1340,12 +1255,10 @@ public void n_array_incomplete_invalid_value_json() """); - } [Fact] public void n_array_inner_array_no_comma_json() - { - TestNST(""" + => TestNST(""" @"[3[4]]" """, """ @@ -1384,12 +1297,10 @@ public void n_array_inner_array_no_comma_json() """); - } [Fact] public void n_array_invalid_utf8_json() - { - TestNST(""" + => TestNST(""" @"[�]" """, """ @@ -1419,12 +1330,10 @@ public void n_array_invalid_utf8_json() """); - } [Fact] public void n_array_items_separated_by_semicolon_json() - { - TestNST(""" + => TestNST(""" @"[1:2]" """, """ @@ -1458,12 +1367,10 @@ public void n_array_items_separated_by_semicolon_json() """); - } [Fact] public void n_array_just_comma_json() - { - TestNST(""" + => TestNST(""" @"[,]" """, """ @@ -1489,12 +1396,10 @@ public void n_array_just_comma_json() """); - } [Fact] public void n_array_just_minus_json() - { - TestNST(""" + => TestNST(""" @"[-]" """, """ @@ -1524,12 +1429,10 @@ public void n_array_just_minus_json() """); - } [Fact] public void n_array_missing_value_json() - { - TestNST(""""" + => TestNST(""""" @"[ , """"]" """"", """ @@ -1558,12 +1461,10 @@ public void n_array_missing_value_json() """); - } [Fact] public void n_array_newlines_unclosed_json() - { - TestNST(""" + => TestNST(""" @"[""a"", 4 ,1," @@ -1612,12 +1513,10 @@ public void n_array_newlines_unclosed_json() """); - } [Fact] public void n_array_number_and_comma_json() - { - TestNST(""" + => TestNST(""" @"[1,]" """, """ @@ -1646,12 +1545,10 @@ public void n_array_number_and_comma_json() """); - } [Fact] public void n_array_number_and_several_commas_json() - { - TestNST(""" + => TestNST(""" @"[1,,]" """, """ @@ -1683,12 +1580,10 @@ public void n_array_number_and_several_commas_json() """); - } [Fact] public void n_array_star_inside_json() - { - TestNST(""" + => TestNST(""" @"[*]" """, """ @@ -1718,12 +1613,10 @@ public void n_array_star_inside_json() """); - } [Fact] public void n_array_unclosed_json() - { - TestNST("""""" + => TestNST("""""" @"[""""" """""", """ @@ -1753,12 +1646,10 @@ public void n_array_unclosed_json() """); - } [Fact] public void n_array_unclosed_trailing_comma_json() - { - TestNST(""" + => TestNST(""" @"[1," """, """ @@ -1791,12 +1682,10 @@ public void n_array_unclosed_trailing_comma_json() """); - } [Fact] public void n_array_unclosed_with_new_lines_json() - { - TestNST(""" + => TestNST(""" @"[1, 1 ,1" @@ -1842,12 +1731,10 @@ public void n_array_unclosed_with_new_lines_json() """); - } [Fact] public void n_array_unclosed_with_object_inside_json() - { - TestNST(""" + => TestNST(""" @"[{}" """, """ @@ -1879,12 +1766,10 @@ public void n_array_unclosed_with_object_inside_json() """); - } [Fact] public void n_incomplete_false_json() - { - TestNST(""" + => TestNST(""" @"[fals]" """, """ @@ -1914,12 +1799,10 @@ public void n_incomplete_false_json() """); - } [Fact] public void n_incomplete_null_json() - { - TestNST(""" + => TestNST(""" @"[nul]" """, """ @@ -1949,12 +1832,10 @@ public void n_incomplete_null_json() """); - } [Fact] public void n_incomplete_true_json() - { - TestNST(""" + => TestNST(""" @"[tru]" """, """ @@ -1984,12 +1865,10 @@ public void n_incomplete_true_json() """); - } [Fact] public void n_number____json() - { - TestNST(""" + => TestNST(""" @"[++1234]" """, """ @@ -2019,12 +1898,10 @@ public void n_number____json() """); - } [Fact] public void n_number__1_json() - { - TestNST(""" + => TestNST(""" @"[+1]" """, """ @@ -2054,12 +1931,10 @@ public void n_number__1_json() """); - } [Fact] public void n_number__Inf_json() - { - TestNST(""" + => TestNST(""" @"[+Inf]" """, """ @@ -2089,12 +1964,10 @@ public void n_number__Inf_json() """); - } [Fact] public void n_number__01_json() - { - TestNST(""" + => TestNST(""" @"[-01]" """, """ @@ -2120,12 +1993,10 @@ public void n_number__01_json() """); - } [Fact] public void n_number__1_0__json() - { - TestNST(""" + => TestNST(""" @"[-1.0.]" """, """ @@ -2155,12 +2026,10 @@ public void n_number__1_0__json() """); - } [Fact] public void n_number__2__json() - { - TestNST(""" + => TestNST(""" @"[-2.]" """, """ @@ -2186,12 +2055,10 @@ public void n_number__2__json() """); - } [Fact] public void n_number__NaN_json() - { - TestNST(""" + => TestNST(""" @"[-NaN]" """, """ @@ -2221,12 +2088,10 @@ public void n_number__NaN_json() """); - } [Fact] public void n_number___1_json() - { - TestNST(""" + => TestNST(""" @"[.-1]" """, """ @@ -2256,12 +2121,10 @@ public void n_number___1_json() """); - } [Fact] public void n_number__2e_3_json() - { - TestNST(""" + => TestNST(""" @"[.2e-3]" """, """ @@ -2287,12 +2150,10 @@ public void n_number__2e_3_json() """); - } [Fact] public void n_number_0_1_2_json() - { - TestNST(""" + => TestNST(""" @"[0.1.2]" """, """ @@ -2322,12 +2183,10 @@ public void n_number_0_1_2_json() """); - } [Fact] public void n_number_0_3e__json() - { - TestNST(""" + => TestNST(""" @"[0.3e+]" """, """ @@ -2357,12 +2216,10 @@ public void n_number_0_3e__json() """); - } [Fact] public void n_number_0_3e_json() - { - TestNST(""" + => TestNST(""" @"[0.3e]" """, """ @@ -2392,12 +2249,10 @@ public void n_number_0_3e_json() """); - } [Fact] public void n_number_0_e1_json() - { - TestNST(""" + => TestNST(""" @"[0.e1]" """, """ @@ -2423,12 +2278,10 @@ public void n_number_0_e1_json() """); - } [Fact] public void n_number_0e__json() - { - TestNST(""" + => TestNST(""" @"[0e+]" """, """ @@ -2458,12 +2311,10 @@ public void n_number_0e__json() """); - } [Fact] public void n_number_0e_json() - { - TestNST(""" + => TestNST(""" @"[0e]" """, """ @@ -2493,12 +2344,10 @@ public void n_number_0e_json() """); - } [Fact] public void n_number_0_capital_E__json() - { - TestNST(""" + => TestNST(""" @"[0E+]" """, """ @@ -2528,12 +2377,10 @@ public void n_number_0_capital_E__json() """); - } [Fact] public void n_number_0_capital_E_json() - { - TestNST(""" + => TestNST(""" @"[0E]" """, """ @@ -2563,12 +2410,10 @@ public void n_number_0_capital_E_json() """); - } [Fact] public void n_number_1_0e__json() - { - TestNST(""" + => TestNST(""" @"[1.0e+]" """, """ @@ -2598,12 +2443,10 @@ public void n_number_1_0e__json() """); - } [Fact] public void n_number_1_0e_json() - { - TestNST(""" + => TestNST(""" @"[1.0e]" """, """ @@ -2633,12 +2476,10 @@ public void n_number_1_0e_json() """); - } [Fact] public void n_number_1eE2_json() - { - TestNST(""" + => TestNST(""" @"[1eE2]" """, """ @@ -2668,12 +2509,10 @@ public void n_number_1eE2_json() """); - } [Fact] public void n_number_1_000_json() - { - TestNST(""" + => TestNST(""" @"[1 000.0]" """, """ @@ -2706,12 +2545,10 @@ public void n_number_1_000_json() """); - } [Fact] public void n_number_2_e_3_json() - { - TestNST(""" + => TestNST(""" @"[2.e+3]" """, """ @@ -2737,12 +2574,10 @@ public void n_number_2_e_3_json() """); - } [Fact] public void n_number_2_e3_json() - { - TestNST(""" + => TestNST(""" @"[2.e3]" """, """ @@ -2768,12 +2603,10 @@ public void n_number_2_e3_json() """); - } [Fact] public void n_number_9_e__json() - { - TestNST(""" + => TestNST(""" @"[9.e+]" """, """ @@ -2803,12 +2636,10 @@ public void n_number_9_e__json() """); - } [Fact] public void n_number_expression_json() - { - TestNST(""" + => TestNST(""" @"[1+2]" """, """ @@ -2838,12 +2669,10 @@ public void n_number_expression_json() """); - } [Fact] public void n_number_hex_1_digit_json() - { - TestNST(""" + => TestNST(""" @"[0x1]" """, """ @@ -2869,12 +2698,10 @@ public void n_number_hex_1_digit_json() """); - } [Fact] public void n_number_hex_2_digits_json() - { - TestNST(""" + => TestNST(""" @"[0x42]" """, """ @@ -2900,12 +2727,10 @@ public void n_number_hex_2_digits_json() """); - } [Fact] public void n_number_Inf_json() - { - TestNST(""" + => TestNST(""" @"[Inf]" """, """ @@ -2935,12 +2760,10 @@ public void n_number_Inf_json() """); - } [Fact] public void n_number_infinity_json() - { - TestNST(""" + => TestNST(""" @"[Infinity]" """, """ @@ -2966,12 +2789,10 @@ public void n_number_infinity_json() """); - } [Fact] public void n_number_invalid___json() - { - TestNST(""" + => TestNST(""" @"[0e+-1]" """, """ @@ -3001,12 +2822,10 @@ public void n_number_invalid___json() """); - } [Fact] public void n_number_invalid_negative_real_json() - { - TestNST(""" + => TestNST(""" @"[-123.123foo]" """, """ @@ -3036,12 +2855,10 @@ public void n_number_invalid_negative_real_json() """); - } [Fact] public void n_number_invalid_utf_8_in_bigger_int_json() - { - TestNST(""" + => TestNST(""" @"[123�]" """, """ @@ -3071,12 +2888,10 @@ public void n_number_invalid_utf_8_in_bigger_int_json() """); - } [Fact] public void n_number_invalid_utf_8_in_exponent_json() - { - TestNST(""" + => TestNST(""" @"[1e1�]" """, """ @@ -3106,12 +2921,10 @@ public void n_number_invalid_utf_8_in_exponent_json() """); - } [Fact] public void n_number_invalid_utf_8_in_int_json() - { - TestNST(""" + => TestNST(""" @"[0�] " """, """ @@ -3143,12 +2956,10 @@ public void n_number_invalid_utf_8_in_int_json() """); - } [Fact] public void n_number_minus_infinity_json() - { - TestNST(""" + => TestNST(""" @"[-Infinity]" """, """ @@ -3175,12 +2986,10 @@ public void n_number_minus_infinity_json() """); - } [Fact] public void n_number_minus_sign_with_trailing_garbage_json() - { - TestNST(""" + => TestNST(""" @"[-foo]" """, """ @@ -3210,12 +3019,10 @@ public void n_number_minus_sign_with_trailing_garbage_json() """); - } [Fact] public void n_number_minus_space_1_json() - { - TestNST(""" + => TestNST(""" @"[- 1]" """, """ @@ -3248,12 +3055,10 @@ public void n_number_minus_space_1_json() """); - } [Fact] public void n_number_NaN_json() - { - TestNST(""" + => TestNST(""" @"[NaN]" """, """ @@ -3279,12 +3084,10 @@ public void n_number_NaN_json() """); - } [Fact] public void n_number_neg_int_starting_with_zero_json() - { - TestNST(""" + => TestNST(""" @"[-012]" """, """ @@ -3310,12 +3113,10 @@ public void n_number_neg_int_starting_with_zero_json() """); - } [Fact] public void n_number_neg_real_without_int_part_json() - { - TestNST(""" + => TestNST(""" @"[-.123]" """, """ @@ -3341,12 +3142,10 @@ public void n_number_neg_real_without_int_part_json() """); - } [Fact] public void n_number_neg_with_garbage_at_end_json() - { - TestNST(""" + => TestNST(""" @"[-1x]" """, """ @@ -3376,12 +3175,10 @@ public void n_number_neg_with_garbage_at_end_json() """); - } [Fact] public void n_number_real_garbage_after_e_json() - { - TestNST(""" + => TestNST(""" @"[1ea]" """, """ @@ -3411,12 +3208,10 @@ public void n_number_real_garbage_after_e_json() """); - } [Fact] public void n_number_real_without_fractional_part_json() - { - TestNST(""" + => TestNST(""" @"[1.]" """, """ @@ -3442,12 +3237,10 @@ public void n_number_real_without_fractional_part_json() """); - } [Fact] public void n_number_real_with_invalid_utf8_after_e_json() - { - TestNST(""" + => TestNST(""" @"[1e�]" """, """ @@ -3477,12 +3270,10 @@ public void n_number_real_with_invalid_utf8_after_e_json() """); - } [Fact] public void n_number_starting_with_dot_json() - { - TestNST(""" + => TestNST(""" @"[.123]" """, """ @@ -3508,12 +3299,10 @@ public void n_number_starting_with_dot_json() """); - } [Fact] public void n_number_U_FF11_fullwidth_digit_one_json() - { - TestNST(""" + => TestNST(""" @"[1]" """, """ @@ -3543,12 +3332,10 @@ public void n_number_U_FF11_fullwidth_digit_one_json() """); - } [Fact] public void n_number_with_alpha_json() - { - TestNST(""" + => TestNST(""" @"[1.2a-3]" """, """ @@ -3578,12 +3365,10 @@ public void n_number_with_alpha_json() """); - } [Fact] public void n_number_with_alpha_char_json() - { - TestNST(""" + => TestNST(""" @"[1.8011670033376514H-308]" """, """ @@ -3613,12 +3398,10 @@ public void n_number_with_alpha_char_json() """); - } [Fact] public void n_number_with_leading_zero_json() - { - TestNST(""" + => TestNST(""" @"[012]" """, """ @@ -3644,12 +3427,10 @@ public void n_number_with_leading_zero_json() """); - } [Fact] public void n_object_bad_value_json() - { - TestNST(""" + => TestNST(""" @"[""x"", truth]" """, """ @@ -3685,12 +3466,10 @@ public void n_object_bad_value_json() """); - } [Fact] public void n_object_bracket_key_json() - { - TestNST(""" + => TestNST(""" @"{[: ""x""} " """, """ @@ -3731,12 +3510,10 @@ public void n_object_bracket_key_json() """); - } [Fact] public void n_object_comma_instead_of_colon_json() - { - TestNST(""" + => TestNST(""" @"{""x"", null}" """, """ @@ -3770,12 +3547,10 @@ public void n_object_comma_instead_of_colon_json() """); - } [Fact] public void n_object_double_colon_json() - { - TestNST(""" + => TestNST(""" @"{""x""::""b""}" """, """ @@ -3813,12 +3588,10 @@ public void n_object_double_colon_json() """); - } [Fact] public void n_object_garbage_at_end_json() - { - TestNST(""" + => TestNST(""" @"{""a"":""a"" 123}" """, """ @@ -3856,12 +3629,10 @@ public void n_object_garbage_at_end_json() """); - } [Fact] public void n_object_key_with_single_quotes_json() - { - TestNST(""" + => TestNST(""" @"{key: 'value'}" """, """ @@ -3891,12 +3662,10 @@ public void n_object_key_with_single_quotes_json() """); - } [Fact] public void n_object_lone_continuation_byte_in_key_and_trailing_comma_json() - { - TestNST(""" + => TestNST(""" @"{""�"":""0"",}" """, """ @@ -3927,12 +3696,10 @@ public void n_object_lone_continuation_byte_in_key_and_trailing_comma_json() """); - } [Fact] public void n_object_missing_colon_json() - { - TestNST(""" + => TestNST(""" @"{""a"" b}" """, """ @@ -3966,12 +3733,10 @@ public void n_object_missing_colon_json() """); - } [Fact] public void n_object_missing_key_json() - { - TestNST(""" + => TestNST(""" @"{:""b""}" """, """ @@ -4005,12 +3770,10 @@ public void n_object_missing_key_json() """); - } [Fact] public void n_object_missing_semicolon_json() - { - TestNST(""" + => TestNST(""" @"{""a"" ""b""}" """, """ @@ -4044,12 +3807,10 @@ public void n_object_missing_semicolon_json() """); - } [Fact] public void n_object_missing_value_json() - { - TestNST(""" + => TestNST(""" @"{""a"":" """, """ @@ -4083,12 +3844,10 @@ public void n_object_missing_value_json() """); - } [Fact] public void n_object_no_colon_json() - { - TestNST("""" + => TestNST("""" @"{""a""" """", """ @@ -4118,12 +3877,10 @@ public void n_object_no_colon_json() """); - } [Fact] public void n_object_non_string_key_json() - { - TestNST(""" + => TestNST(""" @"{1:1}" """, """ @@ -4153,12 +3910,10 @@ public void n_object_non_string_key_json() """); - } [Fact] public void n_object_non_string_key_but_huge_number_instead_json() - { - TestNST(""" + => TestNST(""" @"{9999E9999:1}" """, """ @@ -4188,12 +3943,10 @@ public void n_object_non_string_key_but_huge_number_instead_json() """); - } [Fact] public void n_object_repeated_null_null_json() - { - TestNST(""" + => TestNST(""" @"{null:null,null:null}" """, """ @@ -4231,12 +3984,10 @@ public void n_object_repeated_null_null_json() """); - } [Fact] public void n_object_several_trailing_commas_json() - { - TestNST(""" + => TestNST(""" @"{""id"":0,,,,,}" """, """ @@ -4279,12 +4030,10 @@ public void n_object_several_trailing_commas_json() """); - } [Fact] public void n_object_single_quote_json() - { - TestNST(""" + => TestNST(""" @"{'a':0}" """, """ @@ -4314,12 +4063,10 @@ public void n_object_single_quote_json() """); - } [Fact] public void n_object_trailing_comma_json() - { - TestNST(""" + => TestNST(""" @"{""id"":0,}" """, """ @@ -4350,12 +4097,10 @@ public void n_object_trailing_comma_json() """); - } [Fact] public void n_object_trailing_comment_json() - { - TestNST(""" + => TestNST(""" @"{""a"":""b""}/**/" """, """ @@ -4385,12 +4130,10 @@ public void n_object_trailing_comment_json() """); - } [Fact] public void n_object_trailing_comment_open_json() - { - TestNST(""" + => TestNST(""" @"{""a"":""b""}/**//" """, """ @@ -4424,12 +4167,10 @@ public void n_object_trailing_comment_open_json() """); - } [Fact] public void n_object_trailing_comment_slash_open_json() - { - TestNST(""" + => TestNST(""" @"{""a"":""b""}//" """, """ @@ -4463,12 +4204,10 @@ public void n_object_trailing_comment_slash_open_json() """); - } [Fact] public void n_object_trailing_comment_slash_open_incomplete_json() - { - TestNST(""" + => TestNST(""" @"{""a"":""b""}/" """, """ @@ -4502,12 +4241,10 @@ public void n_object_trailing_comment_slash_open_incomplete_json() """); - } [Fact] public void n_object_two_commas_in_a_row_json() - { - TestNST(""" + => TestNST(""" @"{""a"":""b"",,""c"":""d""}" """, """ @@ -4553,12 +4290,10 @@ public void n_object_two_commas_in_a_row_json() """); - } [Fact] public void n_object_unquoted_key_json() - { - TestNST(""" + => TestNST(""" @"{a: ""b""}" """, """ @@ -4588,12 +4323,10 @@ public void n_object_unquoted_key_json() """); - } [Fact] public void n_object_unterminated_value_json() - { - TestNST(""" + => TestNST(""" @"{""a"":""a" """, """ @@ -4627,12 +4360,10 @@ public void n_object_unterminated_value_json() """); - } [Fact] public void n_object_with_single_string_json() - { - TestNST(""" + => TestNST(""" @"{ ""foo"" : ""bar"", ""a"" }" """, """ @@ -4670,12 +4401,10 @@ public void n_object_with_single_string_json() """); - } [Fact] public void n_object_with_trailing_garbage_json() - { - TestNST(""" + => TestNST(""" @"{""a"":""b""}#" """, """ @@ -4712,12 +4441,10 @@ public void n_object_with_trailing_garbage_json() """); - } [Fact] public void n_single_space_json() - { - TestNST(""" + => TestNST(""" @" " """, """ @@ -4741,12 +4468,10 @@ public void n_single_space_json() """); - } [Fact] public void n_string_1_surrogate_then_escape_json() - { - TestNST(""" + => TestNST(""" @"[""\uD800\""]" """, """ @@ -4776,12 +4501,10 @@ public void n_string_1_surrogate_then_escape_json() """); - } [Fact] public void n_string_1_surrogate_then_escape_u_json() - { - TestNST(""" + => TestNST(""" @"[""\uD800\u""]" """, """ @@ -4811,12 +4534,10 @@ public void n_string_1_surrogate_then_escape_u_json() """); - } [Fact] public void n_string_1_surrogate_then_escape_u1_json() - { - TestNST(""" + => TestNST(""" @"[""\uD800\u1""]" """, """ @@ -4846,12 +4567,10 @@ public void n_string_1_surrogate_then_escape_u1_json() """); - } [Fact] public void n_string_1_surrogate_then_escape_u1x_json() - { - TestNST(""" + => TestNST(""" @"[""\uD800\u1x""]" """, """ @@ -4881,12 +4600,10 @@ public void n_string_1_surrogate_then_escape_u1x_json() """); - } [Fact] public void n_string_accentuated_char_no_quotes_json() - { - TestNST(""" + => TestNST(""" @"[é]" """, """ @@ -4916,12 +4633,10 @@ public void n_string_accentuated_char_no_quotes_json() """); - } [Fact] public void n_string_escaped_backslash_bad_json() - { - TestNST(""" + => TestNST(""" @"[""\\\""]" """, """ @@ -4951,12 +4666,10 @@ public void n_string_escaped_backslash_bad_json() """); - } [Fact] public void n_string_escaped_ctrl_char_tab_json() - { - TestNST(""" + => TestNST(""" @"[""\ ""]" """, """ @@ -4986,12 +4699,10 @@ public void n_string_escaped_ctrl_char_tab_json() """); - } [Fact] public void n_string_escaped_emoji_json() - { - TestNST(""" + => TestNST(""" @"[""\🌀""]" """, """ @@ -5021,12 +4732,10 @@ public void n_string_escaped_emoji_json() """); - } [Fact] public void n_string_escape_x_json() - { - TestNST(""" + => TestNST(""" @"[""\x00""]" """, """ @@ -5056,12 +4765,10 @@ public void n_string_escape_x_json() """); - } [Fact] public void n_string_incomplete_escape_json() - { - TestNST(""" + => TestNST(""" @"[""\""]" """, """ @@ -5091,12 +4798,10 @@ public void n_string_incomplete_escape_json() """); - } [Fact] public void n_string_incomplete_escaped_character_json() - { - TestNST(""" + => TestNST(""" @"[""\u00A""]" """, """ @@ -5126,12 +4831,10 @@ public void n_string_incomplete_escaped_character_json() """); - } [Fact] public void n_string_incomplete_surrogate_json() - { - TestNST(""" + => TestNST(""" @"[""\uD834\uDd""]" """, """ @@ -5161,12 +4864,10 @@ public void n_string_incomplete_surrogate_json() """); - } [Fact] public void n_string_incomplete_surrogate_escape_invalid_json() - { - TestNST(""" + => TestNST(""" @"[""\uD800\uD800\x""]" """, """ @@ -5196,12 +4897,10 @@ public void n_string_incomplete_surrogate_escape_invalid_json() """); - } [Fact] public void n_string_invalid_utf_8_in_escape_json() - { - TestNST(""" + => TestNST(""" @"[""\u�""]" """, """ @@ -5231,12 +4930,10 @@ public void n_string_invalid_utf_8_in_escape_json() """); - } [Fact] public void n_string_invalid_backslash_esc_json() - { - TestNST(""" + => TestNST(""" @"[""\a""]" """, """ @@ -5266,12 +4963,10 @@ public void n_string_invalid_backslash_esc_json() """); - } [Fact] public void n_string_invalid_unicode_escape_json() - { - TestNST(""" + => TestNST(""" @"[""\uqqqq""]" """, """ @@ -5301,12 +4996,10 @@ public void n_string_invalid_unicode_escape_json() """); - } [Fact] public void n_string_invalid_utf8_after_escape_json() - { - TestNST(""" + => TestNST(""" @"[""\�""]" """, """ @@ -5336,12 +5029,10 @@ public void n_string_invalid_utf8_after_escape_json() """); - } [Fact] public void n_string_leading_uescaped_thinspace_json() - { - TestNST(""" + => TestNST(""" @"[\u0020""asd""]" """, """ @@ -5374,12 +5065,10 @@ public void n_string_leading_uescaped_thinspace_json() """); - } [Fact] public void n_string_no_quotes_with_bad_escape_json() - { - TestNST(""" + => TestNST(""" @"[\n]" """, """ @@ -5409,12 +5098,10 @@ public void n_string_no_quotes_with_bad_escape_json() """); - } [Fact] public void n_string_single_doublequote_json() - { - TestNST(""""" + => TestNST(""""" @"""" """"", """ @@ -5438,12 +5125,10 @@ public void n_string_single_doublequote_json() """); - } [Fact] public void n_string_single_quote_json() - { - TestNST(""" + => TestNST(""" @"['single quote']" """, """ @@ -5469,12 +5154,10 @@ public void n_string_single_quote_json() """); - } [Fact] public void n_string_single_string_no_double_quotes_json() - { - TestNST(""" + => TestNST(""" @"abc" """, """ @@ -5498,12 +5181,10 @@ public void n_string_single_string_no_double_quotes_json() """); - } [Fact] public void n_string_start_escape_unclosed_json() - { - TestNST(""" + => TestNST(""" @"[""\" """, """ @@ -5533,12 +5214,10 @@ public void n_string_start_escape_unclosed_json() """); - } [Fact] public void n_string_unescaped_newline_json() - { - TestNST(""" + => TestNST(""" @"[""new line""]" """, """ @@ -5566,12 +5245,10 @@ public void n_string_unescaped_newline_json() """); - } [Fact] public void n_string_unescaped_tab_json() - { - TestNST(""" + => TestNST(""" @"["" ""]" """, """ @@ -5597,12 +5274,10 @@ public void n_string_unescaped_tab_json() """); - } [Fact] public void n_string_unicode_CapitalU_json() - { - TestNST("""" + => TestNST("""" @"""\UA66D""" """", """ @@ -5626,12 +5301,10 @@ public void n_string_unicode_CapitalU_json() """); - } [Fact] public void n_string_with_trailing_garbage_json() - { - TestNST("""""" + => TestNST("""""" @"""""x" """""", """ @@ -5658,12 +5331,10 @@ public void n_string_with_trailing_garbage_json() """); - } [Fact] public void n_structure_angle_bracket___json() - { - TestNST(""" + => TestNST(""" @"<.>" """, """ @@ -5687,12 +5358,10 @@ public void n_structure_angle_bracket___json() """); - } [Fact] public void n_structure_angle_bracket_null_json() - { - TestNST(""" + => TestNST(""" @"[]" """, """ @@ -5722,12 +5391,10 @@ public void n_structure_angle_bracket_null_json() """); - } [Fact] public void n_structure_array_trailing_garbage_json() - { - TestNST(""" + => TestNST(""" @"[1]x" """, """ @@ -5760,12 +5427,10 @@ public void n_structure_array_trailing_garbage_json() """); - } [Fact] public void n_structure_array_with_extra_array_close_json() - { - TestNST(""" + => TestNST(""" @"[1]]" """, """ @@ -5798,12 +5463,10 @@ public void n_structure_array_with_extra_array_close_json() """); - } [Fact] public void n_structure_array_with_unclosed_string_json() - { - TestNST(""" + => TestNST(""" @"[""asd]" """, """ @@ -5833,12 +5496,10 @@ public void n_structure_array_with_unclosed_string_json() """); - } [Fact] public void n_structure_ascii_unicode_identifier_json() - { - TestNST(""" + => TestNST(""" @"aå" """, """ @@ -5862,12 +5523,10 @@ public void n_structure_ascii_unicode_identifier_json() """); - } [Fact] public void n_structure_capitalized_True_json() - { - TestNST(""" + => TestNST(""" @"[True]" """, """ @@ -5897,12 +5556,10 @@ public void n_structure_capitalized_True_json() """); - } [Fact] public void n_structure_close_unopened_array_json() - { - TestNST(""" + => TestNST(""" @"1]" """, """ @@ -5929,12 +5586,10 @@ public void n_structure_close_unopened_array_json() """); - } [Fact] public void n_structure_comma_instead_of_closing_brace_json() - { - TestNST(""" + => TestNST(""" @"{""x"": true," """, """ @@ -5969,12 +5624,10 @@ public void n_structure_comma_instead_of_closing_brace_json() """); - } [Fact] public void n_structure_double_array_json() - { - TestNST(""" + => TestNST(""" @"[][]" """, """ @@ -6005,12 +5658,10 @@ public void n_structure_double_array_json() """); - } [Fact] public void n_structure_end_array_json() - { - TestNST(""" + => TestNST(""" @"]" """, """ @@ -6034,12 +5685,10 @@ public void n_structure_end_array_json() """); - } [Fact] public void n_structure_incomplete_Utf8_BOM_json() - { - TestNST(""" + => TestNST(""" @"�{}" """, """ @@ -6068,12 +5717,10 @@ public void n_structure_incomplete_Utf8_BOM_json() """); - } [Fact] public void n_structure_lone_open_bracket_json() - { - TestNST(""" + => TestNST(""" @"[" """, """ @@ -6099,12 +5746,10 @@ public void n_structure_lone_open_bracket_json() """); - } [Fact] public void n_structure_number_with_trailing_garbage_json() - { - TestNST(""" + => TestNST(""" @"2@" """, """ @@ -6128,12 +5773,10 @@ public void n_structure_number_with_trailing_garbage_json() """); - } [Fact] public void n_structure_object_followed_by_closing_object_json() - { - TestNST(""" + => TestNST(""" @"{}}" """, """ @@ -6162,12 +5805,10 @@ public void n_structure_object_followed_by_closing_object_json() """); - } [Fact] public void n_structure_object_unclosed_no_value_json() - { - TestNST(""""" + => TestNST(""""" @"{"""":" """"", """ @@ -6201,12 +5842,10 @@ public void n_structure_object_unclosed_no_value_json() """); - } [Fact] public void n_structure_object_with_comment_json() - { - TestNST(""" + => TestNST(""" @"{""a"":/*comment*/""b""}" """, """ @@ -6236,12 +5875,10 @@ public void n_structure_object_with_comment_json() """); - } [Fact] public void n_structure_object_with_trailing_garbage_json() - { - TestNST("""" + => TestNST("""" @"{""a"": true} ""x""" """", """ @@ -6278,12 +5915,10 @@ public void n_structure_object_with_trailing_garbage_json() """); - } [Fact] public void n_structure_open_array_apostrophe_json() - { - TestNST(""" + => TestNST(""" @"['" """, """ @@ -6313,12 +5948,10 @@ public void n_structure_open_array_apostrophe_json() """); - } [Fact] public void n_structure_open_array_comma_json() - { - TestNST(""" + => TestNST(""" @"[," """, """ @@ -6348,12 +5981,10 @@ public void n_structure_open_array_comma_json() """); - } [Fact] public void n_structure_open_array_open_object_json() - { - TestNST(""" + => TestNST(""" @"[{" """, """ @@ -6385,12 +6016,10 @@ public void n_structure_open_array_open_object_json() """); - } [Fact] public void n_structure_open_array_open_string_json() - { - TestNST(""" + => TestNST(""" @"[""a" """, """ @@ -6420,12 +6049,10 @@ public void n_structure_open_array_open_string_json() """); - } [Fact] public void n_structure_open_array_string_json() - { - TestNST("""" + => TestNST("""" @"[""a""" """", """ @@ -6455,12 +6082,10 @@ public void n_structure_open_array_string_json() """); - } [Fact] public void n_structure_open_object_json() - { - TestNST(""" + => TestNST(""" @"{" """, """ @@ -6486,12 +6111,10 @@ public void n_structure_open_object_json() """); - } [Fact] public void n_structure_open_object_close_array_json() - { - TestNST(""" + => TestNST(""" @"{]" """, """ @@ -6521,12 +6144,10 @@ public void n_structure_open_object_close_array_json() """); - } [Fact] public void n_structure_open_object_comma_json() - { - TestNST(""" + => TestNST(""" @"{," """, """ @@ -6556,12 +6177,10 @@ public void n_structure_open_object_comma_json() """); - } [Fact] public void n_structure_open_object_open_array_json() - { - TestNST(""" + => TestNST(""" @"{[" """, """ @@ -6593,12 +6212,10 @@ public void n_structure_open_object_open_array_json() """); - } [Fact] public void n_structure_open_object_open_string_json() - { - TestNST(""" + => TestNST(""" @"{""a" """, """ @@ -6628,12 +6245,10 @@ public void n_structure_open_object_open_string_json() """); - } [Fact] public void n_structure_open_object_string_with_apostrophes_json() - { - TestNST(""" + => TestNST(""" @"{'a'" """, """ @@ -6663,12 +6278,10 @@ public void n_structure_open_object_string_with_apostrophes_json() """); - } [Fact] public void n_structure_open_open_json() - { - TestNST(""" + => TestNST(""" @"[""\{[""\{[""\{[""\{" """, """ @@ -6724,12 +6337,10 @@ public void n_structure_open_open_json() """); - } [Fact] public void n_structure_single_star_json() - { - TestNST(""" + => TestNST(""" @"*" """, """ @@ -6753,12 +6364,10 @@ public void n_structure_single_star_json() """); - } [Fact] public void n_structure_trailing___json() - { - TestNST(""" + => TestNST(""" @"{""a"":""b""}#{}" """, """ @@ -6800,12 +6409,10 @@ public void n_structure_trailing___json() """); - } [Fact] public void n_structure_U_2060_word_joined_json() - { - TestNST(""" + => TestNST(""" @"[⁠]" """, """ @@ -6835,12 +6442,10 @@ public void n_structure_U_2060_word_joined_json() """); - } [Fact] public void n_structure_uescaped_LF_before_string_json() - { - TestNST(""""" + => TestNST(""""" @"[\u000A""""]" """"", """ @@ -6873,12 +6478,10 @@ public void n_structure_uescaped_LF_before_string_json() """); - } [Fact] public void n_structure_unclosed_array_json() - { - TestNST(""" + => TestNST(""" @"[1" """, """ @@ -6908,12 +6511,10 @@ public void n_structure_unclosed_array_json() """); - } [Fact] public void n_structure_unclosed_array_partial_null_json() - { - TestNST(""" + => TestNST(""" @"[ false, nul" """, """ @@ -6949,12 +6550,10 @@ public void n_structure_unclosed_array_partial_null_json() """); - } [Fact] public void n_structure_unclosed_array_unfinished_false_json() - { - TestNST(""" + => TestNST(""" @"[ true, fals" """, """ @@ -6990,12 +6589,10 @@ public void n_structure_unclosed_array_unfinished_false_json() """); - } [Fact] public void n_structure_unclosed_array_unfinished_true_json() - { - TestNST(""" + => TestNST(""" @"[ false, tru" """, """ @@ -7031,12 +6628,10 @@ public void n_structure_unclosed_array_unfinished_true_json() """); - } [Fact] public void n_structure_unclosed_object_json() - { - TestNST("""" + => TestNST("""" @"{""asd"":""asd""" """", """ @@ -7070,12 +6665,10 @@ public void n_structure_unclosed_object_json() """); - } [Fact] public void n_structure_unicode_identifier_json() - { - TestNST(""" + => TestNST(""" @"å" """, """ @@ -7099,12 +6692,10 @@ public void n_structure_unicode_identifier_json() """); - } [Fact] public void n_structure_whitespace_formfeed_json() - { - TestNST(""" + => TestNST(""" @"[ ]" """, """ @@ -7126,12 +6717,10 @@ public void n_structure_whitespace_formfeed_json() """); - } [Fact] public void n_structure_whitespace_U_2060_word_joiner_json() - { - TestNST(""" + => TestNST(""" @"[⁠]" """, """ @@ -7161,12 +6750,10 @@ public void n_structure_whitespace_U_2060_word_joiner_json() """); - } [Fact] public void y_array_arraysWithSpaces_json() - { - TestNST(""" + => TestNST(""" @"[[] ]" """, """ @@ -7190,12 +6777,10 @@ public void y_array_arraysWithSpaces_json() """, @"", @""); - } [Fact] public void y_array_empty_string_json() - { - TestNST(""""" + => TestNST(""""" @"[""""]" """"", """ @@ -7217,12 +6802,10 @@ public void y_array_empty_string_json() """, @"", @""); - } [Fact] public void y_array_empty_json() - { - TestNST(""" + => TestNST(""" @"[]" """, """ @@ -7240,12 +6823,10 @@ public void y_array_empty_json() """, @"", @""); - } [Fact] public void y_array_ending_with_newline_json() - { - TestNST(""" + => TestNST(""" @"[""a""]" """, """ @@ -7267,12 +6848,10 @@ public void y_array_ending_with_newline_json() """, @"", @""); - } [Fact] public void y_array_false_json() - { - TestNST(""" + => TestNST(""" @"[false]" """, """ @@ -7294,12 +6873,10 @@ public void y_array_false_json() """, @"", @""); - } [Fact] public void y_array_heterogeneous_json() - { - TestNST(""" + => TestNST(""" @"[null, 1, ""1"", {}]" """, """ @@ -7341,12 +6918,10 @@ public void y_array_heterogeneous_json() """, @"", @""); - } [Fact] public void y_array_null_json() - { - TestNST(""" + => TestNST(""" @"[null]" """, """ @@ -7368,12 +6943,10 @@ public void y_array_null_json() """, @"", @""); - } [Fact] public void y_array_with_1_and_newline_json() - { - TestNST(""" + => TestNST(""" @"[1 ]" """, """ @@ -7397,12 +6970,10 @@ public void y_array_with_1_and_newline_json() """, @"", @""); - } [Fact] public void y_array_with_leading_space_json() - { - TestNST(""" + => TestNST(""" @" [1]" """, """ @@ -7427,12 +6998,10 @@ public void y_array_with_leading_space_json() """, @"", @""); - } [Fact] public void y_array_with_several_null_json() - { - TestNST(""" + => TestNST(""" @"[1,null,null,null,2]" """, """ @@ -7478,12 +7047,10 @@ public void y_array_with_several_null_json() """, @"", @""); - } [Fact] public void y_array_with_trailing_space_json() - { - TestNST(""" + => TestNST(""" @"[2] " """, """ @@ -7505,12 +7072,10 @@ public void y_array_with_trailing_space_json() """, @"", @""); - } [Fact] public void y_number_json() - { - TestNST(""" + => TestNST(""" @"[123e65]" """, """ @@ -7532,12 +7097,10 @@ public void y_number_json() """, @"", @""); - } [Fact] public void y_number_0e_1_json() - { - TestNST(""" + => TestNST(""" @"[0e+1]" """, """ @@ -7559,12 +7122,10 @@ public void y_number_0e_1_json() """, @"", @""); - } [Fact] public void y_number_0e1_json() - { - TestNST(""" + => TestNST(""" @"[0e1]" """, """ @@ -7586,12 +7147,10 @@ public void y_number_0e1_json() """, @"", @""); - } [Fact] public void y_number_after_space_json() - { - TestNST(""" + => TestNST(""" @"[ 4]" """, """ @@ -7613,12 +7172,10 @@ public void y_number_after_space_json() """, @"", @""); - } [Fact] public void y_number_double_close_to_zero_json() - { - TestNST(""" + => TestNST(""" @"[-0.000000000000000000000000000000000000000000000000000000000000000000000000000001] " """, """ @@ -7642,12 +7199,10 @@ public void y_number_double_close_to_zero_json() """, @"", @""); - } [Fact] public void y_number_int_with_exp_json() - { - TestNST(""" + => TestNST(""" @"[20e1]" """, """ @@ -7669,12 +7224,10 @@ public void y_number_int_with_exp_json() """, @"", @""); - } [Fact] public void y_number_minus_zero_json() - { - TestNST(""" + => TestNST(""" @"[-0]" """, """ @@ -7696,12 +7249,10 @@ public void y_number_minus_zero_json() """, @"", @""); - } [Fact] public void y_number_negative_int_json() - { - TestNST(""" + => TestNST(""" @"[-123]" """, """ @@ -7723,12 +7274,10 @@ public void y_number_negative_int_json() """, @"", @""); - } [Fact] public void y_number_negative_one_json() - { - TestNST(""" + => TestNST(""" @"[-1]" """, """ @@ -7750,12 +7299,10 @@ public void y_number_negative_one_json() """, @"", @""); - } [Fact] public void y_number_negative_zero_json() - { - TestNST(""" + => TestNST(""" @"[-0]" """, """ @@ -7777,12 +7324,10 @@ public void y_number_negative_zero_json() """, @"", @""); - } [Fact] public void y_number_real_capital_e_json() - { - TestNST(""" + => TestNST(""" @"[1E22]" """, """ @@ -7804,12 +7349,10 @@ public void y_number_real_capital_e_json() """, @"", @""); - } [Fact] public void y_number_real_capital_e_neg_exp_json() - { - TestNST(""" + => TestNST(""" @"[1E-2]" """, """ @@ -7831,12 +7374,10 @@ public void y_number_real_capital_e_neg_exp_json() """, @"", @""); - } [Fact] public void y_number_real_capital_e_pos_exp_json() - { - TestNST(""" + => TestNST(""" @"[1E+2]" """, """ @@ -7858,12 +7399,10 @@ public void y_number_real_capital_e_pos_exp_json() """, @"", @""); - } [Fact] public void y_number_real_exponent_json() - { - TestNST(""" + => TestNST(""" @"[123e45]" """, """ @@ -7885,12 +7424,10 @@ public void y_number_real_exponent_json() """, @"", @""); - } [Fact] public void y_number_real_fraction_exponent_json() - { - TestNST(""" + => TestNST(""" @"[123.456e78]" """, """ @@ -7912,12 +7449,10 @@ public void y_number_real_fraction_exponent_json() """, @"", @""); - } [Fact] public void y_number_real_neg_exp_json() - { - TestNST(""" + => TestNST(""" @"[1e-2]" """, """ @@ -7939,12 +7474,10 @@ public void y_number_real_neg_exp_json() """, @"", @""); - } [Fact] public void y_number_real_pos_exponent_json() - { - TestNST(""" + => TestNST(""" @"[1e+2]" """, """ @@ -7966,12 +7499,10 @@ public void y_number_real_pos_exponent_json() """, @"", @""); - } [Fact] public void y_number_simple_int_json() - { - TestNST(""" + => TestNST(""" @"[123]" """, """ @@ -7993,12 +7524,10 @@ public void y_number_simple_int_json() """, @"", @""); - } [Fact] public void y_number_simple_real_json() - { - TestNST(""" + => TestNST(""" @"[123.456789]" """, """ @@ -8020,12 +7549,10 @@ public void y_number_simple_real_json() """, @"", @""); - } [Fact] public void y_object_json() - { - TestNST(""" + => TestNST(""" @"{""asd"":""sdf"", ""dfg"":""fgh""}" """, """ @@ -8059,12 +7586,10 @@ public void y_object_json() """, @"", @""); - } [Fact] public void y_object_basic_json() - { - TestNST(""" + => TestNST(""" @"{""asd"":""sdf""}" """, """ @@ -8090,12 +7615,10 @@ public void y_object_basic_json() """, @"", @""); - } [Fact] public void y_object_duplicated_key_json() - { - TestNST(""" + => TestNST(""" @"{""a"":""b"",""a"":""c""}" """, """ @@ -8129,12 +7652,10 @@ public void y_object_duplicated_key_json() """, @"", @""); - } [Fact] public void y_object_duplicated_key_and_value_json() - { - TestNST(""" + => TestNST(""" @"{""a"":""b"",""a"":""b""}" """, """ @@ -8168,12 +7689,10 @@ public void y_object_duplicated_key_and_value_json() """, @"", @""); - } [Fact] public void y_object_empty_json() - { - TestNST(""" + => TestNST(""" @"{}" """, """ @@ -8191,12 +7710,10 @@ public void y_object_empty_json() """, @"", @""); - } [Fact] public void y_object_empty_key_json() - { - TestNST(""""" + => TestNST(""""" @"{"""":0}" """"", """ @@ -8222,12 +7739,10 @@ public void y_object_empty_key_json() """, @"", @""); - } [Fact] public void y_object_escaped_null_in_key_json() - { - TestNST(""" + => TestNST(""" @"{""foo\u0000bar"": 42}" """, """ @@ -8253,12 +7768,10 @@ public void y_object_escaped_null_in_key_json() """, @"", @""); - } [Fact] public void y_object_extreme_numbers_json() - { - TestNST(""" + => TestNST(""" @"{ ""min"": -1.0e+28, ""max"": 1.0e+28 }" """, """ @@ -8292,12 +7805,10 @@ public void y_object_extreme_numbers_json() """, @"", @""); - } [Fact] public void y_object_long_strings_json() - { - TestNST(""" + => TestNST(""" @"{""x"":[{""id"": ""xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx""}], ""id"": ""xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx""}" """, """ @@ -8346,14 +7857,12 @@ public void y_object_long_strings_json() """, - @"", - @""); - } + @"", + @""); [Fact] public void y_object_simple_json() - { - TestNST(""" + => TestNST(""" @"{""a"":[]}" """, """ @@ -8381,12 +7890,10 @@ public void y_object_simple_json() """, @"", @""); - } [Fact] public void y_object_string_unicode_json() - { - TestNST(""" + => TestNST(""" @"{""title"":""\u041f\u043e\u043b\u0442\u043e\u0440\u0430 \u0417\u0435\u043c\u043b\u0435\u043a\u043e\u043f\u0430"" }" """, """ @@ -8412,12 +7919,10 @@ public void y_object_string_unicode_json() """, @"", @""); - } [Fact] public void y_object_with_newlines_json() - { - TestNST(""" + => TestNST(""" @"{ ""a"": ""b"" }" @@ -8447,12 +7952,10 @@ public void y_object_with_newlines_json() """, @"", @""); - } [Fact] public void y_string_1_2_3_bytes_UTF_8_sequences_json() - { - TestNST(""" + => TestNST(""" @"[""\u0060\u012a\u12AB""]" """, """ @@ -8474,12 +7977,10 @@ public void y_string_1_2_3_bytes_UTF_8_sequences_json() """, @"", @""); - } [Fact] public void y_string_accepted_surrogate_pair_json() - { - TestNST(""" + => TestNST(""" @"[""\uD801\udc37""]" """, """ @@ -8501,12 +8002,10 @@ public void y_string_accepted_surrogate_pair_json() """, @"", @""); - } [Fact] public void y_string_accepted_surrogate_pairs_json() - { - TestNST(""" + => TestNST(""" @"[""\ud83d\ude39\ud83d\udc8d""]" """, """ @@ -8528,12 +8027,10 @@ public void y_string_accepted_surrogate_pairs_json() """, @"", @""); - } [Fact] public void y_string_allowed_escapes_json() - { - TestNST(""" + => TestNST(""" @"[""\""\\\/\b\f\n\r\t""]" """, """ @@ -8555,12 +8052,10 @@ public void y_string_allowed_escapes_json() """, @"", @""); - } [Fact] public void y_string_backslash_and_u_escaped_zero_json() - { - TestNST(""" + => TestNST(""" @"[""\\u0000""]" """, """ @@ -8582,12 +8077,10 @@ public void y_string_backslash_and_u_escaped_zero_json() """, @"", @""); - } [Fact] public void y_string_backslash_doublequotes_json() - { - TestNST(""""" + => TestNST(""""" @"[""\""""]" """"", """ @@ -8609,12 +8102,10 @@ public void y_string_backslash_doublequotes_json() """, @"", @""); - } [Fact] public void y_string_comments_json() - { - TestNST(""" + => TestNST(""" @"[""a/*b*/c/*d//e""]" """, """ @@ -8636,12 +8127,10 @@ public void y_string_comments_json() """, @"", @""); - } [Fact] public void y_string_double_escape_a_json() - { - TestNST(""" + => TestNST(""" @"[""\\a""]" """, """ @@ -8663,12 +8152,10 @@ public void y_string_double_escape_a_json() """, @"", @""); - } [Fact] public void y_string_double_escape_n_json() - { - TestNST(""" + => TestNST(""" @"[""\\n""]" """, """ @@ -8690,12 +8177,10 @@ public void y_string_double_escape_n_json() """, @"", @""); - } [Fact] public void y_string_escaped_control_character_json() - { - TestNST(""" + => TestNST(""" @"[""\u0012""]" """, """ @@ -8717,12 +8202,10 @@ public void y_string_escaped_control_character_json() """, @"", @""); - } [Fact] public void y_string_escaped_noncharacter_json() - { - TestNST(""" + => TestNST(""" @"[""\uFFFF""]" """, """ @@ -8744,12 +8227,10 @@ public void y_string_escaped_noncharacter_json() """, @"", @""); - } [Fact] public void y_string_in_array_json() - { - TestNST(""" + => TestNST(""" @"[""asd""]" """, """ @@ -8771,12 +8252,10 @@ public void y_string_in_array_json() """, @"", @""); - } [Fact] public void y_string_in_array_with_leading_space_json() - { - TestNST(""" + => TestNST(""" @"[ ""asd""]" """, """ @@ -8798,12 +8277,10 @@ public void y_string_in_array_with_leading_space_json() """, @"", @""); - } [Fact] public void y_string_last_surrogates_1_and_2_json() - { - TestNST(""" + => TestNST(""" @"[""\uDBFF\uDFFF""]" """, """ @@ -8825,12 +8302,10 @@ public void y_string_last_surrogates_1_and_2_json() """, @"", @""); - } [Fact] public void y_string_nbsp_uescaped_json() - { - TestNST(""" + => TestNST(""" @"[""new\u00A0line""]" """, """ @@ -8852,12 +8327,10 @@ public void y_string_nbsp_uescaped_json() """, @"", @""); - } [Fact] public void y_string_nonCharacterInUTF_8_U_10FFFF_json() - { - TestNST(""" + => TestNST(""" @"[""􏿿""]" """, """ @@ -8879,12 +8352,10 @@ public void y_string_nonCharacterInUTF_8_U_10FFFF_json() """, @"", @""); - } [Fact] public void y_string_null_escape_json() - { - TestNST(""" + => TestNST(""" @"[""\u0000""]" """, """ @@ -8906,12 +8377,10 @@ public void y_string_null_escape_json() """, @"", @""); - } [Fact] public void y_string_one_byte_utf_8_json() - { - TestNST(""" + => TestNST(""" @"[""\u002c""]" """, """ @@ -8933,12 +8402,10 @@ public void y_string_one_byte_utf_8_json() """, @"", @""); - } [Fact] public void y_string_pi_json() - { - TestNST(""" + => TestNST(""" @"[""π""]" """, """ @@ -8960,12 +8427,10 @@ public void y_string_pi_json() """, @"", @""); - } [Fact] public void y_string_reservedCharacterInUTF_8_U_1BFFF_json() - { - TestNST(""" + => TestNST(""" @"[""𛿿""]" """, """ @@ -8987,12 +8452,10 @@ public void y_string_reservedCharacterInUTF_8_U_1BFFF_json() """, @"", @""); - } [Fact] public void y_string_simple_ascii_json() - { - TestNST(""" + => TestNST(""" @"[""asd ""]" """, """ @@ -9014,12 +8477,10 @@ public void y_string_simple_ascii_json() """, @"", @""); - } [Fact] public void y_string_space_json() - { - TestNST("""" + => TestNST("""" @""" """ """", """ @@ -9035,12 +8496,10 @@ public void y_string_space_json() """, @"", @""); - } [Fact] public void y_string_surrogates_U_1D11E_MUSICAL_SYMBOL_G_CLEF_json() - { - TestNST(""" + => TestNST(""" @"[""\uD834\uDd1e""]" """, """ @@ -9062,12 +8521,10 @@ public void y_string_surrogates_U_1D11E_MUSICAL_SYMBOL_G_CLEF_json() """, @"", @""); - } [Fact] public void y_string_three_byte_utf_8_json() - { - TestNST(""" + => TestNST(""" @"[""\u0821""]" """, """ @@ -9089,12 +8546,10 @@ public void y_string_three_byte_utf_8_json() """, @"", @""); - } [Fact] public void y_string_two_byte_utf_8_json() - { - TestNST(""" + => TestNST(""" @"[""\u0123""]" """, """ @@ -9116,12 +8571,10 @@ public void y_string_two_byte_utf_8_json() """, @"", @""); - } [Fact] public void y_string_u_2028_line_sep_json() - { - TestNST(""" + => TestNST(""" @"[""
 ""]" """, """ @@ -9143,12 +8596,10 @@ public void y_string_u_2028_line_sep_json() """, @"", @""); - } [Fact] public void y_string_u_2029_par_sep_json() - { - TestNST(""" + => TestNST(""" @"[""
 ""]" """, """ @@ -9170,12 +8621,10 @@ public void y_string_u_2029_par_sep_json() """, @"", @""); - } [Fact] public void y_string_uEscape_json() - { - TestNST(""" + => TestNST(""" @"[""\u0061\u30af\u30EA\u30b9""]" """, """ @@ -9197,12 +8646,10 @@ public void y_string_uEscape_json() """, @"", @""); - } [Fact] public void y_string_uescaped_newline_json() - { - TestNST(""" + => TestNST(""" @"[""new\u000Aline""]" """, """ @@ -9224,12 +8671,10 @@ public void y_string_uescaped_newline_json() """, @"", @""); - } [Fact] public void y_string_unescaped_char_delete_json() - { - TestNST(""" + => TestNST(""" @"[""""]" """, """ @@ -9251,12 +8696,10 @@ public void y_string_unescaped_char_delete_json() """, @"", @""); - } [Fact] public void y_string_unicode_json() - { - TestNST(""" + => TestNST(""" @"[""\uA66D""]" """, """ @@ -9278,12 +8721,10 @@ public void y_string_unicode_json() """, @"", @""); - } [Fact] public void y_string_unicodeEscapedBackslash_json() - { - TestNST(""" + => TestNST(""" @"[""\u005C""]" """, """ @@ -9305,12 +8746,10 @@ public void y_string_unicodeEscapedBackslash_json() """, @"", @""); - } [Fact] public void y_string_unicode_2_json() - { - TestNST(""" + => TestNST(""" @"[""⍂㈴⍂""]" """, """ @@ -9332,12 +8771,10 @@ public void y_string_unicode_2_json() """, @"", @""); - } [Fact] public void y_string_unicode_escaped_double_quote_json() - { - TestNST(""" + => TestNST(""" @"[""\u0022""]" """, """ @@ -9359,12 +8796,10 @@ public void y_string_unicode_escaped_double_quote_json() """, @"", @""); - } [Fact] public void y_string_unicode_U_10FFFE_nonchar_json() - { - TestNST(""" + => TestNST(""" @"[""\uDBFF\uDFFE""]" """, """ @@ -9386,12 +8821,10 @@ public void y_string_unicode_U_10FFFE_nonchar_json() """, @"", @""); - } [Fact] public void y_string_unicode_U_1FFFE_nonchar_json() - { - TestNST(""" + => TestNST(""" @"[""\uD83F\uDFFE""]" """, """ @@ -9413,12 +8846,10 @@ public void y_string_unicode_U_1FFFE_nonchar_json() """, @"", @""); - } [Fact] public void y_string_unicode_U_200B_ZERO_WIDTH_SPACE_json() - { - TestNST(""" + => TestNST(""" @"[""\u200B""]" """, """ @@ -9440,12 +8871,10 @@ public void y_string_unicode_U_200B_ZERO_WIDTH_SPACE_json() """, @"", @""); - } [Fact] public void y_string_unicode_U_2064_invisible_plus_json() - { - TestNST(""" + => TestNST(""" @"[""\u2064""]" """, """ @@ -9467,12 +8896,10 @@ public void y_string_unicode_U_2064_invisible_plus_json() """, @"", @""); - } [Fact] public void y_string_unicode_U_FDD0_nonchar_json() - { - TestNST(""" + => TestNST(""" @"[""\uFDD0""]" """, """ @@ -9494,12 +8921,10 @@ public void y_string_unicode_U_FDD0_nonchar_json() """, @"", @""); - } [Fact] public void y_string_unicode_U_FFFE_nonchar_json() - { - TestNST(""" + => TestNST(""" @"[""\uFFFE""]" """, """ @@ -9521,12 +8946,10 @@ public void y_string_unicode_U_FFFE_nonchar_json() """, @"", @""); - } [Fact] public void y_string_utf8_json() - { - TestNST(""" + => TestNST(""" @"[""€𝄞""]" """, """ @@ -9548,12 +8971,10 @@ public void y_string_utf8_json() """, @"", @""); - } [Fact] public void y_string_with_del_character_json() - { - TestNST(""" + => TestNST(""" @"[""aa""]" """, """ @@ -9575,12 +8996,10 @@ public void y_string_with_del_character_json() """, @"", @""); - } [Fact] public void y_structure_lonely_false_json() - { - TestNST(""" + => TestNST(""" @"false" """, """ @@ -9596,12 +9015,10 @@ public void y_structure_lonely_false_json() """, @"", @""); - } [Fact] public void y_structure_lonely_int_json() - { - TestNST(""" + => TestNST(""" @"42" """, """ @@ -9617,12 +9034,10 @@ public void y_structure_lonely_int_json() """, @"", @""); - } [Fact] public void y_structure_lonely_negative_real_json() - { - TestNST(""" + => TestNST(""" @"-0.1" """, """ @@ -9638,12 +9053,10 @@ public void y_structure_lonely_negative_real_json() """, @"", @""); - } [Fact] public void y_structure_lonely_null_json() - { - TestNST(""" + => TestNST(""" @"null" """, """ @@ -9659,12 +9072,10 @@ public void y_structure_lonely_null_json() """, @"", @""); - } [Fact] public void y_structure_lonely_string_json() - { - TestNST("""" + => TestNST("""" @"""asd""" """", """ @@ -9680,12 +9091,10 @@ public void y_structure_lonely_string_json() """, @"", @""); - } [Fact] public void y_structure_lonely_true_json() - { - TestNST(""" + => TestNST(""" @"true" """, """ @@ -9701,12 +9110,10 @@ public void y_structure_lonely_true_json() """, @"", @""); - } [Fact] public void y_structure_string_empty_json() - { - TestNST(""""""" + => TestNST(""""""" @"""""" """"""", """ @@ -9722,12 +9129,10 @@ public void y_structure_string_empty_json() """, @"", @""); - } [Fact] public void y_structure_trailing_newline_json() - { - TestNST(""" + => TestNST(""" @"[""a""] " """, """ @@ -9751,12 +9156,10 @@ public void y_structure_trailing_newline_json() """, @"", @""); - } [Fact] public void y_structure_true_in_array_json() - { - TestNST(""" + => TestNST(""" @"[true]" """, """ @@ -9778,12 +9181,10 @@ public void y_structure_true_in_array_json() """, @"", @""); - } [Fact] public void y_structure_whitespace_array_json() - { - TestNST(""" + => TestNST(""" @" [] " """, """ @@ -9804,5 +9205,4 @@ public void y_structure_whitespace_array_json() """, @"", @""); - } } diff --git a/src/EditorFeatures/CSharpTest2/EmbeddedLanguages/RegularExpressions/CSharpRegexParserTests_BasicTests.cs b/src/EditorFeatures/CSharpTest2/EmbeddedLanguages/RegularExpressions/CSharpRegexParserTests_BasicTests.cs index 9459ca193d0a..a7e8f58ab13b 100644 --- a/src/EditorFeatures/CSharpTest2/EmbeddedLanguages/RegularExpressions/CSharpRegexParserTests_BasicTests.cs +++ b/src/EditorFeatures/CSharpTest2/EmbeddedLanguages/RegularExpressions/CSharpRegexParserTests_BasicTests.cs @@ -15,8 +15,7 @@ public sealed partial class CSharpRegexParserTests { [Fact] public void TestEmpty() - { - Test(""" + => Test(""" "" """, """ @@ -29,12 +28,10 @@ public void TestEmpty() """, RegexOptions.None); - } [Fact] public void TestOneWhitespace_IgnorePatternWhitespace() - { - Test(""" + => Test(""" " " """, """ @@ -51,12 +48,10 @@ public void TestOneWhitespace_IgnorePatternWhitespace() """, RegexOptions.IgnorePatternWhitespace); - } [Fact] public void TestTwoWhitespace_IgnorePatternWhitespace() - { - Test(""" + => Test(""" " " """, """ @@ -73,12 +68,10 @@ public void TestTwoWhitespace_IgnorePatternWhitespace() """, RegexOptions.IgnorePatternWhitespace); - } [Fact] public void TestEmptyParenComment() - { - Test(""" + => Test(""" "(?#)" """, """ @@ -95,12 +88,10 @@ public void TestEmptyParenComment() """, RegexOptions.None); - } [Fact] public void TestSimpleParenComment() - { - Test(""" + => Test(""" "(?# )" """, """ @@ -117,12 +108,10 @@ public void TestSimpleParenComment() """, RegexOptions.None); - } [Fact] public void TestUnterminatedParenComment1() - { - Test(""" + => Test(""" "(?#" """, $""" @@ -142,12 +131,10 @@ public void TestUnterminatedParenComment1() """, RegexOptions.None); - } [Fact] public void TestUnterminatedParenComment2() - { - Test(""" + => Test(""" "(?# " """, $""" @@ -167,12 +154,10 @@ public void TestUnterminatedParenComment2() """, RegexOptions.None); - } [Fact] public void TestMultipleComments1() - { - Test(""" + => Test(""" "(?#)(?#)" """, """ @@ -190,12 +175,10 @@ public void TestMultipleComments1() """, RegexOptions.None); - } [Fact] public void TestMultipleComments2() - { - Test(""" + => Test(""" "(?#)(?#)" """, """ @@ -213,12 +196,10 @@ public void TestMultipleComments2() """, RegexOptions.IgnorePatternWhitespace); - } [Fact] public void TestMultipleComments3() - { - Test(""" + => Test(""" "(?#) (?#)" """, """ @@ -242,12 +223,10 @@ public void TestMultipleComments3() """, RegexOptions.None); - } [Fact] public void TestMultipleComments4() - { - Test(""" + => Test(""" "(?#) (?#)" """, """ @@ -266,12 +245,10 @@ public void TestMultipleComments4() """, RegexOptions.IgnorePatternWhitespace); - } [Fact] public void TestDoNotTreatAsCommentAfterEscapeInCharacterClass1() - { - Test(""" + => Test(""" @"[a\p{Lu}(?#)b]" """, """ @@ -304,12 +281,10 @@ public void TestDoNotTreatAsCommentAfterEscapeInCharacterClass1() """, RegexOptions.None); - } [Fact] public void TestDoNotTreatAsCommentAfterEscapeInCharacterClass2() - { - Test(""" + => Test(""" @"[a\0(?#)b]" """, """ @@ -339,12 +314,10 @@ public void TestDoNotTreatAsCommentAfterEscapeInCharacterClass2() """, RegexOptions.None); - } [Fact] public void TestDoNotTreatAsCommentAfterEscapeInCharacterClass3() - { - Test(""" + => Test(""" @"[a\a(?#)b]" """, """ @@ -374,12 +347,10 @@ public void TestDoNotTreatAsCommentAfterEscapeInCharacterClass3() """, RegexOptions.None); - } [Fact] public void TestDoNotTreatAsCommentAfterEscapeInCharacterClass4() - { - Test(""" + => Test(""" @"[a\x00(?#)b]" """, """ @@ -410,12 +381,10 @@ public void TestDoNotTreatAsCommentAfterEscapeInCharacterClass4() """, RegexOptions.None); - } [Fact] public void TestDoNotTreatAsCommentAfterEscapeInCharacterClass5() - { - Test(""" + => Test(""" @"[a\u0000(?#)b]" """, """ @@ -446,12 +415,10 @@ public void TestDoNotTreatAsCommentAfterEscapeInCharacterClass5() """, RegexOptions.None); - } [Fact] public void TestDoNotTreatAsCommentAfterEscapeInCharacterClass6() - { - Test(""" + => Test(""" @"[a\](?#)b]" """, """ @@ -481,12 +448,10 @@ public void TestDoNotTreatAsCommentAfterEscapeInCharacterClass6() """, RegexOptions.None); - } [Fact] public void TestOpenQuestion1() - { - Test(""" + => Test(""" "(?" """, $""" @@ -514,12 +479,10 @@ public void TestOpenQuestion1() """, RegexOptions.None); - } [Fact] public void TestOpenQuestion2() - { - Test(""" + => Test(""" "(?" """, $""" @@ -547,12 +510,10 @@ public void TestOpenQuestion2() """, RegexOptions.IgnorePatternWhitespace); - } [Fact] public void TestOpenQuestion3() - { - Test(""" + => Test(""" "(? " """, $""" @@ -583,12 +544,10 @@ public void TestOpenQuestion3() """, RegexOptions.None); - } [Fact] public void TestOpenQuestion4() - { - Test(""" + => Test(""" "(? " """, $""" @@ -620,12 +579,10 @@ public void TestOpenQuestion4() """, RegexOptions.IgnorePatternWhitespace); - } [Fact] public void TestSimpleOptionsNode1() - { - Test(""" + => Test(""" "(?i)" """, """ @@ -645,12 +602,10 @@ public void TestSimpleOptionsNode1() """, RegexOptions.None); - } [Fact] public void TestSimpleOptionsNode2() - { - Test(""" + => Test(""" "(?im)" """, """ @@ -670,12 +625,10 @@ public void TestSimpleOptionsNode2() """, RegexOptions.None); - } [Fact] public void TestSimpleOptionsNode3() - { - Test(""" + => Test(""" "(?im-x)" """, """ @@ -695,12 +648,10 @@ public void TestSimpleOptionsNode3() """, RegexOptions.None); - } [Fact] public void TestSimpleOptionsNode4() - { - Test(""" + => Test(""" "(?im-x+n)" """, """ @@ -720,12 +671,10 @@ public void TestSimpleOptionsNode4() """, RegexOptions.None); - } [Fact] public void TestOptionThatDoesNotChangeWhitespaceScanning() - { - Test(""" + => Test(""" "(?i) " """, """ @@ -748,12 +697,10 @@ public void TestOptionThatDoesNotChangeWhitespaceScanning() """, RegexOptions.None); - } [Fact] public void TestOptionThatDoesChangeWhitespaceScanning() - { - Test(""" + => Test(""" "(?x) " """, """ @@ -777,12 +724,10 @@ public void TestOptionThatDoesChangeWhitespaceScanning() """, RegexOptions.None); - } [Fact] public void TestOptionThatDoesChangeWhitespaceScanning2() - { - Test(""" + => Test(""" " (?x) " """, """ @@ -809,12 +754,10 @@ public void TestOptionThatDoesChangeWhitespaceScanning2() """, RegexOptions.None); - } [Fact] public void TestOptionThatDoesChangeWhitespaceScanning3() - { - Test(""" + => Test(""" " (?-x) " """, """ @@ -840,12 +783,10 @@ public void TestOptionThatDoesChangeWhitespaceScanning3() """, RegexOptions.IgnorePatternWhitespace); - } [Fact] public void TestOptionRestoredWhenGroupPops() - { - Test(""" + => Test(""" " ( (?-x) ) " """, """ @@ -885,12 +826,10 @@ public void TestOptionRestoredWhenGroupPops() """, RegexOptions.IgnorePatternWhitespace); - } [Fact] public void TestNestedOptionGroup1() - { - Test(""" + => Test(""" " (?-x:) " """, """ @@ -919,12 +858,10 @@ public void TestNestedOptionGroup1() """, RegexOptions.IgnorePatternWhitespace); - } [Fact] public void TestNestedOptionGroup2() - { - Test(""" + => Test(""" " (?-x: ) " """, """ @@ -957,12 +894,10 @@ public void TestNestedOptionGroup2() """, RegexOptions.IgnorePatternWhitespace); - } [Fact] public void TestNestedOptionGroup3() - { - Test(""" + => Test(""" " (?-x: (?+x: ) ) " """, """ @@ -1009,12 +944,10 @@ public void TestNestedOptionGroup3() """, RegexOptions.IgnorePatternWhitespace); - } [Fact] public void TestIncompleteOptionsGroup1() - { - Test(""" + => Test(""" "(?-x" """, $""" @@ -1037,12 +970,10 @@ public void TestIncompleteOptionsGroup1() """, RegexOptions.IgnorePatternWhitespace); - } [Fact] public void TestIncompleteOptionsGroup2() - { - Test(""" + => Test(""" "(?-x " """, $""" @@ -1068,12 +999,10 @@ public void TestIncompleteOptionsGroup2() """, RegexOptions.IgnorePatternWhitespace); - } [Fact] public void TestIncorrectOptionsGroup3() - { - Test(""" + => Test(""" "(?-x :" """, $""" @@ -1099,12 +1028,10 @@ public void TestIncorrectOptionsGroup3() """, RegexOptions.IgnorePatternWhitespace); - } [Fact] public void TestIncorrectOptionsGroup4() - { - Test(""" + => Test(""" "(?-x )" """, $""" @@ -1134,12 +1061,10 @@ public void TestIncorrectOptionsGroup4() """, RegexOptions.IgnorePatternWhitespace); - } [Fact] public void TestIncorrectOptionsGroup5() - { - Test(""" + => Test(""" "(?-x :)" """, $""" @@ -1169,12 +1094,10 @@ public void TestIncorrectOptionsGroup5() """, RegexOptions.IgnorePatternWhitespace); - } [Fact] public void TestCloseParen() - { - Test(""" + => Test(""" ")" """, $""" @@ -1194,12 +1117,10 @@ public void TestCloseParen() """, RegexOptions.None); - } [Fact] public void TestSingleChar() - { - Test(""" + => Test(""" "a" """, """ @@ -1216,12 +1137,10 @@ public void TestSingleChar() """, RegexOptions.None); - } [Fact] public void TestTwoCharsChar() - { - Test(""" + => Test(""" "ab" """, """ @@ -1238,12 +1157,10 @@ public void TestTwoCharsChar() """, RegexOptions.None); - } [Fact] public void TestAsteriskQuantifier() - { - Test(""" + => Test(""" "a*" """, """ @@ -1263,12 +1180,10 @@ public void TestAsteriskQuantifier() """, RegexOptions.None); - } [Fact] public void TestAsteriskQuestionQuantifier() - { - Test(""" + => Test(""" "a*?" """, """ @@ -1291,12 +1206,10 @@ public void TestAsteriskQuestionQuantifier() """, RegexOptions.None); - } [Fact] public void TestPlusQuantifier() - { - Test(""" + => Test(""" "a+" """, """ @@ -1316,12 +1229,10 @@ public void TestPlusQuantifier() """, RegexOptions.None); - } [Fact] public void TestPlusQuestionQuantifier() - { - Test(""" + => Test(""" "a+?" """, """ @@ -1344,12 +1255,10 @@ public void TestPlusQuestionQuantifier() """, RegexOptions.None); - } [Fact] public void TestQuestionQuantifier() - { - Test(""" + => Test(""" "a?" """, """ @@ -1369,12 +1278,10 @@ public void TestQuestionQuantifier() """, RegexOptions.None); - } [Fact] public void TestQuestionQuestionQuantifier() - { - Test(""" + => Test(""" "a??" """, """ @@ -1397,12 +1304,10 @@ public void TestQuestionQuestionQuantifier() """, RegexOptions.None); - } [Fact] public void TestEmptySimpleGroup() - { - Test(""" + => Test(""" "()" """, """ @@ -1422,12 +1327,10 @@ public void TestEmptySimpleGroup() """, RegexOptions.None); - } [Fact] public void TestGroupWithSingleElement() - { - Test(""" + => Test(""" "(a)" """, """ @@ -1451,12 +1354,10 @@ public void TestGroupWithSingleElement() """, RegexOptions.None); - } [Fact] public void TestGroupWithMissingCloseParen() - { - Test(""" + => Test(""" "(" """, $""" @@ -1479,12 +1380,10 @@ public void TestGroupWithMissingCloseParen() """, RegexOptions.None); - } [Fact] public void TestGroupWithElementWithMissingCloseParen() - { - Test(""" + => Test(""" "(a" """, $""" @@ -1511,12 +1410,10 @@ public void TestGroupWithElementWithMissingCloseParen() """, RegexOptions.None); - } [Fact] public void JustBar() - { - Test(""" + => Test(""" "|" """, """ @@ -1533,12 +1430,10 @@ public void JustBar() """, RegexOptions.None); - } [Fact] public void SpaceBar() - { - Test(""" + => Test(""" " |" """, """ @@ -1559,12 +1454,10 @@ public void SpaceBar() """, RegexOptions.None); - } [Fact] public void BarSpace() - { - Test(""" + => Test(""" "| " """, """ @@ -1585,12 +1478,10 @@ public void BarSpace() """, RegexOptions.None); - } [Fact] public void SpaceBarSpace() - { - Test(""" + => Test(""" " | " """, """ @@ -1615,12 +1506,10 @@ public void SpaceBarSpace() """, RegexOptions.None); - } [Fact] public void JustBar_IgnoreWhitespace() - { - Test(""" + => Test(""" "|" """, """ @@ -1637,12 +1526,10 @@ public void JustBar_IgnoreWhitespace() """, RegexOptions.IgnorePatternWhitespace); - } [Fact] public void SpaceBar_IgnoreWhitespace() - { - Test(""" + => Test(""" " |" """, """ @@ -1662,12 +1549,10 @@ public void SpaceBar_IgnoreWhitespace() """, RegexOptions.IgnorePatternWhitespace); - } [Fact] public void BarSpace_IgnoreWhitespace() - { - Test(""" + => Test(""" "| " """, """ @@ -1688,12 +1573,10 @@ public void BarSpace_IgnoreWhitespace() """, RegexOptions.IgnorePatternWhitespace); - } [Fact] public void SpaceBarSpace_IgnoreWhitespace() - { - Test(""" + => Test(""" " | " """, """ @@ -1717,12 +1600,10 @@ public void SpaceBarSpace_IgnoreWhitespace() """, RegexOptions.IgnorePatternWhitespace); - } [Fact] public void DoubleBar() - { - Test(""" + => Test(""" "||" """, """ @@ -1743,12 +1624,10 @@ public void DoubleBar() """, RegexOptions.None); - } [Fact] public void BarInGroup() - { - Test(""" + => Test(""" "(|)" """, """ @@ -1772,12 +1651,10 @@ public void BarInGroup() """, RegexOptions.None); - } [Fact] public void TestExactNumericQuantifier() - { - Test(""" + => Test(""" "a{0}" """, """ @@ -1799,12 +1676,10 @@ public void TestExactNumericQuantifier() """, RegexOptions.None); - } [Fact] public void TestOpenRangeNumericQuantifier() - { - Test(""" + => Test(""" "a{0,}" """, """ @@ -1827,12 +1702,10 @@ public void TestOpenRangeNumericQuantifier() """, RegexOptions.None); - } [Fact] public void TestClosedRangeNumericQuantifier() - { - Test(""" + => Test(""" "a{0,1}" """, """ @@ -1856,12 +1729,10 @@ public void TestClosedRangeNumericQuantifier() """, RegexOptions.None); - } [Fact] public void TestLargeExactRangeNumericQuantifier1() - { - Test(""" + => Test(""" "a{2147483647}" """, """ @@ -1883,12 +1754,10 @@ public void TestLargeExactRangeNumericQuantifier1() """, RegexOptions.None); - } [Fact] public void TestLargeExactRangeNumericQuantifier2() - { - Test(""" + => Test(""" "a{2147483648}" """, $$""" @@ -1913,12 +1782,10 @@ public void TestLargeExactRangeNumericQuantifier2() """, RegexOptions.None); - } [Fact] public void TestLargeOpenRangeNumericQuantifier1() - { - Test(""" + => Test(""" "a{2147483647,}" """, """ @@ -1941,12 +1808,10 @@ public void TestLargeOpenRangeNumericQuantifier1() """, RegexOptions.None); - } [Fact] public void TestLargeOpenRangeNumericQuantifier2() - { - Test(""" + => Test(""" "a{2147483648,}" """, $$""" @@ -1972,12 +1837,10 @@ public void TestLargeOpenRangeNumericQuantifier2() """, RegexOptions.None); - } [Fact] public void TestLargeClosedRangeNumericQuantifier1() - { - Test(""" + => Test(""" "a{0,2147483647}" """, """ @@ -2001,12 +1864,10 @@ public void TestLargeClosedRangeNumericQuantifier1() """, RegexOptions.None); - } [Fact] public void TestLargeClosedRangeNumericQuantifier2() - { - Test(""" + => Test(""" "a{0,2147483648}" """, $$""" @@ -2033,12 +1894,10 @@ public void TestLargeClosedRangeNumericQuantifier2() """, RegexOptions.None); - } [Fact] public void TestBadMinMaxClosedRangeNumericQuantifier() - { - Test(""" + => Test(""" "a{1,0}" """, $$""" @@ -2065,12 +1924,10 @@ public void TestBadMinMaxClosedRangeNumericQuantifier() """, RegexOptions.None); - } [Fact] public void TestLazyExactNumericQuantifier() - { - Test(""" + => Test(""" "a{0}?" """, """ @@ -2095,12 +1952,10 @@ public void TestLazyExactNumericQuantifier() """, RegexOptions.None); - } [Fact] public void TestLazyOpenNumericQuantifier() - { - Test(""" + => Test(""" "a{0,}?" """, """ @@ -2126,12 +1981,10 @@ public void TestLazyOpenNumericQuantifier() """, RegexOptions.None); - } [Fact] public void TestLazyClosedNumericQuantifier() - { - Test(""" + => Test(""" "a{0,1}?" """, """ @@ -2158,12 +2011,10 @@ public void TestLazyClosedNumericQuantifier() """, RegexOptions.None); - } [Fact] public void TestIncompleteNumericQuantifier1() - { - Test(""" + => Test(""" "a{" """, """ @@ -2180,12 +2031,10 @@ public void TestIncompleteNumericQuantifier1() """, RegexOptions.None); - } [Fact] public void TestIncompleteNumericQuantifier2() - { - Test(""" + => Test(""" "a{0" """, """ @@ -2202,12 +2051,10 @@ public void TestIncompleteNumericQuantifier2() """, RegexOptions.None); - } [Fact] public void TestIncompleteNumericQuantifier3() - { - Test(""" + => Test(""" "a{0," """, """ @@ -2224,12 +2071,10 @@ public void TestIncompleteNumericQuantifier3() """, RegexOptions.None); - } [Fact] public void TestIncompleteNumericQuantifier4() - { - Test(""" + => Test(""" "a{0,1" """, """ @@ -2246,12 +2091,10 @@ public void TestIncompleteNumericQuantifier4() """, RegexOptions.None); - } [Fact] public void TestNotNumericQuantifier1() - { - Test(""" + => Test(""" "a{0 }" """, """ @@ -2274,12 +2117,10 @@ public void TestNotNumericQuantifier1() """, RegexOptions.IgnorePatternWhitespace); - } [Fact] public void TestNotNumericQuantifier2() - { - Test(""" + => Test(""" "a{0, }" """, """ @@ -2302,12 +2143,10 @@ public void TestNotNumericQuantifier2() """, RegexOptions.IgnorePatternWhitespace); - } [Fact] public void TestNotNumericQuantifier3() - { - Test(""" + => Test(""" "a{0 ,}" """, """ @@ -2330,12 +2169,10 @@ public void TestNotNumericQuantifier3() """, RegexOptions.IgnorePatternWhitespace); - } [Fact] public void TestNotNumericQuantifier4() - { - Test(""" + => Test(""" "a{0 ,1}" """, """ @@ -2358,12 +2195,10 @@ public void TestNotNumericQuantifier4() """, RegexOptions.IgnorePatternWhitespace); - } [Fact] public void TestNotNumericQuantifier5() - { - Test(""" + => Test(""" "a{0, 1}" """, """ @@ -2386,12 +2221,10 @@ public void TestNotNumericQuantifier5() """, RegexOptions.IgnorePatternWhitespace); - } [Fact] public void TestNotNumericQuantifier6() - { - Test(""" + => Test(""" "a{0,1 }" """, """ @@ -2414,12 +2247,10 @@ public void TestNotNumericQuantifier6() """, RegexOptions.IgnorePatternWhitespace); - } [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/41425")] public void TestLegalOpenCloseBrace1() - { - Test(""" + => Test(""" @"{}" """, """ @@ -2436,12 +2267,10 @@ public void TestLegalOpenCloseBrace1() """, RegexOptions.None); - } [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/41425")] public void TestLegalOpenCloseBrace2() - { - Test(""" + => Test(""" @"{1, 2}" """, """ @@ -2458,12 +2287,10 @@ public void TestLegalOpenCloseBrace2() """, RegexOptions.None); - } [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/41425")] public void TestDanglingNumericQuantifier1() - { - Test(""" + => Test(""" @"{1}" """, $$""" @@ -2486,12 +2313,10 @@ public void TestDanglingNumericQuantifier1() """, RegexOptions.None); - } [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/41425")] public void TestDanglingNumericQuantifier2() - { - Test(""" + => Test(""" @"{1,2}" """, $$""" @@ -2514,12 +2339,10 @@ public void TestDanglingNumericQuantifier2() """, RegexOptions.None); - } [Fact] public void TestLazyQuantifierDueToIgnoredWhitespace() - { - Test(""" + => Test(""" "a* ?" """, """ @@ -2545,12 +2368,10 @@ public void TestLazyQuantifierDueToIgnoredWhitespace() """, RegexOptions.IgnorePatternWhitespace); - } [Fact] public void TestNonLazyQuantifierDueToNonIgnoredWhitespace() - { - Test(""" + => Test(""" "a* ?" """, """ @@ -2576,12 +2397,10 @@ public void TestNonLazyQuantifierDueToNonIgnoredWhitespace() """, RegexOptions.None); - } [Fact] public void TestAsteriskQuantifierAtStart() - { - Test(""" + => Test(""" "*" """, $""" @@ -2601,12 +2420,10 @@ public void TestAsteriskQuantifierAtStart() """, RegexOptions.None); - } [Fact] public void TestAsteriskQuantifierAtStartOfGroup() - { - Test(""" + => Test(""" "(*)" """, $""" @@ -2633,12 +2450,10 @@ public void TestAsteriskQuantifierAtStartOfGroup() """, RegexOptions.None); - } [Fact] public void TestAsteriskQuantifierAfterQuantifier() - { - Test(""" + => Test(""" "a**" """, $""" @@ -2664,12 +2479,10 @@ public void TestAsteriskQuantifierAfterQuantifier() """, RegexOptions.None); - } [Fact] public void TestPlusQuantifierAtStart() - { - Test(""" + => Test(""" "+" """, $""" @@ -2689,12 +2502,10 @@ public void TestPlusQuantifierAtStart() """, RegexOptions.None); - } [Fact] public void TestPlusQuantifierAtStartOfGroup() - { - Test(""" + => Test(""" "(+)" """, $""" @@ -2721,12 +2532,10 @@ public void TestPlusQuantifierAtStartOfGroup() """, RegexOptions.None); - } [Fact] public void TestPlusQuantifierAfterQuantifier() - { - Test(""" + => Test(""" "a*+" """, $""" @@ -2752,12 +2561,10 @@ public void TestPlusQuantifierAfterQuantifier() """, RegexOptions.None); - } [Fact] public void TestQuestionQuantifierAtStart() - { - Test(""" + => Test(""" "?" """, $""" @@ -2777,12 +2584,10 @@ public void TestQuestionQuantifierAtStart() """, RegexOptions.None); - } [Fact] public void TestQuestionQuantifierAtStartOfGroup() - { - Test(""" + => Test(""" "(?)" """, $""" @@ -2808,12 +2613,10 @@ public void TestQuestionQuantifierAtStartOfGroup() """, RegexOptions.None); - } [Fact] public void TestQuestionQuantifierAfterQuantifier() - { - Test(""" + => Test(""" "a*??" """, $""" @@ -2842,12 +2645,10 @@ public void TestQuestionQuantifierAfterQuantifier() """, RegexOptions.None); - } [Fact] public void TestNumericQuantifierAtStart() - { - Test(""" + => Test(""" "{0}" """, $$""" @@ -2870,12 +2671,10 @@ public void TestNumericQuantifierAtStart() """, RegexOptions.None); - } [Fact] public void TestNumericQuantifierAtStartOfGroup() - { - Test(""" + => Test(""" "({0})" """, $$""" @@ -2905,12 +2704,10 @@ public void TestNumericQuantifierAtStartOfGroup() """, RegexOptions.None); - } [Fact] public void TestNumericQuantifierAfterQuantifier() - { - Test(""" + => Test(""" "a*{0}" """, $$""" @@ -2939,12 +2736,10 @@ public void TestNumericQuantifierAfterQuantifier() """, RegexOptions.None); - } [Fact] public void TestNonNumericQuantifierAtStart() - { - Test(""" + => Test(""" "{0" """, """ @@ -2961,12 +2756,10 @@ public void TestNonNumericQuantifierAtStart() """, RegexOptions.None); - } [Fact] public void TestNonNumericQuantifierAtStartOfGroup() - { - Test(""" + => Test(""" "({0)" """, """ @@ -2990,12 +2783,10 @@ public void TestNonNumericQuantifierAtStartOfGroup() """, RegexOptions.None); - } [Fact] public void TestNonNumericQuantifierAfterQuantifier() - { - Test(""" + => Test(""" "a*{0" """, """ @@ -3018,12 +2809,10 @@ public void TestNonNumericQuantifierAfterQuantifier() """, RegexOptions.None); - } [Fact] public void TestEscapeAtEnd1() - { - Test(""" + => Test(""" @"\" """, $""" @@ -3044,12 +2833,10 @@ public void TestEscapeAtEnd1() """, RegexOptions.None); - } [Fact] public void TestEscapeAtEnd2() - { - Test(""" + => Test(""" "\\" """, $""" @@ -3070,12 +2857,10 @@ public void TestEscapeAtEnd2() """, RegexOptions.None); - } [Fact] public void TestSimpleEscape() - { - Test(""" + => Test(""" @"\w" """, """ @@ -3093,12 +2878,10 @@ public void TestSimpleEscape() """, RegexOptions.None); - } [Fact] public void TestPrimaryEscapes1() - { - Test(""" + => Test(""" @"\b\B\A\G\Z\z\w\W\s\W\s\S\d\D" """, """ @@ -3168,12 +2951,10 @@ public void TestPrimaryEscapes1() """, RegexOptions.None); - } [Fact] public void TestControlEscape1() - { - Test(""" + => Test(""" @"\c" """, $""" @@ -3195,12 +2976,10 @@ public void TestControlEscape1() """, RegexOptions.None); - } [Fact] public void TestControlEscape2() - { - Test(""" + => Test(""" @"\c<" """, $""" @@ -3225,12 +3004,10 @@ public void TestControlEscape2() """, RegexOptions.None); - } [Fact] public void TestControlEscape3() - { - Test(""" + => Test(""" @"\ca" """, """ @@ -3249,12 +3026,10 @@ public void TestControlEscape3() """, RegexOptions.None); - } [Fact] public void TestControlEscape4() - { - Test(""" + => Test(""" @"\cA" """, """ @@ -3273,12 +3048,10 @@ public void TestControlEscape4() """, RegexOptions.None); - } [Fact] public void TestControlEscape5() - { - Test(""" + => Test(""" @"\c A" """, $""" @@ -3303,12 +3076,10 @@ public void TestControlEscape5() """, RegexOptions.None); - } [Fact] public void TestControlEscape6() - { - Test(""" + => Test(""" @"\c(a)" """, $""" @@ -3340,12 +3111,10 @@ public void TestControlEscape6() """, RegexOptions.None); - } [Fact] public void TestControlEscape7() - { - Test(""" + => Test(""" @"\c>" """, $""" @@ -3370,12 +3139,10 @@ public void TestControlEscape7() """, RegexOptions.None); - } [Fact] public void TestControlEscape8() - { - Test(""" + => Test(""" @"\c?" """, $""" @@ -3400,12 +3167,10 @@ public void TestControlEscape8() """, RegexOptions.None); - } [Fact] public void TestControlEscape9() - { - Test(""" + => Test(""" @"\c@" """, """ @@ -3424,12 +3189,10 @@ public void TestControlEscape9() """, RegexOptions.None); - } [Fact] public void TestControlEscape10() - { - Test(""" + => Test(""" @"\c^" """, """ @@ -3448,12 +3211,10 @@ public void TestControlEscape10() """, RegexOptions.None); - } [Fact] public void TestControlEscape11() - { - Test(""" + => Test(""" @"\c_" """, """ @@ -3472,12 +3233,10 @@ public void TestControlEscape11() """, RegexOptions.None); - } [Fact] public void TestControlEscape12() - { - Test(""" + => Test(""" @"\c`" """, $""" @@ -3502,12 +3261,10 @@ public void TestControlEscape12() """, RegexOptions.None); - } [Fact] public void TestControlEscape13() - { - Test(""" + => Test(""" @"\c{" """, $$""" @@ -3532,12 +3289,10 @@ public void TestControlEscape13() """, RegexOptions.None); - } [Fact] public void TestControlEscape14() - { - Test(""" + => Test(""" @"\ca" """, """ @@ -3556,12 +3311,10 @@ public void TestControlEscape14() """, RegexOptions.None); - } [Fact] public void TestControlEscape15() - { - Test(""" + => Test(""" @"\cA" """, """ @@ -3580,12 +3333,10 @@ public void TestControlEscape15() """, RegexOptions.None); - } [Fact] public void TestControlEscape16() - { - Test(""" + => Test(""" @"\cz" """, """ @@ -3604,12 +3355,10 @@ public void TestControlEscape16() """, RegexOptions.None); - } [Fact] public void TestControlEscape17() - { - Test(""" + => Test(""" @"\cZ" """, """ @@ -3628,12 +3377,10 @@ public void TestControlEscape17() """, RegexOptions.None); - } [Fact] public void TestControlEscape18() - { - Test(""" + => Test(""" @"\c\" """, """ @@ -3652,12 +3399,10 @@ public void TestControlEscape18() """, RegexOptions.None); - } [Fact] public void TestControlEscape19() - { - Test(""" + => Test(""" @"\c]" """, """ @@ -3676,12 +3421,10 @@ public void TestControlEscape19() """, RegexOptions.None); - } [Fact] public void TestUnknownEscape1() - { - Test(""" + => Test(""" @"\m" """, $""" @@ -3702,12 +3445,10 @@ public void TestUnknownEscape1() """, RegexOptions.None); - } [Fact] public void TestHexEscape1() - { - Test(""" + => Test(""" @"\x" """, $""" @@ -3729,12 +3470,10 @@ public void TestHexEscape1() """, RegexOptions.None); - } [Fact] public void TestHexEscape2() - { - Test(""" + => Test(""" @"\x " """, $""" @@ -3759,12 +3498,10 @@ public void TestHexEscape2() """, RegexOptions.None); - } [Fact] public void TestHexEscape3() - { - Test(""" + => Test(""" @"\x0" """, $""" @@ -3786,12 +3523,10 @@ public void TestHexEscape3() """, RegexOptions.None); - } [Fact] public void TestHexEscape4() - { - Test(""" + => Test(""" @"\x0 " """, $""" @@ -3816,12 +3551,10 @@ public void TestHexEscape4() """, RegexOptions.None); - } [Fact] public void TestHexEscape5() - { - Test(""" + => Test(""" @"\x00" """, """ @@ -3840,12 +3573,10 @@ public void TestHexEscape5() """, RegexOptions.None); - } [Fact] public void TestHexEscape6() - { - Test(""" + => Test(""" @"\x00 " """, """ @@ -3867,12 +3598,10 @@ public void TestHexEscape6() """, RegexOptions.None); - } [Fact] public void TestHexEscape7() - { - Test(""" + => Test(""" @"\x000" """, """ @@ -3894,12 +3623,10 @@ public void TestHexEscape7() """, RegexOptions.None); - } [Fact] public void TestHexEscape8() - { - Test(""" + => Test(""" @"\xff" """, """ @@ -3918,12 +3645,10 @@ public void TestHexEscape8() """, RegexOptions.None); - } [Fact] public void TestHexEscape9() - { - Test(""" + => Test(""" @"\xFF" """, """ @@ -3942,12 +3667,10 @@ public void TestHexEscape9() """, RegexOptions.None); - } [Fact] public void TestHexEscape10() - { - Test(""" + => Test(""" @"\xfF" """, """ @@ -3966,12 +3689,10 @@ public void TestHexEscape10() """, RegexOptions.None); - } [Fact] public void TestHexEscape11() - { - Test(""" + => Test(""" @"\xfff" """, """ @@ -3993,12 +3714,10 @@ public void TestHexEscape11() """, RegexOptions.None); - } [Fact] public void TestHexEscape12() - { - Test(""" + => Test(""" @"\xgg" """, $""" @@ -4023,12 +3742,10 @@ public void TestHexEscape12() """, RegexOptions.None); - } [Fact] public void TestUnknownEscape2() - { - Test(""" + => Test(""" @"\m " """, $""" @@ -4052,12 +3769,10 @@ public void TestUnknownEscape2() """, RegexOptions.None); - } [Fact] public void TestUnicodeEscape1() - { - Test(""" + => Test(""" @"\u" """, $""" @@ -4079,12 +3794,10 @@ public void TestUnicodeEscape1() """, RegexOptions.None); - } [Fact] public void TestUnicodeEscape2() - { - Test(""" + => Test(""" @"\u0" """, $""" @@ -4106,12 +3819,10 @@ public void TestUnicodeEscape2() """, RegexOptions.None); - } [Fact] public void TestUnicodeEscape3() - { - Test(""" + => Test(""" @"\u00" """, $""" @@ -4133,12 +3844,10 @@ public void TestUnicodeEscape3() """, RegexOptions.None); - } [Fact] public void TestUnicodeEscape4() - { - Test(""" + => Test(""" @"\u000" """, $""" @@ -4160,12 +3869,10 @@ public void TestUnicodeEscape4() """, RegexOptions.None); - } [Fact] public void TestUnicodeEscape5() - { - Test(""" + => Test(""" @"\u0000" """, """ @@ -4184,12 +3891,10 @@ public void TestUnicodeEscape5() """, RegexOptions.None); - } [Fact] public void TestUnicodeEscape6() - { - Test(""" + => Test(""" @"\u0000 " """, """ @@ -4211,12 +3916,10 @@ public void TestUnicodeEscape6() """, RegexOptions.None); - } [Fact] public void TestUnicodeEscape7() - { - Test(""" + => Test(""" @"\u " """, $""" @@ -4241,12 +3944,10 @@ public void TestUnicodeEscape7() """, RegexOptions.None); - } [Fact] public void TestUnicodeEscape8() - { - Test(""" + => Test(""" @"\u0 " """, $""" @@ -4271,12 +3972,10 @@ public void TestUnicodeEscape8() """, RegexOptions.None); - } [Fact] public void TestUnicodeEscape9() - { - Test(""" + => Test(""" @"\ugggg" """, $""" @@ -4301,12 +4000,10 @@ public void TestUnicodeEscape9() """, RegexOptions.None); - } [Fact] public void TestOctalEscape1() - { - Test(""" + => Test(""" @"\0" """, """ @@ -4324,12 +4021,10 @@ public void TestOctalEscape1() """, RegexOptions.None); - } [Fact] public void TestOctalEscape2() - { - Test(""" + => Test(""" @"\0 " """, """ @@ -4350,12 +4045,10 @@ public void TestOctalEscape2() """, RegexOptions.None); - } [Fact] public void TestOctalEscape3() - { - Test(""" + => Test(""" @"\00" """, """ @@ -4373,12 +4066,10 @@ public void TestOctalEscape3() """, RegexOptions.None); - } [Fact] public void TestOctalEscape4() - { - Test(""" + => Test(""" @"\00 " """, """ @@ -4399,12 +4090,10 @@ public void TestOctalEscape4() """, RegexOptions.None); - } [Fact] public void TestOctalEscape5() - { - Test(""" + => Test(""" @"\000" """, """ @@ -4422,12 +4111,10 @@ public void TestOctalEscape5() """, RegexOptions.None); - } [Fact] public void TestOctalEscape6() - { - Test(""" + => Test(""" @"\000 " """, """ @@ -4448,12 +4135,10 @@ public void TestOctalEscape6() """, RegexOptions.None); - } [Fact] public void TestOctalEscape7() - { - Test(""" + => Test(""" @"\0000" """, """ @@ -4474,12 +4159,10 @@ public void TestOctalEscape7() """, RegexOptions.None); - } [Fact] public void TestOctalEscape8() - { - Test(""" + => Test(""" @"\0000 " """, """ @@ -4500,12 +4183,10 @@ public void TestOctalEscape8() """, RegexOptions.None); - } [Fact] public void TestOctalEscape9() - { - Test(""" + => Test(""" @"\7" """, $""" @@ -4526,12 +4207,10 @@ public void TestOctalEscape9() """, RegexOptions.None); - } [Fact] public void TestOctalEscape10() - { - Test(""" + => Test(""" @"\78" """, """ @@ -4552,12 +4231,10 @@ public void TestOctalEscape10() """, RegexOptions.None); - } [Fact] public void TestOctalEscape11() - { - Test(""" + => Test(""" @"\8" """, $""" @@ -4578,12 +4255,10 @@ public void TestOctalEscape11() """, RegexOptions.None); - } [Fact] public void TestOctalEscapeEcmascript1() - { - Test(""" + => Test(""" @"\40" """, """ @@ -4601,12 +4276,10 @@ public void TestOctalEscapeEcmascript1() """, RegexOptions.ECMAScript); - } [Fact] public void TestOctalEscapeEcmascript2() - { - Test(""" + => Test(""" @"\401" """, """ @@ -4627,12 +4300,10 @@ public void TestOctalEscapeEcmascript2() """, RegexOptions.ECMAScript); - } [Fact] public void TestOctalEscapeEcmascript3() - { - Test(""" + => Test(""" @"\37" """, """ @@ -4650,12 +4321,10 @@ public void TestOctalEscapeEcmascript3() """, RegexOptions.ECMAScript); - } [Fact] public void TestOctalEscapeEcmascript4() - { - Test(""" + => Test(""" @"\371" """, """ @@ -4673,12 +4342,10 @@ public void TestOctalEscapeEcmascript4() """, RegexOptions.ECMAScript); - } [Fact] public void TestOctalEscapeEcmascript5() - { - Test(""" + => Test(""" @"\0000" """, """ @@ -4699,12 +4366,10 @@ public void TestOctalEscapeEcmascript5() """, RegexOptions.ECMAScript); - } [Fact] public void TestKCaptureEscape1() - { - Test(""" + => Test(""" @"\k" """, $""" @@ -4725,12 +4390,10 @@ public void TestKCaptureEscape1() """, RegexOptions.None); - } [Fact] public void TestKCaptureEscape2() - { - Test(""" + => Test(""" @"\k " """, $""" @@ -4754,12 +4417,10 @@ public void TestKCaptureEscape2() """, RegexOptions.None); - } [Fact] public void TestKCaptureEscape3() - { - Test(""" + => Test(""" @"\k<" """, $""" @@ -4783,12 +4444,10 @@ public void TestKCaptureEscape3() """, RegexOptions.None); - } [Fact] public void TestKCaptureEscape4() - { - Test(""" + => Test(""" @"\k< " """, $""" @@ -4812,12 +4471,10 @@ public void TestKCaptureEscape4() """, RegexOptions.None); - } [Fact] public void TestKCaptureEscape5() - { - Test(""" + => Test(""" @"\k<0" """, $""" @@ -4841,12 +4498,10 @@ public void TestKCaptureEscape5() """, RegexOptions.None); - } [Fact] public void TestKCaptureEscape6() - { - Test(""" + => Test(""" @"\k<0 " """, $""" @@ -4870,12 +4525,10 @@ public void TestKCaptureEscape6() """, RegexOptions.None); - } [Fact] public void TestKCaptureEscape7() - { - Test(""" + => Test(""" @"\k<0>" """, """ @@ -4896,12 +4549,10 @@ public void TestKCaptureEscape7() """, RegexOptions.None); - } [Fact] public void TestKCaptureEscape8() - { - Test(""" + => Test(""" @"\k<0> " """, """ @@ -4925,12 +4576,10 @@ public void TestKCaptureEscape8() """, RegexOptions.None); - } [Fact] public void TestKCaptureEscape9() - { - Test(""" + => Test(""" @"\k<00> " """, """ @@ -4954,12 +4603,10 @@ public void TestKCaptureEscape9() """, RegexOptions.None); - } [Fact] public void TestKCaptureEscape10() - { - Test(""" + => Test(""" @"\k " """, $""" @@ -4986,12 +4633,10 @@ public void TestKCaptureEscape10() """, RegexOptions.None); - } [Fact] public void TestKCaptureEscape11() - { - Test(""" + => Test(""" @"(?)\k " """, """ @@ -5026,12 +4671,10 @@ public void TestKCaptureEscape11() """, RegexOptions.None); - } [Fact] public void TestKCaptureEcmaEscape1() - { - Test(""" + => Test(""" @"\k" """, $""" @@ -5052,12 +4695,10 @@ public void TestKCaptureEcmaEscape1() """, RegexOptions.ECMAScript); - } [Fact] public void TestKCaptureEcmaEscape2() - { - Test(""" + => Test(""" @"\k " """, $""" @@ -5081,12 +4722,10 @@ public void TestKCaptureEcmaEscape2() """, RegexOptions.ECMAScript); - } [Fact] public void TestKCaptureEcmaEscape3() - { - Test(""" + => Test(""" @"\k<" """, $""" @@ -5110,12 +4749,10 @@ public void TestKCaptureEcmaEscape3() """, RegexOptions.ECMAScript); - } [Fact] public void TestKCaptureEcmaEscape4() - { - Test(""" + => Test(""" @"\k< " """, """ @@ -5136,12 +4773,10 @@ public void TestKCaptureEcmaEscape4() """, RegexOptions.ECMAScript); - } [Fact] public void TestKCaptureEcmaEscape5() - { - Test(""" + => Test(""" @"\k<0" """, """ @@ -5162,12 +4797,10 @@ public void TestKCaptureEcmaEscape5() """, RegexOptions.ECMAScript); - } [Fact] public void TestKCaptureEcmaEscape6() - { - Test(""" + => Test(""" @"\k<0 " """, """ @@ -5188,12 +4821,10 @@ public void TestKCaptureEcmaEscape6() """, RegexOptions.ECMAScript); - } [Fact] public void TestKCaptureEcmaEscape7() - { - Test(""" + => Test(""" @"\k<0>" """, """ @@ -5214,12 +4845,10 @@ public void TestKCaptureEcmaEscape7() """, RegexOptions.ECMAScript); - } [Fact] public void TestKCaptureEcmaEscape8() - { - Test(""" + => Test(""" @"\k<0> " """, """ @@ -5243,12 +4872,10 @@ public void TestKCaptureEcmaEscape8() """, RegexOptions.ECMAScript); - } [Fact] public void TestKCaptureQuoteEscape3() - { - Test(""" + => Test(""" @"\k'" """, $""" @@ -5272,12 +4899,10 @@ public void TestKCaptureQuoteEscape3() """, RegexOptions.None); - } [Fact] public void TestKCaptureQuoteEscape4() - { - Test(""" + => Test(""" @"\k' " """, $""" @@ -5301,12 +4926,10 @@ public void TestKCaptureQuoteEscape4() """, RegexOptions.None); - } [Fact] public void TestKCaptureQuoteEscape5() - { - Test(""" + => Test(""" @"\k'0" """, $""" @@ -5330,12 +4953,10 @@ public void TestKCaptureQuoteEscape5() """, RegexOptions.None); - } [Fact] public void TestKCaptureQuoteEscape6() - { - Test(""" + => Test(""" @"\k'0 " """, $""" @@ -5359,12 +4980,10 @@ public void TestKCaptureQuoteEscape6() """, RegexOptions.None); - } [Fact] public void TestKCaptureQuoteEscape7() - { - Test(""" + => Test(""" @"\k'0'" """, """ @@ -5385,12 +5004,10 @@ public void TestKCaptureQuoteEscape7() """, RegexOptions.None); - } [Fact] public void TestKCaptureQuoteEscape8() - { - Test(""" + => Test(""" @"\k'0' " """, """ @@ -5414,12 +5031,10 @@ public void TestKCaptureQuoteEscape8() """, RegexOptions.None); - } [Fact] public void TestKCaptureQuoteEscape9() - { - Test(""" + => Test(""" @"\k'00' " """, """ @@ -5443,12 +5058,10 @@ public void TestKCaptureQuoteEscape9() """, RegexOptions.None); - } [Fact] public void TestKCaptureQuoteEscape10() - { - Test(""" + => Test(""" @"\k'a' " """, $""" @@ -5475,12 +5088,10 @@ public void TestKCaptureQuoteEscape10() """, RegexOptions.None); - } [Fact] public void TestKCaptureQuoteEscape11() - { - Test(""" + => Test(""" @"(?)\k'a' " """, """ @@ -5515,12 +5126,10 @@ public void TestKCaptureQuoteEscape11() """, RegexOptions.None); - } [Fact] public void TestKCaptureWrongQuote1() - { - Test(""" + => Test(""" @"\k<0' " """, $""" @@ -5544,12 +5153,10 @@ public void TestKCaptureWrongQuote1() """, RegexOptions.None); - } [Fact] public void TestKCaptureWrongQuote2() - { - Test(""" + => Test(""" @"\k'0> " """, $""" @@ -5573,12 +5180,10 @@ public void TestKCaptureWrongQuote2() """, RegexOptions.None); - } [Fact] public void TestCaptureEscape1() - { - Test(""" + => Test(""" @"\" """, $""" @@ -5599,12 +5204,10 @@ public void TestCaptureEscape1() """, RegexOptions.None); - } [Fact] public void TestCaptureEscape2() - { - Test(""" + => Test(""" @"\ " """, """ @@ -5622,12 +5225,10 @@ public void TestCaptureEscape2() """, RegexOptions.None); - } [Fact] public void TestCaptureEscape3() - { - Test(""" + => Test(""" @"\<" """, """ @@ -5645,12 +5246,10 @@ public void TestCaptureEscape3() """, RegexOptions.None); - } [Fact] public void TestCaptureEscape4() - { - Test(""" + => Test(""" @"\< " """, """ @@ -5671,12 +5270,10 @@ public void TestCaptureEscape4() """, RegexOptions.None); - } [Fact] public void TestCaptureEscape5() - { - Test(""" + => Test(""" @"\<0" """, """ @@ -5697,12 +5294,10 @@ public void TestCaptureEscape5() """, RegexOptions.None); - } [Fact] public void TestCaptureEscape6() - { - Test(""" + => Test(""" @"\<0 " """, """ @@ -5723,12 +5318,10 @@ public void TestCaptureEscape6() """, RegexOptions.None); - } [Fact] public void TestCaptureEscape7() - { - Test(""" + => Test(""" @"\<0>" """, """ @@ -5748,12 +5341,10 @@ public void TestCaptureEscape7() """, RegexOptions.None); - } [Fact] public void TestCaptureEscape8() - { - Test(""" + => Test(""" @"\<0> " """, """ @@ -5776,12 +5367,10 @@ public void TestCaptureEscape8() """, RegexOptions.None); - } [Fact] public void TestCaptureEscape9() - { - Test(""" + => Test(""" @"\<00> " """, """ @@ -5804,12 +5393,10 @@ public void TestCaptureEscape9() """, RegexOptions.None); - } [Fact] public void TestCaptureEscape10() - { - Test(""" + => Test(""" @"\ " """, $""" @@ -5835,12 +5422,10 @@ public void TestCaptureEscape10() """, RegexOptions.None); - } [Fact] public void TestCaptureEscape11() - { - Test(""" + => Test(""" @"(?)\ " """, """ @@ -5874,12 +5459,10 @@ public void TestCaptureEscape11() """, RegexOptions.None); - } [Fact] public void TestCaptureEcmaEscape1() - { - Test(""" + => Test(""" @"\" """, $""" @@ -5900,12 +5483,10 @@ public void TestCaptureEcmaEscape1() """, RegexOptions.ECMAScript); - } [Fact] public void TestCaptureEcmaEscape2() - { - Test(""" + => Test(""" @"\ " """, """ @@ -5923,12 +5504,10 @@ public void TestCaptureEcmaEscape2() """, RegexOptions.ECMAScript); - } [Fact] public void TestCaptureEcmaEscape3() - { - Test(""" + => Test(""" @"\<" """, """ @@ -5946,12 +5525,10 @@ public void TestCaptureEcmaEscape3() """, RegexOptions.ECMAScript); - } [Fact] public void TestCaptureEcmaEscape4() - { - Test(""" + => Test(""" @"\< " """, """ @@ -5972,12 +5549,10 @@ public void TestCaptureEcmaEscape4() """, RegexOptions.ECMAScript); - } [Fact] public void TestCaptureEcmaEscape5() - { - Test(""" + => Test(""" @"\<0" """, """ @@ -5998,12 +5573,10 @@ public void TestCaptureEcmaEscape5() """, RegexOptions.ECMAScript); - } [Fact] public void TestCaptureEcmaEscape6() - { - Test(""" + => Test(""" @"\<0 " """, """ @@ -6024,12 +5597,10 @@ public void TestCaptureEcmaEscape6() """, RegexOptions.ECMAScript); - } [Fact] public void TestCaptureEcmaEscape7() - { - Test(""" + => Test(""" @"\<0>" """, """ @@ -6049,12 +5620,10 @@ public void TestCaptureEcmaEscape7() """, RegexOptions.ECMAScript); - } [Fact] public void TestCaptureEcmaEscape8() - { - Test(""" + => Test(""" @"\<0> " """, """ @@ -6077,12 +5646,10 @@ public void TestCaptureEcmaEscape8() """, RegexOptions.ECMAScript); - } [Fact] public void TestCaptureQuoteEscape3() - { - Test(""" + => Test(""" @"\'" """, """ @@ -6100,12 +5667,10 @@ public void TestCaptureQuoteEscape3() """, RegexOptions.None); - } [Fact] public void TestCaptureQuoteEscape4() - { - Test(""" + => Test(""" @"\' " """, """ @@ -6126,12 +5691,10 @@ public void TestCaptureQuoteEscape4() """, RegexOptions.None); - } [Fact] public void TestCaptureQuoteEscape5() - { - Test(""" + => Test(""" @"\'0" """, """ @@ -6152,12 +5715,10 @@ public void TestCaptureQuoteEscape5() """, RegexOptions.None); - } [Fact] public void TestCaptureQuoteEscape6() - { - Test(""" + => Test(""" @"\'0 " """, """ @@ -6178,12 +5739,10 @@ public void TestCaptureQuoteEscape6() """, RegexOptions.None); - } [Fact] public void TestCaptureQuoteEscape7() - { - Test(""" + => Test(""" @"\'0'" """, """ @@ -6203,12 +5762,10 @@ public void TestCaptureQuoteEscape7() """, RegexOptions.None); - } [Fact] public void TestCaptureQuoteEscape8() - { - Test(""" + => Test(""" @"\'0' " """, """ @@ -6231,12 +5788,10 @@ public void TestCaptureQuoteEscape8() """, RegexOptions.None); - } [Fact] public void TestCaptureQuoteEscape9() - { - Test(""" + => Test(""" @"\'00' " """, """ @@ -6259,12 +5814,10 @@ public void TestCaptureQuoteEscape9() """, RegexOptions.None); - } [Fact] public void TestCaptureQuoteEscape10() - { - Test(""" + => Test(""" @"\'a' " """, $""" @@ -6290,12 +5843,10 @@ public void TestCaptureQuoteEscape10() """, RegexOptions.None); - } [Fact] public void TestCaptureQuoteEscape11() - { - Test(""" + => Test(""" @"(?)\'a' " """, """ @@ -6329,12 +5880,10 @@ public void TestCaptureQuoteEscape11() """, RegexOptions.None); - } [Fact] public void TestCaptureWrongQuote1() - { - Test(""" + => Test(""" @"\<0' " """, """ @@ -6355,12 +5904,10 @@ public void TestCaptureWrongQuote1() """, RegexOptions.None); - } [Fact] public void TestCaptureWrongQuote2() - { - Test(""" + => Test(""" @"\'0> " """, """ @@ -6381,12 +5928,10 @@ public void TestCaptureWrongQuote2() """, RegexOptions.None); - } [Fact] public void TestDefinedCategoryEscape() - { - Test(""" + => Test(""" "\\p{Cc}" """, """ @@ -6407,12 +5952,10 @@ public void TestDefinedCategoryEscape() """, RegexOptions.None); - } [Fact] public void TestDefinedCategoryEscapeWithSpaces1() - { - Test(""" + => Test(""" "\\p{ Cc }" """, $$""" @@ -6436,12 +5979,10 @@ public void TestDefinedCategoryEscapeWithSpaces1() """, RegexOptions.None); - } [Fact] public void TestDefinedCategoryEscapeWithSpaces2() - { - Test(""" + => Test(""" "\\p{ Cc }" """, $$""" @@ -6477,12 +6018,10 @@ public void TestDefinedCategoryEscapeWithSpaces2() """, RegexOptions.IgnorePatternWhitespace); - } [Fact] public void TestDefinedCategoryEscapeWithSpaces3() - { - Test(""" + => Test(""" "\\p {Cc}" """, $$""" @@ -6509,12 +6048,10 @@ public void TestDefinedCategoryEscapeWithSpaces3() """, RegexOptions.IgnorePatternWhitespace); - } [Fact] public void TestUndefinedCategoryEscape() - { - Test(""" + => Test(""" "\\p{xxx}" """, $$""" @@ -6538,12 +6075,10 @@ public void TestUndefinedCategoryEscape() """, RegexOptions.None); - } [Fact] public void TestTooShortCategoryEscape1() - { - Test(""" + => Test(""" "\\p" """, $""" @@ -6564,12 +6099,10 @@ public void TestTooShortCategoryEscape1() """, RegexOptions.None); - } [Fact] public void TestTooShortCategoryEscape2() - { - Test(""" + => Test(""" "\\p{" """, $$""" @@ -6593,12 +6126,10 @@ public void TestTooShortCategoryEscape2() """, RegexOptions.None); - } [Fact] public void TestTooShortCategoryEscape3() - { - Test(""" + => Test(""" "\\p{}" """, $$""" @@ -6622,12 +6153,10 @@ public void TestTooShortCategoryEscape3() """, RegexOptions.None); - } [Fact] public void TestTooShortCategoryEscape4() - { - Test(""" + => Test(""" "\\p{} " """, $$""" @@ -6651,12 +6180,10 @@ public void TestTooShortCategoryEscape4() """, RegexOptions.None); - } [Fact] public void TestTooShortCategoryEscape5() - { - Test(""" + => Test(""" "\\p {} " """, $$""" @@ -6680,12 +6207,10 @@ public void TestTooShortCategoryEscape5() """, RegexOptions.None); - } [Fact] public void TestTooShortCategoryEscape6() - { - Test(""" + => Test(""" "\\p{Cc " """, $$""" @@ -6709,12 +6234,10 @@ public void TestTooShortCategoryEscape6() """, RegexOptions.None); - } [Fact] public void TestCategoryNameWithDash() - { - Test(""" + => Test(""" "\\p{IsArabicPresentationForms-A}" """, """ @@ -6735,12 +6258,10 @@ public void TestCategoryNameWithDash() """, RegexOptions.None); - } [Fact] public void TestNonCapturingGrouping1() - { - Test(""" + => Test(""" "(?:)" """, """ @@ -6761,12 +6282,10 @@ public void TestNonCapturingGrouping1() """, RegexOptions.None); - } [Fact] public void TestNonCapturingGrouping2() - { - Test(""" + => Test(""" "(?:a)" """, """ @@ -6791,12 +6310,10 @@ public void TestNonCapturingGrouping2() """, RegexOptions.None); - } [Fact] public void TestNonCapturingGrouping3() - { - Test(""" + => Test(""" "(?:" """, $""" @@ -6820,12 +6337,10 @@ public void TestNonCapturingGrouping3() """, RegexOptions.None); - } [Fact] public void TestNonCapturingGrouping4() - { - Test(""" + => Test(""" "(?: " """, $""" @@ -6853,12 +6368,10 @@ public void TestNonCapturingGrouping4() """, RegexOptions.IgnorePatternWhitespace); - } [Fact] public void TestPositiveLookaheadGrouping1() - { - Test(""" + => Test(""" "(?=)" """, """ @@ -6879,12 +6392,10 @@ public void TestPositiveLookaheadGrouping1() """, RegexOptions.None); - } [Fact] public void TestPositiveLookaheadGrouping2() - { - Test(""" + => Test(""" "(?=a)" """, """ @@ -6909,12 +6420,10 @@ public void TestPositiveLookaheadGrouping2() """, RegexOptions.None); - } [Fact] public void TestPositiveLookaheadGrouping3() - { - Test(""" + => Test(""" "(?=" """, $""" @@ -6938,12 +6447,10 @@ public void TestPositiveLookaheadGrouping3() """, RegexOptions.None); - } [Fact] public void TestPositiveLookaheadGrouping4() - { - Test(""" + => Test(""" "(?= " """, $""" @@ -6971,12 +6478,10 @@ public void TestPositiveLookaheadGrouping4() """, RegexOptions.IgnorePatternWhitespace); - } [Fact] public void TestNegativeLookaheadGrouping1() - { - Test(""" + => Test(""" "(?!)" """, """ @@ -6997,12 +6502,10 @@ public void TestNegativeLookaheadGrouping1() """, RegexOptions.None); - } [Fact] public void TestNegativeLookaheadGrouping2() - { - Test(""" + => Test(""" "(?!a)" """, """ @@ -7027,12 +6530,10 @@ public void TestNegativeLookaheadGrouping2() """, RegexOptions.None); - } [Fact] public void TestNegativeLookaheadGrouping3() - { - Test(""" + => Test(""" "(?!" """, $""" @@ -7056,12 +6557,10 @@ public void TestNegativeLookaheadGrouping3() """, RegexOptions.None); - } [Fact] public void TestNegativeLookaheadGrouping4() - { - Test(""" + => Test(""" "(?! " """, $""" @@ -7089,12 +6588,10 @@ public void TestNegativeLookaheadGrouping4() """, RegexOptions.IgnorePatternWhitespace); - } [Fact] public void TestAtomicGrouping1() - { - Test(""" + => Test(""" "(?>)" """, """ @@ -7115,12 +6612,10 @@ public void TestAtomicGrouping1() """, RegexOptions.None); - } [Fact] public void TestAtomicGrouping2() - { - Test(""" + => Test(""" "(?>a)" """, """ @@ -7145,12 +6640,10 @@ public void TestAtomicGrouping2() """, RegexOptions.None); - } [Fact] public void TestAtomicGrouping3() - { - Test(""" + => Test(""" "(?>" """, $""" @@ -7174,12 +6667,10 @@ public void TestAtomicGrouping3() """, RegexOptions.None); - } [Fact] public void TestAtomicGrouping4() - { - Test(""" + => Test(""" "(?> " """, $""" @@ -7207,12 +6698,10 @@ public void TestAtomicGrouping4() """, RegexOptions.IgnorePatternWhitespace); - } [Fact] public void TestPositiveLookbehindGrouping1() - { - Test(""" + => Test(""" "(?<=)" """, """ @@ -7234,12 +6723,10 @@ public void TestPositiveLookbehindGrouping1() """, RegexOptions.None); - } [Fact] public void TestPositiveLookbehindGrouping2() - { - Test(""" + => Test(""" "(?<=a)" """, """ @@ -7265,12 +6752,10 @@ public void TestPositiveLookbehindGrouping2() """, RegexOptions.None); - } [Fact] public void TestPositiveLookbehindGrouping3() - { - Test(""" + => Test(""" "(?<=" """, $""" @@ -7295,12 +6780,10 @@ public void TestPositiveLookbehindGrouping3() """, RegexOptions.None); - } [Fact] public void TestPositiveLookbehindGrouping4() - { - Test(""" + => Test(""" "(?<= " """, $""" @@ -7329,12 +6812,10 @@ public void TestPositiveLookbehindGrouping4() """, RegexOptions.IgnorePatternWhitespace); - } [Fact] public void TestNegativeLookbehindGrouping1() - { - Test(""" + => Test(""" "(? @@ -7356,12 +6837,10 @@ public void TestNegativeLookbehindGrouping1() """, RegexOptions.None); - } [Fact] public void TestNegativeLookbehindGrouping2() - { - Test(""" + => Test(""" "(? @@ -7387,12 +6866,10 @@ public void TestNegativeLookbehindGrouping2() """, RegexOptions.None); - } [Fact] public void TestNegativeLookbehindGrouping3() - { - Test(""" + => Test(""" "(? @@ -7417,12 +6894,10 @@ public void TestNegativeLookbehindGrouping3() """, RegexOptions.None); - } [Fact] public void TestNegativeLookbehindGrouping4() - { - Test(""" + => Test(""" "(? @@ -7451,12 +6926,10 @@ public void TestNegativeLookbehindGrouping4() """, RegexOptions.IgnorePatternWhitespace); - } [Fact] public void TestNamedCapture1() - { - Test(""" + => Test(""" "(?<" """, $""" @@ -7483,12 +6956,10 @@ public void TestNamedCapture1() """, RegexOptions.IgnorePatternWhitespace); - } [Fact] public void TestNamedCapture2() - { - Test(""" + => Test(""" "(?<>" """, $""" @@ -7515,12 +6986,10 @@ public void TestNamedCapture2() """, RegexOptions.IgnorePatternWhitespace); - } [Fact] public void TestNamedCapture3() - { - Test(""" + => Test(""" "(? @@ -7549,12 +7018,10 @@ public void TestNamedCapture3() """, RegexOptions.IgnorePatternWhitespace); - } [Fact] public void TestNamedCapture4() - { - Test(""" + => Test(""" "(?" """, $""" @@ -7582,12 +7049,10 @@ public void TestNamedCapture4() """, RegexOptions.IgnorePatternWhitespace); - } [Fact] public void TestNamedCapture5() - { - Test(""" + => Test(""" "(?a" """, $""" @@ -7619,12 +7084,10 @@ public void TestNamedCapture5() """, RegexOptions.IgnorePatternWhitespace); - } [Fact] public void TestNamedCapture6() - { - Test(""" + => Test(""" "(?a)" """, """ @@ -7653,12 +7116,10 @@ public void TestNamedCapture6() """, RegexOptions.IgnorePatternWhitespace); - } [Fact] public void TestNamedCapture7() - { - Test(""" + => Test(""" "(?a)" """, $""" @@ -7690,12 +7151,10 @@ public void TestNamedCapture7() """, RegexOptions.None); - } [Fact] public void TestNamedCapture8() - { - Test(""" + => Test(""" "(?a)" """, $""" @@ -7730,12 +7189,10 @@ public void TestNamedCapture8() """, RegexOptions.IgnorePatternWhitespace); - } [Fact] public void TestNamedCapture9() - { - Test(""" + => Test(""" "(?< a>a)" """, $""" @@ -7765,12 +7222,10 @@ public void TestNamedCapture9() """, RegexOptions.None); - } [Fact] public void TestNamedCapture10() - { - Test(""" + => Test(""" "(?< a>a)" """, $""" @@ -7803,12 +7258,10 @@ public void TestNamedCapture10() """, RegexOptions.IgnorePatternWhitespace); - } [Fact] public void TestNamedCapture11() - { - Test(""" + => Test(""" "(?< a >a)" """, $""" @@ -7838,12 +7291,10 @@ public void TestNamedCapture11() """, RegexOptions.None); - } [Fact] public void TestNamedCapture12() - { - Test(""" + => Test(""" "(?< a >a)" """, $""" @@ -7882,12 +7333,10 @@ public void TestNamedCapture12() """, RegexOptions.IgnorePatternWhitespace); - } [Fact] public void TestNamedCapture13() - { - Test(""" + => Test(""" "(?a)" """, """ @@ -7916,12 +7365,10 @@ public void TestNamedCapture13() """, RegexOptions.IgnorePatternWhitespace); - } [Fact] public void TestZeroNumberCapture() - { - Test(""" + => Test(""" "(?<0>a)" """, $""" @@ -7951,12 +7398,10 @@ public void TestZeroNumberCapture() """, RegexOptions.IgnorePatternWhitespace); - } [Fact] public void TestNumericNumberCapture1() - { - Test(""" + => Test(""" "(?<1>a)" """, """ @@ -7984,12 +7429,10 @@ public void TestNumericNumberCapture1() """, RegexOptions.IgnorePatternWhitespace); - } [Fact] public void TestNumericNumberCapture2() - { - Test(""" + => Test(""" "(?<10>a)" """, """ @@ -8017,12 +7460,10 @@ public void TestNumericNumberCapture2() """, RegexOptions.IgnorePatternWhitespace); - } [Fact] public void TestNumericNumberCapture3() - { - Test(""" + => Test(""" "(?<1>)" """, """ @@ -8046,12 +7487,10 @@ public void TestNumericNumberCapture3() """, RegexOptions.None); - } [Fact] public void TestNumericNumberCapture4() - { - Test(""" + => Test(""" "(?<1> )" """, """ @@ -8079,12 +7518,10 @@ public void TestNumericNumberCapture4() """, RegexOptions.None); - } [Fact] public void TestNumericNumberCapture6() - { - Test(""" + => Test(""" "(?<1> )" """, """ @@ -8111,12 +7548,10 @@ public void TestNumericNumberCapture6() """, RegexOptions.IgnorePatternWhitespace); - } [Fact] public void TestBalancingGrouping1() - { - Test(""" + => Test(""" "(?<-" """, $""" @@ -8146,12 +7581,10 @@ public void TestBalancingGrouping1() """, RegexOptions.IgnorePatternWhitespace); - } [Fact] public void TestBalancingGrouping2() - { - Test(""" + => Test(""" "(?<-0" """, $""" @@ -8180,12 +7613,10 @@ public void TestBalancingGrouping2() """, RegexOptions.IgnorePatternWhitespace); - } [Fact] public void TestBalancingGrouping3() - { - Test(""" + => Test(""" "(?<-0)" """, $""" @@ -8213,12 +7644,10 @@ public void TestBalancingGrouping3() """, RegexOptions.IgnorePatternWhitespace); - } [Fact] public void TestBalancingGrouping4() - { - Test(""" + => Test(""" "(?<-0>" """, $""" @@ -8246,12 +7675,10 @@ public void TestBalancingGrouping4() """, RegexOptions.IgnorePatternWhitespace); - } [Fact] public void TestBalancingGrouping5() - { - Test(""" + => Test(""" "(?<-0>)" """, """ @@ -8276,12 +7703,10 @@ public void TestBalancingGrouping5() """, RegexOptions.IgnorePatternWhitespace); - } [Fact] public void TestBalancingGrouping6() - { - Test(""" + => Test(""" "(?<-0 >)" """, $""" @@ -8316,12 +7741,10 @@ public void TestBalancingGrouping6() """, RegexOptions.IgnorePatternWhitespace); - } [Fact] public void TestBalancingGrouping7() - { - Test(""" + => Test(""" "(?<- 0 >)" """, $""" @@ -8362,12 +7785,10 @@ public void TestBalancingGrouping7() """, RegexOptions.IgnorePatternWhitespace); - } [Fact] public void TestBalancingGrouping8() - { - Test(""" + => Test(""" "(?<- 0>)" """, $""" @@ -8402,12 +7823,10 @@ public void TestBalancingGrouping8() """, RegexOptions.IgnorePatternWhitespace); - } [Fact] public void TestBalancingGrouping9() - { - Test(""" + => Test(""" "(?<-00>)" """, """ @@ -8432,12 +7851,10 @@ public void TestBalancingGrouping9() """, RegexOptions.IgnorePatternWhitespace); - } [Fact] public void TestBalancingGrouping10() - { - Test(""" + => Test(""" "(? @@ -8469,12 +7886,10 @@ public void TestBalancingGrouping10() """, RegexOptions.IgnorePatternWhitespace); - } [Fact] public void TestBalancingGrouping11() - { - Test(""" + => Test(""" "(? @@ -8505,12 +7920,10 @@ public void TestBalancingGrouping11() """, RegexOptions.IgnorePatternWhitespace); - } [Fact] public void TestBalancingGrouping12() - { - Test(""" + => Test(""" "(? @@ -8540,12 +7953,10 @@ public void TestBalancingGrouping12() """, RegexOptions.IgnorePatternWhitespace); - } [Fact] public void TestBalancingGrouping13() - { - Test(""" + => Test(""" "(?" """, $""" @@ -8575,12 +7986,10 @@ public void TestBalancingGrouping13() """, RegexOptions.IgnorePatternWhitespace); - } [Fact] public void TestBalancingGrouping14() - { - Test(""" + => Test(""" "(?)" """, """ @@ -8607,12 +8016,10 @@ public void TestBalancingGrouping14() """, RegexOptions.IgnorePatternWhitespace); - } [Fact] public void TestBalancingGrouping15() - { - Test(""" + => Test(""" "(?)" """, $""" @@ -8649,12 +8056,10 @@ public void TestBalancingGrouping15() """, RegexOptions.IgnorePatternWhitespace); - } [Fact] public void TestBalancingGrouping16() - { - Test(""" + => Test(""" "(?)" """, $""" @@ -8697,12 +8102,10 @@ public void TestBalancingGrouping16() """, RegexOptions.IgnorePatternWhitespace); - } [Fact] public void TestBalancingGrouping17() - { - Test(""" + => Test(""" "(?)" """, $""" @@ -8739,12 +8142,10 @@ public void TestBalancingGrouping17() """, RegexOptions.IgnorePatternWhitespace); - } [Fact] public void TestBalancingGrouping18() - { - Test(""" + => Test(""" "(?)" """, """ @@ -8771,12 +8172,10 @@ public void TestBalancingGrouping18() """, RegexOptions.IgnorePatternWhitespace); - } [Fact] public void TestBalancingGroupingUndefinedReference1() - { - Test(""" + => Test(""" "(?<-1>)" """, $""" @@ -8804,12 +8203,10 @@ public void TestBalancingGroupingUndefinedReference1() """, RegexOptions.IgnorePatternWhitespace); - } [Fact] public void TestBalancingGroupingDefinedReferenceBehind() - { - Test(""" + => Test(""" "()(?<-1>)" """, """ @@ -8840,12 +8237,10 @@ public void TestBalancingGroupingDefinedReferenceBehind() """, RegexOptions.IgnorePatternWhitespace); - } [Fact] public void TestBalancingGroupingDefinedReferenceAhead() - { - Test(""" + => Test(""" "(?<-1>)()" """, """ @@ -8876,12 +8271,10 @@ public void TestBalancingGroupingDefinedReferenceAhead() """, RegexOptions.IgnorePatternWhitespace); - } [Fact] public void TestBalancingGroupingNamedReferenceBehind() - { - Test(""" + => Test(""" "(?)(?<-a>)" """, """ @@ -8917,12 +8310,10 @@ public void TestBalancingGroupingNamedReferenceBehind() """, RegexOptions.IgnorePatternWhitespace); - } [Fact] public void TestBalancingGroupingNamedReferenceAhead() - { - Test(""" + => Test(""" "(?<-a>)(?)" """, """ @@ -8958,12 +8349,10 @@ public void TestBalancingGroupingNamedReferenceAhead() """, RegexOptions.IgnorePatternWhitespace); - } [Fact] public void TestBalancingGroupingNumberedReferenceBehind() - { - Test(""" + => Test(""" "(?<4>)(?<-4>)" """, """ @@ -8998,12 +8387,10 @@ public void TestBalancingGroupingNumberedReferenceBehind() """, RegexOptions.IgnorePatternWhitespace); - } [Fact] public void TestBalancingGroupingNumberedReferenceAhead() - { - Test(""" + => Test(""" "(?<-4>)(?<4>)" """, """ @@ -9038,12 +8425,10 @@ public void TestBalancingGroupingNumberedReferenceAhead() """, RegexOptions.IgnorePatternWhitespace); - } [Fact] public void TestBalancingGroupingAutoNumberedExists() - { - Test(""" + => Test(""" "(?)(?)(?<-1>)(?<-2>)" """, """ @@ -9101,12 +8486,10 @@ public void TestBalancingGroupingAutoNumberedExists() """, RegexOptions.IgnorePatternWhitespace); - } [Fact] public void TestBalancingGroupingAutoNumbers() - { - Test(""" + => Test(""" "()()(?<-0>)(?<-1>)(?<-2>)(?<-3>)" """, $""" @@ -9179,12 +8562,10 @@ public void TestBalancingGroupingAutoNumbers() """, RegexOptions.IgnorePatternWhitespace); - } [Fact] public void TestBalancingGroupingAutoNumbers1() - { - Test(""" + => Test(""" "()(?)(?<-0>)(?<-1>)(?<-2>)(?<-3>)" """, $""" @@ -9262,12 +8643,10 @@ public void TestBalancingGroupingAutoNumbers1() """, RegexOptions.IgnorePatternWhitespace); - } [Fact] public void TestBalancingGroupingAutoNumbers2() - { - Test(""" + => Test(""" "(?)()(?<-0>)(?<-1>)(?<-2>)(?<-3>)" """, $""" @@ -9345,12 +8724,10 @@ public void TestBalancingGroupingAutoNumbers2() """, RegexOptions.IgnorePatternWhitespace); - } [Fact] public void TestBalancingGroupingAutoNumbers3() - { - Test(""" + => Test(""" "(?)(?)(?<-0>)(?<-1>)(?<-2>)(?<-3>)" """, $""" @@ -9433,12 +8810,10 @@ public void TestBalancingGroupingAutoNumbers3() """, RegexOptions.IgnorePatternWhitespace); - } [Fact] public void TestBalancingGroupingAutoNumbers4() - { - Test(""" + => Test(""" "(?<-0>)(?<-1>)(?<-2>)(?<-3>)()()" """, $""" @@ -9511,12 +8886,10 @@ public void TestBalancingGroupingAutoNumbers4() """, RegexOptions.IgnorePatternWhitespace); - } [Fact] public void TestBalancingGroupingAutoNumbers5_1() - { - Test(""" + => Test(""" "(?<-0>)(?<-1>)(?<-2>)(?<-3>)()(?" """, $""" @@ -9596,12 +8969,10 @@ public void TestBalancingGroupingAutoNumbers5_1() """, RegexOptions.IgnorePatternWhitespace); - } [Fact] public void TestBalancingGroupingAutoNumbers5() - { - Test(""" + => Test(""" "(?<-0>)(?<-1>)(?<-2>)(?<-3>)()(?)" """, $""" @@ -9679,12 +9050,10 @@ public void TestBalancingGroupingAutoNumbers5() """, RegexOptions.IgnorePatternWhitespace); - } [Fact] public void TestBalancingGroupingAutoNumbers6() - { - Test(""" + => Test(""" "(?<-0>)(?<-1>)(?<-2>)(?<-3>)(?)()" """, $""" @@ -9762,12 +9131,10 @@ public void TestBalancingGroupingAutoNumbers6() """, RegexOptions.IgnorePatternWhitespace); - } [Fact] public void TestBalancingGroupingAutoNumbers7_1() - { - Test(""" + => Test(""" "(?<-0>)(?<-1>)(?<-2>)(?<-3>)(?)(?" """, $""" @@ -9852,12 +9219,10 @@ public void TestBalancingGroupingAutoNumbers7_1() """, RegexOptions.IgnorePatternWhitespace); - } [Fact] public void TestBalancingGroupingAutoNumbers7() - { - Test(""" + => Test(""" "(?<-0>)(?<-1>)(?<-2>)(?<-3>)(?)(?)" """, $""" @@ -9940,12 +9305,10 @@ public void TestBalancingGroupingAutoNumbers7() """, RegexOptions.IgnorePatternWhitespace); - } [Fact] public void TestReferenceToBalancingGroupCaptureName1() - { - Test(""" + => Test(""" "(?)(?)" """, """ @@ -9985,12 +9348,10 @@ public void TestReferenceToBalancingGroupCaptureName1() """, RegexOptions.IgnorePatternWhitespace); - } [Fact] public void TestReferenceToBalancingGroupCaptureName2() - { - Test(""" + => Test(""" "(?)(?<-a>)" """, """ @@ -10028,12 +9389,10 @@ public void TestReferenceToBalancingGroupCaptureName2() """, RegexOptions.IgnorePatternWhitespace); - } [Fact] public void TestReferenceToSameBalancingGroup() - { - Test(""" + => Test(""" "(?)" """, """ @@ -10060,12 +9419,10 @@ public void TestReferenceToSameBalancingGroup() """, RegexOptions.IgnorePatternWhitespace); - } [Fact] public void TestQuoteNamedCapture() - { - Test(""" + => Test(""" "(?'a')" """, """ @@ -10090,12 +9447,10 @@ public void TestQuoteNamedCapture() """, RegexOptions.IgnorePatternWhitespace); - } [Fact] public void TestQuoteBalancingCapture1() - { - Test(""" + => Test(""" "(?'-0')" """, """ @@ -10120,12 +9475,10 @@ public void TestQuoteBalancingCapture1() """, RegexOptions.IgnorePatternWhitespace); - } [Fact] public void TestQuoteBalancingCapture2() - { - Test(""" + => Test(""" "(?'a-0')" """, """ @@ -10152,12 +9505,10 @@ public void TestQuoteBalancingCapture2() """, RegexOptions.IgnorePatternWhitespace); - } [Fact] public void TestMismatchedOpenCloseCapture1() - { - Test(""" + => Test(""" "(? @@ -10191,12 +9542,10 @@ public void TestMismatchedOpenCloseCapture1() """, RegexOptions.IgnorePatternWhitespace); - } [Fact] public void TestMismatchedOpenCloseCapture2() - { - Test(""" + => Test(""" "(?'a-0>)" """, $""" @@ -10230,12 +9579,10 @@ public void TestMismatchedOpenCloseCapture2() """, RegexOptions.IgnorePatternWhitespace); - } [Fact] public void TestConditionalCapture1() - { - Test(""" + => Test(""" "(?(" """, $""" @@ -10263,12 +9610,10 @@ public void TestConditionalCapture1() """, RegexOptions.IgnorePatternWhitespace); - } [Fact] public void TestConditionalCapture2() - { - Test(""" + => Test(""" "(?(0" """, $""" @@ -10295,12 +9640,10 @@ public void TestConditionalCapture2() """, RegexOptions.IgnorePatternWhitespace); - } [Fact] public void TestConditionalCapture3() - { - Test(""" + => Test(""" "(?(0)" """, $""" @@ -10326,12 +9669,10 @@ public void TestConditionalCapture3() """, RegexOptions.IgnorePatternWhitespace); - } [Fact] public void TestConditionalCapture4() - { - Test(""" + => Test(""" "(?(0))" """, """ @@ -10354,12 +9695,10 @@ public void TestConditionalCapture4() """, RegexOptions.IgnorePatternWhitespace); - } [Fact] public void TestConditionalCapture5() - { - Test(""" + => Test(""" "(?(0)a)" """, """ @@ -10386,12 +9725,10 @@ public void TestConditionalCapture5() """, RegexOptions.IgnorePatternWhitespace); - } [Fact] public void TestConditionalCapture6() - { - Test(""" + => Test(""" "(?(0)a|)" """, """ @@ -10422,12 +9759,10 @@ public void TestConditionalCapture6() """, RegexOptions.IgnorePatternWhitespace); - } [Fact] public void TestConditionalCapture7() - { - Test(""" + => Test(""" "(?(0)a|b)" """, """ @@ -10462,12 +9797,10 @@ public void TestConditionalCapture7() """, RegexOptions.IgnorePatternWhitespace); - } [Fact] public void TestConditionalCapture8() - { - Test(""" + => Test(""" "(?(0)a|b|)" """, $""" @@ -10509,12 +9842,10 @@ public void TestConditionalCapture8() """, RegexOptions.IgnorePatternWhitespace); - } [Fact] public void TestConditionalCapture9() - { - Test(""" + => Test(""" "(?(0)a|b|c)" """, $""" @@ -10560,12 +9891,10 @@ public void TestConditionalCapture9() """, RegexOptions.IgnorePatternWhitespace); - } [Fact] public void TestConditionalCapture10() - { - Test(""" + => Test(""" "(?(0 )" """, $""" @@ -10594,12 +9923,10 @@ public void TestConditionalCapture10() """, RegexOptions.IgnorePatternWhitespace); - } [Fact] public void TestConditionalCapture11() - { - Test(""" + => Test(""" "(?(1))" """, $""" @@ -10625,12 +9952,10 @@ public void TestConditionalCapture11() """, RegexOptions.IgnorePatternWhitespace); - } [Fact] public void TestConditionalCapture12() - { - Test(""" + => Test(""" "(?(00))" """, """ @@ -10653,12 +9978,10 @@ public void TestConditionalCapture12() """, RegexOptions.IgnorePatternWhitespace); - } [Fact] public void TestConditionalCapture13() - { - Test(""" + => Test(""" "(?(0)a|b|c|d)" """, $""" @@ -10713,12 +10036,10 @@ public void TestConditionalCapture13() """, RegexOptions.IgnorePatternWhitespace); - } [Fact] public void TestConditionalCapture14() - { - Test(""" + => Test(""" "(?(0)a|b|c|d|e)" """, $""" @@ -10782,12 +10103,10 @@ public void TestConditionalCapture14() """, RegexOptions.IgnorePatternWhitespace); - } [Fact] public void TestNamedConditionalCapture1() - { - Test(""" + => Test(""" "(?(a))" """, """ @@ -10816,12 +10135,10 @@ public void TestNamedConditionalCapture1() """, RegexOptions.IgnorePatternWhitespace); - } [Fact] public void TestNamedConditionalCapture2() - { - Test(""" + => Test(""" "(?)(?(a))" """, """ @@ -10855,12 +10172,10 @@ public void TestNamedConditionalCapture2() """, RegexOptions.IgnorePatternWhitespace); - } [Fact] public void TestNamedConditionalCapture3() - { - Test(""" + => Test(""" "(?)(?(a ))" """, """ @@ -10903,12 +10218,10 @@ public void TestNamedConditionalCapture3() """, RegexOptions.IgnorePatternWhitespace); - } [Fact] public void TestNamedConditionalCapture4() - { - Test(""" + => Test(""" "(?)(?( a))" """, """ @@ -10951,12 +10264,10 @@ public void TestNamedConditionalCapture4() """, RegexOptions.IgnorePatternWhitespace); - } [Fact] public void TestNestedGroupsInConditionalGrouping1() - { - Test(""" + => Test(""" "(?(()a()))" """, """ @@ -10997,12 +10308,10 @@ public void TestNestedGroupsInConditionalGrouping1() """, RegexOptions.None); - } [Fact] public void TestNestedGroupsInConditionalGrouping2() - { - Test(""" + => Test(""" "(?((?)a(?)))" """, """ @@ -11053,12 +10362,10 @@ public void TestNestedGroupsInConditionalGrouping2() """, RegexOptions.None); - } [Fact] public void TestCaptureInConditionalGrouping1() - { - Test(""" + => Test(""" "(?(?'" """, $""" @@ -11092,12 +10399,10 @@ public void TestCaptureInConditionalGrouping1() """, RegexOptions.IgnorePatternWhitespace); - } [Fact] public void TestCaptureInConditionalGrouping2() - { - Test(""" + => Test(""" "(?(?'x'))" """, $""" @@ -11129,12 +10434,10 @@ public void TestCaptureInConditionalGrouping2() """, RegexOptions.IgnorePatternWhitespace); - } [Fact] public void TestCommentInConditionalGrouping1() - { - Test(""" + => Test(""" "(?(?#" """, $""" @@ -11173,12 +10476,10 @@ public void TestCommentInConditionalGrouping1() """, RegexOptions.IgnorePatternWhitespace); - } [Fact] public void TestCommentInConditionalGrouping2() - { - Test(""" + => Test(""" "(?(?#)" """, $""" @@ -11217,12 +10518,10 @@ public void TestCommentInConditionalGrouping2() """, RegexOptions.IgnorePatternWhitespace); - } [Fact] public void TestCommentInConditionalGrouping3() - { - Test(""" + => Test(""" "(?(?#))" """, $""" @@ -11261,12 +10560,10 @@ public void TestCommentInConditionalGrouping3() """, RegexOptions.IgnorePatternWhitespace); - } [Fact] public void TestAngleCaptureInConditionalGrouping1() - { - Test(""" + => Test(""" "(?(?<" """, $""" @@ -11300,12 +10597,10 @@ public void TestAngleCaptureInConditionalGrouping1() """, RegexOptions.IgnorePatternWhitespace); - } [Fact] public void TestAngleCaptureInConditionalGrouping2() - { - Test(""" + => Test(""" "(?(? @@ -11339,12 +10634,10 @@ public void TestAngleCaptureInConditionalGrouping2() """, RegexOptions.IgnorePatternWhitespace); - } [Fact] public void TestAngleCaptureInConditionalGrouping3() - { - Test(""" + => Test(""" "(?(?" """, $""" @@ -11377,12 +10670,10 @@ public void TestAngleCaptureInConditionalGrouping3() """, RegexOptions.IgnorePatternWhitespace); - } [Fact] public void TestAngleCaptureInConditionalGrouping4() - { - Test(""" + => Test(""" "(?(?)" """, $""" @@ -11415,12 +10706,10 @@ public void TestAngleCaptureInConditionalGrouping4() """, RegexOptions.IgnorePatternWhitespace); - } [Fact] public void TestAngleCaptureInConditionalGrouping5() - { - Test(""" + => Test(""" "(?(?))" """, $""" @@ -11452,12 +10741,10 @@ public void TestAngleCaptureInConditionalGrouping5() """, RegexOptions.IgnorePatternWhitespace); - } [Fact] public void TestLookbehindAssertionInConditionalGrouping1() - { - Test(""" + => Test(""" "(?(?<=))" """, """ @@ -11485,12 +10772,10 @@ public void TestLookbehindAssertionInConditionalGrouping1() """, RegexOptions.IgnorePatternWhitespace); - } [Fact] public void TestLookbehindAssertionInConditionalGrouping2() - { - Test(""" + => Test(""" "(?(? @@ -11518,12 +10803,10 @@ public void TestLookbehindAssertionInConditionalGrouping2() """, RegexOptions.IgnorePatternWhitespace); - } [Fact] public void TestBackreference1() - { - Test(""" + => Test(""" @"\1" """, $""" @@ -11544,12 +10827,10 @@ public void TestBackreference1() """, RegexOptions.None); - } [Fact] public void TestBackreference2() - { - Test(""" + => Test(""" @"\1 " """, $""" @@ -11573,12 +10854,10 @@ public void TestBackreference2() """, RegexOptions.None); - } [Fact] public void TestBackreference3() - { - Test(""" + => Test(""" @"()\1" """, """ @@ -11602,12 +10881,10 @@ public void TestBackreference3() """, RegexOptions.None); - } [Fact] public void TestBackreference4() - { - Test(""" + => Test(""" @"()\1 " """, """ @@ -11634,12 +10911,10 @@ public void TestBackreference4() """, RegexOptions.None); - } [Fact] public void TestBackreference5() - { - Test(""" + => Test(""" @"()\10 " """, """ @@ -11666,12 +10941,10 @@ public void TestBackreference5() """, RegexOptions.None); - } [Fact] public void TestEcmascriptBackreference1() - { - Test(""" + => Test(""" @"\1" """, """ @@ -11689,12 +10962,10 @@ public void TestEcmascriptBackreference1() """, RegexOptions.ECMAScript); - } [Fact] public void TestEcmascriptBackreference2() - { - Test(""" + => Test(""" @"\1 " """, """ @@ -11715,12 +10986,10 @@ public void TestEcmascriptBackreference2() """, RegexOptions.ECMAScript); - } [Fact] public void TestEcmascriptBackreference3() - { - Test(""" + => Test(""" @"()\1" """, """ @@ -11744,12 +11013,10 @@ public void TestEcmascriptBackreference3() """, RegexOptions.ECMAScript); - } [Fact] public void TestEcmaBackreference4() - { - Test(""" + => Test(""" @"()\1 " """, """ @@ -11776,12 +11043,10 @@ public void TestEcmaBackreference4() """, RegexOptions.ECMAScript); - } [Fact] public void TestEcmascriptBackreference5() - { - Test(""" + => Test(""" @"()\10 " """, """ @@ -11808,12 +11073,10 @@ public void TestEcmascriptBackreference5() """, RegexOptions.ECMAScript); - } [Fact] public void TestEcmascriptBackreference6() - { - Test(""" + => Test(""" @"()()()()()()()()()()\10 " """, """ @@ -11894,12 +11157,10 @@ public void TestEcmascriptBackreference6() """, RegexOptions.ECMAScript); - } [Fact] public void TestCharacterClass1() - { - Test(""" + => Test(""" @"[" """, $""" @@ -11921,12 +11182,10 @@ public void TestCharacterClass1() """, RegexOptions.None); - } [Fact] public void TestCharacterClass2() - { - Test(""" + => Test(""" @"[ " """, $""" @@ -11952,12 +11211,10 @@ public void TestCharacterClass2() """, RegexOptions.None); - } [Fact] public void TestCharacterClass3() - { - Test(""" + => Test(""" @"[]" """, $""" @@ -11983,12 +11240,10 @@ public void TestCharacterClass3() """, RegexOptions.None); - } [Fact] public void TestCharacterClass4() - { - Test(""" + => Test(""" @"[] " """, $""" @@ -12014,12 +11269,10 @@ public void TestCharacterClass4() """, RegexOptions.None); - } [Fact] public void TestCharacterClass5() - { - Test(""" + => Test(""" @"[a]" """, """ @@ -12042,12 +11295,10 @@ public void TestCharacterClass5() """, RegexOptions.None); - } [Fact] public void TestCharacterClass6() - { - Test(""" + => Test(""" @"[a] " """, """ @@ -12073,12 +11324,10 @@ public void TestCharacterClass6() """, RegexOptions.None); - } [Fact] public void TestCharacterClass7() - { - Test(""" + => Test(""" @"[a-" """, $""" @@ -12110,12 +11359,10 @@ public void TestCharacterClass7() """, RegexOptions.None); - } [Fact] public void TestCharacterClass8() - { - Test(""" + => Test(""" @"[a- " """, $""" @@ -12148,12 +11395,10 @@ public void TestCharacterClass8() """, RegexOptions.None); - } [Fact] public void TestCharacterClass9() - { - Test(""" + => Test(""" @"[a-]" """, """ @@ -12176,12 +11421,10 @@ public void TestCharacterClass9() """, RegexOptions.None); - } [Fact] public void TestCharacterClass10() - { - Test(""" + => Test(""" @"[a-] " """, """ @@ -12207,12 +11450,10 @@ public void TestCharacterClass10() """, RegexOptions.None); - } [Fact] public void TestCharacterClass11() - { - Test(""" + => Test(""" @"[a-b]" """, """ @@ -12241,12 +11482,10 @@ public void TestCharacterClass11() """, RegexOptions.None); - } [Fact] public void TestCharacterClass12() - { - Test(""" + => Test(""" @"[a-b] " """, """ @@ -12278,12 +11517,10 @@ public void TestCharacterClass12() """, RegexOptions.None); - } [Fact] public void TestCharacterClass13() - { - Test(""" + => Test(""" @"[a-[b]] " """, """ @@ -12321,12 +11558,10 @@ public void TestCharacterClass13() """, RegexOptions.None); - } [Fact] public void TestCharacterClass14() - { - Test(""" + => Test(""" @"[a-b-[c]] " """, """ @@ -12370,12 +11605,10 @@ public void TestCharacterClass14() """, RegexOptions.None); - } [Fact] public void TestCharacterClass15() - { - Test(""" + => Test(""" @"[a-[b]-c] " """, $""" @@ -12419,12 +11652,10 @@ public void TestCharacterClass15() """, RegexOptions.None); - } [Fact] public void TestCharacterClass16() - { - Test(""" + => Test(""" @"[[a]-b] " """, """ @@ -12450,12 +11681,10 @@ public void TestCharacterClass16() """, RegexOptions.None); - } [Fact] public void TestCharacterClass17() - { - Test(""" + => Test(""" @"[[a]-[b]] " """, """ @@ -12493,12 +11722,10 @@ public void TestCharacterClass17() """, RegexOptions.None); - } [Fact] public void TestCharacterClass18() - { - Test(""" + => Test(""" @"[\w-a] " """, """ @@ -12528,12 +11755,10 @@ public void TestCharacterClass18() """, RegexOptions.None); - } [Fact] public void TestCharacterClass19() - { - Test(""" + => Test(""" @"[a-\w] " """, $""" @@ -12569,12 +11794,10 @@ public void TestCharacterClass19() """, RegexOptions.None); - } [Fact] public void TestCharacterClass20() - { - Test(""" + => Test(""" @"[\p{llll}-a] " """, $$""" @@ -12610,12 +11833,10 @@ public void TestCharacterClass20() """, RegexOptions.None); - } [Fact] public void TestCharacterClass21() - { - Test(""" + => Test(""" @"[\p{Lu}-a] " """, """ @@ -12648,12 +11869,10 @@ public void TestCharacterClass21() """, RegexOptions.None); - } [Fact] public void TestCharacterClass22() - { - Test(""" + => Test(""" @"[a-\p{Lu}] " """, $$""" @@ -12692,12 +11911,10 @@ public void TestCharacterClass22() """, RegexOptions.None); - } [Fact] public void TestCharacterClass23() - { - Test(""" + => Test(""" @"[a-[:Ll:]] " """, """ @@ -12735,12 +11952,10 @@ public void TestCharacterClass23() """, RegexOptions.None); - } [Fact] public void TestCharacterClass24() - { - Test(""" + => Test(""" @"[a-[:Ll]] " """, """ @@ -12778,12 +11993,10 @@ public void TestCharacterClass24() """, RegexOptions.None); - } [Fact] public void TestCharacterClass25() - { - Test(""" + => Test(""" @"[a-[:" """, $""" @@ -12821,12 +12034,10 @@ public void TestCharacterClass25() """, RegexOptions.None); - } [Fact] public void TestCharacterClass26() - { - Test(""" + => Test(""" @"[a-[:L" """, $""" @@ -12864,12 +12075,10 @@ public void TestCharacterClass26() """, RegexOptions.None); - } [Fact] public void TestCharacterClass27() - { - Test(""" + => Test(""" @"[a-[:L:" """, $""" @@ -12907,12 +12116,10 @@ public void TestCharacterClass27() """, RegexOptions.None); - } [Fact] public void TestCharacterClass28() - { - Test(""" + => Test(""" @"[a-[:L:]" """, $""" @@ -12950,12 +12157,10 @@ public void TestCharacterClass28() """, RegexOptions.None); - } [Fact] public void TestCharacterClass29() - { - Test(""" + => Test(""" @"[\-]" """, """ @@ -12979,12 +12184,10 @@ public void TestCharacterClass29() """, RegexOptions.None); - } [Fact] public void TestCharacterClass30() - { - Test(""" + => Test(""" @"[a-b-c] " """, """ @@ -13019,12 +12222,10 @@ public void TestCharacterClass30() """, RegexOptions.None); - } [Fact] public void TestCharacterClass31() - { - Test(""" + => Test(""" @"[-b-c] " """, """ @@ -13059,12 +12260,10 @@ public void TestCharacterClass31() """, RegexOptions.None); - } [Fact] public void TestCharacterClass32() - { - Test(""" + => Test(""" @"[-[b] " """, """ @@ -13090,12 +12289,10 @@ public void TestCharacterClass32() """, RegexOptions.None); - } [Fact] public void TestCharacterClass33() - { - Test(""" + => Test(""" @"[-[b]] " """, """ @@ -13121,12 +12318,10 @@ public void TestCharacterClass33() """, RegexOptions.None); - } [Fact] public void TestCharacterClass34() - { - Test(""" + => Test(""" @"[--b " """, $""" @@ -13161,12 +12356,10 @@ public void TestCharacterClass34() """, RegexOptions.None); - } [Fact] public void TestCharacterClass35() - { - Test(""" + => Test(""" @"[--b] " """, """ @@ -13198,12 +12391,10 @@ public void TestCharacterClass35() """, RegexOptions.None); - } [Fact] public void TestCharacterClass36() - { - Test(""" + => Test(""" @"[--[b " """, $""" @@ -13241,12 +12432,10 @@ public void TestCharacterClass36() """, RegexOptions.None); - } [Fact] public void TestCharacterClass37() - { - Test(""" + => Test(""" @"[--[b] " """, $""" @@ -13288,12 +12477,10 @@ public void TestCharacterClass37() """, RegexOptions.None); - } [Fact] public void TestCharacterClass38() - { - Test(""" + => Test(""" @"[--[b]] " """, """ @@ -13331,12 +12518,10 @@ public void TestCharacterClass38() """, RegexOptions.None); - } [Fact] public void TestCharacterClass39() - { - Test(""" + => Test(""" @"[a--[b " """, $""" @@ -13372,12 +12557,10 @@ public void TestCharacterClass39() """, RegexOptions.None); - } [Fact] public void TestCharacterClass40() - { - Test(""" + => Test(""" @"[,--[a] " """, """ @@ -13412,12 +12595,10 @@ public void TestCharacterClass40() """, RegexOptions.None); - } [Fact] public void TestCharacterClass41() - { - Test(""" + => Test(""" @"[,--[a]] " """, """ @@ -13452,12 +12633,10 @@ public void TestCharacterClass41() """, RegexOptions.None); - } [Fact] public void TestCharacterClass42() - { - Test(""" + => Test(""" @"[\s-a]" """, """ @@ -13484,12 +12663,10 @@ public void TestCharacterClass42() """, RegexOptions.None); - } [Fact] public void TestCharacterClass43() - { - Test(""" + => Test(""" @"[\p{Lu}-a]" """, """ @@ -13519,12 +12696,10 @@ public void TestCharacterClass43() """, RegexOptions.None); - } [Fact] public void TestCharacterClass44() - { - Test(""" + => Test(""" @"[\p{Lu}-a]" """, """ @@ -13554,12 +12729,10 @@ public void TestCharacterClass44() """, RegexOptions.None); - } [Fact] public void TestNegatedCharacterClass1() - { - Test(""" + => Test(""" @"[a]" """, """ @@ -13582,12 +12755,10 @@ public void TestNegatedCharacterClass1() """, RegexOptions.None); - } [Fact] public void TestCharacterClassRange1() - { - Test(""" + => Test(""" @"[\c<-\c>]" """, $""" @@ -13630,12 +12801,10 @@ public void TestCharacterClassRange1() """, RegexOptions.None); - } [Fact] public void TestCharacterClassRange2() - { - Test(""" + => Test(""" @"[\c>-\c<]" """, $""" @@ -13678,12 +12847,10 @@ public void TestCharacterClassRange2() """, RegexOptions.None); - } [Fact] public void TestCharacterClassRange3() - { - Test(""" + => Test(""" @"[\c>-a]" """, $""" @@ -13720,12 +12887,10 @@ public void TestCharacterClassRange3() """, RegexOptions.None); - } [Fact] public void TestCharacterClassRange4() - { - Test(""" + => Test(""" @"[a-\c>]" """, $""" @@ -13762,12 +12927,10 @@ public void TestCharacterClassRange4() """, RegexOptions.None); - } [Fact] public void TestCharacterClassRange5() - { - Test(""" + => Test(""" @"[a--]" """, $""" @@ -13799,12 +12962,10 @@ public void TestCharacterClassRange5() """, RegexOptions.None); - } [Fact] public void TestCharacterClassRange6() - { - Test(""" + => Test(""" @"[--a]" """, """ @@ -13833,12 +12994,10 @@ public void TestCharacterClassRange6() """, RegexOptions.None); - } [Fact] public void TestCharacterClassRange7() - { - Test(""" + => Test(""" @"[a-\-]" """, $""" @@ -13871,12 +13030,10 @@ public void TestCharacterClassRange7() """, RegexOptions.None); - } [Fact] public void TestCharacterClassRange8() - { - Test(""" + => Test(""" @"[\--a]" """, """ @@ -13903,12 +13060,10 @@ public void TestCharacterClassRange8() """, RegexOptions.None); - } [Fact] public void TestCharacterClassRange9() - { - Test(""" + => Test(""" @"[\0-\1]" """, """ @@ -13939,12 +13094,10 @@ public void TestCharacterClassRange9() """, RegexOptions.None); - } [Fact] public void TestCharacterClassRange10() - { - Test(""" + => Test(""" @"[\1-\0]" """, $""" @@ -13978,12 +13131,10 @@ public void TestCharacterClassRange10() """, RegexOptions.None); - } [Fact] public void TestCharacterClassRange11() - { - Test(""" + => Test(""" @"[\0-\01]" """, """ @@ -14014,12 +13165,10 @@ public void TestCharacterClassRange11() """, RegexOptions.None); - } [Fact] public void TestCharacterClassRange12() - { - Test(""" + => Test(""" @"[\01-\0]" """, $""" @@ -14053,12 +13202,10 @@ public void TestCharacterClassRange12() """, RegexOptions.None); - } [Fact] public void TestCharacterClassRange13() - { - Test(""" + => Test(""" @"[[:x:]-a]" """, """ @@ -14084,12 +13231,10 @@ public void TestCharacterClassRange13() """, RegexOptions.None); - } [Fact] public void TestCharacterClassRange14() - { - Test(""" + => Test(""" @"[a-[:x:]]" """, """ @@ -14124,12 +13269,10 @@ public void TestCharacterClassRange14() """, RegexOptions.None); - } [Fact] public void TestCharacterClassRange15() - { - Test(""" + => Test(""" @"[\0-\ca]" """, """ @@ -14161,12 +13304,10 @@ public void TestCharacterClassRange15() """, RegexOptions.None); - } [Fact] public void TestCharacterClassRange16() - { - Test(""" + => Test(""" @"[\ca-\0]" """, $""" @@ -14201,12 +13342,10 @@ public void TestCharacterClassRange16() """, RegexOptions.None); - } [Fact] public void TestCharacterClassRange17() - { - Test(""" + => Test(""" @"[\ca-\cA]" """, """ @@ -14239,12 +13378,10 @@ public void TestCharacterClassRange17() """, RegexOptions.None); - } [Fact] public void TestCharacterClassRange18() - { - Test(""" + => Test(""" @"[\cA-\ca]" """, """ @@ -14277,12 +13414,10 @@ public void TestCharacterClassRange18() """, RegexOptions.None); - } [Fact] public void TestCharacterClassRange19() - { - Test(""" + => Test(""" @"[\u0-\u1]" """, $""" @@ -14319,12 +13454,10 @@ public void TestCharacterClassRange19() """, RegexOptions.None); - } [Fact] public void TestCharacterClassRange20() - { - Test(""" + => Test(""" @"[\u1-\u0]" """, $""" @@ -14361,12 +13494,10 @@ public void TestCharacterClassRange20() """, RegexOptions.None); - } [Fact] public void TestCharacterClassRange21() - { - Test(""" + => Test(""" @"[\u0000-\u0000]" """, """ @@ -14399,12 +13530,10 @@ public void TestCharacterClassRange21() """, RegexOptions.None); - } [Fact] public void TestCharacterClassRange22() - { - Test(""" + => Test(""" @"[\u0000-\u0001]" """, """ @@ -14437,12 +13566,10 @@ public void TestCharacterClassRange22() """, RegexOptions.None); - } [Fact] public void TestCharacterClassRange23() - { - Test(""" + => Test(""" @"[\u0001-\u0000]" """, $""" @@ -14478,12 +13605,10 @@ public void TestCharacterClassRange23() """, RegexOptions.None); - } [Fact] public void TestCharacterClassRange24() - { - Test(""" + => Test(""" @"[\u0001-a]" """, """ @@ -14514,12 +13639,10 @@ public void TestCharacterClassRange24() """, RegexOptions.None); - } [Fact] public void TestCharacterClassRange25() - { - Test(""" + => Test(""" @"[a-\u0001]" """, $""" @@ -14553,12 +13676,10 @@ public void TestCharacterClassRange25() """, RegexOptions.None); - } [Fact] public void TestCharacterClassRange26() - { - Test(""" + => Test(""" @"[a-a]" """, """ @@ -14587,12 +13708,10 @@ public void TestCharacterClassRange26() """, RegexOptions.None); - } [Fact] public void TestCharacterClassRange27() - { - Test(""" + => Test(""" @"[a-A]" """, $""" @@ -14624,12 +13743,10 @@ public void TestCharacterClassRange27() """, RegexOptions.None); - } [Fact] public void TestCharacterClassRange28() - { - Test(""" + => Test(""" @"[A-a]" """, """ @@ -14658,12 +13775,10 @@ public void TestCharacterClassRange28() """, RegexOptions.None); - } [Fact] public void TestCharacterClassRange29() - { - Test(""" + => Test(""" @"[a-a]" """, """ @@ -14692,12 +13807,10 @@ public void TestCharacterClassRange29() """, RegexOptions.IgnoreCase); - } [Fact] public void TestCharacterClassRange30() - { - Test(""" + => Test(""" @"[a-A]" """, $""" @@ -14729,12 +13842,10 @@ public void TestCharacterClassRange30() """, RegexOptions.IgnoreCase); - } [Fact] public void TestCharacterClassRange31() - { - Test(""" + => Test(""" @"[A-a]" """, """ @@ -14763,12 +13874,10 @@ public void TestCharacterClassRange31() """, RegexOptions.IgnoreCase); - } [Fact] public void TestCharacterClassRange32() - { - Test(""" + => Test(""" @"[a-\x61]" """, """ @@ -14799,12 +13908,10 @@ public void TestCharacterClassRange32() """, RegexOptions.None); - } [Fact] public void TestCharacterClassRange33() - { - Test(""" + => Test(""" @"[\x61-a]" """, """ @@ -14835,12 +13942,10 @@ public void TestCharacterClassRange33() """, RegexOptions.None); - } [Fact] public void TestCharacterClassRange34() - { - Test(""" + => Test(""" @"[a-\x60]" """, $""" @@ -14874,12 +13979,10 @@ public void TestCharacterClassRange34() """, RegexOptions.None); - } [Fact] public void TestCharacterClassRange35() - { - Test(""" + => Test(""" @"[\x62-a]" """, $""" @@ -14913,12 +14016,10 @@ public void TestCharacterClassRange35() """, RegexOptions.None); - } [Fact] public void TestCharacterClassRange36() - { - Test(""" + => Test(""" @"[a-\x62]" """, """ @@ -14949,12 +14050,10 @@ public void TestCharacterClassRange36() """, RegexOptions.None); - } [Fact] public void TestCharacterClassRange37() - { - Test(""" + => Test(""" @"[\x62-a]" """, $""" @@ -14988,12 +14087,10 @@ public void TestCharacterClassRange37() """, RegexOptions.None); - } [Fact] public void TestCharacterClassRange38() - { - Test(""" + => Test(""" @"[\3-\cc]" """, """ @@ -15025,12 +14122,10 @@ public void TestCharacterClassRange38() """, RegexOptions.None); - } [Fact] public void TestCharacterClassRange39() - { - Test(""" + => Test(""" @"[\cc-\3]" """, """ @@ -15062,12 +14157,10 @@ public void TestCharacterClassRange39() """, RegexOptions.None); - } [Fact] public void TestCharacterClassRange40() - { - Test(""" + => Test(""" @"[\2-\cc]" """, """ @@ -15099,12 +14192,10 @@ public void TestCharacterClassRange40() """, RegexOptions.None); - } [Fact] public void TestCharacterClassRange41() - { - Test(""" + => Test(""" @"[\cc-\2]" """, $""" @@ -15139,12 +14230,10 @@ public void TestCharacterClassRange41() """, RegexOptions.None); - } [Fact] public void TestCharacterClassRange42() - { - Test(""" + => Test(""" @"[\4-\cc]" """, $""" @@ -15179,12 +14268,10 @@ public void TestCharacterClassRange42() """, RegexOptions.None); - } [Fact] public void TestCharacterClassRange43() - { - Test(""" + => Test(""" @"[\cc-\4]" """, """ @@ -15216,12 +14303,10 @@ public void TestCharacterClassRange43() """, RegexOptions.None); - } [Fact] public void TestCharacterClassRange44() - { - Test(""" + => Test(""" @"[\ca-\cb]" """, """ @@ -15254,12 +14339,10 @@ public void TestCharacterClassRange44() """, RegexOptions.None); - } [Fact] public void TestCharacterClassRange45() - { - Test(""" + => Test(""" @"[\ca-\cB]" """, """ @@ -15292,12 +14375,10 @@ public void TestCharacterClassRange45() """, RegexOptions.None); - } [Fact] public void TestCharacterClassRange46() - { - Test(""" + => Test(""" @"[\cA-\cb]" """, """ @@ -15330,12 +14411,10 @@ public void TestCharacterClassRange46() """, RegexOptions.None); - } [Fact] public void TestCharacterClassRange47() - { - Test(""" + => Test(""" @"[\cA-\cB]" """, """ @@ -15368,12 +14447,10 @@ public void TestCharacterClassRange47() """, RegexOptions.None); - } [Fact] public void TestCharacterClassRange48() - { - Test(""" + => Test(""" @"[\cb-\ca]" """, $""" @@ -15409,12 +14486,10 @@ public void TestCharacterClassRange48() """, RegexOptions.None); - } [Fact] public void TestCharacterClassRange49() - { - Test(""" + => Test(""" @"[\cb-\cA]" """, $""" @@ -15450,12 +14525,10 @@ public void TestCharacterClassRange49() """, RegexOptions.None); - } [Fact] public void TestCharacterClassRange50() - { - Test(""" + => Test(""" @"[\cB-\ca]" """, $""" @@ -15491,12 +14564,10 @@ public void TestCharacterClassRange50() """, RegexOptions.None); - } [Fact] public void TestCharacterClassRange51() - { - Test(""" + => Test(""" @"[\cB-\cA]" """, $""" @@ -15532,12 +14603,10 @@ public void TestCharacterClassRange51() """, RegexOptions.None); - } [Fact] public void TestCharacterClassRange52() - { - Test(""" + => Test(""" @"[\--a]" """, """ @@ -15564,12 +14633,10 @@ public void TestCharacterClassRange52() """, RegexOptions.None); - } [Fact] public void TestCharacterClassRange53() - { - Test(""" + => Test(""" @"[\--#]" """, """ @@ -15596,12 +14663,10 @@ public void TestCharacterClassRange53() """, RegexOptions.None); - } [Fact] public void TestCharacterClassRange54() - { - Test(""" + => Test(""" @"[a-\-]" """, $""" @@ -15634,12 +14699,10 @@ public void TestCharacterClassRange54() """, RegexOptions.None); - } [Fact] public void TestCharacterClassRange55() - { - Test(""" + => Test(""" @"[a-\-b]" """, $""" @@ -15675,12 +14738,10 @@ public void TestCharacterClassRange55() """, RegexOptions.None); - } [Fact] public void TestCharacterClassRange56() - { - Test(""" + => Test(""" @"[a-\-\-b]" """, $""" @@ -15720,12 +14781,10 @@ public void TestCharacterClassRange56() """, RegexOptions.None); - } [Fact] public void TestCharacterClassRange57() - { - Test(""" + => Test(""" @"[b-\-a]" """, $""" @@ -15761,12 +14820,10 @@ public void TestCharacterClassRange57() """, RegexOptions.None); - } [Fact] public void TestCharacterClassRange58() - { - Test(""" + => Test(""" @"[b-\-\-a]" """, $""" @@ -15806,12 +14863,10 @@ public void TestCharacterClassRange58() """, RegexOptions.None); - } [Fact] public void TestCharacterClassRange59() - { - Test(""" + => Test(""" @"[a-\-\D]" """, $""" @@ -15848,12 +14903,10 @@ public void TestCharacterClassRange59() """, RegexOptions.None); - } [Fact] public void TestCharacterClassRange60() - { - Test(""" + => Test(""" @"[a-\-\-\D]" """, $""" @@ -15894,12 +14947,10 @@ public void TestCharacterClassRange60() """, RegexOptions.None); - } [Fact] public void TestCharacterClassRange61() - { - Test(""" + => Test(""" @"[a -\-\b]" """, $""" @@ -15936,12 +14987,10 @@ public void TestCharacterClassRange61() """, RegexOptions.None); - } [Fact] public void TestCharacterClassRange62() - { - Test(""" + => Test(""" @"[ab-\-a]" """, $""" @@ -15980,12 +15029,10 @@ public void TestCharacterClassRange62() """, RegexOptions.None); - } [Fact] public void TestCaptures1() - { - Test(""" + => Test(""" @"()\1" """, """ @@ -16009,12 +15056,10 @@ public void TestCaptures1() """, RegexOptions.None); - } [Fact] public void TestCaptures2() - { - Test(""" + => Test(""" @"()\2" """, $""" @@ -16041,12 +15086,10 @@ public void TestCaptures2() """, RegexOptions.None); - } [Fact] public void TestCaptures3() - { - Test(""" + => Test(""" @"()()\2" """, """ @@ -16076,12 +15119,10 @@ public void TestCaptures3() """, RegexOptions.None); - } [Fact] public void TestCaptures4() - { - Test(""" + => Test(""" @"()\1" """, $""" @@ -16107,12 +15148,10 @@ public void TestCaptures4() """, RegexOptions.ExplicitCapture); - } [Fact] public void TestCaptures5() - { - Test(""" + => Test(""" @"()\2" """, $""" @@ -16138,12 +15177,10 @@ public void TestCaptures5() """, RegexOptions.ExplicitCapture); - } [Fact] public void TestCaptures6() - { - Test(""" + => Test(""" @"()()\2" """, $""" @@ -16174,12 +15211,10 @@ public void TestCaptures6() """, RegexOptions.ExplicitCapture); - } [Fact] public void TestCaptures7() - { - Test(""" + => Test(""" @"()()(?n)\1\2" """, """ @@ -16219,12 +15254,10 @@ public void TestCaptures7() """, RegexOptions.None); - } [Fact] public void TestCaptures8() - { - Test(""" + => Test(""" @"()(?n)()\1\2" """, $""" @@ -16266,12 +15299,10 @@ public void TestCaptures8() """, RegexOptions.None); - } [Fact] public void TestCaptures9() - { - Test(""" + => Test(""" @"(?n)()()\1\2" """, $""" @@ -16313,12 +15344,10 @@ public void TestCaptures9() """, RegexOptions.None); - } [Fact] public void TestCaptures10() - { - Test(""" + => Test(""" @"()()(?n)\1\2" """, $""" @@ -16360,12 +15389,10 @@ public void TestCaptures10() """, RegexOptions.ExplicitCapture); - } [Fact] public void TestCaptures11() - { - Test(""" + => Test(""" @"()(?n)()\1\2" """, $""" @@ -16407,12 +15434,10 @@ public void TestCaptures11() """, RegexOptions.ExplicitCapture); - } [Fact] public void TestCaptures12() - { - Test(""" + => Test(""" @"(?n)()()\1\2" """, $""" @@ -16454,12 +15479,10 @@ public void TestCaptures12() """, RegexOptions.ExplicitCapture); - } [Fact] public void TestCaptures13() - { - Test(""" + => Test(""" @"()()(?-n)\1\2" """, """ @@ -16499,12 +15522,10 @@ public void TestCaptures13() """, RegexOptions.None); - } [Fact] public void TestCaptures14() - { - Test(""" + => Test(""" @"()(?-n)()\1\2" """, """ @@ -16544,12 +15565,10 @@ public void TestCaptures14() """, RegexOptions.None); - } [Fact] public void TestCaptures15() - { - Test(""" + => Test(""" @"(?-n)()()\1\2" """, """ @@ -16589,12 +15608,10 @@ public void TestCaptures15() """, RegexOptions.None); - } [Fact] public void TestCaptures16() - { - Test(""" + => Test(""" @"()()(?-n)\1\2" """, $""" @@ -16636,12 +15653,10 @@ public void TestCaptures16() """, RegexOptions.ExplicitCapture); - } [Fact] public void TestCaptures17() - { - Test(""" + => Test(""" @"()(?-n)()\1\2" """, $""" @@ -16683,12 +15698,10 @@ public void TestCaptures17() """, RegexOptions.ExplicitCapture); - } [Fact] public void TestCaptures18() - { - Test(""" + => Test(""" @"(?-n)()()\1\2" """, """ @@ -16728,12 +15741,10 @@ public void TestCaptures18() """, RegexOptions.ExplicitCapture); - } [Fact] public void TestCaptures19() - { - Test(""" + => Test(""" @"()()(?n:\1\2)" """, """ @@ -16776,12 +15787,10 @@ public void TestCaptures19() """, RegexOptions.None); - } [Fact] public void TestCaptures20() - { - Test(""" + => Test(""" @"()()(?n:\1\2)" """, $""" @@ -16826,12 +15835,10 @@ public void TestCaptures20() """, RegexOptions.ExplicitCapture); - } [Fact] public void TestCaptures21() - { - Test(""" + => Test(""" @"()()(?-n:\1\2)" """, """ @@ -16874,12 +15881,10 @@ public void TestCaptures21() """, RegexOptions.None); - } [Fact] public void TestCaptures22() - { - Test(""" + => Test(""" @"()()(?-n:\1\2)" """, $""" @@ -16924,12 +15929,10 @@ public void TestCaptures22() """, RegexOptions.ExplicitCapture); - } [Fact] public void TestCaptures23() - { - Test(""" + => Test(""" @"(?n:)()()\1\2" """, """ @@ -16971,12 +15974,10 @@ public void TestCaptures23() """, RegexOptions.None); - } [Fact] public void TestCaptures24() - { - Test(""" + => Test(""" @"(?n:)()()\1\2" """, $""" @@ -17020,12 +16021,10 @@ public void TestCaptures24() """, RegexOptions.ExplicitCapture); - } [Fact] public void TestCaptures25() - { - Test(""" + => Test(""" @"(?-n:)()()\1\2" """, """ @@ -17067,12 +16066,10 @@ public void TestCaptures25() """, RegexOptions.None); - } [Fact] public void TestCaptures26() - { - Test(""" + => Test(""" @"(?-n:)()()\1\2" """, $""" @@ -17116,12 +16113,10 @@ public void TestCaptures26() """, RegexOptions.ExplicitCapture); - } [Fact] public void TestCaptures27() - { - Test(""" + => Test(""" @"(?n)(?-n)()()\1\2" """, """ @@ -17167,12 +16162,10 @@ public void TestCaptures27() """, RegexOptions.None); - } [Fact] public void TestCaptures28() - { - Test(""" + => Test(""" @"(?n)(?-n)()()\1\2" """, """ @@ -17218,12 +16211,10 @@ public void TestCaptures28() """, RegexOptions.ExplicitCapture); - } [Fact] public void TestCaptures29() - { - Test(""" + => Test(""" @"(?-n)(?n)()()\1\2" """, $""" @@ -17271,12 +16262,10 @@ public void TestCaptures29() """, RegexOptions.None); - } [Fact] public void TestCaptures30() - { - Test(""" + => Test(""" @"(?-n)(?n)()()\1\2" """, $""" @@ -17324,12 +16313,10 @@ public void TestCaptures30() """, RegexOptions.ExplicitCapture); - } [Fact] public void TestComplex1() - { - Test($""" + => Test($""" @"{And(".*[0-9].*[0-9].*", ".*[A-Z].*[A-Z].*", Not(".*(01|12).*"))}" """, """ @@ -17599,12 +16586,10 @@ public void TestComplex1() """, RegexOptions.None); - } [Fact] public void TestComplex2() - { - Test($""" + => Test($""" @"{And(".*a.*", ".*b.*")}" """, """ @@ -17694,12 +16679,10 @@ public void TestComplex2() """, RegexOptions.None); - } [Fact] public void TestComplex3() - { - Test($""" + => Test($""" @"{And(".*[a-z].*", ".*[A-Z].*", ".*[0-9].*", ".{2,4}")}" """, """ @@ -17928,12 +16911,10 @@ public void TestComplex3() """, RegexOptions.None); - } [Fact] public void TestComplex4() - { - Test($""" + => Test($""" @"{And(".*[a-z].*", ".*[A-Z].*", ".*[0-9].*", ".{4,8}", Not(".*(01|12|23|34|45|56|67|78|89).*"))}" """, """ @@ -18333,7 +17314,6 @@ public void TestComplex4() """, RegexOptions.None); - } [Fact] public void TestComplex5() @@ -19182,8 +18162,7 @@ public void TestComplex5() [Fact] public void TestComplex6() - { - Test(""" + => Test(""" @"pa[5\$s]{2}w[o0]rd$" """, """ @@ -19239,12 +18218,10 @@ public void TestComplex6() """, RegexOptions.None); - } [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/76731")] public void TestCategoryWithNumber() - { - Test(""" + => Test(""" @"[\p{IsLatin-1Supplement}]" """, """ @@ -19271,12 +18248,10 @@ public void TestCategoryWithNumber() """, RegexOptions.None); - } [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/76731")] public void TestCategoryWithUnderscore() - { - Test(""" + => Test(""" @"[\p{_xmlW}]" """, """ @@ -19303,12 +18278,10 @@ public void TestCategoryWithUnderscore() """, RegexOptions.None); - } [Fact] public void TestMinusAsCharacterClassStart() - { - Test(""" + => Test(""" @"[-[:L:]" """, """ @@ -19331,5 +18304,4 @@ public void TestMinusAsCharacterClassStart() """, RegexOptions.None); - } } diff --git a/src/EditorFeatures/CSharpTest2/EmbeddedLanguages/RegularExpressions/CSharpRegexParserTests_DotnetNegativeTests.cs b/src/EditorFeatures/CSharpTest2/EmbeddedLanguages/RegularExpressions/CSharpRegexParserTests_DotnetNegativeTests.cs index c5673e10bcb6..95bf97a8b109 100644 --- a/src/EditorFeatures/CSharpTest2/EmbeddedLanguages/RegularExpressions/CSharpRegexParserTests_DotnetNegativeTests.cs +++ b/src/EditorFeatures/CSharpTest2/EmbeddedLanguages/RegularExpressions/CSharpRegexParserTests_DotnetNegativeTests.cs @@ -15,8 +15,7 @@ public sealed partial class CSharpRegexParserTests { [Fact] public void NegativeTest0() - { - Test(""" + => Test(""" @"cat([a-\d]*)dog" """, $""" @@ -65,12 +64,10 @@ public void NegativeTest0() """, RegexOptions.None); - } [Fact] public void NegativeTest1() - { - Test(""" + => Test(""" @"\k<1" """, $""" @@ -94,12 +91,10 @@ public void NegativeTest1() """, RegexOptions.None); - } [Fact] public void NegativeTest2() - { - Test(""" + => Test(""" @"\k<" """, $""" @@ -123,12 +118,10 @@ public void NegativeTest2() """, RegexOptions.None); - } [Fact] public void NegativeTest3() - { - Test(""" + => Test(""" @"\k" """, $""" @@ -149,12 +142,10 @@ public void NegativeTest3() """, RegexOptions.None); - } [Fact] public void NegativeTest4() - { - Test(""" + => Test(""" @"\1" """, $""" @@ -175,12 +166,10 @@ public void NegativeTest4() """, RegexOptions.None); - } [Fact] public void NegativeTest5() - { - Test(""" + => Test(""" @"(?')" """, $""" @@ -206,12 +195,10 @@ public void NegativeTest5() """, RegexOptions.None); - } [Fact] public void NegativeTest6() - { - Test(""" + => Test(""" @"(?<)" """, $""" @@ -237,12 +224,10 @@ public void NegativeTest6() """, RegexOptions.None); - } [Fact] public void NegativeTest7() - { - Test(""" + => Test(""" @"(?)" """, $""" @@ -268,12 +253,10 @@ public void NegativeTest7() """, RegexOptions.None); - } [Fact] public void NegativeTest8() - { - Test(""" + => Test(""" @"(?>" """, $""" @@ -297,12 +280,10 @@ public void NegativeTest8() """, RegexOptions.None); - } [Fact] public void NegativeTest9() - { - Test(""" + => Test(""" @"(? @@ -327,12 +308,10 @@ public void NegativeTest9() """, RegexOptions.None); - } [Fact] public void NegativeTest10() - { - Test(""" + => Test(""" @"(?<=" """, $""" @@ -357,12 +336,10 @@ public void NegativeTest10() """, RegexOptions.None); - } [Fact] public void NegativeTest11() - { - Test(""" + => Test(""" @"(?!" """, $""" @@ -386,12 +363,10 @@ public void NegativeTest11() """, RegexOptions.None); - } [Fact] public void NegativeTest12() - { - Test(""" + => Test(""" @"(?=" """, $""" @@ -415,12 +390,10 @@ public void NegativeTest12() """, RegexOptions.None); - } [Fact] public void NegativeTest13() - { - Test(""" + => Test(""" @"(?imn )" """, $""" @@ -450,12 +423,10 @@ public void NegativeTest13() """, RegexOptions.None); - } [Fact] public void NegativeTest14() - { - Test(""" + => Test(""" @"(?imn" """, $""" @@ -478,12 +449,10 @@ public void NegativeTest14() """, RegexOptions.None); - } [Fact] public void NegativeTest15() - { - Test(""" + => Test(""" @"(?:" """, $""" @@ -507,12 +476,10 @@ public void NegativeTest15() """, RegexOptions.None); - } [Fact] public void NegativeTest16() - { - Test(""" + => Test(""" @"(?'cat'" """, $""" @@ -540,12 +507,10 @@ public void NegativeTest16() """, RegexOptions.None); - } [Fact] public void NegativeTest17() - { - Test(""" + => Test(""" @"(?'" """, $""" @@ -572,12 +537,10 @@ public void NegativeTest17() """, RegexOptions.None); - } [Fact] public void NegativeTest18() - { - Test(""" + => Test(""" @"[^" """, $""" @@ -600,12 +563,10 @@ public void NegativeTest18() """, RegexOptions.None); - } [Fact] public void NegativeTest19() - { - Test(""" + => Test(""" @"[cat" """, $""" @@ -631,12 +592,10 @@ public void NegativeTest19() """, RegexOptions.None); - } [Fact] public void NegativeTest20() - { - Test(""" + => Test(""" @"[^cat" """, $""" @@ -663,12 +622,10 @@ public void NegativeTest20() """, RegexOptions.None); - } [Fact] public void NegativeTest21() - { - Test(""" + => Test(""" @"[a-" """, $""" @@ -700,12 +657,10 @@ public void NegativeTest21() """, RegexOptions.None); - } [Fact] public void NegativeTest22() - { - Test(""" + => Test(""" @"\p{" """, $$""" @@ -729,12 +684,10 @@ public void NegativeTest22() """, RegexOptions.None); - } [Fact] public void NegativeTest23() - { - Test(""" + => Test(""" @"\p{cat" """, $$""" @@ -758,12 +711,10 @@ public void NegativeTest23() """, RegexOptions.None); - } [Fact] public void NegativeTest24() - { - Test(""" + => Test(""" @"\k @@ -787,12 +738,10 @@ public void NegativeTest24() """, RegexOptions.None); - } [Fact] public void NegativeTest25() - { - Test(""" + => Test(""" @"\p{cat}" """, $$""" @@ -816,12 +765,10 @@ public void NegativeTest25() """, RegexOptions.None); - } [Fact] public void NegativeTest26() - { - Test(""" + => Test(""" @"\P{cat" """, $$""" @@ -845,12 +792,10 @@ public void NegativeTest26() """, RegexOptions.None); - } [Fact] public void NegativeTest27() - { - Test(""" + => Test(""" @"\P{cat}" """, $$""" @@ -874,12 +819,10 @@ public void NegativeTest27() """, RegexOptions.None); - } [Fact] public void NegativeTest28() - { - Test(""" + => Test(""" @"(" """, $""" @@ -902,12 +845,10 @@ public void NegativeTest28() """, RegexOptions.None); - } [Fact] public void NegativeTest29() - { - Test(""" + => Test(""" @"(?" """, $""" @@ -935,12 +876,10 @@ public void NegativeTest29() """, RegexOptions.None); - } [Fact] public void NegativeTest30() - { - Test(""" + => Test(""" @"(?<" """, $""" @@ -967,12 +906,10 @@ public void NegativeTest30() """, RegexOptions.None); - } [Fact] public void NegativeTest31() - { - Test(""" + => Test(""" @"(?" """, $""" @@ -1000,12 +937,10 @@ public void NegativeTest31() """, RegexOptions.None); - } [Fact] public void NegativeTest32() - { - Test(""" + => Test(""" @"\P{" """, $$""" @@ -1029,12 +964,10 @@ public void NegativeTest32() """, RegexOptions.None); - } [Fact] public void NegativeTest33() - { - Test(""" + => Test(""" @"\k<>" """, $""" @@ -1058,12 +991,10 @@ public void NegativeTest33() """, RegexOptions.None); - } [Fact] public void NegativeTest34() - { - Test(""" + => Test(""" @"(?(" """, $""" @@ -1091,12 +1022,10 @@ public void NegativeTest34() """, RegexOptions.None); - } [Fact] public void NegativeTest35() - { - Test(""" + => Test(""" @"(?()|" """, $""" @@ -1128,12 +1057,10 @@ public void NegativeTest35() """, RegexOptions.None); - } [Fact] public void NegativeTest36() - { - Test(""" + => Test(""" @"?(a|b)" """, $""" @@ -1171,12 +1098,10 @@ public void NegativeTest36() """, RegexOptions.None); - } [Fact] public void NegativeTest37() - { - Test(""" + => Test(""" @"?((a)" """, $""" @@ -1214,12 +1139,10 @@ public void NegativeTest37() """, RegexOptions.None); - } [Fact] public void NegativeTest38() - { - Test(""" + => Test(""" @"?((a)a" """, $""" @@ -1260,12 +1183,10 @@ public void NegativeTest38() """, RegexOptions.None); - } [Fact] public void NegativeTest39() - { - Test(""" + => Test(""" @"?((a)a|" """, $""" @@ -1310,12 +1231,10 @@ public void NegativeTest39() """, RegexOptions.None); - } [Fact] public void NegativeTest40() - { - Test(""" + => Test(""" @"?((a)a|b" """, $""" @@ -1364,12 +1283,10 @@ public void NegativeTest40() """, RegexOptions.None); - } [Fact] public void NegativeTest41() - { - Test(""" + => Test(""" @"(?(?i))" """, """ @@ -1405,12 +1322,10 @@ public void NegativeTest41() """, RegexOptions.None); - } [Fact] public void NegativeTest42() - { - Test(""" + => Test(""" @"?(a)" """, $""" @@ -1440,12 +1355,10 @@ public void NegativeTest42() """, RegexOptions.None); - } [Fact] public void NegativeTest43() - { - Test(""" + => Test(""" @"(?(?I))" """, """ @@ -1481,12 +1394,10 @@ public void NegativeTest43() """, RegexOptions.None); - } [Fact] public void NegativeTest44() - { - Test(""" + => Test(""" @"(?(?M))" """, """ @@ -1522,12 +1433,10 @@ public void NegativeTest44() """, RegexOptions.None); - } [Fact] public void NegativeTest45() - { - Test(""" + => Test(""" @"(?(?s))" """, """ @@ -1563,12 +1472,10 @@ public void NegativeTest45() """, RegexOptions.None); - } [Fact] public void NegativeTest46() - { - Test(""" + => Test(""" @"(?(?S))" """, """ @@ -1604,12 +1511,10 @@ public void NegativeTest46() """, RegexOptions.None); - } [Fact] public void NegativeTest47() - { - Test(""" + => Test(""" @"(?(?x))" """, """ @@ -1645,12 +1550,10 @@ public void NegativeTest47() """, RegexOptions.None); - } [Fact] public void NegativeTest48() - { - Test(""" + => Test(""" @"(?(?X))" """, """ @@ -1686,12 +1589,10 @@ public void NegativeTest48() """, RegexOptions.None); - } [Fact] public void NegativeTest49() - { - Test(""" + => Test(""" @"(?(?n))" """, """ @@ -1727,12 +1628,10 @@ public void NegativeTest49() """, RegexOptions.None); - } [Fact] public void NegativeTest50() - { - Test(""" + => Test(""" @"(?(?m))" """, """ @@ -1768,12 +1667,10 @@ public void NegativeTest50() """, RegexOptions.None); - } [Fact] public void NegativeTest51() - { - Test(""" + => Test(""" @"[a" """, $""" @@ -1799,12 +1696,10 @@ public void NegativeTest51() """, RegexOptions.None); - } [Fact] public void NegativeTest52() - { - Test(""" + => Test(""" @"?(a:b)" """, $""" @@ -1834,12 +1729,10 @@ public void NegativeTest52() """, RegexOptions.None); - } [Fact] public void NegativeTest53() - { - Test(""" + => Test(""" @"(?(?" """, $""" @@ -1873,12 +1766,10 @@ public void NegativeTest53() """, RegexOptions.None); - } [Fact] public void NegativeTest54() - { - Test(""" + => Test(""" @"(?(cat" """, $""" @@ -1910,12 +1801,10 @@ public void NegativeTest54() """, RegexOptions.None); - } [Fact] public void NegativeTest55() - { - Test(""" + => Test(""" @"(?(cat)|" """, $""" @@ -1951,12 +1840,10 @@ public void NegativeTest55() """, RegexOptions.None); - } [Fact] public void NegativeTest56() - { - Test(""" + => Test(""" @"foo(?<0>bar)" """, $""" @@ -1989,12 +1876,10 @@ public void NegativeTest56() """, RegexOptions.None); - } [Fact] public void NegativeTest57() - { - Test(""" + => Test(""" @"foo(?'0'bar)" """, $""" @@ -2027,12 +1912,10 @@ public void NegativeTest57() """, RegexOptions.None); - } [Fact] public void NegativeTest58() - { - Test(""" + => Test(""" @"foo(?<1bar)" """, $""" @@ -2066,12 +1949,10 @@ public void NegativeTest58() """, RegexOptions.None); - } [Fact] public void NegativeTest59() - { - Test(""" + => Test(""" @"foo(?'1bar)" """, $""" @@ -2105,12 +1986,10 @@ public void NegativeTest59() """, RegexOptions.None); - } [Fact] public void NegativeTest60() - { - Test(""" + => Test(""" @"(?(" """, $""" @@ -2138,12 +2017,10 @@ public void NegativeTest60() """, RegexOptions.None); - } [Fact] public void NegativeTest61() - { - Test(""" + => Test(""" @"\p{klsak" """, $$""" @@ -2167,12 +2044,10 @@ public void NegativeTest61() """, RegexOptions.None); - } [Fact] public void NegativeTest62() - { - Test(""" + => Test(""" @"(?c:cat)" """, $""" @@ -2202,12 +2077,10 @@ public void NegativeTest62() """, RegexOptions.None); - } [Fact] public void NegativeTest63() - { - Test(""" + => Test(""" @"(??e:cat)" """, $""" @@ -2241,12 +2114,10 @@ public void NegativeTest63() """, RegexOptions.None); - } [Fact] public void NegativeTest64() - { - Test(""" + => Test(""" @"[a-f-[]]+" """, $""" @@ -2294,12 +2165,10 @@ public void NegativeTest64() """, RegexOptions.None); - } [Fact] public void NegativeTest65() - { - Test(""" + => Test(""" @"[A-[]+" """, $""" @@ -2337,12 +2206,10 @@ public void NegativeTest65() """, RegexOptions.None); - } [Fact] public void NegativeTest66() - { - Test(""" + => Test(""" @"(?(?e))" """, $""" @@ -2378,12 +2245,10 @@ public void NegativeTest66() """, RegexOptions.None); - } [Fact] public void NegativeTest67() - { - Test(""" + => Test(""" @"(?(?a)" """, $""" @@ -2420,12 +2285,10 @@ public void NegativeTest67() """, RegexOptions.None); - } [Fact] public void NegativeTest68() - { - Test(""" + => Test(""" @"(?r:cat)" """, $""" @@ -2455,12 +2318,10 @@ public void NegativeTest68() """, RegexOptions.None); - } [Fact] public void NegativeTest69() - { - Test(""" + => Test(""" @"(?(?N))" """, """ @@ -2496,12 +2357,10 @@ public void NegativeTest69() """, RegexOptions.None); - } [Fact] public void NegativeTest70() - { - Test(""" + => Test(""" @"[]" """, $""" @@ -2527,12 +2386,10 @@ public void NegativeTest70() """, RegexOptions.None); - } [Fact] public void NegativeTest71() - { - Test(""" + => Test(""" @"\x2" """, $""" @@ -2554,12 +2411,10 @@ public void NegativeTest71() """, RegexOptions.None); - } [Fact] public void NegativeTest72() - { - Test(""" + => Test(""" @"(cat) (?#cat) \s+ (?#followed by 1 or more whitespace" """, $""" @@ -2603,12 +2458,10 @@ public void NegativeTest72() """, RegexOptions.IgnorePatternWhitespace); - } [Fact] public void NegativeTest73() - { - Test(""" + => Test(""" @"cat(?(?afdcat)dog)" """, $""" @@ -2651,12 +2504,10 @@ public void NegativeTest73() """, RegexOptions.None); - } [Fact] public void NegativeTest74() - { - Test(""" + => Test(""" @"cat(?(?cat)dog)" """, $""" @@ -2699,12 +2550,10 @@ public void NegativeTest74() """, RegexOptions.None); - } [Fact] public void NegativeTest75() - { - Test(""" + => Test(""" @"cat(?(?'cat'cat)dog)" """, $""" @@ -2747,12 +2596,10 @@ public void NegativeTest75() """, RegexOptions.None); - } [Fact] public void NegativeTest76() - { - Test(""" + => Test(""" @"cat(?(?#COMMENT)cat)" """, $""" @@ -2796,12 +2643,10 @@ public void NegativeTest76() """, RegexOptions.None); - } [Fact] public void NegativeTest77() - { - Test(""" + => Test(""" @"(?cat)\w+(?dog)" """, $""" @@ -2866,12 +2711,10 @@ public void NegativeTest77() """, RegexOptions.None); - } [Fact] public void NegativeTest78() - { - Test(""" + => Test(""" @"(?cat)\w+(?dog)" """, $""" @@ -2927,12 +2770,10 @@ public void NegativeTest78() """, RegexOptions.None); - } [Fact] public void NegativeTest79() - { - Test(""" + => Test(""" @"(?cat)\w+(?dog)" """, $""" @@ -2988,12 +2829,10 @@ public void NegativeTest79() """, RegexOptions.None); - } [Fact] public void NegativeTest80() - { - Test(""" + => Test(""" @"(?cat)\w+(?dog)" """, $""" @@ -3049,12 +2888,10 @@ public void NegativeTest80() """, RegexOptions.None); - } [Fact] public void NegativeTest81() - { - Test(""" + => Test(""" @"cat(?<->dog)" """, $""" @@ -3089,12 +2926,10 @@ public void NegativeTest81() """, RegexOptions.None); - } [Fact] public void NegativeTest82() - { - Test(""" + => Test(""" @"cat(?<>dog)" """, $""" @@ -3127,12 +2962,10 @@ public void NegativeTest82() """, RegexOptions.None); - } [Fact] public void NegativeTest83() - { - Test(""" + => Test(""" @"cat(?)_*>dog)" """, $""" @@ -3180,12 +3013,10 @@ public void NegativeTest83() """, RegexOptions.None); - } [Fact] public void NegativeTest84() - { - Test(""" + => Test(""" @"cat(?)_*>dog)" """, $""" @@ -3233,12 +3064,10 @@ public void NegativeTest84() """, RegexOptions.None); - } [Fact] public void NegativeTest85() - { - Test(""" + => Test(""" @"cat(?)_*>dog)" """, $""" @@ -3286,12 +3115,10 @@ public void NegativeTest85() """, RegexOptions.None); - } [Fact] public void NegativeTest86() - { - Test(""" + => Test(""" @"cat(?dog)" """, $""" @@ -3335,12 +3162,10 @@ public void NegativeTest86() """, RegexOptions.None); - } [Fact] public void NegativeTest87() - { - Test(""" + => Test(""" @"cat(?<1dog>dog)" """, $""" @@ -3374,12 +3199,10 @@ public void NegativeTest87() """, RegexOptions.None); - } [Fact] public void NegativeTest88() - { - Test(""" + => Test(""" @"cat(?<0>dog)" """, $""" @@ -3412,12 +3235,10 @@ public void NegativeTest88() """, RegexOptions.None); - } [Fact] public void NegativeTest89() - { - Test(""" + => Test(""" @"([5-\D]*)dog" """, $""" @@ -3463,12 +3284,10 @@ public void NegativeTest89() """, RegexOptions.None); - } [Fact] public void NegativeTest90() - { - Test(""" + => Test(""" @"cat([6-\s]*)dog" """, $""" @@ -3517,12 +3336,10 @@ public void NegativeTest90() """, RegexOptions.None); - } [Fact] public void NegativeTest91() - { - Test(""" + => Test(""" @"cat([c-\S]*)" """, $""" @@ -3568,12 +3385,10 @@ public void NegativeTest91() """, RegexOptions.None); - } [Fact] public void NegativeTest92() - { - Test(""" + => Test(""" @"cat([7-\w]*)" """, $""" @@ -3619,12 +3434,10 @@ public void NegativeTest92() """, RegexOptions.None); - } [Fact] public void NegativeTest93() - { - Test(""" + => Test(""" @"cat([a-\W]*)dog" """, $""" @@ -3673,12 +3486,10 @@ public void NegativeTest93() """, RegexOptions.None); - } [Fact] public void NegativeTest94() - { - Test(""" + => Test(""" @"([f-\p{Lu}]\w*)\s([\p{Lu}]\w*)" """, $$""" @@ -3759,12 +3570,10 @@ public void NegativeTest94() """, RegexOptions.None); - } [Fact] public void NegativeTest95() - { - Test(""" + => Test(""" @"(cat) (?#cat) \s+ (?#followed by 1 or more whitespace" """, $""" @@ -3814,12 +3623,10 @@ public void NegativeTest95() """, RegexOptions.None); - } [Fact] public void NegativeTest96() - { - Test(""" + => Test(""" @"([1-\P{Ll}][\p{Ll}]*)\s([\P{Ll}][\p{Ll}]*)" """, $$""" @@ -3918,12 +3725,10 @@ public void NegativeTest96() """, RegexOptions.None); - } [Fact] public void NegativeTest97() - { - Test(""" + => Test(""" @"[\P]" """, $""" @@ -3950,12 +3755,10 @@ public void NegativeTest97() """, RegexOptions.None); - } [Fact] public void NegativeTest98() - { - Test(""" + => Test(""" @"([\pcat])" """, $""" @@ -3992,12 +3795,10 @@ public void NegativeTest98() """, RegexOptions.None); - } [Fact] public void NegativeTest99() - { - Test(""" + => Test(""" @"([\Pcat])" """, $""" @@ -4034,12 +3835,10 @@ public void NegativeTest99() """, RegexOptions.None); - } [Fact] public void NegativeTest100() - { - Test(""" + => Test(""" @"(\p{" """, $$""" @@ -4071,12 +3870,10 @@ public void NegativeTest100() """, RegexOptions.None); - } [Fact] public void NegativeTest101() - { - Test(""" + => Test(""" @"(\p{Ll" """, $$""" @@ -4108,12 +3905,10 @@ public void NegativeTest101() """, RegexOptions.None); - } [Fact] public void NegativeTest102() - { - Test(""" + => Test(""" @"(cat)([\o]*)(dog)" """, $""" @@ -4170,12 +3965,10 @@ public void NegativeTest102() """, RegexOptions.None); - } [Fact] public void NegativeTest103() - { - Test(""" + => Test(""" @"[\p]" """, $""" @@ -4202,12 +3995,10 @@ public void NegativeTest103() """, RegexOptions.None); - } [Fact] public void NegativeTest104() - { - Test(""" + => Test(""" @"(?cat)\s+(?dog)\kcat" """, $""" @@ -4268,12 +4059,10 @@ public void NegativeTest104() """, RegexOptions.None); - } [Fact] public void NegativeTest105() - { - Test(""" + => Test(""" @"(?cat)\s+(?dog)\k" """, $""" @@ -4334,12 +4123,10 @@ public void NegativeTest105() """, RegexOptions.None); - } [Fact] public void NegativeTest106() - { - Test(""" + => Test(""" @"(?cat)\s+(?dog)\k<8>cat" """, $""" @@ -4403,12 +4190,10 @@ public void NegativeTest106() """, RegexOptions.None); - } [Fact] public void NegativeTest107() - { - Test(""" + => Test(""" @"^[abcd]{1}?*$" """, $$""" @@ -4451,12 +4236,10 @@ public void NegativeTest107() """, RegexOptions.None); - } [Fact] public void NegativeTest108() - { - Test(""" + => Test(""" @"^[abcd]*+$" """, $""" @@ -4494,12 +4277,10 @@ public void NegativeTest108() """, RegexOptions.None); - } [Fact] public void NegativeTest109() - { - Test(""" + => Test(""" @"^[abcd]+*$" """, $""" @@ -4537,12 +4318,10 @@ public void NegativeTest109() """, RegexOptions.None); - } [Fact] public void NegativeTest110() - { - Test(""" + => Test(""" @"^[abcd]?*$" """, $""" @@ -4580,12 +4359,10 @@ public void NegativeTest110() """, RegexOptions.None); - } [Fact] public void NegativeTest111() - { - Test(""" + => Test(""" @"^[abcd]*?+$" """, $""" @@ -4626,12 +4403,10 @@ public void NegativeTest111() """, RegexOptions.None); - } [Fact] public void NegativeTest112() - { - Test(""" + => Test(""" @"^[abcd]+?*$" """, $""" @@ -4672,12 +4447,10 @@ public void NegativeTest112() """, RegexOptions.None); - } [Fact] public void NegativeTest113() - { - Test(""" + => Test(""" @"^[abcd]{1,}?*$" """, $$""" @@ -4721,12 +4494,10 @@ public void NegativeTest113() """, RegexOptions.None); - } [Fact] public void NegativeTest114() - { - Test(""" + => Test(""" @"^[abcd]??*$" """, $""" @@ -4767,12 +4538,10 @@ public void NegativeTest114() """, RegexOptions.None); - } [Fact] public void NegativeTest115() - { - Test(""" + => Test(""" @"^[abcd]+{0,5}$" """, $$""" @@ -4813,12 +4582,10 @@ public void NegativeTest115() """, RegexOptions.None); - } [Fact] public void NegativeTest116() - { - Test(""" + => Test(""" @"^[abcd]?{0,5}$" """, $$""" @@ -4859,12 +4626,10 @@ public void NegativeTest116() """, RegexOptions.None); - } [Fact] public void NegativeTest117() - { - Test(""" + => Test(""" @"\u" """, $""" @@ -4886,12 +4651,10 @@ public void NegativeTest117() """, RegexOptions.None); - } [Fact] public void NegativeTest118() - { - Test(""" + => Test(""" @"\ua" """, $""" @@ -4913,12 +4676,10 @@ public void NegativeTest118() """, RegexOptions.None); - } [Fact] public void NegativeTest119() - { - Test(""" + => Test(""" @"\u0" """, $""" @@ -4940,12 +4701,10 @@ public void NegativeTest119() """, RegexOptions.None); - } [Fact] public void NegativeTest120() - { - Test(""" + => Test(""" @"\x" """, $""" @@ -4967,12 +4726,10 @@ public void NegativeTest120() """, RegexOptions.None); - } [Fact] public void NegativeTest121() - { - Test(""" + => Test(""" @"^[abcd]*{0,5}$" """, $$""" @@ -5013,12 +4770,10 @@ public void NegativeTest121() """, RegexOptions.None); - } [Fact] public void NegativeTest122() - { - Test(""" + => Test(""" @"[" """, $""" @@ -5040,12 +4795,10 @@ public void NegativeTest122() """, RegexOptions.None); - } [Fact] public void NegativeTest123() - { - Test(""" + => Test(""" @"^[abcd]{0,16}?*$" """, $$""" @@ -5090,12 +4843,10 @@ public void NegativeTest123() """, RegexOptions.None); - } [Fact] public void NegativeTest124() - { - Test(""" + => Test(""" @"^[abcd]{1,}*$" """, $$""" @@ -5136,12 +4887,10 @@ public void NegativeTest124() """, RegexOptions.None); - } [Fact] public void NegativeTest125() - { - Test(""" + => Test(""" @"(?cat)\s+(?dog)\k<8>cat" """, $""" @@ -5205,12 +4954,10 @@ public void NegativeTest125() """, RegexOptions.ECMAScript); - } [Fact] public void NegativeTest126() - { - Test(""" + => Test(""" @"(?cat)\s+(?dog)\k8" """, $""" @@ -5271,12 +5018,10 @@ public void NegativeTest126() """, RegexOptions.None); - } [Fact] public void NegativeTest127() - { - Test(""" + => Test(""" @"(?cat)\s+(?dog)\k8" """, $""" @@ -5337,12 +5082,10 @@ public void NegativeTest127() """, RegexOptions.ECMAScript); - } [Fact] public void NegativeTest128() - { - Test(""" + => Test(""" @"(cat)(\7)" """, $""" @@ -5380,12 +5123,10 @@ public void NegativeTest128() """, RegexOptions.None); - } [Fact] public void NegativeTest129() - { - Test(""" + => Test(""" @"(cat)\s+(?<2147483648>dog)" """, $""" @@ -5433,12 +5174,10 @@ public void NegativeTest129() """, RegexOptions.None); - } [Fact] public void NegativeTest130() - { - Test(""" + => Test(""" @"(cat)\s+(?<21474836481097>dog)" """, $""" @@ -5486,12 +5225,10 @@ public void NegativeTest130() """, RegexOptions.None); - } [Fact] public void NegativeTest131() - { - Test(""" + => Test(""" @"^[abcd]{1}*$" """, $$""" @@ -5531,12 +5268,10 @@ public void NegativeTest131() """, RegexOptions.None); - } [Fact] public void NegativeTest132() - { - Test(""" + => Test(""" @"(cat)(\c*)(dog)" """, $""" @@ -5588,12 +5323,10 @@ public void NegativeTest132() """, RegexOptions.None); - } [Fact] public void NegativeTest133() - { - Test(""" + => Test(""" @"(cat)(\c *)(dog)" """, $""" @@ -5648,12 +5381,10 @@ public void NegativeTest133() """, RegexOptions.None); - } [Fact] public void NegativeTest134() - { - Test(""" + => Test(""" @"(cat)(\c?*)(dog)" """, $""" @@ -5709,12 +5440,10 @@ public void NegativeTest134() """, RegexOptions.None); - } [Fact] public void NegativeTest135() - { - Test(""" + => Test(""" @"(cat)(\c`*)(dog)" """, $""" @@ -5769,12 +5498,10 @@ public void NegativeTest135() """, RegexOptions.None); - } [Fact] public void NegativeTest136() - { - Test(""" + => Test(""" @"(cat)(\c\|*)(dog)" """, $""" @@ -5831,12 +5558,10 @@ public void NegativeTest136() """, RegexOptions.None); - } [Fact] public void NegativeTest137() - { - Test(""" + => Test(""" @"(cat)(\c\[*)(dog)" """, $""" @@ -5885,12 +5610,10 @@ public void NegativeTest137() """, RegexOptions.None); - } [Fact] public void NegativeTest138() - { - Test(""" + => Test(""" @"^[abcd]{0,16}*$" """, $$""" @@ -5932,12 +5655,10 @@ public void NegativeTest138() """, RegexOptions.None); - } [Fact] public void NegativeTest139() - { - Test(""" + => Test(""" @"(cat)\c" """, $""" @@ -5969,5 +5690,4 @@ public void NegativeTest139() """, RegexOptions.None); - } } diff --git a/src/EditorFeatures/CSharpTest2/EmbeddedLanguages/RegularExpressions/CSharpRegexParserTests_ReferenceTests.cs b/src/EditorFeatures/CSharpTest2/EmbeddedLanguages/RegularExpressions/CSharpRegexParserTests_ReferenceTests.cs index b594e44e9664..ed91e91a4a75 100644 --- a/src/EditorFeatures/CSharpTest2/EmbeddedLanguages/RegularExpressions/CSharpRegexParserTests_ReferenceTests.cs +++ b/src/EditorFeatures/CSharpTest2/EmbeddedLanguages/RegularExpressions/CSharpRegexParserTests_ReferenceTests.cs @@ -15,8 +15,7 @@ public sealed partial class CSharpRegexParserTests { [Fact] public void ReferenceTest0() - { - Test(""" + => Test(""" @"[aeiou]" """, """ @@ -39,12 +38,10 @@ public void ReferenceTest0() """, RegexOptions.None); - } [Fact] public void ReferenceTest1() - { - Test(""" + => Test(""" @"(?\w+)\s\k\W(?\w+)" """, """ @@ -111,12 +108,10 @@ public void ReferenceTest1() """, RegexOptions.None); - } [Fact] public void ReferenceTest2() - { - Test(""" + => Test(""" @"((?abc)\d+)?(?xyz)(.*)" """, """ @@ -190,12 +185,10 @@ public void ReferenceTest2() """, RegexOptions.None); - } [Fact] public void ReferenceTest3() - { - Test(""" + => Test(""" @"(\w+)\s(\1)" """, """ @@ -238,12 +231,10 @@ public void ReferenceTest3() """, RegexOptions.None); - } [Fact] public void ReferenceTest4() - { - Test(""" + => Test(""" @"\Bqu\w+" """, """ @@ -271,12 +262,10 @@ public void ReferenceTest4() """, RegexOptions.None); - } [Fact] public void ReferenceTest5() - { - Test(""" + => Test(""" @"\bare\w*\b" """, """ @@ -308,12 +297,10 @@ public void ReferenceTest5() """, RegexOptions.None); - } [Fact] public void ReferenceTest6() - { - Test(""" + => Test(""" @"\G(\w+\s?\w*),?" """, """ @@ -365,12 +352,10 @@ public void ReferenceTest6() """, RegexOptions.None); - } [Fact] public void ReferenceTest7() - { - Test(""" + => Test(""" @"\D+(?\d+)\D+(?\d+)?" """, """ @@ -437,12 +422,10 @@ public void ReferenceTest7() """, RegexOptions.None); - } [Fact] public void ReferenceTest8() - { - Test(""" + => Test(""" @"(\s\d{4}(-(\d{4}|present))?,?)+" """, """ @@ -517,12 +500,10 @@ public void ReferenceTest8() """, RegexOptions.None); - } [Fact] public void ReferenceTest9() - { - Test(""" + => Test(""" @"^((\w+(\s?)){2,}),\s(\w+\s\w+),(\s\d{4}(-(\d{4}|present))?,?)+" """, """ @@ -681,12 +662,10 @@ public void ReferenceTest9() """, RegexOptions.None); - } [Fact] public void ReferenceTest10() - { - Test(""" + => Test(""" @"^[0-9-[2468]]+$" """, """ @@ -736,12 +715,10 @@ public void ReferenceTest10() """, RegexOptions.None); - } [Fact] public void ReferenceTest11() - { - Test(""" + => Test(""" @"[a-z-[0-9]]" """, """ @@ -788,12 +765,10 @@ public void ReferenceTest11() """, RegexOptions.None); - } [Fact] public void ReferenceTest12() - { - Test(""" + => Test(""" @"[\p{IsBasicLatin}-[\x00-\x7F]]" """, """ @@ -842,12 +817,10 @@ public void ReferenceTest12() """, RegexOptions.None); - } [Fact] public void ReferenceTest13() - { - Test(""" + => Test(""" @"[\u0000-\uFFFF-[\s\p{P}\p{IsGreek}\x85]]" """, """ @@ -912,12 +885,10 @@ public void ReferenceTest13() """, RegexOptions.None); - } [Fact] public void ReferenceTest14() - { - Test(""" + => Test(""" @"[a-z-[d-w-[m-o]]]" """, """ @@ -982,12 +953,10 @@ public void ReferenceTest14() """, RegexOptions.None); - } [Fact] public void ReferenceTest15() - { - Test(""" + => Test(""" @"((\w+(\s?)){2,}" """, $$""" @@ -1045,12 +1014,10 @@ public void ReferenceTest15() """, RegexOptions.None); - } [Fact] public void ReferenceTest16() - { - Test(""" + => Test(""" @"[a-z-[djp]]" """, """ @@ -1091,12 +1058,10 @@ public void ReferenceTest16() """, RegexOptions.None); - } [Fact] public void ReferenceTest17() - { - Test(""" + => Test(""" @"^[^<>]*(((?'Open'<)[^<>]*)+((?'Close-Open'>)[^<>]*)+)*(?(Open)(?!))$" """, """ @@ -1234,12 +1199,10 @@ public void ReferenceTest17() """, RegexOptions.None); - } [Fact] public void ReferenceTest18() - { - Test(""" + => Test(""" @"((?'Close-Open'>)[^<>]*)+" """, $""" @@ -1296,12 +1259,10 @@ public void ReferenceTest18() """, RegexOptions.None); - } [Fact] public void ReferenceTest19() - { - Test(""" + => Test(""" @"(\w)\1+.\b" """, """ @@ -1340,12 +1301,10 @@ public void ReferenceTest19() """, RegexOptions.None); - } [Fact] public void ReferenceTest20() - { - Test(""" + => Test(""" @"\d{4}\b" """, """ @@ -1372,12 +1331,10 @@ public void ReferenceTest20() """, RegexOptions.None); - } [Fact] public void ReferenceTest21() - { - Test(""" + => Test(""" @"\d{1,2}," """, """ @@ -1405,12 +1362,10 @@ public void ReferenceTest21() """, RegexOptions.None); - } [Fact] public void ReferenceTest22() - { - Test(""" + => Test(""" @"(? @@ -1495,12 +1450,10 @@ public void ReferenceTest22() """, RegexOptions.None); - } [Fact] public void ReferenceTest23() - { - Test(""" + => Test(""" @"(?<=\b20)\d{2}\b" """, """ @@ -1543,12 +1496,10 @@ public void ReferenceTest23() """, RegexOptions.None); - } [Fact] public void ReferenceTest24() - { - Test(""" + => Test(""" @"\b\w+\b(?!\p{P})" """, """ @@ -1592,12 +1543,10 @@ public void ReferenceTest24() """, RegexOptions.None); - } [Fact] public void ReferenceTest25() - { - Test(""" + => Test(""" @"(((?'Open'<)[^<>]*)+((?'Close-Open'>)[^<>]*)+)*" """, """ @@ -1699,12 +1648,10 @@ public void ReferenceTest25() """, RegexOptions.None); - } [Fact] public void ReferenceTest26() - { - Test(""" + => Test(""" @"\b(?!un)\w+\b" """, """ @@ -1744,12 +1691,10 @@ public void ReferenceTest26() """, RegexOptions.None); - } [Fact] public void ReferenceTest27() - { - Test(""" + => Test(""" @"\b(?ix: d \w+)\s" """, """ @@ -1796,12 +1741,10 @@ public void ReferenceTest27() """, RegexOptions.None); - } [Fact] public void ReferenceTest28() - { - Test(""" + => Test(""" @"(?:\w+)" """, """ @@ -1830,12 +1773,10 @@ public void ReferenceTest28() """, RegexOptions.None); - } [Fact] public void ReferenceTest29() - { - Test(""" + => Test(""" @"(?:\b(?:\w+)\W*)+" """, """ @@ -1886,12 +1827,10 @@ public void ReferenceTest29() """, RegexOptions.None); - } [Fact] public void ReferenceTest30() - { - Test(""" + => Test(""" @"(?:\b(?:\w+)\W*)+\." """, """ @@ -1946,12 +1885,10 @@ public void ReferenceTest30() """, RegexOptions.None); - } [Fact] public void ReferenceTest31() - { - Test(""" + => Test(""" @"(?'Close-Open'>)" """, $""" @@ -1985,12 +1922,10 @@ public void ReferenceTest31() """, RegexOptions.None); - } [Fact] public void ReferenceTest32() - { - Test(""" + => Test(""" @"[^<>]*" """, """ @@ -2017,12 +1952,10 @@ public void ReferenceTest32() """, RegexOptions.None); - } [Fact] public void ReferenceTest33() - { - Test(""" + => Test(""" @"\b\w+(?=\sis\b)" """, """ @@ -2066,12 +1999,10 @@ public void ReferenceTest33() """, RegexOptions.None); - } [Fact] public void ReferenceTest34() - { - Test(""" + => Test(""" @"[a-z-[m]]" """, """ @@ -2112,12 +2043,10 @@ public void ReferenceTest34() """, RegexOptions.None); - } [Fact] public void ReferenceTest35() - { - Test(""" + => Test(""" @"^\D\d{1,5}\D*$" """, """ @@ -2159,12 +2088,10 @@ public void ReferenceTest35() """, RegexOptions.None); - } [Fact] public void ReferenceTest36() - { - Test(""" + => Test(""" @"[^0-9]" """, """ @@ -2194,12 +2121,10 @@ public void ReferenceTest36() """, RegexOptions.None); - } [Fact] public void ReferenceTest37() - { - Test(""" + => Test(""" @"(\p{IsGreek}+(\s)?)+" """, """ @@ -2247,12 +2172,10 @@ public void ReferenceTest37() """, RegexOptions.None); - } [Fact] public void ReferenceTest38() - { - Test(""" + => Test(""" @"\b(\p{IsGreek}+(\s)?)+\p{Pd}\s(\p{IsBasicLatin}+(\s)?)+" """, """ @@ -2349,12 +2272,10 @@ public void ReferenceTest38() """, RegexOptions.None); - } [Fact] public void ReferenceTest39() - { - Test(""" + => Test(""" @"\b.*[.?!;:](\s|\z)" """, """ @@ -2407,12 +2328,10 @@ public void ReferenceTest39() """, RegexOptions.None); - } [Fact] public void ReferenceTest40() - { - Test(""" + => Test(""" @"^.+" """, """ @@ -2435,12 +2354,10 @@ public void ReferenceTest40() """, RegexOptions.None); - } [Fact] public void ReferenceTest41() - { - Test(""" + => Test(""" @"[^o]" """, """ @@ -2464,12 +2381,10 @@ public void ReferenceTest41() """, RegexOptions.None); - } [Fact] public void ReferenceTest42() - { - Test(""" + => Test(""" @"\bth[^o]\w+\b" """, """ @@ -2511,12 +2426,10 @@ public void ReferenceTest42() """, RegexOptions.None); - } [Fact] public void ReferenceTest43() - { - Test(""" + => Test(""" @"(\P{Sc})+" """, """ @@ -2547,12 +2460,10 @@ public void ReferenceTest43() """, RegexOptions.None); - } [Fact] public void ReferenceTest44() - { - Test(""" + => Test(""" @"[^\p{P}\d]" """, """ @@ -2584,12 +2495,10 @@ public void ReferenceTest44() """, RegexOptions.None); - } [Fact] public void ReferenceTest45() - { - Test(""" + => Test(""" @"\b[A-Z]\w*\b" """, """ @@ -2633,12 +2542,10 @@ public void ReferenceTest45() """, RegexOptions.None); - } [Fact] public void ReferenceTest46() - { - Test(""" + => Test(""" @"\S+?" """, """ @@ -2662,12 +2569,10 @@ public void ReferenceTest46() """, RegexOptions.None); - } [Fact] public void ReferenceTest47() - { - Test(""" + => Test(""" @"y\s" """, """ @@ -2688,12 +2593,10 @@ public void ReferenceTest47() """, RegexOptions.None); - } [Fact] public void ReferenceTest48() - { - Test(""" + => Test(""" @"gr[ae]y\s\S+?[\s\p{P}]" """, """ @@ -2753,12 +2656,10 @@ public void ReferenceTest48() """, RegexOptions.None); - } [Fact] public void ReferenceTest49() - { - Test(""" + => Test(""" @"[\s\p{P}]" """, """ @@ -2789,12 +2690,10 @@ public void ReferenceTest49() """, RegexOptions.None); - } [Fact] public void ReferenceTest50() - { - Test(""" + => Test(""" @"[\p{P}\d]" """, """ @@ -2825,12 +2724,10 @@ public void ReferenceTest50() """, RegexOptions.None); - } [Fact] public void ReferenceTest51() - { - Test(""" + => Test(""" @"[^aeiou]" """, """ @@ -2854,12 +2751,10 @@ public void ReferenceTest51() """, RegexOptions.None); - } [Fact] public void ReferenceTest52() - { - Test(""" + => Test(""" @"(\w)\1" """, """ @@ -2888,12 +2783,10 @@ public void ReferenceTest52() """, RegexOptions.None); - } [Fact] public void ReferenceTest53() - { - Test(""" + => Test(""" @"[^\p{Ll}\p{Lu}\p{Lt}\p{Lo}\p{Nd}\p{Pc}\p{Lm}] " """, """ @@ -2966,12 +2859,10 @@ public void ReferenceTest53() """, RegexOptions.None); - } [Fact] public void ReferenceTest54() - { - Test(""" + => Test(""" @"[^a-zA-Z_0-9]" """, """ @@ -3022,12 +2913,10 @@ public void ReferenceTest54() """, RegexOptions.None); - } [Fact] public void ReferenceTest55() - { - Test(""" + => Test(""" @"\P{Nd}" """, """ @@ -3048,12 +2937,10 @@ public void ReferenceTest55() """, RegexOptions.None); - } [Fact] public void ReferenceTest56() - { - Test(""" + => Test(""" @"(\(?\d{3}\)?[\s-])?" """, """ @@ -3113,12 +3000,10 @@ public void ReferenceTest56() """, RegexOptions.None); - } [Fact] public void ReferenceTest57() - { - Test(""" + => Test(""" @"^(\(?\d{3}\)?[\s-])?\d{3}-\d{4}$" """, """ @@ -3205,12 +3090,10 @@ public void ReferenceTest57() """, RegexOptions.None); - } [Fact] public void ReferenceTest58() - { - Test(""" + => Test(""" @"[0-9]" """, """ @@ -3239,12 +3122,10 @@ public void ReferenceTest58() """, RegexOptions.None); - } [Fact] public void ReferenceTest59() - { - Test(""" + => Test(""" @"\p{Nd}" """, """ @@ -3265,12 +3146,10 @@ public void ReferenceTest59() """, RegexOptions.None); - } [Fact] public void ReferenceTest60() - { - Test(""" + => Test(""" @"\b(\S+)\s?" """, """ @@ -3309,12 +3188,10 @@ public void ReferenceTest60() """, RegexOptions.None); - } [Fact] public void ReferenceTest61() - { - Test(""" + => Test(""" @"[^ \f\n\r\t\v]" """, """ @@ -3358,12 +3235,10 @@ public void ReferenceTest61() """, RegexOptions.None); - } [Fact] public void ReferenceTest62() - { - Test(""" + => Test(""" @"[^\f\n\r\t\v\x85\p{Z}]" """, """ @@ -3416,12 +3291,10 @@ public void ReferenceTest62() """, RegexOptions.None); - } [Fact] public void ReferenceTest63() - { - Test(""" + => Test(""" @"(\s|$)" """, """ @@ -3454,12 +3327,10 @@ public void ReferenceTest63() """, RegexOptions.None); - } [Fact] public void ReferenceTest64() - { - Test(""" + => Test(""" @"\b\w+(e)?s(\s|$)" """, """ @@ -3519,12 +3390,10 @@ public void ReferenceTest64() """, RegexOptions.None); - } [Fact] public void ReferenceTest65() - { - Test(""" + => Test(""" @"[ \f\n\r\t\v]" """, """ @@ -3567,12 +3436,10 @@ public void ReferenceTest65() """, RegexOptions.None); - } [Fact] public void ReferenceTest66() - { - Test(""" + => Test(""" @"(\W){1,2}" """, """ @@ -3604,12 +3471,10 @@ public void ReferenceTest66() """, RegexOptions.None); - } [Fact] public void ReferenceTest67() - { - Test(""" + => Test(""" @"(\w+)" """, """ @@ -3637,12 +3502,10 @@ public void ReferenceTest67() """, RegexOptions.None); - } [Fact] public void ReferenceTest68() - { - Test(""" + => Test(""" @"\b" """, """ @@ -3660,12 +3523,10 @@ public void ReferenceTest68() """, RegexOptions.None); - } [Fact] public void ReferenceTest69() - { - Test(""" + => Test(""" @"\b(\w+)(\W){1,2}" """, """ @@ -3715,12 +3576,10 @@ public void ReferenceTest69() """, RegexOptions.None); - } [Fact] public void ReferenceTest70() - { - Test(""" + => Test(""" @"(?>(\w)\1+).\b" """, """ @@ -3767,12 +3626,10 @@ public void ReferenceTest70() """, RegexOptions.None); - } [Fact] public void ReferenceTest71() - { - Test(""" + => Test(""" @"(\b(\w+)\W+)+" """, """ @@ -3821,12 +3678,10 @@ public void ReferenceTest71() """, RegexOptions.None); - } [Fact] public void ReferenceTest72() - { - Test(""" + => Test(""" @"(\w)\1+.\b" """, """ @@ -3865,12 +3720,10 @@ public void ReferenceTest72() """, RegexOptions.None); - } [Fact] public void ReferenceTest73() - { - Test(""" + => Test(""" @"\p{Sc}*(\s?\d+[.,]?\d*)\p{Sc}*" """, """ @@ -3944,12 +3797,10 @@ public void ReferenceTest73() """, RegexOptions.None); - } [Fact] public void ReferenceTest74() - { - Test(""" + => Test(""" @"p{Sc}*(?\s?\d+[.,]?\d*)\p{Sc}*" """, """ @@ -4027,12 +3878,10 @@ public void ReferenceTest74() """, RegexOptions.None); - } [Fact] public void ReferenceTest75() - { - Test(""" + => Test(""" @"^(\w+\s?)+$" """, """ @@ -4076,12 +3925,10 @@ public void ReferenceTest75() """, RegexOptions.None); - } [Fact] public void ReferenceTest76() - { - Test(""" + => Test(""" @"(?ix) d \w+ \s" """, """ @@ -4124,12 +3971,10 @@ public void ReferenceTest76() """, RegexOptions.None); - } [Fact] public void ReferenceTest77() - { - Test(""" + => Test(""" @"\b(?ix: d \w+)\s" """, """ @@ -4176,12 +4021,10 @@ public void ReferenceTest77() """, RegexOptions.None); - } [Fact] public void ReferenceTest78() - { - Test(""" + => Test(""" @"\bthe\w*\b" """, """ @@ -4213,12 +4056,10 @@ public void ReferenceTest78() """, RegexOptions.None); - } [Fact] public void ReferenceTest79() - { - Test(""" + => Test(""" @"\b(?i:t)he\w*\b" """, """ @@ -4262,12 +4103,10 @@ public void ReferenceTest79() """, RegexOptions.None); - } [Fact] public void ReferenceTest80() - { - Test(""" + => Test(""" @"^(\w+)\s(\d+)$" """, """ @@ -4319,12 +4158,10 @@ public void ReferenceTest80() """, RegexOptions.None); - } [Fact] public void ReferenceTest81() - { - Test(""" + => Test(""" @"^(\w+)\s(\d+)\r*$" """, """ @@ -4383,12 +4220,10 @@ public void ReferenceTest81() """, RegexOptions.Multiline); - } [Fact] public void ReferenceTest82() - { - Test(""" + => Test(""" @"(?m)^(\w+)\s(\d+)\r*$" """, """ @@ -4453,12 +4288,10 @@ public void ReferenceTest82() """, RegexOptions.Multiline); - } [Fact] public void ReferenceTest83() - { - Test(""" + => Test(""" @"(?s)^.+" """, """ @@ -4487,12 +4320,10 @@ public void ReferenceTest83() """, RegexOptions.None); - } [Fact] public void ReferenceTest84() - { - Test(""" + => Test(""" @"\b(\d{2}-)*(?(1)\d{7}|\d{3}-\d{2}-\d{4})\b" """, """ @@ -4593,12 +4424,10 @@ public void ReferenceTest84() """, RegexOptions.None); - } [Fact] public void ReferenceTest85() - { - Test(""" + => Test(""" @"\b\(?((\w+),?\s?)+[\.!?]\)?" """, """ @@ -4680,12 +4509,10 @@ public void ReferenceTest85() """, RegexOptions.None); - } [Fact] public void ReferenceTest86() - { - Test(""" + => Test(""" @"(?n)\b\(?((?>\w+),?\s?)+[\.!?]\)?" """, """ @@ -4773,12 +4600,10 @@ public void ReferenceTest86() """, RegexOptions.None); - } [Fact] public void ReferenceTest87() - { - Test(""" + => Test(""" @"\b\(?(?n:(?>\w+),?\s?)+[\.!?]\)?" """, """ @@ -4863,12 +4688,10 @@ public void ReferenceTest87() """, RegexOptions.None); - } [Fact] public void ReferenceTest88() - { - Test(""" + => Test(""" @"\b\(?((?>\w+),?\s?)+[\.!?]\)?" """, """ @@ -4951,12 +4774,10 @@ public void ReferenceTest88() """, RegexOptions.IgnorePatternWhitespace); - } [Fact] public void ReferenceTest89() - { - Test(""" + => Test(""" @"(?x)\b \(? ( (?>\w+) ,?\s? )+ [\.!?] \)? # Matches an entire sentence." """, """ @@ -5071,12 +4892,10 @@ public void ReferenceTest89() """, RegexOptions.None); - } [Fact] public void ReferenceTest90() - { - Test(""" + => Test(""" @"\bb\w+\s" """, """ @@ -5108,12 +4927,10 @@ public void ReferenceTest90() """, RegexOptions.RightToLeft); - } [Fact] public void ReferenceTest91() - { - Test(""" + => Test(""" @"(?<=\d{1,2}\s)\w+,?\s\d{4}" """, """ @@ -5177,12 +4994,10 @@ public void ReferenceTest91() """, RegexOptions.RightToLeft); - } [Fact] public void ReferenceTest92() - { - Test(""" + => Test(""" @"\b(\w+\s*)+" """, """ @@ -5224,12 +5039,10 @@ public void ReferenceTest92() """, RegexOptions.ECMAScript); - } [Fact] public void ReferenceTest93() - { - Test(""" + => Test(""" @"((a+)(\1) ?)+" """, """ @@ -5283,12 +5096,10 @@ public void ReferenceTest93() """, RegexOptions.ECMAScript); - } [Fact] public void ReferenceTest94() - { - Test(""" + => Test(""" @"\b(D\w+)\s(d\w+)\b" """, """ @@ -5348,12 +5159,10 @@ public void ReferenceTest94() """, RegexOptions.None); - } [Fact] public void ReferenceTest95() - { - Test(""" + => Test(""" @"\b(D\w+)(?ixn) \s (d\w+) \b" """, """ @@ -5427,12 +5236,10 @@ public void ReferenceTest95() """, RegexOptions.None); - } [Fact] public void ReferenceTest96() - { - Test(""" + => Test(""" @"\b((?# case-sensitive comparison)D\w+)\s((?#case-insensitive comparison)d\w+)\b" """, """ @@ -5498,12 +5305,10 @@ public void ReferenceTest96() """, RegexOptions.None); - } [Fact] public void ReferenceTest97() - { - Test(""" + => Test(""" @"\b\(?((?>\w+),?\s?)+[\.!?]\)?" """, """ @@ -5586,12 +5391,10 @@ public void ReferenceTest97() """, RegexOptions.None); - } [Fact] public void ReferenceTest98() - { - Test(""" + => Test(""" @"\b(?\d{2}-)*(?(n2)\d{7}|\d{3}-\d{2}-\d{4})\b" """, """ @@ -5697,12 +5500,10 @@ public void ReferenceTest98() """, RegexOptions.None); - } [Fact] public void ReferenceTest99() - { - Test(""" + => Test(""" @"\b(\d{2}-\d{7}|\d{3}-\d{2}-\d{4})\b" """, """ @@ -5790,12 +5591,10 @@ public void ReferenceTest99() """, RegexOptions.None); - } [Fact] public void ReferenceTest100() - { - Test(""" + => Test(""" @"\bgr(a|e)y\b" """, """ @@ -5841,12 +5640,10 @@ public void ReferenceTest100() """, RegexOptions.None); - } [Fact] public void ReferenceTest101() - { - Test(""" + => Test(""" @"(?>(\w)\1+).\b" """, """ @@ -5893,12 +5690,10 @@ public void ReferenceTest101() """, RegexOptions.None); - } [Fact] public void ReferenceTest102() - { - Test(""" + => Test(""" @"(\b(\w+)\W+)+" """, """ @@ -5947,12 +5742,10 @@ public void ReferenceTest102() """, RegexOptions.None); - } [Fact] public void ReferenceTest103() - { - Test(""" + => Test(""" @"\b91*9*\b" """, """ @@ -5989,12 +5782,10 @@ public void ReferenceTest103() """, RegexOptions.None); - } [Fact] public void ReferenceTest104() - { - Test(""" + => Test(""" @"\ban+\w*?\b" """, """ @@ -6035,12 +5826,10 @@ public void ReferenceTest104() """, RegexOptions.None); - } [Fact] public void ReferenceTest105() - { - Test(""" + => Test(""" @"\ban?\b" """, """ @@ -6071,12 +5860,10 @@ public void ReferenceTest105() """, RegexOptions.None); - } [Fact] public void ReferenceTest106() - { - Test(""" + => Test(""" @"\b\d+\,\d{3}\b" """, """ @@ -6118,12 +5905,10 @@ public void ReferenceTest106() """, RegexOptions.None); - } [Fact] public void ReferenceTest107() - { - Test(""" + => Test(""" @"\b\d{2,}\b\D+" """, """ @@ -6162,12 +5947,10 @@ public void ReferenceTest107() """, RegexOptions.None); - } [Fact] public void ReferenceTest108() - { - Test(""" + => Test(""" @"(00\s){2,4}" """, """ @@ -6202,12 +5985,10 @@ public void ReferenceTest108() """, RegexOptions.None); - } [Fact] public void ReferenceTest109() - { - Test(""" + => Test(""" @"\b\w*?oo\w*?\b" """, """ @@ -6252,12 +6033,10 @@ public void ReferenceTest109() """, RegexOptions.None); - } [Fact] public void ReferenceTest110() - { - Test(""" + => Test(""" @"\b\w+?\b" """, """ @@ -6289,12 +6068,10 @@ public void ReferenceTest110() """, RegexOptions.None); - } [Fact] public void ReferenceTest111() - { - Test(""" + => Test(""" @"^\s*(System.)??Console.Write(Line)??\(??" """, """ @@ -6372,12 +6149,10 @@ public void ReferenceTest111() """, RegexOptions.None); - } [Fact] public void ReferenceTest112() - { - Test(""" + => Test(""" @"(System.)??" """, """ @@ -6410,12 +6185,10 @@ public void ReferenceTest112() """, RegexOptions.None); - } [Fact] public void ReferenceTest113() - { - Test(""" + => Test(""" @"\b(\w{3,}?\.){2}?\w{3,}?\b" """, """ @@ -6482,12 +6255,10 @@ public void ReferenceTest113() """, RegexOptions.None); - } [Fact] public void ReferenceTest114() - { - Test(""" + => Test(""" @"\b[A-Z](\w*?\s*?){1,10}[.!?]" """, """ @@ -6563,12 +6334,10 @@ public void ReferenceTest114() """, RegexOptions.None); - } [Fact] public void ReferenceTest115() - { - Test(""" + => Test(""" @"b.*([0-9]{4})\b" """, """ @@ -6622,12 +6391,10 @@ public void ReferenceTest115() """, RegexOptions.None); - } [Fact] public void ReferenceTest116() - { - Test(""" + => Test(""" @"\b.*?([0-9]{4})\b" """, """ @@ -6685,12 +6452,10 @@ public void ReferenceTest116() """, RegexOptions.None); - } [Fact] public void ReferenceTest117() - { - Test(""" + => Test(""" @"(a?)*" """, """ @@ -6720,12 +6485,10 @@ public void ReferenceTest117() """, RegexOptions.None); - } [Fact] public void ReferenceTest118() - { - Test(""" + => Test(""" @"(a\1|(?(1)\1)){0,2}" """, """ @@ -6779,12 +6542,10 @@ public void ReferenceTest118() """, RegexOptions.None); - } [Fact] public void ReferenceTest119() - { - Test(""" + => Test(""" @"(a\1|(?(1)\1)){2}" """, """ @@ -6836,12 +6597,10 @@ public void ReferenceTest119() """, RegexOptions.None); - } [Fact] public void ReferenceTest120() - { - Test(""" + => Test(""" @"(\w)\1" """, """ @@ -6870,12 +6629,10 @@ public void ReferenceTest120() """, RegexOptions.None); - } [Fact] public void ReferenceTest121() - { - Test(""" + => Test(""" @"(?\w)\k" """, """ @@ -6912,12 +6669,10 @@ public void ReferenceTest121() """, RegexOptions.None); - } [Fact] public void ReferenceTest122() - { - Test(""" + => Test(""" @"(?<2>\w)\k<2>" """, """ @@ -6953,12 +6708,10 @@ public void ReferenceTest122() """, RegexOptions.None); - } [Fact] public void ReferenceTest123() - { - Test(""" + => Test(""" @"(?<1>a)(?<1>\1b)*" """, """ @@ -7006,12 +6759,10 @@ public void ReferenceTest123() """, RegexOptions.None); - } [Fact] public void ReferenceTest124() - { - Test(""" + => Test(""" @"\b(\p{Lu}{2})(\d{2})?(\p{Lu}{2})\b" """, """ @@ -7090,12 +6841,10 @@ public void ReferenceTest124() """, RegexOptions.None); - } [Fact] public void ReferenceTest125() - { - Test(""" + => Test(""" @"\bgr[ae]y\b" """, """ @@ -7132,12 +6881,10 @@ public void ReferenceTest125() """, RegexOptions.None); - } [Fact] public void ReferenceTest126() - { - Test(""" + => Test(""" @"\b((?# case sensitive comparison)D\w+)\s(?ixn)((?#case insensitive comparison)d\w+)\b" """, """ @@ -7208,12 +6955,10 @@ public void ReferenceTest126() """, RegexOptions.None); - } [Fact] public void ReferenceTest127() - { - Test(""" + => Test(""" @"\{\d+(,-*\d+)*(\:\w{1,4}?)*\}(?x) # Looks for a composite format item." """, """ @@ -7307,5 +7052,4 @@ public void ReferenceTest127() """, RegexOptions.None); - } } diff --git a/src/EditorFeatures/CSharpTest2/Recommendations/AsKeywordRecommenderTests.cs b/src/EditorFeatures/CSharpTest2/Recommendations/AsKeywordRecommenderTests.cs index ae908498fbac..3d6331651ea6 100644 --- a/src/EditorFeatures/CSharpTest2/Recommendations/AsKeywordRecommenderTests.cs +++ b/src/EditorFeatures/CSharpTest2/Recommendations/AsKeywordRecommenderTests.cs @@ -248,4 +248,19 @@ void M(object o) } } """); + + [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/78800")] + public Task TestAfterReturnExpression() + => VerifyKeywordAsync( + """ + class C + { + public static string EvaluateRangeVariable() + { + return RandomValue() $$ + } + + public int RandomValue() => 0; + } + """); } diff --git a/src/EditorFeatures/CSharpTest2/Recommendations/AsyncKeywordRecommenderTests.cs b/src/EditorFeatures/CSharpTest2/Recommendations/AsyncKeywordRecommenderTests.cs index 766d13ce4596..444af824c182 100644 --- a/src/EditorFeatures/CSharpTest2/Recommendations/AsyncKeywordRecommenderTests.cs +++ b/src/EditorFeatures/CSharpTest2/Recommendations/AsyncKeywordRecommenderTests.cs @@ -58,18 +58,12 @@ interface C """); [Fact] - public async Task TestMethodDeclarationInGlobalStatement1() - { - const string text = @"$$"; - await VerifyKeywordAsync(SourceCodeKind.Script, text); - } + public Task TestMethodDeclarationInGlobalStatement1() + => VerifyKeywordAsync(SourceCodeKind.Script, @"$$"); [Fact] - public async Task TestMethodDeclarationInGlobalStatement2() - { - const string text = @"public $$"; - await VerifyKeywordAsync(SourceCodeKind.Script, text); - } + public Task TestMethodDeclarationInGlobalStatement2() + => VerifyKeywordAsync(SourceCodeKind.Script, @"public $$"); [Fact] public Task TestExpressionContext() diff --git a/src/EditorFeatures/CSharpTest2/Recommendations/IsKeywordRecommenderTests.cs b/src/EditorFeatures/CSharpTest2/Recommendations/IsKeywordRecommenderTests.cs index ce21db4353e6..614181bc7e45 100644 --- a/src/EditorFeatures/CSharpTest2/Recommendations/IsKeywordRecommenderTests.cs +++ b/src/EditorFeatures/CSharpTest2/Recommendations/IsKeywordRecommenderTests.cs @@ -301,4 +301,19 @@ void M(object o) } } """); + + [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/78800")] + public Task TestAfterReturnExpression() + => VerifyKeywordAsync( + """ + class C + { + public static string EvaluateRangeVariable() + { + return RandomValue() $$ + } + + public int RandomValue() => 0; + } + """); } diff --git a/src/EditorFeatures/CSharpTest2/Recommendations/RecommenderTests.cs b/src/EditorFeatures/CSharpTest2/Recommendations/RecommenderTests.cs index ed796549b428..5db2336fc59a 100644 --- a/src/EditorFeatures/CSharpTest2/Recommendations/RecommenderTests.cs +++ b/src/EditorFeatures/CSharpTest2/Recommendations/RecommenderTests.cs @@ -172,7 +172,9 @@ internal async Task VerifyKeywordAsync( await VerifyWorkerAsync(text, absent: false, options: scriptOptions ?? Options.Script); } - protected async Task VerifyKeywordAsync(SourceCodeKind kind, string text) + protected async Task VerifyKeywordAsync( + SourceCodeKind kind, + [StringSyntax(PredefinedEmbeddedLanguageNames.CSharpTest)] string text) { switch (kind) { @@ -211,7 +213,9 @@ protected async Task VerifyAbsenceAsync( } } - protected static string AddInsideMethod(string text, bool isAsync = false, string returnType = "void", bool topLevelStatement = false) + protected static string AddInsideMethod( + [StringSyntax(PredefinedEmbeddedLanguageNames.CSharpTest)] string text, + bool isAsync = false, string returnType = "void", bool topLevelStatement = false) { if (topLevelStatement) { diff --git a/src/EditorFeatures/CSharpTest2/Recommendations/SwitchKeywordRecommenderTests.cs b/src/EditorFeatures/CSharpTest2/Recommendations/SwitchKeywordRecommenderTests.cs index 6d1d19f4e05d..477abff07aa9 100644 --- a/src/EditorFeatures/CSharpTest2/Recommendations/SwitchKeywordRecommenderTests.cs +++ b/src/EditorFeatures/CSharpTest2/Recommendations/SwitchKeywordRecommenderTests.cs @@ -15,7 +15,7 @@ public sealed class SwitchKeywordRecommenderTests : KeywordRecommenderTests [Fact] public Task TestAtRoot_Interactive() => VerifyKeywordAsync(SourceCodeKind.Script, -@"$$"); + @"$$"); [Fact] public Task TestAfterClass_Interactive() @@ -44,17 +44,17 @@ public Task TestAfterGlobalVariableDeclaration_Interactive() [Fact] public Task TestNotInUsingAlias() => VerifyAbsenceAsync( -@"using Goo = $$"); + @"using Goo = $$"); [Fact] public Task TestNotInGlobalUsingAlias() => VerifyAbsenceAsync( -@"global using Goo = $$"); + @"global using Goo = $$"); [Fact] public Task TestEmptyStatement() => VerifyKeywordAsync(AddInsideMethod( -@"$$")); + @"$$")); [Fact] public Task TestBeforeStatement() @@ -93,7 +93,7 @@ public Task TestInsideSwitchBlock() [Fact] public Task TestNotAfterSwitch1() => VerifyAbsenceAsync(AddInsideMethod( -@"switch $$")); + @"switch $$")); [Fact] public async Task TestAfterExpression() @@ -119,7 +119,7 @@ public async Task TestAfterTuple() [Fact] public Task TestNotAfterSwitch2() => VerifyAbsenceAsync(AddInsideMethod( -@"switch ($$")); + @"switch ($$")); [Fact] public Task TestNotInClass() @@ -267,4 +267,19 @@ void M(object o) } } """); + + [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/78800")] + public Task TestAfterReturnExpression() + => VerifyKeywordAsync( + """ + class C + { + public static string EvaluateRangeVariable() + { + return RandomValue() $$ + } + + public int RandomValue() => 0; + } + """); } diff --git a/src/EditorFeatures/CSharpTest2/Recommendations/ThisKeywordRecommenderTests.cs b/src/EditorFeatures/CSharpTest2/Recommendations/ThisKeywordRecommenderTests.cs index 9cb38ee0e1cb..781907d9b5c3 100644 --- a/src/EditorFeatures/CSharpTest2/Recommendations/ThisKeywordRecommenderTests.cs +++ b/src/EditorFeatures/CSharpTest2/Recommendations/ThisKeywordRecommenderTests.cs @@ -15,7 +15,7 @@ public sealed class ThisKeywordRecommenderTests : KeywordRecommenderTests [Fact] public Task TestNotAtRoot_Interactive() => VerifyAbsenceAsync(SourceCodeKind.Script, -@"$$"); + @"$$"); [Fact] public Task TestNotAfterClass_Interactive() @@ -44,52 +44,52 @@ public Task TestNotAfterGlobalVariableDeclaration_Interactive() [Fact] public Task TestNotInUsingAlias() => VerifyAbsenceAsync( -@"using Goo = $$"); + @"using Goo = $$"); [Fact] public Task TestNotInGlobalUsingAlias() => VerifyAbsenceAsync( -@"global using Goo = $$"); + @"global using Goo = $$"); [Fact] public Task TestNotAfterAngle() => VerifyAbsenceAsync( -@"interface IGoo<$$"); + @"interface IGoo<$$"); [Fact] public Task TestInterfaceTypeVarianceNotAfterIn() => VerifyAbsenceAsync( -@"interface IGoo VerifyAbsenceAsync( -@"interface IGoo VerifyAbsenceAsync( -@"interface IGoo<[Goo]$$"); + @"interface IGoo<[Goo]$$"); [Fact] public Task TestDelegateTypeVarianceNotAfterAngle() => VerifyAbsenceAsync( -@"delegate void D<$$"); + @"delegate void D<$$"); [Fact] public Task TestDelegateTypeVarianceNotAfterComma() => VerifyAbsenceAsync( -@"delegate void D VerifyAbsenceAsync( -@"delegate void D<[Goo]$$"); + @"delegate void D<[Goo]$$"); [Fact] public Task TestNotThisBaseListAfterAngle() => VerifyAbsenceAsync( -@"interface IGoo : Bar<$$"); + @"interface IGoo : Bar<$$"); [Fact] public Task TestNotInGenericMethod() @@ -181,17 +181,17 @@ public C(int i, [Goo]$$ [Fact] public Task TestNotAfterDelegateOpenParen() => VerifyAbsenceAsync( -@"delegate void D($$"); + @"delegate void D($$"); [Fact] public Task TestNotAfterDelegateComma() => VerifyAbsenceAsync( -@"delegate void D(int i, $$"); + @"delegate void D(int i, $$"); [Fact] public Task TestNotAfterDelegateAttribute() => VerifyAbsenceAsync( -@"delegate void D(int i, [Goo]$$"); + @"delegate void D(int i, [Goo]$$"); [Fact] public Task TestNotAfterOperator() @@ -712,27 +712,27 @@ public C() : $$ [Fact] public Task TestInEmptyStatement() => VerifyKeywordAsync(AddInsideMethod( -@"$$")); + @"$$")); [Fact] public Task TestAfterCast() => VerifyKeywordAsync(AddInsideMethod( -@"stack.Push(((IEnumerable)((TreeSegment)$$")); + @"stack.Push(((IEnumerable)((TreeSegment)$$")); [Fact] public Task TestAfterReturn() => VerifyKeywordAsync(AddInsideMethod( -@"return $$")); + @"return $$")); [Fact] public Task TestAfterIndexer() => VerifyKeywordAsync(AddInsideMethod( -@"return this.items[$$")); + @"return this.items[$$")); [Fact] public Task TestAfterSimpleCast() => VerifyKeywordAsync(AddInsideMethod( -@"return ((IEnumerable)$$")); + @"return ((IEnumerable)$$")); [Fact] public Task TestNotInClass() @@ -1215,7 +1215,21 @@ public void Extension(out $$ object obj, int x) { } [Fact] public Task TestAfterRefExpression() => VerifyKeywordAsync(AddInsideMethod( -@"ref int x = ref $$")); + @"ref int x = ref $$")); + + [Theory, CombinatorialData, WorkItem("https://github.com/dotnet/roslyn/issues/78979")] + public Task TestInsideNameofInAttribute(bool isStatic) + => VerifyKeywordAsync($$""" + public class Example + { + private string _field; + + [MemberNotNull(nameof($$))] + public {{(isStatic ? "static " : " ")}}void Method() + { + } + } + """); #region Collection expressions diff --git a/src/EditorFeatures/CSharpTest2/Recommendations/WithKeywordRecommenderTests.cs b/src/EditorFeatures/CSharpTest2/Recommendations/WithKeywordRecommenderTests.cs index 8ec155e651ba..1646667746b6 100644 --- a/src/EditorFeatures/CSharpTest2/Recommendations/WithKeywordRecommenderTests.cs +++ b/src/EditorFeatures/CSharpTest2/Recommendations/WithKeywordRecommenderTests.cs @@ -253,4 +253,19 @@ void M(object o) } } """); + + [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/78800")] + public Task TestAfterReturnExpression() + => VerifyKeywordAsync( + """ + class C + { + public static string EvaluateRangeVariable() + { + return RandomValue() $$ + } + + public int RandomValue() => 0; + } + """); } diff --git a/src/EditorFeatures/Core/Classification/Syntactic/SyntacticClassificationTaggerProvider.TagComputer.cs b/src/EditorFeatures/Core/Classification/Syntactic/SyntacticClassificationTaggerProvider.TagComputer.cs index f3d09ca34bf1..c696fe16032f 100644 --- a/src/EditorFeatures/Core/Classification/Syntactic/SyntacticClassificationTaggerProvider.TagComputer.cs +++ b/src/EditorFeatures/Core/Classification/Syntactic/SyntacticClassificationTaggerProvider.TagComputer.cs @@ -254,7 +254,7 @@ static ITextSnapshot GetLatest(ImmutableSegmentedList snapshots) CancellationToken cancellationToken) { if (lastProcessedDocument is null) - return ValueTaskFactory.FromResult(null); + return ValueTask.FromResult(null); if (lastProcessedRoot != null) { @@ -262,7 +262,7 @@ static ITextSnapshot GetLatest(ImmutableSegmentedList snapshots) if (currentRoot is not null) return new(classificationService.ComputeSyntacticChangeRange(solutionServices, lastProcessedRoot, currentRoot, _diffTimeout, cancellationToken)); else - return ValueTaskFactory.FromResult(null); + return ValueTask.FromResult(null); } else { diff --git a/src/EditorFeatures/Core/EditorConfigSettings/Aggregator/SettingsAggregator.cs b/src/EditorFeatures/Core/EditorConfigSettings/Aggregator/SettingsAggregator.cs index 0d9689e30347..43f78192c404 100644 --- a/src/EditorFeatures/Core/EditorConfigSettings/Aggregator/SettingsAggregator.cs +++ b/src/EditorFeatures/Core/EditorConfigSettings/Aggregator/SettingsAggregator.cs @@ -94,7 +94,7 @@ private void UpdateProviders(WorkspaceChangeEventArgs e) private ValueTask UpdateProvidersAsync(CancellationToken cancellationToken) { UpdateProviders(_workspace.CurrentSolution.SolutionState); - return ValueTaskFactory.CompletedTask; + return ValueTask.CompletedTask; } [MemberNotNull(nameof(_whitespaceProvider))] diff --git a/src/EditorFeatures/Core/ExternalAccess/VSTypeScript/VSTypeScriptFindUsagesContext.cs b/src/EditorFeatures/Core/ExternalAccess/VSTypeScript/VSTypeScriptFindUsagesContext.cs index eadf81c78509..33ced3158520 100644 --- a/src/EditorFeatures/Core/ExternalAccess/VSTypeScript/VSTypeScriptFindUsagesContext.cs +++ b/src/EditorFeatures/Core/ExternalAccess/VSTypeScript/VSTypeScriptFindUsagesContext.cs @@ -27,7 +27,7 @@ public ValueTask OnDefinitionFoundAsync(VSTypeScriptDefinitionItem definition, C => UnderlyingObject.OnDefinitionFoundAsync(definition.UnderlyingObject, cancellationToken); public ValueTask OnReferenceFoundAsync(VSTypeScriptSourceReferenceItem reference, CancellationToken cancellationToken) - => UnderlyingObject.OnReferencesFoundAsync(IAsyncEnumerableExtensions.SingletonAsync(reference.UnderlyingObject), cancellationToken); + => UnderlyingObject.OnReferencesFoundAsync(AsyncEnumerableFactory.SingletonAsync(reference.UnderlyingObject), cancellationToken); public ValueTask OnCompletedAsync(CancellationToken cancellationToken) => UnderlyingObject.OnCompletedAsync(cancellationToken); diff --git a/src/EditorFeatures/Core/ExternalAccess/VSTypeScript/VSTypeScriptFindUsagesService.cs b/src/EditorFeatures/Core/ExternalAccess/VSTypeScript/VSTypeScriptFindUsagesService.cs index d71ef18593bb..f31894e55e7f 100644 --- a/src/EditorFeatures/Core/ExternalAccess/VSTypeScript/VSTypeScriptFindUsagesService.cs +++ b/src/EditorFeatures/Core/ExternalAccess/VSTypeScript/VSTypeScriptFindUsagesService.cs @@ -46,10 +46,10 @@ public ValueTask OnDefinitionFoundAsync(VSTypeScriptDefinitionItem definition, C => _context.OnDefinitionFoundAsync(definition.UnderlyingObject, cancellationToken); public ValueTask OnReferenceFoundAsync(VSTypeScriptSourceReferenceItem reference, CancellationToken cancellationToken) - => _context.OnReferencesFoundAsync(IAsyncEnumerableExtensions.SingletonAsync(reference.UnderlyingObject), cancellationToken); + => _context.OnReferencesFoundAsync(AsyncEnumerableFactory.SingletonAsync(reference.UnderlyingObject), cancellationToken); public ValueTask OnCompletedAsync(CancellationToken cancellationToken) - => ValueTaskFactory.CompletedTask; + => ValueTask.CompletedTask; } private sealed class ProgressTracker(IStreamingProgressTracker progressTracker) : IVSTypeScriptStreamingProgressTracker diff --git a/src/EditorFeatures/Core/InlineRename/AbstractEditorInlineRenameService.InlineRenameLocationSet.cs b/src/EditorFeatures/Core/InlineRename/AbstractEditorInlineRenameService.InlineRenameLocationSet.cs index 361632cd6441..844b07058feb 100644 --- a/src/EditorFeatures/Core/InlineRename/AbstractEditorInlineRenameService.InlineRenameLocationSet.cs +++ b/src/EditorFeatures/Core/InlineRename/AbstractEditorInlineRenameService.InlineRenameLocationSet.cs @@ -44,7 +44,7 @@ public async Task GetReplacementsAsync( CancellationToken cancellationToken) { var conflicts = await _renameLocationSet.ResolveConflictsAsync( - _renameInfo.RenameSymbol, _renameInfo.GetFinalSymbolName(replacementText), nonConflictSymbolKeys: default, cancellationToken).ConfigureAwait(false); + _renameInfo.RenameSymbol, _renameInfo.GetFinalSymbolName(replacementText), cancellationToken).ConfigureAwait(false); return new InlineRenameReplacementInfo(conflicts); } diff --git a/src/EditorFeatures/Core/Logging/FunctionIdOptions.cs b/src/EditorFeatures/Core/Logging/FunctionIdOptions.cs index 80522259cf43..3b120e1b8bea 100644 --- a/src/EditorFeatures/Core/Logging/FunctionIdOptions.cs +++ b/src/EditorFeatures/Core/Logging/FunctionIdOptions.cs @@ -35,7 +35,7 @@ private static Option2 CreateOption(FunctionId id) } private static IEnumerable GetFunctionIds() - => Enum.GetValues(typeof(FunctionId)).Cast(); + => Enum.GetValues(); public static IEnumerable GetOptions() => GetFunctionIds().Select(GetOption); diff --git a/src/EditorFeatures/Core/Remote/SolutionChecksumUpdater.cs b/src/EditorFeatures/Core/Remote/SolutionChecksumUpdater.cs index eb2afb0a1cbe..9a98110210a1 100644 --- a/src/EditorFeatures/Core/Remote/SolutionChecksumUpdater.cs +++ b/src/EditorFeatures/Core/Remote/SolutionChecksumUpdater.cs @@ -3,6 +3,7 @@ // See the LICENSE file in the project root for more information. using System; +using System.Diagnostics; using System.Threading; using System.Threading.Tasks; using Microsoft.CodeAnalysis.ErrorReporting; @@ -102,11 +103,24 @@ private void OnWorkspaceChanged(WorkspaceChangeEventArgs _) private void OnWorkspaceChangedImmediate(WorkspaceChangeEventArgs e) { - if (e.Kind == WorkspaceChangeKind.DocumentChanged) + if (e.Kind is WorkspaceChangeKind.DocumentChanged or WorkspaceChangeKind.AdditionalDocumentChanged) { var documentId = e.DocumentId!; - var oldDocument = e.OldSolution.GetRequiredDocument(documentId); - var newDocument = e.NewSolution.GetRequiredDocument(documentId); + TextDocument oldDocument; + TextDocument newDocument; + + if (e.Kind == WorkspaceChangeKind.DocumentChanged) + { + oldDocument = e.OldSolution.GetRequiredDocument(documentId); + newDocument = e.NewSolution.GetRequiredDocument(documentId); + } + else + { + Debug.Assert(e.Kind == WorkspaceChangeKind.AdditionalDocumentChanged); + + oldDocument = e.OldSolution.GetRequiredAdditionalDocument(documentId); + newDocument = e.NewSolution.GetRequiredAdditionalDocument(documentId); + } // Fire-and-forget to dispatch notification of this document change event to the remote side // and return to the caller as quickly as possible. @@ -157,8 +171,8 @@ await client.TryInvokeAsync( } private async Task DispatchSynchronizeTextChangesAsync( - Document oldDocument, - Document newDocument) + TextDocument oldDocument, + TextDocument newDocument) { // Explicitly force a yield point here to ensure this method returns to the caller immediately and that // all work is done off the calling thread. diff --git a/src/EditorFeatures/Core/Shared/Tagging/EventSources/TaggerEventSources.WorkspaceChangedEventSource.cs b/src/EditorFeatures/Core/Shared/Tagging/EventSources/TaggerEventSources.WorkspaceChangedEventSource.cs index 51a1735aab53..2ecc88d76e08 100644 --- a/src/EditorFeatures/Core/Shared/Tagging/EventSources/TaggerEventSources.WorkspaceChangedEventSource.cs +++ b/src/EditorFeatures/Core/Shared/Tagging/EventSources/TaggerEventSources.WorkspaceChangedEventSource.cs @@ -3,6 +3,7 @@ // See the LICENSE file in the project root for more information. using System.Threading; +using System.Threading.Tasks; using Microsoft.CodeAnalysis.Shared.TestHooks; using Microsoft.CodeAnalysis.Threading; using Microsoft.VisualStudio.Text; @@ -29,7 +30,7 @@ public WorkspaceChangedEventSource( processBatchAsync: cancellationToken => { RaiseChanged(); - return ValueTaskFactory.CompletedTask; + return ValueTask.CompletedTask; }, asyncListener, CancellationToken.None); diff --git a/src/EditorFeatures/Core/Tagging/AbstractAsynchronousTaggerProvider.TagSource_ProduceTags.cs b/src/EditorFeatures/Core/Tagging/AbstractAsynchronousTaggerProvider.TagSource_ProduceTags.cs index c9eb12fb47e5..87237a63e2c1 100644 --- a/src/EditorFeatures/Core/Tagging/AbstractAsynchronousTaggerProvider.TagSource_ProduceTags.cs +++ b/src/EditorFeatures/Core/Tagging/AbstractAsynchronousTaggerProvider.TagSource_ProduceTags.cs @@ -135,12 +135,12 @@ private void RemoveTagsThatIntersectEdit(TextContentChangedEventArgs e) snapshot, @this._dataSource.SpanTrackingMode, allTagsList); - return ValueTaskFactory.FromResult((oldTagTrees.SetItem(buffer, newTagTree), default(VoidResult))); + return ValueTask.FromResult((oldTagTrees.SetItem(buffer, newTagTree), default(VoidResult))); } } // return oldTagTrees to indicate nothing changed. - return ValueTaskFactory.FromResult((oldTagTrees, default(VoidResult))); + return ValueTask.FromResult((oldTagTrees, default(VoidResult))); }, args: (this, e, tagsToRemove, allTagsList, allTagsSet), _disposalTokenSource.Token).VerifyCompleted(); diff --git a/src/EditorFeatures/Core/Tagging/AbstractAsynchronousTaggerProvider.TagSource_TagsChanged.cs b/src/EditorFeatures/Core/Tagging/AbstractAsynchronousTaggerProvider.TagSource_TagsChanged.cs index c81993f1f283..55a2e9158c3c 100644 --- a/src/EditorFeatures/Core/Tagging/AbstractAsynchronousTaggerProvider.TagSource_TagsChanged.cs +++ b/src/EditorFeatures/Core/Tagging/AbstractAsynchronousTaggerProvider.TagSource_TagsChanged.cs @@ -46,7 +46,7 @@ private ValueTask ProcessTagsChangedAsync( { var tagsChanged = this.TagsChanged; if (tagsChanged == null) - return ValueTaskFactory.CompletedTask; + return ValueTask.CompletedTask; foreach (var collection in snapshotSpans) { @@ -66,7 +66,7 @@ private ValueTask ProcessTagsChangedAsync( tagsChanged(this, new SnapshotSpanEventArgs(span)); } - return ValueTaskFactory.CompletedTask; + return ValueTask.CompletedTask; } } } diff --git a/src/EditorFeatures/DiagnosticsTestUtilities/ChangeSignature/AbstractChangeSignatureTests.cs b/src/EditorFeatures/DiagnosticsTestUtilities/ChangeSignature/AbstractChangeSignatureTests.cs index ff1ae92009f4..6d5705ade3ca 100644 --- a/src/EditorFeatures/DiagnosticsTestUtilities/ChangeSignature/AbstractChangeSignatureTests.cs +++ b/src/EditorFeatures/DiagnosticsTestUtilities/ChangeSignature/AbstractChangeSignatureTests.cs @@ -45,7 +45,7 @@ internal async Task TestChangeSignatureViaCodeActionAsync( { if (expectedCodeAction) { - var testOptions = new TestParameters(); + var testOptions = TestParameters.Default; using var workspace = CreateWorkspaceFromOptions(markup, testOptions); var optionsService = (TestChangeSignatureOptionsService)workspace.Services.GetRequiredService(); diff --git a/src/EditorFeatures/DiagnosticsTestUtilities/CodeActions/AbstractCodeActionOrUserDiagnosticTest.cs b/src/EditorFeatures/DiagnosticsTestUtilities/CodeActions/AbstractCodeActionOrUserDiagnosticTest.cs index 0c1a3714ff67..b7cb8d2ed837 100644 --- a/src/EditorFeatures/DiagnosticsTestUtilities/CodeActions/AbstractCodeActionOrUserDiagnosticTest.cs +++ b/src/EditorFeatures/DiagnosticsTestUtilities/CodeActions/AbstractCodeActionOrUserDiagnosticTest.cs @@ -2,978 +2,29 @@ // 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 - -#if CODE_STYLE -extern alias CODESTYLE_UTILITIES; -#endif - -using System; -using System.Collections.Generic; -using System.Collections.Immutable; -using System.Diagnostics; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; using System.Xml.Linq; -using Microsoft.CodeAnalysis; -using Microsoft.CodeAnalysis.CodeActions; -using Microsoft.CodeAnalysis.CodeFixes; -using Microsoft.CodeAnalysis.CodeRefactorings; using Microsoft.CodeAnalysis.Host; -using Microsoft.CodeAnalysis.Remote; -using Microsoft.CodeAnalysis.Remote.Testing; -using Microsoft.CodeAnalysis.Shared.Extensions; using Microsoft.CodeAnalysis.Test.Utilities; -using Microsoft.CodeAnalysis.Testing; -using Microsoft.CodeAnalysis.Text; -using Microsoft.CodeAnalysis.UnitTests; -using Newtonsoft.Json.Linq; -using Roslyn.Test.Utilities; -using Roslyn.Utilities; -using Xunit; using Xunit.Abstractions; namespace Microsoft.CodeAnalysis.Editor.UnitTests.CodeActions; -#if CODE_STYLE -using OptionsCollectionAlias = CODESTYLE_UTILITIES::Microsoft.CodeAnalysis.Editor.UnitTests.CodeActions.OptionsCollection; -#else -using OptionsCollectionAlias = OptionsCollection; -#endif - [UseExportProvider] -public abstract partial class AbstractCodeActionOrUserDiagnosticTest +public abstract partial class AbstractCodeActionOrUserDiagnosticTest(ITestOutputHelper? logger = null) + : AbstractCodeActionOrUserDiagnosticTest_NoEditor< + EditorTestHostDocument, + EditorTestHostProject, + EditorTestHostSolution, + EditorTestWorkspace>(logger) { - public sealed class TestParameters - { - /// - /// editorconfig options. - /// - internal readonly OptionsCollectionAlias options; - internal readonly OptionsCollectionAlias globalOptions; - internal readonly TestHost testHost; - internal readonly string workspaceKind; - internal readonly object fixProviderData; - internal readonly ParseOptions parseOptions; - internal readonly CompilationOptions compilationOptions; - internal readonly int index; - internal readonly CodeActionPriority? priority; - internal readonly bool retainNonFixableDiagnostics; - internal readonly bool includeDiagnosticsOutsideSelection; - internal readonly bool includeNonLocalDocumentDiagnostics; - internal readonly string title; - internal readonly bool treatPositionIndicatorsAsCode; - - internal TestParameters( - ParseOptions parseOptions = null, - CompilationOptions compilationOptions = null, - OptionsCollectionAlias options = null, - OptionsCollectionAlias globalOptions = null, - object fixProviderData = null, - int index = 0, - CodeActionPriority? priority = null, - bool retainNonFixableDiagnostics = false, - bool includeDiagnosticsOutsideSelection = false, - string title = null, - TestHost testHost = TestHost.OutOfProcess, - string workspaceKind = null, - bool includeNonLocalDocumentDiagnostics = false, - bool treatPositionIndicatorsAsCode = false) - { - this.parseOptions = parseOptions; - this.compilationOptions = compilationOptions; - this.options = options; - this.globalOptions = globalOptions; - this.fixProviderData = fixProviderData; - this.index = index; - this.priority = priority; - this.retainNonFixableDiagnostics = retainNonFixableDiagnostics; - this.includeDiagnosticsOutsideSelection = includeDiagnosticsOutsideSelection; - this.title = title; - this.testHost = testHost; - this.workspaceKind = workspaceKind; - this.includeNonLocalDocumentDiagnostics = includeNonLocalDocumentDiagnostics; - this.treatPositionIndicatorsAsCode = treatPositionIndicatorsAsCode; - } - - public static readonly TestParameters Default = new(parseOptions: null); - - public TestParameters WithParseOptions(ParseOptions parseOptions) - => new(parseOptions, compilationOptions, options, globalOptions, fixProviderData, index, priority, retainNonFixableDiagnostics, includeDiagnosticsOutsideSelection, title, testHost, workspaceKind, includeNonLocalDocumentDiagnostics, treatPositionIndicatorsAsCode); - - public TestParameters WithCompilationOptions(CompilationOptions compilationOptions) - => new(parseOptions, compilationOptions, options, globalOptions, fixProviderData, index, priority, retainNonFixableDiagnostics, includeDiagnosticsOutsideSelection, title, testHost, workspaceKind, includeNonLocalDocumentDiagnostics, treatPositionIndicatorsAsCode); - - internal TestParameters WithOptions(OptionsCollectionAlias options) - => new(parseOptions, compilationOptions, options, globalOptions, fixProviderData, index, priority, retainNonFixableDiagnostics, includeDiagnosticsOutsideSelection, title, testHost, workspaceKind, includeNonLocalDocumentDiagnostics, treatPositionIndicatorsAsCode); - - public TestParameters WithFixProviderData(object fixProviderData) - => new(parseOptions, compilationOptions, options, globalOptions, fixProviderData, index, priority, retainNonFixableDiagnostics, includeDiagnosticsOutsideSelection, title, testHost, workspaceKind, includeNonLocalDocumentDiagnostics, treatPositionIndicatorsAsCode); - - public TestParameters WithIndex(int index) - => new(parseOptions, compilationOptions, options, globalOptions, fixProviderData, index, priority, retainNonFixableDiagnostics, includeDiagnosticsOutsideSelection, title, testHost, workspaceKind, includeNonLocalDocumentDiagnostics, treatPositionIndicatorsAsCode); - - public TestParameters WithRetainNonFixableDiagnostics(bool retainNonFixableDiagnostics) - => new(parseOptions, compilationOptions, options, globalOptions, fixProviderData, index, priority, retainNonFixableDiagnostics, includeDiagnosticsOutsideSelection, title, testHost, workspaceKind, includeNonLocalDocumentDiagnostics, treatPositionIndicatorsAsCode); - - public TestParameters WithIncludeDiagnosticsOutsideSelection(bool includeDiagnosticsOutsideSelection) - => new(parseOptions, compilationOptions, options, globalOptions, fixProviderData, index, priority, retainNonFixableDiagnostics, includeDiagnosticsOutsideSelection, title, testHost, workspaceKind, includeNonLocalDocumentDiagnostics, treatPositionIndicatorsAsCode); - - public TestParameters WithWorkspaceKind(string workspaceKind) - => new(parseOptions, compilationOptions, options, globalOptions, fixProviderData, index, priority, retainNonFixableDiagnostics, includeDiagnosticsOutsideSelection, title, testHost, workspaceKind, includeNonLocalDocumentDiagnostics, treatPositionIndicatorsAsCode); - - public TestParameters WithIncludeNonLocalDocumentDiagnostics(bool includeNonLocalDocumentDiagnostics) - => new(parseOptions, compilationOptions, options, globalOptions, fixProviderData, index, priority, retainNonFixableDiagnostics, includeDiagnosticsOutsideSelection, title, testHost, workspaceKind, includeNonLocalDocumentDiagnostics, treatPositionIndicatorsAsCode); - } - -#pragma warning disable IDE0052 // Remove unread private members (unused when CODE_STYLE is set) - private readonly ITestOutputHelper _logger; -#pragma warning restore - - protected AbstractCodeActionOrUserDiagnosticTest(ITestOutputHelper logger = null) - { - _logger = logger; - } - - private const string AutoGeneratedAnalyzerConfigHeader = @"# auto-generated .editorconfig for code style options"; - - protected internal abstract string GetLanguage(); - protected ParenthesesOptionsProvider ParenthesesOptionsProvider => new ParenthesesOptionsProvider(this.GetLanguage()); - protected abstract ParseOptions GetScriptOptions(); - - private protected virtual IDocumentServiceProvider GetDocumentServiceProvider() - => null; - - protected virtual TestComposition GetComposition() + protected override TestComposition GetComposition() => EditorTestCompositions.EditorFeatures; - protected virtual void InitializeWorkspace(EditorTestWorkspace workspace, TestParameters parameters) - { - } - - protected virtual TestParameters SetParameterDefaults(TestParameters parameters) - => parameters; - - protected EditorTestWorkspace CreateWorkspaceFromOptions(string workspaceMarkupOrCode, TestParameters parameters = null) + private protected override EditorTestWorkspace CreateWorkspace(string workspaceMarkupOrCode, TestParameters parameters, TestComposition composition, IDocumentServiceProvider documentServiceProvider) { - parameters ??= TestParameters.Default; - - var composition = GetComposition().WithTestHostParts(parameters.testHost); - - parameters = SetParameterDefaults(parameters); - - var documentServiceProvider = GetDocumentServiceProvider(); - var workspace = EditorTestWorkspace.IsWorkspaceElement(workspaceMarkupOrCode) ? EditorTestWorkspace.Create(XElement.Parse(workspaceMarkupOrCode), openDocuments: false, composition: composition, documentServiceProvider: documentServiceProvider, workspaceKind: parameters.workspaceKind) : EditorTestWorkspace.Create(GetLanguage(), parameters.compilationOptions, parameters.parseOptions, files: [workspaceMarkupOrCode], composition: composition, documentServiceProvider: documentServiceProvider, workspaceKind: parameters.workspaceKind); - -#if !CODE_STYLE - if (parameters.testHost == TestHost.OutOfProcess && _logger != null) - { - var remoteHostProvider = (InProcRemoteHostClientProvider)workspace.Services.GetRequiredService(); - remoteHostProvider.TraceListener = new XunitTraceListener(_logger); - } -#endif - InitializeWorkspace(workspace, parameters); - - // We create an .editorconfig at project root to apply the options. - // We need to ensure that our projects/documents are rooted for - // execution from CodeStyle layer as we will be adding a rooted .editorconfig to each project - // to apply the options. - if (parameters.options != null) - { - MakeProjectsAndDocumentsRooted(workspace); - AddAnalyzerConfigDocumentWithOptions(workspace, parameters.options); - } - -#if !CODE_STYLE - parameters.globalOptions?.SetGlobalOptions(workspace.GlobalOptions); -#endif return workspace; } - - private static void MakeProjectsAndDocumentsRooted(EditorTestWorkspace workspace) - { - const string defaultRootFilePath = @"z:\"; - var newSolution = workspace.CurrentSolution; - foreach (var projectId in workspace.CurrentSolution.ProjectIds) - { - var project = newSolution.GetProject(projectId); - - string projectRootFilePath; - if (!PathUtilities.IsAbsolute(project.FilePath)) - { - projectRootFilePath = defaultRootFilePath; - newSolution = newSolution.WithProjectFilePath(projectId, Path.Combine(projectRootFilePath, project.FilePath)); - } - else - { - projectRootFilePath = PathUtilities.GetPathRoot(project.FilePath); - } - - foreach (var documentId in project.DocumentIds) - { - var document = newSolution.GetDocument(documentId); - if (!PathUtilities.IsAbsolute(document.FilePath)) - { - newSolution = newSolution.WithDocumentFilePath(documentId, Path.Combine(projectRootFilePath, document.FilePath)); - } - else - { - Assert.Equal(projectRootFilePath, PathUtilities.GetPathRoot(document.FilePath)); - } - } - } - - var applied = workspace.TryApplyChanges(newSolution); - Assert.True(applied); - return; - } - - private static void AddAnalyzerConfigDocumentWithOptions(EditorTestWorkspace workspace, OptionsCollectionAlias options) - { - Debug.Assert(options != null); - var analyzerConfigText = GenerateAnalyzerConfigText(options); - - var newSolution = workspace.CurrentSolution; - foreach (var project in workspace.Projects) - { - Assert.True(PathUtilities.IsAbsolute(project.FilePath)); - var projectRootFilePath = PathUtilities.GetPathRoot(project.FilePath); - var documentId = DocumentId.CreateNewId(project.Id); - newSolution = newSolution.AddAnalyzerConfigDocument( - documentId, - ".editorconfig", - SourceText.From(analyzerConfigText), - filePath: Path.Combine(projectRootFilePath, ".editorconfig")); - } - - var applied = workspace.TryApplyChanges(newSolution); - Assert.True(applied); - return; - - static string GenerateAnalyzerConfigText(OptionsCollectionAlias options) - { - var textBuilder = new StringBuilder(); - - // Add an auto-generated header at the top so we can skip this file in expected baseline validation. - textBuilder.AppendLine(AutoGeneratedAnalyzerConfigHeader); - textBuilder.AppendLine(); - textBuilder.AppendLine(options.GetEditorConfigText()); - return textBuilder.ToString(); - } - } - - private static TestParameters WithRegularOptions(TestParameters parameters) - => parameters.WithParseOptions(parameters.parseOptions?.WithKind(SourceCodeKind.Regular)); - - private TestParameters WithScriptOptions(TestParameters parameters) - => parameters.WithParseOptions(parameters.parseOptions?.WithKind(SourceCodeKind.Script) ?? GetScriptOptions()); - - protected async Task TestMissingInRegularAndScriptAsync( - string initialMarkup, - TestParameters parameters = null, - int codeActionIndex = 0) - { - var ps = parameters ?? TestParameters.Default; - await TestMissingAsync(initialMarkup, WithRegularOptions(ps), codeActionIndex); - await TestMissingAsync(initialMarkup, WithScriptOptions(ps), codeActionIndex); - } - - protected async Task TestMissingAsync( - string initialMarkup, - TestParameters parameters = null, - int codeActionIndex = 0) - { - var ps = parameters ?? TestParameters.Default; - using var workspace = CreateWorkspaceFromOptions(initialMarkup, ps); - - var (actions, _) = await GetCodeActionsAsync(workspace, ps); - var offeredActions = Environment.NewLine + string.Join(Environment.NewLine, actions.Select(action => action.Title)); - - if (codeActionIndex == 0) - { - Assert.True(actions.Length == 0, "An action was offered when none was expected. Offered actions:" + offeredActions); - } - else - { - Assert.True(actions.Length <= codeActionIndex, "An action was offered at the specified index when none was expected. Offered actions:" + offeredActions); - } - } - - protected async Task TestDiagnosticMissingAsync( - string initialMarkup, TestParameters parameters = null) - { - var ps = parameters ?? TestParameters.Default; - using var workspace = CreateWorkspaceFromOptions(initialMarkup, ps); - var diagnostics = await GetDiagnosticsWorkerAsync(workspace, ps); - Assert.True(0 == diagnostics.Length, $"Expected no diagnostics, but got {diagnostics.Length}"); - } - - protected abstract Task<(ImmutableArray, CodeAction actionToInvoke)> GetCodeActionsAsync( - EditorTestWorkspace workspace, TestParameters parameters); - - protected abstract Task> GetDiagnosticsWorkerAsync( - EditorTestWorkspace workspace, TestParameters parameters); - - internal abstract Task GetCodeRefactoringAsync(EditorTestWorkspace workspace, TestParameters parameters); - - protected Task TestSmartTagTextAsync(string initialMarkup, string displayText, int index) - => TestSmartTagTextAsync(initialMarkup, displayText, new TestParameters(index: index)); - - protected Task TestSmartTagGlyphTagsAsync(string initialMarkup, ImmutableArray glyphTags, int index) - => TestSmartTagGlyphTagsAsync(initialMarkup, glyphTags, new TestParameters(index: index)); - - protected async Task TestCodeRefactoringApplicableTextSpan( - string markup, - string textSpanMarker, - TestParameters parameters = null) - { - var ps = parameters ?? TestParameters.Default; - using var workspace = CreateWorkspaceFromOptions(markup, ps); - var refactoring = await GetCodeRefactoringAsync(workspace, ps).ConfigureAwait(false); - - TestFileMarkupParser.GetPositionsAndSpans(markup, out _, out _, out var spans); - Assert.True(spans.ContainsKey(textSpanMarker)); - - var expectedTextSpans = spans[textSpanMarker].Sort(); - var actualTextSpans = refactoring.CodeActions.WhereAsArray(action => action.applicableToSpan is not null).SelectAsArray(action => action.applicableToSpan).Sort(); - Assert.Equal(expectedTextSpans.Length, actualTextSpans.Length); - for (var i = 0; i < expectedTextSpans.Length; i++) - { - Assert.Equal(expectedTextSpans[i], actualTextSpans[i]); - } - } - - protected async Task TestSmartTagTextAsync( - string initialMarkup, - string displayText, - TestParameters parameters = null) - { - var ps = parameters ?? TestParameters.Default; - using var workspace = CreateWorkspaceFromOptions(initialMarkup, ps); - var (_, action) = await GetCodeActionsAsync(workspace, ps); - Assert.Equal(displayText, action.Title); - } - - protected async Task TestSmartTagGlyphTagsAsync( - string initialMarkup, - ImmutableArray glyph, - TestParameters parameters = null) - { - var ps = parameters ?? TestParameters.Default; - using var workspace = CreateWorkspaceFromOptions(initialMarkup, ps); - var (_, action) = await GetCodeActionsAsync(workspace, ps); - AssertEx.Equal(glyph, action.Tags); - } - - protected async Task TestExactActionSetOfferedAsync( - string initialMarkup, - IEnumerable expectedActionSet, - TestParameters parameters = null) - { - var ps = parameters ?? TestParameters.Default; - using var workspace = CreateWorkspaceFromOptions(initialMarkup, ps); - var (actions, _) = await GetCodeActionsAsync(workspace, ps); - - var actualActionSet = actions.Select(a => a.Title); - Assert.True(actualActionSet.SequenceEqual(expectedActionSet), - "Expected: " + string.Join(", ", expectedActionSet) + - "\nActual: " + string.Join(", ", actualActionSet)); - } - - protected async Task TestActionCountAsync( - string initialMarkup, - int count, - TestParameters parameters = null) - { - var ps = parameters ?? TestParameters.Default; - using var workspace = CreateWorkspaceFromOptions(initialMarkup, ps); - var (actions, _) = await GetCodeActionsAsync(workspace, ps); - - Assert.Equal(count, actions.Length); - } - - internal Task TestInRegularAndScriptAsync( - string initialMarkup, - string expectedMarkup, - int index = 0, - CodeActionPriority? priority = null, - CompilationOptions compilationOptions = null, - OptionsCollectionAlias options = null, - object fixProviderData = null, - ParseOptions parseOptions = null, - string title = null, - TestHost testHost = TestHost.OutOfProcess) - { - return TestInRegularAndScript1Async( - initialMarkup, expectedMarkup, - new TestParameters(parseOptions, compilationOptions, options, globalOptions: null, fixProviderData, index, priority, title: title, testHost: testHost)); - } - - internal Task TestInRegularAndScript1Async( - string initialMarkup, - string expectedMarkup, - int index = 0, - TestParameters parameters = null) - { - return TestInRegularAndScript1Async(initialMarkup, expectedMarkup, (parameters ?? TestParameters.Default).WithIndex(index)); - } - - internal async Task TestInRegularAndScript1Async( - string initialMarkup, - string expectedMarkup, - TestParameters parameters) - { - await TestAsync(initialMarkup, expectedMarkup, WithRegularOptions(parameters)); - - // VB scripting is not supported: - if (GetLanguage() == LanguageNames.CSharp) - { - await TestAsync(initialMarkup, expectedMarkup, WithScriptOptions(parameters)); - } - } - - internal Task TestAsync( - string initialMarkup, - string expectedMarkup, - ParseOptions parseOptions, - CompilationOptions compilationOptions = null, - int index = 0, - OptionsCollectionAlias options = null, - object fixProviderData = null, - CodeActionPriority? priority = null, - TestHost testHost = TestHost.OutOfProcess) - { - return TestAsync( - initialMarkup, - expectedMarkup, - new TestParameters(parseOptions, compilationOptions, options, globalOptions: null, fixProviderData, index, priority, testHost: testHost)); - } - - private async Task TestAsync( - string initialMarkup, - string expectedMarkup, - TestParameters parameters) - { - MarkupTestFile.GetSpans( - initialMarkup, - out var initialMarkupWithoutSpans, out var initialSpanMap, - parameters.treatPositionIndicatorsAsCode); - - const string UnnecessaryMarkupKey = "Unnecessary"; - var unnecessarySpans = initialSpanMap.GetOrAdd(UnnecessaryMarkupKey, _ => []); - - MarkupTestFile.GetSpans( - expectedMarkup, - out var expected, out var expectedSpanMap, - parameters.treatPositionIndicatorsAsCode); - - var conflictSpans = expectedSpanMap.GetOrAdd("Conflict", _ => []); - var renameSpans = expectedSpanMap.GetOrAdd("Rename", _ => []); - var warningSpans = expectedSpanMap.GetOrAdd("Warning", _ => []); - var navigationSpans = expectedSpanMap.GetOrAdd("Navigation", _ => []); - - using var workspace = CreateWorkspaceFromOptions(initialMarkup, parameters); - // Ideally this check would always run, but there are several hundred tests that would need to be - // updated with {|Unnecessary:|} spans. - if (unnecessarySpans.Any()) - { - var allDiagnostics = await GetDiagnosticsWorkerAsync(workspace, parameters - .WithRetainNonFixableDiagnostics(true) - .WithIncludeDiagnosticsOutsideSelection(true)); - - TestUnnecessarySpans(allDiagnostics, unnecessarySpans, UnnecessaryMarkupKey, initialMarkupWithoutSpans); - } - - var (_, action) = await GetCodeActionsAsync(workspace, parameters); - await TestActionAsync( - workspace, expected, action, - conflictSpans, renameSpans, warningSpans, navigationSpans, - parameters); - } - - private static void TestUnnecessarySpans( - ImmutableArray diagnostics, - ImmutableArray expectedSpans, - string markupKey, - string initialMarkupWithoutSpans) - { - var unnecessaryLocations = diagnostics.SelectMany(GetUnnecessaryLocations) - .OrderBy(location => location.SourceSpan.Start) - .ThenBy(location => location.SourceSpan.End) - .ToArray(); - - if (expectedSpans.Length != unnecessaryLocations.Length) - { - AssertEx.Fail(BuildFailureMessage(expectedSpans, WellKnownDiagnosticTags.Unnecessary, markupKey, initialMarkupWithoutSpans, diagnostics)); - } - - for (var i = 0; i < expectedSpans.Length; i++) - { - var actual = unnecessaryLocations[i].SourceSpan; - var expected = expectedSpans[i]; - Assert.Equal(expected, actual); - } - - static IEnumerable GetUnnecessaryLocations(Diagnostic diagnostic) - { - if (diagnostic.Descriptor.ImmutableCustomTags().Contains(WellKnownDiagnosticTags.Unnecessary)) - yield return diagnostic.Location; - - if (!diagnostic.Properties.TryGetValue(WellKnownDiagnosticTags.Unnecessary, out var additionalUnnecessaryLocationsString)) - yield break; - - var locations = JArray.Parse(additionalUnnecessaryLocationsString); - foreach (var locationIndex in locations) - yield return diagnostic.AdditionalLocations[(int)locationIndex]; - } - } - - private static string BuildFailureMessage( - ImmutableArray expectedSpans, - string diagnosticTag, - string markupKey, - string initialMarkupWithoutSpans, - ImmutableArray diagnosticsWithTag) - { - var message = $"Expected {expectedSpans.Length} diagnostic spans with custom tag '{diagnosticTag}', but there were {diagnosticsWithTag.Length}."; - - if (expectedSpans.Length == 0) - { - message += $" If a diagnostic span tagged '{diagnosticTag}' is expected, surround the span in the test markup with the following syntax: {{|Unnecessary:...}}"; - - var segments = new List<(int originalStringIndex, string segment)>(); - - foreach (var diagnostic in diagnosticsWithTag) - { - var documentOffset = initialMarkupWithoutSpans.IndexOf(diagnosticsWithTag.First().Location.SourceTree.ToString()); - if (documentOffset == -1) - continue; - - segments.Add((documentOffset + diagnostic.Location.SourceSpan.Start, "{|" + markupKey + ":")); - segments.Add((documentOffset + diagnostic.Location.SourceSpan.End, "|}")); - } - - if (segments.Any()) - { - message += Environment.NewLine - + "Example:" + Environment.NewLine - + Environment.NewLine - + InsertSegments(initialMarkupWithoutSpans, segments); - } - } - - return message; - } - - private static string InsertSegments(string originalString, IEnumerable<(int originalStringIndex, string segment)> segments) - { - var builder = new StringBuilder(); - - var positionInOriginalString = 0; - - foreach (var (originalStringIndex, segment) in segments.OrderBy(s => s.originalStringIndex)) - { - builder.Append(originalString, positionInOriginalString, originalStringIndex - positionInOriginalString); - builder.Append(segment); - - positionInOriginalString = originalStringIndex; - } - - builder.Append(originalString, positionInOriginalString, originalString.Length - positionInOriginalString); - return builder.ToString(); - } - - internal async Task> TestActionAsync( - EditorTestWorkspace workspace, string expected, - CodeAction action, - ImmutableArray conflictSpans, - ImmutableArray renameSpans, - ImmutableArray warningSpans, - ImmutableArray navigationSpans, - TestParameters parameters) - { - var operations = await VerifyActionAndGetOperationsAsync(workspace, action, parameters); - return await TestOperationsAsync( - workspace, expected, operations, conflictSpans, renameSpans, - warningSpans, navigationSpans, expectedChangedDocumentId: null); - } - - protected static async Task> TestOperationsAsync( - EditorTestWorkspace workspace, - string expectedText, - ImmutableArray operations, - ImmutableArray conflictSpans, - ImmutableArray renameSpans, - ImmutableArray warningSpans, - ImmutableArray navigationSpans, - DocumentId expectedChangedDocumentId) - { - var appliedChanges = await ApplyOperationsAndGetSolutionAsync(workspace, operations); - var oldSolution = appliedChanges.Item1; - var newSolution = appliedChanges.Item2; - - if (TestWorkspace.IsWorkspaceElement(expectedText)) - { - var newSolutionWithLinkedFiles = await newSolution.WithMergedLinkedFileChangesAsync(oldSolution); - await VerifyAgainstWorkspaceDefinitionAsync(expectedText, newSolutionWithLinkedFiles, workspace.Composition); - return Tuple.Create(oldSolution, newSolution); - } - - var document = GetDocumentToVerify(expectedChangedDocumentId, oldSolution, newSolution); - - var fixedRoot = await document.GetSyntaxRootAsync(); - var actualText = fixedRoot.ToFullString(); - - // To help when a user just writes a test (and supplied no 'expectedText') just print - // out the entire 'actualText' (without any trimming). in the case that we have both, - // call the normal AssertEx helper which will print out a good diff. - if (expectedText == "") - { - Assert.Equal((object)expectedText, actualText); - } - else - { - AssertEx.EqualOrDiff(expectedText, actualText); - } - - TestAnnotations(conflictSpans, ConflictAnnotation.Kind); - TestAnnotations(renameSpans, RenameAnnotation.Kind); - TestAnnotations(warningSpans, WarningAnnotation.Kind); - TestAnnotations(navigationSpans, NavigationAnnotation.Kind); - - return Tuple.Create(oldSolution, newSolution); - - void TestAnnotations(ImmutableArray expectedSpans, string annotationKind) - { - var annotatedItems = fixedRoot.GetAnnotatedNodesAndTokens(annotationKind).OrderBy(s => s.SpanStart).ToList(); - - Assert.True(expectedSpans.Length == annotatedItems.Count, - $"Annotations of kind '{annotationKind}' didn't match. Expected: {expectedSpans.Length}. Actual: {annotatedItems.Count}."); - - for (var i = 0; i < Math.Min(expectedSpans.Length, annotatedItems.Count); i++) - { - var actual = annotatedItems[i].Span; - var expected = expectedSpans[i]; - Assert.Equal(expected, actual); - } - } - } - - protected static Document GetDocumentToVerify(DocumentId expectedChangedDocumentId, Solution oldSolution, Solution newSolution) - { - Document document; - // If the expectedChangedDocumentId is not mentioned then we expect only single document to be changed - if (expectedChangedDocumentId == null) - { - var projectDifferences = SolutionUtilities.GetSingleChangedProjectChanges(oldSolution, newSolution); - - var documentId = projectDifferences.GetChangedDocuments().FirstOrDefault() ?? projectDifferences.GetAddedDocuments().FirstOrDefault(); - Assert.NotNull(documentId); - document = newSolution.GetDocument(documentId); - } - else - { - // This method obtains only the document changed and does not check the project state. - document = newSolution.GetDocument(expectedChangedDocumentId); - } - - return document; - } - - private static async Task VerifyAgainstWorkspaceDefinitionAsync(string expectedText, Solution newSolution, TestComposition composition) - { - using var expectedWorkspace = TestWorkspace.Create(expectedText, composition: composition); - var expectedSolution = expectedWorkspace.CurrentSolution; - Assert.Equal(expectedSolution.Projects.Count(), newSolution.Projects.Count()); - foreach (var project in newSolution.Projects) - { - var expectedProject = expectedSolution.GetProjectsByName(project.Name).Single(); - Assert.Equal(expectedProject.Documents.Count(), project.Documents.Count()); - - foreach (var doc in project.Documents) - { - var root = await doc.GetSyntaxRootAsync(); - var expectedDocuments = expectedProject.Documents.Where(d => d.Name == doc.Name); - - if (expectedDocuments.Any()) - { - Assert.Single(expectedDocuments); - } - else - { - AssertEx.Fail($"Could not find document with name '{doc.Name}'"); - } - - var expectedDocument = expectedDocuments.Single(); - - var expectedRoot = await expectedDocument.GetSyntaxRootAsync(); - VerifyExpectedDocumentText(expectedRoot.ToFullString(), root.ToFullString()); - } - - foreach (var additionalDoc in project.AdditionalDocuments) - { - var root = await additionalDoc.GetTextAsync(); - var expectedDocument = expectedProject.AdditionalDocuments.Single(d => d.Name == additionalDoc.Name); - var expectedRoot = await expectedDocument.GetTextAsync(); - VerifyExpectedDocumentText(expectedRoot.ToString(), root.ToString()); - } - - foreach (var analyzerConfigDoc in project.AnalyzerConfigDocuments) - { - var root = await analyzerConfigDoc.GetTextAsync(); - var actualString = root.ToString(); - if (actualString.StartsWith(AutoGeneratedAnalyzerConfigHeader)) - { - // Skip validation for analyzer config file that is auto-generated by test framework - // for applying code style options. - continue; - } - - var expectedDocument = expectedProject.AnalyzerConfigDocuments.Single(d => d.FilePath == analyzerConfigDoc.FilePath); - var expectedRoot = await expectedDocument.GetTextAsync(); - VerifyExpectedDocumentText(expectedRoot.ToString(), actualString); - } - } - - return; - - // Local functions. - static void VerifyExpectedDocumentText(string expected, string actual) - { - if (expected == "") - { - Assert.Equal((object)expected, actual); - } - else - { - AssertEx.EqualOrDiff(expected, actual); - } - } - } - - internal async Task> VerifyActionAndGetOperationsAsync( - EditorTestWorkspace workspace, CodeAction action, TestParameters parameters = null) - { - parameters ??= TestParameters.Default; - - if (action is null) - { - var diagnostics = await GetDiagnosticsWorkerAsync(workspace, parameters.WithRetainNonFixableDiagnostics(true)); - - throw new Exception("No action was offered when one was expected. Diagnostics from the compilation: " + string.Join("", diagnostics.Select(d => Environment.NewLine + d.ToString()))); - } - - if (parameters.priority != null) - { - Assert.Equal(parameters.priority.Value, action.Priority); - } - - if (parameters.title != null) - { - Assert.Equal(parameters.title, action.Title); - } - - return await action.GetOperationsAsync( - workspace.CurrentSolution, CodeAnalysisProgress.None, CancellationToken.None); - } - - protected static async Task> ApplyOperationsAndGetSolutionAsync( - EditorTestWorkspace workspace, - IEnumerable operations) - { - Tuple result = null; - foreach (var operation in operations) - { - if (operation is ApplyChangesOperation applyChangesOperation && result == null) - { - result = Tuple.Create(workspace.CurrentSolution, applyChangesOperation.ChangedSolution); - } - else if (operation.ApplyDuringTests) - { - var oldSolution = workspace.CurrentSolution; - await operation.TryApplyAsync(workspace, oldSolution, CodeAnalysisProgress.None, CancellationToken.None); - var newSolution = workspace.CurrentSolution; - result = Tuple.Create(oldSolution, newSolution); - } - } - - if (result == null) - { - throw new InvalidOperationException("No ApplyChangesOperation found"); - } - - return result; - } - - protected virtual ImmutableArray MassageActions(ImmutableArray actions) - => actions; - - internal static void VerifyCodeActionsRegisteredByProvider(CodeFixProvider provider, List fixes) - { - if (provider.GetFixAllProvider() == null) - { - // Only require unique equivalence keys when the fixer supports FixAll - return; - } - - var diagnosticsAndEquivalenceKeyToTitleMap = new Dictionary<(Diagnostic diagnostic, string equivalenceKey), string>(); - foreach (var fix in fixes) - { - VerifyCodeAction(fix.Action, fix.Diagnostics, provider, diagnosticsAndEquivalenceKeyToTitleMap); - } - - return; - - static void VerifyCodeAction( - CodeAction codeAction, - ImmutableArray diagnostics, - CodeFixProvider provider, - Dictionary<(Diagnostic diagnostic, string equivalenceKey), string> diagnosticsAndEquivalenceKeyToTitleMap) - { - if (!codeAction.NestedActions.IsEmpty) - { - // Only validate leaf code actions. - foreach (var nestedAction in codeAction.NestedActions) - { - VerifyCodeAction(nestedAction, diagnostics, provider, diagnosticsAndEquivalenceKeyToTitleMap); - } - - return; - } - - foreach (var diagnostic in diagnostics) - { - var key = (diagnostic, codeAction.EquivalenceKey); - var existingTitle = diagnosticsAndEquivalenceKeyToTitleMap.GetOrAdd(key, _ => codeAction.Title); - if (existingTitle != codeAction.Title) - { - var messageSuffix = codeAction.EquivalenceKey != null - ? string.Empty - : """ - Consider using the title as the equivalence key instead of 'null' - """; - - Assert.False(true, $""" - Expected different 'CodeAction.EquivalenceKey' for code actions registered for same diagnostic: - - Name: '{provider.GetType().Name}' - - Title 1: '{codeAction.Title}' - - Title 2: '{existingTitle}' - - Shared equivalence key: '{codeAction.EquivalenceKey ?? ""}'{messageSuffix} - """); - } - } - } - } - - protected static ImmutableArray FlattenActions(ImmutableArray codeActions) - { - return [.. codeActions.SelectMany(a => a.NestedActions.Length > 0 - ? a.NestedActions - : [a])]; - } - - protected static ImmutableArray GetNestedActions(ImmutableArray codeActions) - => codeActions.SelectManyAsArray(a => a.NestedActions); - - /// - /// Tests all the code actions for the given string. Each code - /// action must produce the corresponding output in the array. - /// - /// Will throw if there are more outputs than code actions or more code actions than outputs. - /// - protected Task TestAllInRegularAndScriptAsync( - string input, - params string[] outputs) - { - return TestAllInRegularAndScriptAsync(input, parameters: null, outputs); - } - - protected async Task TestAllInRegularAndScriptAsync( - string input, - TestParameters parameters, - params string[] outputs) - { - parameters ??= TestParameters.Default; - - for (var index = 0; index < outputs.Length; index++) - { - var output = outputs[index]; - await TestInRegularAndScript1Async(input, output, parameters.WithIndex(index)); - } - - await TestActionCountAsync(input, outputs.Length, parameters); - } - - protected static void GetDocumentAndSelectSpanOrAnnotatedSpan( - EditorTestWorkspace workspace, - out Document document, - out TextSpan span, - out string annotation) - { - annotation = null; - if (!TryGetDocumentAndSelectSpan(workspace, out document, out span)) - { - document = GetDocumentAndAnnotatedSpan(workspace, out annotation, out span); - } - } - - private static bool TryGetDocumentAndSelectSpan(EditorTestWorkspace workspace, out Document document, out TextSpan span) - { - var hostDocument = workspace.Documents.FirstOrDefault(d => d.SelectedSpans.Any()); - if (hostDocument == null) - { - // If there wasn't a span, see if there was a $$ caret. we'll create an empty span - // there if so. - hostDocument = workspace.Documents.FirstOrDefault(d => d.CursorPosition != null); - if (hostDocument == null) - { - document = null; - span = default; - return false; - } - - span = new TextSpan(hostDocument.CursorPosition.Value, 0); - document = workspace.CurrentSolution.GetDocument(hostDocument.Id); - return true; - } - - span = hostDocument.SelectedSpans.Single(); - document = workspace.CurrentSolution.GetDocument(hostDocument.Id); - return true; - } - - private static Document GetDocumentAndAnnotatedSpan(EditorTestWorkspace workspace, out string annotation, out TextSpan span) - { - var annotatedDocuments = workspace.Documents.Where(d => d.AnnotatedSpans.Any()); - var hostDocument = annotatedDocuments.Single(); - var annotatedSpan = hostDocument.AnnotatedSpans.Single(); - annotation = annotatedSpan.Key; - span = annotatedSpan.Value.Single(); - return workspace.CurrentSolution.GetDocument(hostDocument.Id); - } - - protected static FixAllScope? GetFixAllScope(string annotation) - { - if (annotation == null) - { - return null; - } - - return annotation switch - { - "FixAllInDocument" => FixAllScope.Document, - "FixAllInProject" => FixAllScope.Project, - "FixAllInSolution" => FixAllScope.Solution, - "FixAllInContainingMember" => FixAllScope.ContainingMember, - "FixAllInContainingType" => FixAllScope.ContainingType, - "FixAllInSelection" => FixAllScope.Custom, - _ => throw new InvalidProgramException("Incorrect FixAll annotation in test"), - }; - } } diff --git a/src/EditorFeatures/DiagnosticsTestUtilities/CodeActions/AbstractCodeActionOrUserDiagnosticTest_OptionHelpers.cs b/src/EditorFeatures/DiagnosticsTestUtilities/CodeActions/AbstractCodeActionOrUserDiagnosticTest_OptionHelpers.cs deleted file mode 100644 index bca12ea596c6..000000000000 --- a/src/EditorFeatures/DiagnosticsTestUtilities/CodeActions/AbstractCodeActionOrUserDiagnosticTest_OptionHelpers.cs +++ /dev/null @@ -1,50 +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 Microsoft.CodeAnalysis.CodeStyle; -using Microsoft.CodeAnalysis.Options; - -namespace Microsoft.CodeAnalysis.Editor.UnitTests.CodeActions; - -public abstract partial class AbstractCodeActionOrUserDiagnosticTest -{ - internal static (OptionKey2, object?) SingleOption(Option2 option, T enabled) - => (new OptionKey2(option), enabled); - - internal (OptionKey2, object?) SingleOption(PerLanguageOption2 option, T value) - => (new OptionKey2(option, this.GetLanguage()), value); - - internal static (OptionKey2, object) SingleOption(Option2> option, T enabled, NotificationOption2 notification) - => (new OptionKey2(option), new CodeStyleOption2(enabled, notification)); - - internal static (OptionKey2, object) SingleOption(Option2> option, CodeStyleOption2 codeStyle) - => (new OptionKey2(option), codeStyle); - - internal (OptionKey2, object) SingleOption(PerLanguageOption2> option, T enabled, NotificationOption2 notification) - => (new OptionKey2(option, this.GetLanguage()), new CodeStyleOption2(enabled, notification)); - - internal (OptionKey2, object) SingleOption(PerLanguageOption2> option, CodeStyleOption2 codeStyle) - => (new OptionKey2(option, this.GetLanguage()), codeStyle); - - internal static (OptionKey2, object) SingleOption(PerLanguageOption2> option, CodeStyleOption2 codeStyle, string language) - => (new OptionKey2(option, language), codeStyle); - - internal OptionsCollection Option(Option2> option, T enabled, NotificationOption2 notification) - => new OptionsCollection(GetLanguage()) { { option, enabled, notification } }; - - internal OptionsCollection Option(Option2> option, CodeStyleOption2 codeStyle) - => new OptionsCollection(GetLanguage()) { { option, codeStyle } }; - - internal OptionsCollection Option(PerLanguageOption2> option, T enabled, NotificationOption2 notification) - => new OptionsCollection(GetLanguage()) { { option, enabled, notification } }; - - internal OptionsCollection Option(Option2 option, T value) - => new OptionsCollection(GetLanguage()) { { option, value } }; - - internal OptionsCollection Option(PerLanguageOption2 option, T value) - => new OptionsCollection(GetLanguage()) { { option, value } }; - - internal OptionsCollection Option(PerLanguageOption2> option, CodeStyleOption2 codeStyle) - => new OptionsCollection(GetLanguage()) { { option, codeStyle } }; -} diff --git a/src/EditorFeatures/DiagnosticsTestUtilities/CodeActions/AbstractCodeActionTest.cs b/src/EditorFeatures/DiagnosticsTestUtilities/CodeActions/AbstractCodeActionTest.cs index 7090b5e0b51a..142dad1e5a00 100644 --- a/src/EditorFeatures/DiagnosticsTestUtilities/CodeActions/AbstractCodeActionTest.cs +++ b/src/EditorFeatures/DiagnosticsTestUtilities/CodeActions/AbstractCodeActionTest.cs @@ -179,7 +179,7 @@ internal Task TestWithPickMembersDialogAsync( { var ps = parameters ?? TestParameters.Default; var pickMembersService = new TestPickMembersService(chosenSymbols.AsImmutableOrNull(), optionsCallback); - return TestInRegularAndScript1Async( + return TestInRegularAndScriptAsync( initialMarkup, expectedMarkup, index, ps.WithFixProviderData(pickMembersService)); diff --git a/src/EditorFeatures/DiagnosticsTestUtilities/Diagnostics/AbstractDiagnosticProviderBasedUserDiagnosticTest.cs b/src/EditorFeatures/DiagnosticsTestUtilities/Diagnostics/AbstractDiagnosticProviderBasedUserDiagnosticTest.cs index 2524d4ff2505..a179748aa32c 100644 --- a/src/EditorFeatures/DiagnosticsTestUtilities/Diagnostics/AbstractDiagnosticProviderBasedUserDiagnosticTest.cs +++ b/src/EditorFeatures/DiagnosticsTestUtilities/Diagnostics/AbstractDiagnosticProviderBasedUserDiagnosticTest.cs @@ -34,15 +34,11 @@ namespace Microsoft.CodeAnalysis.Editor.UnitTests.Diagnostics; #else using OptionsCollectionAlias = OptionsCollection; #endif -public abstract partial class AbstractDiagnosticProviderBasedUserDiagnosticTest : AbstractUserDiagnosticTest +public abstract partial class AbstractDiagnosticProviderBasedUserDiagnosticTest(ITestOutputHelper logger) + : AbstractUserDiagnosticTest(logger) { private readonly ConcurrentDictionary _analyzerAndFixerMap = []; - protected AbstractDiagnosticProviderBasedUserDiagnosticTest(ITestOutputHelper logger) - : base(logger) - { - } - internal abstract (DiagnosticAnalyzer, CodeFixProvider) CreateDiagnosticProviderAndFixer(Workspace workspace); internal virtual (DiagnosticAnalyzer, CodeFixProvider) CreateDiagnosticProviderAndFixer(Workspace workspace, TestParameters parameters) diff --git a/src/EditorFeatures/DiagnosticsTestUtilities/Diagnostics/AbstractUserDiagnosticTest.cs b/src/EditorFeatures/DiagnosticsTestUtilities/Diagnostics/AbstractUserDiagnosticTest.cs index 370c8dd53a4b..a6a97a33d161 100644 --- a/src/EditorFeatures/DiagnosticsTestUtilities/Diagnostics/AbstractUserDiagnosticTest.cs +++ b/src/EditorFeatures/DiagnosticsTestUtilities/Diagnostics/AbstractUserDiagnosticTest.cs @@ -38,13 +38,9 @@ namespace Microsoft.CodeAnalysis.Editor.UnitTests.Diagnostics; #else using OptionsCollectionAlias = OptionsCollection; #endif -public abstract partial class AbstractUserDiagnosticTest : AbstractCodeActionOrUserDiagnosticTest +public abstract partial class AbstractUserDiagnosticTest(ITestOutputHelper logger) + : AbstractCodeActionOrUserDiagnosticTest(logger) { - protected AbstractUserDiagnosticTest(ITestOutputHelper logger) - : base(logger) - { - } - internal abstract Task<(ImmutableArray, ImmutableArray, CodeAction actionToInvoke)> GetDiagnosticAndFixesAsync( EditorTestWorkspace workspace, TestParameters parameters); @@ -224,16 +220,10 @@ private static FixAllState GetFixAllState( private protected Task TestActionCountInAllFixesAsync( string initialMarkup, - int count, - ParseOptions parseOptions = null, - CompilationOptions compilationOptions = null, - OptionsCollectionAlias options = null, - object fixProviderData = null) + int count) { return TestActionCountInAllFixesAsync( - initialMarkup, - new TestParameters(parseOptions, compilationOptions, options, globalOptions: null, fixProviderData), - count); + initialMarkup, parameters: TestParameters.Default, count); } private async Task TestActionCountInAllFixesAsync( diff --git a/src/EditorFeatures/DiagnosticsTestUtilities/Diagnostics/AbstractUserDiagnosticTest_GenerateTypeDialog.cs b/src/EditorFeatures/DiagnosticsTestUtilities/Diagnostics/AbstractUserDiagnosticTest_GenerateTypeDialog.cs index bd4eee8c6de7..8aada1e66e8b 100644 --- a/src/EditorFeatures/DiagnosticsTestUtilities/Diagnostics/AbstractUserDiagnosticTest_GenerateTypeDialog.cs +++ b/src/EditorFeatures/DiagnosticsTestUtilities/Diagnostics/AbstractUserDiagnosticTest_GenerateTypeDialog.cs @@ -59,7 +59,7 @@ internal async Task TestWithMockedGenerateTypeDialog( ? EditorTestWorkspace.CreateCSharp(initial, composition: s_composition) : EditorTestWorkspace.CreateVisualBasic(initial, composition: s_composition); - var testOptions = new TestParameters(); + var testOptions = TestParameters.Default; var (diagnostics, actions, _) = await GetDiagnosticAndFixesAsync(workspace, testOptions); var testState = new GenerateTypeTestState(workspace, projectToBeModified: projectName, typeName, existingFilename); diff --git a/src/EditorFeatures/DiagnosticsTestUtilities/MoveToNamespace/AbstractMoveToNamespaceTests.cs b/src/EditorFeatures/DiagnosticsTestUtilities/MoveToNamespace/AbstractMoveToNamespaceTests.cs index 8bf62159fc76..95249881b1ff 100644 --- a/src/EditorFeatures/DiagnosticsTestUtilities/MoveToNamespace/AbstractMoveToNamespaceTests.cs +++ b/src/EditorFeatures/DiagnosticsTestUtilities/MoveToNamespace/AbstractMoveToNamespaceTests.cs @@ -32,7 +32,7 @@ public async Task TestMoveToNamespaceAsync( bool optionCancelled = false, IReadOnlyDictionary expectedSymbolChanges = null) { - testParameters ??= new TestParameters(); + testParameters ??= TestParameters.Default; var moveToNamespaceOptions = optionCancelled ? MoveToNamespaceOptionsResult.Cancelled @@ -86,7 +86,7 @@ public async Task TestMoveToNamespaceAsync( if (!optionCancelled && !string.IsNullOrEmpty(targetNamespace)) { - await TestInRegularAndScriptAsync(markup, expectedMarkup, options: testParameters.options); + await TestInRegularAndScriptAsync(markup, expectedMarkup, new(options: testParameters.options)); } } else @@ -97,7 +97,7 @@ public async Task TestMoveToNamespaceAsync( public async Task TestMoveToNamespaceAnalysisAsync(string markup, string expectedNamespaceName) { - var workspace = CreateWorkspaceFromOptions(markup, new TestParameters()); + var workspace = CreateWorkspaceFromOptions(markup, TestParameters.Default); using var testState = new TestState(workspace); var analysis = await testState.MoveToNamespaceService.AnalyzeTypeAtPositionAsync( diff --git a/src/EditorFeatures/ExternalAccess/Debugger/GlassTestsHotReloadService.cs b/src/EditorFeatures/ExternalAccess/Debugger/GlassTestsHotReloadService.cs index f0c4168d22a9..d8b299ea817c 100644 --- a/src/EditorFeatures/ExternalAccess/Debugger/GlassTestsHotReloadService.cs +++ b/src/EditorFeatures/ExternalAccess/Debugger/GlassTestsHotReloadService.cs @@ -15,7 +15,7 @@ namespace Microsoft.CodeAnalysis.ExternalAccess.Debugger; internal sealed class GlassTestsHotReloadService { private static readonly ActiveStatementSpanProvider s_noActiveStatementSpanProvider = - (_, _, _) => ValueTaskFactory.FromResult(ImmutableArray.Empty); + (_, _, _) => ValueTask.FromResult(ImmutableArray.Empty); private readonly IManagedHotReloadService _debuggerService; diff --git a/src/EditorFeatures/Test/Attributes/AttributeTests.cs b/src/EditorFeatures/Test/Attributes/AttributeTests.cs index 30d1ca53ee7a..d930790749c6 100644 --- a/src/EditorFeatures/Test/Attributes/AttributeTests.cs +++ b/src/EditorFeatures/Test/Attributes/AttributeTests.cs @@ -36,10 +36,8 @@ public void CreateExportSyntaxTriviaCodeIssueProviderAttributeWithNullArg() [Fact] public void CreateExportBraceMatcherAttributeWithNullArg() - { - Assert.Throws(() => + => Assert.Throws(() => new ExportBraceMatcherAttribute(null)); - } [Fact] public void CreateExportCompletionProviderAttributeWithNullArg() diff --git a/src/EditorFeatures/Test/CodeGeneration/ExpressionGenerationTests.cs b/src/EditorFeatures/Test/CodeGeneration/ExpressionGenerationTests.cs index 8236575e09b7..4057f5db55ef 100644 --- a/src/EditorFeatures/Test/CodeGeneration/ExpressionGenerationTests.cs +++ b/src/EditorFeatures/Test/CodeGeneration/ExpressionGenerationTests.cs @@ -14,151 +14,124 @@ public sealed class ExpressionGenerationTests : AbstractCodeGenerationTests { [Fact] public void TestFalseExpression() - { - Test( + => Test( f => f.FalseLiteralExpression(), cs: "false", csSimple: "false", vb: "False", vbSimple: "False"); - } [Fact] public void TestTrueExpression() - { - Test( + => Test( f => f.TrueLiteralExpression(), cs: "true", csSimple: "true", vb: "True", vbSimple: "True"); - } [Fact] public void TestNullExpression() - { - Test( + => Test( f => f.NullLiteralExpression(), cs: "null", csSimple: "null", vb: "Nothing", vbSimple: "Nothing"); - } [Fact] public void TestThisExpression() - { - Test( + => Test( f => f.ThisExpression(), cs: "this", csSimple: "this", vb: "Me", vbSimple: "Me"); - } [Fact] public void TestBaseExpression() - { - Test( + => Test( f => f.BaseExpression(), cs: "base", csSimple: "base", vb: "MyBase", vbSimple: "MyBase"); - } [Fact] public void TestInt32LiteralExpression0() - { - Test( + => Test( f => f.LiteralExpression(0), cs: "0", csSimple: "0", vb: "0", vbSimple: "0"); - } [Fact] public void TestInt32LiteralExpression1() - { - Test( + => Test( f => f.LiteralExpression(1), cs: "1", csSimple: "1", vb: "1", vbSimple: "1"); - } [Fact] public void TestInt64LiteralExpression0() - { - Test( + => Test( f => f.LiteralExpression(0L), cs: "0L", csSimple: "0L", vb: "0L", vbSimple: "0L"); - } [Fact] public void TestInt64LiteralExpression1() - { - Test( + => Test( f => f.LiteralExpression(1L), cs: "1L", csSimple: "1L", vb: "1L", vbSimple: "1L"); - } [Fact] public void TestSingleLiteralExpression0() - { - Test( + => Test( f => f.LiteralExpression(0.0f), cs: "0F", csSimple: "0F", vb: "0F", vbSimple: "0F"); - } [Fact] public void TestSingleLiteralExpression1() - { - Test( + => Test( f => f.LiteralExpression(0.5F), cs: "0.5F", csSimple: "0.5F", vb: "0.5F", vbSimple: "0.5F"); - } [Fact] public void TestDoubleLiteralExpression0() - { - Test( + => Test( f => f.LiteralExpression(0.0d), cs: "0D", csSimple: "0D", vb: "0R", vbSimple: "0R"); - } [Fact] public void TestDoubleLiteralExpression1() - { - Test( + => Test( f => f.LiteralExpression(0.5D), cs: "0.5D", csSimple: "0.5D", vb: "0.5R", vbSimple: "0.5R"); - } [Fact] public void TestAddExpression1() - { - Test( + => Test( f => f.AddExpression( f.LiteralExpression(1), f.LiteralExpression(2)), @@ -166,12 +139,10 @@ public void TestAddExpression1() csSimple: "1 + 2", vb: "(1) + (2)", vbSimple: "1 + 2"); - } [Fact] public void TestAddExpression2() - { - Test( + => Test( f => f.AddExpression( f.LiteralExpression(1), f.AddExpression( @@ -181,12 +152,10 @@ public void TestAddExpression2() csSimple: "1 + 2 + 3", vb: "(1) + ((2) + (3))", vbSimple: "1 + (2 + 3)"); - } [Fact] public void TestAddExpression3() - { - Test( + => Test( f => f.AddExpression( f.AddExpression( f.LiteralExpression(1), @@ -196,12 +165,10 @@ public void TestAddExpression3() csSimple: "1 + 2 + 3", vb: "((1) + (2)) + (3)", vbSimple: "1 + 2 + 3"); - } [Fact] public void TestMultiplyExpression1() - { - Test( + => Test( f => f.MultiplyExpression( f.LiteralExpression(1), f.LiteralExpression(2)), @@ -209,12 +176,10 @@ public void TestMultiplyExpression1() csSimple: "1 * 2", vb: "(1) * (2)", vbSimple: "1 * 2"); - } [Fact] public void TestMultiplyExpression2() - { - Test( + => Test( f => f.MultiplyExpression( f.LiteralExpression(1), f.MultiplyExpression( @@ -224,12 +189,10 @@ public void TestMultiplyExpression2() csSimple: "1 * 2 * 3", vb: "(1) * ((2) * (3))", vbSimple: "1 * (2 * 3)"); - } [Fact] public void TestMultiplyExpression3() - { - Test( + => Test( f => f.MultiplyExpression( f.MultiplyExpression( f.LiteralExpression(1), @@ -239,12 +202,10 @@ public void TestMultiplyExpression3() csSimple: "1 * 2 * 3", vb: "((1) * (2)) * (3)", vbSimple: "1 * 2 * 3"); - } [Fact] public void TestBinaryAndExpression1() - { - Test( + => Test( f => f.BitwiseAndExpression( f.LiteralExpression(1), f.LiteralExpression(2)), @@ -252,12 +213,10 @@ public void TestBinaryAndExpression1() csSimple: "1 & 2", vb: "(1) And (2)", vbSimple: "1 And 2"); - } [Fact] public void TestBinaryOrExpression1() - { - Test( + => Test( f => f.BitwiseOrExpression( f.LiteralExpression(1), f.LiteralExpression(2)), @@ -265,12 +224,10 @@ public void TestBinaryOrExpression1() csSimple: "1 | 2", vb: "(1) Or (2)", vbSimple: "1 Or 2"); - } [Fact] public void TestLogicalAndExpression1() - { - Test( + => Test( f => f.LogicalAndExpression( f.LiteralExpression(1), f.LiteralExpression(2)), @@ -278,12 +235,10 @@ public void TestLogicalAndExpression1() csSimple: "1 && 2", vb: "(1) AndAlso (2)", vbSimple: "1 AndAlso 2"); - } [Fact] public void TestLogicalOrExpression1() - { - Test( + => Test( f => f.LogicalOrExpression( f.LiteralExpression(1), f.LiteralExpression(2)), @@ -291,12 +246,10 @@ public void TestLogicalOrExpression1() csSimple: "1 || 2", vb: "(1) OrElse (2)", vbSimple: "1 OrElse 2"); - } [Fact] public void TestMemberAccess1() - { - Test( + => Test( f => f.MemberAccessExpression( f.IdentifierName("E"), f.IdentifierName("M")), @@ -304,12 +257,10 @@ public void TestMemberAccess1() csSimple: "E.M", vb: "E.M", vbSimple: "E.M"); - } [Fact] public void TestConditionalExpression1() - { - Test( + => Test( f => f.ConditionalExpression( f.IdentifierName("E"), f.IdentifierName("T"), @@ -318,12 +269,10 @@ public void TestConditionalExpression1() csSimple: "E ? T : F", vb: "If(E, T, F)", vbSimple: "If(E, T, F)"); - } [Fact] public void TestConditionalAccessExpression1() - { - Test( + => Test( f => f.ConditionalAccessExpression( f.IdentifierName("E"), f.MemberBindingExpression( @@ -332,12 +281,10 @@ public void TestConditionalAccessExpression1() csSimple: "E?.T", vb: "E?.T", vbSimple: "E?.T"); - } [Fact] public void TestConditionalAccessExpression2() - { - Test( + => Test( f => f.ConditionalAccessExpression( f.IdentifierName("E"), f.ElementBindingExpression( @@ -346,24 +293,20 @@ public void TestConditionalAccessExpression2() csSimple: "E?[T]", vb: "E?(T)", vbSimple: "E?(T)"); - } [Fact] public void TestInvocation1() - { - Test( + => Test( f => f.InvocationExpression( f.IdentifierName("E")), cs: "E()", csSimple: "E()", vb: "E()", vbSimple: "E()"); - } [Fact] public void TestInvocation2() - { - Test( + => Test( f => f.InvocationExpression( f.IdentifierName("E"), f.Argument(f.IdentifierName("a"))), @@ -371,12 +314,10 @@ public void TestInvocation2() csSimple: "E(a)", vb: "E(a)", vbSimple: "E(a)"); - } [Fact] public void TestInvocation3() - { - Test( + => Test( f => f.InvocationExpression( f.IdentifierName("E"), f.Argument("n", RefKind.None, f.IdentifierName("a"))), @@ -384,12 +325,10 @@ public void TestInvocation3() csSimple: "E(n: a)", vb: "E(n:=a)", vbSimple: "E(n:=a)"); - } [Fact] public void TestInvocation4() - { - Test( + => Test( f => f.InvocationExpression( f.IdentifierName("E"), f.Argument(null, RefKind.Out, f.IdentifierName("a")), @@ -398,12 +337,10 @@ public void TestInvocation4() csSimple: "E(out a, ref b)", vb: "E(a, b)", vbSimple: "E(a, b)"); - } [Fact] public void TestInvocation5() - { - Test( + => Test( f => f.InvocationExpression( f.IdentifierName("E"), f.Argument("n1", RefKind.Out, f.IdentifierName("a")), @@ -412,24 +349,20 @@ public void TestInvocation5() csSimple: "E(n1: out a, n2: ref b)", vb: "E(n1:=a, n2:=b)", vbSimple: "E(n1:=a, n2:=b)"); - } [Fact] public void TestElementAccess1() - { - Test( + => Test( f => f.ElementAccessExpression( f.IdentifierName("E")), cs: "E[]", csSimple: "E[]", vb: "E()", vbSimple: "E()"); - } [Fact] public void TestElementAccess2() - { - Test( + => Test( f => f.ElementAccessExpression( f.IdentifierName("E"), f.Argument(f.IdentifierName("a"))), @@ -437,12 +370,10 @@ public void TestElementAccess2() csSimple: "E[a]", vb: "E(a)", vbSimple: "E(a)"); - } [Fact] public void TestElementAccess3() - { - Test( + => Test( f => f.ElementAccessExpression( f.IdentifierName("E"), f.Argument("n", RefKind.None, f.IdentifierName("a"))), @@ -450,12 +381,10 @@ public void TestElementAccess3() csSimple: "E[n: a]", vb: "E(n:=a)", vbSimple: "E(n:=a)"); - } [Fact] public void TestElementAccess4() - { - Test( + => Test( f => f.ElementAccessExpression( f.IdentifierName("E"), f.Argument(null, RefKind.Out, f.IdentifierName("a")), @@ -464,12 +393,10 @@ public void TestElementAccess4() csSimple: "E[out a, ref b]", vb: "E(a, b)", vbSimple: "E(a, b)"); - } [Fact] public void TestElementAccess5() - { - Test( + => Test( f => f.ElementAccessExpression( f.IdentifierName("E"), f.Argument("n1", RefKind.Out, f.IdentifierName("a")), @@ -478,12 +405,10 @@ public void TestElementAccess5() csSimple: "E[n1: out a, n2: ref b]", vb: "E(n1:=a, n2:=b)", vbSimple: "E(n1:=a, n2:=b)"); - } [Fact] public void TestIsExpression() - { - Test( + => Test( f => f.IsTypeExpression( f.IdentifierName("a"), CreateClass("SomeType")), @@ -491,12 +416,10 @@ public void TestIsExpression() csSimple: "a is SomeType", vb: "TypeOf (a) Is SomeType", vbSimple: "TypeOf a Is SomeType"); - } [Fact] public void TestAsExpression() - { - Test( + => Test( f => f.TryCastExpression( f.IdentifierName("a"), CreateClass("SomeType")), @@ -504,24 +427,20 @@ public void TestAsExpression() csSimple: "a as SomeType", vb: "TryCast(a, SomeType)", vbSimple: "TryCast(a, SomeType)"); - } [Fact] public void TestNotExpression() - { - Test( + => Test( f => f.LogicalNotExpression( f.IdentifierName("a")), cs: "!(a)", csSimple: "!a", vb: "Not (a)", vbSimple: "Not a"); - } [Fact] public void TestCastExpression() - { - Test( + => Test( f => f.CastExpression( CreateClass("SomeType"), f.IdentifierName("a")), @@ -529,17 +448,14 @@ public void TestCastExpression() csSimple: "(SomeType)a", vb: "DirectCast(a, SomeType)", vbSimple: "DirectCast(a, SomeType)"); - } [Fact] public void TestNegateExpression() - { - Test( + => Test( f => f.NegateExpression( f.IdentifierName("a")), cs: "-(a)", csSimple: "-a", vb: "-(a)", vbSimple: "-a"); - } } diff --git a/src/EditorFeatures/Test/CodeGeneration/ExpressionPrecedenceGenerationTests.cs b/src/EditorFeatures/Test/CodeGeneration/ExpressionPrecedenceGenerationTests.cs index 6d12fbd651b3..0c8fe8fcd497 100644 --- a/src/EditorFeatures/Test/CodeGeneration/ExpressionPrecedenceGenerationTests.cs +++ b/src/EditorFeatures/Test/CodeGeneration/ExpressionPrecedenceGenerationTests.cs @@ -14,8 +14,7 @@ public sealed class ExpressionPrecedenceGenerationTests : AbstractCodeGeneration { [Fact] public void TestAddMultiplyPrecedence1() - { - Test( + => Test( f => f.MultiplyExpression( f.AddExpression( f.LiteralExpression(1), @@ -25,12 +24,10 @@ public void TestAddMultiplyPrecedence1() csSimple: "(1 + 2) * 3", vb: "((1) + (2)) * (3)", vbSimple: "(1 + 2) * 3"); - } [Fact] public void TestAddMultiplyPrecedence2() - { - Test( + => Test( f => f.AddExpression( f.MultiplyExpression( f.LiteralExpression(1), @@ -40,12 +37,10 @@ public void TestAddMultiplyPrecedence2() csSimple: "1 * 2 + 3", vb: "((1) * (2)) + (3)", vbSimple: "1 * 2 + 3"); - } [Fact] public void TestAddMultiplyPrecedence3() - { - Test( + => Test( f => f.MultiplyExpression( f.LiteralExpression(1), f.AddExpression( @@ -55,12 +50,10 @@ public void TestAddMultiplyPrecedence3() csSimple: "1 * (2 + 3)", vb: "(1) * ((2) + (3))", vbSimple: "1 * (2 + 3)"); - } [Fact] public void TestAddMultiplyPrecedence4() - { - Test( + => Test( f => f.AddExpression( f.LiteralExpression(1), f.MultiplyExpression( @@ -70,12 +63,10 @@ public void TestAddMultiplyPrecedence4() csSimple: "1 + 2 * 3", vb: "(1) + ((2) * (3))", vbSimple: "1 + 2 * 3"); - } [Fact] public void TestBitwiseAndOrPrecedence1() - { - Test( + => Test( f => f.BitwiseAndExpression( f.BitwiseOrExpression( f.LiteralExpression(1), @@ -85,12 +76,10 @@ public void TestBitwiseAndOrPrecedence1() csSimple: "(1 | 2) & 3", vb: "((1) Or (2)) And (3)", vbSimple: "(1 Or 2) And 3"); - } [Fact] public void TestBitwiseAndOrPrecedence2() - { - Test( + => Test( f => f.BitwiseOrExpression( f.BitwiseAndExpression( f.LiteralExpression(1), @@ -100,12 +89,10 @@ public void TestBitwiseAndOrPrecedence2() csSimple: "1 & 2 | 3", vb: "((1) And (2)) Or (3)", vbSimple: "1 And 2 Or 3"); - } [Fact] public void TestBitwiseAndOrPrecedence3() - { - Test( + => Test( f => f.BitwiseAndExpression( f.LiteralExpression(1), f.BitwiseOrExpression( @@ -115,12 +102,10 @@ public void TestBitwiseAndOrPrecedence3() csSimple: "1 & (2 | 3)", vb: "(1) And ((2) Or (3))", vbSimple: "1 And (2 Or 3)"); - } [Fact] public void TestBitwiseAndOrPrecedence4() - { - Test( + => Test( f => f.BitwiseOrExpression( f.LiteralExpression(1), f.BitwiseAndExpression( @@ -130,12 +115,10 @@ public void TestBitwiseAndOrPrecedence4() csSimple: "1 | 2 & 3", vb: "(1) Or ((2) And (3))", vbSimple: "1 Or 2 And 3"); - } [Fact] public void TestLogicalAndOrPrecedence1() - { - Test( + => Test( f => f.LogicalAndExpression( f.LogicalOrExpression( f.LiteralExpression(1), @@ -145,12 +128,10 @@ public void TestLogicalAndOrPrecedence1() csSimple: "(1 || 2) && 3", vb: "((1) OrElse (2)) AndAlso (3)", vbSimple: "(1 OrElse 2) AndAlso 3"); - } [Fact] public void TestLogicalAndOrPrecedence2() - { - Test( + => Test( f => f.LogicalOrExpression( f.LogicalAndExpression( f.LiteralExpression(1), @@ -160,12 +141,10 @@ public void TestLogicalAndOrPrecedence2() csSimple: "1 && 2 || 3", vb: "((1) AndAlso (2)) OrElse (3)", vbSimple: "1 AndAlso 2 OrElse 3"); - } [Fact] public void TestLogicalAndOrPrecedence3() - { - Test( + => Test( f => f.LogicalAndExpression( f.LiteralExpression(1), f.LogicalOrExpression( @@ -175,12 +154,10 @@ public void TestLogicalAndOrPrecedence3() csSimple: "1 && (2 || 3)", vb: "(1) AndAlso ((2) OrElse (3))", vbSimple: "1 AndAlso (2 OrElse 3)"); - } [Fact] public void TestLogicalAndOrPrecedence4() - { - Test( + => Test( f => f.LogicalOrExpression( f.LiteralExpression(1), f.LogicalAndExpression( @@ -190,12 +167,10 @@ public void TestLogicalAndOrPrecedence4() csSimple: "1 || 2 && 3", vb: "(1) OrElse ((2) AndAlso (3))", vbSimple: "1 OrElse 2 AndAlso 3"); - } [Fact] public void TestMemberAccessOffOfAdd1() - { - Test( + => Test( f => f.MemberAccessExpression( f.AddExpression( f.LiteralExpression(1), @@ -205,12 +180,10 @@ public void TestMemberAccessOffOfAdd1() csSimple: "(1 + 2).M", vb: "((1) + (2)).M", vbSimple: "(1 + 2).M"); - } [Fact] public void TestConditionalExpression1() - { - Test( + => Test( f => f.ConditionalExpression( f.AssignmentStatement( f.IdentifierName("E1"), @@ -221,12 +194,10 @@ public void TestConditionalExpression1() csSimple: "(E1 = E2) ? T : F", vb: null, vbSimple: null); - } [Fact] public void TestConditionalExpression2() - { - Test( + => Test( f => f.AddExpression( f.ConditionalExpression( f.IdentifierName("E1"), @@ -240,12 +211,10 @@ public void TestConditionalExpression2() csSimple: "(E1 ? T1 : F1) + (E2 ? T2 : F2)", vb: null, vbSimple: null); - } [Fact] public void TestMemberAccessOffOfElementAccess() - { - Test( + => Test( f => f.ElementAccessExpression( f.AddExpression( f.LiteralExpression(1), @@ -255,12 +224,10 @@ public void TestMemberAccessOffOfElementAccess() csSimple: "(1 + 2)[M]", vb: "((1) + (2))(M)", vbSimple: "(1 + 2)(M)"); - } [Fact] public void TestMemberAccessOffOfIsExpression() - { - Test( + => Test( f => f.MemberAccessExpression( f.IsTypeExpression( f.IdentifierName("a"), @@ -270,12 +237,10 @@ public void TestMemberAccessOffOfIsExpression() csSimple: "(a is SomeType).M", vb: "(TypeOf (a) Is SomeType).M", vbSimple: "(TypeOf a Is SomeType).M"); - } [Fact] public void TestIsOfMemberAccessExpression() - { - Test( + => Test( f => f.IsTypeExpression( f.MemberAccessExpression( f.IdentifierName("a"), @@ -285,12 +250,10 @@ public void TestIsOfMemberAccessExpression() csSimple: "a.M is SomeType", vb: "TypeOf (a.M) Is SomeType", vbSimple: "TypeOf a.M Is SomeType"); - } [Fact] public void TestMemberAccessOffOfAsExpression() - { - Test( + => Test( f => f.MemberAccessExpression( f.TryCastExpression( f.IdentifierName("a"), @@ -300,12 +263,10 @@ public void TestMemberAccessOffOfAsExpression() csSimple: "(a as SomeType).M", vb: "(TryCast(a, SomeType)).M", vbSimple: "TryCast(a, SomeType).M"); - } [Fact] public void TestAsOfMemberAccessExpression() - { - Test( + => Test( f => f.TryCastExpression( f.MemberAccessExpression( f.IdentifierName("a"), @@ -315,12 +276,10 @@ public void TestAsOfMemberAccessExpression() csSimple: "a.M as SomeType", vb: "TryCast(a.M, SomeType)", vbSimple: "TryCast(a.M, SomeType)"); - } [Fact] public void TestMemberAccessOffOfNotExpression() - { - Test( + => Test( f => f.MemberAccessExpression( f.LogicalNotExpression( f.IdentifierName("a")), @@ -329,12 +288,10 @@ public void TestMemberAccessOffOfNotExpression() csSimple: "(!a).M", vb: "(Not (a)).M", vbSimple: "(Not a).M"); - } [Fact] public void TestNotOfMemberAccessExpression() - { - Test( + => Test( f => f.LogicalNotExpression( f.MemberAccessExpression( f.IdentifierName("a"), @@ -343,12 +300,10 @@ public void TestNotOfMemberAccessExpression() csSimple: "!a.M", vb: "Not (a.M)", vbSimple: "Not a.M"); - } [Fact] public void TestMemberAccessOffOfCastExpression() - { - Test( + => Test( f => f.MemberAccessExpression( f.CastExpression( CreateClass("SomeType"), @@ -358,12 +313,10 @@ public void TestMemberAccessOffOfCastExpression() csSimple: "((SomeType)a).M", vb: "(DirectCast(a, SomeType)).M", vbSimple: "DirectCast(a, SomeType).M"); - } [Fact] public void TestCastOfAddExpression() - { - Test( + => Test( f => f.CastExpression( CreateClass("SomeType"), f.AddExpression( @@ -373,12 +326,10 @@ public void TestCastOfAddExpression() csSimple: "(SomeType)(a + b)", vb: "DirectCast((a) + (b), SomeType)", vbSimple: "DirectCast(a + b, SomeType)"); - } [Fact] public void TestNegateOfAddExpression() - { - Test( + => Test( f => f.NegateExpression( f.AddExpression( f.IdentifierName("a"), @@ -387,12 +338,10 @@ public void TestNegateOfAddExpression() csSimple: "-(a + b)", vb: "-((a) + (b))", vbSimple: "-(a + b)"); - } [Fact] public void TestMemberAccessOffOfNegate() - { - Test( + => Test( f => f.MemberAccessExpression( f.NegateExpression( f.IdentifierName("a")), @@ -401,12 +350,10 @@ public void TestMemberAccessOffOfNegate() csSimple: "(-a).M", vb: "(-(a)).M", vbSimple: "(-a).M"); - } [Fact] public void TestNegateOfMemberAccess() - { - Test(f => + => Test(f => f.NegateExpression( f.MemberAccessExpression( f.IdentifierName("a"), @@ -415,5 +362,4 @@ public void TestNegateOfMemberAccess() csSimple: "-a.M", vb: "-(a.M)", vbSimple: "-a.M"); - } } diff --git a/src/EditorFeatures/Test/CodeGeneration/NameGenerationTests.cs b/src/EditorFeatures/Test/CodeGeneration/NameGenerationTests.cs index d3e8e3e471ad..21792f0fa66f 100644 --- a/src/EditorFeatures/Test/CodeGeneration/NameGenerationTests.cs +++ b/src/EditorFeatures/Test/CodeGeneration/NameGenerationTests.cs @@ -14,118 +14,97 @@ public sealed class NameGenerationTests : AbstractCodeGenerationTests { [Fact] public void TestIdentifierName() - { - Test( + => Test( f => f.IdentifierName("a"), cs: "a", csSimple: "a", vb: "a", vbSimple: "a"); - } [Fact] public void TestIdentifierNameCSharpKeyword() - { - Test( + => Test( f => f.IdentifierName("int"), cs: "@int", csSimple: "@int", vb: "int", vbSimple: "int"); - } [Fact] public void TestIdentifierNameVisualBasicKeyword() - { - Test( + => Test( f => f.IdentifierName("Integer"), cs: "Integer", csSimple: "Integer", vb: "[Integer]", vbSimple: "[Integer]"); - } [Fact] public void TestGenericName1() - { - Test( + => Test( f => f.GenericName("Outer", CreateClass("Inner1")), cs: "Outer", csSimple: null, vb: "Outer(Of Inner1)", vbSimple: null); - } [Fact] public void TestGenericName2() - { - Test( + => Test( f => f.GenericName("Outer", CreateClass("Inner1"), CreateClass("Inner2")), cs: "Outer", csSimple: null, vb: "Outer(Of Inner1, Inner2)", vbSimple: null); - } [Fact] public void TestGenericNameCSharpKeyword() - { - Test( + => Test( f => f.GenericName("int", CreateClass("string"), CreateClass("bool")), cs: "@int<@string, @bool>", csSimple: null, vb: "int(Of [string], bool)", vbSimple: null); - } [Fact] public void TestGenericNameVisualBasicKeyword() - { - Test( + => Test( f => f.GenericName("Integer", CreateClass("String"), CreateClass("Boolean")), cs: "Integer", csSimple: null, vb: "[Integer](Of [String], [Boolean])", vbSimple: null); - } [Fact] public void TestQualifiedName1() - { - Test( + => Test( f => f.QualifiedName(f.IdentifierName("Outer"), f.IdentifierName("Inner1")), cs: "Outer.Inner1", csSimple: "Outer.Inner1", vb: "Outer.Inner1", vbSimple: "Outer.Inner1"); - } [Fact] public void TestQualifiedNameCSharpKeywords1() - { - Test( + => Test( f => f.QualifiedName(f.IdentifierName("int"), f.IdentifierName("string")), cs: "@int.@string", csSimple: "@int.@string", vb: "int.[string]", vbSimple: "int.string"); - } [Fact] public void TestQualifiedNameVBKeywords1() - { - Test( + => Test( f => f.QualifiedName(f.IdentifierName("Integer"), f.IdentifierName("String")), cs: "Integer.String", csSimple: "Integer.String", vb: "[Integer].[String]", vbSimple: "Integer.String"); - } [Fact] public void TestQualifiedGenericName1() - { - Test( + => Test( f => f.QualifiedName( f.IdentifierName("One"), f.GenericName("Outer", @@ -135,12 +114,10 @@ public void TestQualifiedGenericName1() csSimple: "One.Outer", vb: "One.Outer(Of Inner1, Inner2)", vbSimple: "One.Outer(Of Inner1, Inner2)"); - } [Fact] public void TestQualifiedGenericName2() - { - Test( + => Test( f => f.QualifiedName( f.GenericName("Outer", CreateClass("Inner1"), @@ -150,5 +127,4 @@ public void TestQualifiedGenericName2() csSimple: "Outer.One", vb: "Outer(Of Inner1, Inner2).One", vbSimple: "Outer(Of Inner1, Inner2).One"); - } } diff --git a/src/EditorFeatures/Test/CodeGeneration/StatementGenerationTests.cs b/src/EditorFeatures/Test/CodeGeneration/StatementGenerationTests.cs index a67682016f8d..e002e30fb829 100644 --- a/src/EditorFeatures/Test/CodeGeneration/StatementGenerationTests.cs +++ b/src/EditorFeatures/Test/CodeGeneration/StatementGenerationTests.cs @@ -14,67 +14,55 @@ public sealed class StatementGenerationTests : AbstractCodeGenerationTests { [Fact] public void TestThrowStatement1() - { - Test(f => f.ThrowStatement(), + => Test(f => f.ThrowStatement(), cs: "throw;", csSimple: null, vb: "Throw", vbSimple: null); - } [Fact] public void TestThrowStatement2() - { - Test(f => f.ThrowStatement( + => Test(f => f.ThrowStatement( f.IdentifierName("e")), cs: "throw e;", csSimple: null, vb: "Throw e", vbSimple: null); - } [Fact] public void TestThrowStatement3() - { - Test(f => f.ThrowStatement( + => Test(f => f.ThrowStatement( f.ObjectCreationExpression( CreateClass("NotImplementedException"))), cs: "throw new NotImplementedException();", csSimple: null, vb: "Throw New NotImplementedException()", vbSimple: null); - } [Fact] public void TestReturnStatement1() - { - Test(f => f.ReturnStatement(), + => Test(f => f.ReturnStatement(), cs: "return;", csSimple: null, vb: "Return", vbSimple: null); - } [Fact] public void TestReturnStatement2() - { - Test(f => f.ReturnStatement( + => Test(f => f.ReturnStatement( f.IdentifierName("e")), cs: "return e;", csSimple: null, vb: "Return e", vbSimple: null); - } [Fact] public void TestReturnStatement3() - { - Test(f => f.ReturnStatement( + => Test(f => f.ReturnStatement( f.ObjectCreationExpression( CreateClass("NotImplementedException"))), cs: "return new NotImplementedException();", csSimple: null, vb: "Return New NotImplementedException()", vbSimple: null); - } } diff --git a/src/EditorFeatures/Test/Collections/Immutable/Maps/MapTests.cs b/src/EditorFeatures/Test/Collections/Immutable/Maps/MapTests.cs index 1908f5555133..c7e93e8b55e9 100644 --- a/src/EditorFeatures/Test/Collections/Immutable/Maps/MapTests.cs +++ b/src/EditorFeatures/Test/Collections/Immutable/Maps/MapTests.cs @@ -82,7 +82,9 @@ public void TestRemove() [Fact] public void TestPathology() { - var map = ImmutableDictionary.Create(new PathologicalComparer()) + var comparer = EqualityComparer.Create(EqualityComparer.Default.Equals, _ => 0); + + var map = ImmutableDictionary.Create(comparer) .Add("1", 1) .Add("2", 2) .Add("3", 3) @@ -118,13 +120,4 @@ public void TestPathology() map = map.Remove("5"); Assert.Empty(map); } - - private sealed class PathologicalComparer : IEqualityComparer - { - public bool Equals(T x, T y) - => EqualityComparer.Default.Equals(x, y); - - public int GetHashCode(T obj) - => 0; - } } diff --git a/src/EditorFeatures/Test/CommentSelection/CommentUncommentSelectionCommandHandlerTests.cs b/src/EditorFeatures/Test/CommentSelection/CommentUncommentSelectionCommandHandlerTests.cs index 166d491a783e..f06fd32c2dc6 100644 --- a/src/EditorFeatures/Test/CommentSelection/CommentUncommentSelectionCommandHandlerTests.cs +++ b/src/EditorFeatures/Test/CommentSelection/CommentUncommentSelectionCommandHandlerTests.cs @@ -67,29 +67,21 @@ public override string BlockCommentEndString [Fact] public void Create() - { - Assert.NotNull( + => Assert.NotNull( new MockCommentSelectionService( supportsBlockComment: true)); - } [WpfFact] public void Comment_EmptyLine() - { - CommentSelection(@"|start||end|", [], supportBlockComments: true); - } + => CommentSelection(@"|start||end|", [], supportBlockComments: true); [WpfFact] public void Comment_NoSelectionAtEndOfLine() - { - CommentSelection(@"Some text on a line|start||end|", new[] { new TextChange(TextSpan.FromBounds(0, 0), "//") }, supportBlockComments: true); - } + => CommentSelection(@"Some text on a line|start||end|", new[] { new TextChange(TextSpan.FromBounds(0, 0), "//") }, supportBlockComments: true); [WpfFact] public void Comment_Whitespace() - { - CommentSelection(@" |start| |end| ", [], supportBlockComments: true); - } + => CommentSelection(@" |start| |end| ", [], supportBlockComments: true); [WpfFact] public void Comment_SingleLineBlockWithBlockSelection() @@ -119,9 +111,7 @@ multiple lines [WpfFact] public void Comment_SingleLineBlockWithNoBlockSelection() - { - CommentSelection(@"this is |start| some |end| text", new[] { new TextChange(TextSpan.FromBounds(0, 0), "//") }, supportBlockComments: false); - } + => CommentSelection(@"this is |start| some |end| text", new[] { new TextChange(TextSpan.FromBounds(0, 0), "//") }, supportBlockComments: false); [WpfFact, WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/563915")] [WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/530300")] @@ -307,9 +297,7 @@ class Goo [WpfFact] public void Uncomment_NoSelection() - { - UncommentSelection(@"//Goo|start||end|Bar", new[] { new TextChange(new TextSpan(0, 2), string.Empty) }, Span.FromBounds(0, 6), supportBlockComments: true); - } + => UncommentSelection(@"//Goo|start||end|Bar", new[] { new TextChange(new TextSpan(0, 2), string.Empty) }, Span.FromBounds(0, 6), supportBlockComments: true); [WpfFact] public void Uncomment_MatchesBlockComment() @@ -414,14 +402,11 @@ public void Uncomment_PartOfMultipleComments() [WpfFact, WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/530300")] [WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/563924")] public void Comment_NoSelectionAtStartOfLine() - { - CommentSelection(@"|start||end|using System;", new[] { new TextChange(TextSpan.FromBounds(0, 0), "//") }, new[] { new Span(0, 15) }, supportBlockComments: true); - } + => CommentSelection(@"|start||end|using System;", new[] { new TextChange(TextSpan.FromBounds(0, 0), "//") }, new[] { new Span(0, 15) }, supportBlockComments: true); [WpfFact, WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/932411")] public void Uncomment_NoSelectionInBlockComment() - { - UncommentSelection(@"using /* Sy|start||end|stem.*/IO;", + => UncommentSelection(@"using /* Sy|start||end|stem.*/IO;", expectedChanges: new[] { new TextChange(new TextSpan(6, 2), string.Empty), @@ -429,12 +414,10 @@ public void Uncomment_NoSelectionInBlockComment() }, expectedSelectedSpan: new Span(6, 8), supportBlockComments: true); - } [WpfFact, WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/932411")] public void Uncomment_BlockCommentWithPreviousBlockComment() - { - UncommentSelection(@"/* comment */using /* Sy|start||end|stem.*/IO;", + => UncommentSelection(@"/* comment */using /* Sy|start||end|stem.*/IO;", expectedChanges: new[] { new TextChange(new TextSpan(19, 2), string.Empty), @@ -442,12 +425,10 @@ public void Uncomment_BlockCommentWithPreviousBlockComment() }, expectedSelectedSpan: new Span(19, 8), supportBlockComments: true); - } [WpfFact, WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/932411")] public void Uncomment_InsideEndOfBlockComment() - { - UncommentSelection(@"/*using System;*|start||end|/", + => UncommentSelection(@"/*using System;*|start||end|/", expectedChanges: new[] { new TextChange(new TextSpan(0, 2), string.Empty), @@ -455,12 +436,10 @@ public void Uncomment_InsideEndOfBlockComment() }, expectedSelectedSpan: new Span(0, 13), supportBlockComments: true); - } [WpfFact, WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/932411")] public void Uncomment_AtBeginningOfEndOfBlockComment() - { - UncommentSelection(@"/*using System;|start||end|*/", + => UncommentSelection(@"/*using System;|start||end|*/", expectedChanges: new[] { new TextChange(new TextSpan(0, 2), string.Empty), @@ -468,19 +447,14 @@ public void Uncomment_AtBeginningOfEndOfBlockComment() }, expectedSelectedSpan: new Span(0, 13), supportBlockComments: true); - } [WpfFact, WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/932411")] public void Uncomment_AtEndOfBlockComment() - { - UncommentSelection(@"/*using System;*/|start||end|", [], new Span(17, 0), supportBlockComments: true); - } + => UncommentSelection(@"/*using System;*/|start||end|", [], new Span(17, 0), supportBlockComments: true); [WpfFact, WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/932411")] public void Uncomment_BlockCommentWithNoEnd() - { - UncommentSelection(@"/*using |start||end|System;", [], new Span(8, 0), supportBlockComments: true); - } + => UncommentSelection(@"/*using |start||end|System;", [], new Span(8, 0), supportBlockComments: true); [WpfFact, WorkItem("https://github.com/dotnet/roslyn/issues/31669")] public void Uncomment_BlockWithSingleInside() diff --git a/src/EditorFeatures/Test/CommentSelection/ToggleBlockCommentCommandHandlerTests.cs b/src/EditorFeatures/Test/CommentSelection/ToggleBlockCommentCommandHandlerTests.cs index 7d46d2909905..ace2e2528de1 100644 --- a/src/EditorFeatures/Test/CommentSelection/ToggleBlockCommentCommandHandlerTests.cs +++ b/src/EditorFeatures/Test/CommentSelection/ToggleBlockCommentCommandHandlerTests.cs @@ -21,20 +21,15 @@ public sealed class ToggleBlockCommentCommandHandlerTests : AbstractToggleCommen { [WpfFact] public void AddComment_EmptyCaret() - { - ToggleComment(@"$$", @"[|/**/|]"); - } + => ToggleComment(@"$$", @"[|/**/|]"); [WpfFact] public void AddComment_EmptySelection() - { - ToggleComment(@"[| |]", @"[|/* */|]"); - } + => ToggleComment(@"[| |]", @"[|/* */|]"); [WpfFact] public void AddComment_SingleLineSelected() - { - ToggleComment(""" + => ToggleComment(""" class C { void M() @@ -51,12 +46,10 @@ void M() } } """); - } [WpfFact] public void AddComment_SingleLineWithWhitespaceSelected() - { - ToggleComment(""" + => ToggleComment(""" class C { void M() @@ -73,12 +66,10 @@ void M() } } """); - } [WpfFact] public void AddComment_CaretInsideSingleLine() - { - ToggleComment(""" + => ToggleComment(""" class C { void M() @@ -95,12 +86,10 @@ void M() } } """); - } [WpfFact] public void AddComment_PartialLineSelected() - { - ToggleComment(""" + => ToggleComment(""" class C { void M() @@ -117,12 +106,10 @@ void M() } } """); - } [WpfFact] public void AddComment_CaretInsideToken() - { - ToggleComment(""" + => ToggleComment(""" class C { void M() @@ -139,12 +126,10 @@ void M() } } """); - } [WpfFact] public void AddComment_CaretInsideOperatorToken() - { - ToggleComment(""" + => ToggleComment(""" class C { void M() @@ -161,12 +146,10 @@ void M() } } """); - } [WpfFact] public void AddComment_CaretInsideNewline() - { - ToggleComment(""" + => ToggleComment(""" class C { void M() @@ -183,12 +166,10 @@ void M() } } """); - } [WpfFact] public void AddComment_MultiLineSelection() - { - ToggleComment(""" + => ToggleComment(""" class C { void M() @@ -209,12 +190,10 @@ void M() } } """); - } [WpfFact] public void AddComment_MultiLineSelectionWithWhitespace() - { - ToggleComment(""" + => ToggleComment(""" class C { void M() @@ -239,12 +218,10 @@ void M() } } """); - } [WpfFact] public void AddComment_SingleLineCommentInSelection() - { - ToggleComment(""" + => ToggleComment(""" class C { void M() @@ -263,12 +240,10 @@ void M() } } """); - } [WpfFact] public void AddComment_BlockCommentBetweenCodeInSelection() - { - ToggleComment(""" + => ToggleComment(""" class C { void M() @@ -291,12 +266,10 @@ void M() } } """); - } [WpfFact] public void AddComment_SequentialBlockCommentBetweenCodeInSelection() - { - ToggleComment(""" + => ToggleComment(""" class C { void M() @@ -321,12 +294,10 @@ void M() } } """); - } [WpfFact] public void AddComment_SequentialBlockCommentsAndWhitespaceBetweenCodeInSelection() - { - ToggleComment(""" + => ToggleComment(""" class C { void M() @@ -355,12 +326,10 @@ void M() } } """); - } [WpfFact] public void AddComment_CodeBetweenBlockCommentsInSelection() - { - ToggleComment(""" + => ToggleComment(""" class C { void M() @@ -385,12 +354,10 @@ void M() } } """); - } [WpfFact] public void AddComment_CodeThenCommentInSelection() - { - ToggleComment(""" + => ToggleComment(""" class C { void M() @@ -411,12 +378,10 @@ void M() } } """); - } [WpfFact] public void AddComment_CodeThenCommentAndWhitespaceInSelection() - { - ToggleComment(""" + => ToggleComment(""" class C { void M() @@ -439,12 +404,10 @@ void M() } } """); - } [WpfFact] public void AddComment_CloseCommentOnlyInSelection() - { - ToggleComment(""" + => ToggleComment(""" class C { void M() @@ -465,12 +428,10 @@ void M() } } """); - } [WpfFact] public void AddComment_CodeThenPartialCommentInSelection() - { - ToggleComment(""" + => ToggleComment(""" class C { void M() @@ -491,12 +452,10 @@ void M() } } """); - } [WpfFact] public void AddComment_CommentThenCodeInSelection() - { - ToggleComment(""" + => ToggleComment(""" class C { void M() @@ -517,12 +476,10 @@ void M() } } """); - } [WpfFact] public void AddComment_CommentAndWhitespaceThenCodeInSelection() - { - ToggleComment(""" + => ToggleComment(""" class C { void M() @@ -545,12 +502,10 @@ void M() } } """); - } [WpfFact] public void AddComment_CommentCloseMarkerThenCodeInSelection() - { - ToggleComment(""" + => ToggleComment(""" class C { void M() @@ -571,12 +526,10 @@ void M() } } """); - } [WpfFact] public void AddComment_CodeThenCommentStartMarkerInSelection() - { - ToggleComment(""" + => ToggleComment(""" class C { void M() @@ -597,12 +550,10 @@ void M() } } """); - } [WpfFact] public void AddComment_PartialCommentThenCodeInSelection() - { - ToggleComment(""" + => ToggleComment(""" class C { void M() @@ -623,12 +574,10 @@ void M() } } """); - } [WpfFact] public void AddComment_CaretBeforeBlockOnNewLine() - { - ToggleComment(""" + => ToggleComment(""" class C { void M() @@ -645,12 +594,10 @@ void M() } } """); - } [WpfFact] public void AddComment_CaretBeforeCodeAndBlock() - { - ToggleComment(""" + => ToggleComment(""" class C { void M() @@ -667,12 +614,10 @@ void M() } } """); - } [WpfFact] public void AddComment_CaretAfterBlockOnNewLine() - { - ToggleComment(""" + => ToggleComment(""" class C { void M() @@ -691,12 +636,10 @@ void M() } } """); - } [WpfFact] public void AddComment_CaretAfterBlockAndCode() - { - ToggleComment(""" + => ToggleComment(""" class C { void M() @@ -713,12 +656,10 @@ void M() } } """); - } [WpfFact] public void AddComment_BlockSelection() - { - ToggleComment(""" + => ToggleComment(""" class C { void M() @@ -739,12 +680,10 @@ void M() } } """); - } [WpfFact] public void AddComment_BlockSelectionPartiallyCommented() - { - ToggleComment(""" + => ToggleComment(""" class C { void M() @@ -765,12 +704,10 @@ void M() } } """); - } [WpfFact] public void AddComment_DirectiveInsideSelection() - { - ToggleComment(""" + => ToggleComment(""" class C { void M() @@ -795,12 +732,10 @@ void M() } } """); - } [WpfFact] public void AddComment_WithProjectionBuffer() - { - ToggleCommentWithProjectionBuffer(@"< html >@{|S1:|}", """ + => ToggleCommentWithProjectionBuffer(@"< html >@{|S1:|}", """ {|S1:class C { void M() @@ -817,18 +752,14 @@ void M() } } """); - } [WpfFact] public void RemoveComment_AtBeginningOfFile() - { - ToggleComment(@"[|/**/|]", @""); - } + => ToggleComment(@"[|/**/|]", @""); [WpfFact] public void RemoveComment_CaretInsideBlock() - { - ToggleComment(""" + => ToggleComment(""" class C { void M() @@ -849,12 +780,10 @@ void M() } } """); - } [WpfFact] public void RemoveComment_CaretInsideSequentialBlock() - { - ToggleComment(""" + => ToggleComment(""" class C { void M() @@ -875,12 +804,10 @@ void M() } } """); - } [WpfFact] public void RemoveComment_CaretBeforeBlockOnlyWhitespace() - { - ToggleComment(""" + => ToggleComment(""" class C { void M() @@ -901,12 +828,10 @@ void M() } } """); - } [WpfFact] public void RemoveComment_CaretBeforeMultipleBlocksOnlyWhitespace() - { - ToggleComment(""" + => ToggleComment(""" class C { void M() @@ -927,12 +852,10 @@ void M() } } """); - } [WpfFact] public void RemoveComment_CaretAfterBlockOnlyWhitespace() - { - ToggleComment(""" + => ToggleComment(""" class C { void M() @@ -951,12 +874,10 @@ void M() } } """); - } [WpfFact] public void RemoveComment_CaretAfterMultipleBlocksOnlyWhitespace() - { - ToggleComment(""" + => ToggleComment(""" class C { void M() @@ -975,12 +896,10 @@ void M() } } """); - } [WpfFact] public void RemoveComment_CaretInsideUnclosedBlock() - { - ToggleComment(""" + => ToggleComment(""" class C { void M() @@ -1001,12 +920,10 @@ void M() } }|] """); - } [WpfFact] public void RemoveComment_CommentInsideSelection() - { - ToggleComment(""" + => ToggleComment(""" class C { void M() @@ -1027,12 +944,10 @@ void M() } } """); - } [WpfFact] public void RemoveComment_CommentAndWhitespaceInSelection() - { - ToggleComment(""" + => ToggleComment(""" class C { void M() @@ -1055,12 +970,10 @@ void M() } } """); - } [WpfFact] public void RemoveComment_CommentWithSingleLineCommentInSelection() - { - ToggleComment(""" + => ToggleComment(""" class C { void M() @@ -1081,12 +994,10 @@ void M() } } """); - } [WpfFact] public void RemoveComment_SequentialBlockInSelection() - { - ToggleComment(""" + => ToggleComment(""" class C { void M() @@ -1107,12 +1018,10 @@ void M() } } """); - } [WpfFact] public void RemoveComment_SequentialBlockAndWhitespaceInSelection() - { - ToggleComment(""" + => ToggleComment(""" class C { void M() @@ -1137,12 +1046,10 @@ void M() } } """); - } [WpfFact] public void RemoveComment_CommentPartiallyInsideSelection() - { - ToggleComment(""" + => ToggleComment(""" class C { void M() @@ -1163,12 +1070,10 @@ void M() } } """); - } [WpfFact] public void RemoveComment_PartialSequentialBlockInSelection() - { - ToggleComment(""" + => ToggleComment(""" class C { void M() @@ -1189,12 +1094,10 @@ void M() } } """); - } [WpfFact] public void RemoveComment_BlockSelectionWithMultipleComments() - { - ToggleComment(""" + => ToggleComment(""" class C { void M() @@ -1215,12 +1118,10 @@ void M() } } """); - } [WpfFact] public void RemoveComment_BlockSelectionWithOneComment() - { - ToggleComment(""" + => ToggleComment(""" class C { void M() @@ -1241,12 +1142,10 @@ void M() } } """); - } [WpfFact] public void RemoveComment_WithProjectionBuffer() - { - ToggleCommentWithProjectionBuffer(@"< html >@{|S1:|}", """ + => ToggleCommentWithProjectionBuffer(@"< html >@{|S1:|}", """ {|S1:class C { void M() @@ -1263,7 +1162,6 @@ void M() } } """); - } [WpfFact] public void ToggleComment_MultiLineSelection() diff --git a/src/EditorFeatures/Test/Completion/GlobalAssemblyCacheCompletionHelperTests.cs b/src/EditorFeatures/Test/Completion/GlobalAssemblyCacheCompletionHelperTests.cs index c1cc5caef0d9..62fe501b29d3 100644 --- a/src/EditorFeatures/Test/Completion/GlobalAssemblyCacheCompletionHelperTests.cs +++ b/src/EditorFeatures/Test/Completion/GlobalAssemblyCacheCompletionHelperTests.cs @@ -21,15 +21,11 @@ public sealed class GlobalAssemblyCacheCompletionHelperTests { [ConditionalFact(typeof(WindowsOnly))] public void ExistingReference() - { - VerifyPresence("System.Windows", "System.Windows.Forms"); - } + => VerifyPresence("System.Windows", "System.Windows.Forms"); [ConditionalFact(typeof(WindowsOnly))] public void FullReferenceIdentity() - { - VerifyPresence("System,", typeof(System.Diagnostics.Process).Assembly.FullName); - } + => VerifyPresence("System,", typeof(System.Diagnostics.Process).Assembly.FullName); private static void VerifyPresence(string pathSoFar, string completionItem) { diff --git a/src/EditorFeatures/Test/Diagnostics/IDEDiagnosticIDConfigurationTests.cs b/src/EditorFeatures/Test/Diagnostics/IDEDiagnosticIDConfigurationTests.cs index 4f39dd2c9466..ea55e2675d7f 100644 --- a/src/EditorFeatures/Test/Diagnostics/IDEDiagnosticIDConfigurationTests.cs +++ b/src/EditorFeatures/Test/Diagnostics/IDEDiagnosticIDConfigurationTests.cs @@ -174,8 +174,7 @@ private static void VerifyConfigureSeverityCore(string expected, string language [Fact] public void CSharp_VerifyIDEDiagnosticSeveritiesAreConfigurable() - { - VerifyConfigureSeverityCore(""" + => VerifyConfigureSeverityCore(""" # IDE0001 dotnet_diagnostic.IDE0001.severity = %value% @@ -539,12 +538,10 @@ public void CSharp_VerifyIDEDiagnosticSeveritiesAreConfigurable() # JSON002 dotnet_diagnostic.JSON002.severity = %value% """, LanguageNames.CSharp); - } [Fact] public void VisualBasic_VerifyIDEDiagnosticSeveritiesAreConfigurable() - { - VerifyConfigureSeverityCore(""" + => VerifyConfigureSeverityCore(""" # IDE0001 dotnet_diagnostic.IDE0001.severity = %value% @@ -704,7 +701,6 @@ public void VisualBasic_VerifyIDEDiagnosticSeveritiesAreConfigurable() # JSON002 dotnet_diagnostic.JSON002.severity = %value% """, LanguageNames.VisualBasic); - } private static void VerifyConfigureCodeStyleOptionsCore((string diagnosticId, string optionName, string optionValue)[] expected, string languageName) { diff --git a/src/EditorFeatures/Test/Diagnostics/SuppressMessageAttributeWorkspaceTests.cs b/src/EditorFeatures/Test/Diagnostics/SuppressMessageAttributeWorkspaceTests.cs index 0201b6017e08..49e62037aaf9 100644 --- a/src/EditorFeatures/Test/Diagnostics/SuppressMessageAttributeWorkspaceTests.cs +++ b/src/EditorFeatures/Test/Diagnostics/SuppressMessageAttributeWorkspaceTests.cs @@ -25,7 +25,9 @@ public sealed class SuppressMessageAttributeWorkspaceTests : SuppressMessageAttr private static readonly Lazy _unconditionalSuppressMessageRef = new(() => { - const string unconditionalSuppressMessageDef = """ + return CSharpCompilation.Create("unconditionalsuppress", + options: new CSharpCompilationOptions(OutputKind.DynamicallyLinkedLibrary), + syntaxTrees: [CSharpSyntaxTree.ParseText(""" namespace System.Diagnostics.CodeAnalysis { [System.AttributeUsage(System.AttributeTargets.All, AllowMultiple=true, Inherited=false)] @@ -44,10 +46,7 @@ public UnconditionalSuppressMessageAttribute(string category, string checkId) public string Justification { get; set; } } } - """; - return CSharpCompilation.Create("unconditionalsuppress", - options: new CSharpCompilationOptions(OutputKind.DynamicallyLinkedLibrary), - syntaxTrees: [CSharpSyntaxTree.ParseText(unconditionalSuppressMessageDef)], + """)], references: [TestBase.MscorlibRef]).EmitToImageReference(); }, LazyThreadSafetyMode.PublicationOnly); diff --git a/src/EditorFeatures/Test/DocCommentFormatting/DocCommentFormattingTests.cs b/src/EditorFeatures/Test/DocCommentFormatting/DocCommentFormattingTests.cs index 31795dc86e2d..446a08c44054 100644 --- a/src/EditorFeatures/Test/DocCommentFormatting/DocCommentFormattingTests.cs +++ b/src/EditorFeatures/Test/DocCommentFormatting/DocCommentFormattingTests.cs @@ -32,14 +32,11 @@ private void TestFormat(string xmlFragment, string expected) [Fact] public void CTag() - { - TestFormat("Class Point models a point in a two-dimensional plane.", "Class Point models a point in a two-dimensional plane."); - } + => TestFormat("Class Point models a point in a two-dimensional plane.", "Class Point models a point in a two-dimensional plane."); [Fact] public void ExampleAndCodeTags() - { - TestFormat(""" + => TestFormat(""" This method changes the point's location by the given x- and y-offsets. For example: @@ -49,12 +46,10 @@ This method changes the point's location by the given x- and y-offsets. results in p's having the value (2,8). """, "This method changes the point's location by the given x- and y-offsets. For example:\r\n\r\n Point p = new Point(3,5);\r\n p.Translate(-1,3);\r\n \r\n\r\nresults in p's having the value (2,8)."); - } [Fact] public void ListTag() - { - TestFormat(""" + => TestFormat(""" Here is an example of a bulleted list: @@ -65,12 +60,10 @@ public void ListTag() """, "Here is an example of a bulleted list:\r\n\r\n• Item 1.\r\n• Item 2."); - } [Fact] public void ParaTag() - { - TestFormat(""" + => TestFormat(""" This is the entry point of the Point class testing program. This program tests each method and operator, and is intended to be run after any non-trivial maintenance has @@ -80,80 +73,58 @@ This is the entry point of the Point class testing program. This program tests each method and operator, and is intended to be run after any non-trivial maintenance has been performed on the Point class. """); - } [Fact] public void TestPermissionTag() - { - TestFormat(@"Everyone can access this method.", @"Everyone can access this method."); - } + => TestFormat(@"Everyone can access this method.", @"Everyone can access this method."); [Fact] public void SeeTag() - { - TestFormat(@"", @"AnotherFunction"); - } + => TestFormat(@"", @"AnotherFunction"); [Fact] public void SeeAlsoTag() - { - TestFormat(@"", @"AnotherFunction"); - } + => TestFormat(@"", @"AnotherFunction"); [Fact] public void ValueTag() - { - TestFormat(@"Property X represents the point's x-coordinate.", @"Property X represents the point's x-coordinate."); - } + => TestFormat(@"Property X represents the point's x-coordinate.", @"Property X represents the point's x-coordinate."); [Fact] public void TestParamRefTag() - { - TestFormat(""" + => TestFormat(""" This constructor initializes the new Point to (,). """, "This constructor initializes the new Point to (xor,yor)."); - } [Fact] public void TestTypeParamRefTag() - { - TestFormat(@"This method fetches data and returns a list of .", @"This method fetches data and returns a list of Z."); - } + => TestFormat(@"This method fetches data and returns a list of .", @"This method fetches data and returns a list of Z."); [Fact] public void Whitespace1() - { - TestFormat(" This has extra whitespace. ", "This has extra whitespace."); - } + => TestFormat(" This has extra whitespace. ", "This has extra whitespace."); [Fact] public void Whitespace2() - { - TestFormat(""" + => TestFormat(""" This has extra whitespace. """, "This has extra whitespace."); - } [Fact] public void Whitespace3() - { - TestFormat("This has extra whitespace.", "This has extra whitespace."); - } + => TestFormat("This has extra whitespace.", "This has extra whitespace."); [Fact] public void Paragraphs1() - { - TestFormat(""" + => TestFormat(""" This is part of a paragraph. """, "This is part of a paragraph."); - } [Fact] public void Paragraphs2() - { - TestFormat(""" + => TestFormat(""" This is part of a paragraph. This is also part of a paragraph. """, """ @@ -161,12 +132,10 @@ This is part of a paragraph. This is also part of a paragraph. """); - } [Fact] public void Paragraphs3() - { - TestFormat(""" + => TestFormat(""" This is a summary. This is part of a paragraph. """, """ @@ -174,24 +143,20 @@ This is a summary. This is part of a paragraph. """); - } [Fact] public void Paragraphs4() - { - TestFormat(""" + => TestFormat(""" This is part of a paragraph. This is part of the summary, too. """, """ This is part of a paragraph. This is part of the summary, too. """); - } [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/32838")] public void Paragraphs5() - { - TestFormat(""" + => TestFormat(""" This is part of a
paragraph.
This is also part of a paragraph. """, """ @@ -200,15 +165,13 @@ This is part of a This is also part of a paragraph. """); - } [Theory] [InlineData("

")] [InlineData("


")] [WorkItem("https://github.com/dotnet/roslyn/issues/32838")] public void Paragraphs6(string lineBreak) - { - TestFormat($""" + => TestFormat($""" This is part of a{lineBreak}paragraph. This is also part of a paragraph. """, """ @@ -218,77 +181,52 @@ This is part of a This is also part of a paragraph. """); - } [Fact] public void See1() - { - TestFormat(@"See ", "See System.Object"); - } + => TestFormat(@"See ", "See System.Object"); [Fact] public void See2() - { - TestFormat(@"See ", @"See"); - } + => TestFormat(@"See ", @"See"); [Fact] public void See3() - { - TestFormat(@"See ", "See true"); - } + => TestFormat(@"See ", "See true"); [Fact] public void See4() - { - TestFormat(@"See ", "See https://github.com"); - } + => TestFormat(@"See ", "See https://github.com"); [Fact] public void See5() - { - TestFormat(@"See GitHub", "See GitHub"); - } + => TestFormat(@"See GitHub", "See GitHub"); [Fact] public void See6() - { - TestFormat(@"See ", "See https://github.com"); - } + => TestFormat(@"See ", "See https://github.com"); [Fact] public void SeeAlso1() - { - TestFormat(@"See also ", @"See also System.Object"); - } + => TestFormat(@"See also ", @"See also System.Object"); [Fact] public void SeeAlso2() - { - TestFormat(@"See also ", @"See also"); - } + => TestFormat(@"See also ", @"See also"); [Fact] public void SeeAlso3() - { - TestFormat(@"See also ", "See also true"); - } + => TestFormat(@"See also ", "See also true"); [Fact] public void SeeAlso4() - { - TestFormat(@"See also ", "See also https://github.com"); - } + => TestFormat(@"See also ", "See also https://github.com"); [Fact] public void SeeAlso5() - { - TestFormat(@"See also GitHub", "See also GitHub"); - } + => TestFormat(@"See also GitHub", "See also GitHub"); [Fact] public void SeeAlso6() - { - TestFormat(@"See also ", "See also https://github.com"); - } + => TestFormat(@"See also ", "See also https://github.com"); } diff --git a/src/EditorFeatures/Test/EditAndContinue/EditAndContinueLanguageServiceTests.cs b/src/EditorFeatures/Test/EditAndContinue/EditAndContinueLanguageServiceTests.cs index 07909235d023..389c8beb7008 100644 --- a/src/EditorFeatures/Test/EditAndContinue/EditAndContinueLanguageServiceTests.cs +++ b/src/EditorFeatures/Test/EditAndContinue/EditAndContinueLanguageServiceTests.cs @@ -210,8 +210,9 @@ await localWorkspace.ChangeSolutionAsync(localWorkspace.CurrentSolution ]) ], SyntaxError = syntaxError, - ProjectsToRebuild = [project.Id], - ProjectsToRestart = ImmutableDictionary>.Empty.Add(project.Id, []) + ProjectsToRebuild = [projectId], + ProjectsToRestart = ImmutableDictionary>.Empty.Add(projectId, []), + ProjectsToRedeploy = [projectId], }; }; @@ -276,6 +277,7 @@ await localWorkspace.ChangeSolutionAsync(localWorkspace.CurrentSolution SyntaxError = null, ProjectsToRebuild = [], ProjectsToRestart = ImmutableDictionary>.Empty, + ProjectsToRedeploy = [], }; }; diff --git a/src/EditorFeatures/Test/EditorConfigSettings/Data/CodeStyleSettingsTest.cs b/src/EditorFeatures/Test/EditorConfigSettings/Data/CodeStyleSettingsTest.cs index 9005115118f7..e26b2ec5628d 100644 --- a/src/EditorFeatures/Test/EditorConfigSettings/Data/CodeStyleSettingsTest.cs +++ b/src/EditorFeatures/Test/EditorConfigSettings/Data/CodeStyleSettingsTest.cs @@ -66,8 +66,8 @@ public static void CodeStyleSettingEnumFactory(DayOfWeek defaultValue) description: "TestDesciption", options, updater: null!, - enumValues: (DayOfWeek[])Enum.GetValues(typeof(DayOfWeek)), - valueDescriptions: Enum.GetNames(typeof(DayOfWeek))); + enumValues: Enum.GetValues(), + valueDescriptions: Enum.GetNames()); Assert.Equal(string.Empty, setting.Category); Assert.Equal("TestDesciption", setting.Description); diff --git a/src/EditorFeatures/Test/InheritanceMargin/InheritanceMarginTests.cs b/src/EditorFeatures/Test/InheritanceMargin/InheritanceMarginTests.cs index 1067001816f0..b8e936b3248b 100644 --- a/src/EditorFeatures/Test/InheritanceMargin/InheritanceMarginTests.cs +++ b/src/EditorFeatures/Test/InheritanceMargin/InheritanceMarginTests.cs @@ -367,14 +367,12 @@ public static TestInheritanceTargetItem Create( [Theory, CombinatorialData] public Task TestCSharpClassWithErrorBaseType(TestHost testHost) - { - return VerifyNoItemForDocumentAsync(""" + => VerifyNoItemForDocumentAsync(""" public class Bar : SomethingUnknown { } """, LanguageNames.CSharp, testHost); - } [Theory, CombinatorialData] public Task TestCSharpReferencingMetadata(TestHost testHost) @@ -515,14 +513,12 @@ class {|target1:B|} : A { } [InlineData("interface", TestHost.InProcess)] [InlineData("interface", TestHost.OutOfProcess)] public Task TestCSharpTypeWithoutBaseType(string typeName, TestHost testHost) - { - return VerifyNoItemForDocumentAsync($$""" + => VerifyNoItemForDocumentAsync($$""" public {{typeName}} Bar { } """, LanguageNames.CSharp, testHost); - } [Theory] [InlineData("public Bar() { }", TestHost.InProcess)] @@ -534,8 +530,7 @@ public Task TestCSharpTypeWithoutBaseType(string typeName, TestHost testHost) [InlineData("public static Bar operator +(Bar a, Bar b) => new Bar();", TestHost.InProcess)] [InlineData("public static Bar operator +(Bar a, Bar b) => new Bar();", TestHost.OutOfProcess)] public Task TestCSharpSpecialMember(string memberDeclaration, TestHost testHost) - { - return VerifyInSingleDocumentAsync( + => VerifyInSingleDocumentAsync( $$""" public abstract class {|target1:Bar1|} @@ -554,7 +549,6 @@ public class {|{{SearchAreaTag}}:Bar : Bar1 targetSymbolDisplayName: "Bar1", locationTag: "target1", relationship: InheritanceRelationship.BaseType)])); - } [Theory, CombinatorialData] public Task TestCSharpEventDeclaration(TestHost testHost) @@ -1455,8 +1449,7 @@ public partial class {|target3:Bar|} [Theory, CombinatorialData] public Task TestEmptyFileSingleGlobalImportInOtherFile(TestHost testHost) - { - return VerifyInMultipleDocumentsAsync( + => VerifyInMultipleDocumentsAsync( @"", @"{|target1:global using System;|}", LanguageNames.CSharp, testHost, new TestInheritanceMemberItem( @@ -1465,12 +1458,10 @@ public Task TestEmptyFileSingleGlobalImportInOtherFile(TestHost testHost) targets: [new TargetInfo( targetSymbolDisplayName: "System", relationship: InheritanceRelationship.InheritedImport, "target1")])); - } [Theory, CombinatorialData] public Task TestEmptyFileMultipleGlobalImportInOtherFile(TestHost testHost) - { - return VerifyInMultipleDocumentsAsync( + => VerifyInMultipleDocumentsAsync( @"", """ {|target1:global using System;|} @@ -1489,12 +1480,10 @@ public Task TestEmptyFileMultipleGlobalImportInOtherFile(TestHost testHost) targetSymbolDisplayName: "System.Collections", relationship: InheritanceRelationship.InheritedImport, "target2"), ])); - } [Theory, CombinatorialData] public Task TestFileWithUsing_SingleGlobalImportInOtherFile(TestHost testHost) - { - return VerifyInMultipleDocumentsAsync( + => VerifyInMultipleDocumentsAsync( """ using System.Collections; @@ -1506,12 +1495,10 @@ public Task TestFileWithUsing_SingleGlobalImportInOtherFile(TestHost testHost) targets: [new TargetInfo( targetSymbolDisplayName: "System", relationship: InheritanceRelationship.InheritedImport, "target1")])); - } [Theory, CombinatorialData] public Task TestIgnoreGlobalImportFromSameFile(TestHost testHost) - { - return VerifyInMultipleDocumentsAsync( + => VerifyInMultipleDocumentsAsync( """ global using System.Collections.Generic; @@ -1524,7 +1511,6 @@ public Task TestIgnoreGlobalImportFromSameFile(TestHost testHost) targets: [new TargetInfo( targetSymbolDisplayName: "System", relationship: InheritanceRelationship.InheritedImport, "target1")])); - } #endregion @@ -1532,8 +1518,7 @@ public Task TestIgnoreGlobalImportFromSameFile(TestHost testHost) [Theory, CombinatorialData] public Task TestVisualBasicWithErrorBaseType(TestHost testHost) - { - return VerifyNoItemForDocumentAsync(""" + => VerifyNoItemForDocumentAsync(""" Namespace MyNamespace Public Class Bar @@ -1541,7 +1526,6 @@ Implements SomethingNotExist End Class End Namespace """, LanguageNames.VisualBasic, testHost); - } [Theory, CombinatorialData] public Task TestVisualBasicReferencingMetadata(TestHost testHost) @@ -1675,18 +1659,15 @@ End Class [InlineData("Interface", TestHost.InProcess)] [InlineData("Interface", TestHost.OutOfProcess)] public Task TestVisualBasicTypeWithoutBaseType(string typeName, TestHost testHost) - { - return VerifyNoItemForDocumentAsync($""" + => VerifyNoItemForDocumentAsync($""" {typeName} Bar End {typeName} """, LanguageNames.VisualBasic, testHost); - } [Theory, CombinatorialData] public Task TestVisualBasicMetadataInterface(TestHost testHost) - { - return VerifyInSingleDocumentAsync( + => VerifyInSingleDocumentAsync( """ Imports System.Collections @@ -1712,7 +1693,6 @@ End Class targetSymbolDisplayName: "IEnumerable", relationship: InheritanceRelationship.ImplementedInterface, inMetadata: true)])); - } [Theory, CombinatorialData] public Task TestVisualBasicEventStatement(TestHost testHost) diff --git a/src/EditorFeatures/Test/LinkedFiles/LinkedFileDiffMergingEditorTests.cs b/src/EditorFeatures/Test/LinkedFiles/LinkedFileDiffMergingEditorTests.cs index fcfceb498977..bb3881d8e366 100644 --- a/src/EditorFeatures/Test/LinkedFiles/LinkedFileDiffMergingEditorTests.cs +++ b/src/EditorFeatures/Test/LinkedFiles/LinkedFileDiffMergingEditorTests.cs @@ -53,7 +53,7 @@ public async Task TestCodeActionPreviewAndApply() { // TODO: WPF required due to https://github.com/dotnet/roslyn/issues/46153 using var workspace = EditorTestWorkspace.Create(WorkspaceXml, composition: EditorTestCompositions.EditorFeatures); - var codeIssueOrRefactoring = await GetCodeRefactoringAsync(workspace, new TestParameters()); + var codeIssueOrRefactoring = await GetCodeRefactoringAsync(workspace, TestParameters.Default); await TestActionOnLinkedFiles( workspace, diff --git a/src/EditorFeatures/Test/MetadataAsSource/DocCommentFormatterTests.cs b/src/EditorFeatures/Test/MetadataAsSource/DocCommentFormatterTests.cs index c281e1e6aee9..54c1bece379d 100644 --- a/src/EditorFeatures/Test/MetadataAsSource/DocCommentFormatterTests.cs +++ b/src/EditorFeatures/Test/MetadataAsSource/DocCommentFormatterTests.cs @@ -36,51 +36,40 @@ private void TestFormat(string docCommentXmlFragment, string expectedCSharp, str [Fact] public void Summary() - { - TestFormat("This is a summary.", $@"{FeaturesResources.Summary_colon} + => TestFormat("This is a summary.", $@"{FeaturesResources.Summary_colon} This is a summary."); - } [Fact] public void Wrapping1() - { - TestFormat("I am the very model of a modern major general. This is a very long comment. And getting longer by the minute.", $@"{FeaturesResources.Summary_colon} + => TestFormat("I am the very model of a modern major general. This is a very long comment. And getting longer by the minute.", $@"{FeaturesResources.Summary_colon} I am the very model of a modern major general. This is a very long comment. And getting longer by the minute."); - } [Fact] public void Wrapping2() - { - TestFormat("I amtheverymodelofamodernmajorgeneral.Thisisaverylongcomment.Andgettinglongerbythe minute.", $@"{FeaturesResources.Summary_colon} + => TestFormat("I amtheverymodelofamodernmajorgeneral.Thisisaverylongcomment.Andgettinglongerbythe minute.", $@"{FeaturesResources.Summary_colon} I amtheverymodelofamodernmajorgeneral.Thisisaverylongcomment.Andgettinglongerbythe minute."); - } [Fact] public void Exception() - { - TestFormat(@"throws NotImplementedException", $@"{WorkspacesResources.Exceptions_colon} + => TestFormat(@"throws NotImplementedException", $@"{WorkspacesResources.Exceptions_colon} T:System.NotImplementedException: throws NotImplementedException"); - } [Fact] public void MultipleExceptionTags() - { - TestFormat(@"throws NotImplementedException + => TestFormat(@"throws NotImplementedException throws InvalidOperationException", $@"{WorkspacesResources.Exceptions_colon} T:System.NotImplementedException: throws NotImplementedException T:System.InvalidOperationException: throws InvalidOperationException"); - } [Fact, WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/530760")] public void MultipleExceptionTagsWithSameType() - { - TestFormat(@"throws NotImplementedException for reason X + => TestFormat(@"throws NotImplementedException for reason X throws InvalidOperationException also throws NotImplementedException for reason Y", $@"{WorkspacesResources.Exceptions_colon} T:System.NotImplementedException: @@ -91,26 +80,20 @@ public void MultipleExceptionTagsWithSameType() T:System.InvalidOperationException: throws InvalidOperationException"); - } [Fact] public void Returns() - { - TestFormat(@"A string is returned", $@"{FeaturesResources.Returns_colon} + => TestFormat(@"A string is returned", $@"{FeaturesResources.Returns_colon} A string is returned"); - } [Fact] public void Value() - { - TestFormat(@"A string value", $@"{FeaturesResources.Value_colon} + => TestFormat(@"A string value", $@"{FeaturesResources.Value_colon} A string value"); - } [Fact] public void SummaryAndParams() - { - TestFormat(@"This is the summary. + => TestFormat(@"This is the summary. The param named 'a' The param named 'b'", $@"{FeaturesResources.Summary_colon} This is the summary. @@ -121,24 +104,20 @@ The param named 'a' b: The param named 'b'"); - } [Fact] public void TypeParameters() - { - TestFormat(@"The type param named 'T' + => TestFormat(@"The type param named 'T' The type param named 'U'", $@"{FeaturesResources.Type_parameters_colon} T: The type param named 'T' U: The type param named 'U'"); - } [Fact] public void FormatEverything() - { - TestFormat(@" + => TestFormat(@" This is a summary of something. The param named 'a'. @@ -190,5 +169,4 @@ Thrown when blah blah blah {FeaturesResources.Remarks_colon} This doc comment is really not very remarkable."); - } } diff --git a/src/EditorFeatures/Test/Snippets/RoslynLSPSnippetConvertTests.cs b/src/EditorFeatures/Test/Snippets/RoslynLSPSnippetConvertTests.cs index 73a5607f1ba2..8e88f2620ab4 100644 --- a/src/EditorFeatures/Test/Snippets/RoslynLSPSnippetConvertTests.cs +++ b/src/EditorFeatures/Test/Snippets/RoslynLSPSnippetConvertTests.cs @@ -25,8 +25,7 @@ public class RoslynLSPSnippetConvertTests [Fact] public Task TestExtendSnippetTextChangeForwardsForCaret() - { - return TestAsync(""" + => TestAsync(""" [|if ({|placeholder:true|}) { }|] $$ @@ -35,12 +34,10 @@ public Task TestExtendSnippetTextChangeForwardsForCaret() { } $0 """); - } [Fact] public Task TestExtendSnippetTextChangeBackwardsForCaret() - { - return TestAsync(""" + => TestAsync(""" $$ [|if ({|placeholder:true|}) { }|] @@ -49,12 +46,10 @@ public Task TestExtendSnippetTextChangeBackwardsForCaret() { } """); - } [Fact] public Task TestExtendSnippetTextChangeForwardsForPlaceholder() - { - return TestAsync(""" + => TestAsync(""" [|if (true) {$$ }|] {|placeholder:test|} @@ -63,12 +58,10 @@ public Task TestExtendSnippetTextChangeForwardsForPlaceholder() {$0 } ${1:test} """); - } [Fact] public Task TestExtendSnippetTextChangeBackwardsForPlaceholder() - { - return TestAsync(""" + => TestAsync(""" {|placeholder:test|} [|if (true) {$$ }|] @@ -77,12 +70,10 @@ public Task TestExtendSnippetTextChangeBackwardsForPlaceholder() {$0 } """); - } [Fact] public Task TestExtendSnippetTextChangeForwardsForPlaceholderThenCaret() - { - return TestAsync(""" + => TestAsync(""" [|if (true) { }|] {|placeholder:test|} $$ @@ -91,12 +82,10 @@ public Task TestExtendSnippetTextChangeForwardsForPlaceholderThenCaret() { } ${1:test} $0 """); - } [Fact] public Task TestExtendSnippetTextChangeForwardsForCaretThenPlaceholder() - { - return TestAsync(""" + => TestAsync(""" [|if (true) { }|] $$ {|placeholder:test|} @@ -105,12 +94,10 @@ public Task TestExtendSnippetTextChangeForwardsForCaretThenPlaceholder() { } $0 ${1:test} """); - } [Fact] public Task TestExtendSnippetTextChangeBackwardsForPlaceholderThenCaret() - { - return TestAsync(""" + => TestAsync(""" {|placeholder:test|} $$ [|if (true) { }|] @@ -119,12 +106,10 @@ public Task TestExtendSnippetTextChangeBackwardsForPlaceholderThenCaret() { } """); - } [Fact] public Task TestExtendSnippetTextChangeBackwardsForCaretThenPlaceholder() - { - return TestAsync(""" + => TestAsync(""" $$ {|placeholder:test|} [|if (true) { }|] @@ -133,12 +118,10 @@ public Task TestExtendSnippetTextChangeBackwardsForCaretThenPlaceholder() { } """); - } [Fact] public Task TestExtendSnippetTextChangeBackwardsForCaretForwardsForPlaceholder() - { - return TestAsync(""" + => TestAsync(""" $$ [|if (true) { }|] {|placeholder:test|} @@ -147,12 +130,10 @@ public Task TestExtendSnippetTextChangeBackwardsForCaretForwardsForPlaceholder() { } ${1:test} """); - } [Fact] public Task TestExtendSnippetTextChangeBackwardsForPlaceholderForwardsForCaret() - { - return TestAsync(""" + => TestAsync(""" {|placeholder:test|} [|if (true) { }|] $$ @@ -161,12 +142,10 @@ public Task TestExtendSnippetTextChangeBackwardsForPlaceholderForwardsForCaret() { } $0 """); - } [Fact] public Task TestExtendSnippetTextChangeInMethodForwardsForCaret() - { - return TestAsync(""" + => TestAsync(""" public void Method() { [|if ({|placeholder:true|}) @@ -178,12 +157,10 @@ public void Method() { } $0 """); - } [Fact] public Task TestExtendSnippetTextChangeInMethodBackwardsForCaret() - { - return TestAsync(""" + => TestAsync(""" public void Method() { $$ [|if ({|placeholder:true|}) @@ -195,12 +172,10 @@ public void Method() { } """); - } [Fact] public Task TestExtendSnippetTextChangeInMethodForwardsForPlaceholder() - { - return TestAsync(""" + => TestAsync(""" public void Method() { [|if (true) @@ -212,12 +187,10 @@ public void Method() {$0 } ${1:test} """); - } [Fact] public Task TestExtendSnippetTextChangeInMethodBackwardsForPlaceholder() - { - return TestAsync(""" + => TestAsync(""" public void Method() { {|placeholder:test|} [|if (true) @@ -228,12 +201,10 @@ public void Method() {$0 } """); - } [Fact] public Task TestExtendSnippetTextChangeInMethodForwardsForPlaceholderThenCaret() - { - return TestAsync(""" + => TestAsync(""" public void Method() { [|if (true) @@ -245,12 +216,10 @@ public void Method() { } ${1:test} $0 """); - } [Fact] public Task TestExtendSnippetTextChangeInMethodForwardsForCaretThenPlaceholder() - { - return TestAsync(""" + => TestAsync(""" public void Method() { [|if (true) @@ -262,12 +231,10 @@ public void Method() { } $0 ${1:test} """); - } [Fact] public Task TestExtendSnippetTextChangeInMethodBackwardsForPlaceholderThenCaret() - { - return TestAsync(""" + => TestAsync(""" public void Method() { {|placeholder:test|} $$ [|if (true) @@ -279,12 +246,10 @@ public void Method() { } """); - } [Fact] public Task TestExtendSnippetTextChangeInMethodBackwardsForCaretThenPlaceholder() - { - return TestAsync(""" + => TestAsync(""" public void Method() { $$ {|placeholder:test|} [|if (true) @@ -296,12 +261,10 @@ public void Method() { } """); - } [Fact] public Task TestExtendSnippetTextChangeInMethodBackwardsForCaretForwardsForPlaceholder() - { - return TestAsync(""" + => TestAsync(""" public void Method() { $$ [|if (true) @@ -313,12 +276,10 @@ public void Method() { } ${1:test} """); - } [Fact] public Task TestExtendSnippetTextChangeInMethodBackwardsForPlaceholderForwardsForCaret() - { - return TestAsync(""" + => TestAsync(""" public void Method() { {|placeholder:test|} [|if (true) @@ -330,12 +291,10 @@ public void Method() { } $0 """); - } [Fact] public Task TestExtendSnippetTextChangeInMethodWithCodeBeforeAndAfterBackwardsForPlaceholderForwardsForCaret() - { - return TestAsync(""" + => TestAsync(""" public void Method() { var x = 5; @@ -350,7 +309,6 @@ public void Method() { } $0 """); - } [Fact] public void TestExtendTextChangeInsertion() @@ -380,8 +338,7 @@ public void TestExtendTextChangeReplacement() [Fact] public Task TestForLoopSnippet() - { - return TestAsync(""" + => TestAsync(""" [|for (var {|placeholder1:i|} = 0; {|placeholder1:i|} < {|placeholder2:length|}; {|placeholder1:i|}++) {$$ }|] @@ -390,12 +347,10 @@ public Task TestForLoopSnippet() {$0 } """); - } [Fact] public Task TestIfSnippetSamePlaceholderCursorLocation() - { - return TestAsync(""" + => TestAsync(""" public void Method() { var x = 5; @@ -410,12 +365,10 @@ public void Method() { } """); - } [Fact] public Task TestIfSnippetSameCursorPlaceholderLocation() - { - return TestAsync(""" + => TestAsync(""" public void Method() { var x = 5; @@ -430,7 +383,6 @@ public void Method() { } """); - } #endregion diff --git a/src/EditorFeatures/Test/StackTraceExplorer/StackTraceExplorerTests.cs b/src/EditorFeatures/Test/StackTraceExplorer/StackTraceExplorerTests.cs index ad44dd3ff8b5..93041af759ae 100644 --- a/src/EditorFeatures/Test/StackTraceExplorer/StackTraceExplorerTests.cs +++ b/src/EditorFeatures/Test/StackTraceExplorer/StackTraceExplorerTests.cs @@ -72,8 +72,7 @@ private static void AssertContents(ImmutableArray frames, params st [Fact] public Task TestSymbolFound_DebuggerLine() - { - return TestSymbolFoundAsync( + => TestSymbolFoundAsync( "ConsoleApp4.dll!ConsoleApp4.MyClass.M()", """ using System; @@ -86,7 +85,6 @@ class MyClass } } """); - } [Theory] [InlineData("object", "Object")] @@ -104,8 +102,7 @@ class MyClass [InlineData("uint", "UInt32")] [InlineData("ulong", "UInt64")] public Task TestSpecialTypes(string type, string typeName) - { - return TestSymbolFoundAsync( + => TestSymbolFoundAsync( $"at ConsoleApp.MyClass.M({typeName} value)", $$""" using System; @@ -118,12 +115,10 @@ class MyClass } } """); - } [Fact] public Task TestSymbolFound_DebuggerLine_SingleSimpleClassParam() - { - return TestSymbolFoundAsync( + => TestSymbolFoundAsync( "ConsoleApp4.dll!ConsoleApp4.MyClass.M(String s)", """ using System; @@ -136,12 +131,10 @@ class MyClass } } """); - } [Fact] public Task TestSymbolFound_ExceptionLine() - { - return TestSymbolFoundAsync( + => TestSymbolFoundAsync( "at ConsoleApp4.MyClass.M()", """ using System; @@ -154,12 +147,10 @@ class MyClass } } """); - } [Fact] public Task TestSymbolFound_ExceptionLine_SingleSimpleClassParam() - { - return TestSymbolFoundAsync( + => TestSymbolFoundAsync( "at ConsoleApp4.MyClass.M(String s)", """ using System; @@ -172,12 +163,10 @@ class MyClass } } """); - } [Fact] public Task TestSymbolFound_ExceptionLineWithFile() - { - return TestSymbolFoundAsync( + => TestSymbolFoundAsync( @"at ConsoleApp4.MyClass.M() in C:\repos\ConsoleApp4\ConsoleApp4\Program.cs:line 26", """ using System; @@ -190,12 +179,10 @@ class MyClass } } """); - } [Fact] public Task TestSymbolFound_GenericType() - { - return TestSymbolFoundAsync( + => TestSymbolFoundAsync( @"at ConsoleApp.MyClass`1.M(String s)", """ using System; @@ -207,12 +194,10 @@ class MyClass } } """); - } [Fact] public Task TestSymbolFound_GenericType2() - { - return TestSymbolFoundAsync( + => TestSymbolFoundAsync( @"at ConsoleApp.MyClass`2.M(String s)", """ using System; @@ -224,12 +209,10 @@ class MyClass } } """); - } [Fact] public Task TestSymbolFound_GenericType_GenericArg() - { - return TestSymbolFoundAsync( + => TestSymbolFoundAsync( @"at ConsoleApp.MyClass`1.M(T s)", """ using System; @@ -241,12 +224,10 @@ class MyClass } } """); - } [Fact] public Task TestSymbolFound_ExceptionLine_GenericMethod() - { - return TestSymbolFoundAsync( + => TestSymbolFoundAsync( @"at ConsoleApp4.MyClass.M[T](T t) in C:\repos\Test\MyClass.cs:line 7", """ using System; @@ -259,12 +240,10 @@ class MyClass } } """); - } [Fact] public Task TestSymbolFound_ExceptionLine_GenericMethod_FromActivityLog() - { - return TestSymbolFoundAsync( + => TestSymbolFoundAsync( @"at ConsoleApp4.MyClass.M<T>(T t)", """ using System; @@ -277,12 +256,10 @@ class MyClass } } """); - } [Fact] public Task TestSymbolFound_ExceptionLine_MultipleGenerics() - { - return TestSymbolFoundAsync( + => TestSymbolFoundAsync( "at ConsoleApp4.MyClass.M(T t)", """ using System; @@ -295,12 +272,10 @@ class MyClass } } """); - } [Fact] public Task TestSymbolFound_ParameterSpacing() - { - return TestSymbolFoundAsync( + => TestSymbolFoundAsync( "at ConsoleApp.MyClass.M( String s )", """ namespace ConsoleApp @@ -313,12 +288,10 @@ class MyClass } } """); - } [Fact] public Task TestSymbolFound_OverloadsWithSameName() - { - return TestSymbolFoundAsync( + => TestSymbolFoundAsync( "at ConsoleApp.MyClass.M(String value)", """ namespace ConsoleApp @@ -335,12 +308,10 @@ void M(int value) } } """); - } [Fact] public Task TestSymbolFound_ArrayParameter() - { - return TestSymbolFoundAsync( + => TestSymbolFoundAsync( "at ConsoleApp.MyClass.M(String[] s)", """ namespace ConsoleApp @@ -353,12 +324,10 @@ class MyClass } } """); - } [Fact] public Task TestSymbolFound_MultidimensionArrayParameter() - { - return TestSymbolFoundAsync( + => TestSymbolFoundAsync( "at ConsoleApp.MyClass.M(String[,] s)", """ namespace ConsoleApp @@ -371,12 +340,10 @@ class MyClass } } """); - } [Fact] public Task TestSymbolFound_MultidimensionArrayParameter_WithSpaces() - { - return TestSymbolFoundAsync( + => TestSymbolFoundAsync( "at ConsoleApp.MyClass.M(String[ , ] s)", """ namespace ConsoleApp @@ -389,12 +356,10 @@ class MyClass } } """); - } [Fact] public Task TestSymbolFound_MultidimensionArrayParameter_WithSpaces2() - { - return TestSymbolFoundAsync( + => TestSymbolFoundAsync( "at ConsoleApp.MyClass.M(String[,] s)", """ namespace ConsoleApp @@ -407,12 +372,10 @@ class MyClass } } """); - } [Fact] public Task TestSymbolFound_MultidimensionArrayParameter2() - { - return TestSymbolFoundAsync( + => TestSymbolFoundAsync( "at ConsoleApp.MyClass.M(String[,][] s)", """ namespace ConsoleApp @@ -425,12 +388,10 @@ class MyClass } } """); - } [Fact(Skip = "Symbol search for nested types does not work")] public Task TestSymbolFound_ExceptionLine_GenericsHierarchy() - { - return TestSymbolFoundAsync( + => TestSymbolFoundAsync( "at ConsoleApp4.MyClass`1.MyInnerClass`1.M[T](T t)", """ using System; @@ -449,12 +410,10 @@ public class MyInnerClass } } """); - } [Fact(Skip = "ref params do not work yet")] public Task TestSymbolFound_ExceptionLine_RefArg() - { - return TestSymbolFoundAsync( + => TestSymbolFoundAsync( @"at ConsoleApp4.MyClass.M(String& s) in C:\repos\Test\MyClass.cs:line 8", """ using System; @@ -470,12 +429,10 @@ class MyClass } } """); - } [Fact(Skip = "out params do not work yet")] public Task TestSymbolFound_ExceptionLine_OutArg() - { - return TestSymbolFoundAsync( + => TestSymbolFoundAsync( @"at ConsoleApp4.MyClass.M(String& s) in C:\repos\Test\MyClass.cs:line 8", """ using System; @@ -491,12 +448,10 @@ class MyClass } } """); - } [Fact(Skip = "in params do not work yet")] public Task TestSymbolFound_ExceptionLine_InArg() - { - return TestSymbolFoundAsync( + => TestSymbolFoundAsync( @"at ConsoleApp4.MyClass.M(Int32& i)", """ using System; @@ -512,12 +467,10 @@ class MyClass } } """); - } [Fact(Skip = "Generated types/methods are not supported")] public Task TestSymbolFound_ExceptionLine_AsyncMethod() - { - return TestSymbolFoundAsync( + => TestSymbolFoundAsync( @"at ConsoleApp4.MyClass.<>c.b__1_0() in C:\repos\Test\MyClass.cs:line 15", """ namespace ConsoleApp4 @@ -544,12 +497,10 @@ async Task DoThingAsync() } } """); - } [Fact] public Task TestSymbolFound_ExceptionLine_PropertySet() - { - return TestSymbolFoundAsync( + => TestSymbolFoundAsync( @"at ConsoleApp4.MyClass.set_I(Int32 value)", """ using System; @@ -566,12 +517,10 @@ public int I } } """); - } [Fact] public Task TestSymbolFound_ExceptionLine_PropertyGet() - { - return TestSymbolFoundAsync( + => TestSymbolFoundAsync( @"at ConsoleApp4.MyClass.get_I()", """ using System; @@ -588,12 +537,10 @@ public int I } } """); - } [Fact] public Task TestSymbolFound_ExceptionLine_IndexerSet() - { - return TestSymbolFoundAsync( + => TestSymbolFoundAsync( @"at ConsoleApp4.MyClass.set_Item(Int32 i, Int32 value)", """ using System; @@ -610,12 +557,10 @@ public int this[int i] } } """); - } [Fact] public Task TestSymbolFound_ExceptionLine_IndexerGet() - { - return TestSymbolFoundAsync( + => TestSymbolFoundAsync( @"at ConsoleApp4.MyClass.get_Item(Int32 i)", """ using System; @@ -632,12 +577,10 @@ public int this[int i] } } """); - } [Fact] public Task TestSymbolFound_ExceptionLine_LocalFunction() - { - return TestSymbolFoundAsync( + => TestSymbolFoundAsync( @"at ConsoleApp4.MyClass.g__LocalFunction|0_0()", """ using System; @@ -662,12 +605,10 @@ public void LocalFunction() } } """); - } [Fact] public Task TestSymbolFound_ExceptionLine_MultipleLocalFunctions() - { - return TestSymbolFoundAsync( + => TestSymbolFoundAsync( @"at ConsoleApp4.MyClass.g__LocalFunction|0_0()", """ using System; @@ -698,12 +639,10 @@ void LocalFunction() } } """); - } [Fact] public Task TestSymbolFound_ExceptionLine_MultipleLocalFunctions2() - { - return TestSymbolFoundAsync( + => TestSymbolFoundAsync( @"at ConsoleApp4.MyClass.g__LocalFunction|0_0()", """ using System; @@ -734,12 +673,10 @@ public void M2() } } """); - } [Fact] public Task TestSymbolFound_ExceptionLine_MemberFunctionSameNameAsFunction() - { - return TestSymbolFoundAsync( + => TestSymbolFoundAsync( @"at ConsoleApp4.MyClass.LocalFunction()", """ using System; @@ -764,7 +701,6 @@ void LocalFunction() } } """); - } /// /// Behavior for this test needs some explanation. Note that if there are multiple @@ -779,8 +715,7 @@ void LocalFunction() /// [Fact] public Task TestSymbolFound_ExceptionLine_NestedLocalFunctions() - { - return TestSymbolFoundAsync( + => TestSymbolFoundAsync( @"at C.g__Local|0_1()", """ using System; @@ -803,12 +738,10 @@ void Local() } } """); - } [Fact(Skip = "Top level local functions are not supported")] public Task TestSymbolFound_ExceptionLine_LocalInTopLevelStatement() - { - return TestSymbolFoundAsync( + => TestSymbolFoundAsync( @"at ConsoleApp4.Program.g__LocalInTopLevelStatement|0_0()", """ using System; @@ -820,12 +753,10 @@ public Task TestSymbolFound_ExceptionLine_LocalInTopLevelStatement() throw new Exception(); } """); - } [Fact(Skip = "The parser doesn't correctly handle ..ctor() methods yet")] public Task TestSymbolFound_ExceptionLine_Constructor() - { - return TestSymbolFoundAsync( + => TestSymbolFoundAsync( @"at ConsoleApp4.MyClass..ctor()", """ namespace ConsoleApp4 @@ -844,7 +775,6 @@ public MyClass() } } """); - } [Theory] [InlineData("alkjsdflkjasdlkfjasd")] diff --git a/src/EditorFeatures/Test/Structure/AbstractStructureTaggerProviderTests.cs b/src/EditorFeatures/Test/Structure/AbstractStructureTaggerProviderTests.cs index b193cd048e87..998ce8a8b0d8 100644 --- a/src/EditorFeatures/Test/Structure/AbstractStructureTaggerProviderTests.cs +++ b/src/EditorFeatures/Test/Structure/AbstractStructureTaggerProviderTests.cs @@ -25,84 +25,64 @@ private static void TextContainsRegionOrUsing(string input, bool expected, strin [Fact] public void UsingDirective() - { - TextContainsRegionOrUsing(""" + => TextContainsRegionOrUsing(""" using System; """, true, LanguageNames.CSharp); - } [Fact] public void UsingDirectiveInNamespace() - { - TextContainsRegionOrUsing(""" + => TextContainsRegionOrUsing(""" namespace Goo { using System; } """, true, LanguageNames.CSharp); - } [Fact] public void UsingStaticDirective() - { - TextContainsRegionOrUsing(""" + => TextContainsRegionOrUsing(""" using static System; """, true, LanguageNames.CSharp); - } [Fact] public void UsingAliasDirective() - { - TextContainsRegionOrUsing(""" + => TextContainsRegionOrUsing(""" using A = System; """, true, LanguageNames.CSharp); - } [Fact] public void ExternAlias() - { - TextContainsRegionOrUsing(""" + => TextContainsRegionOrUsing(""" extern alias Goo; """, true, LanguageNames.CSharp); - } [Fact] public void ImportsStatement() - { - TextContainsRegionOrUsing(""" + => TextContainsRegionOrUsing(""" Imports System """, true, LanguageNames.VisualBasic); - } [Fact] public void ImportsAliasStatement() - { - TextContainsRegionOrUsing(""" + => TextContainsRegionOrUsing(""" Imports A = System """, true, LanguageNames.VisualBasic); - } [Fact] public void CSharpRegion1() - { - TextContainsRegionOrUsing(""" + => TextContainsRegionOrUsing(""" #region """, true, LanguageNames.CSharp); - } [Fact] public void CSharpRegion() - { - TextContainsRegionOrUsing(""" + => TextContainsRegionOrUsing(""" #region Goo """, true, LanguageNames.CSharp); - } [Fact] public void VisualBasicRegion() - { - TextContainsRegionOrUsing(""" + => TextContainsRegionOrUsing(""" #Region Goo """, true, LanguageNames.VisualBasic); - } } diff --git a/src/EditorFeatures/Test/Utilities/SymbolEquivalenceComparerTests.cs b/src/EditorFeatures/Test/Utilities/SymbolEquivalenceComparerTests.cs index 2b3e16445508..b4c444072b09 100644 --- a/src/EditorFeatures/Test/Utilities/SymbolEquivalenceComparerTests.cs +++ b/src/EditorFeatures/Test/Utilities/SymbolEquivalenceComparerTests.cs @@ -1896,7 +1896,8 @@ public int GetHashCode(IAssemblySymbol obj) [Fact] public void CustomModifiers_Methods1() { - const string ilSource = """ + MetadataReference r1, r2; + using (var tempAssembly = IlasmUtilities.CreateTempAssembly(""" .class public C { .method public instance int32 [] modopt([mscorlib]System.Int64) F( // 0 @@ -1931,9 +1932,7 @@ .method public instance int32[] F( // 3 throw } } - """; - MetadataReference r1, r2; - using (var tempAssembly = IlasmUtilities.CreateTempAssembly(ilSource)) + """)) { var bytes = File.ReadAllBytes(tempAssembly.Path); r1 = MetadataReference.CreateFromImage(bytes); diff --git a/src/EditorFeatures/Test2/Diagnostics/UseAutoProperty/UseAutoPropertyTests.vb b/src/EditorFeatures/Test2/Diagnostics/UseAutoProperty/UseAutoPropertyTests.vb index c83f5b4f70ca..9b30c5643306 100644 --- a/src/EditorFeatures/Test2/Diagnostics/UseAutoProperty/UseAutoPropertyTests.vb +++ b/src/EditorFeatures/Test2/Diagnostics/UseAutoProperty/UseAutoPropertyTests.vb @@ -131,7 +131,7 @@ partial class C public C() { - this.P = 0; + P = 0; } }".Trim() diff --git a/src/EditorFeatures/Test2/IntelliSense/CSharpCompletionCommandHandlerTests.vb b/src/EditorFeatures/Test2/IntelliSense/CSharpCompletionCommandHandlerTests.vb index 5a12ebcc98c8..7bb5090179af 100644 --- a/src/EditorFeatures/Test2/IntelliSense/CSharpCompletionCommandHandlerTests.vb +++ b/src/EditorFeatures/Test2/IntelliSense/CSharpCompletionCommandHandlerTests.vb @@ -2929,6 +2929,39 @@ namespace B End Using End Function + + + Public Async Function CompletionEnumTypeAndValues_Escaped() As Task + Using state = TestStateFactory.CreateCSharpTestState( + +namespace A +{ + public enum Colors + { + @int, + @string + } +} +namespace B +{ + class Program + { + static void Main(A.Colors c) + { + switch (c) + { + case $$ + } + } +} ) + state.SendInvokeCompletionList() + Await state.AssertCompletionItemsContain(Function(i) i.DisplayText = "A.Colors" AndAlso i.FilterText = "Colors") + Await state.AssertCompletionItemsContain(Function(i) i.DisplayText = "A.Colors.@int" AndAlso i.FilterText = "A.Colors.@int") + Await state.AssertCompletionItemsContain(Function(i) i.DisplayText = "A.Colors.@string" AndAlso i.FilterText = "A.Colors.@string") + Await state.AssertSelectedCompletionItem("A.Colors", isHardSelected:=True) + End Using + End Function + Public Async Function CompletionEnumTypeSelectionSequenceTest() As Task @@ -11931,6 +11964,27 @@ public class C(int x) : Base(x) End Using End Function + + Public Async Function FilterPrimaryConstructorParameters_AllowInBaseTypeWhenCapturedAsMember() As Task + Using state = TestStateFactory.CreateCSharpTestState( + + , + languageVersion:=LanguageVersion.CSharp12) + + state.SendInvokeCompletionList() + Await state.AssertCompletionItemsContain("value", displayTextSuffix:="") + End Using + End Function + Public Async Function TestItemsSorted() As Task Using state = TestStateFactory.CreateCSharpTestState( @@ -12998,6 +13052,32 @@ public class Class1 End Using End Function + + + Public Async Function TestStaticExtensionMethod_OnEnumType(showCompletionInArgumentLists As Boolean) As Task + Using state = TestStateFactory.CreateCSharpTestState( + + using System; + + E.$$ + + enum E; + + static class C + { + extension(E) + { + public static void EM() { } + } + } + , + showCompletionInArgumentLists:=showCompletionInArgumentLists, languageVersion:=LanguageVersionExtensions.CSharpNext) + + state.SendInvokeCompletionList() + Await state.AssertCompletionItemsContain("EM", displayTextSuffix:="") + End Using + End Function + Public Async Function TestOverrideInstanceAssignmentOperator(showCompletionInArgumentLists As Boolean) As Task diff --git a/src/EditorFeatures/Test2/Rename/InlineRenameTests.vb b/src/EditorFeatures/Test2/Rename/InlineRenameTests.vb index 0d6e86c3b498..2013f15300b3 100644 --- a/src/EditorFeatures/Test2/Rename/InlineRenameTests.vb +++ b/src/EditorFeatures/Test2/Rename/InlineRenameTests.vb @@ -2473,5 +2473,59 @@ class [|C|] , host:=host, renameTo:="MyNewProperty") End Using End Sub + + + + Public Sub RenameClassWithAttributeName(host As RenameTestHost) + Using result = RenameEngineResult.Create(_outputHelper, + + + + + + + , host:=host, renameTo:="MyClassAttribute2") + End Using + End Sub + + + + Public Async Function RenameClassWithAttributeName2(host As RenameTestHost) As Task + Using workspace = CreateWorkspaceWithWaiter( + + + + public class [|MyClass$$Attribute|] : System.Attribute + { + public [|MyClassAttribute|]() + { + + } + } + + + , host) + + Dim session = StartSession(workspace) + + ' Type a bit in the file + Dim caretPosition = workspace.Documents.Single(Function(d) d.CursorPosition.HasValue).CursorPosition.Value + Dim textBuffer = workspace.Documents.Single().GetTextBuffer() + + textBuffer.Insert(caretPosition, "2") + + Await session.CommitAsync(previewChanges:=False, editorOperationContext:=Nothing) + + Await VerifyTagsAreCorrect(workspace) + End Using + End Function End Class End Namespace diff --git a/src/EditorFeatures/Test2/Rename/RenameEngineResult.vb b/src/EditorFeatures/Test2/Rename/RenameEngineResult.vb index 203590a2e980..a9c2be0cd3ca 100644 --- a/src/EditorFeatures/Test2/Rename/RenameEngineResult.vb +++ b/src/EditorFeatures/Test2/Rename/RenameEngineResult.vb @@ -136,14 +136,13 @@ Namespace Microsoft.CodeAnalysis.Editor.UnitTests.Rename Dim locations = Renamer.FindRenameLocationsAsync( solution, symbol, renameOptions, CancellationToken.None).GetAwaiter().GetResult() - Return locations.ResolveConflictsAsync(symbol, renameTo, nonConflictSymbolKeys:=Nothing, CancellationToken.None).GetAwaiter().GetResult() + Return locations.ResolveConflictsAsync(symbol, renameTo, CancellationToken.None).GetAwaiter().GetResult() Else ' This tests that rename properly works when the entire call is remoted to OOP and the final result is ' marshaled back. Return Renamer.RenameSymbolAsync( - solution, symbol, renameTo, renameOptions, - nonConflictSymbolKeys:=Nothing, CancellationToken.None).GetAwaiter().GetResult() + solution, symbol, renameTo, renameOptions, CancellationToken.None).GetAwaiter().GetResult() End If End Function diff --git a/src/EditorFeatures/VisualBasicTest/AddMissingImports/VisualBasicAddMissingImportsRefactoringProviderTests.vb b/src/EditorFeatures/VisualBasicTest/AddMissingImports/VisualBasicAddMissingImportsRefactoringProviderTests.vb index b64411e62bc4..f6e24f844f33 100644 --- a/src/EditorFeatures/VisualBasicTest/AddMissingImports/VisualBasicAddMissingImportsRefactoringProviderTests.vb +++ b/src/EditorFeatures/VisualBasicTest/AddMissingImports/VisualBasicAddMissingImportsRefactoringProviderTests.vb @@ -44,7 +44,7 @@ Namespace Microsoft.CodeAnalysis.AddMissingImports {GenerationOptions.SeparateImportDirectiveGroups, separateImportDirectiveGroups} } - Return TestInRegularAndScriptAsync(initialMarkup, expectedMarkup, options:=options) + Return TestInRegularAndScriptAsync(initialMarkup, expectedMarkup, New TestParameters(options:=options)) End Function diff --git a/src/EditorFeatures/VisualBasicTest/CodeActions/AbstractVisualBasicCodeActionTest.vb b/src/EditorFeatures/VisualBasicTest/CodeActions/AbstractVisualBasicCodeActionTest.vb index a9fea777402a..0a2c46ce9586 100644 --- a/src/EditorFeatures/VisualBasicTest/CodeActions/AbstractVisualBasicCodeActionTest.vb +++ b/src/EditorFeatures/VisualBasicTest/CodeActions/AbstractVisualBasicCodeActionTest.vb @@ -28,9 +28,9 @@ Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests.CodeRefactorings Dim initialMarkupStr = initialMarkup.ConvertTestSourceTag() Dim expectedStr = expected.ConvertTestSourceTag() If parseOptions Is Nothing Then - Await MyBase.TestAsync(initialMarkupStr, expectedStr, parseOptions:=_compilationOptions.ParseOptions, compilationOptions:=_compilationOptions, index:=index) + Await MyBase.TestAsync(initialMarkupStr, expectedStr, New TestParameters(parseOptions:=_compilationOptions.ParseOptions, compilationOptions:=_compilationOptions, index:=index)) Else - Await MyBase.TestAsync(initialMarkupStr, expectedStr, parseOptions:=parseOptions, compilationOptions:=_compilationOptions, index:=index) + Await MyBase.TestAsync(initialMarkupStr, expectedStr, New TestParameters(parseOptions:=parseOptions, compilationOptions:=_compilationOptions, index:=index)) End If End Function diff --git a/src/EditorFeatures/VisualBasicTest/CodeActions/AddImport/AbstractAddImportTests.vb b/src/EditorFeatures/VisualBasicTest/CodeActions/AddImport/AbstractAddImportTests.vb index d4bdeeb3cc38..e175c603d321 100644 --- a/src/EditorFeatures/VisualBasicTest/CodeActions/AddImport/AbstractAddImportTests.vb +++ b/src/EditorFeatures/VisualBasicTest/CodeActions/AddImport/AbstractAddImportTests.vb @@ -18,7 +18,7 @@ Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests.CodeActions.AddImp Optional priority As CodeActionPriority? = Nothing, Optional placeSystemFirst As Boolean = True) As Task - Await TestInRegularAndScript1Async( + Await TestInRegularAndScriptAsync( initialMarkup, expectedMarkup, index, parameters:=New TestParameters( options:=[Option](GenerationOptions.PlaceSystemNamespaceFirst, placeSystemFirst), diff --git a/src/EditorFeatures/VisualBasicTest/CodeActions/AddImport/AddImportTests.vb b/src/EditorFeatures/VisualBasicTest/CodeActions/AddImport/AddImportTests.vb index 55fc38ced3d4..922868bcac1f 100644 --- a/src/EditorFeatures/VisualBasicTest/CodeActions/AddImport/AddImportTests.vb +++ b/src/EditorFeatures/VisualBasicTest/CodeActions/AddImport/AddImportTests.vb @@ -1178,7 +1178,7 @@ End Interface" Await TestAsync( initialText, expectedText, - parseOptions:=options) + New TestParameters(parseOptions:=options)) End Function @@ -1199,7 +1199,7 @@ End Interface" Await TestAsync( initialText, expectedText, - parseOptions:=options) + New TestParameters(parseOptions:=options)) End Function @@ -1254,7 +1254,7 @@ End Module Await TestAsync( initialText, expectedText, - parseOptions:=options) + New TestParameters(parseOptions:=options)) End Function @@ -1312,7 +1312,7 @@ End Module Await TestAsync( initialText, expectedText, - parseOptions:=options) + New TestParameters(parseOptions:=options)) End Function @@ -1349,7 +1349,7 @@ End Class Await TestAsync( initialText, expectedText, - parseOptions:=options) + New TestParameters(parseOptions:=options)) End Function @@ -1866,7 +1866,7 @@ Namespace Ext End Sub End Module End Namespace", -parseOptions:=Nothing) +New TestParameters(parseOptions:=Nothing)) End Function @@ -1907,7 +1907,7 @@ Namespace Ext End Sub End Module End Namespace", -parseOptions:=Nothing) +New TestParameters(parseOptions:=Nothing)) End Function @@ -1948,7 +1948,7 @@ Namespace Ext End Sub End Module End Namespace", -parseOptions:=Nothing) +New TestParameters(parseOptions:=Nothing)) End Function @@ -1989,7 +1989,7 @@ Namespace Ext End Sub End Module End Namespace", -parseOptions:=Nothing) +New TestParameters(parseOptions:=Nothing)) End Function @@ -2030,7 +2030,7 @@ Namespace Ext End Sub End Module End Namespace", -parseOptions:=Nothing) +New TestParameters(parseOptions:=Nothing)) End Function @@ -2085,7 +2085,7 @@ Namespace Ext2 End Sub End Module End Namespace", -parseOptions:=Nothing) +New TestParameters(parseOptions:=Nothing)) End Function @@ -2140,8 +2140,7 @@ Namespace Ext2 End Sub End Module End Namespace", -index:=1, -parseOptions:=Nothing) +New TestParameters(index:=1, parseOptions:=Nothing)) End Function diff --git a/src/EditorFeatures/VisualBasicTest/CodeActions/AddImport/AddImportTests_NuGet.vb b/src/EditorFeatures/VisualBasicTest/CodeActions/AddImport/AddImportTests_NuGet.vb index 4ce41e50adf1..f14e15deac78 100644 --- a/src/EditorFeatures/VisualBasicTest/CodeActions/AddImport/AddImportTests_NuGet.vb +++ b/src/EditorFeatures/VisualBasicTest/CodeActions/AddImport/AddImportTests_NuGet.vb @@ -54,7 +54,7 @@ Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests.CodeActions.AddImp Dim packageServiceMock = New Mock(Of ISymbolSearchService)(MockBehavior.Strict) packageServiceMock.Setup(Function(s) s.FindReferenceAssembliesAsync(New TypeQuery("NuGetType", 0), It.IsAny(Of NamespaceQuery), It.IsAny(Of CancellationToken))). - Returns(Function() ValueTaskFactory.FromResult(ImmutableArray(Of ReferenceAssemblyResult).Empty)) + Returns(Function() RoslynValueTaskExtensions.FromResult(ImmutableArray(Of ReferenceAssemblyResult).Empty)) packageServiceMock.Setup(Function(s) s.FindPackagesAsync(PackageSourceHelper.NugetOrgSourceName, New TypeQuery("NuGetType", 0), It.IsAny(Of NamespaceQuery), It.IsAny(Of CancellationToken)())). Returns(Function() CreateSearchResult("NuGetPackage", "NuGetType", CreateNameParts("NuGetNamespace"))) @@ -68,7 +68,7 @@ Imports NuGetNamespace Class C Dim n As NuGetType -End Class", fixProviderData:=New ProviderData(installerServiceMock.Object, packageServiceMock.Object)) +End Class", New TestParameters(fixProviderData:=New ProviderData(installerServiceMock.Object, packageServiceMock.Object))) End Function @@ -83,7 +83,7 @@ End Class", fixProviderData:=New ProviderData(installerServiceMock.Object, packa Dim packageServiceMock = New Mock(Of ISymbolSearchService)(MockBehavior.Strict) packageServiceMock.Setup(Function(s) s.FindReferenceAssembliesAsync(New TypeQuery("NuGetType", 0), It.IsAny(Of NamespaceQuery), It.IsAny(Of CancellationToken))). - Returns(Function() ValueTaskFactory.FromResult(ImmutableArray(Of ReferenceAssemblyResult).Empty)) + Returns(Function() RoslynValueTaskExtensions.FromResult(ImmutableArray(Of ReferenceAssemblyResult).Empty)) packageServiceMock.Setup(Function(s) s.FindPackagesAsync(PackageSourceHelper.NugetOrgSourceName, New TypeQuery("NuGetType", 0), It.IsAny(Of NamespaceQuery), It.IsAny(Of CancellationToken)())). Returns(Function() CreateSearchResult("NuGetPackage", "NuGetType", CreateNameParts("NS1", "NS2"))) @@ -97,7 +97,7 @@ Imports NS1.NS2 Class C Dim n As NuGetType -End Class", fixProviderData:=New ProviderData(installerServiceMock.Object, packageServiceMock.Object)) +End Class", New TestParameters(fixProviderData:=New ProviderData(installerServiceMock.Object, packageServiceMock.Object))) End Function @@ -112,7 +112,7 @@ End Class", fixProviderData:=New ProviderData(installerServiceMock.Object, packa Dim packageServiceMock = New Mock(Of ISymbolSearchService)(MockBehavior.Strict) packageServiceMock.Setup(Function(s) s.FindReferenceAssembliesAsync(New TypeQuery("NuGetType", 0), It.IsAny(Of NamespaceQuery), It.IsAny(Of CancellationToken))). - Returns(Function() ValueTaskFactory.FromResult(ImmutableArray(Of ReferenceAssemblyResult).Empty)) + Returns(Function() RoslynValueTaskExtensions.FromResult(ImmutableArray(Of ReferenceAssemblyResult).Empty)) packageServiceMock.Setup(Function(s) s.FindPackagesAsync(PackageSourceHelper.NugetOrgSourceName, New TypeQuery("NuGetType", 0), It.IsAny(Of NamespaceQuery), It.IsAny(Of CancellationToken)())). Returns(Function() CreateSearchResult("NuGetPackage", "NuGetType", CreateNameParts("NS1", "NS2"))) @@ -124,7 +124,7 @@ End Class", " Class C Dim n As NuGetType -End Class", fixProviderData:=New ProviderData(installerServiceMock.Object, packageServiceMock.Object)) +End Class", New TestParameters(fixProviderData:=New ProviderData(installerServiceMock.Object, packageServiceMock.Object))) End Function @@ -137,7 +137,7 @@ End Class", fixProviderData:=New ProviderData(installerServiceMock.Object, packa Dim packageServiceMock = New Mock(Of ISymbolSearchService)(MockBehavior.Strict) packageServiceMock.Setup(Function(s) s.FindReferenceAssembliesAsync(New TypeQuery("NuGetType", 0), It.IsAny(Of NamespaceQuery), It.IsAny(Of CancellationToken))). - Returns(Function() ValueTaskFactory.FromResult(ImmutableArray(Of ReferenceAssemblyResult).Empty)) + Returns(Function() RoslynValueTaskExtensions.FromResult(ImmutableArray(Of ReferenceAssemblyResult).Empty)) packageServiceMock.Setup(Function(s) s.FindPackagesAsync(PackageSourceHelper.NugetOrgSourceName, New TypeQuery("NuGetType", 0), It.IsAny(Of NamespaceQuery), It.IsAny(Of CancellationToken)())). Returns(Function() CreateSearchResult("NuGetPackage", "NuGetType", CreateNameParts("NS1", "NS2"))) @@ -162,7 +162,7 @@ New TestParameters(fixProviderData:=New ProviderData(installerServiceMock.Object Dim packageServiceMock = New Mock(Of ISymbolSearchService)(MockBehavior.Strict) packageServiceMock.Setup(Function(s) s.FindReferenceAssembliesAsync(New TypeQuery("NuGetType", 0), It.IsAny(Of NamespaceQuery), It.IsAny(Of CancellationToken))). - Returns(Function() ValueTaskFactory.FromResult(ImmutableArray(Of ReferenceAssemblyResult).Empty)) + Returns(Function() RoslynValueTaskExtensions.FromResult(ImmutableArray(Of ReferenceAssemblyResult).Empty)) packageServiceMock.Setup(Function(s) s.FindPackagesAsync(PackageSourceHelper.NugetOrgSourceName, New TypeQuery("NuGetType", 0), It.IsAny(Of NamespaceQuery), It.IsAny(Of CancellationToken)())). Returns(Function() CreateSearchResult("NuGetPackage", "NuGetType", CreateNameParts("NS1", "NS2"))) @@ -204,7 +204,7 @@ parameters:=New TestParameters(index:=2, fixProviderData:=data)) Dim packageServiceMock = New Mock(Of ISymbolSearchService)(MockBehavior.Strict) packageServiceMock.Setup(Function(s) s.FindReferenceAssembliesAsync(New TypeQuery("NuGetType", 0), It.IsAny(Of NamespaceQuery), It.IsAny(Of CancellationToken))). - Returns(Function() ValueTaskFactory.FromResult(ImmutableArray(Of ReferenceAssemblyResult).Empty)) + Returns(Function() RoslynValueTaskExtensions.FromResult(ImmutableArray(Of ReferenceAssemblyResult).Empty)) packageServiceMock.Setup(Function(s) s.FindPackagesAsync(PackageSourceHelper.NugetOrgSourceName, New TypeQuery("NuGetType", 0), It.IsAny(Of NamespaceQuery), It.IsAny(Of CancellationToken)())). Returns(Function() CreateSearchResult("NuGetPackage", "NuGetType", CreateNameParts("NuGetNamespace"))) @@ -218,7 +218,7 @@ Imports NuGetNamespace Class C Dim n As NuGetType -End Class", fixProviderData:=New ProviderData(installerServiceMock.Object, packageServiceMock.Object)) +End Class", New TestParameters(fixProviderData:=New ProviderData(installerServiceMock.Object, packageServiceMock.Object))) installerServiceMock.Verify() End Function @@ -236,7 +236,7 @@ End Class", fixProviderData:=New ProviderData(installerServiceMock.Object, packa Dim packageServiceMock = New Mock(Of ISymbolSearchService)(MockBehavior.Strict) packageServiceMock.Setup(Function(s) s.FindReferenceAssembliesAsync(New TypeQuery("NuGetType", 0), It.IsAny(Of NamespaceQuery), It.IsAny(Of CancellationToken))). - Returns(Function() ValueTaskFactory.FromResult(ImmutableArray(Of ReferenceAssemblyResult).Empty)) + Returns(Function() RoslynValueTaskExtensions.FromResult(ImmutableArray(Of ReferenceAssemblyResult).Empty)) packageServiceMock.Setup(Function(s) s.FindPackagesAsync(PackageSourceHelper.NugetOrgSourceName, New TypeQuery("NuGetType", 0), It.IsAny(Of NamespaceQuery), It.IsAny(Of CancellationToken)())). Returns(Function() CreateSearchResult("NuGetPackage", "NuGetType", CreateNameParts("NuGetNamespace"))) @@ -250,7 +250,7 @@ Imports NuGetNamespace Class C Dim n As NuGetType -End Class", fixProviderData:=New ProviderData(installerServiceMock.Object, packageServiceMock.Object)) +End Class", New TestParameters(fixProviderData:=New ProviderData(installerServiceMock.Object, packageServiceMock.Object))) installerServiceMock.Verify() End Function @@ -264,7 +264,7 @@ End Class", fixProviderData:=New ProviderData(installerServiceMock.Object, packa End Function Private Shared Function CreateSearchResult(ParamArray results As PackageResult()) As ValueTask(Of ImmutableArray(Of PackageResult)) - Return ValueTaskFactory.FromResult(ImmutableArray.Create(results)) + Return RoslynValueTaskExtensions.FromResult(ImmutableArray.Create(results)) End Function Private Shared Function CreateNameParts(ParamArray parts As String()) As ImmutableArray(Of String) diff --git a/src/EditorFeatures/VisualBasicTest/CodeActions/GenerateEqualsAndGetHashCodeFromMembers/GenerateEqualsAndGetHashCodeFromMembersTests.vb b/src/EditorFeatures/VisualBasicTest/CodeActions/GenerateEqualsAndGetHashCodeFromMembers/GenerateEqualsAndGetHashCodeFromMembersTests.vb index 2adb44e0d09b..5f00bdcc3af4 100644 --- a/src/EditorFeatures/VisualBasicTest/CodeActions/GenerateEqualsAndGetHashCodeFromMembers/GenerateEqualsAndGetHashCodeFromMembersTests.vb +++ b/src/EditorFeatures/VisualBasicTest/CodeActions/GenerateEqualsAndGetHashCodeFromMembers/GenerateEqualsAndGetHashCodeFromMembersTests.vb @@ -613,7 +613,7 @@ Class Z Return (a, b).GetHashCode() End Function End Class", -index:=1, compilationOptions:=New VisualBasicCompilationOptions(OutputKind.DynamicallyLinkedLibrary, checkOverflow:=True)) +New TestParameters(index:=1, compilationOptions:=New VisualBasicCompilationOptions(OutputKind.DynamicallyLinkedLibrary, checkOverflow:=True))) End Function @@ -635,7 +635,7 @@ End Class", Return -1757793268 + a.GetHashCode() End Function End Class", -index:=1, compilationOptions:=New VisualBasicCompilationOptions(OutputKind.DynamicallyLinkedLibrary, checkOverflow:=False)) +New TestParameters(index:=1, compilationOptions:=New VisualBasicCompilationOptions(OutputKind.DynamicallyLinkedLibrary, checkOverflow:=False))) End Function diff --git a/src/EditorFeatures/VisualBasicTest/CodeActions/GenerateType/GenerateTypeTests.vb b/src/EditorFeatures/VisualBasicTest/CodeActions/GenerateType/GenerateTypeTests.vb index 9732a2e2226e..166acb0ba2df 100644 --- a/src/EditorFeatures/VisualBasicTest/CodeActions/GenerateType/GenerateTypeTests.vb +++ b/src/EditorFeatures/VisualBasicTest/CodeActions/GenerateType/GenerateTypeTests.vb @@ -121,8 +121,7 @@ End Namespace", Friend Class Bar End Class End Namespace", -index:=1, -parseOptions:=Nothing) ' Namespaces not supported in script +New TestParameters(index:=1, parseOptions:=Nothing)) ' Namespaces not supported in script End Function @@ -459,8 +458,7 @@ End Namespace", End Sub End Class End Namespace", -index:=1, -parseOptions:=Nothing) ' Namespaces not supported in script +New TestParameters(index:=1, parseOptions:=Nothing)) ' Namespaces not supported in script End Function @@ -750,8 +748,7 @@ End Namespace", Friend Class Bar End Class End Namespace", -index:=1, -parseOptions:=Nothing) ' Namespaces not supported in script +New TestParameters(index:=1, parseOptions:=Nothing)) ' Namespaces not supported in script End Function @@ -1430,8 +1427,8 @@ Friend Class T End Sub End Class .NormalizedValue, -index:=1, -options:=[Option](CodeStyleOptions2.PreferIntrinsicPredefinedTypeKeywordInDeclaration, False, NotificationOption2.Error)) +New TestParameters(index:=1, +options:=[Option](CodeStyleOptions2.PreferIntrinsicPredefinedTypeKeywordInDeclaration, False, NotificationOption2.Error))) End Function @@ -1845,8 +1842,7 @@ Friend Class D _i = i End Sub End Class -", - index:=1, options:=options.FieldNamesAreCamelCaseWithUnderscorePrefix) +", New TestParameters(index:=1, options:=options.FieldNamesAreCamelCaseWithUnderscorePrefix)) End Function Public Class AddImportTestsWithAddImportDiagnosticProvider diff --git a/src/EditorFeatures/VisualBasicTest/CodeActions/InitializeParameter/AddParameterCheckTests.vb b/src/EditorFeatures/VisualBasicTest/CodeActions/InitializeParameter/AddParameterCheckTests.vb index 76aefb0ad312..9b09c4c9c5d5 100644 --- a/src/EditorFeatures/VisualBasicTest/CodeActions/InitializeParameter/AddParameterCheckTests.vb +++ b/src/EditorFeatures/VisualBasicTest/CodeActions/InitializeParameter/AddParameterCheckTests.vb @@ -18,7 +18,7 @@ Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests.InitializeParamete Public Async Function TestSimpleReferenceType() As Task - Await TestInRegularAndScript1Async( + Await TestInRegularAndScriptAsync( " Imports System @@ -40,7 +40,7 @@ end class") Public Async Function TestNullable() As Task - Await TestInRegularAndScript1Async( + Await TestInRegularAndScriptAsync( " Imports System @@ -62,7 +62,7 @@ end class") Public Async Function TestOnByRefParameter() As Task - Await TestInRegularAndScript1Async( + Await TestInRegularAndScriptAsync( " class C public sub new([||]byref s as string) @@ -82,7 +82,7 @@ end class") Public Async Function TestOnOutByRefParameter() As Task - Await TestInRegularAndScript1Async( + Await TestInRegularAndScriptAsync( " Imports System.Runtime.InteropServices class C @@ -137,7 +137,7 @@ end class") Public Async Function TestDoNotUpdateExistingFieldAssignment() As Task - Await TestInRegularAndScript1Async( + Await TestInRegularAndScriptAsync( " Imports System @@ -166,7 +166,7 @@ end class") Public Async Function TestDoNotUpdateExistingPropertyAssignment() As Task - Await TestInRegularAndScript1Async( + Await TestInRegularAndScriptAsync( " Imports System @@ -195,7 +195,7 @@ end class") Public Async Function TestInsertAfterExistingNullCheck1() As Task - Await TestInRegularAndScript1Async( + Await TestInRegularAndScriptAsync( " Imports System @@ -222,7 +222,7 @@ end class") Public Async Function TestInsertBeforeExistingNullCheck1() As Task - Await TestInRegularAndScript1Async( + Await TestInRegularAndScriptAsync( " Imports System @@ -309,7 +309,7 @@ end class") Public Async Function TestInMethod() As Task - Await TestInRegularAndScript1Async( + Await TestInRegularAndScriptAsync( " Imports System @@ -331,7 +331,7 @@ end class") Public Async Function TestOnMultiLineSubLambdaParameter() As Task - Await TestInRegularAndScript1Async( + Await TestInRegularAndScriptAsync( " Imports System @@ -357,7 +357,7 @@ end class") Public Async Function TestOnMultiLineFunctionLambdaParameter() As Task - Await TestInRegularAndScript1Async( + Await TestInRegularAndScriptAsync( " Imports System @@ -386,7 +386,7 @@ end class") Public Async Function TestOnSingleLineSubLambdaParameter() As Task - Await TestInRegularAndScript1Async( + Await TestInRegularAndScriptAsync( " Imports System @@ -413,7 +413,7 @@ end class") Public Async Function TestOnSingleLineFunctionLambdaParameter() As Task - Await TestInRegularAndScript1Async( + Await TestInRegularAndScriptAsync( " Imports System @@ -464,7 +464,7 @@ end class") Public Async Function TestSpecialStringCheck1() As Task - Await TestInRegularAndScript1Async( + Await TestInRegularAndScriptAsync( " Imports System @@ -486,7 +486,7 @@ end class", index:=1) Public Async Function TestSpecialStringCheck2() As Task - Await TestInRegularAndScript1Async( + Await TestInRegularAndScriptAsync( " Imports System @@ -513,7 +513,7 @@ end class", index:=2) Try CultureInfo.CurrentUICulture = New CultureInfo("de-DE", useUserOverride:=False) - Await TestInRegularAndScript1Async( + Await TestInRegularAndScriptAsync( " Imports System @@ -538,7 +538,7 @@ end class", index:=1) Public Async Function TestMultiNullableParameters() As Task - Await TestInRegularAndScript1Async( + Await TestInRegularAndScriptAsync( " Imports System @@ -568,7 +568,7 @@ end class", index:=3) Public Async Function TestMultiNullableWithCursorOnNonNullable() As Task - Await TestInRegularAndScript1Async( + Await TestInRegularAndScriptAsync( " Imports System @@ -594,7 +594,7 @@ end class", index:=0) Public Async Function TestSimpleReferenceTypeWithParameterNameSelected1() As Task - Await TestInRegularAndScript1Async( + Await TestInRegularAndScriptAsync( " Imports System @@ -627,7 +627,7 @@ End Class") Public Async Function TestImportSystem() As Task - Await TestInRegularAndScript1Async( + Await TestInRegularAndScriptAsync( " Class C Sub M([||]s As String) diff --git a/src/EditorFeatures/VisualBasicTest/CodeActions/InitializeParameter/InitializeMemberFromParameterTests.vb b/src/EditorFeatures/VisualBasicTest/CodeActions/InitializeParameter/InitializeMemberFromParameterTests.vb index 539f22a50b1a..401c0692bf25 100644 --- a/src/EditorFeatures/VisualBasicTest/CodeActions/InitializeParameter/InitializeMemberFromParameterTests.vb +++ b/src/EditorFeatures/VisualBasicTest/CodeActions/InitializeParameter/InitializeMemberFromParameterTests.vb @@ -19,7 +19,7 @@ Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests.InitializeParamete Public Async Function TestInitializeFieldWithSameName() As Task - Await TestInRegularAndScript1Async( + Await TestInRegularAndScriptAsync( " class C private s As String @@ -41,7 +41,7 @@ end class") Public Async Function TestEndOfParameter1() As Task - Await TestInRegularAndScript1Async( + Await TestInRegularAndScriptAsync( " class C private s As String @@ -63,7 +63,7 @@ end class") Public Async Function TestEndOfParameter2() As Task - Await TestInRegularAndScript1Async( + Await TestInRegularAndScriptAsync( " class C private s As String @@ -84,7 +84,7 @@ end class") Public Async Function TestInitializeFieldWithUnderscoreName() As Task - Await TestInRegularAndScript1Async( + Await TestInRegularAndScriptAsync( " class C private _s As String @@ -105,7 +105,7 @@ end class") Public Async Function TestInitializeWritableProperty() As Task - Await TestInRegularAndScript1Async( + Await TestInRegularAndScriptAsync( " class C Private ReadOnly property S As String @@ -171,7 +171,7 @@ end class") Public Async Function TestInitializeFieldWithWrongType1() As Task - Await TestInRegularAndScript1Async( + Await TestInRegularAndScriptAsync( " class C private s As Integer @@ -194,7 +194,7 @@ end class") Public Async Function TestInitializeFieldWithWrongType2() As Task - Await TestInRegularAndScript1Async( + Await TestInRegularAndScriptAsync( " class C private s As Integer @@ -252,7 +252,7 @@ end class") Public Async Function TestWhenAlreadyInitialized3() As Task - Await TestInRegularAndScript1Async( + Await TestInRegularAndScriptAsync( " class C @@ -278,7 +278,7 @@ end class") Public Async Function TestInsertionLocation1() As Task - Await TestInRegularAndScript1Async( + Await TestInRegularAndScriptAsync( " class C @@ -304,7 +304,7 @@ end class") Public Async Function TestInsertionLocation2() As Task - Await TestInRegularAndScript1Async( + Await TestInRegularAndScriptAsync( " class C private s As String @@ -328,7 +328,7 @@ end class") Public Async Function TestInsertionLocation3() As Task - Await TestInRegularAndScript1Async( + Await TestInRegularAndScriptAsync( " class C @@ -370,7 +370,7 @@ end class") Public Async Function TestInsertionLocation6() As Task - Await TestInRegularAndScript1Async( + Await TestInRegularAndScriptAsync( " class C public sub new(s As String, [||]t As String) @@ -394,7 +394,7 @@ end class") Public Async Function TestInsertionLocation7() As Task - Await TestInRegularAndScript1Async( + Await TestInRegularAndScriptAsync( " class C public sub new([||]s As String, t As String) @@ -417,7 +417,7 @@ end class") Public Async Function TestInitializeFieldWithParameterNameSelected1() As Task - Await TestInRegularAndScript1Async( + Await TestInRegularAndScriptAsync( " class C private s As String @@ -438,7 +438,7 @@ end class") Public Async Function TestInitializeFieldWithParameterNameSelected2() As Task - Await TestInRegularAndScript1Async( + Await TestInRegularAndScriptAsync( " class C private s As String @@ -459,7 +459,7 @@ end class") Public Async Function TestInitializeClassProperty_RequiredAccessibilityOmitIfDefault() As Task - Await TestInRegularAndScript1Async(" + Await TestInRegularAndScriptAsync(" Class C ReadOnly test As Integer = 5 @@ -481,7 +481,7 @@ End Class Public Async Function TestInitializeClassProperty_RequiredAccessibilityNever() As Task - Await TestInRegularAndScript1Async(" + Await TestInRegularAndScriptAsync(" Class C ReadOnly test As Integer = 5 @@ -503,7 +503,7 @@ End Class Public Async Function TestInitializeClassProperty_RequiredAccessibilityAlways() As Task - Await TestInRegularAndScript1Async(" + Await TestInRegularAndScriptAsync(" Class C ReadOnly test As Integer = 5 @@ -525,7 +525,7 @@ End Class Public Async Function TestInitializeClassField_RequiredAccessibilityOmitIfDefault() As Task - Await TestInRegularAndScript1Async(" + Await TestInRegularAndScriptAsync(" Class C ReadOnly test As Integer = 5 @@ -546,7 +546,7 @@ End Class Public Async Function TestInitializeClassField_RequiredAccessibilityNever() As Task - Await TestInRegularAndScript1Async(" + Await TestInRegularAndScriptAsync(" Class C ReadOnly test As Integer = 5 @@ -567,7 +567,7 @@ End Class Public Async Function TestInitializeClassField_RequiredAccessibilityAlways() As Task - Await TestInRegularAndScript1Async(" + Await TestInRegularAndScriptAsync(" Class C ReadOnly test As Integer = 5 @@ -588,7 +588,7 @@ End Class Public Async Function TestInitializeStructProperty_RequiredAccessibilityOmitIfDefault() As Task - Await TestInRegularAndScript1Async(" + Await TestInRegularAndScriptAsync(" Structure S Public Sub New(ByVal [|test|] As Integer) End Sub @@ -606,7 +606,7 @@ End Structure Public Async Function TestInitializeStructProperty_RequiredAccessibilityNever() As Task - Await TestInRegularAndScript1Async(" + Await TestInRegularAndScriptAsync(" Structure S Public Sub New(ByVal [|test|] As Integer) End Sub @@ -624,7 +624,7 @@ End Structure Public Async Function TestInitializeStructProperty_RequiredAccessibilityAlways() As Task - Await TestInRegularAndScript1Async(" + Await TestInRegularAndScriptAsync(" Structure S Public Sub New(ByVal [|test|] As Integer) End Sub @@ -642,7 +642,7 @@ End Structure Public Async Function TestInitializeStructField_RequiredAccessibilityOmitIfDefault() As Task - Await TestInRegularAndScript1Async(" + Await TestInRegularAndScriptAsync(" Structure S Public Sub New(ByVal [|test|] As Integer) End Sub @@ -660,7 +660,7 @@ End Structure Public Async Function TestInitializeStructField_RequiredAccessibilityNever() As Task - Await TestInRegularAndScript1Async(" + Await TestInRegularAndScriptAsync(" Structure S Public Sub New(ByVal [|test|] As Integer) End Sub @@ -678,7 +678,7 @@ End Structure Public Async Function TestInitializeStructField_RequiredAccessibilityAlways() As Task - Await TestInRegularAndScript1Async(" + Await TestInRegularAndScriptAsync(" Structure S Public Sub New(ByVal [|test|] As Integer) End Sub @@ -696,7 +696,7 @@ End Structure Public Async Function TestGenerateRemainingFields1() As Task - Await TestInRegularAndScript1Async( + Await TestInRegularAndScriptAsync( " class C public sub new([||]i as integer, j as integer, k as integer) @@ -718,7 +718,7 @@ end class", index:=3) Public Async Function TestGenerateRemainingFields2() As Task - Await TestInRegularAndScript1Async( + Await TestInRegularAndScriptAsync( " class C Private ReadOnly i As Integer @@ -743,7 +743,7 @@ end class", index:=2) Public Async Function TestGenerateRemainingFields3() As Task - Await TestInRegularAndScript1Async( + Await TestInRegularAndScriptAsync( " class C Private ReadOnly j As Integer @@ -768,7 +768,7 @@ end class", index:=2) Public Async Function TestGenerateRemainingFields4() As Task - Await TestInRegularAndScript1Async( + Await TestInRegularAndScriptAsync( " class C Private ReadOnly k As Integer @@ -793,7 +793,7 @@ end class", index:=2) Public Async Function TestGenerateRemainingProperties1() As Task - Await TestInRegularAndScript1Async( + Await TestInRegularAndScriptAsync( " class C public sub new([||]i as integer, j as integer, k as integer) @@ -815,7 +815,7 @@ end class", index:=2) Public Async Function TestGenerateRemainingProperties2() As Task - Await TestInRegularAndScript1Async( + Await TestInRegularAndScriptAsync( " class C Private ReadOnly i As Integer @@ -841,7 +841,7 @@ end class", index:=3) Public Async Function TestGenerateRemainingProperties3() As Task - Await TestInRegularAndScript1Async( + Await TestInRegularAndScriptAsync( " class C Private ReadOnly j As Integer @@ -867,7 +867,7 @@ end class", index:=3) Public Async Function TestGenerateRemainingProperties4() As Task - Await TestInRegularAndScript1Async( + Await TestInRegularAndScriptAsync( " class C Private ReadOnly k As Integer @@ -893,7 +893,7 @@ end class", index:=3) Public Async Function TestInitializeThrowingProperty1() As Task - Await TestInRegularAndScript1Async( + Await TestInRegularAndScriptAsync( " imports System @@ -925,7 +925,7 @@ end class") Public Async Function TestInitializeThrowingProperty2() As Task - Await TestInRegularAndScript1Async( + Await TestInRegularAndScriptAsync( " imports System @@ -962,7 +962,7 @@ end class") Public Async Function TestInitializeThrowingProperty3() As Task - Await TestInRegularAndScript1Async( + Await TestInRegularAndScriptAsync( " imports System diff --git a/src/EditorFeatures/VisualBasicTest/Diagnostics/AbstractVisualBasicDiagnosticProviderBasedUserDiagnosticTest.vb b/src/EditorFeatures/VisualBasicTest/Diagnostics/AbstractVisualBasicDiagnosticProviderBasedUserDiagnosticTest.vb index bf99aaf26ab6..a33e06cd0ed5 100644 --- a/src/EditorFeatures/VisualBasicTest/Diagnostics/AbstractVisualBasicDiagnosticProviderBasedUserDiagnosticTest.vb +++ b/src/EditorFeatures/VisualBasicTest/Diagnostics/AbstractVisualBasicDiagnosticProviderBasedUserDiagnosticTest.vb @@ -31,9 +31,11 @@ Namespace Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests.Diagnostics Dim initialMarkupStr = initialMarkup.ConvertTestSourceTag() Dim expectedStr = expected.ConvertTestSourceTag() - Await MyBase.TestAsync(initialMarkupStr, expectedStr, - parseOptions:=_compilationOptions.ParseOptions, compilationOptions:=_compilationOptions, - index:=index) + Await MyBase.TestAsync( + initialMarkupStr, expectedStr, + New TestParameters( + parseOptions:=_compilationOptions.ParseOptions, compilationOptions:=_compilationOptions, + index:=index)) End Function Protected Overloads Async Function TestMissingAsync(initialMarkup As XElement) As Task diff --git a/src/ExpressionEvaluator/CSharp/Test/ResultProvider/ResultProviderTests.cs b/src/ExpressionEvaluator/CSharp/Test/ResultProvider/ResultProviderTests.cs index 1f71fa8bd717..8c38fc444130 100644 --- a/src/ExpressionEvaluator/CSharp/Test/ResultProvider/ResultProviderTests.cs +++ b/src/ExpressionEvaluator/CSharp/Test/ResultProvider/ResultProviderTests.cs @@ -15,7 +15,7 @@ public class ResultProviderTests [Fact] public void DkmEvaluationFlagsConflict() { - var values = Enum.GetValues(typeof(DkmEvaluationFlags)).Cast().ToArray(); + var values = Enum.GetValues(); Assert.False(values.Contains(ResultProvider.NoResults)); Assert.False(values.Contains(ResultProvider.NotRoot)); } diff --git a/src/ExpressionEvaluator/Core/Source/FunctionResolver/Microsoft.CodeAnalysis.FunctionResolver.csproj b/src/ExpressionEvaluator/Core/Source/FunctionResolver/Microsoft.CodeAnalysis.FunctionResolver.csproj index b7473a46847a..088aa971be4a 100644 --- a/src/ExpressionEvaluator/Core/Source/FunctionResolver/Microsoft.CodeAnalysis.FunctionResolver.csproj +++ b/src/ExpressionEvaluator/Core/Source/FunctionResolver/Microsoft.CodeAnalysis.FunctionResolver.csproj @@ -8,7 +8,7 @@ true netstandard2.0 true - $(DefineConstants);MICROSOFT_CODEANALYSIS_CONTRACTS_NO_ERROR_REPORTING + $(DefineConstants);MICROSOFT_CODEANALYSIS_CONTRACTS_NO_ERROR_REPORTING;MICROSOFT_CODEANALYSIS_CONTRACTS_NO_VALUE_TASK - $(DefineConstants);MICROSOFT_CODEANALYSIS_POOLEDOBJECTS_NO_POOLED_DISPOSER + $(DefineConstants);MICROSOFT_CODEANALYSIS_POOLEDOBJECTS_NO_POOLED_DISPOSER;MICROSOFT_CODEANALYSIS_CONTRACTS_NO_VALUE_TASK - $(DefineConstants);MICROSOFT_CODEANALYSIS_POOLEDOBJECTS_NO_POOLED_DISPOSER + $(DefineConstants);MICROSOFT_CODEANALYSIS_POOLEDOBJECTS_NO_POOLED_DISPOSER;MICROSOFT_CODEANALYSIS_CONTRACTS_NO_VALUE_TASK + diff --git a/src/LanguageServer/Microsoft.CodeAnalysis.LanguageServer.UnitTests/VirtualProjectXmlProviderTests.cs b/src/LanguageServer/Microsoft.CodeAnalysis.LanguageServer.UnitTests/VirtualProjectXmlProviderTests.cs index 09b63ac338ae..b4809eb519cd 100644 --- a/src/LanguageServer/Microsoft.CodeAnalysis.LanguageServer.UnitTests/VirtualProjectXmlProviderTests.cs +++ b/src/LanguageServer/Microsoft.CodeAnalysis.LanguageServer.UnitTests/VirtualProjectXmlProviderTests.cs @@ -48,7 +48,7 @@ private async Task GetProjectXmlProviderAsync() return exportProvider.GetExportedValue(); } - [Fact] + [Fact(Skip = "https://github.com/dotnet/roslyn/issues/79464")] public async Task GetProjectXml_FileBasedProgram_SdkTooOld_01() { var projectProvider = await GetProjectXmlProviderAsync(); diff --git a/src/LanguageServer/Microsoft.CodeAnalysis.LanguageServer/Program.cs b/src/LanguageServer/Microsoft.CodeAnalysis.LanguageServer/Program.cs index a0660a5fe484..435c54303a75 100644 --- a/src/LanguageServer/Microsoft.CodeAnalysis.LanguageServer/Program.cs +++ b/src/LanguageServer/Microsoft.CodeAnalysis.LanguageServer/Program.cs @@ -32,8 +32,15 @@ WindowsErrorReporting.SetErrorModeOnWindows(); -var parser = CreateCommandLineParser(); -return await parser.Parse(args).InvokeAsync(CancellationToken.None); +var command = CreateCommand(); +var invocationConfiguration = new InvocationConfiguration() +{ + // By default, System.CommandLine will catch all exceptions, log them to the console, and return a non-zero exit code. + // Unfortunately this makes .NET's crash dump collection environment variables (e.g. 'DOTNET_DbgEnableMiniDump') + // entirely useless as it never detects an actual crash. Disable this behavior so we can collect crash dumps when asked to. + EnableDefaultExceptionHandler = false +}; +return await command.Parse(args).InvokeAsync(invocationConfiguration, CancellationToken.None); static async Task RunAsync(ServerConfiguration serverConfiguration, CancellationToken cancellationToken) { @@ -167,7 +174,7 @@ static async Task RunAsync(ServerConfiguration serverConfiguration, Cancellation } } -static CommandLineConfiguration CreateCommandLineParser() +static RootCommand CreateCommand() { var debugOption = new Option("--debug") { @@ -294,15 +301,7 @@ static CommandLineConfiguration CreateCommandLineParser() return RunAsync(serverConfiguration, cancellationToken); }); - var config = new CommandLineConfiguration(rootCommand) - { - // By default, System.CommandLine will catch all exceptions, log them to the console, and return a non-zero exit code. - // Unfortunately this makes .NET's crash dump collection environment variables (e.g. 'DOTNET_DbgEnableMiniDump') - // entirely useless as it never detects an actual crash. Disable this behavior so we can collect crash dumps when asked to. - EnableDefaultExceptionHandler = false - }; - - return config; + return rootCommand; } static (string clientPipe, string serverPipe) CreateNewPipeNames() diff --git a/src/LanguageServer/Microsoft.CommonLanguageServerProtocol.Framework/Microsoft.CommonLanguageServerProtocol.Framework.Shared.projitems b/src/LanguageServer/Microsoft.CommonLanguageServerProtocol.Framework/Microsoft.CommonLanguageServerProtocol.Framework.Shared.projitems index dd8785f1ae8f..42be1c0d315c 100644 --- a/src/LanguageServer/Microsoft.CommonLanguageServerProtocol.Framework/Microsoft.CommonLanguageServerProtocol.Framework.Shared.projitems +++ b/src/LanguageServer/Microsoft.CommonLanguageServerProtocol.Framework/Microsoft.CommonLanguageServerProtocol.Framework.Shared.projitems @@ -9,37 +9,6 @@ Microsoft.CommonLanguageServerProtocol.Framework.Shared - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + \ No newline at end of file diff --git a/src/LanguageServer/Protocol.TestUtilities/LanguageServer/AbstractLanguageServerProtocolTests.cs b/src/LanguageServer/Protocol.TestUtilities/LanguageServer/AbstractLanguageServerProtocolTests.cs index 2db0568718b2..9de1171a566a 100644 --- a/src/LanguageServer/Protocol.TestUtilities/LanguageServer/AbstractLanguageServerProtocolTests.cs +++ b/src/LanguageServer/Protocol.TestUtilities/LanguageServer/AbstractLanguageServerProtocolTests.cs @@ -644,14 +644,25 @@ protected virtual RoslynLanguageServer CreateLanguageServer(Stream inputStream, public async Task GetDocumentAsync(DocumentUri uri) { - var document = await GetCurrentSolution().GetDocumentAsync(new LSP.TextDocumentIdentifier { DocumentUri = uri }, CancellationToken.None).ConfigureAwait(false); + var textDocument = await GetTextDocumentAsync(uri).ConfigureAwait(false); + if (textDocument is not Document document) + { + throw new InvalidOperationException($"Found TextDocument with {uri} in solution, but it is not a Document"); + } + + return document; + } + + public async Task GetTextDocumentAsync(DocumentUri uri) + { + var document = await GetCurrentSolution().GetTextDocumentAsync(new LSP.TextDocumentIdentifier { DocumentUri = uri }, CancellationToken.None).ConfigureAwait(false); Contract.ThrowIfNull(document, $"Unable to find document with {uri} in solution"); return document; } public async Task GetDocumentTextAsync(DocumentUri uri) { - var document = await GetDocumentAsync(uri).ConfigureAwait(false); + var document = await GetTextDocumentAsync(uri).ConfigureAwait(false); return await document.GetTextAsync(CancellationToken.None).ConfigureAwait(false); } diff --git a/src/LanguageServer/Protocol.TestUtilities/Workspaces/LspTestWorkspace.cs b/src/LanguageServer/Protocol.TestUtilities/Workspaces/LspTestWorkspace.cs index ee99173ddc33..1623033092eb 100644 --- a/src/LanguageServer/Protocol.TestUtilities/Workspaces/LspTestWorkspace.cs +++ b/src/LanguageServer/Protocol.TestUtilities/Workspaces/LspTestWorkspace.cs @@ -40,7 +40,7 @@ ValueTask ILspWorkspace.UpdateTextIfPresentAsync(DocumentId documentId, SourceTe { Contract.ThrowIfFalse(_supportsLspMutation); OnDocumentTextChanged(documentId, sourceText, PreservationMode.PreserveIdentity, requireDocumentPresent: false); - return ValueTaskFactory.CompletedTask; + return ValueTask.CompletedTask; } internal override ValueTask TryOnDocumentClosedAsync(DocumentId documentId, CancellationToken cancellationToken) diff --git a/src/LanguageServer/Protocol/Features/CodeCleanup/AbstractCodeCleanupService.cs b/src/LanguageServer/Protocol/Features/CodeCleanup/AbstractCodeCleanupService.cs index 9ab56fa471c3..3b9d7f710486 100644 --- a/src/LanguageServer/Protocol/Features/CodeCleanup/AbstractCodeCleanupService.cs +++ b/src/LanguageServer/Protocol/Features/CodeCleanup/AbstractCodeCleanupService.cs @@ -17,7 +17,6 @@ using Microsoft.CodeAnalysis.RemoveUnnecessaryImports; using Microsoft.CodeAnalysis.Shared.Extensions; using Microsoft.CodeAnalysis.Text; -using Roslyn.Utilities; namespace Microsoft.CodeAnalysis.CodeCleanup; @@ -103,22 +102,39 @@ public async Task CleanupAsync( private static async Task RemoveSortUsingsAsync( Document document, OrganizeUsingsSet organizeUsingsSet, CancellationToken cancellationToken) { - if (organizeUsingsSet.IsRemoveUnusedImportEnabled && - document.GetLanguageService() is { } removeUsingsService) + if (organizeUsingsSet.IsRemoveUnusedImportEnabled) { using (Logger.LogBlock(FunctionId.CodeCleanup_RemoveUnusedImports, cancellationToken)) { - var formattingOptions = await document.GetSyntaxFormattingOptionsAsync(cancellationToken).ConfigureAwait(false); - document = await removeUsingsService.RemoveUnnecessaryImportsAsync(document, cancellationToken).ConfigureAwait(false); + // The compiler reports any usings/imports it didn't think were used. Regardless of the state of + // the code in the file. For example, if there are major parse errors, it can end up causing + // many usings to seem unused simply because the compiler isn't actually able to determine the + // meaning of all the code. Similarly, in scenarios where there may be a bunch of disabled code + // (like when merge markers are introduced) this can happen as well. + // + // For the normal editing experience, this is not a huge deal. The usings/imports may fade, + // but they'll stay around unless the user goes out of the way to remove them. That's not the case + // for code-cleanup, which may run automatically on actions like 'save'. As such, we don't + // remove usings in that case if we see that there are major issues in the file (like syntactic + // diagnostics). + var root = await document.GetRequiredSyntaxRootAsync(cancellationToken).ConfigureAwait(false); + if (!root.GetDiagnostics().Any(d => d.Severity == DiagnosticSeverity.Error)) + { + var formattingOptions = await document.GetSyntaxFormattingOptionsAsync(cancellationToken).ConfigureAwait(false); + + var removeUsingsService = document.GetRequiredLanguageService(); + document = await removeUsingsService.RemoveUnnecessaryImportsAsync(document, cancellationToken).ConfigureAwait(false); + } } } - if (organizeUsingsSet.IsSortImportsEnabled && - document.GetLanguageService() is { } organizeImportsService) + if (organizeUsingsSet.IsSortImportsEnabled) { using (Logger.LogBlock(FunctionId.CodeCleanup_SortImports, cancellationToken)) { var organizeOptions = await document.GetOrganizeImportsOptionsAsync(cancellationToken).ConfigureAwait(false); + + var organizeImportsService = document.GetRequiredLanguageService(); document = await organizeImportsService.OrganizeImportsAsync(document, organizeOptions, cancellationToken).ConfigureAwait(false); } } diff --git a/src/LanguageServer/Protocol/Features/EditAndContinue/EditAndContinueDiagnosticSource_OpenDocument.cs b/src/LanguageServer/Protocol/Features/EditAndContinue/EditAndContinueDiagnosticSource_OpenDocument.cs index be5413ebdeff..c4b2b704f4e9 100644 --- a/src/LanguageServer/Protocol/Features/EditAndContinue/EditAndContinueDiagnosticSource_OpenDocument.cs +++ b/src/LanguageServer/Protocol/Features/EditAndContinue/EditAndContinueDiagnosticSource_OpenDocument.cs @@ -52,7 +52,7 @@ public override async Task> GetDiagnosticsAsync(R var activeStatementSpanProvider = spanLocator != null ? new ActiveStatementSpanProvider((documentId, filePath, cancellationToken) => spanLocator.GetSpansAsync(compileTimeSolution, documentId, filePath, cancellationToken)) - : static (_, _, _) => ValueTaskFactory.FromResult(ImmutableArray.Empty); + : static (_, _, _) => ValueTask.FromResult(ImmutableArray.Empty); var rudeEditDiagnostics = await proxy.GetDocumentDiagnosticsAsync(compileTimeDocument, activeStatementSpanProvider, cancellationToken).ConfigureAwait(false); diff --git a/src/LanguageServer/Protocol/Handler/AbstractRefreshQueue.cs b/src/LanguageServer/Protocol/Handler/AbstractRefreshQueue.cs index 8f917bdf6c16..436a66f1f83f 100644 --- a/src/LanguageServer/Protocol/Handler/AbstractRefreshQueue.cs +++ b/src/LanguageServer/Protocol/Handler/AbstractRefreshQueue.cs @@ -128,7 +128,7 @@ private ValueTask FilterLspTrackedDocumentsAsync( } // LSP is already tracking all changed documents so we don't need to send a refresh request. - return ValueTaskFactory.CompletedTask; + return ValueTask.CompletedTask; } public virtual void Dispose() diff --git a/src/LanguageServer/Protocol/Handler/Diagnostics/AbstractDocumentPullDiagnosticHandler.cs b/src/LanguageServer/Protocol/Handler/Diagnostics/AbstractDocumentPullDiagnosticHandler.cs index a6ac09fcfea3..aa35b9581370 100644 --- a/src/LanguageServer/Protocol/Handler/Diagnostics/AbstractDocumentPullDiagnosticHandler.cs +++ b/src/LanguageServer/Protocol/Handler/Diagnostics/AbstractDocumentPullDiagnosticHandler.cs @@ -35,7 +35,7 @@ protected override ValueTask> GetOrderedDiagno // Only consider open documents here (and only closed ones in the WorkspacePullDiagnosticHandler). Each // handler treats those as separate worlds that they are responsible for. var identifier = GetTextDocumentIdentifier(diagnosticsParams); - if (identifier is null || context.Document is null) + if (identifier is null || context.TextDocument is null) { context.TraceDebug("Ignoring diagnostics request because no text document was provided"); return new([]); diff --git a/src/LanguageServer/Protocol/Handler/References/FindUsagesLSPContext.cs b/src/LanguageServer/Protocol/Handler/References/FindUsagesLSPContext.cs index debd21015697..7998035ba6d0 100644 --- a/src/LanguageServer/Protocol/Handler/References/FindUsagesLSPContext.cs +++ b/src/LanguageServer/Protocol/Handler/References/FindUsagesLSPContext.cs @@ -372,6 +372,6 @@ private ValueTask ReportReferencesAsync(ImmutableSegmentedList solution.GetRequiredDocument(id).FilePath).WhereNotNull()], }); - return ValueTaskFactory.CompletedTask; + return ValueTask.CompletedTask; }, cancellationToken).ConfigureAwait(false); diff --git a/src/LanguageServer/Protocol/Handler/Rename/RenameHandler.cs b/src/LanguageServer/Protocol/Handler/Rename/RenameHandler.cs index 5f4062dfd243..186c0218cfda 100644 --- a/src/LanguageServer/Protocol/Handler/Rename/RenameHandler.cs +++ b/src/LanguageServer/Protocol/Handler/Rename/RenameHandler.cs @@ -54,9 +54,7 @@ internal sealed class RenameHandler() : ILspServiceDocumentRequestHandler IsMiscellaneousFilesDocumentAsync(TextDocument document, CancellationToken cancellationToken) { // In this case, the only documents ever created live in the Miscellaneous Files workspace (which is this object directly), so we can just compare to 'this'. - return ValueTaskFactory.FromResult(document.Project.Solution.Workspace == this); + return ValueTask.FromResult(document.Project.Solution.Workspace == this); } /// @@ -44,7 +44,7 @@ public ValueTask IsMiscellaneousFilesDocumentAsync(TextDocument document, /// from LSP text sync request handling which do not run concurrently. /// public ValueTask AddMiscellaneousDocumentAsync(DocumentUri uri, SourceText documentText, string languageId, ILspLogger logger) - => ValueTaskFactory.FromResult(AddMiscellaneousDocument(uri, documentText, languageId, logger)); + => ValueTask.FromResult(AddMiscellaneousDocument(uri, documentText, languageId, logger)); private TextDocument? AddMiscellaneousDocument(DocumentUri uri, SourceText documentText, string languageId, ILspLogger logger) { @@ -97,7 +97,7 @@ public ValueTask TryRemoveMiscellaneousDocumentAsync(DocumentUri uri, bool remov { if (removeFromMetadataWorkspace && uri.ParsedUri is not null && metadataAsSourceFileService.TryRemoveDocumentFromWorkspace(ProtocolConversions.GetDocumentFilePathFromUri(uri.ParsedUri))) { - return ValueTaskFactory.CompletedTask; + return ValueTask.CompletedTask; } // We'll only ever have a single document matching this URI in the misc solution. @@ -119,13 +119,13 @@ public ValueTask TryRemoveMiscellaneousDocumentAsync(DocumentUri uri, bool remov OnProjectRemoved(project.Id); } - return ValueTaskFactory.CompletedTask; + return ValueTask.CompletedTask; } public ValueTask UpdateTextIfPresentAsync(DocumentId documentId, SourceText sourceText, CancellationToken cancellationToken) { this.OnDocumentTextChanged(documentId, sourceText, PreservationMode.PreserveIdentity, requireDocumentPresent: false); - return ValueTaskFactory.CompletedTask; + return ValueTask.CompletedTask; } private sealed class StaticSourceTextContainer(SourceText text) : SourceTextContainer diff --git a/src/LanguageServer/ProtocolUnitTests/Diagnostics/AbstractPullDiagnosticTestsBase.cs b/src/LanguageServer/ProtocolUnitTests/Diagnostics/AbstractPullDiagnosticTestsBase.cs index c4025e83d9ff..82ac970ee9e6 100644 --- a/src/LanguageServer/ProtocolUnitTests/Diagnostics/AbstractPullDiagnosticTestsBase.cs +++ b/src/LanguageServer/ProtocolUnitTests/Diagnostics/AbstractPullDiagnosticTestsBase.cs @@ -227,7 +227,7 @@ private protected static async Task InsertTextAsync( await testLspServer.InsertTextAsync(document.GetURI(), (lineInfo.Start.Line, lineInfo.Start.Character, text)); } - private protected static Task OpenDocumentAsync(TestLspServer testLspServer, Document document) => testLspServer.OpenDocumentAsync(document.GetURI()); + private protected static Task OpenDocumentAsync(TestLspServer testLspServer, TextDocument document) => testLspServer.OpenDocumentAsync(document.GetURI()); private protected static Task> RunGetDocumentPullDiagnosticsAsync( TestLspServer testLspServer, diff --git a/src/LanguageServer/ProtocolUnitTests/Diagnostics/AdditionalFileDiagnosticsTests.cs b/src/LanguageServer/ProtocolUnitTests/Diagnostics/AdditionalFileDiagnosticsTests.cs index 1552f098d01f..a40f429582e3 100644 --- a/src/LanguageServer/ProtocolUnitTests/Diagnostics/AdditionalFileDiagnosticsTests.cs +++ b/src/LanguageServer/ProtocolUnitTests/Diagnostics/AdditionalFileDiagnosticsTests.cs @@ -2,11 +2,17 @@ // 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.Composition; using System.Linq; +using System.Threading; using System.Threading.Tasks; +using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.Diagnostics; +using Microsoft.CodeAnalysis.Host.Mef; +using Microsoft.CodeAnalysis.LanguageServer.Handler; +using Microsoft.CodeAnalysis.LanguageServer.Handler.Diagnostics; using Microsoft.CodeAnalysis.SolutionCrawler; using Microsoft.CodeAnalysis.Test.Utilities; using Roslyn.Test.Utilities; @@ -22,6 +28,32 @@ public AdditionalFileDiagnosticsTests(ITestOutputHelper testOutputHelper) : base { } + [Theory, CombinatorialData, WorkItem("https://devdiv.visualstudio.com/DevDiv/_workitems/edit/2531252")] + public async Task TestDocumentDiagnosticsReportsAdditionalFileDiagnostic(bool useVSDiagnostics, bool mutatingLspWorkspace) + { + var workspaceXml = + $""" + + + + + + + """; + + await using var testLspServer = await CreateTestWorkspaceFromXmlAsync(workspaceXml, mutatingLspWorkspace, BackgroundAnalysisScope.FullSolution, useVSDiagnostics); + + var additionalDocument = testLspServer.GetCurrentSolution().Projects.Single().AdditionalDocuments.Single(); + await testLspServer.OpenDocumentAsync(additionalDocument.GetURI()); + + var results = await RunGetDocumentPullDiagnosticsAsync(testLspServer, additionalDocument.GetURI(), useVSDiagnostics, category: TestAdditionalFileDocumentSourceProvider.DiagnosticSourceProviderName); + Assert.NotEmpty(results); + AssertEx.Equal( + [ + @$"C:\Test.xaml: [{MockAdditionalFileDiagnosticAnalyzer.Id}]", + ], results.Select(r => $"{r.Uri.GetRequiredParsedUri().LocalPath}: [{string.Join(", ", r.Diagnostics!.Select(d => d.Code?.Value?.ToString()))}]")); + } + [Theory, CombinatorialData] public async Task TestWorkspaceDiagnosticsReportsAdditionalFileDiagnostic(bool useVSDiagnostics, bool mutatingLspWorkspace) { @@ -119,7 +151,7 @@ public async Task TestWorkspaceDiagnosticsWithAdditionalFileInMultipleProjects(b AssertEx.Empty(results2); } - protected override TestComposition Composition => base.Composition.AddParts(typeof(MockAdditionalFileDiagnosticAnalyzer)); + protected override TestComposition Composition => base.Composition.AddParts(typeof(MockAdditionalFileDiagnosticAnalyzer), typeof(TestAdditionalFileDocumentSourceProvider)); private protected override TestAnalyzerReferenceByLanguage CreateTestAnalyzersReference() => new(ImmutableDictionary>.Empty.Add(LanguageNames.CSharp, [DiagnosticExtensions.GetCompilerDiagnosticAnalyzer(LanguageNames.CSharp), new MockAdditionalFileDiagnosticAnalyzer()])); @@ -128,10 +160,10 @@ private protected override TestAnalyzerReferenceByLanguage CreateTestAnalyzersRe private sealed class MockAdditionalFileDiagnosticAnalyzer : DiagnosticAnalyzer { public const string Id = "MockAdditionalDiagnostic"; - private readonly DiagnosticDescriptor _descriptor = new(Id, "MockAdditionalDiagnostic", "MockAdditionalDiagnostic", "InternalCategory", DiagnosticSeverity.Warning, isEnabledByDefault: true, helpLinkUri: "https://github.com/dotnet/roslyn"); + internal static readonly DiagnosticDescriptor Descriptor = new(Id, "MockAdditionalDiagnostic", "MockAdditionalDiagnostic", "InternalCategory", DiagnosticSeverity.Warning, isEnabledByDefault: true, helpLinkUri: "https://github.com/dotnet/roslyn"); public override ImmutableArray SupportedDiagnostics - => [_descriptor]; + => [Descriptor]; public override void Initialize(AnalysisContext context) => context.RegisterCompilationStartAction(CreateAnalyzerWithinCompilation); @@ -140,7 +172,54 @@ public void CreateAnalyzerWithinCompilation(CompilationStartAnalysisContext cont => context.RegisterAdditionalFileAction(AnalyzeCompilation); public void AnalyzeCompilation(AdditionalFileAnalysisContext context) - => context.ReportDiagnostic(Diagnostic.Create(_descriptor, + => context.ReportDiagnostic(Diagnostic.Create(Descriptor, location: Location.Create(context.AdditionalFile.Path, Text.TextSpan.FromBounds(0, 0), new Text.LinePositionSpan(new Text.LinePosition(0, 0), new Text.LinePosition(0, 0))), "args")); } + + [Export(typeof(IDiagnosticSourceProvider)), Shared, PartNotDiscoverable] + [method: ImportingConstructor] + [method: Obsolete(MefConstruction.ImportingConstructorMessage, error: true)] + internal sealed class TestAdditionalFileDocumentSourceProvider() : IDiagnosticSourceProvider + { + internal const string DiagnosticSourceProviderName = "TestAdditionalFileSource"; + + bool IDiagnosticSourceProvider.IsDocument => true; + + string IDiagnosticSourceProvider.Name => DiagnosticSourceProviderName; + + bool IDiagnosticSourceProvider.IsEnabled(LSP.ClientCapabilities clientCapabilities) => true; + + ValueTask> IDiagnosticSourceProvider.CreateDiagnosticSourcesAsync(RequestContext context, CancellationToken cancellationToken) + { + if (context.TextDocument is not null && context.TextDocument is not Document) + { + return new([new TestAdditionalFileDocumentSource(context.TextDocument!)]); + } + + return new([]); + } + + private class TestAdditionalFileDocumentSource(TextDocument textDocument) : IDiagnosticSource + { + public Task> GetDiagnosticsAsync(RequestContext context, CancellationToken cancellationToken) + { + var diagnostic = Diagnostic.Create(MockAdditionalFileDiagnosticAnalyzer.Descriptor, + location: Location.Create(context.TextDocument!.FilePath!, Text.TextSpan.FromBounds(0, 0), new Text.LinePositionSpan(new Text.LinePosition(0, 0), new Text.LinePosition(0, 0))), "args"); + return Task.FromResult>([DiagnosticData.Create(diagnostic, context.TextDocument.Project)]); + } + + public LSP.TextDocumentIdentifier? GetDocumentIdentifier() => new LSP.TextDocumentIdentifier + { + DocumentUri = textDocument.GetURI() + }; + + public ProjectOrDocumentId GetId() => new(textDocument.Id); + + public Project GetProject() => textDocument.Project; + + public bool IsLiveSource() => true; + + public string ToDisplayString() => textDocument.ToString()!; + } + } } diff --git a/src/LanguageServer/ProtocolUnitTests/Diagnostics/DiagnosticRegistrationTests.cs b/src/LanguageServer/ProtocolUnitTests/Diagnostics/DiagnosticRegistrationTests.cs index 632dc099ac85..c6630cc56b93 100644 --- a/src/LanguageServer/ProtocolUnitTests/Diagnostics/DiagnosticRegistrationTests.cs +++ b/src/LanguageServer/ProtocolUnitTests/Diagnostics/DiagnosticRegistrationTests.cs @@ -100,9 +100,7 @@ private sealed class ClientCallbackTarget() [JsonRpcMethod(Methods.ClientRegisterCapabilityName, UseSingleObjectParameterDeserialization = true)] public void ClientRegisterCapability(RegistrationParams registrationParams, CancellationToken _) - { - _registrations.AddRange(registrationParams.Registrations); - } + => _registrations.AddRange(registrationParams.Registrations); /// /// This is safe to call after 'initialized' has completed because capabilties are dynamically registered in the diff --git a/src/LanguageServer/ProtocolUnitTests/ProtocolConversionsTests.cs b/src/LanguageServer/ProtocolUnitTests/ProtocolConversionsTests.cs index 3429e371b80e..f9b1ff471841 100644 --- a/src/LanguageServer/ProtocolUnitTests/ProtocolConversionsTests.cs +++ b/src/LanguageServer/ProtocolUnitTests/ProtocolConversionsTests.cs @@ -170,9 +170,7 @@ public void CreateAbsoluteUri_LocalPaths_Normalized_Unix(string filePath, string [InlineData("git://host/%2525%EE%89%9B/%C2%89%EC%9E%BD")] [InlineData("xy://host/%2525%EE%89%9B/%C2%89%EC%9E%BD")] public void CreateAbsoluteUri_Urls(string url) - { - Assert.Equal(url, ProtocolConversions.CreateAbsoluteUri(url).AbsoluteUri); - } + => Assert.Equal(url, ProtocolConversions.CreateAbsoluteUri(url).AbsoluteUri); [Fact] public void CompletionItemKind_DoNotUseMethodAndFunction() diff --git a/src/RoslynAnalyzers/Microsoft.CodeAnalysis.Analyzers/UnitTests/MetaAnalyzers/DoNotStorePerCompilationDataOntoFieldsRuleTests.cs b/src/RoslynAnalyzers/Microsoft.CodeAnalysis.Analyzers/UnitTests/MetaAnalyzers/DoNotStorePerCompilationDataOntoFieldsRuleTests.cs index 0bf8b2ab5ccf..72498551c874 100644 --- a/src/RoslynAnalyzers/Microsoft.CodeAnalysis.Analyzers/UnitTests/MetaAnalyzers/DoNotStorePerCompilationDataOntoFieldsRuleTests.cs +++ b/src/RoslynAnalyzers/Microsoft.CodeAnalysis.Analyzers/UnitTests/MetaAnalyzers/DoNotStorePerCompilationDataOntoFieldsRuleTests.cs @@ -131,9 +131,8 @@ End Class } [Fact] - public async Task CSharp_NoDiagnosticCasesAsync() - { - await VerifyCS.VerifyAnalyzerAsync(""" + public Task CSharp_NoDiagnosticCasesAsync() + => VerifyCS.VerifyAnalyzerAsync(""" using System; using System.Collections.Generic; @@ -208,12 +207,10 @@ public override void Initialize(AnalysisContext context) } } """); - } [Fact] - public async Task VisualBasic_NoDiagnosticCasesAsync() - { - await VerifyVB.VerifyAnalyzerAsync(""" + public Task VisualBasic_NoDiagnosticCasesAsync() + => VerifyVB.VerifyAnalyzerAsync(""" Imports System Imports System.Collections.Generic @@ -280,12 +277,10 @@ End Sub End Class """); - } [Fact, WorkItem(4308, "https://github.com/dotnet/roslyn-analyzers/issues/4308")] - public async Task CSharp_NestedStruct_NoDiagnosticAsync() - { - await VerifyCS.VerifyAnalyzerAsync(""" + public Task CSharp_NestedStruct_NoDiagnosticAsync() + => VerifyCS.VerifyAnalyzerAsync(""" using System; using System.Collections.Concurrent; @@ -346,14 +341,12 @@ public void AnalyzeSemanticModel(SemanticModelAnalysisContext context, Concurren } } """); - } [Theory] [InlineData("Func")] [InlineData("Action")] public Task CSharp_Func_NoDiagnostic(string delegateType) - { - return VerifyCS.VerifyAnalyzerAsync($$""" + => VerifyCS.VerifyAnalyzerAsync($$""" using System; using System.Collections.Immutable; @@ -380,14 +373,12 @@ public override void Initialize(AnalysisContext context) } } """); - } [Theory] [InlineData("Func")] [InlineData("Action")] public Task CSharp_NestedFunc_NoDiagnostic(string delegateType) - { - return VerifyCS.VerifyAnalyzerAsync($$""" + => VerifyCS.VerifyAnalyzerAsync($$""" using System; using System.Collections.Immutable; @@ -414,14 +405,12 @@ public override void Initialize(AnalysisContext context) } } """); - } [Theory] [InlineData("Func")] [InlineData("Action")] public Task CSharp_NestedNestedFunc_NoDiagnostic(string delegateType) - { - return VerifyCS.VerifyAnalyzerAsync($$""" + => VerifyCS.VerifyAnalyzerAsync($$""" using System; using System.Collections.Generic; @@ -449,13 +438,11 @@ public override void Initialize(AnalysisContext context) } } """); - } [Theory] [CombinatorialData] public Task CSharp_MultiFunc_NoDiagnostic([CombinatorialValues("Func", "Action")] string delegateType, [CombinatorialValues("bool", "int, string")] string types) - { - return VerifyCS.VerifyAnalyzerAsync($$""" + => VerifyCS.VerifyAnalyzerAsync($$""" using System; using System.Collections.Generic; @@ -483,14 +470,12 @@ public override void Initialize(AnalysisContext context) } } """); - } [Theory] [InlineData("Func")] [InlineData("Action")] public Task VisualBasic_Func_NoDiagnostic(string delegateType) - { - return VerifyVB.VerifyAnalyzerAsync($""" + => VerifyVB.VerifyAnalyzerAsync($""" Imports System Imports System.Collections.Immutable @@ -516,14 +501,12 @@ Public Overrides Sub Initialize(context As AnalysisContext) End Sub End Class """); - } [Theory] [InlineData("Func")] [InlineData("Action")] public Task VisualBasic_NestedFunc_NoDiagnostic(string delegateType) - { - return VerifyVB.VerifyAnalyzerAsync($""" + => VerifyVB.VerifyAnalyzerAsync($""" Imports System Imports System.Collections.Immutable @@ -549,14 +532,12 @@ Public Overrides Sub Initialize(context As AnalysisContext) End Sub End Class """); - } [Theory] [InlineData("Func")] [InlineData("Action")] public Task VisualBasic_NestedNestedFunc_NoDiagnostic(string delegateType) - { - return VerifyVB.VerifyAnalyzerAsync($""" + => VerifyVB.VerifyAnalyzerAsync($""" Imports System Imports System.Collections.Generic @@ -583,13 +564,11 @@ Public Overrides Sub Initialize(context As AnalysisContext) End Sub End Class """); - } [Theory] [CombinatorialData] public Task VisualBasic_MultiFunc_NoDiagnostic([CombinatorialValues("Func", "Action")] string delegateType, [CombinatorialValues("Int32", "Int32, String")] string types) - { - return VerifyVB.VerifyAnalyzerAsync($""" + => VerifyVB.VerifyAnalyzerAsync($""" Imports System Imports System.Collections.Immutable @@ -615,7 +594,6 @@ Public Overrides Sub Initialize(context As AnalysisContext) End Sub End Class """); - } private static DiagnosticResult GetCSharpExpectedDiagnostic(int line, int column, string violatingTypeName) => #pragma warning disable RS0030 // Do not use banned APIs diff --git a/src/RoslynAnalyzers/Microsoft.CodeAnalysis.Analyzers/UnitTests/MetaAnalyzers/InvalidReportDiagnosticRuleTests.cs b/src/RoslynAnalyzers/Microsoft.CodeAnalysis.Analyzers/UnitTests/MetaAnalyzers/InvalidReportDiagnosticRuleTests.cs index 2d3a0feda18d..aad2f88d9b85 100644 --- a/src/RoslynAnalyzers/Microsoft.CodeAnalysis.Analyzers/UnitTests/MetaAnalyzers/InvalidReportDiagnosticRuleTests.cs +++ b/src/RoslynAnalyzers/Microsoft.CodeAnalysis.Analyzers/UnitTests/MetaAnalyzers/InvalidReportDiagnosticRuleTests.cs @@ -179,9 +179,8 @@ End Class } [Fact] - public async Task CSharp_NoDiagnosticCasesAsync() - { - await VerifyCS.VerifyAnalyzerAsync(""" + public Task CSharp_NoDiagnosticCasesAsync() + => VerifyCS.VerifyAnalyzerAsync(""" using System; using System.Collections.Immutable; using Microsoft.CodeAnalysis; @@ -219,12 +218,10 @@ private static void AnalyzeSymbol(SymbolAnalysisContext context) } } """); - } [Fact] - public async Task VisualBasic_NoDiagnosticCasesAsync() - { - await VerifyVB.VerifyAnalyzerAsync(""" + public Task VisualBasic_NoDiagnosticCasesAsync() + => VerifyVB.VerifyAnalyzerAsync(""" Imports System Imports System.Collections.Generic Imports System.Collections.Immutable @@ -260,7 +257,6 @@ Private Shared Sub AnalyzeSymbol(context As SymbolAnalysisContext) End Sub End Class """); - } private static DiagnosticResult GetCSharpExpectedDiagnostic(int line, int column, string unsupportedDescriptorName) => #pragma warning disable RS0030 // Do not use banned APIs diff --git a/src/RoslynAnalyzers/Microsoft.CodeAnalysis.Analyzers/UnitTests/MetaAnalyzers/InvalidSyntaxKindTypeArgumentRuleTests.cs b/src/RoslynAnalyzers/Microsoft.CodeAnalysis.Analyzers/UnitTests/MetaAnalyzers/InvalidSyntaxKindTypeArgumentRuleTests.cs index 3a7153622933..41ba495c2515 100644 --- a/src/RoslynAnalyzers/Microsoft.CodeAnalysis.Analyzers/UnitTests/MetaAnalyzers/InvalidSyntaxKindTypeArgumentRuleTests.cs +++ b/src/RoslynAnalyzers/Microsoft.CodeAnalysis.Analyzers/UnitTests/MetaAnalyzers/InvalidSyntaxKindTypeArgumentRuleTests.cs @@ -108,9 +108,8 @@ End Class } [Fact] - public async Task CSharp_NoDiagnosticCasesAsync() - { - await VerifyCS.VerifyAnalyzerAsync(""" + public Task CSharp_NoDiagnosticCasesAsync() + => VerifyCS.VerifyAnalyzerAsync(""" using System; using System.Collections.Immutable; using Microsoft.CodeAnalysis; @@ -148,12 +147,10 @@ private static void AnalyzeCodeBlockStart(CodeBlockStartAnalysisContext conte } } """); - } [Fact] - public async Task VisualBasic_NoDiagnosticCasesAsync() - { - await VerifyVB.VerifyAnalyzerAsync(""" + public Task VisualBasic_NoDiagnosticCasesAsync() + => VerifyVB.VerifyAnalyzerAsync(""" Imports System Imports System.Collections.Immutable Imports Microsoft.CodeAnalysis @@ -185,7 +182,6 @@ Private Shared Sub AnalyzeCodeBlockStart(context As CodeBlockStartAnalysisContex End Sub End Class """); - } private static DiagnosticResult GetCSharpExpectedDiagnostic(int line, int column, string typeArgumentName, string registerMethodName) => #pragma warning disable RS0030 // Do not use banned APIs diff --git a/src/RoslynAnalyzers/Microsoft.CodeAnalysis.Analyzers/UnitTests/MetaAnalyzers/ReleaseTrackingAnalyzerTests.cs b/src/RoslynAnalyzers/Microsoft.CodeAnalysis.Analyzers/UnitTests/MetaAnalyzers/ReleaseTrackingAnalyzerTests.cs index d2a3c1537532..262fb5a25c71 100644 --- a/src/RoslynAnalyzers/Microsoft.CodeAnalysis.Analyzers/UnitTests/MetaAnalyzers/ReleaseTrackingAnalyzerTests.cs +++ b/src/RoslynAnalyzers/Microsoft.CodeAnalysis.Analyzers/UnitTests/MetaAnalyzers/ReleaseTrackingAnalyzerTests.cs @@ -20,10 +20,8 @@ namespace Microsoft.CodeAnalysis.Analyzers.UnitTests.MetaAnalyzers public class ReleaseTrackingAnalyzerTests { [Fact] - public async Task TestNoDeclaredAnalyzersAsync() - { - await VerifyCSharpAsync(@"", @"", @""); - } + public Task TestNoDeclaredAnalyzersAsync() + => VerifyCSharpAsync(@"", @"", @""); [InlineData(@"{|RS2008:""Id1""|}", null, null)] [InlineData(""" @@ -34,9 +32,8 @@ public async Task TestNoDeclaredAnalyzersAsync() """, null, "")] [InlineData(@"{|RS2000:""Id1""|}", "", "")] [Theory] - public async Task TestMissingReleasesFilesAsync(string id, string shippedText, string unshippedText) - { - await VerifyCSharpAsync($$""" + public Task TestMissingReleasesFilesAsync(string id, string shippedText, string unshippedText) + => VerifyCSharpAsync($$""" using System; using System.Collections.Immutable; @@ -54,7 +51,6 @@ class MyAnalyzer : DiagnosticAnalyzer public override void Initialize(AnalysisContext context) { } } """, shippedText, unshippedText); - } [Fact] public async Task TestCodeFixToEnableAnalyzerReleaseTrackingAsync() @@ -145,9 +141,8 @@ public override void Initialize(AnalysisContext context) { } DefaultShippedHeader2WithBorders + "| Id1 | Category1 | Warning | |" + BlankLine + DefaultChangedUnshippedHeaderWithBorders + "| Id3 | Category2 | Warning | Category1 | Warning | |" + BlankLine + DefaultRemovedUnshippedHeaderWithBorders + "| Id2 | Category1 | Warning | |", DefaultRemovedUnshippedHeaderWithBorders + "| Id3 | Category2 | Warning | |")] [Theory] - public async Task TestReleasesFileAlreadyHasEntryAsync(string shippedText, string unshippedText) - { - await VerifyCSharpAsync(""" + public Task TestReleasesFileAlreadyHasEntryAsync(string shippedText, string unshippedText) + => VerifyCSharpAsync(""" using System; using System.Collections.Immutable; @@ -165,7 +160,6 @@ class MyAnalyzer : DiagnosticAnalyzer public override void Initialize(AnalysisContext context) {{ }} } """, shippedText, unshippedText); - } [Fact] public async Task TestRemoveUnshippedDeletedDiagnosticIdRuleAsync() @@ -211,9 +205,8 @@ public override void Initialize(AnalysisContext context) {{ }} } [Fact] - public async Task TestCodeFixToAddUnshippedEntriesAsync() - { - await VerifyCSharpAdditionalFileFixAsync(""" + public Task TestCodeFixToAddUnshippedEntriesAsync() + => VerifyCSharpAdditionalFileFixAsync(""" using System; using System.Collections.Immutable; @@ -247,7 +240,6 @@ public override void Initialize(AnalysisContext context) { } Id2 | Category2 | Disabled | MyAnalyzer Id3 | Category3 | Warning | MyAnalyzer, [Documentation](Dummy) """); - } [Fact] public async Task TestCodeFixToAddUnshippedEntries_DiagnosticDescriptorHelperAsync() @@ -304,9 +296,8 @@ await VerifyCSharpAdditionalFileFixAsync(source, @"", @"", $""" [InlineData(DefaultUnshippedHeader + BlankLine + @"; Comments are preserved" + BlankLine, DefaultUnshippedHeader + @"Id1 | Category1 | Warning | MyAnalyzer" + BlankLine + BlankLine + @"; Comments are preserved" + BlankLine)] [Theory] - public async Task TestCodeFixToAddUnshippedEntries_TriviaIsPreservedAsync(string unshippedText, string fixedUnshippedText) - { - await VerifyCSharpAdditionalFileFixAsync(""" + public Task TestCodeFixToAddUnshippedEntries_TriviaIsPreservedAsync(string unshippedText, string fixedUnshippedText) + => VerifyCSharpAdditionalFileFixAsync(""" using System; using System.Collections.Immutable; @@ -323,7 +314,6 @@ class MyAnalyzer : DiagnosticAnalyzer public override void Initialize(AnalysisContext context) { } } """, @"", unshippedText, fixedUnshippedText); - } // Added after current entry. [InlineData("Id0", DefaultUnshippedHeader + @"Id0 | DifferentCategory | Warning | MyAnalyzer", @@ -340,9 +330,8 @@ public override void Initialize(AnalysisContext context) { } DefaultUnshippedHeader + @"Id1 | Category1 | Warning | MyAnalyzer" + BlankLine + BlankLine + DefaultRemovedUnshippedHeader + @"Id3 | Category | Warning | MyAnalyzer", DefaultShippedHeader + @"Id2 | DifferentCategory | Warning | MyAnalyzer" + BlankLine + @"Id3 | Category | Warning | MyAnalyzer")] [Theory] - public async Task TestCodeFixToAddUnshippedEntries_AlreadyHasDifferentUnshippedEntriesAsync(string differentRuleId, string unshippedText, string fixedUnshippedText, string shippedText = "") - { - await VerifyCSharpAdditionalFileFixAsync($$""" + public Task TestCodeFixToAddUnshippedEntries_AlreadyHasDifferentUnshippedEntriesAsync(string differentRuleId, string unshippedText, string fixedUnshippedText, string shippedText = "") + => VerifyCSharpAdditionalFileFixAsync($$""" using System; using System.Collections.Immutable; @@ -362,7 +351,6 @@ class MyAnalyzer : DiagnosticAnalyzer public override void Initialize(AnalysisContext context) { } } """, shippedText, unshippedText, fixedUnshippedText); - } // Adds to existing new rules table and creates a new changed rules table. [InlineData(DefaultUnshippedHeader + @"Id0 | Category0 | Warning | MyAnalyzer", @@ -373,9 +361,8 @@ public override void Initialize(AnalysisContext context) { } DefaultUnshippedHeader + @"Id1 | Category1 | Warning | MyAnalyzer" + BlankLine + BlankLine + DefaultChangedUnshippedHeader + @"Id0 | Category0 | Warning | Category | Warning | MyAnalyzer" + BlankLine + @"Id2 | DifferentCategory | Warning | Category | Warning | MyAnalyzer", DefaultShippedHeader + @"Id0 | Category | Warning | MyAnalyzer" + BlankLine + @"Id2 | Category | Warning | MyAnalyzer")] [Theory] - public async Task TestCodeFixToAddUnshippedEntriesToMultipleTablesAsync(string unshippedText, string fixedUnshippedText, string shippedText = "") - { - await VerifyCSharpAdditionalFileFixAsync(""" + public Task TestCodeFixToAddUnshippedEntriesToMultipleTablesAsync(string unshippedText, string fixedUnshippedText, string shippedText = "") + => VerifyCSharpAdditionalFileFixAsync(""" using System; using System.Collections.Immutable; @@ -398,7 +385,6 @@ class MyAnalyzer : DiagnosticAnalyzer public override void Initialize(AnalysisContext context) { } } """, shippedText, unshippedText, fixedUnshippedText); - } [InlineData("", DefaultUnshippedHeader + "Id1 | Category1 | Warning | MyAnalyzer", @@ -413,9 +399,8 @@ public override void Initialize(AnalysisContext context) { } DefaultUnshippedHeader + "Id1 | Category1 | Warning | MyAnalyzer", "RS2000")] [Theory] - public async Task TestCodeFixToAddUnshippedEntries_AlreadyHasDifferentShippedEntryAsync(string shippedText, string fixedUnshippedText, string expectedDiagnosticId) - { - await VerifyCSharpAdditionalFileFixAsync($$""" + public Task TestCodeFixToAddUnshippedEntries_AlreadyHasDifferentShippedEntryAsync(string shippedText, string fixedUnshippedText, string expectedDiagnosticId) + => VerifyCSharpAdditionalFileFixAsync($$""" using System; using System.Collections.Immutable; @@ -433,12 +418,10 @@ class MyAnalyzer : DiagnosticAnalyzer public override void Initialize(AnalysisContext context) { } } """, shippedText, @"", fixedUnshippedText); - } [Fact] - public async Task TestCodeFixToUpdateMultipleUnshippedEntriesAsync() - { - await VerifyCSharpAdditionalFileFixAsync(""" + public Task TestCodeFixToUpdateMultipleUnshippedEntriesAsync() + => VerifyCSharpAdditionalFileFixAsync(""" using System; using System.Collections.Immutable; @@ -472,7 +455,6 @@ public override void Initialize(AnalysisContext context) { } Id2 | Category2 | Disabled | MyAnalyzer Id3 | Category3 | Warning | MyAnalyzer """); - } [Fact] public async Task TestCodeFixToAddUnshippedEntries_UndetectedFieldsAsync() @@ -513,9 +495,8 @@ public override void Initialize(AnalysisContext context) { } } [Fact] - public async Task TestNoCodeFixToAddUnshippedEntries_UndetectedFieldsAsync() - { - await VerifyCSharpAsync(""" + public Task TestNoCodeFixToAddUnshippedEntries_UndetectedFieldsAsync() + => VerifyCSharpAsync(""" using System; using System.Collections.Immutable; @@ -541,7 +522,6 @@ class MyAnalyzer : DiagnosticAnalyzer public override void Initialize(AnalysisContext context) { } } """, @"", $@"{DefaultUnshippedHeader}Id1 | CustomCategory | Warning |"); - } // No header in unshipped [InlineData("", "Id1 | Category1 | Warning |")] @@ -731,9 +711,8 @@ public override void Initialize(AnalysisContext context) { } // Duplicate entries with in shipped with second removed entry. [InlineData(DefaultShippedHeader + "Id1 | Category1 | Warning |" + BlankLine + DefaultRemovedUnshippedHeader + "{|RS2005:Id1 | Category2 | Warning ||}", "")] [Theory] - public async Task TestDuplicateEntryInReleaseDiagnosticAsync(string shippedText, string unshippedText) - { - await VerifyCSharpAsync(""" + public Task TestDuplicateEntryInReleaseDiagnosticAsync(string shippedText, string unshippedText) + => VerifyCSharpAsync(""" using System; using System.Collections.Immutable; @@ -750,7 +729,6 @@ class MyAnalyzer : DiagnosticAnalyzer public override void Initialize(AnalysisContext context) { } } """, shippedText, unshippedText); - } // Duplicate entries across shipped and unshipped. [InlineData(DefaultShippedHeader + "Id1 | Category1 | Warning |", DefaultUnshippedHeader + "{|RS2006:Id1 | Category1 | Warning ||}")] @@ -767,9 +745,8 @@ public override void Initialize(AnalysisContext context) { } // Duplicate changed entries across consecutive shipped releases. [InlineData(DefaultShippedHeader + "Id1 | Category1 | Warning |" + BlankLine + DefaultChangedShippedHeader2 + "Id1 | Category1 | Warning | Category1 | Info |" + BlankLine + DefaultChangedShippedHeader3 + "{|RS2006:Id1 | Category1 | Warning | Category1 | Info ||}", "")] [Theory] - public async Task TestDuplicateEntryBetweenReleasesDiagnosticAsync(string shippedText, string unshippedText) - { - await VerifyCSharpAsync(""" + public Task TestDuplicateEntryBetweenReleasesDiagnosticAsync(string shippedText, string unshippedText) + => VerifyCSharpAsync(""" using System; using System.Collections.Immutable; @@ -786,7 +763,6 @@ class MyAnalyzer : DiagnosticAnalyzer public override void Initialize(AnalysisContext context) { } } """, shippedText, unshippedText); - } // Remove entry in unshipped for already shipped release. [InlineData(DefaultShippedHeader + "Id1 | Category1 | Warning |", DefaultRemovedUnshippedHeader + "Id1 | Category1 | Warning |", "RS2004")] @@ -795,9 +771,8 @@ public override void Initialize(AnalysisContext context) { } // Remove entry with changed severity in shipped for a prior shipped release. [InlineData(DefaultShippedHeader + "Id1 | Category1 | Warning |" + BlankLine + DefaultRemovedShippedHeader2 + "Id1 | Category1 | Info |", "", "RS2000")] [Theory] - public async Task TestRemoveEntryInReleaseFile_DiagnosticCasesAsync(string shippedText, string unshippedText, string expectedDiagnosticId) - { - await VerifyCSharpAsync($$""" + public Task TestRemoveEntryInReleaseFile_DiagnosticCasesAsync(string shippedText, string unshippedText, string expectedDiagnosticId) + => VerifyCSharpAsync($$""" using System; using System.Collections.Immutable; @@ -814,7 +789,6 @@ class MyAnalyzer : DiagnosticAnalyzer public override void Initialize(AnalysisContext context) { } } """, shippedText, unshippedText); - } // Invalid remove entry without prior shipped entry in shipped. [InlineData(DefaultRemovedShippedHeader + "Id1 | Category1 | Warning |", "")] @@ -921,9 +895,8 @@ public override void Initialize(AnalysisContext context) { } // Remove entry with changed severity in shipped for a prior shipped release. [InlineData(DefaultShippedHeader + "Id1 | Category1 | Warning |" + BlankLine + DefaultRemovedShippedHeader2 + "Id1 | Category1 | Info |", "")] [Theory] - public async Task TestRemoveEntryInReleaseFile_NoDiagnosticCasesAsync(string shippedText, string unshippedText) - { - await VerifyCSharpAsync(""" + public Task TestRemoveEntryInReleaseFile_NoDiagnosticCasesAsync(string shippedText, string unshippedText) + => VerifyCSharpAsync(""" using System; using System.Collections.Immutable; @@ -937,12 +910,10 @@ class MyAnalyzer : DiagnosticAnalyzer public override void Initialize(AnalysisContext context) { } } """, shippedText, unshippedText); - } [Fact, WorkItem(5828, "https://github.com/dotnet/roslyn-analyzers/issues/5828")] - public async Task TestTargetTypedNew() - { - await VerifyCSharpAsync(""" + public Task TestTargetTypedNew() + => VerifyCSharpAsync(""" using System; using System.Collections.Immutable; @@ -959,7 +930,6 @@ class MyAnalyzer : DiagnosticAnalyzer public override void Initialize(AnalysisContext context) { } } """, @"", $@"{DefaultUnshippedHeader}Id1 | Category1 | Warning |"); - } #region Helpers private const string DefaultUnshippedHeader = ReleaseTrackingHelper.TableTitleNewRules + BlankLine + BlankLine + diff --git a/src/RoslynAnalyzers/Microsoft.CodeAnalysis.Analyzers/UnitTests/MetaAnalyzers/SemanticModelGetDeclaredSymbolAlwaysReturnsNullAnalyzerTests.cs b/src/RoslynAnalyzers/Microsoft.CodeAnalysis.Analyzers/UnitTests/MetaAnalyzers/SemanticModelGetDeclaredSymbolAlwaysReturnsNullAnalyzerTests.cs index 40f6466d31ba..e0af5ea4294f 100644 --- a/src/RoslynAnalyzers/Microsoft.CodeAnalysis.Analyzers/UnitTests/MetaAnalyzers/SemanticModelGetDeclaredSymbolAlwaysReturnsNullAnalyzerTests.cs +++ b/src/RoslynAnalyzers/Microsoft.CodeAnalysis.Analyzers/UnitTests/MetaAnalyzers/SemanticModelGetDeclaredSymbolAlwaysReturnsNullAnalyzerTests.cs @@ -23,8 +23,7 @@ public sealed class SemanticModelGetDeclaredSymbolAlwaysReturnsNullAnalyzerTests [InlineData("ParameterListSyntax")] [InlineData("LockStatementSyntax")] public Task Diagnostic(string type) - { - return new VerifyCS.Test + => new VerifyCS.Test { TestCode = $$""" using Microsoft.CodeAnalysis; @@ -38,15 +37,13 @@ public void M(SemanticModel semanticModel, {{type}} syntax) { """, ExpectedDiagnostics = { new DiagnosticResult(CSharpSemanticModelGetDeclaredSymbolAlwaysReturnsNullAnalyzer.DiagnosticDescriptor).WithLocation(0).WithArguments(type) } }.RunAsync(); - } [Theory] [InlineData("BaseFieldDeclarationSyntax")] [InlineData("FieldDeclarationSyntax")] [InlineData("EventFieldDeclarationSyntax")] public Task Field_Diagnostic(string type) - { - return new VerifyCS.Test + => new VerifyCS.Test { TestCode = $$""" using Microsoft.CodeAnalysis; @@ -60,7 +57,6 @@ public void M(SemanticModel semanticModel, {{type}} syntax) { """, ExpectedDiagnostics = { new DiagnosticResult(CSharpSemanticModelGetDeclaredSymbolAlwaysReturnsNullAnalyzer.FieldDiagnosticDescriptor).WithLocation(0).WithArguments(type) } }.RunAsync(); - } [Theory] [InlineData("SyntaxNode")] @@ -69,8 +65,7 @@ public void M(SemanticModel semanticModel, {{type}} syntax) { [InlineData("EnumMemberDeclarationSyntax")] [InlineData("NamespaceDeclarationSyntax")] public Task NoDiagnostic(string type) - { - return VerifyCS.VerifyAnalyzerAsync($$""" + => VerifyCS.VerifyAnalyzerAsync($$""" using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp.Syntax; @@ -80,12 +75,10 @@ public void M(SemanticModel semanticModel, {{type}} syntax) { } } """); - } [Fact] public Task NoDiagnosticForCompilationError() - { - const string code = """ + => VerifyCS.VerifyAnalyzerAsync(""" using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp.Syntax; @@ -94,15 +87,11 @@ public void M(SemanticModel semanticModel) { var x = semanticModel.{|CS7036:GetDeclaredSymbol|}(); } } - """; - - return VerifyCS.VerifyAnalyzerAsync(code); - } + """); [Fact, WorkItem(7061, "https://github.com/dotnet/roslyn-analyzers/issues/7061")] public Task LocalFunctionStatement_NoDiagnostic() - { - const string code = """ + => VerifyCS.VerifyAnalyzerAsync(""" using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp.Syntax; @@ -113,9 +102,6 @@ public void M(SemanticModel semanticModel, LocalFunctionStatementSyntax syntax) var x = semanticModel.GetDeclaredSymbol(syntax); } } - """; - - return VerifyCS.VerifyAnalyzerAsync(code); - } + """); } } diff --git a/src/RoslynAnalyzers/Microsoft.CodeAnalysis.Analyzers/UnitTests/MetaAnalyzers/StartActionWithNoRegisteredActionsRuleTests.cs b/src/RoslynAnalyzers/Microsoft.CodeAnalysis.Analyzers/UnitTests/MetaAnalyzers/StartActionWithNoRegisteredActionsRuleTests.cs index 35c12f6375c1..3b27c95ad2d7 100644 --- a/src/RoslynAnalyzers/Microsoft.CodeAnalysis.Analyzers/UnitTests/MetaAnalyzers/StartActionWithNoRegisteredActionsRuleTests.cs +++ b/src/RoslynAnalyzers/Microsoft.CodeAnalysis.Analyzers/UnitTests/MetaAnalyzers/StartActionWithNoRegisteredActionsRuleTests.cs @@ -123,9 +123,8 @@ End Class } [Fact] - public async Task CSharp_NoDiagnosticCasesAsync() - { - await VerifyCS.VerifyAnalyzerAsync(""" + public Task CSharp_NoDiagnosticCasesAsync() + => VerifyCS.VerifyAnalyzerAsync(""" using System; using System.Collections.Immutable; using Microsoft.CodeAnalysis; @@ -162,12 +161,10 @@ private static void AnalyzeCodeBlockStart(CodeBlockStartAnalysisContext VerifyCS.VerifyAnalyzerAsync(""" using System; using System.Collections.Immutable; using Microsoft.CodeAnalysis; @@ -207,12 +204,10 @@ private static void AnalyzeCodeBlockStart(CodeBlockStartAnalysisContext VerifyCS.VerifyAnalyzerAsync(""" using System; using System.Collections.Immutable; using Microsoft.CodeAnalysis; @@ -260,12 +255,10 @@ private static void AnalyzeOperationBlock(OperationBlockAnalysisContext context) } } """); - } [Fact] - public async Task CSharp_NoDiagnosticCases_NestedOperationAnalyzerRegistrationAsync() - { - await VerifyCS.VerifyAnalyzerAsync(""" + public Task CSharp_NoDiagnosticCases_NestedOperationAnalyzerRegistrationAsync() + => VerifyCS.VerifyAnalyzerAsync(""" using System; using System.Collections.Immutable; using Microsoft.CodeAnalysis; @@ -317,12 +310,10 @@ private static void AnalyzeOperationBlockStart(OperationBlockStartAnalysisContex } } """); - } [Fact] - public async Task VisualBasic_NoDiagnosticCasesAsync() - { - await VerifyVB.VerifyAnalyzerAsync(""" + public Task VisualBasic_NoDiagnosticCasesAsync() + => VerifyVB.VerifyAnalyzerAsync(""" Imports System Imports System.Collections.Immutable Imports Microsoft.CodeAnalysis @@ -355,12 +346,10 @@ Private Shared Sub AnalyzeCodeBlockStart(context As CodeBlockStartAnalysisContex End Sub End Class """); - } [Fact] - public async Task VisualBasic_NoDiagnosticCases_2Async() - { - await VerifyVB.VerifyAnalyzerAsync(""" + public Task VisualBasic_NoDiagnosticCases_2Async() + => VerifyVB.VerifyAnalyzerAsync(""" Imports System Imports System.Collections.Immutable Imports Microsoft.CodeAnalysis @@ -397,12 +386,10 @@ Private Shared Sub AnalyzeCodeBlockStart(context As CodeBlockStartAnalysisContex End Sub End Class """); - } [Fact] - public async Task VisualBasic_NoDiagnosticCases_OperationAnalyzerRegistrationAsync() - { - await VerifyVB.VerifyAnalyzerAsync(""" + public Task VisualBasic_NoDiagnosticCases_OperationAnalyzerRegistrationAsync() + => VerifyVB.VerifyAnalyzerAsync(""" Imports System Imports System.Collections.Immutable Imports Microsoft.CodeAnalysis @@ -442,12 +429,10 @@ Private Shared Sub AnalyzeOperationBlock(context As OperationBlockAnalysisContex End Sub End Class """); - } [Fact] - public async Task VisualBasic_NoDiagnosticCases_NestedOperationAnalyzerRegistrationAsync() - { - await VerifyVB.VerifyAnalyzerAsync(""" + public Task VisualBasic_NoDiagnosticCases_NestedOperationAnalyzerRegistrationAsync() + => VerifyVB.VerifyAnalyzerAsync(""" Imports System Imports System.Collections.Immutable Imports Microsoft.CodeAnalysis @@ -489,7 +474,6 @@ Private Shared Sub AnalyzeOperationBlockStart(context As OperationBlockStartAnal End Sub End Class """); - } private static DiagnosticResult GetCSharpExpectedDiagnostic(int line, int column, string parameterName, StartActionKind kind) => #pragma warning disable RS0030 // Do not use banned APIs diff --git a/src/RoslynAnalyzers/Microsoft.CodeAnalysis.Analyzers/UnitTests/MetaAnalyzers/StartActionWithOnlyEndActionRuleTests.cs b/src/RoslynAnalyzers/Microsoft.CodeAnalysis.Analyzers/UnitTests/MetaAnalyzers/StartActionWithOnlyEndActionRuleTests.cs index 4a1b559f6d2d..b350dd0e8481 100644 --- a/src/RoslynAnalyzers/Microsoft.CodeAnalysis.Analyzers/UnitTests/MetaAnalyzers/StartActionWithOnlyEndActionRuleTests.cs +++ b/src/RoslynAnalyzers/Microsoft.CodeAnalysis.Analyzers/UnitTests/MetaAnalyzers/StartActionWithOnlyEndActionRuleTests.cs @@ -129,9 +129,8 @@ End Class } [Fact] - public async Task CSharp_NoDiagnosticCasesAsync() - { - await VerifyCS.VerifyAnalyzerAsync(""" + public Task CSharp_NoDiagnosticCasesAsync() + => VerifyCS.VerifyAnalyzerAsync(""" using System; using System.Collections.Immutable; using Microsoft.CodeAnalysis; @@ -181,12 +180,10 @@ private static void AnalyzeOperationBlockStart(OperationBlockStartAnalysisContex } } """); - } [Fact] - public async Task CSharp_NoDiagnosticCases_2Async() - { - await VerifyCS.VerifyAnalyzerAsync(""" + public Task CSharp_NoDiagnosticCases_2Async() + => VerifyCS.VerifyAnalyzerAsync(""" using System; using System.Collections.Immutable; using Microsoft.CodeAnalysis; @@ -229,12 +226,10 @@ private static void AnalyzeCodeBlockStart(CodeBlockStartAnalysisContext VerifyVB.VerifyAnalyzerAsync(""" Imports System Imports System.Collections.Immutable Imports Microsoft.CodeAnalysis @@ -278,12 +273,10 @@ Private Shared Sub AnalyzeOperationBlockStart(context As OperationBlockStartAnal End Sub End Class """); - } [Fact] - public async Task VisualBasic_NoDiagnosticCases_2Async() - { - await VerifyVB.VerifyAnalyzerAsync(""" + public Task VisualBasic_NoDiagnosticCases_2Async() + => VerifyVB.VerifyAnalyzerAsync(""" Imports System Imports System.Collections.Immutable Imports Microsoft.CodeAnalysis @@ -323,7 +316,6 @@ Private Shared Sub AnalyzeCodeBlockStart(context As CodeBlockStartAnalysisContex End Sub End Class """); - } private static DiagnosticResult GetCSharpExpectedDiagnostic(int line, int column, string parameterName, StartActionKind kind) => #pragma warning disable RS0030 // Do not use banned APIs diff --git a/src/RoslynAnalyzers/Microsoft.CodeAnalysis.Analyzers/UnitTests/MetaAnalyzers/UnsupportedSymbolKindArgumentRuleTests.cs b/src/RoslynAnalyzers/Microsoft.CodeAnalysis.Analyzers/UnitTests/MetaAnalyzers/UnsupportedSymbolKindArgumentRuleTests.cs index 19c700b374b1..0cf3d3203725 100644 --- a/src/RoslynAnalyzers/Microsoft.CodeAnalysis.Analyzers/UnitTests/MetaAnalyzers/UnsupportedSymbolKindArgumentRuleTests.cs +++ b/src/RoslynAnalyzers/Microsoft.CodeAnalysis.Analyzers/UnitTests/MetaAnalyzers/UnsupportedSymbolKindArgumentRuleTests.cs @@ -153,9 +153,8 @@ End Class } [Fact] - public async Task CSharp_NoDiagnosticCasesAsync() - { - await VerifyCS.VerifyAnalyzerAsync(""" + public Task CSharp_NoDiagnosticCasesAsync() + => VerifyCS.VerifyAnalyzerAsync(""" using System; using System.Collections.Immutable; using Microsoft.CodeAnalysis; @@ -202,12 +201,10 @@ private static void AnalyzeSyntax(SyntaxNodeAnalysisContext context) } } """); - } [Fact] - public async Task VisualBasic_NoDiagnosticCasesAsync() - { - await VerifyVB.VerifyAnalyzerAsync(""" + public Task VisualBasic_NoDiagnosticCasesAsync() + => VerifyVB.VerifyAnalyzerAsync(""" Imports System Imports System.Collections.Immutable Imports Microsoft.CodeAnalysis @@ -245,7 +242,6 @@ Private Shared Sub AnalyzeSyntax(context As SyntaxNodeAnalysisContext) End Sub End Class """); - } private static DiagnosticResult GetCSharpExpectedDiagnostic(int line, int column, SymbolKind unsupportedSymbolKind) => #pragma warning disable RS0030 // Do not use banned APIs diff --git a/src/RoslynAnalyzers/Microsoft.CodeAnalysis.Analyzers/UnitTests/UpgradeMSBuildWorkspaceAnalyzerTests.cs b/src/RoslynAnalyzers/Microsoft.CodeAnalysis.Analyzers/UnitTests/UpgradeMSBuildWorkspaceAnalyzerTests.cs index 44f111552487..350f50ddf194 100644 --- a/src/RoslynAnalyzers/Microsoft.CodeAnalysis.Analyzers/UnitTests/UpgradeMSBuildWorkspaceAnalyzerTests.cs +++ b/src/RoslynAnalyzers/Microsoft.CodeAnalysis.Analyzers/UnitTests/UpgradeMSBuildWorkspaceAnalyzerTests.cs @@ -41,9 +41,8 @@ private static Task VerifyVisualBasicAsync(string source, ReferenceAssemblies re }.RunAsync(); [Fact] - public async Task CSharp_VerifyWithMSBuildWorkspaceAsync() - { - const string source = """ + public Task CSharp_VerifyWithMSBuildWorkspaceAsync() + => VerifyCSharpAsync(""" using Microsoft.CodeAnalysis.MSBuild; class Usage @@ -53,15 +52,11 @@ void M() var workspace = MSBuildWorkspace.Create(); } } - """; - - await VerifyCSharpAsync(source, s_withMSBuildWorkspaces); - } + """, s_withMSBuildWorkspaces); [Fact] - public async Task CSharp_VerifyWithoutMSBuildWorkspaceAsync() - { - const string source = """ + public Task CSharp_VerifyWithoutMSBuildWorkspaceAsync() + => VerifyCSharpAsync(""" using Microsoft.CodeAnalysis.{|CS0234:MSBuild|}; class Usage @@ -71,14 +66,11 @@ void M() var workspace = [|{|CS0103:MSBuildWorkspace|}|].Create(); } } - """; - await VerifyCSharpAsync(source, s_withDesktopWorkspaces); - } + """, s_withDesktopWorkspaces); [Fact] - public async Task VisualBasic_VerifyWithMSBuildWorkspaceAsync() - { - const string source = """ + public Task VisualBasic_VerifyWithMSBuildWorkspaceAsync() + => VerifyVisualBasicAsync(""" Imports Microsoft.CodeAnalysis.MSBuild Class Usage @@ -86,14 +78,11 @@ Sub M() Dim workspace = MSBuildWorkspace.Create() End Sub End Class - """; - await VerifyVisualBasicAsync(source, s_withMSBuildWorkspaces); - } + """, s_withMSBuildWorkspaces); [Fact] - public async Task VisualBasic_VerifyWithoutMSBuildWorkspaceAsync() - { - const string source = """ + public Task VisualBasic_VerifyWithoutMSBuildWorkspaceAsync() + => VerifyVisualBasicAsync(""" Imports Microsoft.CodeAnalysis.MSBuild Class Usage @@ -101,8 +90,6 @@ Sub M() Dim workspace = [|{|BC30451:MSBuildWorkspace|}|].Create() End Sub End Class - """; - await VerifyVisualBasicAsync(source, s_withDesktopWorkspaces); - } + """, s_withDesktopWorkspaces); } } diff --git a/src/RoslynAnalyzers/PerformanceSensitiveAnalyzers/UnitTests/TypeConversionAllocationAnalyzerTests.cs b/src/RoslynAnalyzers/PerformanceSensitiveAnalyzers/UnitTests/TypeConversionAllocationAnalyzerTests.cs index 39c7bd518870..78b6fe9f4de6 100644 --- a/src/RoslynAnalyzers/PerformanceSensitiveAnalyzers/UnitTests/TypeConversionAllocationAnalyzerTests.cs +++ b/src/RoslynAnalyzers/PerformanceSensitiveAnalyzers/UnitTests/TypeConversionAllocationAnalyzerTests.cs @@ -419,7 +419,7 @@ public void Testing() [Fact] public async Task TypeConversionAllocation_ArgumentWithImplicitStringCastOperatorAsync() { - const string programWithoutImplicitCastOperator = """ + await VerifyCS.VerifyAnalyzerAsync(""" using System; using Roslyn.Utilities; @@ -431,15 +431,11 @@ public static void Dump(AStruct astruct) System.Console.WriteLine(astruct); } } - """; - - await VerifyCS.VerifyAnalyzerAsync(programWithoutImplicitCastOperator, + """, // Test0.cs(10,34): warning HAA0601: Value type to reference type conversion causes boxing at call site (here), and unboxing at the callee-site. Consider using generics if applicable #pragma warning disable RS0030 // Do not use banned APIs VerifyCS.Diagnostic(TypeConversionAllocationAnalyzer.ValueTypeToReferenceTypeConversionRule).WithLocation(9, 34)); -#pragma warning restore RS0030 // Do not use banned APIs - - const string programWithImplicitCastOperator = """ + await VerifyCS.VerifyAnalyzerAsync(""" using System; using Roslyn.Utilities; @@ -464,14 +460,13 @@ public static implicit operator string(AStruct astruct) return astruct.WrappedString; } } - """; - await VerifyCS.VerifyAnalyzerAsync(programWithImplicitCastOperator); + """); } [Fact] public async Task TypeConversionAllocation_YieldReturnImplicitStringCastOperatorAsync() { - const string programWithoutImplicitCastOperator = """ + await VerifyCS.VerifyAnalyzerAsync(""" using System; using Roslyn.Utilities; @@ -483,15 +478,11 @@ public System.Collections.Generic.IEnumerator GetEnumerator() yield return this; } } - """; - - await VerifyCS.VerifyAnalyzerAsync(programWithoutImplicitCastOperator, + """, // Test0.cs(10,22): warning HAA0601: Value type to reference type conversion causes boxing at call site (here), and unboxing at the callee-site. Consider using generics if applicable #pragma warning disable RS0030 // Do not use banned APIs VerifyCS.Diagnostic(TypeConversionAllocationAnalyzer.ValueTypeToReferenceTypeConversionRule).WithLocation(9, 22)); -#pragma warning restore RS0030 // Do not use banned APIs - - const string programWithImplicitCastOperator = """ + await VerifyCS.VerifyAnalyzerAsync(""" using System; using Roslyn.Utilities; @@ -508,9 +499,7 @@ public static implicit operator string(AStruct astruct) return ""; } } - """; - - await VerifyCS.VerifyAnalyzerAsync(programWithImplicitCastOperator); + """); } [Fact] @@ -568,7 +557,7 @@ class Program [Fact] public async Task TypeConversionAllocation_ExpressionBodiedPropertyBoxing_WithBoxingAsync() { - const string snippet = """ + await VerifyCS.VerifyAnalyzerAsync(""" using System; using Roslyn.Utilities; @@ -577,9 +566,7 @@ class Program [PerformanceSensitive("uri")] object Obj => 1; } - """; - - await VerifyCS.VerifyAnalyzerAsync(snippet, + """, // Test0.cs(8,19): warning HAA0601: Value type to reference type conversion causes boxing at call site (here), and unboxing at the callee-site. Consider using generics if applicable #pragma warning disable RS0030 // Do not use banned APIs VerifyCS.Diagnostic(TypeConversionAllocationAnalyzer.ValueTypeToReferenceTypeConversionRule).WithLocation(7, 19)); @@ -587,9 +574,8 @@ await VerifyCS.VerifyAnalyzerAsync(snippet, } [Fact] - public async Task TypeConversionAllocation_ExpressionBodiedPropertyBoxing_WithoutBoxingAsync() - { - const string snippet = """ + public Task TypeConversionAllocation_ExpressionBodiedPropertyBoxing_WithoutBoxingAsync() + => VerifyCS.VerifyAnalyzerAsync(""" using System; using Roslyn.Utilities; @@ -598,15 +584,12 @@ class Program [PerformanceSensitive("uri")] object Obj => 1.ToString(); } - """; - - await VerifyCS.VerifyAnalyzerAsync(snippet); - } + """); [Fact] public async Task TypeConversionAllocation_ExpressionBodiedPropertyDelegateAsync() { - const string snippet = """ + await VerifyCS.VerifyAnalyzerAsync(""" using System; using Roslyn.Utilities; @@ -617,9 +600,7 @@ void Function(int i) { } [PerformanceSensitive("uri")] Action Obj => Function; } - """; - - await VerifyCS.VerifyAnalyzerAsync(snippet, + """, // Test0.cs(10,24): warning HAA0603: This will allocate a delegate instance #pragma warning disable RS0030 // Do not use banned APIs VerifyCS.Diagnostic(TypeConversionAllocationAnalyzer.MethodGroupAllocationRule).WithLocation(9, 24)); @@ -630,7 +611,8 @@ await VerifyCS.VerifyAnalyzerAsync(snippet, public async Task TypeConversionAllocation_ExpressionBodiedPropertyExplicitDelegate_NoWarningAsync() { // Tests that an explicit delegate creation does not trigger HAA0603. It should be handled by HAA0502. - const string snippet = """ + + await VerifyCS.VerifyAnalyzerAsync(""" using System; using Roslyn.Utilities; @@ -641,9 +623,7 @@ void Function(int i) { } [PerformanceSensitive("uri")] Action Obj => new Action(Function); } - """; - - await VerifyCS.VerifyAnalyzerAsync(snippet); + """); } [Fact] @@ -694,9 +674,8 @@ public void SomeMethod() VerifyCS.Diagnostic(TypeConversionAllocationAnalyzer.DelegateOnStructInstanceRule).WithLocation(11, 22)); [Fact] - public async Task TypeConversionAllocation_NoDiagnosticWhenPassingDelegateAsArgumentAsync() - { - const string snippet = """ + public Task TypeConversionAllocation_NoDiagnosticWhenPassingDelegateAsArgumentAsync() + => VerifyCS.VerifyAnalyzerAsync(""" using System; using Roslyn.Utilities; @@ -713,14 +692,11 @@ void DoMore(Action process) process(); } } - """; - await VerifyCS.VerifyAnalyzerAsync(snippet); - } + """); [Fact] - public async Task TypeConversionAllocation_ReportBoxingAllocationForPassingStructInstanceMethodForDelegateConstructorAsync() - { - const string snippet = """ + public Task TypeConversionAllocation_ReportBoxingAllocationForPassingStructInstanceMethodForDelegateConstructorAsync() + => VerifyCS.VerifyAnalyzerAsync(""" using System; using Roslyn.Utilities; @@ -742,17 +718,13 @@ private string FooObjCall(object obj) return obj.ToString(); } } - """; - - await VerifyCS.VerifyAnalyzerAsync(snippet, + """, // Test0.cs(11,54): warning HAA0602: Struct instance method being used for delegate creation, this will result in a boxing instruction VerifyCS.Diagnostic(TypeConversionAllocationAnalyzer.DelegateOnStructInstanceRule).WithSpan(10, 54, 10, 64)); - } [Fact] - public async Task TypeConversionAllocation_DoNotReportBoxingAllocationForPassingStructStaticMethodForDelegateConstructorAsync() - { - const string snippet = """ + public Task TypeConversionAllocation_DoNotReportBoxingAllocationForPassingStructStaticMethodForDelegateConstructorAsync() + => VerifyCS.VerifyAnalyzerAsync(""" using System; using Roslyn.Utilities; @@ -774,15 +746,11 @@ private static string FooObjCall(object obj) return obj.ToString(); } } - """; - - await VerifyCS.VerifyAnalyzerAsync(snippet); - } + """); [Fact] - public async Task TypeConversionAllocation_DoNotReportInlineDelegateAsStructInstanceMethodsAsync() - { - const string snippet = """ + public Task TypeConversionAllocation_DoNotReportInlineDelegateAsStructInstanceMethodsAsync() + => VerifyCS.VerifyAnalyzerAsync(""" using System; using Roslyn.Utilities; @@ -808,8 +776,5 @@ private static void DoSomething2(Action action) { } } - """; - - await VerifyCS.VerifyAnalyzerAsync(snippet); - } + """); } diff --git a/src/RoslynAnalyzers/Roslyn.Diagnostics.Analyzers/UnitTests/NumberCommentsRefactoringTests.cs b/src/RoslynAnalyzers/Roslyn.Diagnostics.Analyzers/UnitTests/NumberCommentsRefactoringTests.cs index a4205d3a6389..468d0951e8f0 100644 --- a/src/RoslynAnalyzers/Roslyn.Diagnostics.Analyzers/UnitTests/NumberCommentsRefactoringTests.cs +++ b/src/RoslynAnalyzers/Roslyn.Diagnostics.Analyzers/UnitTests/NumberCommentsRefactoringTests.cs @@ -12,75 +12,62 @@ namespace Roslyn.Diagnostics.Analyzers.UnitTests public class NumberCommentsRefactoringTests { [Fact] - public async Task TestAsync() - { - const string source = """ + public Task TestAsync() + => VerifyCS.VerifyRefactoringAsync(""" public class C { string s = @" [||]class D { } // "; } - """; - const string fixedSource = """ + """, """ public class C { string s = @" class D { } // 1 "; } - """; - await VerifyCS.VerifyRefactoringAsync(source, fixedSource); - } + """); [Fact] - public async Task TestAsync_RawStringLiteral() - { - const string source = """" + public Task TestAsync_RawStringLiteral() + => VerifyCSharp11Async("""" public class C { string s = """ [||]class D { } // """; } -""""; - const string fixedSource = """" +"""", """" public class C { string s = """ class D { } // 1 """; } -""""; - await VerifyCSharp11Async(source, fixedSource); - } +""""); [Fact] - public async Task TestAsync_RawStringLiteral_Indented() - { - const string source = """" + public Task TestAsync_RawStringLiteral_Indented() + => VerifyCSharp11Async("""" public class C { string s = """ [||]class D { } // """; } -""""; - const string fixedSource = """" +"""", """" public class C { string s = """ class D { } // 1 """; } -""""; - await VerifyCSharp11Async(source, fixedSource); - } +""""); [Fact] - public async Task TestAsync_RawStringLiteral_Indented_Multiple() - { - const string source = """" + public Task TestAsync_RawStringLiteral_Indented_Multiple() + => VerifyCSharp11Async("""" public class C { string s = """ @@ -88,8 +75,7 @@ public class C class E { } //, """; } -""""; - const string fixedSource = """" +"""", """" public class C { string s = """ @@ -97,14 +83,11 @@ class D { } // 1 class E { } // 2, 3 """; } -""""; - await VerifyCSharp11Async(source, fixedSource); - } +""""); [Fact] - public async Task CSharp_VerifyFix_WithTriviaAsync() - { - const string source = """ + public Task CSharp_VerifyFix_WithTriviaAsync() + => VerifyCS.VerifyRefactoringAsync(""" public class C { string s = @@ -112,8 +95,7 @@ public class C class D { } // " /*after*/ ; } - """; - const string fixedSource = """ + """, """ public class C { string s = @@ -121,14 +103,11 @@ public class C class D { } // 1 " /*after*/ ; } - """; - await VerifyCS.VerifyRefactoringAsync(source, fixedSource); - } + """); [Fact] - public async Task CSharp_VerifyFix_NonNumberCommentsLeftAloneAsync() - { - const string source = """ + public Task CSharp_VerifyFix_NonNumberCommentsLeftAloneAsync() + => VerifyCS.VerifyRefactoringAsync(""" public class C { string s = @" @@ -138,8 +117,7 @@ class D // } // test "; } - """; - const string fixedSource = """ + """, """ public class C { string s = @" @@ -149,14 +127,11 @@ class D // 1 } // test "; } - """; - await VerifyCS.VerifyRefactoringAsync(source, fixedSource); - } + """); [Fact] - public async Task CSharp_VerifyFix_MultipleCommasAsync() - { - const string source = """ + public Task CSharp_VerifyFix_MultipleCommasAsync() + => VerifyCS.VerifyRefactoringAsync(""" public class C { string s = @" @@ -165,8 +140,7 @@ public class C } // "; } - """; - const string fixedSource = """ + """, """ public class C { string s = @" @@ -175,54 +149,43 @@ class D // 1 } // 4 "; } - """; - await VerifyCS.VerifyRefactoringAsync(source, fixedSource); - } + """); [Fact] - public async Task CSharp_VerifyFix_LastLineAsync() - { - const string source = """ + public Task CSharp_VerifyFix_LastLineAsync() + => VerifyCS.VerifyRefactoringAsync(""" public class C { string s = @"[||]class D { } //"; } - """; - const string fixedSource = """ + """, """ public class C { string s = @"class D { } // 1"; } - """; - await VerifyCS.VerifyRefactoringAsync(source, fixedSource); - } + """); [Fact] - public async Task CountOverTenAsync() - { - const string source = """ + public Task CountOverTenAsync() + => VerifyCS.VerifyRefactoringAsync(""" public class C { string s = @" [||]class D { } // ,,,,,,,,,,,, "; } - """; - const string fixedSource = """ + """, """ public class C { string s = @" class D { } // 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13 "; } - """; - await VerifyCS.VerifyRefactoringAsync(source, fixedSource); - } + """); [Fact] - public async Task EmptyNumberIsImproperAsync() - { - const string source = """ + public Task EmptyNumberIsImproperAsync() + => VerifyCS.VerifyRefactoringAsync(""" public class C { string s = @" @@ -231,9 +194,7 @@ public class C } // "; } - """; - - const string fixedSource = """ + """, """ public class C { string s = @" @@ -242,15 +203,11 @@ class D // 1 } // 4 "; } - """; - - await VerifyCS.VerifyRefactoringAsync(source, fixedSource); - } + """); [Fact] - public async Task EmptyNumberBeforeCommaIsImproperAsync() - { - const string source = """ + public Task EmptyNumberBeforeCommaIsImproperAsync() + => VerifyCS.VerifyRefactoringAsync(""" public class C { string s = @" @@ -259,9 +216,7 @@ public class C } "; } - """; - - const string fixedSource = """ + """, """ public class C { string s = @" @@ -270,15 +225,11 @@ class C // 1 } "; } - """; - - await VerifyCS.VerifyRefactoringAsync(source, fixedSource); - } + """); [Fact] - public async Task EmptyCommentOnEmptyLineIsProperAsync() - { - const string source = """ + public Task EmptyCommentOnEmptyLineIsProperAsync() + => VerifyCS.VerifyRefactoringAsync(""" public class C { string s = @" @@ -290,9 +241,7 @@ public class C } // "; } - """; - - const string fixedSource = """ + """, """ public class C { string s = @" @@ -304,10 +253,7 @@ class C // 1 } // 4 "; } - """; - - await VerifyCS.VerifyRefactoringAsync(source, fixedSource); - } + """); #region Utilities private async Task VerifyCSharp11Async(string source, string fixedSource) diff --git a/src/RoslynAnalyzers/Roslyn.Diagnostics.Analyzers/UnitTests/PreferNullLiteralTests.cs b/src/RoslynAnalyzers/Roslyn.Diagnostics.Analyzers/UnitTests/PreferNullLiteralTests.cs index 5abafc0ce6da..224c6547859a 100644 --- a/src/RoslynAnalyzers/Roslyn.Diagnostics.Analyzers/UnitTests/PreferNullLiteralTests.cs +++ b/src/RoslynAnalyzers/Roslyn.Diagnostics.Analyzers/UnitTests/PreferNullLiteralTests.cs @@ -129,9 +129,8 @@ void Method2(T value) }.RunAsync(); [Fact] - public async Task NullPointerAsync() - { - var source = """ + public Task NullPointerAsync() + => VerifyCS.VerifyCodeFixAsync(""" unsafe class Type { void Method() @@ -142,8 +141,7 @@ void Method() void Method2(int* value) { } void Method2(byte* value) { } } - """; - var fixedSource = """ + """, """ unsafe class Type { void Method() @@ -154,10 +152,7 @@ void Method() void Method2(int* value) { } void Method2(byte* value) { } } - """; - - await VerifyCS.VerifyCodeFixAsync(source, fixedSource); - } + """); [Fact] public Task PointerInNullableContextAsync() @@ -197,32 +192,26 @@ void Method2(byte* value) { } [Theory] [InlineData("default")] [InlineData("default(object)")] - public async Task PreferNullLiteral_DefaultParameterValueAsync(string defaultValueExpression) - { - var source = $$""" + public Task PreferNullLiteral_DefaultParameterValueAsync(string defaultValueExpression) + => VerifyCS.VerifyCodeFixAsync($$""" class Type { void Method(object value = [|{{defaultValueExpression}}|]) { } } - """; - var fixedSource = """ + """, """ class Type { void Method(object value = null) { } } - """; - - await VerifyCS.VerifyCodeFixAsync(source, fixedSource); - } + """); [Fact] - public async Task PreferNullLiteral_ArgumentFormattingAsync() - { - var source = $$""" + public Task PreferNullLiteral_ArgumentFormattingAsync() + => VerifyCS.VerifyCodeFixAsync($$""" class Type { void Method() @@ -240,8 +229,7 @@ void Method2(params object[] values) { } } - """; - var fixedSource = """ + """, """ class Type { void Method() @@ -259,15 +247,11 @@ void Method2(params object[] values) { } } - """; - - await VerifyCS.VerifyCodeFixAsync(source, fixedSource); - } + """); [Fact] - public async Task PreferNullLiteral_OverloadResolutionAsync() - { - var source = """ + public Task PreferNullLiteral_OverloadResolutionAsync() + => VerifyCS.VerifyCodeFixAsync(""" using System; class Type @@ -285,8 +269,7 @@ void Method2(T value) { } } - """; - var fixedSource = """ + """, """ using System; class Type @@ -304,15 +287,11 @@ void Method2(T value) { } } - """; - - await VerifyCS.VerifyCodeFixAsync(source, fixedSource); - } + """); [Fact] - public async Task PreferNullLiteral_ParenthesizeWhereNecessaryAsync() - { - var source = """ + public Task PreferNullLiteral_ParenthesizeWhereNecessaryAsync() + => VerifyCS.VerifyCodeFixAsync(""" using System; class Type @@ -330,8 +309,7 @@ void Method2(string value) { } } - """; - var fixedSource = """ + """, """ using System; class Type @@ -349,10 +327,7 @@ void Method2(string value) { } } - """; - - await VerifyCS.VerifyCodeFixAsync(source, fixedSource); - } + """); [Fact] public async Task PreferNullLiteral_StructAsync() @@ -403,9 +378,8 @@ T Method() } [Fact] - public async Task PreferNullLiteral_GenericConstrainedToReferenceTypeAsync() - { - var source = """ + public Task PreferNullLiteral_GenericConstrainedToReferenceTypeAsync() + => VerifyCS.VerifyCodeFixAsync(""" class Type { T Method() @@ -414,8 +388,7 @@ T Method() return [|default|]; } } - """; - var fixedSource = """ + """, """ class Type { T Method() @@ -424,10 +397,7 @@ T Method() return null; } } - """; - - await VerifyCS.VerifyCodeFixAsync(source, fixedSource); - } + """); [Fact] public async Task PreferNullLiteral_GenericConstrainedToInterfaceAsync() diff --git a/src/RoslynAnalyzers/Text.Analyzers/UnitTests/IdentifiersShouldBeSpelledCorrectlyTests.cs b/src/RoslynAnalyzers/Text.Analyzers/UnitTests/IdentifiersShouldBeSpelledCorrectlyTests.cs index 73f10827faa0..f94e2c22a6ff 100644 --- a/src/RoslynAnalyzers/Text.Analyzers/UnitTests/IdentifiersShouldBeSpelledCorrectlyTests.cs +++ b/src/RoslynAnalyzers/Text.Analyzers/UnitTests/IdentifiersShouldBeSpelledCorrectlyTests.cs @@ -62,10 +62,8 @@ public static IEnumerable MisspelledMemberParameters [InlineData("class Program { void Member(string name) { } }")] [InlineData("class Program { delegate int GetNumber(string name); }")] [InlineData("class Program { }")] - public async Task NoMisspellings_Verify_NoDiagnosticsAsync(string source) - { - await VerifyCSharpAsync(source); - } + public Task NoMisspellings_Verify_NoDiagnosticsAsync(string source) + => VerifyCSharpAsync(source); [Fact] public async Task MisspellingAllowedByGlobalXmlDictionary_Verify_NoDiagnosticsAsync() @@ -204,24 +202,20 @@ static Solution RenameProjectAssembly(Solution solution, ProjectId projectId) } [Fact] - public async Task NamespaceMisspelled_Verify_EmitsDiagnosticAsync() - { - await VerifyCSharpAsync( + public Task NamespaceMisspelled_Verify_EmitsDiagnosticAsync() + => VerifyCSharpAsync( "namespace Tests.{|#0:MyNarmspace|} {}", VerifyCS.Diagnostic(IdentifiersShouldBeSpelledCorrectlyAnalyzer.NamespaceRule) .WithLocation(0) .WithArguments("Narmspace", "Tests.MyNarmspace")); - } [Fact] - public async Task NamespaceUnmeaningful_Verify_EmitsDiagnosticAsync() - { - await VerifyCSharpAsync( + public Task NamespaceUnmeaningful_Verify_EmitsDiagnosticAsync() + => VerifyCSharpAsync( "namespace Tests.{|#0:A|} {}", VerifyCS.Diagnostic(IdentifiersShouldBeSpelledCorrectlyAnalyzer.NamespaceMoreMeaningfulNameRule) .WithLocation(0) .WithArguments("A")); - } [Theory] [InlineData("namespace MyNamespace { class {|#0:MyClazz|} {} }", "Clazz", "MyNamespace.MyClazz")] @@ -229,14 +223,12 @@ await VerifyCSharpAsync( [InlineData("namespace MyNamespace { enum {|#0:MyEnim|} {} }", "Enim", "MyNamespace.MyEnim")] [InlineData("namespace MyNamespace { interface {|#0:IMyFase|} {} }", "Fase", "MyNamespace.IMyFase")] [InlineData("namespace MyNamespace { delegate int {|#0:MyDelegete|}(); }", "Delegete", "MyNamespace.MyDelegete")] - public async Task TypeMisspelled_Verify_EmitsDiagnosticAsync(string source, string misspelling, string typeName) - { - await VerifyCSharpAsync( + public Task TypeMisspelled_Verify_EmitsDiagnosticAsync(string source, string misspelling, string typeName) + => VerifyCSharpAsync( source, VerifyCS.Diagnostic(IdentifiersShouldBeSpelledCorrectlyAnalyzer.TypeRule) .WithLocation(0) .WithArguments(misspelling, typeName)); - } [Theory] [InlineData("class {|#0:A|} {}", "A")] @@ -244,30 +236,25 @@ await VerifyCSharpAsync( [InlineData("enum {|#0:C|} {}", "C")] [InlineData("interface {|#0:ID|} {}", "D")] [InlineData("delegate int {|#0:E|}();", "E")] - public async Task TypeUnmeaningful_Verify_EmitsDiagnosticAsync(string source, string typeName) - { - await VerifyCSharpAsync( + public Task TypeUnmeaningful_Verify_EmitsDiagnosticAsync(string source, string typeName) + => VerifyCSharpAsync( source, VerifyCS.Diagnostic(IdentifiersShouldBeSpelledCorrectlyAnalyzer.TypeMoreMeaningfulNameRule) .WithLocation(0) .WithArguments(typeName)); - } [Theory] [MemberData(nameof(MisspelledMembers))] - public async Task MemberMisspelled_Verify_EmitsDiagnosticAsync(string source, string misspelling, string memberName) - { - await VerifyCSharpAsync( + public Task MemberMisspelled_Verify_EmitsDiagnosticAsync(string source, string misspelling, string memberName) + => VerifyCSharpAsync( source, VerifyCS.Diagnostic(IdentifiersShouldBeSpelledCorrectlyAnalyzer.MemberRule) .WithLocation(0) .WithArguments(misspelling, memberName)); - } [Fact] - public async Task MemberOverrideMisspelled_Verify_EmitsDiagnosticOnlyAtDefinitionAsync() - { - await VerifyCSharpAsync( + public Task MemberOverrideMisspelled_Verify_EmitsDiagnosticOnlyAtDefinitionAsync() + => VerifyCSharpAsync( """ abstract class Parent { @@ -296,23 +283,19 @@ class Grandchild : Child VerifyCS.Diagnostic(IdentifiersShouldBeSpelledCorrectlyAnalyzer.MemberRule) .WithLocation(1) .WithArguments("Mathod", "Parent.Mathod()")); - } [Theory] [MemberData(nameof(UnmeaningfulMembers))] - public async Task MemberUnmeaningful_Verify_EmitsDiagnosticAsync(string source, string memberName) - { - await VerifyCSharpAsync( + public Task MemberUnmeaningful_Verify_EmitsDiagnosticAsync(string source, string memberName) + => VerifyCSharpAsync( source, VerifyCS.Diagnostic(IdentifiersShouldBeSpelledCorrectlyAnalyzer.MemberMoreMeaningfulNameRule) .WithLocation(0) .WithArguments(memberName)); - } [Fact] - public async Task VariableMisspelled_Verify_EmitsDiagnosticAsync() - { - await VerifyCSharpAsync( + public Task VariableMisspelled_Verify_EmitsDiagnosticAsync() + => VerifyCSharpAsync( """ class Program { @@ -325,23 +308,19 @@ public Program() VerifyCS.Diagnostic(IdentifiersShouldBeSpelledCorrectlyAnalyzer.VariableRule) .WithLocation(0) .WithArguments("Voriable", "myVoriable")); - } [Theory] [MemberData(nameof(MisspelledMemberParameters))] - public async Task MemberParameterMisspelled_Verify_EmitsDiagnosticAsync(string source, string misspelling, string parameterName, string memberName) - { - await VerifyCSharpAsync( + public Task MemberParameterMisspelled_Verify_EmitsDiagnosticAsync(string source, string misspelling, string parameterName, string memberName) + => VerifyCSharpAsync( source, VerifyCS.Diagnostic(IdentifiersShouldBeSpelledCorrectlyAnalyzer.MemberParameterRule) .WithLocation(0) .WithArguments(memberName, misspelling, parameterName)); - } [Fact] - public async Task MemberParameterUnmeaningful_Verify_EmitsDiagnosticAsync() - { - await VerifyCSharpAsync( + public Task MemberParameterUnmeaningful_Verify_EmitsDiagnosticAsync() + => VerifyCSharpAsync( """ class Program { @@ -358,12 +337,10 @@ public void Method(string {|#0:a|}) VerifyCS.Diagnostic(IdentifiersShouldBeSpelledCorrectlyAnalyzer.MemberParameterMoreMeaningfulNameRule) .WithLocation(1) .WithArguments("Program.this[int]", "i")); - } [Fact] - public async Task MemberParameterMisspelledInterfaceImplementation_Verify_EmitsDiagnosticOnlyAtDefinitionAsync() - { - await VerifyCSharpAsync( + public Task MemberParameterMisspelledInterfaceImplementation_Verify_EmitsDiagnosticOnlyAtDefinitionAsync() + => VerifyCSharpAsync( """ interface IProgram { @@ -395,12 +372,10 @@ public void Method2(long {|#2:enviromentId|}) VerifyCS.Diagnostic(IdentifiersShouldBeSpelledCorrectlyAnalyzer.MemberParameterRule) .WithLocation(2) .WithArguments("Program.Method2(long)", "enviroment", "enviromentId")); - } [Fact] - public async Task MemberParameterUnmeaningfulInterfaceImplementation_Verify_EmitsDiagnosticOnlyAtDefinitionAsync() - { - await VerifyCSharpAsync( + public Task MemberParameterUnmeaningfulInterfaceImplementation_Verify_EmitsDiagnosticOnlyAtDefinitionAsync() + => VerifyCSharpAsync( """ interface IProgram { @@ -432,12 +407,10 @@ public void Method2(long {|#2:x|}) VerifyCS.Diagnostic(IdentifiersShouldBeSpelledCorrectlyAnalyzer.MemberParameterMoreMeaningfulNameRule) .WithLocation(2) .WithArguments("Program.Method2(long)", "x")); - } [Fact] - public async Task MemberParameterUnmeaningfulExplicitInterfaceImplementation_Verify_EmitsDiagnosticOnlyAtDefinitionAsync() - { - await VerifyCSharpAsync( + public Task MemberParameterUnmeaningfulExplicitInterfaceImplementation_Verify_EmitsDiagnosticOnlyAtDefinitionAsync() + => VerifyCSharpAsync( """ interface IProgram { @@ -469,12 +442,10 @@ public void Method2(long {|#2:x|}) VerifyCS.Diagnostic(IdentifiersShouldBeSpelledCorrectlyAnalyzer.MemberParameterMoreMeaningfulNameRule) .WithLocation(2) .WithArguments("Program.Method2(long)", "x")); - } [Fact] - public async Task MemberParameterMisspelledExplicitInterfaceImplementation_Verify_EmitsDiagnosticOnlyAtDefinitionAsync() - { - await VerifyCSharpAsync( + public Task MemberParameterMisspelledExplicitInterfaceImplementation_Verify_EmitsDiagnosticOnlyAtDefinitionAsync() + => VerifyCSharpAsync( """ interface IProgram { @@ -506,12 +477,10 @@ public void Method2(long {|#2:enviromentId|}) VerifyCS.Diagnostic(IdentifiersShouldBeSpelledCorrectlyAnalyzer.MemberParameterRule) .WithLocation(2) .WithArguments("Program.Method2(long)", "enviroment", "enviromentId")); - } [Fact] - public async Task MemberParameterMisspelledOverrideImplementation_Verify_EmitsDiagnosticOnlyAtDefinitionAsync() - { - await VerifyCSharpAsync( + public Task MemberParameterMisspelledOverrideImplementation_Verify_EmitsDiagnosticOnlyAtDefinitionAsync() + => VerifyCSharpAsync( """ public abstract class Base { @@ -536,12 +505,10 @@ public void Method2(long {|#1:enviromentId|}) VerifyCS.Diagnostic(IdentifiersShouldBeSpelledCorrectlyAnalyzer.MemberParameterRule) .WithLocation(1) .WithArguments("Derived.Method2(long)", "enviroment", "enviromentId")); - } [Fact] - public async Task MemberParameterMisspelledOverrideImplementationWithNameMismatch_Verify_EmitsDiagnosticOnlyAtDefinitionAsync() - { - await VerifyCSharpAsync( + public Task MemberParameterMisspelledOverrideImplementationWithNameMismatch_Verify_EmitsDiagnosticOnlyAtDefinitionAsync() + => VerifyCSharpAsync( """ public abstract class Base { @@ -602,12 +569,10 @@ public override void Method2(string {|#5:strValue|}) VerifyCS.Diagnostic(IdentifiersShouldBeSpelledCorrectlyAnalyzer.MemberParameterRule) .WithLocation(5) .WithArguments("Derived2.Method2(string)", "str", "strValue")); - } [Fact] - public async Task MemberParameterMisspelledIndexerOVerrideWithNameMismatch_Verify_EmitsDiagnosticOnlyAtDefinitionAsync() - { - await VerifyCSharpAsync( + public Task MemberParameterMisspelledIndexerOVerrideWithNameMismatch_Verify_EmitsDiagnosticOnlyAtDefinitionAsync() + => VerifyCSharpAsync( """ public interface IProgram { @@ -635,27 +600,22 @@ public class DerivedProgram2 : Program VerifyCS.Diagnostic(IdentifiersShouldBeSpelledCorrectlyAnalyzer.MemberParameterRule) .WithLocation(1) .WithArguments("DerivedProgram2.this[int]", "indexe", "indexe")); - } [Fact] - public async Task DelegateParameterMisspelled_Verify_EmitsDiagnosticAsync() - { - await VerifyCSharpAsync( + public Task DelegateParameterMisspelled_Verify_EmitsDiagnosticAsync() + => VerifyCSharpAsync( "delegate void MyDelegate(string {|#0:firstNaem|});", VerifyCS.Diagnostic(IdentifiersShouldBeSpelledCorrectlyAnalyzer.DelegateParameterRule) .WithLocation(0) .WithArguments("MyDelegate", "Naem", "firstNaem")); - } [Fact] - public async Task DelegateParameterUnmeaningful_Verify_EmitsDiagnosticAsync() - { - await VerifyCSharpAsync( + public Task DelegateParameterUnmeaningful_Verify_EmitsDiagnosticAsync() + => VerifyCSharpAsync( "delegate void MyDelegate(string {|#0:a|});", VerifyCS.Diagnostic(IdentifiersShouldBeSpelledCorrectlyAnalyzer.DelegateParameterMoreMeaningfulNameRule) .WithLocation(0) .WithArguments("MyDelegate", "a")); - } [Theory] [InlineData("class MyClass { }", "MyClass", "Wroong", "TWroong")] @@ -663,33 +623,28 @@ await VerifyCSharpAsync( [InlineData("interface IInterface<{|#0:TWroong|}> { }", "IInterface", "Wroong", "TWroong")] [InlineData("delegate int MyDelegate<{|#0:TWroong|}>();", "MyDelegate", "Wroong", "TWroong")] - public async Task TypeTypeParameterMisspelled_Verify_EmitsDiagnosticAsync(string source, string typeName, string misspelling, string typeParameterName) - { - await VerifyCSharpAsync( + public Task TypeTypeParameterMisspelled_Verify_EmitsDiagnosticAsync(string source, string typeName, string misspelling, string typeParameterName) + => VerifyCSharpAsync( source, VerifyCS.Diagnostic(IdentifiersShouldBeSpelledCorrectlyAnalyzer.TypeTypeParameterRule) .WithLocation(0) .WithArguments(typeName, misspelling, typeParameterName)); - } [Theory] [InlineData("class MyClass<{|#0:A|}> { }", "MyClass", "A")] [InlineData("struct MyStructure<{|#0:B|}> { }", "MyStructure", "B")] [InlineData("interface IInterface<{|#0:C|}> { }", "IInterface", "C")] [InlineData("delegate int MyDelegate<{|#0:D|}>();", "MyDelegate", "D")] - public async Task TypeTypeParameterUnmeaningful_Verify_EmitsDiagnosticAsync(string source, string typeName, string typeParameterName) - { - await VerifyCSharpAsync( + public Task TypeTypeParameterUnmeaningful_Verify_EmitsDiagnosticAsync(string source, string typeName, string typeParameterName) + => VerifyCSharpAsync( source, VerifyCS.Diagnostic(IdentifiersShouldBeSpelledCorrectlyAnalyzer.TypeTypeParameterMoreMeaningfulNameRule) .WithLocation(0) .WithArguments(typeName, typeParameterName)); - } [Fact] - public async Task MethodTypeParameterMisspelled_Verify_EmitsDiagnosticAsync() - { - await VerifyCSharpAsync( + public Task MethodTypeParameterMisspelled_Verify_EmitsDiagnosticAsync() + => VerifyCSharpAsync( """ class Program { @@ -701,12 +656,10 @@ class Program VerifyCS.Diagnostic(IdentifiersShouldBeSpelledCorrectlyAnalyzer.MethodTypeParameterRule) .WithLocation(0) .WithArguments("Program.Method(TTipe)", "Tipe", "TTipe")); - } [Fact] - public async Task MethodTypeParameterUnmeaningful_Verify_EmitsDiagnosticAsync() - { - await VerifyCSharpAsync( + public Task MethodTypeParameterUnmeaningful_Verify_EmitsDiagnosticAsync() + => VerifyCSharpAsync( """ class Program { @@ -718,21 +671,16 @@ class Program VerifyCS.Diagnostic(IdentifiersShouldBeSpelledCorrectlyAnalyzer.MethodTypeParameterMoreMeaningfulNameRule) .WithLocation(0) .WithArguments("Program.Method(TA)", "TA")); - } [Fact] - public async Task MisspellingContainsOnlyCapitalizedLetters_Verify_NoDiagnosticsAsync() - { - await VerifyCSharpAsync("class FCCA { }"); - } + public Task MisspellingContainsOnlyCapitalizedLetters_Verify_NoDiagnosticsAsync() + => VerifyCSharpAsync("class FCCA { }"); [Theory] [InlineData("0x0")] [InlineData("0xDEADBEEF")] - public async Task MisspellingStartsWithADigit_Verify_NoDiagnosticsAsync(string misspelling) - { - await VerifyCSharpAsync($"enum Name {{ My{misspelling} }}"); - } + public Task MisspellingStartsWithADigit_Verify_NoDiagnosticsAsync(string misspelling) + => VerifyCSharpAsync($"enum Name {{ My{misspelling} }}"); [Fact] public async Task MalformedXmlDictionary_Verify_EmitsDiagnosticAsync() diff --git a/src/RoslynAnalyzers/Tools/GenerateDocumentationAndConfigFiles/Program.cs b/src/RoslynAnalyzers/Tools/GenerateDocumentationAndConfigFiles/Program.cs index deae10986e16..721aef45d491 100644 --- a/src/RoslynAnalyzers/Tools/GenerateDocumentationAndConfigFiles/Program.cs +++ b/src/RoslynAnalyzers/Tools/GenerateDocumentationAndConfigFiles/Program.cs @@ -257,7 +257,7 @@ public static Task Main(string[] args) return HandleAsync(commandLineArgs, cancellationToken); }); - return rootCommand.Parse(args).InvokeAsync(CancellationToken.None); + return rootCommand.Parse(args).InvokeAsync(null, CancellationToken.None); } private static async Task HandleAsync(CommandLineArgs args, CancellationToken cancellationToken) @@ -992,12 +992,12 @@ void CreateGlobalConfigsForVersion( foreach (var warnAsError in new[] { true, false }) { - foreach (var analysisMode in Enum.GetValues(typeof(AnalysisMode))) + foreach (var analysisMode in Enum.GetValues()) { - CreateGlobalConfig(version, isShippedVersion, analysisLevelVersionString, (AnalysisMode)analysisMode!, warnAsError, releaseTrackingData, category: null); + CreateGlobalConfig(version, isShippedVersion, analysisLevelVersionString, analysisMode, warnAsError, releaseTrackingData, category: null); foreach (var category in categories!) { - CreateGlobalConfig(version, isShippedVersion, analysisLevelVersionString, (AnalysisMode)analysisMode!, warnAsError, releaseTrackingData, category); + CreateGlobalConfig(version, isShippedVersion, analysisLevelVersionString, analysisMode, warnAsError, releaseTrackingData, category); } } } diff --git a/src/RoslynAnalyzers/Tools/RulesetToEditorconfigConverter/Tests/RulesetToEditorconfigConverterTests.cs b/src/RoslynAnalyzers/Tools/RulesetToEditorconfigConverter/Tests/RulesetToEditorconfigConverterTests.cs index 0a3d7293443b..8c6f77b62a1b 100644 --- a/src/RoslynAnalyzers/Tools/RulesetToEditorconfigConverter/Tests/RulesetToEditorconfigConverterTests.cs +++ b/src/RoslynAnalyzers/Tools/RulesetToEditorconfigConverter/Tests/RulesetToEditorconfigConverterTests.cs @@ -48,8 +48,7 @@ private static void Verify(string rulesetText, string expectedEditorconfigText, [Fact] public void RuleSeveritiesPreserved() - { - Verify(""" + => Verify(""" @@ -80,12 +79,10 @@ public void RuleSeveritiesPreserved() dotnet_diagnostic.CA1004.severity = none """); - } [Fact] public void RuleSeveritiesAcrossRulesGroupsPreserved() - { - Verify(""" + => Verify(""" @@ -109,12 +106,10 @@ public void RuleSeveritiesAcrossRulesGroupsPreserved() dotnet_diagnostic.CA1001.severity = warning """); - } [Fact] public void RuleSeverityOverrideAfterIncludePreserved() - { - Verify($""" + => Verify($""" @@ -142,12 +137,10 @@ public void RuleSeverityOverrideAfterIncludePreserved() """); - } [Fact] public void IncludeAllPreserved() - { - Verify(""" + => Verify(""" @@ -171,12 +164,10 @@ public void IncludeAllPreserved() dotnet_diagnostic.CA1000.severity = error """); - } [Fact] public void CommentBeforeRulePreserved() - { - Verify(""" + => Verify(""" @@ -197,12 +188,10 @@ public void CommentBeforeRulePreserved() # Comment before rule dotnet_diagnostic.CA1000.severity = none """); - } [Fact] public void MultilineCommentBeforeRulePreserved() - { - Verify(""" + => Verify(""" @@ -229,12 +218,10 @@ public void MultilineCommentBeforeRulePreserved() # rule dotnet_diagnostic.CA1000.severity = none """); - } [Fact] public void MultipleCommentsBeforeRulePreserved() - { - Verify(""" + => Verify(""" @@ -257,12 +244,10 @@ public void MultipleCommentsBeforeRulePreserved() # Comment2 before rule dotnet_diagnostic.CA1000.severity = none """); - } [Fact] public void CommentAfterRulePreserved() - { - Verify(""" + => Verify(""" @@ -282,12 +267,10 @@ public void CommentAfterRulePreserved() # Comment after rule dotnet_diagnostic.CA1000.severity = none """); - } [Fact] public void CommentsBeforeAndAfterRulePreserved() - { - Verify(""" + => Verify(""" @@ -309,12 +292,10 @@ public void CommentsBeforeAndAfterRulePreserved() # Comment after rule dotnet_diagnostic.CA1000.severity = none """); - } [Fact] public void CommentsFromIncludedRulesetPreserved() - { - Verify($""" + => Verify($""" @@ -341,12 +322,10 @@ public void CommentsFromIncludedRulesetPreserved() """); - } [Fact] public void CommentsFromPrimaryAndIncludedRulesetPreserved() - { - Verify($""" + => Verify($""" @@ -382,12 +361,10 @@ public void CommentsFromPrimaryAndIncludedRulesetPreserved() """); - } [Fact] public void CommentsFromOverrideAfterIncludedRulesetPreserved() - { - Verify($""" + => Verify($""" @@ -419,6 +396,5 @@ public void CommentsFromOverrideAfterIncludedRulesetPreserved() """); - } } } diff --git a/src/RoslynAnalyzers/Utilities.UnitTests/Extensions/IEnumerableExensionsTests.cs b/src/RoslynAnalyzers/Utilities.UnitTests/Extensions/IEnumerableExensionsTests.cs index ca4350321d2a..cd3608974d1b 100644 --- a/src/RoslynAnalyzers/Utilities.UnitTests/Extensions/IEnumerableExensionsTests.cs +++ b/src/RoslynAnalyzers/Utilities.UnitTests/Extensions/IEnumerableExensionsTests.cs @@ -19,9 +19,7 @@ public class IEnumerableExensionsTests [InlineData(3, false)] [Theory] public void IEnumerableHasExactly2_ReturnsTheCorrectValue(int count, bool result) - { - Assert.Equal(result, IEnumerableExtensions.HasExactly(CreateIEnumerable(count), 2)); - } + => Assert.Equal(result, IEnumerableExtensions.HasExactly(CreateIEnumerable(count), 2)); [InlineData(0, false)] [InlineData(1, false)] @@ -29,9 +27,7 @@ public void IEnumerableHasExactly2_ReturnsTheCorrectValue(int count, bool result [InlineData(3, true)] [Theory] public void IEnumerableHasMoreThan2_ReturnsTheCorrectValue(int count, bool result) - { - Assert.Equal(result, IEnumerableExtensions.HasMoreThan(CreateIEnumerable(count), 2)); - } + => Assert.Equal(result, IEnumerableExtensions.HasMoreThan(CreateIEnumerable(count), 2)); [InlineData(0, true)] [InlineData(1, true)] @@ -39,9 +35,7 @@ public void IEnumerableHasMoreThan2_ReturnsTheCorrectValue(int count, bool resul [InlineData(3, false)] [Theory] public void IEnumerableHasFewerThan2_ReturnsTheCorrectValue(int count, bool result) - { - Assert.Equal(result, IEnumerableExtensions.HasFewerThan(CreateIEnumerable(count), 2)); - } + => Assert.Equal(result, IEnumerableExtensions.HasFewerThan(CreateIEnumerable(count), 2)); private static IEnumerable CreateIEnumerable(int count) { @@ -62,9 +56,7 @@ private static IEnumerable CreateIEnumerable(int count) [InlineData(3, false)] [Theory] public void ICollectionHasExactly2_ReturnsTheCorrectValue(int count, bool result) - { - Assert.Equal(result, IEnumerableExtensions.HasExactly(new Collection(count), 2)); - } + => Assert.Equal(result, IEnumerableExtensions.HasExactly(new Collection(count), 2)); [InlineData(0, false)] [InlineData(1, false)] @@ -72,9 +64,7 @@ public void ICollectionHasExactly2_ReturnsTheCorrectValue(int count, bool result [InlineData(3, true)] [Theory] public void ICollectionHasMoreThan2_ReturnsTheCorrectValue(int count, bool result) - { - Assert.Equal(result, IEnumerableExtensions.HasMoreThan(new Collection(count), 2)); - } + => Assert.Equal(result, IEnumerableExtensions.HasMoreThan(new Collection(count), 2)); [InlineData(0, true)] [InlineData(1, true)] @@ -82,9 +72,7 @@ public void ICollectionHasMoreThan2_ReturnsTheCorrectValue(int count, bool resul [InlineData(3, false)] [Theory] public void ICollectionHasFewerThan2_ReturnsTheCorrectValue(int count, bool result) - { - Assert.Equal(result, IEnumerableExtensions.HasFewerThan(new Collection(count), 2)); - } + => Assert.Equal(result, IEnumerableExtensions.HasFewerThan(new Collection(count), 2)); #pragma warning disable CA1010 // Collections should implement generic interface private sealed class Collection : ICollection, IEnumerable @@ -105,9 +93,7 @@ private sealed class Collection : ICollection, IEnumerable [InlineData(3, false)] [Theory] public void IIntCollectionHasExactly2_ReturnsTheCorrectValue(int count, bool result) - { - Assert.Equal(result, IEnumerableExtensions.HasExactly(new IntCollection(count), 2)); - } + => Assert.Equal(result, IEnumerableExtensions.HasExactly(new IntCollection(count), 2)); [InlineData(0, false)] [InlineData(1, false)] @@ -115,9 +101,7 @@ public void IIntCollectionHasExactly2_ReturnsTheCorrectValue(int count, bool res [InlineData(3, true)] [Theory] public void IIntCollectionHasMoreThan2_ReturnsTheCorrectValue(int count, bool result) - { - Assert.Equal(result, IEnumerableExtensions.HasMoreThan(new IntCollection(count), 2)); - } + => Assert.Equal(result, IEnumerableExtensions.HasMoreThan(new IntCollection(count), 2)); [InlineData(0, true)] [InlineData(1, true)] @@ -125,9 +109,7 @@ public void IIntCollectionHasMoreThan2_ReturnsTheCorrectValue(int count, bool re [InlineData(3, false)] [Theory] public void IIntCollectionHasFewerThan2_ReturnsTheCorrectValue(int count, bool result) - { - Assert.Equal(result, IEnumerableExtensions.HasFewerThan(new IntCollection(count), 2)); - } + => Assert.Equal(result, IEnumerableExtensions.HasFewerThan(new IntCollection(count), 2)); private sealed class IntCollection : ICollection { diff --git a/src/RoslynAnalyzers/Utilities.UnitTests/Extensions/ImmutableArrayExensionsTests.cs b/src/RoslynAnalyzers/Utilities.UnitTests/Extensions/ImmutableArrayExensionsTests.cs index 88d60c922180..858093a6493c 100644 --- a/src/RoslynAnalyzers/Utilities.UnitTests/Extensions/ImmutableArrayExensionsTests.cs +++ b/src/RoslynAnalyzers/Utilities.UnitTests/Extensions/ImmutableArrayExensionsTests.cs @@ -16,9 +16,7 @@ public class ImmutableArrayExensionsTests [InlineData(3, false)] [Theory] public void HasExactly2_ReturnsTheCorrectValue(int count, bool result) - { - Assert.Equal(result, global::System.Collections.Immutable.ImmutableArrayExtensions.HasExactly(CreateImmutableArray(count), 2)); - } + => Assert.Equal(result, global::System.Collections.Immutable.ImmutableArrayExtensions.HasExactly(CreateImmutableArray(count), 2)); [InlineData(0, false)] [InlineData(1, false)] @@ -26,9 +24,7 @@ public void HasExactly2_ReturnsTheCorrectValue(int count, bool result) [InlineData(3, true)] [Theory] public void HasMoreThan2_ReturnsTheCorrectValue(int count, bool result) - { - Assert.Equal(result, global::System.Collections.Immutable.ImmutableArrayExtensions.HasMoreThan(CreateImmutableArray(count), 2)); - } + => Assert.Equal(result, global::System.Collections.Immutable.ImmutableArrayExtensions.HasMoreThan(CreateImmutableArray(count), 2)); [InlineData(0, true)] [InlineData(1, true)] @@ -36,9 +32,7 @@ public void HasMoreThan2_ReturnsTheCorrectValue(int count, bool result) [InlineData(3, false)] [Theory] public void HasFewerThan2_ReturnsTheCorrectValue(int count, bool result) - { - Assert.Equal(result, global::System.Collections.Immutable.ImmutableArrayExtensions.HasFewerThan(CreateImmutableArray(count), 2)); - } + => Assert.Equal(result, global::System.Collections.Immutable.ImmutableArrayExtensions.HasFewerThan(CreateImmutableArray(count), 2)); private static ImmutableArray CreateImmutableArray(int count) { diff --git a/src/RoslynAnalyzers/Utilities.UnitTests/FlowAnalysis/Analysis/PropertySetAnalysis/PropertySetAnalysisTests.cs b/src/RoslynAnalyzers/Utilities.UnitTests/FlowAnalysis/Analysis/PropertySetAnalysis/PropertySetAnalysisTests.cs index 434026e4ce08..a816d13a31ac 100644 --- a/src/RoslynAnalyzers/Utilities.UnitTests/FlowAnalysis/Analysis/PropertySetAnalysis/PropertySetAnalysisTests.cs +++ b/src/RoslynAnalyzers/Utilities.UnitTests/FlowAnalysis/Analysis/PropertySetAnalysis/PropertySetAnalysisTests.cs @@ -286,8 +286,7 @@ public static void StaticMethod(TestTypeToTrack staticMethodParameter) [Fact] public void TestTypeToTrack_HazardousIfStringIsNonNull_Flagged() - { - VerifyCSharp(@" + => VerifyCSharp(@" class TestClass { void TestMethod() @@ -299,12 +298,10 @@ void TestMethod() }", TestTypeToTrack_HazardousIfStringIsNonNull, (8, 9, "void TestTypeToTrack.Method()", HazardousUsageEvaluationResult.Flagged)); - } [Fact] public void TestTypeToTrack_HazardousIfStringIsNonNull_StringEmpty_Flagged() - { - VerifyCSharp(@" + => VerifyCSharp(@" using System; class TestClass @@ -318,12 +315,10 @@ void TestMethod() }", TestTypeToTrack_HazardousIfStringIsNonNull, (10, 9, "void TestTypeToTrack.Method()", HazardousUsageEvaluationResult.Flagged)); - } [Fact] public void TestTypeToTrack_HazardousIfStringIsNonNull_Unflagged() - { - VerifyCSharp(@" + => VerifyCSharp(@" class TestClass { void TestMethod() @@ -334,12 +329,10 @@ void TestMethod() }/**/ }", TestTypeToTrack_HazardousIfStringIsNonNull); - } [Fact] public void TestTypeToTrack_HazardousIfStringIsNull_OtherMethod_Flagged() - { - VerifyCSharp(@" + => VerifyCSharp(@" class TestClass { void TestMethod() @@ -352,12 +345,10 @@ void TestMethod() }", TestTypeToTrack_HazardousIfStringIsNonNull, (9, 9, "void OtherClass.OtherMethod(string s, TestTypeToTrack t)", HazardousUsageEvaluationResult.Flagged)); - } [Fact] public void TestTypeToTrack_HazardousIfStringIsNull_StaticMethod_Flagged() - { - VerifyCSharp(@" + => VerifyCSharp(@" class TestClass { void TestMethod() @@ -369,12 +360,10 @@ void TestMethod() }", TestTypeToTrack_HazardousIfStringIsNonNull, (8, 9, "void OtherClass.StaticMethod(TestTypeToTrack staticMethodParameter)", HazardousUsageEvaluationResult.Flagged)); - } [Fact] public void TestTypeToTrack_HazardousIfStringIsNull_OtherClassBothMethods_Flagged() - { - VerifyCSharp(@" + => VerifyCSharp(@" class TestClass { void TestMethod() @@ -389,7 +378,6 @@ void TestMethod() TestTypeToTrack_HazardousIfStringIsNonNull, (9, 9, "void OtherClass.OtherMethod(string s, TestTypeToTrack t)", HazardousUsageEvaluationResult.Flagged), (10, 9, "void OtherClass.StaticMethod(TestTypeToTrack staticMethodParameter)", HazardousUsageEvaluationResult.Flagged)); - } /// /// Parameters for PropertySetAnalysis to flag hazardous usage when the TestTypeToTrackWithConstructor.AString property @@ -448,8 +436,7 @@ void TestMethod() [Fact] public void TestTypeToTrackWithConstructor_HazardousIfStringIsNull_Flagged() - { - VerifyCSharp(@" + => VerifyCSharp(@" class TestClass { void TestMethod() @@ -460,12 +447,10 @@ void TestMethod() }", TestTypeToTrackWithConstructor_HazardousIfStringIsNonNull, (7, 9, "void TestTypeToTrack.Method()", HazardousUsageEvaluationResult.Flagged)); - } [Fact] public void TestTypeToTrackWithConstructor_HazardousIfStringIsNull_StringEmpty_Flagged() - { - VerifyCSharp(@" + => VerifyCSharp(@" using System; class TestClass @@ -478,12 +463,10 @@ void TestMethod() }", TestTypeToTrackWithConstructor_HazardousIfStringIsNonNull, (9, 9, "void TestTypeToTrack.Method()", HazardousUsageEvaluationResult.Flagged)); - } [Fact] public void TestTypeToTrackWithConstructor_HazardousIfStringIsNull_Unflagged() - { - VerifyCSharp(@" + => VerifyCSharp(@" class TestClass { void TestMethod() @@ -493,12 +476,10 @@ void TestMethod() }/**/ }", TestTypeToTrackWithConstructor_HazardousIfStringIsNonNull); - } [Fact] public void TestTypeToTrackWithConstructor_HazardousIfStringIsNull_PropertyAssigned_Flagged() - { - VerifyCSharp(@" + => VerifyCSharp(@" class TestClass { void TestMethod() @@ -510,7 +491,6 @@ void TestMethod() }", TestTypeToTrackWithConstructor_HazardousIfStringIsNonNull, (8, 9, "void TestTypeToTrack.Method()", HazardousUsageEvaluationResult.Flagged)); - } /// /// Parameters for PropertySetAnalysis to flag hazardous usage when the TestTypeToTrack.AnEnum property is Value0 when @@ -547,8 +527,7 @@ void TestMethod() [Fact] public void TestTypeToTrack_HazardousIfEnumIsValue0_Flagged() - { - VerifyCSharp(@" + => VerifyCSharp(@" class TestClass { void TestMethod() @@ -560,12 +539,10 @@ void TestMethod() }", TestTypeToTrack_HazardousIfEnumIsValue0, (8, 9, "void TestTypeToTrack.Method()", HazardousUsageEvaluationResult.Flagged)); - } [Fact] public void TestTypeToTrack_HazardousIfEnumIsValue0_Unflagged() - { - VerifyCSharp(@" + => VerifyCSharp(@" class TestClass { void TestMethod() @@ -576,7 +553,6 @@ void TestMethod() }/**/ }", TestTypeToTrack_HazardousIfEnumIsValue0); - } /// /// Parameters for PropertySetAnalysis to flag hazardous usage when the TestTypeToTrackWithConstructor.AnEnum property @@ -620,8 +596,7 @@ void TestMethod() [Fact] public void TestTypeToTrackWithConstructor_HazardousIfEnumIsValue0_Unflagged() - { - VerifyCSharp(@" + => VerifyCSharp(@" class TestClass { void TestMethod() @@ -631,12 +606,10 @@ void TestMethod() }/**/ }", TestTypeToTrackWithConstructor_HazardousIfEnumIsValue0); - } [Fact] public void TestTypeToTrackWithConstructor_HazardousIfEnumIsValue0_Flagged() - { - VerifyCSharp(@" + => VerifyCSharp(@" class TestClass { void TestMethod() @@ -647,7 +620,6 @@ void TestMethod() }", TestTypeToTrackWithConstructor_HazardousIfEnumIsValue0, (7, 9, "void TestTypeToTrack.Method()", HazardousUsageEvaluationResult.Flagged)); - } /// /// Parameters for PropertySetAnalysis to flag hazardous usage when both TestTypeToTrack.AString starts with 'T' and @@ -702,8 +674,7 @@ void TestMethod() [Fact] public void TestTypeToTrack_HazardousIfStringStartsWithTAndValue2_Flagged() - { - VerifyCSharp(@" + => VerifyCSharp(@" class TestClass { void TestMethod() @@ -716,12 +687,10 @@ void TestMethod() }", TestTypeToTrack_HazardousIfStringStartsWithTAndValue2, (9, 9, "void TestTypeToTrack.Method()", HazardousUsageEvaluationResult.Flagged)); - } [Fact] public void TestTypeToTrack_HazardousIfStringStartsWithTAndValue2_BothMaybe_MaybeFlagged() - { - VerifyCSharp(@" + => VerifyCSharp(@" using System; class TestClass { @@ -746,12 +715,10 @@ void TestMethod() }", TestTypeToTrack_HazardousIfStringStartsWithTAndValue2, (21, 9, "void TestTypeToTrack.Method()", HazardousUsageEvaluationResult.MaybeFlagged)); - } [Fact] public void TestTypeToTrack_HazardousIfStringStartsWithTAndValue2_FirstMaybe_MaybeFlagged() - { - VerifyCSharp(@" + => VerifyCSharp(@" using System; class TestClass { @@ -771,12 +738,10 @@ void TestMethod() }", TestTypeToTrack_HazardousIfStringStartsWithTAndValue2, (16, 9, "void TestTypeToTrack.Method()", HazardousUsageEvaluationResult.MaybeFlagged)); - } [Fact] public void TestTypeToTrack_HazardousIfStringStartsWithTAndValue2_SecondMaybe_MaybeFlagged() - { - VerifyCSharp(@" + => VerifyCSharp(@" using System; class TestClass { @@ -796,12 +761,10 @@ void TestMethod() }", TestTypeToTrack_HazardousIfStringStartsWithTAndValue2, (16, 9, "void TestTypeToTrack.Method()", HazardousUsageEvaluationResult.MaybeFlagged)); - } [Fact] public void TestTypeToTrack_HazardousIfStringStartsWithTAndValue2_FirstFlagged_Unflagged() - { - VerifyCSharp(@" + => VerifyCSharp(@" using System; class TestClass { @@ -814,7 +777,6 @@ void TestMethod() }/**/ }", TestTypeToTrack_HazardousIfStringStartsWithTAndValue2); - } /// /// Parameters for PropertySetAnalysis to flag hazardous usage when both TestTypeToTrack.AnObject is a BitArray. @@ -880,8 +842,7 @@ void TestMethod() [Fact] public void TestTypeToTrackWithConstructor_HazardousIfObjectIsBitArray_Constructor_Flagged() - { - VerifyCSharp(@" + => VerifyCSharp(@" using System; using System.Collections; @@ -895,12 +856,10 @@ void TestMethod() }", TestTypeToTrackWithConstructor_HazardousIfObjectIsBitArray, (10, 9, "void TestTypeToTrack.Method()", HazardousUsageEvaluationResult.Flagged)); - } [Fact] public void TestTypeToTrackWithConstructor_HazardousIfObjectIsBitArray_Constructor_TwoPaths_Flagged() - { - VerifyCSharp(@" + => VerifyCSharp(@" using System; using System.Collections; @@ -918,12 +877,10 @@ void TestMethod() }", TestTypeToTrackWithConstructor_HazardousIfObjectIsBitArray, (14, 9, "void TestTypeToTrack.Method()", HazardousUsageEvaluationResult.Flagged)); - } [Fact] public void TestTypeToTrackWithConstructor_HazardousIfObjectIsBitArray_Constructor_NotFlagged() - { - VerifyCSharp(@" + => VerifyCSharp(@" using System; using System.Collections; @@ -936,7 +893,6 @@ void TestMethod() }/**/ }", TestTypeToTrackWithConstructor_HazardousIfObjectIsBitArray); - } /// /// Parameters for PropertySetAnalysis to flag hazardous usage when both TestTypeToTrackWithConstructor.AString starts @@ -984,8 +940,7 @@ void TestMethod() [Fact] public void TestTypeToTrackWithConstructor_HazardousIfAStringStartsWithA_Flagged() - { - VerifyCSharp(@" + => VerifyCSharp(@" using System; using System.Collections; @@ -999,12 +954,10 @@ void TestMethod() }", TestTypeToTrackWithConstructor_HazardousIfAStringStartsWithA, (10, 9, "void TestTypeToTrack.Method()", HazardousUsageEvaluationResult.Flagged)); - } [Fact] public void TestTypeToTrackWithConstructor_HazardousIfAStringStartsWithA_Interprocedural_Flagged() - { - VerifyCSharp(@" + => VerifyCSharp(@" using System; using System.Collections; @@ -1023,7 +976,6 @@ TestTypeToTrackWithConstructor GetTestType() }", TestTypeToTrackWithConstructor_HazardousIfAStringStartsWithA, (10, 9, "void TestTypeToTrack.Method()", HazardousUsageEvaluationResult.Flagged)); - } /// /// Parameters for PropertySetAnalysis to flag hazardous usage when the TestTypeToTrack.AString property is not null @@ -1064,8 +1016,7 @@ TestTypeToTrackWithConstructor GetTestType() [Fact] public void TestTypeToTrack_HazardousIfStringIsNonNullOnReturn_Flagged() - { - VerifyCSharp(@" + => VerifyCSharp(@" class TestClass { TestTypeToTrack TestMethod() @@ -1077,12 +1028,10 @@ TestTypeToTrack TestMethod() }", TestTypeToTrack_HazardousIfStringIsNonNullOnReturn, (8, 16, null, HazardousUsageEvaluationResult.Flagged)); - } [Fact] public void TestTypeToTrack_HazardousIfStringIsNonNullOnReturn_StringEmpty_Flagged() - { - VerifyCSharp(@" + => VerifyCSharp(@" using System; class TestClass { @@ -1095,12 +1044,10 @@ TestTypeToTrack TestMethod() }", TestTypeToTrack_HazardousIfStringIsNonNullOnReturn, (9, 16, null, HazardousUsageEvaluationResult.Flagged)); - } [Fact] public void TestTypeToTrack_HazardousIfStringIsNonNullOnReturns_Unflagged() - { - VerifyCSharp(@" + => VerifyCSharp(@" class TestClass { TestTypeToTrack TestMethod() @@ -1111,12 +1058,10 @@ TestTypeToTrack TestMethod() }/**/ }", TestTypeToTrack_HazardousIfStringIsNonNullOnReturn); - } [Fact] public void TestTypeToTrack_HazardousIfStringIsNonNullOnReturns_ReturnObject_Unflagged() - { - VerifyCSharp(@" + => VerifyCSharp(@" class TestClass { object TestMethod() @@ -1127,7 +1072,6 @@ object TestMethod() }/**/ }", TestTypeToTrack_HazardousIfStringIsNonNullOnReturn); - } /// /// Parameters for PropertySetAnalysis to flag hazardous usage when the TestTypeToTrack.AString and @@ -1184,8 +1128,7 @@ object TestMethod() [Fact] public void TestTypeToTrack_HazardousIfStringObjectIsNonNull_AStringNonNull_Flagged() - { - VerifyCSharp(@" + => VerifyCSharp(@" class TestClass { void TestMethod() @@ -1197,12 +1140,10 @@ void TestMethod() }", TestTypeToTrack_HazardousIfStringObjectIsNonNull, (8, 9, "void TestTypeToTrack.Method()", HazardousUsageEvaluationResult.Flagged)); - } [Fact] public void TestTypeToTrack_HazardousIfStringObjectIsNonNull_AnObjectNonNull_Flagged() - { - VerifyCSharp(@" + => VerifyCSharp(@" class TestClass { void TestMethod() @@ -1214,12 +1155,10 @@ void TestMethod() }", TestTypeToTrack_HazardousIfStringObjectIsNonNull, (8, 9, "void TestTypeToTrack.Method()", HazardousUsageEvaluationResult.Flagged)); - } [Fact] public void TestTypeToTrack_HazardousIfStringObjectIsNonNull_StringEmpty_Flagged() - { - VerifyCSharp(@" + => VerifyCSharp(@" using System; class TestClass { @@ -1232,12 +1171,10 @@ void TestMethod() }", TestTypeToTrack_HazardousIfStringObjectIsNonNull, (9, 9, "void TestTypeToTrack.Method()", HazardousUsageEvaluationResult.Flagged)); - } [Fact] public void TestTypeToTrack_HazardousIfStringObjectIsNonNull_StringNonNull_ObjectNull_Unflagged() - { - VerifyCSharp(@" + => VerifyCSharp(@" class TestClass { void TestMethod() @@ -1249,12 +1186,10 @@ void TestMethod() }/**/ }", TestTypeToTrack_HazardousIfStringObjectIsNonNull); - } [Fact] public void TestTypeToTrack_HazardousIfStringObjectIsNonNull_AnObjectNonNull_StringNull_Unflagged() - { - VerifyCSharp(@" + => VerifyCSharp(@" class TestClass { void TestMethod() @@ -1266,7 +1201,6 @@ void TestMethod() }/**/ }", TestTypeToTrack_HazardousIfStringObjectIsNonNull); - } private ITestOutputHelper TestOutput { get; } diff --git a/src/RoslynAnalyzers/Utilities/Compiler/Options/AnalyzerOptionsExtensions.cs b/src/RoslynAnalyzers/Utilities/Compiler/Options/AnalyzerOptionsExtensions.cs index 3c1cee6b7e92..49aa7dadceaf 100644 --- a/src/RoslynAnalyzers/Utilities/Compiler/Options/AnalyzerOptionsExtensions.cs +++ b/src/RoslynAnalyzers/Utilities/Compiler/Options/AnalyzerOptionsExtensions.cs @@ -26,7 +26,7 @@ internal static partial class AnalyzerOptionsExtensions { private static readonly ConditionalWeakTable s_cachedOptions = new(); private static readonly ImmutableHashSet s_defaultOutputKinds = - ImmutableHashSet.CreateRange(Enum.GetValues(typeof(OutputKind)).Cast()); + ImmutableHashSet.CreateRange(Enum.GetValues()); private static bool TryGetSyntaxTreeForOption(ISymbol symbol, [NotNullWhen(returnValue: true)] out SyntaxTree? tree) { diff --git a/src/RoslynAnalyzers/Utilities/FlowAnalysis/FlowAnalysis/Analysis/PropertySetAnalysis/PropertySetAbstractValue.ValuePool.cs b/src/RoslynAnalyzers/Utilities/FlowAnalysis/FlowAnalysis/Analysis/PropertySetAnalysis/PropertySetAbstractValue.ValuePool.cs index 2c2ad9118fd4..5a896f20c93f 100644 --- a/src/RoslynAnalyzers/Utilities/FlowAnalysis/FlowAnalysis/Analysis/PropertySetAnalysis/PropertySetAbstractValue.ValuePool.cs +++ b/src/RoslynAnalyzers/Utilities/FlowAnalysis/FlowAnalysis/Analysis/PropertySetAnalysis/PropertySetAbstractValue.ValuePool.cs @@ -26,7 +26,7 @@ private class ValuePool public ValuePool() { - int[] values = Enum.GetValues(typeof(PropertySetAbstractValueKind)).Cast().ToArray(); + int[] values = Enum.GetValues().Cast().ToArray(); Array.Sort(values); for (int i = 0; i < values.Length; i++) { diff --git a/src/RoslynAnalyzers/Utilities/FlowAnalysis/FlowAnalysis/Analysis/TaintedDataAnalysis/TaintedDataConfig.cs b/src/RoslynAnalyzers/Utilities/FlowAnalysis/FlowAnalysis/Analysis/TaintedDataAnalysis/TaintedDataConfig.cs index e72c1c488bf8..55282a867c4a 100644 --- a/src/RoslynAnalyzers/Utilities/FlowAnalysis/FlowAnalysis/Analysis/TaintedDataAnalysis/TaintedDataConfig.cs +++ b/src/RoslynAnalyzers/Utilities/FlowAnalysis/FlowAnalysis/Analysis/TaintedDataAnalysis/TaintedDataConfig.cs @@ -111,7 +111,7 @@ private static TaintedDataConfig Create(Compilation compilation) PooledDictionary<(ImmutableHashSet SourceInfos, ImmutableHashSet SanitizerInfos), (ImmutableHashSet.Builder SinkKinds, ImmutableHashSet.Builder SinkInfos)>.GetInstance(out var sourceSanitizersToSinks); // Using LazyThreadSafetyMode.ExecutionAndPublication to avoid instantiating multiple times. - foreach (SinkKind sinkKind in Enum.GetValues(typeof(SinkKind))) + foreach (var sinkKind in Enum.GetValues()) { ImmutableHashSet sources = GetSourceInfos(sinkKind); if (!sourcesToSymbolMap.TryGetValue(sources, out Lazy> lazySourceSymbolMap)) diff --git a/src/Scripting/CSharpTest/CommandLineRunnerTests.cs b/src/Scripting/CSharpTest/CommandLineRunnerTests.cs index faf7fa792a9e..874cd142ca8d 100644 --- a/src/Scripting/CSharpTest/CommandLineRunnerTests.cs +++ b/src/Scripting/CSharpTest/CommandLineRunnerTests.cs @@ -762,7 +762,7 @@ public void LangVersions() var runner = CreateRunner(["/langversion:?"]); Assert.Equal(0, runner.RunInteractive()); - var expected = Enum.GetValues(typeof(LanguageVersion)).Cast() + var expected = Enum.GetValues() .Select(v => v.ToDisplayString()); var actual = runner.Console.Out.ToString(); diff --git a/src/Test/Perf/Utilities/VsPerfTest.cs b/src/Test/Perf/Utilities/VsPerfTest.cs index ef32c4b258da..4c3fc2202d0b 100644 --- a/src/Test/Perf/Utilities/VsPerfTest.cs +++ b/src/Test/Perf/Utilities/VsPerfTest.cs @@ -89,12 +89,10 @@ protected void InstallVsixes() public override void Test() { - var args = $"{Path.Combine(TempDirectory, _testTemplateName)} -perf -host:vs -roslynonly -rootsuffix:{_rootSuffix}"; - ShellOutVital(TaoPath, args, TempDirectory); + ShellOutVital(TaoPath, $"{Path.Combine(TempDirectory, _testTemplateName)} -perf -host:vs -roslynonly -rootsuffix:{_rootSuffix}", TempDirectory); var logDirectory = Path.Combine(TempDirectory, _testName, "PerfResults"); - var xcopyArgs = $"{logDirectory} {Path.Combine(MyBinaries(), "..", "..", "ToArchive")} /s /i /y"; - ShellOutVital("xcopy", xcopyArgs); + ShellOutVital("xcopy", $"{logDirectory} {Path.Combine(MyBinaries(), "..", "..", "ToArchive")} /s /i /y"); foreach (var xml in Directory.EnumerateFiles(logDirectory, "*.xml")) { diff --git a/src/Tools/ExternalAccess/Razor/Features/RazorCSharpFormattingInteractionService.cs b/src/Tools/ExternalAccess/Razor/Features/RazorCSharpFormattingInteractionService.cs index c613c5cc5ae6..0c1ae6d970fa 100644 --- a/src/Tools/ExternalAccess/Razor/Features/RazorCSharpFormattingInteractionService.cs +++ b/src/Tools/ExternalAccess/Razor/Features/RazorCSharpFormattingInteractionService.cs @@ -2,7 +2,6 @@ // 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.Generic; using System.Collections.Immutable; using System.Threading; @@ -23,6 +22,14 @@ namespace Microsoft.CodeAnalysis.ExternalAccess.Razor /// internal static class RazorCSharpFormattingInteractionService { + public static RazorCSharpSyntaxFormattingOptions GetRazorCSharpSyntaxFormattingOptions(SolutionServices services) + { + var legacyOptionsService = services.GetService(); + var options = legacyOptionsService?.GetSyntaxFormattingOptions(services.GetLanguageServices(LanguageNames.CSharp)) + ?? CSharpSyntaxFormattingOptions.Default; + return new RazorCSharpSyntaxFormattingOptions((CSharpSyntaxFormattingOptions)options); + } + /// /// Returns the text changes necessary to format the document after the user enters a /// character. The position provided is the position of the caret in the document after diff --git a/src/Tools/ExternalAccess/Razor/Features/RazorCSharpSyntaxFormattingOptions.cs b/src/Tools/ExternalAccess/Razor/Features/RazorCSharpSyntaxFormattingOptions.cs index 2c1b57bd4e9d..e182f7b3c065 100644 --- a/src/Tools/ExternalAccess/Razor/Features/RazorCSharpSyntaxFormattingOptions.cs +++ b/src/Tools/ExternalAccess/Razor/Features/RazorCSharpSyntaxFormattingOptions.cs @@ -3,6 +3,7 @@ // See the LICENSE file in the project root for more information. using System; +using System.Runtime.Serialization; using Microsoft.CodeAnalysis.CodeStyle; using Microsoft.CodeAnalysis.CSharp.Formatting; @@ -11,17 +12,18 @@ namespace Microsoft.CodeAnalysis.ExternalAccess.Razor.Features /// /// Wrapper for CSharpSyntaxFormattingOptions for Razor external access. /// + [DataContract] internal sealed record class RazorCSharpSyntaxFormattingOptions( - RazorSpacePlacement Spacing, - RazorBinaryOperatorSpacingOptions SpacingAroundBinaryOperator, - RazorNewLinePlacement NewLines, - RazorLabelPositionOptions LabelPositioning, - RazorIndentationPlacement Indentation, - bool WrappingKeepStatementsOnSingleLine, - bool WrappingPreserveSingleLine, - RazorNamespaceDeclarationPreference NamespaceDeclarations, - bool PreferTopLevelStatements, - int CollectionExpressionWrappingLength) + [property: DataMember] RazorSpacePlacement Spacing, + [property: DataMember] RazorBinaryOperatorSpacingOptions SpacingAroundBinaryOperator, + [property: DataMember] RazorNewLinePlacement NewLines, + [property: DataMember] RazorLabelPositionOptions LabelPositioning, + [property: DataMember] RazorIndentationPlacement Indentation, + [property: DataMember] bool WrappingKeepStatementsOnSingleLine, + [property: DataMember] bool WrappingPreserveSingleLine, + [property: DataMember] RazorNamespaceDeclarationPreference NamespaceDeclarations, + [property: DataMember] bool PreferTopLevelStatements, + [property: DataMember] int CollectionExpressionWrappingLength) { public static readonly RazorCSharpSyntaxFormattingOptions Default = new(); diff --git a/src/VisualStudio/CSharp/Impl/CSharpPackage.cs b/src/VisualStudio/CSharp/Impl/CSharpPackage.cs index bd22bb8b85c9..51b9e1a42331 100644 --- a/src/VisualStudio/CSharp/Impl/CSharpPackage.cs +++ b/src/VisualStudio/CSharp/Impl/CSharpPackage.cs @@ -4,6 +4,7 @@ using System; using System.Collections.Generic; +using System.ComponentModel.Design; using System.Runtime.InteropServices; using System.Threading; using Microsoft.CodeAnalysis; @@ -52,6 +53,7 @@ namespace Microsoft.VisualStudio.LanguageServices.CSharp.LanguageService; [ProvideLanguageEditorOptionPage(typeof(Options.NamingStylesOptionPage), "CSharp", @"Code Style", "Naming", pageNameResourceId: "#115", keywordListResourceId: 314)] [ProvideLanguageEditorOptionPage(typeof(Options.IntelliSenseOptionPage), "CSharp", null, "IntelliSense", pageNameResourceId: "#103", keywordListResourceId: 312)] [ProvideSettingsManifest(PackageRelativeManifestFile = @"UnifiedSettings\csharpSettings.registration.json")] +[ProvideService(typeof(ICSharpTempPECompilerService), IsAsyncQueryable = false, IsCacheable = true, IsFreeThreaded = true, ServiceName = "C# TempPE Compiler Service")] [Guid(Guids.CSharpPackageIdString)] internal sealed class CSharpPackage : AbstractPackage, IVsUserSettingsQuery { @@ -69,10 +71,9 @@ private Task PackageInitializationBackgroundThreadAsync(PackageLoadTasks package { try { - this.RegisterService(async ct => + ((IServiceContainer)this).AddService(typeof(ICSharpTempPECompilerService), (_, _) => { var workspace = this.ComponentModel.GetService(); - await JoinableTaskFactory.SwitchToMainThreadAsync(ct); return new TempPECompilerService(workspace.Services.GetService()); }); } diff --git a/src/VisualStudio/CSharp/Impl/PackageRegistration.pkgdef b/src/VisualStudio/CSharp/Impl/PackageRegistration.pkgdef index 1a5637a51aad..6de5ab0d6747 100644 --- a/src/VisualStudio/CSharp/Impl/PackageRegistration.pkgdef +++ b/src/VisualStudio/CSharp/Impl/PackageRegistration.pkgdef @@ -34,11 +34,6 @@ "Name"="C# Language Service" "IsAsyncQueryable"=dword:00000001 -[$RootKey$\Services\{dba64c84-56df-4e20-8aa6-02332a97f474}] -@="{13c3bbb4-f18f-4111-9f54-a0fb010d9194}" -"Name"="C# TempPE Compiler Service" -"IsAsyncQueryable"=dword:00000001 - [$RootKey$\AutomationProperties\TextEditor\CSharp-Specific] @="#104" "Description"="#105" diff --git a/src/VisualStudio/CSharp/Impl/SemanticSearch/SemanticSearchQueryExecutor.cs b/src/VisualStudio/CSharp/Impl/SemanticSearch/SemanticSearchQueryExecutor.cs index 7766871000a8..cf452757d6c1 100644 --- a/src/VisualStudio/CSharp/Impl/SemanticSearch/SemanticSearchQueryExecutor.cs +++ b/src/VisualStudio/CSharp/Impl/SemanticSearch/SemanticSearchQueryExecutor.cs @@ -8,6 +8,7 @@ using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.Classification; using Microsoft.CodeAnalysis.ErrorReporting; +using Microsoft.CodeAnalysis.FindSymbols; using Microsoft.CodeAnalysis.FindUsages; using Microsoft.CodeAnalysis.Internal.Log; using Microsoft.CodeAnalysis.Notification; @@ -20,8 +21,11 @@ internal sealed class SemanticSearchQueryExecutor( FindUsagesContext presenterContext, IOptionsReader options) { - private sealed class ResultsObserver(IFindUsagesContext presenterContext, Document? queryDocument) : ISemanticSearchResultsObserver + private sealed class ResultsObserver(IFindUsagesContext presenterContext, IOptionsReader options, Document? queryDocument) : ISemanticSearchResultsDefinitionObserver { + public ValueTask GetClassificationOptionsAsync(Microsoft.CodeAnalysis.Host.LanguageServices language, CancellationToken cancellationToken) + => new(options.GetClassificationOptions(language.Language)); + public ValueTask OnDefinitionFoundAsync(DefinitionItem definition, CancellationToken cancellationToken) => presenterContext.OnDefinitionFoundAsync(definition, cancellationToken); @@ -36,9 +40,6 @@ public ValueTask OnUserCodeExceptionAsync(UserCodeExceptionInfo exception, Cance new SearchExceptionDefinitionItem(exception.Message, exception.TypeName, exception.StackTrace, (queryDocument != null) ? new DocumentSpan(queryDocument, exception.Span) : default), cancellationToken); } - private readonly OptionsProvider _classificationOptionsProvider = - OptionsProvider.GetProvider(options, static (reader, language) => reader.GetClassificationOptions(language)); - public async Task ExecuteAsync(string? query, Document? queryDocument, Solution solution, CancellationToken cancellationToken) { Contract.ThrowIfFalse(query is null ^ queryDocument is null); @@ -58,7 +59,7 @@ public async Task ExecuteAsync(string? query, Document? queryDocument, Solution return; } - var resultsObserver = new ResultsObserver(presenterContext, queryDocument); + var resultsObserver = new ResultsObserver(presenterContext, options, queryDocument); query ??= (await queryDocument!.GetTextAsync(cancellationToken).ConfigureAwait(false)).ToString(); ExecuteQueryResult result = default; @@ -96,7 +97,6 @@ public async Task ExecuteAsync(string? query, Document? queryDocument, Solution solution, compileResult.Value.QueryId, resultsObserver, - _classificationOptionsProvider, cancellationToken).ConfigureAwait(false); } catch (Exception e) when (FatalError.ReportAndPropagateUnlessCanceled(e, cancellationToken, ErrorSeverity.Critical)) diff --git a/src/VisualStudio/CSharp/Test/EditorConfigSettings/DataProvider/DataProviderTests.cs b/src/VisualStudio/CSharp/Test/EditorConfigSettings/DataProvider/DataProviderTests.cs index a4fb6b4a1df5..0fc9e17f92cb 100644 --- a/src/VisualStudio/CSharp/Test/EditorConfigSettings/DataProvider/DataProviderTests.cs +++ b/src/VisualStudio/CSharp/Test/EditorConfigSettings/DataProvider/DataProviderTests.cs @@ -66,9 +66,7 @@ private static ISettingsProvider TestGettingSettingsProviderFromLanguageServi [Fact] public void TestGettingAnalyzerSettingsProvider() - { - TestGettingSettingsProviderFromWorkspace(); - } + => TestGettingSettingsProviderFromWorkspace(); [Fact] public void TestGettingCodeStyleSettingsProvider() @@ -86,9 +84,7 @@ public void TestGettingWhitespaceSettingsProvider() [Fact] public void TestGettingNamingStyleSettingsProvider() - { - TestGettingSettingsProviderFromWorkspace(); - } + => TestGettingSettingsProviderFromWorkspace(); [Fact] public void TestGettingAnalyzerSettingsProviderWorkspaceServiceAsync() diff --git a/src/VisualStudio/CSharp/Test/GlyphExtensionsTests.cs b/src/VisualStudio/CSharp/Test/GlyphExtensionsTests.cs index 42970d1a2404..10b698eb77e5 100644 --- a/src/VisualStudio/CSharp/Test/GlyphExtensionsTests.cs +++ b/src/VisualStudio/CSharp/Test/GlyphExtensionsTests.cs @@ -147,30 +147,24 @@ public void GetGlyphGroupTests() [Fact, WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/545015")] public void TestRegularOperatorGlyph() - { - TestGlyph( + => TestGlyph( StandardGlyphGroup.GlyphGroupOperator, SymbolKind.Method, methodKind: MethodKind.UserDefinedOperator); - } [Fact, WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/545015")] public void TestConversionOperatorGlyph() - { - TestGlyph( + => TestGlyph( StandardGlyphGroup.GlyphGroupOperator, SymbolKind.Method, methodKind: MethodKind.Conversion); - } [Fact] public void TestWithEventsMemberGlyph() - { - TestGlyph( + => TestGlyph( StandardGlyphGroup.GlyphGroupField, SymbolKind.Property, isWithEvents: true); - } private static void TestGlyph( StandardGlyphGroup expectedGlyphGroup, diff --git a/src/VisualStudio/CSharp/Test/Interactive/Commands/InteractiveCommandHandlerTests.cs b/src/VisualStudio/CSharp/Test/Interactive/Commands/InteractiveCommandHandlerTests.cs index 490ec9ed386c..8123d6b1f062 100644 --- a/src/VisualStudio/CSharp/Test/Interactive/Commands/InteractiveCommandHandlerTests.cs +++ b/src/VisualStudio/CSharp/Test/Interactive/Commands/InteractiveCommandHandlerTests.cs @@ -169,9 +169,7 @@ public void TestCopyToInteractiveWithoutSelection() [WpfFact] public void TestCopyToInteractive() - { - AssertCopyToInteractive($"{{|Selection:{ExampleCode2}$$|}}", ExampleCode2); - } + => AssertCopyToInteractive($"{{|Selection:{ExampleCode2}$$|}}", ExampleCode2); [WpfFact] public void TestCopyToInteractiveWithNonEmptyBuffer() diff --git a/src/VisualStudio/CSharp/Test/ProjectSystemShim/EntryPointFinderTests.cs b/src/VisualStudio/CSharp/Test/ProjectSystemShim/EntryPointFinderTests.cs index c316cf267bc5..b43852156bf0 100644 --- a/src/VisualStudio/CSharp/Test/ProjectSystemShim/EntryPointFinderTests.cs +++ b/src/VisualStudio/CSharp/Test/ProjectSystemShim/EntryPointFinderTests.cs @@ -21,13 +21,11 @@ public void PositiveTests( [CombinatorialValues("public", "private", "")] string accessibility, [CombinatorialValues("void", "int", "System.Int32", "Int32", "ValueTask", "Task", "ValueTask", "Task")] string returnType, [CombinatorialValues("string[] args", "string[] args1", "")] string parameters) - { - Validate($"static {accessibility} {returnType} Main({parameters})", entryPoints => + => Validate($"static {accessibility} {returnType} Main({parameters})", entryPoints => { Assert.Single(entryPoints); Assert.Equal("C", entryPoints.Single().Name); }); - } private static void NegativeTest(string signature) => Validate(signature, Assert.Empty); @@ -55,34 +53,26 @@ public void TestWrongName( [CombinatorialValues("public", "private", "")] string accessibility, [CombinatorialValues("void", "int", "System.Int32", "Int32", "ValueTask", "Task", "ValueTask", "Task")] string returnType, [CombinatorialValues("string[] args", "string[] args1", "")] string parameters) - { - NegativeTest($"static {accessibility} {returnType} main({parameters})"); - } + => NegativeTest($"static {accessibility} {returnType} main({parameters})"); [Theory, CombinatorialData] public void TestNotStatic( [CombinatorialValues("public", "private", "")] string accessibility, [CombinatorialValues("void", "int", "System.Int32", "Int32", "ValueTask", "Task", "ValueTask", "Task")] string returnType, [CombinatorialValues("string[] args", "string[] args1", "")] string parameters) - { - NegativeTest($"{accessibility} {returnType} Main({parameters})"); - } + => NegativeTest($"{accessibility} {returnType} Main({parameters})"); [Theory, CombinatorialData] public void TestInvalidReturnType( [CombinatorialValues("public", "private", "")] string accessibility, [CombinatorialValues("string", "Task", "ValueTask")] string returnType, [CombinatorialValues("string[] args", "string[] args1", "")] string parameters) - { - NegativeTest($"static {accessibility} {returnType} Main({parameters})"); - } + => NegativeTest($"static {accessibility} {returnType} Main({parameters})"); [Theory, CombinatorialData] public void TestInvalidParameterTypes( [CombinatorialValues("public", "private", "")] string accessibility, [CombinatorialValues("void", "int", "System.Int32", "Int32", "ValueTask", "Task", "ValueTask", "Task")] string returnType, [CombinatorialValues("string args", "string* args", "int[] args", "string[] args1, string[] args2")] string parameters) - { - NegativeTest($"static {accessibility} {returnType} Main({parameters})"); - } + => NegativeTest($"static {accessibility} {returnType} Main({parameters})"); } diff --git a/src/VisualStudio/CSharp/Test/ProjectSystemShim/VisualStudioCompilationOutputFilesTests.cs b/src/VisualStudio/CSharp/Test/ProjectSystemShim/VisualStudioCompilationOutputFilesTests.cs index 6ee1e902fc1b..852481e09f67 100644 --- a/src/VisualStudio/CSharp/Test/ProjectSystemShim/VisualStudioCompilationOutputFilesTests.cs +++ b/src/VisualStudio/CSharp/Test/ProjectSystemShim/VisualStudioCompilationOutputFilesTests.cs @@ -19,9 +19,7 @@ public sealed class VisualStudioCompilationOutputFilesTests : TestBase { [Fact] public void OpenStream_Errors() - { - Assert.Throws(() => new CompilationOutputFilesWithImplicitPdbPath(@"a.dll")); - } + => Assert.Throws(() => new CompilationOutputFilesWithImplicitPdbPath(@"a.dll")); [Theory] [InlineData(DebugInformationFormat.PortablePdb, true)] diff --git a/src/VisualStudio/Core/Def/CodeCleanup/AbstractCodeCleanUpFixer.cs b/src/VisualStudio/Core/Def/CodeCleanup/AbstractCodeCleanUpFixer.cs index e3cac6db1004..80d620c98b01 100644 --- a/src/VisualStudio/Core/Def/CodeCleanup/AbstractCodeCleanUpFixer.cs +++ b/src/VisualStudio/Core/Def/CodeCleanup/AbstractCodeCleanUpFixer.cs @@ -15,7 +15,7 @@ using Microsoft.CodeAnalysis.Host; using Microsoft.CodeAnalysis.Progress; using Microsoft.CodeAnalysis.Shared.Extensions; -using Microsoft.CodeAnalysis.Shared.Utilities; +using Microsoft.CodeAnalysis.Threading; using Microsoft.CodeAnalysis.Text; using Microsoft.VisualStudio.Editor.CodeCleanup; using Microsoft.VisualStudio.Language.CodeCleanUp; @@ -211,7 +211,7 @@ private static async Task FixProjectsAsync( cancellationToken.ThrowIfCancellationRequested(); // And for each project, process all the documents in parallel. - await RoslynParallel.ForEachAsync( + await Parallel.ForEachAsync( source: project.Documents, cancellationToken, async (document, cancellationToken) => diff --git a/src/VisualStudio/Core/Def/DesignerAttribute/VisualStudioDesignerAttributeService.cs b/src/VisualStudio/Core/Def/DesignerAttribute/VisualStudioDesignerAttributeService.cs index 9ab714cc085e..19186ff2d2b4 100644 --- a/src/VisualStudio/Core/Def/DesignerAttribute/VisualStudioDesignerAttributeService.cs +++ b/src/VisualStudio/Core/Def/DesignerAttribute/VisualStudioDesignerAttributeService.cs @@ -315,6 +315,6 @@ public ValueTask ReportDesignerAttributeDataAsync(ImmutableArray diff --git a/src/VisualStudio/Core/Def/Extensions/VsTextSpanExtensions.cs b/src/VisualStudio/Core/Def/Extensions/VsTextSpanExtensions.cs index 6d8f9d9361fc..c4a89df92f61 100644 --- a/src/VisualStudio/Core/Def/Extensions/VsTextSpanExtensions.cs +++ b/src/VisualStudio/Core/Def/Extensions/VsTextSpanExtensions.cs @@ -5,6 +5,7 @@ using System.Threading; using System.Threading.Tasks; using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.Editor.Shared.Extensions; using Microsoft.CodeAnalysis.Editor.Shared.Utilities; using Microsoft.VisualStudio.LanguageServices.Implementation.Venus; using VsTextSpan = Microsoft.VisualStudio.TextManager.Interop.TextSpan; @@ -24,6 +25,24 @@ internal static class VsTextSpanExtensions return null; await threadingContext.JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken); + return MapSpanFromSecondaryBufferToPrimaryBuffer( + spanInSecondaryBuffer, threadingContext, documentId, containedDocument); + } + + /// + /// Only call this from the UI thread. See for the async version. + /// + public static VsTextSpan? MapSpanFromSecondaryBufferToPrimaryBuffer( + this VsTextSpan spanInSecondaryBuffer, + IThreadingContext threadingContext, + DocumentId documentId, + ContainedDocument? containedDocument = null) + { + threadingContext.ThrowIfNotOnUIThread(); + + containedDocument ??= ContainedDocument.TryGetContainedDocument(documentId); + if (containedDocument == null) + return null; var bufferCoordinator = containedDocument.BufferCoordinator; var primary = new VsTextSpan[1]; diff --git a/src/VisualStudio/Core/Def/FindReferences/Contexts/AbstractTableDataSourceFindUsagesContext.cs b/src/VisualStudio/Core/Def/FindReferences/Contexts/AbstractTableDataSourceFindUsagesContext.cs index 0a7c6416824b..18e0cd050bbb 100644 --- a/src/VisualStudio/Core/Def/FindReferences/Contexts/AbstractTableDataSourceFindUsagesContext.cs +++ b/src/VisualStudio/Core/Def/FindReferences/Contexts/AbstractTableDataSourceFindUsagesContext.cs @@ -173,7 +173,7 @@ protected AbstractTableDataSourceFindUsagesContext( cancellationToken => { _tableDataSink.FactorySnapshotChanged(this); - return ValueTaskFactory.CompletedTask; + return ValueTask.CompletedTask; }, presenter._asyncListener, CancellationTokenSource.Token); @@ -537,7 +537,7 @@ public sealed override ValueTask ReportNoResultsAsync(string message, Cancellati NoDefinitionsFoundMessage = message; } - return ValueTaskFactory.CompletedTask; + return ValueTask.CompletedTask; } public sealed override async ValueTask ReportMessageAsync(string message, NotificationSeverity severity, CancellationToken cancellationToken) @@ -571,7 +571,7 @@ private ValueTask UpdateTableProgressAsync(ImmutableSegmentedList<(int current, _findReferencesWindow.SetProgress(current, maximum); } - return ValueTaskFactory.CompletedTask; + return ValueTask.CompletedTask; } protected static DefinitionItem CreateNoResultsDefinitionItem(string message) diff --git a/src/VisualStudio/Core/Def/InlineRename/InlineRenameUndoManager.cs b/src/VisualStudio/Core/Def/InlineRename/InlineRenameUndoManager.cs index 3548aa6d7dc5..ad7fce549b32 100644 --- a/src/VisualStudio/Core/Def/InlineRename/InlineRenameUndoManager.cs +++ b/src/VisualStudio/Core/Def/InlineRename/InlineRenameUndoManager.cs @@ -15,6 +15,9 @@ using Microsoft.CodeAnalysis.ErrorReporting; using Microsoft.CodeAnalysis.Host; using Microsoft.CodeAnalysis.Host.Mef; +using Microsoft.CodeAnalysis.LanguageService; +using Microsoft.CodeAnalysis.Shared.Extensions; +using Microsoft.CodeAnalysis.Text; using Microsoft.VisualStudio.Editor; using Microsoft.VisualStudio.OLE.Interop; using Microsoft.VisualStudio.Text; @@ -171,7 +174,14 @@ public void ApplyCurrentState(ITextBuffer subjectBuffer, object propagateSpansEd return; } - ApplyReplacementText(subjectBuffer, bufferUndoState.TextUndoHistory, propagateSpansEditTag, spans, this.currentState.ReplacementText); + var document = subjectBuffer.CurrentSnapshot.GetOpenDocumentInCurrentContextWithChanges(); + var isCaseSensitive = document?.GetLanguageService()?.IsCaseSensitive ?? true; + + // This is where we apply the replacement text to each inline preview in the buffer. + // Needs to remove the "Attribute" suffix, since the inline preview does not include the "Attribute" suffix in the replacement span, + // so that the user does not see the suffix twice. + ApplyReplacementText(subjectBuffer, bufferUndoState.TextUndoHistory, propagateSpansEditTag, spans, + currentState.ReplacementText.GetWithoutAttributeSuffix(isCaseSensitive) ?? currentState.ReplacementText); // Here we create the descriptions for the redo list dropdown. var undoManager = bufferUndoState.UndoManager; diff --git a/src/VisualStudio/Core/Def/LanguageService/AbstractLanguageService`2.VsLanguageDebugInfo.cs b/src/VisualStudio/Core/Def/LanguageService/AbstractLanguageService`2.VsLanguageDebugInfo.cs index 790628ecd98a..1e3e8b50c8b6 100644 --- a/src/VisualStudio/Core/Def/LanguageService/AbstractLanguageService`2.VsLanguageDebugInfo.cs +++ b/src/VisualStudio/Core/Def/LanguageService/AbstractLanguageService`2.VsLanguageDebugInfo.cs @@ -177,8 +177,13 @@ public int ResolveName(string? pszName, uint dwFlags, out IVsEnumDebugName? ppNa return VSConstants.S_FALSE; } + // NOTE(cyrusn): We have to wait here because the debuggers' ResolveName + // call is synchronous. In the future it would be nice to make it async. ppNames = this.ThreadingContext.JoinableTaskFactory.Run(async () => { + // We're in a blocking JTF run. So ConfigureAwait(true) all calls to ensure we're coming back + // and using the blocked thread whenever possible. + using (Logger.LogBlock(FunctionId.Debugging_VsLanguageDebugInfo_ResolveName, CancellationToken.None)) { using var waitContext = _uiThreadOperationExecutor.BeginExecute( @@ -192,14 +197,11 @@ public int ResolveName(string? pszName, uint dwFlags, out IVsEnumDebugName? ppNa { var solution = _languageService.Workspace.CurrentSolution; - // NOTE(cyrusn): We have to wait here because the debuggers' ResolveName - // call is synchronous. In the future it would be nice to make it async. if (_breakpointService != null) { var breakpoints = await _breakpointService.ResolveBreakpointsAsync( - solution, pszName, cancellationToken).ConfigureAwait(false); - var debugNames = await breakpoints.SelectAsArrayAsync( - bp => CreateDebugNameAsync(bp, cancellationToken)).ConfigureAwait(true); + solution, pszName, cancellationToken).ConfigureAwait(true); + var debugNames = breakpoints.SelectAsArray(bp => CreateDebugName(bp, cancellationToken)); return new VsEnumDebugName(debugNames); } @@ -210,23 +212,28 @@ public int ResolveName(string? pszName, uint dwFlags, out IVsEnumDebugName? ppNa }); return ppNames != null ? VSConstants.S_OK : VSConstants.E_NOTIMPL; - } - private async ValueTask CreateDebugNameAsync( - BreakpointResolutionResult breakpoint, CancellationToken cancellationToken) - { - var document = breakpoint.Document; - var filePath = _languageService.Workspace.GetFilePath(document.Id); - var text = await document.GetValueTextAsync(cancellationToken).ConfigureAwait(false); - var span = text.GetVsTextSpanForSpan(breakpoint.TextSpan); - // If we're inside an Venus code nugget, we need to map the span to the surface buffer. - // Otherwise, we'll just use the original span. - var mappedSpan = await span.MapSpanFromSecondaryBufferToPrimaryBufferAsync( - this.ThreadingContext, document.Id, cancellationToken).ConfigureAwait(true); - if (mappedSpan != null) - span = mappedSpan.Value; - - return new VsDebugName(breakpoint.LocationNameOpt, filePath!, span); + IVsDebugName CreateDebugName( + BreakpointResolutionResult breakpoint, CancellationToken cancellationToken) + { + // We're in a blocking jtf run. So CA(true) all calls to ensure we're coming bac + // and using the blocked thread whenever possible. + + var document = breakpoint.Document; + var filePath = _languageService.Workspace.GetFilePath(document.Id); + + // We're (unfortunately) blocking the UI thread here. So avoid async io as we actually + // awant the IO to complete as quickly as possible, on this thread if necessary. + var text = document.GetTextSynchronously(cancellationToken); + var span = text.GetVsTextSpanForSpan(breakpoint.TextSpan); + // If we're inside an Venus code nugget, we need to map the span to the surface buffer. + // Otherwise, we'll just use the original span. + var mappedSpan = span.MapSpanFromSecondaryBufferToPrimaryBuffer(this.ThreadingContext, document.Id); + if (mappedSpan != null) + span = mappedSpan.Value; + + return new VsDebugName(breakpoint.LocationNameOpt, filePath!, span); + } } public int ValidateBreakpointLocation(IVsTextBuffer pBuffer, int iLine, int iCol, VsTextSpan[] pCodeSpan) diff --git a/src/VisualStudio/Core/Def/LanguageService/AbstractPackage`2.cs b/src/VisualStudio/Core/Def/LanguageService/AbstractPackage`2.cs index 63d18eda9021..4cfe2ae24734 100644 --- a/src/VisualStudio/Core/Def/LanguageService/AbstractPackage`2.cs +++ b/src/VisualStudio/Core/Def/LanguageService/AbstractPackage`2.cs @@ -136,9 +136,6 @@ protected override async Task LoadComponentsAsync(CancellationToken cancellation protected abstract IEnumerable CreateEditorFactories(); protected abstract TLanguageService CreateLanguageService(); - protected void RegisterService(Func> serviceCreator) - => AddService(typeof(T), async (container, cancellationToken, type) => await serviceCreator(cancellationToken).ConfigureAwait(true), promote: true); - // When registering a language service, we need to take its ComAggregate wrapper. protected void RegisterLanguageService(Type t, Func> serviceCreator) => AddService(t, async (container, cancellationToken, type) => await serviceCreator(cancellationToken).ConfigureAwait(true), promote: true); diff --git a/src/VisualStudio/Core/Def/Packaging/PackageInstallerServiceFactory.cs b/src/VisualStudio/Core/Def/Packaging/PackageInstallerServiceFactory.cs index fafe720d01eb..de3f3b67b6b3 100644 --- a/src/VisualStudio/Core/Def/Packaging/PackageInstallerServiceFactory.cs +++ b/src/VisualStudio/Core/Def/Packaging/PackageInstallerServiceFactory.cs @@ -462,7 +462,7 @@ private ValueTask ProcessWorkQueueAsync( // If we've been disconnected, then there's no point proceeding. if (Workspace == null || !IsEnabled) - return ValueTaskFactory.CompletedTask; + return ValueTask.CompletedTask; return ProcessWorkQueueWorkerAsync(workQueue, cancellationToken); } diff --git a/src/VisualStudio/Core/Def/Remote/VisualStudioRemoteHostClientProvider.cs b/src/VisualStudio/Core/Def/Remote/VisualStudioRemoteHostClientProvider.cs index 76e12659cbad..0eddc78a8298 100644 --- a/src/VisualStudio/Core/Def/Remote/VisualStudioRemoteHostClientProvider.cs +++ b/src/VisualStudio/Core/Def/Remote/VisualStudioRemoteHostClientProvider.cs @@ -139,7 +139,7 @@ private VisualStudioRemoteHostClientProvider( var client = await ServiceHubRemoteHostClient.CreateAsync(Services, configuration, localSettingsDirectory, _listenerProvider, serviceBroker, _callbackDispatchers, _threadingContext.DisposalToken).ConfigureAwait(false); // proffer in-proc brokered services: - _ = brokeredServiceContainer.Proffer(SolutionAssetProvider.ServiceDescriptor, (_, _, _, _) => ValueTaskFactory.FromResult(new SolutionAssetProvider(Services))); + _ = brokeredServiceContainer.Proffer(SolutionAssetProvider.ServiceDescriptor, (_, _, _, _) => ValueTask.FromResult(new SolutionAssetProvider(Services))); return client; } diff --git a/src/VisualStudio/Core/Def/RoslynPackage.cs b/src/VisualStudio/Core/Def/RoslynPackage.cs index 7afce1838493..94a12fef9057 100644 --- a/src/VisualStudio/Core/Def/RoslynPackage.cs +++ b/src/VisualStudio/Core/Def/RoslynPackage.cs @@ -134,24 +134,18 @@ private async Task ProfferServiceBrokerServicesAsync(CancellationToken cancellat serviceBrokerContainer.Proffer( WorkspaceProjectFactoryServiceDescriptor.ServiceDescriptor, - (_, _, _, _) => ValueTaskFactory.FromResult(new WorkspaceProjectFactoryService(this.ComponentModel.GetService()))); + (_, _, _, _) => ValueTask.FromResult(new WorkspaceProjectFactoryService(this.ComponentModel.GetService()))); // Must be profferred before any C#/VB projects are loaded and the corresponding UI context activated. serviceBrokerContainer.Proffer( ManagedHotReloadLanguageServiceDescriptor.Descriptor, - (_, _, _, _) => ValueTaskFactory.FromResult(new ManagedEditAndContinueLanguageServiceBridge(this.ComponentModel.GetService()))); + (_, _, _, _) => ValueTask.FromResult(new ManagedEditAndContinueLanguageServiceBridge(this.ComponentModel.GetService()))); } protected override async Task LoadComponentsAsync(CancellationToken cancellationToken) { await TaskScheduler.Default; - await GetServiceAsync(typeof(SVsErrorList)).ConfigureAwait(false); - await GetServiceAsync(typeof(SVsSolution)).ConfigureAwait(false); - await GetServiceAsync(typeof(SVsShell)).ConfigureAwait(false); - await GetServiceAsync(typeof(SVsRunningDocumentTable)).ConfigureAwait(false); - await GetServiceAsync(typeof(SVsTextManager)).ConfigureAwait(false); - // we need to load it as early as possible since we can have errors from // package from each language very early await this.ComponentModel.GetService().InitializeAsync(this, cancellationToken).ConfigureAwait(false); diff --git a/src/VisualStudio/Core/Def/Telemetry/FileLogger.cs b/src/VisualStudio/Core/Def/Telemetry/FileLogger.cs index d6105f7e74e7..8be4ed4130e4 100644 --- a/src/VisualStudio/Core/Def/Telemetry/FileLogger.cs +++ b/src/VisualStudio/Core/Def/Telemetry/FileLogger.cs @@ -110,6 +110,6 @@ private ValueTask ProcessWorkQueueAsync( File.AppendAllText(_logFilePath, buffer.ToString()); }); - return ValueTaskFactory.CompletedTask; + return ValueTask.CompletedTask; } } diff --git a/src/VisualStudio/Core/Impl/SolutionExplorer/SymbolTree/RootSymbolTreeItemSourceProvider.cs b/src/VisualStudio/Core/Impl/SolutionExplorer/SymbolTree/RootSymbolTreeItemSourceProvider.cs index 8e338bc9aac3..ba1f679c8b5c 100644 --- a/src/VisualStudio/Core/Impl/SolutionExplorer/SymbolTree/RootSymbolTreeItemSourceProvider.cs +++ b/src/VisualStudio/Core/Impl/SolutionExplorer/SymbolTree/RootSymbolTreeItemSourceProvider.cs @@ -124,7 +124,7 @@ private async ValueTask UpdateCollectionSourcesAsync( } // Update all the affected documents in parallel. - await RoslynParallel.ForEachAsync( + await Parallel.ForEachAsync( sources, cancellationToken, async (source, cancellationToken) => diff --git a/src/VisualStudio/Core/Test.Next/Services/AssetProviderTests.cs b/src/VisualStudio/Core/Test.Next/Services/AssetProviderTests.cs index 09902a420027..2cd8b39d186c 100644 --- a/src/VisualStudio/Core/Test.Next/Services/AssetProviderTests.cs +++ b/src/VisualStudio/Core/Test.Next/Services/AssetProviderTests.cs @@ -214,7 +214,7 @@ public ValueTask GetAssetsAsync( } } - return ValueTaskFactory.CompletedTask; + return ValueTask.CompletedTask; } } } diff --git a/src/VisualStudio/Core/Test.Next/Services/ServiceHubServicesTests.cs b/src/VisualStudio/Core/Test.Next/Services/ServiceHubServicesTests.cs index 72fc04fc6a70..0e9af0059e89 100644 --- a/src/VisualStudio/Core/Test.Next/Services/ServiceHubServicesTests.cs +++ b/src/VisualStudio/Core/Test.Next/Services/ServiceHubServicesTests.cs @@ -224,7 +224,7 @@ private sealed class DesignerAttributeComputerCallback : IDesignerAttributeDisco public ValueTask ReportDesignerAttributeDataAsync(ImmutableArray infos, CancellationToken cancellationToken) { _infosSource.SetResult(infos); - return ValueTaskFactory.CompletedTask; + return ValueTask.CompletedTask; } } diff --git a/src/VisualStudio/ExternalAccess/Copilot/SemanticSearch/ISemanticSearchCopilotUIProviderImpl.cs b/src/VisualStudio/ExternalAccess/Copilot/SemanticSearch/ISemanticSearchCopilotUIProviderImpl.cs deleted file mode 100644 index be6365859019..000000000000 --- a/src/VisualStudio/ExternalAccess/Copilot/SemanticSearch/ISemanticSearchCopilotUIProviderImpl.cs +++ /dev/null @@ -1,22 +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.Windows.Controls; -using Microsoft.VisualStudio.OLE.Interop; -using Microsoft.VisualStudio.Text.Editor; - -namespace Microsoft.CodeAnalysis.ExternalAccess.Copilot.SemanticSearch; - -internal interface ITextBoxControlImpl -{ - Control Control { get; } - string Text { get; set; } - IOleCommandTarget CommandTarget { get; } - IWpfTextView View { get; } -} - -internal interface ISemanticSearchCopilotUIProviderImpl -{ - ITextBoxControlImpl GetTextBox(); -} diff --git a/src/VisualStudio/ExternalAccess/FSharp/Internal/Editor/FindUsages/FSharpFindUsagesContext.cs b/src/VisualStudio/ExternalAccess/FSharp/Internal/Editor/FindUsages/FSharpFindUsagesContext.cs index aef354f813cd..caa330436d99 100644 --- a/src/VisualStudio/ExternalAccess/FSharp/Internal/Editor/FindUsages/FSharpFindUsagesContext.cs +++ b/src/VisualStudio/ExternalAccess/FSharp/Internal/Editor/FindUsages/FSharpFindUsagesContext.cs @@ -29,7 +29,7 @@ public Task OnDefinitionFoundAsync(FSharp.FindUsages.FSharpDefinitionItem defini public Task OnReferenceFoundAsync(FSharp.FindUsages.FSharpSourceReferenceItem reference) { - return _context.OnReferencesFoundAsync(IAsyncEnumerableExtensions.SingletonAsync(reference.RoslynSourceReferenceItem), CancellationToken).AsTask(); + return _context.OnReferencesFoundAsync(AsyncEnumerableFactory.SingletonAsync(reference.RoslynSourceReferenceItem), CancellationToken).AsTask(); } public Task ReportMessageAsync(string message) diff --git a/src/VisualStudio/IntegrationTest/New.IntegrationTests/CSharp/CSharpRename.cs b/src/VisualStudio/IntegrationTest/New.IntegrationTests/CSharp/CSharpRename.cs index f56fb730a2ef..e63d7fab9e10 100644 --- a/src/VisualStudio/IntegrationTest/New.IntegrationTests/CSharp/CSharpRename.cs +++ b/src/VisualStudio/IntegrationTest/New.IntegrationTests/CSharp/CSharpRename.cs @@ -422,8 +422,7 @@ class $$Program """, HangMitigatingCancellationToken); await TestServices.SolutionExplorer.AddFileAsync(ProjectName, "Class2.cs", @"", cancellationToken: HangMitigatingCancellationToken); await TestServices.SolutionExplorer.OpenFileAsync(ProjectName, "Class2.cs", HangMitigatingCancellationToken); - - const string class2Markup = """ + MarkupTestFile.GetSpans(""" class SomeOtherClass { void M() @@ -431,8 +430,7 @@ void M() [|Program|] p = new [|Program|](); } } - """; - MarkupTestFile.GetSpans(class2Markup, out var code, out var renameSpans); + """, out var code, out var renameSpans); await TestServices.Editor.SetTextAsync(code, HangMitigatingCancellationToken); await TestServices.Editor.PlaceCaretAsync("Program", charsOffset: 0, HangMitigatingCancellationToken); diff --git a/src/VisualStudio/Setup.Dependencies/Roslyn.VisualStudio.Setup.Dependencies.csproj b/src/VisualStudio/Setup.Dependencies/Roslyn.VisualStudio.Setup.Dependencies.csproj index c01ae1ae71a3..0023ce9a234f 100644 --- a/src/VisualStudio/Setup.Dependencies/Roslyn.VisualStudio.Setup.Dependencies.csproj +++ b/src/VisualStudio/Setup.Dependencies/Roslyn.VisualStudio.Setup.Dependencies.csproj @@ -56,6 +56,7 @@ + diff --git a/src/VisualStudio/Setup.ServiceHub/arm64/source.extension.vsixmanifest b/src/VisualStudio/Setup.ServiceHub/arm64/source.extension.vsixmanifest index b9e718f14d3b..c1b765ccf434 100644 --- a/src/VisualStudio/Setup.ServiceHub/arm64/source.extension.vsixmanifest +++ b/src/VisualStudio/Setup.ServiceHub/arm64/source.extension.vsixmanifest @@ -2,8 +2,8 @@ - Roslyn Services for .NET ServiceHub Host (arm64) - Roslyn Services for .NET ServiceHub Host + Roslyn ServiceHub Services (arm64) + Roslyn ServiceHub Services Microsoft.CodeAnalysis.VisualStudio.ServiceHub.Setup.arm64 EULA.rtf true diff --git a/src/VisualStudio/Setup.ServiceHub/x64/source.extension.vsixmanifest b/src/VisualStudio/Setup.ServiceHub/x64/source.extension.vsixmanifest index 7d04c1803ff0..3cfdd350f0e8 100644 --- a/src/VisualStudio/Setup.ServiceHub/x64/source.extension.vsixmanifest +++ b/src/VisualStudio/Setup.ServiceHub/x64/source.extension.vsixmanifest @@ -2,8 +2,8 @@ - Roslyn Services for .NET ServiceHub Host - Roslyn Services for .NET ServiceHub Host + Roslyn ServiceHub Services + Roslyn ServiceHub Services Microsoft.CodeAnalysis.VisualStudio.ServiceHub.Setup.x64 EULA.rtf true diff --git a/src/VisualStudio/VisualBasic/Impl/LanguageService/VisualBasicPackage.vb b/src/VisualStudio/VisualBasic/Impl/LanguageService/VisualBasicPackage.vb index 1889c4c1ab9e..90f17e9234ec 100644 --- a/src/VisualStudio/VisualBasic/Impl/LanguageService/VisualBasicPackage.vb +++ b/src/VisualStudio/VisualBasic/Impl/LanguageService/VisualBasicPackage.vb @@ -2,6 +2,7 @@ ' 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.ComponentModel.Design Imports System.Runtime.InteropServices Imports Microsoft.CodeAnalysis Imports Microsoft.CodeAnalysis.ErrorReporting @@ -37,6 +38,7 @@ Namespace Microsoft.VisualStudio.LanguageServices.VisualBasic + Friend NotInheritable Class VisualBasicPackage Inherits AbstractPackage(Of VisualBasicPackage, VisualBasicLanguageService) @@ -73,12 +75,9 @@ Namespace Microsoft.VisualStudio.LanguageServices.VisualBasic Try RegisterLanguageService(GetType(IVbCompilerService), Function() Task.FromResult(_comAggregate)) - RegisterService(Of IVbTempPECompilerFactory)( - Async Function(ct) - Dim workspace = Me.ComponentModel.GetService(Of VisualStudioWorkspace)() - Await JoinableTaskFactory.SwitchToMainThreadAsync(ct) - Return New TempPECompilerFactory(workspace) - End Function) + DirectCast(Me, IServiceContainer).AddService( + GetType(IVbTempPECompilerFactory), + Function(_1, _2) New TempPECompilerFactory(Me.ComponentModel.GetService(Of VisualStudioWorkspace)())) Catch ex As Exception When FatalError.ReportAndPropagateUnlessCanceled(ex) Throw ExceptionUtilities.Unreachable End Try diff --git a/src/VisualStudio/VisualBasic/Impl/PackageRegistration.pkgdef b/src/VisualStudio/VisualBasic/Impl/PackageRegistration.pkgdef index 04cf35e3f6e4..a0c8dc331b29 100644 --- a/src/VisualStudio/VisualBasic/Impl/PackageRegistration.pkgdef +++ b/src/VisualStudio/VisualBasic/Impl/PackageRegistration.pkgdef @@ -32,11 +32,6 @@ "Name"="Visual Basic Project System Shim" "IsAsyncQueryable"=dword:00000001 -[$RootKey$\Services\{8df9750d-069b-4b81-973a-152e97420c5c}] -@="{574fc912-f74f-4b4e-92c3-f695c208a2bb}" -"Name"="Visual Basic TempPE Compiler Factory Service" -"IsAsyncQueryable"=dword:00000001 - [$RootKey$\AutomationProperties\TextEditor\Basic-Specific] @="#104" "Description"="#106" diff --git a/src/VisualStudio/VisualStudioDiagnosticsToolWindow/OptionPages/PerformanceLoggersPage.cs b/src/VisualStudio/VisualStudioDiagnosticsToolWindow/OptionPages/PerformanceLoggersPage.cs index 690b625d464e..e7eaa6808654 100644 --- a/src/VisualStudio/VisualStudioDiagnosticsToolWindow/OptionPages/PerformanceLoggersPage.cs +++ b/src/VisualStudio/VisualStudioDiagnosticsToolWindow/OptionPages/PerformanceLoggersPage.cs @@ -67,7 +67,7 @@ public static void SetLoggers(IGlobalOptionService globalOptions, IThreadingCont var client = threadingContext.JoinableTaskFactory.Run(() => RemoteHostClient.TryGetClientAsync(workspaceServices, CancellationToken.None)); if (client != null) { - var functionIds = Enum.GetValues(typeof(FunctionId)).Cast().Where(isEnabled).ToImmutableArray(); + var functionIds = Enum.GetValues().Where(isEnabled).ToImmutableArray(); threadingContext.JoinableTaskFactory.Run(async () => _ = await client.TryInvokeAsync( (service, cancellationToken) => service.EnableLoggingAsync(loggerTypeNames, functionIds, cancellationToken), diff --git a/src/VisualStudio/VisualStudioDiagnosticsToolWindow/Panels/TelemetryPanel.xaml.cs b/src/VisualStudio/VisualStudioDiagnosticsToolWindow/Panels/TelemetryPanel.xaml.cs index d3a56757168c..86db5c8073ac 100644 --- a/src/VisualStudio/VisualStudioDiagnosticsToolWindow/Panels/TelemetryPanel.xaml.cs +++ b/src/VisualStudio/VisualStudioDiagnosticsToolWindow/Panels/TelemetryPanel.xaml.cs @@ -54,8 +54,6 @@ private void OnCopy(object sender, RoutedEventArgs e) private static string GetTelemetryString() { - var fixAllScopeValues = Enum.GetValues(typeof(FixAllScope)); - var sb = new StringBuilder(); var seenType = new HashSet(); diff --git a/src/Workspaces/CSharp/Portable/CodeGeneration/CSharpSyntaxGenerator.cs b/src/Workspaces/CSharp/Portable/CodeGeneration/CSharpSyntaxGenerator.cs index cf03d43c8ed4..7ad89b49d266 100644 --- a/src/Workspaces/CSharp/Portable/CodeGeneration/CSharpSyntaxGenerator.cs +++ b/src/Workspaces/CSharp/Portable/CodeGeneration/CSharpSyntaxGenerator.cs @@ -236,9 +236,7 @@ private protected override SyntaxNode MethodDeclaration( return SyntaxFactory.MethodDeclaration( attributeLists: default, - // Pass `withLeadingElasticMarker: true` to ensure method will space itself properly within the members it - // is added to. - modifiers: AsModifierList(accessibility, modifiers, SyntaxKind.MethodDeclaration, withLeadingElasticMarker: true), + modifiers: AsModifierList(accessibility, modifiers, SyntaxKind.MethodDeclaration), returnType: returnType != null ? (TypeSyntax)returnType : SyntaxFactory.PredefinedType(VoidKeyword), explicitInterfaceSpecifier: null, identifier: name.ToIdentifierToken(), @@ -430,12 +428,13 @@ public override SyntaxNode GetAccessorDeclaration(Accessibility accessibility, I private protected override SyntaxNode SetAccessorDeclaration(Accessibility accessibility, bool isInitOnly, IEnumerable? statements) => AccessorDeclaration(isInitOnly ? SyntaxKind.InitAccessorDeclaration : SyntaxKind.SetAccessorDeclaration, accessibility, statements); - private static SyntaxNode AccessorDeclaration( + private static AccessorDeclarationSyntax AccessorDeclaration( SyntaxKind kind, Accessibility accessibility, IEnumerable? statements) { - var accessor = SyntaxFactory.AccessorDeclaration(kind); - accessor = accessor.WithModifiers( - AsModifierList(accessibility, DeclarationModifiers.None, SyntaxKind.PropertyDeclaration)); + var accessor = SyntaxFactory + .AccessorDeclaration(kind) + .WithModifiers( + AsModifierList(accessibility, DeclarationModifiers.None, SyntaxKind.PropertyDeclaration)); accessor = statements == null ? accessor.WithSemicolonToken(SemicolonToken) @@ -1437,7 +1436,10 @@ public override SyntaxNode WithAccessibility(SyntaxNode declaration, Accessibili modifiers = modifiers.WithIsStatic(false); } - var newTokens = Merge(tokens, AsModifierList(accessibility, modifiers)); + // We're updating the modifiers for something. We don't want to add elastic trivia in that case as + // we don't want the act of adding/removing/modifying modifiers to change the formatting of the parent + // construct. + var newTokens = Merge(tokens, AsModifierList(accessibility, modifiers, withLeadingElasticMarker: false)); return SetModifierTokens(d, newTokens); }); } @@ -1647,7 +1649,10 @@ private SyntaxNode WithModifiersInternal(SyntaxNode declaration, DeclarationModi } } - var newTokens = Merge(tokens, AsModifierList(accessibility, modifiers)); + // We're updating the modifiers for something. We don't want to add elastic trivia in that case as + // we don't want the act of adding/removing/modifying modifiers to change the formatting of the parent + // construct. + var newTokens = Merge(tokens, AsModifierList(accessibility, modifiers, withLeadingElasticMarker: false)); return SetModifierTokens(d, newTokens); }); } @@ -1674,13 +1679,13 @@ private static SyntaxTokenList AsModifierList( Accessibility accessibility, DeclarationModifiers modifiers, SyntaxKind kind, - bool withLeadingElasticMarker = false) + bool withLeadingElasticMarker = true) => AsModifierList(accessibility, GetAllowedModifiers(kind) & modifiers, withLeadingElasticMarker); private static SyntaxTokenList AsModifierList( Accessibility accessibility, DeclarationModifiers modifiers, - bool withLeadingElasticMarker = false) + bool withLeadingElasticMarker = true) { using var _ = ArrayBuilder.GetInstance(out var list); diff --git a/src/Workspaces/CSharp/Portable/Recommendations/CSharpRecommendationServiceRunner.cs b/src/Workspaces/CSharp/Portable/Recommendations/CSharpRecommendationServiceRunner.cs index 58bccf1e2827..b9519345df8e 100644 --- a/src/Workspaces/CSharp/Portable/Recommendations/CSharpRecommendationServiceRunner.cs +++ b/src/Workspaces/CSharp/Portable/Recommendations/CSharpRecommendationServiceRunner.cs @@ -443,7 +443,7 @@ static bool IsCapturedPrimaryConstructorParameter( CancellationToken cancellationToken) { // Fine to offer primary constructor parameters in field/property initializers - var initializer = context.TargetToken.GetAncestors().FirstOrDefault(); + var initializer = context.TargetToken.GetAncestor(); if (initializer is { Parent: PropertyDeclarationSyntax or @@ -453,6 +453,11 @@ static bool IsCapturedPrimaryConstructorParameter( return false; } + // Also fine to offer primary constructor parameters in the base type list of that type. + var baseTypeSyntax = context.TargetToken.GetAncestor(); + if (baseTypeSyntax != null) + return false; + // We're not in an initializer. Filter out this primary constructor parameter if it's already been // captured by an existing field or property initializer. diff --git a/src/Workspaces/CSharp/Portable/Rename/CSharpRenameRewriterLanguageService.cs b/src/Workspaces/CSharp/Portable/Rename/CSharpRenameRewriterLanguageService.cs index ddd9ed99601c..a52e40ac9670 100644 --- a/src/Workspaces/CSharp/Portable/Rename/CSharpRenameRewriterLanguageService.cs +++ b/src/Workspaces/CSharp/Portable/Rename/CSharpRenameRewriterLanguageService.cs @@ -1117,59 +1117,40 @@ public override void TryAddPossibleNameConflicts(ISymbol symbol, string replacem private static SyntaxNode? GetExpansionTarget(SyntaxToken token) { // get the directly enclosing statement - var enclosingStatement = token.GetAncestors(n => n is StatementSyntax).FirstOrDefault(); + var enclosingStatement = token.GetAncestor(); // System.Func myFunc = arg => X; var possibleLambdaExpression = enclosingStatement == null - ? token.GetAncestors(n => n is SimpleLambdaExpressionSyntax or ParenthesizedLambdaExpressionSyntax).FirstOrDefault() + ? token.GetAncestor() : null; - if (possibleLambdaExpression != null) - { - var lambdaExpression = ((LambdaExpressionSyntax)possibleLambdaExpression); - if (lambdaExpression.Body is ExpressionSyntax) - { - return lambdaExpression.Body; - } - } + if (possibleLambdaExpression?.ExpressionBody is not null) + return possibleLambdaExpression.ExpressionBody; // int M() => X; var possibleArrowExpressionClause = enclosingStatement == null - ? token.GetAncestors().FirstOrDefault() + ? token.GetAncestor() : null; if (possibleArrowExpressionClause != null) - { return possibleArrowExpressionClause.Expression; - } var enclosingNameMemberCrefOrnull = token.GetAncestors(n => n is NameMemberCrefSyntax).LastOrDefault(); - if (enclosingNameMemberCrefOrnull != null) - { - if (token.Parent is TypeSyntax && token.Parent.Parent is TypeSyntax) - { - enclosingNameMemberCrefOrnull = null; - } - } + if (enclosingNameMemberCrefOrnull != null && token.Parent is TypeSyntax && token.Parent.Parent is TypeSyntax) + enclosingNameMemberCrefOrnull = null; - var enclosingXmlNameAttr = token.GetAncestors(n => n is XmlNameAttributeSyntax).FirstOrDefault(); + var enclosingXmlNameAttr = token.GetAncestor(); if (enclosingXmlNameAttr != null) - { return null; - } - var enclosingInitializer = token.GetAncestors().FirstOrDefault(); + var enclosingInitializer = token.GetAncestor(); if (enclosingStatement == null && enclosingInitializer != null && enclosingInitializer.Parent is VariableDeclaratorSyntax) - { return enclosingInitializer.Value; - } var attributeSyntax = token.GetAncestor(); if (attributeSyntax != null) - { return attributeSyntax; - } // there seems to be no statement above this one. Let's see if we can at least get an SimpleNameSyntax - return enclosingStatement ?? enclosingNameMemberCrefOrnull ?? token.GetAncestors(n => n is SimpleNameSyntax).FirstOrDefault(); + return enclosingStatement ?? enclosingNameMemberCrefOrnull ?? token.GetAncestor(); } #region "Helper Methods" diff --git a/src/Workspaces/CSharp/Portable/Simplification/Reducers/CSharpEscapingReducer.cs b/src/Workspaces/CSharp/Portable/Simplification/Reducers/CSharpEscapingReducer.cs index c56052ac6084..d552f4cc2e55 100644 --- a/src/Workspaces/CSharp/Portable/Simplification/Reducers/CSharpEscapingReducer.cs +++ b/src/Workspaces/CSharp/Portable/Simplification/Reducers/CSharpEscapingReducer.cs @@ -37,7 +37,7 @@ private static SyntaxToken SimplifyIdentifierToken( { var unescapedIdentifier = token.ValueText; - var enclosingXmlNameAttr = token.GetAncestors(n => n is XmlNameAttributeSyntax).FirstOrDefault(); + var enclosingXmlNameAttr = token.GetAncestor(); // always escape keywords if (SyntaxFacts.GetKeywordKind(unescapedIdentifier) != SyntaxKind.None && enclosingXmlNameAttr == null) @@ -52,32 +52,13 @@ private static SyntaxToken SimplifyIdentifierToken( if (SyntaxFacts.GetContextualKeywordKind(unescapedIdentifier) == SyntaxKind.AwaitKeyword) { - var enclosingLambdaExpression = parent.GetAncestorsOrThis(n => (n is SimpleLambdaExpressionSyntax or ParenthesizedLambdaExpressionSyntax)).FirstOrDefault(); - if (enclosingLambdaExpression != null) - { - if (enclosingLambdaExpression is SimpleLambdaExpressionSyntax simpleLambda) - { - if (simpleLambda.AsyncKeyword.Kind() == SyntaxKind.AsyncKeyword) - { - return token; - } - } - - if (enclosingLambdaExpression is ParenthesizedLambdaExpressionSyntax parenLamdba) - { - if (parenLamdba.AsyncKeyword.Kind() == SyntaxKind.AsyncKeyword) - { - return token; - } - } - } - - var enclosingMethodBlock = parent.GetAncestorsOrThis(n => n is MethodDeclarationSyntax).FirstOrDefault(); + var enclosingLambdaExpression = parent.GetAncestorOrThis(); + if (enclosingLambdaExpression != null && enclosingLambdaExpression.AsyncKeyword != default) + return token; - if (enclosingMethodBlock != null && ((MethodDeclarationSyntax)enclosingMethodBlock).Modifiers.Any(SyntaxKind.AsyncKeyword)) - { + var enclosingMethodBlock = parent.GetAncestorOrThis(); + if (enclosingMethodBlock != null && enclosingMethodBlock.Modifiers.Any(SyntaxKind.AsyncKeyword)) return token; - } } // within a query all contextual query keywords need to be escaped, even if they appear in a non query context. diff --git a/src/Workspaces/CSharpTest/CSharpSyntaxFactsServiceTests.cs b/src/Workspaces/CSharpTest/CSharpSyntaxFactsServiceTests.cs index 3dbcebf86a26..4dce31ac1dd5 100644 --- a/src/Workspaces/CSharpTest/CSharpSyntaxFactsServiceTests.cs +++ b/src/Workspaces/CSharpTest/CSharpSyntaxFactsServiceTests.cs @@ -37,208 +37,166 @@ void M() [Fact] public void IsQueryKeyword_From() - { - Assert.True(IsQueryKeyword(WrapInMethod(""" + => Assert.True(IsQueryKeyword(WrapInMethod(""" var result = $$from var1 in collection1 """))); - } [Fact] public void IsQueryKeyword_In() - { - Assert.True(IsQueryKeyword(WrapInMethod(""" + => Assert.True(IsQueryKeyword(WrapInMethod(""" var result = from var1 $$in collection1 """))); - } [Fact] public void IsQueryKeyword_Where() - { - Assert.True(IsQueryKeyword(WrapInMethod(""" + => Assert.True(IsQueryKeyword(WrapInMethod(""" var customerOrders = from cust in customers $$where cust.CustomerID = 1 """))); - } [Fact] public void IsQueryKeyword_Select() - { - Assert.True(IsQueryKeyword(WrapInMethod(""" + => Assert.True(IsQueryKeyword(WrapInMethod(""" var customerOrders = from cust in customers from ord in orders where cust.CustomerID == ord.CustomerID $$select cust.CompanyName, ord.OrderDate """))); - } [Fact] public void IsQueryKeyword_GroupBy_Group() - { - Assert.True(IsQueryKeyword(WrapInMethod(""" + => Assert.True(IsQueryKeyword(WrapInMethod(""" var customersByCountry = from cust in customers $$group cust by cust.Country into g """))); - } [Fact] public void IsQueryKeyword_GroupBy_By() - { - Assert.True(IsQueryKeyword(WrapInMethod(""" + => Assert.True(IsQueryKeyword(WrapInMethod(""" var customersByCountry = from cust in customers group cust $$by cust.Country into g """))); - } [Fact] public void IsQueryKeyword_Into() - { - Assert.True(IsQueryKeyword(WrapInMethod(""" + => Assert.True(IsQueryKeyword(WrapInMethod(""" var customersByCountry = from cust in customers group cust by cust.Country $$into g """))); - } [Fact] public void IsQueryKeyword_GroupJoin_Join() - { - Assert.True(IsQueryKeyword(WrapInMethod(""" + => Assert.True(IsQueryKeyword(WrapInMethod(""" var query = from person in people $$join pet in pets on person equals pet.Owner into gj select new { OwnerName = person.FirstName, Pets = gj }; """))); - } [Fact] public void IsQueryKeyword_GroupJoin_In() - { - Assert.True(IsQueryKeyword(WrapInMethod(""" + => Assert.True(IsQueryKeyword(WrapInMethod(""" var query = from person in people join pet $$in pets on person equals pet.Owner into gj select new { OwnerName = person.FirstName, Pets = gj }; """))); - } [Fact] public void IsQueryKeyword_GroupJoin_On() - { - Assert.True(IsQueryKeyword(WrapInMethod(""" + => Assert.True(IsQueryKeyword(WrapInMethod(""" var query = from person in people join pet in pets $$on person equals pet.Owner into gj select new { OwnerName = person.FirstName, Pets = gj }; """))); - } [Fact] public void IsQueryKeyword_GroupJoin_Equals() - { - Assert.True(IsQueryKeyword(WrapInMethod(""" + => Assert.True(IsQueryKeyword(WrapInMethod(""" var query = from person in people join pet in pets on person $$equals pet.Owner into gj select new { OwnerName = person.FirstName, Pets = gj }; """))); - } [Fact] public void IsQueryKeyword_GroupJoin_Into() - { - Assert.True(IsQueryKeyword(WrapInMethod(""" + => Assert.True(IsQueryKeyword(WrapInMethod(""" var query = from person in people join pet in pets on person equals pet.Owner $$into gj select new { OwnerName = person.FirstName, Pets = gj }; """))); - } [Fact] public void IsQueryKeyword_Join_Join() - { - Assert.True(IsQueryKeyword(WrapInMethod(""" + => Assert.True(IsQueryKeyword(WrapInMethod(""" var query = from person in people $$join pet in pets on person equals pet.Owner select new { OwnerName = person.FirstName, PetName = pet.Name }; """))); - } [Fact] public void IsQueryKeyword_Join_In() - { - Assert.True(IsQueryKeyword(WrapInMethod(""" + => Assert.True(IsQueryKeyword(WrapInMethod(""" var query = from person in people join pet $$in pets on person equals pet.Owner select new { OwnerName = person.FirstName, PetName = pet.Name }; """))); - } [Fact] public void IsQueryKeyword_Join_On() - { - Assert.True(IsQueryKeyword(WrapInMethod(""" + => Assert.True(IsQueryKeyword(WrapInMethod(""" var query = from person in people join pet in pets $$on person equals pet.Owner select new { OwnerName = person.FirstName, PetName = pet.Name }; """))); - } [Fact] public void IsQueryKeyword_Join_Equals() - { - Assert.True(IsQueryKeyword(WrapInMethod(""" + => Assert.True(IsQueryKeyword(WrapInMethod(""" var query = from person in people join pet in pets on person $$equals pet.Owner select new { OwnerName = person.FirstName, PetName = pet.Name }; """))); - } [Fact] public void IsQueryKeyword_Let() - { - Assert.True(IsQueryKeyword(WrapInMethod(""" + => Assert.True(IsQueryKeyword(WrapInMethod(""" var discountedProducts = from prod in products $$let discount = prod.UnitPrice * 0.1 where discount >= 50 select new { prod.ProductName, prod.UnitPrice, Discount } """))); - } [Fact] public void IsQueryKeyword_OrderBy_OrderBy() - { - Assert.True(IsQueryKeyword(WrapInMethod(""" + => Assert.True(IsQueryKeyword(WrapInMethod(""" var titlesDescendingPrice = from book in books $$orderby book.Price descending, book.Title ascending, book.Author select new { book.Title, book.Price } """))); - } [Fact] public void IsQueryKeyword_OrderBy_Descending() - { - Assert.True(IsQueryKeyword(WrapInMethod(""" + => Assert.True(IsQueryKeyword(WrapInMethod(""" var titlesDescendingPrice = from book in books orderby book.Price $$descending, book.Title ascending, book.Author select new { book.Title, book.Price } """))); - } [Fact] public void IsQueryKeyword_OrderBy_Ascending() - { - Assert.True(IsQueryKeyword(WrapInMethod(""" + => Assert.True(IsQueryKeyword(WrapInMethod(""" var titlesDescendingPrice = from book in books orderby book.Price descending, book.Title $$ascending, book.Author select new { book.Title, book.Price } """))); - } [Fact] public void IsQueryKeyword_Not_ForEach_In() - { - Assert.False(IsQueryKeyword(WrapInMethod(""" + => Assert.False(IsQueryKeyword(WrapInMethod(""" foreach (var i $$in new int[0]) { } """))); - } } diff --git a/src/Workspaces/CSharpTest/CodeGeneration/SyntaxGeneratorTests.cs b/src/Workspaces/CSharpTest/CodeGeneration/SyntaxGeneratorTests.cs index 00f9b96b90ef..d064441285f0 100644 --- a/src/Workspaces/CSharpTest/CodeGeneration/SyntaxGeneratorTests.cs +++ b/src/Workspaces/CSharpTest/CodeGeneration/SyntaxGeneratorTests.cs @@ -175,7 +175,7 @@ public void TestAttributeData() using System; public class MyAttribute : Attribute { } """, -@"[MyAttribute]")), + @"[MyAttribute]")), @"[global::MyAttribute]"); VerifySyntax(Generator.Attribute(GetAttributeData( @@ -183,7 +183,7 @@ public class MyAttribute : Attribute { } using System; public class MyAttribute : Attribute { public MyAttribute(object value) { } } """, -@"[MyAttribute(null)]")), + @"[MyAttribute(null)]")), @"[global::MyAttribute(null)]"); VerifySyntax(Generator.Attribute(GetAttributeData( @@ -191,7 +191,7 @@ public class MyAttribute : Attribute { public MyAttribute(object value) { } } using System; public class MyAttribute : Attribute { public MyAttribute(int value) { } } """, -@"[MyAttribute(123)]")), + @"[MyAttribute(123)]")), @"[global::MyAttribute(123)]"); VerifySyntax(Generator.Attribute(GetAttributeData( @@ -199,7 +199,7 @@ public class MyAttribute : Attribute { public MyAttribute(int value) { } } using System; public class MyAttribute : Attribute { public MyAttribute(double value) { } } """, -@"[MyAttribute(12.3)]")), + @"[MyAttribute(12.3)]")), @"[global::MyAttribute(12.3)]"); VerifySyntax(Generator.Attribute(GetAttributeData( @@ -207,7 +207,7 @@ public class MyAttribute : Attribute { public MyAttribute(double value) { } } using System; public class MyAttribute : Attribute { public MyAttribute(string value) { } } """, -@"[MyAttribute(""value"")]")), + @"[MyAttribute(""value"")]")), @"[global::MyAttribute(""value"")]"); VerifySyntax(Generator.Attribute(GetAttributeData( @@ -216,7 +216,7 @@ public class MyAttribute : Attribute { public MyAttribute(string value) { } } public enum E { A, B, C } public class MyAttribute : Attribute { public MyAttribute(E value) { } } """, -@"[MyAttribute(E.A)]")), + @"[MyAttribute(E.A)]")), @"[global::MyAttribute(global::E.A)]"); VerifySyntax(Generator.Attribute(GetAttributeData( @@ -224,7 +224,7 @@ public class MyAttribute : Attribute { public MyAttribute(E value) { } } using System; public class MyAttribute : Attribute { public MyAttribute(Type value) { } } """, -@"[MyAttribute(typeof (MyAttribute))]")), + @"[MyAttribute(typeof (MyAttribute))]")), @"[global::MyAttribute(typeof(global::MyAttribute))]"); VerifySyntax(Generator.Attribute(GetAttributeData( @@ -232,7 +232,7 @@ public class MyAttribute : Attribute { public MyAttribute(Type value) { } } using System; public class MyAttribute : Attribute { public MyAttribute(int[] values) { } } """, -@"[MyAttribute(new [] {1, 2, 3})]")), + @"[MyAttribute(new [] {1, 2, 3})]")), @"[global::MyAttribute(new[] { 1, 2, 3 })]"); VerifySyntax(Generator.Attribute(GetAttributeData( @@ -240,7 +240,7 @@ public class MyAttribute : Attribute { public MyAttribute(int[] values) { } } using System; public class MyAttribute : Attribute { public int Value {get; set;} } """, -@"[MyAttribute(Value = 123)]")), + @"[MyAttribute(Value = 123)]")), @"[global::MyAttribute(Value = 123)]"); var attributes = Generator.GetAttributes(Generator.AddAttributes( @@ -521,19 +521,15 @@ public void TestLocalDeclarationStatements() [Fact] public void TestAddHandlerExpressions() - { - VerifySyntax( + => VerifySyntax( Generator.AddEventHandler(Generator.IdentifierName("@event"), Generator.IdentifierName("handler")), "@event += (handler)"); - } [Fact] public void TestSubtractHandlerExpressions() - { - VerifySyntax( + => VerifySyntax( Generator.RemoveEventHandler(Generator.IdentifierName("@event"), Generator.IdentifierName("handler")), "@event -= (handler)"); - } [Fact] public void TestAwaitExpressions() @@ -674,11 +670,9 @@ public void TestUsingStatements() [Fact] public void TestLockStatements() - { - VerifySyntax( + => VerifySyntax( Generator.LockStatement(Generator.IdentifierName("x"), [Generator.IdentifierName("y")]), "lock (x)\r\n{\r\n y;\r\n}"); - } [Fact] public void TestTryCatchStatements() @@ -2258,8 +2252,7 @@ public void TestWithTypeConstraint() [Fact] public void TestInterfaceDeclarationWithEventFromSymbol() - { - VerifySyntax( + => VerifySyntax( Generator.Declaration(_emptyCompilation.GetTypeByMetadataName("System.ComponentModel.INotifyPropertyChanged")), """ public interface INotifyPropertyChanged @@ -2267,12 +2260,10 @@ public interface INotifyPropertyChanged event global::System.ComponentModel.PropertyChangedEventHandler PropertyChanged; } """); - } [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/38379")] public void TestUnsafeFieldDeclarationFromSymbol() - { - VerifySyntax( + => VerifySyntax( Generator.Declaration( _emptyCompilation.GetTypeByMetadataName("System.IntPtr").GetMembers("ToPointer").Single()), """ @@ -2280,12 +2271,10 @@ public void TestUnsafeFieldDeclarationFromSymbol() { } """); - } [Fact] public void TestEnumDeclarationFromSymbol() - { - VerifySyntax( + => VerifySyntax( Generator.Declaration( _emptyCompilation.GetTypeByMetadataName("System.DateTimeKind")), """ @@ -2296,12 +2285,10 @@ public enum DateTimeKind Local = 2 } """); - } [Fact] public void TestEnumWithUnderlyingTypeFromSymbol() - { - VerifySyntax( + => VerifySyntax( Generator.Declaration( _emptyCompilation.GetTypeByMetadataName("System.Security.SecurityRuleSet")), """ @@ -2312,7 +2299,6 @@ public enum SecurityRuleSet : byte Level2 = 2 } """); - } [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/66381")] public void TestDelegateDeclarationFromSymbol() @@ -2916,6 +2902,30 @@ interface i """); } + [Fact] + public void TestMultipleMembersIntoClass() + { + using var workspace = new AdhocWorkspace(); + var node = Generator.AddMembers(Generator.ClassDeclaration("C"), + [ + Generator.MethodDeclaration("M1", returnType: Generator.TypeExpression(SpecialType.System_Void), accessibility: Accessibility.Public), + Generator.PropertyDeclaration("P1", Generator.TypeExpression(SpecialType.System_Int32), accessibility: Accessibility.Public) + ]); + + AssertEx.EqualOrDiff( + """ + class C + { + public void M1() + { + } + + public int P1 { get; set; } + } + """, + Formatter.Format(node, workspace).ToFullString()); + } + [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/65932")] public void TestAddExpressionBodyMembersToInterface() { @@ -5073,63 +5083,52 @@ public class C2 : C [Fact, WorkItem(" https://devdiv.visualstudio.com/DevDiv/_workitems/edit/1084965")] public void TestNamespaceModifiers() - { - TestModifiersAsync(DeclarationModifiers.None, + => TestModifiersAsync(DeclarationModifiers.None, """ [|namespace N1 { }|] """); - } [Fact, WorkItem(" https://devdiv.visualstudio.com/DevDiv/_workitems/edit/1084965")] public void TestFileScopedNamespaceModifiers() - { - TestModifiersAsync(DeclarationModifiers.None, + => TestModifiersAsync(DeclarationModifiers.None, """ [|namespace N1;|] """); - } [Fact, WorkItem(" https://devdiv.visualstudio.com/DevDiv/_workitems/edit/1084965")] public void TestClassModifiers1() - { - TestModifiersAsync(DeclarationModifiers.Static, + => TestModifiersAsync(DeclarationModifiers.Static, """ [|static class C { }|] """); - } [Fact, WorkItem(" https://devdiv.visualstudio.com/DevDiv/_workitems/edit/1084965")] public void TestMethodModifiers() - { - TestModifiersAsync(DeclarationModifiers.Sealed | DeclarationModifiers.Override, + => TestModifiersAsync(DeclarationModifiers.Sealed | DeclarationModifiers.Override, """ class C { [|public sealed override void M() { }|] } """); - } [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/66170")] public void TestMethodModifiers2() - { - TestModifiersAsync(DeclarationModifiers.ReadOnly, + => TestModifiersAsync(DeclarationModifiers.ReadOnly, """ struct S { [|public readonly void M() { }|] } """); - } [Fact] public void TestAsyncMethodModifier() - { - TestModifiersAsync(DeclarationModifiers.Async, + => TestModifiersAsync(DeclarationModifiers.Async, """ using System.Threading.Tasks; class C @@ -5137,78 +5136,65 @@ class C [|public async Task DoAsync() { await Task.CompletedTask; }|] } """); - } [Fact, WorkItem(" https://devdiv.visualstudio.com/DevDiv/_workitems/edit/1084965")] public void TestPropertyModifiers1() - { - TestModifiersAsync(DeclarationModifiers.Virtual | DeclarationModifiers.ReadOnly, + => TestModifiersAsync(DeclarationModifiers.Virtual | DeclarationModifiers.ReadOnly, """ class C { [|public virtual int X => 0;|] } """); - } [Fact] public void TestPropertyModifiers2() - { - TestModifiersAsync(DeclarationModifiers.ReadOnly | DeclarationModifiers.Required, + => TestModifiersAsync(DeclarationModifiers.ReadOnly | DeclarationModifiers.Required, """ class C { [|public required int X => 0;|] } """); - } [Fact, WorkItem(" https://devdiv.visualstudio.com/DevDiv/_workitems/edit/1084965")] public void TestFieldModifiers1() - { - TestModifiersAsync(DeclarationModifiers.Static, + => TestModifiersAsync(DeclarationModifiers.Static, """ class C { public static int [|X|]; } """); - } [Fact] public void TestFieldModifiers2() - { - TestModifiersAsync(DeclarationModifiers.Required, + => TestModifiersAsync(DeclarationModifiers.Required, """ class C { public required int [|X|]; } """); - } [Fact, WorkItem(" https://devdiv.visualstudio.com/DevDiv/_workitems/edit/1084965")] public void TestEvent1() - { - TestModifiersAsync(DeclarationModifiers.Virtual, + => TestModifiersAsync(DeclarationModifiers.Virtual, """ class C { public virtual event System.Action [|X|]; } """); - } [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/65834")] public void TestStructModifiers1() - { - TestModifiersAsync(DeclarationModifiers.ReadOnly | DeclarationModifiers.Sealed, + => TestModifiersAsync(DeclarationModifiers.ReadOnly | DeclarationModifiers.Sealed, """ public readonly struct [|S|] { } """); - } [Fact] public void TestStructModifiers2() diff --git a/src/Workspaces/CSharpTest/Formatting/EditorConfigOptionParserTests.cs b/src/Workspaces/CSharpTest/Formatting/EditorConfigOptionParserTests.cs index ee5e6e089173..7173905cc1be 100644 --- a/src/Workspaces/CSharpTest/Formatting/EditorConfigOptionParserTests.cs +++ b/src/Workspaces/CSharpTest/Formatting/EditorConfigOptionParserTests.cs @@ -36,40 +36,32 @@ internal void TestParseSpacingWithinParenthesesList(string list, SpacePlacementW InlineData("none", BinaryOperatorSpacingOptions.Remove), InlineData("before_and_after", BinaryOperatorSpacingOptions.Single)] public void TestParseEditorConfigSpacingAroundBinaryOperatorTrue(string value, BinaryOperatorSpacingOptions expectedResult) - { - Assert.True(CSharpFormattingOptions2.ParseEditorConfigSpacingAroundBinaryOperator(value) == (BinaryOperatorSpacingOptionsInternal)expectedResult, + => Assert.True(CSharpFormattingOptions2.ParseEditorConfigSpacingAroundBinaryOperator(value) == (BinaryOperatorSpacingOptionsInternal)expectedResult, $"Expected option {value} to be parsed as set."); - } [Theory, InlineData("ignore,"), InlineData("non"), InlineData("before_and_after,ignore")] public void TestParseEditorConfigSpacingAroundBinaryOperatorFalse(string value) - { - Assert.True(CSharpFormattingOptions2.ParseEditorConfigSpacingAroundBinaryOperator(value) == BinaryOperatorSpacingOptionsInternal.Single, + => Assert.True(CSharpFormattingOptions2.ParseEditorConfigSpacingAroundBinaryOperator(value) == BinaryOperatorSpacingOptionsInternal.Single, $"Expected option {value} to be parsed as default option."); - } [Theory, InlineData("flush_left", LabelPositionOptions.LeftMost), InlineData("no_change", LabelPositionOptions.NoIndent), InlineData("one_less_than_current", LabelPositionOptions.OneLess)] public void TestParseEditorConfigLabelPositioningTrue(string value, LabelPositionOptions expectedValue) - { - Assert.True(CSharpFormattingOptions2.ParseEditorConfigLabelPositioning(value) == (LabelPositionOptionsInternal)expectedValue, + => Assert.True(CSharpFormattingOptions2.ParseEditorConfigLabelPositioning(value) == (LabelPositionOptionsInternal)expectedValue, $"Expected option {value} to be parsed as set."); - } [Theory, InlineData("left_most,"), InlineData("*"), InlineData("one_less_thancurrent")] public void TestParseEditorConfigLabelPositioningFalse(string value) - { - Assert.True(CSharpFormattingOptions2.ParseEditorConfigLabelPositioning(value) == LabelPositionOptionsInternal.NoIndent, + => Assert.True(CSharpFormattingOptions2.ParseEditorConfigLabelPositioning(value) == LabelPositionOptionsInternal.NoIndent, $"Expected option {value} to be parsed default"); - } [Theory] [InlineData("all", @@ -113,18 +105,14 @@ internal void TestParseNewLineBeforeOpenBracePlacementList(string list, NewLineB InlineData(" ignore"), InlineData(" ignore ")] public void TestDetermineIfIgnoreSpacesAroundVariableDeclarationIsSetTrue(string value) - { - Assert.True(CSharpFormattingOptions2.DetermineIfIgnoreSpacesAroundVariableDeclarationIsSet(value), + => Assert.True(CSharpFormattingOptions2.DetermineIfIgnoreSpacesAroundVariableDeclarationIsSet(value), $"Expected option {value} to be set"); - } [Theory, InlineData("do_not_ignore"), InlineData(", "), InlineData(" ignor ")] public void TestDetermineIfIgnoreSpacesAroundVariableDeclarationIsSetFalse(string value) - { - Assert.False(CSharpFormattingOptions2.DetermineIfIgnoreSpacesAroundVariableDeclarationIsSet(value), + => Assert.False(CSharpFormattingOptions2.DetermineIfIgnoreSpacesAroundVariableDeclarationIsSet(value), $"Expected option {value} to be un-set"); - } } diff --git a/src/Workspaces/CSharpTest/Formatting/FormattingTests.cs b/src/Workspaces/CSharpTest/Formatting/FormattingTests.cs index 017e93969403..dc94681b9045 100644 --- a/src/Workspaces/CSharpTest/Formatting/FormattingTests.cs +++ b/src/Workspaces/CSharpTest/Formatting/FormattingTests.cs @@ -6358,100 +6358,98 @@ class Program [Fact, WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/797278")] public async Task TestSpacingOptionAroundControlFlow() { - const string code = """ + var optionSet = new OptionsCollection(LanguageNames.CSharp) + { + { SpaceBetweenParentheses, SpaceBetweenParentheses.DefaultValue.WithFlagValue( SpacePlacementWithinParentheses.ControlFlowStatements, true) }, + }; + + await AssertFormatAsync(""" class Program { public void goo() { int i; - for(i=0; i<10; i++) - {} + for ( i = 0; i < 10; i++ ) + { } - foreach(i in new[] {1,2,3}) - {} + foreach ( i in new[] { 1, 2, 3 } ) + { } - if (i==10) - {} + if ( i == 10 ) + { } - while(i==10) - {} + while ( i == 10 ) + { } - switch(i) + switch ( i ) { default: break; } - do {} while (true); + do { } while ( true ); try { } - catch (System.Exception) + catch ( System.Exception ) { } - catch (System.Exception e) when (true) + catch ( System.Exception e ) when ( true ) { } - using(somevar) + using ( somevar ) { } - lock(somevar) + lock ( somevar ) { } - fixed(char* p = str) + fixed ( char* p = str ) { } } } - """; - const string expected = """ + """, """ class Program { public void goo() { int i; - for ( i = 0; i < 10; i++ ) - { } + for(i=0; i<10; i++) + {} - foreach ( i in new[] { 1, 2, 3 } ) - { } + foreach(i in new[] {1,2,3}) + {} - if ( i == 10 ) - { } + if (i==10) + {} - while ( i == 10 ) - { } + while(i==10) + {} - switch ( i ) + switch(i) { default: break; } - do { } while ( true ); + do {} while (true); try { } - catch ( System.Exception ) + catch (System.Exception) { } - catch ( System.Exception e ) when ( true ) + catch (System.Exception e) when (true) { } - using ( somevar ) + using(somevar) { } - lock ( somevar ) + lock(somevar) { } - fixed ( char* p = str ) + fixed(char* p = str) { } } } - """; - var optionSet = new OptionsCollection(LanguageNames.CSharp) - { - { SpaceBetweenParentheses, SpaceBetweenParentheses.DefaultValue.WithFlagValue( SpacePlacementWithinParentheses.ControlFlowStatements, true) }, - }; - - await AssertFormatAsync(expected, code, changedOptionSet: optionSet); + """, changedOptionSet: optionSet); } [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/37031")] @@ -7512,28 +7510,24 @@ void LocalFunction(int i, string s) [Fact] public async Task ArrayDeclarationShouldFollowEmptySquareBrackets() { - const string code = """ + var options = new OptionsCollection(LanguageNames.CSharp) + { + { CSharpFormattingOptions2.SpaceWithinSquareBrackets, true }, + { CSharpFormattingOptions2.SpaceBetweenEmptySquareBrackets, false } + }; + await AssertFormatAsync(""" class Program { - var t = new Goo(new[ ] { "a", "b" }); + var t = new Goo(new[] { "a", "b" }); } - """; - - const string expected = """ + """, """ class Program { - var t = new Goo(new[] { "a", "b" }); + var t = new Goo(new[ ] { "a", "b" }); } - """; - - var options = new OptionsCollection(LanguageNames.CSharp) - { - { CSharpFormattingOptions2.SpaceWithinSquareBrackets, true }, - { CSharpFormattingOptions2.SpaceBetweenEmptySquareBrackets, false } - }; - await AssertFormatAsync(expected, code, changedOptionSet: options); + """, changedOptionSet: options); } [Fact] @@ -8284,9 +8278,8 @@ static string F(int a, int b, int c) """); [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/62")] - public async Task SpaceAfterWhenInExceptionFilter() - { - const string expected = """ + public Task SpaceAfterWhenInExceptionFilter() + => AssertFormatAsync(""" class C { void M() @@ -8304,9 +8297,7 @@ void M() } } } - """; - - const string code = """ + """, """ class C { void M() @@ -8323,113 +8314,96 @@ void M() } } } - """; - await AssertFormatAsync(expected, code); - } + """); [Fact, WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/1089196")] [WorkItem("https://github.com/dotnet/roslyn/issues/285")] - public async Task FormatHashInBadDirectiveToZeroColumnAnywhereInsideIfDef() - { - const string code = """ + public Task FormatHashInBadDirectiveToZeroColumnAnywhereInsideIfDef() + => AssertFormatAsync(""" class MyClass { static void Main(string[] args) { #if false - # + # #endif } } - """; - - const string expected = """ + """, """ class MyClass { static void Main(string[] args) { #if false - # + # #endif } } - """; - await AssertFormatAsync(expected, code); - } + """); [Fact, WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/1089196")] [WorkItem("https://github.com/dotnet/roslyn/issues/285")] - public async Task FormatHashElseToZeroColumnAnywhereInsideIfDef() - { - const string code = """ + public Task FormatHashElseToZeroColumnAnywhereInsideIfDef() + => AssertFormatAsync(""" class MyClass { static void Main(string[] args) { #if false - #else + #else Appropriate indentation should be here though # #endif } } - """; - - const string expected = """ + """, """ class MyClass { static void Main(string[] args) { #if false - #else + #else Appropriate indentation should be here though # #endif } } - """; - await AssertFormatAsync(expected, code); - } + """); [Fact, WorkItem("http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/1089196")] [WorkItem("https://github.com/dotnet/roslyn/issues/285")] - public async Task FormatHashsToZeroColumnAnywhereInsideIfDef() - { - const string code = """ + public Task FormatHashsToZeroColumnAnywhereInsideIfDef() + => AssertFormatAsync(""" class MyClass { static void Main(string[] args) { #if false - #else - # + #else + # #endif } } - """; - - const string expected = """ + """, """ class MyClass { static void Main(string[] args) { #if false - #else - # + #else + # #endif } } - """; - await AssertFormatAsync(expected, code); - } + """); [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/1118")] public void DoNotAssumeCertainNodeAreAlwaysParented() @@ -8484,43 +8458,41 @@ static void Main(string[] args) [Fact] public async Task SpacingInMethodCallArguments_True() { - const string code = """ + var optionSet = new OptionsCollection(LanguageNames.CSharp) + { + { CSharpFormattingOptions2.SpaceWithinMethodCallParentheses, true }, + { CSharpFormattingOptions2.SpaceAfterMethodCallName, true }, + { CSharpFormattingOptions2.SpaceBetweenEmptyMethodCallParentheses, true }, + }; + await AssertFormatAsync(""" - [Bar(A=1,B=2)] + [Bar ( A = 1, B = 2 )] class Program { public void goo() { - var a = typeof(A); - var b = M(a); - var c = default(A); - var d = sizeof(A); - M(); + var a = typeof ( A ); + var b = M ( a ); + var c = default ( A ); + var d = sizeof ( A ); + M ( ); } } - """; - const string expected = """ + """, """ - [Bar ( A = 1, B = 2 )] + [Bar(A=1,B=2)] class Program { public void goo() { - var a = typeof ( A ); - var b = M ( a ); - var c = default ( A ); - var d = sizeof ( A ); - M ( ); + var a = typeof(A); + var b = M(a); + var c = default(A); + var d = sizeof(A); + M(); } } - """; - var optionSet = new OptionsCollection(LanguageNames.CSharp) - { - { CSharpFormattingOptions2.SpaceWithinMethodCallParentheses, true }, - { CSharpFormattingOptions2.SpaceAfterMethodCallName, true }, - { CSharpFormattingOptions2.SpaceBetweenEmptyMethodCallParentheses, true }, - }; - await AssertFormatAsync(expected, code, changedOptionSet: optionSet); + """, changedOptionSet: optionSet); } [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/1298")] diff --git a/src/Workspaces/Core/Portable/CodeActions/CodeAction_Cleanup.cs b/src/Workspaces/Core/Portable/CodeActions/CodeAction_Cleanup.cs index b43a77428d3a..80b1c93c982d 100644 --- a/src/Workspaces/Core/Portable/CodeActions/CodeAction_Cleanup.cs +++ b/src/Workspaces/Core/Portable/CodeActions/CodeAction_Cleanup.cs @@ -14,9 +14,8 @@ using Microsoft.CodeAnalysis.PooledObjects; using Microsoft.CodeAnalysis.Remote; using Microsoft.CodeAnalysis.Shared.Extensions; -using Microsoft.CodeAnalysis.Shared.Utilities; using Microsoft.CodeAnalysis.Simplification; -using Roslyn.Utilities; +using Microsoft.CodeAnalysis.Threading; namespace Microsoft.CodeAnalysis.CodeActions; diff --git a/src/Workspaces/Core/Portable/CodeFixes/FixAllOccurrences/DocumentBasedFixAllProvider.cs b/src/Workspaces/Core/Portable/CodeFixes/FixAllOccurrences/DocumentBasedFixAllProvider.cs index 88e8fc3f4d4d..796d9d7f1ce1 100644 --- a/src/Workspaces/Core/Portable/CodeFixes/FixAllOccurrences/DocumentBasedFixAllProvider.cs +++ b/src/Workspaces/Core/Portable/CodeFixes/FixAllOccurrences/DocumentBasedFixAllProvider.cs @@ -82,7 +82,7 @@ private async Task DetermineDiagnosticsAndGetFixedDocumentsAsync( // Second, get the fixes for each document+diagnostics pair in parallel, and apply them to determine the new // root/text for each doc. - await RoslynParallel.ForEachAsync( + await Parallel.ForEachAsync( source: documentToDiagnostics, cancellationToken, async (kvp, cancellationToken) => diff --git a/src/Workspaces/Core/Portable/CodeFixes/FixAllOccurrences/FixAllContext.DiagnosticProvider.cs b/src/Workspaces/Core/Portable/CodeFixes/FixAllOccurrences/FixAllContext.DiagnosticProvider.cs index ce49576aa2cb..0c75d33aa929 100644 --- a/src/Workspaces/Core/Portable/CodeFixes/FixAllOccurrences/FixAllContext.DiagnosticProvider.cs +++ b/src/Workspaces/Core/Portable/CodeFixes/FixAllOccurrences/FixAllContext.DiagnosticProvider.cs @@ -9,7 +9,7 @@ using System.Threading.Tasks; using Microsoft.CodeAnalysis.CodeFixesAndRefactorings; using Microsoft.CodeAnalysis.Internal.Log; -using Microsoft.CodeAnalysis.Shared.Utilities; +using Microsoft.CodeAnalysis.Threading; using Roslyn.Utilities; namespace Microsoft.CodeAnalysis.CodeFixes; diff --git a/src/Workspaces/Core/Portable/CodeFixes/FixAllOccurrences/FixAllContextHelper.cs b/src/Workspaces/Core/Portable/CodeFixes/FixAllOccurrences/FixAllContextHelper.cs index 21446325dc7e..83a5f68d6914 100644 --- a/src/Workspaces/Core/Portable/CodeFixes/FixAllOccurrences/FixAllContextHelper.cs +++ b/src/Workspaces/Core/Portable/CodeFixes/FixAllOccurrences/FixAllContextHelper.cs @@ -10,8 +10,8 @@ using Microsoft.CodeAnalysis.CodeFixesAndRefactorings; using Microsoft.CodeAnalysis.PooledObjects; using Microsoft.CodeAnalysis.Shared.Extensions; -using Microsoft.CodeAnalysis.Shared.Utilities; using Microsoft.CodeAnalysis.Text; +using Microsoft.CodeAnalysis.Threading; using Roslyn.Utilities; namespace Microsoft.CodeAnalysis.CodeFixes; diff --git a/src/Workspaces/Core/Portable/CodeFixesAndRefactorings/DocumentBasedFixAllProviderHelpers.cs b/src/Workspaces/Core/Portable/CodeFixesAndRefactorings/DocumentBasedFixAllProviderHelpers.cs index bd02c225db20..dbeca1f4975a 100644 --- a/src/Workspaces/Core/Portable/CodeFixesAndRefactorings/DocumentBasedFixAllProviderHelpers.cs +++ b/src/Workspaces/Core/Portable/CodeFixesAndRefactorings/DocumentBasedFixAllProviderHelpers.cs @@ -9,8 +9,8 @@ using Microsoft.CodeAnalysis.CodeFixes; using Microsoft.CodeAnalysis.Remote; using Microsoft.CodeAnalysis.Shared.Extensions; -using Microsoft.CodeAnalysis.Shared.Utilities; using Microsoft.CodeAnalysis.Text; +using Microsoft.CodeAnalysis.Threading; using Roslyn.Utilities; namespace Microsoft.CodeAnalysis.CodeFixesAndRefactorings; diff --git a/src/Workspaces/Core/Portable/CodeRefactorings/FixAllOccurences/DocumentBasedFixAllProvider.cs b/src/Workspaces/Core/Portable/CodeRefactorings/FixAllOccurences/DocumentBasedFixAllProvider.cs index 6dbcf20bc100..1617b9c9453d 100644 --- a/src/Workspaces/Core/Portable/CodeRefactorings/FixAllOccurences/DocumentBasedFixAllProvider.cs +++ b/src/Workspaces/Core/Portable/CodeRefactorings/FixAllOccurences/DocumentBasedFixAllProvider.cs @@ -89,7 +89,7 @@ private async Task GetFixedDocumentsAsync( // Process all documents in parallel to get the change for each doc. var documentsAndSpansToFix = await fixAllContext.GetFixAllSpansAsync(cancellationToken).ConfigureAwait(false); - await RoslynParallel.ForEachAsync( + await Parallel.ForEachAsync( source: documentsAndSpansToFix, cancellationToken, async (tuple, cancellationToken) => diff --git a/src/Workspaces/Core/Portable/Diagnostics/Extensions.cs b/src/Workspaces/Core/Portable/Diagnostics/Extensions.cs index 266415b4b027..aed55c8038c5 100644 --- a/src/Workspaces/Core/Portable/Diagnostics/Extensions.cs +++ b/src/Workspaces/Core/Portable/Diagnostics/Extensions.cs @@ -15,8 +15,8 @@ using Microsoft.CodeAnalysis.PooledObjects; using Microsoft.CodeAnalysis.Remote; using Microsoft.CodeAnalysis.Shared.Extensions; -using Microsoft.CodeAnalysis.Shared.Utilities; using Microsoft.CodeAnalysis.Text; +using Microsoft.CodeAnalysis.Threading; using Microsoft.CodeAnalysis.Workspaces.Diagnostics; using Roslyn.Utilities; diff --git a/src/Workspaces/Core/Portable/FindSymbols/FindLiterals/FindLiteralsSearchEngine.cs b/src/Workspaces/Core/Portable/FindSymbols/FindLiterals/FindLiteralsSearchEngine.cs index f9ef84d99ba0..15a252b26edb 100644 --- a/src/Workspaces/Core/Portable/FindSymbols/FindLiterals/FindLiteralsSearchEngine.cs +++ b/src/Workspaces/Core/Portable/FindSymbols/FindLiterals/FindLiteralsSearchEngine.cs @@ -87,7 +87,7 @@ private async Task FindReferencesWorkerAsync(CancellationToken cancellationToken var count = _solution.Projects.SelectMany(p => p.DocumentIds).Count(); await _progressTracker.AddItemsAsync(count, cancellationToken).ConfigureAwait(false); - await RoslynParallel.ForEachAsync( + await Parallel.ForEachAsync( source: SelectManyAsync(_solution.Projects, p => p.GetAllRegularAndSourceGeneratedDocumentsAsync(cancellationToken)), cancellationToken, ProcessDocumentAsync).ConfigureAwait(false); diff --git a/src/Workspaces/Core/Portable/FindSymbols/FindReferences/FindReferencesSearchEngine.cs b/src/Workspaces/Core/Portable/FindSymbols/FindReferences/FindReferencesSearchEngine.cs index 1652e97e4425..9fda34d3981d 100644 --- a/src/Workspaces/Core/Portable/FindSymbols/FindReferences/FindReferencesSearchEngine.cs +++ b/src/Workspaces/Core/Portable/FindSymbols/FindReferences/FindReferencesSearchEngine.cs @@ -14,6 +14,7 @@ using Microsoft.CodeAnalysis.PooledObjects; using Microsoft.CodeAnalysis.Shared.Extensions; using Microsoft.CodeAnalysis.Shared.Utilities; +using Microsoft.CodeAnalysis.Threading; using Roslyn.Utilities; namespace Microsoft.CodeAnalysis.FindSymbols; @@ -113,7 +114,7 @@ private async Task PerformSearchAsync( await _progressTracker.AddItemsAsync(projectsToSearch.Length, cancellationToken).ConfigureAwait(false); // Pull off and start searching each project as soon as we can once we've done the inheritance cascade into it. - await RoslynParallel.ForEachAsync( + await Parallel.ForEachAsync( // ForEachAsync will serially pull on the IAsyncEnumerable returned here, kicking off the processing to then // happen in parallel. GetProjectsAndSymbolsToSearchSeriallyAsync(symbolSet, projectsToSearch, symbolToGroup, cancellationToken), @@ -246,7 +247,7 @@ await finder.DetermineDocumentsToSearchAsync( } } - await RoslynParallel.ForEachAsync( + await Parallel.ForEachAsync( documentToSymbolsWithin, GetParallelOptions(cancellationToken), (kvp, cancellationToken) => @@ -297,7 +298,7 @@ private async ValueTask ProcessDocumentAsync( cache.FindMatchingIdentifierTokens(symbol.Name, cancellationToken); } - await RoslynParallel.ForEachAsync( + await Parallel.ForEachAsync( symbolsToSearchFor, GetParallelOptions(cancellationToken), (kvp, cancellationToken) => @@ -310,7 +311,7 @@ await RoslynParallel.ForEachAsync( cache, TryGet(symbolToGlobalAliases, symbolToSearchFor)); ProcessDocument(symbolToSearchFor, symbolGroup, state, onReferenceFound); - return ValueTaskFactory.CompletedTask; + return ValueTask.CompletedTask; }).ConfigureAwait(false); return; diff --git a/src/Workspaces/Core/Portable/FindSymbols/FindReferences/FindReferencesSearchEngine_FindReferencesInDocuments.cs b/src/Workspaces/Core/Portable/FindSymbols/FindReferences/FindReferencesSearchEngine_FindReferencesInDocuments.cs index 87b7f4ca622f..44e770fcb56e 100644 --- a/src/Workspaces/Core/Portable/FindSymbols/FindReferences/FindReferencesSearchEngine_FindReferencesInDocuments.cs +++ b/src/Workspaces/Core/Portable/FindSymbols/FindReferences/FindReferencesSearchEngine_FindReferencesInDocuments.cs @@ -12,7 +12,7 @@ using Microsoft.CodeAnalysis.FindSymbols.Finders; using Microsoft.CodeAnalysis.PooledObjects; using Microsoft.CodeAnalysis.Shared.Extensions; -using Microsoft.CodeAnalysis.Shared.Utilities; +using Microsoft.CodeAnalysis.Threading; namespace Microsoft.CodeAnalysis.FindSymbols; diff --git a/src/Workspaces/Core/Portable/FindSymbols/FindReferences/StreamingFindReferencesProgress.cs b/src/Workspaces/Core/Portable/FindSymbols/FindReferences/StreamingFindReferencesProgress.cs index 92074d8deaa5..6e9c6f833697 100644 --- a/src/Workspaces/Core/Portable/FindSymbols/FindReferences/StreamingFindReferencesProgress.cs +++ b/src/Workspaces/Core/Portable/FindSymbols/FindReferences/StreamingFindReferencesProgress.cs @@ -58,7 +58,7 @@ public ValueTask OnReferencesFoundAsync(ImmutableArray<(SymbolGroup group, ISymb foreach (var (_, symbol, location) in references) _progress.OnReferenceFound(symbol, location); - return ValueTaskFactory.CompletedTask; + return ValueTask.CompletedTask; } public ValueTask OnStartedAsync(CancellationToken cancellationToken) diff --git a/src/Workspaces/Core/Portable/Log/FunctionIdExtensions.cs b/src/Workspaces/Core/Portable/Log/FunctionIdExtensions.cs index eaa4ffc90a8e..3b9da97674b6 100644 --- a/src/Workspaces/Core/Portable/Log/FunctionIdExtensions.cs +++ b/src/Workspaces/Core/Portable/Log/FunctionIdExtensions.cs @@ -11,7 +11,7 @@ namespace Microsoft.CodeAnalysis.Internal.Log; internal static class FunctionIdExtensions { private static readonly Lazy> s_functionIdsToString = new( - () => Enum.GetValues(typeof(FunctionId)).Cast().ToImmutableDictionary(f => f, f => f.ToString())); + () => Enum.GetValues().ToImmutableDictionary(f => f, f => f.ToString())); public static string Convert(this FunctionId functionId) => s_functionIdsToString.Value[functionId]; } diff --git a/src/Workspaces/Core/Portable/Recommendations/AbstractRecommendationService.cs b/src/Workspaces/Core/Portable/Recommendations/AbstractRecommendationService.cs index 04f43188acc6..dc97e88ba7ba 100644 --- a/src/Workspaces/Core/Portable/Recommendations/AbstractRecommendationService.cs +++ b/src/Workspaces/Core/Portable/Recommendations/AbstractRecommendationService.cs @@ -113,7 +113,9 @@ internal bool ShouldIncludeSymbol(ISymbol symbol) if (_context.IsEnumTypeMemberAccessContext) { - return symbol.Kind == SymbolKind.Field; + // Within an enum type, we can access fields of the enum, as well as static extensions on that type. + return symbol.Kind == SymbolKind.Field || + symbol is { IsStatic: true, ContainingType.IsExtension: true }; } // In an expression or statement context, we don't want to display instance members declared in outer containing types. diff --git a/src/Workspaces/Core/Portable/Rename/ConflictEngine/ConflictResolver.Session.cs b/src/Workspaces/Core/Portable/Rename/ConflictEngine/ConflictResolver.Session.cs index abd64f62bbcc..f294e1215bf3 100644 --- a/src/Workspaces/Core/Portable/Rename/ConflictEngine/ConflictResolver.Session.cs +++ b/src/Workspaces/Core/Portable/Rename/ConflictEngine/ConflictResolver.Session.cs @@ -36,7 +36,6 @@ private sealed class Session private readonly DocumentId _documentIdOfRenameSymbolDeclaration; private readonly string _originalText; private readonly string _replacementText; - private readonly ImmutableArray _nonConflictSymbolKeys; private readonly CancellationToken _cancellationToken; private readonly RenameAnnotation _renamedSymbolDeclarationAnnotation = new(); @@ -50,14 +49,12 @@ public Session( SymbolicRenameLocations renameLocationSet, Location renameSymbolDeclarationLocation, string replacementText, - ImmutableArray nonConflictSymbolKeys, CancellationToken cancellationToken) { _renameLocationSet = renameLocationSet; _renameSymbolDeclarationLocation = renameSymbolDeclarationLocation; _originalText = renameLocationSet.Symbol.Name; _replacementText = replacementText; - _nonConflictSymbolKeys = nonConflictSymbolKeys; _cancellationToken = cancellationToken; _replacementTextValid = true; @@ -292,7 +289,7 @@ private async Task DebugVerifyNoErrorsAsync(MutableConflictResolution conflictRe // fixed them because of rename). Also, don't bother checking if a custom // callback was provided. The caller might be ok with a rename that introduces // errors. - if (!documentIdErrorStateLookup[documentId] && _nonConflictSymbolKeys.IsDefault) + if (!documentIdErrorStateLookup[documentId]) { var changeDoc = await conflictResolution.CurrentSolution.GetRequiredDocumentAsync( documentId, RenameOptions.RenameInSourceGeneratedDocuments, _cancellationToken).ConfigureAwait(false); @@ -349,7 +346,6 @@ private async Task IdentifyConflictsAsync( // If we were giving any non-conflict-symbols then ensure that we know what those symbols are in // the current project post after our edits so far. var currentProject = conflictResolution.CurrentSolution.GetRequiredProject(projectId); - var nonConflictSymbols = await GetNonConflictSymbolsAsync(currentProject).ConfigureAwait(false); foreach (var documentId in documentIdsForConflictResolution) { @@ -392,9 +388,8 @@ private async Task IdentifyConflictsAsync( // the spans would have been modified and so we need to adjust the old position // to the new position for which we use the renameSpanTracker, which was tracking // & mapping the old span -> new span during rename - hasConflict = - !IsConflictFreeChange(newReferencedSymbols, nonConflictSymbols) && - await CheckForConflictAsync(conflictResolution, renamedSymbolInNewSolution, conflictAnnotation, newReferencedSymbols).ConfigureAwait(false); + hasConflict = await CheckForConflictAsync( + conflictResolution, renamedSymbolInNewSolution, conflictAnnotation, newReferencedSymbols).ConfigureAwait(false); if (!hasConflict && !conflictAnnotation.IsInvocationExpression) hasConflict = LocalVariableConflictPerLanguage((SyntaxToken)tokenOrNode, newDocument, newReferencedSymbols); @@ -475,32 +470,6 @@ await AddDeclarationConflictsAsync( } } - private async Task?> GetNonConflictSymbolsAsync(Project currentProject) - { - if (_nonConflictSymbolKeys.IsDefault) - return null; - - var compilation = await currentProject.GetRequiredCompilationAsync(_cancellationToken).ConfigureAwait(false); - return [.. _nonConflictSymbolKeys.Select(s => s.Resolve(compilation).GetAnySymbol()).WhereNotNull()]; - } - - private static bool IsConflictFreeChange( - ImmutableArray symbols, ImmutableHashSet? nonConflictSymbols) - { - if (nonConflictSymbols != null) - { - foreach (var symbol in symbols) - { - // Reference not points at a symbol in the conflict-free list. This is a conflict-free change. - if (nonConflictSymbols.Contains(symbol)) - return true; - } - } - - // Just do the default check. - return false; - } - /// /// Gets the list of the nodes that were annotated for a conflict check /// diff --git a/src/Workspaces/Core/Portable/Rename/ConflictEngine/ConflictResolver.cs b/src/Workspaces/Core/Portable/Rename/ConflictEngine/ConflictResolver.cs index d4a2a4a81d33..6b9e792324ba 100644 --- a/src/Workspaces/Core/Portable/Rename/ConflictEngine/ConflictResolver.cs +++ b/src/Workspaces/Core/Portable/Rename/ConflictEngine/ConflictResolver.cs @@ -42,17 +42,12 @@ internal static partial class ConflictResolver /// resolves them where possible. /// /// The new name of the identifier - /// Used after renaming references. References that now bind to any of these - /// symbols are not considered to be in conflict. Useful for features that want to rename existing references to - /// point at some existing symbol. Normally this would be a conflict, but this can be used to override that - /// behavior. /// The cancellation token. /// A conflict resolution containing the new solution. internal static async Task ResolveLightweightConflictsAsync( ISymbol symbol, LightweightRenameLocations lightweightRenameLocations, string replacementText, - ImmutableArray nonConflictSymbolKeys, CancellationToken cancellationToken) { cancellationToken.ThrowIfCancellationRequested(); @@ -68,7 +63,8 @@ internal static async Task ResolveLightweightConflictsAsync( var result = await client.TryInvokeAsync( solution, - (service, solutionInfo, cancellationToken) => service.ResolveConflictsAsync(solutionInfo, serializableSymbol, serializableLocationSet, replacementText, nonConflictSymbolKeys, cancellationToken), + (service, solutionInfo, cancellationToken) => service.ResolveConflictsAsync( + solutionInfo, serializableSymbol, serializableLocationSet, replacementText, cancellationToken), cancellationToken).ConfigureAwait(false); if (result.HasValue && result.Value != null) @@ -83,7 +79,7 @@ internal static async Task ResolveLightweightConflictsAsync( return new ConflictResolution(WorkspacesResources.Failed_to_resolve_rename_conflicts); return await ResolveSymbolicLocationConflictsInCurrentProcessAsync( - heavyweightLocations, replacementText, nonConflictSymbolKeys, cancellationToken).ConfigureAwait(false); + heavyweightLocations, replacementText, cancellationToken).ConfigureAwait(false); } /// @@ -93,7 +89,6 @@ internal static async Task ResolveLightweightConflictsAsync( internal static async Task ResolveSymbolicLocationConflictsInCurrentProcessAsync( SymbolicRenameLocations renameLocations, string replacementText, - ImmutableArray nonConflictSymbolKeys, CancellationToken cancellationToken) { // when someone e.g. renames a symbol from metadata through the API (IDE blocks this), we need to return @@ -105,7 +100,7 @@ internal static async Task ResolveSymbolicLocationConflictsI } var resolution = await ResolveMutableConflictsAsync( - renameLocations, renameSymbolDeclarationLocation, replacementText, nonConflictSymbolKeys, cancellationToken).ConfigureAwait(false); + renameLocations, renameSymbolDeclarationLocation, replacementText, cancellationToken).ConfigureAwait(false); return resolution.ToConflictResolution(); } @@ -114,12 +109,11 @@ private static Task ResolveMutableConflictsAsync( SymbolicRenameLocations renameLocationSet, Location renameSymbolDeclarationLocation, string replacementText, - ImmutableArray nonConflictSymbolKeys, CancellationToken cancellationToken) { cancellationToken.ThrowIfCancellationRequested(); var session = new Session( - renameLocationSet, renameSymbolDeclarationLocation, replacementText, nonConflictSymbolKeys, cancellationToken); + renameLocationSet, renameSymbolDeclarationLocation, replacementText, cancellationToken); return session.ResolveConflictsAsync(); } diff --git a/src/Workspaces/Core/Portable/Rename/IRemoteRenamerService.cs b/src/Workspaces/Core/Portable/Rename/IRemoteRenamerService.cs index 953abf73dcba..c07b54c6bc07 100644 --- a/src/Workspaces/Core/Portable/Rename/IRemoteRenamerService.cs +++ b/src/Workspaces/Core/Portable/Rename/IRemoteRenamerService.cs @@ -27,7 +27,6 @@ internal interface IRemoteRenamerService SerializableSymbolAndProjectId symbolAndProjectId, string replacementText, SymbolRenameOptions options, - ImmutableArray nonConflictSymbolKeys, CancellationToken cancellationToken); ValueTask FindRenameLocationsAsync( @@ -41,7 +40,6 @@ internal interface IRemoteRenamerService SerializableSymbolAndProjectId symbolAndProjectId, SerializableRenameLocations renameLocationSet, string replacementText, - ImmutableArray nonConflictSymbolKeys, CancellationToken cancellationToken); } diff --git a/src/Workspaces/Core/Portable/Rename/LightweightRenameLocations.cs b/src/Workspaces/Core/Portable/Rename/LightweightRenameLocations.cs index 7df6929dcabe..ad9b98cce7fd 100644 --- a/src/Workspaces/Core/Portable/Rename/LightweightRenameLocations.cs +++ b/src/Workspaces/Core/Portable/Rename/LightweightRenameLocations.cs @@ -114,8 +114,8 @@ public static async Task FindRenameLocationsAsync( renameLocations.ReferencedSymbols.SelectAsArray(sym => SerializableSymbolAndProjectId.Dehydrate(solution, sym, cancellationToken))); } - public Task ResolveConflictsAsync(ISymbol symbol, string replacementText, ImmutableArray nonConflictSymbolKeys, CancellationToken cancellationToken) - => ConflictResolver.ResolveLightweightConflictsAsync(symbol, this, replacementText, nonConflictSymbolKeys, cancellationToken); + public Task ResolveConflictsAsync(ISymbol symbol, string replacementText, CancellationToken cancellationToken) + => ConflictResolver.ResolveLightweightConflictsAsync(symbol, this, replacementText, cancellationToken); public LightweightRenameLocations Filter(Func filter) => new( diff --git a/src/Workspaces/Core/Portable/Rename/Renamer.cs b/src/Workspaces/Core/Portable/Rename/Renamer.cs index 7e79da036c02..545bf3d986d4 100644 --- a/src/Workspaces/Core/Portable/Rename/Renamer.cs +++ b/src/Workspaces/Core/Portable/Rename/Renamer.cs @@ -50,7 +50,7 @@ public static async Task RenameSymbolAsync( if (string.IsNullOrEmpty(newName)) throw new ArgumentException(WorkspacesResources._0_must_be_a_non_null_and_non_empty_string, nameof(newName)); - var resolution = await RenameSymbolAsync(solution, symbol, newName, options, nonConflictSymbolKeys: default, cancellationToken).ConfigureAwait(false); + var resolution = await RenameSymbolAsync(solution, symbol, newName, options, cancellationToken).ConfigureAwait(false); if (resolution.IsSuccessful) { @@ -144,7 +144,6 @@ internal static async Task RenameSymbolAsync( ISymbol symbol, string newName, SymbolRenameOptions options, - ImmutableArray nonConflictSymbolKeys, CancellationToken cancellationToken) { Contract.ThrowIfNull(solution); @@ -167,7 +166,6 @@ internal static async Task RenameSymbolAsync( serializedSymbol, newName, options, - nonConflictSymbolKeys, cancellationToken), cancellationToken).ConfigureAwait(false); @@ -180,8 +178,7 @@ internal static async Task RenameSymbolAsync( } return await RenameSymbolInCurrentProcessAsync( - solution, symbol, newName, options, - nonConflictSymbolKeys, cancellationToken).ConfigureAwait(false); + solution, symbol, newName, options, cancellationToken).ConfigureAwait(false); } private static async Task RenameSymbolInCurrentProcessAsync( @@ -189,7 +186,6 @@ private static async Task RenameSymbolInCurrentProcessAsync( ISymbol symbol, string newName, SymbolRenameOptions options, - ImmutableArray nonConflictSymbolKeys, CancellationToken cancellationToken) { Contract.ThrowIfNull(solution); @@ -203,6 +199,6 @@ private static async Task RenameSymbolInCurrentProcessAsync( // without having to go through any intermediary LightweightTypes. var renameLocations = await SymbolicRenameLocations.FindLocationsInCurrentProcessAsync(symbol, solution, options, cancellationToken).ConfigureAwait(false); return await ConflictResolver.ResolveSymbolicLocationConflictsInCurrentProcessAsync( - renameLocations, newName, nonConflictSymbolKeys, cancellationToken).ConfigureAwait(false); + renameLocations, newName, cancellationToken).ConfigureAwait(false); } } diff --git a/src/Workspaces/Core/Portable/SymbolSearch/ISymbolSearchService.cs b/src/Workspaces/Core/Portable/SymbolSearch/ISymbolSearchService.cs index c1714d80fee7..45337f28d766 100644 --- a/src/Workspaces/Core/Portable/SymbolSearch/ISymbolSearchService.cs +++ b/src/Workspaces/Core/Portable/SymbolSearch/ISymbolSearchService.cs @@ -156,11 +156,11 @@ internal sealed class ReferenceAssemblyResult( internal sealed class DefaultSymbolSearchService() : ISymbolSearchService { public ValueTask> FindPackagesAsync(string source, TypeQuery typeQuery, NamespaceQuery namespaceQuery, CancellationToken cancellationToken) - => ValueTaskFactory.FromResult(ImmutableArray.Empty); + => ValueTask.FromResult(ImmutableArray.Empty); public ValueTask> FindPackagesWithAssemblyAsync(string source, string assemblyName, CancellationToken cancellationToken) - => ValueTaskFactory.FromResult(ImmutableArray.Empty); + => ValueTask.FromResult(ImmutableArray.Empty); public ValueTask> FindReferenceAssembliesAsync(TypeQuery typeQuery, NamespaceQuery namespaceQuery, CancellationToken cancellationToken) - => ValueTaskFactory.FromResult(ImmutableArray.Empty); + => ValueTask.FromResult(ImmutableArray.Empty); } diff --git a/src/Workspaces/Core/Portable/Workspace/IsolatedAnalyzerReferenceSet.Desktop.cs b/src/Workspaces/Core/Portable/Workspace/IsolatedAnalyzerReferenceSet.Desktop.cs index c37ad98b42d9..362f448ae826 100644 --- a/src/Workspaces/Core/Portable/Workspace/IsolatedAnalyzerReferenceSet.Desktop.cs +++ b/src/Workspaces/Core/Portable/Workspace/IsolatedAnalyzerReferenceSet.Desktop.cs @@ -27,7 +27,7 @@ public static partial ValueTask> CreateIsolate SolutionServices solutionServices, CancellationToken cancellationToken) { - return ValueTaskFactory.FromResult(references); + return ValueTask.FromResult(references); } public static async partial ValueTask> CreateIsolatedAnalyzerReferencesAsync( diff --git a/src/Workspaces/Core/Portable/Workspace/Workspace_Editor.cs b/src/Workspaces/Core/Portable/Workspace/Workspace_Editor.cs index 5aee5921f967..a7b74adde521 100644 --- a/src/Workspaces/Core/Portable/Workspace/Workspace_Editor.cs +++ b/src/Workspaces/Core/Portable/Workspace/Workspace_Editor.cs @@ -355,7 +355,7 @@ protected internal void OnDocumentOpened(DocumentId documentId, SourceTextContai internal virtual ValueTask TryOnDocumentOpenedAsync(DocumentId documentId, SourceTextContainer textContainer, bool isCurrentContext, CancellationToken cancellationToken) { OnDocumentOpened(documentId, textContainer, isCurrentContext, requireDocumentPresentAndClosed: false); - return ValueTaskFactory.CompletedTask; + return ValueTask.CompletedTask; } internal void OnDocumentOpened(DocumentId documentId, SourceTextContainer textContainer, bool isCurrentContext, bool requireDocumentPresentAndClosed) diff --git a/src/Workspaces/CoreTest/FormattingTests.cs b/src/Workspaces/CoreTest/FormattingTests.cs index a369ae8f60fe..9444609ee5c2 100644 --- a/src/Workspaces/CoreTest/FormattingTests.cs +++ b/src/Workspaces/CoreTest/FormattingTests.cs @@ -22,9 +22,7 @@ public sealed partial class FormattingTests : TestBase { [Fact] public void TestCSharpFormatting() - { - AssertFormatCSharp(@"public class C { public int X; }", @"public class C{public int X;}"); - } + => AssertFormatCSharp(@"public class C { public int X; }", @"public class C{public int X;}"); [Fact] public void TestCSharpDefaultRules() @@ -39,8 +37,7 @@ public void TestCSharpDefaultRules() [Fact] public void TestVisualBasicFormatting() - { - AssertFormatVB(""" + => AssertFormatVB(""" Public Class C Public X As Integer End Class @@ -49,7 +46,6 @@ Public Class C Public X As Integer End Class """); - } [Fact] public void TestVisualBasicDefaultFormattingRules() diff --git a/src/Workspaces/CoreTest/GeneratedCodeRecognitionTests.cs b/src/Workspaces/CoreTest/GeneratedCodeRecognitionTests.cs index 17cfb30270d7..c7f0805b7dba 100644 --- a/src/Workspaces/CoreTest/GeneratedCodeRecognitionTests.cs +++ b/src/Workspaces/CoreTest/GeneratedCodeRecognitionTests.cs @@ -17,8 +17,7 @@ public sealed class GeneratedCodeRecognitionTests { [Fact] public void TestFileNamesNotGenerated() - { - TestFileNames(false, + => TestFileNames(false, "", "Test", "Test.cs", @@ -31,12 +30,10 @@ public void TestFileNamesNotGenerated() "Test.notgenerated.vb", "Test.generated", "Test.designer"); - } [Fact] public void TestFileNamesGenerated() - { - TestFileNames(true, + => TestFileNames(true, "TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92", "TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs", "TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.vb", @@ -50,7 +47,6 @@ public void TestFileNamesGenerated() "Test.g.vb", "Test.g.i.cs", "Test.g.i.vb"); - } private static void TestFileNames(bool assertGenerated, params string[] fileNames) { diff --git a/src/Workspaces/CoreTest/LinkedFileDiffMerging/LinkedFileDiffMergingTests.Features.cs b/src/Workspaces/CoreTest/LinkedFileDiffMerging/LinkedFileDiffMergingTests.Features.cs index 257d59cb4295..319241fff04d 100644 --- a/src/Workspaces/CoreTest/LinkedFileDiffMerging/LinkedFileDiffMergingTests.Features.cs +++ b/src/Workspaces/CoreTest/LinkedFileDiffMerging/LinkedFileDiffMergingTests.Features.cs @@ -12,8 +12,7 @@ public sealed partial class LinkedFileDiffMergingTests { [Fact] public void TestChangeSignature() - { - TestLinkedFileSet( + => TestLinkedFileSet( """ public class Class1 { @@ -93,12 +92,10 @@ void N() } """, LanguageNames.CSharp); - } [Fact] public void TestRename() - { - TestLinkedFileSet( + => TestLinkedFileSet( """ public class Class1 { @@ -178,5 +175,4 @@ void N() } """, LanguageNames.CSharp); - } } diff --git a/src/Workspaces/CoreTest/LinkedFileDiffMerging/LinkedFileDiffMergingTests.TextMerging.cs b/src/Workspaces/CoreTest/LinkedFileDiffMerging/LinkedFileDiffMergingTests.TextMerging.cs index 9b8fb80600ad..346979762d77 100644 --- a/src/Workspaces/CoreTest/LinkedFileDiffMerging/LinkedFileDiffMergingTests.TextMerging.cs +++ b/src/Workspaces/CoreTest/LinkedFileDiffMerging/LinkedFileDiffMergingTests.TextMerging.cs @@ -13,48 +13,39 @@ public partial class LinkedFileDiffMergingTests { [Fact] public void TestIdenticalChanges() - { - TestLinkedFileSet( + => TestLinkedFileSet( "x", ["y", "y"], @"y", LanguageNames.CSharp); - } [Fact] public void TestChangesInOnlyOneFile() - { - TestLinkedFileSet( + => TestLinkedFileSet( "a b c d e", ["a b c d e", "a z c z e"], @"a z c z e", LanguageNames.CSharp); - } [Fact] public void TestIsolatedChangesInBothFiles() - { - TestLinkedFileSet( + => TestLinkedFileSet( "a b c d e", ["a z c d e", "a b c z e"], @"a z c z e", LanguageNames.CSharp); - } [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/44423")] public void TestIdenticalEditAfterIsolatedChanges() - { - TestLinkedFileSet( + => TestLinkedFileSet( "a; b; c; d; e;", ["a; zzz; c; xx; e;", "a; b; c; xx; e;"], @"a; zzz; c; xx; e;", LanguageNames.CSharp); - } [Fact] public void TestOneConflict() - { - TestLinkedFileSet( + => TestLinkedFileSet( "a b c d e", ["a b y d e", "a b z d e"], $""" @@ -67,12 +58,10 @@ a b z d e a b y d e """, LanguageNames.CSharp); - } [Fact] public void TestTwoConflictsOnSameLine() - { - TestLinkedFileSet( + => TestLinkedFileSet( "a b c d e", ["a q1 c z1 e", "a q2 c z2 e"], $""" @@ -85,12 +74,10 @@ a q2 c z2 e a q1 c z1 e """, LanguageNames.CSharp); - } [Fact] public void TestTwoConflictsOnAdjacentLines() - { - TestLinkedFileSet( + => TestLinkedFileSet( """ One Two @@ -126,12 +113,10 @@ public void TestTwoConflictsOnAdjacentLines() Four """, LanguageNames.CSharp); - } [Fact, WorkItem("https://github.com/dotnet/roslyn/issues/44423")] public void TestTwoConflictsOnSeparatedLines() - { - TestLinkedFileSet( + => TestLinkedFileSet( """ One; Two; @@ -175,12 +160,10 @@ public void TestTwoConflictsOnSeparatedLines() Five; """, LanguageNames.CSharp); - } [Fact] public void TestManyLinkedFilesWithOverlappingChange() - { - TestLinkedFileSet( + => TestLinkedFileSet( @"A", [ @"A", @@ -203,14 +186,12 @@ public void TestManyLinkedFilesWithOverlappingChange() B """, LanguageNames.CSharp); - } [Theory] [InlineData(LanguageNames.CSharp)] [InlineData(LanguageNames.VisualBasic)] public void TestCommentsAddedCode(string language) - { - TestLinkedFileSet( + => TestLinkedFileSet( @"", [ @"A", @@ -225,14 +206,12 @@ public void TestCommentsAddedCode(string language) A """, language); - } [Theory] [InlineData(LanguageNames.CSharp)] [InlineData(LanguageNames.VisualBasic)] public void TestCommentsRemovedCode(string language) - { - TestLinkedFileSet( + => TestLinkedFileSet( @"A", [ @"B", @@ -247,5 +226,4 @@ public void TestCommentsRemovedCode(string language) B """, language); - } } diff --git a/src/Workspaces/CoreTest/ObjectSerializationTests.cs b/src/Workspaces/CoreTest/ObjectSerializationTests.cs index a27a1371f5b8..b4a4da322c1a 100644 --- a/src/Workspaces/CoreTest/ObjectSerializationTests.cs +++ b/src/Workspaces/CoreTest/ObjectSerializationTests.cs @@ -188,9 +188,7 @@ public bool Equals(TypeWithOneMember other) [Fact] public void TestValueInt32() - { - TestRoundTripValue(123); - } + => TestRoundTripValue(123); [Fact] public void TestInt32TypeCodes() @@ -402,9 +400,7 @@ public void TestUInt64Values() [Fact] public void TestPrimitiveAPIs() - { - TestRoundTrip(w => TestWritingPrimitiveAPIs(w), r => TestReadingPrimitiveAPIs(r)); - } + => TestRoundTrip(w => TestWritingPrimitiveAPIs(w), r => TestReadingPrimitiveAPIs(r)); private static void TestWritingPrimitiveAPIs(ObjectWriter writer) { @@ -456,9 +452,7 @@ private static void TestReadingPrimitiveAPIs(ObjectReader reader) [Fact] public void TestPrimitivesValue() - { - TestRoundTrip(w => TestWritingPrimitiveValues(w), r => TestReadingPrimitiveValues(r)); - } + => TestRoundTrip(w => TestWritingPrimitiveValues(w), r => TestReadingPrimitiveValues(r)); private static void TestWritingPrimitiveValues(ObjectWriter writer) { diff --git a/src/Workspaces/CoreTest/Options/CodeStyleOptionTests.cs b/src/Workspaces/CoreTest/Options/CodeStyleOptionTests.cs index 713c65d075da..4dc745f8bf71 100644 --- a/src/Workspaces/CoreTest/Options/CodeStyleOptionTests.cs +++ b/src/Workspaces/CoreTest/Options/CodeStyleOptionTests.cs @@ -42,35 +42,27 @@ public void WithValue_Same_String() [Fact] public void WithValue_Equal_Bool() - { - Assert.Equal( + => Assert.Equal( new CodeStyleOption2(true, NotificationOption2.Error).WithValue(false), new CodeStyleOption2(false, NotificationOption2.Error)); - } [Fact] public void WithValue_Equal_Int() - { - Assert.Equal( + => Assert.Equal( new CodeStyleOption2(1, NotificationOption2.Error).WithValue(2), new CodeStyleOption2(2, NotificationOption2.Error)); - } [Fact] public void WithValue_Equal_Enum() - { - Assert.Equal( + => Assert.Equal( new CodeStyleOption2(ExpressionBodyPreference.Never, NotificationOption2.Error).WithValue(ExpressionBodyPreference.WhenPossible), new CodeStyleOption2(ExpressionBodyPreference.WhenPossible, NotificationOption2.Error)); - } [Fact] public void WithValue_Equal_String() - { - Assert.Equal( + => Assert.Equal( new CodeStyleOption2("abc", NotificationOption2.Error).WithValue("xyz"), new CodeStyleOption2("xyz", NotificationOption2.Error)); - } /// /// Verify that bool value can migrate to enum value. diff --git a/src/Workspaces/CoreTest/Options/NamingStylePreferencesTests.cs b/src/Workspaces/CoreTest/Options/NamingStylePreferencesTests.cs index 14ab48ea4418..725d6b18d772 100644 --- a/src/Workspaces/CoreTest/Options/NamingStylePreferencesTests.cs +++ b/src/Workspaces/CoreTest/Options/NamingStylePreferencesTests.cs @@ -25,24 +25,19 @@ private static void AssertTrimmedEqual(string expected, string actual) [Fact] public void Equality() - { - Assert.True( + => Assert.True( NamingStylePreferences.FromXElement(XElement.Parse(NamingStylePreferences.DefaultNamingPreferencesString)).Equals( NamingStylePreferences.FromXElement(XElement.Parse(NamingStylePreferences.DefaultNamingPreferencesString)))); - } [Fact] public void TestPreserveDefaultPreferences() - { - AssertTrimmedEqual( + => AssertTrimmedEqual( NamingStylePreferences.DefaultNamingPreferencesString, ReserializePreferences(NamingStylePreferences.DefaultNamingPreferencesString)); - } [Fact] public void TestCannotUpgrade3To5() - { - AssertTrimmedEqual( + => AssertTrimmedEqual( NamingStylePreferences.DefaultNamingPreferencesString, ReserializePreferences(""" @@ -72,7 +67,6 @@ public void TestCannotUpgrade3To5() """)); - } [Fact] public void TestUpgrade4To5() @@ -156,8 +150,7 @@ public void TestPreserveLatestVersion5() [Fact] public void TestCannotDowngradeHigherThanLatestVersion5() - { - AssertTrimmedEqual( + => AssertTrimmedEqual( NamingStylePreferences.DefaultNamingPreferencesString, ReserializePreferences(""" @@ -187,7 +180,6 @@ public void TestCannotDowngradeHigherThanLatestVersion5() """)); - } /// /// Having duplicates in enums like this means that calling Enum.ToString() will potentially be unstable. diff --git a/src/Workspaces/CoreTest/Shared/Extensions/TextSpanExtensions/SubtractTests.cs b/src/Workspaces/CoreTest/Shared/Extensions/TextSpanExtensions/SubtractTests.cs index b405db4c9059..b72e21821877 100644 --- a/src/Workspaces/CoreTest/Shared/Extensions/TextSpanExtensions/SubtractTests.cs +++ b/src/Workspaces/CoreTest/Shared/Extensions/TextSpanExtensions/SubtractTests.cs @@ -36,288 +36,214 @@ public sealed class SubtractTests : TestBase [Fact] public void StartingBeforeStartAndEndingBeforeStart() - { - Assert.Equal( + => Assert.Equal( [LongSpan], LongSpan.Subtract(TextSpan.FromBounds(RightBeforeStart(LongSpan), RightBeforeStart(LongSpan)))); - } [Fact] public void StartingBeforeStartAndEndingAtStart() - { - Assert.Equal( + => Assert.Equal( [LongSpan], LongSpan.Subtract(TextSpan.FromBounds(RightBeforeStart(LongSpan), AtStart(LongSpan)))); - } [Fact] public void StartingBeforeStartAndEndingAfterStart() - { - Assert.Equal( + => Assert.Equal( [TextSpan.FromBounds(RightAfterStart(LongSpan), AtEnd(LongSpan))], LongSpan.Subtract(TextSpan.FromBounds(RightBeforeStart(LongSpan), RightAfterStart(LongSpan)))); - } [Fact] public void StartingBeforeStartAndEndingBeforeEnd() - { - Assert.Equal( + => Assert.Equal( [TextSpan.FromBounds(RightBeforeEnd(LongSpan), AtEnd(LongSpan))], LongSpan.Subtract(TextSpan.FromBounds(RightBeforeStart(LongSpan), RightBeforeEnd(LongSpan)))); - } [Fact] public void StartingBeforeStartAndEndingAtEnd() - { - Assert.Empty( + => Assert.Empty( LongSpan.Subtract(TextSpan.FromBounds(RightBeforeStart(LongSpan), AtEnd(LongSpan)))); - } [Fact] public void StartingBeforeStartAndEndingAfterEnd() - { - Assert.Empty( + => Assert.Empty( LongSpan.Subtract(TextSpan.FromBounds(RightBeforeStart(LongSpan), RightAfterEnd(LongSpan)))); - } [Fact] public void StartingAtStartAndEndingAtStart() - { - Assert.Equal( + => Assert.Equal( [LongSpan], LongSpan.Subtract(TextSpan.FromBounds(AtStart(LongSpan), AtStart(LongSpan)))); - } [Fact] public void StartingAtStartAndEndingAfterStart() - { - Assert.Equal( + => Assert.Equal( [TextSpan.FromBounds(RightAfterStart(LongSpan), AtEnd(LongSpan))], LongSpan.Subtract(TextSpan.FromBounds(AtStart(LongSpan), RightAfterStart(LongSpan)))); - } [Fact] public void StartingAtStartAndEndingBeforeEnd() - { - Assert.Equal( + => Assert.Equal( [TextSpan.FromBounds(RightBeforeEnd(LongSpan), AtEnd(LongSpan))], LongSpan.Subtract(TextSpan.FromBounds(AtStart(LongSpan), RightBeforeEnd(LongSpan)))); - } [Fact] public void StartingAtStartAndEndingAtEnd() - { - Assert.Empty( + => Assert.Empty( LongSpan.Subtract(TextSpan.FromBounds(AtStart(LongSpan), AtEnd(LongSpan)))); - } [Fact] public void StartingAtStartAndEndingAfterEnd() - { - Assert.Empty( + => Assert.Empty( LongSpan.Subtract(TextSpan.FromBounds(AtStart(LongSpan), RightAfterEnd(LongSpan)))); - } [Fact] public void StartingAfterStartAndEndingAfterStart() - { - Assert.Equal( + => Assert.Equal( [LongSpan], LongSpan.Subtract(TextSpan.FromBounds(RightAfterStart(LongSpan), RightAfterStart(LongSpan)))); - } [Fact] public void StartingAfterStartAndEndingBeforeEnd() - { - Assert.Equal( + => Assert.Equal( [ TextSpan.FromBounds(AtStart(LongSpan), RightAfterStart(LongSpan)), TextSpan.FromBounds(RightBeforeEnd(LongSpan), AtEnd(LongSpan)) ], LongSpan.Subtract(TextSpan.FromBounds(RightAfterStart(LongSpan), RightBeforeEnd(LongSpan)))); - } [Fact] public void StartingAfterStartAndEndingAtEnd() - { - Assert.Equal( + => Assert.Equal( [TextSpan.FromBounds(AtStart(LongSpan), RightAfterStart(LongSpan))], LongSpan.Subtract(TextSpan.FromBounds(RightAfterStart(LongSpan), AtEnd(LongSpan)))); - } [Fact] public void StartingAfterStartAndEndingAfterEnd() - { - Assert.Equal( + => Assert.Equal( [TextSpan.FromBounds(AtStart(LongSpan), RightAfterStart(LongSpan))], LongSpan.Subtract(TextSpan.FromBounds(RightAfterStart(LongSpan), RightAfterEnd(LongSpan)))); - } [Fact] public void StartingBeforeEndAndEndingBeforeEnd() - { - Assert.Equal( + => Assert.Equal( [LongSpan], LongSpan.Subtract(TextSpan.FromBounds(RightBeforeEnd(LongSpan), RightBeforeEnd(LongSpan)))); - } [Fact] public void StartingBeforeEndAndEndingAtEnd() - { - Assert.Equal( + => Assert.Equal( [TextSpan.FromBounds(AtStart(LongSpan), RightBeforeEnd(LongSpan))], LongSpan.Subtract(TextSpan.FromBounds(RightBeforeEnd(LongSpan), AtEnd(LongSpan)))); - } [Fact] public void StartingBeforeEndAndEndingAfterEnd() - { - Assert.Equal( + => Assert.Equal( [TextSpan.FromBounds(AtStart(LongSpan), RightBeforeEnd(LongSpan))], LongSpan.Subtract(TextSpan.FromBounds(RightBeforeEnd(LongSpan), RightAfterEnd(LongSpan)))); - } [Fact] public void StartingAtEndAndEndingAtEnd() - { - Assert.Equal( + => Assert.Equal( [LongSpan], LongSpan.Subtract(TextSpan.FromBounds(AtEnd(LongSpan), AtEnd(LongSpan)))); - } [Fact] public void StartingAtEndAndEndingAfterEnd() - { - Assert.Equal( + => Assert.Equal( [LongSpan], LongSpan.Subtract(TextSpan.FromBounds(AtEnd(LongSpan), RightAfterEnd(LongSpan)))); - } [Fact] public void StartingAfterEndAndEndingAfterEnd() - { - Assert.Equal( + => Assert.Equal( [LongSpan], LongSpan.Subtract(TextSpan.FromBounds(RightAfterEnd(LongSpan), RightAfterEnd(LongSpan)))); - } [Fact] public void UnitSpanStartingBeforeStartAndEndingBeforeStart() - { - Assert.Equal( + => Assert.Equal( [UnitSpan], UnitSpan.Subtract(TextSpan.FromBounds(RightBeforeStart(UnitSpan), RightBeforeStart(UnitSpan)))); - } [Fact] public void UnitSpanStartingBeforeStartAndEndingAtStart() - { - Assert.Equal( + => Assert.Equal( [UnitSpan], UnitSpan.Subtract(TextSpan.FromBounds(RightBeforeStart(UnitSpan), AtStart(UnitSpan)))); - } [Fact] public void UnitSpanStartingBeforeStartAndEndingAtEnd() - { - Assert.Empty( + => Assert.Empty( UnitSpan.Subtract(TextSpan.FromBounds(RightBeforeStart(UnitSpan), AtEnd(UnitSpan)))); - } [Fact] public void UnitSpanStartingBeforeStartAndEndingAfterEnd() - { - Assert.Empty( + => Assert.Empty( UnitSpan.Subtract(TextSpan.FromBounds(RightBeforeStart(UnitSpan), RightAfterEnd(UnitSpan)))); - } [Fact] public void UnitSpanStartingAtStartAndEndingAtStart() - { - Assert.Equal( + => Assert.Equal( [UnitSpan], UnitSpan.Subtract(TextSpan.FromBounds(AtStart(UnitSpan), AtStart(UnitSpan)))); - } [Fact] public void UnitSpanStartingAtStartAndEndingAtEnd() - { - Assert.Empty( + => Assert.Empty( UnitSpan.Subtract(TextSpan.FromBounds(AtStart(UnitSpan), AtEnd(UnitSpan)))); - } [Fact] public void UnitSpanStartingAtStartAndEndingAfterEnd() - { - Assert.Empty( + => Assert.Empty( UnitSpan.Subtract(TextSpan.FromBounds(AtStart(UnitSpan), RightAfterEnd(UnitSpan)))); - } [Fact] public void UnitSpanStartingAtEndAndEndingAtEnd() - { - Assert.Equal( + => Assert.Equal( [UnitSpan], UnitSpan.Subtract(TextSpan.FromBounds(AtEnd(UnitSpan), AtEnd(UnitSpan)))); - } [Fact] public void UnitSpanStartingAtEndAndEndingAfterEnd() - { - Assert.Equal( + => Assert.Equal( [UnitSpan], UnitSpan.Subtract(TextSpan.FromBounds(AtEnd(UnitSpan), RightAfterEnd(UnitSpan)))); - } [Fact] public void UnitSpanStartingAfterEndAndEndingAfterEnd() - { - Assert.Equal( + => Assert.Equal( [UnitSpan], UnitSpan.Subtract(TextSpan.FromBounds(RightAfterEnd(UnitSpan), RightAfterEnd(UnitSpan)))); - } [Fact] public void EmptySpanStartingBeforeStartAndEndingBeforeStart() - { - Assert.Equal( + => Assert.Equal( [EmptySpan], EmptySpan.Subtract(TextSpan.FromBounds(RightBeforeStart(EmptySpan), RightBeforeStart(EmptySpan)))); - } [Fact] public void EmptySpanStartingBeforeStartAndEndingAtSpan() - { - Assert.Empty( + => Assert.Empty( EmptySpan.Subtract(TextSpan.FromBounds(RightBeforeStart(EmptySpan), EmptySpan.Start))); - } [Fact] public void EmptySpanStartingBeforeStartAndEndingAfterEnd() - { - Assert.Empty( + => Assert.Empty( EmptySpan.Subtract(TextSpan.FromBounds(RightBeforeStart(EmptySpan), RightAfterEnd(EmptySpan)))); - } [Fact] public void EmptySpanStartingAtSpanAndEndingAtSpan() - { - Assert.Empty( + => Assert.Empty( EmptySpan.Subtract(TextSpan.FromBounds(EmptySpan.Start, EmptySpan.Start))); - } [Fact] public void EmptySpanStartingAtSpanAndEndingAfterEnd() - { - Assert.Empty( + => Assert.Empty( EmptySpan.Subtract(TextSpan.FromBounds(EmptySpan.Start, RightAfterEnd(EmptySpan)))); - } [Fact] public void EmptySpanStartingAfterEndAndEndingAfterEnd() - { - Assert.Equal( + => Assert.Equal( [EmptySpan], EmptySpan.Subtract(TextSpan.FromBounds(RightAfterEnd(EmptySpan), RightAfterEnd(EmptySpan)))); - } } diff --git a/src/Workspaces/CoreTest/SolutionTests/SolutionWithSourceGeneratorTests.cs b/src/Workspaces/CoreTest/SolutionTests/SolutionWithSourceGeneratorTests.cs index bb335682a357..04e6245305c7 100644 --- a/src/Workspaces/CoreTest/SolutionTests/SolutionWithSourceGeneratorTests.cs +++ b/src/Workspaces/CoreTest/SolutionTests/SolutionWithSourceGeneratorTests.cs @@ -1413,11 +1413,6 @@ private sealed class TestWorkspaceConfigurationService() : IWorkspaceConfigurati internal async Task UpdatingAnalyzerReferenceReloadsGenerators( SourceGeneratorExecutionPreference executionPreference) { - // We have two versions of the same source generator attached to this project as a resource. Each creates a - // 'HelloWorld' class, just with a different string it emits inside. - const string AnalyzerResourceV1 = @"Microsoft.CodeAnalysis.UnitTests.Resources.Microsoft.CodeAnalysis.TestAnalyzerReference.dll.v1"; - const string AnalyzerResourceV2 = @"Microsoft.CodeAnalysis.UnitTests.Resources.Microsoft.CodeAnalysis.TestAnalyzerReference.dll.v2"; - using var workspace = CreateWorkspace([typeof(TestWorkspaceConfigurationService)], TestHost.OutOfProcess); var mefServices = (VisualStudioMefHostServices)workspace.Services.HostServices; @@ -1446,7 +1441,7 @@ internal async Task UpdatingAnalyzerReferenceReloadsGenerators( // Add and test the v1 generator first. { - using (var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(AnalyzerResourceV1)) + using (var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(@"Microsoft.CodeAnalysis.UnitTests.Resources.Microsoft.CodeAnalysis.TestAnalyzerReference.dll.v1")) using (var destination = File.OpenWrite(analyzerPath)) { stream!.CopyTo(destination); @@ -1464,7 +1459,7 @@ internal async Task UpdatingAnalyzerReferenceReloadsGenerators( // Now, overwrite the analyzer reference with a new version that generates different contents { - using (var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(AnalyzerResourceV2)) + using (var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(@"Microsoft.CodeAnalysis.UnitTests.Resources.Microsoft.CodeAnalysis.TestAnalyzerReference.dll.v2")) using (var destination = File.OpenWrite(analyzerPath)) { stream!.CopyTo(destination); diff --git a/src/Workspaces/CoreTest/UtilityTest/NameGeneratorTests.cs b/src/Workspaces/CoreTest/UtilityTest/NameGeneratorTests.cs index 94a4ecd2e320..0b45286e1607 100644 --- a/src/Workspaces/CoreTest/UtilityTest/NameGeneratorTests.cs +++ b/src/Workspaces/CoreTest/UtilityTest/NameGeneratorTests.cs @@ -58,16 +58,12 @@ public void EnsureUniquenessCaseInsensitive(string baseName, string[] reservedNa [Theory] [InlineData(new[] { "test", "Test", "test", "Test" }, new[] { "test1", "Test1", "test2", "Test2" })] public void EnsureUniquenessInPlaceCaseSensitive(string[] names, string[] expectedResult) - { - VerifyEnsureUniquenessInPlace(names, isFixed: null, canUse: null, isCaseSensitive: true, expectedResult); - } + => VerifyEnsureUniquenessInPlace(names, isFixed: null, canUse: null, isCaseSensitive: true, expectedResult); [Theory] [InlineData(new[] { "test", "Test", "test", "Test" }, new[] { "test1", "Test2", "test3", "Test4" })] public void EnsureUniquenessInPlaceNotCaseSensitive(string[] names, string[] expectedResult) - { - VerifyEnsureUniquenessInPlace(names, isFixed: null, canUse: null, isCaseSensitive: false, expectedResult); - } + => VerifyEnsureUniquenessInPlace(names, isFixed: null, canUse: null, isCaseSensitive: false, expectedResult); [Theory] [InlineData(new[] { "test", "test", "test" }, new[] { "test", "test", "test" })] @@ -81,9 +77,7 @@ public void EnsureUniquenessInPlaceAllFixed(string[] names, string[] expectedRes [Theory] [InlineData(new[] { "test", "test", "test" }, new[] { "test1", "test2", "test3" })] public void EnsureUniquenessInPlaceNoneFixed(string[] names, string[] expectedResult) - { - VerifyEnsureUniquenessInPlace(names, isFixed: null, canUse: null, isCaseSensitive: true, expectedResult); - } + => VerifyEnsureUniquenessInPlace(names, isFixed: null, canUse: null, isCaseSensitive: true, expectedResult); [Theory] [InlineData(new[] { "test", "test", "test" }, new[] { "test10", "test11", "test12" })] diff --git a/src/Workspaces/CoreTest/WorkspaceTests/DynamicFileInfoProviderMefTests.cs b/src/Workspaces/CoreTest/WorkspaceTests/DynamicFileInfoProviderMefTests.cs index 3639b3952e49..c74f6e40a1b3 100644 --- a/src/Workspaces/CoreTest/WorkspaceTests/DynamicFileInfoProviderMefTests.cs +++ b/src/Workspaces/CoreTest/WorkspaceTests/DynamicFileInfoProviderMefTests.cs @@ -26,21 +26,17 @@ public void TestFileExtensionsMetadata() [Fact] public void TestInvalidArgument1() - { - Assert.Throws(() => + => Assert.Throws(() => { new ExportDynamicFileInfoProviderAttribute(); }); - } [Fact] public void TestInvalidArgument2() - { - Assert.Throws(() => + => Assert.Throws(() => { new FileExtensionsMetadata(); }); - } internal static Lazy GetDynamicFileInfoProvider() { diff --git a/src/Workspaces/CoreTestUtilities/Fakes/SimpleAssetSource.cs b/src/Workspaces/CoreTestUtilities/Fakes/SimpleAssetSource.cs index ff1d2d43ef6f..271ab19c4181 100644 --- a/src/Workspaces/CoreTestUtilities/Fakes/SimpleAssetSource.cs +++ b/src/Workspaces/CoreTestUtilities/Fakes/SimpleAssetSource.cs @@ -38,6 +38,6 @@ public ValueTask GetAssetsAsync( callback(checksum, (T)asset, arg); } - return ValueTaskFactory.CompletedTask; + return ValueTask.CompletedTask; } } diff --git a/src/Workspaces/CoreTestUtilities/Remote/InProcRemostHostClient.cs b/src/Workspaces/CoreTestUtilities/Remote/InProcRemostHostClient.cs index 696b7d16f7b4..3135a3e85071 100644 --- a/src/Workspaces/CoreTestUtilities/Remote/InProcRemostHostClient.cs +++ b/src/Workspaces/CoreTestUtilities/Remote/InProcRemostHostClient.cs @@ -145,7 +145,7 @@ public event EventHandler? AvailabilityChanged clientConnection.StartListening(); - return ValueTaskFactory.FromResult((T?)clientConnection.ConstructRpcClient()); + return ValueTask.FromResult((T?)clientConnection.ConstructRpcClient()); } } diff --git a/src/Workspaces/CoreTestUtilities/Workspaces/TestWorkspace`1.cs b/src/Workspaces/CoreTestUtilities/Workspaces/TestWorkspace`1.cs index b3090fef39cf..765e78aadfee 100644 --- a/src/Workspaces/CoreTestUtilities/Workspaces/TestWorkspace`1.cs +++ b/src/Workspaces/CoreTestUtilities/Workspaces/TestWorkspace`1.cs @@ -471,7 +471,7 @@ internal override ValueTask TryOnDocumentClosedAsync(DocumentId documentId, Canc Contract.ThrowIfTrue(testDocument.IsSourceGenerated); this.OnDocumentClosedEx(documentId, testDocument.Loader, requireDocumentPresentAndOpen: false); - return ValueTaskFactory.CompletedTask; + return ValueTask.CompletedTask; } public override void CloseDocument(DocumentId documentId) diff --git a/src/Workspaces/Remote/Core/EditAndContinue/ManagedHotReloadLanguageService.cs b/src/Workspaces/Remote/Core/EditAndContinue/ManagedHotReloadLanguageService.cs index 776b784cecab..70df9645d436 100644 --- a/src/Workspaces/Remote/Core/EditAndContinue/ManagedHotReloadLanguageService.cs +++ b/src/Workspaces/Remote/Core/EditAndContinue/ManagedHotReloadLanguageService.cs @@ -36,11 +36,11 @@ private sealed class PdbMatchingSourceTextProvider : IPdbMatchingSourceTextProvi // Returning null will check the file on disk: public ValueTask TryGetMatchingSourceTextAsync(string filePath, ImmutableArray requiredChecksum, SourceHashAlgorithm checksumAlgorithm, CancellationToken cancellationToken) - => ValueTaskFactory.FromResult(null); + => ValueTask.FromResult(null); } private static readonly ActiveStatementSpanProvider s_emptyActiveStatementProvider = - (_, _, _) => ValueTaskFactory.FromResult(ImmutableArray.Empty); + (_, _, _) => ValueTask.FromResult(ImmutableArray.Empty); private readonly ManagedHotReloadServiceProxy _debuggerService = new(serviceBrokerProvider.ServiceBroker); private readonly SolutionSnapshotProviderProxy _solutionSnapshotProvider = new(serviceBrokerProvider.ServiceBroker); @@ -106,7 +106,7 @@ private ValueTask BreakStateOrCapabilitiesChangedAsync(bool? inBreakState, Cance { if (_disabled) { - return ValueTaskFactory.CompletedTask; + return ValueTask.CompletedTask; } try @@ -119,7 +119,7 @@ private ValueTask BreakStateOrCapabilitiesChangedAsync(bool? inBreakState, Cance Disable(); } - return ValueTaskFactory.CompletedTask; + return ValueTask.CompletedTask; } public ValueTask EnterBreakStateAsync(CancellationToken cancellationToken) @@ -135,7 +135,7 @@ public ValueTask CommitUpdatesAsync(CancellationToken cancellationToken) { if (_disabled) { - return ValueTaskFactory.CompletedTask; + return ValueTask.CompletedTask; } try @@ -153,7 +153,7 @@ public ValueTask CommitUpdatesAsync(CancellationToken cancellationToken) Disable(); } - return ValueTaskFactory.CompletedTask; + return ValueTask.CompletedTask; } public async ValueTask UpdateBaselinesAsync(ImmutableArray projectPaths, CancellationToken cancellationToken) @@ -189,7 +189,7 @@ public ValueTask DiscardUpdatesAsync(CancellationToken cancellationToken) { if (_disabled) { - return ValueTaskFactory.CompletedTask; + return ValueTask.CompletedTask; } try @@ -204,14 +204,14 @@ public ValueTask DiscardUpdatesAsync(CancellationToken cancellationToken) Disable(); } - return ValueTaskFactory.CompletedTask; + return ValueTask.CompletedTask; } public ValueTask EndSessionAsync(CancellationToken cancellationToken) { if (_disabled) { - return ValueTaskFactory.CompletedTask; + return ValueTask.CompletedTask; } try @@ -229,7 +229,7 @@ public ValueTask EndSessionAsync(CancellationToken cancellationToken) Disable(); } - return ValueTaskFactory.CompletedTask; + return ValueTask.CompletedTask; } /// diff --git a/src/Workspaces/Remote/Core/RemoteHostAssetWriter.cs b/src/Workspaces/Remote/Core/RemoteHostAssetWriter.cs index f1548eb3fbcb..f3c2787b4a18 100644 --- a/src/Workspaces/Remote/Core/RemoteHostAssetWriter.cs +++ b/src/Workspaces/Remote/Core/RemoteHostAssetWriter.cs @@ -10,7 +10,7 @@ using System.Threading.Tasks; using Microsoft.CodeAnalysis.PooledObjects; using Microsoft.CodeAnalysis.Serialization; -using Microsoft.CodeAnalysis.Shared.Utilities; +using Microsoft.CodeAnalysis.Threading; using Roslyn.Utilities; namespace Microsoft.CodeAnalysis.Remote; diff --git a/src/Workspaces/Remote/ServiceHub/Host/RemoteWorkspace.cs b/src/Workspaces/Remote/ServiceHub/Host/RemoteWorkspace.cs index 7ee0da3b27c2..f6603fc983db 100644 --- a/src/Workspaces/Remote/ServiceHub/Host/RemoteWorkspace.cs +++ b/src/Workspaces/Remote/ServiceHub/Host/RemoteWorkspace.cs @@ -58,7 +58,7 @@ await RunWithSolutionAsync( assetProvider, solutionChecksum, updatePrimaryBranch: true, - implementation: static _ => ValueTaskFactory.FromResult(false), + implementation: static _ => ValueTask.FromResult(false), cancellationToken).ConfigureAwait(false); } @@ -340,7 +340,7 @@ public async ValueTask GetSolutionAsync( CancellationToken cancellationToken) { var (solution, _) = await _remoteWorkspace.RunWithSolutionAsync( - assetProvider, solutionChecksum, updatePrimaryBranch, _ => ValueTaskFactory.FromResult(false), cancellationToken).ConfigureAwait(false); + assetProvider, solutionChecksum, updatePrimaryBranch, _ => ValueTask.FromResult(false), cancellationToken).ConfigureAwait(false); return solution; } } diff --git a/src/Workspaces/Remote/ServiceHub/Host/RemoteWorkspaceManager.cs b/src/Workspaces/Remote/ServiceHub/Host/RemoteWorkspaceManager.cs index 29b8ed058f4c..6a0d9a2c6724 100644 --- a/src/Workspaces/Remote/ServiceHub/Host/RemoteWorkspaceManager.cs +++ b/src/Workspaces/Remote/ServiceHub/Host/RemoteWorkspaceManager.cs @@ -94,7 +94,7 @@ public async ValueTask GetSolutionAsync(ServiceBrokerClient client, Ch var (solution, _) = await workspace.RunWithSolutionAsync( assetProvider, solutionChecksum, - static _ => ValueTaskFactory.FromResult(false), + static _ => ValueTask.FromResult(false), cancellationToken).ConfigureAwait(false); return solution; diff --git a/src/Workspaces/Remote/ServiceHub/Services/AssetSynchronization/RemoteAssetSynchronizationService.cs b/src/Workspaces/Remote/ServiceHub/Services/AssetSynchronization/RemoteAssetSynchronizationService.cs index b352a7a9f921..d96419e82b0d 100644 --- a/src/Workspaces/Remote/ServiceHub/Services/AssetSynchronization/RemoteAssetSynchronizationService.cs +++ b/src/Workspaces/Remote/ServiceHub/Services/AssetSynchronization/RemoteAssetSynchronizationService.cs @@ -50,7 +50,7 @@ public ValueTask SynchronizeActiveDocumentAsync(DocumentId? documentId, Cancella { var documentTrackingService = GetWorkspace().Services.GetRequiredService() as RemoteDocumentTrackingService; documentTrackingService?.SetActiveDocument(documentId); - return ValueTaskFactory.CompletedTask; + return ValueTask.CompletedTask; } public ValueTask SynchronizeTextChangesAsync( diff --git a/src/Workspaces/Remote/ServiceHub/Services/ConvertTupleToStructCodeRefactoringProvider/RemoteConvertTupleToStructCodeRefactoringService.cs b/src/Workspaces/Remote/ServiceHub/Services/ConvertTupleToStructCodeRefactoringProvider/RemoteConvertTupleToStructCodeRefactoringService.cs index a40e6218fc86..2b32dfd634c5 100644 --- a/src/Workspaces/Remote/ServiceHub/Services/ConvertTupleToStructCodeRefactoringProvider/RemoteConvertTupleToStructCodeRefactoringService.cs +++ b/src/Workspaces/Remote/ServiceHub/Services/ConvertTupleToStructCodeRefactoringProvider/RemoteConvertTupleToStructCodeRefactoringService.cs @@ -9,7 +9,7 @@ using Microsoft.CodeAnalysis.ConvertTupleToStruct; using Microsoft.CodeAnalysis.Host; using Microsoft.CodeAnalysis.Shared.Extensions; -using Microsoft.CodeAnalysis.Shared.Utilities; +using Microsoft.CodeAnalysis.Threading; using Microsoft.CodeAnalysis.Text; using Roslyn.Utilities; diff --git a/src/Workspaces/Remote/ServiceHub/Services/EditAndContinue/RemoteEditAndContinueService.cs b/src/Workspaces/Remote/ServiceHub/Services/EditAndContinue/RemoteEditAndContinueService.cs index 06ad70bc0c78..7d5be3e678b6 100644 --- a/src/Workspaces/Remote/ServiceHub/Services/EditAndContinue/RemoteEditAndContinueService.cs +++ b/src/Workspaces/Remote/ServiceHub/Services/EditAndContinue/RemoteEditAndContinueService.cs @@ -100,7 +100,7 @@ public ValueTask BreakStateOrCapabilitiesChangedAsync(DebuggingSessionId session return RunServiceAsync(cancellationToken => { GetService().BreakStateOrCapabilitiesChanged(sessionId, inBreakState); - return ValueTaskFactory.CompletedTask; + return ValueTask.CompletedTask; }, cancellationToken); } @@ -112,7 +112,7 @@ public ValueTask EndDebuggingSessionAsync(DebuggingSessionId sessionId, Cancella return RunServiceAsync(cancellationToken => { GetService().EndDebuggingSession(sessionId); - return ValueTaskFactory.CompletedTask; + return ValueTask.CompletedTask; }, cancellationToken); } @@ -166,7 +166,7 @@ public ValueTask CommitSolutionUpdateAsync(DebuggingSessionId sessionId, Cancell return RunServiceAsync(cancellationToken => { GetService().CommitSolutionUpdate(sessionId); - return ValueTaskFactory.CompletedTask; + return ValueTask.CompletedTask; }, cancellationToken); } diff --git a/src/Workspaces/Remote/ServiceHub/Services/ExtensionMethodImportCompletion/RemoteExtensionMethodImportCompletionService.cs b/src/Workspaces/Remote/ServiceHub/Services/ExtensionMethodImportCompletion/RemoteExtensionMethodImportCompletionService.cs index 03d4ceaa88a7..85da13467363 100644 --- a/src/Workspaces/Remote/ServiceHub/Services/ExtensionMethodImportCompletion/RemoteExtensionMethodImportCompletionService.cs +++ b/src/Workspaces/Remote/ServiceHub/Services/ExtensionMethodImportCompletion/RemoteExtensionMethodImportCompletionService.cs @@ -64,7 +64,7 @@ public ValueTask WarmUpCacheAsync(Checksum solutionChecksum, ProjectId projectId { var project = solution.GetRequiredProject(projectId); ExtensionMethodImportCompletionHelper.WarmUpCacheInCurrentProcess(project); - return ValueTaskFactory.CompletedTask; + return ValueTask.CompletedTask; }, cancellationToken); } } diff --git a/src/Workspaces/Remote/ServiceHub/Services/Initialization/RemoteInitializationService.cs b/src/Workspaces/Remote/ServiceHub/Services/Initialization/RemoteInitializationService.cs index a6ac63781220..3e83bddea125 100644 --- a/src/Workspaces/Remote/ServiceHub/Services/Initialization/RemoteInitializationService.cs +++ b/src/Workspaces/Remote/ServiceHub/Services/Initialization/RemoteInitializationService.cs @@ -31,7 +31,7 @@ protected override IRemoteInitializationService CreateService(in ServiceConstruc var service = (RemoteWorkspaceConfigurationService)GetWorkspaceServices().GetRequiredService(); service.InitializeOptions(options); - return ValueTaskFactory.FromResult(Process.GetCurrentProcess().Id); + return ValueTask.FromResult(Process.GetCurrentProcess().Id); }, cancellationToken).ConfigureAwait(false); return (processId, errorMessage); diff --git a/src/Workspaces/Remote/ServiceHub/Services/MissingImportDiscovery/RemoteMissingImportDiscoveryService.cs b/src/Workspaces/Remote/ServiceHub/Services/MissingImportDiscovery/RemoteMissingImportDiscoveryService.cs index 029001631aa0..8dcb2c7ef89b 100644 --- a/src/Workspaces/Remote/ServiceHub/Services/MissingImportDiscovery/RemoteMissingImportDiscoveryService.cs +++ b/src/Workspaces/Remote/ServiceHub/Services/MissingImportDiscovery/RemoteMissingImportDiscoveryService.cs @@ -39,7 +39,7 @@ public ValueTask> GetFixesAsync( { return RunServiceAsync(solutionChecksum, async solution => { - var document = solution.GetDocument(documentId); + var document = await solution.GetDocumentAsync(documentId, includeSourceGenerated: true, cancellationToken).ConfigureAwait(false); if (document is null) return []; @@ -68,7 +68,7 @@ public ValueTask> GetUniqueFixesAsync( { return RunServiceAsync(solutionChecksum, async solution => { - var document = solution.GetDocument(documentId); + var document = await solution.GetDocumentAsync(documentId, includeSourceGenerated: true, cancellationToken).ConfigureAwait(false); if (document is null) return []; diff --git a/src/Workspaces/Remote/ServiceHub/Services/NavigateToSearch/RemoteNavigateToSearchService.cs b/src/Workspaces/Remote/ServiceHub/Services/NavigateToSearch/RemoteNavigateToSearchService.cs index 5a80474ead4a..69693ec21600 100644 --- a/src/Workspaces/Remote/ServiceHub/Services/NavigateToSearch/RemoteNavigateToSearchService.cs +++ b/src/Workspaces/Remote/ServiceHub/Services/NavigateToSearch/RemoteNavigateToSearchService.cs @@ -42,7 +42,7 @@ public ValueTask HydrateAsync(Checksum solutionChecksum, CancellationToken cance // pulled over from the host side to the remote side. Once this completes, the next // call to SearchFullyLoadedDocumentAsync or SearchFullyLoadedProjectAsync will be // quick as very little will need to by sync'ed over. - return RunServiceAsync(solutionChecksum, solution => ValueTaskFactory.CompletedTask, cancellationToken); + return RunServiceAsync(solutionChecksum, solution => ValueTask.CompletedTask, cancellationToken); } public ValueTask SearchDocumentAndRelatedDocumentsAsync( diff --git a/src/Workspaces/Remote/ServiceHub/Services/ProcessTelemetry/RemoteProcessTelemetryService.PerformanceReporter.cs b/src/Workspaces/Remote/ServiceHub/Services/ProcessTelemetry/RemoteProcessTelemetryService.PerformanceReporter.cs index 3200e4d81149..aa5db4e22ec1 100644 --- a/src/Workspaces/Remote/ServiceHub/Services/ProcessTelemetry/RemoteProcessTelemetryService.PerformanceReporter.cs +++ b/src/Workspaces/Remote/ServiceHub/Services/ProcessTelemetry/RemoteProcessTelemetryService.PerformanceReporter.cs @@ -47,7 +47,7 @@ public PerformanceReporter( private ValueTask ProcessWorkAsync(CancellationToken cancellationToken) { if (!_telemetrySession.IsOptedIn) - return ValueTaskFactory.CompletedTask; + return ValueTask.CompletedTask; using (RoslynLogger.LogBlock(FunctionId.Diagnostics_GeneratePerformaceReport, cancellationToken)) { @@ -72,7 +72,7 @@ private ValueTask ProcessWorkAsync(CancellationToken cancellationToken) } } - return ValueTaskFactory.CompletedTask; + return ValueTask.CompletedTask; } } } diff --git a/src/Workspaces/Remote/ServiceHub/Services/ProcessTelemetry/RemoteProcessTelemetryService.cs b/src/Workspaces/Remote/ServiceHub/Services/ProcessTelemetry/RemoteProcessTelemetryService.cs index 8bc8e89d4c6d..c43060e2e1e2 100644 --- a/src/Workspaces/Remote/ServiceHub/Services/ProcessTelemetry/RemoteProcessTelemetryService.cs +++ b/src/Workspaces/Remote/ServiceHub/Services/ProcessTelemetry/RemoteProcessTelemetryService.cs @@ -67,7 +67,7 @@ public ValueTask InitializeTelemetrySessionAsync(int hostProcessId, string seria _performanceReporter = new PerformanceReporter(telemetrySession, diagnosticAnalyzerPerformanceTracker, _shutdownCancellationSource.Token); } - return ValueTaskFactory.CompletedTask; + return ValueTask.CompletedTask; }, cancellationToken); } @@ -85,7 +85,7 @@ public ValueTask EnableLoggingAsync(ImmutableArray loggerTypeNames, Immu SetRoslynLogger(loggerTypeNames, () => new EtwLogger(logChecker)); SetRoslynLogger(loggerTypeNames, () => new TraceLogger(logChecker)); - return ValueTaskFactory.CompletedTask; + return ValueTask.CompletedTask; }, cancellationToken); } diff --git a/src/Workspaces/Remote/ServiceHub/Services/Renamer/RemoteRenamerService.cs b/src/Workspaces/Remote/ServiceHub/Services/Renamer/RemoteRenamerService.cs index 3d146b0a4ef9..5d899266b8cd 100644 --- a/src/Workspaces/Remote/ServiceHub/Services/Renamer/RemoteRenamerService.cs +++ b/src/Workspaces/Remote/ServiceHub/Services/Renamer/RemoteRenamerService.cs @@ -24,7 +24,6 @@ protected override IRemoteRenamerService CreateService(in ServiceConstructionArg SerializableSymbolAndProjectId symbolAndProjectId, string newName, SymbolRenameOptions options, - ImmutableArray nonConflictSymbolKeys, CancellationToken cancellationToken) { return RunServiceAsync(solutionChecksum, async solution => @@ -36,7 +35,7 @@ protected override IRemoteRenamerService CreateService(in ServiceConstructionArg return null; var result = await Renamer.RenameSymbolAsync( - solution, symbol, newName, options, nonConflictSymbolKeys, cancellationToken).ConfigureAwait(false); + solution, symbol, newName, options, cancellationToken).ConfigureAwait(false); return await result.DehydrateAsync(cancellationToken).ConfigureAwait(false); }, cancellationToken); @@ -72,7 +71,6 @@ protected override IRemoteRenamerService CreateService(in ServiceConstructionArg SerializableSymbolAndProjectId symbolAndProjectId, SerializableRenameLocations serializableLocations, string replacementText, - ImmutableArray nonConflictSymbolKeys, CancellationToken cancellationToken) { return RunServiceAsync(solutionChecksum, async solution => @@ -87,7 +85,7 @@ protected override IRemoteRenamerService CreateService(in ServiceConstructionArg return null; var result = await ConflictResolver.ResolveSymbolicLocationConflictsInCurrentProcessAsync( - locations, replacementText, nonConflictSymbolKeys, cancellationToken).ConfigureAwait(false); + locations, replacementText, cancellationToken).ConfigureAwait(false); return await result.DehydrateAsync(cancellationToken).ConfigureAwait(false); }, cancellationToken); } diff --git a/src/Workspaces/Remote/ServiceHub/Services/SemanticSearch/RemoteSemanticSearchService.cs b/src/Workspaces/Remote/ServiceHub/Services/SemanticSearch/RemoteSemanticSearchService.cs index 4ad6ce988f5a..962fcb09cf49 100644 --- a/src/Workspaces/Remote/ServiceHub/Services/SemanticSearch/RemoteSemanticSearchService.cs +++ b/src/Workspaces/Remote/ServiceHub/Services/SemanticSearch/RemoteSemanticSearchService.cs @@ -5,6 +5,7 @@ using System.Threading; using System.Threading.Tasks; using Microsoft.CodeAnalysis.Classification; +using Microsoft.CodeAnalysis.FindSymbols; using Microsoft.CodeAnalysis.FindUsages; using Microsoft.CodeAnalysis.SemanticSearch; using Roslyn.Utilities; @@ -35,10 +36,12 @@ public ValueTask AddItemsAsync(int itemCount, CancellationToken cancellationToke public ValueTask ItemsCompletedAsync(int itemCount, CancellationToken cancellationToken) => callback.InvokeAsync((callback, cancellationToken) => callback.ItemsCompletedAsync(callbackId, itemCount, cancellationToken), cancellationToken); - public ValueTask OnDefinitionFoundAsync(DefinitionItem definition, CancellationToken cancellationToken) + public async ValueTask OnSymbolFoundAsync(Solution solution, ISymbol symbol, CancellationToken cancellationToken) { + var definition = await SemanticSearchDefinitionItemFactory.CreateAsync(solution, symbol, classificationOptions: this, cancellationToken).ConfigureAwait(false); var dehydratedDefinition = SerializableDefinitionItem.Dehydrate(id: 0, definition); - return callback.InvokeAsync((callback, cancellationToken) => callback.OnDefinitionFoundAsync(callbackId, dehydratedDefinition, cancellationToken), cancellationToken); + + await callback.InvokeAsync((callback, cancellationToken) => callback.OnDefinitionFoundAsync(callbackId, dehydratedDefinition, cancellationToken), cancellationToken).ConfigureAwait(false); } public ValueTask OnUserCodeExceptionAsync(UserCodeExceptionInfo exception, CancellationToken cancellationToken) @@ -60,7 +63,7 @@ public ValueTask CompileQueryAsync( var service = services.GetLanguageServices(language).GetRequiredService(); var result = service.CompileQuery(services, query, referenceAssembliesDir, TraceLogger, cancellationToken); - return ValueTaskFactory.FromResult(result); + return ValueTask.FromResult(result); }, cancellationToken); } @@ -97,7 +100,7 @@ public ValueTask ExecuteQueryAsync( var clientCallbacks = new ClientCallbacks(callback, callbackId); - return await service.ExecuteQueryAsync(solution, queryId, clientCallbacks, clientCallbacks, TraceLogger, cancellationToken).ConfigureAwait(false); + return await service.ExecuteQueryAsync(solution, queryId, observer: clientCallbacks, TraceLogger, cancellationToken).ConfigureAwait(false); }, cancellationToken); } } diff --git a/src/Workspaces/Remote/ServiceHub/Services/SourceGeneration/RemoteSourceGenerationService.cs b/src/Workspaces/Remote/ServiceHub/Services/SourceGeneration/RemoteSourceGenerationService.cs index a5c8a2bf46c5..81bf9c19213e 100644 --- a/src/Workspaces/Remote/ServiceHub/Services/SourceGeneration/RemoteSourceGenerationService.cs +++ b/src/Workspaces/Remote/ServiceHub/Services/SourceGeneration/RemoteSourceGenerationService.cs @@ -146,7 +146,7 @@ public ValueTask> GetSourceGeneratorIden var analyzerReference = project.AnalyzerReferences .First(r => r.FullPath == analyzerReferenceFullPath); - return ValueTaskFactory.FromResult(SourceGeneratorIdentity.GetIdentities(analyzerReference, project.Language)); + return ValueTask.FromResult(SourceGeneratorIdentity.GetIdentities(analyzerReference, project.Language)); }, cancellationToken); } @@ -162,7 +162,7 @@ public ValueTask HasAnalyzersOrSourceGeneratorsAsync( var analyzerReference = project.AnalyzerReferences .First(r => r.FullPath == analyzerReferenceFullPath); - return ValueTaskFactory.FromResult(analyzerReference.HasAnalyzersOrSourceGenerators(project.Language)); + return ValueTask.FromResult(analyzerReference.HasAnalyzersOrSourceGenerators(project.Language)); }, cancellationToken); } } diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/CompilerExtensions.projitems b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/CompilerExtensions.projitems index 6f9309d886cb..a339b11d6313 100644 --- a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/CompilerExtensions.projitems +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/CompilerExtensions.projitems @@ -1,4 +1,4 @@ - + $(MSBuildAllProjects);$(MSBuildThisFileFullPath) @@ -19,10 +19,8 @@ - - @@ -458,7 +456,6 @@ - @@ -496,8 +493,6 @@ - - diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Utilities/IAsyncEnumerableExtensions.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Utilities/IAsyncEnumerableExtensions.cs index 2ea8d5006be9..3df805accec9 100644 --- a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Utilities/IAsyncEnumerableExtensions.cs +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Utilities/IAsyncEnumerableExtensions.cs @@ -4,15 +4,13 @@ using System.Collections.Generic; using System.Collections.Immutable; -using System.Runtime.CompilerServices; using System.Threading; using System.Threading.Channels; using System.Threading.Tasks; -using Microsoft.CodeAnalysis.PooledObjects; namespace Microsoft.CodeAnalysis.Shared.Extensions; -internal static class IAsyncEnumerableExtensions +internal static class AsyncEnumerableFactory { internal static class AsyncEnumerable { @@ -33,15 +31,6 @@ internal static async IAsyncEnumerable SingletonAsync(T value) } #pragma warning restore CS1998 // Async method lacks 'await' operators and will run synchronously - public static async Task> ToImmutableArrayAsync(this IAsyncEnumerable values, CancellationToken cancellationToken) - { - using var _ = ArrayBuilder.GetInstance(out var result); - await foreach (var value in values.WithCancellation(cancellationToken).ConfigureAwait(false)) - result.Add(value); - - return result.ToImmutableAndClear(); - } - /// /// Takes an array of s and produces a single resultant with all their values merged together. Absolutely no ordering guarantee is @@ -78,16 +67,6 @@ static async Task ProcessAsync(IAsyncEnumerable stream, ChannelWriter writ } } - public static async IAsyncEnumerable ReadAllAsync( - this ChannelReader reader, [EnumeratorCancellation] CancellationToken cancellationToken) - { - while (await reader.WaitToReadAsync(cancellationToken).ConfigureAwait(false)) - { - while (reader.TryRead(out var item)) - yield return item; - } - } - /// /// Runs after task completes in any fashion (success, cancellation, faulting) and ensures the channel writer is /// always completed. If the task faults then the exception from that task will be used to complete the channel @@ -100,14 +79,4 @@ public static void CompletesChannel(this Task task, Channel channel) static (task, channel) => ((Channel)channel!).Writer.Complete(task.Exception), channel, CancellationToken.None, TaskContinuationOptions.None, TaskScheduler.Default); } - -#pragma warning disable CS1998 // Async method lacks 'await' operators and will run synchronously -#pragma warning disable VSTHRD200 // Use "Async" suffix for async methods - public static async IAsyncEnumerable AsAsyncEnumerable(this IEnumerable source) -#pragma warning restore VSTHRD200 // Use "Async" suffix for async methods -#pragma warning restore CS1998 // Async method lacks 'await' operators and will run synchronously - { - foreach (var item in source) - yield return item; - } } diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Utilities/PooledBuilderExtensions.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Utilities/PooledBuilderExtensions.cs index 01042b6a8acc..30ff6920299c 100644 --- a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Utilities/PooledBuilderExtensions.cs +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Utilities/PooledBuilderExtensions.cs @@ -2,6 +2,7 @@ // 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.Generic; using System.Collections.Immutable; using System.Linq; @@ -41,12 +42,23 @@ public static Dictionary> ToMultiDictionaryAndFree(th public static ImmutableDictionary> ToImmutableMultiDictionaryAndFree(this PooledDictionary> builders) where K : notnull + => ToImmutableMultiDictionaryAndFree(builders, where: null, whereArg: 0); + + public static ImmutableDictionary> ToImmutableMultiDictionaryAndFree(this PooledDictionary> builders, Func? where, TArg whereArg) + where K : notnull { var result = ImmutableDictionary.CreateBuilder>(); foreach (var (key, items) in builders) { - result.Add(key, items.ToImmutableAndFree()); + if (where == null || where(key, whereArg)) + { + result.Add(key, items.ToImmutableAndFree()); + } + else + { + items.Free(); + } } builders.Free(); diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Utilities/ReferenceCountedDisposable.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Utilities/ReferenceCountedDisposable.cs index 0aec4cb6f8ce..895e26313b27 100644 --- a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Utilities/ReferenceCountedDisposable.cs +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Utilities/ReferenceCountedDisposable.cs @@ -186,13 +186,13 @@ public ValueTask DisposeAsync() { var instanceToDispose = DisposeImpl(); if (instanceToDispose == null) - return ValueTaskFactory.CompletedTask; + return ValueTask.CompletedTask; if (instanceToDispose is IAsyncDisposable asyncDisposable) return asyncDisposable.DisposeAsync(); instanceToDispose.Dispose(); - return ValueTaskFactory.CompletedTask; + return ValueTask.CompletedTask; } private T? DisposeImpl() diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Utilities/RoslynParallel.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Utilities/RoslynParallel.cs deleted file mode 100644 index 5760eec512e1..000000000000 --- a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Utilities/RoslynParallel.cs +++ /dev/null @@ -1,66 +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.Generic; -using System.Threading; -using System.Threading.Tasks; - -namespace Microsoft.CodeAnalysis.Shared.Utilities; - -#pragma warning disable CA1068 // CancellationToken parameters must come last - -internal static partial class RoslynParallel -{ - // For all these helpers, we defer to the native .net core version if we're on .net core. Otherwise, we defer to - // our ported version of that code when on .net framework. - - public static Task ForEachAsync( - IEnumerable source, - CancellationToken cancellationToken, - Func body) - { -#if NET - return Parallel.ForEachAsync(source, cancellationToken, body); -#else - return NetFramework.ForEachAsync(source, cancellationToken, body); -#endif - } - - public static Task ForEachAsync( - IEnumerable source, - ParallelOptions parallelOptions, - Func body) - { -#if NET - return Parallel.ForEachAsync(source, parallelOptions, body); -#else - return NetFramework.ForEachAsync(source, parallelOptions, body); -#endif - } - - public static Task ForEachAsync( - IAsyncEnumerable source, - CancellationToken cancellationToken, - Func body) - { -#if NET - return Parallel.ForEachAsync(source, cancellationToken, body); -#else - return NetFramework.ForEachAsync(source, cancellationToken, body); -#endif - } - - public static Task ForEachAsync( - IAsyncEnumerable source, - ParallelOptions parallelOptions, - Func body) - { -#if NET - return Parallel.ForEachAsync(source, parallelOptions, body); -#else - return NetFramework.ForEachAsync(source, parallelOptions, body); -#endif - } -} diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Utilities/SpecializedTasks.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Utilities/SpecializedTasks.cs index 6c8eaa1f7ace..4d8a12875faf 100644 --- a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Utilities/SpecializedTasks.cs +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Utilities/SpecializedTasks.cs @@ -55,7 +55,7 @@ public static ValueTask WhenAll(IEnumerable> tasks) { var taskArray = tasks.AsArray(); if (taskArray.Length == 0) - return ValueTaskFactory.FromResult(Array.Empty()); + return ValueTask.FromResult(Array.Empty()); var allCompletedSuccessfully = true; for (var i = 0; i < taskArray.Length; i++) @@ -75,7 +75,7 @@ public static ValueTask WhenAll(IEnumerable> tasks) result[i] = taskArray[i].Result; } - return ValueTaskFactory.FromResult(result); + return ValueTask.FromResult(result); } else { diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Extensions/Microsoft.CodeAnalysis.Extensions.projitems b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Extensions/Microsoft.CodeAnalysis.Extensions.projitems index 0411282359f3..bc73e7055556 100644 --- a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Extensions/Microsoft.CodeAnalysis.Extensions.projitems +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Extensions/Microsoft.CodeAnalysis.Extensions.projitems @@ -10,42 +10,7 @@ Microsoft.CodeAnalysis - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Extensions/Symbols/ISymbolExtensions.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Extensions/Symbols/ISymbolExtensions.cs index c6ba0e34aaaf..efa6b676b9ec 100644 --- a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Extensions/Symbols/ISymbolExtensions.cs +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Extensions/Symbols/ISymbolExtensions.cs @@ -11,6 +11,8 @@ using System.Collections.Immutable; using System.Diagnostics.CodeAnalysis; using System.Linq; +using System.Runtime; +using System.Runtime.CompilerServices; using System.Threading; using Microsoft.CodeAnalysis.PooledObjects; using Microsoft.CodeAnalysis.Shared.Utilities; @@ -795,16 +797,41 @@ public static bool IsSymbolWithSpecialDiscardName(this ISymbol symbol) (symbol.Name.Length == 1 || uint.TryParse(symbol.Name[1..], out _) || symbol.Name.All(n => n.Equals('_'))); /// - /// Returns , if the symbol is marked with the . + /// Returns , if the symbol is marked with the and does + /// not have the attribute. /// - /// - /// if the symbol is marked with the . + /// + /// The compiler will emit ObsoleteAttributes on symbols along with CompilerFeatureRequiredAttribute to indicate + /// that the symbol is conditionally obsolete, depending on if the target compiler supports that particular + /// feature or not. This information is then used just to tell the user a specific message, it is not actually + /// intended to indicate the symbol is actually obsolete. As such, we return 'false' here as this check is + /// intended for use by features that use the traditional concept of an actual [Obsolete] attribute added + /// in source by the user themselves. + /// public static bool IsObsolete(this ISymbol symbol) - => symbol.GetAttributes().Any(static x => x.AttributeClass is + { + if (symbol.GetAttributes().Any(static x => x.AttributeClass is + { + MetadataName: nameof(ObsoleteAttribute), + ContainingNamespace.Name: nameof(System), + ContainingNamespace.ContainingNamespace.IsGlobalNamespace: true, + })) { - MetadataName: nameof(ObsoleteAttribute), - ContainingNamespace.Name: nameof(System), - }); + if (!symbol.GetAttributes().Any(static x => x.AttributeClass is + { + MetadataName: nameof(CompilerFeatureRequiredAttribute), + ContainingNamespace.Name: nameof(System.Runtime.CompilerServices), + ContainingNamespace.ContainingNamespace.Name: nameof(System.Runtime), + ContainingNamespace.ContainingNamespace.ContainingNamespace.Name: nameof(System), + ContainingNamespace.ContainingNamespace.ContainingNamespace.ContainingNamespace.IsGlobalNamespace: true, + })) + { + return true; + } + } + + return false; + } public static bool HasAttribute([NotNullWhen(true)] this ISymbol? symbol, [NotNullWhen(true)] INamedTypeSymbol? attributeClass) { diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Extensions/Symbols/ITypeSymbolExtensions.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Extensions/Symbols/ITypeSymbolExtensions.cs index 5bfd70b0f1cd..a94a2942727d 100644 --- a/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Extensions/Symbols/ITypeSymbolExtensions.cs +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Extensions/Symbols/ITypeSymbolExtensions.cs @@ -674,29 +674,32 @@ public static bool IsEnumType([NotNullWhen(true)] this ITypeSymbol? type, [NotNu break; } + // Special case certain structs that we know for certain are immutable, but which may have not been marked that + // way (especially in older frameworks before we had the `readonly struct` feature). + if (IsWellKnownImmutableValueType(type)) + return false; + + // An error type may or may not be a struct, and it may or may not be mutable. As we cannot make a determination, + // we return null to allow the caller to decide what to do. if (type.IsErrorType()) - { return null; - } if (type.TypeKind != TypeKind.Struct) - { return false; - } + + if (type.IsReadOnly) + return false; var hasPrivateField = false; foreach (var member in type.GetMembers()) { if (member is not IFieldSymbol fieldSymbol) - { continue; - } - hasPrivateField |= fieldSymbol.DeclaredAccessibility == Accessibility.Private; if (!fieldSymbol.IsConst && !fieldSymbol.IsReadOnly && !fieldSymbol.IsStatic) - { return true; - } + + hasPrivateField |= fieldSymbol.DeclaredAccessibility == Accessibility.Private; } if (!hasPrivateField) @@ -714,6 +717,38 @@ public static bool IsEnumType([NotNullWhen(true)] this ITypeSymbol? type, [NotNu } return false; + + static bool IsWellKnownImmutableValueType(ITypeSymbol type) + { + // We know that these types are immutable, even if they don't have the IsReadOnly attribute. + if (type is not INamedTypeSymbol + { + ContainingNamespace: + { + Name: nameof(System), + ContainingNamespace.IsGlobalNamespace: true + } + }) + { + return false; + } + + if (type.Name + is nameof(DateTime) + or nameof(ArraySegment<>) + or nameof(DateTimeOffset) + or nameof(Guid) + or nameof(Index) + or nameof(Range) + or nameof(ReadOnlyMemory<>) + or nameof(ReadOnlySpan<>) + or nameof(TimeSpan)) + { + return true; + } + + return false; + } } public static bool IsDisposable([NotNullWhen(returnValue: true)] this ITypeSymbol? type, [NotNullWhen(returnValue: true)] ITypeSymbol? iDisposableType) diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/CodeGeneration/CSharpCodeGenerationService.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/CodeGeneration/CSharpCodeGenerationService.cs index 7334ce1a85a2..f4b099785b53 100644 --- a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/CodeGeneration/CSharpCodeGenerationService.cs +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/CodeGeneration/CSharpCodeGenerationService.cs @@ -537,7 +537,7 @@ private static TDeclarationNode AddStatementsWorker( var token = location.FindToken(cancellationToken); - var block = token.Parent.GetAncestorsOrThis().FirstOrDefault(); + var block = token.Parent.GetAncestorOrThis(); if (block != null) { var blockStatements = block.Statements.ToSet(); diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/CodeGeneration/MethodGenerator.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/CodeGeneration/MethodGenerator.cs index 850b80b3650d..970ec4e972e4 100644 --- a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/CodeGeneration/MethodGenerator.cs +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/CodeGeneration/MethodGenerator.cs @@ -375,9 +375,6 @@ public static SyntaxTokenList GenerateModifiers( if (method.IsVirtual) tokens.Add(VirtualKeyword); - - if (CodeGenerationMethodInfo.GetIsPartial(method) && !method.IsAsync) - tokens.Add(PartialKeyword); } else if (destination is CodeGenerationDestination.CompilationUnit) { @@ -398,7 +395,7 @@ public static SyntaxTokenList GenerateModifiers( tokens.Add(AsyncKeyword); } - if (CodeGenerationMethodInfo.GetIsPartial(method) && method.IsAsync) + if (CodeGenerationMethodInfo.GetIsPartial(method)) tokens.Add(PartialKeyword); return [.. tokens]; diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Editing/CSharpImportAdder.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Editing/CSharpImportAdder.cs index 8b724d4fba4e..7a71c9ba2faf 100644 --- a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Editing/CSharpImportAdder.cs +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Editing/CSharpImportAdder.cs @@ -15,7 +15,7 @@ using Microsoft.CodeAnalysis.Host.Mef; using Microsoft.CodeAnalysis.PooledObjects; using Microsoft.CodeAnalysis.Shared.Extensions; -using Microsoft.CodeAnalysis.Shared.Utilities; +using Microsoft.CodeAnalysis.Threading; using Roslyn.Utilities; namespace Microsoft.CodeAnalysis.CSharp.Editing; diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/ContextQuery/SyntaxTreeExtensions.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/ContextQuery/SyntaxTreeExtensions.cs index 72568fd3a173..10b3ac96f946 100644 --- a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/ContextQuery/SyntaxTreeExtensions.cs +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/Extensions/ContextQuery/SyntaxTreeExtensions.cs @@ -2831,12 +2831,14 @@ public static bool IsIsOrAsOrSwitchOrWithExpressionContext( // is/as/with are valid after expressions. if (token.IsLastTokenOfNode(out var expression)) { - // 'is/as/with' not allowed after a anonymous-method/lambda/method-group. + // 'is/as/with/switch' not allowed after a anonymous-method/lambda. if (expression is AnonymousFunctionExpressionSyntax) return false; + // is/as/with/switch also not allowed after a naked method group reference (e.g. `this.ToString is`). + // They are allowed after a method invocation (e.g. `this.ToString() is`). var symbol = semanticModel.GetSymbolInfo(expression, cancellationToken).GetAnySymbol(); - if (symbol is IMethodSymbol) + if (symbol is IMethodSymbol && expression is not InvocationExpressionSyntax) return false; // However, many names look like expressions. For example: diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/LanguageServices/CSharpSemanticFactsService.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/LanguageServices/CSharpSemanticFactsService.cs index 57dcf24f1f50..44ca77938ca4 100644 --- a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/LanguageServices/CSharpSemanticFactsService.cs +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/CSharp/LanguageServices/CSharpSemanticFactsService.cs @@ -33,24 +33,25 @@ private CSharpSemanticFactsService() protected override SyntaxToken ToIdentifierToken(string identifier) => identifier.ToIdentifierToken(); - protected override IEnumerable GetCollidableSymbols(SemanticModel semanticModel, SyntaxNode location, SyntaxNode container, CancellationToken cancellationToken) + protected override IEnumerable GetCollidableSymbols(SemanticModel semanticModel, SyntaxNode location, SyntaxNode? container, CancellationToken cancellationToken) { // Get all the symbols visible to the current location. var visibleSymbols = semanticModel.LookupSymbols(location.SpanStart); // Local function parameter is allowed to shadow variables since C# 8. - if (semanticModel.Compilation.LanguageVersion().MapSpecifiedToEffectiveVersion() >= LanguageVersion.CSharp8) + // Similarly, a nested primary constructor parameter list can shadow outer parameters in outer types. + var languageVersion = semanticModel.Compilation.LanguageVersion().MapSpecifiedToEffectiveVersion(); + var isLanguageVersionGreaterOrEqualToCSharp8 = languageVersion >= LanguageVersion.CSharp8; + if (isLanguageVersionGreaterOrEqualToCSharp8 && + SyntaxFacts.IsParameterList(container)) { - if (SyntaxFacts.IsParameterList(container) && SyntaxFacts.IsLocalFunctionStatement(container.Parent)) - { + if (container.Parent is LocalFunctionStatementSyntax or TypeDeclarationSyntax) visibleSymbols = visibleSymbols.WhereAsArray(s => !s.MatchesKind(SymbolKind.Local, SymbolKind.Parameter)); - } } // Some symbols in the enclosing block could cause conflicts even if they are not available at the location. // E.g. symbols inside if statements / try catch statements. - var symbolsInBlock = semanticModel.GetAllDeclaredSymbols(container, cancellationToken, - descendInto: n => ShouldDescendInto(n)); + var symbolsInBlock = semanticModel.GetAllDeclaredSymbols(container, cancellationToken, descendInto: ShouldDescendInto); return symbolsInBlock.Concat(visibleSymbols); @@ -60,10 +61,7 @@ protected override IEnumerable GetCollidableSymbols(SemanticModel seman // b) Symbols declared inside the local function do not cause collisions with symbols declared outside them, so avoid considering those symbols. // Exclude lambdas as well when the language version is C# 8 or higher because symbols declared inside no longer collide with outer variables. bool ShouldDescendInto(SyntaxNode node) - { - var isLanguageVersionGreaterOrEqualToCSharp8 = (semanticModel.Compilation as CSharpCompilation)?.LanguageVersion >= LanguageVersion.CSharp8; - return isLanguageVersionGreaterOrEqualToCSharp8 ? !SyntaxFacts.IsAnonymousOrLocalFunction(node) : !SyntaxFacts.IsLocalFunctionStatement(node); - } + => isLanguageVersionGreaterOrEqualToCSharp8 ? !SyntaxFacts.IsAnonymousOrLocalFunction(node) : !SyntaxFacts.IsLocalFunctionStatement(node); } public bool IsExpressionContext(SemanticModel semanticModel, int position, CancellationToken cancellationToken) diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/Extensions/KnownTypes.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/Extensions/KnownTypes.cs index 5d078e435a12..132708f92af9 100644 --- a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/Extensions/KnownTypes.cs +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/Extensions/KnownTypes.cs @@ -2,6 +2,8 @@ // 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.Diagnostics.CodeAnalysis; + namespace Microsoft.CodeAnalysis.Shared.Extensions; internal readonly struct KnownTaskTypes(Compilation compilation) @@ -17,22 +19,25 @@ internal readonly struct KnownTaskTypes(Compilation compilation) public readonly INamedTypeSymbol? IAsyncEnumerableOfTType = compilation.IAsyncEnumerableOfTType(); public readonly INamedTypeSymbol? IAsyncEnumeratorOfTType = compilation.IAsyncEnumeratorOfTType(); - public bool IsTaskLike(ITypeSymbol returnType) + public bool IsTaskLike([NotNullWhen(true)] ITypeSymbol? returnType) { - if (returnType.Equals(this.TaskType)) - return true; + if (returnType is not null) + { + if (returnType.Equals(this.TaskType)) + return true; - if (returnType.Equals(this.ValueTaskType)) - return true; + if (returnType.Equals(this.ValueTaskType)) + return true; - if (returnType.OriginalDefinition.Equals(this.TaskOfTType)) - return true; + if (returnType.OriginalDefinition.Equals(this.TaskOfTType)) + return true; - if (returnType.OriginalDefinition.Equals(this.ValueTaskOfTType)) - return true; + if (returnType.OriginalDefinition.Equals(this.ValueTaskOfTType)) + return true; - if (returnType.IsErrorType()) - return returnType.Name is "Task" or "ValueTask"; + if (returnType.IsErrorType()) + return returnType.Name is "Task" or "ValueTask"; + } return false; } diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/Extensions/TextDocumentExtensions.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/Extensions/TextDocumentExtensions.cs index 1f769a4a6ef2..40f6a6abce8d 100644 --- a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/Extensions/TextDocumentExtensions.cs +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/Extensions/TextDocumentExtensions.cs @@ -15,7 +15,7 @@ internal static partial class TextDocumentExtensions public static ValueTask GetValueTextAsync(this TextDocument document, CancellationToken cancellationToken) { if (document.TryGetText(out var text)) - return ValueTaskFactory.FromResult(text); + return ValueTask.FromResult(text); return new ValueTask(document.GetTextAsync(cancellationToken)); } diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/LanguageServices/SemanticsFactsService/AbstractSemanticFactsService.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/LanguageServices/SemanticsFactsService/AbstractSemanticFactsService.cs index 12f64b48eb15..3644a722d669 100644 --- a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/LanguageServices/SemanticsFactsService/AbstractSemanticFactsService.cs +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/LanguageServices/SemanticsFactsService/AbstractSemanticFactsService.cs @@ -2,8 +2,6 @@ // 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; using System.Collections.Generic; using System.Collections.Immutable; @@ -38,7 +36,7 @@ SymbolKind.Field or s is { Kind: SymbolKind.NamedType, IsStatic: true }; public SyntaxToken GenerateUniqueName( - SemanticModel semanticModel, SyntaxNode location, SyntaxNode containerOpt, + SemanticModel semanticModel, SyntaxNode location, SyntaxNode? containerOpt, string baseName, CancellationToken cancellationToken) { return GenerateUniqueName( @@ -46,7 +44,7 @@ public SyntaxToken GenerateUniqueName( } public SyntaxToken GenerateUniqueName( - SemanticModel semanticModel, SyntaxNode location, SyntaxNode containerOpt, + SemanticModel semanticModel, SyntaxNode location, SyntaxNode? containerOpt, string baseName, IEnumerable usedNames, CancellationToken cancellationToken) { return GenerateUniqueName( @@ -54,7 +52,7 @@ public SyntaxToken GenerateUniqueName( } public SyntaxToken GenerateUniqueLocalName( - SemanticModel semanticModel, SyntaxNode location, SyntaxNode containerOpt, + SemanticModel semanticModel, SyntaxNode location, SyntaxNode? containerOpt, string baseName, CancellationToken cancellationToken) { return GenerateUniqueName( @@ -62,7 +60,7 @@ public SyntaxToken GenerateUniqueLocalName( } public SyntaxToken GenerateUniqueLocalName( - SemanticModel semanticModel, SyntaxNode location, SyntaxNode containerOpt, + SemanticModel semanticModel, SyntaxNode location, SyntaxNode? containerOpt, string baseName, IEnumerable usedNames, CancellationToken cancellationToken) { return GenerateUniqueName( @@ -71,10 +69,15 @@ public SyntaxToken GenerateUniqueLocalName( public SyntaxToken GenerateUniqueName( SemanticModel semanticModel, - SyntaxNode location, SyntaxNode containerOpt, - string baseName, Func filter, - IEnumerable usedNames, CancellationToken cancellationToken) + SyntaxNode location, + SyntaxNode? containerOpt, + string baseName, + Func? filter, + IEnumerable? usedNames, + CancellationToken cancellationToken) { + usedNames ??= []; + var container = containerOpt ?? location.AncestorsAndSelf().FirstOrDefault( a => BlockFacts.IsExecutableBlock(a) || SyntaxFacts.IsParameterList(a) || SyntaxFacts.IsMethodBody(a)); @@ -89,7 +92,7 @@ public SyntaxToken GenerateUniqueName( /// A symbol can possibly collide with the location if it is available to that location and/or /// could cause a compiler error if its name is re-used at that location. /// - protected virtual IEnumerable GetCollidableSymbols(SemanticModel semanticModel, SyntaxNode location, SyntaxNode container, CancellationToken cancellationToken) + protected virtual IEnumerable GetCollidableSymbols(SemanticModel semanticModel, SyntaxNode location, SyntaxNode? container, CancellationToken cancellationToken) => semanticModel.LookupSymbols(location.SpanStart).Concat(semanticModel.GetAllDeclaredSymbols(container, cancellationToken)); public SyntaxToken GenerateUniqueName(string baseName, IEnumerable usedNames) @@ -99,8 +102,6 @@ public SyntaxToken GenerateUniqueName(string baseName, IEnumerable usedN baseName, usedNames, this.SyntaxFacts.IsCaseSensitive)); } -#nullable enable - protected static IMethodSymbol? FindDisposeMethod(Compilation compilation, ITypeSymbol? type, bool isAsync) { if (type is null) @@ -167,8 +168,6 @@ public SyntaxToken GenerateUniqueName(string baseName, IEnumerable usedN } } -#nullable disable - #region ISemanticFacts implementation public bool SupportsImplicitInterfaceImplementation => SemanticFacts.SupportsImplicitInterfaceImplementation; @@ -177,31 +176,31 @@ public SyntaxToken GenerateUniqueName(string baseName, IEnumerable usedN public bool ExposesAnonymousFunctionParameterNames => SemanticFacts.ExposesAnonymousFunctionParameterNames; - public bool IsWrittenTo(SemanticModel semanticModel, SyntaxNode node, CancellationToken cancellationToken) + public bool IsWrittenTo(SemanticModel semanticModel, SyntaxNode? node, CancellationToken cancellationToken) => SemanticFacts.IsWrittenTo(semanticModel, node, cancellationToken); - public bool IsOnlyWrittenTo(SemanticModel semanticModel, SyntaxNode node, CancellationToken cancellationToken) + public bool IsOnlyWrittenTo(SemanticModel semanticModel, SyntaxNode? node, CancellationToken cancellationToken) => SemanticFacts.IsOnlyWrittenTo(semanticModel, node, cancellationToken); - public bool IsInOutContext(SemanticModel semanticModel, SyntaxNode node, CancellationToken cancellationToken) + public bool IsInOutContext(SemanticModel semanticModel, SyntaxNode? node, CancellationToken cancellationToken) => SemanticFacts.IsInOutContext(semanticModel, node, cancellationToken); - public bool IsInRefContext(SemanticModel semanticModel, SyntaxNode node, CancellationToken cancellationToken) + public bool IsInRefContext(SemanticModel semanticModel, SyntaxNode? node, CancellationToken cancellationToken) => SemanticFacts.IsInRefContext(semanticModel, node, cancellationToken); - public bool IsInInContext(SemanticModel semanticModel, SyntaxNode node, CancellationToken cancellationToken) + public bool IsInInContext(SemanticModel semanticModel, SyntaxNode? node, CancellationToken cancellationToken) => SemanticFacts.IsInInContext(semanticModel, node, cancellationToken); - public bool CanReplaceWithRValue(SemanticModel semanticModel, SyntaxNode expression, CancellationToken cancellationToken) + public bool CanReplaceWithRValue(SemanticModel semanticModel, SyntaxNode? expression, CancellationToken cancellationToken) => SemanticFacts.CanReplaceWithRValue(semanticModel, expression, cancellationToken); - public ISymbol GetDeclaredSymbol(SemanticModel semanticModel, SyntaxToken token, CancellationToken cancellationToken) + public ISymbol? GetDeclaredSymbol(SemanticModel semanticModel, SyntaxToken token, CancellationToken cancellationToken) => SemanticFacts.GetDeclaredSymbol(semanticModel, token, cancellationToken); public bool LastEnumValueHasInitializer(INamedTypeSymbol namedTypeSymbol) => SemanticFacts.LastEnumValueHasInitializer(namedTypeSymbol); - public bool TryGetSpeculativeSemanticModel(SemanticModel oldSemanticModel, SyntaxNode oldNode, SyntaxNode newNode, out SemanticModel speculativeModel) + public bool TryGetSpeculativeSemanticModel(SemanticModel oldSemanticModel, SyntaxNode oldNode, SyntaxNode newNode, [NotNullWhen(true)] out SemanticModel? speculativeModel) => SemanticFacts.TryGetSpeculativeSemanticModel(oldSemanticModel, oldNode, newNode, out speculativeModel); public ImmutableHashSet GetAliasNameSet(SemanticModel model, CancellationToken cancellationToken) @@ -213,7 +212,7 @@ public ForEachSymbols GetForEachSymbols(SemanticModel semanticModel, SyntaxNode public SymbolInfo GetCollectionInitializerSymbolInfo(SemanticModel semanticModel, SyntaxNode node, CancellationToken cancellationToken) => SemanticFacts.GetCollectionInitializerSymbolInfo(semanticModel, node, cancellationToken); - public IMethodSymbol GetGetAwaiterMethod(SemanticModel semanticModel, SyntaxNode node) + public IMethodSymbol? GetGetAwaiterMethod(SemanticModel semanticModel, SyntaxNode node) => SemanticFacts.GetGetAwaiterMethod(semanticModel, node); public ImmutableArray GetDeconstructionAssignmentMethods(SemanticModel semanticModel, SyntaxNode node) @@ -228,42 +227,42 @@ public bool IsPartial(INamedTypeSymbol typeSymbol, CancellationToken cancellatio public IEnumerable GetDeclaredSymbols(SemanticModel semanticModel, SyntaxNode memberDeclaration, CancellationToken cancellationToken) => SemanticFacts.GetDeclaredSymbols(semanticModel, memberDeclaration, cancellationToken); - public IParameterSymbol FindParameterForArgument(SemanticModel semanticModel, SyntaxNode argumentNode, bool allowUncertainCandidates, bool allowParams, CancellationToken cancellationToken) + public IParameterSymbol? FindParameterForArgument(SemanticModel semanticModel, SyntaxNode argumentNode, bool allowUncertainCandidates, bool allowParams, CancellationToken cancellationToken) => SemanticFacts.FindParameterForArgument(semanticModel, argumentNode, allowUncertainCandidates, allowParams, cancellationToken); - public IParameterSymbol FindParameterForAttributeArgument(SemanticModel semanticModel, SyntaxNode argumentNode, bool allowUncertainCandidates, bool allowParams, CancellationToken cancellationToken) + public IParameterSymbol? FindParameterForAttributeArgument(SemanticModel semanticModel, SyntaxNode argumentNode, bool allowUncertainCandidates, bool allowParams, CancellationToken cancellationToken) => SemanticFacts.FindParameterForAttributeArgument(semanticModel, argumentNode, allowUncertainCandidates, allowParams, cancellationToken); - public ISymbol FindFieldOrPropertyForArgument(SemanticModel semanticModel, SyntaxNode argumentNode, CancellationToken cancellationToken) + public ISymbol? FindFieldOrPropertyForArgument(SemanticModel semanticModel, SyntaxNode argumentNode, CancellationToken cancellationToken) => SemanticFacts.FindFieldOrPropertyForArgument(semanticModel, argumentNode, cancellationToken); - public ISymbol FindFieldOrPropertyForAttributeArgument(SemanticModel semanticModel, SyntaxNode argumentNode, CancellationToken cancellationToken) + public ISymbol? FindFieldOrPropertyForAttributeArgument(SemanticModel semanticModel, SyntaxNode argumentNode, CancellationToken cancellationToken) => SemanticFacts.FindFieldOrPropertyForAttributeArgument(semanticModel, argumentNode, cancellationToken); - public ImmutableArray GetBestOrAllSymbols(SemanticModel semanticModel, SyntaxNode node, SyntaxToken token, CancellationToken cancellationToken) + public ImmutableArray GetBestOrAllSymbols(SemanticModel semanticModel, SyntaxNode? node, SyntaxToken token, CancellationToken cancellationToken) => SemanticFacts.GetBestOrAllSymbols(semanticModel, node, token, cancellationToken); - public bool IsInsideNameOfExpression(SemanticModel semanticModel, SyntaxNode node, CancellationToken cancellationToken) + public bool IsInsideNameOfExpression(SemanticModel semanticModel, SyntaxNode? node, CancellationToken cancellationToken) => SemanticFacts.IsInsideNameOfExpression(semanticModel, node, cancellationToken); public ImmutableArray GetLocalFunctionSymbols(Compilation compilation, ISymbol symbol, CancellationToken cancellationToken) => SemanticFacts.GetLocalFunctionSymbols(compilation, symbol, cancellationToken); - public bool IsInExpressionTree(SemanticModel semanticModel, SyntaxNode node, INamedTypeSymbol expressionTypeOpt, CancellationToken cancellationToken) + public bool IsInExpressionTree(SemanticModel semanticModel, SyntaxNode node, INamedTypeSymbol? expressionTypeOpt, CancellationToken cancellationToken) => SemanticFacts.IsInExpressionTree(semanticModel, node, expressionTypeOpt, cancellationToken); public string GenerateNameForExpression(SemanticModel semanticModel, SyntaxNode expression, bool capitalize, CancellationToken cancellationToken) => SemanticFacts.GenerateNameForExpression(semanticModel, expression, capitalize, cancellationToken); - public IPreprocessingSymbol GetPreprocessingSymbol(SemanticModel semanticModel, SyntaxNode node) + public IPreprocessingSymbol? GetPreprocessingSymbol(SemanticModel semanticModel, SyntaxNode node) => SemanticFacts.GetPreprocessingSymbol(semanticModel, node); - public bool TryGetPrimaryConstructor(INamedTypeSymbol typeSymbol, [NotNullWhen(true)] out IMethodSymbol primaryConstructor) + public bool TryGetPrimaryConstructor(INamedTypeSymbol typeSymbol, [NotNullWhen(true)] out IMethodSymbol? primaryConstructor) => SemanticFacts.TryGetPrimaryConstructor(typeSymbol, out primaryConstructor); #if WORKSPACE - public Task GetInterceptorSymbolAsync(Document document, int position, CancellationToken cancellationToken) + public Task GetInterceptorSymbolAsync(Document document, int position, CancellationToken cancellationToken) => SemanticFacts.GetInterceptorSymbolAsync(document, position, cancellationToken); #endif diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/Options/OptionsProvider.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/Options/OptionsProvider.cs index 2c46e1d9eaef..acf7fef59183 100644 --- a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/Options/OptionsProvider.cs +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/Options/OptionsProvider.cs @@ -21,7 +21,7 @@ internal static class OptionsProvider private sealed class OptionsReaderProvider(IOptionsReader optionsReader, Func reader) : OptionsProvider { public ValueTask GetOptionsAsync(LanguageServices languageServices, CancellationToken cancellationToken) - => ValueTaskFactory.FromResult(reader(optionsReader, languageServices.Language)); + => ValueTask.FromResult(reader(optionsReader, languageServices.Language)); } public static OptionsProvider GetProvider(this IOptionsReader optionsReader, Func reader) diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/Simplification/AbstractSimplificationService.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/Simplification/AbstractSimplificationService.cs index cf1f0e196799..2d7c6fd29bb9 100644 --- a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/Simplification/AbstractSimplificationService.cs +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/Simplification/AbstractSimplificationService.cs @@ -172,7 +172,7 @@ private async Task ReduceAsync( } else { - await RoslynParallel.ForEachAsync( + await Parallel.ForEachAsync( source: nodesAndTokensToReduce, cancellationToken, ReduceOneNodeOrTokenAsync).ConfigureAwait(false); diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/Utilities/AsyncSymbolVisitor`1.cs b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/Utilities/AsyncSymbolVisitor`1.cs index f1591f9aa32b..cc5811efb3aa 100644 --- a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/Utilities/AsyncSymbolVisitor`1.cs +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/Core/Utilities/AsyncSymbolVisitor`1.cs @@ -12,8 +12,8 @@ internal abstract class AsyncSymbolVisitor : SymbolVisitor Visit(ISymbol? symbol) - => symbol?.Accept(this) ?? ValueTaskFactory.FromResult(DefaultResult); + => symbol?.Accept(this) ?? ValueTask.FromResult(DefaultResult); public override ValueTask DefaultVisit(ISymbol symbol) - => ValueTaskFactory.FromResult(DefaultResult); + => ValueTask.FromResult(DefaultResult); } diff --git a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/Editing/VisualBasicImportAdder.vb b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/Editing/VisualBasicImportAdder.vb index 48df567891d0..636dc2712d34 100644 --- a/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/Editing/VisualBasicImportAdder.vb +++ b/src/Workspaces/SharedUtilitiesAndExtensions/Workspace/VisualBasic/Editing/VisualBasicImportAdder.vb @@ -9,6 +9,7 @@ Imports Microsoft.CodeAnalysis Imports Microsoft.CodeAnalysis.Editing Imports Microsoft.CodeAnalysis.Host.Mef Imports Microsoft.CodeAnalysis.PooledObjects +Imports Microsoft.CodeAnalysis.Threading Imports Microsoft.CodeAnalysis.VisualBasic.LanguageService Imports Microsoft.CodeAnalysis.VisualBasic.Syntax diff --git a/src/Workspaces/VisualBasic/Portable/Simplification/Reducers/VisualBasicEscapingReducer.vb b/src/Workspaces/VisualBasic/Portable/Simplification/Reducers/VisualBasicEscapingReducer.vb index 97c79f4d6f12..2005a9c19fef 100644 --- a/src/Workspaces/VisualBasic/Portable/Simplification/Reducers/VisualBasicEscapingReducer.vb +++ b/src/Workspaces/VisualBasic/Portable/Simplification/Reducers/VisualBasicEscapingReducer.vb @@ -123,7 +123,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Simplification ' escape contextual query keywords if they are the first token after a query expression ' and on the following line Dim previousToken = identifier.GetPreviousToken(False, False, True, True) - Dim queryAncestorOfPrevious = previousToken.GetAncestors(Of QueryExpressionSyntax).FirstOrDefault() + Dim queryAncestorOfPrevious = previousToken.GetAncestor(Of QueryExpressionSyntax) If queryAncestorOfPrevious IsNot Nothing AndAlso queryAncestorOfPrevious.GetLastToken() = previousToken Then lastTokenOfQuery = previousToken @@ -162,7 +162,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Simplification ' if this token is part of a XmlDocument, all trailing whitespace is part of the XmlDocument ' so all line breaks actually will not help. ' see VB spec #11.23.3 - If previousToken.GetAncestors(Of XmlDocumentSyntax).FirstOrDefault() IsNot Nothing Then + If previousToken.GetAncestor(Of XmlDocumentSyntax) IsNot Nothing Then Return identifier End If