Skip to content

Commit

Permalink
Merge pull request #351 from dansiegel/dev/ds/required-platforms
Browse files Browse the repository at this point in the history
Add support for Platform Filtering on Property and Classes
  • Loading branch information
dansiegel authored Dec 22, 2024
2 parents 0133bb4 + ddd698f commit 7f7c43b
Show file tree
Hide file tree
Showing 31 changed files with 671 additions and 198 deletions.
13 changes: 7 additions & 6 deletions E2E/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,21 @@

<PropertyGroup Condition=" '$(PIPELINE_WORKSPACE)' != '' ">
<CIArtifactsDirectory>$([System.IO.Path]::Combine('$(PIPELINE_WORKSPACE)', 'Artifacts'))</CIArtifactsDirectory>
<GeneratedLocalPackage>$([System.IO.Directory]::GetFiles('$(CIArtifactsDirectory)', 'Mobile.BuildTools.2.*.nupkg')[0])</GeneratedLocalPackage>
<GeneratedLocalPackage>$([System.IO.Directory]::GetFiles('$(CIArtifactsDirectory)', 'Mobile.BuildTools.AppSettings.2.*.nupkg')[0])</GeneratedLocalPackage>
</PropertyGroup>
<PropertyGroup Condition=" '$(PIPELINE_WORKSPACE)' == '' ">
<GeneratedLocalPackage>$([System.IO.Directory]::GetFiles('$(LocalArtifactStagingDirectory)', 'Mobile.BuildTools.2.*.nupkg')[0])</GeneratedLocalPackage>
<GeneratedLocalPackage>$([System.IO.Directory]::GetFiles('$(LocalArtifactStagingDirectory)', 'Mobile.BuildTools.AppSettings.2.*.nupkg')[0])</GeneratedLocalPackage>
</PropertyGroup>

<PropertyGroup>
<EmitCompilerGeneratedFiles>true</EmitCompilerGeneratedFiles>
<GenerateLocalPackageFileName>$([System.IO.Path]::GetFileNameWithoutExtension('$(GeneratedLocalPackage)'))</GenerateLocalPackageFileName>
<GeneratedPackageVersion>$(GenerateLocalPackageFileName.Replace('Mobile.BuildTools.', ''))</GeneratedPackageVersion>
<GeneratedPackageVersion>$(GenerateLocalPackageFileName.Replace('Mobile.BuildTools.AppSettings.', ''))</GeneratedPackageVersion>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Mobile.BuildTools" VersionOverride="$(GeneratedPackageVersion)" PrivateAssets="all" />
<PackageReference Include="Mobile.BuildTools.Configuration" VersionOverride="$(GeneratedPackageVersion)" />
<PackageReference Include="Mobile.BuildTools.AppSettings" VersionOverride="$(GeneratedPackageVersion)" PrivateAssets="all" />
<PackageReference Include="Mobile.BuildTools.Core" VersionOverride="$(GeneratedPackageVersion)" PrivateAssets="all" />
</ItemGroup>

</Project>
</Project>
4 changes: 0 additions & 4 deletions E2E/E2E.Core/E2E.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,4 @@
<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Xamarin.Forms" />
</ItemGroup>

</Project>
13 changes: 0 additions & 13 deletions E2E/E2E.Core/Views/DemoPage.xaml

This file was deleted.

16 changes: 0 additions & 16 deletions E2E/E2E.Core/Views/DemoPage.xaml.cs

This file was deleted.

4 changes: 1 addition & 3 deletions E2E/E2E.Tests/E2E.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<IsPackable>false</IsPackable>
<MobileBuildToolsDebug>true</MobileBuildToolsDebug>
</PropertyGroup>
Expand All @@ -10,10 +10,8 @@

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" />
<PackageReference Include="Xamarin.Forms" />
<PackageReference Include="xunit" />
<PackageReference Include="xunit.runner.visualstudio" />
<PackageReference Include="Xamarin.Forms.Mocks" />
</ItemGroup>

<ItemGroup>
Expand Down
95 changes: 95 additions & 0 deletions E2E/E2E.Tests/Fixtures/AppSettingsFixture.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
using System;
using E2E.Tests.Helpers;
using Xunit;

