Exemplo n.º 1
0
        /// <summary>
        /// Creates a solution that will be used as parent for the sources that need to be checked.
        /// </summary>
        /// <param name="projectId">The project identifier to use.</param>
        /// <param name="language">The language for which the solution is being created.</param>
        /// <returns>The created solution.</returns>
        protected virtual Solution CreateSolution(ProjectId projectId, string language)
        {
            var compilationOptions = new CSharpCompilationOptions(OutputKind.DynamicallyLinkedLibrary, allowUnsafe: true);

            var solution = new AdhocWorkspace()
                           .CurrentSolution
                           .AddProject(projectId, TestProjectName, TestProjectName, language)
                           .WithProjectCompilationOptions(projectId, compilationOptions)
                           .AddMetadataReference(projectId, MetadataReferences.CorlibReference)
                           .AddMetadataReference(projectId, MetadataReferences.SystemReference)
                           .AddMetadataReference(projectId, MetadataReferences.SystemCoreReference)
                           .AddMetadataReference(projectId, MetadataReferences.PresentationCoreReference)
                           .AddMetadataReference(projectId, MetadataReferences.PresentationFrameworkReference)
                           .AddMetadataReference(projectId, MetadataReferences.WindowsBaseReference)
                           .AddMetadataReference(projectId, MetadataReferences.SystemXamlReference)
                           .AddMetadataReference(projectId, MetadataReferences.CSharpSymbolsReference)
                           .AddMetadataReference(projectId, MetadataReferences.CodeAnalysisReference);

            solution.Workspace.Options =
                solution.Workspace.Options
                .WithChangedOption(FormattingOptions.IndentationSize, language, this.IndentationSize)
                .WithChangedOption(FormattingOptions.TabSize, language, this.TabSize)
                .WithChangedOption(FormattingOptions.UseTabs, language, this.UseTabs);

            var parseOptions = solution.GetProject(projectId).ParseOptions;

            return(solution.WithProjectParseOptions(projectId, parseOptions.WithDocumentationMode(DocumentationMode.Diagnose)));
        }
        /// <summary>
        /// Creates a solution that will be used as parent for the sources that need to be checked.
        /// </summary>
        /// <param name="projectId">The project identifier to use.</param>
        /// <param name="language">The language for which the solution is being created.</param>
        /// <returns>The created solution.</returns>
        protected virtual Solution CreateSolution(ProjectId projectId, string language)
        {
            var compilationOptions = new CSharpCompilationOptions(OutputKind.DynamicallyLinkedLibrary, allowUnsafe: true);

            Solution solution = new AdhocWorkspace()
                                .CurrentSolution
                                .AddProject(projectId, TestProjectName, TestProjectName, language)
                                .WithProjectCompilationOptions(projectId, compilationOptions)
                                .AddMetadataReference(projectId, MetadataReferences.CorlibReference)
                                .AddMetadataReference(projectId, MetadataReferences.SystemReference)
                                .AddMetadataReference(projectId, MetadataReferences.SystemCoreReference)
                                .AddMetadataReference(projectId, MetadataReferences.CSharpSymbolsReference)
                                .AddMetadataReference(projectId, MetadataReferences.CodeAnalysisReference);

            var settings = this.GetSettings();

            if (!string.IsNullOrEmpty(settings))
            {
                var documentId = DocumentId.CreateNewId(projectId);
                solution = solution.AddAdditionalDocument(documentId, SettingsHelper.PublicApiFileName, settings);
            }

            ParseOptions parseOptions = solution.GetProject(projectId).ParseOptions;

            return(solution.WithProjectParseOptions(projectId, parseOptions.WithDocumentationMode(DocumentationMode.Diagnose)));
        }
