Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarek Safar <marek.safar@gmail.com>2011-01-13 18:40:16 +0300
committerMarek Safar <marek.safar@gmail.com>2011-01-13 18:41:12 +0300
commit147580e6cc5f127a4204176f08f8ac128a8beeba (patch)
tree4861f2a36a97189fb835e986d3b5a3eb09d39b8e
parent50834de0dd1c5ca71fe472288e098528b2ca45b8 (diff)
Implement assembly name unification for imported references
-rw-r--r--mcs/class/IKVM.Reflection/Fusion.cs7
-rw-r--r--mcs/errors/CS1701-lib.cs6
-rw-r--r--mcs/errors/CS1702-lib.cs6
-rw-r--r--mcs/errors/CS1705-lib.cs6
-rw-r--r--mcs/errors/Makefile14
-rw-r--r--mcs/errors/cs1701.cs11
-rw-r--r--mcs/errors/cs1702.cs11
-rw-r--r--mcs/errors/cs1705.cs11
-rw-r--r--mcs/errors/dlls/first/CS1701-lib.cs6
-rw-r--r--mcs/errors/dlls/first/CS1702-lib.cs6
-rw-r--r--mcs/errors/dlls/first/CS1705-lib.cs6
-rw-r--r--mcs/errors/dlls/second/CS1701-lib.cs6
-rw-r--r--mcs/errors/dlls/second/CS1702-lib.cs6
-rw-r--r--mcs/errors/dlls/second/CS1705-lib.cs6
-rw-r--r--mcs/mcs/ikvm.cs45
-rw-r--r--mcs/mcs/report.cs2
-rw-r--r--mcs/tests/InternalsVisibleTest.snkbin596 -> 0 bytes
-rw-r--r--mcs/tests/Makefile2
-rw-r--r--mcs/tests/gtest-friend-00-lib.cs2
-rw-r--r--mcs/tests/gtest-friend-02-lib.cs2
-rw-r--r--mcs/tests/test-695-2-lib.cs2
21 files changed, 155 insertions, 8 deletions
diff --git a/mcs/class/IKVM.Reflection/Fusion.cs b/mcs/class/IKVM.Reflection/Fusion.cs
index 4e81cd20074..219cfd507de 100644
--- a/mcs/class/IKVM.Reflection/Fusion.cs
+++ b/mcs/class/IKVM.Reflection/Fusion.cs
@@ -57,7 +57,7 @@ namespace IKVM.Reflection
[DllImport("fusion", CharSet = CharSet.Unicode)]
private static extern int CompareAssemblyIdentity(string pwzAssemblyIdentity1, bool fUnified1, string pwzAssemblyIdentity2, bool fUnified2, out bool pfEquivalent, out AssemblyComparisonResult pResult);
- private static bool CompareAssemblyIdentityPure(string assemblyIdentity1, bool unified1, string assemblyIdentity2, bool unified2, out AssemblyComparisonResult result)
+ internal static bool CompareAssemblyIdentityPure(string assemblyIdentity1, bool unified1, string assemblyIdentity2, bool unified2, out AssemblyComparisonResult result)
{
ParsedAssemblyName name1;
ParsedAssemblyName name2;
@@ -141,6 +141,11 @@ namespace IKVM.Reflection
return true;
}
}
+ else if (IsStrongNamed(name1))
+ {
+ result = AssemblyComparisonResult.NonEquivalent;
+ return false;
+ }
else
{
result = partial ? AssemblyComparisonResult.EquivalentPartialWeakNamed : AssemblyComparisonResult.EquivalentWeakNamed;
diff --git a/mcs/errors/CS1701-lib.cs b/mcs/errors/CS1701-lib.cs
new file mode 100644
index 00000000000..7a4043f7dc4
--- /dev/null
+++ b/mcs/errors/CS1701-lib.cs
@@ -0,0 +1,6 @@
+public class A
+{
+ public static void Test (B b)
+ {
+ }
+}
diff --git a/mcs/errors/CS1702-lib.cs b/mcs/errors/CS1702-lib.cs
new file mode 100644
index 00000000000..7a4043f7dc4
--- /dev/null
+++ b/mcs/errors/CS1702-lib.cs
@@ -0,0 +1,6 @@
+public class A
+{
+ public static void Test (B b)
+ {
+ }
+}
diff --git a/mcs/errors/CS1705-lib.cs b/mcs/errors/CS1705-lib.cs
new file mode 100644
index 00000000000..7a4043f7dc4
--- /dev/null
+++ b/mcs/errors/CS1705-lib.cs
@@ -0,0 +1,6 @@
+public class A
+{
+ public static void Test (B b)
+ {
+ }
+}
diff --git a/mcs/errors/Makefile b/mcs/errors/Makefile
index 32b381eec11..fbea8c2b34f 100644
--- a/mcs/errors/Makefile
+++ b/mcs/errors/Makefile
@@ -33,6 +33,7 @@ TEST_SUPPORT_FILES = \
CS0730-lib.dll \
CS1542-lib.dll CS1577-lib.dll \
CS1685-2-lib.dll \
+ dlls/first/CS1701-lib.dll dlls/second/CS1701-lib.dll CS1701-lib.dll dlls/first/CS1702-lib.dll dlls/second/CS1702-lib.dll CS1702-lib.dll dlls/first/CS1705-lib.dll dlls/second/CS1705-lib.dll CS1705-lib.dll \
CS2015-lib.dll CS3005-16-lib.dll CS3013-module.dll CSExternAlias-lib.dll \
CSFriendAssembly-lib.dll \
dlls/first/CS1703-lib.dll dlls/first/CS1704-lib.dll \
@@ -81,14 +82,23 @@ run-mcs-tests: $(TEST_SUPPORT_FILES)
endif
clean-local:
- rm -f *.exe *.dll *.log *.mdb dummy.xml *.junk
+ rm -f *.exe *.dll *.log *.mdb dummy.xml *.junk dlls/first/*.dll dlls/second/*.dll
dist-local: dist-default
csproj-local install-local uninstall-local:
+CS1701-lib.dll : CS1701-lib.cs
+ $(CSCOMPILE) /target:library /warn:0 /r:dlls/first/CS1701-lib.dll /out:$@ $<
+
+CS1702-lib.dll : CS1702-lib.cs
+ $(CSCOMPILE) /target:library /warn:0 /r:dlls/first/CS1702-lib.dll /out:$@ $<
+
+CS1705-lib.dll : CS1705-lib.cs
+ $(CSCOMPILE) /target:library /warn:0 /r:dlls/first/CS1705-lib.dll /out:$@ $<
+
%-lib.dll: %-lib.cs
- $(CSCOMPILE) /target:library /out:$@ $<
+ $(CSCOMPILE) /target:library /warn:0 /out:$@ $<
%-module.dll: %-module.cs
$(CSCOMPILE) /target:module /out:$@ $<
diff --git a/mcs/errors/cs1701.cs b/mcs/errors/cs1701.cs
new file mode 100644
index 00000000000..04b29659c31
--- /dev/null
+++ b/mcs/errors/cs1701.cs
@@ -0,0 +1,11 @@
+// CS1701: Assuming assembly reference `CS1701-lib, Version=1.0.0.0, Culture=neutral, PublicKeyToken=36f3ae7e947792e3' matches assembly `CS1701-lib, Version=2.0.1.0, Culture=neutral, PublicKeyToken=36f3ae7e947792e3'. You may need to supply runtime policy
+// Line: 9
+// Compiler options: -warnaserror -r:CS1701-lib.dll -r:dlls/second/CS1701-lib.dll
+
+class C
+{
+ public static void Main ()
+ {
+ A.Test (new B ());
+ }
+}
diff --git a/mcs/errors/cs1702.cs b/mcs/errors/cs1702.cs
new file mode 100644
index 00000000000..898656384c1
--- /dev/null
+++ b/mcs/errors/cs1702.cs
@@ -0,0 +1,11 @@
+// CS1702: Assuming assembly reference `CS1702-lib, Version=1.0.0.0, Culture=neutral, PublicKeyToken=36f3ae7e947792e3' matches assembly `CS1702-lib, Version=1.0.1.0, Culture=neutral, PublicKeyToken=36f3ae7e947792e3'. You may need to supply runtime policy
+// Line: 9
+// Compiler options: -warnaserror -r:CS1702-lib.dll -r:dlls/second/CS1702-lib.dll
+
+class C
+{
+ public static void Main ()
+ {
+ A.Test (new B ());
+ }
+}
diff --git a/mcs/errors/cs1705.cs b/mcs/errors/cs1705.cs
new file mode 100644
index 00000000000..f9ce9bcd018
--- /dev/null
+++ b/mcs/errors/cs1705.cs
@@ -0,0 +1,11 @@
+// CS1705: Assembly `CS1705-lib, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' references `CS1705-lib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=36f3ae7e947792e3' which has higher version number than imported assembly `CS1705-lib, Version=1.0.0.0, Culture=neutral, PublicKeyToken=36f3ae7e947792e3'
+// Line: 9
+// Compiler options: -r:CS1705-lib.dll -r:dlls/second/CS1705-lib.dll
+
+class C
+{
+ public static void Main ()
+ {
+ A.Test (new B ());
+ }
+}
diff --git a/mcs/errors/dlls/first/CS1701-lib.cs b/mcs/errors/dlls/first/CS1701-lib.cs
new file mode 100644
index 00000000000..ea06316444a
--- /dev/null
+++ b/mcs/errors/dlls/first/CS1701-lib.cs
@@ -0,0 +1,6 @@
+[assembly:System.Reflection.AssemblyVersionAttribute ("1.0.0.0")]
+[assembly:System.Reflection.AssemblyKeyFile("key.snk")]
+
+public class B
+{
+} \ No newline at end of file
diff --git a/mcs/errors/dlls/first/CS1702-lib.cs b/mcs/errors/dlls/first/CS1702-lib.cs
new file mode 100644
index 00000000000..ea06316444a
--- /dev/null
+++ b/mcs/errors/dlls/first/CS1702-lib.cs
@@ -0,0 +1,6 @@
+[assembly:System.Reflection.AssemblyVersionAttribute ("1.0.0.0")]
+[assembly:System.Reflection.AssemblyKeyFile("key.snk")]
+
+public class B
+{
+} \ No newline at end of file
diff --git a/mcs/errors/dlls/first/CS1705-lib.cs b/mcs/errors/dlls/first/CS1705-lib.cs
new file mode 100644
index 00000000000..7207e973d3f
--- /dev/null
+++ b/mcs/errors/dlls/first/CS1705-lib.cs
@@ -0,0 +1,6 @@
+[assembly:System.Reflection.AssemblyVersionAttribute ("2.0.0.0")]
+[assembly:System.Reflection.AssemblyKeyFile("key.snk")]
+
+public class B
+{
+} \ No newline at end of file
diff --git a/mcs/errors/dlls/second/CS1701-lib.cs b/mcs/errors/dlls/second/CS1701-lib.cs
new file mode 100644
index 00000000000..d877923feb3
--- /dev/null
+++ b/mcs/errors/dlls/second/CS1701-lib.cs
@@ -0,0 +1,6 @@
+[assembly:System.Reflection.AssemblyVersionAttribute ("2.0.1.0")]
+[assembly:System.Reflection.AssemblyKeyFile("key.snk")]
+
+public class B
+{
+} \ No newline at end of file
diff --git a/mcs/errors/dlls/second/CS1702-lib.cs b/mcs/errors/dlls/second/CS1702-lib.cs
new file mode 100644
index 00000000000..56196aee3a9
--- /dev/null
+++ b/mcs/errors/dlls/second/CS1702-lib.cs
@@ -0,0 +1,6 @@
+[assembly:System.Reflection.AssemblyVersionAttribute ("1.0.1.0")]
+[assembly:System.Reflection.AssemblyKeyFile("key.snk")]
+
+public class B
+{
+} \ No newline at end of file
diff --git a/mcs/errors/dlls/second/CS1705-lib.cs b/mcs/errors/dlls/second/CS1705-lib.cs
new file mode 100644
index 00000000000..ea06316444a
--- /dev/null
+++ b/mcs/errors/dlls/second/CS1705-lib.cs
@@ -0,0 +1,6 @@
+[assembly:System.Reflection.AssemblyVersionAttribute ("1.0.0.0")]
+[assembly:System.Reflection.AssemblyKeyFile("key.snk")]
+
+public class B
+{
+} \ No newline at end of file
diff --git a/mcs/mcs/ikvm.cs b/mcs/mcs/ikvm.cs
index 73a7a404ddb..3b4d98adfa5 100644
--- a/mcs/mcs/ikvm.cs
+++ b/mcs/mcs/ikvm.cs
@@ -207,9 +207,52 @@ namespace Mono.CSharp
Assembly AssemblyReferenceResolver (object sender, IKVM.Reflection.ResolveEventArgs args)
{
- if (args.Name == "mscorlib")
+ var refname = args.Name;
+ if (refname == "mscorlib")
return corlib;
+ Assembly version_mismatch = null;
+ foreach (var assembly in domain.GetAssemblies ()) {
+ AssemblyComparisonResult result;
+ if (!Fusion.CompareAssemblyIdentity (refname, false, assembly.FullName, false, out result)) {
+ if ((result == AssemblyComparisonResult.NonEquivalentVersion || result == AssemblyComparisonResult.NonEquivalentPartialVersion) &&
+ (version_mismatch == null || version_mismatch.GetName ().Version < assembly.GetName ().Version)) {
+ version_mismatch = assembly;
+ }
+
+ continue;
+ }
+
+ if (result == AssemblyComparisonResult.EquivalentFXUnified ||
+ result == AssemblyComparisonResult.EquivalentFullMatch ||
+ result == AssemblyComparisonResult.EquivalentPartialMatch) {
+ return assembly;
+ }
+
+ throw new NotImplementedException ("Assembly equality = " + result.ToString ());
+ }
+
+ if (version_mismatch != null) {
+ var v1 = new AssemblyName (refname).Version;
+ var v2 = version_mismatch.GetName ().Version;
+
+ if (v1 > v2) {
+// compiler.Report.SymbolRelatedToPreviousError (args.RequestingAssembly.Location);
+ compiler.Report.Error (1705, "Assembly `{0}' references `{1}' which has higher version number than imported assembly `{2}'",
+ args.RequestingAssembly.FullName, refname, version_mismatch.GetName ().FullName);
+ } else if (v1.Major != v2.Major || v1.Minor != v2.Minor) {
+ compiler.Report.Warning (1701, 2,
+ "Assuming assembly reference `{0}' matches assembly `{1}'. You may need to supply runtime policy",
+ refname, version_mismatch.GetName ().FullName);
+ } else {
+ compiler.Report.Warning (1702, 3,
+ "Assuming assembly reference `{0}' matches assembly `{1}'. You may need to supply runtime policy",
+ refname, version_mismatch.GetName ().FullName);
+ }
+
+ return version_mismatch;
+ }
+
// AssemblyReference has not been found in the domain
// create missing reference and continue
return new MissingAssembly (domain, args.Name);
diff --git a/mcs/mcs/report.cs b/mcs/mcs/report.cs
index b2d3d1479ee..98ae95c57f3 100644
--- a/mcs/mcs/report.cs
+++ b/mcs/mcs/report.cs
@@ -63,7 +63,7 @@ namespace Mono.CSharp {
1030, 1058, 1066,
1522, 1570, 1571, 1572, 1573, 1574, 1580, 1581, 1584, 1587, 1589, 1590, 1591, 1592,
1607, 1616, 1633, 1634, 1635, 1685, 1690, 1691, 1692, 1695, 1696, 1699, 1683,
- 1700, 1709, 1717, 1718, 1720,
+ 1700, 1701, 1702, 1709, 1717, 1718, 1720,
1901, 1981,
2002, 2023, 2029,
3000, 3001, 3002, 3003, 3005, 3006, 3007, 3008, 3009,
diff --git a/mcs/tests/InternalsVisibleTest.snk b/mcs/tests/InternalsVisibleTest.snk
deleted file mode 100644
index 31de1711f57..00000000000
--- a/mcs/tests/InternalsVisibleTest.snk
+++ /dev/null
Binary files differ
diff --git a/mcs/tests/Makefile b/mcs/tests/Makefile
index 2950fa63629..ce7689944a0 100644
--- a/mcs/tests/Makefile
+++ b/mcs/tests/Makefile
@@ -107,3 +107,5 @@ setup:
$(CSCOMPILE) -t:library dlls/test-679-2/test-679-lib-2.cs
$(CSCOMPILE) -t:library dlls/test-679-1/test-679-lib.cs -r:dlls/test-679-2/test-679-lib-2.dll
+ $(CSCOMPILE) -t:library dlls/first/test-804-lib.cs
+ $(CSCOMPILE) -t:library dlls/second/test-804-lib.cs -r:dlls/first/test-804-lib.dll
diff --git a/mcs/tests/gtest-friend-00-lib.cs b/mcs/tests/gtest-friend-00-lib.cs
index bbdcf0ca5c1..6a4816f9279 100644
--- a/mcs/tests/gtest-friend-00-lib.cs
+++ b/mcs/tests/gtest-friend-00-lib.cs
@@ -1,4 +1,4 @@
-// Compiler options: -keyfile:InternalsVisibleTest.snk -t:library
+// Compiler options: -keyfile:key.snk -t:library
using System;
using System.Runtime.CompilerServices;
diff --git a/mcs/tests/gtest-friend-02-lib.cs b/mcs/tests/gtest-friend-02-lib.cs
index 39b0637681f..f16d9feba06 100644
--- a/mcs/tests/gtest-friend-02-lib.cs
+++ b/mcs/tests/gtest-friend-02-lib.cs
@@ -1,4 +1,4 @@
-// Compiler options: -keyfile:InternalsVisibleTest.snk -t:library
+// Compiler options: -keyfile:key.snk -t:library
using System;
using System.Runtime.CompilerServices;
diff --git a/mcs/tests/test-695-2-lib.cs b/mcs/tests/test-695-2-lib.cs
index 0c8b7f9abbe..0fd7ef85fa8 100644
--- a/mcs/tests/test-695-2-lib.cs
+++ b/mcs/tests/test-695-2-lib.cs
@@ -1,4 +1,4 @@
-// Compiler options: -t:library -keyfile:InternalsVisibleTest.snk
+// Compiler options: -t:library -keyfile:key.snk
class Foo
{