diff --git a/Source/Tools/Flax.Build/Build/Assembler.cs b/Source/Tools/Flax.Build/Build/Assembler.cs index aeb2bb241..aa7e7e215 100644 --- a/Source/Tools/Flax.Build/Build/Assembler.cs +++ b/Source/Tools/Flax.Build/Build/Assembler.cs @@ -20,6 +20,9 @@ namespace Flax.Build /// public class Assembler { + private string _cacheAssemblyPath = null; + private string _cachePath = null; + /// /// The default assembly references added to the projects. /// @@ -31,18 +34,6 @@ namespace Flax.Build typeof(Builder).Assembly, // Flax.Build.exe }; - /// - /// The output assembly path. Use null to store assembly in the process memory. - /// - public string OutputPath = null; - - /// - /// - /// - public string CachePath = null; - - private string CacheAssemblyPath = null; - /// /// The source files for compilation. /// @@ -61,8 +52,8 @@ namespace Flax.Build public Assembler(List sourceFiles, string cachePath = null) { SourceFiles.AddRange(sourceFiles); - CachePath = cachePath; - CacheAssemblyPath = cachePath != null ? Path.Combine(Directory.GetParent(cachePath).FullName, "BuilderRulesCache.dll") : null; + _cachePath = cachePath; + _cacheAssemblyPath = cachePath != null ? Path.Combine(Directory.GetParent(cachePath).FullName, "BuilderRulesCache.dll") : null; } /// @@ -73,7 +64,7 @@ namespace Flax.Build public Assembly Build() { DateTime recentWriteTime = DateTime.MinValue; - if (CachePath != null) + if (_cachePath != null) { foreach (var sourceFile in SourceFiles) { @@ -91,12 +82,12 @@ namespace Flax.Build recentWriteTime = lastWriteTime; } - DateTime cacheTime = File.Exists(CachePath) - ? DateTime.FromBinary(long.Parse(File.ReadAllText(CachePath))) + DateTime cacheTime = File.Exists(_cachePath) + ? DateTime.FromBinary(long.Parse(File.ReadAllText(_cachePath))) : DateTime.MinValue; - if (recentWriteTime <= cacheTime && File.Exists(CacheAssemblyPath)) + if (recentWriteTime <= cacheTime && File.Exists(_cacheAssemblyPath)) { - Assembly cachedAssembly = AssemblyLoadContext.Default.LoadFromAssemblyPath(CacheAssemblyPath); + Assembly cachedAssembly = AssemblyLoadContext.Default.LoadFromAssemblyPath(_cacheAssemblyPath); return cachedAssembly; } } @@ -162,21 +153,21 @@ namespace Flax.Build memoryStream.Seek(0, SeekOrigin.Begin); Assembly compiledAssembly = AssemblyLoadContext.Default.LoadFromStream(memoryStream); - if (CachePath != null && CacheAssemblyPath != null) + if (_cachePath != null && _cacheAssemblyPath != null) { memoryStream.Seek(0, SeekOrigin.Begin); - var cacheDirectory = Path.GetDirectoryName(CacheAssemblyPath); + var cacheDirectory = Path.GetDirectoryName(_cacheAssemblyPath); if (!Directory.Exists(cacheDirectory)) Directory.CreateDirectory(cacheDirectory); - using (FileStream fileStream = File.Open(CacheAssemblyPath, FileMode.Create, FileAccess.Write)) + using (FileStream fileStream = File.Open(_cacheAssemblyPath, FileMode.Create, FileAccess.Write)) { memoryStream.CopyTo(fileStream); fileStream.Close(); } - File.WriteAllText(CachePath, recentWriteTime.ToBinary().ToString()); + File.WriteAllText(_cachePath, recentWriteTime.ToBinary().ToString()); } sw.Stop();