Exemple #1
0
 private async Task <string> GetCompilationErrorsAsync(
     IEnumerable <Project> projectsToConvert)
 {
     var workspaceErrors = _workspace.Value.Diagnostics.GetErrorString();
     var errors          = await projectsToConvert.ParallelSelectAwait(async x => {
         var c = await x.GetCompilationAsync() ?? throw new InvalidOperationException($"Compilation could not be created for {x.Language}");
         return(new[] { CompilationWarnings.WarningsForCompilation(c, c.AssemblyName) });
     }, Env.MaxDop, default).ToArrayAsync();
 /// <summary>
 /// If you've changed the source project not to compile, the results will be very confusing
 /// If this happens randomly, updating the Microsoft.Build dependency may help - it may have to line up with a version installed on the machine in some way.
 /// </summary>
 private static async Task AssertMSBuildIsWorkingAndProjectsValid(
     ImmutableList<WorkspaceDiagnostic> valueDiagnostics, IEnumerable<Project> projectsToConvert)
 {
     var errors = await projectsToConvert.ParallelSelectAsync(async x => {
         var c = await x.GetCompilationAsync();
         return new[]{CompilationWarnings.WarningsForCompilation(c, c.AssemblyName)}.Concat(
             valueDiagnostics.Where(d => d.Kind > WorkspaceDiagnosticKind.Warning).Select(d => d.Message));
     }, Env.MaxDop);
     var errorString = string.Join("\r\n", errors.SelectMany(w => w).Where(w => w != null));
     Assert.True(errorString == "", errorString);
 }
        /// <summary>
        /// If you've changed the source project not to compile, the results will be very confusing
        /// If this happens randomly, updating the Microsoft.Build dependency may help - it may have to line up with a version installed on the machine in some way.
        /// </summary>
        private static async Task AssertMSBuildIsWorkingAndProjectsValid(
            ImmutableList <WorkspaceDiagnostic> valueDiagnostics, IEnumerable <Project> projectsToConvert)
        {
            var compilations = await Task.WhenAll(projectsToConvert.Select(x => x.GetCompilationAsync()));

            IEnumerable <string> errors = compilations
                                          .Select(c => CompilationWarnings.WarningsForCompilation(c, c.AssemblyName)).Concat(
                valueDiagnostics.Where(d => d.Kind > WorkspaceDiagnosticKind.Warning).Select(d => d.Message)
                ).Where(w => w != null);
            var errorString = string.Join("\r\n", errors);

            Assert.True(errorString == "", errorString);
        }
Exemple #4
0
    private async Task <string> GetCompilationErrorsAsync(
        IEnumerable <Project> projectsToConvert)
    {
        var workspaceErrors = (await _workspace.GetValueAsync()).Diagnostics.GetErrorString();
        var errors          = await projectsToConvert.ParallelSelectAwaitAsync(async x => {
            var c = await x.GetCompilationAsync() ?? throw new InvalidOperationException($"Compilation could not be created for {x.Language}");
            return(new[] { CompilationWarnings.WarningsForCompilation(c, c.AssemblyName) });
        }, Env.MaxDop).ToArrayAsync();

        var errorString = string.Join("\r\n", workspaceErrors.Yield().Concat(errors.SelectMany(w => w)).Where(w => w != null));

        return(errorString);
    }