diff --git a/Ryujinx.CustomTasks/GenerateArrays.cs b/Ryujinx.CustomTasks/GenerateArrays.cs index d65fad3..440f284 100644 --- a/Ryujinx.CustomTasks/GenerateArrays.cs +++ b/Ryujinx.CustomTasks/GenerateArrays.cs @@ -1,12 +1,13 @@ -using Microsoft.CodeAnalysis; +using Microsoft.Build.Framework; +using Microsoft.Build.Utilities; +using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp.Syntax; -using Microsoft.Build.Framework; +using Ryujinx.CustomTasks.Helper; +using Ryujinx.CustomTasks.SyntaxWalker; using System.Collections.Generic; using System.IO; -using Ryujinx.CustomTasks.SyntaxWalker; -using Ryujinx.CustomTasks.Helper; -using Task = Microsoft.Build.Utilities.Task; +using System.Linq; namespace Ryujinx.CustomTasks { @@ -54,8 +55,16 @@ namespace Ryujinx.CustomTasks private void AddGeneratedSource(string filePath, string content) { + if (File.Exists(filePath)) + { + File.Delete(filePath); + } + else + { + _outputFiles.Add(filePath); + } + File.WriteAllText(filePath, content); - _outputFiles.Add(filePath); } private ICollection GetArraySizes(string itemPath) @@ -173,9 +182,6 @@ namespace Ryujinx.CustomTasks string arraysFilePath = Path.Combine(OutputPath, ArraysFileName); List arraySizes = new List(); - File.Delete(interfaceFilePath); - File.Delete(arraysFilePath); - foreach (var item in InputFiles) { string fullPath = item.GetMetadata("FullPath"); diff --git a/Ryujinx.CustomTasks/SyntaxWalker/ArraySizeCollector.cs b/Ryujinx.CustomTasks/SyntaxWalker/ArraySizeCollector.cs index 5882bbe..1205c61 100644 --- a/Ryujinx.CustomTasks/SyntaxWalker/ArraySizeCollector.cs +++ b/Ryujinx.CustomTasks/SyntaxWalker/ArraySizeCollector.cs @@ -6,7 +6,8 @@ namespace Ryujinx.CustomTasks.SyntaxWalker { class ArraySizeCollector : CSharpSyntaxWalker { - public ICollection ArraySizes { get; } = new List(); + private readonly HashSet _arraySizes = new HashSet(); + public ICollection ArraySizes => _arraySizes; private void AddArrayString(string name) { @@ -17,9 +18,9 @@ namespace Ryujinx.CustomTasks.SyntaxWalker string rawArrayType = name.Split('<')[0]; - if (int.TryParse(rawArrayType.Substring(5), out int size) && !ArraySizes.Contains(size)) + if (int.TryParse(rawArrayType.Substring(5), out int size)) { - ArraySizes.Add(size); + _arraySizes.Add(size); } }