Exemplo n.º 3
0
        /// <summary>
        /// Creates a solution that will be used as parent for the sources that need to be checked.
        /// </summary>
        /// <param name="projectId">The project identifier to use.</param>
        /// <param name="language">The language for which the solution is being created.</param>
        /// <returns>The created solution.</returns>
        protected virtual Solution CreateSolution(ProjectId projectId, string language)
        {
            var compilationOptions = new CSharpCompilationOptions(OutputKind.DynamicallyLinkedLibrary, allowUnsafe: true);

            var additionalDiagnosticOptions = this.GetDisabledDiagnostics().Select(id => new KeyValuePair <string, ReportDiagnostic>(id, ReportDiagnostic.Suppress));
            var newSpecificOptions          = compilationOptions.SpecificDiagnosticOptions.AddRange(additionalDiagnosticOptions);

            compilationOptions = compilationOptions.WithSpecificDiagnosticOptions(newSpecificOptions);

            Solution solution = new AdhocWorkspace()
                                .CurrentSolution
                                .AddProject(projectId, TestProjectName, TestProjectName, language)
                                .WithProjectCompilationOptions(projectId, compilationOptions)
                                .AddMetadataReference(projectId, CorlibReference)
                                .AddMetadataReference(projectId, SystemReference)
                                .AddMetadataReference(projectId, SystemCoreReference)
                                .AddMetadataReference(projectId, CSharpSymbolsReference)
                                .AddMetadataReference(projectId, CodeAnalysisReference);

            var settings = this.GetSettings();

            if (!string.IsNullOrEmpty(settings))
            {
                var documentId = DocumentId.CreateNewId(projectId);
                solution = solution.AddAdditionalDocument(documentId, SettingsFileName, settings);
            }

            ParseOptions parseOptions = solution.GetProject(projectId).ParseOptions;

            return(solution.WithProjectParseOptions(projectId, parseOptions.WithDocumentationMode(DocumentationMode.Diagnose)));
        }
Exemplo n.º 4
0
        /// <summary>
        /// Creates a solution that will be used as parent for the sources that need to be checked.
        /// </summary>
        /// <param name="projectId">The project identifier to use.</param>
        /// <param name="language">The language for which the solution is being created.</param>
        /// <returns>The created solution.</returns>
        private static Solution CreateSolution(ProjectId projectId, string language)
        {
            var compilationOptions = new CSharpCompilationOptions(OutputKind.DynamicallyLinkedLibrary, allowUnsafe: true);

            var solution = new AdhocWorkspace()
                           .CurrentSolution
                           .AddProject(projectId, TestProjectName, TestProjectName, language)
                           .WithProjectCompilationOptions(projectId, compilationOptions)
                           .AddMetadataReference(projectId, MetadataReferences.MsCorlib)
                           .AddMetadataReference(projectId, MetadataReferences.System)
                           .AddMetadataReference(projectId, MetadataReferences.SystemCore)
                           .AddMetadataReference(projectId, MetadataReferences.SystemNet)
                           .AddMetadataReference(projectId, MetadataReferences.SystemData)
                           .AddMetadataReference(projectId, MetadataReferences.PresentationCore)
                           .AddMetadataReference(projectId, MetadataReferences.PresentationFramework)
                           .AddMetadataReference(projectId, MetadataReferences.WindowsBase)
                           .AddMetadataReference(projectId, MetadataReferences.SystemXml)
                           .AddMetadataReference(projectId, MetadataReferences.SystemXaml)
                           .AddMetadataReference(projectId, MetadataReferences.SystemReactive)
                           .AddMetadataReference(projectId, MetadataReferences.SystemReactiveInterfaces)
                           .AddMetadataReference(projectId, MetadataReferences.SystemReactiveLinq)
                           .AddMetadataReference(projectId, MetadataReferences.CSharpSymbols)
                           .AddMetadataReference(projectId, MetadataReferences.CodeAnalysis)
                           .AddMetadataReference(projectId, MetadataReferences.NUnit);

            solution.Workspace.Options =
                solution.Workspace.Options
                .WithChangedOption(FormattingOptions.IndentationSize, language, DefaultIndentationSize)
                .WithChangedOption(FormattingOptions.TabSize, language, DefaultTabSize)
                .WithChangedOption(FormattingOptions.UseTabs, language, DefaultUseTabs);

            var parseOptions = solution.GetProject(projectId).ParseOptions;

            return(solution.WithProjectParseOptions(projectId, parseOptions.WithDocumentationMode(DocumentationMode.Diagnose)));
        }
        /// <summary>
        /// Creates a solution that will be used as parent for the sources that need to be checked.
        /// </summary>
        /// <param name="projectId">The project identifier to use.</param>
        /// <param name="language">The language for which the solution is being created.</param>
        /// <returns>The created solution.</returns>
        protected virtual Solution CreateSolution(ProjectId projectId, string language)
        {
            var compilationOptions = new CSharpCompilationOptions(OutputKind.DynamicallyLinkedLibrary, allowUnsafe: true);

            Solution solution = new AdhocWorkspace()
                                .CurrentSolution
                                .AddProject(projectId, TestProjectName, TestProjectName, language)
                                .WithProjectCompilationOptions(projectId, compilationOptions)
                                .AddMetadataReference(projectId, MetadataReferences.CorlibReference)
                                .AddMetadataReference(projectId, MetadataReferences.SystemReference)
                                .AddMetadataReference(projectId, MetadataReferences.SystemCoreReference)
                                .AddMetadataReference(projectId, MetadataReferences.CSharpSymbolsReference)
                                .AddMetadataReference(projectId, MetadataReferences.CodeAnalysisReference);

            var publicApi = this.GetUnshippedPublicApi();

            if (publicApi != null)
            {
                var documentId = DocumentId.CreateNewId(projectId);
                solution = solution.AddAdditionalDocument(documentId, DeclarePublicAPIAnalyzer.UnshippedFileName, publicApi, filePath: this.GetUnshippedPublicApiFilePath());
            }

            publicApi = this.GetShippedPublicApi();
            if (publicApi != null)
            {
                var documentId = DocumentId.CreateNewId(projectId);
                solution = solution.AddAdditionalDocument(documentId, DeclarePublicAPIAnalyzer.ShippedFileName, publicApi, filePath: this.GetShippedPublicApiFilePath());
            }

            ParseOptions parseOptions = solution.GetProject(projectId).ParseOptions;

            return(solution.WithProjectParseOptions(projectId, parseOptions.WithDocumentationMode(DocumentationMode.Diagnose)));
        }
