-
Notifications
You must be signed in to change notification settings - Fork 10.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for reloading static files (#27744)
* Add support for reloading static files * Update vanilla css files without a browser reload * Refresh the browser when changes to other static content is detected.
- Loading branch information
Showing
34 changed files
with
582 additions
and
162 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// Copyright (c) .NET Foundation. All rights reserved. | ||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. | ||
|
||
using System; | ||
|
||
namespace Microsoft.DotNet.Watcher | ||
{ | ||
public record DotNetWatchOptions( | ||
bool SuppressHandlingStaticContentFiles, | ||
bool SuppressMSBuildIncrementalism) | ||
{ | ||
public static DotNetWatchOptions Default { get; } = new DotNetWatchOptions | ||
( | ||
SuppressHandlingStaticContentFiles: GetSuppressedValue("DOTNET_WATCH_SUPPRESS_STATIC_FILE_HANDLING"), | ||
SuppressMSBuildIncrementalism: GetSuppressedValue("DOTNET_WATCH_SUPPRESS_MSBUILD_INCREMENTALISM") | ||
); | ||
|
||
private static bool GetSuppressedValue(string key) | ||
{ | ||
var envValue = Environment.GetEnvironmentVariable(key); | ||
return envValue == "1" || envValue == "true"; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// Copyright (c) .NET Foundation. All rights reserved. | ||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. | ||
|
||
namespace Microsoft.DotNet.Watcher | ||
{ | ||
public readonly struct FileItem | ||
{ | ||
public FileItem(string filePath, FileKind fileKind = FileKind.Default, string staticWebAssetPath = null) | ||
{ | ||
FilePath = filePath; | ||
FileKind = fileKind; | ||
StaticWebAssetPath = staticWebAssetPath; | ||
} | ||
|
||
public string FilePath { get; } | ||
|
||
public FileKind FileKind { get; } | ||
|
||
public string StaticWebAssetPath { get; } | ||
} | ||
} |
9 changes: 3 additions & 6 deletions
9
src/Tools/dotnet-watch/src/IFileSet.cs → src/Tools/dotnet-watch/src/FileKind.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,11 @@ | ||
// Copyright (c) .NET Foundation. All rights reserved. | ||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. | ||
|
||
using System.Collections.Generic; | ||
|
||
namespace Microsoft.DotNet.Watcher | ||
{ | ||
public interface IFileSet : IEnumerable<string> | ||
public enum FileKind | ||
{ | ||
bool IsNetCoreApp31OrNewer { get; } | ||
|
||
bool Contains(string filePath); | ||
Default, | ||
StaticFile, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// Copyright (c) .NET Foundation. All rights reserved. | ||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. | ||
|
||
using System; | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
|
||
namespace Microsoft.DotNet.Watcher | ||
{ | ||
public class FileSet : IEnumerable<FileItem> | ||
{ | ||
private readonly Dictionary<string, FileItem> _files; | ||
|
||
public FileSet(bool isNetCoreApp31OrNewer, IEnumerable<FileItem> files) | ||
{ | ||
IsNetCoreApp31OrNewer = isNetCoreApp31OrNewer; | ||
_files = new Dictionary<string, FileItem>(StringComparer.Ordinal); | ||
foreach (var item in files) | ||
{ | ||
_files[item.FilePath] = item; | ||
} | ||
} | ||
|
||
public bool TryGetValue(string filePath, out FileItem fileItem) => _files.TryGetValue(filePath, out fileItem); | ||
|
||
public int Count => _files.Count; | ||
|
||
public bool IsNetCoreApp31OrNewer { get; } | ||
|
||
public static readonly FileSet Empty = new FileSet(false, Array.Empty<FileItem>()); | ||
|
||
public IEnumerator<FileItem> GetEnumerator() => _files.Values.GetEnumerator(); | ||
|
||
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,14 @@ | ||
// Copyright (c) .NET Foundation. All rights reserved. | ||
// Copyright (c) .NET Foundation. All rights reserved. | ||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. | ||
|
||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using Microsoft.DotNet.Watcher.Internal; | ||
|
||
namespace Microsoft.DotNet.Watcher | ||
{ | ||
public interface IFileSetFactory | ||
{ | ||
Task<IFileSet> CreateAsync(CancellationToken cancellationToken); | ||
Task<FileSet> CreateAsync(CancellationToken cancellationToken); | ||
} | ||
} | ||
} |
Oops, something went wrong.