Skip to content

Commit

Permalink
Adapt the code and project structure to easuly build with Unity
Browse files Browse the repository at this point in the history
  • Loading branch information
aaubry committed Sep 28, 2021
1 parent 35013cd commit baa5b66
Show file tree
Hide file tree
Showing 32 changed files with 22 additions and 13 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,5 @@ BenchmarkDotNet.Artifacts

/YamlDotNet.AotTest/exitcode.txt
/tools/build/Properties/launchSettings.json
/YamlDotNet.Unity
*.meta
6 changes: 4 additions & 2 deletions YamlDotNet/Core/ParserExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -129,13 +129,15 @@ public static T Expect<T>(this IParser parser) where T : ParsingEvent
}

[Obsolete("Please use TryConsume<T>(out var evt) instead")]
public static T? Allow<T>(this IParser parser) where T : ParsingEvent
[return: MaybeNull]
public static T Allow<T>(this IParser parser) where T : ParsingEvent
{
return parser.TryConsume<T>(out var @event) ? @event : default;
}

[Obsolete("Please use Accept<T>(out var evt) instead")]
public static T? Peek<T>(this IParser parser) where T : ParsingEvent
[return: MaybeNull]
public static T Peek<T>(this IParser parser) where T : ParsingEvent
{
return parser.Accept<T>(out var @event) ? @event : default;
}
Expand Down
4 changes: 3 additions & 1 deletion YamlDotNet/Helpers/ExpressionExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#if !NET20

using System;
using System.Diagnostics.CodeAnalysis;
using System.Linq.Expressions;
using System.Reflection;

Expand All @@ -47,7 +48,8 @@ public static PropertyInfo AsProperty(this LambdaExpression propertyAccessor)
return property;
}

private static TMemberInfo? TryGetMemberExpression<TMemberInfo>(LambdaExpression lambdaExpression)
[return: MaybeNull]
private static TMemberInfo TryGetMemberExpression<TMemberInfo>(LambdaExpression lambdaExpression)
where TMemberInfo : MemberInfo
{
if (lambdaExpression.Parameters.Count != 1)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
The subdirectories of this directory contain platform-specific code
that aims to bridge the gap between the different targetted platforms.

Each directory sould contain code that should only be included
Each directory should contain code that should only be included or excluded
on a set of platforms. The name of the directory should consist of a list
of target platforms, separated by a plus sign (+).
Optionally, a sub-directory named 'others' may be added. Its contents will be
included in all other target platforms.
In that directory, every file inside the 'include' subdirectory
will be included in those platforms, while every file inside the 'exclude' subdirectory
will be included in all other platforms.

Most (all?) types added to this folder should be internal to avoid conflicting
with other libraries.
2 changes: 1 addition & 1 deletion YamlDotNet/Serialization/Utilities/TypeConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ partial class TypeConverter
/// </summary>
/// <typeparam name="TConvertible">The type to which the converter should be associated.</typeparam>
/// <typeparam name="TConverter">The type of the converter.</typeparam>
#if !(NETCOREAPP3_1 || NETSTANDARD2_1 || NETSTANDARD1_3 || UNITY)
#if NET20 || NET35 || NET45
[System.Security.Permissions.PermissionSet(System.Security.Permissions.SecurityAction.LinkDemand, Name = "FullTrust")]
#endif
public static void RegisterTypeConverter<TConvertible, TConverter>()
Expand Down
4 changes: 3 additions & 1 deletion YamlDotNet/Serialization/YamlAttributeOverrides.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using HashCode = YamlDotNet.Core.HashCode;

Expand Down Expand Up @@ -107,7 +108,8 @@ public int Matches(Type matchType)

private readonly Dictionary<AttributeKey, List<AttributeMapping>> overrides = new Dictionary<AttributeKey, List<AttributeMapping>>();

public T? GetAttribute<T>(Type type, string member) where T : Attribute
[return: MaybeNull]
public T GetAttribute<T>(Type type, string member) where T : Attribute
{
if (overrides.TryGetValue(new AttributeKey(typeof(T), member), out var mappings))
{
Expand Down
10 changes: 5 additions & 5 deletions YamlDotNet/YamlDotNet.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@
</PropertyGroup>

<ItemGroup>
<None Include="Helpers/Portability/**/*.cs" />
<Compile Remove="Helpers/Portability/**/*.cs" />
<Compile Include="Helpers/Portability/*$(RealTargetFramework)*/*.cs" />
<Compile Include="Helpers/Portability/*/others/*.cs" />
<Compile Remove="Helpers/Portability/*$(RealTargetFramework)*/others/*.cs" />
<None Include="Portability/**/*.cs" />
<Compile Remove="Portability/**/*.cs" />
<Compile Include="Portability/*$(RealTargetFramework)*/include/*.cs" />
<Compile Include="Portability/*/exclude/*.cs" />
<Compile Remove="Portability/*$(RealTargetFramework)*/exclude/*.cs" />
</ItemGroup>

<ItemGroup>
Expand Down

0 comments on commit baa5b66

Please sign in to comment.