internal IEnumerable <CSharpAttributeData> GetCustomAttributesToEmit( PEModuleBuilder moduleBuilder, bool emittingRefAssembly, bool emittingAssemblyAttributesInNetModule ) { CheckDefinitionInvariant(); ImmutableArray <CSharpAttributeData> userDefined = this.GetAttributes(); ArrayBuilder <SynthesizedAttributeData> synthesized = null; this.AddSynthesizedAttributes(moduleBuilder, ref synthesized); if (emittingRefAssembly && !HasReferenceAssemblyAttribute) { var referenceAssemblyAttribute = this.DeclaringCompilation.TrySynthesizeAttribute( WellKnownMember.System_Runtime_CompilerServices_ReferenceAssemblyAttribute__ctor, isOptionalUse: true ); Symbol.AddSynthesizedAttribute(ref synthesized, referenceAssemblyAttribute); } // Note that callers of this method (CCI and ReflectionEmitter) have to enumerate // all items of the returned iterator, otherwise the synthesized ArrayBuilder may leak. return(GetCustomAttributesToEmit( userDefined, synthesized, isReturnType: false, emittingAssemblyAttributesInNetModule: emittingAssemblyAttributesInNetModule )); }