Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate to .NET Standard 2.0. 🚚 #94

Merged
merged 1 commit into from
Aug 25, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## v17.0.1
* Migration to **.NET Standard 2.0**.

## v16.0.3
* With additional overloads for `.PickRandom(IList)` and `.PickRandom(ICollection)` we can now add `.PickRandom("cat", "dog", "fish")` back to the API.

Expand Down
8 changes: 2 additions & 6 deletions Source/Bogus/Bogus.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
</PackageReleaseNotes>
<Version>0.0.0-localbuild</Version>
<Authors>Brian Chavez</Authors>
<TargetFrameworks>net40;netstandard1.3</TargetFrameworks>
<TargetFrameworks>net40;netstandard2.0</TargetFrameworks>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<AssemblyOriginatorKeyFile>
</AssemblyOriginatorKeyFile>
Expand All @@ -18,7 +18,6 @@
<PackageLicenseUrl>https://raw.githubusercontent.com/bchavez/Bogus/master/LICENSE</PackageLicenseUrl>
<RepositoryType>git</RepositoryType>
<RepositoryUrl>https://github.com/bchavez/Bogus</RepositoryUrl>
<PackageTargetFallback Condition=" '$(TargetFramework)' == 'netstandard1.3' ">$(PackageTargetFallback);portable-net451+win8;dnxcore50</PackageTargetFallback>
<GenerateAssemblyTitleAttribute>false</GenerateAssemblyTitleAttribute>
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
<GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute>
Expand All @@ -28,7 +27,7 @@
<GenerateAssemblyInformationalVersionAttribute>false</GenerateAssemblyInformationalVersionAttribute>
<GenerateAssemblyDescriptionAttribute>false</GenerateAssemblyDescriptionAttribute>
</PropertyGroup>
<PropertyGroup Condition=" '$(TargetFramework)' == 'netstandard1.3' ">
<PropertyGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' ">
<DefineConstants>$(DefineConstants);STANDARD</DefineConstants>
</PropertyGroup>
<ItemGroup>
Expand All @@ -37,9 +36,6 @@
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="10.0.3" />
</ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard1.3' ">
<PackageReference Include="System.Reflection.TypeExtensions" Version="4.3.0" />
</ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'net40' ">
<Reference Include="System" />
<Reference Include="Microsoft.CSharp" />
Expand Down
2 changes: 1 addition & 1 deletion Source/Bogus/DataSet.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System;
using System.Text.RegularExpressions;
using Bogus.Extensions;
using Bogus.Platform;
using Newtonsoft.Json.Linq;

namespace Bogus
Expand Down
5 changes: 2 additions & 3 deletions Source/Bogus/Database.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ public static class Database
/// </summary>
private static JObject Initialize()
{
//var asm = typeof(Database).Assembly;
var asm = typeof(Database).GetAssembly();
var asm = typeof(Database).Assembly;
var root = new JObject();

var resourcesFound = false;
Expand All @@ -35,7 +34,7 @@ private static JObject Initialize()
resourcesFound = true;
if( resourceName.EndsWith(".locale.json") )
{
using( var s = typeof(Database).GetAssembly().GetManifestResourceStream(resourceName) )
using( var s = asm.GetManifestResourceStream(resourceName) )
using( var sr = new StreamReader(s) )
{
var serializer = new JsonSerializer();
Expand Down
60 changes: 0 additions & 60 deletions Source/Bogus/Extensions/CrossPlatform.cs

This file was deleted.

17 changes: 17 additions & 0 deletions Source/Bogus/Platform/ExtensionsForType.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using System;
using System.Reflection;

namespace Bogus.Platform
{
internal static class ExtensionsForType
{
public static T GetCustomAttributeX<T>(this Type type) where T : Attribute
{
#if STANDARD
return type.GetCustomAttribute<T>();
#else
return Attribute.GetCustomAttribute(type, typeof(T)) as T;
#endif
}
}
}
2 changes: 1 addition & 1 deletion Source/Bogus/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ internal static class AssemblyVersionInformation {
internal const System.String AssemblyVersion = "0.0.0";
internal const System.String AssemblyFileVersion = "0.0.0";
internal const System.String AssemblyInformationalVersion = "0.0.0-localbuild built on 1/1/2015 12:00:00 AM";
internal const System.String AssemblyTrademark = "Apache License v2.0";
internal const System.String AssemblyTrademark = "MIT License";
internal const System.String AssemblyDescription = "https://github.com/bchavez/Bogus";
internal const System.String InternalsVisibleTo = "Bogus.Tests";
}
Expand Down
2 changes: 1 addition & 1 deletion Source/Bogus/Randomizer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ public string Replace(string format)
public T Enum<T>(params T[] exclude) where T : struct
{
var e = typeof(T);
if(!e.IsEnum())
if(!e.IsEnum)
throw new ArgumentException("When calling Enum<T>() with no parameters T must be an enum.");

var selection = System.Enum.GetNames(e);
Expand Down