Skip to content

Commit b3b95a7

Browse files
authored
Releases/1.5.0 (#7)
* Removing AppVeyor badges from README * Adding .NET Standard 2.0 target / Updating to v1.5 * Moving Type extensions from ReadableExpressions * Updating packages / Adding .NET 5 test project * Adding v1.5 NuGet package
1 parent c7e7c86 commit b3b95a7

20 files changed

+323
-130
lines changed

Directory.Build.props

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,17 @@
44
<Company>AgileObjects Ltd</Company>
55
<Product>AgileObjects.NetStandardPolyfills</Product>
66
<Authors>Steve Wilkes</Authors>
7-
<Copyright>Copyright © AgileObjects Ltd 2020</Copyright>
7+
<Copyright>Copyright © AgileObjects Ltd 2021</Copyright>
88
<NeutralResourcesLanguage>en</NeutralResourcesLanguage>
99
<AssemblyOriginatorKeyFile>..\NetStandardPolyfills.snk</AssemblyOriginatorKeyFile>
1010
<SignAssembly>true</SignAssembly>
1111
<PublicSign Condition=" '$(OS)' != 'Windows_NT' ">true</PublicSign>
1212
<RepositoryType>git</RepositoryType>
1313
<RepositoryUrl>https://github.com/AgileObjects/NetStandardPolyfills</RepositoryUrl>
14-
<Version>1.4.1</Version>
15-
<VersionPrefix>1.4.1</VersionPrefix>
16-
<AssemblyVersion>1.4.1.0</AssemblyVersion>
17-
<FileVersion>1.4.1.0</FileVersion>
14+
<Version>1.5.0</Version>
15+
<VersionPrefix>1.5.0</VersionPrefix>
16+
<AssemblyVersion>1.5.0.0</AssemblyVersion>
17+
<FileVersion>1.5.0.0</FileVersion>
1818
</PropertyGroup>
1919

2020
</Project>

NetStandardPolyfills.UnitTests.Net35/NetStandardPolyfills.UnitTests.Net35.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@
3636
<ItemGroup>
3737
<Reference Include="System" />
3838
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.9.0" />
39-
<PackageReference Include="NUnit" Version="3.12.0" />
40-
<PackageReference Include="NUnit3TestAdapter" Version="3.16.1">
39+
<PackageReference Include="NUnit" Version="3.13.1" />
40+
<PackageReference Include="NUnit3TestAdapter" Version="3.17.0">
4141
<PrivateAssets>all</PrivateAssets>
4242
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
4343
</PackageReference>

NetStandardPolyfills.UnitTests.Net40/NetStandardPolyfills.UnitTests.Net40.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424
</PropertyGroup>
2525

2626
<ItemGroup>
27-
<PackageReference Include="NUnit" Version="3.12.0" />
28-
<PackageReference Include="NUnit3TestAdapter" Version="3.16.1">
27+
<PackageReference Include="NUnit" Version="3.13.1" />
28+
<PackageReference Include="NUnit3TestAdapter" Version="3.17.0">
2929
<PrivateAssets>all</PrivateAssets>
3030
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
3131
</PackageReference>

NetStandardPolyfills.UnitTests.Net40/WhenCheckingTypeData.cs

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
namespace AgileObjects.NetStandardPolyfills.UnitTests
22
{
3+
using System;
34
using System.Collections;
45
using System.Collections.Generic;
6+
using System.Collections.ObjectModel;
57
using System.Linq;
68
using TestClasses;
79
#if FEATURE_XUNIT
@@ -155,5 +157,107 @@ public void ShouldDetermineThatATypeIsNotAClosedType()
155157
{
156158
typeof(List<string>).IsClosedTypeOf(typeof(IEnumerable<>)).ShouldBeFalse();
157159
}
160+
161+
[Fact]
162+
public void ShouldDetermineAClassCanBeNull()
163+
{
164+
typeof(object).CanBeNull().ShouldBeTrue();
165+
}
166+
167+
[Fact]
168+
public void ShouldDetermineAnInterfaceCanBeNull()
169+
{
170+
typeof(IDisposable).CanBeNull().ShouldBeTrue();
171+
}
172+
173+
[Fact]
174+
public void ShouldDetermineANullableIntCanBeNull()
175+
{
176+
typeof(int?).CanBeNull().ShouldBeTrue();
177+
}
178+
179+
[Fact]
180+
public void ShouldDetermineAStringCanBeNull()
181+
{
182+
typeof(string).CanBeNull().ShouldBeTrue();
183+
}
184+
185+
[Fact]
186+
public void ShouldDetermineADateTimeCannotBeNull()
187+
{
188+
typeof(DateTime).CanBeNull().ShouldBeFalse();
189+
}
190+
191+
[Fact]
192+
public void ShouldDetermineANullableLongIsNullable()
193+
{
194+
typeof(long?).IsNullableType().ShouldBeTrue();
195+
}
196+
197+
[Fact]
198+
public void ShouldDetermineALongIsNotNullable()
199+
{
200+
typeof(long).IsNullableType().ShouldBeFalse();
201+
}
202+
203+
[Fact]
204+
public void ShouldGetAShortFromANullablehort()
205+
{
206+
typeof(short?).GetNonNullableType().ShouldBe(typeof(short));
207+
}
208+
209+
[Fact]
210+
public void ShouldGetATimeSpanFromATimeSpan()
211+
{
212+
typeof(TimeSpan).GetNonNullableType().ShouldBe(typeof(TimeSpan));
213+
}
214+
215+
[Fact]
216+
public void ShouldDetermineAGenericListIsEnumerable()
217+
{
218+
typeof(List<string>).IsEnumerable().ShouldBeTrue();
219+
}
220+
221+
[Fact]
222+
public void ShouldDetermineAnIntArrayIsEnumerable()
223+
{
224+
typeof(int[]).IsEnumerable().ShouldBeTrue();
225+
}
226+
227+
[Fact]
228+
public void ShouldDetermineAGenericIEnumerableIsEnumerable()
229+
{
230+
typeof(IEnumerable<object>).IsEnumerable().ShouldBeTrue();
231+
}
232+
233+
[Fact]
234+
public void ShouldDetermineAnICollectionIsEnumerable()
235+
{
236+
typeof(ICollection).IsEnumerable().ShouldBeTrue();
237+
}
238+
239+
[Fact]
240+
public void ShouldDetermineACollectionIsEnumerable()
241+
{
242+
typeof(Collection<string>).IsEnumerable().ShouldBeTrue();
243+
}
244+
245+
[Fact]
246+
public void ShouldDetermineADictionaryIsEnumerable()
247+
{
248+
typeof(Dictionary<string, object>).IsEnumerable().ShouldBeTrue();
249+
}
250+
251+
[Fact]
252+
public void ShouldDetermineAStringIsNotEnumerable()
253+
{
254+
typeof(string).IsEnumerable().ShouldBeFalse();
255+
}
256+
257+
[Fact]
258+
public void ShouldDetermineAnObjectIsNotEnumerable()
259+
{
260+
typeof(object).IsEnumerable().ShouldBeFalse();
261+
}
158262
}
159263
}

