Skip to content

Commit

Permalink
Remove LINQ from GuidGenerator
Browse files Browse the repository at this point in the history
  • Loading branch information
Sergio0694 committed Jan 31, 2024
1 parent e556f5e commit ff7d4a2
Showing 1 changed file with 26 additions and 3 deletions.
29 changes: 26 additions & 3 deletions src/WinRT.Runtime/GuidGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

using System;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Reflection;
using System.Security.Cryptography;
using System.Text;
Expand Down Expand Up @@ -101,7 +100,19 @@ public static string GetSignature(
}
else
{
var args = type.GetFields(BindingFlags.Instance | BindingFlags.Public).Select(fi => GetSignature(fi.FieldType));
static string[] SelectSignaturesForFields(FieldInfo[] fields)
{
string[] signatures = new string[fields.Length];

for (int i = 0; i < fields.Length; i++)
{
signatures[i] = GetSignature(fields[i].FieldType);
}

return signatures;
}

var args = SelectSignaturesForFields(type.GetFields(BindingFlags.Instance | BindingFlags.Public));
return "struct(" + type.FullName + ";" + String.Join(";", args) + ")";
}
}
Expand All @@ -117,7 +128,19 @@ public static string GetSignature(

if (type.IsGenericType)
{
var args = type.GetGenericArguments().Select(t => GetSignature(t));
static string[] SelectSignaturesForTypes(Type[] types)
{
string[] signatures = new string[types.Length];

for (int i = 0; i < types.Length; i++)
{
signatures[i] = GetSignature(types[i]);
}

return signatures;
}

var args = SelectSignaturesForTypes(type.GetGenericArguments());
return "pinterface({" + GetGUID(type) + "};" + String.Join(";", args) + ")";
}

Expand Down

0 comments on commit ff7d4a2

Please sign in to comment.