Skip to content

Commit 9ba6281

Browse files
authored
Merge release/dev17.9 to main (#9640)
This is an automatically generated pull request from release/dev17.9 into main. Once all conflicts are resolved and all the tests pass, you are free to merge the pull request. 🐯 ## Troubleshooting conflicts ### Identify authors of changes which introduced merge conflicts Scroll to the bottom, then for each file containing conflicts copy its path into the following searches: - https://github.com/dotnet/razor/find/release/dev17.9 - https://github.com/dotnet/razor/find/main Usually the most recent change to a file between the two branches is considered to have introduced the conflicts, but sometimes it will be necessary to look for the conflicting lines and check the blame in each branch. Generally the author whose change introduced the conflicts should pull down this PR, fix the conflicts locally, then push up a commit resolving the conflicts. ### Resolve merge conflicts using your local repo Sometimes merge conflicts may be present on GitHub but merging locally will work without conflicts. This is due to differences between the merge algorithm used in local git versus the one used by GitHub. ``` bash git fetch --all git checkout -t upstream/merges/release/dev17.9-to-main git reset --hard upstream/main git merge upstream/release/dev17.9 # Fix merge conflicts git commit git push upstream merges/release/dev17.9-to-main --force ```
2 parents f1a00bb + bad69ab commit 9ba6281

File tree

3 files changed

+65
-6
lines changed

3 files changed

+65
-6
lines changed

azure-pipelines.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,10 @@ stages:
8383
pool:
8484
${{ if eq(variables['System.TeamProject'], 'public') }}:
8585
name: $(DncEngPublicBuildPool)
86-
demands: ImageOverride -equals windows.vs2022preview.scout.amd64.open
86+
demands: ImageOverride -equals windows.vs2022preview.amd64.open
8787
${{ if ne(variables['System.TeamProject'], 'public') }}:
8888
name: $(DncEngInternalBuildPool)
89-
demands: ImageOverride -equals windows.vs2022preview.scout.amd64
89+
demands: ImageOverride -equals windows.vs2022preview.amd64
9090
steps:
9191
- task: NuGetCommand@2
9292
displayName: 'Clear NuGet caches'
@@ -127,10 +127,10 @@ stages:
127127
pool:
128128
${{ if eq(variables['System.TeamProject'], 'public') }}:
129129
name: $(DncEngPublicBuildPool)
130-
demands: ImageOverride -equals windows.vs2022preview.scout.amd64.open
130+
demands: ImageOverride -equals windows.vs2022preview.amd64.open
131131
${{ if ne(variables['System.TeamProject'], 'public') }}:
132132
name: $(DncEngInternalBuildPool)
133-
demands: ImageOverride -equals windows.vs2022preview.scout.amd64
133+
demands: ImageOverride -equals windows.vs2022preview.amd64
134134
strategy:
135135
matrix:
136136
${{ if eq(variables['System.TeamProject'], 'public') }}:

src/Razor/src/Microsoft.VisualStudio.LanguageServerClient.Razor/RazorProjectInfoPublisher.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using System;
55
using System.Collections.Generic;
66
using System.ComponentModel.Composition;
7+
using System.Diagnostics;
78
using System.IO;
89
using System.Linq;
910
using System.Threading.Tasks;
@@ -171,6 +172,19 @@ internal void ProjectSnapshotManager_Changed(object sender, ProjectChangeEventAr
171172
}
172173

173174
break;
175+
case ProjectChangeKind.DocumentChanged:
176+
// DocumentChanged normally isn't a great trigger for publishing, given that it happens while a user types
177+
// but for a brand new project, its possible this DocumentChanged actually represents a DocumentOpen, and
178+
// it could be the first one, so its important to publish if there is no project configuration file present
179+
if (ProjectWorkspacePublishable(args) &&
180+
_projectConfigurationFilePathStore.TryGet(args.ProjectKey, out var configurationFilePath) &&
181+
!FileExists(configurationFilePath))
182+
{
183+
ImmediatePublish(args.Newer!);
184+
}
185+
186+
break;
187+
174188
case ProjectChangeKind.DocumentRemoved:
175189
case ProjectChangeKind.DocumentAdded:
176190

@@ -195,6 +209,10 @@ internal void ProjectSnapshotManager_Changed(object sender, ProjectChangeEventAr
195209
case ProjectChangeKind.ProjectRemoved:
196210
RemovePublishingData(args.Older!);
197211
break;
212+
213+
default:
214+
Debug.Fail("A new ProjectChangeKind has been added that the RazorProjectInfoPublisher doesn't know how to deal with");
215+
break;
198216
}
199217

200218
static bool ProjectWorkspacePublishable(ProjectChangeEventArgs args)

src/Razor/test/Microsoft.VisualStudio.LanguageServerClient.Razor.Test/RazorProjectInfoPublisherTest.cs

Lines changed: 43 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,44 @@ await RunOnDispatcherThreadAsync(() =>
158158
Assert.True(serializationSuccessful);
159159
}
160160

161+
[Fact]
162+
public async Task ProjectManager_Changed_DocumentOpened_InitializedProject_NoFile_Active_Publishes()
163+
{
164+
// Arrange
165+
var serializationSuccessful = false;
166+
var hostProject = new HostProject(@"C:\path\to\project.csproj", @"C:\path\to\obj", RazorConfiguration.Default, rootNamespace: "TestRootNamespace");
167+
var hostDocument = new HostDocument(@"C:\path\to\file.razor", "file.razor");
168+
_projectSnapshotManager.ProjectAdded(hostProject);
169+
_projectSnapshotManager.ProjectWorkspaceStateChanged(hostProject.Key, ProjectWorkspaceState.Default);
170+
_projectSnapshotManager.DocumentAdded(hostProject.Key, hostDocument, new EmptyTextLoader(hostDocument.FilePath));
171+
var projectSnapshot = _projectSnapshotManager.GetProjects()[0];
172+
var expectedConfigurationFilePath = @"C:\path\to\obj\bin\Debug\project.razor.bin";
173+
_projectConfigurationFilePathStore.Set(projectSnapshot.Key, expectedConfigurationFilePath);
174+
var publisher = new TestRazorProjectInfoPublisher(
175+
_projectConfigurationFilePathStore,
176+
onSerializeToFile: (snapshot, configurationFilePath) =>
177+
{
178+
Assert.Equal(expectedConfigurationFilePath, configurationFilePath);
179+
serializationSuccessful = true;
180+
},
181+
configurationFileExists: false)
182+
{
183+
EnqueueDelay = 10,
184+
_active = true
185+
};
186+
publisher.Initialize(_projectSnapshotManager);
187+
188+
// Act
189+
await RunOnDispatcherThreadAsync(() =>
190+
{
191+
_projectSnapshotManager.DocumentOpened(hostProject.Key, hostDocument.FilePath, SourceText.From(string.Empty));
192+
});
193+
194+
// Assert
195+
Assert.Empty(publisher.DeferredPublishTasks);
196+
Assert.True(serializationSuccessful);
197+
}
198+
161199
[Theory]
162200
[InlineData(ProjectChangeKind.DocumentAdded)]
163201
[InlineData(ProjectChangeKind.DocumentRemoved)]
@@ -586,6 +624,7 @@ private class TestRazorProjectInfoPublisher : RazorProjectInfoPublisher
586624

587625
private readonly bool _shouldSerialize;
588626
private readonly bool _useRealShouldSerialize;
627+
private readonly bool _configurationFileExists;
589628

590629
static TestRazorProjectInfoPublisher()
591630
{
@@ -598,17 +637,19 @@ public TestRazorProjectInfoPublisher(
598637
ProjectConfigurationFilePathStore projectStatePublishFilePathStore,
599638
Action<IProjectSnapshot, string> onSerializeToFile = null,
600639
bool shouldSerialize = true,
601-
bool useRealShouldSerialize = false)
640+
bool useRealShouldSerialize = false,
641+
bool configurationFileExists = true)
602642
: base(s_lspEditorFeatureDetector.Object, projectStatePublishFilePathStore, TestRazorLogger.Instance)
603643
{
604644
_onSerializeToFile = onSerializeToFile ?? ((_1, _2) => throw new XunitException("SerializeToFile should not have been called."));
605645
_shouldSerialize = shouldSerialize;
606646
_useRealShouldSerialize = useRealShouldSerialize;
647+
_configurationFileExists = configurationFileExists;
607648
}
608649

609650
protected override bool FileExists(string file)
610651
{
611-
return true;
652+
return _configurationFileExists;
612653
}
613654

614655
protected override void SerializeToFile(IProjectSnapshot projectSnapshot, string configurationFilePath) => _onSerializeToFile?.Invoke(projectSnapshot, configurationFilePath);

0 commit comments

Comments
 (0)