Skip to content

Commit 33fde18

Browse files
committed
PR feedback
1 parent 67a2661 commit 33fde18

File tree

4 files changed

+30
-30
lines changed

4 files changed

+30
-30
lines changed

src/EditorFeatures/Core/InlineRename/InlineRenameSession.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -939,14 +939,18 @@ private async Task<Solution> GetFinalSolutionAsync(ImmutableArray<(DocumentId, s
939939
{
940940
if (documentId.IsSourceGenerated)
941941
{
942-
var document = await finalSolution.GetDocumentAsync(documentId, includeSourceGenerated: true, CancellationToken.None).ConfigureAwait(false);
942+
var document = await finalSolution.GetDocumentAsync(documentId, includeSourceGenerated: true, CancellationToken.None).ConfigureAwait(true);
943943
Contract.ThrowIfFalse(document.IsRazorSourceGeneratedDocument());
944944
}
945945

946946
finalSolution = newRoot != null
947947
? finalSolution.WithDocumentSyntaxRoot(documentId, newRoot)
948948
: finalSolution.WithDocumentText(documentId, newText);
949949

950+
// WithDocumentName doesn't support source generated documents, and there should be no circumstance were they'd
951+
// be renamed anyway. Given rename only supports Razor generated documents, and those are always named for the Razor
952+
// file they come from, and nothing in Roslyn knows to rename those documents, we can safely skip this step. Razor
953+
// may process the results of this rename and rename the document if it needs to later.
950954
if (!documentId.IsSourceGenerated)
951955
{
952956
finalSolution = finalSolution.WithDocumentName(documentId, newName);

src/Tools/ExternalAccess/Razor/Features/RazorSourceGeneratedDocumentSpanMappingService.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ public async Task<ImmutableArray<MappedTextChange>> GetMappedTextChangesAsync(Do
5454
}
5555

5656
return changesBuilder.ToImmutableAndClear();
57-
5857
}
5958

6059
public async Task<ImmutableArray<MappedSpanResult>> MapSpansAsync(Document document, ImmutableArray<TextSpan> spans, CancellationToken cancellationToken)

src/VisualStudio/Core/Def/ProjectSystem/VisualStudioWorkspaceImpl.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -657,7 +657,7 @@ internal override void ApplyMappedFileChanges(SolutionChanges solutionChanges)
657657

658658
var newDocument = projectChanges.NewProject.GetRequiredDocument(changedDocumentId);
659659
var mappedTextChanges = await mappingService.GetMappedTextChangesAsync(
660-
oldDocument, newDocument, cancellationToken).ConfigureAwait(false);
660+
oldDocument, newDocument, cancellationToken).ConfigureAwait(true);
661661
foreach (var (filePath, textChange) in mappedTextChanges)
662662
{
663663
filePathToMappedTextChanges.Add(filePath, (textChange, projectChanges.ProjectId));
@@ -672,15 +672,15 @@ internal override void ApplyMappedFileChanges(SolutionChanges solutionChanges)
672672
// so the mapper has something to compare to.
673673
foreach (var (docId, state) in solutionChanges.NewSolution.CompilationState.FrozenSourceGeneratedDocumentStates.States)
674674
{
675-
var document = await solutionChanges.OldSolution.GetRequiredDocumentAsync(docId, includeSourceGenerated: true, cancellationToken).ConfigureAwait(false);
675+
var document = await solutionChanges.OldSolution.GetRequiredDocumentAsync(docId, includeSourceGenerated: true, cancellationToken).ConfigureAwait(true);
676676
Contract.ThrowIfFalse(document.IsRazorSourceGeneratedDocument());
677677
}
678678

679679
foreach (var docId in solutionChanges.GetExplicitlyChangedSourceGeneratedDocuments())
680680
{
681681
var oldDocument = solutionChanges.OldSolution.GetRequiredSourceGeneratedDocumentForAlreadyGeneratedId(docId);
682682
var newDocument = solutionChanges.NewSolution.GetRequiredSourceGeneratedDocumentForAlreadyGeneratedId(docId);
683-
var mappedTextChanges = await sourceGeneratedDocumentMappingService.GetMappedTextChangesAsync(oldDocument, newDocument, cancellationToken).ConfigureAwait(false);
683+
var mappedTextChanges = await sourceGeneratedDocumentMappingService.GetMappedTextChangesAsync(oldDocument, newDocument, cancellationToken).ConfigureAwait(true);
684684
foreach (var (filePath, textChange) in mappedTextChanges)
685685
{
686686
filePathToMappedTextChanges.Add(filePath, (textChange, docId.ProjectId));

src/Workspaces/Core/Portable/Workspace/Solution/SolutionChanges.cs

Lines changed: 22 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -13,60 +13,57 @@ namespace Microsoft.CodeAnalysis;
1313

1414
public readonly struct SolutionChanges
1515
{
16-
private readonly Solution _newSolution;
17-
private readonly Solution _oldSolution;
18-
19-
internal Solution OldSolution => _oldSolution;
20-
internal Solution NewSolution => _newSolution;
16+
internal Solution OldSolution { get; }
17+
internal Solution NewSolution { get; }
2118

2219
internal SolutionChanges(Solution newSolution, Solution oldSolution)
2320
{
24-
_newSolution = newSolution;
25-
_oldSolution = oldSolution;
21+
NewSolution = newSolution;
22+
OldSolution = oldSolution;
2623
}
2724

2825
public IEnumerable<Project> GetAddedProjects()
2926
{
30-
foreach (var id in _newSolution.ProjectIds)
27+
foreach (var id in NewSolution.ProjectIds)
3128
{
32-
if (!_oldSolution.ContainsProject(id))
29+
if (!OldSolution.ContainsProject(id))
3330
{
34-
yield return _newSolution.GetRequiredProject(id);
31+
yield return NewSolution.GetRequiredProject(id);
3532
}
3633
}
3734
}
3835

3936
public IEnumerable<ProjectChanges> GetProjectChanges()
4037
{
41-
var old = _oldSolution;
38+
var old = OldSolution;
4239

4340
// if the project states are different then there is a change.
44-
foreach (var id in _newSolution.ProjectIds)
41+
foreach (var id in NewSolution.ProjectIds)
4542
{
46-
var newState = _newSolution.GetProjectState(id);
43+
var newState = NewSolution.GetProjectState(id);
4744
var oldState = old.GetProjectState(id);
4845
if (oldState != null && newState != null && newState != oldState)
4946
{
50-
yield return _newSolution.GetRequiredProject(id).GetChanges(_oldSolution.GetRequiredProject(id));
47+
yield return NewSolution.GetRequiredProject(id).GetChanges(OldSolution.GetRequiredProject(id));
5148
}
5249
}
5350
}
5451

5552
public IEnumerable<Project> GetRemovedProjects()
5653
{
57-
foreach (var id in _oldSolution.ProjectIds)
54+
foreach (var id in OldSolution.ProjectIds)
5855
{
59-
if (!_newSolution.ContainsProject(id))
56+
if (!NewSolution.ContainsProject(id))
6057
{
61-
yield return _oldSolution.GetRequiredProject(id);
58+
yield return OldSolution.GetRequiredProject(id);
6259
}
6360
}
6461
}
6562

6663
public IEnumerable<AnalyzerReference> GetAddedAnalyzerReferences()
6764
{
68-
var oldAnalyzerReferences = new HashSet<AnalyzerReference>(_oldSolution.AnalyzerReferences);
69-
foreach (var analyzerReference in _newSolution.AnalyzerReferences)
65+
var oldAnalyzerReferences = new HashSet<AnalyzerReference>(OldSolution.AnalyzerReferences);
66+
foreach (var analyzerReference in NewSolution.AnalyzerReferences)
7067
{
7168
if (!oldAnalyzerReferences.Contains(analyzerReference))
7269
{
@@ -77,8 +74,8 @@ public IEnumerable<AnalyzerReference> GetAddedAnalyzerReferences()
7774

7875
public IEnumerable<AnalyzerReference> GetRemovedAnalyzerReferences()
7976
{
80-
var newAnalyzerReferences = new HashSet<AnalyzerReference>(_newSolution.AnalyzerReferences);
81-
foreach (var analyzerReference in _oldSolution.AnalyzerReferences)
77+
var newAnalyzerReferences = new HashSet<AnalyzerReference>(NewSolution.AnalyzerReferences);
78+
foreach (var analyzerReference in OldSolution.AnalyzerReferences)
8279
{
8380
if (!newAnalyzerReferences.Contains(analyzerReference))
8481
{
@@ -97,18 +94,18 @@ public IEnumerable<AnalyzerReference> GetRemovedAnalyzerReferences()
9794
/// </remarks>
9895
internal IEnumerable<DocumentId> GetExplicitlyChangedSourceGeneratedDocuments()
9996
{
100-
if (_newSolution.CompilationState.FrozenSourceGeneratedDocumentStates.IsEmpty)
97+
if (NewSolution.CompilationState.FrozenSourceGeneratedDocumentStates.IsEmpty)
10198
return [];
10299

103100
using var _ = ArrayBuilder<SourceGeneratedDocumentState>.GetInstance(out var oldStateBuilder);
104-
foreach (var (id, _) in _newSolution.CompilationState.FrozenSourceGeneratedDocumentStates.States)
101+
foreach (var (id, _) in NewSolution.CompilationState.FrozenSourceGeneratedDocumentStates.States)
105102
{
106-
var oldState = _oldSolution.CompilationState.TryGetSourceGeneratedDocumentStateForAlreadyGeneratedId(id);
103+
var oldState = OldSolution.CompilationState.TryGetSourceGeneratedDocumentStateForAlreadyGeneratedId(id);
107104
oldStateBuilder.AddIfNotNull(oldState);
108105
}
109106

110107
var oldStates = new TextDocumentStates<SourceGeneratedDocumentState>(oldStateBuilder);
111-
return _newSolution.CompilationState.FrozenSourceGeneratedDocumentStates.GetChangedStateIds(
108+
return NewSolution.CompilationState.FrozenSourceGeneratedDocumentStates.GetChangedStateIds(
112109
oldStates,
113110
ignoreUnchangedContent: true,
114111
ignoreUnchangeableDocuments: false);

0 commit comments

Comments
 (0)