[Mono-dev] [PATCH] New managed code for unmanaged (Win32) resourcehandling (SRE, PEAPI, MCS)

Marek Safar marek.safar at seznam.cz
Tue Mar 7 14:31:20 EST 2006


Hello Kornél,
> Note that SRE and PEAPI parts were not discussed yet so I am waiting
> comments on those parts from component owners.
>
>> Well, I would prefer to use the memory solution.
>> 1. It's faster
>> 2. It's easier to implement, no problems with file removing, creating,
>> locking, etc.
>> 3. I don't believe that anyone will link more than 10 MB resource file.
>
> I think this is an important feature of my resource handling 
> infrastructure
> because you can use large resources if you want. But note that FileStream
> provides it's own buffering over OS file cache, so you will notice no (or
> little) difference for resource files smaller than 4K as they are 
> retained
> in memory by FileStream in fact. But note that only SRE is involved in 
> this
> question as mcs does no actual resource conversion.
My concern was not about speed, but about reliability. I just don't 
believe it is worthwhile
to utilize file system when it can be done in memory.
Are you sure that the filename will be unique even when you run several 
instances of mcs simultaneously ?

>> 2.  Please provide error tests for as many new error codes as possible.
>
> There are a lot of possible errors, but they are mapped to the same error
> code. BTW can I place invalid .ico and .res files in errors directory 
> where
> the .cs files are?
Yes, you can place there any files which you require for your test case.
It's good practice to use same file name as is name of test file, just 
add some prefix.

>> I prefer this method of code sharing instead of copying all the sources
>> to every file. Please use reflection to get instance of your internal
>> classes. I know you are using several fields, so if you really need them
>> then a solution can be to introduce interface e.g. IResource with all
>> required properties and methods and distribute only this interface file
>> across. Of course, you will need some factory method to create this
>> interface but that is the trivial part.
>
> The Resource Table generation code is included only in SRE. Also note 
> that
> there are at least 7 classes (including DefaultResource that is the 
> only one
> directly used by mcs) that are not included in SRE as mcs generates
> different default resource than SRE. And a lot of classes required by
> resource converter are not included in mcs as resource conversion is
> performed by SRE rather than mcs.
>
> I belive that it's better not to extend SRE with internal methods 
> intended
> to public use if it can be achieved using public methods available in 
> MS.NET
> as well. Whats the point of doing what you suggest?
You are saying that all these files are not used by corlib ?

--- mcs/mcs/mcs.exe.sources    (revision 57534)
+++ mcs/mcs/mcs.exe.sources    (working copy)
@@ -36,4 +36,31 @@
 ../class/Mono.CompilerServices.SymbolWriter/MonoSymbolTable.cs
 ../class/Mono.CompilerServices.SymbolWriter/MonoSymbolWriter.cs
 ../class/corlib/Mono.Security.Cryptography/CryptoConvert.cs
+../class/corlib/Mono.UnmanagedResources/BITMAPINFOHEADER.cs
+../class/corlib/Mono.UnmanagedResources/DefaultResource.cs
+../class/corlib/Mono.UnmanagedResources/IconInfoHeader.cs
+../class/corlib/Mono.UnmanagedResources/ICONRESDIR.cs
+../class/corlib/Mono.UnmanagedResources/NEWHEADER.cs
+../class/corlib/Mono.UnmanagedResources/RESDIR.cs
+../class/corlib/Mono.UnmanagedResources/ResInfo.cs
+../class/corlib/Mono.UnmanagedResources/ResourceException.cs
+../class/corlib/Mono.UnmanagedResources/ResourceFile.cs
+../class/corlib/Mono.UnmanagedResources/RESOURCEHEADER.cs
+../class/corlib/Mono.UnmanagedResources/ResourceIdentifier.cs
+../class/corlib/Mono.UnmanagedResources/ResourceMemoryFlags.cs
+../class/corlib/Mono.UnmanagedResources/ResourceName.cs
+../class/corlib/Mono.UnmanagedResources/ResourceNode.cs
+../class/corlib/Mono.UnmanagedResources/ResourceOrdinal.cs
+../class/corlib/Mono.UnmanagedResources/ResourceStream.cs
+../class/corlib/Mono.UnmanagedResources/ResourceTypes.cs
+../class/corlib/Mono.UnmanagedResources/VersionInfoBlock.cs
+../class/corlib/Mono.UnmanagedResources/VersionInfoBlockCollection.cs
+../class/corlib/Mono.UnmanagedResources/VersionInfoFileFlags.cs
+../class/corlib/Mono.UnmanagedResources/VersionInfoFileOSes.cs
+../class/corlib/Mono.UnmanagedResources/VersionInfoFileSubtypes.cs
+../class/corlib/Mono.UnmanagedResources/VersionInfoFileTypes.cs
+../class/corlib/Mono.UnmanagedResources/VersionInfoResource.cs
+../class/corlib/Mono.UnmanagedResources/VersionInfoString.cs
+../class/corlib/Mono.UnmanagedResources/VersionInfoWordArray.cs
+../class/corlib/Mono.UnmanagedResources/VS_FIXEDFILEINFO.cs

>> +            return ((languageId << 16) | codePage).ToString(upperCase ?
>> "X8" : "x8", CultureInfo.InvariantCulture);
>> Please use constants instead of X8, x8
>
> I don't really understand what you mean on using constants.
I just don't know what these x8 and X8 strings are. If you declare 
constant with some explanatory name
it will be easier to understand what they are used for.

Marek




More information about the Mono-devel-list mailing list