Fix embedded types being generated in resolver by AlanLiu90 · Pull Request #2000 · MessagePack-CSharp/MessagePack-CSharp · GitHub
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/MessagePack.SourceGenerator/CodeAnalysis/TypeCollector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,10 @@ static FormatterCache()

private static class GeneratedMessagePackResolverGetFormatterHelper
{
private static readonly global::System.Collections.Generic.Dictionary<global::System.Type, int> closedTypeLookup = new global::System.Collections.Generic.Dictionary<global::System.Type, int>(3)
private static readonly global::System.Collections.Generic.Dictionary<global::System.Type, int> closedTypeLookup = new global::System.Collections.Generic.Dictionary<global::System.Type, int>(2)
{
{ typeof(global::System.Int32[][]), 0 },
{ typeof(global::System.Int32[]), 1 },
{ typeof(global::ContainerObject), 2 },
{ typeof(global::ContainerObject), 1 },
};

internal static object GetFormatter(global::System.Type t)
Expand All @@ -53,8 +52,7 @@ internal static object GetFormatter(global::System.Type t)
switch (closedKey)
{
case 0: return new MsgPack::Formatters.ArrayFormatter<global::System.Int32[]>();
case 1: return new MsgPack::Formatters.ArrayFormatter<global::System.Int32>();
case 2: return new global::MessagePack.GeneratedMessagePackResolver.ContainerObjectFormatter();
case 1: return new global::MessagePack.GeneratedMessagePackResolver.ContainerObjectFormatter();
default: return null; // unreachable
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,12 @@ static FormatterCache()

private static class GeneratedMessagePackResolverGetFormatterHelper
{
private static readonly global::System.Collections.Generic.Dictionary<global::System.Type, int> closedTypeLookup = new global::System.Collections.Generic.Dictionary<global::System.Type, int>(5)
private static readonly global::System.Collections.Generic.Dictionary<global::System.Type, int> closedTypeLookup = new global::System.Collections.Generic.Dictionary<global::System.Type, int>(4)
{
{ typeof(global::System.Int32[]), 0 },
{ typeof(global::System.Collections.Generic.IEnumerable<global::System.Guid>), 1 },
{ typeof(global::TempProject.Wrapper<global::System.Collections.Generic.IEnumerable<global::System.Guid>>), 2 },
{ typeof(global::TempProject.Wrapper<int[]>), 3 },
{ typeof(global::TempProject.Wrapper<string>), 4 },
{ typeof(global::System.Collections.Generic.IEnumerable<global::System.Guid>), 0 },
{ typeof(global::TempProject.Wrapper<global::System.Collections.Generic.IEnumerable<global::System.Guid>>), 1 },
{ typeof(global::TempProject.Wrapper<int[]>), 2 },
{ typeof(global::TempProject.Wrapper<string>), 3 },
};
private static readonly global::System.Collections.Generic.Dictionary<global::System.Type, int> openTypeLookup = new global::System.Collections.Generic.Dictionary<global::System.Type, int>(1)
{
Expand All @@ -58,11 +57,10 @@ internal static object GetFormatter(global::System.Type t)
{
switch (closedKey)
{
case 0: return new MsgPack::Formatters.ArrayFormatter<global::System.Int32>();
case 1: return new MsgPack::Formatters.InterfaceEnumerableFormatter<global::System.Guid>();
case 2: return new global::MessagePack.GeneratedMessagePackResolver.TempProject.WrapperFormatter<global::System.Collections.Generic.IEnumerable<global::System.Guid>>();
case 3: return new global::MessagePack.GeneratedMessagePackResolver.TempProject.WrapperFormatter<int[]>();
case 4: return new global::MessagePack.GeneratedMessagePackResolver.TempProject.WrapperFormatter<string>();
case 0: return new MsgPack::Formatters.InterfaceEnumerableFormatter<global::System.Guid>();
case 1: return new global::MessagePack.GeneratedMessagePackResolver.TempProject.WrapperFormatter<global::System.Collections.Generic.IEnumerable<global::System.Guid>>();
case 2: return new global::MessagePack.GeneratedMessagePackResolver.TempProject.WrapperFormatter<int[]>();
case 3: return new global::MessagePack.GeneratedMessagePackResolver.TempProject.WrapperFormatter<string>();
default: return null; // unreachable
};
}
Expand Down