namespace E2E.Tests.Fixtures
{
public class AppSettingsFixture
{
[Fact]
public void AStringIsOfTypeString()
{
Assert.IsType<string>(AppSettings.AString);
Assert.Equal("Hello World!", AppSettings.AString);
}

[Fact]
public void AnIntIsOfTypeInt()
{
Assert.IsType<int>(AppSettings.AnInt);
Assert.Equal(5, AppSettings.AnInt);
}

[Fact]
public void ADoubleIsOfTypeDouble()
{
Assert.IsType<double>(AppSettings.ADouble);
Assert.Equal(3.14, AppSettings.ADouble);
}

[Fact]
public void ABoolIsOfTypeBool()
{
Assert.IsType<bool>(AppSettings.ABool);
Assert.False(AppSettings.ABool);
}

[Fact]
public void AFloatIsOfTypeFloat()
{
Assert.IsType<float>(AppSettings.AFloat);
Assert.Equal(4.2F, AppSettings.AFloat);
}

[Fact]
public void ADateIsOfTypeDateTime()
{
Assert.IsType<DateTime>(AppSettings.ADate);
Assert.Equal(DateTime.Parse("January 1, 2020"), AppSettings.ADate);
}

[Fact]
public void AUriIsOfTypeUri()
{
Assert.IsType<Uri>(AppSettings.AUri);
Assert.Equal(new Uri("https://mobilebuildtools.com"), AppSettings.AUri);
}

[Fact]
public void AStringArrayHas3Elements()
{
Assert.Equal(3, AppSettings.AStringArray.Length);
Assert.Contains("Foo", AppSettings.AStringArray);
Assert.Contains("Bar", AppSettings.AStringArray);
Assert.Contains("Baz", AppSettings.AStringArray);
}

[Fact]
public void AStringArrayIsOfTypeStringArray()
{
Assert.IsType<string[]>(AppSettings.AStringArray);
Assert.Equal(3, AppSettings.AStringArray.Length);
}

[Fact]
public void AppCenterSecretIsNull()
{
Assert.Null(AppSettings.AppCenterSecret);
}

[Fact]
public void SomeDefaultBoolIsFalse()
{
Assert.IsType<bool>(AppSettings.SomeDefaultBool);
Assert.False(AppSettings.SomeDefaultBool);
}

[Fact]
public void DoesNotGeneratePlatformSpecificProperty()
{
var type = typeof(AppSettings);
var property = type.GetProperty("APlatformProperty");
Assert.Null(property);
}
}
}
90 changes: 45 additions & 45 deletions E2E/E2E.Tests/Fixtures/SCSSToCSSFixture.cs
Original file line number Diff line number Diff line change
@@ -1,51 +1,51 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using E2E.Core;
using Xunit;
// using System;
// using System.Collections.Generic;
// using System.IO;
// using System.Linq;
// using System.Reflection;
// using E2E.Core;
// using Xunit;

namespace E2E.Tests.Fixtures
{
public class SCSSToCSSFixture
{
public const string ExpectedCSSResourceId = "E2E.Core.theme.style.css";
public const string SecondaryExpectedCSSResourceId = "E2E.Core.theme.anotherStyle.css";
public const string ExpectedCSS = @".primaryButton{background-color:#006}^button{background-color:transparent}";
// namespace E2E.Tests.Fixtures
// {
// public class SCSSToCSSFixture
// {
// public const string ExpectedCSSResourceId = "E2E.Core.theme.style.css";
// public const string SecondaryExpectedCSSResourceId = "E2E.Core.theme.anotherStyle.css";
// public const string ExpectedCSS = @".primaryButton{background-color:#006}^button{background-color:transparent}";

[Fact]
public void CssIsEmbedded()
{
Assert.NotEmpty(CommonLib.GetManifestResourceNames());
Assert.Contains(ExpectedCSSResourceId, CommonLib.GetManifestResourceNames());
}
// [Fact]
// public void CssIsEmbedded()
// {
// Assert.NotEmpty(CommonLib.GetManifestResourceNames());
// Assert.Contains(ExpectedCSSResourceId, CommonLib.GetManifestResourceNames());
// }

[Fact]
public void SecondaryCssIsEmbedded()
{
Assert.Contains(SecondaryExpectedCSSResourceId, CommonLib.GetManifestResourceNames());
}
// [Fact]
// public void SecondaryCssIsEmbedded()
// {
// Assert.Contains(SecondaryExpectedCSSResourceId, CommonLib.GetManifestResourceNames());
// }

[Fact]
public void CssWasProperlyFormatted()
{
using (var stream = typeof(CommonLib).Assembly.GetManifestResourceStream(ExpectedCSSResourceId))
using (var reader = new StreamReader(stream))
{
Assert.NotNull(stream);
var css = reader.ReadLine();
Assert.Equal(ExpectedCSS, css);
}
}
// [Fact]
// public void CssWasProperlyFormatted()
// {
// using (var stream = typeof(CommonLib).Assembly.GetManifestResourceStream(ExpectedCSSResourceId))
// using (var reader = new StreamReader(stream))
// {
// Assert.NotNull(stream);
// var css = reader.ReadLine();
// Assert.Equal(ExpectedCSS, css);
// }
// }

[Fact]
public void SCSSIsNotEmbedded()
{
Assert.Empty(EmbeddedResources().Where(r => r.EndsWith(".scss", StringComparison.InvariantCultureIgnoreCase)));
}
// [Fact]
// public void SCSSIsNotEmbedded()
// {
// Assert.Empty(EmbeddedResources().Where(r => r.EndsWith(".scss", StringComparison.InvariantCultureIgnoreCase)));
// }

private IEnumerable<string> EmbeddedResources() =>
GetType().Assembly.GetManifestResourceNames();
}
}
// private IEnumerable<string> EmbeddedResources() =>
// GetType().Assembly.GetManifestResourceNames();
// }
// }
76 changes: 0 additions & 76 deletions E2E/E2E.Tests/Fixtures/SecretsFixture.cs

This file was deleted.

Loading

0 comments on commit 7f7c43b

Please sign in to comment.