Exemplo n.º 6
0
        /// <summary>
        /// Creates a solution that will be used as parent for the sources that need to be checked.
        /// </summary>
        /// <param name="projectId">The project identifier to use.</param>
        /// <param name="language">The language for which the solution is being created.</param>
        /// <returns>The created solution.</returns>
        protected virtual Solution CreateSolution(ProjectId projectId, string language)
        {
            Solution solution = new AdhocWorkspace()
                                .CurrentSolution
                                .AddProject(projectId, TestProjectName, TestProjectName, language)
                                .WithProjectCompilationOptions(projectId, new CSharpCompilationOptions(OutputKind.DynamicallyLinkedLibrary, allowUnsafe: true))
                                .AddMetadataReference(projectId, CorlibReference)
                                .AddMetadataReference(projectId, SystemReference)
                                .AddMetadataReference(projectId, SystemCoreReference)
                                .AddMetadataReference(projectId, CSharpSymbolsReference)
                                .AddMetadataReference(projectId, CodeAnalysisReference);

            ParseOptions parseOptions = solution.GetProject(projectId).ParseOptions;

            return(solution.WithProjectParseOptions(projectId, parseOptions.WithDocumentationMode(DocumentationMode.Diagnose)));
        }
Exemplo n.º 7
0
        /// <summary>
        /// Create a project using the inputted strings as sources.
        /// </summary>
        /// <param name="sources">Classes in the form of strings</param>
        /// <param name="language">The language the source code is in</param>
        /// <returns>A Project created out of the Documents created from the source strings</returns>
        private Project CreateProject(string[] sources, string language = LanguageNames.CSharp, bool usePortableReference = false)
        {
            string fileNamePrefix     = DefaultFilePathPrefix;
            string fileExt            = language == LanguageNames.CSharp ? CSharpDefaultFileExt : VisualBasicDefaultExt;
            var    compilationOptions = new CSharpCompilationOptions(OutputKind.DynamicallyLinkedLibrary, allowUnsafe: true);

            var projectId = ProjectId.CreateNewId(debugName: TestProjectName);

            var corlibReference = usePortableReference ? PortableCorlibReference : CorlibReference;

            var solution = new AdhocWorkspace()
                           .CurrentSolution
                           .AddProject(projectId, TestProjectName, TestProjectName, language)
                           .WithProjectCompilationOptions(projectId, compilationOptions)
                           .AddMetadataReference(projectId, corlibReference)
                           .AddMetadataReference(projectId, SystemCoreReference)
                           .AddMetadataReference(projectId, CSharpSymbolsReference)
                           .AddMetadataReference(projectId, CodeAnalysisReference)
                           .AddMetadataReference(projectId, ThisProjectReference)
                           .AddMetadataReference(projectId, MsTestReference)
                           .AddMetadataReference(projectId, XunitReference);

            var settings = this.GetSettings();

            if (!string.IsNullOrEmpty(settings))
            {
                var documentId = DocumentId.CreateNewId(projectId);
                solution = solution.AddAdditionalDocument(documentId, SettingsFileName, settings);
            }

            ParseOptions parseOptions = solution.GetProject(projectId).ParseOptions;

            solution.WithProjectParseOptions(projectId, parseOptions.WithDocumentationMode(DocumentationMode.Diagnose));

            int count = 0;

            foreach (var source in sources)
            {
                var newFileName = fileNamePrefix + count + "." + fileExt;
                var documentId  = DocumentId.CreateNewId(projectId, debugName: newFileName);
                solution = solution.AddDocument(documentId, newFileName, SourceText.From(source));
                count++;
            }

            return(solution.GetProject(projectId));
        }
