public void EmitDemangler(IILEmitter emitter) { if (!Context.MappedTypes.TryGetValue(Demangler.Method.DeclaringType.CreateKey(), out _)) { Context.Error("demangler must be defined in the target assembly"); } var method = emitter.Importer.Import(Demangler.Method); var mi = emitter.Importer.Import(method); emitter.Call(mi); }
protected CFMangleMethod(IContextImpl context, string name) : base(context) { Name = name; Mangler = context.Plugin <ICFMangler>() ?? throw context.Error($"add ${nameof(ICFMangler)} to the context first"); }
public ProjectLoader(IContextImpl context, string path, ProjectOptions options) : base(context) { _options = options ?? new ProjectOptions(); if (_options.Configuration == null) { _options.Configuration = Context.DebugMode ? "Debug" : "Release"; } _allProjects = new Dictionary <string, Project>(); _allReferences = new HashSet <string>(); _allPackageReferences = new HashSet <string>(); if (File.Exists(path)) { _root = GetProject(path); } else if (Directory.Exists(path)) { var files = Directory.GetFiles(path, "*.csproj"); if (files.Length == 0) { throw context.Error($"no .csproj files found in {path}"); } if (files.Length > 1) { throw context.Error($"multiple .csproj files found in {path}"); } _root = GetProject(files[0]); } else { throw context.Error($"path does not exist: {path}"); } if (context.OutputFolder == null) { context.OutputFolder = new DirectoryInfo(Path.Combine(Path.GetDirectoryName(_root.AssemblyPath), NetfuserFactory.NetfuserName)); } if (_options.Building != Building.No) { var builderPath = _options.BuilderPath; if (string.IsNullOrEmpty(builderPath)) { // using https://github.com/Microsoft/vswhere/wiki/Find-MSBuild var vswhere = Environment.ExpandEnvironmentVariables( @"%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe"); if (File.Exists(vswhere)) { var buildTools = Utils.RunProcess(vswhere, "-latest -prerelease -products * -requires Microsoft.Component.MSBuild -property installationPath") .StdOut.ReadLines().FirstOrDefault(); if (!string.IsNullOrEmpty(buildTools) && Directory.Exists(buildTools)) { var msbuild = Path.Combine(buildTools, @"MSBuild\Current\Bin\MSBuild.exe"); if (!File.Exists(msbuild)) { msbuild = Path.Combine(buildTools, @"MSBuild\15.0\Bin\MSBuild.exe"); } if (File.Exists(msbuild)) { var ver = Utils.RunProcess(msbuild, "/version").StdOut.ReadLines().LastOrDefault(); if (Version.TryParse(ver, out _msbuildVersion)) { builderPath = msbuild; _buildTool = BuildTool.Msbuild; } } } if (string.IsNullOrEmpty(builderPath)) { var devenv = Utils.RunProcess(vswhere, "-latest -prerelease -property productPath") .StdOut; if (File.Exists(devenv)) { builderPath = devenv; _buildTool = BuildTool.Devenv; } } } } if (string.IsNullOrEmpty(builderPath) || _buildTool == BuildTool.None) { throw context.Error( "could not find msbuild.exe or devenv.exe on this computer, please specify path in options or set Building to No"); } _builderPath = builderPath; } }