Files
sbox-public/engine/Sandbox.Compiling/Compiler/Compiler.Watch.cs
s&box team 71f266059a Open source release
This commit imports the C# engine code and game files, excluding C++ source code.

[Source-Commit: ceb3d758046e50faa6258bc3b658a30c97743268]
2025-11-24 09:05:18 +00:00

31 lines
725 B
C#

namespace Sandbox;
partial class Compiler
{
private List<FileWatch> sourceWatchers = new();
/// <summary>
/// Watch the filesystem for changes to our c# files, and trigger a recompile if they change.
/// </summary>
public void WatchForChanges()
{
foreach ( var fs in SourceLocations )
{
var watcher = fs.Watch( "*.*" );
watcher.OnChangedFile += OnFileChanged;
sourceWatchers.Add( watcher );
}
}
private void OnFileChanged( string file )
{
if ( !file.EndsWith( ".cs", StringComparison.OrdinalIgnoreCase ) && !file.EndsWith( ".razor", StringComparison.OrdinalIgnoreCase ) )
return;
if ( file.Contains( "/obj/", StringComparison.OrdinalIgnoreCase ) )
return;
MarkForRecompile();
}
}