Exemplo n.º 8
0
        private static Solution CreateSolution(ProjectId projectId, string projectName)
        {
            var compilationOptions = new CSharpCompilationOptions(OutputKind.DynamicallyLinkedLibrary, allowUnsafe: true);
            var solution           = new AdhocWorkspace()
                                     .CurrentSolution
                                     .AddProject(projectId, projectName, projectName, LanguageNames.CSharp)
                                     .WithProjectCompilationOptions(projectId, compilationOptions)
                                     .AddMetadataReference(projectId, MetadataReference.CreateFromFile(typeof(object).Assembly.Location).WithAliases(ImmutableArray.Create("global", "corlib")))
                                     .AddMetadataReference(projectId, MetadataReference.CreateFromFile(typeof(System.Diagnostics.Debug).Assembly.Location).WithAliases(ImmutableArray.Create("global", "system")))
                                     .AddMetadataReference(projectId, MetadataReference.CreateFromFile(typeof(Enumerable).Assembly.Location))
                                     .AddMetadataReference(projectId, MetadataReference.CreateFromFile(typeof(WebClient).Assembly.Location))
                                     .AddMetadataReference(projectId, MetadataReference.CreateFromFile(typeof(System.Xml.Serialization.XmlSerializer).Assembly.Location))
                                     .AddMetadataReference(projectId, MetadataReference.CreateFromFile(typeof(CSharpCompilation).Assembly.Location))
                                     .AddMetadataReference(projectId, MetadataReference.CreateFromFile(typeof(Compilation).Assembly.Location));
            var parseOptions = solution.GetProject(projectId).ParseOptions;

            return(solution.WithProjectParseOptions(projectId, parseOptions.WithDocumentationMode(DocumentationMode.Diagnose)));
        }
