/
githubmirror
/
roslyn
Обзор
Документация
Войти
/
githubmirror
/
roslyn
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
src/Features/CSharpTest/ConvertBetweenRegularAndVerbatimString/ConvertBetweenRegularAndVerbatimStringTests.cs
293 строки
7 KB
Jared Parsons
Port remaining unit test projects to Linux (#83153)
17 апр 2026, 19:00
Не верифицирован
17 апр 2026, 19:00
8b511b9
Код
Авторство
О чём код?
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. #nullable disable using System; using System.Threading.Tasks; using Microsoft.CodeAnalysis.CodeRefactorings; using Microsoft.CodeAnalysis.CSharp.ConvertBetweenRegularAndVerbatimString; using Microsoft.CodeAnalysis.Editor.CSharp.UnitTests.CodeRefactorings; using Microsoft.CodeAnalysis.Test.Utilities; using Xunit; namespace Microsoft.CodeAnalysis.Editor.CSharp.UnitTests.ConvertBetweenRegularAndVerbatimString; [Trait(Traits.Feature, Traits.Features.CodeActionsConvertBetweenRegularAndVerbatimString)] public sealed class ConvertBetweenRegularAndVerbatimStringTests : AbstractCSharpCodeActionTest_NoEditor { private static string NewLineEscape { get; } = Environment.NewLine == "\r\n" ? @"\r\n" : @"\n"; protected override CodeRefactoringProvider CreateCodeRefactoringProvider(TestWorkspace workspace, TestParameters parameters) => new ConvertBetweenRegularAndVerbatimStringCodeRefactoringProvider(); [Fact] public Task EmptyRegularString() => TestMissingAsync(""" class Test { void Method() { var v = "[||]"; } } """); [Fact] public Task RegularStringWithMissingCloseQuote() => TestMissingAsync(""" class Test { void Method() { var v = "[||]; } } """); [Fact] public Task VerbatimStringWithMissingCloseQuote() => TestMissingAsync(""" class Test { void Method() { var v = @"[||]; } } """); [Fact] public Task EmptyVerbatimString() => TestInRegularAndScriptAsync(""" class Test { void Method() { var v = @"[||]"; } } """, """ class Test { void Method() { var v = ""; } } """); [Fact] public Task TestLeadingAndTrailingTrivia() => TestInRegularAndScriptAsync(""" class Test { void Method() { var v = // leading @"[||]" /* trailing */; } } """, """ class Test { void Method() { var v = // leading "" /* trailing */; } } """); [Fact] public Task RegularStringWithBasicText() => TestMissingAsync(""" class Test { void Method() { var v = "[||]a"; } } """); [Fact] public Task VerbatimStringWithBasicText() => TestInRegularAndScriptAsync(""" class Test { void Method() { var v = @"[||]a"; } } """, """ class Test { void Method() { var v = "a"; } } """); [Fact] public Task RegularStringWithUnicodeEscape() => TestMissingAsync(""" class Test { void Method() { var v = "[||]\u0001"; } } """); [Fact] public Task RegularStringWithEscapedNewLine() => TestInRegularAndScriptAsync(""" class Test { void Method() { var v = "[||]a\r\nb"; } } """.Replace(@"\r\n", NewLineEscape), """ class Test { void Method() { var v = @"a b"; } } """); [Fact] public Task VerbatimStringWithNewLine() => TestInRegularAndScriptAsync(""" class Test { void Method() { var v = @"[||]a b"; } } """, """ class Test { void Method() { var v = "a\r\nb"; } } """.Replace(@"\r\n", NewLineEscape)); [Fact] public Task RegularStringWithEscapedNull() => TestMissingAsync(""" class Test { void Method() { var v = "[||]a\0b"; } } """); [Fact] public Task RegularStringWithEscapedQuote() => TestInRegularAndScriptAsync(""" class Test { void Method() { var v = "[||]a\"b"; } } """, """ class Test { void Method() { var v = @"a""b"; } } """); [Fact] public Task VerbatimStringWithEscapedQuote() => TestInRegularAndScriptAsync(""" class Test { void Method() { var v = @"[||]a""b"; } } """, """ class Test { void Method() { var v = "a\"b"; } } """); [Fact] public Task DoNotEscapeCurlyBracesInRegularString() => TestInRegularAndScriptAsync(""" class Test { void Method() { var v = "[||]a\r\n{1}"; } } """.Replace(@"\r\n", NewLineEscape), """ class Test { void Method() { var v = @"a {1}"; } } """); [Fact] public Task DoNotEscapeCurlyBracesInVerbatimString() => TestInRegularAndScriptAsync(""" class Test { void Method() { var v = @"[||]a {1}"; } } """, """ class Test { void Method() { var v = "a\r\n{1}"; } } """.Replace(@"\r\n", NewLineEscape)); }