From 803845e76d1b85faace8d476ff76d94689fc32dd Mon Sep 17 00:00:00 2001 From: ProActive-Engineer Date: Mon, 6 Mar 2023 22:01:39 +0000 Subject: [PATCH] Add integration test for netstandard library (#53) * Add integration test for netstandard * Fix publish command: https://github.com/dotnet/performance/pull/2774 --- NetEscapades.EnumGenerators.sln | 14 +++++++ build/Build.cs | 2 +- .../EnumInNamespaceExtensionsTests.cs | 8 ++-- ...thDescriptionInNamespaceExtensionsTests.cs | 16 ++++---- ...thDisplayNameInNamespaceExtensionsTests.cs | 16 ++++---- .../EnumWithSameDisplayNameExtensionsTests.cs | 16 ++++---- .../ExtensionTests.cs | 8 ++-- .../FlagsEnumExtensionsTests.cs | 10 ++--- .../LongEnumExtensionsTests.cs | 10 ++--- ...des.EnumGenerators.IntegrationTests.csproj | 1 + ...rators.NetStandard.IntegrationTests.csproj | 38 +++++++++++++++++++ ...scapades.EnumGenerators.NetStandard.csproj | 21 ++++++++++ ...s.Nuget.Attributes.IntegrationTests.csproj | 3 +- ...umGenerators.Nuget.IntegrationTests.csproj | 1 + 14 files changed, 120 insertions(+), 44 deletions(-) create mode 100644 tests/NetEscapades.EnumGenerators.NetStandard.IntegrationTests/NetEscapades.EnumGenerators.NetStandard.IntegrationTests.csproj create mode 100644 tests/NetEscapades.EnumGenerators.NetStandard/NetEscapades.EnumGenerators.NetStandard.csproj diff --git a/NetEscapades.EnumGenerators.sln b/NetEscapades.EnumGenerators.sln index e078820..a8b93a3 100644 --- a/NetEscapades.EnumGenerators.sln +++ b/NetEscapades.EnumGenerators.sln @@ -27,6 +27,10 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "samples", "samples", "{AC0D EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ToStringFastExample", "samples\ToStringFastExample\ToStringFastExample.csproj", "{BDF8C04B-D0E3-4FF5-82C3-E8FDF3916C16}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NetEscapades.EnumGenerators.NetStandard", "tests\NetEscapades.EnumGenerators.NetStandard\NetEscapades.EnumGenerators.NetStandard.csproj", "{40B2D8D1-7523-498D-9753-CECC3A44071A}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NetEscapades.EnumGenerators.NetStandard.IntegrationTests", "tests\NetEscapades.EnumGenerators.NetStandard.IntegrationTests\NetEscapades.EnumGenerators.NetStandard.IntegrationTests.csproj", "{7A0F5EA5-DB7B-49E0-827D-946C80175322}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -66,6 +70,14 @@ Global {BDF8C04B-D0E3-4FF5-82C3-E8FDF3916C16}.Debug|Any CPU.Build.0 = Debug|Any CPU {BDF8C04B-D0E3-4FF5-82C3-E8FDF3916C16}.Release|Any CPU.ActiveCfg = Release|Any CPU {BDF8C04B-D0E3-4FF5-82C3-E8FDF3916C16}.Release|Any CPU.Build.0 = Release|Any CPU + {40B2D8D1-7523-498D-9753-CECC3A44071A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {40B2D8D1-7523-498D-9753-CECC3A44071A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {40B2D8D1-7523-498D-9753-CECC3A44071A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {40B2D8D1-7523-498D-9753-CECC3A44071A}.Release|Any CPU.Build.0 = Release|Any CPU + {7A0F5EA5-DB7B-49E0-827D-946C80175322}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {7A0F5EA5-DB7B-49E0-827D-946C80175322}.Debug|Any CPU.Build.0 = Debug|Any CPU + {7A0F5EA5-DB7B-49E0-827D-946C80175322}.Release|Any CPU.ActiveCfg = Release|Any CPU + {7A0F5EA5-DB7B-49E0-827D-946C80175322}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(NestedProjects) = preSolution {FC6F4934-4512-45DB-ABDA-5FAD96742B73} = {78D56637-F921-437D-A9AC-FBEAD78344BE} @@ -76,5 +88,7 @@ Global {8B6E63F3-EB6A-4A72-86B1-A49E53C62305} = {78D56637-F921-437D-A9AC-FBEAD78344BE} {E7D66FE9-65BC-4DC8-AC86-5C5BE10D8E61} = {FF6F43E8-36EA-4BF0-9B2E-8ACC91C5F939} {BDF8C04B-D0E3-4FF5-82C3-E8FDF3916C16} = {AC0DDDB0-385D-43B8-A770-C79EE2077D05} + {40B2D8D1-7523-498D-9753-CECC3A44071A} = {FF6F43E8-36EA-4BF0-9B2E-8ACC91C5F939} + {7A0F5EA5-DB7B-49E0-827D-946C80175322} = {FF6F43E8-36EA-4BF0-9B2E-8ACC91C5F939} EndGlobalSection EndGlobal diff --git a/build/Build.cs b/build/Build.cs index 985e016..c989e02 100644 --- a/build/Build.cs +++ b/build/Build.cs @@ -104,7 +104,7 @@ class Build : NukeBuild { DotNetPack(s => s .SetConfiguration(Configuration) - .SetOutputDirectory(ArtifactsDirectory) + .SetProperty("PublishDir", ArtifactsDirectory) .EnableNoBuild() .EnableNoRestore() .When(IsServerBuild, x => x.SetProperty("ContinuousIntegrationBuild", "true")) diff --git a/tests/NetEscapades.EnumGenerators.IntegrationTests/EnumInNamespaceExtensionsTests.cs b/tests/NetEscapades.EnumGenerators.IntegrationTests/EnumInNamespaceExtensionsTests.cs index cf89b11..e502103 100644 --- a/tests/NetEscapades.EnumGenerators.IntegrationTests/EnumInNamespaceExtensionsTests.cs +++ b/tests/NetEscapades.EnumGenerators.IntegrationTests/EnumInNamespaceExtensionsTests.cs @@ -32,12 +32,12 @@ public class EnumInNamespaceExtensionsTests : ExtensionTests protected override string ToStringFast(EnumInNamespace value) => value.ToStringFast(); protected override bool IsDefined(EnumInNamespace value) => EnumInNamespaceExtensions.IsDefined(value); protected override bool IsDefined(string name, bool allowMatchingMetadataAttribute) => EnumInNamespaceExtensions.IsDefined(name, allowMatchingMetadataAttribute: false); -#if NETCOREAPP && !NETCOREAPP2_0 && !NETCOREAPP1_1 && !NETCOREAPP1_0 +#if READONLYSPAN protected override bool IsDefined(in ReadOnlySpan name, bool allowMatchingMetadataAttribute) => EnumInNamespaceExtensions.IsDefined(name, allowMatchingMetadataAttribute: false); #endif protected override bool TryParse(string name, out EnumInNamespace parsed, bool ignoreCase, bool allowMatchingMetadataAttribute) => EnumInNamespaceExtensions.TryParse(name, out parsed, ignoreCase); -#if NETCOREAPP && !NETCOREAPP2_0 && !NETCOREAPP1_1 && !NETCOREAPP1_0 +#if READONLYSPAN protected override bool TryParse(in ReadOnlySpan name, out EnumInNamespace parsed, bool ignoreCase, bool allowMatchingMetadataAttribute) => EnumInNamespaceExtensions.TryParse(name, out parsed, ignoreCase); #endif @@ -54,7 +54,7 @@ protected override bool TryParse(in ReadOnlySpan name, out EnumInNamespace [MemberData(nameof(ValuesToParse))] public void GeneratesIsDefinedUsingName(string name) => GeneratesIsDefinedTest(name, allowMatchingMetadataAttribute: false); -#if NETCOREAPP && !NETCOREAPP2_0 && !NETCOREAPP1_1 && !NETCOREAPP1_0 +#if READONLYSPAN [Theory] [MemberData(nameof(ValuesToParse))] public void GeneratesIsDefinedUsingNameAsSpan(string name) => GeneratesIsDefinedTest(name.AsSpan(), allowMatchingMetadataAttribute: false); @@ -64,7 +64,7 @@ protected override bool TryParse(in ReadOnlySpan name, out EnumInNamespace [MemberData(nameof(ValuesToParse))] public void GeneratesTryParse(string name) => GeneratesTryParseTest(name, ignoreCase: false, allowMatchingMetadataAttribute: false); -#if NETCOREAPP && !NETCOREAPP2_0 && !NETCOREAPP1_1 && !NETCOREAPP1_0 +#if READONLYSPAN [Theory] [MemberData(nameof(ValuesToParse))] public void GeneratesTryParseUsingSpan(string name) => GeneratesTryParseTest(name.AsSpan(), ignoreCase: false, allowMatchingMetadataAttribute: false); diff --git a/tests/NetEscapades.EnumGenerators.IntegrationTests/EnumWithDescriptionInNamespaceExtensionsTests.cs b/tests/NetEscapades.EnumGenerators.IntegrationTests/EnumWithDescriptionInNamespaceExtensionsTests.cs index e070621..1b40336 100644 --- a/tests/NetEscapades.EnumGenerators.IntegrationTests/EnumWithDescriptionInNamespaceExtensionsTests.cs +++ b/tests/NetEscapades.EnumGenerators.IntegrationTests/EnumWithDescriptionInNamespaceExtensionsTests.cs @@ -32,12 +32,12 @@ public class EnumWithDescriptionInNamespaceExtensionsTests : ExtensionTests value.ToStringFast(); protected override bool IsDefined(EnumWithDescriptionInNamespace value) => EnumWithDescriptionInNamespaceExtensions.IsDefined(value); protected override bool IsDefined(string name, bool allowMatchingMetadataAttribute) => EnumWithDescriptionInNamespaceExtensions.IsDefined(name, allowMatchingMetadataAttribute); -#if NETCOREAPP && !NETCOREAPP2_0 && !NETCOREAPP1_1 && !NETCOREAPP1_0 +#if READONLYSPAN protected override bool IsDefined(in ReadOnlySpan name, bool allowMatchingMetadataAttribute = false) => EnumWithDescriptionInNamespaceExtensions.IsDefined(name, allowMatchingMetadataAttribute); #endif protected override bool TryParse(string name, out EnumWithDescriptionInNamespace parsed, bool ignoreCase, bool allowMatchingMetadataAttribute) => EnumWithDescriptionInNamespaceExtensions.TryParse(name, out parsed, ignoreCase, allowMatchingMetadataAttribute); -#if NETCOREAPP && !NETCOREAPP2_0 && !NETCOREAPP1_1 && !NETCOREAPP1_0 +#if READONLYSPAN protected override bool TryParse(in ReadOnlySpan name, out EnumWithDescriptionInNamespace parsed, bool ignoreCase, bool allowMatchingMetadataAttribute) => EnumWithDescriptionInNamespaceExtensions.TryParse(name, out parsed, ignoreCase, allowMatchingMetadataAttribute); #endif @@ -54,7 +54,7 @@ protected override bool TryParse(in ReadOnlySpan name, out EnumWithDescrip [MemberData(nameof(ValuesToParse))] public void GeneratesIsDefinedUsingName(string name) => GeneratesIsDefinedTest(name, allowMatchingMetadataAttribute: false); -#if NETCOREAPP && !NETCOREAPP2_0 && !NETCOREAPP1_1 && !NETCOREAPP1_0 +#if READONLYSPAN [Theory] [MemberData(nameof(ValuesToParse))] public void GeneratesIsDefinedUsingNameAsSpan(string name) => GeneratesIsDefinedTest(name.AsSpan(), allowMatchingMetadataAttribute: false); @@ -64,7 +64,7 @@ protected override bool TryParse(in ReadOnlySpan name, out EnumWithDescrip [MemberData(nameof(ValuesToParse))] public void GeneratesIsDefinedUsingNameallowMatchingMetadataAttribute(string name) => GeneratesIsDefinedTest(name, allowMatchingMetadataAttribute: true); -#if NETCOREAPP && !NETCOREAPP2_0 && !NETCOREAPP1_1 && !NETCOREAPP1_0 +#if READONLYSPAN [Theory] [MemberData(nameof(ValuesToParse))] public void GeneratesIsDefinedUsingNameallowMatchingMetadataAttributeAsSpan(string name) => GeneratesIsDefinedTest(name.AsSpan(), allowMatchingMetadataAttribute: true); @@ -74,7 +74,7 @@ protected override bool TryParse(in ReadOnlySpan name, out EnumWithDescrip [MemberData(nameof(ValuesToParse))] public void GeneratesTryParse(string name) => GeneratesTryParseTest(name, ignoreCase: false, allowMatchingMetadataAttribute: false); -#if NETCOREAPP && !NETCOREAPP2_0 && !NETCOREAPP1_1 && !NETCOREAPP1_0 +#if READONLYSPAN [Theory] [MemberData(nameof(ValuesToParse))] public void GeneratesTryParseAsSpan(string name) => GeneratesTryParseTest(name.AsSpan(), ignoreCase: false, allowMatchingMetadataAttribute: false); @@ -84,7 +84,7 @@ protected override bool TryParse(in ReadOnlySpan name, out EnumWithDescrip [MemberData(nameof(ValuesToParse))] public void GeneratesTryParseallowMatchingMetadataAttribute(string name) => GeneratesTryParseTest(name, ignoreCase: false, allowMatchingMetadataAttribute: true); -#if NETCOREAPP && !NETCOREAPP2_0 && !NETCOREAPP1_1 && !NETCOREAPP1_0 +#if READONLYSPAN [Theory] [MemberData(nameof(ValuesToParse))] public void GeneratesTryParseallowMatchingMetadataAttributeAsSpan(string name) => GeneratesTryParseTest(name.AsSpan(), ignoreCase: false, allowMatchingMetadataAttribute: true); @@ -94,7 +94,7 @@ protected override bool TryParse(in ReadOnlySpan name, out EnumWithDescrip [MemberData(nameof(ValuesToParse))] public void GeneratesTryParseIgnoreCase(string name) => GeneratesTryParseTest(name, ignoreCase: true, allowMatchingMetadataAttribute: false); -#if NETCOREAPP +#if READONLYSPAN [Theory] [MemberData(nameof(ValuesToParse))] public void GeneratesTryParseIgnoreCaseAsSpan(string name) => GeneratesTryParseTest(name.AsSpan(), ignoreCase: true, allowMatchingMetadataAttribute: false); @@ -104,7 +104,7 @@ protected override bool TryParse(in ReadOnlySpan name, out EnumWithDescrip [MemberData(nameof(ValuesToParse))] public void GeneratesTryParseIgnoreCaseallowMatchingMetadataAttribute(string name) => GeneratesTryParseTest(name, ignoreCase: true, allowMatchingMetadataAttribute: true); -#if NETCOREAPP && !NETCOREAPP2_0 && !NETCOREAPP1_1 && !NETCOREAPP1_0 +#if READONLYSPAN [Theory] [MemberData(nameof(ValuesToParse))] public void GeneratesTryParseIgnoreCaseallowMatchingMetadataAttributeAsSpan(string name) => GeneratesTryParseTest(name.AsSpan(), ignoreCase: true, allowMatchingMetadataAttribute: true); diff --git a/tests/NetEscapades.EnumGenerators.IntegrationTests/EnumWithDisplayNameInNamespaceExtensionsTests.cs b/tests/NetEscapades.EnumGenerators.IntegrationTests/EnumWithDisplayNameInNamespaceExtensionsTests.cs index 8c31945..11ab8e4 100644 --- a/tests/NetEscapades.EnumGenerators.IntegrationTests/EnumWithDisplayNameInNamespaceExtensionsTests.cs +++ b/tests/NetEscapades.EnumGenerators.IntegrationTests/EnumWithDisplayNameInNamespaceExtensionsTests.cs @@ -32,12 +32,12 @@ public class EnumWithDisplayNameInNamespaceExtensionsTests : ExtensionTests value.ToStringFast(); protected override bool IsDefined(EnumWithDisplayNameInNamespace value) => EnumWithDisplayNameInNamespaceExtensions.IsDefined(value); protected override bool IsDefined(string name, bool allowMatchingMetadataAttribute) => EnumWithDisplayNameInNamespaceExtensions.IsDefined(name, allowMatchingMetadataAttribute); -#if NETCOREAPP && !NETCOREAPP2_0 && !NETCOREAPP1_1 && !NETCOREAPP1_0 +#if READONLYSPAN protected override bool IsDefined(in ReadOnlySpan name, bool allowMatchingMetadataAttribute = false) => EnumWithDisplayNameInNamespaceExtensions.IsDefined(name, allowMatchingMetadataAttribute); #endif protected override bool TryParse(string name, out EnumWithDisplayNameInNamespace parsed, bool ignoreCase, bool allowMatchingMetadataAttribute) => EnumWithDisplayNameInNamespaceExtensions.TryParse(name, out parsed, ignoreCase, allowMatchingMetadataAttribute); -#if NETCOREAPP && !NETCOREAPP2_0 && !NETCOREAPP1_1 && !NETCOREAPP1_0 +#if READONLYSPAN protected override bool TryParse(in ReadOnlySpan name, out EnumWithDisplayNameInNamespace parsed, bool ignoreCase, bool allowMatchingMetadataAttribute) => EnumWithDisplayNameInNamespaceExtensions.TryParse(name, out parsed, ignoreCase, allowMatchingMetadataAttribute); #endif @@ -54,7 +54,7 @@ protected override bool TryParse(in ReadOnlySpan name, out EnumWithDisplay [MemberData(nameof(ValuesToParse))] public void GeneratesIsDefinedUsingName(string name) => GeneratesIsDefinedTest(name, allowMatchingMetadataAttribute: false); -#if NETCOREAPP && !NETCOREAPP2_0 && !NETCOREAPP1_1 && !NETCOREAPP1_0 +#if READONLYSPAN [Theory] [MemberData(nameof(ValuesToParse))] public void GeneratesIsDefinedUsingNameAsSpan(string name) => GeneratesIsDefinedTest(name.AsSpan(), allowMatchingMetadataAttribute: false); @@ -64,7 +64,7 @@ protected override bool TryParse(in ReadOnlySpan name, out EnumWithDisplay [MemberData(nameof(ValuesToParse))] public void GeneratesIsDefinedUsingNameallowMatchingMetadataAttribute(string name) => GeneratesIsDefinedTest(name, allowMatchingMetadataAttribute: true); -#if NETCOREAPP && !NETCOREAPP2_0 && !NETCOREAPP1_1 && !NETCOREAPP1_0 +#if READONLYSPAN [Theory] [MemberData(nameof(ValuesToParse))] public void GeneratesIsDefinedUsingNameallowMatchingMetadataAttributeAsSpan(string name) => GeneratesIsDefinedTest(name.AsSpan(), allowMatchingMetadataAttribute: true); @@ -74,7 +74,7 @@ protected override bool TryParse(in ReadOnlySpan name, out EnumWithDisplay [MemberData(nameof(ValuesToParse))] public void GeneratesTryParse(string name) => GeneratesTryParseTest(name, ignoreCase: false, allowMatchingMetadataAttribute: false); -#if NETCOREAPP && !NETCOREAPP2_0 && !NETCOREAPP1_1 && !NETCOREAPP1_0 +#if READONLYSPAN [Theory] [MemberData(nameof(ValuesToParse))] public void GeneratesTryParseAsSpan(string name) => GeneratesTryParseTest(name.AsSpan(), ignoreCase: false, allowMatchingMetadataAttribute: false); @@ -84,7 +84,7 @@ protected override bool TryParse(in ReadOnlySpan name, out EnumWithDisplay [MemberData(nameof(ValuesToParse))] public void GeneratesTryParseallowMatchingMetadataAttribute(string name) => GeneratesTryParseTest(name, ignoreCase: false, allowMatchingMetadataAttribute: true); -#if NETCOREAPP && !NETCOREAPP2_0 && !NETCOREAPP1_1 && !NETCOREAPP1_0 +#if READONLYSPAN [Theory] [MemberData(nameof(ValuesToParse))] public void GeneratesTryParseallowMatchingMetadataAttributeAsSpan(string name) => GeneratesTryParseTest(name.AsSpan(), ignoreCase: false, allowMatchingMetadataAttribute: true); @@ -94,7 +94,7 @@ protected override bool TryParse(in ReadOnlySpan name, out EnumWithDisplay [MemberData(nameof(ValuesToParse))] public void GeneratesTryParseIgnoreCase(string name) => GeneratesTryParseTest(name, ignoreCase: true, allowMatchingMetadataAttribute: false); -#if NETCOREAPP +#if READONLYSPAN [Theory] [MemberData(nameof(ValuesToParse))] public void GeneratesTryParseIgnoreCaseAsSpan(string name) => GeneratesTryParseTest(name.AsSpan(), ignoreCase: true, allowMatchingMetadataAttribute: false); @@ -104,7 +104,7 @@ protected override bool TryParse(in ReadOnlySpan name, out EnumWithDisplay [MemberData(nameof(ValuesToParse))] public void GeneratesTryParseIgnoreCaseallowMatchingMetadataAttribute(string name) => GeneratesTryParseTest(name, ignoreCase: true, allowMatchingMetadataAttribute: true); -#if NETCOREAPP && !NETCOREAPP2_0 && !NETCOREAPP1_1 && !NETCOREAPP1_0 +#if READONLYSPAN [Theory] [MemberData(nameof(ValuesToParse))] public void GeneratesTryParseIgnoreCaseallowMatchingMetadataAttributeAsSpan(string name) => GeneratesTryParseTest(name.AsSpan(), ignoreCase: true, allowMatchingMetadataAttribute: true); diff --git a/tests/NetEscapades.EnumGenerators.IntegrationTests/EnumWithSameDisplayNameExtensionsTests.cs b/tests/NetEscapades.EnumGenerators.IntegrationTests/EnumWithSameDisplayNameExtensionsTests.cs index de2bfe4..d24165f 100644 --- a/tests/NetEscapades.EnumGenerators.IntegrationTests/EnumWithSameDisplayNameExtensionsTests.cs +++ b/tests/NetEscapades.EnumGenerators.IntegrationTests/EnumWithSameDisplayNameExtensionsTests.cs @@ -32,12 +32,12 @@ public class EnumWithSameDisplayNameExtensionsTests : ExtensionTests value.ToStringFast(); protected override bool IsDefined(EnumWithSameDisplayName value) => EnumWithSameDisplayNameExtensions.IsDefined(value); protected override bool IsDefined(string name, bool allowMatchingMetadataAttribute) => EnumWithSameDisplayNameExtensions.IsDefined(name, allowMatchingMetadataAttribute); -#if NETCOREAPP && !NETCOREAPP2_0 && !NETCOREAPP1_1 && !NETCOREAPP1_0 +#if READONLYSPAN protected override bool IsDefined(in ReadOnlySpan name, bool allowMatchingMetadataAttribute) => EnumWithSameDisplayNameExtensions.IsDefined(name, allowMatchingMetadataAttribute); #endif protected override bool TryParse(string name, out EnumWithSameDisplayName parsed, bool ignoreCase, bool allowMatchingMetadataAttribute) => EnumWithSameDisplayNameExtensions.TryParse(name, out parsed, ignoreCase, allowMatchingMetadataAttribute); -#if NETCOREAPP && !NETCOREAPP2_0 && !NETCOREAPP1_1 && !NETCOREAPP1_0 +#if READONLYSPAN protected override bool TryParse(in ReadOnlySpan name, out EnumWithSameDisplayName parsed, bool ignoreCase, bool allowMatchingMetadataAttribute) => EnumWithSameDisplayNameExtensions.TryParse(name, out parsed, ignoreCase, allowMatchingMetadataAttribute); #endif @@ -54,7 +54,7 @@ protected override bool TryParse(in ReadOnlySpan name, out EnumWithSameDis [MemberData(nameof(ValuesToParse))] public void GeneratesIsDefinedUsingName(string name) => GeneratesIsDefinedTest(name, allowMatchingMetadataAttribute: false); -#if NETCOREAPP && !NETCOREAPP2_0 && !NETCOREAPP1_1 && !NETCOREAPP1_0 +#if READONLYSPAN [Theory] [MemberData(nameof(ValuesToParse))] public void GeneratesIsDefinedUsingNameAsSpan(string name) => GeneratesIsDefinedTest(name.AsSpan(), allowMatchingMetadataAttribute: false); @@ -64,7 +64,7 @@ protected override bool TryParse(in ReadOnlySpan name, out EnumWithSameDis [MemberData(nameof(ValuesToParse))] public void GeneratesIsDefinedUsingNameallowMatchingMetadataAttribute(string name) => GeneratesIsDefinedTest(name, allowMatchingMetadataAttribute: true); -#if NETCOREAPP && !NETCOREAPP2_0 && !NETCOREAPP1_1 && !NETCOREAPP1_0 +#if READONLYSPAN [Theory] [MemberData(nameof(ValuesToParse))] public void GeneratesIsDefinedUsingNameallowMatchingMetadataAttributeAsSpan(string name) => GeneratesIsDefinedTest(name.AsSpan(), allowMatchingMetadataAttribute: true); @@ -74,7 +74,7 @@ protected override bool TryParse(in ReadOnlySpan name, out EnumWithSameDis [MemberData(nameof(ValuesToParse))] public void GeneratesTryParse(string name) => GeneratesTryParseTest(name, ignoreCase: false, allowMatchingMetadataAttribute: false); -#if NETCOREAPP && !NETCOREAPP2_0 && !NETCOREAPP1_1 && !NETCOREAPP1_0 +#if READONLYSPAN [Theory] [MemberData(nameof(ValuesToParse))] public void GeneratesTryParseAsSpan(string name) => GeneratesTryParseTest(name.AsSpan(), ignoreCase: false, allowMatchingMetadataAttribute: false); @@ -84,7 +84,7 @@ protected override bool TryParse(in ReadOnlySpan name, out EnumWithSameDis [MemberData(nameof(ValuesToParse))] public void GeneratesTryParseallowMatchingMetadataAttribute(string name) => GeneratesTryParseTest(name, ignoreCase: false, allowMatchingMetadataAttribute: true); -#if NETCOREAPP && !NETCOREAPP2_0 && !NETCOREAPP1_1 && !NETCOREAPP1_0 +#if READONLYSPAN [Theory] [MemberData(nameof(ValuesToParse))] public void GeneratesTryParseallowMatchingMetadataAttributeAsSpan(string name) => GeneratesTryParseTest(name.AsSpan(), ignoreCase: false, allowMatchingMetadataAttribute: true); @@ -94,7 +94,7 @@ protected override bool TryParse(in ReadOnlySpan name, out EnumWithSameDis [MemberData(nameof(ValuesToParse))] public void GeneratesTryParseIgnoreCase(string name) => GeneratesTryParseTest(name, ignoreCase: true, allowMatchingMetadataAttribute: false); -#if NETCOREAPP && !NETCOREAPP2_0 && !NETCOREAPP1_1 && !NETCOREAPP1_0 +#if READONLYSPAN [Theory] [MemberData(nameof(ValuesToParse))] public void GeneratesTryParseIgnoreCaseAsSpan(string name) => GeneratesTryParseTest(name.AsSpan(), ignoreCase: true, allowMatchingMetadataAttribute: false); @@ -104,7 +104,7 @@ protected override bool TryParse(in ReadOnlySpan name, out EnumWithSameDis [MemberData(nameof(ValuesToParse))] public void GeneratesTryParseIgnoreCaseallowMatchingMetadataAttribute(string name) => GeneratesTryParseTest(name, ignoreCase: true, allowMatchingMetadataAttribute: true); -#if NETCOREAPP && !NETCOREAPP2_0 && !NETCOREAPP1_1 && !NETCOREAPP1_0 +#if READONLYSPAN [Theory] [MemberData(nameof(ValuesToParse))] public void GeneratesTryParseIgnoreCaseallowMatchingMetadataAttributeAsSpan(string name) => GeneratesTryParseTest(name.AsSpan(), ignoreCase: true, allowMatchingMetadataAttribute: true); diff --git a/tests/NetEscapades.EnumGenerators.IntegrationTests/ExtensionTests.cs b/tests/NetEscapades.EnumGenerators.IntegrationTests/ExtensionTests.cs index 26a1d87..206f7d7 100644 --- a/tests/NetEscapades.EnumGenerators.IntegrationTests/ExtensionTests.cs +++ b/tests/NetEscapades.EnumGenerators.IntegrationTests/ExtensionTests.cs @@ -13,11 +13,11 @@ public abstract class ExtensionTests where T : struct protected abstract string ToStringFast(T value); protected abstract bool IsDefined(T value); protected abstract bool IsDefined(string name, bool allowMatchingMetadataAttribute = false); -#if NETCOREAPP && !NETCOREAPP2_0 && !NETCOREAPP1_1 && !NETCOREAPP1_0 +#if READONLYSPAN protected abstract bool IsDefined(in ReadOnlySpan name, bool allowMatchingMetadataAttribute); #endif protected abstract bool TryParse(string name, out T parsed, bool ignoreCase, bool allowMatchingMetadataAttribute); -#if NETCOREAPP && !NETCOREAPP2_0 && !NETCOREAPP1_1 && !NETCOREAPP1_0 +#if READONLYSPAN protected abstract bool TryParse(in ReadOnlySpan name, out T parsed, bool ignoreCase, bool allowMatchingMetadataAttribute); #endif @@ -46,7 +46,7 @@ protected void GeneratesIsDefinedTest(string name, bool allowMatchingMetadataAtt isDefined.Should().Be(expectedResult); } -#if NETCOREAPP && !NETCOREAPP2_0 && !NETCOREAPP1_1 && !NETCOREAPP1_0 +#if READONLYSPAN protected void GeneratesIsDefinedTest(in ReadOnlySpan name, bool allowMatchingMetadataAttribute) { var isDefined = IsDefined(name, allowMatchingMetadataAttribute); @@ -84,7 +84,7 @@ protected void GeneratesTryParseTest(string name, bool ignoreCase, bool allowMat result.Should().Be(expectedResult); } -#if NETCOREAPP && !NETCOREAPP2_0 && !NETCOREAPP1_1 && !NETCOREAPP1_0 +#if READONLYSPAN protected void GeneratesTryParseTest(in ReadOnlySpan name, bool ignoreCase, bool allowMatchingMetadataAttribute) { var isValid = TryParse(name, out var result, ignoreCase, allowMatchingMetadataAttribute); diff --git a/tests/NetEscapades.EnumGenerators.IntegrationTests/FlagsEnumExtensionsTests.cs b/tests/NetEscapades.EnumGenerators.IntegrationTests/FlagsEnumExtensionsTests.cs index a1b870d..06cd9e3 100644 --- a/tests/NetEscapades.EnumGenerators.IntegrationTests/FlagsEnumExtensionsTests.cs +++ b/tests/NetEscapades.EnumGenerators.IntegrationTests/FlagsEnumExtensionsTests.cs @@ -36,12 +36,12 @@ public class FlagsEnumExtensionsTests : ExtensionTests protected override string ToStringFast(FlagsEnum value) => value.ToStringFast(); protected override bool IsDefined(FlagsEnum value) => FlagsEnumExtensions.IsDefined(value); protected override bool IsDefined(string name, bool allowMatchingMetadataAttribute) => FlagsEnumExtensions.IsDefined(name, allowMatchingMetadataAttribute: false); -#if NETCOREAPP && !NETCOREAPP2_0 && !NETCOREAPP1_1 && !NETCOREAPP1_0 +#if READONLYSPAN protected override bool IsDefined(in ReadOnlySpan name, bool allowMatchingMetadataAttribute) => FlagsEnumExtensions.IsDefined(name, allowMatchingMetadataAttribute: false); #endif protected override bool TryParse(string name, out FlagsEnum parsed, bool ignoreCase, bool allowMatchingMetadataAttribute) => FlagsEnumExtensions.TryParse(name, out parsed, ignoreCase); -#if NETCOREAPP && !NETCOREAPP2_0 && !NETCOREAPP1_1 && !NETCOREAPP1_0 +#if READONLYSPAN protected override bool TryParse(in ReadOnlySpan name, out FlagsEnum parsed, bool ignoreCase, bool allowMatchingMetadataAttribute) => FlagsEnumExtensions.TryParse(name, out parsed, ignoreCase); #endif @@ -64,7 +64,7 @@ protected override bool TryParse(in ReadOnlySpan name, out FlagsEnum parse [MemberData(nameof(ValuesToParse))] public void GeneratesIsDefinedUsingName(string name) => GeneratesIsDefinedTest(name, allowMatchingMetadataAttribute: false); -#if NETCOREAPP && !NETCOREAPP2_0 && !NETCOREAPP1_1 && !NETCOREAPP1_0 +#if READONLYSPAN [Theory] [MemberData(nameof(ValuesToParse))] public void GeneratesIsDefinedUsingNameAsSpan(string name) => GeneratesIsDefinedTest(name.AsSpan(), allowMatchingMetadataAttribute: false); @@ -101,7 +101,7 @@ public void HasFlags(FlagsEnum value, FlagsEnum flag) [MemberData(nameof(ValuesToParse))] public void GeneratesTryParse(string name) => GeneratesTryParseTest(name, ignoreCase: false, allowMatchingMetadataAttribute: false); -#if NETCOREAPP && !NETCOREAPP2_0 && !NETCOREAPP1_1 && !NETCOREAPP1_0 +#if READONLYSPAN [Theory] [MemberData(nameof(ValuesToParse))] public void GeneratesTryParseAsSpan(string name) => GeneratesTryParseTest(name.AsSpan(), ignoreCase: false, allowMatchingMetadataAttribute: false); @@ -111,7 +111,7 @@ public void HasFlags(FlagsEnum value, FlagsEnum flag) [MemberData(nameof(ValuesToParse))] public void GeneratesTryParseIgnoreCase(string name) => GeneratesTryParseTest(name, ignoreCase: true, allowMatchingMetadataAttribute: false); -#if NETCOREAPP && !NETCOREAPP2_0 && !NETCOREAPP1_1 && !NETCOREAPP1_0 +#if READONLYSPAN [Theory] [MemberData(nameof(ValuesToParse))] public void GeneratesTryParseIgnoreCaseAsSpan(string name) => GeneratesTryParseTest(name.AsSpan(), ignoreCase: true, allowMatchingMetadataAttribute: false); diff --git a/tests/NetEscapades.EnumGenerators.IntegrationTests/LongEnumExtensionsTests.cs b/tests/NetEscapades.EnumGenerators.IntegrationTests/LongEnumExtensionsTests.cs index b29c086..7934051 100644 --- a/tests/NetEscapades.EnumGenerators.IntegrationTests/LongEnumExtensionsTests.cs +++ b/tests/NetEscapades.EnumGenerators.IntegrationTests/LongEnumExtensionsTests.cs @@ -32,12 +32,12 @@ public class LongEnumExtensionsTests : ExtensionTests protected override string ToStringFast(LongEnum value) => value.ToStringFast(); protected override bool IsDefined(LongEnum value) => LongEnumExtensions.IsDefined(value); protected override bool IsDefined(string name, bool allowMatchingMetadataAttribute) => LongEnumExtensions.IsDefined(name, allowMatchingMetadataAttribute: false); -#if NETCOREAPP && !NETCOREAPP2_0 && !NETCOREAPP1_1 && !NETCOREAPP1_0 +#if READONLYSPAN protected override bool IsDefined(in ReadOnlySpan name, bool allowMatchingMetadataAttribute) => LongEnumExtensions.IsDefined(name, allowMatchingMetadataAttribute: false); #endif protected override bool TryParse(string name, out LongEnum parsed, bool ignoreCase, bool allowMatchingMetadataAttribute) => LongEnumExtensions.TryParse(name, out parsed, ignoreCase); -#if NETCOREAPP && !NETCOREAPP2_0 && !NETCOREAPP1_1 && !NETCOREAPP1_0 +#if READONLYSPAN protected override bool TryParse(in ReadOnlySpan name, out LongEnum parsed, bool ignoreCase, bool allowMatchingMetadataAttribute) => LongEnumExtensions.TryParse(name, out parsed, ignoreCase); #endif @@ -54,7 +54,7 @@ protected override bool TryParse(in ReadOnlySpan name, out LongEnum parsed [MemberData(nameof(ValuesToParse))] public void GeneratesIsDefinedUsingName(string name) => GeneratesIsDefinedTest(name, allowMatchingMetadataAttribute: false); -#if NETCOREAPP && !NETCOREAPP2_0 && !NETCOREAPP1_1 && !NETCOREAPP1_0 +#if READONLYSPAN [Theory] [MemberData(nameof(ValuesToParse))] public void GeneratesIsDefinedUsingNameAsSpan(string name) => GeneratesIsDefinedTest(name.AsSpan(), allowMatchingMetadataAttribute: false); @@ -64,7 +64,7 @@ protected override bool TryParse(in ReadOnlySpan name, out LongEnum parsed [MemberData(nameof(ValuesToParse))] public void GeneratesTryParse(string name) => GeneratesTryParseTest(name, ignoreCase:false, allowMatchingMetadataAttribute: false); -#if NETCOREAPP && !NETCOREAPP2_0 && !NETCOREAPP1_1 && !NETCOREAPP1_0 +#if READONLYSPAN [Theory] [MemberData(nameof(ValuesToParse))] public void GeneratesTryParseAsSpan(string name) => GeneratesTryParseTest(name.AsSpan(), ignoreCase: false, allowMatchingMetadataAttribute: false); @@ -74,7 +74,7 @@ protected override bool TryParse(in ReadOnlySpan name, out LongEnum parsed [MemberData(nameof(ValuesToParse))] public void GeneratesTryParseIgnoreCase(string name) => GeneratesTryParseTest(name, ignoreCase: true, allowMatchingMetadataAttribute: false); -#if NETCOREAPP && !NETCOREAPP2_0 && !NETCOREAPP1_1 && !NETCOREAPP1_0 +#if READONLYSPAN [Theory] [MemberData(nameof(ValuesToParse))] public void GeneratesTryParseIgnoreCaseAsAspan(string name) => GeneratesTryParseTest(name.AsSpan(), ignoreCase: true, allowMatchingMetadataAttribute: false); diff --git a/tests/NetEscapades.EnumGenerators.IntegrationTests/NetEscapades.EnumGenerators.IntegrationTests.csproj b/tests/NetEscapades.EnumGenerators.IntegrationTests/NetEscapades.EnumGenerators.IntegrationTests.csproj index 973e466..e5777b0 100644 --- a/tests/NetEscapades.EnumGenerators.IntegrationTests/NetEscapades.EnumGenerators.IntegrationTests.csproj +++ b/tests/NetEscapades.EnumGenerators.IntegrationTests/NetEscapades.EnumGenerators.IntegrationTests.csproj @@ -4,6 +4,7 @@ netcoreapp2.1;netcoreapp3.1;net5.0;net6.0;net7.0 net48;$(TargetFrameworks) false + $(DefineConstants);READONLYSPAN diff --git a/tests/NetEscapades.EnumGenerators.NetStandard.IntegrationTests/NetEscapades.EnumGenerators.NetStandard.IntegrationTests.csproj b/tests/NetEscapades.EnumGenerators.NetStandard.IntegrationTests/NetEscapades.EnumGenerators.NetStandard.IntegrationTests.csproj new file mode 100644 index 0000000..61df05b --- /dev/null +++ b/tests/NetEscapades.EnumGenerators.NetStandard.IntegrationTests/NetEscapades.EnumGenerators.NetStandard.IntegrationTests.csproj @@ -0,0 +1,38 @@ + + + + netcoreapp2.1;netcoreapp3.1;net5.0;net6.0;net7.0 + net48;$(TargetFrameworks) + false + enable + + + + + + + + + + + + + + + + + + + + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + + diff --git a/tests/NetEscapades.EnumGenerators.NetStandard/NetEscapades.EnumGenerators.NetStandard.csproj b/tests/NetEscapades.EnumGenerators.NetStandard/NetEscapades.EnumGenerators.NetStandard.csproj new file mode 100644 index 0000000..d73e493 --- /dev/null +++ b/tests/NetEscapades.EnumGenerators.NetStandard/NetEscapades.EnumGenerators.NetStandard.csproj @@ -0,0 +1,21 @@ + + + + netstandard2.0 + false + enable + + + + + + + + + + + + + + + diff --git a/tests/NetEscapades.EnumGenerators.Nuget.Attributes.IntegrationTests/NetEscapades.EnumGenerators.Nuget.Attributes.IntegrationTests.csproj b/tests/NetEscapades.EnumGenerators.Nuget.Attributes.IntegrationTests/NetEscapades.EnumGenerators.Nuget.Attributes.IntegrationTests.csproj index 9d45f03..b742abf 100644 --- a/tests/NetEscapades.EnumGenerators.Nuget.Attributes.IntegrationTests/NetEscapades.EnumGenerators.Nuget.Attributes.IntegrationTests.csproj +++ b/tests/NetEscapades.EnumGenerators.Nuget.Attributes.IntegrationTests/NetEscapades.EnumGenerators.Nuget.Attributes.IntegrationTests.csproj @@ -5,7 +5,8 @@ net48;$(TargetFrameworks) false enable - NETESCAPADES_ENUMGENERATORS_EMBED_ATTRIBUTES + $(DefineConstants);NETESCAPADES_ENUMGENERATORS_EMBED_ATTRIBUTES + $(DefineConstants);READONLYSPAN diff --git a/tests/NetEscapades.EnumGenerators.Nuget.IntegrationTests/NetEscapades.EnumGenerators.Nuget.IntegrationTests.csproj b/tests/NetEscapades.EnumGenerators.Nuget.IntegrationTests/NetEscapades.EnumGenerators.Nuget.IntegrationTests.csproj index ec01b3c..cc7a6ec 100644 --- a/tests/NetEscapades.EnumGenerators.Nuget.IntegrationTests/NetEscapades.EnumGenerators.Nuget.IntegrationTests.csproj +++ b/tests/NetEscapades.EnumGenerators.Nuget.IntegrationTests/NetEscapades.EnumGenerators.Nuget.IntegrationTests.csproj @@ -5,6 +5,7 @@ net48;$(TargetFrameworks) false enable + $(DefineConstants);READONLYSPAN