Skip to content

Commit 561bb89

Browse files
authored
Fix MoveType to create debuggable documents (#78554)
1 parent 986c13b commit 561bb89

File tree

44 files changed

+265
-246
lines changed

Some content is hidden

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

44 files changed

+265
-246
lines changed

eng/config/BannedSymbols.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ M:Microsoft.CodeAnalysis.VisualBasic.VisualBasicSyntaxTree.Create(Microsoft.Code
5959
M:Microsoft.CodeAnalysis.VisualBasic.VisualBasicSyntaxTree.Create(Microsoft.CodeAnalysis.VisualBasic.VisualBasicSyntaxNode,Microsoft.CodeAnalysis.VisualBasic.VisualBasicParseOptions,System.String,System.Text.Encoding); Use VisualBasicSyntaxTree sublass that takes checksum algorithm
6060
M:Microsoft.CodeAnalysis.VisualBasic.VisualBasicSyntaxTree.ParseText(System.String,Microsoft.CodeAnalysis.VisualBasic.VisualBasicParseOptions,System.String,System.Text.Encoding,System.Collections.Immutable.ImmutableDictionary{System.String,Microsoft.CodeAnalysis.ReportDiagnostic},System.Threading.CancellationToken); Use overload with SourceText
6161
M:Microsoft.CodeAnalysis.Workspaces.Workspace.SetCurrentSolution(Microsoft.CodeAnalysis.Solution); Use SetCurrentSolutionEx instead.
62+
M:Microsoft.CodeAnalysis.Project.AddDocument(System.String,System.String,System.Collections.Generic.IEnumerable{System.String},System.String); Use overload that takes SourceText. Make sure SourceText is created with encoding and checksum algorithm.
6263
M:System.Enum.GetHashCode(); Cast to integral type to avoid boxing on .NET Framework
6364
M:Microsoft.CodeAnalysis.CodeActions.CodeAction.PostProcessAsync(System.Collections.Generic.IEnumerable{Microsoft.CodeAnalysis.CodeActions.CodeActionOperation},System.Threading.CancellationToken); Use overload that takes a solution
6465
M:Microsoft.CodeAnalysis.CodeActions.CodeAction.PostProcessChangesAsync(Microsoft.CodeAnalysis.Solution,System.Threading.CancellationToken); Use overload that takes a solution

src/Analyzers/CSharp/Tests/MakeFieldReadonly/MakeFieldReadonlyTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2012,7 +2012,7 @@ await TestMissingInRegularAndScriptAsync(
20122012
"""
20132013
<Workspace>
20142014
<Project Language = "C#" AssemblyName="Assembly1" CommonReferences="true">
2015-
<Document FilePath = "z:\\File1.cs">
2015+
<Document FilePath = "File1.cs">
20162016
public sealed partial class Test
20172017
{
20182018
private int [|_value|];
@@ -2021,7 +2021,7 @@ public static void M()
20212021
=> _ = new Test { Value = 1 };
20222022
}
20232023
</Document>
2024-
<Document FilePath = "z:\\File2.g.cs">
2024+
<Document FilePath = "File2.g.cs">
20252025
using System.CodeDom.Compiler;
20262026
20272027
[GeneratedCode(null, null)]

src/Analyzers/CSharp/Tests/UseAutoProperty/UseAutoPropertyTests.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2751,15 +2751,15 @@ await TestInRegularAndScript1Async(
27512751
"""
27522752
<Workspace>
27532753
<Project Language = "C#" AssemblyName="Assembly1" CommonReferences="true">
2754-
<Document FilePath = "z:\\file.cs">
2754+
<Document FilePath = "file.cs">
27552755
public class Foo
27562756
{
27572757
private readonly object o;
27582758
27592759
[||]public object O => o;
27602760
}
27612761
</Document>
2762-
<AnalyzerConfigDocument FilePath = "z:\\.editorconfig">
2762+
<AnalyzerConfigDocument FilePath = ".editorconfig">
27632763
[*]
27642764
indent_style = tab
27652765
</AnalyzerConfigDocument>
@@ -2769,13 +2769,13 @@ public class Foo
27692769
"""
27702770
<Workspace>
27712771
<Project Language = "C#" AssemblyName="Assembly1" CommonReferences="true">
2772-
<Document FilePath = "z:\\file.cs">
2772+
<Document FilePath = "file.cs">
27732773
public class Foo
27742774
{
27752775
public object O { get; }
27762776
}
27772777
</Document>
2778-
<AnalyzerConfigDocument FilePath = "z:\\.editorconfig">
2778+
<AnalyzerConfigDocument FilePath = ".editorconfig">
27792779
[*]
27802780
indent_style = tab
27812781
</AnalyzerConfigDocument>
@@ -2791,15 +2791,15 @@ await TestInRegularAndScript1Async(
27912791
"""
27922792
<Workspace>
27932793
<Project Language = "C#" AssemblyName="Assembly1" CommonReferences="true">
2794-
<Document FilePath = "z:\\file.cs">
2794+
<Document FilePath = "file.cs">
27952795
public class Foo
27962796
{
27972797
private readonly object o;
27982798
27992799
[||]public object O => o;
28002800
}
28012801
</Document>
2802-
<AnalyzerConfigDocument FilePath = "z:\\.editorconfig">
2802+
<AnalyzerConfigDocument FilePath = ".editorconfig">
28032803
[*]
28042804
indent_style = space
28052805
</AnalyzerConfigDocument>
@@ -2809,13 +2809,13 @@ public class Foo
28092809
"""
28102810
<Workspace>
28112811
<Project Language = "C#" AssemblyName="Assembly1" CommonReferences="true">
2812-
<Document FilePath = "z:\\file.cs">
2812+
<Document FilePath = "file.cs">
28132813
public class Foo
28142814
{
28152815
public object O { get; }
28162816
}
28172817
</Document>
2818-
<AnalyzerConfigDocument FilePath = "z:\\.editorconfig">
2818+
<AnalyzerConfigDocument FilePath = ".editorconfig">
28192819
[*]
28202820
indent_style = space
28212821
</AnalyzerConfigDocument>

src/Analyzers/VisualBasic/Tests/UseAutoProperty/UseAutoPropertyTests.vb

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1126,7 +1126,7 @@ End Class", options:=[Option](FormattingOptions2.UseTabs, False))
11261126
Await TestInRegularAndScriptAsync(
11271127
"<Workspace>
11281128
<Project Language = ""Visual Basic"" AssemblyName=""Assembly1"" CommonReferences=""true"">
1129-
<Document FilePath = ""z:\\file.vb"">
1129+
<Document FilePath = ""file.vb"">
11301130
Public Class Foo
11311131
[||]Private ReadOnly o2 As Object
11321132

@@ -1137,20 +1137,20 @@ Public Class Foo
11371137
End Property
11381138
End Class
11391139
</Document>
1140-
<AnalyzerConfigDocument FilePath = ""z:\\.editorconfig"">
1140+
<AnalyzerConfigDocument FilePath = "".editorconfig"">
11411141
[*]
11421142
indent_style = tab
11431143
</AnalyzerConfigDocument>
11441144
</Project>
11451145
</Workspace>",
11461146
"<Workspace>
11471147
<Project Language = ""Visual Basic"" AssemblyName=""Assembly1"" CommonReferences=""true"">
1148-
<Document FilePath = ""z:\\file.vb"">
1148+
<Document FilePath = ""file.vb"">
11491149
Public Class Foo
11501150
Public ReadOnly Property O As Object
11511151
End Class
11521152
</Document>
1153-
<AnalyzerConfigDocument FilePath = ""z:\\.editorconfig"">
1153+
<AnalyzerConfigDocument FilePath = "".editorconfig"">
11541154
[*]
11551155
indent_style = tab
11561156
</AnalyzerConfigDocument>
@@ -1163,7 +1163,7 @@ indent_style = tab
11631163
Await TestInRegularAndScriptAsync(
11641164
"<Workspace>
11651165
<Project Language = ""Visual Basic"" AssemblyName=""Assembly1"" CommonReferences=""true"">
1166-
<Document FilePath = ""z:\\file.vb"">
1166+
<Document FilePath = ""file.vb"">
11671167
Public Class Foo
11681168
[||]Private ReadOnly o2 As Object
11691169

@@ -1174,20 +1174,20 @@ Public Class Foo
11741174
End Property
11751175
End Class
11761176
</Document>
1177-
<AnalyzerConfigDocument FilePath = ""z:\\.editorconfig"">
1177+
<AnalyzerConfigDocument FilePath = "".editorconfig"">
11781178
[*]
11791179
indent_style = space
11801180
</AnalyzerConfigDocument>
11811181
</Project>
11821182
</Workspace>",
11831183
"<Workspace>
11841184
<Project Language = ""Visual Basic"" AssemblyName=""Assembly1"" CommonReferences=""true"">
1185-
<Document FilePath = ""z:\\file.vb"">
1185+
<Document FilePath = ""file.vb"">
11861186
Public Class Foo
11871187
Public ReadOnly Property O As Object
11881188
End Class
11891189
</Document>
1190-
<AnalyzerConfigDocument FilePath = ""z:\\.editorconfig"">
1190+
<AnalyzerConfigDocument FilePath = "".editorconfig"">
11911191
[*]
11921192
indent_style = space
11931193
</AnalyzerConfigDocument>

src/EditorFeatures/CSharpTest/ChangeSignature/AddParameterTests.Formatting.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -516,15 +516,15 @@ public async Task AddParameter_Formatting_PreserveIndentBraces_Editorconfig()
516516
var markup = @"
517517
<Workspace>
518518
<Project Language=""C#"" AssemblyName=""Assembly1"" CommonReferences=""true"">
519-
<Document FilePath=""z:\\file.cs"">
519+
<Document FilePath=""file.cs"">
520520
public class C
521521
{
522522
public void M$$()
523523
{
524524
}
525525
}
526526
</Document>
527-
<AnalyzerConfigDocument FilePath=""z:\\.editorconfig"">[*.cs]
527+
<AnalyzerConfigDocument FilePath="".editorconfig"">[*.cs]
528528
csharp_indent_braces = true
529529
</AnalyzerConfigDocument>
530530
</Project>

src/EditorFeatures/CSharpTest/ExtractInterface/ExtractInterfaceTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2007,7 +2007,7 @@ public async Task RemoveEnumeratorCancellationAttribute()
20072007
var markup = """
20082008
<Workspace>
20092009
<Project Language="C#" AssemblyName="Assembly1" CommonReferencesNet8="true">
2010-
<Document FilePath="z:\\file.cs"><![CDATA[using System;
2010+
<Document FilePath="file.cs"><![CDATA[using System;
20112011
using System.Collections.Generic;
20122012
using System.Runtime.CompilerServices;
20132013

src/EditorFeatures/CSharpTest/Interactive/NavigateTo/InteractiveNavigateToTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -621,7 +621,7 @@ void assertDescription(string label, string value)
621621
Assert.Equal(value, descriptionItem.Details.Single().Text);
622622
}
623623

624-
assertDescription("File:", w.Documents.Single().Name);
624+
assertDescription("File:", w.Documents.Single().FilePath);
625625
assertDescription("Line:", "3"); // one based line number
626626
assertDescription("Project:", "Test");
627627
});

src/EditorFeatures/CSharpTest/NavigateTo/NavigateToTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1029,13 +1029,13 @@ await TestAsync(testHost, composition, """
10291029

10301030
var descriptionItems = itemDisplay.DescriptionItems;
10311031

1032-
void assertDescription(string label, string value)
1032+
void assertDescription(string label, string? value)
10331033
{
10341034
var descriptionItem = descriptionItems.Single(i => i.Category.Single().Text == label);
10351035
Assert.Equal(value, descriptionItem.Details.Single().Text);
10361036
}
10371037

1038-
assertDescription("File:", w.Documents.Single().Name);
1038+
assertDescription("File:", w.Documents.Single().FilePath);
10391039
assertDescription("Line:", "3"); // one based line number
10401040
assertDescription("Project:", "Test");
10411041
});

src/EditorFeatures/CSharpTest/Rename/CSharpInlineRenameServiceTests.cs

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using System;
66
using System.Collections.Generic;
77
using System.Collections.Immutable;
8+
using System.IO;
89
using System.Linq;
910
using System.Text.Json;
1011
using System.Threading;
@@ -77,16 +78,21 @@ private static async Task VerifyGetRenameContextAsync(
7778
[WorkItem("https://github.com/dotnet/roslyn/issues/74545")]
7879
public async Task VerifyContextReachEndOfFile()
7980
{
80-
var markup = @"
81-
public class Sampl$$eClass()
82-
{
83-
}";
81+
var markup = """
82+
public class Sampl$$eClass()
83+
{
84+
}
85+
""";
86+
87+
var escapedPath = Path.Combine(TestWorkspace.RootDirectory, "test1.cs").Replace("\\", "\\\\");
88+
8489
await VerifyGetRenameContextAsync(
8590
markup,
86-
@"
87-
{
88-
""definition"" : [ {""Item1"":""test1.cs"", ""Item2"":""public class SampleClass()\r\n{\r\n}""} ]
89-
}",
91+
$$"""
92+
{
93+
"definition": [{"Item1":"{{escapedPath}}", "Item2":"public class SampleClass()\r\n{\r\n}"}]
94+
}
95+
""",
9096
new SymbolRenameOptions(),
9197
CancellationToken.None);
9298
}

src/EditorFeatures/DiagnosticsTestUtilities/CodeActions/AbstractCodeActionOrUserDiagnosticTest_TestAddDocument.cs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ await TestAddDocument(
4343
}
4444
}
4545

46-
protected async Task<Tuple<Solution, Solution>> TestAddDocumentAsync(
46+
protected async Task<(Solution oldSolution, Solution newSolution)> TestAddDocumentAsync(
4747
TestParameters parameters,
4848
EditorTestWorkspace workspace,
4949
string expectedMarkup,
@@ -71,7 +71,7 @@ await TestAddDocument(
7171
expectedDocumentName, action);
7272
}
7373

74-
private async Task<Tuple<Solution, Solution>> TestAddDocument(
74+
private async Task<(Solution oldSolution, Solution newSolution)> TestAddDocument(
7575
EditorTestWorkspace workspace,
7676
string expectedMarkup,
7777
ImmutableArray<string> expectedFolders,
@@ -89,7 +89,7 @@ private async Task<Tuple<Solution, Solution>> TestAddDocument(
8989
expectedDocumentName: expectedDocumentName);
9090
}
9191

92-
protected static async Task<Tuple<Solution, Solution>> TestAddDocument(
92+
protected static async Task<(Solution oldSolution, Solution newSolution)> TestAddDocument(
9393
EditorTestWorkspace workspace,
9494
string expected,
9595
ImmutableArray<CodeActionOperation> operations,
@@ -98,9 +98,7 @@ protected static async Task<Tuple<Solution, Solution>> TestAddDocument(
9898
ImmutableArray<string> expectedFolders,
9999
string expectedDocumentName)
100100
{
101-
var appliedChanges = await ApplyOperationsAndGetSolutionAsync(workspace, operations);
102-
var oldSolution = appliedChanges.Item1;
103-
var newSolution = appliedChanges.Item2;
101+
var (oldSolution, newSolution) = await ApplyOperationsAndGetSolutionAsync(workspace, operations);
104102

105103
Document addedDocument = null;
106104
if (!hasProjectChange)
@@ -155,6 +153,6 @@ protected static async Task<Tuple<Solution, Solution>> TestAddDocument(
155153
Assert.True(hasPreview);
156154
}
157155

158-
return Tuple.Create(oldSolution, newSolution);
156+
return (oldSolution, newSolution);
159157
}
160158
}

0 commit comments

Comments
 (0)