// Internal for testing internal void Publish(ProjectSnapshot projectSnapshot) { if (projectSnapshot is null) { throw new ArgumentNullException(nameof(projectSnapshot)); } lock (_publishLock) { string publishFilePath = null; try { if (!PublishFilePathMappings.TryGetValue(projectSnapshot.FilePath, out publishFilePath)) { return; } SerializeToFile(projectSnapshot, publishFilePath); } catch (Exception ex) { _logger.LogWarning($@"Could not update Razor project configuration file '{publishFilePath}': {ex}"); } } }
// Internal for testing internal void RemovePublishingData(ProjectSnapshot projectSnapshot) { lock (_publishLock) { var oldProjectFilePath = projectSnapshot.FilePath; if (!PublishFilePathMappings.TryGetValue(oldProjectFilePath, out var publishFilePath)) { // If we don't track the value in PublishFilePathMappings that means it's already been removed, do nothing. return; } if (_pendingProjectPublishes.TryGetValue(oldProjectFilePath, out _)) { // Project was removed while a delayed publish was in flight. Clear the in-flight publish so it noops. _pendingProjectPublishes.Remove(oldProjectFilePath); } } }
public override void RemovePublishFilePath(string projectFilePath) { Debug.Assert(_joinableTaskContext.IsOnMainThread, "RemovePublishFilePath should have been on main thread"); PublishFilePathMappings.TryRemove(projectFilePath, out var _); }