Exemplo n.º 9
0
        private static Project CreateProject(AnalyzerVerificationContext context, string[] sources)
        {
            var projectId = ProjectId.CreateNewId(TestProjectName);

            var solution = new AdhocWorkspace()
                           .CurrentSolution
                           .AddProject(projectId, TestProjectName, TestProjectName, LanguageNames.CSharp);

            solution = UnityAssemblies().Aggregate(solution, (current, dll) => current.AddMetadataReference(projectId, MetadataReference.CreateFromFile(dll)));
            solution = solution.WithProjectParseOptions(projectId, new CSharpParseOptions(context.LanguageVersion));

            var count = 0;

            foreach (var source in sources)
            {
                var newFileName = DefaultFilePathPrefix + count + "." + CSharpDefaultFileExt;
                var documentId  = DocumentId.CreateNewId(projectId, newFileName);
                solution = solution.AddDocument(documentId, newFileName, SourceText.From(source), filePath: @"/" + newFileName);
                count++;
            }

            return(solution.GetProject(projectId));
        }
        /// <summary>
        /// Creates a solution that will be used as parent for the sources that need to be checked.
        /// </summary>
        /// <param name="projectId">The project identifier to use.</param>
        /// <param name="language">The language for which the solution is being created.</param>
        /// <returns>The created solution.</returns>
        protected virtual Solution CreateSolution(ProjectId projectId, string language)
        {
            var compilationOptions = new CSharpCompilationOptions(OutputKind.DynamicallyLinkedLibrary, allowUnsafe: true);

            var solution = new AdhocWorkspace()
                           .CurrentSolution
                           .AddProject(projectId, TestProjectName, TestProjectName, language)
                           .WithProjectCompilationOptions(projectId, compilationOptions)
                           .AddMetadataReference(projectId, MetadataReferences.CorlibReference)
                           .AddMetadataReference(projectId, MetadataReferences.SystemReference)
                           .AddMetadataReference(projectId, MetadataReferences.SystemCoreReference)
                           .AddMetadataReference(projectId, MetadataReferences.CSharpSymbolsReference)
                           .AddMetadataReference(projectId, MetadataReferences.CodeAnalysisReference);

            solution.Workspace.Options =
                solution.Workspace.Options
                .WithChangedOption(FormattingOptions.IndentationSize, language, IndentationSize)
                .WithChangedOption(FormattingOptions.TabSize, language, TabSize)
                .WithChangedOption(FormattingOptions.UseTabs, language, UseTabs);

            var settings = GetSettings();

            var defaultSettings = new StyleCopSettings();

            if (IndentationSize != defaultSettings.Indentation.IndentationSize ||
                UseTabs != defaultSettings.Indentation.UseTabs ||
                TabSize != defaultSettings.Indentation.TabSize)
            {
                var indentationSettings = $@"
{{
  ""settings"": {{
    ""indentation"": {{
      ""indentationSize"": {IndentationSize},
      ""useTabs"": {UseTabs.ToString().ToLowerInvariant()},
      ""tabSize"": {TabSize}
    }}
  }}
}}
";

                if (string.IsNullOrEmpty(settings))
                {
                    settings = indentationSettings;
                }
                else
                {
                    var mergedSettings = JsonConvert.DeserializeObject <JObject>(settings);
                    mergedSettings.Merge(JsonConvert.DeserializeObject <JObject>(indentationSettings));
                    settings = JsonConvert.SerializeObject(mergedSettings);
                }
            }

            if (!string.IsNullOrEmpty(settings))
            {
                var documentId = DocumentId.CreateNewId(projectId);
                solution = solution.AddAdditionalDocument(documentId, SettingsHelper.SettingsFileName, settings);
            }

            var parseOptions = solution.GetProject(projectId).ParseOptions;

            return(solution.WithProjectParseOptions(projectId, parseOptions.WithDocumentationMode(DocumentationMode.Diagnose)));
        }
