From 210ff0973bc8322728658022ea65a4529b17365f Mon Sep 17 00:00:00 2001 From: tmat Date: Thu, 29 Sep 2022 09:22:52 -0700 Subject: [PATCH 1/7] Make all public API in dotnet-watch.dll internal and sealed. dotnet-watch.dll has been intended to be used as a tool, not consumed as a library and expose any extensibility points via public APIs. --- src/BuiltInTools/dotnet-watch/DotNetWatchContext.cs | 2 +- src/BuiltInTools/dotnet-watch/DotNetWatcher.cs | 2 +- src/BuiltInTools/dotnet-watch/FileSet.cs | 2 +- .../dotnet-watch/Filters/BrowserRefreshFilter.cs | 2 +- .../dotnet-watch/Filters/BrowserRefreshServer.cs | 2 +- .../dotnet-watch/Filters/DotNetBuildFilter.cs | 2 +- .../dotnet-watch/Filters/IWatchFilter.cs | 2 +- .../dotnet-watch/Filters/LaunchBrowserFilter.cs | 2 +- .../dotnet-watch/Filters/MSBuildEvaluationFilter.cs | 4 ++-- .../dotnet-watch/Filters/NoRestoreFilter.cs | 2 +- .../dotnet-watch/HotReload/HotReloadEventSource.cs | 2 +- .../dotnet-watch/HotReload/HotReloadProfileReader.cs | 2 +- .../dotnet-watch/HotReload/RudeEditDialog.cs | 2 +- .../dotnet-watch/HotReloadDotNetWatcher.cs | 2 +- src/BuiltInTools/dotnet-watch/IFileSetFactory.cs | 2 +- .../dotnet-watch/Internal/ConsoleReporter.cs | 12 ++++++------ .../dotnet-watch/Internal/ConsoleRequester.cs | 2 +- .../dotnet-watch/Internal/FileSetWatcher.cs | 2 +- .../dotnet-watch/Internal/FileWatcher.cs | 2 +- .../Internal/FileWatcher/FileWatcherFactory.cs | 2 +- .../Internal/FileWatcher/IFileSystemWatcher.cs | 2 +- .../dotnet-watch/Internal/HotReloadFileSetWatcher.cs | 2 +- src/BuiltInTools/dotnet-watch/Internal/IConsole.cs | 2 +- src/BuiltInTools/dotnet-watch/Internal/IReporter.cs | 2 +- src/BuiltInTools/dotnet-watch/Internal/IRequester.cs | 2 +- .../dotnet-watch/Internal/MSBuildFileSetResult.cs | 6 +++--- .../dotnet-watch/Internal/MsBuildFileSetFactory.cs | 2 +- .../dotnet-watch/Internal/NullReporter.cs | 2 +- .../dotnet-watch/Internal/OutputCapture.cs | 2 +- src/BuiltInTools/dotnet-watch/Internal/OutputSink.cs | 2 +- .../dotnet-watch/Internal/PhysicalConsole.cs | 2 +- .../dotnet-watch/Internal/ProcessRunner.cs | 2 +- .../dotnet-watch/LaunchSettingsProfile.cs | 2 +- src/BuiltInTools/dotnet-watch/ProcessSpec.cs | 4 ++-- src/BuiltInTools/dotnet-watch/Program.cs | 2 +- 35 files changed, 44 insertions(+), 44 deletions(-) diff --git a/src/BuiltInTools/dotnet-watch/DotNetWatchContext.cs b/src/BuiltInTools/dotnet-watch/DotNetWatchContext.cs index fda0e2449121..2ffd92345ac5 100644 --- a/src/BuiltInTools/dotnet-watch/DotNetWatchContext.cs +++ b/src/BuiltInTools/dotnet-watch/DotNetWatchContext.cs @@ -8,7 +8,7 @@ namespace Microsoft.DotNet.Watcher.Tools { - public class DotNetWatchContext + internal sealed class DotNetWatchContext { public IReporter Reporter { get; init; } = NullReporter.Singleton; diff --git a/src/BuiltInTools/dotnet-watch/DotNetWatcher.cs b/src/BuiltInTools/dotnet-watch/DotNetWatcher.cs index 2d464d8aa893..7a04f379004b 100644 --- a/src/BuiltInTools/dotnet-watch/DotNetWatcher.cs +++ b/src/BuiltInTools/dotnet-watch/DotNetWatcher.cs @@ -14,7 +14,7 @@ namespace Microsoft.DotNet.Watcher { - public class DotNetWatcher : IAsyncDisposable + internal sealed class DotNetWatcher : IAsyncDisposable { private readonly IReporter _reporter; private readonly ProcessRunner _processRunner; diff --git a/src/BuiltInTools/dotnet-watch/FileSet.cs b/src/BuiltInTools/dotnet-watch/FileSet.cs index 469792e6cafd..23ed80e70ded 100644 --- a/src/BuiltInTools/dotnet-watch/FileSet.cs +++ b/src/BuiltInTools/dotnet-watch/FileSet.cs @@ -7,7 +7,7 @@ namespace Microsoft.DotNet.Watcher { - public class FileSet : IEnumerable + internal sealed class FileSet : IEnumerable { private readonly Dictionary _files; diff --git a/src/BuiltInTools/dotnet-watch/Filters/BrowserRefreshFilter.cs b/src/BuiltInTools/dotnet-watch/Filters/BrowserRefreshFilter.cs index 66241cbfc0cc..625351aabc7b 100644 --- a/src/BuiltInTools/dotnet-watch/Filters/BrowserRefreshFilter.cs +++ b/src/BuiltInTools/dotnet-watch/Filters/BrowserRefreshFilter.cs @@ -13,7 +13,7 @@ namespace Microsoft.DotNet.Watcher.Tools { - public sealed class BrowserRefreshFilter : IWatchFilter, IAsyncDisposable + internal sealed class BrowserRefreshFilter : IWatchFilter, IAsyncDisposable { private readonly bool _suppressBrowserRefresh; private readonly IReporter _reporter; diff --git a/src/BuiltInTools/dotnet-watch/Filters/BrowserRefreshServer.cs b/src/BuiltInTools/dotnet-watch/Filters/BrowserRefreshServer.cs index 16aac65a340d..55ccf664888b 100644 --- a/src/BuiltInTools/dotnet-watch/Filters/BrowserRefreshServer.cs +++ b/src/BuiltInTools/dotnet-watch/Filters/BrowserRefreshServer.cs @@ -24,7 +24,7 @@ namespace Microsoft.DotNet.Watcher.Tools { - public class BrowserRefreshServer : IAsyncDisposable + internal sealed class BrowserRefreshServer : IAsyncDisposable { private readonly byte[] ReloadMessage = Encoding.UTF8.GetBytes("Reload"); private readonly byte[] WaitMessage = Encoding.UTF8.GetBytes("Wait"); diff --git a/src/BuiltInTools/dotnet-watch/Filters/DotNetBuildFilter.cs b/src/BuiltInTools/dotnet-watch/Filters/DotNetBuildFilter.cs index ce02d25e8bdc..695e1043f561 100644 --- a/src/BuiltInTools/dotnet-watch/Filters/DotNetBuildFilter.cs +++ b/src/BuiltInTools/dotnet-watch/Filters/DotNetBuildFilter.cs @@ -10,7 +10,7 @@ namespace Microsoft.DotNet.Watcher.Tools { - public class DotNetBuildFilter : IWatchFilter + internal sealed class DotNetBuildFilter : IWatchFilter { private readonly IFileSetFactory _fileSetFactory; private readonly ProcessRunner _processRunner; diff --git a/src/BuiltInTools/dotnet-watch/Filters/IWatchFilter.cs b/src/BuiltInTools/dotnet-watch/Filters/IWatchFilter.cs index 1dcfa3939238..442bf91ae944 100644 --- a/src/BuiltInTools/dotnet-watch/Filters/IWatchFilter.cs +++ b/src/BuiltInTools/dotnet-watch/Filters/IWatchFilter.cs @@ -6,7 +6,7 @@ namespace Microsoft.DotNet.Watcher.Tools { - public interface IWatchFilter + internal interface IWatchFilter { ValueTask ProcessAsync(DotNetWatchContext context, CancellationToken cancellationToken); } diff --git a/src/BuiltInTools/dotnet-watch/Filters/LaunchBrowserFilter.cs b/src/BuiltInTools/dotnet-watch/Filters/LaunchBrowserFilter.cs index e4a7949c1504..4886ce17e33e 100644 --- a/src/BuiltInTools/dotnet-watch/Filters/LaunchBrowserFilter.cs +++ b/src/BuiltInTools/dotnet-watch/Filters/LaunchBrowserFilter.cs @@ -11,7 +11,7 @@ namespace Microsoft.DotNet.Watcher.Tools { - public sealed class LaunchBrowserFilter : IWatchFilter, IAsyncDisposable + internal sealed class LaunchBrowserFilter : IWatchFilter, IAsyncDisposable { private static readonly Regex NowListeningRegex = new Regex(@"Now listening on: (?.*)\s*$", RegexOptions.None | RegexOptions.Compiled, TimeSpan.FromSeconds(10)); private readonly bool _runningInTest; diff --git a/src/BuiltInTools/dotnet-watch/Filters/MSBuildEvaluationFilter.cs b/src/BuiltInTools/dotnet-watch/Filters/MSBuildEvaluationFilter.cs index d46e7c0a6e66..b6f4bdea7a23 100644 --- a/src/BuiltInTools/dotnet-watch/Filters/MSBuildEvaluationFilter.cs +++ b/src/BuiltInTools/dotnet-watch/Filters/MSBuildEvaluationFilter.cs @@ -10,7 +10,7 @@ namespace Microsoft.DotNet.Watcher.Tools { - public class MSBuildEvaluationFilter : IWatchFilter + internal sealed class MSBuildEvaluationFilter : IWatchFilter { // File types that require an MSBuild re-evaluation private static readonly string[] _msBuildFileExtensions = new[] @@ -94,7 +94,7 @@ private bool RequiresMSBuildRevaluation(DotNetWatchContext context) return msbuildFiles; } - protected virtual DateTime GetLastWriteTimeUtcSafely(string file) + private DateTime GetLastWriteTimeUtcSafely(string file) { try { diff --git a/src/BuiltInTools/dotnet-watch/Filters/NoRestoreFilter.cs b/src/BuiltInTools/dotnet-watch/Filters/NoRestoreFilter.cs index c33a117bcd9a..413b2c24a3c5 100644 --- a/src/BuiltInTools/dotnet-watch/Filters/NoRestoreFilter.cs +++ b/src/BuiltInTools/dotnet-watch/Filters/NoRestoreFilter.cs @@ -10,7 +10,7 @@ namespace Microsoft.DotNet.Watcher.Tools { - public sealed class NoRestoreFilter : IWatchFilter + internal sealed class NoRestoreFilter : IWatchFilter { private bool _canUseNoRestore; private string[] _noRestoreArguments; diff --git a/src/BuiltInTools/dotnet-watch/HotReload/HotReloadEventSource.cs b/src/BuiltInTools/dotnet-watch/HotReload/HotReloadEventSource.cs index 8175dbd67a85..e73810290fc9 100644 --- a/src/BuiltInTools/dotnet-watch/HotReload/HotReloadEventSource.cs +++ b/src/BuiltInTools/dotnet-watch/HotReload/HotReloadEventSource.cs @@ -18,7 +18,7 @@ public enum StartType ScopedCssHandler } - public class Keywords + internal sealed class Keywords { public const EventKeywords Perf = (EventKeywords)1; } diff --git a/src/BuiltInTools/dotnet-watch/HotReload/HotReloadProfileReader.cs b/src/BuiltInTools/dotnet-watch/HotReload/HotReloadProfileReader.cs index 10a4469299ca..63146bf4747f 100644 --- a/src/BuiltInTools/dotnet-watch/HotReload/HotReloadProfileReader.cs +++ b/src/BuiltInTools/dotnet-watch/HotReload/HotReloadProfileReader.cs @@ -10,7 +10,7 @@ namespace Microsoft.DotNet.Watcher.Tools { - public static class HotReloadProfileReader + internal static class HotReloadProfileReader { public static HotReloadProfile InferHotReloadProfile(ProjectGraph projectGraph, IReporter reporter) { diff --git a/src/BuiltInTools/dotnet-watch/HotReload/RudeEditDialog.cs b/src/BuiltInTools/dotnet-watch/HotReload/RudeEditDialog.cs index 02a572288265..c7888dd31478 100644 --- a/src/BuiltInTools/dotnet-watch/HotReload/RudeEditDialog.cs +++ b/src/BuiltInTools/dotnet-watch/HotReload/RudeEditDialog.cs @@ -8,7 +8,7 @@ namespace Microsoft.DotNet.Watcher.Tools { - public class RudeEditDialog + internal sealed class RudeEditDialog { private readonly IReporter _reporter; private readonly IRequester _requester; diff --git a/src/BuiltInTools/dotnet-watch/HotReloadDotNetWatcher.cs b/src/BuiltInTools/dotnet-watch/HotReloadDotNetWatcher.cs index f2cf300fafbd..1b57cb5c9b47 100644 --- a/src/BuiltInTools/dotnet-watch/HotReloadDotNetWatcher.cs +++ b/src/BuiltInTools/dotnet-watch/HotReloadDotNetWatcher.cs @@ -19,7 +19,7 @@ namespace Microsoft.DotNet.Watcher { - public class HotReloadDotNetWatcher : IAsyncDisposable + internal sealed class HotReloadDotNetWatcher : IAsyncDisposable { private readonly IReporter _reporter; private readonly IConsole _console; diff --git a/src/BuiltInTools/dotnet-watch/IFileSetFactory.cs b/src/BuiltInTools/dotnet-watch/IFileSetFactory.cs index 1cad758ec2b3..b2e05cb43450 100644 --- a/src/BuiltInTools/dotnet-watch/IFileSetFactory.cs +++ b/src/BuiltInTools/dotnet-watch/IFileSetFactory.cs @@ -6,7 +6,7 @@ namespace Microsoft.DotNet.Watcher { - public interface IFileSetFactory + internal interface IFileSetFactory { Task CreateAsync(CancellationToken cancellationToken); } diff --git a/src/BuiltInTools/dotnet-watch/Internal/ConsoleReporter.cs b/src/BuiltInTools/dotnet-watch/Internal/ConsoleReporter.cs index 61576dba9154..e85b2954767f 100644 --- a/src/BuiltInTools/dotnet-watch/Internal/ConsoleReporter.cs +++ b/src/BuiltInTools/dotnet-watch/Internal/ConsoleReporter.cs @@ -13,7 +13,7 @@ namespace Microsoft.Extensions.Tools.Internal /// This API supports infrastructure and is not intended to be used /// directly from your code. This API may change or be removed in future releases. /// - public class ConsoleReporter : IReporter + internal sealed class ConsoleReporter : IReporter { private readonly object _writeLock = new object(); @@ -31,7 +31,7 @@ public ConsoleReporter(IConsole console, bool verbose, bool quiet, bool suppress SuppressEmojis = suppressEmojis; } - protected IConsole Console { get; } + private IConsole Console { get; } public bool IsVerbose { get; set; } public bool IsQuiet { get; set; } public bool SuppressEmojis { get; set; } @@ -58,17 +58,17 @@ private void WriteLine(TextWriter writer, string message, ConsoleColor? color, s } } - public virtual void Error(string message, string emoji = "❌") + public void Error(string message, string emoji = "❌") { WriteLine(Console.Error, message, ConsoleColor.Red, emoji); } - public virtual void Warn(string message, string emoji = "⌚") + public void Warn(string message, string emoji = "⌚") { WriteLine(Console.Out, message, ConsoleColor.Yellow, emoji); } - public virtual void Output(string message, string emoji = "⌚") + public void Output(string message, string emoji = "⌚") { if (IsQuiet) { @@ -78,7 +78,7 @@ public virtual void Output(string message, string emoji = "⌚") WriteLine(Console.Out, message, color: null, emoji); } - public virtual void Verbose(string message, string emoji = "⌚") + public void Verbose(string message, string emoji = "⌚") { if (!IsVerbose) { diff --git a/src/BuiltInTools/dotnet-watch/Internal/ConsoleRequester.cs b/src/BuiltInTools/dotnet-watch/Internal/ConsoleRequester.cs index b5c41a04ca07..9dc197fbdd83 100644 --- a/src/BuiltInTools/dotnet-watch/Internal/ConsoleRequester.cs +++ b/src/BuiltInTools/dotnet-watch/Internal/ConsoleRequester.cs @@ -13,7 +13,7 @@ namespace Microsoft.Extensions.Tools.Internal /// This API supports infrastructure and is not intended to be used /// directly from your code. This API may change or be removed in future releases. /// - public class ConsoleRequester : IRequester + internal sealed class ConsoleRequester : IRequester { private readonly object _writeLock = new object(); diff --git a/src/BuiltInTools/dotnet-watch/Internal/FileSetWatcher.cs b/src/BuiltInTools/dotnet-watch/Internal/FileSetWatcher.cs index 8e1a0994cf33..de145b778a72 100644 --- a/src/BuiltInTools/dotnet-watch/Internal/FileSetWatcher.cs +++ b/src/BuiltInTools/dotnet-watch/Internal/FileSetWatcher.cs @@ -9,7 +9,7 @@ namespace Microsoft.DotNet.Watcher.Internal { - public class FileSetWatcher : IDisposable + internal sealed class FileSetWatcher : IDisposable { private readonly FileWatcher _fileWatcher; private readonly FileSet _fileSet; diff --git a/src/BuiltInTools/dotnet-watch/Internal/FileWatcher.cs b/src/BuiltInTools/dotnet-watch/Internal/FileWatcher.cs index c94dfc63a23a..e782977b11e4 100644 --- a/src/BuiltInTools/dotnet-watch/Internal/FileWatcher.cs +++ b/src/BuiltInTools/dotnet-watch/Internal/FileWatcher.cs @@ -9,7 +9,7 @@ namespace Microsoft.DotNet.Watcher.Internal { - public class FileWatcher + internal sealed class FileWatcher { private bool _disposed; diff --git a/src/BuiltInTools/dotnet-watch/Internal/FileWatcher/FileWatcherFactory.cs b/src/BuiltInTools/dotnet-watch/Internal/FileWatcher/FileWatcherFactory.cs index 9c91176ec123..03a76fdcfe32 100644 --- a/src/BuiltInTools/dotnet-watch/Internal/FileWatcher/FileWatcherFactory.cs +++ b/src/BuiltInTools/dotnet-watch/Internal/FileWatcher/FileWatcherFactory.cs @@ -5,7 +5,7 @@ namespace Microsoft.DotNet.Watcher.Internal { - public static class FileWatcherFactory + internal static class FileWatcherFactory { public static IFileSystemWatcher CreateWatcher(string watchedDirectory) => CreateWatcher(watchedDirectory, CommandLineOptions.IsPollingEnabled); diff --git a/src/BuiltInTools/dotnet-watch/Internal/FileWatcher/IFileSystemWatcher.cs b/src/BuiltInTools/dotnet-watch/Internal/FileWatcher/IFileSystemWatcher.cs index bfdca7f59026..ec043fe36906 100644 --- a/src/BuiltInTools/dotnet-watch/Internal/FileWatcher/IFileSystemWatcher.cs +++ b/src/BuiltInTools/dotnet-watch/Internal/FileWatcher/IFileSystemWatcher.cs @@ -5,7 +5,7 @@ namespace Microsoft.DotNet.Watcher.Internal { - public interface IFileSystemWatcher : IDisposable + internal interface IFileSystemWatcher : IDisposable { event EventHandler<(string filePath, bool newFile)> OnFileChange; diff --git a/src/BuiltInTools/dotnet-watch/Internal/HotReloadFileSetWatcher.cs b/src/BuiltInTools/dotnet-watch/Internal/HotReloadFileSetWatcher.cs index dd85976559c3..8f4cfc23d20b 100644 --- a/src/BuiltInTools/dotnet-watch/Internal/HotReloadFileSetWatcher.cs +++ b/src/BuiltInTools/dotnet-watch/Internal/HotReloadFileSetWatcher.cs @@ -14,7 +14,7 @@ namespace Microsoft.DotNet.Watcher.Internal { - public class HotReloadFileSetWatcher : IDisposable + internal sealed class HotReloadFileSetWatcher : IDisposable { private static readonly TimeSpan DebounceInterval = TimeSpan.FromMilliseconds(50); private readonly FileWatcher _fileWatcher; diff --git a/src/BuiltInTools/dotnet-watch/Internal/IConsole.cs b/src/BuiltInTools/dotnet-watch/Internal/IConsole.cs index 7b8d9e35a43e..329952dd76e2 100644 --- a/src/BuiltInTools/dotnet-watch/Internal/IConsole.cs +++ b/src/BuiltInTools/dotnet-watch/Internal/IConsole.cs @@ -10,7 +10,7 @@ namespace Microsoft.Extensions.Tools.Internal /// This API supports infrastructure and is not intended to be used /// directly from your code. This API may change or be removed in future releases. /// - public interface IConsole + internal interface IConsole { event ConsoleCancelEventHandler CancelKeyPress; event Action KeyPressed; diff --git a/src/BuiltInTools/dotnet-watch/Internal/IReporter.cs b/src/BuiltInTools/dotnet-watch/Internal/IReporter.cs index 027561059b47..5b55c6f4df20 100644 --- a/src/BuiltInTools/dotnet-watch/Internal/IReporter.cs +++ b/src/BuiltInTools/dotnet-watch/Internal/IReporter.cs @@ -7,7 +7,7 @@ namespace Microsoft.Extensions.Tools.Internal /// This API supports infrastructure and is not intended to be used /// directly from your code. This API may change or be removed in future releases. /// - public interface IReporter + internal interface IReporter { public bool IsVerbose => false; void Verbose(string message, string emoji = "⌚"); diff --git a/src/BuiltInTools/dotnet-watch/Internal/IRequester.cs b/src/BuiltInTools/dotnet-watch/Internal/IRequester.cs index 94cd4044a7b2..8a82f115356b 100644 --- a/src/BuiltInTools/dotnet-watch/Internal/IRequester.cs +++ b/src/BuiltInTools/dotnet-watch/Internal/IRequester.cs @@ -10,7 +10,7 @@ namespace Microsoft.Extensions.Tools.Internal /// This API supports infrastructure and is not intended to be used /// directly from your code. This API may change or be removed in future releases. /// - public interface IRequester + internal interface IRequester { Task GetKeyAsync(string prompt, Func validateInput, CancellationToken cancellationToken); } diff --git a/src/BuiltInTools/dotnet-watch/Internal/MSBuildFileSetResult.cs b/src/BuiltInTools/dotnet-watch/Internal/MSBuildFileSetResult.cs index 4831286f7d4e..16c91b4c5c23 100644 --- a/src/BuiltInTools/dotnet-watch/Internal/MSBuildFileSetResult.cs +++ b/src/BuiltInTools/dotnet-watch/Internal/MSBuildFileSetResult.cs @@ -6,7 +6,7 @@ namespace Microsoft.DotNet.Watcher.Internal { - public class MSBuildFileSetResult + internal sealed class MSBuildFileSetResult { public string RunCommand { get; set; } @@ -25,14 +25,14 @@ public class MSBuildFileSetResult public Dictionary Projects { get; set; } } - public class ProjectItems + internal sealed class ProjectItems { public List Files { get; set; } = new(); public List StaticFiles { get; set; } = new(); } - public class StaticFileItem + internal sealed class StaticFileItem { public string FilePath { get; set; } diff --git a/src/BuiltInTools/dotnet-watch/Internal/MsBuildFileSetFactory.cs b/src/BuiltInTools/dotnet-watch/Internal/MsBuildFileSetFactory.cs index 5b46f9b0b652..2780ea0ef0b5 100644 --- a/src/BuiltInTools/dotnet-watch/Internal/MsBuildFileSetFactory.cs +++ b/src/BuiltInTools/dotnet-watch/Internal/MsBuildFileSetFactory.cs @@ -16,7 +16,7 @@ namespace Microsoft.DotNet.Watcher.Internal { - public class MsBuildFileSetFactory : IFileSetFactory + internal sealed class MsBuildFileSetFactory : IFileSetFactory { private const string TargetName = "GenerateWatchList"; private const string WatchTargetsFileName = "DotNetWatch.targets"; diff --git a/src/BuiltInTools/dotnet-watch/Internal/NullReporter.cs b/src/BuiltInTools/dotnet-watch/Internal/NullReporter.cs index bbc5cb000c6b..5bd2b0c59db8 100644 --- a/src/BuiltInTools/dotnet-watch/Internal/NullReporter.cs +++ b/src/BuiltInTools/dotnet-watch/Internal/NullReporter.cs @@ -7,7 +7,7 @@ namespace Microsoft.Extensions.Tools.Internal /// This API supports infrastructure and is not intended to be used /// directly from your code. This API may change or be removed in future releases. /// - public class NullReporter : IReporter + internal sealed class NullReporter : IReporter { private NullReporter() { } diff --git a/src/BuiltInTools/dotnet-watch/Internal/OutputCapture.cs b/src/BuiltInTools/dotnet-watch/Internal/OutputCapture.cs index 08e051f732c0..426a1951278e 100644 --- a/src/BuiltInTools/dotnet-watch/Internal/OutputCapture.cs +++ b/src/BuiltInTools/dotnet-watch/Internal/OutputCapture.cs @@ -5,7 +5,7 @@ namespace Microsoft.DotNet.Watcher.Internal { - public class OutputCapture + internal sealed class OutputCapture { private readonly List _lines = new List(); public IEnumerable Lines => _lines; diff --git a/src/BuiltInTools/dotnet-watch/Internal/OutputSink.cs b/src/BuiltInTools/dotnet-watch/Internal/OutputSink.cs index eb176564eff9..d48a96ed1b11 100644 --- a/src/BuiltInTools/dotnet-watch/Internal/OutputSink.cs +++ b/src/BuiltInTools/dotnet-watch/Internal/OutputSink.cs @@ -3,7 +3,7 @@ namespace Microsoft.DotNet.Watcher.Internal { - public class OutputSink + internal sealed class OutputSink { public OutputCapture Current { get; private set; } public OutputCapture StartCapture() diff --git a/src/BuiltInTools/dotnet-watch/Internal/PhysicalConsole.cs b/src/BuiltInTools/dotnet-watch/Internal/PhysicalConsole.cs index 8ea2026e9bfc..81ecf11717f5 100644 --- a/src/BuiltInTools/dotnet-watch/Internal/PhysicalConsole.cs +++ b/src/BuiltInTools/dotnet-watch/Internal/PhysicalConsole.cs @@ -13,7 +13,7 @@ namespace Microsoft.Extensions.Tools.Internal /// This API supports infrastructure and is not intended to be used /// directly from your code. This API may change or be removed in future releases. /// - public class PhysicalConsole : IConsole + internal sealed class PhysicalConsole : IConsole { private readonly List> _keyPressedListeners = new(); diff --git a/src/BuiltInTools/dotnet-watch/Internal/ProcessRunner.cs b/src/BuiltInTools/dotnet-watch/Internal/ProcessRunner.cs index 1c5e9e7ff40d..80dcd15cfb4c 100644 --- a/src/BuiltInTools/dotnet-watch/Internal/ProcessRunner.cs +++ b/src/BuiltInTools/dotnet-watch/Internal/ProcessRunner.cs @@ -14,7 +14,7 @@ namespace Microsoft.DotNet.Watcher.Internal { - public class ProcessRunner + internal sealed class ProcessRunner { private static readonly Func _getEnvironmentVariable = static key => Environment.GetEnvironmentVariable(key); diff --git a/src/BuiltInTools/dotnet-watch/LaunchSettingsProfile.cs b/src/BuiltInTools/dotnet-watch/LaunchSettingsProfile.cs index 3bcec9495a23..d4217e61a028 100644 --- a/src/BuiltInTools/dotnet-watch/LaunchSettingsProfile.cs +++ b/src/BuiltInTools/dotnet-watch/LaunchSettingsProfile.cs @@ -12,7 +12,7 @@ namespace Microsoft.DotNet.Watcher.Tools { - public class LaunchSettingsProfile + internal sealed class LaunchSettingsProfile { public string? ApplicationUrl { get; set; } diff --git a/src/BuiltInTools/dotnet-watch/ProcessSpec.cs b/src/BuiltInTools/dotnet-watch/ProcessSpec.cs index 83cbbaddafc7..68f6b2e1e740 100644 --- a/src/BuiltInTools/dotnet-watch/ProcessSpec.cs +++ b/src/BuiltInTools/dotnet-watch/ProcessSpec.cs @@ -9,7 +9,7 @@ namespace Microsoft.DotNet.Watcher { - public class ProcessSpec + internal sealed class ProcessSpec { public string Executable { get; set; } public string WorkingDirectory { get; set; } @@ -28,7 +28,7 @@ public string ShortDisplayName() public CancellationToken CancelOutputCapture { get; set; } - public sealed class ProcessSpecEnvironmentVariables : Dictionary + internal sealed class ProcessSpecEnvironmentVariables : Dictionary { public List DotNetStartupHooks { get; } = new(); public List AspNetCoreHostingStartupAssemblies { get; } = new(); diff --git a/src/BuiltInTools/dotnet-watch/Program.cs b/src/BuiltInTools/dotnet-watch/Program.cs index 21219eb2388e..7e0cc0819167 100644 --- a/src/BuiltInTools/dotnet-watch/Program.cs +++ b/src/BuiltInTools/dotnet-watch/Program.cs @@ -23,7 +23,7 @@ namespace Microsoft.DotNet.Watcher { - public class Program : IDisposable + internal sealed class Program : IDisposable { private const string Description = @" Environment variables: From 359dd5866b05a2d7242a93fca8f508413f0e038c Mon Sep 17 00:00:00 2001 From: tmat Date: Thu, 29 Sep 2022 09:28:01 -0700 Subject: [PATCH 2/7] enums and records --- src/BuiltInTools/dotnet-watch/DotNetWatchOptions.cs | 2 +- src/BuiltInTools/dotnet-watch/FileItem.cs | 2 +- .../dotnet-watch/HotReload/BlazorWebAssemblyDeltaApplier.cs | 2 +- .../dotnet-watch/HotReload/DefaultDeltaApplier.cs | 4 ++-- .../dotnet-watch/HotReload/HotReloadEventSource.cs | 5 ++--- src/BuiltInTools/dotnet-watch/HotReload/HotReloadProfile.cs | 2 +- src/BuiltInTools/dotnet-watch/ProjectInfo.cs | 2 +- 7 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/BuiltInTools/dotnet-watch/DotNetWatchOptions.cs b/src/BuiltInTools/dotnet-watch/DotNetWatchOptions.cs index 4ced6b44ec06..3aeac9b8f58a 100644 --- a/src/BuiltInTools/dotnet-watch/DotNetWatchOptions.cs +++ b/src/BuiltInTools/dotnet-watch/DotNetWatchOptions.cs @@ -5,7 +5,7 @@ namespace Microsoft.DotNet.Watcher { - public record DotNetWatchOptions( + internal sealed record DotNetWatchOptions( bool SuppressHandlingStaticContentFiles, bool SuppressMSBuildIncrementalism, bool SuppressLaunchBrowser, diff --git a/src/BuiltInTools/dotnet-watch/FileItem.cs b/src/BuiltInTools/dotnet-watch/FileItem.cs index 55d162234506..ad45d163a486 100644 --- a/src/BuiltInTools/dotnet-watch/FileItem.cs +++ b/src/BuiltInTools/dotnet-watch/FileItem.cs @@ -3,7 +3,7 @@ namespace Microsoft.DotNet.Watcher { - public readonly struct FileItem + internal readonly struct FileItem { public string FilePath { get; init; } diff --git a/src/BuiltInTools/dotnet-watch/HotReload/BlazorWebAssemblyDeltaApplier.cs b/src/BuiltInTools/dotnet-watch/HotReload/BlazorWebAssemblyDeltaApplier.cs index 1727442ab28a..6a3aea759e2e 100644 --- a/src/BuiltInTools/dotnet-watch/HotReload/BlazorWebAssemblyDeltaApplier.cs +++ b/src/BuiltInTools/dotnet-watch/HotReload/BlazorWebAssemblyDeltaApplier.cs @@ -158,7 +158,7 @@ private readonly struct UpdateDelta public int[] UpdatedTypes { get; init; } } - public readonly struct HotReloadDiagnostics + private readonly struct HotReloadDiagnostics { public string Type => "HotReloadDiagnosticsv1"; diff --git a/src/BuiltInTools/dotnet-watch/HotReload/DefaultDeltaApplier.cs b/src/BuiltInTools/dotnet-watch/HotReload/DefaultDeltaApplier.cs index 9637b4248ed8..f463f9840ebf 100644 --- a/src/BuiltInTools/dotnet-watch/HotReload/DefaultDeltaApplier.cs +++ b/src/BuiltInTools/dotnet-watch/HotReload/DefaultDeltaApplier.cs @@ -141,14 +141,14 @@ public void Dispose() _pipe?.Dispose(); } - public readonly struct HotReloadDiagnostics + private readonly struct HotReloadDiagnostics { public string Type => "HotReloadDiagnosticsv1"; public IEnumerable Diagnostics { get; init; } } - public readonly struct AspNetCoreHotReloadApplied + private readonly struct AspNetCoreHotReloadApplied { public string Type => "AspNetCoreHotReloadApplied"; } diff --git a/src/BuiltInTools/dotnet-watch/HotReload/HotReloadEventSource.cs b/src/BuiltInTools/dotnet-watch/HotReload/HotReloadEventSource.cs index e73810290fc9..b57b75578256 100644 --- a/src/BuiltInTools/dotnet-watch/HotReload/HotReloadEventSource.cs +++ b/src/BuiltInTools/dotnet-watch/HotReload/HotReloadEventSource.cs @@ -7,9 +7,8 @@ namespace Microsoft.DotNet.Watcher.Tools { [EventSource(Name = "HotReload")] - class HotReloadEventSource : EventSource + internal sealed class HotReloadEventSource : EventSource { - public enum StartType { Main, @@ -31,4 +30,4 @@ internal sealed class Keywords public static readonly HotReloadEventSource Log = new HotReloadEventSource(); } -} \ No newline at end of file +} diff --git a/src/BuiltInTools/dotnet-watch/HotReload/HotReloadProfile.cs b/src/BuiltInTools/dotnet-watch/HotReload/HotReloadProfile.cs index 01b64bc3a580..974fd950f5e1 100644 --- a/src/BuiltInTools/dotnet-watch/HotReload/HotReloadProfile.cs +++ b/src/BuiltInTools/dotnet-watch/HotReload/HotReloadProfile.cs @@ -3,7 +3,7 @@ namespace Microsoft.DotNet.Watcher.Tools { - public enum HotReloadProfile + internal enum HotReloadProfile { Default, diff --git a/src/BuiltInTools/dotnet-watch/ProjectInfo.cs b/src/BuiltInTools/dotnet-watch/ProjectInfo.cs index 45e0e8628365..52480966b21a 100644 --- a/src/BuiltInTools/dotnet-watch/ProjectInfo.cs +++ b/src/BuiltInTools/dotnet-watch/ProjectInfo.cs @@ -7,7 +7,7 @@ namespace Microsoft.DotNet.Watcher { - public record ProjectInfo + internal sealed record ProjectInfo ( string ProjectPath, bool IsNetCoreApp, From 982a0f29434606ef01785739d8eb7f838045aeee Mon Sep 17 00:00:00 2001 From: tmat Date: Thu, 29 Sep 2022 10:00:12 -0700 Subject: [PATCH 3/7] Fixes --- .../dotnet-watch/Filters/MSBuildEvaluationFilter.cs | 4 ++-- src/Tests/dotnet-watch.Tests/MSBuildEvaluationFilterTest.cs | 4 ++-- src/Tests/dotnet-watch.Tests/Utilities/AssertEx.cs | 2 +- .../Nuget/.template.config/localize/templatestrings.cs.json | 2 +- .../Nuget/.template.config/localize/templatestrings.de.json | 2 +- .../Nuget/.template.config/localize/templatestrings.es.json | 2 +- .../Nuget/.template.config/localize/templatestrings.fr.json | 2 +- .../Nuget/.template.config/localize/templatestrings.it.json | 2 +- .../Nuget/.template.config/localize/templatestrings.ja.json | 2 +- .../Nuget/.template.config/localize/templatestrings.ko.json | 2 +- .../Nuget/.template.config/localize/templatestrings.pl.json | 2 +- .../.template.config/localize/templatestrings.pt-BR.json | 2 +- .../Nuget/.template.config/localize/templatestrings.ru.json | 2 +- .../Nuget/.template.config/localize/templatestrings.tr.json | 2 +- .../.template.config/localize/templatestrings.zh-Hans.json | 2 +- .../.template.config/localize/templatestrings.zh-Hant.json | 2 +- 16 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/BuiltInTools/dotnet-watch/Filters/MSBuildEvaluationFilter.cs b/src/BuiltInTools/dotnet-watch/Filters/MSBuildEvaluationFilter.cs index b6f4bdea7a23..a711e2518fdc 100644 --- a/src/BuiltInTools/dotnet-watch/Filters/MSBuildEvaluationFilter.cs +++ b/src/BuiltInTools/dotnet-watch/Filters/MSBuildEvaluationFilter.cs @@ -10,7 +10,7 @@ namespace Microsoft.DotNet.Watcher.Tools { - internal sealed class MSBuildEvaluationFilter : IWatchFilter + internal class MSBuildEvaluationFilter : IWatchFilter { // File types that require an MSBuild re-evaluation private static readonly string[] _msBuildFileExtensions = new[] @@ -94,7 +94,7 @@ private bool RequiresMSBuildRevaluation(DotNetWatchContext context) return msbuildFiles; } - private DateTime GetLastWriteTimeUtcSafely(string file) + private protected virtual DateTime GetLastWriteTimeUtcSafely(string file) { try { diff --git a/src/Tests/dotnet-watch.Tests/MSBuildEvaluationFilterTest.cs b/src/Tests/dotnet-watch.Tests/MSBuildEvaluationFilterTest.cs index 57a96d19ad7e..656d827593be 100644 --- a/src/Tests/dotnet-watch.Tests/MSBuildEvaluationFilterTest.cs +++ b/src/Tests/dotnet-watch.Tests/MSBuildEvaluationFilterTest.cs @@ -123,7 +123,7 @@ public async Task ProcessAsync_SetsEvaluationRequired_IfMSBuildFileChanges_ButIs Assert.True(context.RequiresMSBuildRevaluation); } - public class TestableMSBuildEvaluationFilter : MSBuildEvaluationFilter + private class TestableMSBuildEvaluationFilter : MSBuildEvaluationFilter { public TestableMSBuildEvaluationFilter(IFileSetFactory factory) : base(factory) @@ -132,7 +132,7 @@ public TestableMSBuildEvaluationFilter(IFileSetFactory factory) public Dictionary Timestamps { get; } = new Dictionary(); - protected override DateTime GetLastWriteTimeUtcSafely(string file) => Timestamps[file]; + private protected override DateTime GetLastWriteTimeUtcSafely(string file) => Timestamps[file]; } } } diff --git a/src/Tests/dotnet-watch.Tests/Utilities/AssertEx.cs b/src/Tests/dotnet-watch.Tests/Utilities/AssertEx.cs index 2f778d29c208..de0f6c6c9c90 100644 --- a/src/Tests/dotnet-watch.Tests/Utilities/AssertEx.cs +++ b/src/Tests/dotnet-watch.Tests/Utilities/AssertEx.cs @@ -8,7 +8,7 @@ namespace Microsoft.DotNet.Watcher.Tools { - public static class AssertEx + internal static class AssertEx { public static void EqualFileList(string root, IEnumerable expectedFiles, FileSet actualFiles) => EqualFileList(root, expectedFiles, actualFiles.Select(f => f.FilePath)); diff --git a/template_feed/Microsoft.DotNet.Common.ItemTemplates/content/Nuget/.template.config/localize/templatestrings.cs.json b/template_feed/Microsoft.DotNet.Common.ItemTemplates/content/Nuget/.template.config/localize/templatestrings.cs.json index 3fe91fe1f9e9..56adf0ebe1b2 100644 --- a/template_feed/Microsoft.DotNet.Common.ItemTemplates/content/Nuget/.template.config/localize/templatestrings.cs.json +++ b/template_feed/Microsoft.DotNet.Common.ItemTemplates/content/Nuget/.template.config/localize/templatestrings.cs.json @@ -1,4 +1,4 @@ -{ +{ "author": "Microsoft", "name": "Konfigurace NuGet", "description": "Soubor pro konfiguraci umístění, ve kterých bude NuGet hledat balíčky", diff --git a/template_feed/Microsoft.DotNet.Common.ItemTemplates/content/Nuget/.template.config/localize/templatestrings.de.json b/template_feed/Microsoft.DotNet.Common.ItemTemplates/content/Nuget/.template.config/localize/templatestrings.de.json index 0f62cdc6de07..2c8bd4cc97cd 100644 --- a/template_feed/Microsoft.DotNet.Common.ItemTemplates/content/Nuget/.template.config/localize/templatestrings.de.json +++ b/template_feed/Microsoft.DotNet.Common.ItemTemplates/content/Nuget/.template.config/localize/templatestrings.de.json @@ -1,4 +1,4 @@ -{ +{ "author": "Microsoft", "name": "NuGet-Konfig.", "description": "Eine Datei zum Konfigurieren der Speicherorte, in denen NuGet nach Paketen suchen wird", diff --git a/template_feed/Microsoft.DotNet.Common.ItemTemplates/content/Nuget/.template.config/localize/templatestrings.es.json b/template_feed/Microsoft.DotNet.Common.ItemTemplates/content/Nuget/.template.config/localize/templatestrings.es.json index 2d30b60751a1..574dbb34aa3b 100644 --- a/template_feed/Microsoft.DotNet.Common.ItemTemplates/content/Nuget/.template.config/localize/templatestrings.es.json +++ b/template_feed/Microsoft.DotNet.Common.ItemTemplates/content/Nuget/.template.config/localize/templatestrings.es.json @@ -1,4 +1,4 @@ -{ +{ "author": "Microsoft", "name": "Configuración de NuGet", "description": "Un archivo para configurar las ubicaciones en las que NuGet buscará paquetes", diff --git a/template_feed/Microsoft.DotNet.Common.ItemTemplates/content/Nuget/.template.config/localize/templatestrings.fr.json b/template_feed/Microsoft.DotNet.Common.ItemTemplates/content/Nuget/.template.config/localize/templatestrings.fr.json index 78938efa0adf..7a31c2f2d144 100644 --- a/template_feed/Microsoft.DotNet.Common.ItemTemplates/content/Nuget/.template.config/localize/templatestrings.fr.json +++ b/template_feed/Microsoft.DotNet.Common.ItemTemplates/content/Nuget/.template.config/localize/templatestrings.fr.json @@ -1,4 +1,4 @@ -{ +{ "author": "Microsoft", "name": "Configuration NuGet", "description": "Un fichier permettant de configurer les emplacements où NuGet recherche des packages", diff --git a/template_feed/Microsoft.DotNet.Common.ItemTemplates/content/Nuget/.template.config/localize/templatestrings.it.json b/template_feed/Microsoft.DotNet.Common.ItemTemplates/content/Nuget/.template.config/localize/templatestrings.it.json index d555f763d291..df2bf66de4a8 100644 --- a/template_feed/Microsoft.DotNet.Common.ItemTemplates/content/Nuget/.template.config/localize/templatestrings.it.json +++ b/template_feed/Microsoft.DotNet.Common.ItemTemplates/content/Nuget/.template.config/localize/templatestrings.it.json @@ -1,4 +1,4 @@ -{ +{ "author": "Microsoft", "name": "Configurazione NuGet", "description": "Un file per la configurazione del NuGet dei percorsi eseguirà la ricerca dei pacchetti", diff --git a/template_feed/Microsoft.DotNet.Common.ItemTemplates/content/Nuget/.template.config/localize/templatestrings.ja.json b/template_feed/Microsoft.DotNet.Common.ItemTemplates/content/Nuget/.template.config/localize/templatestrings.ja.json index 0378b4298da7..13f3ddd4a46a 100644 --- a/template_feed/Microsoft.DotNet.Common.ItemTemplates/content/Nuget/.template.config/localize/templatestrings.ja.json +++ b/template_feed/Microsoft.DotNet.Common.ItemTemplates/content/Nuget/.template.config/localize/templatestrings.ja.json @@ -1,4 +1,4 @@ -{ +{ "author": "Microsoft", "name": "NuGet Config", "description": "NuGet がパッケージが検索する場所を構成するためのファイル", diff --git a/template_feed/Microsoft.DotNet.Common.ItemTemplates/content/Nuget/.template.config/localize/templatestrings.ko.json b/template_feed/Microsoft.DotNet.Common.ItemTemplates/content/Nuget/.template.config/localize/templatestrings.ko.json index 6d4f3ac36dda..0cd5583261f6 100644 --- a/template_feed/Microsoft.DotNet.Common.ItemTemplates/content/Nuget/.template.config/localize/templatestrings.ko.json +++ b/template_feed/Microsoft.DotNet.Common.ItemTemplates/content/Nuget/.template.config/localize/templatestrings.ko.json @@ -1,4 +1,4 @@ -{ +{ "author": "Microsoft", "name": "NuGet 구성", "description": "NuGet 패키지를 검색할 위치를 구성하는 파일", diff --git a/template_feed/Microsoft.DotNet.Common.ItemTemplates/content/Nuget/.template.config/localize/templatestrings.pl.json b/template_feed/Microsoft.DotNet.Common.ItemTemplates/content/Nuget/.template.config/localize/templatestrings.pl.json index ede49888202d..89ed7eec8e3b 100644 --- a/template_feed/Microsoft.DotNet.Common.ItemTemplates/content/Nuget/.template.config/localize/templatestrings.pl.json +++ b/template_feed/Microsoft.DotNet.Common.ItemTemplates/content/Nuget/.template.config/localize/templatestrings.pl.json @@ -1,4 +1,4 @@ -{ +{ "author": "Microsoft", "name": "Konfigurowanie NuGet", "description": "Plik na potrzeby konfigurowania lokalizacji NuGet będzie wyszukiwać pakietów", diff --git a/template_feed/Microsoft.DotNet.Common.ItemTemplates/content/Nuget/.template.config/localize/templatestrings.pt-BR.json b/template_feed/Microsoft.DotNet.Common.ItemTemplates/content/Nuget/.template.config/localize/templatestrings.pt-BR.json index 070f1a37b745..83af4b433477 100644 --- a/template_feed/Microsoft.DotNet.Common.ItemTemplates/content/Nuget/.template.config/localize/templatestrings.pt-BR.json +++ b/template_feed/Microsoft.DotNet.Common.ItemTemplates/content/Nuget/.template.config/localize/templatestrings.pt-BR.json @@ -1,4 +1,4 @@ -{ +{ "author": "Microsoft", "name": "Configuração do NuGet", "description": "Um arquivo para configurar os locais em que o NuGet procurará pacotes", diff --git a/template_feed/Microsoft.DotNet.Common.ItemTemplates/content/Nuget/.template.config/localize/templatestrings.ru.json b/template_feed/Microsoft.DotNet.Common.ItemTemplates/content/Nuget/.template.config/localize/templatestrings.ru.json index ff639a7237b2..4e3f8852abda 100644 --- a/template_feed/Microsoft.DotNet.Common.ItemTemplates/content/Nuget/.template.config/localize/templatestrings.ru.json +++ b/template_feed/Microsoft.DotNet.Common.ItemTemplates/content/Nuget/.template.config/localize/templatestrings.ru.json @@ -1,4 +1,4 @@ -{ +{ "author": "Майкрософт", "name": "Конфигурация NuGet", "description": "Файл для настройки расположений, в которых NuGet будет искать пакеты", diff --git a/template_feed/Microsoft.DotNet.Common.ItemTemplates/content/Nuget/.template.config/localize/templatestrings.tr.json b/template_feed/Microsoft.DotNet.Common.ItemTemplates/content/Nuget/.template.config/localize/templatestrings.tr.json index 78f336dc9888..8197c35f7159 100644 --- a/template_feed/Microsoft.DotNet.Common.ItemTemplates/content/Nuget/.template.config/localize/templatestrings.tr.json +++ b/template_feed/Microsoft.DotNet.Common.ItemTemplates/content/Nuget/.template.config/localize/templatestrings.tr.json @@ -1,4 +1,4 @@ -{ +{ "author": "Microsoft", "name": "NuGet Yapılandırması", "description": "NuGet'in paketleri arama yapacağı konumları yapılandırmaya yönelik dosya", diff --git a/template_feed/Microsoft.DotNet.Common.ItemTemplates/content/Nuget/.template.config/localize/templatestrings.zh-Hans.json b/template_feed/Microsoft.DotNet.Common.ItemTemplates/content/Nuget/.template.config/localize/templatestrings.zh-Hans.json index e4ba4c9eb093..8b1d29316a86 100644 --- a/template_feed/Microsoft.DotNet.Common.ItemTemplates/content/Nuget/.template.config/localize/templatestrings.zh-Hans.json +++ b/template_feed/Microsoft.DotNet.Common.ItemTemplates/content/Nuget/.template.config/localize/templatestrings.zh-Hans.json @@ -1,4 +1,4 @@ -{ +{ "author": "Microsoft", "name": "NuGet 配置", "description": "用于配置位置 NuGet 的文件将搜索包", diff --git a/template_feed/Microsoft.DotNet.Common.ItemTemplates/content/Nuget/.template.config/localize/templatestrings.zh-Hant.json b/template_feed/Microsoft.DotNet.Common.ItemTemplates/content/Nuget/.template.config/localize/templatestrings.zh-Hant.json index 9bf3189fdd84..b1857690eb33 100644 --- a/template_feed/Microsoft.DotNet.Common.ItemTemplates/content/Nuget/.template.config/localize/templatestrings.zh-Hant.json +++ b/template_feed/Microsoft.DotNet.Common.ItemTemplates/content/Nuget/.template.config/localize/templatestrings.zh-Hant.json @@ -1,4 +1,4 @@ -{ +{ "author": "Microsoft", "name": "NuGet 組態", "description": "用於設定檔案位置 NuGet 將會搜尋套件", From 9016aa01511552119cb484838c24a9cd8d2b337e Mon Sep 17 00:00:00 2001 From: tmat Date: Fri, 14 Oct 2022 10:35:12 -0700 Subject: [PATCH 4/7] Add moq IVT --- src/BuiltInTools/dotnet-watch/Properties/AssemblyInfo.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/BuiltInTools/dotnet-watch/Properties/AssemblyInfo.cs b/src/BuiltInTools/dotnet-watch/Properties/AssemblyInfo.cs index 0f22f5d5cff3..5d1f2951028f 100644 --- a/src/BuiltInTools/dotnet-watch/Properties/AssemblyInfo.cs +++ b/src/BuiltInTools/dotnet-watch/Properties/AssemblyInfo.cs @@ -4,3 +4,4 @@ using System.Runtime.CompilerServices; [assembly: InternalsVisibleTo("dotnet-watch.Tests, PublicKey = 0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")] +[assembly: InternalsVisibleTo("DynamicProxyGenAssembly2, PublicKey=0024000004800000940000000602000000240000525341310004000001000100c547cac37abd99c8db225ef2f6c8a3602f3b3606cc9891605d02baa56104f4cfc0734aa39b93bf7852f7d9266654753cc297e7d2edfe0bac1cdcf9f717241550e0a7b191195b7667bb4f64bcb8e2121380fd1d9d46ad2d92d2d15605093924cceaf74c4861eff62abf69b9291ed0a340e113be11e6a7d3113e92484cf7045cc7")] From 89735597d5991c6bb1f7742abdc8d339cd002540 Mon Sep 17 00:00:00 2001 From: tmat Date: Fri, 18 Nov 2022 12:52:14 -0800 Subject: [PATCH 5/7] Prevent hangs when waiting for failed output --- .../Utilities/AwaitableProcess.cs | 29 ++++++++++++++----- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/src/Tests/dotnet-watch.Tests/Utilities/AwaitableProcess.cs b/src/Tests/dotnet-watch.Tests/Utilities/AwaitableProcess.cs index 739fa4638435..dddb6e5352a5 100644 --- a/src/Tests/dotnet-watch.Tests/Utilities/AwaitableProcess.cs +++ b/src/Tests/dotnet-watch.Tests/Utilities/AwaitableProcess.cs @@ -80,18 +80,33 @@ public async Task GetOutputLineAsync(Predicate success, Predicat { bool failed = false; + using var cancellationOnFailure = new CancellationTokenSource(); + while (!_source.Completion.IsCompleted && !failed) { - while (await _source.OutputAvailableAsync(CancellationToken.None)) + try { - var line = await _source.ReceiveAsync(CancellationToken.None); - _lines.Add(line); - if (success(line)) + while (await _source.OutputAvailableAsync(cancellationOnFailure.Token)) { - return line; + var line = await _source.ReceiveAsync(cancellationOnFailure.Token); + _lines.Add(line); + if (success(line)) + { + return line; + } + + if (failure(line)) + { + failed = true; + + // Limit the time to collect remaining output after a failure to avoid hangs: + cancellationOnFailure.CancelAfter(TimeSpan.FromSeconds(1)); + } } - - failed |= failure(line); + } + catch (OperationCanceledException) when (failed) + { + break; } } From 984cfdf1c4217484560c107fa8c3e5b6a1f8794f Mon Sep 17 00:00:00 2001 From: tmat Date: Fri, 18 Nov 2022 12:52:56 -0800 Subject: [PATCH 6/7] Annotate MSBuildFileSetResult with data contract attributes --- .../Utilities/IsExternalInit.cs | 20 ++++++++ .../Internal/MSBuildFileSetResult.cs | 40 ++++++++++----- .../FileSetSerializerTests.cs | 49 +++++++++++++++++++ .../dotnet-watch.Tests.csproj | 1 + 4 files changed, 98 insertions(+), 12 deletions(-) create mode 100644 src/BuiltInTools/DotNetWatchTasks/Utilities/IsExternalInit.cs create mode 100644 src/Tests/dotnet-watch.Tests/FileSetSerializerTests.cs diff --git a/src/BuiltInTools/DotNetWatchTasks/Utilities/IsExternalInit.cs b/src/BuiltInTools/DotNetWatchTasks/Utilities/IsExternalInit.cs new file mode 100644 index 000000000000..7d1e00360964 --- /dev/null +++ b/src/BuiltInTools/DotNetWatchTasks/Utilities/IsExternalInit.cs @@ -0,0 +1,20 @@ +// 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. + +// Copied from: +// https://github.com/dotnet/runtime/blob/218ef0f7776c2c20f6c594e3475b80f1fe2d7d08/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/IsExternalInit.cs + +using System.ComponentModel; + +namespace System.Runtime.CompilerServices +{ + /// + /// Reserved to be used by the compiler for tracking metadata. + /// This class should not be used by developers in source code. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + internal static class IsExternalInit + { + } +} diff --git a/src/BuiltInTools/dotnet-watch/Internal/MSBuildFileSetResult.cs b/src/BuiltInTools/dotnet-watch/Internal/MSBuildFileSetResult.cs index 16c91b4c5c23..295afb4d72b6 100644 --- a/src/BuiltInTools/dotnet-watch/Internal/MSBuildFileSetResult.cs +++ b/src/BuiltInTools/dotnet-watch/Internal/MSBuildFileSetResult.cs @@ -3,39 +3,55 @@ using System; using System.Collections.Generic; +using System.Runtime.Serialization; namespace Microsoft.DotNet.Watcher.Internal { + [DataContract] internal sealed class MSBuildFileSetResult { - public string RunCommand { get; set; } + [DataMember] + public string RunCommand { get; init; } - public string RunArguments { get; set; } + [DataMember] + public string RunArguments { get; init; } - public string RunWorkingDirectory { get; set; } + [DataMember] + public string RunWorkingDirectory { get; init; } - public bool IsNetCoreApp { get; set; } + [DataMember] + public bool IsNetCoreApp { get; init; } - public string TargetFrameworkVersion { get; set; } + [DataMember] + public string TargetFrameworkVersion { get; init; } - public string RuntimeIdentifier { get; set; } + [DataMember] + public string RuntimeIdentifier { get; init; } - public string DefaultAppHostRuntimeIdentifier { get; set; } + [DataMember] + public string DefaultAppHostRuntimeIdentifier { get; init; } - public Dictionary Projects { get; set; } + [DataMember] + public Dictionary Projects { get; init; } } + [DataContract] internal sealed class ProjectItems { - public List Files { get; set; } = new(); + [DataMember] + public List Files { get; init; } = new(); - public List StaticFiles { get; set; } = new(); + [DataMember] + public List StaticFiles { get; init; } = new(); } + [DataContract] internal sealed class StaticFileItem { - public string FilePath { get; set; } + [DataMember] + public string FilePath { get; init; } - public string StaticWebAssetPath { get; set; } + [DataMember] + public string StaticWebAssetPath { get; init; } } } diff --git a/src/Tests/dotnet-watch.Tests/FileSetSerializerTests.cs b/src/Tests/dotnet-watch.Tests/FileSetSerializerTests.cs new file mode 100644 index 000000000000..495142f9d6b1 --- /dev/null +++ b/src/Tests/dotnet-watch.Tests/FileSetSerializerTests.cs @@ -0,0 +1,49 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. +// + +using System.IO; +using System.Runtime.Serialization.Json; +using System.Text; +using System.Text.Json; +using System.Threading; +using System.Threading.Tasks; +using Microsoft.DotNet.Watcher.Internal; +using Xunit; + +namespace Microsoft.DotNet.Watcher.Tools; + +public class FileSetSerializerTests +{ + [Fact] + public async Task Serialize() + { + var fileSetResult = new MSBuildFileSetResult() + { + IsNetCoreApp = true, + TargetFrameworkVersion = "net5.0", + RuntimeIdentifier = "win-arm64", + DefaultAppHostRuntimeIdentifier = "", + RunCommand = "run", + RunArguments = "args", + RunWorkingDirectory = "dir", + Projects = new() { { "proj", new() { Files = new() { "a.cs", "b.cs" }, StaticFiles = new() { new() { FilePath = "path1", StaticWebAssetPath = "path2" } } } } } + }; + + using var stream = new MemoryStream(); + + var serializer = new DataContractJsonSerializer(fileSetResult.GetType(), new DataContractJsonSerializerSettings + { + UseSimpleDictionaryFormat = true, + }); + + using (var writer = JsonReaderWriterFactory.CreateJsonWriter(stream, Encoding.UTF8, ownsStream: false, indent: true)) + { + serializer.WriteObject(writer, fileSetResult); + } + + stream.Position = 0; + + await JsonSerializer.DeserializeAsync(stream, cancellationToken: CancellationToken.None); + } +} diff --git a/src/Tests/dotnet-watch.Tests/dotnet-watch.Tests.csproj b/src/Tests/dotnet-watch.Tests/dotnet-watch.Tests.csproj index c126799ec11f..7cac2bac18ac 100644 --- a/src/Tests/dotnet-watch.Tests/dotnet-watch.Tests.csproj +++ b/src/Tests/dotnet-watch.Tests/dotnet-watch.Tests.csproj @@ -3,6 +3,7 @@ Exe $(ToolsetTargetFramework) MicrosoftAspNetCore + Microsoft.DotNet.Watcher.Tools From 95d689058ef27d3a9317a646875ed44bc22f7d36 Mon Sep 17 00:00:00 2001 From: tmat Date: Fri, 18 Nov 2022 10:41:45 -0800 Subject: [PATCH 7/7] Avoid potential NRE --- src/BuiltInTools/dotnet-watch/HotReloadDotNetWatcher.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/BuiltInTools/dotnet-watch/HotReloadDotNetWatcher.cs b/src/BuiltInTools/dotnet-watch/HotReloadDotNetWatcher.cs index 1b57cb5c9b47..992d785b28c3 100644 --- a/src/BuiltInTools/dotnet-watch/HotReloadDotNetWatcher.cs +++ b/src/BuiltInTools/dotnet-watch/HotReloadDotNetWatcher.cs @@ -309,8 +309,8 @@ private void ConfigureExecutable(DotNetWatchContext context, ProcessSpec process } var rootVariableName = EnvironmentVariableNames.TryGetDotNetRootVariableName( - project.RuntimeIdentifier, - project.DefaultAppHostRuntimeIdentifier, + project.RuntimeIdentifier ?? "", + project.DefaultAppHostRuntimeIdentifier ?? "", project.TargetFrameworkVersion); if (rootVariableName != null && string.IsNullOrEmpty(Environment.GetEnvironmentVariable(rootVariableName)))