示例#1
0
        protected override async Task <IEnumerable <IDocument> > ExecuteAsync(IDocument input, IExecutionContext context)
        {
            context.LogDebug($"Processing Sass for {input.ToSafeDisplayString()}");

            FilePath inputPath = await _inputPath.GetValueAsync(input, context);

            if (inputPath?.IsAbsolute != true)
            {
                inputPath = context.FileSystem.GetInputFile(new FilePath(Path.GetRandomFileName())).Path;
                context.LogWarning($"No input path found for document {input.ToSafeDisplayString()}, using {inputPath.FileName.FullPath}");
            }

            string content = await input.GetStringAsync();

            // Sass conversion
            FileImporter importer = new FileImporter(context.FileSystem, _importPathFunc);
            ScssOptions  options  = new ScssOptions
            {
                OutputStyle       = _outputStyle,
                GenerateSourceMap = _generateSourceMap,
                SourceComments    = _includeSourceComments,
                InputFile         = inputPath.FullPath,
                TryImport         = importer.TryImport
            };
            IEnumerable <string> includePaths = _includePaths
                                                .Where(x => x != null)
                                                .Select(x => x.IsAbsolute ? x.FullPath : context.FileSystem.GetContainingInputPath(x)?.Combine(x)?.FullPath)
                                                .Where(x => x != null);

            options.IncludePaths.AddRange(includePaths);
            ScssResult result = Scss.ConvertToCss(content, options);

            // Process the result
            DirectoryPath relativeDirectory = context.FileSystem.GetContainingInputPath(inputPath);
            FilePath      relativePath      = relativeDirectory?.GetRelativePath(inputPath) ?? inputPath.FileName;

            FilePath  cssPath     = relativePath.ChangeExtension("css");
            IDocument cssDocument = input.Clone(
                cssPath,
                await context.GetContentProviderAsync(result.Css ?? string.Empty));

            // Generate a source map if requested
            if (_generateSourceMap && result.SourceMap != null)
            {
                FilePath  sourceMapPath     = relativePath.ChangeExtension("map");
                IDocument sourceMapDocument = input.Clone(
                    sourceMapPath,
                    await context.GetContentProviderAsync(result.SourceMap));
                return(new[] { cssDocument, sourceMapDocument });
            }

            return(cssDocument.Yield());
        }
        public bool Build(IProject project)
        {
            AssemblerOutput output;

            using (IAssembler assembler = _assemblerFactory.CreateAssembler())
            {
                AssemblerHelper.SetupAssembler(assembler, _inputFile, _outputFile, project.ProjectDirectory,
                                               project.IncludeDirs);

                string outputString;
                switch (_stepType)
                {
                case BuildStepType.All:
                    outputString =
                        assembler.Assemble(AssemblyFlags.Normal | AssemblyFlags.SymbolTable | AssemblyFlags.List);
                    output = new AssemblerOutput(outputString,
                                                 !outputString.Contains("error") && !outputString.Contains("Couldn't"));
                    project.BuildSystem.ProjectOutput = _outputFile;
                    project.BuildSystem.ListOutput    = _outputFile.ChangeExtension("lst");
                    project.BuildSystem.LabelOutput   = _outputFile.ChangeExtension("lab");
                    break;

                case BuildStepType.Assemble:
                    outputString = assembler.Assemble(AssemblyFlags.Normal);
                    output       = new AssemblerOutput(outputString,
                                                       !outputString.Contains("error") && !outputString.Contains("Couldn't"));
                    project.BuildSystem.ProjectOutput = _outputFile;
                    break;

                case BuildStepType.Listing:
                    outputString = assembler.Assemble(AssemblyFlags.Normal | AssemblyFlags.List);
                    output       = new AssemblerOutput(outputString,
                                                       !outputString.Contains("error") && !outputString.Contains("Couldn't"));
                    project.BuildSystem.ListOutput = _outputFile.ChangeExtension("lst");
                    break;

                case BuildStepType.SymbolTable:
                    outputString = assembler.Assemble(AssemblyFlags.Normal | AssemblyFlags.SymbolTable);
                    output       = new AssemblerOutput(outputString,
                                                       !outputString.Contains("error") && !outputString.Contains("Couldn't"));
                    project.BuildSystem.LabelOutput = _outputFile.ChangeExtension("lab");
                    break;

                default:
                    throw new InvalidOperationException("Unknown step type");
                }
            }
            _outputText = output.OutputText;
            return(output.Succeeded);
        }
