Thanks, I had seen that link already. How would I find Entity Framework
developers?
It looks like EF is using it to while iterating through the cache to
select the assembly which matches the assemblyname being passed in. The
function it is used in is
DefaultAssemblyResolver.ResolveAssembly and they use it as follows:
// look in the already loaded assemblies
foreach (var current in GetAlreadyLoadedNonSystemAssemblies())
{
if (AssemblyName.ReferenceMatchesDefinition(referenceName, new
AssemblyName(current.FullName)))
{
return current;
}
}
I had been looking at that link but it contradicts even the MSDN description.
It seems obvious that without logic to take version into account the version it
cannot resolve a correct from incorrect dll.
http://stackoverflow.com/questions/2494421/how-does-assemblyname-referencematchesdefinition-work
I was digging around on that link Somewhere on that page there is a response by
some other Microsoft developers, which give an explanation of the compare which
at least would be able to tell one dll from another in a meaning full way which
lead me to change the implementation to the following:
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.Equals(definition.Name,
StringComparison.InvariantCultureIgnoreCase))
{
return false;
}
//
http://stackoverflow.com/questions/2494421/how-does-assemblyname-referencematchesdefinition-work
// "A ReferenceIdentity matches a DefinitionIdentity,
if and only if the value of all the attributes
// specified in the ReferenceIdentity match the value
of the corresponding attributes of the DefinitionIdentity.
// If an attribute is missing in the ReferenceIdentity,
it matches any value for that attribute in DefinitionIdentity.
// For example, Ref “name” matches Def “name,
culture=neutral”, and Def “name, culture=en-us”.
// But Ref “name, culture=neutral” does not match Def
“name, culture=en-us”."
if (reference.CultureInfo != null)
{
if (definition.CultureInfo == null ||
reference.CultureInfo != definition.CultureInfo )
{
return false;
}
}.
byte [] refToken = reference.GetPublicKeyToken();
if (refToken != null && refToken.Length != 0)
{
byte [] defToken = definition.GetPublicKeyToken();
if (deftoken == null || defToken.Length != 4 ||
refToken[0] != defToken[0] || refToken[1] != defToken[1]
||
refToken[2] != defToken[2] || refToken[3] != defToken[3]
)
{
return false;
}
if (reference.Version != null)
{
if (definition.Version == null || reference.Version
!= definition.Version )
{
return false;
}
}
}
return true ;
}
Don't know how Im going to find entity Framework developers. I always will
write Unit Tests of course.
________________________________
From: Marek Safar-2 [via Mono] [ml-node+s1490590n4660696...@n4.nabble.com]
Sent: Wednesday, August 28, 2013 2:21 AM
To: Mark Lintner
Subject: Re: A possible implementation for
AssemblyName.ReferenceMatchesDefinition
Hi,
This API is broken by design and it's not clear what it should really do. It'd
probably be better to check with EF devs whether they really intended to use it
and for what purposes. Even for naive implementation please write unit test and
check whether it passes on .net
http://stackoverflow.com/questions/2494421/how-does-assemblyname-referencematchesdefinition-work
Marek
On Tue, Aug 27, 2013 at 5:29 PM, 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-tp4660683p4660696.html
To unsubscribe from A possible implementation for
AssemblyName.ReferenceMatchesDefinition, click
here<http://mono.1490590.n4.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=4660683&code=bWxpbnRuZXJAc2luZW5vbWluZS5uZXR8NDY2MDY4M3w2OTQwNjY1ODM=>.
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:
http://mono.1490590.n4.nabble.com/A-possible-implementation-for-AssemblyName-ReferenceMatchesDefinition-tp4660683p4660697.html
Sent from the Mono - Dev mailing list archive at Nabble.com.
_______________________________________________
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list