mirror of
https://github.com/AssetRipper/AssetRipper.CIL.git
synced 2026-11-13 20:05:28 -10:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b49a6b2a75 | ||
|
|
ff8d07d1b4 |
No files matched your search
@@ -15,12 +15,12 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="AsmResolver.DotNet" Version="5.5.0" />
|
||||
<PackageReference Include="AsmResolver.DotNet" Version="5.5.1" />
|
||||
<PackageReference Include="PolySharp" Version="1.14.1" PrivateAssets="all" IncludeAssets="runtime; build; native; contentfiles; analyzers; buildtransitive" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Include="../README.md" Pack="true" PackagePath="/"/>
|
||||
<None Include="../README.md" Pack="true" PackagePath="/" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -15,7 +15,20 @@ internal static class MethodDefinitionExtensions
|
||||
|
||||
public static bool ShouldCallBaseConstructor(this MethodDefinition methodDefinition)
|
||||
{
|
||||
return methodDefinition.IsInstanceConstructor() && methodDefinition.DeclaringType?.IsValueType is not true;
|
||||
return methodDefinition.IsInstanceConstructor() && !methodDefinition.IsDeclaredByValueType();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Is this method declared inside a struct?
|
||||
/// </summary>
|
||||
public static bool IsDeclaredByValueType(this MethodDefinition methodDefinition)
|
||||
{
|
||||
return methodDefinition.DeclaringType?.IsValueType is true;
|
||||
}
|
||||
|
||||
public static bool ShouldInitializeFields(this MethodDefinition methodDefinition)
|
||||
{
|
||||
return methodDefinition.IsInstanceConstructor() && methodDefinition.IsDeclaredByValueType();
|
||||
}
|
||||
|
||||
public static bool IsManagedMethodWithBody(this MethodDefinition managedMethod)
|
||||
|
||||
@@ -51,6 +51,22 @@ public static class MethodStubber
|
||||
return;
|
||||
}
|
||||
|
||||
if (methodDefinition.ShouldInitializeFields())
|
||||
{
|
||||
TypeDefinition declaringType = methodDefinition.DeclaringType!;
|
||||
foreach (FieldDefinition field in declaringType.Fields)
|
||||
{
|
||||
if (field.IsStatic || field.Signature is null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
methodInstructions.Add(CilOpCodes.Ldarg_0);
|
||||
methodInstructions.AddDefaultValueForType(field.Signature.FieldType);
|
||||
methodInstructions.Add(CilOpCodes.Stfld, field);
|
||||
}
|
||||
}
|
||||
|
||||
if (methodDefinition.ShouldCallBaseConstructor() && TryGetBaseConstructor(methodDefinition, out IMethodDescriptor? baseConstructor))
|
||||
{
|
||||
MethodSignature? methodSignature = baseConstructor.Signature;
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<CheckForOverflowUnderflow>true</CheckForOverflowUnderflow>
|
||||
<PolySharpIncludeRuntimeSupportedAttributes>true</PolySharpIncludeRuntimeSupportedAttributes>
|
||||
|
||||
<Version>1.0.1</Version>
|
||||
<Version>1.0.2</Version>
|
||||
<AssemblyVersion>$(Version)</AssemblyVersion>
|
||||
<Copyright>Copyright (c) 2024 ds5678</Copyright>
|
||||
<Authors>ds5678</Authors>
|
||||
|
||||
Reference in new issue
Block a user