Esempio n. 1
0
        private static bool ContentEqual(SourceFileCollection x, SourceFileCollection y)
        {
            if (x.Count != y.Count)
            {
                return(false);
            }

            for (var i = 0; i < x.Count; i++)
            {
                if (x[i].filename != y[i].filename)
                {
                    return(false);
                }

                if (!Equals(x[i].content.Encoding, y[i].content.Encoding))
                {
                    return(false);
                }

                if (!x[i].content.ContentEquals(y[i].content))
                {
                    return(false);
                }
            }

            return(true);
        }
Esempio n. 2
0
        public async Task FormatAllFiles(CancellationToken cancellationToken = default)
        {
            var sourceFiles = new SourceFileCollection(root);

            var stopwatch = Stopwatch.StartNew();
            await Task.WhenAll(sourceFiles.Select(sourceFile => FormatSingleFile(sourceFile, cancellationToken)));

            stopwatch.Stop();

            Console.WriteLine($"Formatted {sourceFiles.Count()} file(s) in {(int)stopwatch.Elapsed.TotalMilliseconds}ms");
        }
Esempio n. 3
0
        internal static Solution CreateOtherReference(Solution solution,
                                                      ProjectId projectId,
                                                      SourceFileCollection documents,
                                                      CSharpCompilationOptions compilationOptions = null)
        {
            if (compilationOptions is null)
            {
                compilationOptions = new(OutputKind.DynamicallyLinkedLibrary);
            }

            var targetProject = solution.GetProject(projectId);

            var project = solution.AddProject("Other", "Other", "C#")
                          .WithMetadataReferences(targetProject.MetadataReferences)
                          .WithCompilationOptions(compilationOptions);

            foreach (var(filename, content) in documents)
            {
                project = project.AddDocument(Path.GetFileNameWithoutExtension(filename), content, filePath: filename).Project;
            }

            return(project.Solution.AddProjectReference(projectId, new(project.Id)));
        }
 void SurrogateRead(StreamingContext context)
 {
     SourceFiles = new SourceFileCollection();
     SourceFiles.AddRange(_sourceFileCollectionSurrogate.SourceFiles.Select(x => new SourceFile(x.Name)));
     _ReadSourceFileContent();
 }
 public ScriptSequenceData()
 {
     SourceFiles = new SourceFileCollection();
     FrameworkAssemblies = new HashSet<string>();
     ExternalAssemblies = new HashSet<string>();
 }
 void SurrogateRead(StreamingContext context)
 {
     SourceFiles = new SourceFileCollection();
     SourceFiles.AddRange(_sourceFileCollectionSurrogate.SourceFiles.Select(x => new SourceFile(x.Name)));
     _ReadSourceFileContent();
 }
 public ScriptSequenceData()
 {
     SourceFiles         = new SourceFileCollection();
     FrameworkAssemblies = new HashSet <string>();
     ExternalAssemblies  = new HashSet <string>();
 }
 public SourceFileCollectionSurrogate(SourceFileCollection sourceFileCollection)
 {
     SourceFiles = sourceFileCollection.Select(x => new SourceFileSurrogate(x)).ToArray();
 }
 public SourceFileCollectionSurrogate(SourceFileCollection sourceFileCollection)
 {
     SourceFiles = sourceFileCollection.Select(x => new SourceFileSurrogate(x)).ToArray();
 }