Skip to content
This repository has been archived by the owner on Oct 4, 2021. It is now read-only.

Commit

Permalink
[Core] Port remaining SystemAssemblyService Cecil code to IKVM
Browse files Browse the repository at this point in the history
  • Loading branch information
mhutch committed Feb 17, 2013
1 parent f1e5b50 commit 1344096
Showing 1 changed file with 7 additions and 23 deletions.
Expand Up @@ -29,17 +29,11 @@
//

using System;
using System.Threading;
using System.IO;
using System.Xml;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using MonoDevelop.Core.Execution;
using MonoDevelop.Core.AddIns;
using MonoDevelop.Core.Serialization;
using Mono.Addins;
using Mono.Cecil;
using System.Reflection;
using System.Linq;

Expand Down Expand Up @@ -321,15 +315,15 @@ static void BuildFrameworkRelations (TargetFramework fx, Dictionary<TargetFramew
//FIXME: this is totally broken. assemblies can't just belong to one framework
public TargetFrameworkMoniker GetTargetFrameworkForAssembly (TargetRuntime tr, string file)
{
var universe = new IKVM.Reflection.Universe ();
try {
AssemblyDefinition asm = AssemblyDefinition.ReadAssembly (file);

foreach (AssemblyNameReference aname in asm.MainModule.AssemblyReferences) {
if (aname.Name == "mscorlib") {
IKVM.Reflection.Assembly assembly = universe.LoadFile (file);
foreach (var r in assembly.GetReferencedAssemblies ()) {
if (r.Name == "mscorlib") {
TargetFramework compatibleFramework = null;
// If there are several frameworks that can run the file, pick one that is installed
foreach (TargetFramework tf in GetKnownFrameworks ()) {
if (tf.GetCorlibVersion () == aname.Version.ToString ()) {
if (tf.GetCorlibVersion () == r.Version.ToString ()) {
compatibleFramework = tf;
if (tr.IsInstalled (tf))
return tf.Id;
Expand All @@ -342,6 +336,8 @@ public TargetFrameworkMoniker GetTargetFrameworkForAssembly (TargetRuntime tr, s
}
} catch {
// Ignore
} finally {
universe.Dispose ();
}
return TargetFrameworkMoniker.UNKNOWN;
}
Expand Down Expand Up @@ -376,18 +372,6 @@ public static IEnumerable<string> GetAssemblyReferences (string fileName)
yield return r.Name;
}
}

/* CECIL version:
Mono.Cecil.AssemblyDefinition adef;
try {
adef = Mono.Cecil.AssemblyDefinition.ReadAssembly (fileName);
} catch {
yield break;
}
foreach (Mono.Cecil.AssemblyNameReference aref in adef.MainModule.AssemblyReferences) {
yield return aref.Name;
}*/
}

public class ManifestResource
Expand Down

0 comments on commit 1344096

Please sign in to comment.