Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make all public API in dotnet-watch.dll internal and sealed. #28260

Merged
merged 7 commits into from
Nov 22, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions src/BuiltInTools/DotNetWatchTasks/Utilities/IsExternalInit.cs
Original file line number Diff line number Diff line change
@@ -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
{
/// <summary>
/// Reserved to be used by the compiler for tracking metadata.
/// This class should not be used by developers in source code.
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never)]
internal static class IsExternalInit
{
}
}
2 changes: 1 addition & 1 deletion src/BuiltInTools/dotnet-watch/DotNetWatchContext.cs
Original file line number Diff line number Diff line change
@@ -8,7 +8,7 @@

namespace Microsoft.DotNet.Watcher.Tools
{
public class DotNetWatchContext
internal sealed class DotNetWatchContext
{
public IReporter Reporter { get; init; } = NullReporter.Singleton;

2 changes: 1 addition & 1 deletion src/BuiltInTools/dotnet-watch/DotNetWatchOptions.cs
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@

namespace Microsoft.DotNet.Watcher
{
public record DotNetWatchOptions(
internal sealed record DotNetWatchOptions(
bool SuppressHandlingStaticContentFiles,
bool SuppressMSBuildIncrementalism,
bool SuppressLaunchBrowser,
2 changes: 1 addition & 1 deletion src/BuiltInTools/dotnet-watch/DotNetWatcher.cs
Original file line number Diff line number Diff line change
@@ -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;
2 changes: 1 addition & 1 deletion src/BuiltInTools/dotnet-watch/FileItem.cs
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@

namespace Microsoft.DotNet.Watcher
{
public readonly struct FileItem
internal readonly struct FileItem
{
public string FilePath { get; init; }

2 changes: 1 addition & 1 deletion src/BuiltInTools/dotnet-watch/FileSet.cs
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@

namespace Microsoft.DotNet.Watcher
{
public class FileSet : IEnumerable<FileItem>
internal sealed class FileSet : IEnumerable<FileItem>
{
private readonly Dictionary<string, FileItem> _files;

Original file line number Diff line number Diff line change
@@ -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;
Original file line number Diff line number Diff line change
@@ -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");
2 changes: 1 addition & 1 deletion src/BuiltInTools/dotnet-watch/Filters/DotNetBuildFilter.cs
Original file line number Diff line number Diff line change
@@ -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;
2 changes: 1 addition & 1 deletion src/BuiltInTools/dotnet-watch/Filters/IWatchFilter.cs
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@

namespace Microsoft.DotNet.Watcher.Tools
{
public interface IWatchFilter
internal interface IWatchFilter
{
ValueTask ProcessAsync(DotNetWatchContext context, CancellationToken cancellationToken);
}
Original file line number Diff line number Diff line change
@@ -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: (?<url>.*)\s*$", RegexOptions.None | RegexOptions.Compiled, TimeSpan.FromSeconds(10));
private readonly bool _runningInTest;
Original file line number Diff line number Diff line change
@@ -10,7 +10,7 @@

namespace Microsoft.DotNet.Watcher.Tools
{
public 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;
}

protected virtual DateTime GetLastWriteTimeUtcSafely(string file)
private protected virtual DateTime GetLastWriteTimeUtcSafely(string file)
{
try
{
2 changes: 1 addition & 1 deletion src/BuiltInTools/dotnet-watch/Filters/NoRestoreFilter.cs
Original file line number Diff line number Diff line change
@@ -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;
Original file line number Diff line number Diff line change
@@ -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";

Original file line number Diff line number Diff line change
@@ -141,14 +141,14 @@ public void Dispose()
_pipe?.Dispose();
}

public readonly struct HotReloadDiagnostics
private readonly struct HotReloadDiagnostics
{
public string Type => "HotReloadDiagnosticsv1";

public IEnumerable<string> Diagnostics { get; init; }
}

public readonly struct AspNetCoreHotReloadApplied
private readonly struct AspNetCoreHotReloadApplied
{
public string Type => "AspNetCoreHotReloadApplied";
}
Original file line number Diff line number Diff line change
@@ -7,9 +7,8 @@
namespace Microsoft.DotNet.Watcher.Tools
{
[EventSource(Name = "HotReload")]
class HotReloadEventSource : EventSource
internal sealed class HotReloadEventSource : EventSource
{

public enum StartType
{
Main,
@@ -18,7 +17,7 @@ public enum StartType
ScopedCssHandler
}

public class Keywords
internal sealed class Keywords
{
public const EventKeywords Perf = (EventKeywords)1;
}
@@ -31,4 +30,4 @@ public class Keywords

public static readonly HotReloadEventSource Log = new HotReloadEventSource();
}
}
}
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@

namespace Microsoft.DotNet.Watcher.Tools
{
public enum HotReloadProfile
internal enum HotReloadProfile
{
Default,

Original file line number Diff line number Diff line change
@@ -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)
{
2 changes: 1 addition & 1 deletion src/BuiltInTools/dotnet-watch/HotReload/RudeEditDialog.cs
Original file line number Diff line number Diff line change
@@ -8,7 +8,7 @@

namespace Microsoft.DotNet.Watcher.Tools
{
public class RudeEditDialog
internal sealed class RudeEditDialog
{
private readonly IReporter _reporter;
private readonly IRequester _requester;
6 changes: 3 additions & 3 deletions src/BuiltInTools/dotnet-watch/HotReloadDotNetWatcher.cs
Original file line number Diff line number Diff line change
@@ -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;
@@ -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)))
2 changes: 1 addition & 1 deletion src/BuiltInTools/dotnet-watch/IFileSetFactory.cs
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@

namespace Microsoft.DotNet.Watcher
{
public interface IFileSetFactory
internal interface IFileSetFactory
{
Task<FileSet> CreateAsync(CancellationToken cancellationToken);
}
12 changes: 6 additions & 6 deletions src/BuiltInTools/dotnet-watch/Internal/ConsoleReporter.cs
Original file line number Diff line number Diff line change
@@ -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.
/// </summary>
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)
{
2 changes: 1 addition & 1 deletion src/BuiltInTools/dotnet-watch/Internal/ConsoleRequester.cs
Original file line number Diff line number Diff line change
@@ -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.
/// </summary>
public class ConsoleRequester : IRequester
internal sealed class ConsoleRequester : IRequester
{
private readonly object _writeLock = new object();

2 changes: 1 addition & 1 deletion src/BuiltInTools/dotnet-watch/Internal/FileSetWatcher.cs
Original file line number Diff line number Diff line change
@@ -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;
2 changes: 1 addition & 1 deletion src/BuiltInTools/dotnet-watch/Internal/FileWatcher.cs
Original file line number Diff line number Diff line change
@@ -9,7 +9,7 @@

namespace Microsoft.DotNet.Watcher.Internal
{
public class FileWatcher
internal sealed class FileWatcher
{
private bool _disposed;

Original file line number Diff line number Diff line change
@@ -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);
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@

namespace Microsoft.DotNet.Watcher.Internal
{
public interface IFileSystemWatcher : IDisposable
internal interface IFileSystemWatcher : IDisposable
{
event EventHandler<(string filePath, bool newFile)> OnFileChange;

Original file line number Diff line number Diff line change
@@ -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;
2 changes: 1 addition & 1 deletion src/BuiltInTools/dotnet-watch/Internal/IConsole.cs
Original file line number Diff line number Diff line change
@@ -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.
/// </summary>
public interface IConsole
internal interface IConsole
{
event ConsoleCancelEventHandler CancelKeyPress;
event Action<ConsoleKeyInfo> KeyPressed;
2 changes: 1 addition & 1 deletion src/BuiltInTools/dotnet-watch/Internal/IReporter.cs
Original file line number Diff line number Diff line change
@@ -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.
/// </summary>
public interface IReporter
internal interface IReporter
{
public bool IsVerbose => false;
void Verbose(string message, string emoji = "⌚");
2 changes: 1 addition & 1 deletion src/BuiltInTools/dotnet-watch/Internal/IRequester.cs
Original file line number Diff line number Diff line change
@@ -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.
/// </summary>
public interface IRequester
internal interface IRequester
{
Task<ConsoleKey> GetKeyAsync(string prompt, Func<ConsoleKey, bool> validateInput, CancellationToken cancellationToken);
}
Loading