NetStandardPolyfills.UnitTests.NetCore2/NetStandardPolyfills.UnitTests.NetCore2.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@
3232
</ItemGroup>
3333

3434
<ItemGroup>
35-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.9.0" />
35+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.4" />
3636
<PackageReference Include="System.Data.Common" Version="4.3.0" />
3737
<PackageReference Include="xunit" Version="2.4.1" />
38-
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1">
38+
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
3939
<PrivateAssets>all</PrivateAssets>
4040
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
4141
</PackageReference>

NetStandardPolyfills.UnitTests.NetCore3/NetStandardPolyfills.UnitTests.NetCore3.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@
3232
</ItemGroup>
3333

3434
<ItemGroup>
35-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.5.0" />
35+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.4" />
3636
<PackageReference Include="System.Data.Common" Version="4.3.0" />
3737
<PackageReference Include="xunit" Version="2.4.1" />
38-
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1">
38+
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
3939
<PrivateAssets>all</PrivateAssets>
4040
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
4141
</PackageReference>
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFramework>net5.0</TargetFramework>
5+
<LangVersion>8.0</LangVersion>
6+
<RootNamespace>AgileObjects.NetStandardPolyfills.UnitTests</RootNamespace>
7+
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
8+
<WarningsAsErrors></WarningsAsErrors>
9+
<NoWarn>0649;1701;1702</NoWarn>
10+
<DebugType>full</DebugType>
11+
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
12+
<IsPackable>false</IsPackable>
13+
</PropertyGroup>
14+
15+
<PropertyGroup>
16+
<DefineConstants>$(DefineConstants);TRACE;FEATURE_XUNIT</DefineConstants>
17+
</PropertyGroup>
18+
19+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
20+
<DefineConstants>$(DefineConstants);DEBUG</DefineConstants>
21+
</PropertyGroup>
22+
23+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
24+
<DefineConstants>$(DefineConstants);RELEASE</DefineConstants>
25+
</PropertyGroup>
26+
27+
<ItemGroup>
28+
<Compile Include="..\NetStandardPolyfills.UnitTests.Net40\**\*.cs" Exclude="..\NetStandardPolyfills.UnitTests.Net40\obj\**\*.cs;">
29+
<Link>%(RecursiveDir)%(Filename)%(Extension)</Link>
30+
</Compile>
31+
</ItemGroup>
32+
33+
<ItemGroup>
34+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.4" />
35+
<PackageReference Include="System.Data.Common" Version="4.3.0" />
36+
<PackageReference Include="xunit" Version="2.4.1" />
37+
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
38+
<PrivateAssets>all</PrivateAssets>
39+
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
40+
</PackageReference>
41+
</ItemGroup>
42+
43+
<ItemGroup>
44+
<ProjectReference Include="..\NetStandardPolyfills\NetStandardPolyfills.csproj" />
45+
</ItemGroup>
46+
47+
<ItemGroup>
48+
<Service Include="{82a7f48d-3b50-4b1e-b82e-3ada8210c358}" />
49+
</ItemGroup>
50+
51+
</Project>

