Import YamlDotNet.
This commit is contained in:
47
Assets/YamlDotNet/Portability/NullableReferences.cs
Normal file
47
Assets/YamlDotNet/Portability/NullableReferences.cs
Normal file
@@ -0,0 +1,47 @@
|
||||
// This file is part of YamlDotNet - A .NET library for YAML.
|
||||
// Copyright (c) Antoine Aubry and contributors
|
||||
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
// this software and associated documentation files (the "Software"), to deal in
|
||||
// the Software without restriction, including without limitation the rights to
|
||||
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
// of the Software, and to permit persons to whom the Software is furnished to do
|
||||
// so, subject to the following conditions:
|
||||
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
namespace System.Diagnostics.CodeAnalysis
|
||||
{
|
||||
[AttributeUsage(AttributeTargets.Parameter, Inherited = false)]
|
||||
internal sealed class NotNullWhenAttribute : Attribute
|
||||
{
|
||||
public NotNullWhenAttribute(bool returnValue) { }
|
||||
}
|
||||
|
||||
[AttributeUsage(AttributeTargets.Parameter, Inherited = false)]
|
||||
internal sealed class MaybeNullWhenAttribute : Attribute
|
||||
{
|
||||
public MaybeNullWhenAttribute(bool returnValue) { }
|
||||
}
|
||||
|
||||
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Parameter | AttributeTargets.Property | AttributeTargets.ReturnValue, Inherited = false)]
|
||||
internal sealed class MaybeNullAttribute : Attribute
|
||||
{
|
||||
public MaybeNullAttribute() { }
|
||||
}
|
||||
|
||||
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Parameter | AttributeTargets.Property, Inherited = false)]
|
||||
internal sealed class AllowNullAttribute : Attribute
|
||||
{
|
||||
public AllowNullAttribute() { }
|
||||
}
|
||||
}
|
11
Assets/YamlDotNet/Portability/NullableReferences.cs.meta
Normal file
11
Assets/YamlDotNet/Portability/NullableReferences.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 27b4cc9905862e44ebfcea2e376c18c3
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
8
Assets/YamlDotNet/Portability/netstandard1.3.meta
Normal file
8
Assets/YamlDotNet/Portability/netstandard1.3.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: afa0f7aa07140a84b8965f0ed8650262
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,42 @@
|
||||
// This file is part of YamlDotNet - A .NET library for YAML.
|
||||
// Copyright (c) Antoine Aubry and contributors
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
// this software and associated documentation files (the "Software"), to deal in
|
||||
// the Software without restriction, including without limitation the rights to
|
||||
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
// of the Software, and to permit persons to whom the Software is furnished to do
|
||||
// so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
using System;
|
||||
using System.Globalization;
|
||||
|
||||
namespace YamlDotNet
|
||||
{
|
||||
internal sealed class CultureInfoAdapter : CultureInfo
|
||||
{
|
||||
private readonly IFormatProvider provider;
|
||||
|
||||
public CultureInfoAdapter(CultureInfo baseCulture, IFormatProvider provider)
|
||||
: base(baseCulture.LCID)
|
||||
{
|
||||
this.provider = provider;
|
||||
}
|
||||
|
||||
public override object? GetFormat(Type? formatType)
|
||||
{
|
||||
return provider.GetFormat(formatType);
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3b57d4cc1492d5f47a8e2be5142d8e92
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,166 @@
|
||||
// This file is part of YamlDotNet - A .NET library for YAML.
|
||||
// Copyright (c) Antoine Aubry and contributors
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
// this software and associated documentation files (the "Software"), to deal in
|
||||
// the Software without restriction, including without limitation the rights to
|
||||
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
// of the Software, and to permit persons to whom the Software is furnished to do
|
||||
// so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
|
||||
namespace YamlDotNet
|
||||
{
|
||||
internal static class ReflectionExtensions
|
||||
{
|
||||
public static Type? BaseType(this Type type)
|
||||
{
|
||||
return type.BaseType;
|
||||
}
|
||||
|
||||
public static bool IsValueType(this Type type)
|
||||
{
|
||||
return type.IsValueType;
|
||||
}
|
||||
|
||||
public static bool IsGenericType(this Type type)
|
||||
{
|
||||
return type.IsGenericType;
|
||||
}
|
||||
|
||||
public static bool IsGenericTypeDefinition(this Type type)
|
||||
{
|
||||
return type.IsGenericTypeDefinition;
|
||||
}
|
||||
|
||||
public static bool IsInterface(this Type type)
|
||||
{
|
||||
return type.IsInterface;
|
||||
}
|
||||
|
||||
public static bool IsEnum(this Type type)
|
||||
{
|
||||
return type.IsEnum;
|
||||
}
|
||||
|
||||
public static bool IsDbNull(this object value)
|
||||
{
|
||||
return value is DBNull;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether the specified type has a default constructor.
|
||||
/// </summary>
|
||||
/// <param name="type">The type.</param>
|
||||
/// <returns>
|
||||
/// <c>true</c> if the type has a default constructor; otherwise, <c>false</c>.
|
||||
/// </returns>
|
||||
public static bool HasDefaultConstructor(this Type type)
|
||||
{
|
||||
return type.IsValueType || type.GetConstructor(BindingFlags.Public | BindingFlags.Instance, null, Type.EmptyTypes, null) != null;
|
||||
}
|
||||
|
||||
public static TypeCode GetTypeCode(this Type type)
|
||||
{
|
||||
return Type.GetTypeCode(type);
|
||||
}
|
||||
|
||||
public static PropertyInfo? GetPublicProperty(this Type type, string name)
|
||||
{
|
||||
return type.GetProperty(name);
|
||||
}
|
||||
|
||||
public static FieldInfo? GetPublicStaticField(this Type type, string name)
|
||||
{
|
||||
return type.GetField(name, BindingFlags.Static | BindingFlags.Public);
|
||||
}
|
||||
|
||||
public static IEnumerable<PropertyInfo> GetProperties(this Type type, bool includeNonPublic)
|
||||
{
|
||||
var bindingFlags = BindingFlags.Instance | BindingFlags.Public;
|
||||
|
||||
if (includeNonPublic)
|
||||
{
|
||||
bindingFlags |= BindingFlags.NonPublic;
|
||||
}
|
||||
|
||||
return type.IsInterface
|
||||
? (new Type[] { type })
|
||||
.Concat(type.GetInterfaces())
|
||||
.SelectMany(i => i.GetProperties(bindingFlags))
|
||||
: type.GetProperties(bindingFlags);
|
||||
}
|
||||
|
||||
public static IEnumerable<PropertyInfo> GetPublicProperties(this Type type) => GetProperties(type, false);
|
||||
|
||||
public static IEnumerable<FieldInfo> GetPublicFields(this Type type)
|
||||
{
|
||||
return type.GetFields(BindingFlags.Instance | BindingFlags.Public);
|
||||
}
|
||||
|
||||
public static IEnumerable<MethodInfo> GetPublicStaticMethods(this Type type)
|
||||
{
|
||||
return type.GetMethods(BindingFlags.Static | BindingFlags.Public);
|
||||
}
|
||||
|
||||
public static MethodInfo GetPrivateStaticMethod(this Type type, string name)
|
||||
{
|
||||
return type.GetMethod(name, BindingFlags.Static | BindingFlags.NonPublic)
|
||||
?? throw new MissingMethodException($"Expected to find a method named '{name}' in '{type.FullName}'.");
|
||||
}
|
||||
|
||||
public static MethodInfo? GetPublicStaticMethod(this Type type, string name, params Type[] parameterTypes)
|
||||
{
|
||||
return type.GetMethod(name, BindingFlags.Public | BindingFlags.Static, null, parameterTypes, null);
|
||||
}
|
||||
|
||||
public static MethodInfo? GetPublicInstanceMethod(this Type type, string name)
|
||||
{
|
||||
return type.GetMethod(name, BindingFlags.Public | BindingFlags.Instance);
|
||||
}
|
||||
|
||||
private static readonly FieldInfo? RemoteStackTraceField = typeof(Exception)
|
||||
.GetField("_remoteStackTraceString", BindingFlags.Instance | BindingFlags.NonPublic);
|
||||
|
||||
public static Exception Unwrap(this TargetInvocationException ex)
|
||||
{
|
||||
var result = ex.InnerException;
|
||||
if (result == null)
|
||||
{
|
||||
return ex;
|
||||
}
|
||||
|
||||
if (RemoteStackTraceField != null)
|
||||
{
|
||||
RemoteStackTraceField.SetValue(result, result.StackTrace + "\r\n");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public static bool IsInstanceOf(this Type type, object o)
|
||||
{
|
||||
return type.IsInstanceOfType(o);
|
||||
}
|
||||
|
||||
public static Attribute[] GetAllCustomAttributes<TAttribute>(this PropertyInfo property)
|
||||
{
|
||||
// Don't use IMemberInfo.GetCustomAttributes, it ignores the inherit parameter
|
||||
return Attribute.GetCustomAttributes(property, typeof(TAttribute));
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f309b2324c56de5419e209fe229d1ec3
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
8
Assets/YamlDotNet/Portability/unitysubset3.5.meta
Normal file
8
Assets/YamlDotNet/Portability/unitysubset3.5.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b5c36140127ae7341a98c738f9d6254b
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,33 @@
|
||||
// This file is part of YamlDotNet - A .NET library for YAML.
|
||||
// Copyright (c) Antoine Aubry and contributors
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
// this software and associated documentation files (the "Software"), to deal in
|
||||
// the Software without restriction, including without limitation the rights to
|
||||
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
// of the Software, and to permit persons to whom the Software is furnished to do
|
||||
// so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
using System.Reflection;
|
||||
|
||||
namespace YamlDotNet
|
||||
{
|
||||
internal static class PropertyInfoExtensions
|
||||
{
|
||||
public static object? ReadValue(this PropertyInfo property, object target)
|
||||
{
|
||||
return property.GetGetMethod().Invoke(target, null);
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8942d729fabed6e4e8defd6e16fbe638
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,30 @@
|
||||
// This file is part of YamlDotNet - A .NET library for YAML.
|
||||
// Copyright (c) Antoine Aubry and contributors
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
// this software and associated documentation files (the "Software"), to deal in
|
||||
// the Software without restriction, including without limitation the rights to
|
||||
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
// of the Software, and to permit persons to whom the Software is furnished to do
|
||||
// so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace YamlDotNet
|
||||
{
|
||||
internal static class StandardRegexOptions
|
||||
{
|
||||
public const RegexOptions Compiled = RegexOptions.None;
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 212fb3ce30a7ede4b8fd1b7af348700b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Reference in New Issue
Block a user