Skip to content

Commit

Permalink
Added multi-targeting for .NET 4.5
Browse files Browse the repository at this point in the history
- The perviously targeted .NET Standard 1.0 should work almost everywhere. However, on the full .NET Framework, it included a lot of unnecessary packages under the .NET Standard Library, which is less than desirable.
  • Loading branch information
shravan2x committed Aug 28, 2017
1 parent e157f3b commit 9367a30
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 8 deletions.
22 changes: 14 additions & 8 deletions Gameloop.Vdf/Gameloop.Vdf.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard1.0</TargetFramework>
<TargetFrameworks>netstandard1.0;net45</TargetFrameworks>
<Description>A high-performance framework for the Valve Data Format, also called KeyValues.</Description>
<Copyright>Copyright © Shravan Rajinikanth 2016</Copyright>
<Company>Gameloop</Company>
Expand All @@ -20,19 +20,25 @@
<RepositoryType>git</RepositoryType>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<DefineConstants>NETSTANDARD1_0</DefineConstants>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<DocumentationFile>bin\Release\netstandard1.0\Gameloop.Vdf.xml</DocumentationFile>
<DefineConstants>RELEASE;NETSTANDARD1_0</DefineConstants>
<DefineConstants>RELEASE</DefineConstants>
<NoWarn>1591;1701;1702;1705</NoWarn>
<Optimize>true</Optimize>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.CSharp" Version="4.3.0" />
<PropertyGroup Condition="'$(TargetFramework)' == 'net45'">
<AssemblyTitle>Vdf.NET</AssemblyTitle>
<DefineConstants>HAVE_FULL_REFLECTION</DefineConstants>
</PropertyGroup>

<PropertyGroup Condition="'$(TargetFramework)' == 'netstandard1.0'">
<AssemblyTitle>Vdf.NET .NET Standard 1.0</AssemblyTitle>
<DefineConstants>NETSTANDARD1_0;PORTABLE</DefineConstants>
</PropertyGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'netstandard1.0'">
<PackageReference Include="Microsoft.CSharp" Version="4.4.0" />
<PackageReference Include="System.ComponentModel.TypeConverter" Version="4.3.0" />
</ItemGroup>

Expand Down
3 changes: 3 additions & 0 deletions Gameloop.Vdf/Utilities/ReflectionUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,11 @@

using System;
using System.Linq;
using System.Reflection;

namespace Gameloop.Vdf.Utilities
{
#if PORTABLE
[Flags]
internal enum BindingFlags
{
Expand All @@ -52,6 +54,7 @@ internal enum BindingFlags
OptionalParamBinding = 262144,
IgnoreReturn = 16777216
}
#endif

internal static class ReflectionUtils
{
Expand Down
10 changes: 10 additions & 0 deletions Gameloop.Vdf/Utilities/TypeExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,21 @@ namespace Gameloop.Vdf.Utilities
{
internal static class TypeExtensions
{
#if DOTNET || PORTABLE
#if !DOTNET
private const BindingFlags DefaultFlags = BindingFlags.Public | BindingFlags.Static | BindingFlags.Instance;
#endif
#endif

#if (DOTNET || PORTABLE)
public static MethodInfo GetBaseDefinition(this MethodInfo method)
{
return method.GetRuntimeBaseDefinition();
}
#endif

#if (DOTNET || PORTABLE)
#if !DOTNET
public static MethodInfo GetMethod(this Type type, string name)
{
return type.GetMethod(name, DefaultFlags);
Expand All @@ -52,6 +60,8 @@ public static IEnumerable<MethodInfo> GetMethods(this Type type, BindingFlags bi
{
return type.GetTypeInfo().DeclaredMethods;
}
#endif
#endif

public static Type BaseType(this Type type)
{
Expand Down

0 comments on commit 9367a30

Please sign in to comment.