Skip to content

Commit

Permalink
Merge pull request #518 from AArnott/fix507
Browse files Browse the repository at this point in the history
Use UNITY_2018_3_OR_NEWER for #if instead of UNITY_STANDALONE
  • Loading branch information
neuecc committed Jul 23, 2019
2 parents 260c05b + 6743b60 commit 3d26901
Show file tree
Hide file tree
Showing 39 changed files with 79 additions and 79 deletions.
Expand Up @@ -8,7 +8,7 @@
using System.Collections.ObjectModel;
using System.Linq;

#if !UNITY_STANDALONE
#if !UNITY_2018_3_OR_NEWER
using System.Collections.Concurrent;
#endif

Expand Down Expand Up @@ -217,7 +217,7 @@ public void Serialize(ref MessagePackWriter writer, TCollection value, MessagePa
{
while (e.MoveNext())
{
#if !UNITY_STANDALONE
#if !UNITY_2018_3_OR_NEWER
formatter.Serialize(ref writer, e.Current, options);
#else
formatter.Serialize(ref writer, (TElement)e.Current, options);
Expand All @@ -243,7 +243,7 @@ public void Serialize(ref MessagePackWriter writer, TCollection value, MessagePa
while (e.MoveNext())
{
count++;
#if !UNITY_STANDALONE
#if !UNITY_2018_3_OR_NEWER
formatter.Serialize(ref scratchWriter, e.Current, options);
#else
formatter.Serialize(ref scratchWriter, (TElement)e.Current, options);
Expand Down Expand Up @@ -294,7 +294,7 @@ public TCollection Deserialize(ref MessagePackReader reader, MessagePackSerializ
{
return collection.Count;
}
#if !UNITY_STANDALONE
#if !UNITY_2018_3_OR_NEWER
else
{
var c2 = sequence as IReadOnlyCollection<TElement>;
Expand Down Expand Up @@ -842,7 +842,7 @@ public IDictionary Deserialize(ref MessagePackReader reader, MessagePackSerializ
}
}

#if !UNITY_STANDALONE
#if !UNITY_2018_3_OR_NEWER

public sealed class ObservableCollectionFormatter<T> : CollectionFormatterBase<T, ObservableCollection<T>>
{
Expand Down
Expand Up @@ -6,15 +6,15 @@
using System.Collections.Generic;
using System.Collections.ObjectModel;

#if !UNITY_STANDALONE
#if !UNITY_2018_3_OR_NEWER
using System.Collections.Concurrent;
#endif

#pragma warning disable SA1649 // File name should match first type name

namespace MessagePack.Formatters
{
#if !UNITY_STANDALONE
#if !UNITY_2018_3_OR_NEWER

// unfortunately, can't use IDictionary<KVP> because supports IReadOnlyDictionary.
public abstract class DictionaryFormatterBase<TKey, TValue, TIntermediate, TEnumerator, TDictionary> : IMessagePackFormatter<TDictionary>
Expand Down
@@ -1,7 +1,7 @@
// Copyright (c) All contributors. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

#if !UNITY_STANDALONE
#if !UNITY_2018_3_OR_NEWER

using System;
using System.Buffers;
Expand Down
Expand Up @@ -35,7 +35,7 @@ private PrimitiveObjectFormatter()
{
}

#if !UNITY_STANDALONE
#if !UNITY_2018_3_OR_NEWER

public static bool IsSupportedType(Type type, TypeInfo typeInfo, object value)
{
Expand Down Expand Up @@ -135,7 +135,7 @@ public void Serialize(ref MessagePackWriter writer, object value, MessagePackSer
}
else
{
#if UNITY_STANDALONE && !NETFX_CORE
#if UNITY_2018_3_OR_NEWER && !NETFX_CORE
if (t.IsEnum)
#else
if (t.GetTypeInfo().IsEnum)
Expand Down
Expand Up @@ -9,7 +9,7 @@
using System.Text;
using MessagePack.Internal;

#if !UNITY_STANDALONE
#if !UNITY_2018_3_OR_NEWER
using System.Threading.Tasks;
#endif

Expand Down Expand Up @@ -417,7 +417,7 @@ public BitArray Deserialize(ref MessagePackReader reader, MessagePackSerializerO
}
}

#if !UNITY_STANDALONE
#if !UNITY_2018_3_OR_NEWER

public sealed class BigIntegerFormatter : IMessagePackFormatter<System.Numerics.BigInteger>
{
Expand Down
@@ -1,7 +1,7 @@
// Copyright (c) All contributors. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

#if !UNITY_STANDALONE
#if !UNITY_2018_3_OR_NEWER

using System;
using System.Buffers;
Expand Down
@@ -1,7 +1,7 @@
// Copyright (c) All contributors. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

#if !UNITY_STANDALONE
#if !UNITY_2018_3_OR_NEWER

using System;
using System.Buffers;
Expand Down
@@ -1,7 +1,7 @@
// Copyright (c) All contributors. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

#if !UNITY_STANDALONE
#if !UNITY_2018_3_OR_NEWER

using System;
using System.Buffers;
Expand Down
@@ -1,7 +1,7 @@
// Copyright (c) All contributors. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

#if !UNITY_STANDALONE
#if !UNITY_2018_3_OR_NEWER
using System;
using System.Buffers;

Expand Down
Expand Up @@ -40,7 +40,7 @@ public static IMessagePackFormatter<T> GetFormatterWithVerify<T>(this IFormatter
return formatter;
}

#if !UNITY_STANDALONE
#if !UNITY_2018_3_OR_NEWER

public static object GetFormatterDynamic(this IFormatterResolver resolver, Type type)
{
Expand Down
@@ -1,7 +1,7 @@
// Copyright (c) All contributors. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

#if !UNITY_STANDALONE
#if !UNITY_2018_3_OR_NEWER

using System;

Expand Down
Expand Up @@ -50,7 +50,7 @@ public void Add(string str, int value)
}
}

#if !UNITY_STANDALONE
#if !UNITY_2018_3_OR_NEWER

public bool TryGetValue(in ReadOnlySequence<byte> bytes, out int value) => this.TryGetValue(bytes.ToArray(), out value);

Expand Down Expand Up @@ -208,7 +208,7 @@ public AutomataNode Add(ulong key, int value, string originalKey)
return v;
}

#if !UNITY_STANDALONE
#if !UNITY_2018_3_OR_NEWER

public AutomataNode SearchNext(ref ReadOnlySpan<byte> value)
{
Expand Down Expand Up @@ -425,7 +425,7 @@ private static void EmitSearchNextCore(ILGenerator il, LocalBuilder bytesSpan, L
/// </remarks>
public static class AutomataKeyGen
{
#if !UNITY_STANDALONE
#if !UNITY_2018_3_OR_NEWER
public static readonly MethodInfo GetKeyMethod = typeof(AutomataKeyGen).GetRuntimeMethod(nameof(GetKey), new[] { typeof(ReadOnlySpan<byte>).MakeByRefType() });
#endif

Expand Down
Expand Up @@ -11,7 +11,7 @@ internal static class ByteArrayComparer
{
#if ENABLE_UNSAFE_MSGPACK

#if !UNITY_STANDALONE
#if !UNITY_2018_3_OR_NEWER

private static readonly bool Is32Bit = IntPtr.Size == 4;

Expand All @@ -30,7 +30,7 @@ public static int GetHashCode(ReadOnlySpan<byte> bytes)

#endif

#if !UNITY_STANDALONE
#if !UNITY_2018_3_OR_NEWER
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
#endif
public static unsafe bool Equals(ReadOnlySpan<byte> xs, ReadOnlySpan<byte> ys)
Expand Down Expand Up @@ -112,7 +112,7 @@ public static unsafe bool Equals(ReadOnlySpan<byte> xs, ReadOnlySpan<byte> ys)
}

#else
#if !UNITY_STANDALONE
#if !UNITY_2018_3_OR_NEWER
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
#endif
public static bool Equals(ReadOnlySpan<byte> xs, ReadOnlySpan<byte> ys)
Expand Down
Expand Up @@ -94,7 +94,7 @@ public bool TryGetValue(ReadOnlySpan<byte> key, out int value)
}

{
#if !UNITY_STANDALONE
#if !UNITY_2018_3_OR_NEWER
ref Entry v = ref entry[0];
#else
var v = entry[0];
Expand All @@ -108,7 +108,7 @@ public bool TryGetValue(ReadOnlySpan<byte> key, out int value)

for (int i = 1; i < entry.Length; i++)
{
#if !UNITY_STANDALONE
#if !UNITY_2018_3_OR_NEWER
ref Entry v = ref entry[i];
#else
var v = entry[i];
Expand All @@ -125,16 +125,16 @@ public bool TryGetValue(ReadOnlySpan<byte> key, out int value)
return false;
}

#if !UNITY_STANDALONE
#if !UNITY_2018_3_OR_NEWER
private static readonly bool Is32Bit = IntPtr.Size == 4;
#endif

#if !UNITY_STANDALONE
#if !UNITY_2018_3_OR_NEWER
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
#endif
private static ulong ByteArrayGetHashCode(ReadOnlySpan<byte> x)
{
#if !UNITY_STANDALONE
#if !UNITY_2018_3_OR_NEWER
// FarmHash https://github.com/google/farmhash
if (x == null)
{
Expand Down
@@ -1,7 +1,7 @@
// Copyright (c) All contributors. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

#if !UNITY_STANDALONE
#if !UNITY_2018_3_OR_NEWER

using System;
using System.Reflection;
Expand Down
@@ -1,7 +1,7 @@
// Copyright (c) All contributors. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

#if !UNITY_STANDALONE
#if !UNITY_2018_3_OR_NEWER

using System;
using System.Runtime.CompilerServices;
Expand Down
Expand Up @@ -179,15 +179,15 @@ public GuidBits(ReadOnlySpan<byte> utf8string)
throw new ArgumentException("Invalid Guid Pattern.");
}

#if !UNITY_STANDALONE
#if !UNITY_2018_3_OR_NEWER
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
#endif
private static byte Parse(ReadOnlySpan<byte> bytes, int highOffset)
{
return unchecked((byte)((SwitchParse(bytes[highOffset]) * 16) + SwitchParse(bytes[highOffset + 1])));
}

#if !UNITY_STANDALONE
#if !UNITY_2018_3_OR_NEWER
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
#endif
private static byte SwitchParse(byte b)
Expand Down
@@ -1,7 +1,7 @@
// Copyright (c) All contributors. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

#if !UNITY_STANDALONE && !NET_STANDARD_2_0
#if !UNITY_2018_3_OR_NEWER && !NET_STANDARD_2_0

using System;
using System.Linq;
Expand Down
@@ -1,7 +1,7 @@
// Copyright (c) All contributors. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

#if !UNITY_STANDALONE
#if !UNITY_2018_3_OR_NEWER

using System;
using System.Collections.Generic;
Expand Down Expand Up @@ -36,7 +36,7 @@ public static bool IsIndexer(this System.Reflection.PropertyInfo propertyInfo)
return propertyInfo.GetIndexParameters().Length > 0;
}

#if !UNITY_STANDALONE
#if !UNITY_2018_3_OR_NEWER

public static bool IsConstructedGenericType(this System.Reflection.TypeInfo type)
{
Expand Down
Expand Up @@ -203,9 +203,9 @@ private static int CalculateCapacity(int collectionSize, float loadFactor)

private static void VolatileWrite(ref Entry location, Entry value)
{
#if !UNITY_STANDALONE
#if !UNITY_2018_3_OR_NEWER
System.Threading.Volatile.Write(ref location, value);
#elif UNITY_STANDALONE || NET_4_6
#elif UNITY_2018_3_OR_NEWER || NET_4_6
System.Threading.Volatile.Write(ref location, value);
#else
System.Threading.Thread.MemoryBarrier();
Expand All @@ -215,9 +215,9 @@ private static void VolatileWrite(ref Entry location, Entry value)

private static void VolatileWrite(ref Entry[] location, Entry[] value)
{
#if !UNITY_STANDALONE
#if !UNITY_2018_3_OR_NEWER
System.Threading.Volatile.Write(ref location, value);
#elif UNITY_STANDALONE || NET_4_6
#elif UNITY_2018_3_OR_NEWER || NET_4_6
System.Threading.Volatile.Write(ref location, value);
#else
System.Threading.Thread.MemoryBarrier();
Expand Down
@@ -1,7 +1,7 @@
// Copyright (c) All contributors. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

#if !UNITY_STANDALONE
#if !UNITY_2018_3_OR_NEWER

using System;
using System.Runtime.CompilerServices;
Expand Down
@@ -1,7 +1,7 @@
// Copyright (c) All contributors. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

#if !UNITY_STANDALONE
#if !UNITY_2018_3_OR_NEWER

using System;
using System.Buffers;
Expand Down
Expand Up @@ -7,7 +7,7 @@ namespace MessagePack.LZ4
{
internal partial class LZ4Codec
{
#if UNITY_STANDALONE
#if UNITY_2018_3_OR_NEWER

// use 'Safe' code for Unity because in IL2CPP gots strange behaviour.

Expand Down
Expand Up @@ -321,7 +321,7 @@ private static void ToJsonCore(ref MessagePackReader reader, TextWriter writer)
writer.Write(dt.ToString("o", CultureInfo.InvariantCulture));
writer.Write("\"");
}
#if !UNITY_STANDALONE
#if !UNITY_2018_3_OR_NEWER
else if (extHeader.TypeCode == TypelessFormatter.ExtensionTypeCode)
{
// prepare type name token
Expand Down
@@ -1,7 +1,7 @@
// Copyright (c) All contributors. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

#if !UNITY_STANDALONE
#if !UNITY_2018_3_OR_NEWER

using System;
using System.IO;
Expand Down

0 comments on commit 3d26901

Please sign in to comment.