示例#1
0
 public void ChangeExtensionTest()
 {
     _paths
     .Where(p => p.IsFile)
     .All(p => p.ChangeExtension(".exe").GetExtension() == ".exe");
     EAssert.Throws <ArgumentException>(() => directoryA.ChangeExtension(".exe"));
 }
        public static FileSystemPath GetDbgShimDirectory(FileSystemPath assemblyPath,
                                                         RuntimeConfigToPlatformRange runtimeConfigJsonToPlatformRange, PlatformRangeToPlatformInfo platformRangeToInfo, ILogger logger)
        {
            var runtimeConfigPath = assemblyPath.ChangeExtension(RuntimeConfigExtension);

            logger.Trace($"Using runtime config: {runtimeConfigPath}");
            var platform = platformRangeToInfo(runtimeConfigJsonToPlatformRange(runtimeConfigPath));

            if (platform == null)
            {
                logger.Trace("Detecting platform using deps.json...");
                var depsFile = GetJsonFileByLauncher(assemblyPath, "deps.json");
                var platformRangeFromDepsJson = GetPlatformRangeFromDepsJson(depsFile);
                platform = platformRangeToInfo(platformRangeFromDepsJson);
            }

            logger.Trace($"Detected platform is {platform?.ToString() ?? "<no platform>"}");

            while (platform != null && !IsDbgShimExists(platform.TargetFrameworkFolder))
            {
                logger.Trace($"dbgshim was not found in {platform.TargetFrameworkFolder}");
                var frameworkRuntimeConfigPath = platform.TargetFrameworkFolder /
                                                 RelativePath.TryParse(
                    $"{platform.TargetFrameworkId.PresentableString}.{RuntimeConfigExtension}");
                platform = platformRangeToInfo(runtimeConfigJsonToPlatformRange(frameworkRuntimeConfigPath));
                logger.Trace($"The next platform is {platform?.ToString() ?? "<no platform>"}");
            }

            logger.Trace(
                $"The final platform is {platform?.ToString() ?? "<no platform>"}. Shim directory: {platform?.TargetFrameworkFolder?.ToString() ?? "<no platform>"}");

            return(platform != null ? platform.TargetFrameworkFolder : FileSystemPath.Empty);
        }
        public static string CompileSource(FileSystemPath source, string[] references)
        {
            var assembly = source.ChangeExtension("dll");

            if (assembly.ExistsFile && source.FileModificationTimeUtc <= assembly.FileModificationTimeUtc)
            {
                return(assembly.Name);
            }

            var rootedReferences = references
                                   .Where(Path.IsPathRooted)
                                   .ToArray();

            var parameters = new CompilerParameters();

            parameters.ReferencedAssemblies.AddRange(rootedReferences);
            parameters.OutputAssembly = assembly.ToString();

            var provider = new CSharpCodeProvider();
            var result   = provider.CompileAssemblyFromFile(parameters, source.ToString());

            if (result.Errors.HasErrors)
            {
                throw new InvalidOperationException(result.Errors.ToStringWithCount());
            }

            return(assembly.Name);
        }
 public void ChangeExtensionTest()
 {
     foreach (var p in _paths.Where(p => p.IsFile))
     {
         Assert.IsTrue(p.ChangeExtension(".exe").GetExtension() == ".exe");
     }
     EAssert.Throws <ArgumentException>(() => directoryA.ChangeExtension(".exe"));
 }
示例#5
0
 public void ChangeExtensionTest()
 {
     foreach (var p in _paths.Where(p => p.IsFile))
     {
         Assert.True(p.ChangeExtension(".exe").GetExtension() == ".exe");
     }
     // ReSharper disable once ReturnValueOfPureMethodIsNotUsed
     EAssert.Throws <ArgumentException>(() => DirectoryA.ChangeExtension(".exe"));
 }
 private static FileSystemPath GetIniPathForModule(FileSystemPath path) => path.ChangeExtension(".ini");
 public static FileSystemPath GetRuntimeConfigFromAssemblyPath(FileSystemPath assemblyPath)
 {
     return(assemblyPath.ChangeExtension(RuntimeConfigExtension));
 }
 public static FileSystemPath GetJsonFileByLauncher(FileSystemPath launcherPath, string jsonFileExtensionWithoutDot)
 {
     return(PlatformUtil.IsRunningUnderWindows
 ? launcherPath.ChangeExtension(jsonFileExtensionWithoutDot)
 : launcherPath.Directory.Combine($"{launcherPath.Name}.{jsonFileExtensionWithoutDot}"));
 }
示例#9
0
 private static FileSystemPath GetAssetLocationFromMetaFile(FileSystemPath metaFileLocation)
 {
     return(metaFileLocation.ChangeExtension(string.Empty));
 }