{
FileName = output;
AssemblyName an = Assembly.GetAssemblyName (name, output);
+
+ if (an.KeyPair != null) {
+ // If we are going to strong name our assembly make
+ // sure all its refs are strong named
+ foreach (Assembly a in TypeManager.GetAssemblies ()) {
+ AssemblyName ref_name = a.GetName ();
+ byte [] b = ref_name.GetPublicKeyToken ();
+ if (b == null || b.Length == 0) {
+ Report.Warning (1577, "Assembly generation failed " +
+ "-- Referenced assembly '" +
+ ref_name.Name +
+ "' does not have a strong name.");
+ //Environment.Exit (1);
+ }
+ }
+ }
current_domain = AppDomain.CurrentDomain;
public abstract class CommonAssemblyModulClass: Attributable {
+ static string[] attribute_targets = new string [] { "assembly", "module" };
protected CommonAssemblyModulClass ():
base (null)
{
}
- public void AddAttribute (AttributeSection attr)
+ public void AddAttributes (ArrayList attrs)
{
if (OptAttributes == null) {
- OptAttributes = new Attributes (attr);
+ OptAttributes = new Attributes (attrs);
return;
}
- OptAttributes.AddAttributeSection (attr);
+ OptAttributes.AddAttributes (attrs);
+ OptAttributes.CheckTargets (ValidAttributeTargets);
}
public virtual void Emit (TypeContainer tc)
}
return a;
}
+
+ protected override string[] ValidAttributeTargets {
+ get {
+ return attribute_targets;
+ }
+ }
}
public class AssemblyClass: CommonAssemblyModulClass {
is_cls_compliant = a.GetClsCompliantAttributeValue (null);
}
- //TODO: this code is buggy because compare Attribute name without resolve is wrong
public AssemblyName GetAssemblyName (string name, string output)
{
if (OptAttributes != null) {
- foreach (AttributeSection asect in OptAttributes.AttributeSections) {
- if (asect.Target != "assembly")
+ foreach (Attribute a in OptAttributes.Attrs) {
+ if (a.Target != "assembly")
continue;
- // strongname attributes don't support AllowMultiple
- Attribute a = (Attribute) asect.Attributes [0];
+ // TODO: This code is buggy: comparing Attribute name without resolving it is wrong.
+ // However, this is invoked by CodeGen.Init, at which time none of the namespaces
+ // are loaded yet.
switch (a.Name) {
case "AssemblyKeyFile":
+ case "AssemblyKeyFileAttribute":
+ case "System.Reflection.AssemblyKeyFileAttribute":
if (RootContext.StrongNameKeyFile != null) {
Report.Warning (1616, "Compiler option -keyfile overrides " +
"AssemblyKeyFileAttribute");
}
break;
case "AssemblyKeyName":
+ case "AssemblyKeyNameAttribute":
+ case "System.Reflection.AssemblyKeyNameAttribute":
if (RootContext.StrongNameKeyContainer != null) {
Report.Warning (1616, "Compiler option -keycontainer overrides " +
"AssemblyKeyNameAttribute");
}
break;
case "AssemblyDelaySign":
+ case "AssemblyDelaySignAttribute":
+ case "System.Reflection.AssemblyDelaySignAttribute":
RootContext.StrongNameDelaySign = a.GetBoolean ();
break;
}
public class ModuleClass: CommonAssemblyModulClass {
// TODO: make it private and move all builder based methods here
public ModuleBuilder Builder;
-
bool m_module_is_unsafe;
public ModuleClass (bool is_unsafe)