示例#3
0
        public void SimpleWrappers()
        {
            Assert.AreEqual(Path.Combine("test"), FilePath.Combine("test"));
            Assert.AreEqual(Path.Combine("test", "1"), FilePath.Combine("test", "1"));
            Assert.AreEqual(Path.Combine("test/", @"1\"), FilePath.Combine("test/", @"1\"));

            const string aFilePath = @"hello\there.txt";
            const string aFileName = "hello";

            Assert.AreEqual(Path.GetExtension(aFilePath), FilePath.Extension(aFilePath));
            Assert.AreEqual(Path.GetExtension(aFileName), FilePath.Extension(aFileName));

            Assert.AreEqual(
                Path.ChangeExtension(aFilePath, ".png"),
                FilePath.ChangeExtension(aFilePath, ".png"));
            Assert.AreEqual(
                Path.ChangeExtension(aFileName, ".txt"),
                FilePath.ChangeExtension(aFileName, ".txt"));

            Assert.AreEqual(Path.GetDirectoryName(aFilePath), FilePath.DirectoryName(aFilePath));
            Assert.AreEqual(Path.GetDirectoryName(aFileName), FilePath.DirectoryName(aFileName));

            Assert.AreEqual(Path.HasExtension(aFilePath), FilePath.HasExtension(aFilePath));
            Assert.AreEqual(Path.HasExtension(aFileName), FilePath.HasExtension(aFileName));
        }
示例#4
0
        /// <summary>
        /// Saves the solution file.
        /// </summary>
        /// <param name = "reporter">The progress reporter to use for logging.</param>
        public override void Save(IProgressReporter reporter)
        {
            reporter.ProgressVisible = true;
            for (int i = 0; i < Nodes.Count; i++)
            {
                reporter.Report("Saving {0}.", Nodes[i].Name);
                Nodes[i].Save(reporter);
                //progressReporter.ProgressPercentage = (int)(((double)Nodes.Count / (double)i) * 100);
            }

            reporter.Report("Writing solution file.");

            using (var writer = new StreamWriter(FilePath.FullPath))
            {
                using (var solutionWriter = new SolutionWriter(writer))
                {
                    solutionWriter.WriteSolution(this);
                }
            }

            reporter.Report("Writing solution settings.");

            Settings.Save(FilePath.ChangeExtension(".litesettings").FullPath);

            reporter.Report("Finished saving solution.");
            reporter.ProgressVisible = false;
            HasUnsavedData = false;
        }
示例#5
0
        /// <summary>
        /// Restarts MonoDevelop
        /// </summary>
        /// <param name="reopenWorkspace"> true to reopen current workspace. </param>
        internal virtual void RestartIde(bool reopenWorkspace)
        {
            var reopen = reopenWorkspace && IdeApp.Workspace != null && IdeApp.Workspace.Items.Count > 0;

            FilePath path = Environment.GetCommandLineArgs()[0];

            if (Platform.IsMac && path.Extension == ".exe")
            {
                path = path.ChangeExtension(null);
            }

            if (!File.Exists(path))
            {
                throw new Exception(path + " not found");
            }

            var proc = new Process();

            var psi = new ProcessStartInfo(path)
            {
                CreateNoWindow   = true,
                UseShellExecute  = false,
                WorkingDirectory = Environment.CurrentDirectory,
            };

            var recentWorkspace = reopen ? DesktopService.RecentFiles.GetProjects().FirstOrDefault()?.FileName : string.Empty;

            if (!string.IsNullOrEmpty(recentWorkspace))
            {
                psi.Arguments = recentWorkspace;
            }

            proc.StartInfo = psi;
            proc.Start();
        }
示例#6
0
        private IReadOnlyCollection <CakeScriptAlias> InspectAssembly(AssemblyDefinition assembly, FilePath path)
        {
            var result        = new List <CakeScriptAlias>();
            var documentation = _documentation.Load(path.ChangeExtension("xml"));

            foreach (var module in assembly.Modules)
            {
                foreach (var type in module.Types)
                {
                    if (type.IsSpecialName)
                    {
                        continue;
                    }
                    if (type.Name == "<Module>")
                    {
                        continue;
                    }
                    if (type.Name.StartsWith("_"))
                    {
                        continue;
                    }
                    if (type.IsAnonymousType())
                    {
                        continue;
                    }

                    InspectType(assembly, type, documentation, result);
                }
            }

            return(result);
        }
示例#7
0
        /// <summary>
        /// Generates a normalized link given a path and other conditions.
        /// </summary>
        /// <param name="path">The path to get a link for.</param>
        /// <param name="host">The host for the link (or <c>null</c> to omit the host).</param>
        /// <param name="root">The root path for the link (or <c>null</c> for no root path).</param>
        /// <param name="scheme">The scheme for the link (or <c>null</c> for "http").</param>
        /// <param name="hidePages">An array of page names to hide (or <c>null</c> to not hide any pages).</param>
        /// <param name="hideExtensions">An array of file extensions to hide (or <c>null</c> to not hide extensions or an empty array to hide all file extensions).</param>
        /// <returns>A generated link.</returns>
        public static string GetLink(NormalizedPath path, string host, DirectoryPath root, string scheme, string[] hidePages, string[] hideExtensions)
        {
            // Remove index pages and extensions if a file path
            FilePath filePath = path as FilePath;

            if (filePath != null)
            {
                if (hidePages != null && filePath.FullPath != "/" &&
                    hidePages.Where(x => x != null).Select(x => x.EndsWith(".") ? x : x + ".").Any(x => filePath.FileName.FullPath.StartsWith(x)))
                {
                    path = filePath.Directory;
                }
                else if (hideExtensions != null &&
                         (hideExtensions.Length == 0 || hideExtensions.Where(x => x != null).Select(x => x.StartsWith(".") ? x : "." + x).Contains(filePath.Extension)))
                {
                    path = filePath.ChangeExtension(null);
                }
            }

            // Collapse the link to a string
            string link = string.Empty;

            if (path != null)
            {
                link = path.FullPath;
                if (string.IsNullOrWhiteSpace(link) || link == ".")
                {
                    link = "/";
                }
                if (!link.StartsWith("/"))
                {
                    link = "/" + link;
                }
            }

            // Collapse the root and combine
            string rootLink = root == null ? string.Empty : root.FullPath;

            if (rootLink.EndsWith("/"))
            {
                rootLink = rootLink.Substring(0, rootLink.Length - 1);
            }

            // Add the host and convert to URI for escaping
            UriBuilder builder = new UriBuilder
            {
                Path   = rootLink + link,
                Scheme = scheme ?? "http"
            };
            bool hasHost = false;

            if (!string.IsNullOrWhiteSpace(host))
            {
                builder.Host = host;
                hasHost      = true;
            }
            Uri uri = builder.Uri;

            return(hasHost ? uri.AbsoluteUri : uri.AbsolutePath);
        }
示例#8
0
        public static string GetLink(NormalizedPath path, string host, DirectoryPath root, bool useHttps, bool hideIndexPages, bool hideExtensions)
        {
            // Remove index pages and extensions if a file path
            FilePath filePath = path as FilePath;

            if (filePath != null)
            {
                if (hideIndexPages && filePath.FileName.FullPath.StartsWith("index."))
                {
                    path = filePath.Directory;
                }
                else if (hideExtensions)
                {
                    path = filePath.ChangeExtension(null);
                }
            }

            // Collapse the link to a string
            string link = string.Empty;

            if (path != null)
            {
                link = path.FullPath;
                if (string.IsNullOrWhiteSpace(link) || link == ".")
                {
                    link = "/";
                }
                if (!link.StartsWith("/"))
                {
                    link = "/" + link;
                }
            }

            // Collapse the root and combine
            string rootLink = root == null ? string.Empty : root.FullPath;

            if (rootLink.EndsWith("/"))
            {
                rootLink = rootLink.Substring(0, rootLink.Length - 1);
            }

            // Add the host and convert to URI for escaping
            UriBuilder builder = new UriBuilder
            {
                Path   = rootLink + link,
                Scheme = useHttps ? "https" : "http"
            };
            bool hasHost = false;

            if (!string.IsNullOrWhiteSpace(host))
            {
                builder.Host = host;
                hasHost      = true;
            }
            Uri uri = builder.Uri;

            return(hasHost ? uri.AbsoluteUri : uri.AbsolutePath);
        }
示例#9
0
        public string Serialize(PublishInfo info, IProjectFile projFile)
        {
            FilePath filePath       = info.DestinationFilePath;
            string   sourceFilePath = info.SourceFilePath;
            string   des            = filePath.ChangeExtension(".csb");
            string   res            = Services.ProjectOperations.CurrentSelectedSolution.ItemDirectory;

            return(CSCocosHelp.ConvertToBinByFlat(des, sourceFilePath, res));
        }
示例#10
0
 public static byte [] GetDebugSymbolsFromAssemblyPath(FilePath path)
 {
     try {
         // Prefer MDBs, then PDBs. Mono outputs Foo.dll.mdb, so change the extension to that.
         var mdbPath = path.ChangeExtension(".dll.mdb");
         if (mdbPath.FileExists)
         {
             return(File.ReadAllBytes(mdbPath));
         }
         // This is intentionally not using mdbPath, because MS .NET names the symbol files
         // Foo.pdb, compared to Mono's Foo.dll.mdb.
         var pdbPath = path.ChangeExtension(".pdb");
         return(pdbPath.FileExists ? File.ReadAllBytes(pdbPath) : null);
     } catch (Exception e) {
         Log.Warning(TAG, $"Could not get debug symbols for assembly at {path}", e);
         return(null);
     }
 }
        public string Serialize(PublishInfo info, IProjectFile projFile)
        {
            FilePath destinationFilePath = (FilePath)info.DestinationFilePath;
            string   sourceFilePath      = info.SourceFilePath;
            string   des           = (string)destinationFilePath.ChangeExtension(".csb");
            string   itemDirectory = (string)Services.ProjectOperations.CurrentSelectedSolution.ItemDirectory;

            return(CSCocosHelp.ConvertToBinProto(des, sourceFilePath, itemDirectory));
        }
示例#12
0
            public void Can_Change_Extension_Of_Path(string input, string extension, string expected)
            {
                // Given
                var path = new FilePath(input);

                // When
                path = path.ChangeExtension(extension);

                // Then
                path.ToString().ShouldBe(expected);
            }
示例#13
0
            public void Can_Change_Extension_Of_Path()
            {
                // Given
                var path = new FilePath("temp/hello.txt");

                // When
                path = path.ChangeExtension(".dat");

                // Then
                Assert.Equal("temp/hello.dat", path.ToString());
            }
示例#14
0
        protected IFile GetOutputFile(IDocument input, IExecutionContext context)
        {
            FilePath path = null;

            if (_useWriteMetadata)
            {
                string metadataKey = null;

                // WritePath
                path = input.FilePath(Keys.WritePath);
                if (path != null)
                {
                    metadataKey = Keys.WritePath;
                }

                // WriteFileName
                DirectoryPath relativeFileDir = input.DirectoryPath(Keys.RelativeFileDir);
                FilePath      writeFileName   = input.FilePath(Keys.WriteFileName);
                if (path == null &&
                    relativeFileDir != null &&
                    writeFileName != null)
                {
                    metadataKey = Keys.WriteFileName;
                    path        = relativeFileDir.CombineFile(writeFileName);
                }

                // WriteExtension
                FilePath relativeFilePath = input.FilePath(Keys.RelativeFilePath);
                string   writeExtension   = input.String(Keys.WriteExtension);
                if (path == null &&
                    relativeFilePath != null &&
                    !string.IsNullOrWhiteSpace(writeExtension))
                {
                    metadataKey = Keys.WriteExtension;
                    path        = relativeFilePath.ChangeExtension(writeExtension);
                }

                // Warn if needed
                if (metadataKey != null && _warnOnWriteMetadata)
                {
                    Trace.Warning("An extension or delegate was specified for the WriteFiles module, but the metadata key {0} took precedence for the document with source {1}."
                                  + " Call UseWriteMetadata(false) to prevent the special write metadata keys from overriding WriteFiles constructor values.",
                                  metadataKey, input.SourceString());
                }
            }

            // Func
            if (path == null)
            {
                path = _path.Invoke <FilePath>(input, context);
            }

            return(path != null?context.FileSystem.GetOutputFile(path) : null);
        }
示例#15
0
        private void addDirButton_Click(object sender, EventArgs e)
        {
            int        count     = buildSeqList.Items.Count;
            FilePath   fileName  = new FilePath(_project.ProjectName + ".asm");
            IBuildStep stepToAdd = new InternalBuildStep(count, BuildStepType.Assemble,
                                                         fileName, fileName.ChangeExtension("8xk"));

            _currentConfig.AddStep(stepToAdd);
            buildSeqList.Items.Insert(count, stepToAdd);
            _needsSave = true;
        }
示例#16
0
            public void Can_Change_Extension_Of_Windows_Path(string input, string extension, string expected)
            {
                // Given
                var path = new FilePath(input);

                // When
                path = path.ChangeExtension(extension);

                // Then
                Assert.Equal(expected, path.ToString());
            }
示例#17
0
            public void ShouldChangeExtension(string extension, string expected)
            {
                // Given
                FilePath path = new FilePath("temp/hello.txt");

                // When
                path = path.ChangeExtension(extension);

                // Then
                Assert.AreEqual(expected, path.ToString());
            }
示例#18
0
            public void CanChangeExtensionOfPath()
            {
                // Given
                FilePath path = new FilePath("temp/hello.txt");

                // When
                path = path.ChangeExtension(".dat");

                // Then
                Assert.AreEqual("temp/hello.dat", path.ToString());
            }
示例#19
0
		public FilePath GetValidFormatName (object obj, FilePath fileName)
		{
			if (slnFileFormat.CanWriteFile (obj, this))
				return slnFileFormat.GetValidFormatName (obj, fileName, this);
			else {
				string ext = MSBuildProjectService.GetExtensionForItem ((SolutionEntityItem)obj);
				if (!string.IsNullOrEmpty (ext))
					return fileName.ChangeExtension ("." + ext);
				else
					return fileName;
			}
		}
示例#20
0
        /// <summary>
        /// Writes the document content to disk with the specified extension with the same
        /// base file name and relative path as the input file. This requires metadata
        /// for <c>RelativeFilePath</c> to be set (which is done by default by the <see cref="ReadFiles"/> module).
        /// </summary>
        /// <param name="extension">The extension to use for writing the file.</param>
        public WriteFiles(string extension)
        {
            if (extension == null)
            {
                throw new ArgumentNullException(nameof(extension));
            }

            _path = (x, y) =>
            {
                FilePath fileRelative = x.FilePath(Keys.RelativeFilePath);
                return(fileRelative?.ChangeExtension(extension));
            };
            _warnOnWriteMetadata = true;
        }
示例#21
0
        /// <summary>
        /// Gets the output path of the input document.
        /// </summary>
        /// <param name="input">The input document.</param>
        /// <param name="context">The execution context.</param>
        /// <returns>The outout path.</returns>
        protected FilePath GetOutputPath(IDocument input, IExecutionContext context)
        {
            FilePath path = null;

            if (_useWriteMetadata)
            {
                string metadataKey = null;

                // WritePath
                path = input.FilePath(Keys.WritePath);
                if (path != null)
                {
                    metadataKey = Keys.WritePath;
                }

                // WriteFileName
                DirectoryPath relativeFileDir = input.DirectoryPath(Keys.RelativeFileDir);
                FilePath      writeFileName   = input.FilePath(Keys.WriteFileName);
                if (path == null &&
                    relativeFileDir != null &&
                    writeFileName != null)
                {
                    metadataKey = Keys.WriteFileName;
                    path        = relativeFileDir.CombineFile(writeFileName);
                }

                // WriteExtension
                FilePath relativeFilePath = input.FilePath(Keys.RelativeFilePath);
                string   writeExtension   = input.String(Keys.WriteExtension);
                if (path == null &&
                    relativeFilePath != null &&
                    !string.IsNullOrWhiteSpace(writeExtension))
                {
                    metadataKey = Keys.WriteExtension;
                    path        = relativeFilePath.ChangeExtension(writeExtension);
                }

                // Warn if needed
                if (metadataKey != null && _warnOnWriteMetadata)
                {
                    Trace.Warning($"An extension or delegate was specified for the WriteFiles module, but the metadata key {metadataKey} took precedence for the document with source {input.SourceString()}"
                                  + $" resulting in an output path of {path}. Call UseWriteMetadata(false) to prevent the special write metadata keys from overriding WriteFiles constructor values.");
                }
            }

            // Fallback to the default behavior function
            return(path ?? _path.Invoke <FilePath>(input, context, "while getting path"));
        }
        static FilePath FilterFileName(SelectFileDialogData data, string fileName)
        {
            FilePath result = fileName;

            // FileDialog doesn't show the file extension when saving a file and chooses the extension based
            // the file filter. But * is no valid extension so the default file name extension needs to be set in that case.
            if (result.Extension == ".*")
            {
                var ext = Path.GetExtension(data.InitialFileName);
                if (!string.IsNullOrEmpty(ext))
                {
                    result = result.ChangeExtension(ext);
                }
            }
            return(result);
        }
示例#23
0
 public FilePath GetValidFormatName(object obj, FilePath fileName)
 {
     if (slnFileFormat.CanWriteFile(obj, this))
     {
         return(slnFileFormat.GetValidFormatName(obj, fileName, this));
     }
     else
     {
         string ext = MSBuildProjectService.GetExtensionForItem((SolutionEntityItem)obj);
         if (!string.IsNullOrEmpty(ext))
         {
             return(fileName.ChangeExtension("." + ext));
         }
         else
         {
             return(fileName);
         }
     }
 }
示例#24
0
        public Option <string> BuildSolution(FilePath SolutionPath)
        {
            var manager = MSEX.BuildManager.DefaultBuildManager;
            var project = new MSEX.ProjectInstance(SolutionPath);

            var logPath      = SolutionPath.ChangeExtension("binlog");
            var buildRequest = new MSEX.BuildRequestData(project, array("Build"));
            var result       = manager.Build
                               (
                new MSEX.BuildParameters
            {
                Loggers = metacore.roitems <ILogger>(new MSL.ConsoleLogger())
            },
                buildRequest
                               );

            var targetResults = result.ResultsByTarget["Build"];

            return(targetResults.ResultCode.ToString());
        }
示例#25
0
        public void PropertyTest()
        {
            var filePath = new FilePath(DirectoryPath.OS.Temp, "Test.txt");

            Assert.True(filePath.SplitValues.Count > 0);
            Assert.Equal("Test.txt", filePath.SplitValuesLast);

            Assert.Equal("Test.txt", filePath.FileName);
            Assert.Equal("Test", filePath.FileNameWithoutExtension);
            Assert.Equal(".txt", filePath.Extension);
            Assert.Equal(DirectoryPath.OS.Temp.IfEndsWithPathThenRemove(), filePath.DirectoryName);

            filePath.ChangeFileName("Hallo.xxx");
            Assert.Equal("Hallo.xxx", filePath.FileName);
            Assert.Equal("Hallo", filePath.FileNameWithoutExtension);
            Assert.Equal(".xxx", filePath.Extension);
            Assert.Equal(DirectoryPath.OS.Temp.IfEndsWithPathThenRemove(), filePath.DirectoryName);

            filePath.ChangeExtension(".json");
            Assert.Equal("Hallo.json", filePath.FileName);
            Assert.Equal("Hallo", filePath.FileNameWithoutExtension);
            Assert.Equal(".json", filePath.Extension);
            Assert.Equal(DirectoryPath.OS.Temp.IfEndsWithPathThenRemove(), filePath.DirectoryName);

            filePath.ChangeFileNameWithoutExtension("Test");
            Assert.Equal("Test.json", filePath.FileName);
            Assert.Equal("Test", filePath.FileNameWithoutExtension);
            Assert.Equal(".json", filePath.Extension);
            Assert.Equal(DirectoryPath.OS.Temp.IfEndsWithPathThenRemove(), filePath.DirectoryName);

            filePath.RemoveExtension();
            Assert.Equal("Test", filePath.FileName);
            Assert.Equal("Test", filePath.FileNameWithoutExtension);
            Assert.Equal("", filePath.Extension);
            Assert.Equal(DirectoryPath.OS.Temp.IfEndsWithPathThenRemove(), filePath.DirectoryName);
        }
示例#26
0
 public FilePath GetValidFormatName(object obj, FilePath fileName)
 {
     return(fileName.ChangeExtension(visualDExt));
 }
示例#27
0
 public FilePath GetFileName(FilePath fileNameWithoutExtension)
 {
     return(fileNameWithoutExtension.ChangeExtension(".d"));
 }
 public FilePath GetValidFormatName(object obj, FilePath fileName)
 {
     return(fileName.ChangeExtension(".md-nunit"));
 }
示例#29
0
        /// <inheritdoc />
        public IEnumerable <IDocument> Execute(IReadOnlyList <IDocument> inputs, IExecutionContext context)
        {
            return(inputs
                   .AsParallel()
                   .SelectMany(context, input =>
            {
                Trace.Verbose($"Processing Sass for {input.SourceString()}");

                FilePath inputPath = _inputPath.Invoke <FilePath>(input, context);
                if (inputPath?.IsAbsolute != true)
                {
                    inputPath = context.FileSystem.GetInputFile(new FilePath(Path.GetRandomFileName())).Path;
                    Trace.Warning($"No input path found for document {input.SourceString()}, using {inputPath.FileName.FullPath}");
                }

                string content = input.Content;

                // Sass conversion
                FileImporter importer = new FileImporter(context.FileSystem, _importPathFunc);
                ScssOptions options = new ScssOptions
                {
                    OutputStyle = _outputStyle,
                    GenerateSourceMap = _generateSourceMap,
                    SourceComments = _includeSourceComments,
                    InputFile = inputPath.FullPath,
                    TryImport = importer.TryImport
                };
                options.IncludePaths.AddRange(
                    _includePaths
                    .Where(x => x != null)
                    .Select(x => x.IsAbsolute ? x.FullPath : context.FileSystem.GetContainingInputPath(x)?.Combine(x)?.FullPath)
                    .Where(x => x != null));
                ScssResult result = Scss.ConvertToCss(content, options);

                // Process the result
                DirectoryPath relativeDirectory = context.FileSystem.GetContainingInputPath(inputPath);
                FilePath relativePath = relativeDirectory?.GetRelativePath(inputPath) ?? inputPath.FileName;

                FilePath cssPath = relativePath.ChangeExtension("css");
                IDocument cssDocument = context.GetDocument(
                    input,
                    context.GetContentStream(result.Css ?? string.Empty),
                    new MetadataItems
                {
                    { Keys.RelativeFilePath, cssPath },
                    { Keys.WritePath, cssPath }
                });

                IDocument sourceMapDocument = null;
                if (_generateSourceMap && result.SourceMap != null)
                {
                    FilePath sourceMapPath = relativePath.ChangeExtension("map");
                    sourceMapDocument = context.GetDocument(
                        input,
                        context.GetContentStream(result.SourceMap),
                        new MetadataItems
                    {
                        { Keys.RelativeFilePath, sourceMapPath },
                        { Keys.WritePath, sourceMapPath }
                    });
                }

                return new[] { cssDocument, sourceMapDocument };
            })
                   .Where(x => x != null));
        }
示例#30
0
		public FilePath GetValidFormatName (object obj, FilePath fileName)
		{
			return fileName.ChangeExtension (visualDExt);
		}
示例#31
0
 public FilePath GetFileName(FilePath fileNameWithoutExtension)
 {
     return fileNameWithoutExtension.ChangeExtension(".d");
 }
示例#32
0
        /// <summary>
        /// Constructs a unique filename using the extension of the current file
        /// </summary>
        /// <returns></returns>
        public static FilePath UniqueName(this FilePath path)
        {
            var ext = $"{guid().ToString("N")}.{path.Extension}";

            return(path.ChangeExtension(ext));
        }
		public FilePath GetValidFormatName (object obj, FilePath fileName)
		{
			return fileName.ChangeExtension (".md-nunit");
		}