protected override async Task <UpgradeStepInitializeResult> InitializeImplAsync(IUpgradeContext context, CancellationToken token) { if (context is null) { throw new ArgumentNullException(nameof(context)); } Project = context.CurrentProject.Required(); var projectPath = Project.FileInfo; Logger.LogDebug("Opening project {ProjectPath}", projectPath); await RefreshDiagnosticsAsync(Project, token).ConfigureAwait(false); foreach (var step in SubSteps) { // Update substep status based on new diagnostic information await step.InitializeAsync(context, token).ConfigureAwait(false); } return(Diagnostics.Any() ? new UpgradeStepInitializeResult(UpgradeStepStatus.Incomplete, $"{Diagnostics.Count()} upgrade diagnostics need fixed", BuildBreakRisk.None) : new UpgradeStepInitializeResult(UpgradeStepStatus.Complete, "No upgrade diagnostics found", BuildBreakRisk.None)); }
internal SyntaxToken(SyntaxKind kind, SyntaxKind contextualKind, bool isMissing, SourceRange sourceRange, string text, object value, IEnumerable <SyntaxNode> leadingTrivia, IEnumerable <SyntaxNode> trailingTrivia, IEnumerable <Diagnostic> diagnostics) : base(kind, diagnostics) { ContextualKind = contextualKind; IsMissing = isMissing; Text = text; SourceRange = sourceRange; Value = value; LeadingTrivia = leadingTrivia.ToImmutableArray(); foreach (var triviaNode in LeadingTrivia) { ((SyntaxNodeBase)triviaNode).Parent = this; } TrailingTrivia = trailingTrivia.ToImmutableArray(); foreach (var triviaNode in TrailingTrivia) { ((SyntaxNodeBase)triviaNode).Parent = this; } FullSourceRange = ComputeFullSpan(sourceRange, LeadingTrivia, TrailingTrivia); ContainsDiagnostics = Diagnostics.Any() || LeadingTrivia.Any(x => x.ContainsDiagnostics) || TrailingTrivia.Any(x => x.ContainsDiagnostics); }
protected override async Task <UpgradeStepApplyResult> ApplyImplAsync(IUpgradeContext context, CancellationToken token) { if (context is null) { throw new ArgumentNullException(nameof(context)); } // Reload the workspace in case code fixes modified the project file await context.ReloadWorkspaceAsync(token).ConfigureAwait(false); // Apply any necessary cleanup to the project file var file = context.CurrentProject.Required().GetFile(); file.Simplify(); await file.SaveAsync(token).ConfigureAwait(false); if (Diagnostics.Any()) { Logger.LogInformation("Source updates complete with {DiagnosticCount} diagnostics remaining which require manual updates", Diagnostics.Count()); foreach (var diagnostic in Diagnostics) { Logger.LogWarning("Manual updates needed to address: {DiagnosticId}@{DiagnosticLocation}: {DiagnosticMessage}", diagnostic.Id, diagnostic.Location, diagnostic.GetMessage()); } } return(new UpgradeStepApplyResult(UpgradeStepStatus.Complete, string.Empty)); }
internal SyntaxToken(PretokenizedSyntaxToken pretokenizedToken, SourceLocation position) : base((SyntaxKind)pretokenizedToken.RawKind, ConvertDiagnostics(pretokenizedToken.Diagnostics, position)) { ContextualKind = (SyntaxKind)pretokenizedToken.RawContextualKind; Text = pretokenizedToken.Text; Value = pretokenizedToken.Value; SourceRange = new SourceRange(position + pretokenizedToken.LeadingTriviaWidth, pretokenizedToken.Width); FullSourceRange = new SourceRange(position, pretokenizedToken.FullWidth); var triviaPosition = position; var convertedLeadingTrivia = new List <SyntaxNode>(); foreach (var trivia in pretokenizedToken.LeadingTrivia) { convertedLeadingTrivia.Add(new SyntaxTrivia( (SyntaxKind)trivia.RawKind, trivia.Text, new SourceRange(triviaPosition, trivia.FullWidth), ConvertDiagnostics(trivia.Diagnostics, triviaPosition))); triviaPosition += trivia.FullWidth; } LeadingTrivia = convertedLeadingTrivia.ToImmutableArray(); triviaPosition = SourceRange.End; var convertedTrailingTrivia = new List <SyntaxNode>(); foreach (var trivia in pretokenizedToken.TrailingTrivia) { convertedTrailingTrivia.Add(new SyntaxTrivia( (SyntaxKind)trivia.RawKind, trivia.Text, new SourceRange(triviaPosition, trivia.FullWidth), ConvertDiagnostics(trivia.Diagnostics, triviaPosition))); triviaPosition += trivia.FullWidth; } TrailingTrivia = convertedTrailingTrivia.ToImmutableArray(); ContainsDiagnostics = Diagnostics.Any() || LeadingTrivia.Any(x => x.ContainsDiagnostics) || TrailingTrivia.Any(x => x.ContainsDiagnostics); }
/// <nodoc /> public override string ToString() { if (!HasError) { return("CORRECT"); } var result = new StringBuilder(); if (Diagnostics.Any()) { result.AppendLine(I($"Diagnostics ({Diagnostics.Count}):")); foreach (var d in Diagnostics) { result.AppendLine(I($"\t{d}")); } } return(result.ToString()); }
protected override async Task <UpgradeStepApplyResult> ApplyImplAsync(IUpgradeContext context, CancellationToken token) { if (context is null) { throw new ArgumentNullException(nameof(context)); } var file = context.CurrentProject.Required().GetFile(); file.Simplify(); await file.SaveAsync(token).ConfigureAwait(false); if (Diagnostics.Any()) { Logger.LogWarning("Completing source updates with {DiagnosticCount} diagnostics still unaddressed", Diagnostics.Count()); } return(new UpgradeStepApplyResult(UpgradeStepStatus.Complete, string.Empty)); }
internal SyntaxToken(SyntaxKind kind, SyntaxKind contextualKind, bool isMissing, SourceRange sourceRange, TextSpan span, string text, object value, IEnumerable <SyntaxNode> leadingTrivia, IEnumerable <SyntaxNode> trailingTrivia, IEnumerable <Diagnostic> diagnostics, MacroReference macroReference, bool isFirstTokenInMacroExpansion) : base(kind, text, span, diagnostics) { ContextualKind = contextualKind; IsMissing = isMissing; SourceRange = sourceRange; Value = value; LeadingTrivia = leadingTrivia.ToImmutableArray(); foreach (var triviaNode in LeadingTrivia) { triviaNode.Parent = this; } TrailingTrivia = trailingTrivia.ToImmutableArray(); foreach (var triviaNode in TrailingTrivia) { triviaNode.Parent = this; } FullSourceRange = ComputeFullSpan(sourceRange, LeadingTrivia, TrailingTrivia); ContainsDiagnostics = Diagnostics.Any() || LeadingTrivia.Any(x => x.ContainsDiagnostics) || TrailingTrivia.Any(x => x.ContainsDiagnostics); ContainsDirectives = LeadingTrivia.OfType <DirectiveTriviaSyntax>().Any() || TrailingTrivia.OfType <DirectiveTriviaSyntax>().Any(); MacroReference = macroReference; IsFirstTokenInMacroExpansion = isFirstTokenInMacroExpansion; }
public bool IsSuccess() { return(!Diagnostics.Any(d => d.Severity == CompilationDiagnosticSeverity.Error)); }