Exemplo n.º 1
0
        private static string GetIlasmPath()
        {
            if (ExecutionConditionUtil.IsWindowsDesktop)
            {
                // The desktop ilasm is still necessary because a number of our tests depend on being able to
                // emit PDB files for net modules. That feature is not available on coreclr ilasm.
                return(Path.Combine(
                           Path.GetDirectoryName(RuntimeUtilities.GetAssemblyLocation(typeof(object))),
                           "ilasm.exe"
                           ));
            }

            var ilasmExeName = PlatformInformation.IsWindows ? "ilasm.exe" : "ilasm";
            var directory    = Path.GetDirectoryName(
                RuntimeUtilities.GetAssemblyLocation(typeof(RuntimeUtilities))
                );
            string ridName;

            if (ExecutionConditionUtil.IsWindows)
            {
                ridName = "win-x64";
            }
            else if (ExecutionConditionUtil.IsMacOS)
            {
                ridName = "osx-x64";
            }
            else if (ExecutionConditionUtil.IsLinux)
            {
                ridName = "linux-x64";
            }
            else
            {
                throw new PlatformNotSupportedException(
                          "Runtime platform not supported for testing"
                          );
            }

            return(Path.Combine(directory, "runtimes", ridName, "native", ilasmExeName));
        }
Exemplo n.º 2
0
        public void Emit(Compilation mainCompilation, IEnumerable <ResourceDescription> manifestResources, bool usePdbForDebugging = false)
        {
            _testData.Methods.Clear();
            var diagnostics  = DiagnosticBag.GetInstance();
            var dependencies = new List <ModuleData>();
            var mainOutput   = RuntimeUtilities.EmitCompilation(mainCompilation, manifestResources, dependencies, diagnostics, _testData);

            if (mainOutput.HasValue)
            {
                _diagnostics = diagnostics.ToReadOnly();
                _mainImage   = mainOutput.Value.Assembly;
                _pdb         = mainOutput.Value.Pdb;
            }
            else
            {
                _mainImage   = default(ImmutableArray <byte>);
                _pdb         = default(ImmutableArray <byte>);
                _diagnostics = default(ImmutableArray <Diagnostic>);

                string dumpDir;
                DumpAssemblyData(dependencies, out dumpDir);
                throw new EmitException(diagnostics.ToReadOnly(), dumpDir);
            }
        }
Exemplo n.º 3
0
 public string DumpAssemblyData(out string dumpDirectory)
 {
     return(RuntimeUtilities.DumpAssemblyData(ModuleDatas, out dumpDirectory));
 }