[ClassInterface (ClassInterfaceType.None)]
public sealed class AssemblyBuilder : Assembly, _AssemblyBuilder {
#region Sync with object-internals.h
- private IntPtr dynamic_assembly;
+ private UIntPtr dynamic_assembly; /* GC-tracked */
private MethodInfo entry_point;
private ModuleBuilder[] modules;
private string name;
this.access = (uint)access;
// don't call GetCurrentDirectory for Run-only builders (CAS may not like that)
- if (IsSave && (directory == null || directory == String.Empty)) {
+ if (IsSave && (directory == null || directory.Length == 0)) {
dir = Directory.GetCurrentDirectory ();
} else {
dir = directory;
}
#endif
+#if NET_2_0
+ [MonoTODO]
+ public override bool ReflectionOnly {
+ get { return base.ReflectionOnly; }
+ }
+#endif
+
public void AddResourceFile (string name, string fileName)
{
AddResourceFile (name, fileName, ResourceAttributes.Public);
win32_resources [win32_resources.Length - 1] = new MonoWin32Resource (res.Type.Id, res.Name.Id, res.Language, ms.ToArray ());
}
- [MonoTODO]
+ [MonoTODO ("Not currently implemenented")]
public void DefineUnmanagedResource (byte[] resource)
{
if (resource == null)
{
if (resourceFileName == null)
throw new ArgumentNullException ("resourceFileName");
- if (resourceFileName == String.Empty)
+ if (resourceFileName.Length == 0)
throw new ArgumentException ("resourceFileName");
if (!File.Exists (resourceFileName) || Directory.Exists (resourceFileName))
throw new FileNotFoundException ("File '" + resourceFileName + "' does not exists or is a directory.");
- using (FileStream fs = new FileStream (resourceFileName, FileMode.Open)) {
+ using (FileStream fs = new FileStream (resourceFileName, FileMode.Open, FileAccess.Read)) {
Win32ResFileReader reader = new Win32ResFileReader (fs);
foreach (Win32EncodedResource res in reader.ReadResources ()) {
public void DefineVersionInfoResource ()
{
if (version_res != null)
- throw new ArgumentException ("Native resource has already been defined.");
+ throw new ArgumentException ("Native resource has already been defined.");
version_res = new Win32VersionResource (1, 0);
version_res.LegalCopyright = cb.string_arg ();
else if (attrname == "System.Reflection.AssemblyTrademarkAttribute")
version_res.LegalTrademarks = cb.string_arg ();
- else if (attrname == "System.Reflection.AssemblyCultureAttribute")
- version_res.FileLanguage = new CultureInfo (GetCultureString (cb.string_arg ())).LCID;
+ else if (attrname == "System.Reflection.AssemblyCultureAttribute"){
+ int lcid;
+
+ try {
+ lcid = new CultureInfo (GetCultureString (cb.string_arg ())).LCID;
+ } catch (ArgumentException){
+ //
+ // This means that the resource is set to the invariant, but
+ // the locale encoded will come from the AssemblyName anyways.
+ //
+ // In fact, my exploration of MS.NEt shows that this is always
+ // set to zero, so I wonder if we should completely drop this
+ // code from here.
+ //
+ lcid = CultureInfo.InvariantCulture.LCID;
+ }
+ version_res.FileLanguage = lcid;
+ }
else if (attrname == "System.Reflection.AssemblyFileVersionAttribute")
version_res.FileVersion = cb.string_arg ();
else if (attrname == "System.Reflection.AssemblyInformationalVersionAttribute")
*/
version_res = new Win32VersionResource (1, 0);
- version_res.ProductName = product;
- version_res.ProductVersion = productVersion;
- version_res.CompanyName = company;
- version_res.LegalCopyright = copyright;
- version_res.LegalTrademarks = trademark;
+ version_res.ProductName = product != null ? product : " ";
+ version_res.ProductVersion = productVersion != null ? productVersion : " ";
+ version_res.CompanyName = company != null ? company : " ";
+ version_res.LegalCopyright = copyright != null ? copyright : " ";
+ version_res.LegalTrademarks = trademark != null ? trademark : " ";
}
/*
{
if (iconFileName == null)
throw new ArgumentNullException ("iconFileName");
- if (iconFileName == String.Empty)
+ if (iconFileName.Length == 0)
throw new ArgumentException ("iconFileName");
if (!File.Exists (iconFileName) || Directory.Exists (iconFileName))
throw new FileNotFoundException ("File '" + iconFileName + "' does not exists or is a directory.");
- using (FileStream fs = new FileStream (iconFileName, FileMode.Open)) {
+ using (FileStream fs = new FileStream (iconFileName, FileMode.Open, FileAccess.Read)) {
Win32IconFileReader reader = new Win32IconFileReader (fs);
ICONDIRENTRY[] entries = reader.ReadIcons ();
// Add missing info
if (version_res.Version == "0.0.0.0")
version_res.Version = version;
- if (version_res.FileVersion.Trim () == "" && version != null)
+ if (version_res.FileVersion.Trim ().Length == 0 && version != null)
version_res.FileVersion = version;
version_res.InternalName = Path.GetFileNameWithoutExtension (fileName);
version_res.OriginalFilename = fileName;
{
if (name == null)
throw new ArgumentNullException ("name");
- if (name == "")
- throw new ArgumentException ("Name can't be null");
+ if (name.Length == 0)
+ throw new ArgumentException ("Empty name is not legal.", "name");
if (modules != null)
for (int i = 0; i < modules.Length; ++i)
}
}
+#if NET_2_0
+ ModuleBuilder manifest_module;
+
+ //
+ // MS.NET seems to return a ModuleBuilder when GetManifestModule () is called
+ // on an assemblybuilder.
+ //
+ internal override Module GetManifestModule () {
+ if (manifest_module == null)
+ manifest_module = DefineDynamicModule ("Default Dynamic Module");
+ return manifest_module;
+ }
+#endif
+
#if NET_2_0
public
#else
throw new ArgumentNullException ("name");
if (fileName == null)
throw new ArgumentNullException ("fileName");
- if (name == "")
- throw new ArgumentException ("name cannot be empty", "name");
- if (fileName == "")
- throw new ArgumentException ("fileName cannot be empty", "fileName");
+ if (name.Length == 0)
+ throw new ArgumentException ("Empty name is not legal.", "name");
+ if (fileName.Length == 0)
+ throw new ArgumentException ("Empty file name is not legal.", "fileName");
if (Path.GetFileName (fileName) != fileName)
- throw new ArgumentException ("fileName '" + fileName + "' must not include a path.");
+ throw new ArgumentException ("fileName '" + fileName + "' must not include a path.", "fileName");
// Resource files are created/searched under the assembly storage
// directory