This commit is contained in:
Ken Schlobohm 2021-03-05 09:18:25 -06:00
Родитель bd09c12f17
Коммит 698f6795c5
6 изменённых файлов: 12 добавлений и 12 удалений

Просмотреть файл

@ -12,7 +12,7 @@ namespace Microsoft.DotNet.UpgradeAssistant
string FilePath { get; }
Languages Language { get; }
Language Language { get; }
Project GetRoslynProject();

Просмотреть файл

@ -6,7 +6,7 @@ namespace Microsoft.DotNet.UpgradeAssistant
/// <summary>
/// An abstraction used to make contextual decisions based on language.
/// </summary>
public enum Languages
public enum Language
{
/// <summary>
/// The default. Used when the language has not been inspected, or cannot be determined.

Просмотреть файл

@ -43,16 +43,16 @@ namespace Microsoft.DotNet.UpgradeAssistant.MSBuild
return Context.GetOrAddProject(project.FilePath);
});
public Languages Language => ParseLanguageByProjectFileExtension(FilePath);
public Language Language => ParseLanguageByProjectFileExtension(FilePath);
private static Languages ParseLanguageByProjectFileExtension(string filePath)
private static Language ParseLanguageByProjectFileExtension(string filePath)
{
return Path.GetExtension(filePath).ToUpperInvariant() switch
{
".CSPROJ"=> Languages.CSharp,
".VBPROJ"=> Languages.VisualBasic,
".FSPROJ"=> Languages.FSharp,
_ => Languages.Unknown
".CSPROJ"=> Language.CSharp,
".VBPROJ"=> Language.VisualBasic,
".FSPROJ"=> Language.FSharp,
_ => Language.Unknown
};
}

Просмотреть файл

@ -26,7 +26,7 @@ namespace Microsoft.DotNet.UpgradeAssistant.Checks
throw new ArgumentNullException(nameof(project));
}
if (project.Language == Languages.VisualBasic && project.Components.HasFlag(ProjectComponents.Wpf))
if (project.Language == Language.VisualBasic && project.Components.HasFlag(ProjectComponents.Wpf))
{
_logger.LogCritical("Project {Project} cannot be upgraded. try-convert version 0.7.212201 does not support the migration of Visual Basic WPF applications", project.FilePath);
return Task.FromResult(false);

Просмотреть файл

@ -71,7 +71,7 @@ namespace Microsoft.DotNet.UpgradeAssistant.Steps.Templates
}
}
protected override bool IsApplicableImpl(IUpgradeContext context) => context?.CurrentProject is not null && context.CurrentProject.Language == Languages.CSharp && _templateProvider.TemplateConfigFileNames.Any();
protected override bool IsApplicableImpl(IUpgradeContext context) => context?.CurrentProject is not null && context.CurrentProject.Language == Language.CSharp && _templateProvider.TemplateConfigFileNames.Any();
protected override async Task<UpgradeStepInitializeResult> InitializeImplAsync(IUpgradeContext context, CancellationToken token)
{

Просмотреть файл

@ -48,7 +48,7 @@ namespace Microsoft.DotNet.UpgradeAssistant.Tests.Checks
private static IProject GetValidProject()
{
var project = new Mock<IProject>();
project.Setup(p => p.Language).Returns(Languages.CSharp);
project.Setup(p => p.Language).Returns(Language.CSharp);
project.Setup(p => p.Components).Returns(ProjectComponents.Wpf);
return project.Object;
@ -57,7 +57,7 @@ namespace Microsoft.DotNet.UpgradeAssistant.Tests.Checks
private static IProject GetInvalidProject()
{
var project = new Mock<IProject>();
project.Setup(p => p.Language).Returns(Languages.VisualBasic);
project.Setup(p => p.Language).Returns(Language.VisualBasic);
project.Setup(p => p.Components).Returns(ProjectComponents.Wpf);
return project.Object;