Skip to content

Commit

Permalink
Fixed incorrect pseudo custom attribute generation
Browse files Browse the repository at this point in the history
  • Loading branch information
ElektroKill committed Mar 28, 2024
1 parent fd28d71 commit c02cd51
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions dnSpy/dnSpy.Contracts.Logic/Decompiler/CustomAttributesUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,7 @@ static CustomAttribute CreateMarshalTypeCustomAttribute(ModuleDef module, Marsha
if (fami.IsElementTypeValid)
ca.NamedArguments.Add(new CANamedArgument(isField: true, unmanagedTypeType, arraySubTypeName, new CAArgument(unmanagedTypeType, (int)fami.ElementType)));
}
if (mt is SafeArrayMarshalType sami) {
else if (mt is SafeArrayMarshalType sami) {
if (sami.IsVariantTypeValid) {
var varEnumType = new ValueTypeSig(new TypeRefUser(module, systemRuntimeInteropServicesName, varEnumName, interopAsmRef));
ca.NamedArguments.Add(new CANamedArgument(isField: true, varEnumType, safeArraySubTypeName, new CAArgument(varEnumType, (int)sami.VariantType)));
Expand All @@ -481,27 +481,27 @@ static CustomAttribute CreateMarshalTypeCustomAttribute(ModuleDef module, Marsha
ca.NamedArguments.Add(new CANamedArgument(isField: true, typeType, safeArrayUserDefinedSubTypeName, new CAArgument(typeType, sami.UserDefinedSubType)));
}
}
if (mt is ArrayMarshalType ami) {
else if (mt is ArrayMarshalType ami) {
if (ami.IsElementTypeValid && ami.ElementType != NativeType.Max)
ca.NamedArguments.Add(new CANamedArgument(isField: true, unmanagedTypeType, arraySubTypeName, new CAArgument(unmanagedTypeType, (int)ami.ElementType)));
if (ami.IsSizeValid)
ca.NamedArguments.Add(new CANamedArgument(isField: true, module.CorLibTypes.Int32, sizeConstName, new CAArgument(module.CorLibTypes.Int32, ami.Size)));
if (ami.Flags != 0 && ami.ParamNumber >= 0)
ca.NamedArguments.Add(new CANamedArgument(isField: true, module.CorLibTypes.Int16, sizeParamIndexName, new CAArgument(module.CorLibTypes.Int16, (short)ami.ParamNumber)));
}
if (mt is CustomMarshalType cmi) {
else if (mt is CustomMarshalType cmi) {
if (cmi.CustomMarshaler != null) {
var typeType = new ClassSig(new TypeRefUser(module, systemName, typeName, module.CorLibTypes.AssemblyRef));
ca.NamedArguments.Add(new CANamedArgument(isField: true, typeType, marshalTypeRefName, new CAArgument(typeType, cmi.CustomMarshaler)));
}
if (!UTF8String.IsNullOrEmpty(cmi.Cookie))
ca.NamedArguments.Add(new CANamedArgument(isField: true, module.CorLibTypes.String, marshalCookieName, new CAArgument(module.CorLibTypes.String, cmi.Cookie)));
}
if (mt is FixedSysStringMarshalType fssmi) {
else if (mt is FixedSysStringMarshalType fssmi) {
if (fssmi.IsSizeValid)
ca.NamedArguments.Add(new CANamedArgument(isField: true, module.CorLibTypes.Int32, sizeConstName, new CAArgument(module.CorLibTypes.Int32, fssmi.Size)));
}
if (mt is InterfaceMarshalType imti) {
else if (mt is InterfaceMarshalType imti) {
if (imti.IsIidParamIndexValid)
ca.NamedArguments.Add(new CANamedArgument(isField: true, module.CorLibTypes.Int32, iidParameterIndexName, new CAArgument(module.CorLibTypes.Int32, imti.IidParamIndex)));
}
Expand Down Expand Up @@ -536,7 +536,7 @@ defMemCa.ConstructorArguments[0].Value is UTF8String defMember &&
defMember != itemName && defMember == property.Name) {
var module = property.Module;
var declType = new TypeRefUser(module, systemRuntimeCompilerServicesName, indexerNameAttributeName, module.CorLibTypes.AssemblyRef);
var newCa = new CustomAttribute(new MemberRefUser(module, ctorName, MethodSig.CreateInstance(module.CorLibTypes.Void), declType));
var newCa = new CustomAttribute(new MemberRefUser(module, ctorName, MethodSig.CreateInstance(module.CorLibTypes.Void, module.CorLibTypes.String), declType));
newCa.ConstructorArguments.Add(new CAArgument(module.CorLibTypes.String, defMember));
yield return newCa;
}
Expand Down

0 comments on commit c02cd51

Please sign in to comment.