[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
2 changed files with 19 additions and 12 deletions
|
@ -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;
|
||||||
using Microsoft.CodeAnalysis.CSharp.Syntax;
|
using Microsoft.CodeAnalysis.CSharp.Syntax;
|
||||||
using Microsoft.Build.Framework;
|
using Ryujinx.CustomTasks.Helper;
|
||||||
|
using Ryujinx.CustomTasks.SyntaxWalker;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using Ryujinx.CustomTasks.SyntaxWalker;
|
using System.Linq;
|
||||||
using Ryujinx.CustomTasks.Helper;
|
|
||||||
using Task = Microsoft.Build.Utilities.Task;
|
|
||||||
|
|
||||||
namespace Ryujinx.CustomTasks
|
namespace Ryujinx.CustomTasks
|
||||||
{
|
{
|
||||||
|
@ -54,10 +55,18 @@ namespace Ryujinx.CustomTasks
|
||||||
|
|
||||||
private void AddGeneratedSource(string filePath, string content)
|
private void AddGeneratedSource(string filePath, string content)
|
||||||
{
|
{
|
||||||
File.WriteAllText(filePath, content);
|
if (File.Exists(filePath))
|
||||||
|
{
|
||||||
|
File.Delete(filePath);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
_outputFiles.Add(filePath);
|
_outputFiles.Add(filePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
File.WriteAllText(filePath, content);
|
||||||
|
}
|
||||||
|
|
||||||
private ICollection<int> GetArraySizes(string itemPath)
|
private ICollection<int> GetArraySizes(string itemPath)
|
||||||
{
|
{
|
||||||
Log.LogMessage(MessageImportance.Low, $"Searching for StructArray types in: {itemPath}");
|
Log.LogMessage(MessageImportance.Low, $"Searching for StructArray types in: {itemPath}");
|
||||||
|
@ -173,9 +182,6 @@ namespace Ryujinx.CustomTasks
|
||||||
string arraysFilePath = Path.Combine(OutputPath, ArraysFileName);
|
string arraysFilePath = Path.Combine(OutputPath, ArraysFileName);
|
||||||
List<int> arraySizes = new List<int>();
|
List<int> arraySizes = new List<int>();
|
||||||
|
|
||||||
File.Delete(interfaceFilePath);
|
|
||||||
File.Delete(arraysFilePath);
|
|
||||||
|
|
||||||
foreach (var item in InputFiles)
|
foreach (var item in InputFiles)
|
||||||
{
|
{
|
||||||
string fullPath = item.GetMetadata("FullPath");
|
string fullPath = item.GetMetadata("FullPath");
|
||||||
|
|
|
@ -6,7 +6,8 @@ namespace Ryujinx.CustomTasks.SyntaxWalker
|
||||||
{
|
{
|
||||||
class ArraySizeCollector : CSharpSyntaxWalker
|
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)
|
private void AddArrayString(string name)
|
||||||
{
|
{
|
||||||
|
@ -17,9 +18,9 @@ namespace Ryujinx.CustomTasks.SyntaxWalker
|
||||||
|
|
||||||
string rawArrayType = name.Split('<')[0];
|
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