Skip to content

Commit

Permalink
Disable VisualBasic and WCF UpgradeSteps on non-Windows platforms
Browse files Browse the repository at this point in the history
  • Loading branch information
jstedfast committed Feb 16, 2023
1 parent c6c0961 commit 56e01b5
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

using System;
using System.Linq;
using System.Runtime.InteropServices;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Extensions.Logging;
Expand Down Expand Up @@ -37,7 +38,7 @@ public EnableMyDotSupportSubStep(VisualBasicProjectUpdaterStep vbProjectUpdaterS
protected override Task<bool> IsApplicableImplAsync(IUpgradeContext context, CancellationToken token)
{
// VB updates don't apply until a project is selected
if (context?.CurrentProject is null)
if (context?.CurrentProject is null || !RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
return Task.FromResult(false);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Extensions.Logging;
Expand Down Expand Up @@ -61,7 +62,7 @@ public VisualBasicProjectUpdaterStep(ILogger<VisualBasicProjectUpdaterStep> logg
protected override async Task<bool> IsApplicableImplAsync(IUpgradeContext context, CancellationToken token)
{
// The VisualBasicProjectUpdaterStep is only applicable when a project is loaded
if (context?.CurrentProject is null)
if (context?.CurrentProject is null || !RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis;
Expand Down Expand Up @@ -69,7 +70,7 @@ public WCFUpdateStep(ILogger<WCFUpdateStep> logger, ILoggerFactory loggerFactory
_path = new FilePath();
}

protected override Task<bool> IsApplicableImplAsync(IUpgradeContext context, CancellationToken token) => Task.FromResult(context?.CurrentProject is not null);
protected override Task<bool> IsApplicableImplAsync(IUpgradeContext context, CancellationToken token) => Task.FromResult(context?.CurrentProject is not null && RuntimeInformation.IsOSPlatform(OSPlatform.Windows));

protected override Task<UpgradeStepInitializeResult> InitializeImplAsync(IUpgradeContext context, CancellationToken token)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Linq;
Expand All @@ -26,6 +27,11 @@ public class UpdaterFactoryTest
[InlineData("TestInputFiles\\MultiServicesConfig.txt", "TestExpectedFiles\\MultiServicesTemplateCode.txt")]
public void UpdateFactoryTemplateTest(string input, string expected)
{
if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
return;
}

input = input.Replace('\\', Path.DirectorySeparatorChar);
expected = expected.Replace('\\', Path.DirectorySeparatorChar);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Runtime.InteropServices;
using System.Threading.Tasks;
using Autofac.Extras.Moq;
using Microsoft.CodeAnalysis.CSharp;
Expand Down Expand Up @@ -42,6 +43,11 @@ public WCFUpdateStepTest(ITestOutputHelper output)
[InlineData(Proj, "TestInputFiles\\MultiServicesSourceCode.txt", "TestInputFiles\\MultiServicesConfig.txt", "", UpgradeStepStatus.Incomplete)] // Multiple services case
public void WCFUpdateTest(string proj, string main, string config, string directive, UpgradeStepStatus expected)
{
if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
return;
}

proj = proj.Replace('\\', Path.DirectorySeparatorChar);
main = main.Replace('\\', Path.DirectorySeparatorChar);
config = config.Replace('\\', Path.DirectorySeparatorChar);
Expand Down
21 changes: 10 additions & 11 deletions tests/tool/Integration.Tests/E2ETest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,23 +40,22 @@ public E2ETest(ITestOutputHelper output)
_output = output;
}

[InlineData("PCL", "SamplePCL.csproj", "")]
[InlineData("WpfSample/csharp", "BeanTrader.sln", "BeanTraderClient.csproj")]
[InlineData("PCL", "SamplePCL.csproj", "", true)]
[InlineData("WpfSample/csharp", "BeanTrader.sln", "BeanTraderClient.csproj", true)]
/*
[InlineData("WebLibrary/csharp", "WebLibrary.csproj", "")]
[InlineData("AspNetSample/csharp", "TemplateMvc.csproj", "")]
[InlineData("WebLibrary/csharp", "WebLibrary.csproj", "", true)]
[InlineData("AspNetSample/csharp", "TemplateMvc.csproj", "", true)]
*/
[InlineData("WpfSample/vb", "WpfApp1.sln", "")]
[InlineData("WCFSample", "ConsoleApp.csproj", "")]
[InlineData("WpfSample/vb", "WpfApp1.sln", "", true)]
[InlineData("WCFSample", "ConsoleApp.csproj", "", true)]

// TODO: [mgoertz] Re-enable after MAUI workloads are installed on test machines
// [InlineData("MauiSample/droid", "EwDavidForms.sln", "EwDavidForms.Android.csproj")]
// [InlineData("MauiSample/ios", "EwDavidForms.sln", "EwDavidForms.iOS.csproj")]
// [InlineData("MauiSample/droid", "EwDavidForms.sln", "EwDavidForms.Android.csproj", false)]
// [InlineData("MauiSample/ios", "EwDavidForms.sln", "EwDavidForms.iOS.csproj", false)]
[Theory]
public async Task UpgradeTest(string scenarioPath, string inputFileName, string entrypoint)
public async Task UpgradeTest(string scenarioPath, string inputFileName, string entrypoint, bool windowsOnly)
{
if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows) &&
(scenarioPath == "PCL" || scenarioPath == "WpfSample/csharp"))
if (windowsOnly && !RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
return;
}
Expand Down

0 comments on commit 56e01b5

Please sign in to comment.