Skip to content

Commit 815456f

Browse files
separate file, RuntimeTypeHandlerEqualityComparere.cs
1 parent 779bcaf commit 815456f

File tree

3 files changed

+37
-25
lines changed

3 files changed

+37
-25
lines changed

src/MessagePack.GeneratorCore/Utils/PseudoCompilation.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -401,8 +401,13 @@ private static string NormalizeDirectorySeparators(string path)
401401

402402
private static IEnumerable<string> GetCompileFullPaths(XElement compile, string includeOrRemovePattern, string csProjRoot)
403403
{
404+
if (string.IsNullOrEmpty(csProjRoot))
405+
{
406+
csProjRoot = "./";
407+
}
408+
404409
// solve macro
405-
includeOrRemovePattern = includeOrRemovePattern.Replace("$(ProjectDir)", csProjRoot);
410+
includeOrRemovePattern = includeOrRemovePattern.Replace("$(ProjectDir)", csProjRoot).Replace("$(MSBuildProjectDirectory)", csProjRoot);
406411

407412
var matcher = new Matcher(StringComparison.OrdinalIgnoreCase);
408413
matcher.AddIncludePatterns(includeOrRemovePattern.Split(';'));
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// Copyright (c) All contributors. All rights reserved.
2+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
3+
4+
using System;
5+
using System.Collections.Generic;
6+
7+
namespace MessagePack.Internal
8+
{
9+
// This code is used in generated code so must be public.
10+
11+
// RuntimeTypeHandle can embed directly by OpCodes.Ldtoken
12+
// It does not implements IEquatable<T>(but GetHashCode and Equals is implemented) so needs this to avoid boxing.
13+
public class RuntimeTypeHandleEqualityComparer : IEqualityComparer<RuntimeTypeHandle>
14+
{
15+
public static readonly IEqualityComparer<RuntimeTypeHandle> Default = new RuntimeTypeHandleEqualityComparer();
16+
17+
private RuntimeTypeHandleEqualityComparer()
18+
{
19+
}
20+
21+
public bool Equals(RuntimeTypeHandle x, RuntimeTypeHandle y)
22+
{
23+
return x.Equals(y);
24+
}
25+
26+
public int GetHashCode(RuntimeTypeHandle obj)
27+
{
28+
return obj.GetHashCode();
29+
}
30+
}
31+
}

src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Resolvers/DynamicUnionResolver.cs

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -480,30 +480,6 @@ private static class MessagePackWriterTypeInfo
480480
internal static readonly MethodInfo WriteNil = typeof(MessagePackWriter).GetRuntimeMethod(nameof(MessagePackWriter.WriteNil), Type.EmptyTypes);
481481
}
482482
}
483-
}
484-
485-
namespace MessagePack.Internal
486-
{
487-
// RuntimeTypeHandle can embed directly by OpCodes.Ldtoken
488-
// It does not implements IEquatable<T>(but GetHashCode and Equals is implemented) so needs this to avoid boxing.
489-
public class RuntimeTypeHandleEqualityComparer : IEqualityComparer<RuntimeTypeHandle>
490-
{
491-
public static readonly IEqualityComparer<RuntimeTypeHandle> Default = new RuntimeTypeHandleEqualityComparer();
492-
493-
private RuntimeTypeHandleEqualityComparer()
494-
{
495-
}
496-
497-
public bool Equals(RuntimeTypeHandle x, RuntimeTypeHandle y)
498-
{
499-
return x.Equals(y);
500-
}
501-
502-
public int GetHashCode(RuntimeTypeHandle obj)
503-
{
504-
return obj.GetHashCode();
505-
}
506-
}
507483

508484
internal class MessagePackDynamicUnionResolverException : MessagePackSerializationException
509485
{

0 commit comments

Comments
 (0)