public MetadataWriter(AssemblyDefinition asm, MetadataRoot root, AssemblyKind kind, TargetRuntime rt, BinaryWriter writer) { m_assembly = asm; m_root = root; m_runtime = rt; m_imgWriter = new ImageWriter (this, kind, writer); m_binaryWriter = m_imgWriter.GetTextWriter (); m_stringCache = new Hashtable (); m_stringWriter = new MemoryBinaryWriter (Encoding.UTF8); m_stringWriter.Write ((byte) 0); m_guidCache = new Hashtable (); m_guidWriter = new MemoryBinaryWriter (); m_usCache = new Hashtable (); m_usWriter = new MemoryBinaryWriter (Encoding.Unicode); m_usWriter.Write ((byte) 0); m_blobCache = new Hashtable (); m_blobWriter = new MemoryBinaryWriter (); m_blobWriter.Write ((byte) 0); m_tWriter = new MemoryBinaryWriter (); m_tableWriter = new MetadataTableWriter (this, m_tWriter); m_cilWriter = new MemoryBinaryWriter (); m_fieldDataWriter = new MemoryBinaryWriter (); m_resWriter = new MemoryBinaryWriter (); }
static string FindXmlDocumentation(string assemblyFileName, TargetRuntime runtime) { string fileName; switch (runtime) { case TargetRuntime.Net_1_0: fileName = LookupLocalizedXmlDoc(Path.Combine(frameworkPath, "v1.0.3705", assemblyFileName)); break; case TargetRuntime.Net_1_1: fileName = LookupLocalizedXmlDoc(Path.Combine(frameworkPath, "v1.1.4322", assemblyFileName)); break; case TargetRuntime.Net_2_0: fileName = LookupLocalizedXmlDoc(Path.Combine(frameworkPath, "v2.0.50727", assemblyFileName)) ?? LookupLocalizedXmlDoc(Path.Combine(referenceAssembliesPath, "v3.5")) ?? LookupLocalizedXmlDoc(Path.Combine(referenceAssembliesPath, "v3.0")) ?? LookupLocalizedXmlDoc(Path.Combine(referenceAssembliesPath, @".NETFramework\v3.5\Profile\Client")); break; case TargetRuntime.Net_4_0: default: fileName = LookupLocalizedXmlDoc(Path.Combine(referenceAssembliesPath, @".NETFramework\v4.0", assemblyFileName)) ?? LookupLocalizedXmlDoc(Path.Combine(frameworkPath, "v4.0.30319", assemblyFileName)); break; } return fileName; }
public static AssemblyDefinition DefineAssembly(string assemblyName, string moduleName, TargetRuntime rt, AssemblyKind kind) { AssemblyNameDefinition asmName = new AssemblyNameDefinition (); asmName.Name = assemblyName; AssemblyDefinition asm = new AssemblyDefinition (asmName); asm.Runtime = rt; asm.Kind = kind; ModuleDefinition main = new ModuleDefinition (moduleName, asm, true); asm.Modules.Add (main); return asm; }
public void ParseTargetPlatformDirectory(TargetRuntime runtime, string platformDirectory) { targetRuntime = runtime; targetPlatformDirectory = platformDirectory; if (!string.IsNullOrEmpty(targetPlatformDirectory)) { if (!Directory.Exists(targetPlatformDirectory)) throw new ArgumentException("Platform directory not found: \"" + targetPlatformDirectory + "\"."); } }
public static string LoadAssembly(TargetRuntime runtime, string file) { string name = "Assembly:" + runtime.Id + ":" + Path.GetFullPath(file); if (GetDom(name, true) != null) { return(name); } else { return(null); } }
public static MonoDebuggerStartInfo CreateDebuggerStartInfo(TargetRuntime tr) { if (tr == null) { tr = MonoDevelop.Core.Runtime.SystemAssemblyService.DefaultRuntime; } MonoDebuggerStartInfo startInfo = new MonoDebuggerStartInfo(); MonoTargetRuntime mtr = (MonoTargetRuntime)tr; startInfo.ServerEnvironment = mtr.EnvironmentVariables; startInfo.MonoPrefix = mtr.Prefix; return(startInfo); }
internal ModuleDefinition(Image image) : this() { this.Image = image; this.kind = image.Kind; this.runtime = image.Runtime; this.architecture = image.Architecture; this.attributes = image.Attributes; this.characteristics = image.Characteristics; this.fq_name = image.FileName; this.reader = new MetadataReader(this); }
public void ParseTargetPlatformDirectory(TargetRuntime runtime, string platformDirectory) { targetRuntime = runtime; targetPlatformDirectory = platformDirectory; if (!string.IsNullOrEmpty(targetPlatformDirectory)) { if (!Directory.Exists(targetPlatformDirectory)) { throw new ArgumentException("Platform directory not found: \"" + targetPlatformDirectory + "\"."); } } }
public override Int32 GetHashCode() { Int32 hashCode = 0; hashCode += AssemblyName.GetHashCode(); hashCode -= TargetRuntime.GetHashCode(); hashCode += TargetArchitecture.GetHashCode(); hashCode -= ExecutionRuntime.GetHashCode(); hashCode += ExecutionArchitecture.GetHashCode(); hashCode -= FileName.GetHashCode(); hashCode += MethodName.GetHashCode(); return(hashCode); }
public static string RuntimeVersionString (this TargetRuntime runtime) { switch (runtime) { case TargetRuntime.Net_1_0: return "v1.0.3705"; case TargetRuntime.Net_1_1: return "v1.1.4322"; case TargetRuntime.Net_2_0: return "v2.0.50727"; case TargetRuntime.Net_4_0: default: return "v4.0.30319"; } }
public string GetPath(TargetRuntime targetRuntime) { switch (targetRuntime) { case TargetRuntime.NetFramework: return("JitHosts\\NetFramework"); case TargetRuntime.NetCore: return("JitHosts\\NetCore"); default: throw new ArgumentOutOfRangeException(nameof(targetRuntime), targetRuntime, null); } }
/// <summary> /// Gets the project builder exe to be used to for a specific runtime and tools version /// </summary> static string GetExeLocation(TargetRuntime runtime, string toolsVersion, bool requiresMicrosoftBuild) { // If the builder for the latest MSBuild tools is being requested, return a local copy of the exe. // That local copy is configured to add additional msbuild search paths defined by add-ins. var mainExe = GetMSBuildExeLocationInBundle(runtime); var exe = GetExeLocationInBundle(runtime, toolsVersion, requiresMicrosoftBuild); if (exe == mainExe) { return(GetLocalMSBuildExeLocation(runtime)); } return(exe); }
static string GetCompilerName(TargetRuntime runtime, TargetFramework fx) { string csc = runtime.GetToolPath(fx, "csc"); if (csc != null) { return(csc); } else { string message = GettextCatalog.GetString("C# compiler not found for {0}.", fx.Name); LoggingService.LogError(message); throw new Exception(message); } }
void Init() { //set the framework to an available SL version //FIXME: we need to base these on the MSBuild targets, so that changes are persisted var fx = Runtime.SystemAssemblyService.GetTargetFramework("SL3.0"); if (TargetRuntime.IsInstalled(fx)) { TargetFramework = fx; } else { TargetFramework = Runtime.SystemAssemblyService.GetTargetFramework("SL2.0"); } }
public static string RuntimeVersionString(this TargetRuntime runtime) { switch (runtime) { case TargetRuntime.Net_1_0: return("v1.0.3705"); case TargetRuntime.Net_1_1: return("v1.1.4322"); case TargetRuntime.Net_2_0: return("v2.0.50727"); } return("v4.0.30319"); }
public void ParseTargetPlatformDirectory(TargetRuntime runtime, string platformDirectory) { targetRuntime = runtime; targetPlatformDirectory = platformDirectory; if (string.IsNullOrEmpty(targetPlatformDirectory) && (runtime != sourceRuntime)) GetPlatformPath(runtime); if (!string.IsNullOrEmpty(targetPlatformDirectory)) { if (!Directory.Exists(targetPlatformDirectory)) throw new ArgumentException("Platform directory not found: \"" + targetPlatformDirectory + "\"."); // TODO: only tested for Windows, not for Mono! //if (!File.Exists(Path.Combine(targetPlatformDirectory, "mscorlib.dll"))) // throw new ArgumentException("Invalid platform directory: \"" + targetPlatformDirectory + "\" (mscorlib.dll not found)."); } }
static MSBuildSdks() { TargetRuntime runtime = IdeApp.Preferences.DefaultTargetRuntime; string binPath = runtime.GetMSBuildBinPath("15.0"); if (binPath != null) { string sdksPath = Path.Combine(binPath, "Sdks"); if (Directory.Exists(sdksPath)) { Installed = true; MSBuildSDKsPath = sdksPath; } } }
public IList <ItemToolboxNode> LoadItemsIsolated(TargetRuntime runtime, Type loaderType, string filename) { if (!typeof(IExternalToolboxLoader).IsAssignableFrom(loaderType)) { throw new InvalidOperationException("Type '" + loaderType + "' does not implement 'IExternalToolboxLoader'"); } try { ExternalItemLoader loader = CreateExternalLoader <ExternalItemLoader> (runtime); string s = loader.LoadItems(loaderType.Assembly.FullName, loaderType.FullName, filename); XmlDataSerializer ser = new XmlDataSerializer(MonoDevelop.Projects.Services.ProjectService.DataContext); ToolboxList list = (ToolboxList)ser.Deserialize(new StringReader(s), typeof(ToolboxList)); return(list); } catch { return(new List <ItemToolboxNode> ()); } }
private static string FindXmlDocumentation(string moduleFileName, TargetRuntime runtime) { string fileName; switch (runtime) { case TargetRuntime.Net_1_0: #if !NET35 fileName = LookupXmlDoc(Path.Combine(frameworkPath, "v1.0.3705", moduleFileName)); #else fileName = LookupXmlDoc(Path.Combine(Path.Combine(frameworkPath, "v1.0.3705"), moduleFileName)); #endif break; case TargetRuntime.Net_1_1: #if !NET35 fileName = LookupXmlDoc(Path.Combine(frameworkPath, "v1.1.4322", moduleFileName)); #else fileName = LookupXmlDoc(Path.Combine(Path.Combine(frameworkPath, "v1.1.4322"), moduleFileName)); #endif break; case TargetRuntime.Net_2_0: #if !NET35 fileName = LookupXmlDoc(Path.Combine(frameworkPath, "v2.0.50727", moduleFileName)) ?? LookupXmlDoc(Path.Combine(referenceAssembliesPath, "v3.5", moduleFileName)) ?? LookupXmlDoc(Path.Combine(referenceAssembliesPath, @"v3.0\en", moduleFileName)) ?? LookupXmlDoc(Path.Combine(referenceAssembliesPath, @".NETFramework\v3.5\Profile\Client", moduleFileName)); #else fileName = LookupXmlDoc(Path.Combine(Path.Combine(frameworkPath, "v2.0.50727"), moduleFileName)) ?? LookupXmlDoc(Path.Combine(Path.Combine(referenceAssembliesPath, "v3.5"), moduleFileName)) ?? LookupXmlDoc(Path.Combine(Path.Combine(referenceAssembliesPath, @"v3.0\en"), moduleFileName)) ?? LookupXmlDoc(Path.Combine(Path.Combine(referenceAssembliesPath, @".NETFramework\v3.5\Profile\Client"), moduleFileName)); #endif break; case TargetRuntime.Net_4_0: #if !NET35 fileName = LookupXmlDoc(Path.Combine(referenceAssembliesPath, @".NETFramework\v4.0", moduleFileName)) ?? LookupXmlDoc(Path.Combine(frameworkPath, "v4.0.30319", moduleFileName)); #else fileName = LookupXmlDoc(Path.Combine(Path.Combine(referenceAssembliesPath, @".NETFramework\v4.0"), moduleFileName)) ?? LookupXmlDoc(Path.Combine(Path.Combine(frameworkPath, "v4.0.30319"), moduleFileName)); #endif break; default: fileName = null; break; } return fileName; }
private void Validate( List <ResolvedInjectedMethod> injectedMethods, List <ResolvedInjecteeAssembly> injecteeAssemblies ) { AssemblyDefinition minInjecteeTargetRuntimeAssemblyDefinition = null; AssemblyDefinition maxInjectedTargetRuntimeAssemblyDefinition = null; foreach (ResolvedInjectedMethod injectedMethod in injectedMethods) { AssemblyDefinition assemblyDefinition = injectedMethod.MethodDefinition.Module.Assembly; TargetRuntime targetRuntime = assemblyDefinition.MainModule.Runtime; if (maxInjectedTargetRuntimeAssemblyDefinition == null || targetRuntime < maxInjectedTargetRuntimeAssemblyDefinition.MainModule.Runtime) { maxInjectedTargetRuntimeAssemblyDefinition = assemblyDefinition; } } foreach (ResolvedInjecteeAssembly injecteeAssembly in injecteeAssemblies) { AssemblyDefinition assemblyDefinition = injecteeAssembly.AssemblyDefinition; TargetRuntime targetRuntime = assemblyDefinition.MainModule.Runtime; if (minInjecteeTargetRuntimeAssemblyDefinition == null || targetRuntime > minInjecteeTargetRuntimeAssemblyDefinition.MainModule.Runtime) { minInjecteeTargetRuntimeAssemblyDefinition = assemblyDefinition; } } if (maxInjectedTargetRuntimeAssemblyDefinition == null) { throw new InvalidOperationException(nameof(maxInjectedTargetRuntimeAssemblyDefinition) + " == null"); } foreach (ResolvedInjecteeAssembly injecteeAssembly in injecteeAssemblies) { if (injecteeAssembly.AssemblyDefinition.MainModule.Runtime < maxInjectedTargetRuntimeAssemblyDefinition.MainModule.Runtime) { throw new MethodInlineInjectorException( $"Injectee assembly '{injecteeAssembly.AssemblyDefinition}' " + $"uses runtime version {injecteeAssembly.AssemblyDefinition.MainModule.Runtime}, " + $"but assembly '{maxInjectedTargetRuntimeAssemblyDefinition}' used in injection uses runtime " + $"version {maxInjectedTargetRuntimeAssemblyDefinition.MainModule.Runtime}." ); } } }
async Task RestoreWorkspacePreferences (WorkspaceItem item) { // Restore local configuration data try { WorkspaceUserData data = item.UserProperties.GetValue<WorkspaceUserData> ("MonoDevelop.Ide.Workspace"); if (data != null) { ActiveExecutionTarget = null; if (GetConfigurations ().Contains (data.ActiveConfiguration)) activeConfiguration = data.ActiveConfiguration; else activeConfiguration = GetBestDefaultConfiguration (); if (string.IsNullOrEmpty (data.ActiveRuntime)) UseDefaultRuntime = true; else { TargetRuntime tr = Runtime.SystemAssemblyService.GetTargetRuntime (data.ActiveRuntime); if (tr != null) ActiveRuntime = tr; else UseDefaultRuntime = true; } OnActiveConfigurationChanged (); } else { ActiveConfigurationId = GetBestDefaultConfiguration (); } } catch (Exception ex) { LoggingService.LogError ("Exception while loading user solution preferences.", ex); } // Allow add-ins to restore preferences if (LoadingUserPreferences != null) { UserPreferencesEventArgs args = new UserPreferencesEventArgs (item, item.UserProperties); try { foreach (AsyncEventHandler<UserPreferencesEventArgs> d in LoadingUserPreferences.GetInvocationList ()) await d (this, args); } catch (Exception ex) { LoggingService.LogError ("Exception in LoadingUserPreferences.", ex); } } }
static string GetExeLocation(TargetRuntime runtime, string toolsVersion) { FilePath sourceExe = typeof(MSBuildProjectService).Assembly.Location; if ((runtime is MsNetTargetRuntime) && int.Parse(toolsVersion.Split('.')[0]) >= 4) { toolsVersion = "dotnet." + toolsVersion; } var exe = sourceExe.ParentDirectory.Combine("MSBuild", toolsVersion, "MonoDevelop.Projects.Formats.MSBuild.exe"); if (File.Exists(exe)) { return(exe); } throw new InvalidOperationException("Unsupported MSBuild ToolsVersion '" + toolsVersion + "'"); }
private TargetRuntime ParseTargetPlatform() { TargetRuntime runtime = PrimaryAssemblyMainModule.Runtime; if (Options.TargetPlatformVersion != null) { switch (Options.TargetPlatformVersion) { case "v2": runtime = TargetRuntime.Net_2_0; break; case "v4": runtime = TargetRuntime.Net_4_0; break; default: throw new ArgumentException($"Invalid TargetPlatformVersion: '{Options.TargetPlatformVersion}'"); } _platformFixer.ParseTargetPlatformDirectory(runtime, Options.TargetPlatformDirectory); } return(runtime); }
static string FindXmlDocumentation(FileName assemblyFileName, TargetRuntime runtime) { // First, look in the same directory as the assembly. // This usually works for .NET reference assembies and 3rd party libraries string xmlFileName = LookupLocalizedXmlDoc(assemblyFileName); if (xmlFileName != null) { return(xmlFileName); } // Otherwise, assume the assembly is part of .NET and try looking // in the framework directory. // (if the assembly is not part of .NET, we won't find anything there) string name = assemblyFileName.GetFileName(); switch (runtime) { case TargetRuntime.Net_1_0: xmlFileName = LookupLocalizedXmlDoc(Path.Combine(frameworkPath, "v1.0.3705", name)); break; case TargetRuntime.Net_1_1: xmlFileName = LookupLocalizedXmlDoc(Path.Combine(frameworkPath, "v1.1.4322", name)); break; case TargetRuntime.Net_2_0: xmlFileName = LookupLocalizedXmlDoc(Path.Combine(referenceAssembliesPath, "v3.5", name)) ?? LookupLocalizedXmlDoc(Path.Combine(referenceAssembliesPath, @".NETFramework\v3.5\Profile\Client", name)) ?? LookupLocalizedXmlDoc(Path.Combine(referenceAssembliesPath, "v3.0", name)) ?? LookupLocalizedXmlDoc(Path.Combine(frameworkPath, "v2.0.50727", name)); break; case TargetRuntime.Net_4_0: default: xmlFileName = LookupLocalizedXmlDoc(Path.Combine(referenceAssembliesPath, @".NETFramework\v4.6", name)) ?? LookupLocalizedXmlDoc(Path.Combine(referenceAssembliesPath, @".NETFramework\v4.5.2", name)) ?? LookupLocalizedXmlDoc(Path.Combine(referenceAssembliesPath, @".NETFramework\v4.5.1", name)) ?? LookupLocalizedXmlDoc(Path.Combine(referenceAssembliesPath, @".NETFramework\v4.5", name)) ?? LookupLocalizedXmlDoc(Path.Combine(referenceAssembliesPath, @".NETFramework\v4.0", name)) ?? LookupLocalizedXmlDoc(Path.Combine(frameworkPath, "v4.0.30319", name)); break; } return(xmlFileName); }
public MonoRuntimePanelWidget() { this.Build(); textview1.SetMarkup(textview1.Buffer.Text); labelRunning.Markup = GettextCatalog.GetString( "{0} is currently running on <b>{1}</b>.", BrandingService.ApplicationName, Runtime.SystemAssemblyService.CurrentRuntime.DisplayName ); store = new ListStore(typeof(string), typeof(object)); tree.Model = store; tree.SearchColumn = -1; // disable the interactive search CellRendererText crt = new CellRendererText(); tree.AppendColumn(GettextCatalog.GetString("Runtime"), crt, "markup", 0); TargetRuntime defRuntime = IdeApp.Preferences.DefaultTargetRuntime; foreach (TargetRuntime tr in Runtime.SystemAssemblyService.GetTargetRuntimes()) { string name = tr.DisplayName; TreeIter it; if (tr == defRuntime) { name = string.Format("<b>{0} {1}</b>", name, GettextCatalog.GetString("(Default)")); defaultIter = it = store.AppendValues(name, tr); } else { it = store.AppendValues(name, tr); } if (tr.IsRunning) { runningIter = it; } } tree.Selection.Changed += HandleChanged; UpdateButtons(); SetupAccessibility(); }
protected override void Initialize(TargetRuntime runtime, TargetFramework framework) { base.Initialize(runtime, framework); fxVersion = GetFxVersion(framework); foreach (var dir in GetMoonDirectories()) { var fxdir = dir.Combine(fxVersion); var buildVersion = fxdir.Combine("buildversion"); if (Directory.Exists(fxdir) && Directory.Exists(fxdir + "-redist") && File.Exists(buildVersion)) { if (LoadVersionString(buildVersion) && RegisterRedistAssemblies(dir)) { this.location = dir; } break; } } }
private int DoLoadRules(System.Reflection.Assembly assembly, AssemblyCache cache, Severity severity, bool ignoreBreaks) { int count = 0; TargetRuntime runtime = cache.Assembly.Runtime; #if DEBUG m_checkIDs.Add("C1004"); // rule failed rule #endif Type[] types = assembly.GetTypes(); foreach (Type t in types) { if (t.IsClass && !t.IsAbstract && typeof(Rule).IsAssignableFrom(t)) { try { object o = Activator.CreateInstance(t, new object[] { cache, this }); Rule rule = (Rule)o; if (rule.Runtime <= runtime) { if (DoRuleRequiresCheck(rule.CheckID, severity, ignoreBreaks)) { rule.Register(m_dispatcher); m_rules.Add(rule); } } ++count; #if DEBUG m_checkIDs.Add(rule.CheckID); #endif } catch (Exception e) { Console.Error.WriteLine("Couldn't instantiate {0}", t); Console.Error.WriteLine(e.Message); Log.ErrorLine(this, e.StackTrace); } } } return(count); }
public void NotApplicableBefore2_0() { // ensure that the rule does not apply for types defined in 1.x assemblies TypeDefinition violator = DefinitionLoader.GetTypeDefinition <NoUseOfGenerics> (); TargetRuntime realRuntime = violator.Module.Runtime; try { // fake assembly runtime version and do the check violator.Module.Runtime = TargetRuntime.Net_1_1; Rule.Active = true; Rule.Initialize(Runner); Assert.IsFalse(Rule.Active, "Active"); } catch { // rollback violator.Module.Runtime = realRuntime; Rule.Active = true; } }
public void Initialize() { // ensure that the rule does not apply for types defined in 1.x assemblies TypeDefinition violator = DefinitionLoader.GetTypeDefinition <ConsiderUsingStopwatchTest> (); TargetRuntime realRuntime = violator.Module.Runtime; try { // fake assembly runtime version and do the check violator.Module.Runtime = TargetRuntime.Net_1_1; Rule.Active = true; Rule.Initialize(Runner); Assert.IsFalse(Rule.Active, "Active"); } catch { // rollback violator.Module.Runtime = realRuntime; Rule.Active = true; } }
private static string GetDotNetVersion(TargetRuntime runtime) { switch (runtime) { case TargetRuntime.Net_1_0: return("1.0.3705"); case TargetRuntime.Net_1_1: return("1.1.4322"); case TargetRuntime.Net_2_0: return("2.0.50727"); case TargetRuntime.Net_4_0: return("4.0.30319"); } return("UNKNOWN"); }
//if possible, find a ClrVersion that the language binding can handle TargetFramework GetValidFrameworkVersion(TargetFramework suggestion) { if (suggestion == null) { if (LanguageBinding == null) { return(null); } else { suggestion = Services.ProjectService.DefaultTargetFramework; } } if (SupportsFramework(suggestion)) { return(suggestion); } TargetFramework oneSupported = null; foreach (TargetFramework f in Runtime.SystemAssemblyService.GetTargetFrameworks()) { if (SupportsFramework(f)) { if (TargetRuntime.IsInstalled(f)) { return(f); } else if (oneSupported == null) { oneSupported = f; } } } if (oneSupported != null) { return(oneSupported); } return(null); }
public void ParseTargetPlatformDirectory(TargetRuntime runtime, string platformDirectory) { targetRuntime = runtime; targetPlatformDirectory = platformDirectory; if (string.IsNullOrEmpty(targetPlatformDirectory) && (runtime != sourceRuntime)) { GetPlatformPath(runtime); } if (!string.IsNullOrEmpty(targetPlatformDirectory)) { if (!Directory.Exists(targetPlatformDirectory)) { throw new ArgumentException("Platform directory not found: \"" + targetPlatformDirectory + "\"."); } // TODO: only tested for Windows, not for Mono! //if (!File.Exists(Path.Combine(targetPlatformDirectory, "mscorlib.dll"))) // throw new ArgumentException("Invalid platform directory: \"" + targetPlatformDirectory + "\" (mscorlib.dll not found)."); } }
static ICompilation GetSystemWebDom(TargetRuntime runtime, TargetFramework targetFramework) { string file = runtime.AssemblyContext.GetAssemblyNameForVersion(sysWebAssemblyName, targetFramework); if (string.IsNullOrEmpty(file)) { throw new Exception("System.Web assembly name not found for framework " + targetFramework.Id); } file = runtime.AssemblyContext.GetAssemblyLocation(file, targetFramework); if (string.IsNullOrEmpty(file)) { throw new Exception("System.Web assembly file not found for framework " + targetFramework.Id); } var dom = new SimpleCompilation(TypeSystemService.LoadAssemblyContext(runtime, targetFramework, file)); if (dom == null) { throw new Exception("System.Web parse database not found for framework " + targetFramework.Id + " file '" + file + "'"); } return(dom); }
static ProjectDom GetSystemWebDom(TargetRuntime runtime, TargetFramework targetFramework) { string file = runtime.AssemblyContext.GetAssemblyNameForVersion(sysWebAssemblyName, targetFramework); if (string.IsNullOrEmpty(file)) { throw new Exception("System.Web assembly name not found for framework " + targetFramework.Id); } file = runtime.AssemblyContext.GetAssemblyLocation(file, targetFramework); if (string.IsNullOrEmpty(file)) { throw new Exception("System.Web assembly file not found for framework " + targetFramework.Id); } ProjectDom dom = ProjectDomService.GetAssemblyDom(runtime, file); if (dom == null) { throw new Exception("System.Web parse database not found for framework " + targetFramework.Id + " file '" + file + "'"); } return(dom); }
/// <summary> /// Initializes a new instance of the <see cref="DllInfo"/> class. /// </summary> /// <param name="targetRuntime">The runtime that this <see cref="DllInfo"/> targets.</param> /// <param name="resourceName">The resource name of the main DLL to be loaded.</param> /// <param name="additionalResourceNames"> /// The resource names of any additional DLLs that neede to be loaded. /// </param> /// <exception cref="ArgumentNullException"> /// <paramref name="resourceName"/> is null. /// </exception> /// <exception cref="ArgumentException"> /// <paramref name="resourceName"/> is empty. /// or /// <paramref name="resourceName"/> is not found in this assembly's manifest resource names. /// or /// <paramref name="additionalResourceNames"/> has any null elements. /// or /// <paramref name="additionalResourceNames"/> has any empty elements. /// or /// <paramref name="additionalResourceNames"/> has any elements that are not found in this assembly's manifest resource names. /// </exception> public DllInfo(TargetRuntime targetRuntime, string resourceName, params string[] additionalResourceNames) { if (resourceName == null) { throw new ArgumentNullException("resourceName"); } if (resourceName == "") { throw new ArgumentException("'resourceName' must not be empty.", "resourceName"); } if (!_assemblyManifestResourceNames.Contains(resourceName)) { throw new ArgumentException(string.Format("Resource '{0}' was not found in the assembly manifest resource names: {1}", resourceName, string.Join(", ", _assemblyManifestResourceNames.Select(n => "'" + n + "'"))), "resourceName"); } if (additionalResourceNames != null) { foreach (var additionalResourceName in additionalResourceNames) { if (additionalResourceName == null) { throw new ArgumentException("Elements of 'additionalResourceNames' must not be null.", "additionalResourceNames"); } if (additionalResourceName == "") { throw new ArgumentException("Elements of 'additionalResourceNames' must not be empty.", "additionalResourceNames"); } if (!_assemblyManifestResourceNames.Contains(additionalResourceName)) { throw new ArgumentException(string.Format("Additional resource '{0}' was not found in the assembly manifest resource names: {1}", additionalResourceName, string.Join(", ", _assemblyManifestResourceNames.Select(n => "'" + n + "'"))), "additionalResourceNames"); } } } _targetRuntime = targetRuntime; _resourceName = resourceName; _additionalResourceNames = additionalResourceNames ?? new string[0]; }
protected override void PopulateSupportFileList(MonoDevelop.Projects.FileCopySet list, ConfigurationSelector solutionConfiguration) { base.PopulateSupportFileList (list, solutionConfiguration); //HACK: workaround for MD not local-copying package references foreach (var projectReference in References) { if (projectReference.Package != null && projectReference.Package.Name == "monogame") { if (projectReference.ReferenceType == ReferenceType.Gac) { foreach (var assem in projectReference.Package.Assemblies) { list.Add (assem.Location); var cfg = (MonoGameProjectConfiguration)solutionConfiguration.GetConfiguration (this); if (cfg.DebugMode) { var mdbFile = TargetRuntime.GetAssemblyDebugInfoFile (assem.Location); if (System.IO.File.Exists (mdbFile)) list.Add (mdbFile); } } } break; } } }
protected void GetPlatformPath(TargetRuntime runtime) { // TODO: obviously, this only works for Windows, not for Mono! string platformBasePath = Path.GetFullPath(Path.Combine(Environment.SystemDirectory, "..\\Microsoft.NET\\Framework\\")); List<string> platformDirectories = new List<string>(Directory.GetDirectories(platformBasePath)); switch (runtime) { case (TargetRuntime.Net_1_0): targetPlatformDirectory = platformDirectories.First(x => Path.GetFileName(x).StartsWith("v1.0.")); break; case (TargetRuntime.Net_1_1): targetPlatformDirectory = platformDirectories.First(x => Path.GetFileName(x).StartsWith("v1.1.")); break; case (TargetRuntime.Net_2_0): targetPlatformDirectory = platformDirectories.First(x => Path.GetFileName(x).StartsWith("v2.0.")); break; case (TargetRuntime.Net_4_0): targetPlatformDirectory = platformDirectories.First(x => Path.GetFileName(x).StartsWith("v4.0.")); break; default: throw new NotImplementedException(); } }
public PlatformFixer(IRepackContext repack, TargetRuntime runtime) { this.repack = repack; sourceRuntime = runtime; }
static string FindXmlDocumentation(FileName assemblyFileName, TargetRuntime runtime) { // First, look in the same directory as the assembly. // This usually works for .NET reference assembies and 3rd party libraries string xmlFileName = LookupLocalizedXmlDoc(assemblyFileName); if (xmlFileName != null) return xmlFileName; // Otherwise, assume the assembly is part of .NET and try looking // in the framework directory. // (if the assembly is not part of .NET, we won't find anything there) string name = assemblyFileName.GetFileName(); switch (runtime) { case TargetRuntime.Net_1_0: xmlFileName = LookupLocalizedXmlDoc(Path.Combine(frameworkPath, "v1.0.3705", name)); break; case TargetRuntime.Net_1_1: xmlFileName = LookupLocalizedXmlDoc(Path.Combine(frameworkPath, "v1.1.4322", name)); break; case TargetRuntime.Net_2_0: xmlFileName = LookupLocalizedXmlDoc(Path.Combine(referenceAssembliesPath, "v3.5", name)) ?? LookupLocalizedXmlDoc(Path.Combine(referenceAssembliesPath, @".NETFramework\v3.5\Profile\Client", name)) ?? LookupLocalizedXmlDoc(Path.Combine(referenceAssembliesPath, "v3.0", name)) ?? LookupLocalizedXmlDoc(Path.Combine(frameworkPath, "v2.0.50727", name)); break; case TargetRuntime.Net_4_0: default: xmlFileName = LookupLocalizedXmlDoc(Path.Combine(referenceAssembliesPath, @".NETFramework\v4.5.2", name)) ?? LookupLocalizedXmlDoc(Path.Combine(referenceAssembliesPath, @".NETFramework\v4.5.1", name)) ?? LookupLocalizedXmlDoc(Path.Combine(referenceAssembliesPath, @".NETFramework\v4.5", name)) ?? LookupLocalizedXmlDoc(Path.Combine(referenceAssembliesPath, @".NETFramework\v4.0", name)) ?? LookupLocalizedXmlDoc(Path.Combine(frameworkPath, "v4.0.30319", name)); break; } return xmlFileName; }
public ManagedAlternatives(string module, string alternatives, TargetRuntime runtime) { Module = module; Alternatives = alternatives; Runtime = runtime; }
public PlatformFixer(TargetRuntime runtime) { sourceRuntime = runtime; }
public static AssemblyDefinition DefineAssembly (string name, TargetRuntime rt, AssemblyKind kind) { return DefineAssembly (name, name, rt, kind); }
private static string GetDotNetVersion(TargetRuntime runtime) { switch (runtime) { case TargetRuntime.Net_1_0: return "1.0.3705"; case TargetRuntime.Net_1_1: return "1.1.4322"; case TargetRuntime.Net_2_0: return "2.0.50727"; case TargetRuntime.Net_4_0: return "4.0.30319"; } return "UNKNOWN"; }