NetStandardPolyfills.sln

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,14 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NetStandardPolyfills.UnitTe
1717
EndProject
1818
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NetStandardPolyfills.UnitTests.NetCore2", "NetStandardPolyfills.UnitTests.NetCore2\NetStandardPolyfills.UnitTests.NetCore2.csproj", "{C6870A19-A0E3-40C3-904B-D871CC71CD21}"
1919
EndProject
20-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NetStandardPolyfills.UnitTests.Net35", "NetStandardPolyfills.UnitTests.Net35\NetStandardPolyfills.UnitTests.Net35.csproj", "{378EE300-C36E-4C4C-8D15-04041CD07451}"
20+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NetStandardPolyfills.UnitTests.Net35", "NetStandardPolyfills.UnitTests.Net35\NetStandardPolyfills.UnitTests.Net35.csproj", "{378EE300-C36E-4C4C-8D15-04041CD07451}"
2121
EndProject
2222
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NetStandardPolyfills.UnitTests.Net40", "NetStandardPolyfills.UnitTests.Net40\NetStandardPolyfills.UnitTests.Net40.csproj", "{72B288A2-46C5-47F4-9AF4-6BB63FA90374}"
2323
EndProject
2424
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NetStandardPolyfills.UnitTests.NetCore3", "NetStandardPolyfills.UnitTests.NetCore3\NetStandardPolyfills.UnitTests.NetCore3.csproj", "{362B2A1B-429F-40B6-B97D-08B05558EE49}"
2525
EndProject
26+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NetStandardPolyfills.UnitTests.NetCore5", "NetStandardPolyfills.UnitTests.NetCore5\NetStandardPolyfills.UnitTests.NetCore5.csproj", "{7A4DE738-191C-4866-87A8-8312C4AD9494}"
27+
EndProject
2628
Global
2729
GlobalSection(SolutionConfigurationPlatforms) = preSolution
2830
Debug|Any CPU = Debug|Any CPU
@@ -53,6 +55,10 @@ Global
5355
{362B2A1B-429F-40B6-B97D-08B05558EE49}.Debug|Any CPU.Build.0 = Debug|Any CPU
5456
{362B2A1B-429F-40B6-B97D-08B05558EE49}.Release|Any CPU.ActiveCfg = Release|Any CPU
5557
{362B2A1B-429F-40B6-B97D-08B05558EE49}.Release|Any CPU.Build.0 = Release|Any CPU
58+
{7A4DE738-191C-4866-87A8-8312C4AD9494}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
59+
{7A4DE738-191C-4866-87A8-8312C4AD9494}.Debug|Any CPU.Build.0 = Debug|Any CPU
60+
{7A4DE738-191C-4866-87A8-8312C4AD9494}.Release|Any CPU.ActiveCfg = Release|Any CPU
61+
{7A4DE738-191C-4866-87A8-8312C4AD9494}.Release|Any CPU.Build.0 = Release|Any CPU
5662
EndGlobalSection
5763
GlobalSection(SolutionProperties) = preSolution
5864
HideSolutionNode = FALSE

