[Mono-dev] A possible implementation for AssemblyName.ReferenceMatchesDefinition

Daniel Lo Nigro lists at dan.cx
Wed Aug 28 00:57:43 UTC 2013


It looks like the behaviour may have changed between .NET versions... The
MSDN page for .NET Framework 3.5 onwards (including 4.5) states:

Returns a value indicating whether two assembly names are the same. The
> comparison is based on the simple assembly names.
> return value - true if the simple assembly names are the same; otherwise,
> false.
> The comparison depends only on the simple assembly name. It ignores
> version, culture, and public key token.


But the .NET Framework 2.0
page<http://msdn.microsoft.com/en-us/library/system.reflection.assemblyname.referencematchesdefinition(v=vs.80).aspx>states:

Returns a value indicating whether the loader resolves two assembly names
> to the same assembly.
> Return Value - true if the loader resolves definition to the same assembly
> as reference; otherwise, false.
> Both reference and definition are resolved by the loader, including policy
> evaluation, and then definition is tested for equality to reference.


It sounds like it did a lot more work in the .NET 2.0 implementation. Not
sure why it changed and I can't seem to find much information on it.



On Wed, Aug 28, 2013 at 10:46 AM, mlgo <mlintner at sinenomine.net> wrote:

>  Right. Thanks. I hadn't thought about that. I keep suspecting that the
> documentation is not right though. That in fact what needs to be done is
> determine if the names actually refer to the same dll. Hopefully someone
> can reply to this who knows more about the internals of this. Otherwise
> I need to find some more real world uses of it in dotnet source code so I
> can better understand if this is the right way to go.
> ------------------------------
>
>  *From:* Daniel Lo Nigro [via Mono] [ml-node+[hidden email]<http://user/SendEmail.jtp?type=node&node=4660692&i=0>
> ]
> *Sent:* Tuesday, August 27, 2013 7:20 PM
> *To:* Mark Lintner
> *Subject:* Re: A possible implementation for
> AssemblyName.ReferenceMatchesDefinition
>
>   You may want to ignore culture and case in your comparison:
>
>  return reference.Name.Equals(definition.Name,
> StringComparison.InvariantCultureIgnoreCase)
>
>
>
> On Wed, Aug 28, 2013 at 1:29 AM, mlgo <[hidden email]<https://connect.emailsrvr.com/owa/UrlBlockedError.aspx>
> > wrote:
>
>> According to
>>
>> http://msdn.microsoft.com/en-us/library/system.reflection.assemblyname.referencematchesdefinition.aspx
>>
>> The following is what is expected to be returned from
>> ReferenceMatchesDefinition.
>>
>> Returns a value indicating whether two assembly names are the same. The
>> comparison is based on the simple assembly names.
>>
>> This seems naïve but below is a tentative implementation of that. Any
>> ideas?
>>
>> public static bool ReferenceMatchesDefinition (AssemblyName reference,
>> AssemblyName definition)
>>                 {
>>                         if (reference == null)
>>                                 throw new ArgumentNullException
>> ("reference");
>>                         if (definition == null)
>>                                 throw new ArgumentNullException
>> ("definition");
>>                         if (reference.Name != definition.Name)
>>                                 return false;
>>
>>                         return reference.Name.Equals(definition.Name);
>>                 }
>>
>>
>>
>>
>> --
>> View this message in context:
>> http://mono.1490590.n4.nabble.com/A-possible-implementation-for-AssemblyName-ReferenceMatchesDefinition-tp4660683.html
>> Sent from the Mono - Dev mailing list archive at Nabble.com.
>> _______________________________________________
>> Mono-devel-list mailing list
>> [hidden email] <https://connect.emailsrvr.com/owa/UrlBlockedError.aspx>
>> http://lists.ximian.com/mailman/listinfo/mono-devel-list
>>
>
>
> _______________________________________________
> Mono-devel-list mailing list
> [hidden email] <https://connect.emailsrvr.com/owa/UrlBlockedError.aspx>
> http://lists.ximian.com/mailman/listinfo/mono-devel-list
>
>
> ------------------------------
>  If you reply to this email, your message will be added to the discussion
> below:
>
> http://mono.1490590.n4.nabble.com/A-possible-implementation-for-AssemblyName-ReferenceMatchesDefinition-tp4660683p4660691.html
>  To unsubscribe from A possible implementation for
> AssemblyName.ReferenceMatchesDefinition, click here.
> NAML<http://mono.1490590.n4.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>
> ------------------------------
> View this message in context: RE: A possible implementation for
> AssemblyName.ReferenceMatchesDefinition<http://mono.1490590.n4.nabble.com/A-possible-implementation-for-AssemblyName-ReferenceMatchesDefinition-tp4660683p4660692.html>
>
> Sent from the Mono - Dev mailing list archive<http://mono.1490590.n4.nabble.com/Mono-Dev-f1517221.html>at Nabble.com.
>
> _______________________________________________
> Mono-devel-list mailing list
> Mono-devel-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-devel-list
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ximian.com/pipermail/mono-devel-list/attachments/20130828/d2f7db15/attachment-0001.html>


More information about the Mono-devel-list mailing list