This repository was archived by the owner on Apr 20, 2023. It is now read-only.
Repository navigation
Migration Report #4310
Merged
Merged
Migration Report #4310
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
src/Microsoft.DotNet.ProjectJsonMigration/ProjectContextExtensions.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| // Copyright (c) .NET Foundation and contributors. All rights reserved. | ||
| // Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
|
||
| using System; | ||
| using System.Collections.Generic; | ||
| using Microsoft.Build.Construction; | ||
| using System.Linq; | ||
| using Microsoft.DotNet.ProjectModel; | ||
| using System.IO; | ||
|
|
||
| namespace Microsoft.DotNet.ProjectJsonMigration | ||
| { | ||
| public static class ProjectContextExtensions | ||
| { | ||
| public static string GetProjectName(this ProjectContext projectContext) | ||
| { | ||
| // _ here is just an arbitrary configuration value so we can obtain the output name | ||
| return Path.GetFileNameWithoutExtension(projectContext.GetOutputPaths("_").CompilationFiles.Assembly); | ||
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
Sorry, something went wrong. |
||
| } | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
src/Microsoft.DotNet.ProjectJsonMigration/Report/MigrationReport.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| // Copyright (c) .NET Foundation and contributors. All rights reserved. | ||
| // Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
|
||
| using System; | ||
| using System.Collections.Generic; | ||
| using System.Linq; | ||
|
|
||
| namespace Microsoft.DotNet.ProjectJsonMigration | ||
| { | ||
| /// Any changes to this need to be reflected in roslyn-project-system | ||
| /// TODO add link | ||
| public class MigrationReport | ||
| { | ||
| public List<ProjectMigrationReport> ProjectMigrationReports { get; } | ||
|
|
||
| public int MigratedProjectsCount => ProjectMigrationReports.Count; | ||
|
|
||
| public int SucceededProjectsCount => ProjectMigrationReports.Count(p => p.Succeeded); | ||
|
|
||
| public int FailedProjectsCount => ProjectMigrationReports.Count(p => p.Failed); | ||
|
|
||
| public bool AllSucceeded => ! ProjectMigrationReports.Any(p => p.Failed); | ||
|
|
||
| public MigrationReport Merge(MigrationReport otherReport) | ||
| { | ||
| var allReports = ProjectMigrationReports.Concat(otherReport.ProjectMigrationReports).ToList(); | ||
| var dedupedReports = DedupeSkippedReports(allReports); | ||
|
|
||
| return new MigrationReport(dedupedReports); | ||
| } | ||
|
|
||
| private List<ProjectMigrationReport> DedupeSkippedReports(List<ProjectMigrationReport> allReports) | ||
| { | ||
| var reportDict = new Dictionary<string, ProjectMigrationReport>(); | ||
|
|
||
| foreach (var report in allReports) | ||
| { | ||
| ProjectMigrationReport existingReport; | ||
|
|
||
| if (reportDict.TryGetValue(report.ProjectDirectory, out existingReport)) | ||
| { | ||
| if (existingReport.Skipped) | ||
| { | ||
| reportDict[report.ProjectDirectory] = report; | ||
| } | ||
| else if (!report.Skipped) | ||
| { | ||
| MigrationTrace.Instance.WriteLine("Detected double project migration: {report.ProjectDirectory}"); | ||
| } | ||
| } | ||
| else | ||
| { | ||
| reportDict[report.ProjectDirectory] = report; | ||
| } | ||
| } | ||
|
|
||
| return reportDict.Values.ToList(); | ||
| } | ||
|
|
||
| public MigrationReport(List<ProjectMigrationReport> projectMigrationReports) | ||
| { | ||
| ProjectMigrationReports = projectMigrationReports; | ||
| } | ||
| } | ||
| } |
45 changes: 45 additions & 0 deletions
45
src/Microsoft.DotNet.ProjectJsonMigration/Report/ProjectMigrationReport.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| // Copyright (c) .NET Foundation and contributors. All rights reserved. | ||
| // Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
|
||
| using System.Collections.Generic; | ||
| using System.Linq; | ||
| namespace Microsoft.DotNet.ProjectJsonMigration | ||
| { | ||
| public class ProjectMigrationReport | ||
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
Sorry, something went wrong. |
||
| { | ||
| public string ProjectDirectory { get; } | ||
|
|
||
| public string ProjectName { get; } | ||
|
|
||
| public string OutputMSBuildProject { get; } | ||
|
|
||
| public List<MigrationError> Errors { get; } | ||
|
|
||
| public List<string> Warnings { get; } | ||
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
Sorry, something went wrong. |
||
|
|
||
| public bool Skipped { get; } | ||
|
|
||
| public bool Failed => Errors.Any(); | ||
|
|
||
| public bool Succeeded => !Errors.Any(); | ||
|
|
||
| public ProjectMigrationReport(string projectDirectory, string projectName, bool skipped) | ||
| : this(projectDirectory, projectName, null, null, null, skipped: skipped) { } | ||
|
|
||
| public ProjectMigrationReport(string projectDirectory, string projectName, List<MigrationError> errors, List<string> warnings) | ||
| : this(projectDirectory, projectName, null, errors, warnings) { } | ||
|
|
||
| public ProjectMigrationReport(string projectDirectory, string projectName, string outputMSBuildProject, List<string> warnings) | ||
| : this(projectDirectory, projectName, outputMSBuildProject, null, warnings) { } | ||
|
|
||
| private ProjectMigrationReport(string projectDirectory, string projectName, string outputMSBuildProject, List<MigrationError> errors, List<string> warnings, bool skipped=false) | ||
| { | ||
| ProjectDirectory = projectDirectory; | ||
| ProjectName = projectName; | ||
| OutputMSBuildProject = outputMSBuildProject; | ||
| Errors = errors ?? new List<MigrationError>(); | ||
| Warnings = warnings ?? new List<string>(); | ||
| Skipped=skipped; | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.