NetStandardPolyfills/AssemblyExtensionsPolyfill.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
1-

2-
namespace AgileObjects.NetStandardPolyfills
1+
namespace AgileObjects.NetStandardPolyfills
32
{
43
using System;
5-
#if NET_STANDARD
4+
#if NETSTANDARD1_0
65
using System.Linq;
76
#endif
87
using System.Reflection;
8+
#if NETSTANDARD1_0
99
using Extensions;
10+
#endif
1011

1112
/// <summary>
1213
/// Provides a set of static methods for obtaining Assembly information in .NET Standard 1.0.
@@ -22,7 +23,7 @@ public static class AssemblyExtensionsPolyfill
2223
/// </returns>
2324
public static Type[] GetAllTypes(this Assembly assembly)
2425
{
25-
#if NET_STANDARD
26+
#if NETSTANDARD1_0
2627
return assembly.DefinedTypes.Project(ti => ti.AsType()).ToArray();
2728
#else
2829
return assembly.GetTypes();

NetStandardPolyfills/ConstructorExtensionsPolyfill.cs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@
22
{
33
using System;
44
using System.Collections.Generic;
5-
#if NET_STANDARD
5+
#if NETSTANDARD1_0
66
using System.Linq;
77
#endif
88
using System.Reflection;
9+
#if NETSTANDARD1_0
910
using Extensions;
11+
#endif
1012

1113
/// <summary>
1214
/// Provides a set of static methods methods for obtaining constructor information in .NET Standard 1.0 and .NET 4.0.
@@ -20,7 +22,7 @@ public static class ConstructorExtensionsPolyfill
2022
/// <returns>The given <paramref name="type"/>'s public, instance-scoped constructors.</returns>
2123
public static IEnumerable<ConstructorInfo> GetPublicInstanceConstructors(this Type type)
2224
{
23-
#if NET_STANDARD
25+
#if NETSTANDARD1_0
2426
return GetConstructors(type, isPublic: true, isStatic: false);
2527
#else
2628
return type.GetConstructors(BindingFlags.Public | BindingFlags.Instance);
@@ -41,7 +43,7 @@ public static IEnumerable<ConstructorInfo> GetPublicInstanceConstructors(this Ty
4143
/// </returns>
4244
public static ConstructorInfo GetPublicInstanceConstructor(this Type type, params Type[] parameterTypes)
4345
{
44-
#if NET_STANDARD
46+
#if NETSTANDARD1_0
4547
return type
4648
.GetPublicInstanceConstructors()
4749
.GetConstructorWithTypes(parameterTypes);
@@ -57,7 +59,7 @@ public static ConstructorInfo GetPublicInstanceConstructor(this Type type, param
5759
/// <returns>The given <paramref name="type"/>'s non-public, instance-scoped constructors.</returns>
5860
public static IEnumerable<ConstructorInfo> GetNonPublicInstanceConstructors(this Type type)
5961
{
60-
#if NET_STANDARD
62+
#if NETSTANDARD1_0
6163
return GetConstructors(type, isPublic: false, isStatic: false);
6264
#else
6365
return type.GetConstructors(BindingFlags.NonPublic | BindingFlags.Instance);
@@ -78,7 +80,7 @@ public static IEnumerable<ConstructorInfo> GetNonPublicInstanceConstructors(this
7880
/// </returns>
7981
public static ConstructorInfo GetNonPublicInstanceConstructor(this Type type, params Type[] parameterTypes)
8082
{
81-
#if NET_STANDARD
83+
#if NETSTANDARD1_0
8284
return type
8385
.GetNonPublicInstanceConstructors()
8486
.GetConstructorWithTypes(parameterTypes);
@@ -91,7 +93,7 @@ public static ConstructorInfo GetNonPublicInstanceConstructor(this Type type, pa
9193
#endif
9294
}
9395

94-
#if NET_STANDARD
96+
#if NETSTANDARD1_0
9597
internal static IEnumerable<ConstructorInfo> GetConstructors(this Type type, bool isPublic, bool isStatic)
9698
=> type.GetTypeInfo().DeclaredConstructors.Filter(c => (c.IsPublic == isPublic) && (c.IsStatic == isStatic));
9799

0 commit comments

Comments
 (0)