Exemplo n.º 1
0
        public static string DeleteExistingHostpolicy(string coreRoot)
        {
            string hostPolicyFileName = XPlatformUtils.GetStandardNativeLibraryFileName("hostpolicy");
            string destinationPath = Path.Combine(coreRoot, hostPolicyFileName);
            if (File.Exists(destinationPath))
            {
                File.Delete(destinationPath);
            }

            return destinationPath;
        }
Exemplo n.º 2
0
        public static void Initialize(string testBasePath, string coreRoot)
        {
            string hostPolicyFileName = XPlatformUtils.GetStandardNativeLibraryFileName("hostpolicy");
            string destinationPath    = DeleteExistingHostpolicy(coreRoot);

            File.Copy(
                Path.Combine(testBasePath, hostPolicyFileName),
                destinationPath);

            _assemblyDependencyResolverType = typeof(object).Assembly.GetType("System.Runtime.Loader.AssemblyDependencyResolver");

            // This is needed for marshalling of function pointers to work - requires private access to the CDR unfortunately
            // Delegate marshalling doesn't support casting delegates to anything but the original type
            // so we need to use the original type.
            _corehost_error_writer_fnType = _assemblyDependencyResolverType.GetNestedType("corehost_error_writer_fn", System.Reflection.BindingFlags.NonPublic);
        }
Exemplo n.º 3
0
        protected override void Initialize()
        {
            // Make sure there's no hostpolicy available
            _officialHostPolicyPath = HostPolicyMock.DeleteExistingHostpolicy(CoreRoot);
            string hostPolicyFileName = XPlatformUtils.GetStandardNativeLibraryFileName("hostpolicy");

            _localHostPolicyPath   = Path.Combine(TestBasePath, hostPolicyFileName);
            _renamedHostPolicyPath = Path.Combine(TestBasePath, hostPolicyFileName + "_renamed");
            if (File.Exists(_renamedHostPolicyPath))
            {
                File.Delete(_renamedHostPolicyPath);
            }
            File.Move(_localHostPolicyPath, _renamedHostPolicyPath);

            _componentDirectory = Path.Combine(TestBasePath, $"InvalidHostingComponent_{Guid.NewGuid().ToString().Substring(0, 8)}");
            Directory.CreateDirectory(_componentDirectory);
            _componentAssemblyPath = Path.Combine(_componentDirectory, "InvalidHostingComponent.dll");
            File.WriteAllText(_componentAssemblyPath, "Mock assembly");
        }
Exemplo n.º 4
0
 private string CreateMockStandardNativeLibrary(string relativePath, string simpleName)
 {
     return(CreateMockAssembly(
                relativePath + Path.DirectorySeparatorChar + XPlatformUtils.GetStandardNativeLibraryFileName(simpleName)));
 }