mirror of
https://github.com/Ryujinx/Ryujinx.CustomTasks.git
synced 2024-12-22 19:05:33 +00:00
[GenArrays] Replace List<> with HashList<> & Fix duplicate entries warning when compiling (#1)
* Replace List<> with HashSet<> * Fix duplicate entries warning If generated sources already exist don't add them to _outputFiles. * Address gdkchan's review comments
This commit is contained in:
parent
ed48dfcab6
commit
55f28500f0
|
@ -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,10 +55,18 @@ namespace Ryujinx.CustomTasks
|
|||
|
||||
private void AddGeneratedSource(string filePath, string content)
|
||||
{
|
||||
File.WriteAllText(filePath, content);
|
||||
if (File.Exists(filePath))
|
||||
{
|
||||
File.Delete(filePath);
|
||||
}
|
||||
else
|
||||
{
|
||||
_outputFiles.Add(filePath);
|
||||
}
|
||||
|
||||
File.WriteAllText(filePath, content);
|
||||
}
|
||||
|
||||
private ICollection<int> GetArraySizes(string itemPath)
|
||||
{
|
||||
Log.LogMessage(MessageImportance.Low, $"Searching for StructArray types in: {itemPath}");
|
||||
|
@ -173,9 +182,6 @@ namespace Ryujinx.CustomTasks
|
|||
string arraysFilePath = Path.Combine(OutputPath, ArraysFileName);
|
||||
List<int> arraySizes = new List<int>();
|
||||
|
||||
File.Delete(interfaceFilePath);
|
||||
File.Delete(arraysFilePath);
|
||||
|
||||
foreach (var item in InputFiles)
|
||||
{
|
||||
string fullPath = item.GetMetadata("FullPath");
|
||||
|
|
|
@ -6,7 +6,8 @@ namespace Ryujinx.CustomTasks.SyntaxWalker
|
|||
{
|
||||
class ArraySizeCollector : CSharpSyntaxWalker
|
||||
{
|
||||
public ICollection<int> ArraySizes { get; } = new List<int>();
|
||||
private readonly HashSet<int> _arraySizes = new HashSet<int>();
|
||||
public ICollection<int> 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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue