protected override Mono.Cecil.CustomAttribute GetOutAttribute(ParameterDefinition parameter) { if (parameter.IsOutParameter()) { return GetInOrOutAttribute(parameter, false); } return base.GetOutAttribute(parameter); }
protected virtual void WriteOutOrRefKeyWord(ParameterDefinition parameter) { if (parameter.IsOutParameter()) { WriteKeyword(KeyWordWriter.Out); } else { WriteKeyword(KeyWordWriter.ByRef); } }
protected virtual CustomAttribute GetOutAttribute(ParameterDefinition parameter) { if (parameter.IsOutParameter()) { return null; } if (parameter == null || !parameter.IsOut) { return null; } //ModuleDefinition paramDeclaringModule = parameter.Method.ReturnType.Module; //IMetadataScope referencedCorlib = paramDeclaringModule.TypeSystem.Corlib; ///// The type reference is created this way in order to avoid resolving it. ///// This will help the program print valid code, even in cases when the targeted corlib cannot be found (i.e. decompiling .NET 1.1) ///// The reference to the parameterless constructor is created for the same reason. //TypeReference outAttributeTypeReference = new TypeReference("System.Runtime.InteropServices", "OutAttribute", paramDeclaringModule, referencedCorlib); //if (outAttributeTypeReference == null) //{ // return null; //} //MethodReference emptyCtor = new MethodReference(".ctor", paramDeclaringModule.TypeSystem.Void, outAttributeTypeReference); //return new CustomAttribute(emptyCtor); return GetInOrOutAttribute(parameter, false); }