Exemplo n.º 11
0
        /// <summary>
        /// Creates a solution that will be used as parent for the sources that need to be checked.
        /// </summary>
        /// <param name="projectId">The project identifier to use.</param>
        /// <param name="language">The language for which the solution is being created.</param>
        /// <returns>The created solution.</returns>
        protected virtual Solution CreateSolution(ProjectId projectId, string language)
        {
            var compilationOptions = new CSharpCompilationOptions(OutputKind.DynamicallyLinkedLibrary, allowUnsafe: true);

            Solution solution = new AdhocWorkspace()
                                .CurrentSolution
                                .AddProject(projectId, TestProjectName, TestProjectName, language)
                                .WithProjectCompilationOptions(projectId, compilationOptions)
                                .AddMetadataReference(projectId, MetadataReferences.CorlibReference)
                                .AddMetadataReference(projectId, MetadataReferences.SystemReference)
                                .AddMetadataReference(projectId, MetadataReferences.SystemCoreReference)
                                .AddMetadataReference(projectId, MetadataReferences.CSharpSymbolsReference)
                                .AddMetadataReference(projectId, MetadataReferences.CodeAnalysisReference);

            if (MetadataReferences.SystemRuntimeReference != null)
            {
                solution = solution.AddMetadataReference(projectId, MetadataReferences.SystemRuntimeReference);
            }

            if (MetadataReferences.SystemValueTupleReference != null)
            {
                solution = solution.AddMetadataReference(projectId, MetadataReferences.SystemValueTupleReference);
            }

            solution.Workspace.Options =
                solution.Workspace.Options
                .WithChangedOption(FormattingOptions.IndentationSize, language, this.IndentationSize)
                .WithChangedOption(FormattingOptions.TabSize, language, this.TabSize)
                .WithChangedOption(FormattingOptions.UseTabs, language, this.UseTabs);

            var settings = this.GetSettings();

            StyleCopSettings defaultSettings = new StyleCopSettings();

            if (this.IndentationSize != defaultSettings.Indentation.IndentationSize ||
                this.UseTabs != defaultSettings.Indentation.UseTabs ||
                this.TabSize != defaultSettings.Indentation.TabSize)
            {
                var indentationSettings = $@"
{{
  ""settings"": {{
    ""indentation"": {{
      ""indentationSize"": {this.IndentationSize},
      ""useTabs"": {this.UseTabs.ToString().ToLowerInvariant()},
      ""tabSize"": {this.TabSize}
    }}
  }}
}}
";

                if (string.IsNullOrEmpty(settings))
                {
                    settings = indentationSettings;
                }
                else
                {
                    JsonObject indentationObject = JsonReader.Parse(indentationSettings).AsJsonObject;
                    JsonObject settingsObject    = JsonReader.Parse(settings).AsJsonObject;
                    JsonObject mergedSettings    = MergeJsonObjects(settingsObject, indentationObject);
                    using (var writer = new JsonWriter(pretty: true))
                    {
                        settings = writer.Serialize(mergedSettings);
                    }
                }
            }

            if (!string.IsNullOrEmpty(settings))
            {
                var documentId = DocumentId.CreateNewId(projectId);
                solution = solution.AddAdditionalDocument(documentId, this.GetSettingsFileName(), settings);
            }

            ParseOptions parseOptions = solution.GetProject(projectId).ParseOptions;

            return(solution.WithProjectParseOptions(projectId, parseOptions.WithDocumentationMode(DocumentationMode.Diagnose)));
        }
        /// <summary>
        /// Create a project using the inputted strings as sources.
        /// </summary>
        /// <param name="sources">Classes in the form of strings</param>
        /// <param name="language">The language the source code is in</param>
        /// <param name="framework">The targed unit test framework.</param>
        /// <returns>A Project created out of the Documents created from the source strings</returns>
        private Project CreateProject(string[] sources, string language, UnitTestFramework framework)
        {
            string fileNamePrefix     = DefaultFilePathPrefix;
            string fileExt            = language == LanguageNames.CSharp ? CSharpDefaultFileExt : VisualBasicDefaultExt;
            var    compilationOptions = new CSharpCompilationOptions(OutputKind.DynamicallyLinkedLibrary, allowUnsafe: true);

            var projectId = ProjectId.CreateNewId(debugName: TestProjectName);

            MetadataReference corlibReference;
            MetadataReference unitTestFrameworkReference;

            switch (framework)
            {
            case UnitTestFramework.MSTest:
                unitTestFrameworkReference = MsTestReference;
                corlibReference            = CorlibReference;
                break;

            case UnitTestFramework.Xunit:
                unitTestFrameworkReference = XunitReference;
                corlibReference            = PortableCorlibReference;
                break;

            case UnitTestFramework.NUnit:
                unitTestFrameworkReference = NUnitReference;
                corlibReference            = CorlibReference;
                break;

            default:
                throw new ArgumentException("The provided value is not supported", nameof(framework));
            }

            var solution = new AdhocWorkspace()
                           .CurrentSolution
                           .AddProject(projectId, TestProjectName, TestProjectName, language)
                           .WithProjectCompilationOptions(projectId, compilationOptions)
                           .AddMetadataReference(projectId, corlibReference)
                           .AddMetadataReference(projectId, SystemCoreReference)
                           .AddMetadataReference(projectId, CSharpSymbolsReference)
                           .AddMetadataReference(projectId, CodeAnalysisReference)
                           .AddMetadataReference(projectId, ThisProjectReference)
                           .AddMetadataReference(projectId, unitTestFrameworkReference);

            var settings = this.GetSettings();

            if (!string.IsNullOrEmpty(settings))
            {
                var documentId = DocumentId.CreateNewId(projectId);
                solution = solution.AddAdditionalDocument(documentId, SettingsFileName, settings);
            }

            ParseOptions parseOptions = solution.GetProject(projectId).ParseOptions;

#pragma warning disable RS1014 // Do not ignore values returned by methods on immutable objects.
            solution.WithProjectParseOptions(projectId, parseOptions.WithDocumentationMode(DocumentationMode.Diagnose));
#pragma warning restore RS1014 // Do not ignore values returned by methods on immutable objects.

            int count = 0;
            foreach (var source in sources)
            {
                var newFileName = fileNamePrefix + count + "." + fileExt;
                var documentId  = DocumentId.CreateNewId(projectId, debugName: newFileName);
                solution = solution.AddDocument(documentId, newFileName, SourceText.From(source));
                count++;
            }

            return(solution.GetProject(projectId));
        }