+
+ try {
+ var fi = typeof (AssemblyBuilder).GetField ("culture", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.SetField);
+ fi.SetValue (CodeGen.Assembly.Builder, value == "neutral" ? "" : value);
+ } catch {
+ Report.RuntimeMissingSupport (a.Location, "AssemblyCultureAttribute setting");
+ }
+
+ return;
+ }
+
+ if (a.Type == pa.AssemblyVersion) {
+ string value = a.GetString ();
+ if (value == null || value.Length == 0)
+ return;
+
+ var vinfo = IsValidAssemblyVersion (value.Replace ('*', '0'));
+ if (vinfo == null) {
+ a.Error_AttributeEmitError (string.Format ("Specified version `{0}' is not valid", value));
+ return;
+ }
+
+ try {
+ var fi = typeof (AssemblyBuilder).GetField ("version", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.SetField);
+ fi.SetValue (CodeGen.Assembly.Builder, vinfo);
+ } catch {
+ Report.RuntimeMissingSupport (a.Location, "AssemblyVersionAttribute setting");
+ }
+
+ return;
+ }
+
+ if (a.Type == pa.AssemblyAlgorithmId) {
+ const int pos = 2; // skip CA header
+ uint alg = (uint) cdata [pos];
+ alg |= ((uint) cdata [pos + 1]) << 8;
+ alg |= ((uint) cdata [pos + 2]) << 16;
+ alg |= ((uint) cdata [pos + 3]) << 24;
+
+ try {
+ var fi = typeof (AssemblyBuilder).GetField ("algid", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.SetField);
+ fi.SetValue (CodeGen.Assembly.Builder, alg);
+ } catch {
+ Report.RuntimeMissingSupport (a.Location, "AssemblyAlgorithmIdAttribute setting");
+ }
+
+ return;
+ }
+
+ if (a.Type == pa.AssemblyFlags) {
+ const int pos = 2; // skip CA header
+ uint flags = (uint) cdata[pos];
+ flags |= ((uint) cdata[pos + 1]) << 8;
+ flags |= ((uint) cdata[pos + 2]) << 16;
+ flags |= ((uint) cdata[pos + 3]) << 24;
+
+ // Ignore set PublicKey flag if assembly is not strongnamed
+ if ((flags & (uint) AssemblyNameFlags.PublicKey) != 0 && (CodeGen.Assembly.Builder.GetName ().KeyPair == null))
+ flags &= ~(uint)AssemblyNameFlags.PublicKey;
+
+ try {
+ var fi = typeof (AssemblyBuilder).GetField ("flags", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.SetField);
+ fi.SetValue (CodeGen.Assembly.Builder, flags);
+ } catch {
+ Report.RuntimeMissingSupport (a.Location, "AssemblyFlagsAttribute setting");
+ }
+
+ return;
+ }
+
+ if (a.Type == pa.InternalsVisibleTo && !CheckInternalsVisibleAttribute (a))
+ return;
+
+ if (a.Type == pa.TypeForwarder) {
+ TypeSpec t = a.GetArgumentType ();
+ if (t == null || TypeManager.HasElementType (t)) {
+ Report.Error (735, a.Location, "Invalid type specified as an argument for TypeForwardedTo attribute");
+ return;
+ }
+
+ if (emitted_forwarders == null) {
+ emitted_forwarders = new Dictionary<ITypeDefinition, Attribute> ();
+ } else if (emitted_forwarders.ContainsKey (t.MemberDefinition)) {
+ Report.SymbolRelatedToPreviousError(emitted_forwarders[t.MemberDefinition].Location, null);
+ Report.Error(739, a.Location, "A duplicate type forward of type `{0}'",
+ TypeManager.CSharpName(t));
+ return;
+ }
+
+ emitted_forwarders.Add(t.MemberDefinition, a);
+
+ if (t.Assembly == Builder) {
+ Report.SymbolRelatedToPreviousError (t);
+ Report.Error (729, a.Location, "Cannot forward type `{0}' because it is defined in this assembly",
+ TypeManager.CSharpName (t));
+ return;
+ }
+
+ if (t.IsNested) {
+ Report.Error (730, a.Location, "Cannot forward type `{0}' because it is a nested type",
+ TypeManager.CSharpName (t));
+ return;
+ }
+
+ if (add_type_forwarder == null) {
+ add_type_forwarder = typeof (AssemblyBuilder).GetMethod ("AddTypeForwarder",
+ BindingFlags.NonPublic | BindingFlags.Instance);
+
+ if (add_type_forwarder == null) {
+ Report.RuntimeMissingSupport (a.Location, "TypeForwardedTo attribute");
+ return;
+ }
+ }
+
+ add_type_forwarder.Invoke (Builder, new object[] { t.GetMetaInfo () });
+ return;
+ }
+
+ if (a.Type == pa.Extension) {
+ a.Error_MisusedExtensionAttribute ();
+ return;