Skip to content

Commit

Permalink
Remove event generation
Browse files Browse the repository at this point in the history
  • Loading branch information
ds5678 committed Sep 20, 2024
1 parent cd94520 commit edd8865
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 97 deletions.
8 changes: 1 addition & 7 deletions Il2CppInterop.Generator/Contexts/FieldRewriteContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,7 @@ private string UnmangleFieldName(FieldDefinition field, GeneratorOptions options

if (!field.Name.IsObfuscated(options))
{
var name = field.Name.MakeValidInSource();
while (field.DeclaringType!.Events.Any(e => e.Name == name)
|| field.DeclaringType!.Fields.Any(f => f.Name == name && f != field))
{
name += "_"; // Backing fields for events have the same name as the event.
}
return name;
return field.Name.MakeValidInSource();
}

if (renamedFieldCounts == null) throw new ArgumentNullException(nameof(renamedFieldCounts));
Expand Down
60 changes: 0 additions & 60 deletions Il2CppInterop.Generator/Passes/Pass71GenerateEvents.cs

This file was deleted.

25 changes: 0 additions & 25 deletions Il2CppInterop.Generator/Passes/Pass80UnstripMethods.cs
Original file line number Diff line number Diff line change
Expand Up @@ -124,16 +124,6 @@ public static void DoPass(RewriteGlobalContext context)
var property = GetOrCreateProperty(unityMethod, newMethod);
property.SetMethod = newMethod;
}
else if (unityMethod.IsAddMethod)
{
var @event = GetOrCreateEvent(unityMethod, newMethod);
@event.AddMethod = newMethod;
}
else if (unityMethod.IsRemoveMethod)
{
var @event = GetOrCreateEvent(unityMethod, newMethod);
@event.RemoveMethod = newMethod;
}

var paramsMethod = context.CreateParamsMethod(unityMethod, newMethod, imports,
type => ResolveTypeInNewAssemblies(context, type, imports));
Expand Down Expand Up @@ -181,21 +171,6 @@ private static PropertyDefinition GetOrCreateProperty(MethodDefinition unityMeth
return newProperty;
}

private static EventDefinition GetOrCreateEvent(MethodDefinition unityMethod, MethodDefinition newMethod)
{
var unityEvent =
unityMethod.DeclaringType!.Events.Single(
it => it.AddMethod == unityMethod || it.RemoveMethod == unityMethod);
var newEvent = newMethod.DeclaringType!.Events.SingleOrDefault(it => it.Name == unityEvent.Name);
if (newEvent == null)
{
newEvent = new EventDefinition(unityEvent.Name, unityEvent.Attributes, newMethod.Signature!.ParameterTypes.Single().ToTypeDefOrRef());
newMethod.DeclaringType.Events.Add(newEvent);
}

return newEvent;
}

internal static TypeSignature? ResolveTypeInNewAssemblies(RewriteGlobalContext context, TypeSignature? unityType,
RuntimeAssemblyReferences imports)
{
Expand Down
5 changes: 0 additions & 5 deletions Il2CppInterop.Generator/Runners/InteropAssemblyGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -153,11 +153,6 @@ public void Run(GeneratorOptions options)
Pass70GenerateProperties.DoPass(rewriteContext);
}

using (new TimingCookie("Creating events"))
{
Pass71GenerateEvents.DoPass(rewriteContext);
}

if (options.UnityBaseLibsDir != null)
{
using (new TimingCookie("Unstripping types"))
Expand Down

0 comments on commit edd8865

Please sign in to comment.