Skip to content

Commit b133546

Browse files
committed
Add .NET 4.5 portable project (profile 259)
Fix incompatible code Remove unused EnumUtils.cs with compile error in new profile
1 parent 4ae8842 commit b133546

File tree

4 files changed

+70
-74
lines changed

4 files changed

+70
-74
lines changed

Src/UnitsNet.sln

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Scripts", "Scripts", "{8A38
2323
Scripts\GenerateUnits.ps1 = Scripts\GenerateUnits.ps1
2424
EndProjectSection
2525
EndProject
26+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnitsNet.Portable45", "UnitsNet\UnitsNet.Portable45.csproj", "{72BC5ED7-7496-4048-9233-7A4A843FE8A2}"
27+
EndProject
2628
Global
2729
GlobalSection(SolutionConfigurationPlatforms) = preSolution
2830
Debug|Any CPU = Debug|Any CPU
@@ -65,6 +67,16 @@ Global
6567
{6D74103A-9393-42E8-83A8-9E01F806E29D}.Release|ARM.ActiveCfg = Release|Any CPU
6668
{6D74103A-9393-42E8-83A8-9E01F806E29D}.Release|x64.ActiveCfg = Release|Any CPU
6769
{6D74103A-9393-42E8-83A8-9E01F806E29D}.Release|x86.ActiveCfg = Release|Any CPU
70+
{72BC5ED7-7496-4048-9233-7A4A843FE8A2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
71+
{72BC5ED7-7496-4048-9233-7A4A843FE8A2}.Debug|Any CPU.Build.0 = Debug|Any CPU
72+
{72BC5ED7-7496-4048-9233-7A4A843FE8A2}.Debug|ARM.ActiveCfg = Debug|Any CPU
73+
{72BC5ED7-7496-4048-9233-7A4A843FE8A2}.Debug|x64.ActiveCfg = Debug|Any CPU
74+
{72BC5ED7-7496-4048-9233-7A4A843FE8A2}.Debug|x86.ActiveCfg = Debug|Any CPU
75+
{72BC5ED7-7496-4048-9233-7A4A843FE8A2}.Release|Any CPU.ActiveCfg = Release|Any CPU
76+
{72BC5ED7-7496-4048-9233-7A4A843FE8A2}.Release|Any CPU.Build.0 = Release|Any CPU
77+
{72BC5ED7-7496-4048-9233-7A4A843FE8A2}.Release|ARM.ActiveCfg = Release|Any CPU
78+
{72BC5ED7-7496-4048-9233-7A4A843FE8A2}.Release|x64.ActiveCfg = Release|Any CPU
79+
{72BC5ED7-7496-4048-9233-7A4A843FE8A2}.Release|x86.ActiveCfg = Release|Any CPU
6880
EndGlobalSection
6981
GlobalSection(SolutionProperties) = preSolution
7082
HideSolutionNode = FALSE

Src/UnitsNet/CustomCode/UnitSystem.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
using System.Collections.Generic;
2424
using System.Globalization;
2525
using System.Linq;
26+
using System.Reflection;
2627
using UnitsNet.Annotations;
2728
using UnitsNet.I18n;
2829

@@ -162,8 +163,13 @@ public void MapUnitToAbbreviation<TUnit>(TUnit unit, params string[] abbreviatio
162163
[PublicAPI]
163164
public void MapUnitToAbbreviation(Type unitType, int unitValue, [NotNull] params string[] abbreviations)
164165
{
166+
#if PORTABLE45
167+
if (!unitType.GetTypeInfo().IsEnum)
168+
throw new ArgumentException("Must be an enum type.", "unitType");
169+
#else
165170
if (!unitType.IsEnum)
166171
throw new ArgumentException("Must be an enum type.", "unitType");
172+
#endif
167173
if (abbreviations == null)
168174
throw new ArgumentNullException("abbreviations");
169175

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
4+
<PropertyGroup>
5+
<MinimumVisualStudioVersion>11.0</MinimumVisualStudioVersion>
6+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
7+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
8+
<ProjectGuid>{72BC5ED7-7496-4048-9233-7A4A843FE8A2}</ProjectGuid>
9+
<OutputType>Library</OutputType>
10+
<AppDesignerFolder>Properties</AppDesignerFolder>
11+
<RootNamespace>UnitsNet.Portable45</RootNamespace>
12+
<AssemblyName>UnitsNet.Portable45</AssemblyName>
13+
<DefaultLanguage>en-US</DefaultLanguage>
14+
<FileAlignment>512</FileAlignment>
15+
<ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
16+
<TargetFrameworkProfile>Profile259</TargetFrameworkProfile>
17+
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
18+
<OutputPath>..\..\Build\bin\$(Platform)_$(Configuration)\</OutputPath>
19+
</PropertyGroup>
20+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
21+
<DebugSymbols>true</DebugSymbols>
22+
<DebugType>full</DebugType>
23+
<Optimize>false</Optimize>
24+
<DefineConstants>TRACE;DEBUG;PORTABLE45</DefineConstants>
25+
<ErrorReport>prompt</ErrorReport>
26+
<WarningLevel>4</WarningLevel>
27+
</PropertyGroup>
28+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
29+
<DebugType>pdbonly</DebugType>
30+
<Optimize>true</Optimize>
31+
<DefineConstants>TRACE</DefineConstants>
32+
<ErrorReport>prompt</ErrorReport>
33+
<WarningLevel>4</WarningLevel>
34+
</PropertyGroup>
35+
<ItemGroup>
36+
<!-- A reference to the entire .NET Framework is automatically included -->
37+
</ItemGroup>
38+
<ItemGroup>
39+
<Compile Include="**\*.cs" Exclude="obj\**" />
40+
</ItemGroup>
41+
<ItemGroup>
42+
<None Include="packages.config" />
43+
</ItemGroup>
44+
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\Portable\$(TargetFrameworkVersion)\Microsoft.Portable.CSharp.targets" />
45+
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
46+
Other similar extension points exist, see Microsoft.Common.targets.
47+
<Target Name="BeforeBuild">
48+
</Target>
49+
<Target Name="AfterBuild">
50+
</Target>
51+
-->
52+
</Project>

Src/UnitsNet/Utils/EnumUtils.cs

Lines changed: 0 additions & 74 deletions
This file was deleted.

0 commit comments

Comments
 (0)