Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/net20'
Browse files Browse the repository at this point in the history
  • Loading branch information
aaubry committed Jan 24, 2018
2 parents 1fa7d87 + 6383edb commit 42bf5ff
Show file tree
Hide file tree
Showing 17 changed files with 493 additions and 33 deletions.
30 changes: 19 additions & 11 deletions CONTRIBUTING.md
Expand Up @@ -67,21 +67,29 @@ Building for Unity requires installing

The Portable versions target [Profile259](http://embed.plnkr.co/03ck2dCtnJogBKHJ9EjY/preview). If you do not have that profile installed, a workaround is to [get the reference assemblies from here](https://ci.appveyor.com/api/buildjobs/hrqgt7tibmar826q/artifacts/Profile259.zip) and extract them to `C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETPortable\v4.5\Profile\Profile259`.

### Target platforms

The project targets the following platforms:

* .NET Framework 4.5
* .NET Framework 3.5
* .NET Framework 2.0
* .NET Standard 1.3
* Unity Subset v3.5

In the csproj, the `TargetFrameworks` element also targets net40, but that is a hack used to target Unity. That target is overriden and in reality it targets Unity Subset v3.5.

### Build configurations

The following table describes the available build configurations:

| Configuration | Target | Defines | Description |
|---------------------------------|------------------------------|----------------------------------|--------------------------------------|
| Debug | .NET 3.5 | DEBUG | Default debug build. |
| Release-Unsigned | .NET 3.5 | | Release build, not signed. |
| Release-Signed | .NET 3.5 | SIGNED | Release build, signed. |
| Release-DotNetStandard-Unsigned | .NET Core (netstandard 1.3) | NETSTANDARD1_3; PORTABLE | Release .NET Core build, not signed. |
| Release-DotNetStandard-Signed | .NET Core (netstandard 1.3) | NETSTANDARD1_3; PORTABLE; SIGNED | Release .NET Core build, signed. |
| Release-Portable-Unsigned | .NET 4.5 portable Profile259 | PORTABLE | Portable class library, not signed. |
| Release-Portable-Signed | .NET 4.5 portable Profile259 | PORTABLE; SIGNED | Portable class library, signed. |
| Debug-UnitySubset-v35 | Unity Subset v3.5 | DEBUG; UNITY | Debug build for Unity target. |
| Release-UnitySubset-v35 | Unity Subset v3.5 | UNITY | Release build for Unity target. |
| Configuration | Description |
|--------------------------|-------------------------------------------------------------------------------------|
| Debug | Default debug build. |
| Release-Unsigned | Release build, not signed. |
| Release-Signed | Release build, signed. |
| Debug-AOT | Builds the AOT tests project, that tests compatibility with mono's AOT compilation. |
| Release-PerformanceTests | Builds the performance tests projects. |

There are a few differences between the various target platforms,
mainly in the reflection API. In order to adapt the code to each platform,
Expand Down
13 changes: 13 additions & 0 deletions README.md
Expand Up @@ -45,6 +45,19 @@ Please read [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.

# Changelog

## Version 4.2.4

* Refactored the project and solution so that they load and build cleanly in VS2017.
* Reviewed the target platforms.
* **The currently supported platforms are now:**
* .NET Framework 4.5
* .NET Framework 3.5
* .NET Framework 2.0 (**experimental**)
* .NET Standard 1.3
* Unity Subset v3.5
* **The following platforms are no longer supported:**
* Profile259 (please upgrade to netstandard)

## Version 4.2.3

Bug fixes:
Expand Down
74 changes: 74 additions & 0 deletions YamlDotNet.Test/Portability.cs
@@ -0,0 +1,74 @@
using System;
using System.Linq.Expressions;
using System.Reflection;
using YamlDotNet.Serialization;

namespace YamlDotNet.Test
{
#if NET20
internal static class Portability
{
public static SerializerBuilder WithAttributeOverride<TClass>(this SerializerBuilder builder, Expression<Func<TClass, object>> propertyAccessor, Attribute attribute)
{
return builder.WithAttributeOverride(typeof(TClass), propertyAccessor.AsProperty().Name, attribute);
}

public static DeserializerBuilder WithAttributeOverride<TClass>(this DeserializerBuilder builder, Expression<Func<TClass, object>> propertyAccessor, Attribute attribute)
{
return builder.WithAttributeOverride(typeof(TClass), propertyAccessor.AsProperty().Name, attribute);
}

public static void Add<TClass>(this YamlAttributeOverrides overrides, Expression<Func<TClass, object>> propertyAccessor, Attribute attribute)
{
var property = propertyAccessor.AsProperty();
overrides.Add(typeof(TClass), property.Name, attribute);
}

public static PropertyInfo AsProperty(this LambdaExpression propertyAccessor)
{
var property = TryGetMemberExpression<PropertyInfo>(propertyAccessor);
if (property == null)
{
throw new ArgumentException("Expected a lambda expression in the form: x => x.SomeProperty", "propertyAccessor");
}

return property;
}

private static TMemberInfo TryGetMemberExpression<TMemberInfo>(LambdaExpression lambdaExpression)
where TMemberInfo : MemberInfo
{
if (lambdaExpression.Parameters.Count != 1)
{
return null;
}

var body = lambdaExpression.Body;

var castExpression = body as UnaryExpression;
if (castExpression != null)
{
if (castExpression.NodeType != ExpressionType.Convert)
{
return null;
}

body = castExpression.Operand;
}

var memberExpression = body as MemberExpression;
if (memberExpression == null)
{
return null;
}

if (memberExpression.Expression != lambdaExpression.Parameters[0])
{
return null;
}

return memberExpression.Member as TMemberInfo;
}
}
#endif
}
2 changes: 1 addition & 1 deletion YamlDotNet.Test/RepresentationModel/YamlStreamTests.cs
Expand Up @@ -64,7 +64,7 @@ public void InfinitelyRecursiveNodeToStringSucceeds()

var toString = stream.Documents.Single().RootNode.ToString();

toString.Should().Contain(YamlNode.MaximumRecursionLevelReachedToStringValue);
toString.Should().Contain("WARNING! INFINITE RECURSION!");
}

[Fact]
Expand Down
21 changes: 20 additions & 1 deletion YamlDotNet.Test/YamlDotNet.Test.csproj
Expand Up @@ -26,6 +26,16 @@
</CustomCommands>
</CustomCommands>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug-Net20|AnyCPU' ">
<TargetFrameworks>net452</TargetFrameworks>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug-Net20\</OutputPath>
<DefineConstants>TRACE;NET20;DEBUG;TEST_DUMP</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release-Unsigned|AnyCPU' ">
<TargetFrameworks>net452</TargetFrameworks>
<DebugType>pdbonly</DebugType>
Expand All @@ -35,6 +45,15 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release-Net20-Unsigned|AnyCPU' ">
<TargetFrameworks>net452</TargetFrameworks>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release-Net20-Unsigned\</OutputPath>
<DefineConstants>TRACE;NET20</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release-DotNetStandard-Unsigned|AnyCPU' ">
<TargetFrameworks>netcoreapp1.0</TargetFrameworks>
<DebugType>pdbonly</DebugType>
Expand All @@ -58,7 +77,7 @@

<ItemGroup>
<PackageReference Include="FluentAssertions" Version="4.19.2" />
<PackageReference Include="FakeItEasy" Version="3.3.2" />
<PackageReference Include="FakeItEasy" Version="4.3.0" />
<PackageReference Include="Microsoft.CSharp" Version="4.3.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.0.0" />
<PackageReference Include="Microsoft.TestPlatform.TestHost" Version="15.0.0" />
Expand Down
2 changes: 1 addition & 1 deletion YamlDotNet/Core/Constants.cs
Expand Up @@ -27,7 +27,7 @@ namespace YamlDotNet.Core
/// <summary>
/// Defines constants thar relate to the YAML specification.
/// </summary>
internal static class Constants
public static class Constants
{
public static readonly TagDirective[] DefaultTagDirectives =
{
Expand Down
2 changes: 1 addition & 1 deletion YamlDotNet/Core/Cursor.cs
Expand Up @@ -24,7 +24,7 @@
namespace YamlDotNet.Core
{
[Serializable]
internal class Cursor
public class Cursor
{
public int Index { get; set; }
public int Line { get; set; }
Expand Down
7 changes: 5 additions & 2 deletions YamlDotNet/Helpers/ExpressionExtensions.cs
@@ -1,6 +1,8 @@
using System;
using System.Linq.Expressions;
#if !NET20

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

namespace YamlDotNet.Helpers
{
Expand Down Expand Up @@ -60,3 +62,4 @@ private static TMemberInfo TryGetMemberExpression<TMemberInfo>(LambdaExpression
}
}
}
#endif

0 comments on commit 42bf5ff

Please sign in to comment.