From a8eba9573a4b62f829324764bfb8133ea0f30672 Mon Sep 17 00:00:00 2001 From: y-sasaki <11359025+Y-YoL@users.noreply.github.com> Date: Fri, 2 Dec 2022 21:39:51 +0900 Subject: [PATCH 001/660] Change globa.json rollForward to feature --- global.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/global.json b/global.json index 954a92e75..9d800d823 100644 --- a/global.json +++ b/global.json @@ -1,7 +1,7 @@ { "sdk": { "version": "6.0.300", - "rollForward": "patch", + "rollForward": "feature", "allowPrerelease": false } } From fe3c6e5340fbcf076266abd0d3c5286c92c82645 Mon Sep 17 00:00:00 2001 From: y-sasaki <11359025+Y-YoL@users.noreply.github.com> Date: Mon, 19 Dec 2022 20:58:12 +0900 Subject: [PATCH 002/660] Change generator project setting - remove project dependency - update dependency package version --- .../MessagePack.Generator.csproj | 86 ++++++++++++++++--- 1 file changed, 74 insertions(+), 12 deletions(-) diff --git a/src/MessagePack.Generator/MessagePack.Generator.csproj b/src/MessagePack.Generator/MessagePack.Generator.csproj index 42b02f30f..d5bb59495 100644 --- a/src/MessagePack.Generator/MessagePack.Generator.csproj +++ b/src/MessagePack.Generator/MessagePack.Generator.csproj @@ -3,13 +3,12 @@ mpc Exe - netcoreapp3.1;net6.0 - 10 + netstandard2.0 + 11 + enable enable - true - true - mpc - Major + true + cs MessagePack.Generator @@ -19,15 +18,78 @@ - - - - - + + - + + + + + + + True + True + EnumTemplate.tt + + + True + True + FormatterTemplate.tt + + + True + True + ResolverTemplate.tt + + + True + True + StringKeyFormatterTemplate.tt + + + %(FileName).tt + True + True + + + True + True + UnionTemplate.tt + + + + + + TextTemplatingFilePreprocessor + EnumTemplate.cs + MessagePackCompiler.Generator + + + TextTemplatingFilePreprocessor + FormatterTemplate.cs + MessagePackCompiler.Generator + + + TextTemplatingFilePreprocessor + ResolverTemplate.cs + MessagePackCompiler.Generator + + + TextTemplatingFilePreprocessor + StringKeyFormatterTemplate.cs + MessagePackCompiler.Generator + + + TextTemplatingFilePreprocessor + UnionTemplate.cs + MessagePackCompiler.Generator + + + + + From 539f7d7679318f998114d050d2c5eb746e6b96d9 Mon Sep 17 00:00:00 2001 From: y-sasaki <11359025+Y-YoL@users.noreply.github.com> Date: Mon, 19 Dec 2022 21:35:18 +0900 Subject: [PATCH 003/660] Add dependency reference --- src/MessagePack.Generator/MessagePack.Generator.csproj | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/MessagePack.Generator/MessagePack.Generator.csproj b/src/MessagePack.Generator/MessagePack.Generator.csproj index d5bb59495..e97461f3e 100644 --- a/src/MessagePack.Generator/MessagePack.Generator.csproj +++ b/src/MessagePack.Generator/MessagePack.Generator.csproj @@ -1,8 +1,6 @@  - mpc - Exe netstandard2.0 11 enable @@ -20,11 +18,16 @@ + + + + + From ceefa17010a1397ccbedd8f9c1dfcd0efd24fdf2 Mon Sep 17 00:00:00 2001 From: y-sasaki <11359025+Y-YoL@users.noreply.github.com> Date: Mon, 19 Dec 2022 21:38:23 +0900 Subject: [PATCH 004/660] Replace Generator --- .../IGeneratorContext.cs | 11 ++ .../MessagepackCompiler.cs | 108 --------------- .../MessagepackGenerator.Emit.cs | 108 +++++++++++++++ .../MessagepackGenerator.cs | 128 ++++++++++++++++++ .../CodeAnalysis/TypeCollector.cs | 35 ++++- 5 files changed, 280 insertions(+), 110 deletions(-) create mode 100644 src/MessagePack.Generator/IGeneratorContext.cs delete mode 100644 src/MessagePack.Generator/MessagepackCompiler.cs create mode 100644 src/MessagePack.Generator/MessagepackGenerator.Emit.cs create mode 100644 src/MessagePack.Generator/MessagepackGenerator.cs diff --git a/src/MessagePack.Generator/IGeneratorContext.cs b/src/MessagePack.Generator/IGeneratorContext.cs new file mode 100644 index 000000000..b4fe9f3a8 --- /dev/null +++ b/src/MessagePack.Generator/IGeneratorContext.cs @@ -0,0 +1,11 @@ +// Copyright (c) All contributors. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +namespace MessagePack.Generator; + +public interface IGeneratorContext +{ + CancellationToken CancellationToken { get; } + + void AddSource(string hintName, string source); +} diff --git a/src/MessagePack.Generator/MessagepackCompiler.cs b/src/MessagePack.Generator/MessagepackCompiler.cs deleted file mode 100644 index dfea81961..000000000 --- a/src/MessagePack.Generator/MessagepackCompiler.cs +++ /dev/null @@ -1,108 +0,0 @@ -// Copyright (c) All contributors. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - -using System; -using System.Collections.Generic; -using System.IO; -using System.Runtime.Loader; -using System.Threading; -using System.Threading.Tasks; -using ConsoleAppFramework; -using Microsoft.Build.Locator; -using Microsoft.Build.Logging; -using Microsoft.CodeAnalysis; -using Microsoft.CodeAnalysis.CSharp; -using Microsoft.CodeAnalysis.MSBuild; -using Microsoft.Extensions.Hosting; - -namespace MessagePack.Generator -{ - public class MessagepackCompiler : ConsoleAppBase - { - private static async Task Main(string[] args) - { - var instance = MSBuildLocator.RegisterDefaults(); - AssemblyLoadContext.Default.Resolving += (assemblyLoadContext, assemblyName) => - { - var path = Path.Combine(instance.MSBuildPath, assemblyName.Name + ".dll"); - if (File.Exists(path)) - { - return assemblyLoadContext.LoadFromAssemblyPath(path); - } - - return null; - }; - - await Host.CreateDefaultBuilder() - .ConfigureLogging(logging => logging.ReplaceToSimpleConsole()) - .RunConsoleAppFrameworkAsync(args); - } - - public async Task RunAsync( - [Option("i", "Input path to MSBuild project file or the directory containing Unity source files.")] string input, - [Option("o", "Output file path(.cs) or directory (multiple generate file).")] string output, - [Option("c", "Conditional compiler symbols, split with ','. Ignored if a project file is specified for input.")] string? conditionalSymbol = null, - [Option("r", "Set resolver name.")] string resolverName = "GeneratedResolver", - [Option("n", "Set namespace root name.")] string @namespace = "MessagePack", - [Option("m", "Force use map mode serialization.")] bool useMapMode = false, - [Option("ms", "Generate #if-- files by symbols, split with ','.")] string? multipleIfDirectiveOutputSymbols = null, - [Option("ei", "Ignore type names.")] string[]? externalIgnoreTypeNames = null) - { - Workspace? workspace = null; - try - { - Compilation compilation; - if (Directory.Exists(input)) - { - string[]? conditionalSymbols = conditionalSymbol?.Split(','); - compilation = await PseudoCompilation.CreateFromDirectoryAsync(input, conditionalSymbols, this.Context.CancellationToken); - } - else - { - (workspace, compilation) = await this.OpenMSBuildProjectAsync(input, this.Context.CancellationToken); - } - - await new MessagePackCompiler.CodeGenerator(x => Console.WriteLine(x), this.Context.CancellationToken) - .GenerateFileAsync( - compilation, - output, - resolverName, - @namespace, - useMapMode, - multipleIfDirectiveOutputSymbols, - externalIgnoreTypeNames).ConfigureAwait(false); - } - catch (OperationCanceledException) - { - await Console.Error.WriteLineAsync("Canceled"); - throw; - } - finally - { - workspace?.Dispose(); - } - } - - private async Task<(Workspace Workspace, Compilation Compilation)> OpenMSBuildProjectAsync(string projectPath, CancellationToken cancellationToken) - { - var workspace = MSBuildWorkspace.Create(); - try - { - var logger = new ConsoleLogger(Microsoft.Build.Framework.LoggerVerbosity.Quiet); - var project = await workspace.OpenProjectAsync(projectPath, logger, null, cancellationToken); - var compilation = await project.GetCompilationAsync(cancellationToken); - if (compilation is null) - { - throw new NotSupportedException("The project does not support creating Compilation."); - } - - return (workspace, compilation); - } - catch - { - workspace.Dispose(); - throw; - } - } - } -} diff --git a/src/MessagePack.Generator/MessagepackGenerator.Emit.cs b/src/MessagePack.Generator/MessagepackGenerator.Emit.cs new file mode 100644 index 000000000..9056748f7 --- /dev/null +++ b/src/MessagePack.Generator/MessagepackGenerator.Emit.cs @@ -0,0 +1,108 @@ +// Copyright (c) All contributors. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using System.Text; +using MessagePackCompiler.CodeAnalysis; +using MessagePackCompiler.Generator; +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.CSharp.Syntax; + +namespace MessagePack.Generator; + +public partial class MessagepackGenerator +{ + private static void Generate(TypeDeclarationSyntax syntax, Compilation compilation, IGeneratorContext context) + { + var semanticModel = compilation.GetSemanticModel(syntax.SyntaxTree); + + var typeSymbol = semanticModel.GetDeclaredSymbol(syntax, context.CancellationToken) as ITypeSymbol; + if (typeSymbol == null) + { + return; + } + + var fullType = typeSymbol.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat) + .Replace("global::", string.Empty) + .Replace("<", "_") + .Replace(">", "_"); + + var collector = new TypeCollector(compilation, true, isForceUseMap: false, ignoreTypeNames: null, typeSymbol); + + var (objectInfo, enumInfo, genericInfo, unionInfo) = collector.Collect(); + + var code = GenerateFormatterSync(string.Empty, string.Empty, objectInfo, enumInfo, unionInfo, genericInfo); + + context.AddSource($"{fullType}.MessagePackFormatter.g.cs", code); + } + + /// + /// Generates the specialized resolver and formatters for the types that require serialization in a given compilation. + /// + /// The resolver name. + /// The namespace for the generated type to be created in. + /// The ObjectSerializationInfo array which TypeCollector.Collect returns. + /// The EnumSerializationInfo array which TypeCollector.Collect returns. + /// The UnionSerializationInfo array which TypeCollector.Collect returns. + /// The GenericSerializationInfo array which TypeCollector.Collect returns. + private static string GenerateFormatterSync(string resolverName, string namespaceDot, ObjectSerializationInfo[] objectInfo, EnumSerializationInfo[] enumInfo, UnionSerializationInfo[] unionInfo, GenericSerializationInfo[] genericInfo) + { + var objectFormatterTemplates = objectInfo + .GroupBy(x => (x.Namespace, x.IsStringKey)) + .Select(x => + { + var (nameSpace, isStringKey) = x.Key; + var objectSerializationInfos = x.ToArray(); + var ns = namespaceDot + "Formatters" + (nameSpace is null ? string.Empty : "." + nameSpace); + var template = isStringKey ? new StringKeyFormatterTemplate(ns, objectSerializationInfos) : (IFormatterTemplate)new FormatterTemplate(ns, objectSerializationInfos); + return template; + }) + .ToArray(); + + string GetNamespace(IGrouping x) + { + if (x.Key == null) + { + return namespaceDot + "Formatters"; + } + + return namespaceDot + "Formatters." + x.Key; + } + + var enumFormatterTemplates = enumInfo + .GroupBy(x => x.Namespace) + .Select(x => new EnumTemplate(GetNamespace(x), x.ToArray())) + .ToArray(); + + var unionFormatterTemplates = unionInfo + .GroupBy(x => x.Namespace) + .Select(x => new UnionTemplate(GetNamespace(x), x.ToArray())) + .ToArray(); + + var resolverTemplate = new ResolverTemplate(namespaceDot + "Resolvers", namespaceDot + "Formatters", resolverName, genericInfo.Where(x => !x.IsOpenGenericType).Cast().Concat(enumInfo).Concat(unionInfo).Concat(objectInfo.Where(x => !x.IsOpenGenericType)).ToArray()); + + var sb = new StringBuilder(); + sb.AppendLine(resolverTemplate.TransformText()); + sb.AppendLine(); + foreach (var item in enumFormatterTemplates) + { + var text = item.TransformText(); + sb.AppendLine(text); + } + + sb.AppendLine(); + foreach (var item in unionFormatterTemplates) + { + var text = item.TransformText(); + sb.AppendLine(text); + } + + sb.AppendLine(); + foreach (var item in objectFormatterTemplates) + { + var text = item.TransformText(); + sb.AppendLine(text); + } + + return sb.ToString(); + } +} diff --git a/src/MessagePack.Generator/MessagepackGenerator.cs b/src/MessagePack.Generator/MessagepackGenerator.cs new file mode 100644 index 000000000..d5ff98aed --- /dev/null +++ b/src/MessagePack.Generator/MessagepackGenerator.cs @@ -0,0 +1,128 @@ +// Copyright (c) All contributors. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.CSharp.Syntax; + +namespace MessagePack.Generator; + +[Generator(LanguageNames.CSharp)] +public partial class MessagepackGenerator : IIncrementalGenerator +{ + public const string MessagePackObjectAttributeFullName = "MessagePack.MessagePackObjectAttribute"; + + public void Initialize(IncrementalGeneratorInitializationContext context) + { + var typeDeclarations = context.SyntaxProvider.ForAttributeWithMetadataName( + MessagePackObjectAttributeFullName, + predicate: static (node, _) => node is TypeDeclarationSyntax, + transform: static (context, _) => (TypeDeclarationSyntax)context.TargetNode); + + var source = typeDeclarations + .Combine(context.CompilationProvider) + .WithComparer(Comparer.Instance); + + context.RegisterSourceOutput(source, static (context, source) => + { + var (typeDeclaration, compilation) = source; + Generate(typeDeclaration, compilation, new GeneratorContext(context)); + }); + } + + private class Comparer : IEqualityComparer<(TypeDeclarationSyntax, Compilation)> + { + public static readonly Comparer Instance = new Comparer(); + + public bool Equals((TypeDeclarationSyntax, Compilation) x, (TypeDeclarationSyntax, Compilation) y) + { + return x.Item1.Equals(y.Item1); + } + + public int GetHashCode((TypeDeclarationSyntax, Compilation) obj) + { + return obj.Item1.GetHashCode(); + } + } + + private class GeneratorContext : IGeneratorContext + { + private SourceProductionContext context; + + public GeneratorContext(SourceProductionContext context) + { + this.context = context; + } + + public CancellationToken CancellationToken => context.CancellationToken; + + public void AddSource(string hintName, string source) => context.AddSource(hintName, source); + } + +#if false + public async Task RunAsync( + [Option("i", "Input path to MSBuild project file or the directory containing Unity source files.")] string input, + [Option("o", "Output file path(.cs) or directory (multiple generate file).")] string output, + [Option("c", "Conditional compiler symbols, split with ','. Ignored if a project file is specified for input.")] string? conditionalSymbol = null, + [Option("r", "Set resolver name.")] string resolverName = "GeneratedResolver", + [Option("n", "Set namespace root name.")] string @namespace = "MessagePack", + [Option("m", "Force use map mode serialization.")] bool useMapMode = false, + [Option("ms", "Generate #if-- files by symbols, split with ','.")] string? multipleIfDirectiveOutputSymbols = null, + [Option("ei", "Ignore type names.")] string[]? externalIgnoreTypeNames = null) + { + try + { + Compilation compilation; + if (Directory.Exists(input)) + { + string[]? conditionalSymbols = conditionalSymbol?.Split(','); + compilation = await PseudoCompilation.CreateFromDirectoryAsync(input, conditionalSymbols, this.Context.CancellationToken); + } + else + { + (workspace, compilation) = await this.OpenMSBuildProjectAsync(input, this.Context.CancellationToken); + } + + await new MessagePackCompiler.CodeGenerator(x => Console.WriteLine(x), this.Context.CancellationToken) + .GenerateFileAsync( + compilation, + output, + resolverName, + @namespace, + useMapMode, + multipleIfDirectiveOutputSymbols, + externalIgnoreTypeNames).ConfigureAwait(false); + } + catch (OperationCanceledException) + { + await Console.Error.WriteLineAsync("Canceled"); + throw; + } + finally + { + workspace?.Dispose(); + } + } + + private async Task<(Workspace Workspace, Compilation Compilation)> OpenMSBuildProjectAsync(string projectPath, CancellationToken cancellationToken) + { + var workspace = MSBuildWorkspace.Create(); + try + { + var logger = new ConsoleLogger(Microsoft.Build.Framework.LoggerVerbosity.Quiet); + var project = await workspace.OpenProjectAsync(projectPath, logger, null, cancellationToken); + var compilation = await project.GetCompilationAsync(cancellationToken); + if (compilation is null) + { + throw new NotSupportedException("The project does not support creating Compilation."); + } + + return (workspace, compilation); + } + catch + { + workspace.Dispose(); + throw; + } + } +#endif +} diff --git a/src/MessagePack.GeneratorCore/CodeAnalysis/TypeCollector.cs b/src/MessagePack.GeneratorCore/CodeAnalysis/TypeCollector.cs index da68130aa..9f7fd8c0f 100644 --- a/src/MessagePack.GeneratorCore/CodeAnalysis/TypeCollector.cs +++ b/src/MessagePack.GeneratorCore/CodeAnalysis/TypeCollector.cs @@ -91,7 +91,7 @@ public class TypeCollector private readonly bool isForceUseMap; private readonly ReferenceSymbols typeReferences; - private readonly INamedTypeSymbol[] targetTypes; + private readonly ITypeSymbol[] targetTypes; private readonly HashSet embeddedTypes = new(new[] { "short", @@ -285,6 +285,37 @@ public TypeCollector(Compilation compilation, bool disallowInternal, bool isForc .ToArray(); } + public TypeCollector(Compilation compilation, bool disallowInternal, bool isForceUseMap, string[]? ignoreTypeNames, ITypeSymbol targetType) + { + this.typeReferences = new ReferenceSymbols(compilation, _ => { }); + this.disallowInternal = disallowInternal; + this.isForceUseMap = isForceUseMap; + this.externalIgnoreTypeNames = new HashSet(ignoreTypeNames ?? Array.Empty()); + this.compilation = compilation; + + targetTypes = new[] { targetType } + .Where(x => + { + if (x.DeclaredAccessibility == Accessibility.Public) + { + return true; + } + + if (!disallowInternal) + { + return x.DeclaredAccessibility == Accessibility.Friend; + } + + return false; + }) + .Where(x => + ((x.TypeKind == TypeKind.Interface) && x.GetAttributes().Any(x2 => x2.AttributeClass.ApproximatelyEqual(typeReferences.UnionAttribute))) + || ((x.TypeKind == TypeKind.Class && x.IsAbstract) && x.GetAttributes().Any(x2 => x2.AttributeClass.ApproximatelyEqual(typeReferences.UnionAttribute))) + || ((x.TypeKind == TypeKind.Class) && x.GetAttributes().Any(x2 => x2.AttributeClass.ApproximatelyEqual(typeReferences.MessagePackObjectAttribute))) + || ((x.TypeKind == TypeKind.Struct) && x.GetAttributes().Any(x2 => x2.AttributeClass.ApproximatelyEqual(typeReferences.MessagePackObjectAttribute)))) + .ToArray(); + } + private void ResetWorkspace() { this.alreadyCollected.Clear(); @@ -299,7 +330,7 @@ private void ResetWorkspace() { this.ResetWorkspace(); - foreach (INamedTypeSymbol item in this.targetTypes) + foreach (var item in this.targetTypes) { this.CollectCore(item); } From 9f695cc822420fa45e3c453a8b97c83aa888a705 Mon Sep 17 00:00:00 2001 From: y-sasaki <11359025+Y-YoL@users.noreply.github.com> Date: Mon, 19 Dec 2022 23:37:45 +0900 Subject: [PATCH 005/660] Replace GeneratedResolver to ModuleInitializer --- .../MessagepackGenerator.Emit.cs | 41 +++++++++++++++++-- .../Resolvers/StaticCompositeResolver.cs | 21 ++++++++++ 2 files changed, 58 insertions(+), 4 deletions(-) diff --git a/src/MessagePack.Generator/MessagepackGenerator.Emit.cs b/src/MessagePack.Generator/MessagepackGenerator.Emit.cs index 9056748f7..921521551 100644 --- a/src/MessagePack.Generator/MessagepackGenerator.Emit.cs +++ b/src/MessagePack.Generator/MessagepackGenerator.Emit.cs @@ -78,14 +78,11 @@ string GetNamespace(IGrouping x) .Select(x => new UnionTemplate(GetNamespace(x), x.ToArray())) .ToArray(); - var resolverTemplate = new ResolverTemplate(namespaceDot + "Resolvers", namespaceDot + "Formatters", resolverName, genericInfo.Where(x => !x.IsOpenGenericType).Cast().Concat(enumInfo).Concat(unionInfo).Concat(objectInfo.Where(x => !x.IsOpenGenericType)).ToArray()); - var sb = new StringBuilder(); - sb.AppendLine(resolverTemplate.TransformText()); - sb.AppendLine(); foreach (var item in enumFormatterTemplates) { var text = item.TransformText(); + ResolverText(sb, item.Namespace, item.EnumSerializationInfos.Select(x => x.Name)); sb.AppendLine(text); } @@ -93,6 +90,7 @@ string GetNamespace(IGrouping x) foreach (var item in unionFormatterTemplates) { var text = item.TransformText(); + ResolverText(sb, item.Namespace, item.UnionSerializationInfos.Select(x => x.Name)); sb.AppendLine(text); } @@ -100,9 +98,44 @@ string GetNamespace(IGrouping x) foreach (var item in objectFormatterTemplates) { var text = item.TransformText(); + ResolverText(sb, item.Namespace, item.ObjectSerializationInfos.Select(x => x.Name)); sb.AppendLine(text); } return sb.ToString(); } + + private static void ResolverText(StringBuilder sb, string ns, IEnumerable names) + { + var begin = $$""" +using System.Runtime.CompilerServices; + +namespace {{ns}} +{ + partial class FormatterRegister + { +"""; + + var end = $$""" + } +} +"""; + + sb.AppendLine(begin); + + foreach (var item in names) + { + var code = $$""" + + [ModuleInitializer] + internal static void {{item}}FormatterRegister() + { + MessagePack.Resolvers.StaticCompositeResolver.Instance.AddGeneratedFormatter(new global::{{ns}}.{{item}}Formatter()); + } +"""; + sb.AppendLine(code); + } + + sb.AppendLine(end); + } } diff --git a/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Resolvers/StaticCompositeResolver.cs b/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Resolvers/StaticCompositeResolver.cs index 8d8037bc2..441eff7f2 100644 --- a/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Resolvers/StaticCompositeResolver.cs +++ b/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Resolvers/StaticCompositeResolver.cs @@ -2,6 +2,7 @@ // Licensed under the MIT license. See LICENSE file in the project root for full license information. using System; +using System.Collections.Concurrent; using System.Collections.Generic; using MessagePack.Formatters; @@ -15,6 +16,7 @@ public class StaticCompositeResolver : IFormatterResolver public static readonly StaticCompositeResolver Instance = new StaticCompositeResolver(); private bool freezed; + private ConcurrentBag generatedFormatters = new ConcurrentBag(); private IReadOnlyList formatters; private IReadOnlyList resolvers; @@ -108,6 +110,16 @@ public void Register(IReadOnlyList formatters, IReadOnlyL this.resolvers = resolvers; } + public void AddGeneratedFormatter(IMessagePackFormatter formatter) + { + if (this.freezed) + { + throw new InvalidOperationException("Register must call on startup(before use GetFormatter)."); + } + + this.generatedFormatters.Add(formatter); + } + /// /// Gets an instance that can serialize or deserialize some type . /// @@ -125,6 +137,15 @@ private static class Cache static Cache() { Instance.freezed = true; + foreach (var item in Instance.generatedFormatters) + { + if (item is IMessagePackFormatter f) + { + Formatter = f; + return; + } + } + foreach (var item in Instance.formatters) { if (item is IMessagePackFormatter f) From 4db43421949fe26f779347b6ce1c20f1a3af9406 Mon Sep 17 00:00:00 2001 From: y-sasaki <11359025+Y-YoL@users.noreply.github.com> Date: Thu, 22 Dec 2022 21:40:26 +0900 Subject: [PATCH 006/660] Add Generator.Roslyn3 csproj --- MessagePack.sln | 11 +- .../.editorconfig | 4 + .../MessagePack.Generator.Roslyn3.csproj | 103 ++++++++ .../MessagepackGenerator.cs | 82 ++++++ .../MessagepackGenerator.cs | 68 ----- .../PseudoCompilation.cs | 235 ------------------ 6 files changed, 198 insertions(+), 305 deletions(-) create mode 100644 src/MessagePack.Generator.Roslyn3/.editorconfig create mode 100644 src/MessagePack.Generator.Roslyn3/MessagePack.Generator.Roslyn3.csproj create mode 100644 src/MessagePack.Generator.Roslyn3/MessagepackGenerator.cs delete mode 100644 src/MessagePack.Generator/PseudoCompilation.cs diff --git a/MessagePack.sln b/MessagePack.sln index 77d762b8a..d13f47aa6 100644 --- a/MessagePack.sln +++ b/MessagePack.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.29108.181 +# Visual Studio Version 17 +VisualStudioVersion = 17.4.33103.184 MinimumVisualStudioVersion = 10.0.40219.1 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{86309CF6-0054-4CE3-BFD3-CA0AA7DB17BC}" EndProject @@ -88,6 +88,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MessagePack.Experimental.Te EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MessagePack.GeneratedCode.Tests", "tests\MessagePack.GeneratedCode.Tests\MessagePack.GeneratedCode.Tests.csproj", "{D4CE7347-CEBE-46E5-BD12-1319573B6C5E}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MessagePack.Generator.Roslyn3", "src\MessagePack.Generator.Roslyn3\MessagePack.Generator.Roslyn3.csproj", "{45A72780-93EF-4CD1-9FCD-D56A42A3B966}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -202,6 +204,10 @@ Global {D4CE7347-CEBE-46E5-BD12-1319573B6C5E}.Debug|Any CPU.Build.0 = Debug|Any CPU {D4CE7347-CEBE-46E5-BD12-1319573B6C5E}.Release|Any CPU.ActiveCfg = Release|Any CPU {D4CE7347-CEBE-46E5-BD12-1319573B6C5E}.Release|Any CPU.Build.0 = Release|Any CPU + {45A72780-93EF-4CD1-9FCD-D56A42A3B966}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {45A72780-93EF-4CD1-9FCD-D56A42A3B966}.Debug|Any CPU.Build.0 = Debug|Any CPU + {45A72780-93EF-4CD1-9FCD-D56A42A3B966}.Release|Any CPU.ActiveCfg = Release|Any CPU + {45A72780-93EF-4CD1-9FCD-D56A42A3B966}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -234,6 +240,7 @@ Global {AC2503A7-736D-4AE6-9355-CF35D9DF6139} = {86309CF6-0054-4CE3-BFD3-CA0AA7DB17BC} {8AB40D1C-1134-4D77-B39A-19AEDC729450} = {19FE674A-AC94-4E7E-B24C-2285D1D04CDE} {D4CE7347-CEBE-46E5-BD12-1319573B6C5E} = {19FE674A-AC94-4E7E-B24C-2285D1D04CDE} + {45A72780-93EF-4CD1-9FCD-D56A42A3B966} = {86309CF6-0054-4CE3-BFD3-CA0AA7DB17BC} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {B3911209-2DBF-47F8-98F6-BBC0EDFE63DE} diff --git a/src/MessagePack.Generator.Roslyn3/.editorconfig b/src/MessagePack.Generator.Roslyn3/.editorconfig new file mode 100644 index 000000000..6b835fc65 --- /dev/null +++ b/src/MessagePack.Generator.Roslyn3/.editorconfig @@ -0,0 +1,4 @@ +[*.cs] + +# VSTHRD111: Use ConfigureAwait(bool) +dotnet_diagnostic.VSTHRD111.severity = none diff --git a/src/MessagePack.Generator.Roslyn3/MessagePack.Generator.Roslyn3.csproj b/src/MessagePack.Generator.Roslyn3/MessagePack.Generator.Roslyn3.csproj new file mode 100644 index 000000000..e6138e486 --- /dev/null +++ b/src/MessagePack.Generator.Roslyn3/MessagePack.Generator.Roslyn3.csproj @@ -0,0 +1,103 @@ + + + + netstandard2.0 + 11 + enable + enable + ROSLYN3 + true + cs + + + MessagePack.Generator + MessagePack Code Generator + MessagePack standalone code generator. + MsgPack;MessagePack;Serialization;Formatter;Serializer;Unity;Xamarin + + + + + + + + + + + + + + + + + + + + + + + + True + True + EnumTemplate.tt + + + True + True + FormatterTemplate.tt + + + True + True + ResolverTemplate.tt + + + True + True + StringKeyFormatterTemplate.tt + + + %(FileName).tt + True + True + + + True + True + UnionTemplate.tt + + + + + + TextTemplatingFilePreprocessor + EnumTemplate.cs + MessagePackCompiler.Generator + + + TextTemplatingFilePreprocessor + FormatterTemplate.cs + MessagePackCompiler.Generator + + + TextTemplatingFilePreprocessor + ResolverTemplate.cs + MessagePackCompiler.Generator + + + TextTemplatingFilePreprocessor + StringKeyFormatterTemplate.cs + MessagePackCompiler.Generator + + + TextTemplatingFilePreprocessor + UnionTemplate.cs + MessagePackCompiler.Generator + + + + + + + + diff --git a/src/MessagePack.Generator.Roslyn3/MessagepackGenerator.cs b/src/MessagePack.Generator.Roslyn3/MessagepackGenerator.cs new file mode 100644 index 000000000..316f914b3 --- /dev/null +++ b/src/MessagePack.Generator.Roslyn3/MessagepackGenerator.cs @@ -0,0 +1,82 @@ +// Copyright (c) All contributors. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.CSharp.Syntax; + +namespace MessagePack.Generator; + +[Generator(LanguageNames.CSharp)] +public partial class MessagepackGenerator : ISourceGenerator +{ + public const string MessagePackObjectAttributeFullName = "MessagePack.MessagePackObjectAttribute"; + + public void Initialize(GeneratorInitializationContext context) + { + context.RegisterForSyntaxNotifications(SyntaxContextReceiver.Create); + } + + public void Execute(GeneratorExecutionContext context) + { + if (context.SyntaxContextReceiver is not SyntaxContextReceiver receiver || receiver.ClassDeclarations.Count == 0) + { + return; + } + + var compiation = context.Compilation; + var generateContext = new GeneratorContext(context); + + foreach (var syntax in receiver.ClassDeclarations) + { + Generate(syntax, compiation, generateContext); + } + } + + private class SyntaxContextReceiver : ISyntaxContextReceiver + { + internal static ISyntaxContextReceiver Create() + { + return new SyntaxContextReceiver(); + } + + public HashSet ClassDeclarations { get; } = new(); + + public void OnVisitSyntaxNode(GeneratorSyntaxContext context) + { + if (context.Node is TypeDeclarationSyntax typeSyntax) + { + if (typeSyntax.AttributeLists.Count > 0) + { + var hasAttribute = typeSyntax.AttributeLists + .SelectMany(x => x.Attributes) + .Any(x => x.Name.ToString() is "MessagePackObject" + or "MessagePackObjectAttribute" + or "MessagePack.MessagePackObject" + or "MessagePack.MessagePackObjectAttribute" + or "Union" + or "UnionAttribute" + or "MessagePack.Union" + or "MessagePack.UnionAttribute"); + if (hasAttribute) + { + ClassDeclarations.Add(typeSyntax); + } + } + } + } + } + + private class GeneratorContext : IGeneratorContext + { + private GeneratorExecutionContext context; + + public GeneratorContext(GeneratorExecutionContext context) + { + this.context = context; + } + + public CancellationToken CancellationToken => context.CancellationToken; + + public void AddSource(string hintName, string source) => context.AddSource(hintName, source); + } +} diff --git a/src/MessagePack.Generator/MessagepackGenerator.cs b/src/MessagePack.Generator/MessagepackGenerator.cs index d5ff98aed..c5344dcf5 100644 --- a/src/MessagePack.Generator/MessagepackGenerator.cs +++ b/src/MessagePack.Generator/MessagepackGenerator.cs @@ -57,72 +57,4 @@ public GeneratorContext(SourceProductionContext context) public void AddSource(string hintName, string source) => context.AddSource(hintName, source); } - -#if false - public async Task RunAsync( - [Option("i", "Input path to MSBuild project file or the directory containing Unity source files.")] string input, - [Option("o", "Output file path(.cs) or directory (multiple generate file).")] string output, - [Option("c", "Conditional compiler symbols, split with ','. Ignored if a project file is specified for input.")] string? conditionalSymbol = null, - [Option("r", "Set resolver name.")] string resolverName = "GeneratedResolver", - [Option("n", "Set namespace root name.")] string @namespace = "MessagePack", - [Option("m", "Force use map mode serialization.")] bool useMapMode = false, - [Option("ms", "Generate #if-- files by symbols, split with ','.")] string? multipleIfDirectiveOutputSymbols = null, - [Option("ei", "Ignore type names.")] string[]? externalIgnoreTypeNames = null) - { - try - { - Compilation compilation; - if (Directory.Exists(input)) - { - string[]? conditionalSymbols = conditionalSymbol?.Split(','); - compilation = await PseudoCompilation.CreateFromDirectoryAsync(input, conditionalSymbols, this.Context.CancellationToken); - } - else - { - (workspace, compilation) = await this.OpenMSBuildProjectAsync(input, this.Context.CancellationToken); - } - - await new MessagePackCompiler.CodeGenerator(x => Console.WriteLine(x), this.Context.CancellationToken) - .GenerateFileAsync( - compilation, - output, - resolverName, - @namespace, - useMapMode, - multipleIfDirectiveOutputSymbols, - externalIgnoreTypeNames).ConfigureAwait(false); - } - catch (OperationCanceledException) - { - await Console.Error.WriteLineAsync("Canceled"); - throw; - } - finally - { - workspace?.Dispose(); - } - } - - private async Task<(Workspace Workspace, Compilation Compilation)> OpenMSBuildProjectAsync(string projectPath, CancellationToken cancellationToken) - { - var workspace = MSBuildWorkspace.Create(); - try - { - var logger = new ConsoleLogger(Microsoft.Build.Framework.LoggerVerbosity.Quiet); - var project = await workspace.OpenProjectAsync(projectPath, logger, null, cancellationToken); - var compilation = await project.GetCompilationAsync(cancellationToken); - if (compilation is null) - { - throw new NotSupportedException("The project does not support creating Compilation."); - } - - return (workspace, compilation); - } - catch - { - workspace.Dispose(); - throw; - } - } -#endif } diff --git a/src/MessagePack.Generator/PseudoCompilation.cs b/src/MessagePack.Generator/PseudoCompilation.cs deleted file mode 100644 index 80d5a1ed2..000000000 --- a/src/MessagePack.Generator/PseudoCompilation.cs +++ /dev/null @@ -1,235 +0,0 @@ -// Copyright (c) All contributors. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Runtime.Serialization; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -using Microsoft.CodeAnalysis; -using Microsoft.CodeAnalysis.CSharp; -using Microsoft.CodeAnalysis.CSharp.Syntax; - -namespace MessagePack.Generator -{ - internal static class PseudoCompilation - { - internal static async Task CreateFromDirectoryAsync(string directoryRoot, IEnumerable? preprocessorSymbols, CancellationToken cancellationToken) - { - var parseOption = new CSharpParseOptions(LanguageVersion.Latest, DocumentationMode.Parse, SourceCodeKind.Regular, CleanPreprocessorSymbols(preprocessorSymbols)); - - var syntaxTrees = new List(); - var hasAnnotations = false; - foreach (var file in IterateCsFileWithoutBinObj(directoryRoot)) - { - var text = File.ReadAllText(NormalizeDirectorySeparators(file), Encoding.UTF8); - var syntax = CSharpSyntaxTree.ParseText(text, parseOption); - syntaxTrees.Add(syntax); - if (Path.GetFileNameWithoutExtension(file) == "Attributes") - { - var root = await syntax.GetRootAsync(cancellationToken).ConfigureAwait(false); - if (root.DescendantNodes().OfType().Any(x => x.Identifier.Text == "MessagePackObjectAttribute")) - { - hasAnnotations = true; - } - } - } - - if (!hasAnnotations) - { - syntaxTrees.Add(CSharpSyntaxTree.ParseText(DummyAnnotation, parseOption)); - } - - var metadata = GetStandardReferences().Select(x => MetadataReference.CreateFromFile(x)).ToArray(); - - var compilation = CSharpCompilation.Create( - "CodeGenTemp", - syntaxTrees, - DistinctReference(metadata), - new CSharpCompilationOptions(OutputKind.DynamicallyLinkedLibrary, allowUnsafe: true)); - - return compilation; - } - - private static IEnumerable DistinctReference(IEnumerable metadataReferences) - { - var set = new HashSet(); - foreach (var item in metadataReferences) - { - if (item.Display is object && set.Add(Path.GetFileName(item.Display))) - { - yield return item; - } - } - } - - private static List GetStandardReferences() - { - var standardMetadataType = new[] - { - typeof(object), - typeof(Attribute), - typeof(Enumerable), - typeof(Task<>), - typeof(IgnoreDataMemberAttribute), - typeof(System.Collections.Hashtable), - typeof(System.Collections.Generic.List<>), - typeof(System.Collections.Generic.HashSet<>), - typeof(System.Collections.Immutable.IImmutableList<>), - typeof(System.Linq.ILookup<,>), - typeof(System.Tuple<>), - typeof(System.ValueTuple<>), - typeof(System.Collections.Concurrent.ConcurrentDictionary<,>), - typeof(System.Collections.ObjectModel.ObservableCollection<>), - }; - - var metadata = standardMetadataType - .Select(x => x.Assembly.Location) - .Distinct() - .ToList(); - - var dir = new FileInfo(typeof(object).Assembly.Location).Directory ?? throw new NullReferenceException("Assembly location directory not found!"); - { - var path = Path.Combine(dir.FullName, "netstandard.dll"); - if (File.Exists(path)) - { - metadata.Add(path); - } - } - - { - var path = Path.Combine(dir.FullName, "System.Runtime.dll"); - if (File.Exists(path)) - { - metadata.Add(path); - } - } - - return metadata; - } - - private static IEnumerable? CleanPreprocessorSymbols(IEnumerable? preprocessorSymbols) - { - return preprocessorSymbols?.Where(x => !string.IsNullOrWhiteSpace(x)); - } - - private static IEnumerable IterateCsFileWithoutBinObj(string root) - { - foreach (var item in Directory.EnumerateFiles(root, "*.cs", SearchOption.TopDirectoryOnly)) - { - yield return item; - } - - foreach (var dir in Directory.GetDirectories(root, "*", SearchOption.TopDirectoryOnly)) - { - var dirName = new DirectoryInfo(dir).Name; - if (dirName == "bin" || dirName == "obj") - { - continue; - } - - foreach (var item in IterateCsFileWithoutBinObj(dir)) - { - yield return item; - } - } - } - - private static string NormalizeDirectorySeparators(string path) - { - return path.Replace('\\', Path.DirectorySeparatorChar).Replace('/', Path.DirectorySeparatorChar); - } - - private const string DummyAnnotation = @" -using System; - -namespace MessagePack -{ - [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct, AllowMultiple = false, Inherited = true)] - public class MessagePackObjectAttribute : Attribute - { - public bool KeyAsPropertyName { get; private set; } - - public MessagePackObjectAttribute(bool keyAsPropertyName = false) - { - this.KeyAsPropertyName = keyAsPropertyName; - } - } - - [AttributeUsage(AttributeTargets.Property | AttributeTargets.Field, AllowMultiple = false, Inherited = true)] - public class KeyAttribute : Attribute - { - public int? IntKey { get; private set; } - public string StringKey { get; private set; } - - public KeyAttribute(int x) - { - this.IntKey = x; - } - - public KeyAttribute(string x) - { - this.StringKey = x; - } - } - - [AttributeUsage(AttributeTargets.Property | AttributeTargets.Field, AllowMultiple = false, Inherited = true)] - public class IgnoreMemberAttribute : Attribute - { - } - - [AttributeUsage(AttributeTargets.Interface | AttributeTargets.Class, AllowMultiple = true, Inherited = false)] - public class UnionAttribute : Attribute - { - public int Key { get; private set; } - public Type SubType { get; private set; } - - public UnionAttribute(int key, Type subType) - { - this.Key = key; - this.SubType = subType; - } - } - - [AttributeUsage(AttributeTargets.Constructor, AllowMultiple = false, Inherited = true)] - public class SerializationConstructorAttribute : Attribute - { - } - - [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Interface | AttributeTargets.Enum | AttributeTargets.Field | AttributeTargets.Property, AllowMultiple = false, Inherited = true)] - public class MessagePackFormatterAttribute : Attribute - { - public Type FormatterType { get; private set; } - public object[] Arguments { get; private set; } - - public MessagePackFormatterAttribute(Type formatterType) - { - this.FormatterType = formatterType; - } - - public MessagePackFormatterAttribute(Type formatterType, params object[] arguments) - { - this.FormatterType = formatterType; - this.Arguments = arguments; - } - } -} - -using System; -using System.Collections.Generic; -using System.Text; - -namespace MessagePack -{ - public interface IMessagePackSerializationCallbackReceiver - { - void OnBeforeSerialize(); - void OnAfterDeserialize(); - } -} -"; - } -} From e962638021fa4511878e977feca7117123de3058 Mon Sep 17 00:00:00 2001 From: y-sasaki <11359025+Y-YoL@users.noreply.github.com> Date: Thu, 22 Dec 2022 22:55:40 +0900 Subject: [PATCH 007/660] Fix GetFormatterWithVerify missing error --- src/MessagePack.Generator/MessagepackGenerator.Emit.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/MessagePack.Generator/MessagepackGenerator.Emit.cs b/src/MessagePack.Generator/MessagepackGenerator.Emit.cs index 921521551..e0936e576 100644 --- a/src/MessagePack.Generator/MessagepackGenerator.Emit.cs +++ b/src/MessagePack.Generator/MessagepackGenerator.Emit.cs @@ -109,6 +109,7 @@ private static void ResolverText(StringBuilder sb, string ns, IEnumerable Date: Wed, 4 Jan 2023 17:09:49 +0900 Subject: [PATCH 008/660] Fix array formatters is not registered --- .../MessagepackGenerator.Emit.cs | 33 +++++++++++-------- .../CodeAnalysis/TypeCollector.cs | 8 ++++- 2 files changed, 27 insertions(+), 14 deletions(-) diff --git a/src/MessagePack.Generator/MessagepackGenerator.Emit.cs b/src/MessagePack.Generator/MessagepackGenerator.Emit.cs index e0936e576..108800a02 100644 --- a/src/MessagePack.Generator/MessagepackGenerator.Emit.cs +++ b/src/MessagePack.Generator/MessagepackGenerator.Emit.cs @@ -30,7 +30,7 @@ private static void Generate(TypeDeclarationSyntax syntax, Compilation compilati var (objectInfo, enumInfo, genericInfo, unionInfo) = collector.Collect(); - var code = GenerateFormatterSync(string.Empty, string.Empty, objectInfo, enumInfo, unionInfo, genericInfo); + var code = GenerateFormatterSync(fullType.Replace(".", "_"), string.Empty, objectInfo, enumInfo, unionInfo, genericInfo); context.AddSource($"{fullType}.MessagePackFormatter.g.cs", code); } @@ -68,6 +68,18 @@ string GetNamespace(IGrouping x) return namespaceDot + "Formatters." + x.Key; } + var sb = new StringBuilder(); + ResolverText( + sb, + namespaceDot + "Resolvers", + resolverName, + genericInfo + .Where(x => !x.IsOpenGenericType) + .Cast() + .Concat(enumInfo) + .Concat(unionInfo) + .Concat(objectInfo.Where(x => !x.IsOpenGenericType))); + var enumFormatterTemplates = enumInfo .GroupBy(x => x.Namespace) .Select(x => new EnumTemplate(GetNamespace(x), x.ToArray())) @@ -78,11 +90,9 @@ string GetNamespace(IGrouping x) .Select(x => new UnionTemplate(GetNamespace(x), x.ToArray())) .ToArray(); - var sb = new StringBuilder(); foreach (var item in enumFormatterTemplates) { var text = item.TransformText(); - ResolverText(sb, item.Namespace, item.EnumSerializationInfos.Select(x => x.Name)); sb.AppendLine(text); } @@ -90,7 +100,6 @@ string GetNamespace(IGrouping x) foreach (var item in unionFormatterTemplates) { var text = item.TransformText(); - ResolverText(sb, item.Namespace, item.UnionSerializationInfos.Select(x => x.Name)); sb.AppendLine(text); } @@ -98,14 +107,13 @@ string GetNamespace(IGrouping x) foreach (var item in objectFormatterTemplates) { var text = item.TransformText(); - ResolverText(sb, item.Namespace, item.ObjectSerializationInfos.Select(x => x.Name)); sb.AppendLine(text); } return sb.ToString(); } - private static void ResolverText(StringBuilder sb, string ns, IEnumerable names) + private static void ResolverText(StringBuilder sb, string ns, string resolverName, IEnumerable registerInfos) { var begin = $$""" using System.Runtime.CompilerServices; @@ -115,24 +123,23 @@ namespace {{ns}} { partial class FormatterRegister { + [ModuleInitializer] + internal static void {{resolverName}}FormatterRegister() + { """; var end = $$""" + } } } """; sb.AppendLine(begin); - foreach (var item in names) + foreach (var item in registerInfos) { var code = $$""" - - [ModuleInitializer] - internal static void {{item}}FormatterRegister() - { - MessagePack.Resolvers.StaticCompositeResolver.Instance.AddGeneratedFormatter(new global::{{ns}}.{{item}}Formatter()); - } + MessagePack.Resolvers.StaticCompositeResolver.Instance.AddGeneratedFormatter(new global::Formatters.{{item.FormatterName}}()); """; sb.AppendLine(code); } diff --git a/src/MessagePack.GeneratorCore/CodeAnalysis/TypeCollector.cs b/src/MessagePack.GeneratorCore/CodeAnalysis/TypeCollector.cs index 9f7fd8c0f..2f2699390 100644 --- a/src/MessagePack.GeneratorCore/CodeAnalysis/TypeCollector.cs +++ b/src/MessagePack.GeneratorCore/CodeAnalysis/TypeCollector.cs @@ -241,6 +241,8 @@ public class TypeCollector private readonly bool disallowInternal; + private readonly bool excludeArrayElement; + private readonly HashSet externalIgnoreTypeNames; // visitor workspace: @@ -292,6 +294,7 @@ public TypeCollector(Compilation compilation, bool disallowInternal, bool isForc this.isForceUseMap = isForceUseMap; this.externalIgnoreTypeNames = new HashSet(ignoreTypeNames ?? Array.Empty()); this.compilation = compilation; + this.excludeArrayElement = true; targetTypes = new[] { targetType } .Where(x => @@ -463,7 +466,10 @@ private void CollectGenericUnion(INamedTypeSymbol type) private void CollectArray(IArrayTypeSymbol array) { ITypeSymbol elemType = array.ElementType; - this.CollectCore(elemType); + if (!excludeArrayElement) + { + this.CollectCore(elemType); + } var fullName = array.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat); var elementTypeDisplayName = elemType.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat); From 51dac96294deeaa818ed9a409be4482e9378e01c Mon Sep 17 00:00:00 2001 From: y-sasaki <11359025+Y-YoL@users.noreply.github.com> Date: Wed, 4 Jan 2023 17:48:45 +0900 Subject: [PATCH 009/660] Fix formatter duplicate definisions --- .../MessagepackGenerator.Emit.cs | 8 +++--- .../MessagepackGenerator.cs | 25 +++++++++++++------ 2 files changed, 23 insertions(+), 10 deletions(-) diff --git a/src/MessagePack.Generator/MessagepackGenerator.Emit.cs b/src/MessagePack.Generator/MessagepackGenerator.Emit.cs index 108800a02..01a2dd35a 100644 --- a/src/MessagePack.Generator/MessagepackGenerator.Emit.cs +++ b/src/MessagePack.Generator/MessagepackGenerator.Emit.cs @@ -97,17 +97,19 @@ string GetNamespace(IGrouping x) } sb.AppendLine(); - foreach (var item in unionFormatterTemplates) + foreach (var item in objectFormatterTemplates) { var text = item.TransformText(); sb.AppendLine(text); + return sb.ToString(); } sb.AppendLine(); - foreach (var item in objectFormatterTemplates) + foreach (var item in unionFormatterTemplates) { var text = item.TransformText(); sb.AppendLine(text); + return sb.ToString(); } return sb.ToString(); @@ -139,7 +141,7 @@ partial class FormatterRegister foreach (var item in registerInfos) { var code = $$""" - MessagePack.Resolvers.StaticCompositeResolver.Instance.AddGeneratedFormatter(new global::Formatters.{{item.FormatterName}}()); + MessagePack.Resolvers.StaticCompositeResolver.Instance.AddGeneratedFormatter(new {{(item.FormatterName.StartsWith("global::") ? item.FormatterName : "global::Formatters." + item.FormatterName)}}()); """; sb.AppendLine(code); } diff --git a/src/MessagePack.Generator/MessagepackGenerator.cs b/src/MessagePack.Generator/MessagepackGenerator.cs index c5344dcf5..d0ce067a6 100644 --- a/src/MessagePack.Generator/MessagepackGenerator.cs +++ b/src/MessagePack.Generator/MessagepackGenerator.cs @@ -10,6 +10,7 @@ namespace MessagePack.Generator; public partial class MessagepackGenerator : IIncrementalGenerator { public const string MessagePackObjectAttributeFullName = "MessagePack.MessagePackObjectAttribute"; + public const string MessagePackUnionAttributeFullName = "MessagePack.UnionAttribute"; public void Initialize(IncrementalGeneratorInitializationContext context) { @@ -17,16 +18,26 @@ public void Initialize(IncrementalGeneratorInitializationContext context) MessagePackObjectAttributeFullName, predicate: static (node, _) => node is TypeDeclarationSyntax, transform: static (context, _) => (TypeDeclarationSyntax)context.TargetNode); + Register(typeDeclarations); - var source = typeDeclarations - .Combine(context.CompilationProvider) - .WithComparer(Comparer.Instance); + var typeDeclarations2 = context.SyntaxProvider.ForAttributeWithMetadataName( + MessagePackUnionAttributeFullName, + predicate: static (node, _) => node is InterfaceDeclarationSyntax, + transform: static (context, _) => (TypeDeclarationSyntax)context.TargetNode); + Register(typeDeclarations2); - context.RegisterSourceOutput(source, static (context, source) => + void Register(IncrementalValuesProvider typeDeclarations) { - var (typeDeclaration, compilation) = source; - Generate(typeDeclaration, compilation, new GeneratorContext(context)); - }); + var source = typeDeclarations + .Combine(context.CompilationProvider) + .WithComparer(Comparer.Instance); + + context.RegisterSourceOutput(source, static (context, source) => + { + var (typeDeclaration, compilation) = source; + Generate(typeDeclaration, compilation, new GeneratorContext(context)); + }); + } } private class Comparer : IEqualityComparer<(TypeDeclarationSyntax, Compilation)> From fb2395d9a7cc483f5f1a37a82b104fde93883b34 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Mon, 27 Feb 2023 09:46:58 -0700 Subject: [PATCH 010/660] Add dotnet CLI tools --- .config/dotnet-tools.json | 18 ++++++++++++++++++ init.ps1 | 5 +++++ 2 files changed, 23 insertions(+) create mode 100644 .config/dotnet-tools.json diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json new file mode 100644 index 000000000..2599e26ad --- /dev/null +++ b/.config/dotnet-tools.json @@ -0,0 +1,18 @@ +{ + "version": 1, + "isRoot": true, + "tools": { + "powershell": { + "version": "7.3.3", + "commands": [ + "pwsh" + ] + }, + "dotnet-format": { + "version": "5.1.250801", + "commands": [ + "dotnet-format" + ] + } + } +} \ No newline at end of file diff --git a/init.ps1 b/init.ps1 index ad3b4145c..5bace1e62 100755 --- a/init.ps1 +++ b/init.ps1 @@ -91,6 +91,11 @@ try { if ($lastexitcode -ne 0) { throw "Failure while restoring packages." } + + dotnet tool restore @RestoreArguments + if ($lastexitcode -ne 0) { + throw "Failure while restoring dotnet CLI tools." + } } & "$PSScriptRoot/tools/Set-EnvVars.ps1" -Variables $EnvVars -PrependPath $PrependPath | Out-Null From 20876a310991753e11be38033d0a12f3e45f54ac Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Sun, 12 Mar 2023 17:43:59 -0600 Subject: [PATCH 011/660] Build v2.6-alpha in develop --- version.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.json b/version.json index f24af0f90..232c22237 100644 --- a/version.json +++ b/version.json @@ -1,6 +1,6 @@ { "$schema": "https://raw.githubusercontent.com/dotnet/Nerdbank.GitVersioning/master/src/NerdBank.GitVersioning/version.schema.json", - "version": "2.5", + "version": "2.6-alpha", "publicReleaseRefSpec": [ "^refs/heads/master$", "^refs/heads/v1\\.x$", From ea48c8eaa182f224ca3ed1a38f2a8034d15dacce Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Mon, 13 Mar 2023 15:27:56 -0600 Subject: [PATCH 012/660] Updated SDK installer script to be able to find 7.0.200 --- tools/Install-DotNetSdk.ps1 | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/tools/Install-DotNetSdk.ps1 b/tools/Install-DotNetSdk.ps1 index 6bff5c278..10af50411 100644 --- a/tools/Install-DotNetSdk.ps1 +++ b/tools/Install-DotNetSdk.ps1 @@ -137,6 +137,14 @@ Function Get-InstallerExe( if ($release.$sku.version -eq $Version) { $filesElement = $release.$sku.files } + if (!$filesElement -and ($sku -eq 'sdk') -and $release.sdks) { + foreach ($sdk in $release.sdks) { + if ($sdk.version -eq $Version) { + $filesElement = $sdk.files + break + } + } + } if ($filesElement) { foreach ($file in $filesElement) { @@ -155,7 +163,7 @@ Function Get-InstallerExe( if ($url) { Get-FileFromWeb -Uri $url -OutDir $DotNetInstallScriptRoot } else { - Write-Error "Unable to find release of $sku v$Version" + throw "Unable to find release of $sku v$Version" } } From 2987b4457b0242e91913e9d9f4b43b5db079fd50 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Mon, 13 Mar 2023 15:31:46 -0600 Subject: [PATCH 013/660] Bump SDK version to 7.0.201 --- global.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/global.json b/global.json index cc08211e2..cf9eefa6e 100644 --- a/global.json +++ b/global.json @@ -1,6 +1,6 @@ { "sdk": { - "version": "7.0.101", + "version": "7.0.201", "rollForward": "patch", "allowPrerelease": false } From f911a00e8960f75756ed0ce36b33a0afc97c8681 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Mon, 20 Mar 2023 17:07:54 -0600 Subject: [PATCH 014/660] Delete MessagePack.MSBuild.Tasks project The source generator will altogether deprecate this. --- MessagePack.sln | 9 +- .../MessagePack.MSBuild.Tasks.csproj | 38 ------ .../MessagePackGenerator.cs | 113 ------------------ .../build/MessagePack.MSBuild.Tasks.props | 12 -- .../build/MessagePack.MSBuild.Tasks.targets | 28 ----- 5 files changed, 1 insertion(+), 199 deletions(-) delete mode 100644 src/MessagePack.MSBuild.Tasks/MessagePack.MSBuild.Tasks.csproj delete mode 100644 src/MessagePack.MSBuild.Tasks/MessagePackGenerator.cs delete mode 100644 src/MessagePack.MSBuild.Tasks/build/MessagePack.MSBuild.Tasks.props delete mode 100644 src/MessagePack.MSBuild.Tasks/build/MessagePack.MSBuild.Tasks.targets diff --git a/MessagePack.sln b/MessagePack.sln index d701ef3b4..bef174b68 100644 --- a/MessagePack.sln +++ b/MessagePack.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 17 -VisualStudioVersion = 17.5.33201.384 +VisualStudioVersion = 17.4.33103.184 MinimumVisualStudioVersion = 10.0.40219.1 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{86309CF6-0054-4CE3-BFD3-CA0AA7DB17BC}" ProjectSection(SolutionItems) = preProject @@ -79,8 +79,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MessagePack.GeneratorCore", EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MessagePack.Generator", "src\MessagePack.Generator\MessagePack.Generator.csproj", "{32C91908-5CAD-4C95-B240-ACBBACAC9476}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MessagePack.MSBuild.Tasks", "src\MessagePack.MSBuild.Tasks\MessagePack.MSBuild.Tasks.csproj", "{8DB135F5-A6FE-44E4-9853-7B48ED21F21B}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MessagePackAnalyzer.Tests", "tests\MessagePackAnalyzer.Tests\MessagePackAnalyzer.Tests.csproj", "{7E5FB4B9-A0F5-4B10-A1F3-03AC0BC8265A}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MessagePack.Generator.Tests", "tests\MessagePack.Generator.Tests\MessagePack.Generator.Tests.csproj", "{6AC51E68-4681-463A-B4B6-BD53517244B2}" @@ -181,10 +179,6 @@ Global {32C91908-5CAD-4C95-B240-ACBBACAC9476}.Debug|Any CPU.Build.0 = Debug|Any CPU {32C91908-5CAD-4C95-B240-ACBBACAC9476}.Release|Any CPU.ActiveCfg = Release|Any CPU {32C91908-5CAD-4C95-B240-ACBBACAC9476}.Release|Any CPU.Build.0 = Release|Any CPU - {8DB135F5-A6FE-44E4-9853-7B48ED21F21B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {8DB135F5-A6FE-44E4-9853-7B48ED21F21B}.Debug|Any CPU.Build.0 = Debug|Any CPU - {8DB135F5-A6FE-44E4-9853-7B48ED21F21B}.Release|Any CPU.ActiveCfg = Release|Any CPU - {8DB135F5-A6FE-44E4-9853-7B48ED21F21B}.Release|Any CPU.Build.0 = Release|Any CPU {7E5FB4B9-A0F5-4B10-A1F3-03AC0BC8265A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {7E5FB4B9-A0F5-4B10-A1F3-03AC0BC8265A}.Debug|Any CPU.Build.0 = Debug|Any CPU {7E5FB4B9-A0F5-4B10-A1F3-03AC0BC8265A}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -238,7 +232,6 @@ Global {8D9FD130-7905-47D8-A25C-7FDEE28EA0E8} = {19FE674A-AC94-4E7E-B24C-2285D1D04CDE} {9962132D-A271-4E68-ACC1-18FA93462552} = {86309CF6-0054-4CE3-BFD3-CA0AA7DB17BC} {32C91908-5CAD-4C95-B240-ACBBACAC9476} = {86309CF6-0054-4CE3-BFD3-CA0AA7DB17BC} - {8DB135F5-A6FE-44E4-9853-7B48ED21F21B} = {86309CF6-0054-4CE3-BFD3-CA0AA7DB17BC} {7E5FB4B9-A0F5-4B10-A1F3-03AC0BC8265A} = {19FE674A-AC94-4E7E-B24C-2285D1D04CDE} {6AC51E68-4681-463A-B4B6-BD53517244B2} = {19FE674A-AC94-4E7E-B24C-2285D1D04CDE} {4C9BB260-62D8-49CD-9F9C-9AA6A8BFC637} = {51A614B0-E583-4DD2-AC7D-6A65634582E0} diff --git a/src/MessagePack.MSBuild.Tasks/MessagePack.MSBuild.Tasks.csproj b/src/MessagePack.MSBuild.Tasks/MessagePack.MSBuild.Tasks.csproj deleted file mode 100644 index 6f2e11c86..000000000 --- a/src/MessagePack.MSBuild.Tasks/MessagePack.MSBuild.Tasks.csproj +++ /dev/null @@ -1,38 +0,0 @@ - - - - netstandard2.0 - - true - true - false - $(TargetsForTfmSpecificContentInPackage);AddBuildOutputAndDependencies - true - true - MessagePack CodeGenerator Tasks - MSBuild Tasks of MessagePack for C#. - MsgPack;MessagePack;Serialization;Formatter;Serializer;Unity;Xamarin - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/MessagePack.MSBuild.Tasks/MessagePackGenerator.cs b/src/MessagePack.MSBuild.Tasks/MessagePackGenerator.cs deleted file mode 100644 index 69d8f23e5..000000000 --- a/src/MessagePack.MSBuild.Tasks/MessagePackGenerator.cs +++ /dev/null @@ -1,113 +0,0 @@ -// Copyright (c) All contributors. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Threading; -using System.Threading.Tasks; -using MessagePackCompiler; -using Microsoft.Build.Framework; -using Microsoft.CodeAnalysis; -using Microsoft.CodeAnalysis.CSharp; -using Microsoft.CodeAnalysis.Text; - -// synchronous blocks aren't a problem in MSBuild tasks -#pragma warning disable VSTHRD002 // Avoid problematic synchronous waits - -namespace MessagePack.MSBuild.Tasks -{ - public class MessagePackGenerator : Microsoft.Build.Utilities.Task, ICancelableTask - { - private readonly CancellationTokenSource cts = new CancellationTokenSource(); - - [Required] - public ITaskItem[] Compile { get; set; } = null!; - - [Required] - public string GeneratedOutputPath { get; set; } = null!; - - [Required] - public ITaskItem[] ReferencePath { get; set; } = null!; - - public string? DefineConstants { get; set; } - - [Required] - public string ResolverName { get; set; } = null!; - - public string? Namespace { get; set; } - - public bool UseMapMode { get; set; } - - public string[]? ExternalIgnoreTypeNames { get; set; } - - internal CancellationToken CancellationToken => this.cts.Token; - - public void Cancel() => this.cts.Cancel(); - - public override bool Execute() - { - if (string.IsNullOrWhiteSpace(this.ResolverName)) - { - this.Log.LogError($"{nameof(ResolverName)} task parameter must not be set to an empty value."); - return false; - } - - try - { - var compilation = this.CreateCompilation(); - - var generator = new CodeGenerator(x => this.Log.LogMessage(x), CancellationToken.None); - generator.GenerateFileAsync( - compilation, - this.GeneratedOutputPath, - ResolverName, - Namespace, - UseMapMode, - null, - ExternalIgnoreTypeNames).GetAwaiter().GetResult(); - } - catch (Exception ex) - { - this.Log.LogErrorFromException(ex, true); - return false; - } - - return true; - } - - private Compilation CreateCompilation() - { - var parseOptions = new CSharpParseOptions(LanguageVersion.Latest, DocumentationMode.Parse, SourceCodeKind.Regular, this.DefineConstants?.Split(';', ',')); - var syntaxTrees = new List(this.Compile.Length); - foreach (var path in this.Compile) - { - string fullPath = path.GetMetadata("FullPath"); - - if (string.Equals(fullPath, Path.GetFullPath(this.GeneratedOutputPath), StringComparison.OrdinalIgnoreCase)) - { - // Do not include a stale version of the file we are to generate in the compilation. - continue; - } - - using var compile = File.OpenRead(path.ItemSpec); - var sourceText = SourceText.From(compile); - syntaxTrees.Add(CSharpSyntaxTree.ParseText(sourceText, parseOptions, fullPath, cancellationToken: this.CancellationToken)); - } - - var references = - from referencePath in this.ReferencePath - select MetadataReference.CreateFromFile(referencePath.ItemSpec); - - var options = new CSharpCompilationOptions( - OutputKind.DynamicallyLinkedLibrary); - var compilation = CSharpCompilation.Create( - "MsgPackTempProj", - syntaxTrees, - references, - options); - return compilation; - } - } -} diff --git a/src/MessagePack.MSBuild.Tasks/build/MessagePack.MSBuild.Tasks.props b/src/MessagePack.MSBuild.Tasks/build/MessagePack.MSBuild.Tasks.props deleted file mode 100644 index 2139219dd..000000000 --- a/src/MessagePack.MSBuild.Tasks/build/MessagePack.MSBuild.Tasks.props +++ /dev/null @@ -1,12 +0,0 @@ - - - - MessagePack - - - GeneratedResolver - - - false - - diff --git a/src/MessagePack.MSBuild.Tasks/build/MessagePack.MSBuild.Tasks.targets b/src/MessagePack.MSBuild.Tasks/build/MessagePack.MSBuild.Tasks.targets deleted file mode 100644 index e95cf9e90..000000000 --- a/src/MessagePack.MSBuild.Tasks/build/MessagePack.MSBuild.Tasks.targets +++ /dev/null @@ -1,28 +0,0 @@ - - - $(IntermediateOutputPath)mpc_generated.cs - - - - - - - - - - - - - From 267ba7fa71eaf7c2df8e71f8dbbbd9cae94c5b30 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Mon, 20 Mar 2023 18:01:18 -0600 Subject: [PATCH 015/660] Refactor source generating projects --- Directory.Packages.props | 8 +- MessagePack.sln | 7 - .../DynamicCodeDumper.csproj | 3 + .../MessagePack.Generator.Roslyn3.csproj | 75 +- .../CodeAnalysis/Definitions.cs | 282 +++++ .../CodeAnalysis/TypeCollector.cs | 1093 ++++++++++++++++ src/MessagePack.Generator/CodeGenerator.cs | 312 +++++ .../MessagePack.Generator.csproj | 71 +- .../MessagepackGenerator.Emit.cs | 4 +- .../Transforms}/EnumTemplate.cs | 6 +- .../Transforms}/EnumTemplate.tt | 2 - .../Transforms}/FormatterTemplate.cs | 6 +- .../Transforms}/FormatterTemplate.tt | 2 - .../Transforms/IFormatterTemplate.cs | 15 + .../Transforms}/ResolverTemplate.cs | 6 +- .../Transforms}/ResolverTemplate.tt | 2 - .../ShouldUseFormatterResolverHelper.cs | 46 + .../Transforms/StringKey/EmbedStringHelper.cs | 85 ++ .../StringKeyFormatterDeserializeHelper.cs | 248 ++++ .../StringKey/StringKeyFormatterTemplate.cs | 6 +- .../StringKey/StringKeyFormatterTemplate.tt | 2 +- .../Transforms/TemplatePartials.cs | 79 ++ .../Transforms}/UnionTemplate.cs | 6 +- .../Transforms}/UnionTemplate.tt | 2 - .../Utils/RoslynExtensions.cs | 48 + src/MessagePack.GeneratorCore/.editorconfig | 4 - .../CodeAnalysis/Definitions.cs | 282 ----- .../CodeAnalysis/TypeCollector.cs | 1094 ----------------- .../CodeGenerator.cs | 319 ----- .../Generator/IFormatterTemplate.cs | 16 - .../ShouldUseFormatterResolverHelper.cs | 48 - .../Generator/StringKey/EmbedStringHelper.cs | 87 -- .../StringKeyFormatterDeserializeHelper.cs | 252 ---- .../Generator/TemplatePartials.cs | 80 -- .../MessagePack.GeneratorCore.csproj | 79 -- .../Utils/RoslynExtensions.cs | 51 - .../Internal/AutomataDictionary.cs | 91 -- .../MessagePack/Internal/AutomataKeyGen.cs | 109 ++ .../MessagePack.Generator.Tests.csproj | 2 +- 39 files changed, 2407 insertions(+), 2523 deletions(-) create mode 100644 src/MessagePack.Generator/CodeAnalysis/Definitions.cs create mode 100644 src/MessagePack.Generator/CodeAnalysis/TypeCollector.cs create mode 100644 src/MessagePack.Generator/CodeGenerator.cs rename src/{MessagePack.GeneratorCore/Generator => MessagePack.Generator/Transforms}/EnumTemplate.cs (98%) rename src/{MessagePack.GeneratorCore/Generator => MessagePack.Generator/Transforms}/EnumTemplate.tt (94%) rename src/{MessagePack.GeneratorCore/Generator => MessagePack.Generator/Transforms}/FormatterTemplate.cs (99%) rename src/{MessagePack.GeneratorCore/Generator => MessagePack.Generator/Transforms}/FormatterTemplate.tt (98%) create mode 100644 src/MessagePack.Generator/Transforms/IFormatterTemplate.cs rename src/{MessagePack.GeneratorCore/Generator => MessagePack.Generator/Transforms}/ResolverTemplate.cs (98%) rename src/{MessagePack.GeneratorCore/Generator => MessagePack.Generator/Transforms}/ResolverTemplate.tt (96%) create mode 100644 src/MessagePack.Generator/Transforms/ShouldUseFormatterResolverHelper.cs create mode 100644 src/MessagePack.Generator/Transforms/StringKey/EmbedStringHelper.cs create mode 100644 src/MessagePack.Generator/Transforms/StringKey/StringKeyFormatterDeserializeHelper.cs rename src/{MessagePack.GeneratorCore/Generator => MessagePack.Generator/Transforms}/StringKey/StringKeyFormatterTemplate.cs (99%) rename src/{MessagePack.GeneratorCore/Generator => MessagePack.Generator/Transforms}/StringKey/StringKeyFormatterTemplate.tt (99%) create mode 100644 src/MessagePack.Generator/Transforms/TemplatePartials.cs rename src/{MessagePack.GeneratorCore/Generator => MessagePack.Generator/Transforms}/UnionTemplate.cs (98%) rename src/{MessagePack.GeneratorCore/Generator => MessagePack.Generator/Transforms}/UnionTemplate.tt (97%) create mode 100644 src/MessagePack.Generator/Utils/RoslynExtensions.cs delete mode 100644 src/MessagePack.GeneratorCore/.editorconfig delete mode 100644 src/MessagePack.GeneratorCore/CodeAnalysis/Definitions.cs delete mode 100644 src/MessagePack.GeneratorCore/CodeAnalysis/TypeCollector.cs delete mode 100644 src/MessagePack.GeneratorCore/CodeGenerator.cs delete mode 100644 src/MessagePack.GeneratorCore/Generator/IFormatterTemplate.cs delete mode 100644 src/MessagePack.GeneratorCore/Generator/ShouldUseFormatterResolverHelper.cs delete mode 100644 src/MessagePack.GeneratorCore/Generator/StringKey/EmbedStringHelper.cs delete mode 100644 src/MessagePack.GeneratorCore/Generator/StringKey/StringKeyFormatterDeserializeHelper.cs delete mode 100644 src/MessagePack.GeneratorCore/Generator/TemplatePartials.cs delete mode 100644 src/MessagePack.GeneratorCore/MessagePack.GeneratorCore.csproj delete mode 100644 src/MessagePack.GeneratorCore/Utils/RoslynExtensions.cs create mode 100644 src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Internal/AutomataKeyGen.cs diff --git a/Directory.Packages.props b/Directory.Packages.props index 5675501d0..a1f151d30 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -7,9 +7,9 @@ 0.13.5 - - 3.9.0 - 4.4.0 + + 4.3.0 + 4.5.0 @@ -51,7 +51,7 @@ - + diff --git a/MessagePack.sln b/MessagePack.sln index bef174b68..9c06b75f9 100644 --- a/MessagePack.sln +++ b/MessagePack.sln @@ -75,8 +75,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MessagePack.Internal", "san EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MessagePack.Internal.Tests", "tests\MessagePack.Internal.Tests\MessagePack.Internal.Tests.csproj", "{8D9FD130-7905-47D8-A25C-7FDEE28EA0E8}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MessagePack.GeneratorCore", "src\MessagePack.GeneratorCore\MessagePack.GeneratorCore.csproj", "{9962132D-A271-4E68-ACC1-18FA93462552}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MessagePack.Generator", "src\MessagePack.Generator\MessagePack.Generator.csproj", "{32C91908-5CAD-4C95-B240-ACBBACAC9476}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MessagePackAnalyzer.Tests", "tests\MessagePackAnalyzer.Tests\MessagePackAnalyzer.Tests.csproj", "{7E5FB4B9-A0F5-4B10-A1F3-03AC0BC8265A}" @@ -171,10 +169,6 @@ Global {8D9FD130-7905-47D8-A25C-7FDEE28EA0E8}.Debug|Any CPU.Build.0 = Debug|Any CPU {8D9FD130-7905-47D8-A25C-7FDEE28EA0E8}.Release|Any CPU.ActiveCfg = Release|Any CPU {8D9FD130-7905-47D8-A25C-7FDEE28EA0E8}.Release|Any CPU.Build.0 = Release|Any CPU - {9962132D-A271-4E68-ACC1-18FA93462552}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {9962132D-A271-4E68-ACC1-18FA93462552}.Debug|Any CPU.Build.0 = Debug|Any CPU - {9962132D-A271-4E68-ACC1-18FA93462552}.Release|Any CPU.ActiveCfg = Release|Any CPU - {9962132D-A271-4E68-ACC1-18FA93462552}.Release|Any CPU.Build.0 = Release|Any CPU {32C91908-5CAD-4C95-B240-ACBBACAC9476}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {32C91908-5CAD-4C95-B240-ACBBACAC9476}.Debug|Any CPU.Build.0 = Debug|Any CPU {32C91908-5CAD-4C95-B240-ACBBACAC9476}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -230,7 +224,6 @@ Global {4142EA80-FEF4-44A5-8553-1AE84BEBAFED} = {51A614B0-E583-4DD2-AC7D-6A65634582E0} {C100FBA6-4164-4D6A-A532-5984D2B8DCB0} = {BF4C4202-5015-4FBD-80E6-D0F36A06F700} {8D9FD130-7905-47D8-A25C-7FDEE28EA0E8} = {19FE674A-AC94-4E7E-B24C-2285D1D04CDE} - {9962132D-A271-4E68-ACC1-18FA93462552} = {86309CF6-0054-4CE3-BFD3-CA0AA7DB17BC} {32C91908-5CAD-4C95-B240-ACBBACAC9476} = {86309CF6-0054-4CE3-BFD3-CA0AA7DB17BC} {7E5FB4B9-A0F5-4B10-A1F3-03AC0BC8265A} = {19FE674A-AC94-4E7E-B24C-2285D1D04CDE} {6AC51E68-4681-463A-B4B6-BD53517244B2} = {19FE674A-AC94-4E7E-B24C-2285D1D04CDE} diff --git a/sandbox/DynamicCodeDumper/DynamicCodeDumper.csproj b/sandbox/DynamicCodeDumper/DynamicCodeDumper.csproj index ef675b4ea..9759790ae 100644 --- a/sandbox/DynamicCodeDumper/DynamicCodeDumper.csproj +++ b/sandbox/DynamicCodeDumper/DynamicCodeDumper.csproj @@ -31,6 +31,9 @@ Code\AutomataDictionary.cs + + Code\AutomataKeyGen.cs + Code\ThreadsafeTypeKeyHashTable.cs diff --git a/src/MessagePack.Generator.Roslyn3/MessagePack.Generator.Roslyn3.csproj b/src/MessagePack.Generator.Roslyn3/MessagePack.Generator.Roslyn3.csproj index f497d4542..b25ffbde0 100644 --- a/src/MessagePack.Generator.Roslyn3/MessagePack.Generator.Roslyn3.csproj +++ b/src/MessagePack.Generator.Roslyn3/MessagePack.Generator.Roslyn3.csproj @@ -6,7 +6,6 @@ enable enable ROSLYN3 - true cs @@ -21,80 +20,16 @@ - - - - - + + + - + - - - - - - - True - True - EnumTemplate.tt - - - True - True - FormatterTemplate.tt - - - True - True - ResolverTemplate.tt - - - True - True - StringKeyFormatterTemplate.tt - - - %(FileName).tt - True - True - - - True - True - UnionTemplate.tt - - - - - - TextTemplatingFilePreprocessor - EnumTemplate.cs - MessagePackCompiler.Generator - - - TextTemplatingFilePreprocessor - FormatterTemplate.cs - MessagePackCompiler.Generator - - - TextTemplatingFilePreprocessor - ResolverTemplate.cs - MessagePackCompiler.Generator - - - TextTemplatingFilePreprocessor - StringKeyFormatterTemplate.cs - MessagePackCompiler.Generator - - - TextTemplatingFilePreprocessor - UnionTemplate.cs - MessagePackCompiler.Generator - + diff --git a/src/MessagePack.Generator/CodeAnalysis/Definitions.cs b/src/MessagePack.Generator/CodeAnalysis/Definitions.cs new file mode 100644 index 000000000..a93a92acd --- /dev/null +++ b/src/MessagePack.Generator/CodeAnalysis/Definitions.cs @@ -0,0 +1,282 @@ +// Copyright (c) All contributors. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using System; +using System.Collections.Generic; +using System.Linq; +using MessagePack.Generator.Transforms; + +#pragma warning disable SA1402 // File may only contain a single type +#pragma warning disable SA1649 // File name should match first type name + +namespace MessagePack.Generator.CodeAnalysis; + +public interface INamespaceInfo +{ + string? Namespace { get; } +} + +public interface IResolverRegisterInfo +{ + string FullName { get; } + + string FormatterName { get; } +} + +public class ObjectSerializationInfo : IResolverRegisterInfo, INamespaceInfo +{ + public string Name { get; } + + public string FullName { get; } + + public string? Namespace { get; } + + public GenericTypeParameterInfo[] GenericTypeParameters { get; } + + public bool IsOpenGenericType { get; } + + public bool IsIntKey { get; } + + public bool IsStringKey + { + get { return !this.IsIntKey; } + } + + public bool IsClass { get; } + + public MemberSerializationInfo[] ConstructorParameters { get; } + + public MemberSerializationInfo[] Members { get; } + + public bool HasIMessagePackSerializationCallbackReceiver { get; } + + public bool NeedsCastOnBefore { get; } + + public bool NeedsCastOnAfter { get; } + + public string FormatterName => this.Namespace == null ? FormatterNameWithoutNameSpace : this.Namespace + "." + FormatterNameWithoutNameSpace; + + public string FormatterNameWithoutNameSpace => this.Name + "Formatter" + (this.IsOpenGenericType ? $"<{string.Join(", ", this.GenericTypeParameters.Select(x => x.Name))}>" : string.Empty); + + public int WriteCount + { + get + { + if (this.IsStringKey) + { + return this.Members.Count(x => x.IsReadable); + } + else + { + return this.MaxKey; + } + } + } + + public int MaxKey + { + get + { + return this.Members.Where(x => x.IsReadable).Select(x => x.IntKey).DefaultIfEmpty(-1).Max(); + } + } + + public MemberSerializationInfo? GetMember(int index) + { + return this.Members.FirstOrDefault(x => x.IntKey == index); + } + + public string GetConstructorString() + { + var args = string.Join(", ", this.ConstructorParameters.Select(x => "__" + x.Name + "__")); + return $"{this.FullName}({args})"; + } + + public ObjectSerializationInfo(bool isClass, bool isOpenGenericType, GenericTypeParameterInfo[] genericTypeParameterInfos, MemberSerializationInfo[] constructorParameters, bool isIntKey, MemberSerializationInfo[] members, string name, string fullName, string? @namespace, bool hasSerializationConstructor, bool needsCastOnAfter, bool needsCastOnBefore) + { + IsClass = isClass; + IsOpenGenericType = isOpenGenericType; + GenericTypeParameters = genericTypeParameterInfos; + ConstructorParameters = constructorParameters; + IsIntKey = isIntKey; + Members = members; + Name = name; + FullName = fullName; + Namespace = @namespace; + HasIMessagePackSerializationCallbackReceiver = hasSerializationConstructor; + NeedsCastOnAfter = needsCastOnAfter; + NeedsCastOnBefore = needsCastOnBefore; + } +} + +public class GenericTypeParameterInfo +{ + public string Name { get; } + + public string Constraints { get; } + + public bool HasConstraints { get; } + + public GenericTypeParameterInfo(string name, string constraints) + { + Name = name ?? throw new ArgumentNullException(nameof(name)); + Constraints = constraints ?? throw new ArgumentNullException(nameof(name)); + HasConstraints = constraints != string.Empty; + } +} + +public class MemberSerializationInfo +{ + public bool IsProperty { get; } + + public bool IsWritable { get; } + + public bool IsReadable { get; } + + public int IntKey { get; } + + public string StringKey { get; } + + public string Type { get; } + + public string Name { get; } + + public string ShortTypeName { get; } + + public string? CustomFormatterTypeName { get; } + + private readonly HashSet primitiveTypes = new(ShouldUseFormatterResolverHelper.PrimitiveTypes); + + public MemberSerializationInfo(bool isProperty, bool isWritable, bool isReadable, int intKey, string stringKey, string name, string type, string shortTypeName, string? customFormatterTypeName) + { + IsProperty = isProperty; + IsWritable = isWritable; + IsReadable = isReadable; + IntKey = intKey; + StringKey = stringKey; + Type = type; + Name = name; + ShortTypeName = shortTypeName; + CustomFormatterTypeName = customFormatterTypeName; + } + + public string GetSerializeMethodString() + { + if (CustomFormatterTypeName != null) + { + return $"this.__{this.Name}CustomFormatter__.Serialize(ref writer, value.{this.Name}, options)"; + } + else if (this.primitiveTypes.Contains(this.Type)) + { + return "writer.Write(value." + this.Name + ")"; + } + else + { + return $"global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<{this.Type}>(formatterResolver).Serialize(ref writer, value.{this.Name}, options)"; + } + } + + public string GetDeserializeMethodString() + { + if (CustomFormatterTypeName != null) + { + return $"this.__{this.Name}CustomFormatter__.Deserialize(ref reader, options)"; + } + else if (this.primitiveTypes.Contains(this.Type)) + { + if (this.Type == "byte[]") + { + return "global::MessagePack.Internal.CodeGenHelpers.GetArrayFromNullableSequence(reader.ReadBytes())"; + } + else + { + return $"reader.Read{this.ShortTypeName!.Replace("[]", "s")}()"; + } + } + else + { + return $"global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<{this.Type}>(formatterResolver).Deserialize(ref reader, options)"; + } + } +} + +public class EnumSerializationInfo : IResolverRegisterInfo, INamespaceInfo +{ + public EnumSerializationInfo(string? @namespace, string name, string fullName, string underlyingType) + { + Namespace = @namespace; + Name = name; + FullName = fullName; + UnderlyingType = underlyingType; + } + + public string? Namespace { get; } + + public string Name { get; } + + public string FullName { get; } + + public string UnderlyingType { get; } + + public string FormatterName => (this.Namespace == null ? this.Name : this.Namespace + "." + this.Name) + "Formatter"; +} + +public class GenericSerializationInfo : IResolverRegisterInfo, IEquatable +{ + public string FullName { get; } + + public string FormatterName { get; } + + public bool IsOpenGenericType { get; } + + public bool Equals(GenericSerializationInfo? other) + { + return this.FullName.Equals(other?.FullName); + } + + public override int GetHashCode() + { + return this.FullName.GetHashCode(); + } + + public GenericSerializationInfo(string fullName, string formatterName, bool isOpenGenericType) + { + FullName = fullName; + FormatterName = formatterName; + IsOpenGenericType = isOpenGenericType; + } +} + +public class UnionSerializationInfo : IResolverRegisterInfo, INamespaceInfo +{ + public string? Namespace { get; } + + public string Name { get; } + + public string FullName { get; } + + public string FormatterName => (this.Namespace == null ? this.Name : this.Namespace + "." + this.Name) + "Formatter"; + + public UnionSubTypeInfo[] SubTypes { get; } + + public UnionSerializationInfo(string? @namespace, string name, string fullName, UnionSubTypeInfo[] subTypes) + { + Namespace = @namespace; + Name = name; + FullName = fullName; + SubTypes = subTypes; + } +} + +public class UnionSubTypeInfo +{ + public UnionSubTypeInfo(int key, string type) + { + Key = key; + Type = type; + } + + public int Key { get; } + + public string Type { get; } +} diff --git a/src/MessagePack.Generator/CodeAnalysis/TypeCollector.cs b/src/MessagePack.Generator/CodeAnalysis/TypeCollector.cs new file mode 100644 index 000000000..3e955a240 --- /dev/null +++ b/src/MessagePack.Generator/CodeAnalysis/TypeCollector.cs @@ -0,0 +1,1093 @@ +// Copyright (c) All contributors. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +#pragma warning disable SA1402 // File may only contain a single type +#pragma warning disable SA1649 // File name should match first type name + +using System; +using System.Collections.Generic; +using System.Collections.Immutable; +using System.Linq; +using System.Text; +using System.Text.RegularExpressions; +using Microsoft.CodeAnalysis; + +namespace MessagePack.Generator.CodeAnalysis; + +public class MessagePackGeneratorResolveFailedException : Exception +{ + public MessagePackGeneratorResolveFailedException(string message) + : base(message) + { + } +} + +internal class ReferenceSymbols +{ +#pragma warning disable SA1401 // Fields should be private + internal readonly INamedTypeSymbol? Task; + internal readonly INamedTypeSymbol? TaskOfT; + internal readonly INamedTypeSymbol MessagePackObjectAttribute; + internal readonly INamedTypeSymbol UnionAttribute; + internal readonly INamedTypeSymbol SerializationConstructorAttribute; + internal readonly INamedTypeSymbol KeyAttribute; + internal readonly INamedTypeSymbol IgnoreAttribute; + internal readonly INamedTypeSymbol? IgnoreDataMemberAttribute; + internal readonly INamedTypeSymbol IMessagePackSerializationCallbackReceiver; + internal readonly INamedTypeSymbol MessagePackFormatterAttribute; +#pragma warning restore SA1401 // Fields should be private + + public ReferenceSymbols(Compilation compilation, Action logger) + { + TaskOfT = compilation.GetTypeByMetadataName("System.Threading.Tasks.Task`1"); + if (TaskOfT == null) + { + logger("failed to get metadata of System.Threading.Tasks.Task`1"); + } + + Task = compilation.GetTypeByMetadataName("System.Threading.Tasks.Task"); + if (Task == null) + { + logger("failed to get metadata of System.Threading.Tasks.Task"); + } + + MessagePackObjectAttribute = compilation.GetTypeByMetadataName("MessagePack.MessagePackObjectAttribute") + ?? throw new InvalidOperationException("failed to get metadata of MessagePack.MessagePackObjectAttribute"); + + UnionAttribute = compilation.GetTypeByMetadataName("MessagePack.UnionAttribute") + ?? throw new InvalidOperationException("failed to get metadata of MessagePack.UnionAttribute"); + + SerializationConstructorAttribute = compilation.GetTypeByMetadataName("MessagePack.SerializationConstructorAttribute") + ?? throw new InvalidOperationException("failed to get metadata of MessagePack.SerializationConstructorAttribute"); + + KeyAttribute = compilation.GetTypeByMetadataName("MessagePack.KeyAttribute") + ?? throw new InvalidOperationException("failed to get metadata of MessagePack.KeyAttribute"); + + IgnoreAttribute = compilation.GetTypeByMetadataName("MessagePack.IgnoreMemberAttribute") + ?? throw new InvalidOperationException("failed to get metadata of MessagePack.IgnoreMemberAttribute"); + + IgnoreDataMemberAttribute = compilation.GetTypeByMetadataName("System.Runtime.Serialization.IgnoreDataMemberAttribute"); + if (IgnoreDataMemberAttribute == null) + { + logger("failed to get metadata of System.Runtime.Serialization.IgnoreDataMemberAttribute"); + } + + IMessagePackSerializationCallbackReceiver = compilation.GetTypeByMetadataName("MessagePack.IMessagePackSerializationCallbackReceiver") + ?? throw new InvalidOperationException("failed to get metadata of MessagePack.IMessagePackSerializationCallbackReceiver"); + + MessagePackFormatterAttribute = compilation.GetTypeByMetadataName("MessagePack.MessagePackFormatterAttribute") + ?? throw new InvalidOperationException("failed to get metadata of MessagePack.MessagePackFormatterAttribute"); + } +} + +public class TypeCollector +{ + private static readonly SymbolDisplayFormat BinaryWriteFormat = new SymbolDisplayFormat( + genericsOptions: SymbolDisplayGenericsOptions.IncludeTypeParameters, + miscellaneousOptions: SymbolDisplayMiscellaneousOptions.ExpandNullable, + typeQualificationStyle: SymbolDisplayTypeQualificationStyle.NameOnly); + + private static readonly SymbolDisplayFormat ShortTypeNameFormat = new SymbolDisplayFormat( + typeQualificationStyle: SymbolDisplayTypeQualificationStyle.NameAndContainingTypes); + + private readonly bool isForceUseMap; + private readonly ReferenceSymbols typeReferences; + private readonly ITypeSymbol[] targetTypes; + private readonly HashSet embeddedTypes = new(new[] + { + "short", + "int", + "long", + "ushort", + "uint", + "ulong", + "float", + "double", + "bool", + "byte", + "sbyte", + "decimal", + "char", + "string", + "object", + "System.Guid", + "System.TimeSpan", + "System.DateTime", + "System.DateTimeOffset", + + "MessagePack.Nil", + + // and arrays + "short[]", + "int[]", + "long[]", + "ushort[]", + "uint[]", + "ulong[]", + "float[]", + "double[]", + "bool[]", + "byte[]", + "sbyte[]", + "decimal[]", + "char[]", + "string[]", + "System.DateTime[]", + "System.ArraySegment", + "System.ArraySegment?", + + // extensions + "UnityEngine.Vector2", + "UnityEngine.Vector3", + "UnityEngine.Vector4", + "UnityEngine.Quaternion", + "UnityEngine.Color", + "UnityEngine.Bounds", + "UnityEngine.Rect", + "UnityEngine.AnimationCurve", + "UnityEngine.RectOffset", + "UnityEngine.Gradient", + "UnityEngine.WrapMode", + "UnityEngine.GradientMode", + "UnityEngine.Keyframe", + "UnityEngine.Matrix4x4", + "UnityEngine.GradientColorKey", + "UnityEngine.GradientAlphaKey", + "UnityEngine.Color32", + "UnityEngine.LayerMask", + "UnityEngine.Vector2Int", + "UnityEngine.Vector3Int", + "UnityEngine.RangeInt", + "UnityEngine.RectInt", + "UnityEngine.BoundsInt", + + "System.Reactive.Unit", + }); + + private readonly Dictionary knownGenericTypes = new() + { +#pragma warning disable SA1509 // Opening braces should not be preceded by blank line + { "System.Collections.Generic.List<>", "global::MessagePack.Formatters.ListFormatter" }, + { "System.Collections.Generic.LinkedList<>", "global::MessagePack.Formatters.LinkedListFormatter" }, + { "System.Collections.Generic.Queue<>", "global::MessagePack.Formatters.QueueFormatter" }, + { "System.Collections.Generic.Stack<>", "global::MessagePack.Formatters.StackFormatter" }, + { "System.Collections.Generic.HashSet<>", "global::MessagePack.Formatters.HashSetFormatter" }, + { "System.Collections.ObjectModel.ReadOnlyCollection<>", "global::MessagePack.Formatters.ReadOnlyCollectionFormatter" }, + { "System.Collections.Generic.IList<>", "global::MessagePack.Formatters.InterfaceListFormatter2" }, + { "System.Collections.Generic.ICollection<>", "global::MessagePack.Formatters.InterfaceCollectionFormatter2" }, + { "System.Collections.Generic.IEnumerable<>", "global::MessagePack.Formatters.InterfaceEnumerableFormatter" }, + { "System.Collections.Generic.Dictionary<,>", "global::MessagePack.Formatters.DictionaryFormatter" }, + { "System.Collections.Generic.IDictionary<,>", "global::MessagePack.Formatters.InterfaceDictionaryFormatter" }, + { "System.Collections.Generic.SortedDictionary<,>", "global::MessagePack.Formatters.SortedDictionaryFormatter" }, + { "System.Collections.Generic.SortedList<,>", "global::MessagePack.Formatters.SortedListFormatter" }, + { "System.Linq.ILookup<,>", "global::MessagePack.Formatters.InterfaceLookupFormatter" }, + { "System.Linq.IGrouping<,>", "global::MessagePack.Formatters.InterfaceGroupingFormatter" }, + { "System.Collections.ObjectModel.ObservableCollection<>", "global::MessagePack.Formatters.ObservableCollectionFormatter" }, + { "System.Collections.ObjectModel.ReadOnlyObservableCollection<>", "global::MessagePack.Formatters.ReadOnlyObservableCollectionFormatter" }, + { "System.Collections.Generic.IReadOnlyList<>", "global::MessagePack.Formatters.InterfaceReadOnlyListFormatter" }, + { "System.Collections.Generic.IReadOnlyCollection<>", "global::MessagePack.Formatters.InterfaceReadOnlyCollectionFormatter" }, + { "System.Collections.Generic.ISet<>", "global::MessagePack.Formatters.InterfaceSetFormatter" }, + { "System.Collections.Concurrent.ConcurrentBag<>", "global::MessagePack.Formatters.ConcurrentBagFormatter" }, + { "System.Collections.Concurrent.ConcurrentQueue<>", "global::MessagePack.Formatters.ConcurrentQueueFormatter" }, + { "System.Collections.Concurrent.ConcurrentStack<>", "global::MessagePack.Formatters.ConcurrentStackFormatter" }, + { "System.Collections.ObjectModel.ReadOnlyDictionary<,>", "global::MessagePack.Formatters.ReadOnlyDictionaryFormatter" }, + { "System.Collections.Generic.IReadOnlyDictionary<,>", "global::MessagePack.Formatters.InterfaceReadOnlyDictionaryFormatter" }, + { "System.Collections.Concurrent.ConcurrentDictionary<,>", "global::MessagePack.Formatters.ConcurrentDictionaryFormatter" }, + { "System.Lazy<>", "global::MessagePack.Formatters.LazyFormatter" }, + { "System.Threading.Tasks<>", "global::MessagePack.Formatters.TaskValueFormatter" }, + + { "System.Tuple<>", "global::MessagePack.Formatters.TupleFormatter" }, + { "System.Tuple<,>", "global::MessagePack.Formatters.TupleFormatter" }, + { "System.Tuple<,,>", "global::MessagePack.Formatters.TupleFormatter" }, + { "System.Tuple<,,,>", "global::MessagePack.Formatters.TupleFormatter" }, + { "System.Tuple<,,,,>", "global::MessagePack.Formatters.TupleFormatter" }, + { "System.Tuple<,,,,,>", "global::MessagePack.Formatters.TupleFormatter" }, + { "System.Tuple<,,,,,,>", "global::MessagePack.Formatters.TupleFormatter" }, + { "System.Tuple<,,,,,,,>", "global::MessagePack.Formatters.TupleFormatter" }, + + { "System.ValueTuple<>", "global::MessagePack.Formatters.ValueTupleFormatter" }, + { "System.ValueTuple<,>", "global::MessagePack.Formatters.ValueTupleFormatter" }, + { "System.ValueTuple<,,>", "global::MessagePack.Formatters.ValueTupleFormatter" }, + { "System.ValueTuple<,,,>", "global::MessagePack.Formatters.ValueTupleFormatter" }, + { "System.ValueTuple<,,,,>", "global::MessagePack.Formatters.ValueTupleFormatter" }, + { "System.ValueTuple<,,,,,>", "global::MessagePack.Formatters.ValueTupleFormatter" }, + { "System.ValueTuple<,,,,,,>", "global::MessagePack.Formatters.ValueTupleFormatter" }, + { "System.ValueTuple<,,,,,,,>", "global::MessagePack.Formatters.ValueTupleFormatter" }, + + { "System.Collections.Generic.KeyValuePair<,>", "global::MessagePack.Formatters.KeyValuePairFormatter" }, + { "System.Threading.Tasks.ValueTask<>", "global::MessagePack.Formatters.KeyValuePairFormatter" }, + { "System.ArraySegment<>", "global::MessagePack.Formatters.ArraySegmentFormatter" }, + + // extensions + { "System.Collections.Immutable.ImmutableArray<>", "global::MessagePack.ImmutableCollection.ImmutableArrayFormatter" }, + { "System.Collections.Immutable.ImmutableList<>", "global::MessagePack.ImmutableCollection.ImmutableListFormatter" }, + { "System.Collections.Immutable.ImmutableDictionary<,>", "global::MessagePack.ImmutableCollection.ImmutableDictionaryFormatter" }, + { "System.Collections.Immutable.ImmutableHashSet<>", "global::MessagePack.ImmutableCollection.ImmutableHashSetFormatter" }, + { "System.Collections.Immutable.ImmutableSortedDictionary<,>", "global::MessagePack.ImmutableCollection.ImmutableSortedDictionaryFormatter" }, + { "System.Collections.Immutable.ImmutableSortedSet<>", "global::MessagePack.ImmutableCollection.ImmutableSortedSetFormatter" }, + { "System.Collections.Immutable.ImmutableQueue<>", "global::MessagePack.ImmutableCollection.ImmutableQueueFormatter" }, + { "System.Collections.Immutable.ImmutableStack<>", "global::MessagePack.ImmutableCollection.ImmutableStackFormatter" }, + { "System.Collections.Immutable.IImmutableList<>", "global::MessagePack.ImmutableCollection.InterfaceImmutableListFormatter" }, + { "System.Collections.Immutable.IImmutableDictionary<,>", "global::MessagePack.ImmutableCollection.InterfaceImmutableDictionaryFormatter" }, + { "System.Collections.Immutable.IImmutableQueue<>", "global::MessagePack.ImmutableCollection.InterfaceImmutableQueueFormatter" }, + { "System.Collections.Immutable.IImmutableSet<>", "global::MessagePack.ImmutableCollection.InterfaceImmutableSetFormatter" }, + { "System.Collections.Immutable.IImmutableStack<>", "global::MessagePack.ImmutableCollection.InterfaceImmutableStackFormatter" }, + + { "Reactive.Bindings.ReactiveProperty<>", "global::MessagePack.ReactivePropertyExtension.ReactivePropertyFormatter" }, + { "Reactive.Bindings.IReactiveProperty<>", "global::MessagePack.ReactivePropertyExtension.InterfaceReactivePropertyFormatter" }, + { "Reactive.Bindings.IReadOnlyReactiveProperty<>", "global::MessagePack.ReactivePropertyExtension.InterfaceReadOnlyReactivePropertyFormatter" }, + { "Reactive.Bindings.ReactiveCollection<>", "global::MessagePack.ReactivePropertyExtension.ReactiveCollectionFormatter" }, +#pragma warning restore SA1509 // Opening braces should not be preceded by blank line + }; + + private readonly bool disallowInternal; + + private readonly bool excludeArrayElement; + + private readonly HashSet externalIgnoreTypeNames; + + // visitor workspace: +#pragma warning disable RS1024 // Compare symbols correctly (https://github.com/dotnet/roslyn-analyzers/issues/5246) + private readonly HashSet alreadyCollected = new(SymbolEqualityComparer.Default); +#pragma warning restore RS1024 // Compare symbols correctly + private readonly List collectedObjectInfo = new(); + private readonly List collectedEnumInfo = new(); + private readonly List collectedGenericInfo = new(); + private readonly List collectedUnionInfo = new(); + + private readonly Compilation compilation; + + public TypeCollector(Compilation compilation, bool disallowInternal, bool isForceUseMap, string[]? ignoreTypeNames, Action logger) + { + this.typeReferences = new ReferenceSymbols(compilation, logger); + this.disallowInternal = disallowInternal; + this.isForceUseMap = isForceUseMap; + this.externalIgnoreTypeNames = new HashSet(ignoreTypeNames ?? Array.Empty()); + this.compilation = compilation; + + targetTypes = compilation.GetNamedTypeSymbols() + .Where(x => + { + if (x.DeclaredAccessibility == Accessibility.Public) + { + return true; + } + + if (!disallowInternal) + { + return x.DeclaredAccessibility == Accessibility.Friend; + } + + return false; + }) + .Where(x => + ((x.TypeKind == TypeKind.Interface) && x.GetAttributes().Any(x2 => x2.AttributeClass.ApproximatelyEqual(typeReferences.UnionAttribute))) + || ((x.TypeKind == TypeKind.Class && x.IsAbstract) && x.GetAttributes().Any(x2 => x2.AttributeClass.ApproximatelyEqual(typeReferences.UnionAttribute))) + || ((x.TypeKind == TypeKind.Class) && x.GetAttributes().Any(x2 => x2.AttributeClass.ApproximatelyEqual(typeReferences.MessagePackObjectAttribute))) + || ((x.TypeKind == TypeKind.Struct) && x.GetAttributes().Any(x2 => x2.AttributeClass.ApproximatelyEqual(typeReferences.MessagePackObjectAttribute)))) + .ToArray(); + } + + public TypeCollector(Compilation compilation, bool disallowInternal, bool isForceUseMap, string[]? ignoreTypeNames, ITypeSymbol targetType) + { + this.typeReferences = new ReferenceSymbols(compilation, _ => { }); + this.disallowInternal = disallowInternal; + this.isForceUseMap = isForceUseMap; + this.externalIgnoreTypeNames = new HashSet(ignoreTypeNames ?? Array.Empty()); + this.compilation = compilation; + this.excludeArrayElement = true; + + targetTypes = new[] { targetType } + .Where(x => + { + if (x.DeclaredAccessibility == Accessibility.Public) + { + return true; + } + + if (!disallowInternal) + { + return x.DeclaredAccessibility == Accessibility.Friend; + } + + return false; + }) + .Where(x => + ((x.TypeKind == TypeKind.Interface) && x.GetAttributes().Any(x2 => x2.AttributeClass.ApproximatelyEqual(typeReferences.UnionAttribute))) + || ((x.TypeKind == TypeKind.Class && x.IsAbstract) && x.GetAttributes().Any(x2 => x2.AttributeClass.ApproximatelyEqual(typeReferences.UnionAttribute))) + || ((x.TypeKind == TypeKind.Class) && x.GetAttributes().Any(x2 => x2.AttributeClass.ApproximatelyEqual(typeReferences.MessagePackObjectAttribute))) + || ((x.TypeKind == TypeKind.Struct) && x.GetAttributes().Any(x2 => x2.AttributeClass.ApproximatelyEqual(typeReferences.MessagePackObjectAttribute)))) + .ToArray(); + } + + private void ResetWorkspace() + { + this.alreadyCollected.Clear(); + this.collectedObjectInfo.Clear(); + this.collectedEnumInfo.Clear(); + this.collectedGenericInfo.Clear(); + this.collectedUnionInfo.Clear(); + } + + // EntryPoint + public (ObjectSerializationInfo[] ObjectInfo, EnumSerializationInfo[] EnumInfo, GenericSerializationInfo[] GenericInfo, UnionSerializationInfo[] UnionInfo) Collect() + { + this.ResetWorkspace(); + + foreach (var item in this.targetTypes) + { + this.CollectCore(item); + } + + return ( + this.collectedObjectInfo.OrderBy(x => x.FullName).ToArray(), + this.collectedEnumInfo.OrderBy(x => x.FullName).ToArray(), + this.collectedGenericInfo.Distinct().OrderBy(x => x.FullName).ToArray(), + this.collectedUnionInfo.OrderBy(x => x.FullName).ToArray()); + } + + // Gate of recursive collect + private void CollectCore(ITypeSymbol typeSymbol) + { + if (!this.alreadyCollected.Add(typeSymbol)) + { + return; + } + + var typeSymbolString = typeSymbol.WithNullableAnnotation(NullableAnnotation.NotAnnotated).ToString() ?? throw new InvalidOperationException(); + if (this.embeddedTypes.Contains(typeSymbolString)) + { + return; + } + + if (this.externalIgnoreTypeNames.Contains(typeSymbolString)) + { + return; + } + + if (typeSymbol is IArrayTypeSymbol arrayTypeSymbol) + { + this.CollectArray((IArrayTypeSymbol)ToTupleUnderlyingType(arrayTypeSymbol)); + return; + } + + if (!this.IsAllowAccessibility(typeSymbol)) + { + return; + } + + if (!(typeSymbol is INamedTypeSymbol type)) + { + return; + } + + var customFormatterAttr = typeSymbol.GetAttributes().FirstOrDefault(x => x.AttributeClass.ApproximatelyEqual(this.typeReferences.MessagePackFormatterAttribute)); + if (customFormatterAttr != null) + { + return; + } + + if (type.EnumUnderlyingType != null) + { + this.CollectEnum(type, type.EnumUnderlyingType); + return; + } + + if (type.IsGenericType) + { + this.CollectGeneric((INamedTypeSymbol)ToTupleUnderlyingType(type)); + return; + } + + if (type.Locations[0].IsInMetadata) + { + return; + } + + if (type.TypeKind == TypeKind.Interface || (type.TypeKind == TypeKind.Class && type.IsAbstract)) + { + this.CollectUnion(type); + return; + } + + this.CollectObject(type); + } + + private void CollectEnum(INamedTypeSymbol type, ISymbol enumUnderlyingType) + { + var info = new EnumSerializationInfo(type.ContainingNamespace.IsGlobalNamespace ? null : type.ContainingNamespace.ToDisplayString(), type.ToDisplayString(ShortTypeNameFormat).Replace(".", "_"), type.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat), enumUnderlyingType.ToDisplayString(BinaryWriteFormat)); + this.collectedEnumInfo.Add(info); + } + + private void CollectUnion(INamedTypeSymbol type) + { + ImmutableArray[] unionAttrs = type.GetAttributes().Where(x => x.AttributeClass.ApproximatelyEqual(this.typeReferences.UnionAttribute)).Select(x => x.ConstructorArguments).ToArray(); + if (unionAttrs.Length == 0) + { + throw new MessagePackGeneratorResolveFailedException("Serialization Type must mark UnionAttribute." + " type: " + type.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat)); + } + + // 0, Int 1, SubType + UnionSubTypeInfo UnionSubTypeInfoSelector(ImmutableArray x) + { + if (!(x[0] is { Value: int key }) || !(x[1] is { Value: ITypeSymbol typeSymbol })) + { + throw new NotSupportedException("AOT code generation only supports UnionAttribute that uses a Type parameter, but the " + type.ToDisplayString(SymbolDisplayFormat.CSharpErrorMessageFormat) + " type uses an unsupported parameter."); + } + + var typeName = typeSymbol.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat); + return new UnionSubTypeInfo(key, typeName); + } + + var info = new UnionSerializationInfo(type.ContainingNamespace.IsGlobalNamespace ? null : type.ContainingNamespace.ToDisplayString(), type.Name, type.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat), unionAttrs.Select(UnionSubTypeInfoSelector).OrderBy(x => x.Key).ToArray()); + + this.collectedUnionInfo.Add(info); + } + + private void CollectGenericUnion(INamedTypeSymbol type) + { + var unionAttrs = type.GetAttributes().Where(x => x.AttributeClass.ApproximatelyEqual(this.typeReferences.UnionAttribute)).Select(x => x.ConstructorArguments); + using var enumerator = unionAttrs.GetEnumerator(); + if (!enumerator.MoveNext()) + { + return; + } + + do + { + var x = enumerator.Current; + if (x[1] is { Value: INamedTypeSymbol unionType } && alreadyCollected.Contains(unionType) == false) + { + CollectCore(unionType); + } + } + while (enumerator.MoveNext()); + } + + private void CollectArray(IArrayTypeSymbol array) + { + ITypeSymbol elemType = array.ElementType; + if (!excludeArrayElement) + { + this.CollectCore(elemType); + } + + var fullName = array.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat); + var elementTypeDisplayName = elemType.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat); + string formatterName; + if (array.IsSZArray) + { + formatterName = "global::MessagePack.Formatters.ArrayFormatter<" + elementTypeDisplayName + ">"; + } + else + { + formatterName = array.Rank switch + { + 2 => "global::MessagePack.Formatters.TwoDimensionalArrayFormatter<" + elementTypeDisplayName + ">", + 3 => "global::MessagePack.Formatters.ThreeDimensionalArrayFormatter<" + elementTypeDisplayName + ">", + 4 => "global::MessagePack.Formatters.FourDimensionalArrayFormatter<" + elementTypeDisplayName + ">", + _ => throw new InvalidOperationException("does not supports array dimension, " + fullName), + }; + } + + var info = new GenericSerializationInfo(fullName, formatterName, elemType is ITypeParameterSymbol); + this.collectedGenericInfo.Add(info); + } + + private ITypeSymbol ToTupleUnderlyingType(ITypeSymbol typeSymbol) + { + if (typeSymbol is IArrayTypeSymbol array) + { + return compilation.CreateArrayTypeSymbol(ToTupleUnderlyingType(array.ElementType), array.Rank); + } + + if (typeSymbol is not INamedTypeSymbol namedType || !namedType.IsGenericType) + { + return typeSymbol; + } + + namedType = namedType.TupleUnderlyingType ?? namedType; + var newTypeArguments = namedType.TypeArguments.Select(ToTupleUnderlyingType).ToArray(); + if (!namedType.TypeArguments.SequenceEqual(newTypeArguments)) + { + return namedType.ConstructedFrom.Construct(newTypeArguments); + } + + return namedType; + } + + private void CollectGeneric(INamedTypeSymbol type) + { + INamedTypeSymbol genericType = type.ConstructUnboundGenericType(); + var genericTypeString = genericType.ToDisplayString(); + var fullName = type.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat); + var isOpenGenericType = IsOpenGenericTypeRecursively(type); + + // special case + if (fullName == "global::System.ArraySegment" || fullName == "global::System.ArraySegment?") + { + return; + } + + // nullable + if (genericTypeString == "T?") + { + var firstTypeArgument = type.TypeArguments[0]; + this.CollectCore(firstTypeArgument); + + if (this.embeddedTypes.Contains(firstTypeArgument.ToString()!)) + { + return; + } + + var info = new GenericSerializationInfo(type.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat), "global::MessagePack.Formatters.NullableFormatter<" + firstTypeArgument.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat) + ">", isOpenGenericType); + this.collectedGenericInfo.Add(info); + return; + } + + // collection + if (this.knownGenericTypes.TryGetValue(genericTypeString, out var formatter)) + { + foreach (ITypeSymbol item in type.TypeArguments) + { + this.CollectCore(item); + } + + var typeArgs = string.Join(", ", type.TypeArguments.Select(x => x.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat))); + var f = formatter.Replace("TREPLACE", typeArgs); + + var info = new GenericSerializationInfo(type.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat), f, isOpenGenericType); + + this.collectedGenericInfo.Add(info); + + if (genericTypeString != "System.Linq.ILookup<,>") + { + return; + } + + formatter = this.knownGenericTypes["System.Linq.IGrouping<,>"]; + f = formatter.Replace("TREPLACE", typeArgs); + + var groupingInfo = new GenericSerializationInfo("global::System.Linq.IGrouping<" + typeArgs + ">", f, isOpenGenericType); + this.collectedGenericInfo.Add(groupingInfo); + + formatter = this.knownGenericTypes["System.Collections.Generic.IEnumerable<>"]; + typeArgs = type.TypeArguments[1].ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat); + f = formatter.Replace("TREPLACE", typeArgs); + + var enumerableInfo = new GenericSerializationInfo("global::System.Collections.Generic.IEnumerable<" + typeArgs + ">", f, isOpenGenericType); + this.collectedGenericInfo.Add(enumerableInfo); + return; + } + + // Generic types + if (type.IsDefinition) + { + this.CollectGenericUnion(type); + this.CollectObject(type); + return; + } + else + { + // Collect substituted types for the properties and fields. + // NOTE: It is used to register formatters from nested generic type. + // However, closed generic types such as `Foo` are not registered as a formatter. + GetObjectInfo(type); + + // Collect generic type definition, that is not collected when it is defined outside target project. + CollectCore(type.OriginalDefinition); + } + + // Collect substituted types for the type parameters (e.g. Bar in Foo) + foreach (var item in type.TypeArguments) + { + this.CollectCore(item); + } + + var formatterBuilder = new StringBuilder(); + if (!type.ContainingNamespace.IsGlobalNamespace) + { + formatterBuilder.Append(type.ContainingNamespace.ToDisplayString() + "."); + } + + formatterBuilder.Append(type.Name); + formatterBuilder.Append("Formatter<"); + var typeArgumentIterator = type.TypeArguments.GetEnumerator(); + { + if (typeArgumentIterator.MoveNext()) + { + formatterBuilder.Append(typeArgumentIterator.Current.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat)); + } + + while (typeArgumentIterator.MoveNext()) + { + formatterBuilder.Append(", "); + formatterBuilder.Append(typeArgumentIterator.Current.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat)); + } + } + + formatterBuilder.Append('>'); + + var genericSerializationInfo = new GenericSerializationInfo(type.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat), formatterBuilder.ToString(), isOpenGenericType); + this.collectedGenericInfo.Add(genericSerializationInfo); + } + + private void CollectObject(INamedTypeSymbol type) + { + ObjectSerializationInfo info = GetObjectInfo(type); + collectedObjectInfo.Add(info); + } + + private ObjectSerializationInfo GetObjectInfo(INamedTypeSymbol type) + { + var isClass = !type.IsValueType; + var isOpenGenericType = type.IsGenericType; + + AttributeData contractAttr = type.GetAttributes().FirstOrDefault(x => x.AttributeClass.ApproximatelyEqual(this.typeReferences.MessagePackObjectAttribute)) + ?? throw new MessagePackGeneratorResolveFailedException("Serialization Object must mark MessagePackObjectAttribute." + " type: " + type.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat)); + + var isIntKey = true; + var intMembers = new Dictionary(); + var stringMembers = new Dictionary(); + + if (this.isForceUseMap || (contractAttr.ConstructorArguments[0] is { Value: bool firstConstructorArgument } && firstConstructorArgument)) + { + // All public members are serialize target except [Ignore] member. + isIntKey = false; + + var hiddenIntKey = 0; + + foreach (IPropertySymbol item in type.GetAllMembers().OfType().Where(x => !x.IsOverride)) + { + if (item.GetAttributes().Any(x => (x.AttributeClass.ApproximatelyEqual(this.typeReferences.IgnoreAttribute) || x.AttributeClass?.Name == this.typeReferences.IgnoreDataMemberAttribute?.Name))) + { + continue; + } + + var isReadable = item.GetMethod != null && item.GetMethod.DeclaredAccessibility == Accessibility.Public && !item.IsStatic; + var isWritable = item.SetMethod != null && item.SetMethod.DeclaredAccessibility == Accessibility.Public && !item.IsStatic; + if (!isReadable && !isWritable) + { + continue; + } + + var customFormatterAttr = item.GetAttributes().FirstOrDefault(x => x.AttributeClass.ApproximatelyEqual(this.typeReferences.MessagePackFormatterAttribute))?.ConstructorArguments[0].Value as INamedTypeSymbol; + var member = new MemberSerializationInfo(true, isWritable, isReadable, hiddenIntKey++, item.Name, item.Name, item.Type.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat), item.Type.ToDisplayString(BinaryWriteFormat), customFormatterAttr?.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat)); + stringMembers.Add(member.StringKey, member); + + this.CollectCore(item.Type); // recursive collect + } + + foreach (IFieldSymbol item in type.GetAllMembers().OfType()) + { + if (item.GetAttributes().Any(x => (x.AttributeClass.ApproximatelyEqual(this.typeReferences.IgnoreAttribute) || x.AttributeClass?.Name == this.typeReferences.IgnoreDataMemberAttribute?.Name))) + { + continue; + } + + if (item.IsImplicitlyDeclared) + { + continue; + } + + var isReadable = item.DeclaredAccessibility == Accessibility.Public && !item.IsStatic; + var isWritable = item.DeclaredAccessibility == Accessibility.Public && !item.IsReadOnly && !item.IsStatic; + if (!isReadable && !isWritable) + { + continue; + } + + var customFormatterAttr = item.GetAttributes().FirstOrDefault(x => x.AttributeClass.ApproximatelyEqual(this.typeReferences.MessagePackFormatterAttribute))?.ConstructorArguments[0].Value as INamedTypeSymbol; + var member = new MemberSerializationInfo(false, isWritable, isReadable, hiddenIntKey++, item.Name, item.Name, item.Type.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat), item.Type.ToDisplayString(BinaryWriteFormat), customFormatterAttr?.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat)); + stringMembers.Add(member.StringKey, member); + this.CollectCore(item.Type); // recursive collect + } + } + else + { + // Only KeyAttribute members + var searchFirst = true; + var hiddenIntKey = 0; + + foreach (IPropertySymbol item in type.GetAllMembers().OfType()) + { + if (item.IsIndexer) + { + continue; // .tt files don't generate good code for this yet: https://github.com/neuecc/MessagePack-CSharp/issues/390 + } + + if (item.GetAttributes().Any(x => + { + var typeReferencesIgnoreDataMemberAttribute = this.typeReferences.IgnoreDataMemberAttribute; + return typeReferencesIgnoreDataMemberAttribute != null && (x.AttributeClass.ApproximatelyEqual(this.typeReferences.IgnoreAttribute) || x.AttributeClass.ApproximatelyEqual(typeReferencesIgnoreDataMemberAttribute)); + })) + { + continue; + } + + var isReadable = item.GetMethod != null && item.GetMethod.DeclaredAccessibility == Accessibility.Public && !item.IsStatic; + var isWritable = item.SetMethod != null && item.SetMethod.DeclaredAccessibility == Accessibility.Public && !item.IsStatic; + if (!isReadable && !isWritable) + { + continue; + } + + var customFormatterAttr = item.GetAttributes().FirstOrDefault(x => x.AttributeClass.ApproximatelyEqual(this.typeReferences.MessagePackFormatterAttribute))?.ConstructorArguments[0].Value as INamedTypeSymbol; + var key = item.GetAttributes().FirstOrDefault(x => x.AttributeClass.ApproximatelyEqual(this.typeReferences.KeyAttribute))?.ConstructorArguments[0] + ?? throw new MessagePackGeneratorResolveFailedException("all public members must mark KeyAttribute or IgnoreMemberAttribute." + " type: " + type.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat) + " member:" + item.Name); + + var intKey = key is { Value: int intKeyValue } ? intKeyValue : default(int?); + var stringKey = key is { Value: string stringKeyValue } ? stringKeyValue : default; + if (intKey == null && stringKey == null) + { + throw new MessagePackGeneratorResolveFailedException("both IntKey and StringKey are null." + " type: " + type.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat) + " member:" + item.Name); + } + + if (searchFirst) + { + searchFirst = false; + isIntKey = intKey != null; + } + else + { + if ((isIntKey && intKey == null) || (!isIntKey && stringKey == null)) + { + throw new MessagePackGeneratorResolveFailedException("all members key type must be same." + " type: " + type.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat) + " member:" + item.Name); + } + } + + if (isIntKey) + { + if (intMembers.ContainsKey(intKey!.Value)) + { + throw new MessagePackGeneratorResolveFailedException("key is duplicated, all members key must be unique." + " type: " + type.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat) + " member:" + item.Name); + } + + var member = new MemberSerializationInfo(true, isWritable, isReadable, intKey!.Value, item.Name, item.Name, item.Type.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat), item.Type.ToDisplayString(BinaryWriteFormat), customFormatterAttr?.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat)); + intMembers.Add(member.IntKey, member); + } + else + { + if (stringMembers.ContainsKey(stringKey!)) + { + throw new MessagePackGeneratorResolveFailedException("key is duplicated, all members key must be unique." + " type: " + type.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat) + " member:" + item.Name); + } + + var member = new MemberSerializationInfo(true, isWritable, isReadable, hiddenIntKey++, stringKey!, item.Name, item.Type.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat), item.Type.ToDisplayString(BinaryWriteFormat), customFormatterAttr?.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat)); + stringMembers.Add(member.StringKey, member); + } + + var messagePackFormatter = item.GetAttributes().FirstOrDefault(x => x.AttributeClass.ApproximatelyEqual(this.typeReferences.MessagePackFormatterAttribute))?.ConstructorArguments[0]; + + if (messagePackFormatter == null) + { + this.CollectCore(item.Type); // recursive collect + } + } + + foreach (IFieldSymbol item in type.GetAllMembers().OfType()) + { + if (item.IsImplicitlyDeclared) + { + continue; + } + + if (item.GetAttributes().Any(x => x.AttributeClass.ApproximatelyEqual(this.typeReferences.IgnoreAttribute))) + { + continue; + } + + var isReadable = item.DeclaredAccessibility == Accessibility.Public && !item.IsStatic; + var isWritable = item.DeclaredAccessibility == Accessibility.Public && !item.IsReadOnly && !item.IsStatic; + if (!isReadable && !isWritable) + { + continue; + } + + var customFormatterAttr = item.GetAttributes().FirstOrDefault(x => x.AttributeClass.ApproximatelyEqual(this.typeReferences.MessagePackFormatterAttribute))?.ConstructorArguments[0].Value as INamedTypeSymbol; + var key = item.GetAttributes().FirstOrDefault(x => x.AttributeClass.ApproximatelyEqual(this.typeReferences.KeyAttribute))?.ConstructorArguments[0] + ?? throw new MessagePackGeneratorResolveFailedException("all public members must mark KeyAttribute or IgnoreMemberAttribute." + " type: " + type.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat) + " member:" + item.Name); + + var intKey = key is { Value: int intKeyValue } ? intKeyValue : default(int?); + var stringKey = key is { Value: string stringKeyValue } ? stringKeyValue : default; + if (intKey == null && stringKey == null) + { + throw new MessagePackGeneratorResolveFailedException("both IntKey and StringKey are null." + " type: " + type.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat) + " member:" + item.Name); + } + + if (searchFirst) + { + searchFirst = false; + isIntKey = intKey != null; + } + else + { + if ((isIntKey && intKey == null) || (!isIntKey && stringKey == null)) + { + throw new MessagePackGeneratorResolveFailedException("all members key type must be same." + " type: " + type.Name + " member:" + item.Name); + } + } + + if (isIntKey) + { + if (intMembers.ContainsKey(intKey!.Value)) + { + throw new MessagePackGeneratorResolveFailedException("key is duplicated, all members key must be unique." + " type: " + type.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat) + " member:" + item.Name); + } + + var member = new MemberSerializationInfo(true, isWritable, isReadable, intKey!.Value, item.Name, item.Name, item.Type.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat), item.Type.ToDisplayString(BinaryWriteFormat), customFormatterAttr?.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat)); + intMembers.Add(member.IntKey, member); + } + else + { + if (stringMembers.ContainsKey(stringKey!)) + { + throw new MessagePackGeneratorResolveFailedException("key is duplicated, all members key must be unique." + " type: " + type.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat) + " member:" + item.Name); + } + + var member = new MemberSerializationInfo(true, isWritable, isReadable, hiddenIntKey++, stringKey!, item.Name, item.Type.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat), item.Type.ToDisplayString(BinaryWriteFormat), customFormatterAttr?.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat)); + stringMembers.Add(member.StringKey, member); + } + + this.CollectCore(item.Type); // recursive collect + } + } + + // GetConstructor + var ctorEnumerator = default(IEnumerator); + var ctor = type.Constructors.Where(x => x.DeclaredAccessibility == Accessibility.Public).SingleOrDefault(x => x.GetAttributes().Any(y => y.AttributeClass != null && y.AttributeClass.ApproximatelyEqual(this.typeReferences.SerializationConstructorAttribute))); + if (ctor == null) + { + ctorEnumerator = type.Constructors.Where(x => x.DeclaredAccessibility == Accessibility.Public).OrderByDescending(x => x.Parameters.Length).GetEnumerator(); + + if (ctorEnumerator.MoveNext()) + { + ctor = ctorEnumerator.Current; + } + } + + // struct allows null ctor + if (ctor == null && isClass) + { + throw new MessagePackGeneratorResolveFailedException("can't find public constructor. type:" + type.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat)); + } + + var constructorParameters = new List(); + if (ctor != null) + { + var constructorLookupDictionary = stringMembers.ToLookup(x => x.Key, x => x, StringComparer.OrdinalIgnoreCase); + do + { + constructorParameters.Clear(); + var ctorParamIndex = 0; + foreach (IParameterSymbol item in ctor!.Parameters) + { + MemberSerializationInfo paramMember; + if (isIntKey) + { + if (intMembers.TryGetValue(ctorParamIndex, out paramMember!)) + { + if (item.Type.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat) == paramMember.Type && paramMember.IsReadable) + { + constructorParameters.Add(paramMember); + } + else + { + if (ctorEnumerator != null) + { + ctor = null; + continue; + } + else + { + throw new MessagePackGeneratorResolveFailedException("can't find matched constructor parameter, parameterType mismatch. type:" + type.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat) + " parameterIndex:" + ctorParamIndex + " parameterType:" + item.Type.Name); + } + } + } + else + { + if (ctorEnumerator != null) + { + ctor = null; + continue; + } + else + { + throw new MessagePackGeneratorResolveFailedException("can't find matched constructor parameter, index not found. type:" + type.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat) + " parameterIndex:" + ctorParamIndex); + } + } + } + else + { + IEnumerable> hasKey = constructorLookupDictionary[item.Name]; + using var enumerator = hasKey.GetEnumerator(); + + // hasKey.Count() == 0 + if (!enumerator.MoveNext()) + { + if (ctorEnumerator == null) + { + throw new MessagePackGeneratorResolveFailedException("can't find matched constructor parameter, index not found. type:" + type.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat) + " parameterName:" + item.Name); + } + + ctor = null; + continue; + } + + var first = enumerator.Current.Value; + + // hasKey.Count() != 1 + if (enumerator.MoveNext()) + { + if (ctorEnumerator == null) + { + throw new MessagePackGeneratorResolveFailedException("duplicate matched constructor parameter name:" + type.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat) + " parameterName:" + item.Name + " parameterType:" + item.Type.Name); + } + + ctor = null; + continue; + } + + paramMember = first; + if (item.Type.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat) == paramMember.Type && paramMember.IsReadable) + { + constructorParameters.Add(paramMember); + } + else + { + if (ctorEnumerator == null) + { + throw new MessagePackGeneratorResolveFailedException("can't find matched constructor parameter, parameterType mismatch. type:" + type.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat) + " parameterName:" + item.Name + " parameterType:" + item.Type.Name); + } + + ctor = null; + continue; + } + } + + ctorParamIndex++; + } + } + while (TryGetNextConstructor(ctorEnumerator, ref ctor)); + + if (ctor == null) + { + throw new MessagePackGeneratorResolveFailedException("can't find matched constructor. type:" + type.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat)); + } + } + + var hasSerializationConstructor = type.AllInterfaces.Any(x => x.ApproximatelyEqual(this.typeReferences.IMessagePackSerializationCallbackReceiver)); + var needsCastOnBefore = true; + var needsCastOnAfter = true; + if (hasSerializationConstructor) + { + needsCastOnBefore = !type.GetMembers("OnBeforeSerialize").Any(); + needsCastOnAfter = !type.GetMembers("OnAfterDeserialize").Any(); + } + + var info = new ObjectSerializationInfo(isClass, isOpenGenericType, isOpenGenericType ? type.TypeParameters.Select(ToGenericTypeParameterInfo).ToArray() : Array.Empty(), constructorParameters.ToArray(), isIntKey, isIntKey ? intMembers.Values.ToArray() : stringMembers.Values.ToArray(), isOpenGenericType ? GetGenericFormatterClassName(type) : GetMinimallyQualifiedClassName(type), type.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat), type.ContainingNamespace.IsGlobalNamespace ? null : type.ContainingNamespace.ToDisplayString(), hasSerializationConstructor, needsCastOnAfter, needsCastOnBefore); + + return info; + } + + private static GenericTypeParameterInfo ToGenericTypeParameterInfo(ITypeParameterSymbol typeParameter) + { + var constraints = new List(); + + // `notnull`, `unmanaged`, `class`, `struct` constraint must come before any constraints. + if (typeParameter.HasNotNullConstraint) + { + constraints.Add("notnull"); + } + + if (typeParameter.HasReferenceTypeConstraint) + { + constraints.Add(typeParameter.ReferenceTypeConstraintNullableAnnotation == NullableAnnotation.Annotated ? "class?" : "class"); + } + + if (typeParameter.HasValueTypeConstraint) + { + constraints.Add(typeParameter.HasUnmanagedTypeConstraint ? "unmanaged" : "struct"); + } + + // constraint types (IDisposable, IEnumerable ...) + foreach (var t in typeParameter.ConstraintTypes) + { + var constraintTypeFullName = t.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat.AddMiscellaneousOptions(SymbolDisplayMiscellaneousOptions.IncludeNullableReferenceTypeModifier)); + constraints.Add(constraintTypeFullName); + } + + // `new()` constraint must be last in constraints. + if (typeParameter.HasConstructorConstraint) + { + constraints.Add("new()"); + } + + return new GenericTypeParameterInfo(typeParameter.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat), string.Join(", ", constraints)); + } + + private static string GetGenericFormatterClassName(INamedTypeSymbol type) + { + return type.Name; + } + + private static string GetMinimallyQualifiedClassName(INamedTypeSymbol type) + { + var name = type.ContainingType is object ? GetMinimallyQualifiedClassName(type.ContainingType) + "_" : string.Empty; + name += type.ToDisplayString(SymbolDisplayFormat.MinimallyQualifiedFormat); + name = name.Replace('.', '_'); + name = name.Replace('<', '_'); + name = name.Replace('>', '_'); + name = Regex.Replace(name, @"\[([,])*\]", match => $"Array{match.Length - 1}"); + name = name.Replace("?", string.Empty); + return name; + } + + private static bool TryGetNextConstructor(IEnumerator? ctorEnumerator, ref IMethodSymbol? ctor) + { + if (ctorEnumerator == null || ctor != null) + { + return false; + } + + if (ctorEnumerator.MoveNext()) + { + ctor = ctorEnumerator.Current; + return true; + } + else + { + ctor = null; + return false; + } + } + + private bool IsAllowAccessibility(ITypeSymbol symbol) + { + do + { + if (symbol.DeclaredAccessibility != Accessibility.Public) + { + if (this.disallowInternal) + { + return false; + } + + if (symbol.DeclaredAccessibility != Accessibility.Internal) + { + return true; + } + } + + symbol = symbol.ContainingType; + } + while (symbol != null); + + return true; + } + + private bool IsOpenGenericTypeRecursively(INamedTypeSymbol type) + { + return type.IsGenericType && type.TypeArguments.Any(x => x is ITypeParameterSymbol || (x is INamedTypeSymbol symbol && IsOpenGenericTypeRecursively(symbol))); + } +} diff --git a/src/MessagePack.Generator/CodeGenerator.cs b/src/MessagePack.Generator/CodeGenerator.cs new file mode 100644 index 000000000..9fce4c4bb --- /dev/null +++ b/src/MessagePack.Generator/CodeGenerator.cs @@ -0,0 +1,312 @@ +// Copyright (c) All contributors. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using System.Diagnostics; +using System.Text; +using MessagePack.Generator.CodeAnalysis; +using MessagePack.Generator.Transforms; +using Microsoft.CodeAnalysis; + +namespace MessagePack.Generator; + +public class CodeGenerator +{ + private static readonly HashSet InvalidFileCharSet = new(Path.GetInvalidFileNameChars()); + + private static readonly Encoding NoBomUtf8 = new UTF8Encoding(false); + + private readonly Action logger; + + public CodeGenerator(Action logger, CancellationToken cancellationToken) + { + this.logger = logger; + } + + /// + /// Generates the specialized resolver and formatters for the types that require serialization in a given compilation. + /// + /// The compilation to read types from as an input to code generation. + /// The name of the generated source file. + /// The resolver name. + /// The namespace for the generated type to be created in. May be null. + /// A boolean value that indicates whether all formatters should use property maps instead of more compact arrays. + /// A comma-delimited list of symbols that should surround redundant generated files. May be null. + /// May be null. + /// A task that indicates when generation has completed. + public async Task GenerateFileAsync( + Compilation compilation, + string output, + string resolverName, + string? @namespace, + bool useMapMode, + string? multipleIfDirectiveOutputSymbols, + string[]? externalIgnoreTypeNames) + { + var namespaceDot = string.IsNullOrWhiteSpace(@namespace) ? string.Empty : @namespace + "."; + var multipleOutputSymbols = multipleIfDirectiveOutputSymbols?.Split(',') ?? Array.Empty(); + + var sw = Stopwatch.StartNew(); + + foreach (var multiOutputSymbol in multipleOutputSymbols.Length == 0 ? new[] { string.Empty } : multipleOutputSymbols) + { + logger("Project Compilation Start:" + compilation.AssemblyName); + + var collector = new TypeCollector(compilation, true, useMapMode, externalIgnoreTypeNames, Console.WriteLine); + + logger("Project Compilation Complete:" + sw.Elapsed.ToString()); + + sw.Restart(); + logger("Method Collect Start"); + + var (objectInfo, enumInfo, genericInfo, unionInfo) = collector.Collect(); + + logger("Method Collect Complete:" + sw.Elapsed.ToString()); + + logger("Output Generation Start"); + sw.Restart(); + + if (Path.GetExtension(output) == ".cs") + { + // SingleFile Output + var fullGeneratedProgramText = GenerateSingleFileSync(resolverName, namespaceDot, objectInfo, enumInfo, unionInfo, genericInfo); + if (multiOutputSymbol == string.Empty) + { + await OutputAsync(output, fullGeneratedProgramText); + } + else + { + var fname = Path.GetFileNameWithoutExtension(output) + "." + MultiSymbolToSafeFilePath(multiOutputSymbol) + ".cs"; + var text = $"#if {multiOutputSymbol}" + Environment.NewLine + fullGeneratedProgramText + Environment.NewLine + "#endif"; + await OutputAsync(Path.Combine(Path.GetDirectoryName(output) ?? string.Empty, fname), text); + } + } + else + { + // Multiple File output + await GenerateMultipleFileAsync(output, resolverName, objectInfo, enumInfo, unionInfo, namespaceDot, multiOutputSymbol, genericInfo); + } + + if (objectInfo.Length == 0 && enumInfo.Length == 0 && genericInfo.Length == 0 && unionInfo.Length == 0) + { + logger("Generated result is empty, unexpected result?"); + } + } + + logger("Output Generation Complete:" + sw.Elapsed.ToString()); + } + + /// + /// Generates the specialized resolver and formatters for the types that require serialization in a given compilation. + /// + /// The resolver name. + /// The namespace for the generated type to be created in. + /// The ObjectSerializationInfo array which TypeCollector.Collect returns. + /// The EnumSerializationInfo array which TypeCollector.Collect returns. + /// The UnionSerializationInfo array which TypeCollector.Collect returns. + /// The GenericSerializationInfo array which TypeCollector.Collect returns. + public static string GenerateSingleFileSync(string resolverName, string namespaceDot, ObjectSerializationInfo[] objectInfo, EnumSerializationInfo[] enumInfo, UnionSerializationInfo[] unionInfo, GenericSerializationInfo[] genericInfo) + { + var objectFormatterTemplates = objectInfo + .GroupBy(x => (x.Namespace, x.IsStringKey)) + .Select(x => + { + var (nameSpace, isStringKey) = x.Key; + var objectSerializationInfos = x.ToArray(); + var ns = namespaceDot + "Formatters" + (nameSpace is null ? string.Empty : "." + nameSpace); + var template = isStringKey ? new StringKeyFormatterTemplate(ns, objectSerializationInfos) : (IFormatterTemplate)new FormatterTemplate(ns, objectSerializationInfos); + return template; + }) + .ToArray(); + + string GetNamespace(IGrouping x) + { + if (x.Key == null) + { + return namespaceDot + "Formatters"; + } + + return namespaceDot + "Formatters." + x.Key; + } + + var enumFormatterTemplates = enumInfo + .GroupBy(x => x.Namespace) + .Select(x => new EnumTemplate(GetNamespace(x), x.ToArray())) + .ToArray(); + + var unionFormatterTemplates = unionInfo + .GroupBy(x => x.Namespace) + .Select(x => new UnionTemplate(GetNamespace(x), x.ToArray())) + .ToArray(); + + var resolverTemplate = new ResolverTemplate(namespaceDot + "Resolvers", namespaceDot + "Formatters", resolverName, genericInfo.Where(x => !x.IsOpenGenericType).Cast().Concat(enumInfo).Concat(unionInfo).Concat(objectInfo.Where(x => !x.IsOpenGenericType)).ToArray()); + + var sb = new StringBuilder(); + sb.AppendLine(resolverTemplate.TransformText()); + sb.AppendLine(); + foreach (var item in enumFormatterTemplates) + { + var text = item.TransformText(); + sb.AppendLine(text); + } + + sb.AppendLine(); + foreach (var item in unionFormatterTemplates) + { + var text = item.TransformText(); + sb.AppendLine(text); + } + + sb.AppendLine(); + foreach (var item in objectFormatterTemplates) + { + var text = item.TransformText(); + sb.AppendLine(text); + } + + return sb.ToString(); + } + + private Task GenerateMultipleFileAsync(string output, string resolverName, ObjectSerializationInfo[] objectInfo, EnumSerializationInfo[] enumInfo, UnionSerializationInfo[] unionInfo, string namespaceDot, string multioutSymbol, GenericSerializationInfo[] genericInfo) + { + string GetNamespace(INamespaceInfo x) + { + if (x.Namespace == null) + { + return namespaceDot + "Formatters"; + } + + return namespaceDot + "Formatters." + x.Namespace; + } + + var waitingTasks = new Task[objectInfo.Length + enumInfo.Length + unionInfo.Length + 1]; + var waitingIndex = 0; + foreach (var x in objectInfo) + { + var ns = namespaceDot + "Formatters" + (x.Namespace is null ? string.Empty : "." + x.Namespace); + var template = x.IsStringKey ? new StringKeyFormatterTemplate(ns, new[] { x }) : (IFormatterTemplate)new FormatterTemplate(ns, new[] { x }); + var text = template.TransformText(); + waitingTasks[waitingIndex++] = OutputToDirAsync(output, template.Namespace, x.Name + "Formatter", multioutSymbol, text); + } + + foreach (var x in enumInfo) + { + var template = new EnumTemplate(GetNamespace(x), new[] { x }); + var text = template.TransformText(); + waitingTasks[waitingIndex++] = OutputToDirAsync(output, template.Namespace, x.Name + "Formatter", multioutSymbol, text); + } + + foreach (var x in unionInfo) + { + var template = new UnionTemplate(GetNamespace(x), new[] { x }); + var text = template.TransformText(); + waitingTasks[waitingIndex++] = OutputToDirAsync(output, template.Namespace, x.Name + "Formatter", multioutSymbol, text); + } + + var resolverTemplate = new ResolverTemplate(namespaceDot + "Resolvers", namespaceDot + "Formatters", resolverName, genericInfo.Where(x => !x.IsOpenGenericType).Cast().Concat(enumInfo).Concat(unionInfo).Concat(objectInfo.Where(x => !x.IsOpenGenericType)).ToArray()); + waitingTasks[waitingIndex] = OutputToDirAsync(output, resolverTemplate.Namespace, resolverTemplate.ResolverName, multioutSymbol, resolverTemplate.TransformText()); + return Task.WhenAll(waitingTasks); + } + + private Task OutputToDirAsync(string dir, string ns, string name, string multipleOutSymbol, string text) + { + var builder = new StringBuilder(); + void AppendDir(string dir) + { + if (dir.Length != 0) + { + builder.Append(dir); + if (dir[dir.Length - 1] != Path.DirectorySeparatorChar && dir[dir.Length - 1] != Path.AltDirectorySeparatorChar) + { + builder.Append(Path.DirectorySeparatorChar); + } + } + } + + void AppendChar(char c) + { + if (c == '.' || InvalidFileCharSet.Contains(c)) + { + builder.Append('_'); + } + else + { + builder.Append(c); + } + } + + void Append(string text) + { + var span = text.AsSpan(); + while (!span.IsEmpty) + { + var index = span.IndexOf("global::".AsSpan()); + if (index == -1) + { + foreach (var c in span) + { + AppendChar(c); + } + + break; + } + + if (index == 0) + { + span = span.Slice("global::".Length); + continue; + } + + foreach (var c in span.Slice(0, index)) + { + AppendChar(c); + } + + span = span.Slice(index + "global::".Length); + } + } + + AppendDir(dir); + + if (!string.IsNullOrWhiteSpace(multipleOutSymbol)) + { + text = $"#if {multipleOutSymbol}" + Environment.NewLine + text + Environment.NewLine + "#endif"; + AppendDir(MultiSymbolToSafeFilePath(multipleOutSymbol)); + } + + Append(ns); + builder.Append('_'); + Append(name); + builder.Append(".cs"); + + return OutputAsync(builder.ToString(), text); + } + + private Task OutputAsync(string path, string text) + { + path = path.Replace("global::", string.Empty); + + const string prefix = "[Out]"; + logger(prefix + path); + + var fi = new FileInfo(path); + if (fi.Directory != null && !fi.Directory.Exists) + { + fi.Directory.Create(); + } + + File.WriteAllText(path, NormalizeNewLines(text), NoBomUtf8); + return Task.CompletedTask; + } + + private static string MultiSymbolToSafeFilePath(string symbol) + { + return symbol.Replace("!", "NOT_").Replace("(", string.Empty).Replace(")", string.Empty).Replace("||", "_OR_").Replace("&&", "_AND_"); + } + + private static string NormalizeNewLines(string content) + { + // The T4 generated code may be text with mixed line ending types. (CR + CRLF) + // We need to normalize the line ending type in each Operating Systems. (e.g. Windows=CRLF, Linux/macOS=LF) + return content.Replace("\r\n", "\n").Replace("\n", Environment.NewLine); + } +} diff --git a/src/MessagePack.Generator/MessagePack.Generator.csproj b/src/MessagePack.Generator/MessagePack.Generator.csproj index b350ee8fb..5d97f41ba 100644 --- a/src/MessagePack.Generator/MessagePack.Generator.csproj +++ b/src/MessagePack.Generator/MessagePack.Generator.csproj @@ -5,26 +5,81 @@ 11 enable enable - true cs MessagePack.Generator MessagePack Code Generator - MessagePack standalone code generator. + MessagePack C# source generator. MsgPack;MessagePack;Serialization;Formatter;Serializer;Unity;Xamarin - - - - - + + - + + + + + True + True + EnumTemplate.tt + + + True + True + FormatterTemplate.tt + + + True + True + ResolverTemplate.tt + + + True + True + StringKeyFormatterTemplate.tt + + + %(FileName).tt + True + True + + + True + True + UnionTemplate.tt + + + + + + EnumTemplate.cs + TextTemplatingFilePreprocessor + + + FormatterTemplate.cs + TextTemplatingFilePreprocessor + + + ResolverTemplate.cs + TextTemplatingFilePreprocessor + + + StringKeyFormatterTemplate.cs + TextTemplatingFilePreprocessor + MessagePack.Generator.Transforms + + + UnionTemplate.cs + TextTemplatingFilePreprocessor + + + + diff --git a/src/MessagePack.Generator/MessagepackGenerator.Emit.cs b/src/MessagePack.Generator/MessagepackGenerator.Emit.cs index 01a2dd35a..11c02d9cf 100644 --- a/src/MessagePack.Generator/MessagepackGenerator.Emit.cs +++ b/src/MessagePack.Generator/MessagepackGenerator.Emit.cs @@ -2,8 +2,8 @@ // Licensed under the MIT license. See LICENSE file in the project root for full license information. using System.Text; -using MessagePackCompiler.CodeAnalysis; -using MessagePackCompiler.Generator; +using MessagePack.Generator.CodeAnalysis; +using MessagePack.Generator.Transforms; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp.Syntax; diff --git a/src/MessagePack.GeneratorCore/Generator/EnumTemplate.cs b/src/MessagePack.Generator/Transforms/EnumTemplate.cs similarity index 98% rename from src/MessagePack.GeneratorCore/Generator/EnumTemplate.cs rename to src/MessagePack.Generator/Transforms/EnumTemplate.cs index 382112a3b..d7e00e617 100644 --- a/src/MessagePack.GeneratorCore/Generator/EnumTemplate.cs +++ b/src/MessagePack.Generator/Transforms/EnumTemplate.cs @@ -7,7 +7,7 @@ // the code is regenerated. // // ------------------------------------------------------------------------------ -namespace MessagePackCompiler.Generator +namespace MessagePack.Generator.Transforms { using System.Linq; using System.Text; @@ -26,8 +26,6 @@ public partial class EnumTemplate : EnumTemplateBase public virtual string TransformText() { this.Write(@"// -// THIS (.cs) FILE IS GENERATED BY MPC(MessagePack-CSharp). DO NOT CHANGE IT. -// #pragma warning disable 618 #pragma warning disable 612 @@ -93,7 +91,7 @@ public class EnumTemplateBase /// /// The string builder that generation-time code is using to assemble generated output /// - protected System.Text.StringBuilder GenerationEnvironment + public System.Text.StringBuilder GenerationEnvironment { get { diff --git a/src/MessagePack.GeneratorCore/Generator/EnumTemplate.tt b/src/MessagePack.Generator/Transforms/EnumTemplate.tt similarity index 94% rename from src/MessagePack.GeneratorCore/Generator/EnumTemplate.tt rename to src/MessagePack.Generator/Transforms/EnumTemplate.tt index 74214c6c1..825902caf 100644 --- a/src/MessagePack.GeneratorCore/Generator/EnumTemplate.tt +++ b/src/MessagePack.Generator/Transforms/EnumTemplate.tt @@ -4,8 +4,6 @@ <#@ import namespace="System.Text" #> <#@ import namespace="System.Collections.Generic" #> // -// THIS (.cs) FILE IS GENERATED BY MPC(MessagePack-CSharp). DO NOT CHANGE IT. -// #pragma warning disable 618 #pragma warning disable 612 diff --git a/src/MessagePack.GeneratorCore/Generator/FormatterTemplate.cs b/src/MessagePack.Generator/Transforms/FormatterTemplate.cs similarity index 99% rename from src/MessagePack.GeneratorCore/Generator/FormatterTemplate.cs rename to src/MessagePack.Generator/Transforms/FormatterTemplate.cs index 396d6a52d..0c8a8940f 100644 --- a/src/MessagePack.GeneratorCore/Generator/FormatterTemplate.cs +++ b/src/MessagePack.Generator/Transforms/FormatterTemplate.cs @@ -7,7 +7,7 @@ // the code is regenerated. // // ------------------------------------------------------------------------------ -namespace MessagePackCompiler.Generator +namespace MessagePack.Generator.Transforms { using System.Linq; using System.Text; @@ -26,8 +26,6 @@ public partial class FormatterTemplate : FormatterTemplateBase public virtual string TransformText() { this.Write(@"// -// THIS (.cs) FILE IS GENERATED BY MPC(MessagePack-CSharp). DO NOT CHANGE IT. -// #pragma warning disable 618 #pragma warning disable 612 @@ -242,7 +240,7 @@ public class FormatterTemplateBase /// /// The string builder that generation-time code is using to assemble generated output /// - protected System.Text.StringBuilder GenerationEnvironment + public System.Text.StringBuilder GenerationEnvironment { get { diff --git a/src/MessagePack.GeneratorCore/Generator/FormatterTemplate.tt b/src/MessagePack.Generator/Transforms/FormatterTemplate.tt similarity index 98% rename from src/MessagePack.GeneratorCore/Generator/FormatterTemplate.tt rename to src/MessagePack.Generator/Transforms/FormatterTemplate.tt index 240b107fc..adbd7faa1 100644 --- a/src/MessagePack.GeneratorCore/Generator/FormatterTemplate.tt +++ b/src/MessagePack.Generator/Transforms/FormatterTemplate.tt @@ -4,8 +4,6 @@ <#@ import namespace="System.Text" #> <#@ import namespace="System.Collections.Generic" #> // -// THIS (.cs) FILE IS GENERATED BY MPC(MessagePack-CSharp). DO NOT CHANGE IT. -// #pragma warning disable 618 #pragma warning disable 612 diff --git a/src/MessagePack.Generator/Transforms/IFormatterTemplate.cs b/src/MessagePack.Generator/Transforms/IFormatterTemplate.cs new file mode 100644 index 000000000..e76860c13 --- /dev/null +++ b/src/MessagePack.Generator/Transforms/IFormatterTemplate.cs @@ -0,0 +1,15 @@ +// Copyright (c) All contributors. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using MessagePack.Generator.CodeAnalysis; + +namespace MessagePack.Generator.Transforms; + +public interface IFormatterTemplate +{ + string Namespace { get; } + + ObjectSerializationInfo[] ObjectSerializationInfos { get; } + + string TransformText(); +} diff --git a/src/MessagePack.GeneratorCore/Generator/ResolverTemplate.cs b/src/MessagePack.Generator/Transforms/ResolverTemplate.cs similarity index 98% rename from src/MessagePack.GeneratorCore/Generator/ResolverTemplate.cs rename to src/MessagePack.Generator/Transforms/ResolverTemplate.cs index 58f207114..f817bdd8f 100644 --- a/src/MessagePack.GeneratorCore/Generator/ResolverTemplate.cs +++ b/src/MessagePack.Generator/Transforms/ResolverTemplate.cs @@ -7,7 +7,7 @@ // the code is regenerated. // // ------------------------------------------------------------------------------ -namespace MessagePackCompiler.Generator +namespace MessagePack.Generator.Transforms { using System.Linq; using System.Text; @@ -26,8 +26,6 @@ public partial class ResolverTemplate : ResolverTemplateBase public virtual string TransformText() { this.Write(@"// -// THIS (.cs) FILE IS GENERATED BY MPC(MessagePack-CSharp). DO NOT CHANGE IT. -// #pragma warning disable 618 #pragma warning disable 612 @@ -146,7 +144,7 @@ public class ResolverTemplateBase /// /// The string builder that generation-time code is using to assemble generated output /// - protected System.Text.StringBuilder GenerationEnvironment + public System.Text.StringBuilder GenerationEnvironment { get { diff --git a/src/MessagePack.GeneratorCore/Generator/ResolverTemplate.tt b/src/MessagePack.Generator/Transforms/ResolverTemplate.tt similarity index 96% rename from src/MessagePack.GeneratorCore/Generator/ResolverTemplate.tt rename to src/MessagePack.Generator/Transforms/ResolverTemplate.tt index 6837185df..f634c97d8 100644 --- a/src/MessagePack.GeneratorCore/Generator/ResolverTemplate.tt +++ b/src/MessagePack.Generator/Transforms/ResolverTemplate.tt @@ -4,8 +4,6 @@ <#@ import namespace="System.Text" #> <#@ import namespace="System.Collections.Generic" #> // -// THIS (.cs) FILE IS GENERATED BY MPC(MessagePack-CSharp). DO NOT CHANGE IT. -// #pragma warning disable 618 #pragma warning disable 612 diff --git a/src/MessagePack.Generator/Transforms/ShouldUseFormatterResolverHelper.cs b/src/MessagePack.Generator/Transforms/ShouldUseFormatterResolverHelper.cs new file mode 100644 index 000000000..f9d718734 --- /dev/null +++ b/src/MessagePack.Generator/Transforms/ShouldUseFormatterResolverHelper.cs @@ -0,0 +1,46 @@ +// Copyright (c) All contributors. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using MessagePack.Generator.CodeAnalysis; + +namespace MessagePack.Generator.Transforms; + +public static class ShouldUseFormatterResolverHelper +{ + /// + /// Keep this list in sync with DynamicObjectTypeBuilder.IsOptimizeTargetType. + /// + internal static readonly string[] PrimitiveTypes = + { + "short", + "int", + "long", + "ushort", + "uint", + "ulong", + "float", + "double", + "bool", + "byte", + "sbyte", + "char", + "byte[]", + + // Do not include types that resolvers are allowed to modify. + ////"global::System.DateTime", // OldSpec has no support, so for that and perf reasons a .NET native DateTime resolver exists. + ////"string", // https://github.com/Cysharp/MasterMemory provides custom formatter for string interning. + }; + + public static bool ShouldUseFormatterResolver(MemberSerializationInfo[] infos) + { + foreach (var memberSerializationInfo in infos) + { + if (memberSerializationInfo.CustomFormatterTypeName == null && Array.IndexOf(PrimitiveTypes, memberSerializationInfo.Type) == -1) + { + return true; + } + } + + return false; + } +} diff --git a/src/MessagePack.Generator/Transforms/StringKey/EmbedStringHelper.cs b/src/MessagePack.Generator/Transforms/StringKey/EmbedStringHelper.cs new file mode 100644 index 000000000..40b879b2e --- /dev/null +++ b/src/MessagePack.Generator/Transforms/StringKey/EmbedStringHelper.cs @@ -0,0 +1,85 @@ +// Copyright (c) All contributors. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using System.Text; + +namespace MessagePack.Generator.Transforms; + +public static class EmbedStringHelper +{ + public static readonly Encoding Utf8 = new UTF8Encoding(false); + + public static string ToByteArrayString(byte[] binary) + { + var headerLength = GetHeaderLength(binary.Length); + Span header = stackalloc byte[headerLength]; + EmbedHeader(binary.Length, header); + var buffer = new StringBuilder().Append("new byte[").Append(headerLength).Append(" + ").Append(binary.Length).Append("] { ").Append(header[0]); + foreach (var b in header.Slice(1)) + { + buffer.Append(", ").Append(b); + } + + foreach (var b in binary) + { + buffer.Append(", ").Append(b); + } + + return buffer.Append(" }").ToString(); + } + + public static int GetHeaderLength(int byteCount) + { + if (byteCount <= 31) + { + return 1; + } + + if (byteCount <= byte.MaxValue) + { + return 2; + } + + return byteCount <= ushort.MaxValue ? 3 : 5; + } + + public static void EmbedHeader(int byteCount, Span destination) + { + if (byteCount <= 31) + { + destination[0] = (byte)(0xa0 | byteCount); + return; + } + + if (byteCount <= byte.MaxValue) + { + destination[0] = 0xd9; + destination[1] = unchecked((byte)byteCount); + return; + } + + if (byteCount <= ushort.MaxValue) + { + destination[0] = 0xda; + destination[1] = unchecked((byte)(byteCount >> 8)); + destination[2] = unchecked((byte)byteCount); + return; + } + + destination[0] = 0xdb; + destination[1] = unchecked((byte)(byteCount >> 24)); + destination[2] = unchecked((byte)(byteCount >> 16)); + destination[3] = unchecked((byte)(byteCount >> 8)); + destination[4] = unchecked((byte)byteCount); + } + + public static byte[] GetEncodedStringBytes(string value) + { + var byteCount = Utf8.GetByteCount(value); + var headerLength = GetHeaderLength(byteCount); + var bytes = new byte[headerLength + byteCount]; + EmbedHeader(byteCount, bytes); + Utf8.GetBytes(value, 0, value.Length, bytes, headerLength); + return bytes; + } +} diff --git a/src/MessagePack.Generator/Transforms/StringKey/StringKeyFormatterDeserializeHelper.cs b/src/MessagePack.Generator/Transforms/StringKey/StringKeyFormatterDeserializeHelper.cs new file mode 100644 index 000000000..7801b06eb --- /dev/null +++ b/src/MessagePack.Generator/Transforms/StringKey/StringKeyFormatterDeserializeHelper.cs @@ -0,0 +1,248 @@ +// Copyright (c) All contributors. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using System.Text; +using MessagePack.Generator.CodeAnalysis; +using MessagePack.Internal; + +namespace MessagePack.Generator.Transforms; + +internal static class StringKeyFormatterDeserializeHelper +{ + public static string Classify(ObjectSerializationInfo objectSerializationInfo, string indent, bool canOverwrite) + { + var memberArray = objectSerializationInfo.Members; + var buffer = new StringBuilder(); + foreach (var memberInfoTuples in memberArray.Select(member => new MemberInfoTuple(member, IsConstructorParameter(objectSerializationInfo, member))).GroupBy(member => member.Binary.Length)) + { + var binaryLength = memberInfoTuples.Key; + var keyLength = binaryLength >> 3; + keyLength += keyLength << 3 == binaryLength ? 0 : 1; + + buffer.Append(indent).Append("case ").Append(binaryLength).Append(":\r\n"); + ClassifyRecursion(buffer, indent, 1, keyLength, memberInfoTuples, canOverwrite); + } + + return buffer.ToString(); + } + + private static bool IsConstructorParameter(ObjectSerializationInfo objectSerializationInfo, MemberSerializationInfo member) + { + foreach (var parameter in objectSerializationInfo.ConstructorParameters) + { + if (parameter.Equals(member)) + { + return true; + } + } + + return false; + } + + private static void Assign(StringBuilder buffer, in MemberInfoTuple member, bool canOverwrite, string indent, string tab, int tabCount) + { + if (member.Info.IsWritable || member.IsConstructorParameter) + { + if (canOverwrite) + { + buffer.Append("____result.").Append(member.Info.Name).Append(" = "); + } + else + { + if (!member.IsConstructorParameter) + { + buffer.Append("__").Append(member.Info.Name).Append("__IsInitialized = true;\r\n").Append(indent); + for (var i = 0; i < tabCount; i++) + { + buffer.Append(tab); + } + } + + buffer.Append("__").Append(member.Info.Name).Append("__ = "); + } + + buffer.Append(member.Info.GetDeserializeMethodString()).Append(";\r\n"); + } + else + { + buffer.Append("reader.Skip();\r\n"); + } + } + + private static void ClassifyRecursion(StringBuilder buffer, string indent, int tabCount, int keyLength, IEnumerable memberCollection, bool canOverwrite) + { + const string Tab = " "; + buffer.Append(indent); + for (var i = 0; i < tabCount; i++) + { + buffer.Append(Tab); + } + + var memberArray = memberCollection.ToArray(); + if (memberArray.Length == 1) + { + var member = memberArray[0]; + EmbedOne(buffer, indent, tabCount, member, canOverwrite); + return; + } + + buffer.Append("switch (global::MessagePack.Internal.AutomataKeyGen.GetKey(ref stringKey))\r\n").Append(indent); + for (var i = 0; i < tabCount; i++) + { + buffer.Append(Tab); + } + + buffer.Append("{\r\n" + Tab).Append(indent); + for (var i = 0; i < tabCount; i++) + { + buffer.Append(Tab); + } + + buffer.Append("default: goto FAIL;"); + + foreach (var grouping in memberArray.GroupBy(member => member.Key[tabCount - 1])) + { + buffer.Append("\r\n" + Tab).Append(indent); + for (var i = 0; i < tabCount; i++) + { + buffer.Append(Tab); + } + + buffer.Append("case ").Append(grouping.Key).Append("UL:\r\n"); + + if (tabCount == keyLength) + { + buffer.Append(Tab + Tab).Append(indent); + for (var i = 0; i < tabCount; i++) + { + buffer.Append(Tab); + } + + var member = grouping.Single(); + Assign(buffer, member, canOverwrite, indent, Tab, tabCount + 2); + buffer.Append(Tab + Tab).Append(indent); + for (var i = 0; i < tabCount; i++) + { + buffer.Append(Tab); + } + + buffer.Append("continue;"); + continue; + } + + ClassifyRecursion(buffer, indent + Tab, tabCount + 1, keyLength, grouping, canOverwrite); + } + + buffer.Append("\r\n").Append(indent); + for (var i = 0; i < tabCount; i++) + { + buffer.Append(Tab); + } + + buffer.Append("}\r\n"); + } + + private static void EmbedOne(StringBuilder buffer, string indent, int tabCount, in MemberInfoTuple member, bool canOverwrite) + { + const string Tab = " "; + var binary = member.Binary.AsSpan((tabCount - 1) << 3); + + switch (binary.Length) + { + case 1: + buffer.Append("if (stringKey[0] != ").Append(binary[0]); + break; + case 2: + case 3: + case 4: + case 5: + case 6: + case 7: + case 8: + buffer.Append("if (global::MessagePack.Internal.AutomataKeyGen.GetKey(ref stringKey) != ").Append(member.Key[tabCount - 1]).Append("UL"); + break; + default: + EmbedSequenceEqual(buffer, member, (tabCount << 3) - 8); + break; + } + + buffer.Append(") { goto FAIL; }\r\n\r\n").Append(indent); + for (var i = 0; i < tabCount; i++) + { + buffer.Append(Tab); + } + + Assign(buffer, member, canOverwrite, indent, Tab, tabCount); + buffer.Append(indent); + for (var i = 0; i < tabCount; i++) + { + buffer.Append(Tab); + } + + buffer.Append("continue;\r\n"); + } + + private static void EmbedSequenceEqual(StringBuilder buffer, MemberInfoTuple member, int startPosition) + { + buffer + .Append("if (!global::System.MemoryExtensions.SequenceEqual(stringKey, GetSpan_") + .Append(member.Info.Name) + .Append("().Slice(") + .Append(EmbedStringHelper.GetHeaderLength(member.Binary.Length)); + + if (startPosition != 0) + { + buffer.Append(" + ").Append(startPosition); + } + + buffer.Append("))"); + } +} + +internal readonly struct MemberInfoTuple : IComparable +{ + public readonly MemberSerializationInfo Info; + public readonly bool IsConstructorParameter; + public readonly byte[] Binary; + public readonly ulong[] Key; + + public MemberInfoTuple(MemberSerializationInfo info, bool isConstructorParameter) + { + Info = info; + IsConstructorParameter = isConstructorParameter; + Binary = EmbedStringHelper.Utf8.GetBytes(info.StringKey); + ReadOnlySpan span = Binary; + var keyLength = Binary.Length >> 3; + keyLength += keyLength << 3 == Binary.Length ? 0 : 1; + Key = new ulong[keyLength]; + for (var i = 0; i < Key.Length; i++) + { + Key[i] = AutomataKeyGen.GetKey(ref span); + } + } + + public int CompareTo(MemberInfoTuple other) + { + if (Info == other.Info) + { + return 0; + } + + var c = Binary.Length.CompareTo(other.Binary.Length); + if (c != 0) + { + return c; + } + + for (var i = 0; i < Key.Length; i++) + { + c = Key[i].CompareTo(other.Key[i]); + if (c != 0) + { + return c; + } + } + + return 0; + } +} diff --git a/src/MessagePack.GeneratorCore/Generator/StringKey/StringKeyFormatterTemplate.cs b/src/MessagePack.Generator/Transforms/StringKey/StringKeyFormatterTemplate.cs similarity index 99% rename from src/MessagePack.GeneratorCore/Generator/StringKey/StringKeyFormatterTemplate.cs rename to src/MessagePack.Generator/Transforms/StringKey/StringKeyFormatterTemplate.cs index 083c69037..c987afa10 100644 --- a/src/MessagePack.GeneratorCore/Generator/StringKey/StringKeyFormatterTemplate.cs +++ b/src/MessagePack.Generator/Transforms/StringKey/StringKeyFormatterTemplate.cs @@ -7,12 +7,12 @@ // the code is regenerated. // // ------------------------------------------------------------------------------ -namespace MessagePackCompiler.Generator +namespace MessagePack.Generator.Transforms { using System; using System.Linq; using System.Collections.Generic; - using MessagePackCompiler.CodeAnalysis; + using MessagePack.Generator.CodeAnalysis; /// /// Class to produce the template output @@ -239,7 +239,7 @@ public class StringKeyFormatterTemplateBase /// /// The string builder that generation-time code is using to assemble generated output /// - protected System.Text.StringBuilder GenerationEnvironment + public System.Text.StringBuilder GenerationEnvironment { get { diff --git a/src/MessagePack.GeneratorCore/Generator/StringKey/StringKeyFormatterTemplate.tt b/src/MessagePack.Generator/Transforms/StringKey/StringKeyFormatterTemplate.tt similarity index 99% rename from src/MessagePack.GeneratorCore/Generator/StringKey/StringKeyFormatterTemplate.tt rename to src/MessagePack.Generator/Transforms/StringKey/StringKeyFormatterTemplate.tt index 6a6c3a8e2..81af93673 100644 --- a/src/MessagePack.GeneratorCore/Generator/StringKey/StringKeyFormatterTemplate.tt +++ b/src/MessagePack.Generator/Transforms/StringKey/StringKeyFormatterTemplate.tt @@ -3,7 +3,7 @@ <#@ import namespace="System" #> <#@ import namespace="System.Linq" #> <#@ import namespace="System.Collections.Generic" #> -<#@ import namespace="MessagePackCompiler.CodeAnalysis" #> +<#@ import namespace="MessagePack.Generator.CodeAnalysis" #> // // THIS (.cs) FILE IS GENERATED BY MPC(MessagePack-CSharp). DO NOT CHANGE IT. // diff --git a/src/MessagePack.Generator/Transforms/TemplatePartials.cs b/src/MessagePack.Generator/Transforms/TemplatePartials.cs new file mode 100644 index 000000000..a401eb7bd --- /dev/null +++ b/src/MessagePack.Generator/Transforms/TemplatePartials.cs @@ -0,0 +1,79 @@ +// Copyright (c) All contributors. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +#pragma warning disable SA1402 // File may only contain a single type + +using MessagePack.Generator.CodeAnalysis; + +namespace MessagePack.Generator.Transforms; + +public partial class FormatterTemplate : IFormatterTemplate +{ + public FormatterTemplate(string @namespace, ObjectSerializationInfo[] objectSerializationInfos) + { + Namespace = @namespace; + ObjectSerializationInfos = objectSerializationInfos; + } + + public string Namespace { get; } + + public ObjectSerializationInfo[] ObjectSerializationInfos { get; } +} + +public partial class StringKeyFormatterTemplate : IFormatterTemplate +{ + public StringKeyFormatterTemplate(string @namespace, ObjectSerializationInfo[] objectSerializationInfos) + { + Namespace = @namespace; + ObjectSerializationInfos = objectSerializationInfos; + } + + public string Namespace { get; } + + public ObjectSerializationInfo[] ObjectSerializationInfos { get; } +} + +public partial class ResolverTemplate +{ + public ResolverTemplate(string @namespace, string formatterNamespace, string resolverName, IResolverRegisterInfo[] registerInfos) + { + Namespace = @namespace; + FormatterNamespace = formatterNamespace; + ResolverName = resolverName; + RegisterInfos = registerInfos; + } + + public string Namespace { get; } + + public string FormatterNamespace { get; } + + public string ResolverName { get; } + + public IResolverRegisterInfo[] RegisterInfos { get; } +} + +public partial class EnumTemplate +{ + public EnumTemplate(string @namespace, EnumSerializationInfo[] enumSerializationInfos) + { + Namespace = @namespace; + EnumSerializationInfos = enumSerializationInfos; + } + + public string Namespace { get; } + + public EnumSerializationInfo[] EnumSerializationInfos { get; } +} + +public partial class UnionTemplate +{ + public UnionTemplate(string @namespace, UnionSerializationInfo[] unionSerializationInfos) + { + Namespace = @namespace; + UnionSerializationInfos = unionSerializationInfos; + } + + public string Namespace { get; } + + public UnionSerializationInfo[] UnionSerializationInfos { get; } +} diff --git a/src/MessagePack.GeneratorCore/Generator/UnionTemplate.cs b/src/MessagePack.Generator/Transforms/UnionTemplate.cs similarity index 98% rename from src/MessagePack.GeneratorCore/Generator/UnionTemplate.cs rename to src/MessagePack.Generator/Transforms/UnionTemplate.cs index 12e2abb8f..027cfeb57 100644 --- a/src/MessagePack.GeneratorCore/Generator/UnionTemplate.cs +++ b/src/MessagePack.Generator/Transforms/UnionTemplate.cs @@ -7,7 +7,7 @@ // the code is regenerated. // // ------------------------------------------------------------------------------ -namespace MessagePackCompiler.Generator +namespace MessagePack.Generator.Transforms { using System.Linq; using System.Text; @@ -26,8 +26,6 @@ public partial class UnionTemplate : UnionTemplateBase public virtual string TransformText() { this.Write(@"// -// THIS (.cs) FILE IS GENERATED BY MPC(MessagePack-CSharp). DO NOT CHANGE IT. -// #pragma warning disable 618 #pragma warning disable 612 @@ -170,7 +168,7 @@ public class UnionTemplateBase /// /// The string builder that generation-time code is using to assemble generated output /// - protected System.Text.StringBuilder GenerationEnvironment + public System.Text.StringBuilder GenerationEnvironment { get { diff --git a/src/MessagePack.GeneratorCore/Generator/UnionTemplate.tt b/src/MessagePack.Generator/Transforms/UnionTemplate.tt similarity index 97% rename from src/MessagePack.GeneratorCore/Generator/UnionTemplate.tt rename to src/MessagePack.Generator/Transforms/UnionTemplate.tt index a3ecb671d..5bebcc7dd 100644 --- a/src/MessagePack.GeneratorCore/Generator/UnionTemplate.tt +++ b/src/MessagePack.Generator/Transforms/UnionTemplate.tt @@ -4,8 +4,6 @@ <#@ import namespace="System.Text" #> <#@ import namespace="System.Collections.Generic" #> // -// THIS (.cs) FILE IS GENERATED BY MPC(MessagePack-CSharp). DO NOT CHANGE IT. -// #pragma warning disable 618 #pragma warning disable 612 diff --git a/src/MessagePack.Generator/Utils/RoslynExtensions.cs b/src/MessagePack.Generator/Utils/RoslynExtensions.cs new file mode 100644 index 000000000..6a1649fc9 --- /dev/null +++ b/src/MessagePack.Generator/Utils/RoslynExtensions.cs @@ -0,0 +1,48 @@ +// Copyright (c) All contributors. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using Microsoft.CodeAnalysis; + +namespace MessagePack.Generator; + +// Utility and Extension methods for Roslyn +internal static class RoslynExtensions +{ + public static IEnumerable GetNamedTypeSymbols(this Compilation compilation) + { + return compilation.SyntaxTrees.SelectMany(syntaxTree => + { + var semModel = compilation.GetSemanticModel(syntaxTree); + return syntaxTree.GetRoot() + .DescendantNodes() + .Select(x => semModel.GetDeclaredSymbol(x)) + .OfType(); + }); + } + + public static IEnumerable GetAllMembers(this ITypeSymbol symbol) + { + var t = symbol; + while (t != null) + { + foreach (var item in t.GetMembers()) + { + yield return item; + } + + t = t.BaseType; + } + } + + public static bool ApproximatelyEqual(this INamedTypeSymbol? left, INamedTypeSymbol? right) + { + if (left is IErrorTypeSymbol || right is IErrorTypeSymbol) + { + return left?.ToDisplayString() == right?.ToDisplayString(); + } + else + { + return SymbolEqualityComparer.Default.Equals(left, right); + } + } +} diff --git a/src/MessagePack.GeneratorCore/.editorconfig b/src/MessagePack.GeneratorCore/.editorconfig deleted file mode 100644 index 6b835fc65..000000000 --- a/src/MessagePack.GeneratorCore/.editorconfig +++ /dev/null @@ -1,4 +0,0 @@ -[*.cs] - -# VSTHRD111: Use ConfigureAwait(bool) -dotnet_diagnostic.VSTHRD111.severity = none diff --git a/src/MessagePack.GeneratorCore/CodeAnalysis/Definitions.cs b/src/MessagePack.GeneratorCore/CodeAnalysis/Definitions.cs deleted file mode 100644 index c7282896d..000000000 --- a/src/MessagePack.GeneratorCore/CodeAnalysis/Definitions.cs +++ /dev/null @@ -1,282 +0,0 @@ -// Copyright (c) All contributors. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - -using System; -using System.Collections.Generic; -using System.Linq; - -#pragma warning disable SA1402 // File may only contain a single type -#pragma warning disable SA1649 // File name should match first type name - -namespace MessagePackCompiler.CodeAnalysis -{ - public interface INamespaceInfo - { - string? Namespace { get; } - } - - public interface IResolverRegisterInfo - { - string FullName { get; } - - string FormatterName { get; } - } - - public class ObjectSerializationInfo : IResolverRegisterInfo, INamespaceInfo - { - public string Name { get; } - - public string FullName { get; } - - public string? Namespace { get; } - - public GenericTypeParameterInfo[] GenericTypeParameters { get; } - - public bool IsOpenGenericType { get; } - - public bool IsIntKey { get; } - - public bool IsStringKey - { - get { return !this.IsIntKey; } - } - - public bool IsClass { get; } - - public MemberSerializationInfo[] ConstructorParameters { get; } - - public MemberSerializationInfo[] Members { get; } - - public bool HasIMessagePackSerializationCallbackReceiver { get; } - - public bool NeedsCastOnBefore { get; } - - public bool NeedsCastOnAfter { get; } - - public string FormatterName => this.Namespace == null ? FormatterNameWithoutNameSpace : this.Namespace + "." + FormatterNameWithoutNameSpace; - - public string FormatterNameWithoutNameSpace => this.Name + "Formatter" + (this.IsOpenGenericType ? $"<{string.Join(", ", this.GenericTypeParameters.Select(x => x.Name))}>" : string.Empty); - - public int WriteCount - { - get - { - if (this.IsStringKey) - { - return this.Members.Count(x => x.IsReadable); - } - else - { - return this.MaxKey; - } - } - } - - public int MaxKey - { - get - { - return this.Members.Where(x => x.IsReadable).Select(x => x.IntKey).DefaultIfEmpty(-1).Max(); - } - } - - public MemberSerializationInfo? GetMember(int index) - { - return this.Members.FirstOrDefault(x => x.IntKey == index); - } - - public string GetConstructorString() - { - var args = string.Join(", ", this.ConstructorParameters.Select(x => "__" + x.Name + "__")); - return $"{this.FullName}({args})"; - } - - public ObjectSerializationInfo(bool isClass, bool isOpenGenericType, GenericTypeParameterInfo[] genericTypeParameterInfos, MemberSerializationInfo[] constructorParameters, bool isIntKey, MemberSerializationInfo[] members, string name, string fullName, string? @namespace, bool hasSerializationConstructor, bool needsCastOnAfter, bool needsCastOnBefore) - { - IsClass = isClass; - IsOpenGenericType = isOpenGenericType; - GenericTypeParameters = genericTypeParameterInfos; - ConstructorParameters = constructorParameters; - IsIntKey = isIntKey; - Members = members; - Name = name; - FullName = fullName; - Namespace = @namespace; - HasIMessagePackSerializationCallbackReceiver = hasSerializationConstructor; - NeedsCastOnAfter = needsCastOnAfter; - NeedsCastOnBefore = needsCastOnBefore; - } - } - - public class GenericTypeParameterInfo - { - public string Name { get; } - - public string Constraints { get; } - - public bool HasConstraints { get; } - - public GenericTypeParameterInfo(string name, string constraints) - { - Name = name ?? throw new ArgumentNullException(nameof(name)); - Constraints = constraints ?? throw new ArgumentNullException(nameof(name)); - HasConstraints = constraints != string.Empty; - } - } - - public class MemberSerializationInfo - { - public bool IsProperty { get; } - - public bool IsWritable { get; } - - public bool IsReadable { get; } - - public int IntKey { get; } - - public string StringKey { get; } - - public string Type { get; } - - public string Name { get; } - - public string ShortTypeName { get; } - - public string? CustomFormatterTypeName { get; } - - private readonly HashSet primitiveTypes = new(Generator.ShouldUseFormatterResolverHelper.PrimitiveTypes); - - public MemberSerializationInfo(bool isProperty, bool isWritable, bool isReadable, int intKey, string stringKey, string name, string type, string shortTypeName, string? customFormatterTypeName) - { - IsProperty = isProperty; - IsWritable = isWritable; - IsReadable = isReadable; - IntKey = intKey; - StringKey = stringKey; - Type = type; - Name = name; - ShortTypeName = shortTypeName; - CustomFormatterTypeName = customFormatterTypeName; - } - - public string GetSerializeMethodString() - { - if (CustomFormatterTypeName != null) - { - return $"this.__{this.Name}CustomFormatter__.Serialize(ref writer, value.{this.Name}, options)"; - } - else if (this.primitiveTypes.Contains(this.Type)) - { - return "writer.Write(value." + this.Name + ")"; - } - else - { - return $"global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<{this.Type}>(formatterResolver).Serialize(ref writer, value.{this.Name}, options)"; - } - } - - public string GetDeserializeMethodString() - { - if (CustomFormatterTypeName != null) - { - return $"this.__{this.Name}CustomFormatter__.Deserialize(ref reader, options)"; - } - else if (this.primitiveTypes.Contains(this.Type)) - { - if (this.Type == "byte[]") - { - return "global::MessagePack.Internal.CodeGenHelpers.GetArrayFromNullableSequence(reader.ReadBytes())"; - } - else - { - return $"reader.Read{this.ShortTypeName!.Replace("[]", "s")}()"; - } - } - else - { - return $"global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<{this.Type}>(formatterResolver).Deserialize(ref reader, options)"; - } - } - } - - public class EnumSerializationInfo : IResolverRegisterInfo, INamespaceInfo - { - public EnumSerializationInfo(string? @namespace, string name, string fullName, string underlyingType) - { - Namespace = @namespace; - Name = name; - FullName = fullName; - UnderlyingType = underlyingType; - } - - public string? Namespace { get; } - - public string Name { get; } - - public string FullName { get; } - - public string UnderlyingType { get; } - - public string FormatterName => (this.Namespace == null ? this.Name : this.Namespace + "." + this.Name) + "Formatter"; - } - - public class GenericSerializationInfo : IResolverRegisterInfo, IEquatable - { - public string FullName { get; } - - public string FormatterName { get; } - - public bool IsOpenGenericType { get; } - - public bool Equals(GenericSerializationInfo? other) - { - return this.FullName.Equals(other?.FullName); - } - - public override int GetHashCode() - { - return this.FullName.GetHashCode(); - } - - public GenericSerializationInfo(string fullName, string formatterName, bool isOpenGenericType) - { - FullName = fullName; - FormatterName = formatterName; - IsOpenGenericType = isOpenGenericType; - } - } - - public class UnionSerializationInfo : IResolverRegisterInfo, INamespaceInfo - { - public string? Namespace { get; } - - public string Name { get; } - - public string FullName { get; } - - public string FormatterName => (this.Namespace == null ? this.Name : this.Namespace + "." + this.Name) + "Formatter"; - - public UnionSubTypeInfo[] SubTypes { get; } - - public UnionSerializationInfo(string? @namespace, string name, string fullName, UnionSubTypeInfo[] subTypes) - { - Namespace = @namespace; - Name = name; - FullName = fullName; - SubTypes = subTypes; - } - } - - public class UnionSubTypeInfo - { - public UnionSubTypeInfo(int key, string type) - { - Key = key; - Type = type; - } - - public int Key { get; } - - public string Type { get; } - } -} diff --git a/src/MessagePack.GeneratorCore/CodeAnalysis/TypeCollector.cs b/src/MessagePack.GeneratorCore/CodeAnalysis/TypeCollector.cs deleted file mode 100644 index 5558a67c4..000000000 --- a/src/MessagePack.GeneratorCore/CodeAnalysis/TypeCollector.cs +++ /dev/null @@ -1,1094 +0,0 @@ -// Copyright (c) All contributors. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - -#pragma warning disable SA1402 // File may only contain a single type -#pragma warning disable SA1649 // File name should match first type name - -using System; -using System.Collections.Generic; -using System.Collections.Immutable; -using System.Linq; -using System.Text; -using System.Text.RegularExpressions; -using Microsoft.CodeAnalysis; - -namespace MessagePackCompiler.CodeAnalysis -{ - public class MessagePackGeneratorResolveFailedException : Exception - { - public MessagePackGeneratorResolveFailedException(string message) - : base(message) - { - } - } - - internal class ReferenceSymbols - { -#pragma warning disable SA1401 // Fields should be private - internal readonly INamedTypeSymbol? Task; - internal readonly INamedTypeSymbol? TaskOfT; - internal readonly INamedTypeSymbol MessagePackObjectAttribute; - internal readonly INamedTypeSymbol UnionAttribute; - internal readonly INamedTypeSymbol SerializationConstructorAttribute; - internal readonly INamedTypeSymbol KeyAttribute; - internal readonly INamedTypeSymbol IgnoreAttribute; - internal readonly INamedTypeSymbol? IgnoreDataMemberAttribute; - internal readonly INamedTypeSymbol IMessagePackSerializationCallbackReceiver; - internal readonly INamedTypeSymbol MessagePackFormatterAttribute; -#pragma warning restore SA1401 // Fields should be private - - public ReferenceSymbols(Compilation compilation, Action logger) - { - TaskOfT = compilation.GetTypeByMetadataName("System.Threading.Tasks.Task`1"); - if (TaskOfT == null) - { - logger("failed to get metadata of System.Threading.Tasks.Task`1"); - } - - Task = compilation.GetTypeByMetadataName("System.Threading.Tasks.Task"); - if (Task == null) - { - logger("failed to get metadata of System.Threading.Tasks.Task"); - } - - MessagePackObjectAttribute = compilation.GetTypeByMetadataName("MessagePack.MessagePackObjectAttribute") - ?? throw new InvalidOperationException("failed to get metadata of MessagePack.MessagePackObjectAttribute"); - - UnionAttribute = compilation.GetTypeByMetadataName("MessagePack.UnionAttribute") - ?? throw new InvalidOperationException("failed to get metadata of MessagePack.UnionAttribute"); - - SerializationConstructorAttribute = compilation.GetTypeByMetadataName("MessagePack.SerializationConstructorAttribute") - ?? throw new InvalidOperationException("failed to get metadata of MessagePack.SerializationConstructorAttribute"); - - KeyAttribute = compilation.GetTypeByMetadataName("MessagePack.KeyAttribute") - ?? throw new InvalidOperationException("failed to get metadata of MessagePack.KeyAttribute"); - - IgnoreAttribute = compilation.GetTypeByMetadataName("MessagePack.IgnoreMemberAttribute") - ?? throw new InvalidOperationException("failed to get metadata of MessagePack.IgnoreMemberAttribute"); - - IgnoreDataMemberAttribute = compilation.GetTypeByMetadataName("System.Runtime.Serialization.IgnoreDataMemberAttribute"); - if (IgnoreDataMemberAttribute == null) - { - logger("failed to get metadata of System.Runtime.Serialization.IgnoreDataMemberAttribute"); - } - - IMessagePackSerializationCallbackReceiver = compilation.GetTypeByMetadataName("MessagePack.IMessagePackSerializationCallbackReceiver") - ?? throw new InvalidOperationException("failed to get metadata of MessagePack.IMessagePackSerializationCallbackReceiver"); - - MessagePackFormatterAttribute = compilation.GetTypeByMetadataName("MessagePack.MessagePackFormatterAttribute") - ?? throw new InvalidOperationException("failed to get metadata of MessagePack.MessagePackFormatterAttribute"); - } - } - - public class TypeCollector - { - private static readonly SymbolDisplayFormat BinaryWriteFormat = new SymbolDisplayFormat( - genericsOptions: SymbolDisplayGenericsOptions.IncludeTypeParameters, - miscellaneousOptions: SymbolDisplayMiscellaneousOptions.ExpandNullable, - typeQualificationStyle: SymbolDisplayTypeQualificationStyle.NameOnly); - - private static readonly SymbolDisplayFormat ShortTypeNameFormat = new SymbolDisplayFormat( - typeQualificationStyle: SymbolDisplayTypeQualificationStyle.NameAndContainingTypes); - - private readonly bool isForceUseMap; - private readonly ReferenceSymbols typeReferences; - private readonly ITypeSymbol[] targetTypes; - private readonly HashSet embeddedTypes = new(new[] - { - "short", - "int", - "long", - "ushort", - "uint", - "ulong", - "float", - "double", - "bool", - "byte", - "sbyte", - "decimal", - "char", - "string", - "object", - "System.Guid", - "System.TimeSpan", - "System.DateTime", - "System.DateTimeOffset", - - "MessagePack.Nil", - - // and arrays - "short[]", - "int[]", - "long[]", - "ushort[]", - "uint[]", - "ulong[]", - "float[]", - "double[]", - "bool[]", - "byte[]", - "sbyte[]", - "decimal[]", - "char[]", - "string[]", - "System.DateTime[]", - "System.ArraySegment", - "System.ArraySegment?", - - // extensions - "UnityEngine.Vector2", - "UnityEngine.Vector3", - "UnityEngine.Vector4", - "UnityEngine.Quaternion", - "UnityEngine.Color", - "UnityEngine.Bounds", - "UnityEngine.Rect", - "UnityEngine.AnimationCurve", - "UnityEngine.RectOffset", - "UnityEngine.Gradient", - "UnityEngine.WrapMode", - "UnityEngine.GradientMode", - "UnityEngine.Keyframe", - "UnityEngine.Matrix4x4", - "UnityEngine.GradientColorKey", - "UnityEngine.GradientAlphaKey", - "UnityEngine.Color32", - "UnityEngine.LayerMask", - "UnityEngine.Vector2Int", - "UnityEngine.Vector3Int", - "UnityEngine.RangeInt", - "UnityEngine.RectInt", - "UnityEngine.BoundsInt", - - "System.Reactive.Unit", - }); - - private readonly Dictionary knownGenericTypes = new() - { -#pragma warning disable SA1509 // Opening braces should not be preceded by blank line - { "System.Collections.Generic.List<>", "global::MessagePack.Formatters.ListFormatter" }, - { "System.Collections.Generic.LinkedList<>", "global::MessagePack.Formatters.LinkedListFormatter" }, - { "System.Collections.Generic.Queue<>", "global::MessagePack.Formatters.QueueFormatter" }, - { "System.Collections.Generic.Stack<>", "global::MessagePack.Formatters.StackFormatter" }, - { "System.Collections.Generic.HashSet<>", "global::MessagePack.Formatters.HashSetFormatter" }, - { "System.Collections.ObjectModel.ReadOnlyCollection<>", "global::MessagePack.Formatters.ReadOnlyCollectionFormatter" }, - { "System.Collections.Generic.IList<>", "global::MessagePack.Formatters.InterfaceListFormatter2" }, - { "System.Collections.Generic.ICollection<>", "global::MessagePack.Formatters.InterfaceCollectionFormatter2" }, - { "System.Collections.Generic.IEnumerable<>", "global::MessagePack.Formatters.InterfaceEnumerableFormatter" }, - { "System.Collections.Generic.Dictionary<,>", "global::MessagePack.Formatters.DictionaryFormatter" }, - { "System.Collections.Generic.IDictionary<,>", "global::MessagePack.Formatters.InterfaceDictionaryFormatter" }, - { "System.Collections.Generic.SortedDictionary<,>", "global::MessagePack.Formatters.SortedDictionaryFormatter" }, - { "System.Collections.Generic.SortedList<,>", "global::MessagePack.Formatters.SortedListFormatter" }, - { "System.Linq.ILookup<,>", "global::MessagePack.Formatters.InterfaceLookupFormatter" }, - { "System.Linq.IGrouping<,>", "global::MessagePack.Formatters.InterfaceGroupingFormatter" }, - { "System.Collections.ObjectModel.ObservableCollection<>", "global::MessagePack.Formatters.ObservableCollectionFormatter" }, - { "System.Collections.ObjectModel.ReadOnlyObservableCollection<>", "global::MessagePack.Formatters.ReadOnlyObservableCollectionFormatter" }, - { "System.Collections.Generic.IReadOnlyList<>", "global::MessagePack.Formatters.InterfaceReadOnlyListFormatter" }, - { "System.Collections.Generic.IReadOnlyCollection<>", "global::MessagePack.Formatters.InterfaceReadOnlyCollectionFormatter" }, - { "System.Collections.Generic.ISet<>", "global::MessagePack.Formatters.InterfaceSetFormatter" }, - { "System.Collections.Concurrent.ConcurrentBag<>", "global::MessagePack.Formatters.ConcurrentBagFormatter" }, - { "System.Collections.Concurrent.ConcurrentQueue<>", "global::MessagePack.Formatters.ConcurrentQueueFormatter" }, - { "System.Collections.Concurrent.ConcurrentStack<>", "global::MessagePack.Formatters.ConcurrentStackFormatter" }, - { "System.Collections.ObjectModel.ReadOnlyDictionary<,>", "global::MessagePack.Formatters.ReadOnlyDictionaryFormatter" }, - { "System.Collections.Generic.IReadOnlyDictionary<,>", "global::MessagePack.Formatters.InterfaceReadOnlyDictionaryFormatter" }, - { "System.Collections.Concurrent.ConcurrentDictionary<,>", "global::MessagePack.Formatters.ConcurrentDictionaryFormatter" }, - { "System.Lazy<>", "global::MessagePack.Formatters.LazyFormatter" }, - { "System.Threading.Tasks<>", "global::MessagePack.Formatters.TaskValueFormatter" }, - - { "System.Tuple<>", "global::MessagePack.Formatters.TupleFormatter" }, - { "System.Tuple<,>", "global::MessagePack.Formatters.TupleFormatter" }, - { "System.Tuple<,,>", "global::MessagePack.Formatters.TupleFormatter" }, - { "System.Tuple<,,,>", "global::MessagePack.Formatters.TupleFormatter" }, - { "System.Tuple<,,,,>", "global::MessagePack.Formatters.TupleFormatter" }, - { "System.Tuple<,,,,,>", "global::MessagePack.Formatters.TupleFormatter" }, - { "System.Tuple<,,,,,,>", "global::MessagePack.Formatters.TupleFormatter" }, - { "System.Tuple<,,,,,,,>", "global::MessagePack.Formatters.TupleFormatter" }, - - { "System.ValueTuple<>", "global::MessagePack.Formatters.ValueTupleFormatter" }, - { "System.ValueTuple<,>", "global::MessagePack.Formatters.ValueTupleFormatter" }, - { "System.ValueTuple<,,>", "global::MessagePack.Formatters.ValueTupleFormatter" }, - { "System.ValueTuple<,,,>", "global::MessagePack.Formatters.ValueTupleFormatter" }, - { "System.ValueTuple<,,,,>", "global::MessagePack.Formatters.ValueTupleFormatter" }, - { "System.ValueTuple<,,,,,>", "global::MessagePack.Formatters.ValueTupleFormatter" }, - { "System.ValueTuple<,,,,,,>", "global::MessagePack.Formatters.ValueTupleFormatter" }, - { "System.ValueTuple<,,,,,,,>", "global::MessagePack.Formatters.ValueTupleFormatter" }, - - { "System.Collections.Generic.KeyValuePair<,>", "global::MessagePack.Formatters.KeyValuePairFormatter" }, - { "System.Threading.Tasks.ValueTask<>", "global::MessagePack.Formatters.KeyValuePairFormatter" }, - { "System.ArraySegment<>", "global::MessagePack.Formatters.ArraySegmentFormatter" }, - - // extensions - { "System.Collections.Immutable.ImmutableArray<>", "global::MessagePack.ImmutableCollection.ImmutableArrayFormatter" }, - { "System.Collections.Immutable.ImmutableList<>", "global::MessagePack.ImmutableCollection.ImmutableListFormatter" }, - { "System.Collections.Immutable.ImmutableDictionary<,>", "global::MessagePack.ImmutableCollection.ImmutableDictionaryFormatter" }, - { "System.Collections.Immutable.ImmutableHashSet<>", "global::MessagePack.ImmutableCollection.ImmutableHashSetFormatter" }, - { "System.Collections.Immutable.ImmutableSortedDictionary<,>", "global::MessagePack.ImmutableCollection.ImmutableSortedDictionaryFormatter" }, - { "System.Collections.Immutable.ImmutableSortedSet<>", "global::MessagePack.ImmutableCollection.ImmutableSortedSetFormatter" }, - { "System.Collections.Immutable.ImmutableQueue<>", "global::MessagePack.ImmutableCollection.ImmutableQueueFormatter" }, - { "System.Collections.Immutable.ImmutableStack<>", "global::MessagePack.ImmutableCollection.ImmutableStackFormatter" }, - { "System.Collections.Immutable.IImmutableList<>", "global::MessagePack.ImmutableCollection.InterfaceImmutableListFormatter" }, - { "System.Collections.Immutable.IImmutableDictionary<,>", "global::MessagePack.ImmutableCollection.InterfaceImmutableDictionaryFormatter" }, - { "System.Collections.Immutable.IImmutableQueue<>", "global::MessagePack.ImmutableCollection.InterfaceImmutableQueueFormatter" }, - { "System.Collections.Immutable.IImmutableSet<>", "global::MessagePack.ImmutableCollection.InterfaceImmutableSetFormatter" }, - { "System.Collections.Immutable.IImmutableStack<>", "global::MessagePack.ImmutableCollection.InterfaceImmutableStackFormatter" }, - - { "Reactive.Bindings.ReactiveProperty<>", "global::MessagePack.ReactivePropertyExtension.ReactivePropertyFormatter" }, - { "Reactive.Bindings.IReactiveProperty<>", "global::MessagePack.ReactivePropertyExtension.InterfaceReactivePropertyFormatter" }, - { "Reactive.Bindings.IReadOnlyReactiveProperty<>", "global::MessagePack.ReactivePropertyExtension.InterfaceReadOnlyReactivePropertyFormatter" }, - { "Reactive.Bindings.ReactiveCollection<>", "global::MessagePack.ReactivePropertyExtension.ReactiveCollectionFormatter" }, -#pragma warning restore SA1509 // Opening braces should not be preceded by blank line - }; - - private readonly bool disallowInternal; - - private readonly bool excludeArrayElement; - - private readonly HashSet externalIgnoreTypeNames; - - // visitor workspace: -#pragma warning disable RS1024 // Compare symbols correctly (https://github.com/dotnet/roslyn-analyzers/issues/5246) - private readonly HashSet alreadyCollected = new(SymbolEqualityComparer.Default); -#pragma warning restore RS1024 // Compare symbols correctly - private readonly List collectedObjectInfo = new(); - private readonly List collectedEnumInfo = new(); - private readonly List collectedGenericInfo = new(); - private readonly List collectedUnionInfo = new(); - - private readonly Compilation compilation; - - public TypeCollector(Compilation compilation, bool disallowInternal, bool isForceUseMap, string[]? ignoreTypeNames, Action logger) - { - this.typeReferences = new ReferenceSymbols(compilation, logger); - this.disallowInternal = disallowInternal; - this.isForceUseMap = isForceUseMap; - this.externalIgnoreTypeNames = new HashSet(ignoreTypeNames ?? Array.Empty()); - this.compilation = compilation; - - targetTypes = compilation.GetNamedTypeSymbols() - .Where(x => - { - if (x.DeclaredAccessibility == Accessibility.Public) - { - return true; - } - - if (!disallowInternal) - { - return x.DeclaredAccessibility == Accessibility.Friend; - } - - return false; - }) - .Where(x => - ((x.TypeKind == TypeKind.Interface) && x.GetAttributes().Any(x2 => x2.AttributeClass.ApproximatelyEqual(typeReferences.UnionAttribute))) - || ((x.TypeKind == TypeKind.Class && x.IsAbstract) && x.GetAttributes().Any(x2 => x2.AttributeClass.ApproximatelyEqual(typeReferences.UnionAttribute))) - || ((x.TypeKind == TypeKind.Class) && x.GetAttributes().Any(x2 => x2.AttributeClass.ApproximatelyEqual(typeReferences.MessagePackObjectAttribute))) - || ((x.TypeKind == TypeKind.Struct) && x.GetAttributes().Any(x2 => x2.AttributeClass.ApproximatelyEqual(typeReferences.MessagePackObjectAttribute)))) - .ToArray(); - } - - public TypeCollector(Compilation compilation, bool disallowInternal, bool isForceUseMap, string[]? ignoreTypeNames, ITypeSymbol targetType) - { - this.typeReferences = new ReferenceSymbols(compilation, _ => { }); - this.disallowInternal = disallowInternal; - this.isForceUseMap = isForceUseMap; - this.externalIgnoreTypeNames = new HashSet(ignoreTypeNames ?? Array.Empty()); - this.compilation = compilation; - this.excludeArrayElement = true; - - targetTypes = new[] { targetType } - .Where(x => - { - if (x.DeclaredAccessibility == Accessibility.Public) - { - return true; - } - - if (!disallowInternal) - { - return x.DeclaredAccessibility == Accessibility.Friend; - } - - return false; - }) - .Where(x => - ((x.TypeKind == TypeKind.Interface) && x.GetAttributes().Any(x2 => x2.AttributeClass.ApproximatelyEqual(typeReferences.UnionAttribute))) - || ((x.TypeKind == TypeKind.Class && x.IsAbstract) && x.GetAttributes().Any(x2 => x2.AttributeClass.ApproximatelyEqual(typeReferences.UnionAttribute))) - || ((x.TypeKind == TypeKind.Class) && x.GetAttributes().Any(x2 => x2.AttributeClass.ApproximatelyEqual(typeReferences.MessagePackObjectAttribute))) - || ((x.TypeKind == TypeKind.Struct) && x.GetAttributes().Any(x2 => x2.AttributeClass.ApproximatelyEqual(typeReferences.MessagePackObjectAttribute)))) - .ToArray(); - } - - private void ResetWorkspace() - { - this.alreadyCollected.Clear(); - this.collectedObjectInfo.Clear(); - this.collectedEnumInfo.Clear(); - this.collectedGenericInfo.Clear(); - this.collectedUnionInfo.Clear(); - } - - // EntryPoint - public (ObjectSerializationInfo[] ObjectInfo, EnumSerializationInfo[] EnumInfo, GenericSerializationInfo[] GenericInfo, UnionSerializationInfo[] UnionInfo) Collect() - { - this.ResetWorkspace(); - - foreach (var item in this.targetTypes) - { - this.CollectCore(item); - } - - return ( - this.collectedObjectInfo.OrderBy(x => x.FullName).ToArray(), - this.collectedEnumInfo.OrderBy(x => x.FullName).ToArray(), - this.collectedGenericInfo.Distinct().OrderBy(x => x.FullName).ToArray(), - this.collectedUnionInfo.OrderBy(x => x.FullName).ToArray()); - } - - // Gate of recursive collect - private void CollectCore(ITypeSymbol typeSymbol) - { - if (!this.alreadyCollected.Add(typeSymbol)) - { - return; - } - - var typeSymbolString = typeSymbol.WithNullableAnnotation(NullableAnnotation.NotAnnotated).ToString() ?? throw new InvalidOperationException(); - if (this.embeddedTypes.Contains(typeSymbolString)) - { - return; - } - - if (this.externalIgnoreTypeNames.Contains(typeSymbolString)) - { - return; - } - - if (typeSymbol is IArrayTypeSymbol arrayTypeSymbol) - { - this.CollectArray((IArrayTypeSymbol)ToTupleUnderlyingType(arrayTypeSymbol)); - return; - } - - if (!this.IsAllowAccessibility(typeSymbol)) - { - return; - } - - if (!(typeSymbol is INamedTypeSymbol type)) - { - return; - } - - var customFormatterAttr = typeSymbol.GetAttributes().FirstOrDefault(x => x.AttributeClass.ApproximatelyEqual(this.typeReferences.MessagePackFormatterAttribute)); - if (customFormatterAttr != null) - { - return; - } - - if (type.EnumUnderlyingType != null) - { - this.CollectEnum(type, type.EnumUnderlyingType); - return; - } - - if (type.IsGenericType) - { - this.CollectGeneric((INamedTypeSymbol)ToTupleUnderlyingType(type)); - return; - } - - if (type.Locations[0].IsInMetadata) - { - return; - } - - if (type.TypeKind == TypeKind.Interface || (type.TypeKind == TypeKind.Class && type.IsAbstract)) - { - this.CollectUnion(type); - return; - } - - this.CollectObject(type); - } - - private void CollectEnum(INamedTypeSymbol type, ISymbol enumUnderlyingType) - { - var info = new EnumSerializationInfo(type.ContainingNamespace.IsGlobalNamespace ? null : type.ContainingNamespace.ToDisplayString(), type.ToDisplayString(ShortTypeNameFormat).Replace(".", "_"), type.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat), enumUnderlyingType.ToDisplayString(BinaryWriteFormat)); - this.collectedEnumInfo.Add(info); - } - - private void CollectUnion(INamedTypeSymbol type) - { - ImmutableArray[] unionAttrs = type.GetAttributes().Where(x => x.AttributeClass.ApproximatelyEqual(this.typeReferences.UnionAttribute)).Select(x => x.ConstructorArguments).ToArray(); - if (unionAttrs.Length == 0) - { - throw new MessagePackGeneratorResolveFailedException("Serialization Type must mark UnionAttribute." + " type: " + type.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat)); - } - - // 0, Int 1, SubType - UnionSubTypeInfo UnionSubTypeInfoSelector(ImmutableArray x) - { - if (!(x[0] is { Value: int key }) || !(x[1] is { Value: ITypeSymbol typeSymbol })) - { - throw new NotSupportedException("AOT code generation only supports UnionAttribute that uses a Type parameter, but the " + type.ToDisplayString(SymbolDisplayFormat.CSharpErrorMessageFormat) + " type uses an unsupported parameter."); - } - - var typeName = typeSymbol.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat); - return new UnionSubTypeInfo(key, typeName); - } - - var info = new UnionSerializationInfo(type.ContainingNamespace.IsGlobalNamespace ? null : type.ContainingNamespace.ToDisplayString(), type.Name, type.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat), unionAttrs.Select(UnionSubTypeInfoSelector).OrderBy(x => x.Key).ToArray()); - - this.collectedUnionInfo.Add(info); - } - - private void CollectGenericUnion(INamedTypeSymbol type) - { - var unionAttrs = type.GetAttributes().Where(x => x.AttributeClass.ApproximatelyEqual(this.typeReferences.UnionAttribute)).Select(x => x.ConstructorArguments); - using var enumerator = unionAttrs.GetEnumerator(); - if (!enumerator.MoveNext()) - { - return; - } - - do - { - var x = enumerator.Current; - if (x[1] is { Value: INamedTypeSymbol unionType } && alreadyCollected.Contains(unionType) == false) - { - CollectCore(unionType); - } - } - while (enumerator.MoveNext()); - } - - private void CollectArray(IArrayTypeSymbol array) - { - ITypeSymbol elemType = array.ElementType; - if (!excludeArrayElement) - { - this.CollectCore(elemType); - } - - var fullName = array.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat); - var elementTypeDisplayName = elemType.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat); - string formatterName; - if (array.IsSZArray) - { - formatterName = "global::MessagePack.Formatters.ArrayFormatter<" + elementTypeDisplayName + ">"; - } - else - { - formatterName = array.Rank switch - { - 2 => "global::MessagePack.Formatters.TwoDimensionalArrayFormatter<" + elementTypeDisplayName + ">", - 3 => "global::MessagePack.Formatters.ThreeDimensionalArrayFormatter<" + elementTypeDisplayName + ">", - 4 => "global::MessagePack.Formatters.FourDimensionalArrayFormatter<" + elementTypeDisplayName + ">", - _ => throw new InvalidOperationException("does not supports array dimension, " + fullName), - }; - } - - var info = new GenericSerializationInfo(fullName, formatterName, elemType is ITypeParameterSymbol); - this.collectedGenericInfo.Add(info); - } - - private ITypeSymbol ToTupleUnderlyingType(ITypeSymbol typeSymbol) - { - if (typeSymbol is IArrayTypeSymbol array) - { - return compilation.CreateArrayTypeSymbol(ToTupleUnderlyingType(array.ElementType), array.Rank); - } - - if (typeSymbol is not INamedTypeSymbol namedType || !namedType.IsGenericType) - { - return typeSymbol; - } - - namedType = namedType.TupleUnderlyingType ?? namedType; - var newTypeArguments = namedType.TypeArguments.Select(ToTupleUnderlyingType).ToArray(); - if (!namedType.TypeArguments.SequenceEqual(newTypeArguments)) - { - return namedType.ConstructedFrom.Construct(newTypeArguments); - } - - return namedType; - } - - private void CollectGeneric(INamedTypeSymbol type) - { - INamedTypeSymbol genericType = type.ConstructUnboundGenericType(); - var genericTypeString = genericType.ToDisplayString(); - var fullName = type.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat); - var isOpenGenericType = IsOpenGenericTypeRecursively(type); - - // special case - if (fullName == "global::System.ArraySegment" || fullName == "global::System.ArraySegment?") - { - return; - } - - // nullable - if (genericTypeString == "T?") - { - var firstTypeArgument = type.TypeArguments[0]; - this.CollectCore(firstTypeArgument); - - if (this.embeddedTypes.Contains(firstTypeArgument.ToString()!)) - { - return; - } - - var info = new GenericSerializationInfo(type.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat), "global::MessagePack.Formatters.NullableFormatter<" + firstTypeArgument.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat) + ">", isOpenGenericType); - this.collectedGenericInfo.Add(info); - return; - } - - // collection - if (this.knownGenericTypes.TryGetValue(genericTypeString, out var formatter)) - { - foreach (ITypeSymbol item in type.TypeArguments) - { - this.CollectCore(item); - } - - var typeArgs = string.Join(", ", type.TypeArguments.Select(x => x.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat))); - var f = formatter.Replace("TREPLACE", typeArgs); - - var info = new GenericSerializationInfo(type.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat), f, isOpenGenericType); - - this.collectedGenericInfo.Add(info); - - if (genericTypeString != "System.Linq.ILookup<,>") - { - return; - } - - formatter = this.knownGenericTypes["System.Linq.IGrouping<,>"]; - f = formatter.Replace("TREPLACE", typeArgs); - - var groupingInfo = new GenericSerializationInfo("global::System.Linq.IGrouping<" + typeArgs + ">", f, isOpenGenericType); - this.collectedGenericInfo.Add(groupingInfo); - - formatter = this.knownGenericTypes["System.Collections.Generic.IEnumerable<>"]; - typeArgs = type.TypeArguments[1].ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat); - f = formatter.Replace("TREPLACE", typeArgs); - - var enumerableInfo = new GenericSerializationInfo("global::System.Collections.Generic.IEnumerable<" + typeArgs + ">", f, isOpenGenericType); - this.collectedGenericInfo.Add(enumerableInfo); - return; - } - - // Generic types - if (type.IsDefinition) - { - this.CollectGenericUnion(type); - this.CollectObject(type); - return; - } - else - { - // Collect substituted types for the properties and fields. - // NOTE: It is used to register formatters from nested generic type. - // However, closed generic types such as `Foo` are not registered as a formatter. - GetObjectInfo(type); - - // Collect generic type definition, that is not collected when it is defined outside target project. - CollectCore(type.OriginalDefinition); - } - - // Collect substituted types for the type parameters (e.g. Bar in Foo) - foreach (var item in type.TypeArguments) - { - this.CollectCore(item); - } - - var formatterBuilder = new StringBuilder(); - if (!type.ContainingNamespace.IsGlobalNamespace) - { - formatterBuilder.Append(type.ContainingNamespace.ToDisplayString() + "."); - } - - formatterBuilder.Append(type.Name); - formatterBuilder.Append("Formatter<"); - var typeArgumentIterator = type.TypeArguments.GetEnumerator(); - { - if (typeArgumentIterator.MoveNext()) - { - formatterBuilder.Append(typeArgumentIterator.Current.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat)); - } - - while (typeArgumentIterator.MoveNext()) - { - formatterBuilder.Append(", "); - formatterBuilder.Append(typeArgumentIterator.Current.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat)); - } - } - - formatterBuilder.Append('>'); - - var genericSerializationInfo = new GenericSerializationInfo(type.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat), formatterBuilder.ToString(), isOpenGenericType); - this.collectedGenericInfo.Add(genericSerializationInfo); - } - - private void CollectObject(INamedTypeSymbol type) - { - ObjectSerializationInfo info = GetObjectInfo(type); - collectedObjectInfo.Add(info); - } - - private ObjectSerializationInfo GetObjectInfo(INamedTypeSymbol type) - { - var isClass = !type.IsValueType; - var isOpenGenericType = type.IsGenericType; - - AttributeData contractAttr = type.GetAttributes().FirstOrDefault(x => x.AttributeClass.ApproximatelyEqual(this.typeReferences.MessagePackObjectAttribute)) - ?? throw new MessagePackGeneratorResolveFailedException("Serialization Object must mark MessagePackObjectAttribute." + " type: " + type.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat)); - - var isIntKey = true; - var intMembers = new Dictionary(); - var stringMembers = new Dictionary(); - - if (this.isForceUseMap || (contractAttr.ConstructorArguments[0] is { Value: bool firstConstructorArgument } && firstConstructorArgument)) - { - // All public members are serialize target except [Ignore] member. - isIntKey = false; - - var hiddenIntKey = 0; - - foreach (IPropertySymbol item in type.GetAllMembers().OfType().Where(x => !x.IsOverride)) - { - if (item.GetAttributes().Any(x => (x.AttributeClass.ApproximatelyEqual(this.typeReferences.IgnoreAttribute) || x.AttributeClass?.Name == this.typeReferences.IgnoreDataMemberAttribute?.Name))) - { - continue; - } - - var isReadable = item.GetMethod != null && item.GetMethod.DeclaredAccessibility == Accessibility.Public && !item.IsStatic; - var isWritable = item.SetMethod != null && item.SetMethod.DeclaredAccessibility == Accessibility.Public && !item.IsStatic; - if (!isReadable && !isWritable) - { - continue; - } - - var customFormatterAttr = item.GetAttributes().FirstOrDefault(x => x.AttributeClass.ApproximatelyEqual(this.typeReferences.MessagePackFormatterAttribute))?.ConstructorArguments[0].Value as INamedTypeSymbol; - var member = new MemberSerializationInfo(true, isWritable, isReadable, hiddenIntKey++, item.Name, item.Name, item.Type.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat), item.Type.ToDisplayString(BinaryWriteFormat), customFormatterAttr?.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat)); - stringMembers.Add(member.StringKey, member); - - this.CollectCore(item.Type); // recursive collect - } - - foreach (IFieldSymbol item in type.GetAllMembers().OfType()) - { - if (item.GetAttributes().Any(x => (x.AttributeClass.ApproximatelyEqual(this.typeReferences.IgnoreAttribute) || x.AttributeClass?.Name == this.typeReferences.IgnoreDataMemberAttribute?.Name))) - { - continue; - } - - if (item.IsImplicitlyDeclared) - { - continue; - } - - var isReadable = item.DeclaredAccessibility == Accessibility.Public && !item.IsStatic; - var isWritable = item.DeclaredAccessibility == Accessibility.Public && !item.IsReadOnly && !item.IsStatic; - if (!isReadable && !isWritable) - { - continue; - } - - var customFormatterAttr = item.GetAttributes().FirstOrDefault(x => x.AttributeClass.ApproximatelyEqual(this.typeReferences.MessagePackFormatterAttribute))?.ConstructorArguments[0].Value as INamedTypeSymbol; - var member = new MemberSerializationInfo(false, isWritable, isReadable, hiddenIntKey++, item.Name, item.Name, item.Type.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat), item.Type.ToDisplayString(BinaryWriteFormat), customFormatterAttr?.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat)); - stringMembers.Add(member.StringKey, member); - this.CollectCore(item.Type); // recursive collect - } - } - else - { - // Only KeyAttribute members - var searchFirst = true; - var hiddenIntKey = 0; - - foreach (IPropertySymbol item in type.GetAllMembers().OfType()) - { - if (item.IsIndexer) - { - continue; // .tt files don't generate good code for this yet: https://github.com/neuecc/MessagePack-CSharp/issues/390 - } - - if (item.GetAttributes().Any(x => - { - var typeReferencesIgnoreDataMemberAttribute = this.typeReferences.IgnoreDataMemberAttribute; - return typeReferencesIgnoreDataMemberAttribute != null && (x.AttributeClass.ApproximatelyEqual(this.typeReferences.IgnoreAttribute) || x.AttributeClass.ApproximatelyEqual(typeReferencesIgnoreDataMemberAttribute)); - })) - { - continue; - } - - var isReadable = item.GetMethod != null && item.GetMethod.DeclaredAccessibility == Accessibility.Public && !item.IsStatic; - var isWritable = item.SetMethod != null && item.SetMethod.DeclaredAccessibility == Accessibility.Public && !item.IsStatic; - if (!isReadable && !isWritable) - { - continue; - } - - var customFormatterAttr = item.GetAttributes().FirstOrDefault(x => x.AttributeClass.ApproximatelyEqual(this.typeReferences.MessagePackFormatterAttribute))?.ConstructorArguments[0].Value as INamedTypeSymbol; - var key = item.GetAttributes().FirstOrDefault(x => x.AttributeClass.ApproximatelyEqual(this.typeReferences.KeyAttribute))?.ConstructorArguments[0] - ?? throw new MessagePackGeneratorResolveFailedException("all public members must mark KeyAttribute or IgnoreMemberAttribute." + " type: " + type.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat) + " member:" + item.Name); - - var intKey = key is { Value: int intKeyValue } ? intKeyValue : default(int?); - var stringKey = key is { Value: string stringKeyValue } ? stringKeyValue : default; - if (intKey == null && stringKey == null) - { - throw new MessagePackGeneratorResolveFailedException("both IntKey and StringKey are null." + " type: " + type.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat) + " member:" + item.Name); - } - - if (searchFirst) - { - searchFirst = false; - isIntKey = intKey != null; - } - else - { - if ((isIntKey && intKey == null) || (!isIntKey && stringKey == null)) - { - throw new MessagePackGeneratorResolveFailedException("all members key type must be same." + " type: " + type.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat) + " member:" + item.Name); - } - } - - if (isIntKey) - { - if (intMembers.ContainsKey(intKey!.Value)) - { - throw new MessagePackGeneratorResolveFailedException("key is duplicated, all members key must be unique." + " type: " + type.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat) + " member:" + item.Name); - } - - var member = new MemberSerializationInfo(true, isWritable, isReadable, intKey!.Value, item.Name, item.Name, item.Type.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat), item.Type.ToDisplayString(BinaryWriteFormat), customFormatterAttr?.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat)); - intMembers.Add(member.IntKey, member); - } - else - { - if (stringMembers.ContainsKey(stringKey!)) - { - throw new MessagePackGeneratorResolveFailedException("key is duplicated, all members key must be unique." + " type: " + type.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat) + " member:" + item.Name); - } - - var member = new MemberSerializationInfo(true, isWritable, isReadable, hiddenIntKey++, stringKey!, item.Name, item.Type.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat), item.Type.ToDisplayString(BinaryWriteFormat), customFormatterAttr?.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat)); - stringMembers.Add(member.StringKey, member); - } - - var messagePackFormatter = item.GetAttributes().FirstOrDefault(x => x.AttributeClass.ApproximatelyEqual(this.typeReferences.MessagePackFormatterAttribute))?.ConstructorArguments[0]; - - if (messagePackFormatter == null) - { - this.CollectCore(item.Type); // recursive collect - } - } - - foreach (IFieldSymbol item in type.GetAllMembers().OfType()) - { - if (item.IsImplicitlyDeclared) - { - continue; - } - - if (item.GetAttributes().Any(x => x.AttributeClass.ApproximatelyEqual(this.typeReferences.IgnoreAttribute))) - { - continue; - } - - var isReadable = item.DeclaredAccessibility == Accessibility.Public && !item.IsStatic; - var isWritable = item.DeclaredAccessibility == Accessibility.Public && !item.IsReadOnly && !item.IsStatic; - if (!isReadable && !isWritable) - { - continue; - } - - var customFormatterAttr = item.GetAttributes().FirstOrDefault(x => x.AttributeClass.ApproximatelyEqual(this.typeReferences.MessagePackFormatterAttribute))?.ConstructorArguments[0].Value as INamedTypeSymbol; - var key = item.GetAttributes().FirstOrDefault(x => x.AttributeClass.ApproximatelyEqual(this.typeReferences.KeyAttribute))?.ConstructorArguments[0] - ?? throw new MessagePackGeneratorResolveFailedException("all public members must mark KeyAttribute or IgnoreMemberAttribute." + " type: " + type.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat) + " member:" + item.Name); - - var intKey = key is { Value: int intKeyValue } ? intKeyValue : default(int?); - var stringKey = key is { Value: string stringKeyValue } ? stringKeyValue : default; - if (intKey == null && stringKey == null) - { - throw new MessagePackGeneratorResolveFailedException("both IntKey and StringKey are null." + " type: " + type.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat) + " member:" + item.Name); - } - - if (searchFirst) - { - searchFirst = false; - isIntKey = intKey != null; - } - else - { - if ((isIntKey && intKey == null) || (!isIntKey && stringKey == null)) - { - throw new MessagePackGeneratorResolveFailedException("all members key type must be same." + " type: " + type.Name + " member:" + item.Name); - } - } - - if (isIntKey) - { - if (intMembers.ContainsKey(intKey!.Value)) - { - throw new MessagePackGeneratorResolveFailedException("key is duplicated, all members key must be unique." + " type: " + type.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat) + " member:" + item.Name); - } - - var member = new MemberSerializationInfo(true, isWritable, isReadable, intKey!.Value, item.Name, item.Name, item.Type.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat), item.Type.ToDisplayString(BinaryWriteFormat), customFormatterAttr?.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat)); - intMembers.Add(member.IntKey, member); - } - else - { - if (stringMembers.ContainsKey(stringKey!)) - { - throw new MessagePackGeneratorResolveFailedException("key is duplicated, all members key must be unique." + " type: " + type.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat) + " member:" + item.Name); - } - - var member = new MemberSerializationInfo(true, isWritable, isReadable, hiddenIntKey++, stringKey!, item.Name, item.Type.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat), item.Type.ToDisplayString(BinaryWriteFormat), customFormatterAttr?.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat)); - stringMembers.Add(member.StringKey, member); - } - - this.CollectCore(item.Type); // recursive collect - } - } - - // GetConstructor - var ctorEnumerator = default(IEnumerator); - var ctor = type.Constructors.Where(x => x.DeclaredAccessibility == Accessibility.Public).SingleOrDefault(x => x.GetAttributes().Any(y => y.AttributeClass != null && y.AttributeClass.ApproximatelyEqual(this.typeReferences.SerializationConstructorAttribute))); - if (ctor == null) - { - ctorEnumerator = type.Constructors.Where(x => x.DeclaredAccessibility == Accessibility.Public).OrderByDescending(x => x.Parameters.Length).GetEnumerator(); - - if (ctorEnumerator.MoveNext()) - { - ctor = ctorEnumerator.Current; - } - } - - // struct allows null ctor - if (ctor == null && isClass) - { - throw new MessagePackGeneratorResolveFailedException("can't find public constructor. type:" + type.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat)); - } - - var constructorParameters = new List(); - if (ctor != null) - { - var constructorLookupDictionary = stringMembers.ToLookup(x => x.Key, x => x, StringComparer.OrdinalIgnoreCase); - do - { - constructorParameters.Clear(); - var ctorParamIndex = 0; - foreach (IParameterSymbol item in ctor!.Parameters) - { - MemberSerializationInfo paramMember; - if (isIntKey) - { - if (intMembers.TryGetValue(ctorParamIndex, out paramMember!)) - { - if (item.Type.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat) == paramMember.Type && paramMember.IsReadable) - { - constructorParameters.Add(paramMember); - } - else - { - if (ctorEnumerator != null) - { - ctor = null; - continue; - } - else - { - throw new MessagePackGeneratorResolveFailedException("can't find matched constructor parameter, parameterType mismatch. type:" + type.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat) + " parameterIndex:" + ctorParamIndex + " parameterType:" + item.Type.Name); - } - } - } - else - { - if (ctorEnumerator != null) - { - ctor = null; - continue; - } - else - { - throw new MessagePackGeneratorResolveFailedException("can't find matched constructor parameter, index not found. type:" + type.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat) + " parameterIndex:" + ctorParamIndex); - } - } - } - else - { - IEnumerable> hasKey = constructorLookupDictionary[item.Name]; - using var enumerator = hasKey.GetEnumerator(); - - // hasKey.Count() == 0 - if (!enumerator.MoveNext()) - { - if (ctorEnumerator == null) - { - throw new MessagePackGeneratorResolveFailedException("can't find matched constructor parameter, index not found. type:" + type.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat) + " parameterName:" + item.Name); - } - - ctor = null; - continue; - } - - var first = enumerator.Current.Value; - - // hasKey.Count() != 1 - if (enumerator.MoveNext()) - { - if (ctorEnumerator == null) - { - throw new MessagePackGeneratorResolveFailedException("duplicate matched constructor parameter name:" + type.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat) + " parameterName:" + item.Name + " parameterType:" + item.Type.Name); - } - - ctor = null; - continue; - } - - paramMember = first; - if (item.Type.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat) == paramMember.Type && paramMember.IsReadable) - { - constructorParameters.Add(paramMember); - } - else - { - if (ctorEnumerator == null) - { - throw new MessagePackGeneratorResolveFailedException("can't find matched constructor parameter, parameterType mismatch. type:" + type.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat) + " parameterName:" + item.Name + " parameterType:" + item.Type.Name); - } - - ctor = null; - continue; - } - } - - ctorParamIndex++; - } - } - while (TryGetNextConstructor(ctorEnumerator, ref ctor)); - - if (ctor == null) - { - throw new MessagePackGeneratorResolveFailedException("can't find matched constructor. type:" + type.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat)); - } - } - - var hasSerializationConstructor = type.AllInterfaces.Any(x => x.ApproximatelyEqual(this.typeReferences.IMessagePackSerializationCallbackReceiver)); - var needsCastOnBefore = true; - var needsCastOnAfter = true; - if (hasSerializationConstructor) - { - needsCastOnBefore = !type.GetMembers("OnBeforeSerialize").Any(); - needsCastOnAfter = !type.GetMembers("OnAfterDeserialize").Any(); - } - - var info = new ObjectSerializationInfo(isClass, isOpenGenericType, isOpenGenericType ? type.TypeParameters.Select(ToGenericTypeParameterInfo).ToArray() : Array.Empty(), constructorParameters.ToArray(), isIntKey, isIntKey ? intMembers.Values.ToArray() : stringMembers.Values.ToArray(), isOpenGenericType ? GetGenericFormatterClassName(type) : GetMinimallyQualifiedClassName(type), type.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat), type.ContainingNamespace.IsGlobalNamespace ? null : type.ContainingNamespace.ToDisplayString(), hasSerializationConstructor, needsCastOnAfter, needsCastOnBefore); - - return info; - } - - private static GenericTypeParameterInfo ToGenericTypeParameterInfo(ITypeParameterSymbol typeParameter) - { - var constraints = new List(); - - // `notnull`, `unmanaged`, `class`, `struct` constraint must come before any constraints. - if (typeParameter.HasNotNullConstraint) - { - constraints.Add("notnull"); - } - - if (typeParameter.HasReferenceTypeConstraint) - { - constraints.Add(typeParameter.ReferenceTypeConstraintNullableAnnotation == NullableAnnotation.Annotated ? "class?" : "class"); - } - - if (typeParameter.HasValueTypeConstraint) - { - constraints.Add(typeParameter.HasUnmanagedTypeConstraint ? "unmanaged" : "struct"); - } - - // constraint types (IDisposable, IEnumerable ...) - foreach (var t in typeParameter.ConstraintTypes) - { - var constraintTypeFullName = t.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat.AddMiscellaneousOptions(SymbolDisplayMiscellaneousOptions.IncludeNullableReferenceTypeModifier)); - constraints.Add(constraintTypeFullName); - } - - // `new()` constraint must be last in constraints. - if (typeParameter.HasConstructorConstraint) - { - constraints.Add("new()"); - } - - return new GenericTypeParameterInfo(typeParameter.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat), string.Join(", ", constraints)); - } - - private static string GetGenericFormatterClassName(INamedTypeSymbol type) - { - return type.Name; - } - - private static string GetMinimallyQualifiedClassName(INamedTypeSymbol type) - { - var name = type.ContainingType is object ? GetMinimallyQualifiedClassName(type.ContainingType) + "_" : string.Empty; - name += type.ToDisplayString(SymbolDisplayFormat.MinimallyQualifiedFormat); - name = name.Replace('.', '_'); - name = name.Replace('<', '_'); - name = name.Replace('>', '_'); - name = Regex.Replace(name, @"\[([,])*\]", match => $"Array{match.Length - 1}"); - name = name.Replace("?", string.Empty); - return name; - } - - private static bool TryGetNextConstructor(IEnumerator? ctorEnumerator, ref IMethodSymbol? ctor) - { - if (ctorEnumerator == null || ctor != null) - { - return false; - } - - if (ctorEnumerator.MoveNext()) - { - ctor = ctorEnumerator.Current; - return true; - } - else - { - ctor = null; - return false; - } - } - - private bool IsAllowAccessibility(ITypeSymbol symbol) - { - do - { - if (symbol.DeclaredAccessibility != Accessibility.Public) - { - if (this.disallowInternal) - { - return false; - } - - if (symbol.DeclaredAccessibility != Accessibility.Internal) - { - return true; - } - } - - symbol = symbol.ContainingType; - } - while (symbol != null); - - return true; - } - - private bool IsOpenGenericTypeRecursively(INamedTypeSymbol type) - { - return type.IsGenericType && type.TypeArguments.Any(x => x is ITypeParameterSymbol || (x is INamedTypeSymbol symbol && IsOpenGenericTypeRecursively(symbol))); - } - } -} diff --git a/src/MessagePack.GeneratorCore/CodeGenerator.cs b/src/MessagePack.GeneratorCore/CodeGenerator.cs deleted file mode 100644 index 1f48973e3..000000000 --- a/src/MessagePack.GeneratorCore/CodeGenerator.cs +++ /dev/null @@ -1,319 +0,0 @@ -// Copyright (c) All contributors. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -using MessagePackCompiler.CodeAnalysis; -using MessagePackCompiler.Generator; -using Microsoft.CodeAnalysis; - -namespace MessagePackCompiler -{ - public class CodeGenerator - { - private static readonly HashSet InvalidFileCharSet = new(Path.GetInvalidFileNameChars()); - - private static readonly Encoding NoBomUtf8 = new UTF8Encoding(false); - - private readonly Action logger; - - public CodeGenerator(Action logger, CancellationToken cancellationToken) - { - this.logger = logger; - } - - /// - /// Generates the specialized resolver and formatters for the types that require serialization in a given compilation. - /// - /// The compilation to read types from as an input to code generation. - /// The name of the generated source file. - /// The resolver name. - /// The namespace for the generated type to be created in. May be null. - /// A boolean value that indicates whether all formatters should use property maps instead of more compact arrays. - /// A comma-delimited list of symbols that should surround redundant generated files. May be null. - /// May be null. - /// A task that indicates when generation has completed. - public async Task GenerateFileAsync( - Compilation compilation, - string output, - string resolverName, - string? @namespace, - bool useMapMode, - string? multipleIfDirectiveOutputSymbols, - string[]? externalIgnoreTypeNames) - { - var namespaceDot = string.IsNullOrWhiteSpace(@namespace) ? string.Empty : @namespace + "."; - var multipleOutputSymbols = multipleIfDirectiveOutputSymbols?.Split(',') ?? Array.Empty(); - - var sw = Stopwatch.StartNew(); - - foreach (var multiOutputSymbol in multipleOutputSymbols.Length == 0 ? new[] { string.Empty } : multipleOutputSymbols) - { - logger("Project Compilation Start:" + compilation.AssemblyName); - - var collector = new TypeCollector(compilation, true, useMapMode, externalIgnoreTypeNames, Console.WriteLine); - - logger("Project Compilation Complete:" + sw.Elapsed.ToString()); - - sw.Restart(); - logger("Method Collect Start"); - - var (objectInfo, enumInfo, genericInfo, unionInfo) = collector.Collect(); - - logger("Method Collect Complete:" + sw.Elapsed.ToString()); - - logger("Output Generation Start"); - sw.Restart(); - - if (Path.GetExtension(output) == ".cs") - { - // SingleFile Output - var fullGeneratedProgramText = GenerateSingleFileSync(resolverName, namespaceDot, objectInfo, enumInfo, unionInfo, genericInfo); - if (multiOutputSymbol == string.Empty) - { - await OutputAsync(output, fullGeneratedProgramText); - } - else - { - var fname = Path.GetFileNameWithoutExtension(output) + "." + MultiSymbolToSafeFilePath(multiOutputSymbol) + ".cs"; - var text = $"#if {multiOutputSymbol}" + Environment.NewLine + fullGeneratedProgramText + Environment.NewLine + "#endif"; - await OutputAsync(Path.Combine(Path.GetDirectoryName(output) ?? string.Empty, fname), text); - } - } - else - { - // Multiple File output - await GenerateMultipleFileAsync(output, resolverName, objectInfo, enumInfo, unionInfo, namespaceDot, multiOutputSymbol, genericInfo); - } - - if (objectInfo.Length == 0 && enumInfo.Length == 0 && genericInfo.Length == 0 && unionInfo.Length == 0) - { - logger("Generated result is empty, unexpected result?"); - } - } - - logger("Output Generation Complete:" + sw.Elapsed.ToString()); - } - - /// - /// Generates the specialized resolver and formatters for the types that require serialization in a given compilation. - /// - /// The resolver name. - /// The namespace for the generated type to be created in. - /// The ObjectSerializationInfo array which TypeCollector.Collect returns. - /// The EnumSerializationInfo array which TypeCollector.Collect returns. - /// The UnionSerializationInfo array which TypeCollector.Collect returns. - /// The GenericSerializationInfo array which TypeCollector.Collect returns. - public static string GenerateSingleFileSync(string resolverName, string namespaceDot, ObjectSerializationInfo[] objectInfo, EnumSerializationInfo[] enumInfo, UnionSerializationInfo[] unionInfo, GenericSerializationInfo[] genericInfo) - { - var objectFormatterTemplates = objectInfo - .GroupBy(x => (x.Namespace, x.IsStringKey)) - .Select(x => - { - var (nameSpace, isStringKey) = x.Key; - var objectSerializationInfos = x.ToArray(); - var ns = namespaceDot + "Formatters" + (nameSpace is null ? string.Empty : "." + nameSpace); - var template = isStringKey ? new StringKeyFormatterTemplate(ns, objectSerializationInfos) : (IFormatterTemplate)new FormatterTemplate(ns, objectSerializationInfos); - return template; - }) - .ToArray(); - - string GetNamespace(IGrouping x) - { - if (x.Key == null) - { - return namespaceDot + "Formatters"; - } - - return namespaceDot + "Formatters." + x.Key; - } - - var enumFormatterTemplates = enumInfo - .GroupBy(x => x.Namespace) - .Select(x => new EnumTemplate(GetNamespace(x), x.ToArray())) - .ToArray(); - - var unionFormatterTemplates = unionInfo - .GroupBy(x => x.Namespace) - .Select(x => new UnionTemplate(GetNamespace(x), x.ToArray())) - .ToArray(); - - var resolverTemplate = new ResolverTemplate(namespaceDot + "Resolvers", namespaceDot + "Formatters", resolverName, genericInfo.Where(x => !x.IsOpenGenericType).Cast().Concat(enumInfo).Concat(unionInfo).Concat(objectInfo.Where(x => !x.IsOpenGenericType)).ToArray()); - - var sb = new StringBuilder(); - sb.AppendLine(resolverTemplate.TransformText()); - sb.AppendLine(); - foreach (var item in enumFormatterTemplates) - { - var text = item.TransformText(); - sb.AppendLine(text); - } - - sb.AppendLine(); - foreach (var item in unionFormatterTemplates) - { - var text = item.TransformText(); - sb.AppendLine(text); - } - - sb.AppendLine(); - foreach (var item in objectFormatterTemplates) - { - var text = item.TransformText(); - sb.AppendLine(text); - } - - return sb.ToString(); - } - - private Task GenerateMultipleFileAsync(string output, string resolverName, ObjectSerializationInfo[] objectInfo, EnumSerializationInfo[] enumInfo, UnionSerializationInfo[] unionInfo, string namespaceDot, string multioutSymbol, GenericSerializationInfo[] genericInfo) - { - string GetNamespace(INamespaceInfo x) - { - if (x.Namespace == null) - { - return namespaceDot + "Formatters"; - } - - return namespaceDot + "Formatters." + x.Namespace; - } - - var waitingTasks = new Task[objectInfo.Length + enumInfo.Length + unionInfo.Length + 1]; - var waitingIndex = 0; - foreach (var x in objectInfo) - { - var ns = namespaceDot + "Formatters" + (x.Namespace is null ? string.Empty : "." + x.Namespace); - var template = x.IsStringKey ? new StringKeyFormatterTemplate(ns, new[] { x }) : (IFormatterTemplate)new FormatterTemplate(ns, new[] { x }); - var text = template.TransformText(); - waitingTasks[waitingIndex++] = OutputToDirAsync(output, template.Namespace, x.Name + "Formatter", multioutSymbol, text); - } - - foreach (var x in enumInfo) - { - var template = new EnumTemplate(GetNamespace(x), new[] { x }); - var text = template.TransformText(); - waitingTasks[waitingIndex++] = OutputToDirAsync(output, template.Namespace, x.Name + "Formatter", multioutSymbol, text); - } - - foreach (var x in unionInfo) - { - var template = new UnionTemplate(GetNamespace(x), new[] { x }); - var text = template.TransformText(); - waitingTasks[waitingIndex++] = OutputToDirAsync(output, template.Namespace, x.Name + "Formatter", multioutSymbol, text); - } - - var resolverTemplate = new ResolverTemplate(namespaceDot + "Resolvers", namespaceDot + "Formatters", resolverName, genericInfo.Where(x => !x.IsOpenGenericType).Cast().Concat(enumInfo).Concat(unionInfo).Concat(objectInfo.Where(x => !x.IsOpenGenericType)).ToArray()); - waitingTasks[waitingIndex] = OutputToDirAsync(output, resolverTemplate.Namespace, resolverTemplate.ResolverName, multioutSymbol, resolverTemplate.TransformText()); - return Task.WhenAll(waitingTasks); - } - - private Task OutputToDirAsync(string dir, string ns, string name, string multipleOutSymbol, string text) - { - var builder = new StringBuilder(); - void AppendDir(string dir) - { - if (dir.Length != 0) - { - builder.Append(dir); - if (dir[dir.Length - 1] != Path.DirectorySeparatorChar && dir[dir.Length - 1] != Path.AltDirectorySeparatorChar) - { - builder.Append(Path.DirectorySeparatorChar); - } - } - } - - void AppendChar(char c) - { - if (c == '.' || InvalidFileCharSet.Contains(c)) - { - builder.Append('_'); - } - else - { - builder.Append(c); - } - } - - void Append(string text) - { - var span = text.AsSpan(); - while (!span.IsEmpty) - { - var index = span.IndexOf("global::".AsSpan()); - if (index == -1) - { - foreach (var c in span) - { - AppendChar(c); - } - - break; - } - - if (index == 0) - { - span = span.Slice("global::".Length); - continue; - } - - foreach (var c in span.Slice(0, index)) - { - AppendChar(c); - } - - span = span.Slice(index + "global::".Length); - } - } - - AppendDir(dir); - - if (!string.IsNullOrWhiteSpace(multipleOutSymbol)) - { - text = $"#if {multipleOutSymbol}" + Environment.NewLine + text + Environment.NewLine + "#endif"; - AppendDir(MultiSymbolToSafeFilePath(multipleOutSymbol)); - } - - Append(ns); - builder.Append('_'); - Append(name); - builder.Append(".cs"); - - return OutputAsync(builder.ToString(), text); - } - - private Task OutputAsync(string path, string text) - { - path = path.Replace("global::", string.Empty); - - const string prefix = "[Out]"; - logger(prefix + path); - - var fi = new FileInfo(path); - if (fi.Directory != null && !fi.Directory.Exists) - { - fi.Directory.Create(); - } - - File.WriteAllText(path, NormalizeNewLines(text), NoBomUtf8); - return Task.CompletedTask; - } - - private static string MultiSymbolToSafeFilePath(string symbol) - { - return symbol.Replace("!", "NOT_").Replace("(", string.Empty).Replace(")", string.Empty).Replace("||", "_OR_").Replace("&&", "_AND_"); - } - - private static string NormalizeNewLines(string content) - { - // The T4 generated code may be text with mixed line ending types. (CR + CRLF) - // We need to normalize the line ending type in each Operating Systems. (e.g. Windows=CRLF, Linux/macOS=LF) - return content.Replace("\r\n", "\n").Replace("\n", Environment.NewLine); - } - } -} diff --git a/src/MessagePack.GeneratorCore/Generator/IFormatterTemplate.cs b/src/MessagePack.GeneratorCore/Generator/IFormatterTemplate.cs deleted file mode 100644 index ea3363a6e..000000000 --- a/src/MessagePack.GeneratorCore/Generator/IFormatterTemplate.cs +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (c) All contributors. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - -using MessagePackCompiler.CodeAnalysis; - -namespace MessagePackCompiler.Generator -{ - public interface IFormatterTemplate - { - string Namespace { get; } - - ObjectSerializationInfo[] ObjectSerializationInfos { get; } - - string TransformText(); - } -} diff --git a/src/MessagePack.GeneratorCore/Generator/ShouldUseFormatterResolverHelper.cs b/src/MessagePack.GeneratorCore/Generator/ShouldUseFormatterResolverHelper.cs deleted file mode 100644 index ab5e61866..000000000 --- a/src/MessagePack.GeneratorCore/Generator/ShouldUseFormatterResolverHelper.cs +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright (c) All contributors. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - -using System; -using MessagePackCompiler.CodeAnalysis; - -namespace MessagePackCompiler.Generator -{ - public static class ShouldUseFormatterResolverHelper - { - /// - /// Keep this list in sync with DynamicObjectTypeBuilder.IsOptimizeTargetType. - /// - internal static readonly string[] PrimitiveTypes = - { - "short", - "int", - "long", - "ushort", - "uint", - "ulong", - "float", - "double", - "bool", - "byte", - "sbyte", - "char", - "byte[]", - - // Do not include types that resolvers are allowed to modify. - ////"global::System.DateTime", // OldSpec has no support, so for that and perf reasons a .NET native DateTime resolver exists. - ////"string", // https://github.com/Cysharp/MasterMemory provides custom formatter for string interning. - }; - - public static bool ShouldUseFormatterResolver(MemberSerializationInfo[] infos) - { - foreach (var memberSerializationInfo in infos) - { - if (memberSerializationInfo.CustomFormatterTypeName == null && Array.IndexOf(PrimitiveTypes, memberSerializationInfo.Type) == -1) - { - return true; - } - } - - return false; - } - } -} diff --git a/src/MessagePack.GeneratorCore/Generator/StringKey/EmbedStringHelper.cs b/src/MessagePack.GeneratorCore/Generator/StringKey/EmbedStringHelper.cs deleted file mode 100644 index f10e26087..000000000 --- a/src/MessagePack.GeneratorCore/Generator/StringKey/EmbedStringHelper.cs +++ /dev/null @@ -1,87 +0,0 @@ -// Copyright (c) All contributors. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - -using System; -using System.Text; - -namespace MessagePackCompiler.Generator -{ - public static class EmbedStringHelper - { - public static readonly Encoding Utf8 = new UTF8Encoding(false); - - public static string ToByteArrayString(byte[] binary) - { - var headerLength = GetHeaderLength(binary.Length); - Span header = stackalloc byte[headerLength]; - EmbedHeader(binary.Length, header); - var buffer = new StringBuilder().Append("new byte[").Append(headerLength).Append(" + ").Append(binary.Length).Append("] { ").Append(header[0]); - foreach (var b in header.Slice(1)) - { - buffer.Append(", ").Append(b); - } - - foreach (var b in binary) - { - buffer.Append(", ").Append(b); - } - - return buffer.Append(" }").ToString(); - } - - public static int GetHeaderLength(int byteCount) - { - if (byteCount <= 31) - { - return 1; - } - - if (byteCount <= byte.MaxValue) - { - return 2; - } - - return byteCount <= ushort.MaxValue ? 3 : 5; - } - - public static void EmbedHeader(int byteCount, Span destination) - { - if (byteCount <= 31) - { - destination[0] = (byte)(0xa0 | byteCount); - return; - } - - if (byteCount <= byte.MaxValue) - { - destination[0] = 0xd9; - destination[1] = unchecked((byte)byteCount); - return; - } - - if (byteCount <= ushort.MaxValue) - { - destination[0] = 0xda; - destination[1] = unchecked((byte)(byteCount >> 8)); - destination[2] = unchecked((byte)byteCount); - return; - } - - destination[0] = 0xdb; - destination[1] = unchecked((byte)(byteCount >> 24)); - destination[2] = unchecked((byte)(byteCount >> 16)); - destination[3] = unchecked((byte)(byteCount >> 8)); - destination[4] = unchecked((byte)byteCount); - } - - public static byte[] GetEncodedStringBytes(string value) - { - var byteCount = Utf8.GetByteCount(value); - var headerLength = GetHeaderLength(byteCount); - var bytes = new byte[headerLength + byteCount]; - EmbedHeader(byteCount, bytes); - Utf8.GetBytes(value, 0, value.Length, bytes, headerLength); - return bytes; - } - } -} diff --git a/src/MessagePack.GeneratorCore/Generator/StringKey/StringKeyFormatterDeserializeHelper.cs b/src/MessagePack.GeneratorCore/Generator/StringKey/StringKeyFormatterDeserializeHelper.cs deleted file mode 100644 index f65bed0b3..000000000 --- a/src/MessagePack.GeneratorCore/Generator/StringKey/StringKeyFormatterDeserializeHelper.cs +++ /dev/null @@ -1,252 +0,0 @@ -// Copyright (c) All contributors. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using MessagePack.Internal; -using MessagePackCompiler.CodeAnalysis; - -namespace MessagePackCompiler.Generator -{ - internal static class StringKeyFormatterDeserializeHelper - { - public static string Classify(ObjectSerializationInfo objectSerializationInfo, string indent, bool canOverwrite) - { - var memberArray = objectSerializationInfo.Members; - var buffer = new StringBuilder(); - foreach (var memberInfoTuples in memberArray.Select(member => new MemberInfoTuple(member, IsConstructorParameter(objectSerializationInfo, member))).GroupBy(member => member.Binary.Length)) - { - var binaryLength = memberInfoTuples.Key; - var keyLength = binaryLength >> 3; - keyLength += keyLength << 3 == binaryLength ? 0 : 1; - - buffer.Append(indent).Append("case ").Append(binaryLength).Append(":\r\n"); - ClassifyRecursion(buffer, indent, 1, keyLength, memberInfoTuples, canOverwrite); - } - - return buffer.ToString(); - } - - private static bool IsConstructorParameter(ObjectSerializationInfo objectSerializationInfo, MemberSerializationInfo member) - { - foreach (var parameter in objectSerializationInfo.ConstructorParameters) - { - if (parameter.Equals(member)) - { - return true; - } - } - - return false; - } - - private static void Assign(StringBuilder buffer, in MemberInfoTuple member, bool canOverwrite, string indent, string tab, int tabCount) - { - if (member.Info.IsWritable || member.IsConstructorParameter) - { - if (canOverwrite) - { - buffer.Append("____result.").Append(member.Info.Name).Append(" = "); - } - else - { - if (!member.IsConstructorParameter) - { - buffer.Append("__").Append(member.Info.Name).Append("__IsInitialized = true;\r\n").Append(indent); - for (var i = 0; i < tabCount; i++) - { - buffer.Append(tab); - } - } - - buffer.Append("__").Append(member.Info.Name).Append("__ = "); - } - - buffer.Append(member.Info.GetDeserializeMethodString()).Append(";\r\n"); - } - else - { - buffer.Append("reader.Skip();\r\n"); - } - } - - private static void ClassifyRecursion(StringBuilder buffer, string indent, int tabCount, int keyLength, IEnumerable memberCollection, bool canOverwrite) - { - const string Tab = " "; - buffer.Append(indent); - for (var i = 0; i < tabCount; i++) - { - buffer.Append(Tab); - } - - var memberArray = memberCollection.ToArray(); - if (memberArray.Length == 1) - { - var member = memberArray[0]; - EmbedOne(buffer, indent, tabCount, member, canOverwrite); - return; - } - - buffer.Append("switch (global::MessagePack.Internal.AutomataKeyGen.GetKey(ref stringKey))\r\n").Append(indent); - for (var i = 0; i < tabCount; i++) - { - buffer.Append(Tab); - } - - buffer.Append("{\r\n" + Tab).Append(indent); - for (var i = 0; i < tabCount; i++) - { - buffer.Append(Tab); - } - - buffer.Append("default: goto FAIL;"); - - foreach (var grouping in memberArray.GroupBy(member => member.Key[tabCount - 1])) - { - buffer.Append("\r\n" + Tab).Append(indent); - for (var i = 0; i < tabCount; i++) - { - buffer.Append(Tab); - } - - buffer.Append("case ").Append(grouping.Key).Append("UL:\r\n"); - - if (tabCount == keyLength) - { - buffer.Append(Tab + Tab).Append(indent); - for (var i = 0; i < tabCount; i++) - { - buffer.Append(Tab); - } - - var member = grouping.Single(); - Assign(buffer, member, canOverwrite, indent, Tab, tabCount + 2); - buffer.Append(Tab + Tab).Append(indent); - for (var i = 0; i < tabCount; i++) - { - buffer.Append(Tab); - } - - buffer.Append("continue;"); - continue; - } - - ClassifyRecursion(buffer, indent + Tab, tabCount + 1, keyLength, grouping, canOverwrite); - } - - buffer.Append("\r\n").Append(indent); - for (var i = 0; i < tabCount; i++) - { - buffer.Append(Tab); - } - - buffer.Append("}\r\n"); - } - - private static void EmbedOne(StringBuilder buffer, string indent, int tabCount, in MemberInfoTuple member, bool canOverwrite) - { - const string Tab = " "; - var binary = member.Binary.AsSpan((tabCount - 1) << 3); - - switch (binary.Length) - { - case 1: - buffer.Append("if (stringKey[0] != ").Append(binary[0]); - break; - case 2: - case 3: - case 4: - case 5: - case 6: - case 7: - case 8: - buffer.Append("if (global::MessagePack.Internal.AutomataKeyGen.GetKey(ref stringKey) != ").Append(member.Key[tabCount - 1]).Append("UL"); - break; - default: - EmbedSequenceEqual(buffer, member, (tabCount << 3) - 8); - break; - } - - buffer.Append(") { goto FAIL; }\r\n\r\n").Append(indent); - for (var i = 0; i < tabCount; i++) - { - buffer.Append(Tab); - } - - Assign(buffer, member, canOverwrite, indent, Tab, tabCount); - buffer.Append(indent); - for (var i = 0; i < tabCount; i++) - { - buffer.Append(Tab); - } - - buffer.Append("continue;\r\n"); - } - - private static void EmbedSequenceEqual(StringBuilder buffer, MemberInfoTuple member, int startPosition) - { - buffer - .Append("if (!global::System.MemoryExtensions.SequenceEqual(stringKey, GetSpan_") - .Append(member.Info.Name) - .Append("().Slice(") - .Append(EmbedStringHelper.GetHeaderLength(member.Binary.Length)); - - if (startPosition != 0) - { - buffer.Append(" + ").Append(startPosition); - } - - buffer.Append("))"); - } - } - - internal readonly struct MemberInfoTuple : IComparable - { - public readonly MemberSerializationInfo Info; - public readonly bool IsConstructorParameter; - public readonly byte[] Binary; - public readonly ulong[] Key; - - public MemberInfoTuple(MemberSerializationInfo info, bool isConstructorParameter) - { - Info = info; - IsConstructorParameter = isConstructorParameter; - Binary = EmbedStringHelper.Utf8.GetBytes(info.StringKey); - ReadOnlySpan span = Binary; - var keyLength = Binary.Length >> 3; - keyLength += keyLength << 3 == Binary.Length ? 0 : 1; - Key = new ulong[keyLength]; - for (var i = 0; i < Key.Length; i++) - { - Key[i] = AutomataKeyGen.GetKey(ref span); - } - } - - public int CompareTo(MemberInfoTuple other) - { - if (Info == other.Info) - { - return 0; - } - - var c = Binary.Length.CompareTo(other.Binary.Length); - if (c != 0) - { - return c; - } - - for (var i = 0; i < Key.Length; i++) - { - c = Key[i].CompareTo(other.Key[i]); - if (c != 0) - { - return c; - } - } - - return 0; - } - } -} diff --git a/src/MessagePack.GeneratorCore/Generator/TemplatePartials.cs b/src/MessagePack.GeneratorCore/Generator/TemplatePartials.cs deleted file mode 100644 index 9e04131b9..000000000 --- a/src/MessagePack.GeneratorCore/Generator/TemplatePartials.cs +++ /dev/null @@ -1,80 +0,0 @@ -// Copyright (c) All contributors. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - -#pragma warning disable SA1402 // File may only contain a single type - -using MessagePackCompiler.CodeAnalysis; - -namespace MessagePackCompiler.Generator -{ - public partial class FormatterTemplate : IFormatterTemplate - { - public FormatterTemplate(string @namespace, ObjectSerializationInfo[] objectSerializationInfos) - { - Namespace = @namespace; - ObjectSerializationInfos = objectSerializationInfos; - } - - public string Namespace { get; } - - public ObjectSerializationInfo[] ObjectSerializationInfos { get; } - } - - public partial class StringKeyFormatterTemplate : IFormatterTemplate - { - public StringKeyFormatterTemplate(string @namespace, ObjectSerializationInfo[] objectSerializationInfos) - { - Namespace = @namespace; - ObjectSerializationInfos = objectSerializationInfos; - } - - public string Namespace { get; } - - public ObjectSerializationInfo[] ObjectSerializationInfos { get; } - } - - public partial class ResolverTemplate - { - public ResolverTemplate(string @namespace, string formatterNamespace, string resolverName, IResolverRegisterInfo[] registerInfos) - { - Namespace = @namespace; - FormatterNamespace = formatterNamespace; - ResolverName = resolverName; - RegisterInfos = registerInfos; - } - - public string Namespace { get; } - - public string FormatterNamespace { get; } - - public string ResolverName { get; } - - public IResolverRegisterInfo[] RegisterInfos { get; } - } - - public partial class EnumTemplate - { - public EnumTemplate(string @namespace, EnumSerializationInfo[] enumSerializationInfos) - { - Namespace = @namespace; - EnumSerializationInfos = enumSerializationInfos; - } - - public string Namespace { get; } - - public EnumSerializationInfo[] EnumSerializationInfos { get; } - } - - public partial class UnionTemplate - { - public UnionTemplate(string @namespace, UnionSerializationInfo[] unionSerializationInfos) - { - Namespace = @namespace; - UnionSerializationInfos = unionSerializationInfos; - } - - public string Namespace { get; } - - public UnionSerializationInfo[] UnionSerializationInfos { get; } - } -} diff --git a/src/MessagePack.GeneratorCore/MessagePack.GeneratorCore.csproj b/src/MessagePack.GeneratorCore/MessagePack.GeneratorCore.csproj deleted file mode 100644 index 2714c70f3..000000000 --- a/src/MessagePack.GeneratorCore/MessagePack.GeneratorCore.csproj +++ /dev/null @@ -1,79 +0,0 @@ - - - - netstandard2.0 - MessagePackCompiler - false - - - - - - - - - - True - True - EnumTemplate.tt - - - True - True - FormatterTemplate.tt - - - True - True - ResolverTemplate.tt - - - True - True - StringKeyFormatterTemplate.tt - - - %(FileName).tt - True - True - - - True - True - UnionTemplate.tt - - - - - - EnumTemplate.cs - TextTemplatingFilePreprocessor - - - FormatterTemplate.cs - TextTemplatingFilePreprocessor - - - ResolverTemplate.cs - TextTemplatingFilePreprocessor - - - StringKeyFormatterTemplate.cs - TextTemplatingFilePreprocessor - MessagePackCompiler.Generator - - - UnionTemplate.cs - TextTemplatingFilePreprocessor - - - - - - - - - - - - diff --git a/src/MessagePack.GeneratorCore/Utils/RoslynExtensions.cs b/src/MessagePack.GeneratorCore/Utils/RoslynExtensions.cs deleted file mode 100644 index b8645e11b..000000000 --- a/src/MessagePack.GeneratorCore/Utils/RoslynExtensions.cs +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright (c) All contributors. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - -using System.Collections.Generic; -using System.Linq; -using Microsoft.CodeAnalysis; - -namespace MessagePackCompiler -{ - // Utility and Extension methods for Roslyn - internal static class RoslynExtensions - { - public static IEnumerable GetNamedTypeSymbols(this Compilation compilation) - { - return compilation.SyntaxTrees.SelectMany(syntaxTree => - { - var semModel = compilation.GetSemanticModel(syntaxTree); - return syntaxTree.GetRoot() - .DescendantNodes() - .Select(x => semModel.GetDeclaredSymbol(x)) - .OfType(); - }); - } - - public static IEnumerable GetAllMembers(this ITypeSymbol symbol) - { - var t = symbol; - while (t != null) - { - foreach (var item in t.GetMembers()) - { - yield return item; - } - - t = t.BaseType; - } - } - - public static bool ApproximatelyEqual(this INamedTypeSymbol? left, INamedTypeSymbol? right) - { - if (left is IErrorTypeSymbol || right is IErrorTypeSymbol) - { - return left?.ToDisplayString() == right?.ToDisplayString(); - } - else - { - return SymbolEqualityComparer.Default.Equals(left, right); - } - } - } -} diff --git a/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Internal/AutomataDictionary.cs b/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Internal/AutomataDictionary.cs index 0b6a21bd7..808dc10aa 100644 --- a/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Internal/AutomataDictionary.cs +++ b/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Internal/AutomataDictionary.cs @@ -408,95 +408,4 @@ private static void EmitSearchNextCore(ILGenerator il, LocalBuilder bytesSpan, L #endif } } - - /// - /// This is used by dynamically generated code. It can be made internal after we enable our dynamic assemblies to access internals. - /// But that trick may require net46, so maybe we should leave this as public. - /// - public static class AutomataKeyGen - { - public static readonly MethodInfo GetKeyMethod = typeof(AutomataKeyGen).GetRuntimeMethod(nameof(GetKey), new[] { typeof(ReadOnlySpan).MakeByRefType() }) ?? throw new Exception("Unable to find our own APIs."); - - public static ulong GetKey(ref ReadOnlySpan span) - { - ulong key; - - unchecked - { - if (span.Length >= 8) - { - key = SafeBitConverter.ToUInt64(span); - span = span.Slice(8); - } - else - { - switch (span.Length) - { - case 1: - { - key = span[0]; - span = span.Slice(1); - break; - } - - case 2: - { - key = SafeBitConverter.ToUInt16(span); - span = span.Slice(2); - break; - } - - case 3: - { - var a = span[0]; - var b = SafeBitConverter.ToUInt16(span.Slice(1)); - key = a | (ulong)b << 8; - span = span.Slice(3); - break; - } - - case 4: - { - key = SafeBitConverter.ToUInt32(span); - span = span.Slice(4); - break; - } - - case 5: - { - var a = span[0]; - var b = SafeBitConverter.ToUInt32(span.Slice(1)); - key = a | (ulong)b << 8; - span = span.Slice(5); - break; - } - - case 6: - { - ulong a = SafeBitConverter.ToUInt16(span); - ulong b = SafeBitConverter.ToUInt32(span.Slice(2)); - key = a | (b << 16); - span = span.Slice(6); - break; - } - - case 7: - { - var a = span[0]; - var b = SafeBitConverter.ToUInt16(span.Slice(1)); - var c = SafeBitConverter.ToUInt32(span.Slice(3)); - key = a | (ulong)b << 8 | (ulong)c << 24; - span = span.Slice(7); - break; - } - - default: - throw new MessagePackSerializationException("Not Supported Length"); - } - } - - return key; - } - } - } } diff --git a/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Internal/AutomataKeyGen.cs b/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Internal/AutomataKeyGen.cs new file mode 100644 index 000000000..283fc9c83 --- /dev/null +++ b/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Internal/AutomataKeyGen.cs @@ -0,0 +1,109 @@ +// Copyright (c) All contributors. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using System; +using System.Buffers; +using System.Collections; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using System.Reflection.Emit; +using System.Runtime.InteropServices; +using System.Text; + +#pragma warning disable SA1402 // File may only contain a single type +#pragma warning disable SA1509 // Opening braces should not be preceded by blank line + +namespace MessagePack.Internal +{ + /// + /// This is used by dynamically generated code. It can be made internal after we enable our dynamic assemblies to access internals. + /// But that trick may require net46, so maybe we should leave this as public. + /// + public static class AutomataKeyGen + { + public static readonly MethodInfo GetKeyMethod = typeof(AutomataKeyGen).GetRuntimeMethod(nameof(GetKey), new[] { typeof(ReadOnlySpan).MakeByRefType() }) ?? throw new Exception("Unable to find our own APIs."); + + public static ulong GetKey(ref ReadOnlySpan span) + { + ulong key; + + unchecked + { + if (span.Length >= 8) + { + key = SafeBitConverter.ToUInt64(span); + span = span.Slice(8); + } + else + { + switch (span.Length) + { + case 1: + { + key = span[0]; + span = span.Slice(1); + break; + } + + case 2: + { + key = SafeBitConverter.ToUInt16(span); + span = span.Slice(2); + break; + } + + case 3: + { + var a = span[0]; + var b = SafeBitConverter.ToUInt16(span.Slice(1)); + key = a | (ulong)b << 8; + span = span.Slice(3); + break; + } + + case 4: + { + key = SafeBitConverter.ToUInt32(span); + span = span.Slice(4); + break; + } + + case 5: + { + var a = span[0]; + var b = SafeBitConverter.ToUInt32(span.Slice(1)); + key = a | (ulong)b << 8; + span = span.Slice(5); + break; + } + + case 6: + { + ulong a = SafeBitConverter.ToUInt16(span); + ulong b = SafeBitConverter.ToUInt32(span.Slice(2)); + key = a | (b << 16); + span = span.Slice(6); + break; + } + + case 7: + { + var a = span[0]; + var b = SafeBitConverter.ToUInt16(span.Slice(1)); + var c = SafeBitConverter.ToUInt32(span.Slice(3)); + key = a | (ulong)b << 8 | (ulong)c << 24; + span = span.Slice(7); + break; + } + + default: + throw new MessagePackSerializationException("Not Supported Length"); + } + } + + return key; + } + } + } +} diff --git a/tests/MessagePack.Generator.Tests/MessagePack.Generator.Tests.csproj b/tests/MessagePack.Generator.Tests/MessagePack.Generator.Tests.csproj index d8b1a4c83..173496d34 100644 --- a/tests/MessagePack.Generator.Tests/MessagePack.Generator.Tests.csproj +++ b/tests/MessagePack.Generator.Tests/MessagePack.Generator.Tests.csproj @@ -14,7 +14,7 @@ - + From 4763459c0862bdf37931a387369bcc40c8491d16 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Mon, 20 Mar 2023 18:04:49 -0600 Subject: [PATCH 016/660] Rollback Roslyn3 to 3.9 It presumably should be 3.8, but it doesn't compile with 3.8 at this point. --- Directory.Packages.props | 1 - .../MessagePack.Generator.Roslyn3.csproj | 3 +++ src/MessagePack.Generator.Roslyn3/MessagepackGenerator.cs | 4 ++-- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/Directory.Packages.props b/Directory.Packages.props index a1f151d30..68defe23d 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -7,7 +7,6 @@ 0.13.5 - 4.3.0 4.5.0 diff --git a/src/MessagePack.Generator.Roslyn3/MessagePack.Generator.Roslyn3.csproj b/src/MessagePack.Generator.Roslyn3/MessagePack.Generator.Roslyn3.csproj index b25ffbde0..57f0e9df9 100644 --- a/src/MessagePack.Generator.Roslyn3/MessagePack.Generator.Roslyn3.csproj +++ b/src/MessagePack.Generator.Roslyn3/MessagePack.Generator.Roslyn3.csproj @@ -7,6 +7,9 @@ enable ROSLYN3 cs + + + 3.9.0 MessagePack.Generator diff --git a/src/MessagePack.Generator.Roslyn3/MessagepackGenerator.cs b/src/MessagePack.Generator.Roslyn3/MessagepackGenerator.cs index 316f914b3..cd0dbb0ab 100644 --- a/src/MessagePack.Generator.Roslyn3/MessagepackGenerator.cs +++ b/src/MessagePack.Generator.Roslyn3/MessagepackGenerator.cs @@ -23,12 +23,12 @@ public void Execute(GeneratorExecutionContext context) return; } - var compiation = context.Compilation; + var compilation = context.Compilation; var generateContext = new GeneratorContext(context); foreach (var syntax in receiver.ClassDeclarations) { - Generate(syntax, compiation, generateContext); + Generate(syntax, compilation, generateContext); } } From 7ede56cbc29812b402ddb55a1bf65f6afbaa4277 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Mon, 20 Mar 2023 21:43:50 -0600 Subject: [PATCH 017/660] Got first new test passing --- Directory.Packages.props | 1 + nuget.config | 10 + .../MessagepackGenerator.cs | 2 +- .../MessagepackGenerator.Emit.cs | 2 +- .../MessagepackGenerator.cs | 12 +- .../GenerateEnumFormatterTest.cs | 178 +++++++++++++++--- .../MessagePack.Generator.Tests.csproj | 13 ++ tests/MessagePack.Generator.Tests/Usings.cs | 1 + .../CSharpSourceGeneratorVerifier`1+Test.cs | 56 ++++++ .../Verifiers/ReferenceHelper.cs | 11 ++ 10 files changed, 258 insertions(+), 28 deletions(-) create mode 100644 tests/MessagePack.Generator.Tests/Usings.cs create mode 100644 tests/MessagePack.Generator.Tests/Verifiers/CSharpSourceGeneratorVerifier`1+Test.cs create mode 100644 tests/MessagePack.Generator.Tests/Verifiers/ReferenceHelper.cs diff --git a/Directory.Packages.props b/Directory.Packages.props index 68defe23d..2802d86ef 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -30,6 +30,7 @@ + diff --git a/nuget.config b/nuget.config index 2ed04eeb6..2f513c3f4 100644 --- a/nuget.config +++ b/nuget.config @@ -7,9 +7,19 @@ + + + + + + + + + + diff --git a/src/MessagePack.Generator.Roslyn3/MessagepackGenerator.cs b/src/MessagePack.Generator.Roslyn3/MessagepackGenerator.cs index cd0dbb0ab..3ef472a03 100644 --- a/src/MessagePack.Generator.Roslyn3/MessagepackGenerator.cs +++ b/src/MessagePack.Generator.Roslyn3/MessagepackGenerator.cs @@ -7,7 +7,7 @@ namespace MessagePack.Generator; [Generator(LanguageNames.CSharp)] -public partial class MessagepackGenerator : ISourceGenerator +public partial class MessagePackGenerator : ISourceGenerator { public const string MessagePackObjectAttributeFullName = "MessagePack.MessagePackObjectAttribute"; diff --git a/src/MessagePack.Generator/MessagepackGenerator.Emit.cs b/src/MessagePack.Generator/MessagepackGenerator.Emit.cs index 11c02d9cf..dbeb289ea 100644 --- a/src/MessagePack.Generator/MessagepackGenerator.Emit.cs +++ b/src/MessagePack.Generator/MessagepackGenerator.Emit.cs @@ -9,7 +9,7 @@ namespace MessagePack.Generator; -public partial class MessagepackGenerator +public partial class MessagePackGenerator { private static void Generate(TypeDeclarationSyntax syntax, Compilation compilation, IGeneratorContext context) { diff --git a/src/MessagePack.Generator/MessagepackGenerator.cs b/src/MessagePack.Generator/MessagepackGenerator.cs index d0ce067a6..4435bf329 100644 --- a/src/MessagePack.Generator/MessagepackGenerator.cs +++ b/src/MessagePack.Generator/MessagepackGenerator.cs @@ -7,11 +7,16 @@ namespace MessagePack.Generator; [Generator(LanguageNames.CSharp)] -public partial class MessagepackGenerator : IIncrementalGenerator +public partial class MessagePackGenerator : IIncrementalGenerator, ISourceGenerator { public const string MessagePackObjectAttributeFullName = "MessagePack.MessagePackObjectAttribute"; public const string MessagePackUnionAttributeFullName = "MessagePack.UnionAttribute"; + public void Execute(GeneratorExecutionContext context) + { + throw new NotImplementedException(); + } + public void Initialize(IncrementalGeneratorInitializationContext context) { var typeDeclarations = context.SyntaxProvider.ForAttributeWithMetadataName( @@ -40,6 +45,11 @@ void Register(IncrementalValuesProvider typeDeclarations) } } + public void Initialize(GeneratorInitializationContext context) + { + throw new NotImplementedException(); + } + private class Comparer : IEqualityComparer<(TypeDeclarationSyntax, Compilation)> { public static readonly Comparer Instance = new Comparer(); diff --git a/tests/MessagePack.Generator.Tests/GenerateEnumFormatterTest.cs b/tests/MessagePack.Generator.Tests/GenerateEnumFormatterTest.cs index 2ad23fcbe..ce4d2098d 100644 --- a/tests/MessagePack.Generator.Tests/GenerateEnumFormatterTest.cs +++ b/tests/MessagePack.Generator.Tests/GenerateEnumFormatterTest.cs @@ -2,11 +2,15 @@ // Licensed under the MIT license. See LICENSE file in the project root for full license information. using System; +using System.Text; using System.Threading; using System.Threading.Tasks; using FluentAssertions; +using Microsoft.CodeAnalysis.Text; +using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; using Xunit; using Xunit.Abstractions; +using VerifyCS = CSharpSourceGeneratorVerifier; namespace MessagePack.Generator.Tests { @@ -22,42 +26,166 @@ public GenerateEnumFormatterTest(ITestOutputHelper testOutputHelper) [Fact] public async Task EnumFormatter() { - using var tempWorkarea = TemporaryProjectWorkarea.Create(); - var contents = @" + string contents = """ using System; using System.Collections.Generic; using MessagePack; -namespace TempProject +namespace TempProject; + +[MessagePackObject] +public class MyMessagePackObject +{ + [Key(0)] + public MyEnum EnumValue { get; set; } +} + +public enum MyEnum +{ + A, B, C +} +"""; + string generated = """ +using System.Runtime.CompilerServices; +using MessagePack; + +namespace Resolvers { - [MessagePackObject] - public class MyMessagePackObject + partial class FormatterRegister { - [Key(0)] - public MyEnum EnumValue { get; set; } + [ModuleInitializer] + internal static void TempProject_MyMessagePackObjectFormatterRegister() + { + MessagePack.Resolvers.StaticCompositeResolver.Instance.AddGeneratedFormatter(new global::Formatters.TempProject.MyEnumFormatter()); + MessagePack.Resolvers.StaticCompositeResolver.Instance.AddGeneratedFormatter(new global::Formatters.TempProject.MyMessagePackObjectFormatter()); + } + } +} +// + +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 168 +#pragma warning disable CS1591 // document public APIs + +#pragma warning disable SA1403 // File may only contain a single namespace +#pragma warning disable SA1649 // File name should match first type name + +namespace Formatters.TempProject +{ + + public sealed class MyEnumFormatter : global::MessagePack.Formatters.IMessagePackFormatter + { + public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::TempProject.MyEnum value, global::MessagePack.MessagePackSerializerOptions options) + { + writer.Write((global::System.Int32)value); + } + + public global::TempProject.MyEnum Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) + { + return (global::TempProject.MyEnum)reader.ReadInt32(); + } } +} + +#pragma warning restore 168 +#pragma warning restore 414 +#pragma warning restore 618 +#pragma warning restore 612 + +#pragma warning restore SA1403 // File may only contain a single namespace +#pragma warning restore SA1649 // File name should match first type name + + +// + +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 168 +#pragma warning disable CS1591 // document public APIs - public enum MyEnum +#pragma warning disable SA1129 // Do not use default value type constructor +#pragma warning disable SA1309 // Field names should not begin with underscore +#pragma warning disable SA1312 // Variable names should begin with lower-case letter +#pragma warning disable SA1403 // File may only contain a single namespace +#pragma warning disable SA1649 // File name should match first type name + +namespace Formatters.TempProject +{ + public sealed class MyMessagePackObjectFormatter : global::MessagePack.Formatters.IMessagePackFormatter { - A, B, C + + public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::TempProject.MyMessagePackObject value, global::MessagePack.MessagePackSerializerOptions options) + { + if (value == null) + { + writer.WriteNil(); + return; + } + + global::MessagePack.IFormatterResolver formatterResolver = options.Resolver; + writer.WriteArrayHeader(1); + global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Serialize(ref writer, value.EnumValue, options); + } + + public global::TempProject.MyMessagePackObject Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) + { + if (reader.TryReadNil()) + { + return null; + } + + options.Security.DepthStep(ref reader); + global::MessagePack.IFormatterResolver formatterResolver = options.Resolver; + var length = reader.ReadArrayHeader(); + var ____result = new global::TempProject.MyMessagePackObject(); + + for (int i = 0; i < length; i++) + { + switch (i) + { + case 0: + ____result.EnumValue = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Deserialize(ref reader, options); + break; + default: + reader.Skip(); + break; + } + } + + reader.Depth--; + return ____result; + } } + } - "; - tempWorkarea.AddFileToTargetProject("MyMessagePackObject.cs", contents); - - var compiler = new MessagePackCompiler.CodeGenerator(testOutputHelper.WriteLine, CancellationToken.None); - await compiler.GenerateFileAsync( - tempWorkarea.GetOutputCompilation().Compilation, - tempWorkarea.OutputDirectory, - "TempProjectResolver", - "TempProject.Generated", - false, - string.Empty, - Array.Empty()); - - var compilation = tempWorkarea.GetOutputCompilation(); - var symbols = compilation.GetNamedTypeSymbolsFromGenerated(); - symbols.Should().Contain(x => x.Name == "MyEnumFormatter"); + +#pragma warning restore 168 +#pragma warning restore 414 +#pragma warning restore 618 +#pragma warning restore 612 + +#pragma warning restore SA1129 // Do not use default value type constructor +#pragma warning restore SA1309 // Field names should not begin with underscore +#pragma warning restore SA1312 // Variable names should begin with lower-case letter +#pragma warning restore SA1403 // File may only contain a single namespace +#pragma warning restore SA1649 // File name should match first type name + + +"""; + await new VerifyCS.Test + { + TestState = + { + Sources = { contents }, + GeneratedSources = + { + (typeof(MessagePackGenerator), "TempProject.MyMessagePackObject.MessagePackFormatter.g.cs", SourceText.From(generated, Encoding.UTF8, SourceHashAlgorithm.Sha1)), + }, + }, + }.RunAsync(); } } } diff --git a/tests/MessagePack.Generator.Tests/MessagePack.Generator.Tests.csproj b/tests/MessagePack.Generator.Tests/MessagePack.Generator.Tests.csproj index 173496d34..7b621b055 100644 --- a/tests/MessagePack.Generator.Tests/MessagePack.Generator.Tests.csproj +++ b/tests/MessagePack.Generator.Tests/MessagePack.Generator.Tests.csproj @@ -2,10 +2,23 @@ net7.0 + true + 11 + + + + + + + + + + + diff --git a/tests/MessagePack.Generator.Tests/Usings.cs b/tests/MessagePack.Generator.Tests/Usings.cs new file mode 100644 index 000000000..67e549f86 --- /dev/null +++ b/tests/MessagePack.Generator.Tests/Usings.cs @@ -0,0 +1 @@ +global using System.Collections.Immutable; diff --git a/tests/MessagePack.Generator.Tests/Verifiers/CSharpSourceGeneratorVerifier`1+Test.cs b/tests/MessagePack.Generator.Tests/Verifiers/CSharpSourceGeneratorVerifier`1+Test.cs new file mode 100644 index 000000000..335166eeb --- /dev/null +++ b/tests/MessagePack.Generator.Tests/Verifiers/CSharpSourceGeneratorVerifier`1+Test.cs @@ -0,0 +1,56 @@ +// Copyright (c) All contributors. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using System.Collections.Immutable; +using MessagePack; +using MessagePack.Formatters; +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.CSharp; +using Microsoft.CodeAnalysis.CSharp.Testing; +using Microsoft.CodeAnalysis.Testing.Verifiers; + +public static partial class CSharpSourceGeneratorVerifier + where TSourceGenerator : ISourceGenerator, new() +{ + public class Test : CSharpSourceGeneratorTest + { + public Test() + { + this.ReferenceAssemblies = ReferenceHelper.DefaultReferences; + + this.SolutionTransforms.Add((solution, projectId) => + { + Project project = solution.GetProject(projectId); + + project = project + .AddMetadataReference(MetadataReference.CreateFromFile(typeof(MessagePackObjectAttribute).Assembly.Location)) + .AddMetadataReference(MetadataReference.CreateFromFile(typeof(IMessagePackFormatter).Assembly.Location)); + + return project.Solution; + }); + } + + protected override CompilationOptions CreateCompilationOptions() + { + CompilationOptions compilationOptions = base.CreateCompilationOptions(); + return compilationOptions.WithSpecificDiagnosticOptions( + compilationOptions.SpecificDiagnosticOptions.SetItems(GetNullableWarningsFromCompiler())); + } + + public LanguageVersion LanguageVersion { get; set; } = LanguageVersion.Latest; + + private static ImmutableDictionary GetNullableWarningsFromCompiler() + { + string[] args = { "/warnaserror:nullable" }; + CSharpCommandLineArguments commandLineArguments = CSharpCommandLineParser.Default.Parse(args, baseDirectory: Environment.CurrentDirectory, sdkDirectory: Environment.CurrentDirectory); + ImmutableDictionary nullableWarnings = commandLineArguments.CompilationOptions.SpecificDiagnosticOptions; + + return nullableWarnings; + } + + protected override ParseOptions CreateParseOptions() + { + return ((CSharpParseOptions)base.CreateParseOptions()).WithLanguageVersion(LanguageVersion); + } + } +} diff --git a/tests/MessagePack.Generator.Tests/Verifiers/ReferenceHelper.cs b/tests/MessagePack.Generator.Tests/Verifiers/ReferenceHelper.cs new file mode 100644 index 000000000..b8b7104e8 --- /dev/null +++ b/tests/MessagePack.Generator.Tests/Verifiers/ReferenceHelper.cs @@ -0,0 +1,11 @@ +// Copyright (c) All contributors. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using System.Reflection; +using MessagePack; +using Microsoft.CodeAnalysis.Testing; + +internal static class ReferenceHelper +{ + public static ReferenceAssemblies DefaultReferences = ReferenceAssemblies.Net.Net70; +} From 4d99531aba7d3be61b1a1c92511b484943b10f76 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Tue, 21 Mar 2023 06:33:26 -0600 Subject: [PATCH 018/660] Fix package restore --- Directory.Packages.props | 2 +- nuget.config | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/Directory.Packages.props b/Directory.Packages.props index 2802d86ef..a272bdda2 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -35,7 +35,7 @@ - + diff --git a/nuget.config b/nuget.config index 2f513c3f4..ba780d4f6 100644 --- a/nuget.config +++ b/nuget.config @@ -17,6 +17,7 @@ + From c9e9a10ddeb29d218d196d2b6fd309394634f91b Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Tue, 21 Mar 2023 06:39:13 -0600 Subject: [PATCH 019/660] Remove checked-in generated code --- sandbox/Sandbox/Generated.cs | 4481 -------------------------------- sandbox/Sandbox/codegen.bat | 4 - sandbox/Sandbox/codegen.ps1 | 1 - sandbox/TestData2/Generated.cs | 1012 -------- sandbox/TestData2/codegen.bat | 4 - sandbox/TestData2/codegen.ps1 | 1 - sandbox/codegen.ps1 | 11 - 7 files changed, 5514 deletions(-) delete mode 100644 sandbox/Sandbox/Generated.cs delete mode 100644 sandbox/Sandbox/codegen.bat delete mode 100644 sandbox/Sandbox/codegen.ps1 delete mode 100644 sandbox/TestData2/Generated.cs delete mode 100644 sandbox/TestData2/codegen.bat delete mode 100644 sandbox/TestData2/codegen.ps1 delete mode 100644 sandbox/codegen.ps1 diff --git a/sandbox/Sandbox/Generated.cs b/sandbox/Sandbox/Generated.cs deleted file mode 100644 index 696478189..000000000 --- a/sandbox/Sandbox/Generated.cs +++ /dev/null @@ -1,4481 +0,0 @@ -// -// THIS (.cs) FILE IS GENERATED BY MPC(MessagePack-CSharp). DO NOT CHANGE IT. -// - -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 168 -#pragma warning disable CS1591 // document public APIs - -#pragma warning disable SA1312 // Variable names should begin with lower-case letter -#pragma warning disable SA1649 // File name should match first type name - -namespace MessagePack.Resolvers -{ - public class GeneratedResolver : global::MessagePack.IFormatterResolver - { - public static readonly global::MessagePack.IFormatterResolver Instance = new GeneratedResolver(); - - private GeneratedResolver() - { - } - - public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() - { - return FormatterCache.Formatter; - } - - private static class FormatterCache - { - internal static readonly global::MessagePack.Formatters.IMessagePackFormatter Formatter; - - static FormatterCache() - { - var f = GeneratedResolverGetFormatterHelper.GetFormatter(typeof(T)); - if (f != null) - { - Formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; - } - } - } - } - - internal static class GeneratedResolverGetFormatterHelper - { - private static readonly global::System.Collections.Generic.Dictionary lookup; - - static GeneratedResolverGetFormatterHelper() - { - lookup = new global::System.Collections.Generic.Dictionary(72) - { - { typeof(global::GlobalMyEnum[,]), 0 }, - { typeof(global::GlobalMyEnum[]), 1 }, - { typeof(global::QuestMessageBody[]), 2 }, - { typeof(global::System.Collections.Generic.IDictionary), 3 }, - { typeof(global::System.Collections.Generic.IList), 4 }, - { typeof(int[,,,]), 5 }, - { typeof(int[,,]), 6 }, - { typeof(int[,]), 7 }, - { typeof(global::GlobalMyEnum), 8 }, - { typeof(global::SharedData.ByteEnum), 9 }, - { typeof(global::IMessageBody), 10 }, - { typeof(global::SharedData.IIVersioningUnion), 11 }, - { typeof(global::SharedData.IUnionChecker), 12 }, - { typeof(global::SharedData.IUnionChecker2), 13 }, - { typeof(global::SharedData.IUnionSample), 14 }, - { typeof(global::SharedData.RootUnionType), 15 }, - { typeof(global::Abcdefg.Efcdigjl.Ateatatea.Hgfagfafgad.TnonodsfarnoiuAtatqaga), 16 }, - { typeof(global::ArrayTestTest), 17 }, - { typeof(global::ComplexModel), 18 }, - { typeof(global::GlobalMan), 19 }, - { typeof(global::Message), 20 }, - { typeof(global::MessagePackFormatterFieldUser), 21 }, - { typeof(global::PerfBenchmarkDotNet.StringKeySerializerTarget), 22 }, - { typeof(global::QuestMessageBody), 23 }, - { typeof(global::SharedData.ArrayOptimizeClass), 24 }, - { typeof(global::SharedData.BarClass), 25 }, - { typeof(global::SharedData.Callback1), 26 }, - { typeof(global::SharedData.Callback1_2), 27 }, - { typeof(global::SharedData.Callback2), 28 }, - { typeof(global::SharedData.Callback2_2), 29 }, - { typeof(global::SharedData.DefaultValueIntKeyClassWithExplicitConstructor), 30 }, - { typeof(global::SharedData.DefaultValueIntKeyClassWithoutExplicitConstructor), 31 }, - { typeof(global::SharedData.DefaultValueIntKeyStructWithExplicitConstructor), 32 }, - { typeof(global::SharedData.DefaultValueStringKeyClassWithExplicitConstructor), 33 }, - { typeof(global::SharedData.DefaultValueStringKeyClassWithoutExplicitConstructor), 34 }, - { typeof(global::SharedData.DefaultValueStringKeyStructWithExplicitConstructor), 35 }, - { typeof(global::SharedData.Empty1), 36 }, - { typeof(global::SharedData.Empty2), 37 }, - { typeof(global::SharedData.EmptyClass), 38 }, - { typeof(global::SharedData.EmptyStruct), 39 }, - { typeof(global::SharedData.FirstSimpleData), 40 }, - { typeof(global::SharedData.FooClass), 41 }, - { typeof(global::SharedData.HolderV0), 42 }, - { typeof(global::SharedData.HolderV1), 43 }, - { typeof(global::SharedData.HolderV2), 44 }, - { typeof(global::SharedData.MyClass), 45 }, - { typeof(global::SharedData.MySubUnion1), 46 }, - { typeof(global::SharedData.MySubUnion2), 47 }, - { typeof(global::SharedData.MySubUnion3), 48 }, - { typeof(global::SharedData.MySubUnion4), 49 }, - { typeof(global::SharedData.NestParent.NestContract), 50 }, - { typeof(global::SharedData.NonEmpty1), 51 }, - { typeof(global::SharedData.NonEmpty2), 52 }, - { typeof(global::SharedData.SimpleIntKeyData), 53 }, - { typeof(global::SharedData.SimpleStringKeyData), 54 }, - { typeof(global::SharedData.SimpleStructIntKeyData), 55 }, - { typeof(global::SharedData.SimpleStructStringKeyData), 56 }, - { typeof(global::SharedData.SubUnionType1), 57 }, - { typeof(global::SharedData.SubUnionType2), 58 }, - { typeof(global::SharedData.UnVersionBlockTest), 59 }, - { typeof(global::SharedData.Vector2), 60 }, - { typeof(global::SharedData.Vector3Like), 61 }, - { typeof(global::SharedData.VectorLike2), 62 }, - { typeof(global::SharedData.Version0), 63 }, - { typeof(global::SharedData.Version1), 64 }, - { typeof(global::SharedData.Version2), 65 }, - { typeof(global::SharedData.VersionBlockTest), 66 }, - { typeof(global::SharedData.VersioningUnion), 67 }, - { typeof(global::SharedData.WithIndexer), 68 }, - { typeof(global::SimpleModel), 69 }, - { typeof(global::StampMessageBody), 70 }, - { typeof(global::TextMessageBody), 71 }, - }; - } - - internal static object GetFormatter(global::System.Type t) - { - int key; - if (!lookup.TryGetValue(t, out key)) - { - return null; - } - - switch (key) - { - case 0: return new global::MessagePack.Formatters.TwoDimensionalArrayFormatter(); - case 1: return new global::MessagePack.Formatters.ArrayFormatter(); - case 2: return new global::MessagePack.Formatters.ArrayFormatter(); - case 3: return new global::MessagePack.Formatters.InterfaceDictionaryFormatter(); - case 4: return new global::MessagePack.Formatters.InterfaceListFormatter2(); - case 5: return new global::MessagePack.Formatters.FourDimensionalArrayFormatter(); - case 6: return new global::MessagePack.Formatters.ThreeDimensionalArrayFormatter(); - case 7: return new global::MessagePack.Formatters.TwoDimensionalArrayFormatter(); - case 8: return new MessagePack.Formatters.GlobalMyEnumFormatter(); - case 9: return new MessagePack.Formatters.SharedData.ByteEnumFormatter(); - case 10: return new MessagePack.Formatters.IMessageBodyFormatter(); - case 11: return new MessagePack.Formatters.SharedData.IIVersioningUnionFormatter(); - case 12: return new MessagePack.Formatters.SharedData.IUnionCheckerFormatter(); - case 13: return new MessagePack.Formatters.SharedData.IUnionChecker2Formatter(); - case 14: return new MessagePack.Formatters.SharedData.IUnionSampleFormatter(); - case 15: return new MessagePack.Formatters.SharedData.RootUnionTypeFormatter(); - case 16: return new MessagePack.Formatters.Abcdefg.Efcdigjl.Ateatatea.Hgfagfafgad.TnonodsfarnoiuAtatqagaFormatter(); - case 17: return new MessagePack.Formatters.ArrayTestTestFormatter(); - case 18: return new MessagePack.Formatters.ComplexModelFormatter(); - case 19: return new MessagePack.Formatters.GlobalManFormatter(); - case 20: return new MessagePack.Formatters.MessageFormatter(); - case 21: return new MessagePack.Formatters.MessagePackFormatterFieldUserFormatter(); - case 22: return new MessagePack.Formatters.PerfBenchmarkDotNet.StringKeySerializerTargetFormatter(); - case 23: return new MessagePack.Formatters.QuestMessageBodyFormatter(); - case 24: return new MessagePack.Formatters.SharedData.ArrayOptimizeClassFormatter(); - case 25: return new MessagePack.Formatters.SharedData.BarClassFormatter(); - case 26: return new MessagePack.Formatters.SharedData.Callback1Formatter(); - case 27: return new MessagePack.Formatters.SharedData.Callback1_2Formatter(); - case 28: return new MessagePack.Formatters.SharedData.Callback2Formatter(); - case 29: return new MessagePack.Formatters.SharedData.Callback2_2Formatter(); - case 30: return new MessagePack.Formatters.SharedData.DefaultValueIntKeyClassWithExplicitConstructorFormatter(); - case 31: return new MessagePack.Formatters.SharedData.DefaultValueIntKeyClassWithoutExplicitConstructorFormatter(); - case 32: return new MessagePack.Formatters.SharedData.DefaultValueIntKeyStructWithExplicitConstructorFormatter(); - case 33: return new MessagePack.Formatters.SharedData.DefaultValueStringKeyClassWithExplicitConstructorFormatter(); - case 34: return new MessagePack.Formatters.SharedData.DefaultValueStringKeyClassWithoutExplicitConstructorFormatter(); - case 35: return new MessagePack.Formatters.SharedData.DefaultValueStringKeyStructWithExplicitConstructorFormatter(); - case 36: return new MessagePack.Formatters.SharedData.Empty1Formatter(); - case 37: return new MessagePack.Formatters.SharedData.Empty2Formatter(); - case 38: return new MessagePack.Formatters.SharedData.EmptyClassFormatter(); - case 39: return new MessagePack.Formatters.SharedData.EmptyStructFormatter(); - case 40: return new MessagePack.Formatters.SharedData.FirstSimpleDataFormatter(); - case 41: return new MessagePack.Formatters.SharedData.FooClassFormatter(); - case 42: return new MessagePack.Formatters.SharedData.HolderV0Formatter(); - case 43: return new MessagePack.Formatters.SharedData.HolderV1Formatter(); - case 44: return new MessagePack.Formatters.SharedData.HolderV2Formatter(); - case 45: return new MessagePack.Formatters.SharedData.MyClassFormatter(); - case 46: return new MessagePack.Formatters.SharedData.MySubUnion1Formatter(); - case 47: return new MessagePack.Formatters.SharedData.MySubUnion2Formatter(); - case 48: return new MessagePack.Formatters.SharedData.MySubUnion3Formatter(); - case 49: return new MessagePack.Formatters.SharedData.MySubUnion4Formatter(); - case 50: return new MessagePack.Formatters.SharedData.NestParent_NestContractFormatter(); - case 51: return new MessagePack.Formatters.SharedData.NonEmpty1Formatter(); - case 52: return new MessagePack.Formatters.SharedData.NonEmpty2Formatter(); - case 53: return new MessagePack.Formatters.SharedData.SimpleIntKeyDataFormatter(); - case 54: return new MessagePack.Formatters.SharedData.SimpleStringKeyDataFormatter(); - case 55: return new MessagePack.Formatters.SharedData.SimpleStructIntKeyDataFormatter(); - case 56: return new MessagePack.Formatters.SharedData.SimpleStructStringKeyDataFormatter(); - case 57: return new MessagePack.Formatters.SharedData.SubUnionType1Formatter(); - case 58: return new MessagePack.Formatters.SharedData.SubUnionType2Formatter(); - case 59: return new MessagePack.Formatters.SharedData.UnVersionBlockTestFormatter(); - case 60: return new MessagePack.Formatters.SharedData.Vector2Formatter(); - case 61: return new MessagePack.Formatters.SharedData.Vector3LikeFormatter(); - case 62: return new MessagePack.Formatters.SharedData.VectorLike2Formatter(); - case 63: return new MessagePack.Formatters.SharedData.Version0Formatter(); - case 64: return new MessagePack.Formatters.SharedData.Version1Formatter(); - case 65: return new MessagePack.Formatters.SharedData.Version2Formatter(); - case 66: return new MessagePack.Formatters.SharedData.VersionBlockTestFormatter(); - case 67: return new MessagePack.Formatters.SharedData.VersioningUnionFormatter(); - case 68: return new MessagePack.Formatters.SharedData.WithIndexerFormatter(); - case 69: return new MessagePack.Formatters.SimpleModelFormatter(); - case 70: return new MessagePack.Formatters.StampMessageBodyFormatter(); - case 71: return new MessagePack.Formatters.TextMessageBodyFormatter(); - default: return null; - } - } - } -} - -#pragma warning restore 168 -#pragma warning restore 414 -#pragma warning restore 618 -#pragma warning restore 612 - -#pragma warning restore SA1312 // Variable names should begin with lower-case letter -#pragma warning restore SA1649 // File name should match first type name - - -// -// THIS (.cs) FILE IS GENERATED BY MPC(MessagePack-CSharp). DO NOT CHANGE IT. -// - -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 168 -#pragma warning disable CS1591 // document public APIs - -#pragma warning disable SA1403 // File may only contain a single namespace -#pragma warning disable SA1649 // File name should match first type name - -namespace MessagePack.Formatters -{ - - public sealed class GlobalMyEnumFormatter : global::MessagePack.Formatters.IMessagePackFormatter - { - public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::GlobalMyEnum value, global::MessagePack.MessagePackSerializerOptions options) - { - writer.Write((global::System.Int32)value); - } - - public global::GlobalMyEnum Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - return (global::GlobalMyEnum)reader.ReadInt32(); - } - } -} - -#pragma warning restore 168 -#pragma warning restore 414 -#pragma warning restore 618 -#pragma warning restore 612 - -#pragma warning restore SA1403 // File may only contain a single namespace -#pragma warning restore SA1649 // File name should match first type name - -// -// THIS (.cs) FILE IS GENERATED BY MPC(MessagePack-CSharp). DO NOT CHANGE IT. -// - -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 168 -#pragma warning disable CS1591 // document public APIs - -#pragma warning disable SA1403 // File may only contain a single namespace -#pragma warning disable SA1649 // File name should match first type name - -namespace MessagePack.Formatters.SharedData -{ - - public sealed class ByteEnumFormatter : global::MessagePack.Formatters.IMessagePackFormatter - { - public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::SharedData.ByteEnum value, global::MessagePack.MessagePackSerializerOptions options) - { - writer.Write((global::System.Byte)value); - } - - public global::SharedData.ByteEnum Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - return (global::SharedData.ByteEnum)reader.ReadByte(); - } - } -} - -#pragma warning restore 168 -#pragma warning restore 414 -#pragma warning restore 618 -#pragma warning restore 612 - -#pragma warning restore SA1403 // File may only contain a single namespace -#pragma warning restore SA1649 // File name should match first type name - - -// -// THIS (.cs) FILE IS GENERATED BY MPC(MessagePack-CSharp). DO NOT CHANGE IT. -// - -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 168 -#pragma warning disable CS1591 // document public APIs - -#pragma warning disable SA1403 // File may only contain a single namespace -#pragma warning disable SA1649 // File name should match first type name - -namespace MessagePack.Formatters -{ - public sealed class IMessageBodyFormatter : global::MessagePack.Formatters.IMessagePackFormatter - { - private readonly global::System.Collections.Generic.Dictionary> typeToKeyAndJumpMap; - private readonly global::System.Collections.Generic.Dictionary keyToJumpMap; - - public IMessageBodyFormatter() - { - this.typeToKeyAndJumpMap = new global::System.Collections.Generic.Dictionary>(3, global::MessagePack.Internal.RuntimeTypeHandleEqualityComparer.Default) - { - { typeof(global::TextMessageBody).TypeHandle, new global::System.Collections.Generic.KeyValuePair(10, 0) }, - { typeof(global::StampMessageBody).TypeHandle, new global::System.Collections.Generic.KeyValuePair(14, 1) }, - { typeof(global::QuestMessageBody).TypeHandle, new global::System.Collections.Generic.KeyValuePair(25, 2) }, - }; - this.keyToJumpMap = new global::System.Collections.Generic.Dictionary(3) - { - { 10, 0 }, - { 14, 1 }, - { 25, 2 }, - }; - } - - public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::IMessageBody value, global::MessagePack.MessagePackSerializerOptions options) - { - global::System.Collections.Generic.KeyValuePair keyValuePair; - if (value != null && this.typeToKeyAndJumpMap.TryGetValue(value.GetType().TypeHandle, out keyValuePair)) - { - writer.WriteArrayHeader(2); - writer.WriteInt32(keyValuePair.Key); - switch (keyValuePair.Value) - { - case 0: - global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(options.Resolver).Serialize(ref writer, (global::TextMessageBody)value, options); - break; - case 1: - global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(options.Resolver).Serialize(ref writer, (global::StampMessageBody)value, options); - break; - case 2: - global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(options.Resolver).Serialize(ref writer, (global::QuestMessageBody)value, options); - break; - default: - break; - } - - return; - } - - writer.WriteNil(); - } - - public global::IMessageBody Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - if (reader.TryReadNil()) - { - return null; - } - - if (reader.ReadArrayHeader() != 2) - { - throw new global::System.InvalidOperationException("Invalid Union data was detected. Type:global::IMessageBody"); - } - - options.Security.DepthStep(ref reader); - var key = reader.ReadInt32(); - - if (!this.keyToJumpMap.TryGetValue(key, out key)) - { - key = -1; - } - - global::IMessageBody result = null; - switch (key) - { - case 0: - result = (global::IMessageBody)global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(options.Resolver).Deserialize(ref reader, options); - break; - case 1: - result = (global::IMessageBody)global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(options.Resolver).Deserialize(ref reader, options); - break; - case 2: - result = (global::IMessageBody)global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(options.Resolver).Deserialize(ref reader, options); - break; - default: - reader.Skip(); - break; - } - - reader.Depth--; - return result; - } - } - - -} - -#pragma warning restore 168 -#pragma warning restore 414 -#pragma warning restore 618 -#pragma warning restore 612 - -#pragma warning restore SA1403 // File may only contain a single namespace -#pragma warning restore SA1649 // File name should match first type name - -// -// THIS (.cs) FILE IS GENERATED BY MPC(MessagePack-CSharp). DO NOT CHANGE IT. -// - -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 168 -#pragma warning disable CS1591 // document public APIs - -#pragma warning disable SA1403 // File may only contain a single namespace -#pragma warning disable SA1649 // File name should match first type name - -namespace MessagePack.Formatters.SharedData -{ - public sealed class IIVersioningUnionFormatter : global::MessagePack.Formatters.IMessagePackFormatter - { - private readonly global::System.Collections.Generic.Dictionary> typeToKeyAndJumpMap; - private readonly global::System.Collections.Generic.Dictionary keyToJumpMap; - - public IIVersioningUnionFormatter() - { - this.typeToKeyAndJumpMap = new global::System.Collections.Generic.Dictionary>(1, global::MessagePack.Internal.RuntimeTypeHandleEqualityComparer.Default) - { - { typeof(global::SharedData.MySubUnion1).TypeHandle, new global::System.Collections.Generic.KeyValuePair(0, 0) }, - }; - this.keyToJumpMap = new global::System.Collections.Generic.Dictionary(1) - { - { 0, 0 }, - }; - } - - public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::SharedData.IIVersioningUnion value, global::MessagePack.MessagePackSerializerOptions options) - { - global::System.Collections.Generic.KeyValuePair keyValuePair; - if (value != null && this.typeToKeyAndJumpMap.TryGetValue(value.GetType().TypeHandle, out keyValuePair)) - { - writer.WriteArrayHeader(2); - writer.WriteInt32(keyValuePair.Key); - switch (keyValuePair.Value) - { - case 0: - global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(options.Resolver).Serialize(ref writer, (global::SharedData.MySubUnion1)value, options); - break; - default: - break; - } - - return; - } - - writer.WriteNil(); - } - - public global::SharedData.IIVersioningUnion Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - if (reader.TryReadNil()) - { - return null; - } - - if (reader.ReadArrayHeader() != 2) - { - throw new global::System.InvalidOperationException("Invalid Union data was detected. Type:global::SharedData.IIVersioningUnion"); - } - - options.Security.DepthStep(ref reader); - var key = reader.ReadInt32(); - - if (!this.keyToJumpMap.TryGetValue(key, out key)) - { - key = -1; - } - - global::SharedData.IIVersioningUnion result = null; - switch (key) - { - case 0: - result = (global::SharedData.IIVersioningUnion)global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(options.Resolver).Deserialize(ref reader, options); - break; - default: - reader.Skip(); - break; - } - - reader.Depth--; - return result; - } - } - - public sealed class IUnionCheckerFormatter : global::MessagePack.Formatters.IMessagePackFormatter - { - private readonly global::System.Collections.Generic.Dictionary> typeToKeyAndJumpMap; - private readonly global::System.Collections.Generic.Dictionary keyToJumpMap; - - public IUnionCheckerFormatter() - { - this.typeToKeyAndJumpMap = new global::System.Collections.Generic.Dictionary>(4, global::MessagePack.Internal.RuntimeTypeHandleEqualityComparer.Default) - { - { typeof(global::SharedData.MySubUnion1).TypeHandle, new global::System.Collections.Generic.KeyValuePair(0, 0) }, - { typeof(global::SharedData.MySubUnion2).TypeHandle, new global::System.Collections.Generic.KeyValuePair(1, 1) }, - { typeof(global::SharedData.MySubUnion3).TypeHandle, new global::System.Collections.Generic.KeyValuePair(2, 2) }, - { typeof(global::SharedData.MySubUnion4).TypeHandle, new global::System.Collections.Generic.KeyValuePair(3, 3) }, - }; - this.keyToJumpMap = new global::System.Collections.Generic.Dictionary(4) - { - { 0, 0 }, - { 1, 1 }, - { 2, 2 }, - { 3, 3 }, - }; - } - - public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::SharedData.IUnionChecker value, global::MessagePack.MessagePackSerializerOptions options) - { - global::System.Collections.Generic.KeyValuePair keyValuePair; - if (value != null && this.typeToKeyAndJumpMap.TryGetValue(value.GetType().TypeHandle, out keyValuePair)) - { - writer.WriteArrayHeader(2); - writer.WriteInt32(keyValuePair.Key); - switch (keyValuePair.Value) - { - case 0: - global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(options.Resolver).Serialize(ref writer, (global::SharedData.MySubUnion1)value, options); - break; - case 1: - global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(options.Resolver).Serialize(ref writer, (global::SharedData.MySubUnion2)value, options); - break; - case 2: - global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(options.Resolver).Serialize(ref writer, (global::SharedData.MySubUnion3)value, options); - break; - case 3: - global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(options.Resolver).Serialize(ref writer, (global::SharedData.MySubUnion4)value, options); - break; - default: - break; - } - - return; - } - - writer.WriteNil(); - } - - public global::SharedData.IUnionChecker Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - if (reader.TryReadNil()) - { - return null; - } - - if (reader.ReadArrayHeader() != 2) - { - throw new global::System.InvalidOperationException("Invalid Union data was detected. Type:global::SharedData.IUnionChecker"); - } - - options.Security.DepthStep(ref reader); - var key = reader.ReadInt32(); - - if (!this.keyToJumpMap.TryGetValue(key, out key)) - { - key = -1; - } - - global::SharedData.IUnionChecker result = null; - switch (key) - { - case 0: - result = (global::SharedData.IUnionChecker)global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(options.Resolver).Deserialize(ref reader, options); - break; - case 1: - result = (global::SharedData.IUnionChecker)global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(options.Resolver).Deserialize(ref reader, options); - break; - case 2: - result = (global::SharedData.IUnionChecker)global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(options.Resolver).Deserialize(ref reader, options); - break; - case 3: - result = (global::SharedData.IUnionChecker)global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(options.Resolver).Deserialize(ref reader, options); - break; - default: - reader.Skip(); - break; - } - - reader.Depth--; - return result; - } - } - - public sealed class IUnionChecker2Formatter : global::MessagePack.Formatters.IMessagePackFormatter - { - private readonly global::System.Collections.Generic.Dictionary> typeToKeyAndJumpMap; - private readonly global::System.Collections.Generic.Dictionary keyToJumpMap; - - public IUnionChecker2Formatter() - { - this.typeToKeyAndJumpMap = new global::System.Collections.Generic.Dictionary>(4, global::MessagePack.Internal.RuntimeTypeHandleEqualityComparer.Default) - { - { typeof(global::SharedData.MySubUnion2).TypeHandle, new global::System.Collections.Generic.KeyValuePair(31, 0) }, - { typeof(global::SharedData.MySubUnion3).TypeHandle, new global::System.Collections.Generic.KeyValuePair(42, 1) }, - { typeof(global::SharedData.MySubUnion4).TypeHandle, new global::System.Collections.Generic.KeyValuePair(63, 2) }, - { typeof(global::SharedData.MySubUnion1).TypeHandle, new global::System.Collections.Generic.KeyValuePair(120, 3) }, - }; - this.keyToJumpMap = new global::System.Collections.Generic.Dictionary(4) - { - { 31, 0 }, - { 42, 1 }, - { 63, 2 }, - { 120, 3 }, - }; - } - - public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::SharedData.IUnionChecker2 value, global::MessagePack.MessagePackSerializerOptions options) - { - global::System.Collections.Generic.KeyValuePair keyValuePair; - if (value != null && this.typeToKeyAndJumpMap.TryGetValue(value.GetType().TypeHandle, out keyValuePair)) - { - writer.WriteArrayHeader(2); - writer.WriteInt32(keyValuePair.Key); - switch (keyValuePair.Value) - { - case 0: - global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(options.Resolver).Serialize(ref writer, (global::SharedData.MySubUnion2)value, options); - break; - case 1: - global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(options.Resolver).Serialize(ref writer, (global::SharedData.MySubUnion3)value, options); - break; - case 2: - global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(options.Resolver).Serialize(ref writer, (global::SharedData.MySubUnion4)value, options); - break; - case 3: - global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(options.Resolver).Serialize(ref writer, (global::SharedData.MySubUnion1)value, options); - break; - default: - break; - } - - return; - } - - writer.WriteNil(); - } - - public global::SharedData.IUnionChecker2 Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - if (reader.TryReadNil()) - { - return null; - } - - if (reader.ReadArrayHeader() != 2) - { - throw new global::System.InvalidOperationException("Invalid Union data was detected. Type:global::SharedData.IUnionChecker2"); - } - - options.Security.DepthStep(ref reader); - var key = reader.ReadInt32(); - - if (!this.keyToJumpMap.TryGetValue(key, out key)) - { - key = -1; - } - - global::SharedData.IUnionChecker2 result = null; - switch (key) - { - case 0: - result = (global::SharedData.IUnionChecker2)global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(options.Resolver).Deserialize(ref reader, options); - break; - case 1: - result = (global::SharedData.IUnionChecker2)global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(options.Resolver).Deserialize(ref reader, options); - break; - case 2: - result = (global::SharedData.IUnionChecker2)global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(options.Resolver).Deserialize(ref reader, options); - break; - case 3: - result = (global::SharedData.IUnionChecker2)global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(options.Resolver).Deserialize(ref reader, options); - break; - default: - reader.Skip(); - break; - } - - reader.Depth--; - return result; - } - } - - public sealed class IUnionSampleFormatter : global::MessagePack.Formatters.IMessagePackFormatter - { - private readonly global::System.Collections.Generic.Dictionary> typeToKeyAndJumpMap; - private readonly global::System.Collections.Generic.Dictionary keyToJumpMap; - - public IUnionSampleFormatter() - { - this.typeToKeyAndJumpMap = new global::System.Collections.Generic.Dictionary>(2, global::MessagePack.Internal.RuntimeTypeHandleEqualityComparer.Default) - { - { typeof(global::SharedData.FooClass).TypeHandle, new global::System.Collections.Generic.KeyValuePair(0, 0) }, - { typeof(global::SharedData.BarClass).TypeHandle, new global::System.Collections.Generic.KeyValuePair(100, 1) }, - }; - this.keyToJumpMap = new global::System.Collections.Generic.Dictionary(2) - { - { 0, 0 }, - { 100, 1 }, - }; - } - - public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::SharedData.IUnionSample value, global::MessagePack.MessagePackSerializerOptions options) - { - global::System.Collections.Generic.KeyValuePair keyValuePair; - if (value != null && this.typeToKeyAndJumpMap.TryGetValue(value.GetType().TypeHandle, out keyValuePair)) - { - writer.WriteArrayHeader(2); - writer.WriteInt32(keyValuePair.Key); - switch (keyValuePair.Value) - { - case 0: - global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(options.Resolver).Serialize(ref writer, (global::SharedData.FooClass)value, options); - break; - case 1: - global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(options.Resolver).Serialize(ref writer, (global::SharedData.BarClass)value, options); - break; - default: - break; - } - - return; - } - - writer.WriteNil(); - } - - public global::SharedData.IUnionSample Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - if (reader.TryReadNil()) - { - return null; - } - - if (reader.ReadArrayHeader() != 2) - { - throw new global::System.InvalidOperationException("Invalid Union data was detected. Type:global::SharedData.IUnionSample"); - } - - options.Security.DepthStep(ref reader); - var key = reader.ReadInt32(); - - if (!this.keyToJumpMap.TryGetValue(key, out key)) - { - key = -1; - } - - global::SharedData.IUnionSample result = null; - switch (key) - { - case 0: - result = (global::SharedData.IUnionSample)global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(options.Resolver).Deserialize(ref reader, options); - break; - case 1: - result = (global::SharedData.IUnionSample)global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(options.Resolver).Deserialize(ref reader, options); - break; - default: - reader.Skip(); - break; - } - - reader.Depth--; - return result; - } - } - - public sealed class RootUnionTypeFormatter : global::MessagePack.Formatters.IMessagePackFormatter - { - private readonly global::System.Collections.Generic.Dictionary> typeToKeyAndJumpMap; - private readonly global::System.Collections.Generic.Dictionary keyToJumpMap; - - public RootUnionTypeFormatter() - { - this.typeToKeyAndJumpMap = new global::System.Collections.Generic.Dictionary>(2, global::MessagePack.Internal.RuntimeTypeHandleEqualityComparer.Default) - { - { typeof(global::SharedData.SubUnionType1).TypeHandle, new global::System.Collections.Generic.KeyValuePair(0, 0) }, - { typeof(global::SharedData.SubUnionType2).TypeHandle, new global::System.Collections.Generic.KeyValuePair(1, 1) }, - }; - this.keyToJumpMap = new global::System.Collections.Generic.Dictionary(2) - { - { 0, 0 }, - { 1, 1 }, - }; - } - - public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::SharedData.RootUnionType value, global::MessagePack.MessagePackSerializerOptions options) - { - global::System.Collections.Generic.KeyValuePair keyValuePair; - if (value != null && this.typeToKeyAndJumpMap.TryGetValue(value.GetType().TypeHandle, out keyValuePair)) - { - writer.WriteArrayHeader(2); - writer.WriteInt32(keyValuePair.Key); - switch (keyValuePair.Value) - { - case 0: - global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(options.Resolver).Serialize(ref writer, (global::SharedData.SubUnionType1)value, options); - break; - case 1: - global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(options.Resolver).Serialize(ref writer, (global::SharedData.SubUnionType2)value, options); - break; - default: - break; - } - - return; - } - - writer.WriteNil(); - } - - public global::SharedData.RootUnionType Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - if (reader.TryReadNil()) - { - return null; - } - - if (reader.ReadArrayHeader() != 2) - { - throw new global::System.InvalidOperationException("Invalid Union data was detected. Type:global::SharedData.RootUnionType"); - } - - options.Security.DepthStep(ref reader); - var key = reader.ReadInt32(); - - if (!this.keyToJumpMap.TryGetValue(key, out key)) - { - key = -1; - } - - global::SharedData.RootUnionType result = null; - switch (key) - { - case 0: - result = (global::SharedData.RootUnionType)global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(options.Resolver).Deserialize(ref reader, options); - break; - case 1: - result = (global::SharedData.RootUnionType)global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(options.Resolver).Deserialize(ref reader, options); - break; - default: - reader.Skip(); - break; - } - - reader.Depth--; - return result; - } - } - - -} - -#pragma warning restore 168 -#pragma warning restore 414 -#pragma warning restore 618 -#pragma warning restore 612 - -#pragma warning restore SA1403 // File may only contain a single namespace -#pragma warning restore SA1649 // File name should match first type name - - -// -// THIS (.cs) FILE IS GENERATED BY MPC(MessagePack-CSharp). DO NOT CHANGE IT. -// - -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 168 -#pragma warning disable CS1591 // document public APIs - -#pragma warning disable SA1129 // Do not use default value type constructor -#pragma warning disable SA1309 // Field names should not begin with underscore -#pragma warning disable SA1312 // Variable names should begin with lower-case letter -#pragma warning disable SA1403 // File may only contain a single namespace -#pragma warning disable SA1649 // File name should match first type name - -namespace MessagePack.Formatters.Abcdefg.Efcdigjl.Ateatatea.Hgfagfafgad -{ - public sealed class TnonodsfarnoiuAtatqagaFormatter : global::MessagePack.Formatters.IMessagePackFormatter - { - - public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::Abcdefg.Efcdigjl.Ateatatea.Hgfagfafgad.TnonodsfarnoiuAtatqaga value, global::MessagePack.MessagePackSerializerOptions options) - { - if (value == null) - { - writer.WriteNil(); - return; - } - - writer.WriteArrayHeader(1); - writer.Write(value.MyProperty); - } - - public global::Abcdefg.Efcdigjl.Ateatatea.Hgfagfafgad.TnonodsfarnoiuAtatqaga Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - if (reader.TryReadNil()) - { - return null; - } - - options.Security.DepthStep(ref reader); - var length = reader.ReadArrayHeader(); - var ____result = new global::Abcdefg.Efcdigjl.Ateatatea.Hgfagfafgad.TnonodsfarnoiuAtatqaga(); - - for (int i = 0; i < length; i++) - { - switch (i) - { - case 0: - ____result.MyProperty = reader.ReadInt32(); - break; - default: - reader.Skip(); - break; - } - } - - reader.Depth--; - return ____result; - } - } - -} - -#pragma warning restore 168 -#pragma warning restore 414 -#pragma warning restore 618 -#pragma warning restore 612 - -#pragma warning restore SA1129 // Do not use default value type constructor -#pragma warning restore SA1309 // Field names should not begin with underscore -#pragma warning restore SA1312 // Variable names should begin with lower-case letter -#pragma warning restore SA1403 // File may only contain a single namespace -#pragma warning restore SA1649 // File name should match first type name - -// -// THIS (.cs) FILE IS GENERATED BY MPC(MessagePack-CSharp). DO NOT CHANGE IT. -// - -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 168 -#pragma warning disable CS1591 // document public APIs - -#pragma warning disable SA1129 // Do not use default value type constructor -#pragma warning disable SA1309 // Field names should not begin with underscore -#pragma warning disable SA1312 // Variable names should begin with lower-case letter -#pragma warning disable SA1403 // File may only contain a single namespace -#pragma warning disable SA1649 // File name should match first type name - -namespace MessagePack.Formatters -{ - public sealed class ArrayTestTestFormatter : global::MessagePack.Formatters.IMessagePackFormatter - { - - public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::ArrayTestTest value, global::MessagePack.MessagePackSerializerOptions options) - { - if (value == null) - { - writer.WriteNil(); - return; - } - - global::MessagePack.IFormatterResolver formatterResolver = options.Resolver; - writer.WriteArrayHeader(7); - global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Serialize(ref writer, value.MyProperty0, options); - global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Serialize(ref writer, value.MyProperty1, options); - global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Serialize(ref writer, value.MyProperty2, options); - global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Serialize(ref writer, value.MyProperty3, options); - global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Serialize(ref writer, value.MyProperty4, options); - global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Serialize(ref writer, value.MyProperty5, options); - global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Serialize(ref writer, value.MyProperty6, options); - } - - public global::ArrayTestTest Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - if (reader.TryReadNil()) - { - return null; - } - - options.Security.DepthStep(ref reader); - global::MessagePack.IFormatterResolver formatterResolver = options.Resolver; - var length = reader.ReadArrayHeader(); - var ____result = new global::ArrayTestTest(); - - for (int i = 0; i < length; i++) - { - switch (i) - { - case 0: - ____result.MyProperty0 = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Deserialize(ref reader, options); - break; - case 1: - ____result.MyProperty1 = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Deserialize(ref reader, options); - break; - case 2: - ____result.MyProperty2 = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Deserialize(ref reader, options); - break; - case 3: - ____result.MyProperty3 = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Deserialize(ref reader, options); - break; - case 4: - ____result.MyProperty4 = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Deserialize(ref reader, options); - break; - case 5: - ____result.MyProperty5 = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Deserialize(ref reader, options); - break; - case 6: - ____result.MyProperty6 = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Deserialize(ref reader, options); - break; - default: - reader.Skip(); - break; - } - } - - reader.Depth--; - return ____result; - } - } - - public sealed class GlobalManFormatter : global::MessagePack.Formatters.IMessagePackFormatter - { - - public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::GlobalMan value, global::MessagePack.MessagePackSerializerOptions options) - { - if (value == null) - { - writer.WriteNil(); - return; - } - - writer.WriteArrayHeader(1); - writer.Write(value.MyProperty); - } - - public global::GlobalMan Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - if (reader.TryReadNil()) - { - return null; - } - - options.Security.DepthStep(ref reader); - var length = reader.ReadArrayHeader(); - var ____result = new global::GlobalMan(); - - for (int i = 0; i < length; i++) - { - switch (i) - { - case 0: - ____result.MyProperty = reader.ReadInt32(); - break; - default: - reader.Skip(); - break; - } - } - - reader.Depth--; - return ____result; - } - } - - public sealed class MessageFormatter : global::MessagePack.Formatters.IMessagePackFormatter - { - - public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::Message value, global::MessagePack.MessagePackSerializerOptions options) - { - if (value == null) - { - writer.WriteNil(); - return; - } - - global::MessagePack.IFormatterResolver formatterResolver = options.Resolver; - writer.WriteArrayHeader(4); - writer.Write(value.UserId); - writer.Write(value.RoomId); - global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Serialize(ref writer, value.PostTime, options); - global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Serialize(ref writer, value.Body, options); - } - - public global::Message Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - if (reader.TryReadNil()) - { - return null; - } - - options.Security.DepthStep(ref reader); - global::MessagePack.IFormatterResolver formatterResolver = options.Resolver; - var length = reader.ReadArrayHeader(); - var ____result = new global::Message(); - - for (int i = 0; i < length; i++) - { - switch (i) - { - case 0: - ____result.UserId = reader.ReadInt32(); - break; - case 1: - ____result.RoomId = reader.ReadInt32(); - break; - case 2: - ____result.PostTime = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Deserialize(ref reader, options); - break; - case 3: - ____result.Body = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Deserialize(ref reader, options); - break; - default: - reader.Skip(); - break; - } - } - - reader.Depth--; - return ____result; - } - } - - public sealed class MessagePackFormatterFieldUserFormatter : global::MessagePack.Formatters.IMessagePackFormatter - { - private readonly global::MessagePack.Formatters.NativeDateTimeFormatter __TimestampCustomFormatter__ = new global::MessagePack.Formatters.NativeDateTimeFormatter(); - - public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::MessagePackFormatterFieldUser value, global::MessagePack.MessagePackSerializerOptions options) - { - if (value == null) - { - writer.WriteNil(); - return; - } - - writer.WriteArrayHeader(1); - this.__TimestampCustomFormatter__.Serialize(ref writer, value.Timestamp, options); - } - - public global::MessagePackFormatterFieldUser Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - if (reader.TryReadNil()) - { - return null; - } - - options.Security.DepthStep(ref reader); - var length = reader.ReadArrayHeader(); - var ____result = new global::MessagePackFormatterFieldUser(); - - for (int i = 0; i < length; i++) - { - switch (i) - { - case 0: - ____result.Timestamp = this.__TimestampCustomFormatter__.Deserialize(ref reader, options); - break; - default: - reader.Skip(); - break; - } - } - - reader.Depth--; - return ____result; - } - } - - public sealed class QuestMessageBodyFormatter : global::MessagePack.Formatters.IMessagePackFormatter - { - - public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::QuestMessageBody value, global::MessagePack.MessagePackSerializerOptions options) - { - if (value == null) - { - writer.WriteNil(); - return; - } - - global::MessagePack.IFormatterResolver formatterResolver = options.Resolver; - writer.WriteArrayHeader(2); - writer.Write(value.QuestId); - global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Serialize(ref writer, value.Text, options); - } - - public global::QuestMessageBody Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - if (reader.TryReadNil()) - { - return null; - } - - options.Security.DepthStep(ref reader); - global::MessagePack.IFormatterResolver formatterResolver = options.Resolver; - var length = reader.ReadArrayHeader(); - var ____result = new global::QuestMessageBody(); - - for (int i = 0; i < length; i++) - { - switch (i) - { - case 0: - ____result.QuestId = reader.ReadInt32(); - break; - case 1: - ____result.Text = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Deserialize(ref reader, options); - break; - default: - reader.Skip(); - break; - } - } - - reader.Depth--; - return ____result; - } - } - - public sealed class StampMessageBodyFormatter : global::MessagePack.Formatters.IMessagePackFormatter - { - - public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::StampMessageBody value, global::MessagePack.MessagePackSerializerOptions options) - { - if (value == null) - { - writer.WriteNil(); - return; - } - - writer.WriteArrayHeader(1); - writer.Write(value.StampId); - } - - public global::StampMessageBody Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - if (reader.TryReadNil()) - { - return null; - } - - options.Security.DepthStep(ref reader); - var length = reader.ReadArrayHeader(); - var ____result = new global::StampMessageBody(); - - for (int i = 0; i < length; i++) - { - switch (i) - { - case 0: - ____result.StampId = reader.ReadInt32(); - break; - default: - reader.Skip(); - break; - } - } - - reader.Depth--; - return ____result; - } - } - - public sealed class TextMessageBodyFormatter : global::MessagePack.Formatters.IMessagePackFormatter - { - - public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::TextMessageBody value, global::MessagePack.MessagePackSerializerOptions options) - { - if (value == null) - { - writer.WriteNil(); - return; - } - - global::MessagePack.IFormatterResolver formatterResolver = options.Resolver; - writer.WriteArrayHeader(1); - global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Serialize(ref writer, value.Text, options); - } - - public global::TextMessageBody Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - if (reader.TryReadNil()) - { - return null; - } - - options.Security.DepthStep(ref reader); - global::MessagePack.IFormatterResolver formatterResolver = options.Resolver; - var length = reader.ReadArrayHeader(); - var ____result = new global::TextMessageBody(); - - for (int i = 0; i < length; i++) - { - switch (i) - { - case 0: - ____result.Text = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Deserialize(ref reader, options); - break; - default: - reader.Skip(); - break; - } - } - - reader.Depth--; - return ____result; - } - } - -} - -#pragma warning restore 168 -#pragma warning restore 414 -#pragma warning restore 618 -#pragma warning restore 612 - -#pragma warning restore SA1129 // Do not use default value type constructor -#pragma warning restore SA1309 // Field names should not begin with underscore -#pragma warning restore SA1312 // Variable names should begin with lower-case letter -#pragma warning restore SA1403 // File may only contain a single namespace -#pragma warning restore SA1649 // File name should match first type name - -// -// THIS (.cs) FILE IS GENERATED BY MPC(MessagePack-CSharp). DO NOT CHANGE IT. -// - -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 168 -#pragma warning disable CS1591 // document public APIs - -#pragma warning disable SA1129 // Do not use default value type constructor -#pragma warning disable SA1309 // Field names should not begin with underscore -#pragma warning disable SA1312 // Variable names should begin with lower-case letter -#pragma warning disable SA1403 // File may only contain a single namespace -#pragma warning disable SA1649 // File name should match first type name - -namespace MessagePack.Formatters -{ - public sealed class ComplexModelFormatter : global::MessagePack.Formatters.IMessagePackFormatter - { - // AdditionalProperty - private static global::System.ReadOnlySpan GetSpan_AdditionalProperty() => new byte[1 + 18] { 178, 65, 100, 100, 105, 116, 105, 111, 110, 97, 108, 80, 114, 111, 112, 101, 114, 116, 121 }; - // CreatedOn - private static global::System.ReadOnlySpan GetSpan_CreatedOn() => new byte[1 + 9] { 169, 67, 114, 101, 97, 116, 101, 100, 79, 110 }; - // Id - private static global::System.ReadOnlySpan GetSpan_Id() => new byte[1 + 2] { 162, 73, 100 }; - // Name - private static global::System.ReadOnlySpan GetSpan_Name() => new byte[1 + 4] { 164, 78, 97, 109, 101 }; - // UpdatedOn - private static global::System.ReadOnlySpan GetSpan_UpdatedOn() => new byte[1 + 9] { 169, 85, 112, 100, 97, 116, 101, 100, 79, 110 }; - // SimpleModels - private static global::System.ReadOnlySpan GetSpan_SimpleModels() => new byte[1 + 12] { 172, 83, 105, 109, 112, 108, 101, 77, 111, 100, 101, 108, 115 }; - - public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::ComplexModel value, global::MessagePack.MessagePackSerializerOptions options) - { - if (value is null) - { - writer.WriteNil(); - return; - } - - var formatterResolver = options.Resolver; - writer.WriteMapHeader(6); - writer.WriteRaw(GetSpan_AdditionalProperty()); - global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify>(formatterResolver).Serialize(ref writer, value.AdditionalProperty, options); - writer.WriteRaw(GetSpan_CreatedOn()); - global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Serialize(ref writer, value.CreatedOn, options); - writer.WriteRaw(GetSpan_Id()); - global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Serialize(ref writer, value.Id, options); - writer.WriteRaw(GetSpan_Name()); - global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Serialize(ref writer, value.Name, options); - writer.WriteRaw(GetSpan_UpdatedOn()); - global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Serialize(ref writer, value.UpdatedOn, options); - writer.WriteRaw(GetSpan_SimpleModels()); - global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify>(formatterResolver).Serialize(ref writer, value.SimpleModels, options); - } - - public global::ComplexModel Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - if (reader.TryReadNil()) - { - return null; - } - - options.Security.DepthStep(ref reader); - var formatterResolver = options.Resolver; - var length = reader.ReadMapHeader(); - var ____result = new global::ComplexModel(); - - for (int i = 0; i < length; i++) - { - var stringKey = global::MessagePack.Internal.CodeGenHelpers.ReadStringSpan(ref reader); - switch (stringKey.Length) - { - default: - FAIL: - reader.Skip(); - continue; - case 18: - if (!global::System.MemoryExtensions.SequenceEqual(stringKey, GetSpan_AdditionalProperty().Slice(1))) { goto FAIL; } - - reader.Skip(); - continue; - case 9: - switch (global::MessagePack.Internal.AutomataKeyGen.GetKey(ref stringKey)) - { - default: goto FAIL; - case 5720808977192022595UL: - if (stringKey[0] != 110) { goto FAIL; } - - ____result.CreatedOn = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Deserialize(ref reader, options); - continue; - - case 5720808977191956565UL: - if (stringKey[0] != 110) { goto FAIL; } - - ____result.UpdatedOn = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Deserialize(ref reader, options); - continue; - - } - case 2: - if (global::MessagePack.Internal.AutomataKeyGen.GetKey(ref stringKey) != 25673UL) { goto FAIL; } - - ____result.Id = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Deserialize(ref reader, options); - continue; - case 4: - if (global::MessagePack.Internal.AutomataKeyGen.GetKey(ref stringKey) != 1701667150UL) { goto FAIL; } - - ____result.Name = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Deserialize(ref reader, options); - continue; - case 12: - if (!global::System.MemoryExtensions.SequenceEqual(stringKey, GetSpan_SimpleModels().Slice(1))) { goto FAIL; } - - reader.Skip(); - continue; - - } - } - - reader.Depth--; - return ____result; - } - } - - public sealed class SimpleModelFormatter : global::MessagePack.Formatters.IMessagePackFormatter - { - // Id - private static global::System.ReadOnlySpan GetSpan_Id() => new byte[1 + 2] { 162, 73, 100 }; - // Name - private static global::System.ReadOnlySpan GetSpan_Name() => new byte[1 + 4] { 164, 78, 97, 109, 101 }; - // CreatedOn - private static global::System.ReadOnlySpan GetSpan_CreatedOn() => new byte[1 + 9] { 169, 67, 114, 101, 97, 116, 101, 100, 79, 110 }; - // Precision - private static global::System.ReadOnlySpan GetSpan_Precision() => new byte[1 + 9] { 169, 80, 114, 101, 99, 105, 115, 105, 111, 110 }; - // Money - private static global::System.ReadOnlySpan GetSpan_Money() => new byte[1 + 5] { 165, 77, 111, 110, 101, 121 }; - // Amount - private static global::System.ReadOnlySpan GetSpan_Amount() => new byte[1 + 6] { 166, 65, 109, 111, 117, 110, 116 }; - - public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::SimpleModel value, global::MessagePack.MessagePackSerializerOptions options) - { - if (value is null) - { - writer.WriteNil(); - return; - } - - var formatterResolver = options.Resolver; - writer.WriteMapHeader(6); - writer.WriteRaw(GetSpan_Id()); - writer.Write(value.Id); - writer.WriteRaw(GetSpan_Name()); - global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Serialize(ref writer, value.Name, options); - writer.WriteRaw(GetSpan_CreatedOn()); - global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Serialize(ref writer, value.CreatedOn, options); - writer.WriteRaw(GetSpan_Precision()); - writer.Write(value.Precision); - writer.WriteRaw(GetSpan_Money()); - global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Serialize(ref writer, value.Money, options); - writer.WriteRaw(GetSpan_Amount()); - writer.Write(value.Amount); - } - - public global::SimpleModel Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - if (reader.TryReadNil()) - { - return null; - } - - options.Security.DepthStep(ref reader); - var formatterResolver = options.Resolver; - var length = reader.ReadMapHeader(); - var ____result = new global::SimpleModel(); - - for (int i = 0; i < length; i++) - { - var stringKey = global::MessagePack.Internal.CodeGenHelpers.ReadStringSpan(ref reader); - switch (stringKey.Length) - { - default: - FAIL: - reader.Skip(); - continue; - case 2: - if (global::MessagePack.Internal.AutomataKeyGen.GetKey(ref stringKey) != 25673UL) { goto FAIL; } - - ____result.Id = reader.ReadInt32(); - continue; - case 4: - if (global::MessagePack.Internal.AutomataKeyGen.GetKey(ref stringKey) != 1701667150UL) { goto FAIL; } - - ____result.Name = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Deserialize(ref reader, options); - continue; - case 9: - switch (global::MessagePack.Internal.AutomataKeyGen.GetKey(ref stringKey)) - { - default: goto FAIL; - case 5720808977192022595UL: - if (stringKey[0] != 110) { goto FAIL; } - - ____result.CreatedOn = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Deserialize(ref reader, options); - continue; - - case 8028074707240972880UL: - if (stringKey[0] != 110) { goto FAIL; } - - ____result.Precision = reader.ReadInt32(); - continue; - - } - case 5: - if (global::MessagePack.Internal.AutomataKeyGen.GetKey(ref stringKey) != 521392779085UL) { goto FAIL; } - - ____result.Money = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Deserialize(ref reader, options); - continue; - case 6: - if (global::MessagePack.Internal.AutomataKeyGen.GetKey(ref stringKey) != 128017765461313UL) { goto FAIL; } - - reader.Skip(); - continue; - - } - } - - reader.Depth--; - return ____result; - } - } - -} - -#pragma warning restore 168 -#pragma warning restore 414 -#pragma warning restore 618 -#pragma warning restore 612 - -#pragma warning restore SA1129 // Do not use default value type constructor -#pragma warning restore SA1309 // Field names should not begin with underscore -#pragma warning restore SA1312 // Variable names should begin with lower-case letter -#pragma warning restore SA1403 // File may only contain a single namespace -#pragma warning restore SA1649 // File name should match first type name - -// -// THIS (.cs) FILE IS GENERATED BY MPC(MessagePack-CSharp). DO NOT CHANGE IT. -// - -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 168 -#pragma warning disable CS1591 // document public APIs - -#pragma warning disable SA1129 // Do not use default value type constructor -#pragma warning disable SA1309 // Field names should not begin with underscore -#pragma warning disable SA1312 // Variable names should begin with lower-case letter -#pragma warning disable SA1403 // File may only contain a single namespace -#pragma warning disable SA1649 // File name should match first type name - -namespace MessagePack.Formatters.PerfBenchmarkDotNet -{ - public sealed class StringKeySerializerTargetFormatter : global::MessagePack.Formatters.IMessagePackFormatter - { - // MyProperty1 - private static global::System.ReadOnlySpan GetSpan_MyProperty1() => new byte[1 + 11] { 171, 77, 121, 80, 114, 111, 112, 101, 114, 116, 121, 49 }; - // MyProperty2 - private static global::System.ReadOnlySpan GetSpan_MyProperty2() => new byte[1 + 11] { 171, 77, 121, 80, 114, 111, 112, 101, 114, 116, 121, 50 }; - // MyProperty3 - private static global::System.ReadOnlySpan GetSpan_MyProperty3() => new byte[1 + 11] { 171, 77, 121, 80, 114, 111, 112, 101, 114, 116, 121, 51 }; - // MyProperty4 - private static global::System.ReadOnlySpan GetSpan_MyProperty4() => new byte[1 + 11] { 171, 77, 121, 80, 114, 111, 112, 101, 114, 116, 121, 52 }; - // MyProperty5 - private static global::System.ReadOnlySpan GetSpan_MyProperty5() => new byte[1 + 11] { 171, 77, 121, 80, 114, 111, 112, 101, 114, 116, 121, 53 }; - // MyProperty6 - private static global::System.ReadOnlySpan GetSpan_MyProperty6() => new byte[1 + 11] { 171, 77, 121, 80, 114, 111, 112, 101, 114, 116, 121, 54 }; - // MyProperty7 - private static global::System.ReadOnlySpan GetSpan_MyProperty7() => new byte[1 + 11] { 171, 77, 121, 80, 114, 111, 112, 101, 114, 116, 121, 55 }; - // MyProperty8 - private static global::System.ReadOnlySpan GetSpan_MyProperty8() => new byte[1 + 11] { 171, 77, 121, 80, 114, 111, 112, 101, 114, 116, 121, 56 }; - // MyProperty9 - private static global::System.ReadOnlySpan GetSpan_MyProperty9() => new byte[1 + 11] { 171, 77, 121, 80, 114, 111, 112, 101, 114, 116, 121, 57 }; - - public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::PerfBenchmarkDotNet.StringKeySerializerTarget value, global::MessagePack.MessagePackSerializerOptions options) - { - if (value is null) - { - writer.WriteNil(); - return; - } - - writer.WriteMapHeader(9); - writer.WriteRaw(GetSpan_MyProperty1()); - writer.Write(value.MyProperty1); - writer.WriteRaw(GetSpan_MyProperty2()); - writer.Write(value.MyProperty2); - writer.WriteRaw(GetSpan_MyProperty3()); - writer.Write(value.MyProperty3); - writer.WriteRaw(GetSpan_MyProperty4()); - writer.Write(value.MyProperty4); - writer.WriteRaw(GetSpan_MyProperty5()); - writer.Write(value.MyProperty5); - writer.WriteRaw(GetSpan_MyProperty6()); - writer.Write(value.MyProperty6); - writer.WriteRaw(GetSpan_MyProperty7()); - writer.Write(value.MyProperty7); - writer.WriteRaw(GetSpan_MyProperty8()); - writer.Write(value.MyProperty8); - writer.WriteRaw(GetSpan_MyProperty9()); - writer.Write(value.MyProperty9); - } - - public global::PerfBenchmarkDotNet.StringKeySerializerTarget Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - if (reader.TryReadNil()) - { - return null; - } - - options.Security.DepthStep(ref reader); - var length = reader.ReadMapHeader(); - var ____result = new global::PerfBenchmarkDotNet.StringKeySerializerTarget(); - - for (int i = 0; i < length; i++) - { - var stringKey = global::MessagePack.Internal.CodeGenHelpers.ReadStringSpan(ref reader); - switch (stringKey.Length) - { - default: - FAIL: - reader.Skip(); - continue; - case 11: - switch (global::MessagePack.Internal.AutomataKeyGen.GetKey(ref stringKey)) - { - default: goto FAIL; - case 8243118316933118285UL: - switch (global::MessagePack.Internal.AutomataKeyGen.GetKey(ref stringKey)) - { - default: goto FAIL; - case 3242356UL: - ____result.MyProperty1 = reader.ReadInt32(); - continue; - case 3307892UL: - ____result.MyProperty2 = reader.ReadInt32(); - continue; - case 3373428UL: - ____result.MyProperty3 = reader.ReadInt32(); - continue; - case 3438964UL: - ____result.MyProperty4 = reader.ReadInt32(); - continue; - case 3504500UL: - ____result.MyProperty5 = reader.ReadInt32(); - continue; - case 3570036UL: - ____result.MyProperty6 = reader.ReadInt32(); - continue; - case 3635572UL: - ____result.MyProperty7 = reader.ReadInt32(); - continue; - case 3701108UL: - ____result.MyProperty8 = reader.ReadInt32(); - continue; - case 3766644UL: - ____result.MyProperty9 = reader.ReadInt32(); - continue; - } - - } - - } - } - - reader.Depth--; - return ____result; - } - } - -} - -#pragma warning restore 168 -#pragma warning restore 414 -#pragma warning restore 618 -#pragma warning restore 612 - -#pragma warning restore SA1129 // Do not use default value type constructor -#pragma warning restore SA1309 // Field names should not begin with underscore -#pragma warning restore SA1312 // Variable names should begin with lower-case letter -#pragma warning restore SA1403 // File may only contain a single namespace -#pragma warning restore SA1649 // File name should match first type name - -// -// THIS (.cs) FILE IS GENERATED BY MPC(MessagePack-CSharp). DO NOT CHANGE IT. -// - -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 168 -#pragma warning disable CS1591 // document public APIs - -#pragma warning disable SA1129 // Do not use default value type constructor -#pragma warning disable SA1309 // Field names should not begin with underscore -#pragma warning disable SA1312 // Variable names should begin with lower-case letter -#pragma warning disable SA1403 // File may only contain a single namespace -#pragma warning disable SA1649 // File name should match first type name - -namespace MessagePack.Formatters.SharedData -{ - public sealed class ArrayOptimizeClassFormatter : global::MessagePack.Formatters.IMessagePackFormatter - { - - public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::SharedData.ArrayOptimizeClass value, global::MessagePack.MessagePackSerializerOptions options) - { - if (value == null) - { - writer.WriteNil(); - return; - } - - writer.WriteArrayHeader(16); - writer.Write(value.MyProperty0); - writer.Write(value.MyProperty1); - writer.Write(value.MyProperty2); - writer.Write(value.MyProperty3); - writer.Write(value.MyProperty4); - writer.Write(value.MyProperty5); - writer.Write(value.MyProperty6); - writer.Write(value.MyProperty7); - writer.Write(value.MyProperty8); - writer.Write(value.MyProvperty9); - writer.Write(value.MyProperty10); - writer.Write(value.MyProperty11); - writer.Write(value.MyPropverty12); - writer.Write(value.MyPropevrty13); - writer.Write(value.MyProperty14); - writer.Write(value.MyProperty15); - } - - public global::SharedData.ArrayOptimizeClass Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - if (reader.TryReadNil()) - { - return null; - } - - options.Security.DepthStep(ref reader); - var length = reader.ReadArrayHeader(); - var ____result = new global::SharedData.ArrayOptimizeClass(); - - for (int i = 0; i < length; i++) - { - switch (i) - { - case 0: - ____result.MyProperty0 = reader.ReadInt32(); - break; - case 1: - ____result.MyProperty1 = reader.ReadInt32(); - break; - case 2: - ____result.MyProperty2 = reader.ReadInt32(); - break; - case 3: - ____result.MyProperty3 = reader.ReadInt32(); - break; - case 4: - ____result.MyProperty4 = reader.ReadInt32(); - break; - case 5: - ____result.MyProperty5 = reader.ReadInt32(); - break; - case 6: - ____result.MyProperty6 = reader.ReadInt32(); - break; - case 7: - ____result.MyProperty7 = reader.ReadInt32(); - break; - case 8: - ____result.MyProperty8 = reader.ReadInt32(); - break; - case 9: - ____result.MyProvperty9 = reader.ReadInt32(); - break; - case 10: - ____result.MyProperty10 = reader.ReadInt32(); - break; - case 11: - ____result.MyProperty11 = reader.ReadInt32(); - break; - case 12: - ____result.MyPropverty12 = reader.ReadInt32(); - break; - case 13: - ____result.MyPropevrty13 = reader.ReadInt32(); - break; - case 14: - ____result.MyProperty14 = reader.ReadInt32(); - break; - case 15: - ____result.MyProperty15 = reader.ReadInt32(); - break; - default: - reader.Skip(); - break; - } - } - - reader.Depth--; - return ____result; - } - } - - public sealed class BarClassFormatter : global::MessagePack.Formatters.IMessagePackFormatter - { - - public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::SharedData.BarClass value, global::MessagePack.MessagePackSerializerOptions options) - { - if (value == null) - { - writer.WriteNil(); - return; - } - - global::MessagePack.IFormatterResolver formatterResolver = options.Resolver; - writer.WriteArrayHeader(1); - global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Serialize(ref writer, value.OPQ, options); - } - - public global::SharedData.BarClass Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - if (reader.TryReadNil()) - { - return null; - } - - options.Security.DepthStep(ref reader); - global::MessagePack.IFormatterResolver formatterResolver = options.Resolver; - var length = reader.ReadArrayHeader(); - var ____result = new global::SharedData.BarClass(); - - for (int i = 0; i < length; i++) - { - switch (i) - { - case 0: - ____result.OPQ = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Deserialize(ref reader, options); - break; - default: - reader.Skip(); - break; - } - } - - reader.Depth--; - return ____result; - } - } - - public sealed class Callback1Formatter : global::MessagePack.Formatters.IMessagePackFormatter - { - - public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::SharedData.Callback1 value, global::MessagePack.MessagePackSerializerOptions options) - { - if (value == null) - { - writer.WriteNil(); - return; - } - - value.OnBeforeSerialize(); - writer.WriteArrayHeader(1); - writer.Write(value.X); - } - - public global::SharedData.Callback1 Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - if (reader.TryReadNil()) - { - return null; - } - - options.Security.DepthStep(ref reader); - var length = reader.ReadArrayHeader(); - var __X__ = default(int); - - for (int i = 0; i < length; i++) - { - switch (i) - { - case 0: - __X__ = reader.ReadInt32(); - break; - default: - reader.Skip(); - break; - } - } - - var ____result = new global::SharedData.Callback1(__X__); - ____result.OnAfterDeserialize(); - reader.Depth--; - return ____result; - } - } - - public sealed class Callback1_2Formatter : global::MessagePack.Formatters.IMessagePackFormatter - { - - public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::SharedData.Callback1_2 value, global::MessagePack.MessagePackSerializerOptions options) - { - if (value == null) - { - writer.WriteNil(); - return; - } - - ((global::MessagePack.IMessagePackSerializationCallbackReceiver)value).OnBeforeSerialize(); - writer.WriteArrayHeader(1); - writer.Write(value.X); - } - - public global::SharedData.Callback1_2 Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - if (reader.TryReadNil()) - { - return null; - } - - options.Security.DepthStep(ref reader); - var length = reader.ReadArrayHeader(); - var __X__ = default(int); - - for (int i = 0; i < length; i++) - { - switch (i) - { - case 0: - __X__ = reader.ReadInt32(); - break; - default: - reader.Skip(); - break; - } - } - - var ____result = new global::SharedData.Callback1_2(__X__); - ((global::MessagePack.IMessagePackSerializationCallbackReceiver)____result).OnAfterDeserialize(); - reader.Depth--; - return ____result; - } - } - - public sealed class DefaultValueIntKeyClassWithExplicitConstructorFormatter : global::MessagePack.Formatters.IMessagePackFormatter - { - - public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::SharedData.DefaultValueIntKeyClassWithExplicitConstructor value, global::MessagePack.MessagePackSerializerOptions options) - { - if (value == null) - { - writer.WriteNil(); - return; - } - - global::MessagePack.IFormatterResolver formatterResolver = options.Resolver; - writer.WriteArrayHeader(4); - writer.Write(value.Prop1); - writer.Write(value.Prop2); - global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Serialize(ref writer, value.Prop3, options); - global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Serialize(ref writer, value.Prop4, options); - } - - public global::SharedData.DefaultValueIntKeyClassWithExplicitConstructor Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - if (reader.TryReadNil()) - { - return null; - } - - options.Security.DepthStep(ref reader); - global::MessagePack.IFormatterResolver formatterResolver = options.Resolver; - var length = reader.ReadArrayHeader(); - var __Prop1__ = default(int); - var __Prop2__ = default(int); - var __Prop3__ = default(string); - var __Prop4__ = default(string); - - for (int i = 0; i < length; i++) - { - switch (i) - { - case 0: - __Prop1__ = reader.ReadInt32(); - break; - case 1: - __Prop2__ = reader.ReadInt32(); - break; - case 2: - __Prop3__ = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Deserialize(ref reader, options); - break; - case 3: - __Prop4__ = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Deserialize(ref reader, options); - break; - default: - reader.Skip(); - break; - } - } - - var ____result = new global::SharedData.DefaultValueIntKeyClassWithExplicitConstructor(__Prop1__); - if (length <= 1) - { - goto MEMBER_ASSIGNMENT_END; - } - - ____result.Prop2 = __Prop2__; - if (length <= 2) - { - goto MEMBER_ASSIGNMENT_END; - } - - ____result.Prop3 = __Prop3__; - if (length <= 3) - { - goto MEMBER_ASSIGNMENT_END; - } - - ____result.Prop4 = __Prop4__; - - MEMBER_ASSIGNMENT_END: - reader.Depth--; - return ____result; - } - } - - public sealed class DefaultValueIntKeyClassWithoutExplicitConstructorFormatter : global::MessagePack.Formatters.IMessagePackFormatter - { - - public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::SharedData.DefaultValueIntKeyClassWithoutExplicitConstructor value, global::MessagePack.MessagePackSerializerOptions options) - { - if (value == null) - { - writer.WriteNil(); - return; - } - - writer.WriteArrayHeader(2); - writer.Write(value.Prop1); - writer.Write(value.Prop2); - } - - public global::SharedData.DefaultValueIntKeyClassWithoutExplicitConstructor Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - if (reader.TryReadNil()) - { - return null; - } - - options.Security.DepthStep(ref reader); - var length = reader.ReadArrayHeader(); - var ____result = new global::SharedData.DefaultValueIntKeyClassWithoutExplicitConstructor(); - - for (int i = 0; i < length; i++) - { - switch (i) - { - case 0: - ____result.Prop1 = reader.ReadInt32(); - break; - case 1: - ____result.Prop2 = reader.ReadInt32(); - break; - default: - reader.Skip(); - break; - } - } - - reader.Depth--; - return ____result; - } - } - - public sealed class DefaultValueIntKeyStructWithExplicitConstructorFormatter : global::MessagePack.Formatters.IMessagePackFormatter - { - - public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::SharedData.DefaultValueIntKeyStructWithExplicitConstructor value, global::MessagePack.MessagePackSerializerOptions options) - { - writer.WriteArrayHeader(2); - writer.Write(value.Prop1); - writer.Write(value.Prop2); - } - - public global::SharedData.DefaultValueIntKeyStructWithExplicitConstructor Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - if (reader.TryReadNil()) - { - throw new global::System.InvalidOperationException("typecode is null, struct not supported"); - } - - options.Security.DepthStep(ref reader); - var length = reader.ReadArrayHeader(); - var __Prop1__ = default(int); - var __Prop2__ = default(int); - - for (int i = 0; i < length; i++) - { - switch (i) - { - case 0: - __Prop1__ = reader.ReadInt32(); - break; - case 1: - __Prop2__ = reader.ReadInt32(); - break; - default: - reader.Skip(); - break; - } - } - - var ____result = new global::SharedData.DefaultValueIntKeyStructWithExplicitConstructor(__Prop1__); - if (length <= 1) - { - goto MEMBER_ASSIGNMENT_END; - } - - ____result.Prop2 = __Prop2__; - - MEMBER_ASSIGNMENT_END: - reader.Depth--; - return ____result; - } - } - - public sealed class DynamicArgumentTupleFormatter : global::MessagePack.Formatters.IMessagePackFormatter> - { - - public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::SharedData.DynamicArgumentTuple value, global::MessagePack.MessagePackSerializerOptions options) - { - global::MessagePack.IFormatterResolver formatterResolver = options.Resolver; - writer.WriteArrayHeader(9); - global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Serialize(ref writer, value.Item1, options); - global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Serialize(ref writer, value.Item2, options); - global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Serialize(ref writer, value.Item3, options); - global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Serialize(ref writer, value.Item4, options); - global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Serialize(ref writer, value.Item5, options); - global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Serialize(ref writer, value.Item6, options); - global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Serialize(ref writer, value.Item7, options); - global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Serialize(ref writer, value.Item8, options); - global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Serialize(ref writer, value.Item9, options); - } - - public global::SharedData.DynamicArgumentTuple Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - if (reader.TryReadNil()) - { - throw new global::System.InvalidOperationException("typecode is null, struct not supported"); - } - - options.Security.DepthStep(ref reader); - global::MessagePack.IFormatterResolver formatterResolver = options.Resolver; - var length = reader.ReadArrayHeader(); - var __Item1__ = default(T1); - var __Item2__ = default(T2); - var __Item3__ = default(T3); - var __Item4__ = default(T4); - var __Item5__ = default(T5); - var __Item6__ = default(T6); - var __Item7__ = default(T7); - var __Item8__ = default(T8); - var __Item9__ = default(T9); - - for (int i = 0; i < length; i++) - { - switch (i) - { - case 0: - __Item1__ = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Deserialize(ref reader, options); - break; - case 1: - __Item2__ = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Deserialize(ref reader, options); - break; - case 2: - __Item3__ = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Deserialize(ref reader, options); - break; - case 3: - __Item4__ = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Deserialize(ref reader, options); - break; - case 4: - __Item5__ = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Deserialize(ref reader, options); - break; - case 5: - __Item6__ = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Deserialize(ref reader, options); - break; - case 6: - __Item7__ = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Deserialize(ref reader, options); - break; - case 7: - __Item8__ = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Deserialize(ref reader, options); - break; - case 8: - __Item9__ = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Deserialize(ref reader, options); - break; - default: - reader.Skip(); - break; - } - } - - var ____result = new global::SharedData.DynamicArgumentTuple(__Item1__, __Item2__, __Item3__, __Item4__, __Item5__, __Item6__, __Item7__, __Item8__, __Item9__); - reader.Depth--; - return ____result; - } - } - - public sealed class Empty1Formatter : global::MessagePack.Formatters.IMessagePackFormatter - { - - public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::SharedData.Empty1 value, global::MessagePack.MessagePackSerializerOptions options) - { - if (value == null) - { - writer.WriteNil(); - return; - } - - writer.WriteArrayHeader(0); - } - - public global::SharedData.Empty1 Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - if (reader.TryReadNil()) - { - return null; - } - - reader.Skip(); - return new global::SharedData.Empty1(); - } - } - - public sealed class EmptyClassFormatter : global::MessagePack.Formatters.IMessagePackFormatter - { - - public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::SharedData.EmptyClass value, global::MessagePack.MessagePackSerializerOptions options) - { - if (value == null) - { - writer.WriteNil(); - return; - } - - writer.WriteArrayHeader(0); - } - - public global::SharedData.EmptyClass Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - if (reader.TryReadNil()) - { - return null; - } - - reader.Skip(); - return new global::SharedData.EmptyClass(); - } - } - - public sealed class EmptyStructFormatter : global::MessagePack.Formatters.IMessagePackFormatter - { - - public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::SharedData.EmptyStruct value, global::MessagePack.MessagePackSerializerOptions options) - { - writer.WriteArrayHeader(0); - } - - public global::SharedData.EmptyStruct Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - if (reader.TryReadNil()) - { - throw new global::System.InvalidOperationException("typecode is null, struct not supported"); - } - - reader.Skip(); - return new global::SharedData.EmptyStruct(); - } - } - - public sealed class FirstSimpleDataFormatter : global::MessagePack.Formatters.IMessagePackFormatter - { - - public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::SharedData.FirstSimpleData value, global::MessagePack.MessagePackSerializerOptions options) - { - if (value == null) - { - writer.WriteNil(); - return; - } - - global::MessagePack.IFormatterResolver formatterResolver = options.Resolver; - writer.WriteArrayHeader(3); - writer.Write(value.Prop1); - global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Serialize(ref writer, value.Prop2, options); - writer.Write(value.Prop3); - } - - public global::SharedData.FirstSimpleData Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - if (reader.TryReadNil()) - { - return null; - } - - options.Security.DepthStep(ref reader); - global::MessagePack.IFormatterResolver formatterResolver = options.Resolver; - var length = reader.ReadArrayHeader(); - var ____result = new global::SharedData.FirstSimpleData(); - - for (int i = 0; i < length; i++) - { - switch (i) - { - case 0: - ____result.Prop1 = reader.ReadInt32(); - break; - case 1: - ____result.Prop2 = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Deserialize(ref reader, options); - break; - case 2: - ____result.Prop3 = reader.ReadInt32(); - break; - default: - reader.Skip(); - break; - } - } - - reader.Depth--; - return ____result; - } - } - - public sealed class FooClassFormatter : global::MessagePack.Formatters.IMessagePackFormatter - { - - public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::SharedData.FooClass value, global::MessagePack.MessagePackSerializerOptions options) - { - if (value == null) - { - writer.WriteNil(); - return; - } - - writer.WriteArrayHeader(1); - writer.Write(value.XYZ); - } - - public global::SharedData.FooClass Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - if (reader.TryReadNil()) - { - return null; - } - - options.Security.DepthStep(ref reader); - var length = reader.ReadArrayHeader(); - var ____result = new global::SharedData.FooClass(); - - for (int i = 0; i < length; i++) - { - switch (i) - { - case 0: - ____result.XYZ = reader.ReadInt32(); - break; - default: - reader.Skip(); - break; - } - } - - reader.Depth--; - return ____result; - } - } - - public sealed class GenericClassFormatter : global::MessagePack.Formatters.IMessagePackFormatter> - { - - public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::SharedData.GenericClass value, global::MessagePack.MessagePackSerializerOptions options) - { - if (value == null) - { - writer.WriteNil(); - return; - } - - global::MessagePack.IFormatterResolver formatterResolver = options.Resolver; - writer.WriteArrayHeader(2); - global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Serialize(ref writer, value.MyProperty0, options); - global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Serialize(ref writer, value.MyProperty1, options); - } - - public global::SharedData.GenericClass Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - if (reader.TryReadNil()) - { - return null; - } - - options.Security.DepthStep(ref reader); - global::MessagePack.IFormatterResolver formatterResolver = options.Resolver; - var length = reader.ReadArrayHeader(); - var ____result = new global::SharedData.GenericClass(); - - for (int i = 0; i < length; i++) - { - switch (i) - { - case 0: - ____result.MyProperty0 = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Deserialize(ref reader, options); - break; - case 1: - ____result.MyProperty1 = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Deserialize(ref reader, options); - break; - default: - reader.Skip(); - break; - } - } - - reader.Depth--; - return ____result; - } - } - - public sealed class GenericConstrainedClassIntKeyFormatter : global::MessagePack.Formatters.IMessagePackFormatter> - where T1 : class - where T2 : class, global::System.Collections.Generic.IEqualityComparer - { - - public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::SharedData.GenericConstrainedClassIntKey value, global::MessagePack.MessagePackSerializerOptions options) - { - if (value == null) - { - writer.WriteNil(); - return; - } - - global::MessagePack.IFormatterResolver formatterResolver = options.Resolver; - writer.WriteArrayHeader(2); - global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Serialize(ref writer, value.MyProperty0, options); - global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Serialize(ref writer, value.Comparer, options); - } - - public global::SharedData.GenericConstrainedClassIntKey Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - if (reader.TryReadNil()) - { - return null; - } - - options.Security.DepthStep(ref reader); - global::MessagePack.IFormatterResolver formatterResolver = options.Resolver; - var length = reader.ReadArrayHeader(); - var ____result = new global::SharedData.GenericConstrainedClassIntKey(); - - for (int i = 0; i < length; i++) - { - switch (i) - { - case 0: - ____result.MyProperty0 = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Deserialize(ref reader, options); - break; - case 1: - ____result.Comparer = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Deserialize(ref reader, options); - break; - default: - reader.Skip(); - break; - } - } - - reader.Depth--; - return ____result; - } - } - - public sealed class GenericConstrainedStructIntKeyFormatter : global::MessagePack.Formatters.IMessagePackFormatter> - where T1 : unmanaged - where T2 : unmanaged, global::System.Collections.Generic.IEqualityComparer - { - - public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::SharedData.GenericConstrainedStructIntKey value, global::MessagePack.MessagePackSerializerOptions options) - { - global::MessagePack.IFormatterResolver formatterResolver = options.Resolver; - writer.WriteArrayHeader(2); - global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Serialize(ref writer, value.MyProperty0, options); - global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Serialize(ref writer, value.Comparer, options); - } - - public global::SharedData.GenericConstrainedStructIntKey Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - if (reader.TryReadNil()) - { - throw new global::System.InvalidOperationException("typecode is null, struct not supported"); - } - - options.Security.DepthStep(ref reader); - global::MessagePack.IFormatterResolver formatterResolver = options.Resolver; - var length = reader.ReadArrayHeader(); - var ____result = new global::SharedData.GenericConstrainedStructIntKey(); - - for (int i = 0; i < length; i++) - { - switch (i) - { - case 0: - ____result.MyProperty0 = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Deserialize(ref reader, options); - break; - case 1: - ____result.Comparer = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Deserialize(ref reader, options); - break; - default: - reader.Skip(); - break; - } - } - - reader.Depth--; - return ____result; - } - } - - public sealed class GenericStructFormatter : global::MessagePack.Formatters.IMessagePackFormatter> - { - - public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::SharedData.GenericStruct value, global::MessagePack.MessagePackSerializerOptions options) - { - global::MessagePack.IFormatterResolver formatterResolver = options.Resolver; - writer.WriteArrayHeader(2); - global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Serialize(ref writer, value.MyProperty0, options); - global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Serialize(ref writer, value.MyProperty1, options); - } - - public global::SharedData.GenericStruct Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - if (reader.TryReadNil()) - { - throw new global::System.InvalidOperationException("typecode is null, struct not supported"); - } - - options.Security.DepthStep(ref reader); - global::MessagePack.IFormatterResolver formatterResolver = options.Resolver; - var length = reader.ReadArrayHeader(); - var ____result = new global::SharedData.GenericStruct(); - - for (int i = 0; i < length; i++) - { - switch (i) - { - case 0: - ____result.MyProperty0 = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Deserialize(ref reader, options); - break; - case 1: - ____result.MyProperty1 = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Deserialize(ref reader, options); - break; - default: - reader.Skip(); - break; - } - } - - reader.Depth--; - return ____result; - } - } - - public sealed class HolderV0Formatter : global::MessagePack.Formatters.IMessagePackFormatter - { - - public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::SharedData.HolderV0 value, global::MessagePack.MessagePackSerializerOptions options) - { - if (value == null) - { - writer.WriteNil(); - return; - } - - global::MessagePack.IFormatterResolver formatterResolver = options.Resolver; - writer.WriteArrayHeader(2); - global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Serialize(ref writer, value.MyProperty1, options); - writer.Write(value.After); - } - - public global::SharedData.HolderV0 Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - if (reader.TryReadNil()) - { - return null; - } - - options.Security.DepthStep(ref reader); - global::MessagePack.IFormatterResolver formatterResolver = options.Resolver; - var length = reader.ReadArrayHeader(); - var ____result = new global::SharedData.HolderV0(); - - for (int i = 0; i < length; i++) - { - switch (i) - { - case 0: - ____result.MyProperty1 = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Deserialize(ref reader, options); - break; - case 1: - ____result.After = reader.ReadInt32(); - break; - default: - reader.Skip(); - break; - } - } - - reader.Depth--; - return ____result; - } - } - - public sealed class HolderV1Formatter : global::MessagePack.Formatters.IMessagePackFormatter - { - - public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::SharedData.HolderV1 value, global::MessagePack.MessagePackSerializerOptions options) - { - if (value == null) - { - writer.WriteNil(); - return; - } - - global::MessagePack.IFormatterResolver formatterResolver = options.Resolver; - writer.WriteArrayHeader(2); - global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Serialize(ref writer, value.MyProperty1, options); - writer.Write(value.After); - } - - public global::SharedData.HolderV1 Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - if (reader.TryReadNil()) - { - return null; - } - - options.Security.DepthStep(ref reader); - global::MessagePack.IFormatterResolver formatterResolver = options.Resolver; - var length = reader.ReadArrayHeader(); - var ____result = new global::SharedData.HolderV1(); - - for (int i = 0; i < length; i++) - { - switch (i) - { - case 0: - ____result.MyProperty1 = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Deserialize(ref reader, options); - break; - case 1: - ____result.After = reader.ReadInt32(); - break; - default: - reader.Skip(); - break; - } - } - - reader.Depth--; - return ____result; - } - } - - public sealed class HolderV2Formatter : global::MessagePack.Formatters.IMessagePackFormatter - { - - public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::SharedData.HolderV2 value, global::MessagePack.MessagePackSerializerOptions options) - { - if (value == null) - { - writer.WriteNil(); - return; - } - - global::MessagePack.IFormatterResolver formatterResolver = options.Resolver; - writer.WriteArrayHeader(2); - global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Serialize(ref writer, value.MyProperty1, options); - writer.Write(value.After); - } - - public global::SharedData.HolderV2 Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - if (reader.TryReadNil()) - { - return null; - } - - options.Security.DepthStep(ref reader); - global::MessagePack.IFormatterResolver formatterResolver = options.Resolver; - var length = reader.ReadArrayHeader(); - var ____result = new global::SharedData.HolderV2(); - - for (int i = 0; i < length; i++) - { - switch (i) - { - case 0: - ____result.MyProperty1 = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Deserialize(ref reader, options); - break; - case 1: - ____result.After = reader.ReadInt32(); - break; - default: - reader.Skip(); - break; - } - } - - reader.Depth--; - return ____result; - } - } - - public sealed class MyClassFormatter : global::MessagePack.Formatters.IMessagePackFormatter - { - - public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::SharedData.MyClass value, global::MessagePack.MessagePackSerializerOptions options) - { - if (value == null) - { - writer.WriteNil(); - return; - } - - writer.WriteArrayHeader(3); - writer.Write(value.MyProperty1); - writer.Write(value.MyProperty2); - writer.Write(value.MyProperty3); - } - - public global::SharedData.MyClass Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - if (reader.TryReadNil()) - { - return null; - } - - options.Security.DepthStep(ref reader); - var length = reader.ReadArrayHeader(); - var ____result = new global::SharedData.MyClass(); - - for (int i = 0; i < length; i++) - { - switch (i) - { - case 0: - ____result.MyProperty1 = reader.ReadInt32(); - break; - case 1: - ____result.MyProperty2 = reader.ReadInt32(); - break; - case 2: - ____result.MyProperty3 = reader.ReadInt32(); - break; - default: - reader.Skip(); - break; - } - } - - reader.Depth--; - return ____result; - } - } - - public sealed class MySubUnion1Formatter : global::MessagePack.Formatters.IMessagePackFormatter - { - - public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::SharedData.MySubUnion1 value, global::MessagePack.MessagePackSerializerOptions options) - { - if (value == null) - { - writer.WriteNil(); - return; - } - - writer.WriteArrayHeader(4); - writer.WriteNil(); - writer.WriteNil(); - writer.WriteNil(); - writer.Write(value.One); - } - - public global::SharedData.MySubUnion1 Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - if (reader.TryReadNil()) - { - return null; - } - - options.Security.DepthStep(ref reader); - var length = reader.ReadArrayHeader(); - var ____result = new global::SharedData.MySubUnion1(); - - for (int i = 0; i < length; i++) - { - switch (i) - { - case 3: - ____result.One = reader.ReadInt32(); - break; - default: - reader.Skip(); - break; - } - } - - reader.Depth--; - return ____result; - } - } - - public sealed class MySubUnion2Formatter : global::MessagePack.Formatters.IMessagePackFormatter - { - - public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::SharedData.MySubUnion2 value, global::MessagePack.MessagePackSerializerOptions options) - { - writer.WriteArrayHeader(6); - writer.WriteNil(); - writer.WriteNil(); - writer.WriteNil(); - writer.WriteNil(); - writer.WriteNil(); - writer.Write(value.Two); - } - - public global::SharedData.MySubUnion2 Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - if (reader.TryReadNil()) - { - throw new global::System.InvalidOperationException("typecode is null, struct not supported"); - } - - options.Security.DepthStep(ref reader); - var length = reader.ReadArrayHeader(); - var ____result = new global::SharedData.MySubUnion2(); - - for (int i = 0; i < length; i++) - { - switch (i) - { - case 5: - ____result.Two = reader.ReadInt32(); - break; - default: - reader.Skip(); - break; - } - } - - reader.Depth--; - return ____result; - } - } - - public sealed class MySubUnion3Formatter : global::MessagePack.Formatters.IMessagePackFormatter - { - - public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::SharedData.MySubUnion3 value, global::MessagePack.MessagePackSerializerOptions options) - { - if (value == null) - { - writer.WriteNil(); - return; - } - - writer.WriteArrayHeader(3); - writer.WriteNil(); - writer.WriteNil(); - writer.Write(value.Three); - } - - public global::SharedData.MySubUnion3 Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - if (reader.TryReadNil()) - { - return null; - } - - options.Security.DepthStep(ref reader); - var length = reader.ReadArrayHeader(); - var ____result = new global::SharedData.MySubUnion3(); - - for (int i = 0; i < length; i++) - { - switch (i) - { - case 2: - ____result.Three = reader.ReadInt32(); - break; - default: - reader.Skip(); - break; - } - } - - reader.Depth--; - return ____result; - } - } - - public sealed class MySubUnion4Formatter : global::MessagePack.Formatters.IMessagePackFormatter - { - - public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::SharedData.MySubUnion4 value, global::MessagePack.MessagePackSerializerOptions options) - { - writer.WriteArrayHeader(8); - writer.WriteNil(); - writer.WriteNil(); - writer.WriteNil(); - writer.WriteNil(); - writer.WriteNil(); - writer.WriteNil(); - writer.WriteNil(); - writer.Write(value.Four); - } - - public global::SharedData.MySubUnion4 Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - if (reader.TryReadNil()) - { - throw new global::System.InvalidOperationException("typecode is null, struct not supported"); - } - - options.Security.DepthStep(ref reader); - var length = reader.ReadArrayHeader(); - var ____result = new global::SharedData.MySubUnion4(); - - for (int i = 0; i < length; i++) - { - switch (i) - { - case 7: - ____result.Four = reader.ReadInt32(); - break; - default: - reader.Skip(); - break; - } - } - - reader.Depth--; - return ____result; - } - } - - public sealed class NestParent_NestContractFormatter : global::MessagePack.Formatters.IMessagePackFormatter - { - - public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::SharedData.NestParent.NestContract value, global::MessagePack.MessagePackSerializerOptions options) - { - if (value == null) - { - writer.WriteNil(); - return; - } - - writer.WriteArrayHeader(1); - writer.Write(value.MyProperty); - } - - public global::SharedData.NestParent.NestContract Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - if (reader.TryReadNil()) - { - return null; - } - - options.Security.DepthStep(ref reader); - var length = reader.ReadArrayHeader(); - var ____result = new global::SharedData.NestParent.NestContract(); - - for (int i = 0; i < length; i++) - { - switch (i) - { - case 0: - ____result.MyProperty = reader.ReadInt32(); - break; - default: - reader.Skip(); - break; - } - } - - reader.Depth--; - return ____result; - } - } - - public sealed class NonEmpty1Formatter : global::MessagePack.Formatters.IMessagePackFormatter - { - - public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::SharedData.NonEmpty1 value, global::MessagePack.MessagePackSerializerOptions options) - { - if (value == null) - { - writer.WriteNil(); - return; - } - - writer.WriteArrayHeader(1); - writer.Write(value.MyProperty); - } - - public global::SharedData.NonEmpty1 Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - if (reader.TryReadNil()) - { - return null; - } - - options.Security.DepthStep(ref reader); - var length = reader.ReadArrayHeader(); - var ____result = new global::SharedData.NonEmpty1(); - - for (int i = 0; i < length; i++) - { - switch (i) - { - case 0: - ____result.MyProperty = reader.ReadInt32(); - break; - default: - reader.Skip(); - break; - } - } - - reader.Depth--; - return ____result; - } - } - - public sealed class SimpleIntKeyDataFormatter : global::MessagePack.Formatters.IMessagePackFormatter - { - - public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::SharedData.SimpleIntKeyData value, global::MessagePack.MessagePackSerializerOptions options) - { - if (value == null) - { - writer.WriteNil(); - return; - } - - global::MessagePack.IFormatterResolver formatterResolver = options.Resolver; - writer.WriteArrayHeader(7); - writer.Write(value.Prop1); - global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Serialize(ref writer, value.Prop2, options); - global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Serialize(ref writer, value.Prop3, options); - global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Serialize(ref writer, value.Prop4, options); - global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Serialize(ref writer, value.Prop5, options); - global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Serialize(ref writer, value.Prop6, options); - writer.Write(value.BytesSpecial); - } - - public global::SharedData.SimpleIntKeyData Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - if (reader.TryReadNil()) - { - return null; - } - - options.Security.DepthStep(ref reader); - global::MessagePack.IFormatterResolver formatterResolver = options.Resolver; - var length = reader.ReadArrayHeader(); - var ____result = new global::SharedData.SimpleIntKeyData(); - - for (int i = 0; i < length; i++) - { - switch (i) - { - case 0: - ____result.Prop1 = reader.ReadInt32(); - break; - case 1: - ____result.Prop2 = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Deserialize(ref reader, options); - break; - case 2: - ____result.Prop3 = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Deserialize(ref reader, options); - break; - case 3: - ____result.Prop4 = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Deserialize(ref reader, options); - break; - case 4: - ____result.Prop5 = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Deserialize(ref reader, options); - break; - case 5: - ____result.Prop6 = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Deserialize(ref reader, options); - break; - case 6: - ____result.BytesSpecial = global::MessagePack.Internal.CodeGenHelpers.GetArrayFromNullableSequence(reader.ReadBytes()); - break; - default: - reader.Skip(); - break; - } - } - - reader.Depth--; - return ____result; - } - } - - public sealed class SimpleStructIntKeyDataFormatter : global::MessagePack.Formatters.IMessagePackFormatter - { - - public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::SharedData.SimpleStructIntKeyData value, global::MessagePack.MessagePackSerializerOptions options) - { - writer.WriteArrayHeader(3); - writer.Write(value.X); - writer.Write(value.Y); - writer.Write(value.BytesSpecial); - } - - public global::SharedData.SimpleStructIntKeyData Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - if (reader.TryReadNil()) - { - throw new global::System.InvalidOperationException("typecode is null, struct not supported"); - } - - options.Security.DepthStep(ref reader); - var length = reader.ReadArrayHeader(); - var ____result = new global::SharedData.SimpleStructIntKeyData(); - - for (int i = 0; i < length; i++) - { - switch (i) - { - case 0: - ____result.X = reader.ReadInt32(); - break; - case 1: - ____result.Y = reader.ReadInt32(); - break; - case 2: - ____result.BytesSpecial = global::MessagePack.Internal.CodeGenHelpers.GetArrayFromNullableSequence(reader.ReadBytes()); - break; - default: - reader.Skip(); - break; - } - } - - reader.Depth--; - return ____result; - } - } - - public sealed class SubUnionType1Formatter : global::MessagePack.Formatters.IMessagePackFormatter - { - - public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::SharedData.SubUnionType1 value, global::MessagePack.MessagePackSerializerOptions options) - { - if (value == null) - { - writer.WriteNil(); - return; - } - - writer.WriteArrayHeader(2); - writer.Write(value.MyProperty); - writer.Write(value.MyProperty1); - } - - public global::SharedData.SubUnionType1 Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - if (reader.TryReadNil()) - { - return null; - } - - options.Security.DepthStep(ref reader); - var length = reader.ReadArrayHeader(); - var ____result = new global::SharedData.SubUnionType1(); - - for (int i = 0; i < length; i++) - { - switch (i) - { - case 0: - ____result.MyProperty = reader.ReadInt32(); - break; - case 1: - ____result.MyProperty1 = reader.ReadInt32(); - break; - default: - reader.Skip(); - break; - } - } - - reader.Depth--; - return ____result; - } - } - - public sealed class SubUnionType2Formatter : global::MessagePack.Formatters.IMessagePackFormatter - { - - public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::SharedData.SubUnionType2 value, global::MessagePack.MessagePackSerializerOptions options) - { - if (value == null) - { - writer.WriteNil(); - return; - } - - writer.WriteArrayHeader(2); - writer.Write(value.MyProperty); - writer.Write(value.MyProperty2); - } - - public global::SharedData.SubUnionType2 Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - if (reader.TryReadNil()) - { - return null; - } - - options.Security.DepthStep(ref reader); - var length = reader.ReadArrayHeader(); - var ____result = new global::SharedData.SubUnionType2(); - - for (int i = 0; i < length; i++) - { - switch (i) - { - case 0: - ____result.MyProperty = reader.ReadInt32(); - break; - case 1: - ____result.MyProperty2 = reader.ReadInt32(); - break; - default: - reader.Skip(); - break; - } - } - - reader.Depth--; - return ____result; - } - } - - public sealed class UnVersionBlockTestFormatter : global::MessagePack.Formatters.IMessagePackFormatter - { - - public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::SharedData.UnVersionBlockTest value, global::MessagePack.MessagePackSerializerOptions options) - { - if (value == null) - { - writer.WriteNil(); - return; - } - - writer.WriteArrayHeader(3); - writer.Write(value.MyProperty); - writer.WriteNil(); - writer.Write(value.MyProperty2); - } - - public global::SharedData.UnVersionBlockTest Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - if (reader.TryReadNil()) - { - return null; - } - - options.Security.DepthStep(ref reader); - var length = reader.ReadArrayHeader(); - var ____result = new global::SharedData.UnVersionBlockTest(); - - for (int i = 0; i < length; i++) - { - switch (i) - { - case 0: - ____result.MyProperty = reader.ReadInt32(); - break; - case 2: - ____result.MyProperty2 = reader.ReadInt32(); - break; - default: - reader.Skip(); - break; - } - } - - reader.Depth--; - return ____result; - } - } - - public sealed class Vector2Formatter : global::MessagePack.Formatters.IMessagePackFormatter - { - - public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::SharedData.Vector2 value, global::MessagePack.MessagePackSerializerOptions options) - { - writer.WriteArrayHeader(2); - writer.Write(value.X); - writer.Write(value.Y); - } - - public global::SharedData.Vector2 Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - if (reader.TryReadNil()) - { - throw new global::System.InvalidOperationException("typecode is null, struct not supported"); - } - - options.Security.DepthStep(ref reader); - var length = reader.ReadArrayHeader(); - var __X__ = default(float); - var __Y__ = default(float); - - for (int i = 0; i < length; i++) - { - switch (i) - { - case 0: - __X__ = reader.ReadSingle(); - break; - case 1: - __Y__ = reader.ReadSingle(); - break; - default: - reader.Skip(); - break; - } - } - - var ____result = new global::SharedData.Vector2(__X__, __Y__); - reader.Depth--; - return ____result; - } - } - - public sealed class Vector3LikeFormatter : global::MessagePack.Formatters.IMessagePackFormatter - { - - public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::SharedData.Vector3Like value, global::MessagePack.MessagePackSerializerOptions options) - { - writer.WriteArrayHeader(3); - writer.Write(value.x); - writer.Write(value.y); - writer.Write(value.z); - } - - public global::SharedData.Vector3Like Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - if (reader.TryReadNil()) - { - throw new global::System.InvalidOperationException("typecode is null, struct not supported"); - } - - options.Security.DepthStep(ref reader); - var length = reader.ReadArrayHeader(); - var __x__ = default(float); - var __y__ = default(float); - var __z__ = default(float); - - for (int i = 0; i < length; i++) - { - switch (i) - { - case 0: - __x__ = reader.ReadSingle(); - break; - case 1: - __y__ = reader.ReadSingle(); - break; - case 2: - __z__ = reader.ReadSingle(); - break; - default: - reader.Skip(); - break; - } - } - - var ____result = new global::SharedData.Vector3Like(__x__, __y__, __z__); - reader.Depth--; - return ____result; - } - } - - public sealed class VectorLike2Formatter : global::MessagePack.Formatters.IMessagePackFormatter - { - - public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::SharedData.VectorLike2 value, global::MessagePack.MessagePackSerializerOptions options) - { - writer.WriteArrayHeader(2); - writer.Write(value.x); - writer.Write(value.y); - } - - public global::SharedData.VectorLike2 Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - if (reader.TryReadNil()) - { - throw new global::System.InvalidOperationException("typecode is null, struct not supported"); - } - - options.Security.DepthStep(ref reader); - var length = reader.ReadArrayHeader(); - var __x__ = default(float); - var __y__ = default(float); - - for (int i = 0; i < length; i++) - { - switch (i) - { - case 0: - __x__ = reader.ReadSingle(); - break; - case 1: - __y__ = reader.ReadSingle(); - break; - default: - reader.Skip(); - break; - } - } - - var ____result = new global::SharedData.VectorLike2(__x__, __y__); - reader.Depth--; - return ____result; - } - } - - public sealed class Version0Formatter : global::MessagePack.Formatters.IMessagePackFormatter - { - - public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::SharedData.Version0 value, global::MessagePack.MessagePackSerializerOptions options) - { - if (value == null) - { - writer.WriteNil(); - return; - } - - writer.WriteArrayHeader(4); - writer.WriteNil(); - writer.WriteNil(); - writer.WriteNil(); - writer.Write(value.MyProperty1); - } - - public global::SharedData.Version0 Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - if (reader.TryReadNil()) - { - return null; - } - - options.Security.DepthStep(ref reader); - var length = reader.ReadArrayHeader(); - var ____result = new global::SharedData.Version0(); - - for (int i = 0; i < length; i++) - { - switch (i) - { - case 3: - ____result.MyProperty1 = reader.ReadInt32(); - break; - default: - reader.Skip(); - break; - } - } - - reader.Depth--; - return ____result; - } - } - - public sealed class Version1Formatter : global::MessagePack.Formatters.IMessagePackFormatter - { - - public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::SharedData.Version1 value, global::MessagePack.MessagePackSerializerOptions options) - { - if (value == null) - { - writer.WriteNil(); - return; - } - - writer.WriteArrayHeader(6); - writer.WriteNil(); - writer.WriteNil(); - writer.WriteNil(); - writer.Write(value.MyProperty1); - writer.Write(value.MyProperty2); - writer.Write(value.MyProperty3); - } - - public global::SharedData.Version1 Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - if (reader.TryReadNil()) - { - return null; - } - - options.Security.DepthStep(ref reader); - var length = reader.ReadArrayHeader(); - var ____result = new global::SharedData.Version1(); - - for (int i = 0; i < length; i++) - { - switch (i) - { - case 3: - ____result.MyProperty1 = reader.ReadInt32(); - break; - case 4: - ____result.MyProperty2 = reader.ReadInt32(); - break; - case 5: - ____result.MyProperty3 = reader.ReadInt32(); - break; - default: - reader.Skip(); - break; - } - } - - reader.Depth--; - return ____result; - } - } - - public sealed class Version2Formatter : global::MessagePack.Formatters.IMessagePackFormatter - { - - public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::SharedData.Version2 value, global::MessagePack.MessagePackSerializerOptions options) - { - if (value == null) - { - writer.WriteNil(); - return; - } - - writer.WriteArrayHeader(8); - writer.WriteNil(); - writer.WriteNil(); - writer.WriteNil(); - writer.Write(value.MyProperty1); - writer.Write(value.MyProperty2); - writer.Write(value.MyProperty3); - writer.WriteNil(); - writer.Write(value.MyProperty5); - } - - public global::SharedData.Version2 Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - if (reader.TryReadNil()) - { - return null; - } - - options.Security.DepthStep(ref reader); - var length = reader.ReadArrayHeader(); - var ____result = new global::SharedData.Version2(); - - for (int i = 0; i < length; i++) - { - switch (i) - { - case 3: - ____result.MyProperty1 = reader.ReadInt32(); - break; - case 4: - ____result.MyProperty2 = reader.ReadInt32(); - break; - case 5: - ____result.MyProperty3 = reader.ReadInt32(); - break; - case 7: - ____result.MyProperty5 = reader.ReadInt32(); - break; - default: - reader.Skip(); - break; - } - } - - reader.Depth--; - return ____result; - } - } - - public sealed class VersionBlockTestFormatter : global::MessagePack.Formatters.IMessagePackFormatter - { - - public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::SharedData.VersionBlockTest value, global::MessagePack.MessagePackSerializerOptions options) - { - if (value == null) - { - writer.WriteNil(); - return; - } - - global::MessagePack.IFormatterResolver formatterResolver = options.Resolver; - writer.WriteArrayHeader(3); - writer.Write(value.MyProperty); - global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Serialize(ref writer, value.UnknownBlock, options); - writer.Write(value.MyProperty2); - } - - public global::SharedData.VersionBlockTest Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - if (reader.TryReadNil()) - { - return null; - } - - options.Security.DepthStep(ref reader); - global::MessagePack.IFormatterResolver formatterResolver = options.Resolver; - var length = reader.ReadArrayHeader(); - var ____result = new global::SharedData.VersionBlockTest(); - - for (int i = 0; i < length; i++) - { - switch (i) - { - case 0: - ____result.MyProperty = reader.ReadInt32(); - break; - case 1: - ____result.UnknownBlock = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Deserialize(ref reader, options); - break; - case 2: - ____result.MyProperty2 = reader.ReadInt32(); - break; - default: - reader.Skip(); - break; - } - } - - reader.Depth--; - return ____result; - } - } - - public sealed class VersioningUnionFormatter : global::MessagePack.Formatters.IMessagePackFormatter - { - - public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::SharedData.VersioningUnion value, global::MessagePack.MessagePackSerializerOptions options) - { - if (value == null) - { - writer.WriteNil(); - return; - } - - writer.WriteArrayHeader(8); - writer.WriteNil(); - writer.WriteNil(); - writer.WriteNil(); - writer.WriteNil(); - writer.WriteNil(); - writer.WriteNil(); - writer.WriteNil(); - writer.Write(value.FV); - } - - public global::SharedData.VersioningUnion Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - if (reader.TryReadNil()) - { - return null; - } - - options.Security.DepthStep(ref reader); - var length = reader.ReadArrayHeader(); - var ____result = new global::SharedData.VersioningUnion(); - - for (int i = 0; i < length; i++) - { - switch (i) - { - case 7: - ____result.FV = reader.ReadInt32(); - break; - default: - reader.Skip(); - break; - } - } - - reader.Depth--; - return ____result; - } - } - - public sealed class WithIndexerFormatter : global::MessagePack.Formatters.IMessagePackFormatter - { - - public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::SharedData.WithIndexer value, global::MessagePack.MessagePackSerializerOptions options) - { - if (value == null) - { - writer.WriteNil(); - return; - } - - global::MessagePack.IFormatterResolver formatterResolver = options.Resolver; - writer.WriteArrayHeader(2); - writer.Write(value.Data1); - global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Serialize(ref writer, value.Data2, options); - } - - public global::SharedData.WithIndexer Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - if (reader.TryReadNil()) - { - return null; - } - - options.Security.DepthStep(ref reader); - global::MessagePack.IFormatterResolver formatterResolver = options.Resolver; - var length = reader.ReadArrayHeader(); - var ____result = new global::SharedData.WithIndexer(); - - for (int i = 0; i < length; i++) - { - switch (i) - { - case 0: - ____result.Data1 = reader.ReadInt32(); - break; - case 1: - ____result.Data2 = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Deserialize(ref reader, options); - break; - default: - reader.Skip(); - break; - } - } - - reader.Depth--; - return ____result; - } - } - -} - -#pragma warning restore 168 -#pragma warning restore 414 -#pragma warning restore 618 -#pragma warning restore 612 - -#pragma warning restore SA1129 // Do not use default value type constructor -#pragma warning restore SA1309 // Field names should not begin with underscore -#pragma warning restore SA1312 // Variable names should begin with lower-case letter -#pragma warning restore SA1403 // File may only contain a single namespace -#pragma warning restore SA1649 // File name should match first type name - -// -// THIS (.cs) FILE IS GENERATED BY MPC(MessagePack-CSharp). DO NOT CHANGE IT. -// - -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 168 -#pragma warning disable CS1591 // document public APIs - -#pragma warning disable SA1129 // Do not use default value type constructor -#pragma warning disable SA1309 // Field names should not begin with underscore -#pragma warning disable SA1312 // Variable names should begin with lower-case letter -#pragma warning disable SA1403 // File may only contain a single namespace -#pragma warning disable SA1649 // File name should match first type name - -namespace MessagePack.Formatters.SharedData -{ - public sealed class Callback2Formatter : global::MessagePack.Formatters.IMessagePackFormatter - { - // X - private static global::System.ReadOnlySpan GetSpan_X() => new byte[1 + 1] { 161, 88 }; - - public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::SharedData.Callback2 value, global::MessagePack.MessagePackSerializerOptions options) - { - value.OnBeforeSerialize(); - writer.WriteMapHeader(1); - writer.WriteRaw(GetSpan_X()); - writer.Write(value.X); - } - - public global::SharedData.Callback2 Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - if (reader.TryReadNil()) - { - throw new global::System.InvalidOperationException("typecode is null, struct not supported"); - } - - options.Security.DepthStep(ref reader); - var length = reader.ReadMapHeader(); - var __X__ = default(int); - - for (int i = 0; i < length; i++) - { - var stringKey = global::MessagePack.Internal.CodeGenHelpers.ReadStringSpan(ref reader); - switch (stringKey.Length) - { - default: - FAIL: - reader.Skip(); - continue; - case 1: - if (stringKey[0] != 88) { goto FAIL; } - - __X__ = reader.ReadInt32(); - continue; - - } - } - - var ____result = new global::SharedData.Callback2(__X__); - ____result.OnAfterDeserialize(); - reader.Depth--; - return ____result; - } - } - - public sealed class Callback2_2Formatter : global::MessagePack.Formatters.IMessagePackFormatter - { - // X - private static global::System.ReadOnlySpan GetSpan_X() => new byte[1 + 1] { 161, 88 }; - - public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::SharedData.Callback2_2 value, global::MessagePack.MessagePackSerializerOptions options) - { - ((global::MessagePack.IMessagePackSerializationCallbackReceiver)value).OnBeforeSerialize(); - writer.WriteMapHeader(1); - writer.WriteRaw(GetSpan_X()); - writer.Write(value.X); - } - - public global::SharedData.Callback2_2 Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - if (reader.TryReadNil()) - { - throw new global::System.InvalidOperationException("typecode is null, struct not supported"); - } - - options.Security.DepthStep(ref reader); - var length = reader.ReadMapHeader(); - var __X__ = default(int); - - for (int i = 0; i < length; i++) - { - var stringKey = global::MessagePack.Internal.CodeGenHelpers.ReadStringSpan(ref reader); - switch (stringKey.Length) - { - default: - FAIL: - reader.Skip(); - continue; - case 1: - if (stringKey[0] != 88) { goto FAIL; } - - __X__ = reader.ReadInt32(); - continue; - - } - } - - var ____result = new global::SharedData.Callback2_2(__X__); - ((global::MessagePack.IMessagePackSerializationCallbackReceiver)____result).OnAfterDeserialize(); - reader.Depth--; - return ____result; - } - } - - public sealed class DefaultValueStringKeyClassWithExplicitConstructorFormatter : global::MessagePack.Formatters.IMessagePackFormatter - { - // Prop1 - private static global::System.ReadOnlySpan GetSpan_Prop1() => new byte[1 + 5] { 165, 80, 114, 111, 112, 49 }; - // Prop2 - private static global::System.ReadOnlySpan GetSpan_Prop2() => new byte[1 + 5] { 165, 80, 114, 111, 112, 50 }; - - public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::SharedData.DefaultValueStringKeyClassWithExplicitConstructor value, global::MessagePack.MessagePackSerializerOptions options) - { - if (value is null) - { - writer.WriteNil(); - return; - } - - writer.WriteMapHeader(2); - writer.WriteRaw(GetSpan_Prop1()); - writer.Write(value.Prop1); - writer.WriteRaw(GetSpan_Prop2()); - writer.Write(value.Prop2); - } - - public global::SharedData.DefaultValueStringKeyClassWithExplicitConstructor Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - if (reader.TryReadNil()) - { - return null; - } - - options.Security.DepthStep(ref reader); - var length = reader.ReadMapHeader(); - var __Prop1__ = default(int); - var __Prop2__IsInitialized = false; - var __Prop2__ = default(int); - - for (int i = 0; i < length; i++) - { - var stringKey = global::MessagePack.Internal.CodeGenHelpers.ReadStringSpan(ref reader); - switch (stringKey.Length) - { - default: - FAIL: - reader.Skip(); - continue; - case 5: - switch (global::MessagePack.Internal.AutomataKeyGen.GetKey(ref stringKey)) - { - default: goto FAIL; - case 212339749456UL: - __Prop1__ = reader.ReadInt32(); - continue; - case 216634716752UL: - __Prop2__IsInitialized = true; - __Prop2__ = reader.ReadInt32(); - continue; - } - - } - } - - var ____result = new global::SharedData.DefaultValueStringKeyClassWithExplicitConstructor(__Prop1__); - if (__Prop2__IsInitialized) - { - ____result.Prop2 = __Prop2__; - } - - reader.Depth--; - return ____result; - } - } - - public sealed class DefaultValueStringKeyClassWithoutExplicitConstructorFormatter : global::MessagePack.Formatters.IMessagePackFormatter - { - // Prop1 - private static global::System.ReadOnlySpan GetSpan_Prop1() => new byte[1 + 5] { 165, 80, 114, 111, 112, 49 }; - // Prop2 - private static global::System.ReadOnlySpan GetSpan_Prop2() => new byte[1 + 5] { 165, 80, 114, 111, 112, 50 }; - - public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::SharedData.DefaultValueStringKeyClassWithoutExplicitConstructor value, global::MessagePack.MessagePackSerializerOptions options) - { - if (value is null) - { - writer.WriteNil(); - return; - } - - writer.WriteMapHeader(2); - writer.WriteRaw(GetSpan_Prop1()); - writer.Write(value.Prop1); - writer.WriteRaw(GetSpan_Prop2()); - writer.Write(value.Prop2); - } - - public global::SharedData.DefaultValueStringKeyClassWithoutExplicitConstructor Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - if (reader.TryReadNil()) - { - return null; - } - - options.Security.DepthStep(ref reader); - var length = reader.ReadMapHeader(); - var ____result = new global::SharedData.DefaultValueStringKeyClassWithoutExplicitConstructor(); - - for (int i = 0; i < length; i++) - { - var stringKey = global::MessagePack.Internal.CodeGenHelpers.ReadStringSpan(ref reader); - switch (stringKey.Length) - { - default: - FAIL: - reader.Skip(); - continue; - case 5: - switch (global::MessagePack.Internal.AutomataKeyGen.GetKey(ref stringKey)) - { - default: goto FAIL; - case 212339749456UL: - ____result.Prop1 = reader.ReadInt32(); - continue; - case 216634716752UL: - ____result.Prop2 = reader.ReadInt32(); - continue; - } - - } - } - - reader.Depth--; - return ____result; - } - } - - public sealed class DefaultValueStringKeyStructWithExplicitConstructorFormatter : global::MessagePack.Formatters.IMessagePackFormatter - { - // Prop1 - private static global::System.ReadOnlySpan GetSpan_Prop1() => new byte[1 + 5] { 165, 80, 114, 111, 112, 49 }; - // Prop2 - private static global::System.ReadOnlySpan GetSpan_Prop2() => new byte[1 + 5] { 165, 80, 114, 111, 112, 50 }; - - public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::SharedData.DefaultValueStringKeyStructWithExplicitConstructor value, global::MessagePack.MessagePackSerializerOptions options) - { - writer.WriteMapHeader(2); - writer.WriteRaw(GetSpan_Prop1()); - writer.Write(value.Prop1); - writer.WriteRaw(GetSpan_Prop2()); - writer.Write(value.Prop2); - } - - public global::SharedData.DefaultValueStringKeyStructWithExplicitConstructor Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - if (reader.TryReadNil()) - { - throw new global::System.InvalidOperationException("typecode is null, struct not supported"); - } - - options.Security.DepthStep(ref reader); - var length = reader.ReadMapHeader(); - var __Prop1__ = default(int); - var __Prop2__IsInitialized = false; - var __Prop2__ = default(int); - - for (int i = 0; i < length; i++) - { - var stringKey = global::MessagePack.Internal.CodeGenHelpers.ReadStringSpan(ref reader); - switch (stringKey.Length) - { - default: - FAIL: - reader.Skip(); - continue; - case 5: - switch (global::MessagePack.Internal.AutomataKeyGen.GetKey(ref stringKey)) - { - default: goto FAIL; - case 212339749456UL: - __Prop1__ = reader.ReadInt32(); - continue; - case 216634716752UL: - __Prop2__IsInitialized = true; - __Prop2__ = reader.ReadInt32(); - continue; - } - - } - } - - var ____result = new global::SharedData.DefaultValueStringKeyStructWithExplicitConstructor(__Prop1__); - if (__Prop2__IsInitialized) - { - ____result.Prop2 = __Prop2__; - } - - reader.Depth--; - return ____result; - } - } - - public sealed class Empty2Formatter : global::MessagePack.Formatters.IMessagePackFormatter - { - public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::SharedData.Empty2 value, global::MessagePack.MessagePackSerializerOptions options) - { - if (value is null) - { - writer.WriteNil(); - return; - } - - writer.WriteMapHeader(0); - } - - public global::SharedData.Empty2 Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - if (reader.TryReadNil()) - { - return null; - } - - reader.Skip(); - var ____result = new global::SharedData.Empty2(); - return ____result; - } - } - - public sealed class GenericConstrainedClassStringKeyFormatter : global::MessagePack.Formatters.IMessagePackFormatter> - where T1 : class - where T2 : class, global::System.Collections.Generic.IEqualityComparer - { - // MyProperty0 - private static global::System.ReadOnlySpan GetSpan_MyProperty0() => new byte[1 + 11] { 171, 77, 121, 80, 114, 111, 112, 101, 114, 116, 121, 48 }; - // Comparer - private static global::System.ReadOnlySpan GetSpan_Comparer() => new byte[1 + 8] { 168, 67, 111, 109, 112, 97, 114, 101, 114 }; - - public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::SharedData.GenericConstrainedClassStringKey value, global::MessagePack.MessagePackSerializerOptions options) - { - if (value is null) - { - writer.WriteNil(); - return; - } - - var formatterResolver = options.Resolver; - writer.WriteMapHeader(2); - writer.WriteRaw(GetSpan_MyProperty0()); - global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Serialize(ref writer, value.MyProperty0, options); - writer.WriteRaw(GetSpan_Comparer()); - global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Serialize(ref writer, value.Comparer, options); - } - - public global::SharedData.GenericConstrainedClassStringKey Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - if (reader.TryReadNil()) - { - return null; - } - - options.Security.DepthStep(ref reader); - var formatterResolver = options.Resolver; - var length = reader.ReadMapHeader(); - var ____result = new global::SharedData.GenericConstrainedClassStringKey(); - - for (int i = 0; i < length; i++) - { - var stringKey = global::MessagePack.Internal.CodeGenHelpers.ReadStringSpan(ref reader); - switch (stringKey.Length) - { - default: - FAIL: - reader.Skip(); - continue; - case 11: - if (!global::System.MemoryExtensions.SequenceEqual(stringKey, GetSpan_MyProperty0().Slice(1))) { goto FAIL; } - - ____result.MyProperty0 = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Deserialize(ref reader, options); - continue; - case 8: - if (global::MessagePack.Internal.AutomataKeyGen.GetKey(ref stringKey) != 8243120455795175235UL) { goto FAIL; } - - ____result.Comparer = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Deserialize(ref reader, options); - continue; - - } - } - - reader.Depth--; - return ____result; - } - } - - public sealed class GenericConstrainedStructStringKeyFormatter : global::MessagePack.Formatters.IMessagePackFormatter> - where T1 : unmanaged - where T2 : unmanaged, global::System.Collections.Generic.IEqualityComparer - { - // MyProperty0 - private static global::System.ReadOnlySpan GetSpan_MyProperty0() => new byte[1 + 11] { 171, 77, 121, 80, 114, 111, 112, 101, 114, 116, 121, 48 }; - // Comparer - private static global::System.ReadOnlySpan GetSpan_Comparer() => new byte[1 + 8] { 168, 67, 111, 109, 112, 97, 114, 101, 114 }; - - public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::SharedData.GenericConstrainedStructStringKey value, global::MessagePack.MessagePackSerializerOptions options) - { - var formatterResolver = options.Resolver; - writer.WriteMapHeader(2); - writer.WriteRaw(GetSpan_MyProperty0()); - global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Serialize(ref writer, value.MyProperty0, options); - writer.WriteRaw(GetSpan_Comparer()); - global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Serialize(ref writer, value.Comparer, options); - } - - public global::SharedData.GenericConstrainedStructStringKey Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - if (reader.TryReadNil()) - { - throw new global::System.InvalidOperationException("typecode is null, struct not supported"); - } - - options.Security.DepthStep(ref reader); - var formatterResolver = options.Resolver; - var length = reader.ReadMapHeader(); - var ____result = new global::SharedData.GenericConstrainedStructStringKey(); - - for (int i = 0; i < length; i++) - { - var stringKey = global::MessagePack.Internal.CodeGenHelpers.ReadStringSpan(ref reader); - switch (stringKey.Length) - { - default: - FAIL: - reader.Skip(); - continue; - case 11: - if (!global::System.MemoryExtensions.SequenceEqual(stringKey, GetSpan_MyProperty0().Slice(1))) { goto FAIL; } - - ____result.MyProperty0 = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Deserialize(ref reader, options); - continue; - case 8: - if (global::MessagePack.Internal.AutomataKeyGen.GetKey(ref stringKey) != 8243120455795175235UL) { goto FAIL; } - - ____result.Comparer = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Deserialize(ref reader, options); - continue; - - } - } - - reader.Depth--; - return ____result; - } - } - - public sealed class NonEmpty2Formatter : global::MessagePack.Formatters.IMessagePackFormatter - { - // MyProperty - private static global::System.ReadOnlySpan GetSpan_MyProperty() => new byte[1 + 10] { 170, 77, 121, 80, 114, 111, 112, 101, 114, 116, 121 }; - - public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::SharedData.NonEmpty2 value, global::MessagePack.MessagePackSerializerOptions options) - { - if (value is null) - { - writer.WriteNil(); - return; - } - - writer.WriteMapHeader(1); - writer.WriteRaw(GetSpan_MyProperty()); - writer.Write(value.MyProperty); - } - - public global::SharedData.NonEmpty2 Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - if (reader.TryReadNil()) - { - return null; - } - - options.Security.DepthStep(ref reader); - var length = reader.ReadMapHeader(); - var ____result = new global::SharedData.NonEmpty2(); - - for (int i = 0; i < length; i++) - { - var stringKey = global::MessagePack.Internal.CodeGenHelpers.ReadStringSpan(ref reader); - switch (stringKey.Length) - { - default: - FAIL: - reader.Skip(); - continue; - case 10: - if (!global::System.MemoryExtensions.SequenceEqual(stringKey, GetSpan_MyProperty().Slice(1))) { goto FAIL; } - - ____result.MyProperty = reader.ReadInt32(); - continue; - - } - } - - reader.Depth--; - return ____result; - } - } - - public sealed class SimpleStringKeyDataFormatter : global::MessagePack.Formatters.IMessagePackFormatter - { - // Prop1 - private static global::System.ReadOnlySpan GetSpan_Prop1() => new byte[1 + 5] { 165, 80, 114, 111, 112, 49 }; - // Prop2 - private static global::System.ReadOnlySpan GetSpan_Prop2() => new byte[1 + 5] { 165, 80, 114, 111, 112, 50 }; - // Prop3 - private static global::System.ReadOnlySpan GetSpan_Prop3() => new byte[1 + 5] { 165, 80, 114, 111, 112, 51 }; - - public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::SharedData.SimpleStringKeyData value, global::MessagePack.MessagePackSerializerOptions options) - { - if (value is null) - { - writer.WriteNil(); - return; - } - - var formatterResolver = options.Resolver; - writer.WriteMapHeader(3); - writer.WriteRaw(GetSpan_Prop1()); - writer.Write(value.Prop1); - writer.WriteRaw(GetSpan_Prop2()); - global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Serialize(ref writer, value.Prop2, options); - writer.WriteRaw(GetSpan_Prop3()); - writer.Write(value.Prop3); - } - - public global::SharedData.SimpleStringKeyData Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - if (reader.TryReadNil()) - { - return null; - } - - options.Security.DepthStep(ref reader); - var formatterResolver = options.Resolver; - var length = reader.ReadMapHeader(); - var ____result = new global::SharedData.SimpleStringKeyData(); - - for (int i = 0; i < length; i++) - { - var stringKey = global::MessagePack.Internal.CodeGenHelpers.ReadStringSpan(ref reader); - switch (stringKey.Length) - { - default: - FAIL: - reader.Skip(); - continue; - case 5: - switch (global::MessagePack.Internal.AutomataKeyGen.GetKey(ref stringKey)) - { - default: goto FAIL; - case 212339749456UL: - ____result.Prop1 = reader.ReadInt32(); - continue; - case 216634716752UL: - ____result.Prop2 = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Deserialize(ref reader, options); - continue; - case 220929684048UL: - ____result.Prop3 = reader.ReadInt32(); - continue; - } - - } - } - - reader.Depth--; - return ____result; - } - } - - public sealed class SimpleStructStringKeyDataFormatter : global::MessagePack.Formatters.IMessagePackFormatter - { - // key-X - private static global::System.ReadOnlySpan GetSpan_X() => new byte[1 + 5] { 165, 107, 101, 121, 45, 88 }; - // key-Y - private static global::System.ReadOnlySpan GetSpan_Y() => new byte[1 + 5] { 165, 107, 101, 121, 45, 89 }; - - public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::SharedData.SimpleStructStringKeyData value, global::MessagePack.MessagePackSerializerOptions options) - { - var formatterResolver = options.Resolver; - writer.WriteMapHeader(2); - writer.WriteRaw(GetSpan_X()); - writer.Write(value.X); - writer.WriteRaw(GetSpan_Y()); - global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Serialize(ref writer, value.Y, options); - } - - public global::SharedData.SimpleStructStringKeyData Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - if (reader.TryReadNil()) - { - throw new global::System.InvalidOperationException("typecode is null, struct not supported"); - } - - options.Security.DepthStep(ref reader); - var formatterResolver = options.Resolver; - var length = reader.ReadMapHeader(); - var ____result = new global::SharedData.SimpleStructStringKeyData(); - - for (int i = 0; i < length; i++) - { - var stringKey = global::MessagePack.Internal.CodeGenHelpers.ReadStringSpan(ref reader); - switch (stringKey.Length) - { - default: - FAIL: - reader.Skip(); - continue; - case 5: - switch (global::MessagePack.Internal.AutomataKeyGen.GetKey(ref stringKey)) - { - default: goto FAIL; - case 378720052587UL: - ____result.X = reader.ReadInt32(); - continue; - case 383015019883UL: - ____result.Y = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Deserialize(ref reader, options); - continue; - } - - } - } - - reader.Depth--; - return ____result; - } - } - -} - -#pragma warning restore 168 -#pragma warning restore 414 -#pragma warning restore 618 -#pragma warning restore 612 - -#pragma warning restore SA1129 // Do not use default value type constructor -#pragma warning restore SA1309 // Field names should not begin with underscore -#pragma warning restore SA1312 // Variable names should begin with lower-case letter -#pragma warning restore SA1403 // File may only contain a single namespace -#pragma warning restore SA1649 // File name should match first type name - diff --git a/sandbox/Sandbox/codegen.bat b/sandbox/Sandbox/codegen.bat deleted file mode 100644 index 970285c2f..000000000 --- a/sandbox/Sandbox/codegen.bat +++ /dev/null @@ -1,4 +0,0 @@ -@echo off -SETLOCAL -set PS1UnderCmd=1 -powershell.exe -NoProfile -NoLogo -ExecutionPolicy bypass -Command "try { & '%~dpn0.ps1' %*; exit $LASTEXITCODE } catch { write-host $_; exit 1 }" diff --git a/sandbox/Sandbox/codegen.ps1 b/sandbox/Sandbox/codegen.ps1 deleted file mode 100644 index dc51471af..000000000 --- a/sandbox/Sandbox/codegen.ps1 +++ /dev/null @@ -1 +0,0 @@ -dotnet run -f "net7.0" --project "$PSScriptRoot/../../src/MessagePack.Generator/MessagePack.Generator.csproj" -- -i "$PSScriptRoot/../SharedData/SharedData.csproj" -o "$PSScriptRoot/Generated.cs" diff --git a/sandbox/TestData2/Generated.cs b/sandbox/TestData2/Generated.cs deleted file mode 100644 index ac86ae02f..000000000 --- a/sandbox/TestData2/Generated.cs +++ /dev/null @@ -1,1012 +0,0 @@ -// -// THIS (.cs) FILE IS GENERATED BY MPC(MessagePack-CSharp). DO NOT CHANGE IT. -// - -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 168 -#pragma warning disable CS1591 // document public APIs - -#pragma warning disable SA1312 // Variable names should begin with lower-case letter -#pragma warning disable SA1649 // File name should match first type name - -namespace MessagePack.Resolvers -{ - public class GeneratedResolver : global::MessagePack.IFormatterResolver - { - public static readonly global::MessagePack.IFormatterResolver Instance = new GeneratedResolver(); - - private GeneratedResolver() - { - } - - public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() - { - return FormatterCache.Formatter; - } - - private static class FormatterCache - { - internal static readonly global::MessagePack.Formatters.IMessagePackFormatter Formatter; - - static FormatterCache() - { - var f = GeneratedResolverGetFormatterHelper.GetFormatter(typeof(T)); - if (f != null) - { - Formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; - } - } - } - } - - internal static class GeneratedResolverGetFormatterHelper - { - private static readonly global::System.Collections.Generic.Dictionary lookup; - - static GeneratedResolverGetFormatterHelper() - { - lookup = new global::System.Collections.Generic.Dictionary(20) - { - { typeof(global::System.Collections.Generic.List), 0 }, - { typeof(global::System.Collections.Generic.List), 1 }, - { typeof(global::System.Collections.Generic.List), 2 }, - { typeof(global::System.Collections.Generic.List>), 3 }, - { typeof(global::TestData2.NestedGenericTestA), 4 }, - { typeof(global::TestData2.NestedGenericTestB), 5 }, - { typeof(global::TestData2.Nest1.Id), 6 }, - { typeof(global::TestData2.Nest2.Id), 7 }, - { typeof(global::TestData2.A), 8 }, - { typeof(global::TestData2.B), 9 }, - { typeof(global::TestData2.C), 10 }, - { typeof(global::TestData2.Nest1), 11 }, - { typeof(global::TestData2.Nest1.IdType), 12 }, - { typeof(global::TestData2.Nest2), 13 }, - { typeof(global::TestData2.Nest2.IdType), 14 }, - { typeof(global::TestData2.NestedGenericTestC), 15 }, - { typeof(global::TestData2.NullableTest), 16 }, - { typeof(global::TestData2.PropNameCheck1), 17 }, - { typeof(global::TestData2.PropNameCheck2), 18 }, - { typeof(global::TestData2.Record), 19 }, - }; - } - - internal static object GetFormatter(global::System.Type t) - { - int key; - if (!lookup.TryGetValue(t, out key)) - { - return null; - } - - switch (key) - { - case 0: return new global::MessagePack.Formatters.ListFormatter(); - case 1: return new global::MessagePack.Formatters.ListFormatter(); - case 2: return new global::MessagePack.Formatters.ListFormatter(); - case 3: return new global::MessagePack.Formatters.ListFormatter>(); - case 4: return new MessagePack.Formatters.TestData2.NestedGenericTestAFormatter(); - case 5: return new MessagePack.Formatters.TestData2.NestedGenericTestBFormatter(); - case 6: return new MessagePack.Formatters.TestData2.Nest1_IdFormatter(); - case 7: return new MessagePack.Formatters.TestData2.Nest2_IdFormatter(); - case 8: return new MessagePack.Formatters.TestData2.AFormatter(); - case 9: return new MessagePack.Formatters.TestData2.BFormatter(); - case 10: return new MessagePack.Formatters.TestData2.CFormatter(); - case 11: return new MessagePack.Formatters.TestData2.Nest1Formatter(); - case 12: return new MessagePack.Formatters.TestData2.Nest1_IdTypeFormatter(); - case 13: return new MessagePack.Formatters.TestData2.Nest2Formatter(); - case 14: return new MessagePack.Formatters.TestData2.Nest2_IdTypeFormatter(); - case 15: return new MessagePack.Formatters.TestData2.NestedGenericTestCFormatter(); - case 16: return new MessagePack.Formatters.TestData2.NullableTestFormatter(); - case 17: return new MessagePack.Formatters.TestData2.PropNameCheck1Formatter(); - case 18: return new MessagePack.Formatters.TestData2.PropNameCheck2Formatter(); - case 19: return new MessagePack.Formatters.TestData2.RecordFormatter(); - default: return null; - } - } - } -} - -#pragma warning restore 168 -#pragma warning restore 414 -#pragma warning restore 618 -#pragma warning restore 612 - -#pragma warning restore SA1312 // Variable names should begin with lower-case letter -#pragma warning restore SA1649 // File name should match first type name - - -// -// THIS (.cs) FILE IS GENERATED BY MPC(MessagePack-CSharp). DO NOT CHANGE IT. -// - -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 168 -#pragma warning disable CS1591 // document public APIs - -#pragma warning disable SA1403 // File may only contain a single namespace -#pragma warning disable SA1649 // File name should match first type name - -namespace MessagePack.Formatters.TestData2 -{ - - public sealed class Nest1_IdFormatter : global::MessagePack.Formatters.IMessagePackFormatter - { - public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::TestData2.Nest1.Id value, global::MessagePack.MessagePackSerializerOptions options) - { - writer.Write((global::System.Int32)value); - } - - public global::TestData2.Nest1.Id Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - return (global::TestData2.Nest1.Id)reader.ReadInt32(); - } - } - - public sealed class Nest2_IdFormatter : global::MessagePack.Formatters.IMessagePackFormatter - { - public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::TestData2.Nest2.Id value, global::MessagePack.MessagePackSerializerOptions options) - { - writer.Write((global::System.Int32)value); - } - - public global::TestData2.Nest2.Id Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - return (global::TestData2.Nest2.Id)reader.ReadInt32(); - } - } -} - -#pragma warning restore 168 -#pragma warning restore 414 -#pragma warning restore 618 -#pragma warning restore 612 - -#pragma warning restore SA1403 // File may only contain a single namespace -#pragma warning restore SA1649 // File name should match first type name - - - -// -// THIS (.cs) FILE IS GENERATED BY MPC(MessagePack-CSharp). DO NOT CHANGE IT. -// - -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 168 -#pragma warning disable CS1591 // document public APIs - -#pragma warning disable SA1129 // Do not use default value type constructor -#pragma warning disable SA1309 // Field names should not begin with underscore -#pragma warning disable SA1312 // Variable names should begin with lower-case letter -#pragma warning disable SA1403 // File may only contain a single namespace -#pragma warning disable SA1649 // File name should match first type name - -namespace MessagePack.Formatters.TestData2 -{ - public sealed class AFormatter : global::MessagePack.Formatters.IMessagePackFormatter - { - // a - private static global::System.ReadOnlySpan GetSpan_a() => new byte[1 + 1] { 161, 97 }; - // bs - private static global::System.ReadOnlySpan GetSpan_bs() => new byte[1 + 2] { 162, 98, 115 }; - // c - private static global::System.ReadOnlySpan GetSpan_c() => new byte[1 + 1] { 161, 99 }; - - public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::TestData2.A value, global::MessagePack.MessagePackSerializerOptions options) - { - if (value is null) - { - writer.WriteNil(); - return; - } - - var formatterResolver = options.Resolver; - writer.WriteMapHeader(3); - writer.WriteRaw(GetSpan_a()); - writer.Write(value.a); - writer.WriteRaw(GetSpan_bs()); - global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify>(formatterResolver).Serialize(ref writer, value.bs, options); - writer.WriteRaw(GetSpan_c()); - global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Serialize(ref writer, value.c, options); - } - - public global::TestData2.A Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - if (reader.TryReadNil()) - { - return null; - } - - options.Security.DepthStep(ref reader); - var formatterResolver = options.Resolver; - var length = reader.ReadMapHeader(); - var ____result = new global::TestData2.A(); - - for (int i = 0; i < length; i++) - { - var stringKey = global::MessagePack.Internal.CodeGenHelpers.ReadStringSpan(ref reader); - switch (stringKey.Length) - { - default: - FAIL: - reader.Skip(); - continue; - case 1: - switch (global::MessagePack.Internal.AutomataKeyGen.GetKey(ref stringKey)) - { - default: goto FAIL; - case 97UL: - ____result.a = reader.ReadInt32(); - continue; - case 99UL: - ____result.c = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Deserialize(ref reader, options); - continue; - } - case 2: - if (global::MessagePack.Internal.AutomataKeyGen.GetKey(ref stringKey) != 29538UL) { goto FAIL; } - - ____result.bs = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify>(formatterResolver).Deserialize(ref reader, options); - continue; - - } - } - - reader.Depth--; - return ____result; - } - } - - public sealed class BFormatter : global::MessagePack.Formatters.IMessagePackFormatter - { - // ass - private static global::System.ReadOnlySpan GetSpan_ass() => new byte[1 + 3] { 163, 97, 115, 115 }; - // c - private static global::System.ReadOnlySpan GetSpan_c() => new byte[1 + 1] { 161, 99 }; - // a - private static global::System.ReadOnlySpan GetSpan_a() => new byte[1 + 1] { 161, 97 }; - - public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::TestData2.B value, global::MessagePack.MessagePackSerializerOptions options) - { - if (value is null) - { - writer.WriteNil(); - return; - } - - var formatterResolver = options.Resolver; - writer.WriteMapHeader(3); - writer.WriteRaw(GetSpan_ass()); - global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify>(formatterResolver).Serialize(ref writer, value.ass, options); - writer.WriteRaw(GetSpan_c()); - global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Serialize(ref writer, value.c, options); - writer.WriteRaw(GetSpan_a()); - writer.Write(value.a); - } - - public global::TestData2.B Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - if (reader.TryReadNil()) - { - return null; - } - - options.Security.DepthStep(ref reader); - var formatterResolver = options.Resolver; - var length = reader.ReadMapHeader(); - var ____result = new global::TestData2.B(); - - for (int i = 0; i < length; i++) - { - var stringKey = global::MessagePack.Internal.CodeGenHelpers.ReadStringSpan(ref reader); - switch (stringKey.Length) - { - default: - FAIL: - reader.Skip(); - continue; - case 3: - if (global::MessagePack.Internal.AutomataKeyGen.GetKey(ref stringKey) != 7566177UL) { goto FAIL; } - - ____result.ass = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify>(formatterResolver).Deserialize(ref reader, options); - continue; - case 1: - switch (global::MessagePack.Internal.AutomataKeyGen.GetKey(ref stringKey)) - { - default: goto FAIL; - case 99UL: - ____result.c = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Deserialize(ref reader, options); - continue; - case 97UL: - ____result.a = reader.ReadInt32(); - continue; - } - - } - } - - reader.Depth--; - return ____result; - } - } - - public sealed class CFormatter : global::MessagePack.Formatters.IMessagePackFormatter - { - // b - private static global::System.ReadOnlySpan GetSpan_b() => new byte[1 + 1] { 161, 98 }; - // a - private static global::System.ReadOnlySpan GetSpan_a() => new byte[1 + 1] { 161, 97 }; - - public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::TestData2.C value, global::MessagePack.MessagePackSerializerOptions options) - { - if (value is null) - { - writer.WriteNil(); - return; - } - - var formatterResolver = options.Resolver; - writer.WriteMapHeader(2); - writer.WriteRaw(GetSpan_b()); - global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Serialize(ref writer, value.b, options); - writer.WriteRaw(GetSpan_a()); - writer.Write(value.a); - } - - public global::TestData2.C Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - if (reader.TryReadNil()) - { - return null; - } - - options.Security.DepthStep(ref reader); - var formatterResolver = options.Resolver; - var length = reader.ReadMapHeader(); - var ____result = new global::TestData2.C(); - - for (int i = 0; i < length; i++) - { - var stringKey = global::MessagePack.Internal.CodeGenHelpers.ReadStringSpan(ref reader); - switch (stringKey.Length) - { - default: - FAIL: - reader.Skip(); - continue; - case 1: - switch (global::MessagePack.Internal.AutomataKeyGen.GetKey(ref stringKey)) - { - default: goto FAIL; - case 98UL: - ____result.b = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Deserialize(ref reader, options); - continue; - case 97UL: - ____result.a = reader.ReadInt32(); - continue; - } - - } - } - - reader.Depth--; - return ____result; - } - } - - public sealed class Nest1Formatter : global::MessagePack.Formatters.IMessagePackFormatter - { - // EnumId - private static global::System.ReadOnlySpan GetSpan_EnumId() => new byte[1 + 6] { 166, 69, 110, 117, 109, 73, 100 }; - // ClassId - private static global::System.ReadOnlySpan GetSpan_ClassId() => new byte[1 + 7] { 167, 67, 108, 97, 115, 115, 73, 100 }; - - public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::TestData2.Nest1 value, global::MessagePack.MessagePackSerializerOptions options) - { - if (value is null) - { - writer.WriteNil(); - return; - } - - var formatterResolver = options.Resolver; - writer.WriteMapHeader(2); - writer.WriteRaw(GetSpan_EnumId()); - global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Serialize(ref writer, value.EnumId, options); - writer.WriteRaw(GetSpan_ClassId()); - global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Serialize(ref writer, value.ClassId, options); - } - - public global::TestData2.Nest1 Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - if (reader.TryReadNil()) - { - return null; - } - - options.Security.DepthStep(ref reader); - var formatterResolver = options.Resolver; - var length = reader.ReadMapHeader(); - var ____result = new global::TestData2.Nest1(); - - for (int i = 0; i < length; i++) - { - var stringKey = global::MessagePack.Internal.CodeGenHelpers.ReadStringSpan(ref reader); - switch (stringKey.Length) - { - default: - FAIL: - reader.Skip(); - continue; - case 6: - if (global::MessagePack.Internal.AutomataKeyGen.GetKey(ref stringKey) != 110266531802693UL) { goto FAIL; } - - ____result.EnumId = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Deserialize(ref reader, options); - continue; - case 7: - if (global::MessagePack.Internal.AutomataKeyGen.GetKey(ref stringKey) != 28228257876896835UL) { goto FAIL; } - - ____result.ClassId = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Deserialize(ref reader, options); - continue; - - } - } - - reader.Depth--; - return ____result; - } - } - - public sealed class Nest1_IdTypeFormatter : global::MessagePack.Formatters.IMessagePackFormatter - { - public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::TestData2.Nest1.IdType value, global::MessagePack.MessagePackSerializerOptions options) - { - if (value is null) - { - writer.WriteNil(); - return; - } - - writer.WriteMapHeader(0); - } - - public global::TestData2.Nest1.IdType Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - if (reader.TryReadNil()) - { - return null; - } - - reader.Skip(); - var ____result = new global::TestData2.Nest1.IdType(); - return ____result; - } - } - - public sealed class Nest2Formatter : global::MessagePack.Formatters.IMessagePackFormatter - { - // EnumId - private static global::System.ReadOnlySpan GetSpan_EnumId() => new byte[1 + 6] { 166, 69, 110, 117, 109, 73, 100 }; - // ClassId - private static global::System.ReadOnlySpan GetSpan_ClassId() => new byte[1 + 7] { 167, 67, 108, 97, 115, 115, 73, 100 }; - - public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::TestData2.Nest2 value, global::MessagePack.MessagePackSerializerOptions options) - { - if (value is null) - { - writer.WriteNil(); - return; - } - - var formatterResolver = options.Resolver; - writer.WriteMapHeader(2); - writer.WriteRaw(GetSpan_EnumId()); - global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Serialize(ref writer, value.EnumId, options); - writer.WriteRaw(GetSpan_ClassId()); - global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Serialize(ref writer, value.ClassId, options); - } - - public global::TestData2.Nest2 Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - if (reader.TryReadNil()) - { - return null; - } - - options.Security.DepthStep(ref reader); - var formatterResolver = options.Resolver; - var length = reader.ReadMapHeader(); - var ____result = new global::TestData2.Nest2(); - - for (int i = 0; i < length; i++) - { - var stringKey = global::MessagePack.Internal.CodeGenHelpers.ReadStringSpan(ref reader); - switch (stringKey.Length) - { - default: - FAIL: - reader.Skip(); - continue; - case 6: - if (global::MessagePack.Internal.AutomataKeyGen.GetKey(ref stringKey) != 110266531802693UL) { goto FAIL; } - - ____result.EnumId = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Deserialize(ref reader, options); - continue; - case 7: - if (global::MessagePack.Internal.AutomataKeyGen.GetKey(ref stringKey) != 28228257876896835UL) { goto FAIL; } - - ____result.ClassId = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Deserialize(ref reader, options); - continue; - - } - } - - reader.Depth--; - return ____result; - } - } - - public sealed class Nest2_IdTypeFormatter : global::MessagePack.Formatters.IMessagePackFormatter - { - public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::TestData2.Nest2.IdType value, global::MessagePack.MessagePackSerializerOptions options) - { - if (value is null) - { - writer.WriteNil(); - return; - } - - writer.WriteMapHeader(0); - } - - public global::TestData2.Nest2.IdType Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - if (reader.TryReadNil()) - { - return null; - } - - reader.Skip(); - var ____result = new global::TestData2.Nest2.IdType(); - return ____result; - } - } - - public sealed class NestedGenericTestAFormatter : global::MessagePack.Formatters.IMessagePackFormatter> - { - // Field - private static global::System.ReadOnlySpan GetSpan_Field() => new byte[1 + 5] { 165, 70, 105, 101, 108, 100 }; - - public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::TestData2.NestedGenericTestA value, global::MessagePack.MessagePackSerializerOptions options) - { - if (value is null) - { - writer.WriteNil(); - return; - } - - var formatterResolver = options.Resolver; - writer.WriteMapHeader(1); - writer.WriteRaw(GetSpan_Field()); - global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Serialize(ref writer, value.Field, options); - } - - public global::TestData2.NestedGenericTestA Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - if (reader.TryReadNil()) - { - return null; - } - - options.Security.DepthStep(ref reader); - var formatterResolver = options.Resolver; - var length = reader.ReadMapHeader(); - var ____result = new global::TestData2.NestedGenericTestA(); - - for (int i = 0; i < length; i++) - { - var stringKey = global::MessagePack.Internal.CodeGenHelpers.ReadStringSpan(ref reader); - switch (stringKey.Length) - { - default: - FAIL: - reader.Skip(); - continue; - case 5: - if (global::MessagePack.Internal.AutomataKeyGen.GetKey(ref stringKey) != 431315315014UL) { goto FAIL; } - - ____result.Field = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Deserialize(ref reader, options); - continue; - - } - } - - reader.Depth--; - return ____result; - } - } - - public sealed class NestedGenericTestBFormatter : global::MessagePack.Formatters.IMessagePackFormatter> - { - // Field - private static global::System.ReadOnlySpan GetSpan_Field() => new byte[1 + 5] { 165, 70, 105, 101, 108, 100 }; - - public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::TestData2.NestedGenericTestB value, global::MessagePack.MessagePackSerializerOptions options) - { - if (value is null) - { - writer.WriteNil(); - return; - } - - var formatterResolver = options.Resolver; - writer.WriteMapHeader(1); - writer.WriteRaw(GetSpan_Field()); - global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify>>(formatterResolver).Serialize(ref writer, value.Field, options); - } - - public global::TestData2.NestedGenericTestB Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - if (reader.TryReadNil()) - { - return null; - } - - options.Security.DepthStep(ref reader); - var formatterResolver = options.Resolver; - var length = reader.ReadMapHeader(); - var ____result = new global::TestData2.NestedGenericTestB(); - - for (int i = 0; i < length; i++) - { - var stringKey = global::MessagePack.Internal.CodeGenHelpers.ReadStringSpan(ref reader); - switch (stringKey.Length) - { - default: - FAIL: - reader.Skip(); - continue; - case 5: - if (global::MessagePack.Internal.AutomataKeyGen.GetKey(ref stringKey) != 431315315014UL) { goto FAIL; } - - ____result.Field = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify>>(formatterResolver).Deserialize(ref reader, options); - continue; - - } - } - - reader.Depth--; - return ____result; - } - } - - public sealed class NestedGenericTestCFormatter : global::MessagePack.Formatters.IMessagePackFormatter - { - // Field - private static global::System.ReadOnlySpan GetSpan_Field() => new byte[1 + 5] { 165, 70, 105, 101, 108, 100 }; - - public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::TestData2.NestedGenericTestC value, global::MessagePack.MessagePackSerializerOptions options) - { - if (value is null) - { - writer.WriteNil(); - return; - } - - var formatterResolver = options.Resolver; - writer.WriteMapHeader(1); - writer.WriteRaw(GetSpan_Field()); - global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify>(formatterResolver).Serialize(ref writer, value.Field, options); - } - - public global::TestData2.NestedGenericTestC Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - if (reader.TryReadNil()) - { - return null; - } - - options.Security.DepthStep(ref reader); - var formatterResolver = options.Resolver; - var length = reader.ReadMapHeader(); - var ____result = new global::TestData2.NestedGenericTestC(); - - for (int i = 0; i < length; i++) - { - var stringKey = global::MessagePack.Internal.CodeGenHelpers.ReadStringSpan(ref reader); - switch (stringKey.Length) - { - default: - FAIL: - reader.Skip(); - continue; - case 5: - if (global::MessagePack.Internal.AutomataKeyGen.GetKey(ref stringKey) != 431315315014UL) { goto FAIL; } - - ____result.Field = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify>(formatterResolver).Deserialize(ref reader, options); - continue; - - } - } - - reader.Depth--; - return ____result; - } - } - - public sealed class NullableTestFormatter : global::MessagePack.Formatters.IMessagePackFormatter - { - // a - private static global::System.ReadOnlySpan GetSpan_a() => new byte[1 + 1] { 161, 97 }; - // b - private static global::System.ReadOnlySpan GetSpan_b() => new byte[1 + 1] { 161, 98 }; - - public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::TestData2.NullableTest value, global::MessagePack.MessagePackSerializerOptions options) - { - if (value is null) - { - writer.WriteNil(); - return; - } - - var formatterResolver = options.Resolver; - writer.WriteMapHeader(2); - writer.WriteRaw(GetSpan_a()); - global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Serialize(ref writer, value.a, options); - writer.WriteRaw(GetSpan_b()); - global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify>(formatterResolver).Serialize(ref writer, value.b, options); - } - - public global::TestData2.NullableTest Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - if (reader.TryReadNil()) - { - return null; - } - - options.Security.DepthStep(ref reader); - var formatterResolver = options.Resolver; - var length = reader.ReadMapHeader(); - var ____result = new global::TestData2.NullableTest(); - - for (int i = 0; i < length; i++) - { - var stringKey = global::MessagePack.Internal.CodeGenHelpers.ReadStringSpan(ref reader); - switch (stringKey.Length) - { - default: - FAIL: - reader.Skip(); - continue; - case 1: - switch (global::MessagePack.Internal.AutomataKeyGen.GetKey(ref stringKey)) - { - default: goto FAIL; - case 97UL: - ____result.a = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Deserialize(ref reader, options); - continue; - case 98UL: - ____result.b = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify>(formatterResolver).Deserialize(ref reader, options); - continue; - } - - } - } - - reader.Depth--; - return ____result; - } - } - - public sealed class PropNameCheck1Formatter : global::MessagePack.Formatters.IMessagePackFormatter - { - // MyProperty1 - private static global::System.ReadOnlySpan GetSpan_MyProperty1() => new byte[1 + 11] { 171, 77, 121, 80, 114, 111, 112, 101, 114, 116, 121, 49 }; - // MyProperty2 - private static global::System.ReadOnlySpan GetSpan_MyProperty2() => new byte[1 + 11] { 171, 77, 121, 80, 114, 111, 112, 101, 114, 116, 121, 50 }; - - public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::TestData2.PropNameCheck1 value, global::MessagePack.MessagePackSerializerOptions options) - { - if (value is null) - { - writer.WriteNil(); - return; - } - - var formatterResolver = options.Resolver; - writer.WriteMapHeader(2); - writer.WriteRaw(GetSpan_MyProperty1()); - global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Serialize(ref writer, value.MyProperty1, options); - writer.WriteRaw(GetSpan_MyProperty2()); - global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Serialize(ref writer, value.MyProperty2, options); - } - - public global::TestData2.PropNameCheck1 Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - if (reader.TryReadNil()) - { - return null; - } - - options.Security.DepthStep(ref reader); - var formatterResolver = options.Resolver; - var length = reader.ReadMapHeader(); - var ____result = new global::TestData2.PropNameCheck1(); - - for (int i = 0; i < length; i++) - { - var stringKey = global::MessagePack.Internal.CodeGenHelpers.ReadStringSpan(ref reader); - switch (stringKey.Length) - { - default: - FAIL: - reader.Skip(); - continue; - case 11: - switch (global::MessagePack.Internal.AutomataKeyGen.GetKey(ref stringKey)) - { - default: goto FAIL; - case 8243118316933118285UL: - switch (global::MessagePack.Internal.AutomataKeyGen.GetKey(ref stringKey)) - { - default: goto FAIL; - case 3242356UL: - ____result.MyProperty1 = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Deserialize(ref reader, options); - continue; - case 3307892UL: - ____result.MyProperty2 = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Deserialize(ref reader, options); - continue; - } - - } - - } - } - - reader.Depth--; - return ____result; - } - } - - public sealed class PropNameCheck2Formatter : global::MessagePack.Formatters.IMessagePackFormatter - { - // MyProperty1 - private static global::System.ReadOnlySpan GetSpan_MyProperty1() => new byte[1 + 11] { 171, 77, 121, 80, 114, 111, 112, 101, 114, 116, 121, 49 }; - // MyProperty2 - private static global::System.ReadOnlySpan GetSpan_MyProperty2() => new byte[1 + 11] { 171, 77, 121, 80, 114, 111, 112, 101, 114, 116, 121, 50 }; - - public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::TestData2.PropNameCheck2 value, global::MessagePack.MessagePackSerializerOptions options) - { - if (value is null) - { - writer.WriteNil(); - return; - } - - var formatterResolver = options.Resolver; - writer.WriteMapHeader(2); - writer.WriteRaw(GetSpan_MyProperty1()); - global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Serialize(ref writer, value.MyProperty1, options); - writer.WriteRaw(GetSpan_MyProperty2()); - global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Serialize(ref writer, value.MyProperty2, options); - } - - public global::TestData2.PropNameCheck2 Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - if (reader.TryReadNil()) - { - return null; - } - - options.Security.DepthStep(ref reader); - var formatterResolver = options.Resolver; - var length = reader.ReadMapHeader(); - var ____result = new global::TestData2.PropNameCheck2(); - - for (int i = 0; i < length; i++) - { - var stringKey = global::MessagePack.Internal.CodeGenHelpers.ReadStringSpan(ref reader); - switch (stringKey.Length) - { - default: - FAIL: - reader.Skip(); - continue; - case 11: - switch (global::MessagePack.Internal.AutomataKeyGen.GetKey(ref stringKey)) - { - default: goto FAIL; - case 8243118316933118285UL: - switch (global::MessagePack.Internal.AutomataKeyGen.GetKey(ref stringKey)) - { - default: goto FAIL; - case 3242356UL: - ____result.MyProperty1 = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Deserialize(ref reader, options); - continue; - case 3307892UL: - ____result.MyProperty2 = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Deserialize(ref reader, options); - continue; - } - - } - - } - } - - reader.Depth--; - return ____result; - } - } - - public sealed class RecordFormatter : global::MessagePack.Formatters.IMessagePackFormatter - { - // SomeProperty - private static global::System.ReadOnlySpan GetSpan_SomeProperty() => new byte[1 + 12] { 172, 83, 111, 109, 101, 80, 114, 111, 112, 101, 114, 116, 121 }; - - public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::TestData2.Record value, global::MessagePack.MessagePackSerializerOptions options) - { - if (value is null) - { - writer.WriteNil(); - return; - } - - var formatterResolver = options.Resolver; - writer.WriteMapHeader(1); - writer.WriteRaw(GetSpan_SomeProperty()); - global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Serialize(ref writer, value.SomeProperty, options); - } - - public global::TestData2.Record Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - if (reader.TryReadNil()) - { - return null; - } - - options.Security.DepthStep(ref reader); - var formatterResolver = options.Resolver; - var length = reader.ReadMapHeader(); - var __SomeProperty__ = default(string); - - for (int i = 0; i < length; i++) - { - var stringKey = global::MessagePack.Internal.CodeGenHelpers.ReadStringSpan(ref reader); - switch (stringKey.Length) - { - default: - FAIL: - reader.Skip(); - continue; - case 12: - if (!global::System.MemoryExtensions.SequenceEqual(stringKey, GetSpan_SomeProperty().Slice(1))) { goto FAIL; } - - __SomeProperty__ = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Deserialize(ref reader, options); - continue; - - } - } - - var ____result = new global::TestData2.Record(__SomeProperty__); - reader.Depth--; - return ____result; - } - } - -} - -#pragma warning restore 168 -#pragma warning restore 414 -#pragma warning restore 618 -#pragma warning restore 612 - -#pragma warning restore SA1129 // Do not use default value type constructor -#pragma warning restore SA1309 // Field names should not begin with underscore -#pragma warning restore SA1312 // Variable names should begin with lower-case letter -#pragma warning restore SA1403 // File may only contain a single namespace -#pragma warning restore SA1649 // File name should match first type name - diff --git a/sandbox/TestData2/codegen.bat b/sandbox/TestData2/codegen.bat deleted file mode 100644 index 970285c2f..000000000 --- a/sandbox/TestData2/codegen.bat +++ /dev/null @@ -1,4 +0,0 @@ -@echo off -SETLOCAL -set PS1UnderCmd=1 -powershell.exe -NoProfile -NoLogo -ExecutionPolicy bypass -Command "try { & '%~dpn0.ps1' %*; exit $LASTEXITCODE } catch { write-host $_; exit 1 }" diff --git a/sandbox/TestData2/codegen.ps1 b/sandbox/TestData2/codegen.ps1 deleted file mode 100644 index 98a829e9c..000000000 --- a/sandbox/TestData2/codegen.ps1 +++ /dev/null @@ -1 +0,0 @@ -dotnet run -f "net7.0" --project "$PSScriptRoot/../../src/MessagePack.Generator/MessagePack.Generator.csproj" -- -i "$PSScriptRoot/TestData2.csproj" -o "$PSScriptRoot/Generated.cs" diff --git a/sandbox/codegen.ps1 b/sandbox/codegen.ps1 deleted file mode 100644 index f8f1b9245..000000000 --- a/sandbox/codegen.ps1 +++ /dev/null @@ -1,11 +0,0 @@ -$codeGenScripts = - "$PSScriptRoot/Sandbox/codegen.ps1", - "$PSScriptRoot/TestData2/codegen.ps1" - -$exitCode = 0 -$codeGenScripts | % { - & $_ - if ($LASTEXITCODE -ne 0) { $exitCode = 1 } -} - -exit $exitCode From 19c252c6be8971ae90b6ff3cce284b513d3ce77b Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Tue, 21 Mar 2023 15:08:10 -0600 Subject: [PATCH 020/660] Get the first source generator test running as it should --- README.md | 48 +- doc/msbuildtask.md | 6 +- .../MessagePack.Generator.Roslyn3.csproj | 1 + ...ckGenerator.cs => MessagePackGenerator.cs} | 8 +- .../CodeAnalysis/AnalyzerOptions.cs | 39 + src/MessagePack.Generator/CodeGenerator.cs | 2 +- .../MessagePack.Generator.csproj | 14 + ...r.Emit.cs => MessagePackGenerator.Emit.cs} | 86 +- ...ckGenerator.cs => MessagePackGenerator.cs} | 29 +- .../Transforms/EnumTemplate.cs | 24 +- .../Transforms/EnumTemplate.tt | 18 - .../Transforms/FormatterTemplate.cs | 30 +- .../Transforms/FormatterTemplate.tt | 24 - .../Transforms/ResolverTemplate.cs | 38 +- .../Transforms/ResolverTemplate.tt | 28 +- .../Transforms/TemplatePartials.cs | 8 +- .../Transforms/UnionTemplate.cs | 25 +- .../Transforms/UnionTemplate.tt | 18 - .../build/MessagePack.Generator.props | 13 + .../Resolvers/StaticCompositeResolver.cs | 12 +- .../Tests/Generated/GeneratedResolver.cs | 5761 ----------------- .../Tests/Generated/GeneratedResolver.cs.meta | 11 - .../GenerateEnumFormatterTest.cs | 180 +- .../MessagePack.Generator.Tests.csproj | 10 + ...essagePackObject.MessagePackFormatter.g.cs | 147 + tests/MessagePack.Generator.Tests/Usings.cs | 9 +- .../CSharpSourceGeneratorVerifier`1+Test.cs | 156 +- .../Verifiers/ReferenceHelper.cs | 2 - 28 files changed, 464 insertions(+), 6283 deletions(-) rename src/MessagePack.Generator.Roslyn3/{MessagepackGenerator.cs => MessagePackGenerator.cs} (89%) create mode 100644 src/MessagePack.Generator/CodeAnalysis/AnalyzerOptions.cs rename src/MessagePack.Generator/{MessagepackGenerator.Emit.cs => MessagePackGenerator.Emit.cs} (57%) rename src/MessagePack.Generator/{MessagepackGenerator.cs => MessagePackGenerator.cs} (76%) create mode 100644 src/MessagePack.Generator/build/MessagePack.Generator.props delete mode 100644 src/MessagePack.UnityClient/Assets/Scripts/Tests/Generated/GeneratedResolver.cs delete mode 100644 src/MessagePack.UnityClient/Assets/Scripts/Tests/Generated/GeneratedResolver.cs.meta create mode 100644 tests/MessagePack.Generator.Tests/Resources/EnumFormatter/MyTestNamespace.MyMessagePackObject.MessagePackFormatter.g.cs diff --git a/README.md b/README.md index 3e75e5b4c..b187f7896 100644 --- a/README.md +++ b/README.md @@ -1582,55 +1582,13 @@ Because strict-AOT environments such as Xamarin and Unity IL2CPP forbid runtime > Note: When using Unity, dynamic code generation only works when targeting .NET Framework 4.x + mono runtime. For all other Unity targets, AOT is required. -If you want to avoid the upfront dynamic generation cost or you need to run on Xamarin or Unity, you need AOT code generation. `mpc` (MessagePackCompiler) is the code generator of MessagePack for C#. mpc uses [Roslyn](https://github.com/dotnet/roslyn) to analyze source code. - -First of all, mpc requires [.NET Core 3 Runtime](https://dotnet.microsoft.com/download). The easiest way to acquire and run mpc is as a dotnet tool. - -``` -dotnet tool install --global MessagePack.Generator -``` - -Installing it as a local tool allows you to include the tools and versions that you use in your source control system. Run these commands in the root of your repo: - -``` -dotnet new tool-manifest -dotnet tool install MessagePack.Generator -``` - -Check in your `.config\dotnet-tools.json` file. On another machine you can "restore" your tool using the `dotnet tool restore` command. - -Once you have the tool installed, simply invoke using `dotnet mpc` within your repo: - -``` -dotnet mpc --help -``` - -Alternatively, you can download mpc from the [releases][Releases] page, that includes platform native binaries (that don't require a separate dotnet runtime). +If you want to avoid the upfront dynamic generation cost or you need to run on Xamarin or Unity, you need AOT code generation. ``` -Usage: mpc [options...] - -Options: - -i, -input Input path to MSBuild project file or the directory containing Unity source files. (Required) - -o, -output Output file path(.cs) or directory(multiple generate file). (Required) - -c, -conditionalSymbol Conditional compiler symbols, split with ','. (Default: null) - -r, -resolverName Set resolver name. (Default: GeneratedResolver) - -n, -namespace Set namespace root name. (Default: MessagePack) - -m, -useMapMode Force use map mode serialization. (Default: False) - -ms, -multipleIfDirectiveOutputSymbols Generate #if-- files by symbols, split with ','. (Default: null) -``` - -`mpc` targets C# code with `[MessagePackObject]` or `[Union]` annotations. - -```cmd -// Simple Sample: -dotnet mpc -i "..\src\Sandbox.Shared.csproj" -o "MessagePackGenerated.cs" - -// Use force map simulate DynamicContractlessObjectResolver -dotnet mpc -i "..\src\Sandbox.Shared.csproj" -o "MessagePackGenerated.cs" -m +dotnet add package MessagePack.Generator ``` -By default, `mpc` generates the resolver as `MessagePack.Resolvers.GeneratedResolver` and formatters as`MessagePack.Formatters.*`. +The source generator generates the resolver as `MessagePack.Resolvers.GeneratedResolver` and formatters as`MessagePack.Formatters.*`. Here is the full sample code to register a generated resolver in Unity. diff --git a/doc/msbuildtask.md b/doc/msbuildtask.md index 5b9d75c86..a7cabf1d8 100644 --- a/doc/msbuildtask.md +++ b/doc/msbuildtask.md @@ -3,10 +3,10 @@ Cold startup performance and AOT environments can benefit by pre-compiling the specialized code for serializing and deserializing your custom types. -Install the `MessagePack.MSBuild.Tasks` NuGet package in your project: - [![NuGet](https://img.shields.io/nuget/v/MessagePack.MSBuild.Tasks.svg)](https://www.nuget.org/packages/MessagePack.MSBuild.Tasks) +Install the `MessagePack.Generator` NuGet package in your project: + [![NuGet](https://img.shields.io/nuget/v/MessagePack.Generator.svg)](https://www.nuget.org/packages/MessagePack.Generator) -This package automatically gets the MessagePack Compiler (mpc) to run during the build to produce a source file in the intermediate directory and adds it to the compilation, consumable in the normal way: +This package automatically gets the MessagePack source generator to run during the build to produce a source file in the intermediate directory and adds it to the compilation, consumable in the normal way: ```cs using System; diff --git a/src/MessagePack.Generator.Roslyn3/MessagePack.Generator.Roslyn3.csproj b/src/MessagePack.Generator.Roslyn3/MessagePack.Generator.Roslyn3.csproj index 57f0e9df9..c55019f87 100644 --- a/src/MessagePack.Generator.Roslyn3/MessagePack.Generator.Roslyn3.csproj +++ b/src/MessagePack.Generator.Roslyn3/MessagePack.Generator.Roslyn3.csproj @@ -19,6 +19,7 @@ + diff --git a/src/MessagePack.Generator.Roslyn3/MessagepackGenerator.cs b/src/MessagePack.Generator.Roslyn3/MessagePackGenerator.cs similarity index 89% rename from src/MessagePack.Generator.Roslyn3/MessagepackGenerator.cs rename to src/MessagePack.Generator.Roslyn3/MessagePackGenerator.cs index 3ef472a03..fbe6f9367 100644 --- a/src/MessagePack.Generator.Roslyn3/MessagepackGenerator.cs +++ b/src/MessagePack.Generator.Roslyn3/MessagePackGenerator.cs @@ -1,6 +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. +using MessagePack.Generator.CodeAnalysis; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp.Syntax; @@ -23,12 +24,13 @@ public void Execute(GeneratorExecutionContext context) return; } - var compilation = context.Compilation; - var generateContext = new GeneratorContext(context); + Compilation compilation = context.Compilation; + GeneratorContext generateContext = new(context); + AnalyzerOptions options = AnalyzerOptions.Parse(context.AnalyzerConfigOptions.GlobalOptions); foreach (var syntax in receiver.ClassDeclarations) { - Generate(syntax, compilation, generateContext); + Generate(syntax, options, compilation, generateContext); } } diff --git a/src/MessagePack.Generator/CodeAnalysis/AnalyzerOptions.cs b/src/MessagePack.Generator/CodeAnalysis/AnalyzerOptions.cs new file mode 100644 index 000000000..4b249d20b --- /dev/null +++ b/src/MessagePack.Generator/CodeAnalysis/AnalyzerOptions.cs @@ -0,0 +1,39 @@ +// Copyright (c) All contributors. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using Microsoft.CodeAnalysis.Diagnostics; + +namespace MessagePack.Generator.CodeAnalysis; + +public record AnalyzerOptions(string Namespace = "MessagePack", string ResolverName = "GeneratedResolver", bool UsesMapMode = false) +{ + public const string MessagePackGeneratedResolverNamespace = "build_property.MessagePackGeneratedResolverNamespace"; + public const string MessagePackGeneratedResolverName = "build_property.MessagePackGeneratedResolverName"; + public const string MessagePackGeneratedUsesMapMode = "build_property.MessagePackGeneratedUsesMapMode"; + + public static readonly AnalyzerOptions Default = new AnalyzerOptions(); + + public string ResolverNamespace => $"{Namespace}.Resolvers"; + + public string FormatterNamespace => $"{Namespace}.Formatters"; + + public static AnalyzerOptions Parse(AnalyzerConfigOptions options) + { + if (!options.TryGetValue(MessagePackGeneratedResolverNamespace, out string? @namespace)) + { + @namespace = Default.Namespace; + } + + if (!options.TryGetValue(MessagePackGeneratedResolverName, out string? resolverName)) + { + resolverName = Default.ResolverName; + } + + if (!options.TryGetValue(MessagePackGeneratedUsesMapMode, out string? usesMapMode)) + { + usesMapMode = Default.UsesMapMode ? "true" : "false"; + } + + return new AnalyzerOptions(@namespace, resolverName, string.Equals(usesMapMode, "true", StringComparison.OrdinalIgnoreCase)); + } +} diff --git a/src/MessagePack.Generator/CodeGenerator.cs b/src/MessagePack.Generator/CodeGenerator.cs index 9fce4c4bb..2290fc78d 100644 --- a/src/MessagePack.Generator/CodeGenerator.cs +++ b/src/MessagePack.Generator/CodeGenerator.cs @@ -203,7 +203,7 @@ string GetNamespace(INamespaceInfo x) } var resolverTemplate = new ResolverTemplate(namespaceDot + "Resolvers", namespaceDot + "Formatters", resolverName, genericInfo.Where(x => !x.IsOpenGenericType).Cast().Concat(enumInfo).Concat(unionInfo).Concat(objectInfo.Where(x => !x.IsOpenGenericType)).ToArray()); - waitingTasks[waitingIndex] = OutputToDirAsync(output, resolverTemplate.Namespace, resolverTemplate.ResolverName, multioutSymbol, resolverTemplate.TransformText()); + waitingTasks[waitingIndex] = OutputToDirAsync(output, resolverTemplate.ResolverNamespace, resolverTemplate.ResolverName, multioutSymbol, resolverTemplate.TransformText()); return Task.WhenAll(waitingTasks); } diff --git a/src/MessagePack.Generator/MessagePack.Generator.csproj b/src/MessagePack.Generator/MessagePack.Generator.csproj index 5d97f41ba..a6dfbf5d8 100644 --- a/src/MessagePack.Generator/MessagePack.Generator.csproj +++ b/src/MessagePack.Generator/MessagePack.Generator.csproj @@ -7,6 +7,11 @@ enable cs + + false + false + true + MessagePack.Generator MessagePack Code Generator @@ -15,10 +20,19 @@ + + + + + true + build\ + + + diff --git a/src/MessagePack.Generator/MessagepackGenerator.Emit.cs b/src/MessagePack.Generator/MessagePackGenerator.Emit.cs similarity index 57% rename from src/MessagePack.Generator/MessagepackGenerator.Emit.cs rename to src/MessagePack.Generator/MessagePackGenerator.Emit.cs index dbeb289ea..15db931ff 100644 --- a/src/MessagePack.Generator/MessagepackGenerator.Emit.cs +++ b/src/MessagePack.Generator/MessagePackGenerator.Emit.cs @@ -11,7 +11,7 @@ namespace MessagePack.Generator; public partial class MessagePackGenerator { - private static void Generate(TypeDeclarationSyntax syntax, Compilation compilation, IGeneratorContext context) + private static void Generate(TypeDeclarationSyntax syntax, AnalyzerOptions analyzerOptions, Compilation compilation, IGeneratorContext context) { var semanticModel = compilation.GetSemanticModel(syntax.SyntaxTree); @@ -26,11 +26,11 @@ private static void Generate(TypeDeclarationSyntax syntax, Compilation compilati .Replace("<", "_") .Replace(">", "_"); - var collector = new TypeCollector(compilation, true, isForceUseMap: false, ignoreTypeNames: null, typeSymbol); + TypeCollector collector = new(compilation, true, isForceUseMap: false, ignoreTypeNames: null, typeSymbol); var (objectInfo, enumInfo, genericInfo, unionInfo) = collector.Collect(); - var code = GenerateFormatterSync(fullType.Replace(".", "_"), string.Empty, objectInfo, enumInfo, unionInfo, genericInfo); + var code = GenerateFormatterSync(analyzerOptions, objectInfo, enumInfo, unionInfo, genericInfo); context.AddSource($"{fullType}.MessagePackFormatter.g.cs", code); } @@ -38,13 +38,12 @@ private static void Generate(TypeDeclarationSyntax syntax, Compilation compilati /// /// Generates the specialized resolver and formatters for the types that require serialization in a given compilation. /// - /// The resolver name. - /// The namespace for the generated type to be created in. + /// The analyzer options. /// The ObjectSerializationInfo array which TypeCollector.Collect returns. /// The EnumSerializationInfo array which TypeCollector.Collect returns. /// The UnionSerializationInfo array which TypeCollector.Collect returns. /// The GenericSerializationInfo array which TypeCollector.Collect returns. - private static string GenerateFormatterSync(string resolverName, string namespaceDot, ObjectSerializationInfo[] objectInfo, EnumSerializationInfo[] enumInfo, UnionSerializationInfo[] unionInfo, GenericSerializationInfo[] genericInfo) + private static string GenerateFormatterSync(AnalyzerOptions options, ObjectSerializationInfo[] objectInfo, EnumSerializationInfo[] enumInfo, UnionSerializationInfo[] unionInfo, GenericSerializationInfo[] genericInfo) { var objectFormatterTemplates = objectInfo .GroupBy(x => (x.Namespace, x.IsStringKey)) @@ -52,42 +51,51 @@ private static string GenerateFormatterSync(string resolverName, string namespac { var (nameSpace, isStringKey) = x.Key; var objectSerializationInfos = x.ToArray(); - var ns = namespaceDot + "Formatters" + (nameSpace is null ? string.Empty : "." + nameSpace); - var template = isStringKey ? new StringKeyFormatterTemplate(ns, objectSerializationInfos) : (IFormatterTemplate)new FormatterTemplate(ns, objectSerializationInfos); + string formatterNamespace = options.FormatterNamespace + "." + nameSpace; + var template = isStringKey ? new StringKeyFormatterTemplate(formatterNamespace, objectSerializationInfos) : (IFormatterTemplate)new FormatterTemplate(formatterNamespace, objectSerializationInfos); return template; }) .ToArray(); - string GetNamespace(IGrouping x) - { - if (x.Key == null) - { - return namespaceDot + "Formatters"; - } + StringBuilder sb = new(); - return namespaceDot + "Formatters." + x.Key; - } + sb.AppendLine(""" +// + +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 168 + +#pragma warning disable CS1591 // document public APIs + +#pragma warning disable SA1129 // Do not use default value type constructor +#pragma warning disable SA1309 // Field names should not begin with underscore +#pragma warning disable SA1312 // Variable names should begin with lower-case letter +#pragma warning disable SA1403 // File may only contain a single namespace +#pragma warning disable SA1649 // File name should match first type name + +"""); - var sb = new StringBuilder(); ResolverText( sb, - namespaceDot + "Resolvers", - resolverName, + options, genericInfo .Where(x => !x.IsOpenGenericType) .Cast() .Concat(enumInfo) .Concat(unionInfo) - .Concat(objectInfo.Where(x => !x.IsOpenGenericType))); + .Concat(objectInfo.Where(x => !x.IsOpenGenericType)) + .ToArray()); var enumFormatterTemplates = enumInfo .GroupBy(x => x.Namespace) - .Select(x => new EnumTemplate(GetNamespace(x), x.ToArray())) + .Select(x => new EnumTemplate($"{options.FormatterNamespace}.{x.Key}", x.ToArray())) .ToArray(); var unionFormatterTemplates = unionInfo .GroupBy(x => x.Namespace) - .Select(x => new UnionTemplate(GetNamespace(x), x.ToArray())) + .Select(x => new UnionTemplate(options.FormatterNamespace, x.ToArray())) .ToArray(); foreach (var item in enumFormatterTemplates) @@ -115,37 +123,9 @@ string GetNamespace(IGrouping x) return sb.ToString(); } - private static void ResolverText(StringBuilder sb, string ns, string resolverName, IEnumerable registerInfos) - { - var begin = $$""" -using System.Runtime.CompilerServices; -using MessagePack; - -namespace {{ns}} -{ - partial class FormatterRegister + private static void ResolverText(StringBuilder sb, AnalyzerOptions options, IReadOnlyList registerInfos) { - [ModuleInitializer] - internal static void {{resolverName}}FormatterRegister() - { -"""; - - var end = $$""" - } - } -} -"""; - - sb.AppendLine(begin); - - foreach (var item in registerInfos) - { - var code = $$""" - MessagePack.Resolvers.StaticCompositeResolver.Instance.AddGeneratedFormatter(new {{(item.FormatterName.StartsWith("global::") ? item.FormatterName : "global::Formatters." + item.FormatterName)}}()); -"""; - sb.AppendLine(code); - } - - sb.AppendLine(end); + ResolverTemplate resolverTemplate = new(options.ResolverNamespace, options.FormatterNamespace, options.ResolverName, registerInfos); + sb.AppendLine(resolverTemplate.TransformText()); } } diff --git a/src/MessagePack.Generator/MessagepackGenerator.cs b/src/MessagePack.Generator/MessagePackGenerator.cs similarity index 76% rename from src/MessagePack.Generator/MessagepackGenerator.cs rename to src/MessagePack.Generator/MessagePackGenerator.cs index 4435bf329..dc0114074 100644 --- a/src/MessagePack.Generator/MessagepackGenerator.cs +++ b/src/MessagePack.Generator/MessagePackGenerator.cs @@ -1,55 +1,48 @@ // Copyright (c) All contributors. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. +using MessagePack.Generator.CodeAnalysis; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp.Syntax; namespace MessagePack.Generator; [Generator(LanguageNames.CSharp)] -public partial class MessagePackGenerator : IIncrementalGenerator, ISourceGenerator +public partial class MessagePackGenerator : IIncrementalGenerator { public const string MessagePackObjectAttributeFullName = "MessagePack.MessagePackObjectAttribute"; public const string MessagePackUnionAttributeFullName = "MessagePack.UnionAttribute"; - public void Execute(GeneratorExecutionContext context) - { - throw new NotImplementedException(); - } - public void Initialize(IncrementalGeneratorInitializationContext context) { - var typeDeclarations = context.SyntaxProvider.ForAttributeWithMetadataName( + IncrementalValueProvider options = context.AnalyzerConfigOptionsProvider.Select((provider, ct) => AnalyzerOptions.Parse(provider.GlobalOptions)); + + var messagePackObjectTypes = context.SyntaxProvider.ForAttributeWithMetadataName( MessagePackObjectAttributeFullName, predicate: static (node, _) => node is TypeDeclarationSyntax, transform: static (context, _) => (TypeDeclarationSyntax)context.TargetNode); - Register(typeDeclarations); + Register(messagePackObjectTypes); - var typeDeclarations2 = context.SyntaxProvider.ForAttributeWithMetadataName( + var unionTypes = context.SyntaxProvider.ForAttributeWithMetadataName( MessagePackUnionAttributeFullName, predicate: static (node, _) => node is InterfaceDeclarationSyntax, transform: static (context, _) => (TypeDeclarationSyntax)context.TargetNode); - Register(typeDeclarations2); + Register(unionTypes); void Register(IncrementalValuesProvider typeDeclarations) { var source = typeDeclarations .Combine(context.CompilationProvider) - .WithComparer(Comparer.Instance); + .Combine(options); context.RegisterSourceOutput(source, static (context, source) => { - var (typeDeclaration, compilation) = source; - Generate(typeDeclaration, compilation, new GeneratorContext(context)); + var ((typeDeclaration, compilation), options) = source; + Generate(typeDeclaration, options, compilation, new GeneratorContext(context)); }); } } - public void Initialize(GeneratorInitializationContext context) - { - throw new NotImplementedException(); - } - private class Comparer : IEqualityComparer<(TypeDeclarationSyntax, Compilation)> { public static readonly Comparer Instance = new Comparer(); diff --git a/src/MessagePack.Generator/Transforms/EnumTemplate.cs b/src/MessagePack.Generator/Transforms/EnumTemplate.cs index d7e00e617..09ee9bcfd 100644 --- a/src/MessagePack.Generator/Transforms/EnumTemplate.cs +++ b/src/MessagePack.Generator/Transforms/EnumTemplate.cs @@ -25,18 +25,7 @@ public partial class EnumTemplate : EnumTemplateBase /// public virtual string TransformText() { - this.Write(@"// - -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 168 -#pragma warning disable CS1591 // document public APIs - -#pragma warning disable SA1403 // File may only contain a single namespace -#pragma warning disable SA1649 // File name should match first type name - -namespace "); + this.Write("\r\nnamespace "); this.Write(this.ToStringHelper.ToStringWithCulture(Namespace)); this.Write("\r\n{\r\n"); foreach(var info in EnumSerializationInfos) { @@ -59,16 +48,7 @@ namespace "); this.Write(this.ToStringHelper.ToStringWithCulture(info.UnderlyingType)); this.Write("();\r\n }\r\n }\r\n"); } - this.Write(@"} - -#pragma warning restore 168 -#pragma warning restore 414 -#pragma warning restore 618 -#pragma warning restore 612 - -#pragma warning restore SA1403 // File may only contain a single namespace -#pragma warning restore SA1649 // File name should match first type name -"); + this.Write("}\r\n"); return this.GenerationEnvironment.ToString(); } } diff --git a/src/MessagePack.Generator/Transforms/EnumTemplate.tt b/src/MessagePack.Generator/Transforms/EnumTemplate.tt index 825902caf..6d5d1c7d4 100644 --- a/src/MessagePack.Generator/Transforms/EnumTemplate.tt +++ b/src/MessagePack.Generator/Transforms/EnumTemplate.tt @@ -3,16 +3,6 @@ <#@ import namespace="System.Linq" #> <#@ import namespace="System.Text" #> <#@ import namespace="System.Collections.Generic" #> -// - -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 168 -#pragma warning disable CS1591 // document public APIs - -#pragma warning disable SA1403 // File may only contain a single namespace -#pragma warning disable SA1649 // File name should match first type name namespace <#= Namespace #> { @@ -32,11 +22,3 @@ namespace <#= Namespace #> } <# } #> } - -#pragma warning restore 168 -#pragma warning restore 414 -#pragma warning restore 618 -#pragma warning restore 612 - -#pragma warning restore SA1403 // File may only contain a single namespace -#pragma warning restore SA1649 // File name should match first type name diff --git a/src/MessagePack.Generator/Transforms/FormatterTemplate.cs b/src/MessagePack.Generator/Transforms/FormatterTemplate.cs index 0c8a8940f..54a8d4b97 100644 --- a/src/MessagePack.Generator/Transforms/FormatterTemplate.cs +++ b/src/MessagePack.Generator/Transforms/FormatterTemplate.cs @@ -25,21 +25,7 @@ public partial class FormatterTemplate : FormatterTemplateBase /// public virtual string TransformText() { - this.Write(@"// - -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 168 -#pragma warning disable CS1591 // document public APIs - -#pragma warning disable SA1129 // Do not use default value type constructor -#pragma warning disable SA1309 // Field names should not begin with underscore -#pragma warning disable SA1312 // Variable names should begin with lower-case letter -#pragma warning disable SA1403 // File may only contain a single namespace -#pragma warning disable SA1649 // File name should match first type name - -namespace "); + this.Write("\r\nnamespace "); this.Write(this.ToStringHelper.ToStringWithCulture(Namespace)); this.Write("\r\n{\r\n"); foreach (var objInfo in ObjectSerializationInfos) { @@ -205,19 +191,7 @@ namespace "); } this.Write(" }\r\n }\r\n\r\n"); } - this.Write(@"} - -#pragma warning restore 168 -#pragma warning restore 414 -#pragma warning restore 618 -#pragma warning restore 612 - -#pragma warning restore SA1129 // Do not use default value type constructor -#pragma warning restore SA1309 // Field names should not begin with underscore -#pragma warning restore SA1312 // Variable names should begin with lower-case letter -#pragma warning restore SA1403 // File may only contain a single namespace -#pragma warning restore SA1649 // File name should match first type name -"); + this.Write("}\r\n"); return this.GenerationEnvironment.ToString(); } } diff --git a/src/MessagePack.Generator/Transforms/FormatterTemplate.tt b/src/MessagePack.Generator/Transforms/FormatterTemplate.tt index adbd7faa1..c823e3edf 100644 --- a/src/MessagePack.Generator/Transforms/FormatterTemplate.tt +++ b/src/MessagePack.Generator/Transforms/FormatterTemplate.tt @@ -3,19 +3,6 @@ <#@ import namespace="System.Linq" #> <#@ import namespace="System.Text" #> <#@ import namespace="System.Collections.Generic" #> -// - -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 168 -#pragma warning disable CS1591 // document public APIs - -#pragma warning disable SA1129 // Do not use default value type constructor -#pragma warning disable SA1309 // Field names should not begin with underscore -#pragma warning disable SA1312 // Variable names should begin with lower-case letter -#pragma warning disable SA1403 // File may only contain a single namespace -#pragma warning disable SA1649 // File name should match first type name namespace <#= Namespace #> { @@ -152,14 +139,3 @@ namespace <#= Namespace #> } <# } #>} - -#pragma warning restore 168 -#pragma warning restore 414 -#pragma warning restore 618 -#pragma warning restore 612 - -#pragma warning restore SA1129 // Do not use default value type constructor -#pragma warning restore SA1309 // Field names should not begin with underscore -#pragma warning restore SA1312 // Variable names should begin with lower-case letter -#pragma warning restore SA1403 // File may only contain a single namespace -#pragma warning restore SA1649 // File name should match first type name diff --git a/src/MessagePack.Generator/Transforms/ResolverTemplate.cs b/src/MessagePack.Generator/Transforms/ResolverTemplate.cs index f817bdd8f..380839526 100644 --- a/src/MessagePack.Generator/Transforms/ResolverTemplate.cs +++ b/src/MessagePack.Generator/Transforms/ResolverTemplate.cs @@ -25,19 +25,8 @@ public partial class ResolverTemplate : ResolverTemplateBase /// public virtual string TransformText() { - this.Write(@"// - -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 168 -#pragma warning disable CS1591 // document public APIs - -#pragma warning disable SA1312 // Variable names should begin with lower-case letter -#pragma warning disable SA1649 // File name should match first type name - -namespace "); - this.Write(this.ToStringHelper.ToStringWithCulture(Namespace)); + this.Write("\r\nnamespace "); + this.Write(this.ToStringHelper.ToStringWithCulture(ResolverNamespace)); this.Write("\r\n{\r\n public class "); this.Write(this.ToStringHelper.ToStringWithCulture(ResolverName)); this.Write(" : global::MessagePack.IFormatterResolver\r\n {\r\n public static readonly " + @@ -78,9 +67,9 @@ internal static class "); this.Write(this.ToStringHelper.ToStringWithCulture(ResolverName)); this.Write("GetFormatterHelper()\r\n {\r\n lookup = new global::System.Collecti" + "ons.Generic.Dictionary("); - this.Write(this.ToStringHelper.ToStringWithCulture(RegisterInfos.Length)); + this.Write(this.ToStringHelper.ToStringWithCulture(RegisterInfos.Count)); this.Write(")\r\n {\r\n"); - for(var i = 0; i < RegisterInfos.Length; i++) { var x = RegisterInfos[i]; + for(var i = 0; i < RegisterInfos.Count; i++) { var x = RegisterInfos[i]; this.Write(" { typeof("); this.Write(this.ToStringHelper.ToStringWithCulture(x.FullName)); this.Write("), "); @@ -101,27 +90,14 @@ internal static object GetFormatter(global::System.Type t) switch (key) { "); - for(var i = 0; i < RegisterInfos.Length; i++) { var x = RegisterInfos[i]; + for(var i = 0; i < RegisterInfos.Count; i++) { var x = RegisterInfos[i]; this.Write(" case "); this.Write(this.ToStringHelper.ToStringWithCulture(i)); this.Write(": return new "); - this.Write(this.ToStringHelper.ToStringWithCulture(x.FormatterName.StartsWith("global::") ? x.FormatterName: (!string.IsNullOrEmpty(FormatterNamespace) ? FormatterNamespace + "." : FormatterNamespace) + x.FormatterName)); + this.Write(this.ToStringHelper.ToStringWithCulture(x.FormatterName.StartsWith("global::") ? x.FormatterName : (FormatterNamespace + "." + x.FormatterName))); this.Write("();\r\n"); } - this.Write(@" default: return null; - } - } - } -} - -#pragma warning restore 168 -#pragma warning restore 414 -#pragma warning restore 618 -#pragma warning restore 612 - -#pragma warning restore SA1312 // Variable names should begin with lower-case letter -#pragma warning restore SA1649 // File name should match first type name -"); + this.Write(" default: return null;\r\n }\r\n }\r\n }\r\n}\r\n"); return this.GenerationEnvironment.ToString(); } } diff --git a/src/MessagePack.Generator/Transforms/ResolverTemplate.tt b/src/MessagePack.Generator/Transforms/ResolverTemplate.tt index f634c97d8..d553524d2 100644 --- a/src/MessagePack.Generator/Transforms/ResolverTemplate.tt +++ b/src/MessagePack.Generator/Transforms/ResolverTemplate.tt @@ -3,18 +3,8 @@ <#@ import namespace="System.Linq" #> <#@ import namespace="System.Text" #> <#@ import namespace="System.Collections.Generic" #> -// -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 168 -#pragma warning disable CS1591 // document public APIs - -#pragma warning disable SA1312 // Variable names should begin with lower-case letter -#pragma warning disable SA1649 // File name should match first type name - -namespace <#= Namespace #> +namespace <#= ResolverNamespace #> { public class <#= ResolverName #> : global::MessagePack.IFormatterResolver { @@ -50,9 +40,9 @@ namespace <#= Namespace #> static <#= ResolverName #>GetFormatterHelper() { - lookup = new global::System.Collections.Generic.Dictionary(<#= RegisterInfos.Length #>) + lookup = new global::System.Collections.Generic.Dictionary(<#= RegisterInfos.Count #>) { -<# for(var i = 0; i < RegisterInfos.Length; i++) { var x = RegisterInfos[i]; #> +<# for(var i = 0; i < RegisterInfos.Count; i++) { var x = RegisterInfos[i]; #> { typeof(<#= x.FullName #>), <#= i #> }, <# } #> }; @@ -68,19 +58,11 @@ namespace <#= Namespace #> switch (key) { -<# for(var i = 0; i < RegisterInfos.Length; i++) { var x = RegisterInfos[i]; #> - case <#= i #>: return new <#= x.FormatterName.StartsWith("global::") ? x.FormatterName: (!string.IsNullOrEmpty(FormatterNamespace) ? FormatterNamespace + "." : FormatterNamespace) + x.FormatterName #>(); +<# for(var i = 0; i < RegisterInfos.Count; i++) { var x = RegisterInfos[i]; #> + case <#= i #>: return new <#= x.FormatterName.StartsWith("global::") ? x.FormatterName : (FormatterNamespace + "." + x.FormatterName) #>(); <# } #> default: return null; } } } } - -#pragma warning restore 168 -#pragma warning restore 414 -#pragma warning restore 618 -#pragma warning restore 612 - -#pragma warning restore SA1312 // Variable names should begin with lower-case letter -#pragma warning restore SA1649 // File name should match first type name diff --git a/src/MessagePack.Generator/Transforms/TemplatePartials.cs b/src/MessagePack.Generator/Transforms/TemplatePartials.cs index a401eb7bd..680da18fc 100644 --- a/src/MessagePack.Generator/Transforms/TemplatePartials.cs +++ b/src/MessagePack.Generator/Transforms/TemplatePartials.cs @@ -35,21 +35,21 @@ public StringKeyFormatterTemplate(string @namespace, ObjectSerializationInfo[] o public partial class ResolverTemplate { - public ResolverTemplate(string @namespace, string formatterNamespace, string resolverName, IResolverRegisterInfo[] registerInfos) + public ResolverTemplate(string resolverNamespace, string formatterNamespace, string resolverName, IReadOnlyList registerInfos) { - Namespace = @namespace; + ResolverNamespace = resolverNamespace; FormatterNamespace = formatterNamespace; ResolverName = resolverName; RegisterInfos = registerInfos; } - public string Namespace { get; } + public string ResolverNamespace { get; } public string FormatterNamespace { get; } public string ResolverName { get; } - public IResolverRegisterInfo[] RegisterInfos { get; } + public IReadOnlyList RegisterInfos { get; } } public partial class EnumTemplate diff --git a/src/MessagePack.Generator/Transforms/UnionTemplate.cs b/src/MessagePack.Generator/Transforms/UnionTemplate.cs index 027cfeb57..d19631dfb 100644 --- a/src/MessagePack.Generator/Transforms/UnionTemplate.cs +++ b/src/MessagePack.Generator/Transforms/UnionTemplate.cs @@ -25,18 +25,7 @@ public partial class UnionTemplate : UnionTemplateBase /// public virtual string TransformText() { - this.Write(@"// - -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 168 -#pragma warning disable CS1591 // document public APIs - -#pragma warning disable SA1403 // File may only contain a single namespace -#pragma warning disable SA1649 // File name should match first type name - -namespace "); + this.Write("\r\nnamespace "); this.Write(this.ToStringHelper.ToStringWithCulture(Namespace)); this.Write("\r\n{\r\n"); foreach(var info in UnionSerializationInfos) { @@ -135,17 +124,7 @@ namespace "); " break;\r\n }\r\n\r\n reader.Depth--;\r\n return result" + ";\r\n }\r\n }\r\n\r\n"); } - this.Write(@" -} - -#pragma warning restore 168 -#pragma warning restore 414 -#pragma warning restore 618 -#pragma warning restore 612 - -#pragma warning restore SA1403 // File may only contain a single namespace -#pragma warning restore SA1649 // File name should match first type name -"); + this.Write("\r\n}\r\n"); return this.GenerationEnvironment.ToString(); } } diff --git a/src/MessagePack.Generator/Transforms/UnionTemplate.tt b/src/MessagePack.Generator/Transforms/UnionTemplate.tt index 5bebcc7dd..9c805d1ee 100644 --- a/src/MessagePack.Generator/Transforms/UnionTemplate.tt +++ b/src/MessagePack.Generator/Transforms/UnionTemplate.tt @@ -3,16 +3,6 @@ <#@ import namespace="System.Linq" #> <#@ import namespace="System.Text" #> <#@ import namespace="System.Collections.Generic" #> -// - -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 168 -#pragma warning disable CS1591 // document public APIs - -#pragma warning disable SA1403 // File may only contain a single namespace -#pragma warning disable SA1649 // File name should match first type name namespace <#= Namespace #> { @@ -103,11 +93,3 @@ namespace <#= Namespace #> <# } #> } - -#pragma warning restore 168 -#pragma warning restore 414 -#pragma warning restore 618 -#pragma warning restore 612 - -#pragma warning restore SA1403 // File may only contain a single namespace -#pragma warning restore SA1649 // File name should match first type name diff --git a/src/MessagePack.Generator/build/MessagePack.Generator.props b/src/MessagePack.Generator/build/MessagePack.Generator.props new file mode 100644 index 000000000..25d918e23 --- /dev/null +++ b/src/MessagePack.Generator/build/MessagePack.Generator.props @@ -0,0 +1,13 @@ + + + MessagePack + GeneratedResolver + false + + + + + + + + \ No newline at end of file diff --git a/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Resolvers/StaticCompositeResolver.cs b/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Resolvers/StaticCompositeResolver.cs index ad64044a6..cbe767e1d 100644 --- a/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Resolvers/StaticCompositeResolver.cs +++ b/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Resolvers/StaticCompositeResolver.cs @@ -15,7 +15,7 @@ public class StaticCompositeResolver : IFormatterResolver { public static readonly StaticCompositeResolver Instance = new StaticCompositeResolver(); - private bool freezed; + private bool frozen; private ConcurrentBag generatedFormatters = new ConcurrentBag(); private IReadOnlyList formatters; private IReadOnlyList resolvers; @@ -37,7 +37,7 @@ private StaticCompositeResolver() /// public void Register(params IMessagePackFormatter[] formatters) { - if (this.freezed) + if (this.frozen) { throw new InvalidOperationException("Register must call on startup(before use GetFormatter)."); } @@ -62,7 +62,7 @@ public void Register(params IMessagePackFormatter[] formatters) /// public void Register(params IFormatterResolver[] resolvers) { - if (this.freezed) + if (this.frozen) { throw new InvalidOperationException("Register must call on startup(before use GetFormatter)."); } @@ -91,7 +91,7 @@ public void Register(params IFormatterResolver[] resolvers) /// public void Register(IReadOnlyList formatters, IReadOnlyList resolvers) { - if (this.freezed) + if (this.frozen) { throw new InvalidOperationException("Register must call on startup(before use GetFormatter)."); } @@ -112,7 +112,7 @@ public void Register(IReadOnlyList formatters, IReadOnlyL public void AddGeneratedFormatter(IMessagePackFormatter formatter) { - if (this.freezed) + if (this.frozen) { throw new InvalidOperationException("Register must call on startup(before use GetFormatter)."); } @@ -136,7 +136,7 @@ private static class Cache static Cache() { - Instance.freezed = true; + Instance.frozen = true; foreach (var item in Instance.generatedFormatters) { if (item is IMessagePackFormatter f) diff --git a/src/MessagePack.UnityClient/Assets/Scripts/Tests/Generated/GeneratedResolver.cs b/src/MessagePack.UnityClient/Assets/Scripts/Tests/Generated/GeneratedResolver.cs deleted file mode 100644 index b82cb9e18..000000000 --- a/src/MessagePack.UnityClient/Assets/Scripts/Tests/Generated/GeneratedResolver.cs +++ /dev/null @@ -1,5761 +0,0 @@ -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 168 - -#pragma warning disable SA1200 // Using directives should be placed correctly -#pragma warning disable SA1312 // Variable names should begin with lower-case letter -#pragma warning disable SA1649 // File name should match first type name - -namespace MessagePack.Resolvers -{ - using System; - using System.Buffers; - using MessagePack; - - public class GeneratedResolver : global::MessagePack.IFormatterResolver - { - public static readonly global::MessagePack.IFormatterResolver Instance = new GeneratedResolver(); - - private GeneratedResolver() - { - } - - public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() - { - return FormatterCache.Formatter; - } - - private static class FormatterCache - { - internal static readonly global::MessagePack.Formatters.IMessagePackFormatter Formatter; - - static FormatterCache() - { - var f = GeneratedResolverGetFormatterHelper.GetFormatter(typeof(T)); - if (f != null) - { - Formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; - } - } - } - } - - internal static class GeneratedResolverGetFormatterHelper - { - private static readonly global::System.Collections.Generic.Dictionary lookup; - - static GeneratedResolverGetFormatterHelper() - { - lookup = new global::System.Collections.Generic.Dictionary(88) - { - { typeof(int[,]), 0 }, - { typeof(global::GlobalMyEnum[,]), 1 }, - { typeof(int[,,]), 2 }, - { typeof(int[,,,]), 3 }, - { typeof(global::GlobalMyEnum[]), 4 }, - { typeof(global::QuestMessageBody[]), 5 }, - { typeof(global::System.Collections.Generic.IDictionary), 6 }, - { typeof(global::System.Collections.Generic.IList), 7 }, - { typeof(global::ComplexdUnion.A[]), 8 }, - { typeof(global::ComplexdUnion.A2[]), 9 }, - { typeof(global::SharedData.ByteEnum), 10 }, - { typeof(global::GlobalMyEnum), 11 }, - { typeof(global::SharedData.IUnionChecker), 12 }, - { typeof(global::SharedData.IUnionChecker2), 13 }, - { typeof(global::SharedData.IIVersioningUnion), 14 }, - { typeof(global::SharedData.RootUnionType), 15 }, - { typeof(global::SharedData.IUnionSample), 16 }, - { typeof(global::IMessageBody), 17 }, - { typeof(global::MessagePack.Tests.DynamicObjectResolverOrderTest.AbstractBase), 18 }, - { typeof(global::ComplexdUnion.A), 19 }, - { typeof(global::ComplexdUnion.A2), 20 }, - { typeof(global::ClassUnion.RootUnionType), 21 }, - { typeof(global::SharedData.FirstSimpleData), 22 }, - { typeof(global::SharedData.SimpleStringKeyData), 23 }, - { typeof(global::SharedData.SimpleStructIntKeyData), 24 }, - { typeof(global::SharedData.SimpleStructStringKeyData), 25 }, - { typeof(global::SharedData.SimpleIntKeyData), 26 }, - { typeof(global::SharedData.Vector2), 27 }, - { typeof(global::SharedData.EmptyClass), 28 }, - { typeof(global::SharedData.EmptyStruct), 29 }, - { typeof(global::SharedData.Version1), 30 }, - { typeof(global::SharedData.Version2), 31 }, - { typeof(global::SharedData.Version0), 32 }, - { typeof(global::SharedData.HolderV1), 33 }, - { typeof(global::SharedData.HolderV2), 34 }, - { typeof(global::SharedData.HolderV0), 35 }, - { typeof(global::SharedData.Callback1), 36 }, - { typeof(global::SharedData.Callback1_2), 37 }, - { typeof(global::SharedData.Callback2), 38 }, - { typeof(global::SharedData.Callback2_2), 39 }, - { typeof(global::SharedData.SubUnionType1), 40 }, - { typeof(global::SharedData.SubUnionType2), 41 }, - { typeof(global::SharedData.MySubUnion1), 42 }, - { typeof(global::SharedData.MySubUnion2), 43 }, - { typeof(global::SharedData.MySubUnion3), 44 }, - { typeof(global::SharedData.MySubUnion4), 45 }, - { typeof(global::SharedData.VersioningUnion), 46 }, - { typeof(global::SharedData.MyClass), 47 }, - { typeof(global::SharedData.VersionBlockTest), 48 }, - { typeof(global::SharedData.UnVersionBlockTest), 49 }, - { typeof(global::SharedData.Empty1), 50 }, - { typeof(global::SharedData.Empty2), 51 }, - { typeof(global::SharedData.NonEmpty1), 52 }, - { typeof(global::SharedData.NonEmpty2), 53 }, - { typeof(global::SharedData.VectorLike2), 54 }, - { typeof(global::SharedData.Vector3Like), 55 }, - { typeof(global::SharedData.ArrayOptimizeClass), 56 }, - { typeof(global::SharedData.NestParent.NestContract), 57 }, - { typeof(global::SharedData.FooClass), 58 }, - { typeof(global::SharedData.BarClass), 59 }, - { typeof(global::SharedData.WithIndexer), 60 }, - { typeof(global::Abcdefg.Efcdigjl.Ateatatea.Hgfagfafgad.TnonodsfarnoiuAtatqaga), 61 }, - { typeof(global::GlobalMan), 62 }, - { typeof(global::Message), 63 }, - { typeof(global::TextMessageBody), 64 }, - { typeof(global::StampMessageBody), 65 }, - { typeof(global::QuestMessageBody), 66 }, - { typeof(global::ArrayTestTest), 67 }, - { typeof(global::SimpleModel), 68 }, - { typeof(global::ComplexModel), 69 }, - { typeof(global::PerfBenchmarkDotNet.StringKeySerializerTarget), 70 }, - { typeof(global::MessagePack.Tests.DynamicObjectResolverConstructorTest.TestConstructor1), 71 }, - { typeof(global::MessagePack.Tests.DynamicObjectResolverConstructorTest.TestConstructor2), 72 }, - { typeof(global::MessagePack.Tests.DynamicObjectResolverConstructorTest.TestConstructor3), 73 }, - { typeof(global::MessagePack.Tests.DynamicObjectResolverOrderTest.OrderOrder), 74 }, - { typeof(global::MessagePack.Tests.IgnoreTest.ViewModel), 75 }, - { typeof(global::MessagePack.Tests.MessagePackFormatterPerFieldTest.MyClass), 76 }, - { typeof(global::MessagePack.Tests.MessagePackFormatterPerFieldTest.MyStruct), 77 }, - { typeof(global::MessagePack.Tests.NewGuidFormatterTest.InClass), 78 }, - { typeof(global::MessagePack.Tests.Foo), 79 }, - { typeof(global::MessagePack.Tests.PrimitivelikeFormatterTest.MyDateTimeResolverTest), 80 }, - { typeof(global::ComplexdUnion.DummyForGenerate), 81 }, - { typeof(global::ComplexdUnion.B), 82 }, - { typeof(global::ComplexdUnion.C), 83 }, - { typeof(global::ComplexdUnion.B2), 84 }, - { typeof(global::ComplexdUnion.C2), 85 }, - { typeof(global::ClassUnion.SubUnionType1), 86 }, - { typeof(global::ClassUnion.SubUnionType2), 87 }, - }; - } - - internal static object GetFormatter(Type t) - { - int key; - if (!lookup.TryGetValue(t, out key)) - { - return null; - } - - switch (key) - { - case 0: return new global::MessagePack.Formatters.TwoDimensionalArrayFormatter(); - case 1: return new global::MessagePack.Formatters.TwoDimensionalArrayFormatter(); - case 2: return new global::MessagePack.Formatters.ThreeDimensionalArrayFormatter(); - case 3: return new global::MessagePack.Formatters.FourDimensionalArrayFormatter(); - case 4: return new global::MessagePack.Formatters.ArrayFormatter(); - case 5: return new global::MessagePack.Formatters.ArrayFormatter(); - case 6: return new global::MessagePack.Formatters.InterfaceDictionaryFormatter(); - case 7: return new global::MessagePack.Formatters.InterfaceListFormatter(); - case 8: return new global::MessagePack.Formatters.ArrayFormatter(); - case 9: return new global::MessagePack.Formatters.ArrayFormatter(); - case 10: return new MessagePack.Formatters.SharedData.ByteEnumFormatter(); - case 11: return new MessagePack.Formatters.GlobalMyEnumFormatter(); - case 12: return new MessagePack.Formatters.SharedData.IUnionCheckerFormatter(); - case 13: return new MessagePack.Formatters.SharedData.IUnionChecker2Formatter(); - case 14: return new MessagePack.Formatters.SharedData.IIVersioningUnionFormatter(); - case 15: return new MessagePack.Formatters.SharedData.RootUnionTypeFormatter(); - case 16: return new MessagePack.Formatters.SharedData.IUnionSampleFormatter(); - case 17: return new MessagePack.Formatters.IMessageBodyFormatter(); - case 18: return new MessagePack.Formatters.MessagePack.Tests.AbstractBaseFormatter(); - case 19: return new MessagePack.Formatters.ComplexdUnion.AFormatter(); - case 20: return new MessagePack.Formatters.ComplexdUnion.A2Formatter(); - case 21: return new MessagePack.Formatters.ClassUnion.RootUnionTypeFormatter(); - case 22: return new MessagePack.Formatters.SharedData.FirstSimpleDataFormatter(); - case 23: return new MessagePack.Formatters.SharedData.SimpleStringKeyDataFormatter(); - case 24: return new MessagePack.Formatters.SharedData.SimpleStructIntKeyDataFormatter(); - case 25: return new MessagePack.Formatters.SharedData.SimpleStructStringKeyDataFormatter(); - case 26: return new MessagePack.Formatters.SharedData.SimpleIntKeyDataFormatter(); - case 27: return new MessagePack.Formatters.SharedData.Vector2Formatter(); - case 28: return new MessagePack.Formatters.SharedData.EmptyClassFormatter(); - case 29: return new MessagePack.Formatters.SharedData.EmptyStructFormatter(); - case 30: return new MessagePack.Formatters.SharedData.Version1Formatter(); - case 31: return new MessagePack.Formatters.SharedData.Version2Formatter(); - case 32: return new MessagePack.Formatters.SharedData.Version0Formatter(); - case 33: return new MessagePack.Formatters.SharedData.HolderV1Formatter(); - case 34: return new MessagePack.Formatters.SharedData.HolderV2Formatter(); - case 35: return new MessagePack.Formatters.SharedData.HolderV0Formatter(); - case 36: return new MessagePack.Formatters.SharedData.Callback1Formatter(); - case 37: return new MessagePack.Formatters.SharedData.Callback1_2Formatter(); - case 38: return new MessagePack.Formatters.SharedData.Callback2Formatter(); - case 39: return new MessagePack.Formatters.SharedData.Callback2_2Formatter(); - case 40: return new MessagePack.Formatters.SharedData.SubUnionType1Formatter(); - case 41: return new MessagePack.Formatters.SharedData.SubUnionType2Formatter(); - case 42: return new MessagePack.Formatters.SharedData.MySubUnion1Formatter(); - case 43: return new MessagePack.Formatters.SharedData.MySubUnion2Formatter(); - case 44: return new MessagePack.Formatters.SharedData.MySubUnion3Formatter(); - case 45: return new MessagePack.Formatters.SharedData.MySubUnion4Formatter(); - case 46: return new MessagePack.Formatters.SharedData.VersioningUnionFormatter(); - case 47: return new MessagePack.Formatters.SharedData.MyClassFormatter(); - case 48: return new MessagePack.Formatters.SharedData.VersionBlockTestFormatter(); - case 49: return new MessagePack.Formatters.SharedData.UnVersionBlockTestFormatter(); - case 50: return new MessagePack.Formatters.SharedData.Empty1Formatter(); - case 51: return new MessagePack.Formatters.SharedData.Empty2Formatter(); - case 52: return new MessagePack.Formatters.SharedData.NonEmpty1Formatter(); - case 53: return new MessagePack.Formatters.SharedData.NonEmpty2Formatter(); - case 54: return new MessagePack.Formatters.SharedData.VectorLike2Formatter(); - case 55: return new MessagePack.Formatters.SharedData.Vector3LikeFormatter(); - case 56: return new MessagePack.Formatters.SharedData.ArrayOptimizeClassFormatter(); - case 57: return new MessagePack.Formatters.SharedData.NestParent_NestContractFormatter(); - case 58: return new MessagePack.Formatters.SharedData.FooClassFormatter(); - case 59: return new MessagePack.Formatters.SharedData.BarClassFormatter(); - case 60: return new MessagePack.Formatters.SharedData.WithIndexerFormatter(); - case 61: return new MessagePack.Formatters.Abcdefg.Efcdigjl.Ateatatea.Hgfagfafgad.TnonodsfarnoiuAtatqagaFormatter(); - case 62: return new MessagePack.Formatters.GlobalManFormatter(); - case 63: return new MessagePack.Formatters.MessageFormatter(); - case 64: return new MessagePack.Formatters.TextMessageBodyFormatter(); - case 65: return new MessagePack.Formatters.StampMessageBodyFormatter(); - case 66: return new MessagePack.Formatters.QuestMessageBodyFormatter(); - case 67: return new MessagePack.Formatters.ArrayTestTestFormatter(); - case 68: return new MessagePack.Formatters.SimpleModelFormatter(); - case 69: return new MessagePack.Formatters.ComplexModelFormatter(); - case 70: return new MessagePack.Formatters.PerfBenchmarkDotNet.StringKeySerializerTargetFormatter(); - case 71: return new MessagePack.Formatters.MessagePack.Tests.DynamicObjectResolverConstructorTest_TestConstructor1Formatter(); - case 72: return new MessagePack.Formatters.MessagePack.Tests.DynamicObjectResolverConstructorTest_TestConstructor2Formatter(); - case 73: return new MessagePack.Formatters.MessagePack.Tests.DynamicObjectResolverConstructorTest_TestConstructor3Formatter(); - case 74: return new MessagePack.Formatters.MessagePack.Tests.DynamicObjectResolverOrderTest_OrderOrderFormatter(); - case 75: return new MessagePack.Formatters.MessagePack.Tests.IgnoreTest_ViewModelFormatter(); - case 76: return new MessagePack.Formatters.MessagePack.Tests.MessagePackFormatterPerFieldTest_MyClassFormatter(); - case 77: return new MessagePack.Formatters.MessagePack.Tests.MessagePackFormatterPerFieldTest_MyStructFormatter(); - case 78: return new MessagePack.Formatters.MessagePack.Tests.NewGuidFormatterTest_InClassFormatter(); - case 79: return new MessagePack.Formatters.MessagePack.Tests.FooFormatter(); - case 80: return new MessagePack.Formatters.MessagePack.Tests.PrimitivelikeFormatterTest_MyDateTimeResolverTestFormatter(); - case 81: return new MessagePack.Formatters.ComplexdUnion.DummyForGenerateFormatter(); - case 82: return new MessagePack.Formatters.ComplexdUnion.BFormatter(); - case 83: return new MessagePack.Formatters.ComplexdUnion.CFormatter(); - case 84: return new MessagePack.Formatters.ComplexdUnion.B2Formatter(); - case 85: return new MessagePack.Formatters.ComplexdUnion.C2Formatter(); - case 86: return new MessagePack.Formatters.ClassUnion.SubUnionType1Formatter(); - case 87: return new MessagePack.Formatters.ClassUnion.SubUnionType2Formatter(); - default: return null; - } - } - } -} - -#pragma warning restore 168 -#pragma warning restore 414 -#pragma warning restore 618 -#pragma warning restore 612 - -#pragma warning restore SA1312 // Variable names should begin with lower-case letter -#pragma warning restore SA1200 // Using directives should be placed correctly -#pragma warning restore SA1649 // File name should match first type name - - -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 168 - -#pragma warning disable SA1200 // Using directives should be placed correctly -#pragma warning disable SA1403 // File may only contain a single namespace -#pragma warning disable SA1649 // File name should match first type name - -namespace MessagePack.Formatters.SharedData -{ - using System; - using System.Buffers; - using MessagePack; - - public sealed class ByteEnumFormatter : global::MessagePack.Formatters.IMessagePackFormatter - { - public void Serialize(ref MessagePackWriter writer, global::SharedData.ByteEnum value, global::MessagePack.MessagePackSerializerOptions options) - { - writer.Write((Byte)value); - } - - public global::SharedData.ByteEnum Deserialize(ref MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - return (global::SharedData.ByteEnum)reader.ReadByte(); - } - } -} - -#pragma warning restore 168 -#pragma warning restore 414 -#pragma warning restore 618 -#pragma warning restore 612 - -#pragma warning restore SA1200 // Using directives should be placed correctly -#pragma warning restore SA1403 // File may only contain a single namespace -#pragma warning restore SA1649 // File name should match first type name - -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 168 - -#pragma warning disable SA1200 // Using directives should be placed correctly -#pragma warning disable SA1403 // File may only contain a single namespace -#pragma warning disable SA1649 // File name should match first type name - -namespace MessagePack.Formatters -{ - using System; - using System.Buffers; - using MessagePack; - - public sealed class GlobalMyEnumFormatter : global::MessagePack.Formatters.IMessagePackFormatter - { - public void Serialize(ref MessagePackWriter writer, global::GlobalMyEnum value, global::MessagePack.MessagePackSerializerOptions options) - { - writer.Write((Int32)value); - } - - public global::GlobalMyEnum Deserialize(ref MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - return (global::GlobalMyEnum)reader.ReadInt32(); - } - } -} - -#pragma warning restore 168 -#pragma warning restore 414 -#pragma warning restore 618 -#pragma warning restore 612 - -#pragma warning restore SA1200 // Using directives should be placed correctly -#pragma warning restore SA1403 // File may only contain a single namespace -#pragma warning restore SA1649 // File name should match first type name - - -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 168 - -#pragma warning disable SA1200 // Using directives should be placed correctly -#pragma warning disable SA1403 // File may only contain a single namespace -#pragma warning disable SA1649 // File name should match first type name - -namespace MessagePack.Formatters.SharedData -{ - using System; - using System.Buffers; - using System.Collections.Generic; - using MessagePack; - - public sealed class IUnionCheckerFormatter : global::MessagePack.Formatters.IMessagePackFormatter - { - private readonly Dictionary> typeToKeyAndJumpMap; - private readonly Dictionary keyToJumpMap; - - public IUnionCheckerFormatter() - { - this.typeToKeyAndJumpMap = new Dictionary>(4, global::MessagePack.Internal.RuntimeTypeHandleEqualityComparer.Default) - { - { typeof(global::SharedData.MySubUnion1).TypeHandle, new KeyValuePair(0, 0) }, - { typeof(global::SharedData.MySubUnion2).TypeHandle, new KeyValuePair(1, 1) }, - { typeof(global::SharedData.MySubUnion3).TypeHandle, new KeyValuePair(2, 2) }, - { typeof(global::SharedData.MySubUnion4).TypeHandle, new KeyValuePair(3, 3) }, - }; - this.keyToJumpMap = new Dictionary(4) - { - { 0, 0 }, - { 1, 1 }, - { 2, 2 }, - { 3, 3 }, - }; - } - - public void Serialize(ref MessagePackWriter writer, global::SharedData.IUnionChecker value, global::MessagePack.MessagePackSerializerOptions options) - { - KeyValuePair keyValuePair; - if (value != null && this.typeToKeyAndJumpMap.TryGetValue(value.GetType().TypeHandle, out keyValuePair)) - { - writer.WriteArrayHeader(2); - writer.WriteInt32(keyValuePair.Key); - switch (keyValuePair.Value) - { - case 0: - options.Resolver.GetFormatterWithVerify().Serialize(ref writer, (global::SharedData.MySubUnion1)value, options); - break; - case 1: - options.Resolver.GetFormatterWithVerify().Serialize(ref writer, (global::SharedData.MySubUnion2)value, options); - break; - case 2: - options.Resolver.GetFormatterWithVerify().Serialize(ref writer, (global::SharedData.MySubUnion3)value, options); - break; - case 3: - options.Resolver.GetFormatterWithVerify().Serialize(ref writer, (global::SharedData.MySubUnion4)value, options); - break; - default: - break; - } - - return; - } - - writer.WriteNil(); - } - - public global::SharedData.IUnionChecker Deserialize(ref MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - if (reader.TryReadNil()) - { - return null; - } - - if (reader.ReadArrayHeader() != 2) - { - throw new InvalidOperationException("Invalid Union data was detected. Type:global::SharedData.IUnionChecker"); - } - - var key = reader.ReadInt32(); - - if (!this.keyToJumpMap.TryGetValue(key, out key)) - { - key = -1; - } - - global::SharedData.IUnionChecker result = null; - switch (key) - { - case 0: - result = (global::SharedData.IUnionChecker)options.Resolver.GetFormatterWithVerify().Deserialize(ref reader, options); - break; - case 1: - result = (global::SharedData.IUnionChecker)options.Resolver.GetFormatterWithVerify().Deserialize(ref reader, options); - break; - case 2: - result = (global::SharedData.IUnionChecker)options.Resolver.GetFormatterWithVerify().Deserialize(ref reader, options); - break; - case 3: - result = (global::SharedData.IUnionChecker)options.Resolver.GetFormatterWithVerify().Deserialize(ref reader, options); - break; - default: - reader.Skip(); - break; - } - - return result; - } - } - - public sealed class IUnionChecker2Formatter : global::MessagePack.Formatters.IMessagePackFormatter - { - private readonly Dictionary> typeToKeyAndJumpMap; - private readonly Dictionary keyToJumpMap; - - public IUnionChecker2Formatter() - { - this.typeToKeyAndJumpMap = new Dictionary>(4, global::MessagePack.Internal.RuntimeTypeHandleEqualityComparer.Default) - { - { typeof(global::SharedData.MySubUnion2).TypeHandle, new KeyValuePair(31, 0) }, - { typeof(global::SharedData.MySubUnion3).TypeHandle, new KeyValuePair(42, 1) }, - { typeof(global::SharedData.MySubUnion4).TypeHandle, new KeyValuePair(63, 2) }, - { typeof(global::SharedData.MySubUnion1).TypeHandle, new KeyValuePair(120, 3) }, - }; - this.keyToJumpMap = new Dictionary(4) - { - { 31, 0 }, - { 42, 1 }, - { 63, 2 }, - { 120, 3 }, - }; - } - - public void Serialize(ref MessagePackWriter writer, global::SharedData.IUnionChecker2 value, global::MessagePack.MessagePackSerializerOptions options) - { - KeyValuePair keyValuePair; - if (value != null && this.typeToKeyAndJumpMap.TryGetValue(value.GetType().TypeHandle, out keyValuePair)) - { - writer.WriteArrayHeader(2); - writer.WriteInt32(keyValuePair.Key); - switch (keyValuePair.Value) - { - case 0: - options.Resolver.GetFormatterWithVerify().Serialize(ref writer, (global::SharedData.MySubUnion2)value, options); - break; - case 1: - options.Resolver.GetFormatterWithVerify().Serialize(ref writer, (global::SharedData.MySubUnion3)value, options); - break; - case 2: - options.Resolver.GetFormatterWithVerify().Serialize(ref writer, (global::SharedData.MySubUnion4)value, options); - break; - case 3: - options.Resolver.GetFormatterWithVerify().Serialize(ref writer, (global::SharedData.MySubUnion1)value, options); - break; - default: - break; - } - - return; - } - - writer.WriteNil(); - } - - public global::SharedData.IUnionChecker2 Deserialize(ref MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - if (reader.TryReadNil()) - { - return null; - } - - if (reader.ReadArrayHeader() != 2) - { - throw new InvalidOperationException("Invalid Union data was detected. Type:global::SharedData.IUnionChecker2"); - } - - var key = reader.ReadInt32(); - - if (!this.keyToJumpMap.TryGetValue(key, out key)) - { - key = -1; - } - - global::SharedData.IUnionChecker2 result = null; - switch (key) - { - case 0: - result = (global::SharedData.IUnionChecker2)options.Resolver.GetFormatterWithVerify().Deserialize(ref reader, options); - break; - case 1: - result = (global::SharedData.IUnionChecker2)options.Resolver.GetFormatterWithVerify().Deserialize(ref reader, options); - break; - case 2: - result = (global::SharedData.IUnionChecker2)options.Resolver.GetFormatterWithVerify().Deserialize(ref reader, options); - break; - case 3: - result = (global::SharedData.IUnionChecker2)options.Resolver.GetFormatterWithVerify().Deserialize(ref reader, options); - break; - default: - reader.Skip(); - break; - } - - return result; - } - } - - public sealed class IIVersioningUnionFormatter : global::MessagePack.Formatters.IMessagePackFormatter - { - private readonly Dictionary> typeToKeyAndJumpMap; - private readonly Dictionary keyToJumpMap; - - public IIVersioningUnionFormatter() - { - this.typeToKeyAndJumpMap = new Dictionary>(1, global::MessagePack.Internal.RuntimeTypeHandleEqualityComparer.Default) - { - { typeof(global::SharedData.MySubUnion1).TypeHandle, new KeyValuePair(0, 0) }, - }; - this.keyToJumpMap = new Dictionary(1) - { - { 0, 0 }, - }; - } - - public void Serialize(ref MessagePackWriter writer, global::SharedData.IIVersioningUnion value, global::MessagePack.MessagePackSerializerOptions options) - { - KeyValuePair keyValuePair; - if (value != null && this.typeToKeyAndJumpMap.TryGetValue(value.GetType().TypeHandle, out keyValuePair)) - { - writer.WriteArrayHeader(2); - writer.WriteInt32(keyValuePair.Key); - switch (keyValuePair.Value) - { - case 0: - options.Resolver.GetFormatterWithVerify().Serialize(ref writer, (global::SharedData.MySubUnion1)value, options); - break; - default: - break; - } - - return; - } - - writer.WriteNil(); - } - - public global::SharedData.IIVersioningUnion Deserialize(ref MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - if (reader.TryReadNil()) - { - return null; - } - - if (reader.ReadArrayHeader() != 2) - { - throw new InvalidOperationException("Invalid Union data was detected. Type:global::SharedData.IIVersioningUnion"); - } - - var key = reader.ReadInt32(); - - if (!this.keyToJumpMap.TryGetValue(key, out key)) - { - key = -1; - } - - global::SharedData.IIVersioningUnion result = null; - switch (key) - { - case 0: - result = (global::SharedData.IIVersioningUnion)options.Resolver.GetFormatterWithVerify().Deserialize(ref reader, options); - break; - default: - reader.Skip(); - break; - } - - return result; - } - } - - public sealed class RootUnionTypeFormatter : global::MessagePack.Formatters.IMessagePackFormatter - { - private readonly Dictionary> typeToKeyAndJumpMap; - private readonly Dictionary keyToJumpMap; - - public RootUnionTypeFormatter() - { - this.typeToKeyAndJumpMap = new Dictionary>(2, global::MessagePack.Internal.RuntimeTypeHandleEqualityComparer.Default) - { - { typeof(global::SharedData.SubUnionType1).TypeHandle, new KeyValuePair(0, 0) }, - { typeof(global::SharedData.SubUnionType2).TypeHandle, new KeyValuePair(1, 1) }, - }; - this.keyToJumpMap = new Dictionary(2) - { - { 0, 0 }, - { 1, 1 }, - }; - } - - public void Serialize(ref MessagePackWriter writer, global::SharedData.RootUnionType value, global::MessagePack.MessagePackSerializerOptions options) - { - KeyValuePair keyValuePair; - if (value != null && this.typeToKeyAndJumpMap.TryGetValue(value.GetType().TypeHandle, out keyValuePair)) - { - writer.WriteArrayHeader(2); - writer.WriteInt32(keyValuePair.Key); - switch (keyValuePair.Value) - { - case 0: - options.Resolver.GetFormatterWithVerify().Serialize(ref writer, (global::SharedData.SubUnionType1)value, options); - break; - case 1: - options.Resolver.GetFormatterWithVerify().Serialize(ref writer, (global::SharedData.SubUnionType2)value, options); - break; - default: - break; - } - - return; - } - - writer.WriteNil(); - } - - public global::SharedData.RootUnionType Deserialize(ref MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - if (reader.TryReadNil()) - { - return null; - } - - if (reader.ReadArrayHeader() != 2) - { - throw new InvalidOperationException("Invalid Union data was detected. Type:global::SharedData.RootUnionType"); - } - - var key = reader.ReadInt32(); - - if (!this.keyToJumpMap.TryGetValue(key, out key)) - { - key = -1; - } - - global::SharedData.RootUnionType result = null; - switch (key) - { - case 0: - result = (global::SharedData.RootUnionType)options.Resolver.GetFormatterWithVerify().Deserialize(ref reader, options); - break; - case 1: - result = (global::SharedData.RootUnionType)options.Resolver.GetFormatterWithVerify().Deserialize(ref reader, options); - break; - default: - reader.Skip(); - break; - } - - return result; - } - } - - public sealed class IUnionSampleFormatter : global::MessagePack.Formatters.IMessagePackFormatter - { - private readonly Dictionary> typeToKeyAndJumpMap; - private readonly Dictionary keyToJumpMap; - - public IUnionSampleFormatter() - { - this.typeToKeyAndJumpMap = new Dictionary>(2, global::MessagePack.Internal.RuntimeTypeHandleEqualityComparer.Default) - { - { typeof(global::SharedData.FooClass).TypeHandle, new KeyValuePair(0, 0) }, - { typeof(global::SharedData.BarClass).TypeHandle, new KeyValuePair(100, 1) }, - }; - this.keyToJumpMap = new Dictionary(2) - { - { 0, 0 }, - { 100, 1 }, - }; - } - - public void Serialize(ref MessagePackWriter writer, global::SharedData.IUnionSample value, global::MessagePack.MessagePackSerializerOptions options) - { - KeyValuePair keyValuePair; - if (value != null && this.typeToKeyAndJumpMap.TryGetValue(value.GetType().TypeHandle, out keyValuePair)) - { - writer.WriteArrayHeader(2); - writer.WriteInt32(keyValuePair.Key); - switch (keyValuePair.Value) - { - case 0: - options.Resolver.GetFormatterWithVerify().Serialize(ref writer, (global::SharedData.FooClass)value, options); - break; - case 1: - options.Resolver.GetFormatterWithVerify().Serialize(ref writer, (global::SharedData.BarClass)value, options); - break; - default: - break; - } - - return; - } - - writer.WriteNil(); - } - - public global::SharedData.IUnionSample Deserialize(ref MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - if (reader.TryReadNil()) - { - return null; - } - - if (reader.ReadArrayHeader() != 2) - { - throw new InvalidOperationException("Invalid Union data was detected. Type:global::SharedData.IUnionSample"); - } - - var key = reader.ReadInt32(); - - if (!this.keyToJumpMap.TryGetValue(key, out key)) - { - key = -1; - } - - global::SharedData.IUnionSample result = null; - switch (key) - { - case 0: - result = (global::SharedData.IUnionSample)options.Resolver.GetFormatterWithVerify().Deserialize(ref reader, options); - break; - case 1: - result = (global::SharedData.IUnionSample)options.Resolver.GetFormatterWithVerify().Deserialize(ref reader, options); - break; - default: - reader.Skip(); - break; - } - - return result; - } - } - - -} - -#pragma warning restore 168 -#pragma warning restore 414 -#pragma warning restore 618 -#pragma warning restore 612 - -#pragma warning restore SA1200 // Using directives should be placed correctly -#pragma warning restore SA1403 // File may only contain a single namespace -#pragma warning restore SA1649 // File name should match first type name - -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 168 - -#pragma warning disable SA1200 // Using directives should be placed correctly -#pragma warning disable SA1403 // File may only contain a single namespace -#pragma warning disable SA1649 // File name should match first type name - -namespace MessagePack.Formatters -{ - using System; - using System.Buffers; - using System.Collections.Generic; - using MessagePack; - - public sealed class IMessageBodyFormatter : global::MessagePack.Formatters.IMessagePackFormatter - { - private readonly Dictionary> typeToKeyAndJumpMap; - private readonly Dictionary keyToJumpMap; - - public IMessageBodyFormatter() - { - this.typeToKeyAndJumpMap = new Dictionary>(3, global::MessagePack.Internal.RuntimeTypeHandleEqualityComparer.Default) - { - { typeof(global::TextMessageBody).TypeHandle, new KeyValuePair(10, 0) }, - { typeof(global::StampMessageBody).TypeHandle, new KeyValuePair(14, 1) }, - { typeof(global::QuestMessageBody).TypeHandle, new KeyValuePair(25, 2) }, - }; - this.keyToJumpMap = new Dictionary(3) - { - { 10, 0 }, - { 14, 1 }, - { 25, 2 }, - }; - } - - public void Serialize(ref MessagePackWriter writer, global::IMessageBody value, global::MessagePack.MessagePackSerializerOptions options) - { - KeyValuePair keyValuePair; - if (value != null && this.typeToKeyAndJumpMap.TryGetValue(value.GetType().TypeHandle, out keyValuePair)) - { - writer.WriteArrayHeader(2); - writer.WriteInt32(keyValuePair.Key); - switch (keyValuePair.Value) - { - case 0: - options.Resolver.GetFormatterWithVerify().Serialize(ref writer, (global::TextMessageBody)value, options); - break; - case 1: - options.Resolver.GetFormatterWithVerify().Serialize(ref writer, (global::StampMessageBody)value, options); - break; - case 2: - options.Resolver.GetFormatterWithVerify().Serialize(ref writer, (global::QuestMessageBody)value, options); - break; - default: - break; - } - - return; - } - - writer.WriteNil(); - } - - public global::IMessageBody Deserialize(ref MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - if (reader.TryReadNil()) - { - return null; - } - - if (reader.ReadArrayHeader() != 2) - { - throw new InvalidOperationException("Invalid Union data was detected. Type:global::IMessageBody"); - } - - var key = reader.ReadInt32(); - - if (!this.keyToJumpMap.TryGetValue(key, out key)) - { - key = -1; - } - - global::IMessageBody result = null; - switch (key) - { - case 0: - result = (global::IMessageBody)options.Resolver.GetFormatterWithVerify().Deserialize(ref reader, options); - break; - case 1: - result = (global::IMessageBody)options.Resolver.GetFormatterWithVerify().Deserialize(ref reader, options); - break; - case 2: - result = (global::IMessageBody)options.Resolver.GetFormatterWithVerify().Deserialize(ref reader, options); - break; - default: - reader.Skip(); - break; - } - - return result; - } - } - - -} - -#pragma warning restore 168 -#pragma warning restore 414 -#pragma warning restore 618 -#pragma warning restore 612 - -#pragma warning restore SA1200 // Using directives should be placed correctly -#pragma warning restore SA1403 // File may only contain a single namespace -#pragma warning restore SA1649 // File name should match first type name - -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 168 - -#pragma warning disable SA1200 // Using directives should be placed correctly -#pragma warning disable SA1403 // File may only contain a single namespace -#pragma warning disable SA1649 // File name should match first type name - -namespace MessagePack.Formatters.MessagePack.Tests -{ - using System; - using System.Buffers; - using System.Collections.Generic; - using MessagePack; - - public sealed class AbstractBaseFormatter : global::MessagePack.Formatters.IMessagePackFormatter - { - private readonly Dictionary> typeToKeyAndJumpMap; - private readonly Dictionary keyToJumpMap; - - public AbstractBaseFormatter() - { - this.typeToKeyAndJumpMap = new Dictionary>(1, global::MessagePack.Internal.RuntimeTypeHandleEqualityComparer.Default) - { - { typeof(global::MessagePack.Tests.DynamicObjectResolverOrderTest.RealClass).TypeHandle, new KeyValuePair(0, 0) }, - }; - this.keyToJumpMap = new Dictionary(1) - { - { 0, 0 }, - }; - } - - public void Serialize(ref MessagePackWriter writer, global::MessagePack.Tests.DynamicObjectResolverOrderTest.AbstractBase value, global::MessagePack.MessagePackSerializerOptions options) - { - KeyValuePair keyValuePair; - if (value != null && this.typeToKeyAndJumpMap.TryGetValue(value.GetType().TypeHandle, out keyValuePair)) - { - writer.WriteArrayHeader(2); - writer.WriteInt32(keyValuePair.Key); - switch (keyValuePair.Value) - { - case 0: - options.Resolver.GetFormatterWithVerify().Serialize(ref writer, (global::MessagePack.Tests.DynamicObjectResolverOrderTest.RealClass)value, options); - break; - default: - break; - } - - return; - } - - writer.WriteNil(); - } - - public global::MessagePack.Tests.DynamicObjectResolverOrderTest.AbstractBase Deserialize(ref MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - if (reader.TryReadNil()) - { - return null; - } - - if (reader.ReadArrayHeader() != 2) - { - throw new InvalidOperationException("Invalid Union data was detected. Type:global::MessagePack.Tests.DynamicObjectResolverOrderTest.AbstractBase"); - } - - var key = reader.ReadInt32(); - - if (!this.keyToJumpMap.TryGetValue(key, out key)) - { - key = -1; - } - - global::MessagePack.Tests.DynamicObjectResolverOrderTest.AbstractBase result = null; - switch (key) - { - case 0: - result = (global::MessagePack.Tests.DynamicObjectResolverOrderTest.AbstractBase)options.Resolver.GetFormatterWithVerify().Deserialize(ref reader, options); - break; - default: - reader.Skip(); - break; - } - - return result; - } - } - - -} - -#pragma warning restore 168 -#pragma warning restore 414 -#pragma warning restore 618 -#pragma warning restore 612 - -#pragma warning restore SA1200 // Using directives should be placed correctly -#pragma warning restore SA1403 // File may only contain a single namespace -#pragma warning restore SA1649 // File name should match first type name - -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 168 - -#pragma warning disable SA1200 // Using directives should be placed correctly -#pragma warning disable SA1403 // File may only contain a single namespace -#pragma warning disable SA1649 // File name should match first type name - -namespace MessagePack.Formatters.ComplexdUnion -{ - using System; - using System.Buffers; - using System.Collections.Generic; - using MessagePack; - - public sealed class AFormatter : global::MessagePack.Formatters.IMessagePackFormatter - { - private readonly Dictionary> typeToKeyAndJumpMap; - private readonly Dictionary keyToJumpMap; - - public AFormatter() - { - this.typeToKeyAndJumpMap = new Dictionary>(2, global::MessagePack.Internal.RuntimeTypeHandleEqualityComparer.Default) - { - { typeof(global::ComplexdUnion.B).TypeHandle, new KeyValuePair(0, 0) }, - { typeof(global::ComplexdUnion.C).TypeHandle, new KeyValuePair(1, 1) }, - }; - this.keyToJumpMap = new Dictionary(2) - { - { 0, 0 }, - { 1, 1 }, - }; - } - - public void Serialize(ref MessagePackWriter writer, global::ComplexdUnion.A value, global::MessagePack.MessagePackSerializerOptions options) - { - KeyValuePair keyValuePair; - if (value != null && this.typeToKeyAndJumpMap.TryGetValue(value.GetType().TypeHandle, out keyValuePair)) - { - writer.WriteArrayHeader(2); - writer.WriteInt32(keyValuePair.Key); - switch (keyValuePair.Value) - { - case 0: - options.Resolver.GetFormatterWithVerify().Serialize(ref writer, (global::ComplexdUnion.B)value, options); - break; - case 1: - options.Resolver.GetFormatterWithVerify().Serialize(ref writer, (global::ComplexdUnion.C)value, options); - break; - default: - break; - } - - return; - } - - writer.WriteNil(); - } - - public global::ComplexdUnion.A Deserialize(ref MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - if (reader.TryReadNil()) - { - return null; - } - - if (reader.ReadArrayHeader() != 2) - { - throw new InvalidOperationException("Invalid Union data was detected. Type:global::ComplexdUnion.A"); - } - - var key = reader.ReadInt32(); - - if (!this.keyToJumpMap.TryGetValue(key, out key)) - { - key = -1; - } - - global::ComplexdUnion.A result = null; - switch (key) - { - case 0: - result = (global::ComplexdUnion.A)options.Resolver.GetFormatterWithVerify().Deserialize(ref reader, options); - break; - case 1: - result = (global::ComplexdUnion.A)options.Resolver.GetFormatterWithVerify().Deserialize(ref reader, options); - break; - default: - reader.Skip(); - break; - } - - return result; - } - } - - public sealed class A2Formatter : global::MessagePack.Formatters.IMessagePackFormatter - { - private readonly Dictionary> typeToKeyAndJumpMap; - private readonly Dictionary keyToJumpMap; - - public A2Formatter() - { - this.typeToKeyAndJumpMap = new Dictionary>(2, global::MessagePack.Internal.RuntimeTypeHandleEqualityComparer.Default) - { - { typeof(global::ComplexdUnion.B2).TypeHandle, new KeyValuePair(0, 0) }, - { typeof(global::ComplexdUnion.C2).TypeHandle, new KeyValuePair(1, 1) }, - }; - this.keyToJumpMap = new Dictionary(2) - { - { 0, 0 }, - { 1, 1 }, - }; - } - - public void Serialize(ref MessagePackWriter writer, global::ComplexdUnion.A2 value, global::MessagePack.MessagePackSerializerOptions options) - { - KeyValuePair keyValuePair; - if (value != null && this.typeToKeyAndJumpMap.TryGetValue(value.GetType().TypeHandle, out keyValuePair)) - { - writer.WriteArrayHeader(2); - writer.WriteInt32(keyValuePair.Key); - switch (keyValuePair.Value) - { - case 0: - options.Resolver.GetFormatterWithVerify().Serialize(ref writer, (global::ComplexdUnion.B2)value, options); - break; - case 1: - options.Resolver.GetFormatterWithVerify().Serialize(ref writer, (global::ComplexdUnion.C2)value, options); - break; - default: - break; - } - - return; - } - - writer.WriteNil(); - } - - public global::ComplexdUnion.A2 Deserialize(ref MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - if (reader.TryReadNil()) - { - return null; - } - - if (reader.ReadArrayHeader() != 2) - { - throw new InvalidOperationException("Invalid Union data was detected. Type:global::ComplexdUnion.A2"); - } - - var key = reader.ReadInt32(); - - if (!this.keyToJumpMap.TryGetValue(key, out key)) - { - key = -1; - } - - global::ComplexdUnion.A2 result = null; - switch (key) - { - case 0: - result = (global::ComplexdUnion.A2)options.Resolver.GetFormatterWithVerify().Deserialize(ref reader, options); - break; - case 1: - result = (global::ComplexdUnion.A2)options.Resolver.GetFormatterWithVerify().Deserialize(ref reader, options); - break; - default: - reader.Skip(); - break; - } - - return result; - } - } - - -} - -#pragma warning restore 168 -#pragma warning restore 414 -#pragma warning restore 618 -#pragma warning restore 612 - -#pragma warning restore SA1200 // Using directives should be placed correctly -#pragma warning restore SA1403 // File may only contain a single namespace -#pragma warning restore SA1649 // File name should match first type name - -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 168 - -#pragma warning disable SA1200 // Using directives should be placed correctly -#pragma warning disable SA1403 // File may only contain a single namespace -#pragma warning disable SA1649 // File name should match first type name - -namespace MessagePack.Formatters.ClassUnion -{ - using System; - using System.Buffers; - using System.Collections.Generic; - using MessagePack; - - public sealed class RootUnionTypeFormatter : global::MessagePack.Formatters.IMessagePackFormatter - { - private readonly Dictionary> typeToKeyAndJumpMap; - private readonly Dictionary keyToJumpMap; - - public RootUnionTypeFormatter() - { - this.typeToKeyAndJumpMap = new Dictionary>(2, global::MessagePack.Internal.RuntimeTypeHandleEqualityComparer.Default) - { - { typeof(global::ClassUnion.SubUnionType1).TypeHandle, new KeyValuePair(0, 0) }, - { typeof(global::ClassUnion.SubUnionType2).TypeHandle, new KeyValuePair(1, 1) }, - }; - this.keyToJumpMap = new Dictionary(2) - { - { 0, 0 }, - { 1, 1 }, - }; - } - - public void Serialize(ref MessagePackWriter writer, global::ClassUnion.RootUnionType value, global::MessagePack.MessagePackSerializerOptions options) - { - KeyValuePair keyValuePair; - if (value != null && this.typeToKeyAndJumpMap.TryGetValue(value.GetType().TypeHandle, out keyValuePair)) - { - writer.WriteArrayHeader(2); - writer.WriteInt32(keyValuePair.Key); - switch (keyValuePair.Value) - { - case 0: - options.Resolver.GetFormatterWithVerify().Serialize(ref writer, (global::ClassUnion.SubUnionType1)value, options); - break; - case 1: - options.Resolver.GetFormatterWithVerify().Serialize(ref writer, (global::ClassUnion.SubUnionType2)value, options); - break; - default: - break; - } - - return; - } - - writer.WriteNil(); - } - - public global::ClassUnion.RootUnionType Deserialize(ref MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - if (reader.TryReadNil()) - { - return null; - } - - if (reader.ReadArrayHeader() != 2) - { - throw new InvalidOperationException("Invalid Union data was detected. Type:global::ClassUnion.RootUnionType"); - } - - var key = reader.ReadInt32(); - - if (!this.keyToJumpMap.TryGetValue(key, out key)) - { - key = -1; - } - - global::ClassUnion.RootUnionType result = null; - switch (key) - { - case 0: - result = (global::ClassUnion.RootUnionType)options.Resolver.GetFormatterWithVerify().Deserialize(ref reader, options); - break; - case 1: - result = (global::ClassUnion.RootUnionType)options.Resolver.GetFormatterWithVerify().Deserialize(ref reader, options); - break; - default: - reader.Skip(); - break; - } - - return result; - } - } - - -} - -#pragma warning restore 168 -#pragma warning restore 414 -#pragma warning restore 618 -#pragma warning restore 612 - -#pragma warning restore SA1200 // Using directives should be placed correctly -#pragma warning restore SA1403 // File may only contain a single namespace -#pragma warning restore SA1649 // File name should match first type name - - -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 168 - -#pragma warning disable SA1129 // Do not use default value type constructor -#pragma warning disable SA1200 // Using directives should be placed correctly -#pragma warning disable SA1309 // Field names should not begin with underscore -#pragma warning disable SA1312 // Variable names should begin with lower-case letter -#pragma warning disable SA1403 // File may only contain a single namespace -#pragma warning disable SA1649 // File name should match first type name - -namespace MessagePack.Formatters.SharedData -{ - using System; - using System.Buffers; - using MessagePack; - - public sealed class FirstSimpleDataFormatter : global::MessagePack.Formatters.IMessagePackFormatter - { - - - public void Serialize(ref MessagePackWriter writer, global::SharedData.FirstSimpleData value, global::MessagePack.MessagePackSerializerOptions options) - { - if (value == null) - { - writer.WriteNil(); - return; - } - - IFormatterResolver formatterResolver = options.Resolver; - writer.WriteArrayHeader(3); - writer.Write(value.Prop1); - formatterResolver.GetFormatterWithVerify().Serialize(ref writer, value.Prop2, options); - writer.Write(value.Prop3); - } - - public global::SharedData.FirstSimpleData Deserialize(ref MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - if (reader.TryReadNil()) - { - return null; - } - - IFormatterResolver formatterResolver = options.Resolver; - var length = reader.ReadArrayHeader(); - var __Prop1__ = default(int); - var __Prop2__ = default(string); - var __Prop3__ = default(int); - - for (int i = 0; i < length; i++) - { - var key = i; - - switch (key) - { - case 0: - __Prop1__ = reader.ReadInt32(); - break; - case 1: - __Prop2__ = formatterResolver.GetFormatterWithVerify().Deserialize(ref reader, options); - break; - case 2: - __Prop3__ = reader.ReadInt32(); - break; - default: - reader.Skip(); - break; - } - } - - var ____result = new global::SharedData.FirstSimpleData(); - ____result.Prop1 = __Prop1__; - ____result.Prop2 = __Prop2__; - ____result.Prop3 = __Prop3__; - return ____result; - } - } - - public sealed class SimpleStringKeyDataFormatter : global::MessagePack.Formatters.IMessagePackFormatter - { - - - private readonly global::MessagePack.Internal.AutomataDictionary ____keyMapping; - private readonly byte[][] ____stringByteKeys; - - public SimpleStringKeyDataFormatter() - { - this.____keyMapping = new global::MessagePack.Internal.AutomataDictionary() - { - { "Prop1", 0 }, - { "Prop2", 1 }, - { "Prop3", 2 }, - }; - - this.____stringByteKeys = new byte[][] - { - global::MessagePack.Internal.CodeGenHelpers.GetEncodedStringBytes("Prop1"), - global::MessagePack.Internal.CodeGenHelpers.GetEncodedStringBytes("Prop2"), - global::MessagePack.Internal.CodeGenHelpers.GetEncodedStringBytes("Prop3"), - }; - } - - public void Serialize(ref MessagePackWriter writer, global::SharedData.SimpleStringKeyData value, global::MessagePack.MessagePackSerializerOptions options) - { - if (value == null) - { - writer.WriteNil(); - return; - } - - IFormatterResolver formatterResolver = options.Resolver; - writer.WriteMapHeader(3); - writer.WriteRaw(this.____stringByteKeys[0]); - writer.Write(value.Prop1); - writer.WriteRaw(this.____stringByteKeys[1]); - formatterResolver.GetFormatterWithVerify().Serialize(ref writer, value.Prop2, options); - writer.WriteRaw(this.____stringByteKeys[2]); - writer.Write(value.Prop3); - } - - public global::SharedData.SimpleStringKeyData Deserialize(ref MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - if (reader.TryReadNil()) - { - return null; - } - - IFormatterResolver formatterResolver = options.Resolver; - var length = reader.ReadMapHeader(); - var __Prop1__ = default(int); - var __Prop2__ = default(global::SharedData.ByteEnum); - var __Prop3__ = default(int); - - for (int i = 0; i < length; i++) - { - ReadOnlySequence stringKey = reader.ReadStringSequence().Value; - int key; - if (!this.____keyMapping.TryGetValue(stringKey, out key)) - { - reader.Skip(); - continue; - } - - switch (key) - { - case 0: - __Prop1__ = reader.ReadInt32(); - break; - case 1: - __Prop2__ = formatterResolver.GetFormatterWithVerify().Deserialize(ref reader, options); - break; - case 2: - __Prop3__ = reader.ReadInt32(); - break; - default: - reader.Skip(); - break; - } - } - - var ____result = new global::SharedData.SimpleStringKeyData(); - ____result.Prop1 = __Prop1__; - ____result.Prop2 = __Prop2__; - ____result.Prop3 = __Prop3__; - return ____result; - } - } - - public sealed class SimpleStructIntKeyDataFormatter : global::MessagePack.Formatters.IMessagePackFormatter - { - - - public void Serialize(ref MessagePackWriter writer, global::SharedData.SimpleStructIntKeyData value, global::MessagePack.MessagePackSerializerOptions options) - { - IFormatterResolver formatterResolver = options.Resolver; - writer.WriteArrayHeader(3); - writer.Write(value.X); - writer.Write(value.Y); - formatterResolver.GetFormatterWithVerify().Serialize(ref writer, value.BytesSpecial, options); - } - - public global::SharedData.SimpleStructIntKeyData Deserialize(ref MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - if (reader.TryReadNil()) - { - throw new InvalidOperationException("typecode is null, struct not supported"); - } - - IFormatterResolver formatterResolver = options.Resolver; - var length = reader.ReadArrayHeader(); - var __X__ = default(int); - var __Y__ = default(int); - var __BytesSpecial__ = default(byte[]); - - for (int i = 0; i < length; i++) - { - var key = i; - - switch (key) - { - case 0: - __X__ = reader.ReadInt32(); - break; - case 1: - __Y__ = reader.ReadInt32(); - break; - case 2: - __BytesSpecial__ = formatterResolver.GetFormatterWithVerify().Deserialize(ref reader, options); - break; - default: - reader.Skip(); - break; - } - } - - var ____result = new global::SharedData.SimpleStructIntKeyData(); - ____result.X = __X__; - ____result.Y = __Y__; - ____result.BytesSpecial = __BytesSpecial__; - return ____result; - } - } - - public sealed class SimpleStructStringKeyDataFormatter : global::MessagePack.Formatters.IMessagePackFormatter - { - - - private readonly global::MessagePack.Internal.AutomataDictionary ____keyMapping; - private readonly byte[][] ____stringByteKeys; - - public SimpleStructStringKeyDataFormatter() - { - this.____keyMapping = new global::MessagePack.Internal.AutomataDictionary() - { - { "key-X", 0 }, - { "key-Y", 1 }, - }; - - this.____stringByteKeys = new byte[][] - { - global::MessagePack.Internal.CodeGenHelpers.GetEncodedStringBytes("key-X"), - global::MessagePack.Internal.CodeGenHelpers.GetEncodedStringBytes("key-Y"), - }; - } - - public void Serialize(ref MessagePackWriter writer, global::SharedData.SimpleStructStringKeyData value, global::MessagePack.MessagePackSerializerOptions options) - { - IFormatterResolver formatterResolver = options.Resolver; - writer.WriteMapHeader(2); - writer.WriteRaw(this.____stringByteKeys[0]); - writer.Write(value.X); - writer.WriteRaw(this.____stringByteKeys[1]); - formatterResolver.GetFormatterWithVerify().Serialize(ref writer, value.Y, options); - } - - public global::SharedData.SimpleStructStringKeyData Deserialize(ref MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - if (reader.TryReadNil()) - { - throw new InvalidOperationException("typecode is null, struct not supported"); - } - - IFormatterResolver formatterResolver = options.Resolver; - var length = reader.ReadMapHeader(); - var __X__ = default(int); - var __Y__ = default(int[]); - - for (int i = 0; i < length; i++) - { - ReadOnlySequence stringKey = reader.ReadStringSequence().Value; - int key; - if (!this.____keyMapping.TryGetValue(stringKey, out key)) - { - reader.Skip(); - continue; - } - - switch (key) - { - case 0: - __X__ = reader.ReadInt32(); - break; - case 1: - __Y__ = formatterResolver.GetFormatterWithVerify().Deserialize(ref reader, options); - break; - default: - reader.Skip(); - break; - } - } - - var ____result = new global::SharedData.SimpleStructStringKeyData(); - ____result.X = __X__; - ____result.Y = __Y__; - return ____result; - } - } - - public sealed class SimpleIntKeyDataFormatter : global::MessagePack.Formatters.IMessagePackFormatter - { - - - public void Serialize(ref MessagePackWriter writer, global::SharedData.SimpleIntKeyData value, global::MessagePack.MessagePackSerializerOptions options) - { - if (value == null) - { - writer.WriteNil(); - return; - } - - IFormatterResolver formatterResolver = options.Resolver; - writer.WriteArrayHeader(7); - writer.Write(value.Prop1); - formatterResolver.GetFormatterWithVerify().Serialize(ref writer, value.Prop2, options); - formatterResolver.GetFormatterWithVerify().Serialize(ref writer, value.Prop3, options); - formatterResolver.GetFormatterWithVerify().Serialize(ref writer, value.Prop4, options); - formatterResolver.GetFormatterWithVerify().Serialize(ref writer, value.Prop5, options); - formatterResolver.GetFormatterWithVerify().Serialize(ref writer, value.Prop6, options); - formatterResolver.GetFormatterWithVerify().Serialize(ref writer, value.BytesSpecial, options); - } - - public global::SharedData.SimpleIntKeyData Deserialize(ref MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - if (reader.TryReadNil()) - { - return null; - } - - IFormatterResolver formatterResolver = options.Resolver; - var length = reader.ReadArrayHeader(); - var __Prop1__ = default(int); - var __Prop2__ = default(global::SharedData.ByteEnum); - var __Prop3__ = default(string); - var __Prop4__ = default(global::SharedData.SimpleStringKeyData); - var __Prop5__ = default(global::SharedData.SimpleStructIntKeyData); - var __Prop6__ = default(global::SharedData.SimpleStructStringKeyData); - var __BytesSpecial__ = default(byte[]); - - for (int i = 0; i < length; i++) - { - var key = i; - - switch (key) - { - case 0: - __Prop1__ = reader.ReadInt32(); - break; - case 1: - __Prop2__ = formatterResolver.GetFormatterWithVerify().Deserialize(ref reader, options); - break; - case 2: - __Prop3__ = formatterResolver.GetFormatterWithVerify().Deserialize(ref reader, options); - break; - case 3: - __Prop4__ = formatterResolver.GetFormatterWithVerify().Deserialize(ref reader, options); - break; - case 4: - __Prop5__ = formatterResolver.GetFormatterWithVerify().Deserialize(ref reader, options); - break; - case 5: - __Prop6__ = formatterResolver.GetFormatterWithVerify().Deserialize(ref reader, options); - break; - case 6: - __BytesSpecial__ = formatterResolver.GetFormatterWithVerify().Deserialize(ref reader, options); - break; - default: - reader.Skip(); - break; - } - } - - var ____result = new global::SharedData.SimpleIntKeyData(); - ____result.Prop1 = __Prop1__; - ____result.Prop2 = __Prop2__; - ____result.Prop3 = __Prop3__; - ____result.Prop4 = __Prop4__; - ____result.Prop5 = __Prop5__; - ____result.Prop6 = __Prop6__; - ____result.BytesSpecial = __BytesSpecial__; - return ____result; - } - } - - public sealed class Vector2Formatter : global::MessagePack.Formatters.IMessagePackFormatter - { - - - public void Serialize(ref MessagePackWriter writer, global::SharedData.Vector2 value, global::MessagePack.MessagePackSerializerOptions options) - { - IFormatterResolver formatterResolver = options.Resolver; - writer.WriteArrayHeader(2); - writer.Write(value.X); - writer.Write(value.Y); - } - - public global::SharedData.Vector2 Deserialize(ref MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - if (reader.TryReadNil()) - { - throw new InvalidOperationException("typecode is null, struct not supported"); - } - - IFormatterResolver formatterResolver = options.Resolver; - var length = reader.ReadArrayHeader(); - var __X__ = default(float); - var __Y__ = default(float); - - for (int i = 0; i < length; i++) - { - var key = i; - - switch (key) - { - case 0: - __X__ = reader.ReadSingle(); - break; - case 1: - __Y__ = reader.ReadSingle(); - break; - default: - reader.Skip(); - break; - } - } - - var ____result = new global::SharedData.Vector2(__X__, __Y__); - return ____result; - } - } - - public sealed class EmptyClassFormatter : global::MessagePack.Formatters.IMessagePackFormatter - { - - - public void Serialize(ref MessagePackWriter writer, global::SharedData.EmptyClass value, global::MessagePack.MessagePackSerializerOptions options) - { - if (value == null) - { - writer.WriteNil(); - return; - } - - IFormatterResolver formatterResolver = options.Resolver; - writer.WriteArrayHeader(0); - } - - public global::SharedData.EmptyClass Deserialize(ref MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - if (reader.TryReadNil()) - { - return null; - } - - IFormatterResolver formatterResolver = options.Resolver; - var length = reader.ReadArrayHeader(); - - for (int i = 0; i < length; i++) - { - var key = i; - - switch (key) - { - default: - reader.Skip(); - break; - } - } - - var ____result = new global::SharedData.EmptyClass(); - return ____result; - } - } - - public sealed class EmptyStructFormatter : global::MessagePack.Formatters.IMessagePackFormatter - { - - - public void Serialize(ref MessagePackWriter writer, global::SharedData.EmptyStruct value, global::MessagePack.MessagePackSerializerOptions options) - { - IFormatterResolver formatterResolver = options.Resolver; - writer.WriteArrayHeader(0); - } - - public global::SharedData.EmptyStruct Deserialize(ref MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - if (reader.TryReadNil()) - { - throw new InvalidOperationException("typecode is null, struct not supported"); - } - - IFormatterResolver formatterResolver = options.Resolver; - var length = reader.ReadArrayHeader(); - - for (int i = 0; i < length; i++) - { - var key = i; - - switch (key) - { - default: - reader.Skip(); - break; - } - } - - var ____result = new global::SharedData.EmptyStruct(); - return ____result; - } - } - - public sealed class Version1Formatter : global::MessagePack.Formatters.IMessagePackFormatter - { - - - public void Serialize(ref MessagePackWriter writer, global::SharedData.Version1 value, global::MessagePack.MessagePackSerializerOptions options) - { - if (value == null) - { - writer.WriteNil(); - return; - } - - IFormatterResolver formatterResolver = options.Resolver; - writer.WriteArrayHeader(6); - writer.WriteNil(); - writer.WriteNil(); - writer.WriteNil(); - writer.Write(value.MyProperty1); - writer.Write(value.MyProperty2); - writer.Write(value.MyProperty3); - } - - public global::SharedData.Version1 Deserialize(ref MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - if (reader.TryReadNil()) - { - return null; - } - - IFormatterResolver formatterResolver = options.Resolver; - var length = reader.ReadArrayHeader(); - var __MyProperty1__ = default(int); - var __MyProperty2__ = default(int); - var __MyProperty3__ = default(int); - - for (int i = 0; i < length; i++) - { - var key = i; - - switch (key) - { - case 3: - __MyProperty1__ = reader.ReadInt32(); - break; - case 4: - __MyProperty2__ = reader.ReadInt32(); - break; - case 5: - __MyProperty3__ = reader.ReadInt32(); - break; - default: - reader.Skip(); - break; - } - } - - var ____result = new global::SharedData.Version1(); - ____result.MyProperty1 = __MyProperty1__; - ____result.MyProperty2 = __MyProperty2__; - ____result.MyProperty3 = __MyProperty3__; - return ____result; - } - } - - public sealed class Version2Formatter : global::MessagePack.Formatters.IMessagePackFormatter - { - - - public void Serialize(ref MessagePackWriter writer, global::SharedData.Version2 value, global::MessagePack.MessagePackSerializerOptions options) - { - if (value == null) - { - writer.WriteNil(); - return; - } - - IFormatterResolver formatterResolver = options.Resolver; - writer.WriteArrayHeader(8); - writer.WriteNil(); - writer.WriteNil(); - writer.WriteNil(); - writer.Write(value.MyProperty1); - writer.Write(value.MyProperty2); - writer.Write(value.MyProperty3); - writer.WriteNil(); - writer.Write(value.MyProperty5); - } - - public global::SharedData.Version2 Deserialize(ref MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - if (reader.TryReadNil()) - { - return null; - } - - IFormatterResolver formatterResolver = options.Resolver; - var length = reader.ReadArrayHeader(); - var __MyProperty1__ = default(int); - var __MyProperty2__ = default(int); - var __MyProperty3__ = default(int); - var __MyProperty5__ = default(int); - - for (int i = 0; i < length; i++) - { - var key = i; - - switch (key) - { - case 3: - __MyProperty1__ = reader.ReadInt32(); - break; - case 4: - __MyProperty2__ = reader.ReadInt32(); - break; - case 5: - __MyProperty3__ = reader.ReadInt32(); - break; - case 7: - __MyProperty5__ = reader.ReadInt32(); - break; - default: - reader.Skip(); - break; - } - } - - var ____result = new global::SharedData.Version2(); - ____result.MyProperty1 = __MyProperty1__; - ____result.MyProperty2 = __MyProperty2__; - ____result.MyProperty3 = __MyProperty3__; - ____result.MyProperty5 = __MyProperty5__; - return ____result; - } - } - - public sealed class Version0Formatter : global::MessagePack.Formatters.IMessagePackFormatter - { - - - public void Serialize(ref MessagePackWriter writer, global::SharedData.Version0 value, global::MessagePack.MessagePackSerializerOptions options) - { - if (value == null) - { - writer.WriteNil(); - return; - } - - IFormatterResolver formatterResolver = options.Resolver; - writer.WriteArrayHeader(4); - writer.WriteNil(); - writer.WriteNil(); - writer.WriteNil(); - writer.Write(value.MyProperty1); - } - - public global::SharedData.Version0 Deserialize(ref MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - if (reader.TryReadNil()) - { - return null; - } - - IFormatterResolver formatterResolver = options.Resolver; - var length = reader.ReadArrayHeader(); - var __MyProperty1__ = default(int); - - for (int i = 0; i < length; i++) - { - var key = i; - - switch (key) - { - case 3: - __MyProperty1__ = reader.ReadInt32(); - break; - default: - reader.Skip(); - break; - } - } - - var ____result = new global::SharedData.Version0(); - ____result.MyProperty1 = __MyProperty1__; - return ____result; - } - } - - public sealed class HolderV1Formatter : global::MessagePack.Formatters.IMessagePackFormatter - { - - - public void Serialize(ref MessagePackWriter writer, global::SharedData.HolderV1 value, global::MessagePack.MessagePackSerializerOptions options) - { - if (value == null) - { - writer.WriteNil(); - return; - } - - IFormatterResolver formatterResolver = options.Resolver; - writer.WriteArrayHeader(2); - formatterResolver.GetFormatterWithVerify().Serialize(ref writer, value.MyProperty1, options); - writer.Write(value.After); - } - - public global::SharedData.HolderV1 Deserialize(ref MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - if (reader.TryReadNil()) - { - return null; - } - - IFormatterResolver formatterResolver = options.Resolver; - var length = reader.ReadArrayHeader(); - var __MyProperty1__ = default(global::SharedData.Version1); - var __After__ = default(int); - - for (int i = 0; i < length; i++) - { - var key = i; - - switch (key) - { - case 0: - __MyProperty1__ = formatterResolver.GetFormatterWithVerify().Deserialize(ref reader, options); - break; - case 1: - __After__ = reader.ReadInt32(); - break; - default: - reader.Skip(); - break; - } - } - - var ____result = new global::SharedData.HolderV1(); - ____result.MyProperty1 = __MyProperty1__; - ____result.After = __After__; - return ____result; - } - } - - public sealed class HolderV2Formatter : global::MessagePack.Formatters.IMessagePackFormatter - { - - - public void Serialize(ref MessagePackWriter writer, global::SharedData.HolderV2 value, global::MessagePack.MessagePackSerializerOptions options) - { - if (value == null) - { - writer.WriteNil(); - return; - } - - IFormatterResolver formatterResolver = options.Resolver; - writer.WriteArrayHeader(2); - formatterResolver.GetFormatterWithVerify().Serialize(ref writer, value.MyProperty1, options); - writer.Write(value.After); - } - - public global::SharedData.HolderV2 Deserialize(ref MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - if (reader.TryReadNil()) - { - return null; - } - - IFormatterResolver formatterResolver = options.Resolver; - var length = reader.ReadArrayHeader(); - var __MyProperty1__ = default(global::SharedData.Version2); - var __After__ = default(int); - - for (int i = 0; i < length; i++) - { - var key = i; - - switch (key) - { - case 0: - __MyProperty1__ = formatterResolver.GetFormatterWithVerify().Deserialize(ref reader, options); - break; - case 1: - __After__ = reader.ReadInt32(); - break; - default: - reader.Skip(); - break; - } - } - - var ____result = new global::SharedData.HolderV2(); - ____result.MyProperty1 = __MyProperty1__; - ____result.After = __After__; - return ____result; - } - } - - public sealed class HolderV0Formatter : global::MessagePack.Formatters.IMessagePackFormatter - { - - - public void Serialize(ref MessagePackWriter writer, global::SharedData.HolderV0 value, global::MessagePack.MessagePackSerializerOptions options) - { - if (value == null) - { - writer.WriteNil(); - return; - } - - IFormatterResolver formatterResolver = options.Resolver; - writer.WriteArrayHeader(2); - formatterResolver.GetFormatterWithVerify().Serialize(ref writer, value.MyProperty1, options); - writer.Write(value.After); - } - - public global::SharedData.HolderV0 Deserialize(ref MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - if (reader.TryReadNil()) - { - return null; - } - - IFormatterResolver formatterResolver = options.Resolver; - var length = reader.ReadArrayHeader(); - var __MyProperty1__ = default(global::SharedData.Version0); - var __After__ = default(int); - - for (int i = 0; i < length; i++) - { - var key = i; - - switch (key) - { - case 0: - __MyProperty1__ = formatterResolver.GetFormatterWithVerify().Deserialize(ref reader, options); - break; - case 1: - __After__ = reader.ReadInt32(); - break; - default: - reader.Skip(); - break; - } - } - - var ____result = new global::SharedData.HolderV0(); - ____result.MyProperty1 = __MyProperty1__; - ____result.After = __After__; - return ____result; - } - } - - public sealed class Callback1Formatter : global::MessagePack.Formatters.IMessagePackFormatter - { - - - public void Serialize(ref MessagePackWriter writer, global::SharedData.Callback1 value, global::MessagePack.MessagePackSerializerOptions options) - { - if (value == null) - { - writer.WriteNil(); - return; - } - - IFormatterResolver formatterResolver = options.Resolver; - value.OnBeforeSerialize(); - writer.WriteArrayHeader(1); - writer.Write(value.X); - } - - public global::SharedData.Callback1 Deserialize(ref MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - if (reader.TryReadNil()) - { - return null; - } - - IFormatterResolver formatterResolver = options.Resolver; - var length = reader.ReadArrayHeader(); - var __X__ = default(int); - - for (int i = 0; i < length; i++) - { - var key = i; - - switch (key) - { - case 0: - __X__ = reader.ReadInt32(); - break; - default: - reader.Skip(); - break; - } - } - - var ____result = new global::SharedData.Callback1(__X__); - ____result.X = __X__; - ____result.OnAfterDeserialize(); - return ____result; - } - } - - public sealed class Callback1_2Formatter : global::MessagePack.Formatters.IMessagePackFormatter - { - - - public void Serialize(ref MessagePackWriter writer, global::SharedData.Callback1_2 value, global::MessagePack.MessagePackSerializerOptions options) - { - if (value == null) - { - writer.WriteNil(); - return; - } - - IFormatterResolver formatterResolver = options.Resolver; - ((IMessagePackSerializationCallbackReceiver)value).OnBeforeSerialize(); - writer.WriteArrayHeader(1); - writer.Write(value.X); - } - - public global::SharedData.Callback1_2 Deserialize(ref MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - if (reader.TryReadNil()) - { - return null; - } - - IFormatterResolver formatterResolver = options.Resolver; - var length = reader.ReadArrayHeader(); - var __X__ = default(int); - - for (int i = 0; i < length; i++) - { - var key = i; - - switch (key) - { - case 0: - __X__ = reader.ReadInt32(); - break; - default: - reader.Skip(); - break; - } - } - - var ____result = new global::SharedData.Callback1_2(__X__); - ____result.X = __X__; - ((IMessagePackSerializationCallbackReceiver)____result).OnAfterDeserialize(); - return ____result; - } - } - - public sealed class Callback2Formatter : global::MessagePack.Formatters.IMessagePackFormatter - { - - - private readonly global::MessagePack.Internal.AutomataDictionary ____keyMapping; - private readonly byte[][] ____stringByteKeys; - - public Callback2Formatter() - { - this.____keyMapping = new global::MessagePack.Internal.AutomataDictionary() - { - { "X", 0 }, - }; - - this.____stringByteKeys = new byte[][] - { - global::MessagePack.Internal.CodeGenHelpers.GetEncodedStringBytes("X"), - }; - } - - public void Serialize(ref MessagePackWriter writer, global::SharedData.Callback2 value, global::MessagePack.MessagePackSerializerOptions options) - { - IFormatterResolver formatterResolver = options.Resolver; - value.OnBeforeSerialize(); - writer.WriteMapHeader(1); - writer.WriteRaw(this.____stringByteKeys[0]); - writer.Write(value.X); - } - - public global::SharedData.Callback2 Deserialize(ref MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - if (reader.TryReadNil()) - { - throw new InvalidOperationException("typecode is null, struct not supported"); - } - - IFormatterResolver formatterResolver = options.Resolver; - var length = reader.ReadMapHeader(); - var __X__ = default(int); - - for (int i = 0; i < length; i++) - { - ReadOnlySequence stringKey = reader.ReadStringSequence().Value; - int key; - if (!this.____keyMapping.TryGetValue(stringKey, out key)) - { - reader.Skip(); - continue; - } - - switch (key) - { - case 0: - __X__ = reader.ReadInt32(); - break; - default: - reader.Skip(); - break; - } - } - - var ____result = new global::SharedData.Callback2(__X__); - ____result.X = __X__; - ____result.OnAfterDeserialize(); - return ____result; - } - } - - public sealed class Callback2_2Formatter : global::MessagePack.Formatters.IMessagePackFormatter - { - - - private readonly global::MessagePack.Internal.AutomataDictionary ____keyMapping; - private readonly byte[][] ____stringByteKeys; - - public Callback2_2Formatter() - { - this.____keyMapping = new global::MessagePack.Internal.AutomataDictionary() - { - { "X", 0 }, - }; - - this.____stringByteKeys = new byte[][] - { - global::MessagePack.Internal.CodeGenHelpers.GetEncodedStringBytes("X"), - }; - } - - public void Serialize(ref MessagePackWriter writer, global::SharedData.Callback2_2 value, global::MessagePack.MessagePackSerializerOptions options) - { - IFormatterResolver formatterResolver = options.Resolver; - ((IMessagePackSerializationCallbackReceiver)value).OnBeforeSerialize(); - writer.WriteMapHeader(1); - writer.WriteRaw(this.____stringByteKeys[0]); - writer.Write(value.X); - } - - public global::SharedData.Callback2_2 Deserialize(ref MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - if (reader.TryReadNil()) - { - throw new InvalidOperationException("typecode is null, struct not supported"); - } - - IFormatterResolver formatterResolver = options.Resolver; - var length = reader.ReadMapHeader(); - var __X__ = default(int); - - for (int i = 0; i < length; i++) - { - ReadOnlySequence stringKey = reader.ReadStringSequence().Value; - int key; - if (!this.____keyMapping.TryGetValue(stringKey, out key)) - { - reader.Skip(); - continue; - } - - switch (key) - { - case 0: - __X__ = reader.ReadInt32(); - break; - default: - reader.Skip(); - break; - } - } - - var ____result = new global::SharedData.Callback2_2(__X__); - ____result.X = __X__; - ((IMessagePackSerializationCallbackReceiver)____result).OnAfterDeserialize(); - return ____result; - } - } - - public sealed class SubUnionType1Formatter : global::MessagePack.Formatters.IMessagePackFormatter - { - - - public void Serialize(ref MessagePackWriter writer, global::SharedData.SubUnionType1 value, global::MessagePack.MessagePackSerializerOptions options) - { - if (value == null) - { - writer.WriteNil(); - return; - } - - IFormatterResolver formatterResolver = options.Resolver; - writer.WriteArrayHeader(2); - writer.Write(value.MyProperty); - writer.Write(value.MyProperty1); - } - - public global::SharedData.SubUnionType1 Deserialize(ref MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - if (reader.TryReadNil()) - { - return null; - } - - IFormatterResolver formatterResolver = options.Resolver; - var length = reader.ReadArrayHeader(); - var __MyProperty1__ = default(int); - var __MyProperty__ = default(int); - - for (int i = 0; i < length; i++) - { - var key = i; - - switch (key) - { - case 1: - __MyProperty1__ = reader.ReadInt32(); - break; - case 0: - __MyProperty__ = reader.ReadInt32(); - break; - default: - reader.Skip(); - break; - } - } - - var ____result = new global::SharedData.SubUnionType1(); - ____result.MyProperty1 = __MyProperty1__; - ____result.MyProperty = __MyProperty__; - return ____result; - } - } - - public sealed class SubUnionType2Formatter : global::MessagePack.Formatters.IMessagePackFormatter - { - - - public void Serialize(ref MessagePackWriter writer, global::SharedData.SubUnionType2 value, global::MessagePack.MessagePackSerializerOptions options) - { - if (value == null) - { - writer.WriteNil(); - return; - } - - IFormatterResolver formatterResolver = options.Resolver; - writer.WriteArrayHeader(2); - writer.Write(value.MyProperty); - writer.Write(value.MyProperty2); - } - - public global::SharedData.SubUnionType2 Deserialize(ref MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - if (reader.TryReadNil()) - { - return null; - } - - IFormatterResolver formatterResolver = options.Resolver; - var length = reader.ReadArrayHeader(); - var __MyProperty2__ = default(int); - var __MyProperty__ = default(int); - - for (int i = 0; i < length; i++) - { - var key = i; - - switch (key) - { - case 1: - __MyProperty2__ = reader.ReadInt32(); - break; - case 0: - __MyProperty__ = reader.ReadInt32(); - break; - default: - reader.Skip(); - break; - } - } - - var ____result = new global::SharedData.SubUnionType2(); - ____result.MyProperty2 = __MyProperty2__; - ____result.MyProperty = __MyProperty__; - return ____result; - } - } - - public sealed class MySubUnion1Formatter : global::MessagePack.Formatters.IMessagePackFormatter - { - - - public void Serialize(ref MessagePackWriter writer, global::SharedData.MySubUnion1 value, global::MessagePack.MessagePackSerializerOptions options) - { - if (value == null) - { - writer.WriteNil(); - return; - } - - IFormatterResolver formatterResolver = options.Resolver; - writer.WriteArrayHeader(4); - writer.WriteNil(); - writer.WriteNil(); - writer.WriteNil(); - writer.Write(value.One); - } - - public global::SharedData.MySubUnion1 Deserialize(ref MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - if (reader.TryReadNil()) - { - return null; - } - - IFormatterResolver formatterResolver = options.Resolver; - var length = reader.ReadArrayHeader(); - var __One__ = default(int); - - for (int i = 0; i < length; i++) - { - var key = i; - - switch (key) - { - case 3: - __One__ = reader.ReadInt32(); - break; - default: - reader.Skip(); - break; - } - } - - var ____result = new global::SharedData.MySubUnion1(); - ____result.One = __One__; - return ____result; - } - } - - public sealed class MySubUnion2Formatter : global::MessagePack.Formatters.IMessagePackFormatter - { - - - public void Serialize(ref MessagePackWriter writer, global::SharedData.MySubUnion2 value, global::MessagePack.MessagePackSerializerOptions options) - { - IFormatterResolver formatterResolver = options.Resolver; - writer.WriteArrayHeader(6); - writer.WriteNil(); - writer.WriteNil(); - writer.WriteNil(); - writer.WriteNil(); - writer.WriteNil(); - writer.Write(value.Two); - } - - public global::SharedData.MySubUnion2 Deserialize(ref MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - if (reader.TryReadNil()) - { - throw new InvalidOperationException("typecode is null, struct not supported"); - } - - IFormatterResolver formatterResolver = options.Resolver; - var length = reader.ReadArrayHeader(); - var __Two__ = default(int); - - for (int i = 0; i < length; i++) - { - var key = i; - - switch (key) - { - case 5: - __Two__ = reader.ReadInt32(); - break; - default: - reader.Skip(); - break; - } - } - - var ____result = new global::SharedData.MySubUnion2(); - ____result.Two = __Two__; - return ____result; - } - } - - public sealed class MySubUnion3Formatter : global::MessagePack.Formatters.IMessagePackFormatter - { - - - public void Serialize(ref MessagePackWriter writer, global::SharedData.MySubUnion3 value, global::MessagePack.MessagePackSerializerOptions options) - { - if (value == null) - { - writer.WriteNil(); - return; - } - - IFormatterResolver formatterResolver = options.Resolver; - writer.WriteArrayHeader(3); - writer.WriteNil(); - writer.WriteNil(); - writer.Write(value.Three); - } - - public global::SharedData.MySubUnion3 Deserialize(ref MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - if (reader.TryReadNil()) - { - return null; - } - - IFormatterResolver formatterResolver = options.Resolver; - var length = reader.ReadArrayHeader(); - var __Three__ = default(int); - - for (int i = 0; i < length; i++) - { - var key = i; - - switch (key) - { - case 2: - __Three__ = reader.ReadInt32(); - break; - default: - reader.Skip(); - break; - } - } - - var ____result = new global::SharedData.MySubUnion3(); - ____result.Three = __Three__; - return ____result; - } - } - - public sealed class MySubUnion4Formatter : global::MessagePack.Formatters.IMessagePackFormatter - { - - - public void Serialize(ref MessagePackWriter writer, global::SharedData.MySubUnion4 value, global::MessagePack.MessagePackSerializerOptions options) - { - IFormatterResolver formatterResolver = options.Resolver; - writer.WriteArrayHeader(8); - writer.WriteNil(); - writer.WriteNil(); - writer.WriteNil(); - writer.WriteNil(); - writer.WriteNil(); - writer.WriteNil(); - writer.WriteNil(); - writer.Write(value.Four); - } - - public global::SharedData.MySubUnion4 Deserialize(ref MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - if (reader.TryReadNil()) - { - throw new InvalidOperationException("typecode is null, struct not supported"); - } - - IFormatterResolver formatterResolver = options.Resolver; - var length = reader.ReadArrayHeader(); - var __Four__ = default(int); - - for (int i = 0; i < length; i++) - { - var key = i; - - switch (key) - { - case 7: - __Four__ = reader.ReadInt32(); - break; - default: - reader.Skip(); - break; - } - } - - var ____result = new global::SharedData.MySubUnion4(); - ____result.Four = __Four__; - return ____result; - } - } - - public sealed class VersioningUnionFormatter : global::MessagePack.Formatters.IMessagePackFormatter - { - - - public void Serialize(ref MessagePackWriter writer, global::SharedData.VersioningUnion value, global::MessagePack.MessagePackSerializerOptions options) - { - if (value == null) - { - writer.WriteNil(); - return; - } - - IFormatterResolver formatterResolver = options.Resolver; - writer.WriteArrayHeader(8); - writer.WriteNil(); - writer.WriteNil(); - writer.WriteNil(); - writer.WriteNil(); - writer.WriteNil(); - writer.WriteNil(); - writer.WriteNil(); - writer.Write(value.FV); - } - - public global::SharedData.VersioningUnion Deserialize(ref MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - if (reader.TryReadNil()) - { - return null; - } - - IFormatterResolver formatterResolver = options.Resolver; - var length = reader.ReadArrayHeader(); - var __FV__ = default(int); - - for (int i = 0; i < length; i++) - { - var key = i; - - switch (key) - { - case 7: - __FV__ = reader.ReadInt32(); - break; - default: - reader.Skip(); - break; - } - } - - var ____result = new global::SharedData.VersioningUnion(); - ____result.FV = __FV__; - return ____result; - } - } - - public sealed class MyClassFormatter : global::MessagePack.Formatters.IMessagePackFormatter - { - - - public void Serialize(ref MessagePackWriter writer, global::SharedData.MyClass value, global::MessagePack.MessagePackSerializerOptions options) - { - if (value == null) - { - writer.WriteNil(); - return; - } - - IFormatterResolver formatterResolver = options.Resolver; - writer.WriteArrayHeader(3); - writer.Write(value.MyProperty1); - writer.Write(value.MyProperty2); - writer.Write(value.MyProperty3); - } - - public global::SharedData.MyClass Deserialize(ref MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - if (reader.TryReadNil()) - { - return null; - } - - IFormatterResolver formatterResolver = options.Resolver; - var length = reader.ReadArrayHeader(); - var __MyProperty1__ = default(int); - var __MyProperty2__ = default(int); - var __MyProperty3__ = default(int); - - for (int i = 0; i < length; i++) - { - var key = i; - - switch (key) - { - case 0: - __MyProperty1__ = reader.ReadInt32(); - break; - case 1: - __MyProperty2__ = reader.ReadInt32(); - break; - case 2: - __MyProperty3__ = reader.ReadInt32(); - break; - default: - reader.Skip(); - break; - } - } - - var ____result = new global::SharedData.MyClass(); - ____result.MyProperty1 = __MyProperty1__; - ____result.MyProperty2 = __MyProperty2__; - ____result.MyProperty3 = __MyProperty3__; - return ____result; - } - } - - public sealed class VersionBlockTestFormatter : global::MessagePack.Formatters.IMessagePackFormatter - { - - - public void Serialize(ref MessagePackWriter writer, global::SharedData.VersionBlockTest value, global::MessagePack.MessagePackSerializerOptions options) - { - if (value == null) - { - writer.WriteNil(); - return; - } - - IFormatterResolver formatterResolver = options.Resolver; - writer.WriteArrayHeader(3); - writer.Write(value.MyProperty); - formatterResolver.GetFormatterWithVerify().Serialize(ref writer, value.UnknownBlock, options); - writer.Write(value.MyProperty2); - } - - public global::SharedData.VersionBlockTest Deserialize(ref MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - if (reader.TryReadNil()) - { - return null; - } - - IFormatterResolver formatterResolver = options.Resolver; - var length = reader.ReadArrayHeader(); - var __MyProperty__ = default(int); - var __UnknownBlock__ = default(global::SharedData.MyClass); - var __MyProperty2__ = default(int); - - for (int i = 0; i < length; i++) - { - var key = i; - - switch (key) - { - case 0: - __MyProperty__ = reader.ReadInt32(); - break; - case 1: - __UnknownBlock__ = formatterResolver.GetFormatterWithVerify().Deserialize(ref reader, options); - break; - case 2: - __MyProperty2__ = reader.ReadInt32(); - break; - default: - reader.Skip(); - break; - } - } - - var ____result = new global::SharedData.VersionBlockTest(); - ____result.MyProperty = __MyProperty__; - ____result.UnknownBlock = __UnknownBlock__; - ____result.MyProperty2 = __MyProperty2__; - return ____result; - } - } - - public sealed class UnVersionBlockTestFormatter : global::MessagePack.Formatters.IMessagePackFormatter - { - - - public void Serialize(ref MessagePackWriter writer, global::SharedData.UnVersionBlockTest value, global::MessagePack.MessagePackSerializerOptions options) - { - if (value == null) - { - writer.WriteNil(); - return; - } - - IFormatterResolver formatterResolver = options.Resolver; - writer.WriteArrayHeader(3); - writer.Write(value.MyProperty); - writer.WriteNil(); - writer.Write(value.MyProperty2); - } - - public global::SharedData.UnVersionBlockTest Deserialize(ref MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - if (reader.TryReadNil()) - { - return null; - } - - IFormatterResolver formatterResolver = options.Resolver; - var length = reader.ReadArrayHeader(); - var __MyProperty__ = default(int); - var __MyProperty2__ = default(int); - - for (int i = 0; i < length; i++) - { - var key = i; - - switch (key) - { - case 0: - __MyProperty__ = reader.ReadInt32(); - break; - case 2: - __MyProperty2__ = reader.ReadInt32(); - break; - default: - reader.Skip(); - break; - } - } - - var ____result = new global::SharedData.UnVersionBlockTest(); - ____result.MyProperty = __MyProperty__; - ____result.MyProperty2 = __MyProperty2__; - return ____result; - } - } - - public sealed class Empty1Formatter : global::MessagePack.Formatters.IMessagePackFormatter - { - - - public void Serialize(ref MessagePackWriter writer, global::SharedData.Empty1 value, global::MessagePack.MessagePackSerializerOptions options) - { - if (value == null) - { - writer.WriteNil(); - return; - } - - IFormatterResolver formatterResolver = options.Resolver; - writer.WriteArrayHeader(0); - } - - public global::SharedData.Empty1 Deserialize(ref MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - if (reader.TryReadNil()) - { - return null; - } - - IFormatterResolver formatterResolver = options.Resolver; - var length = reader.ReadArrayHeader(); - - for (int i = 0; i < length; i++) - { - var key = i; - - switch (key) - { - default: - reader.Skip(); - break; - } - } - - var ____result = new global::SharedData.Empty1(); - return ____result; - } - } - - public sealed class Empty2Formatter : global::MessagePack.Formatters.IMessagePackFormatter - { - - - private readonly global::MessagePack.Internal.AutomataDictionary ____keyMapping; - private readonly byte[][] ____stringByteKeys; - - public Empty2Formatter() - { - this.____keyMapping = new global::MessagePack.Internal.AutomataDictionary() - { - }; - - this.____stringByteKeys = new byte[][] - { - }; - } - - public void Serialize(ref MessagePackWriter writer, global::SharedData.Empty2 value, global::MessagePack.MessagePackSerializerOptions options) - { - if (value == null) - { - writer.WriteNil(); - return; - } - - IFormatterResolver formatterResolver = options.Resolver; - writer.WriteMapHeader(0); - } - - public global::SharedData.Empty2 Deserialize(ref MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - if (reader.TryReadNil()) - { - return null; - } - - IFormatterResolver formatterResolver = options.Resolver; - var length = reader.ReadMapHeader(); - - for (int i = 0; i < length; i++) - { - ReadOnlySequence stringKey = reader.ReadStringSequence().Value; - int key; - if (!this.____keyMapping.TryGetValue(stringKey, out key)) - { - reader.Skip(); - continue; - } - - switch (key) - { - default: - reader.Skip(); - break; - } - } - - var ____result = new global::SharedData.Empty2(); - return ____result; - } - } - - public sealed class NonEmpty1Formatter : global::MessagePack.Formatters.IMessagePackFormatter - { - - - public void Serialize(ref MessagePackWriter writer, global::SharedData.NonEmpty1 value, global::MessagePack.MessagePackSerializerOptions options) - { - if (value == null) - { - writer.WriteNil(); - return; - } - - IFormatterResolver formatterResolver = options.Resolver; - writer.WriteArrayHeader(1); - writer.Write(value.MyProperty); - } - - public global::SharedData.NonEmpty1 Deserialize(ref MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - if (reader.TryReadNil()) - { - return null; - } - - IFormatterResolver formatterResolver = options.Resolver; - var length = reader.ReadArrayHeader(); - var __MyProperty__ = default(int); - - for (int i = 0; i < length; i++) - { - var key = i; - - switch (key) - { - case 0: - __MyProperty__ = reader.ReadInt32(); - break; - default: - reader.Skip(); - break; - } - } - - var ____result = new global::SharedData.NonEmpty1(); - ____result.MyProperty = __MyProperty__; - return ____result; - } - } - - public sealed class NonEmpty2Formatter : global::MessagePack.Formatters.IMessagePackFormatter - { - - - private readonly global::MessagePack.Internal.AutomataDictionary ____keyMapping; - private readonly byte[][] ____stringByteKeys; - - public NonEmpty2Formatter() - { - this.____keyMapping = new global::MessagePack.Internal.AutomataDictionary() - { - { "MyProperty", 0 }, - }; - - this.____stringByteKeys = new byte[][] - { - global::MessagePack.Internal.CodeGenHelpers.GetEncodedStringBytes("MyProperty"), - }; - } - - public void Serialize(ref MessagePackWriter writer, global::SharedData.NonEmpty2 value, global::MessagePack.MessagePackSerializerOptions options) - { - if (value == null) - { - writer.WriteNil(); - return; - } - - IFormatterResolver formatterResolver = options.Resolver; - writer.WriteMapHeader(1); - writer.WriteRaw(this.____stringByteKeys[0]); - writer.Write(value.MyProperty); - } - - public global::SharedData.NonEmpty2 Deserialize(ref MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - if (reader.TryReadNil()) - { - return null; - } - - IFormatterResolver formatterResolver = options.Resolver; - var length = reader.ReadMapHeader(); - var __MyProperty__ = default(int); - - for (int i = 0; i < length; i++) - { - ReadOnlySequence stringKey = reader.ReadStringSequence().Value; - int key; - if (!this.____keyMapping.TryGetValue(stringKey, out key)) - { - reader.Skip(); - continue; - } - - switch (key) - { - case 0: - __MyProperty__ = reader.ReadInt32(); - break; - default: - reader.Skip(); - break; - } - } - - var ____result = new global::SharedData.NonEmpty2(); - ____result.MyProperty = __MyProperty__; - return ____result; - } - } - - public sealed class VectorLike2Formatter : global::MessagePack.Formatters.IMessagePackFormatter - { - - - public void Serialize(ref MessagePackWriter writer, global::SharedData.VectorLike2 value, global::MessagePack.MessagePackSerializerOptions options) - { - IFormatterResolver formatterResolver = options.Resolver; - writer.WriteArrayHeader(2); - writer.Write(value.x); - writer.Write(value.y); - } - - public global::SharedData.VectorLike2 Deserialize(ref MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - if (reader.TryReadNil()) - { - throw new InvalidOperationException("typecode is null, struct not supported"); - } - - IFormatterResolver formatterResolver = options.Resolver; - var length = reader.ReadArrayHeader(); - var __x__ = default(float); - var __y__ = default(float); - - for (int i = 0; i < length; i++) - { - var key = i; - - switch (key) - { - case 0: - __x__ = reader.ReadSingle(); - break; - case 1: - __y__ = reader.ReadSingle(); - break; - default: - reader.Skip(); - break; - } - } - - var ____result = new global::SharedData.VectorLike2(__x__, __y__); - ____result.x = __x__; - ____result.y = __y__; - return ____result; - } - } - - public sealed class Vector3LikeFormatter : global::MessagePack.Formatters.IMessagePackFormatter - { - - - public void Serialize(ref MessagePackWriter writer, global::SharedData.Vector3Like value, global::MessagePack.MessagePackSerializerOptions options) - { - IFormatterResolver formatterResolver = options.Resolver; - writer.WriteArrayHeader(3); - writer.Write(value.x); - writer.Write(value.y); - writer.Write(value.z); - } - - public global::SharedData.Vector3Like Deserialize(ref MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - if (reader.TryReadNil()) - { - throw new InvalidOperationException("typecode is null, struct not supported"); - } - - IFormatterResolver formatterResolver = options.Resolver; - var length = reader.ReadArrayHeader(); - var __x__ = default(float); - var __y__ = default(float); - var __z__ = default(float); - - for (int i = 0; i < length; i++) - { - var key = i; - - switch (key) - { - case 0: - __x__ = reader.ReadSingle(); - break; - case 1: - __y__ = reader.ReadSingle(); - break; - case 2: - __z__ = reader.ReadSingle(); - break; - default: - reader.Skip(); - break; - } - } - - var ____result = new global::SharedData.Vector3Like(__x__, __y__, __z__); - ____result.x = __x__; - ____result.y = __y__; - ____result.z = __z__; - return ____result; - } - } - - public sealed class ArrayOptimizeClassFormatter : global::MessagePack.Formatters.IMessagePackFormatter - { - - - public void Serialize(ref MessagePackWriter writer, global::SharedData.ArrayOptimizeClass value, global::MessagePack.MessagePackSerializerOptions options) - { - if (value == null) - { - writer.WriteNil(); - return; - } - - IFormatterResolver formatterResolver = options.Resolver; - writer.WriteArrayHeader(16); - writer.Write(value.MyProperty0); - writer.Write(value.MyProperty1); - writer.Write(value.MyProperty2); - writer.Write(value.MyProperty3); - writer.Write(value.MyProperty4); - writer.Write(value.MyProperty5); - writer.Write(value.MyProperty6); - writer.Write(value.MyProperty7); - writer.Write(value.MyProperty8); - writer.Write(value.MyProvperty9); - writer.Write(value.MyProperty10); - writer.Write(value.MyProperty11); - writer.Write(value.MyPropverty12); - writer.Write(value.MyPropevrty13); - writer.Write(value.MyProperty14); - writer.Write(value.MyProperty15); - } - - public global::SharedData.ArrayOptimizeClass Deserialize(ref MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - if (reader.TryReadNil()) - { - return null; - } - - IFormatterResolver formatterResolver = options.Resolver; - var length = reader.ReadArrayHeader(); - var __MyProperty0__ = default(int); - var __MyProperty1__ = default(int); - var __MyProperty2__ = default(int); - var __MyProperty3__ = default(int); - var __MyProperty4__ = default(int); - var __MyProperty5__ = default(int); - var __MyProperty6__ = default(int); - var __MyProperty7__ = default(int); - var __MyProperty8__ = default(int); - var __MyProvperty9__ = default(int); - var __MyProperty10__ = default(int); - var __MyProperty11__ = default(int); - var __MyPropverty12__ = default(int); - var __MyPropevrty13__ = default(int); - var __MyProperty14__ = default(int); - var __MyProperty15__ = default(int); - - for (int i = 0; i < length; i++) - { - var key = i; - - switch (key) - { - case 0: - __MyProperty0__ = reader.ReadInt32(); - break; - case 1: - __MyProperty1__ = reader.ReadInt32(); - break; - case 2: - __MyProperty2__ = reader.ReadInt32(); - break; - case 3: - __MyProperty3__ = reader.ReadInt32(); - break; - case 4: - __MyProperty4__ = reader.ReadInt32(); - break; - case 5: - __MyProperty5__ = reader.ReadInt32(); - break; - case 6: - __MyProperty6__ = reader.ReadInt32(); - break; - case 7: - __MyProperty7__ = reader.ReadInt32(); - break; - case 8: - __MyProperty8__ = reader.ReadInt32(); - break; - case 9: - __MyProvperty9__ = reader.ReadInt32(); - break; - case 10: - __MyProperty10__ = reader.ReadInt32(); - break; - case 11: - __MyProperty11__ = reader.ReadInt32(); - break; - case 12: - __MyPropverty12__ = reader.ReadInt32(); - break; - case 13: - __MyPropevrty13__ = reader.ReadInt32(); - break; - case 14: - __MyProperty14__ = reader.ReadInt32(); - break; - case 15: - __MyProperty15__ = reader.ReadInt32(); - break; - default: - reader.Skip(); - break; - } - } - - var ____result = new global::SharedData.ArrayOptimizeClass(); - ____result.MyProperty0 = __MyProperty0__; - ____result.MyProperty1 = __MyProperty1__; - ____result.MyProperty2 = __MyProperty2__; - ____result.MyProperty3 = __MyProperty3__; - ____result.MyProperty4 = __MyProperty4__; - ____result.MyProperty5 = __MyProperty5__; - ____result.MyProperty6 = __MyProperty6__; - ____result.MyProperty7 = __MyProperty7__; - ____result.MyProperty8 = __MyProperty8__; - ____result.MyProvperty9 = __MyProvperty9__; - ____result.MyProperty10 = __MyProperty10__; - ____result.MyProperty11 = __MyProperty11__; - ____result.MyPropverty12 = __MyPropverty12__; - ____result.MyPropevrty13 = __MyPropevrty13__; - ____result.MyProperty14 = __MyProperty14__; - ____result.MyProperty15 = __MyProperty15__; - return ____result; - } - } - - public sealed class NestParent_NestContractFormatter : global::MessagePack.Formatters.IMessagePackFormatter - { - - - public void Serialize(ref MessagePackWriter writer, global::SharedData.NestParent.NestContract value, global::MessagePack.MessagePackSerializerOptions options) - { - if (value == null) - { - writer.WriteNil(); - return; - } - - IFormatterResolver formatterResolver = options.Resolver; - writer.WriteArrayHeader(1); - writer.Write(value.MyProperty); - } - - public global::SharedData.NestParent.NestContract Deserialize(ref MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - if (reader.TryReadNil()) - { - return null; - } - - IFormatterResolver formatterResolver = options.Resolver; - var length = reader.ReadArrayHeader(); - var __MyProperty__ = default(int); - - for (int i = 0; i < length; i++) - { - var key = i; - - switch (key) - { - case 0: - __MyProperty__ = reader.ReadInt32(); - break; - default: - reader.Skip(); - break; - } - } - - var ____result = new global::SharedData.NestParent.NestContract(); - ____result.MyProperty = __MyProperty__; - return ____result; - } - } - - public sealed class FooClassFormatter : global::MessagePack.Formatters.IMessagePackFormatter - { - - - public void Serialize(ref MessagePackWriter writer, global::SharedData.FooClass value, global::MessagePack.MessagePackSerializerOptions options) - { - if (value == null) - { - writer.WriteNil(); - return; - } - - IFormatterResolver formatterResolver = options.Resolver; - writer.WriteArrayHeader(1); - writer.Write(value.XYZ); - } - - public global::SharedData.FooClass Deserialize(ref MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - if (reader.TryReadNil()) - { - return null; - } - - IFormatterResolver formatterResolver = options.Resolver; - var length = reader.ReadArrayHeader(); - var __XYZ__ = default(int); - - for (int i = 0; i < length; i++) - { - var key = i; - - switch (key) - { - case 0: - __XYZ__ = reader.ReadInt32(); - break; - default: - reader.Skip(); - break; - } - } - - var ____result = new global::SharedData.FooClass(); - ____result.XYZ = __XYZ__; - return ____result; - } - } - - public sealed class BarClassFormatter : global::MessagePack.Formatters.IMessagePackFormatter - { - - - public void Serialize(ref MessagePackWriter writer, global::SharedData.BarClass value, global::MessagePack.MessagePackSerializerOptions options) - { - if (value == null) - { - writer.WriteNil(); - return; - } - - IFormatterResolver formatterResolver = options.Resolver; - writer.WriteArrayHeader(1); - formatterResolver.GetFormatterWithVerify().Serialize(ref writer, value.OPQ, options); - } - - public global::SharedData.BarClass Deserialize(ref MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - if (reader.TryReadNil()) - { - return null; - } - - IFormatterResolver formatterResolver = options.Resolver; - var length = reader.ReadArrayHeader(); - var __OPQ__ = default(string); - - for (int i = 0; i < length; i++) - { - var key = i; - - switch (key) - { - case 0: - __OPQ__ = formatterResolver.GetFormatterWithVerify().Deserialize(ref reader, options); - break; - default: - reader.Skip(); - break; - } - } - - var ____result = new global::SharedData.BarClass(); - ____result.OPQ = __OPQ__; - return ____result; - } - } - - public sealed class WithIndexerFormatter : global::MessagePack.Formatters.IMessagePackFormatter - { - - - public void Serialize(ref MessagePackWriter writer, global::SharedData.WithIndexer value, global::MessagePack.MessagePackSerializerOptions options) - { - if (value == null) - { - writer.WriteNil(); - return; - } - - IFormatterResolver formatterResolver = options.Resolver; - writer.WriteArrayHeader(2); - writer.Write(value.Data1); - formatterResolver.GetFormatterWithVerify().Serialize(ref writer, value.Data2, options); - } - - public global::SharedData.WithIndexer Deserialize(ref MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - if (reader.TryReadNil()) - { - return null; - } - - IFormatterResolver formatterResolver = options.Resolver; - var length = reader.ReadArrayHeader(); - var __Data1__ = default(int); - var __Data2__ = default(string); - - for (int i = 0; i < length; i++) - { - var key = i; - - switch (key) - { - case 0: - __Data1__ = reader.ReadInt32(); - break; - case 1: - __Data2__ = formatterResolver.GetFormatterWithVerify().Deserialize(ref reader, options); - break; - default: - reader.Skip(); - break; - } - } - - var ____result = new global::SharedData.WithIndexer(); - ____result.Data1 = __Data1__; - ____result.Data2 = __Data2__; - return ____result; - } - } -} - -#pragma warning restore 168 -#pragma warning restore 414 -#pragma warning restore 618 -#pragma warning restore 612 - -#pragma warning restore SA1129 // Do not use default value type constructor -#pragma warning restore SA1200 // Using directives should be placed correctly -#pragma warning restore SA1309 // Field names should not begin with underscore -#pragma warning restore SA1312 // Variable names should begin with lower-case letter -#pragma warning restore SA1403 // File may only contain a single namespace -#pragma warning restore SA1649 // File name should match first type name - -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 168 - -#pragma warning disable SA1129 // Do not use default value type constructor -#pragma warning disable SA1200 // Using directives should be placed correctly -#pragma warning disable SA1309 // Field names should not begin with underscore -#pragma warning disable SA1312 // Variable names should begin with lower-case letter -#pragma warning disable SA1403 // File may only contain a single namespace -#pragma warning disable SA1649 // File name should match first type name - -namespace MessagePack.Formatters.Abcdefg.Efcdigjl.Ateatatea.Hgfagfafgad -{ - using System; - using System.Buffers; - using MessagePack; - - public sealed class TnonodsfarnoiuAtatqagaFormatter : global::MessagePack.Formatters.IMessagePackFormatter - { - - - public void Serialize(ref MessagePackWriter writer, global::Abcdefg.Efcdigjl.Ateatatea.Hgfagfafgad.TnonodsfarnoiuAtatqaga value, global::MessagePack.MessagePackSerializerOptions options) - { - if (value == null) - { - writer.WriteNil(); - return; - } - - IFormatterResolver formatterResolver = options.Resolver; - writer.WriteArrayHeader(1); - writer.Write(value.MyProperty); - } - - public global::Abcdefg.Efcdigjl.Ateatatea.Hgfagfafgad.TnonodsfarnoiuAtatqaga Deserialize(ref MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - if (reader.TryReadNil()) - { - return null; - } - - IFormatterResolver formatterResolver = options.Resolver; - var length = reader.ReadArrayHeader(); - var __MyProperty__ = default(int); - - for (int i = 0; i < length; i++) - { - var key = i; - - switch (key) - { - case 0: - __MyProperty__ = reader.ReadInt32(); - break; - default: - reader.Skip(); - break; - } - } - - var ____result = new global::Abcdefg.Efcdigjl.Ateatatea.Hgfagfafgad.TnonodsfarnoiuAtatqaga(); - ____result.MyProperty = __MyProperty__; - return ____result; - } - } -} - -#pragma warning restore 168 -#pragma warning restore 414 -#pragma warning restore 618 -#pragma warning restore 612 - -#pragma warning restore SA1129 // Do not use default value type constructor -#pragma warning restore SA1200 // Using directives should be placed correctly -#pragma warning restore SA1309 // Field names should not begin with underscore -#pragma warning restore SA1312 // Variable names should begin with lower-case letter -#pragma warning restore SA1403 // File may only contain a single namespace -#pragma warning restore SA1649 // File name should match first type name - -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 168 - -#pragma warning disable SA1129 // Do not use default value type constructor -#pragma warning disable SA1200 // Using directives should be placed correctly -#pragma warning disable SA1309 // Field names should not begin with underscore -#pragma warning disable SA1312 // Variable names should begin with lower-case letter -#pragma warning disable SA1403 // File may only contain a single namespace -#pragma warning disable SA1649 // File name should match first type name - -namespace MessagePack.Formatters -{ - using System; - using System.Buffers; - using MessagePack; - - public sealed class GlobalManFormatter : global::MessagePack.Formatters.IMessagePackFormatter - { - - - public void Serialize(ref MessagePackWriter writer, global::GlobalMan value, global::MessagePack.MessagePackSerializerOptions options) - { - if (value == null) - { - writer.WriteNil(); - return; - } - - IFormatterResolver formatterResolver = options.Resolver; - writer.WriteArrayHeader(1); - writer.Write(value.MyProperty); - } - - public global::GlobalMan Deserialize(ref MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - if (reader.TryReadNil()) - { - return null; - } - - IFormatterResolver formatterResolver = options.Resolver; - var length = reader.ReadArrayHeader(); - var __MyProperty__ = default(int); - - for (int i = 0; i < length; i++) - { - var key = i; - - switch (key) - { - case 0: - __MyProperty__ = reader.ReadInt32(); - break; - default: - reader.Skip(); - break; - } - } - - var ____result = new global::GlobalMan(); - ____result.MyProperty = __MyProperty__; - return ____result; - } - } - - public sealed class MessageFormatter : global::MessagePack.Formatters.IMessagePackFormatter - { - - - public void Serialize(ref MessagePackWriter writer, global::Message value, global::MessagePack.MessagePackSerializerOptions options) - { - if (value == null) - { - writer.WriteNil(); - return; - } - - IFormatterResolver formatterResolver = options.Resolver; - writer.WriteArrayHeader(4); - writer.Write(value.UserId); - writer.Write(value.RoomId); - formatterResolver.GetFormatterWithVerify().Serialize(ref writer, value.PostTime, options); - formatterResolver.GetFormatterWithVerify().Serialize(ref writer, value.Body, options); - } - - public global::Message Deserialize(ref MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - if (reader.TryReadNil()) - { - return null; - } - - IFormatterResolver formatterResolver = options.Resolver; - var length = reader.ReadArrayHeader(); - var __UserId__ = default(int); - var __RoomId__ = default(int); - var __PostTime__ = default(global::System.DateTime); - var __Body__ = default(global::IMessageBody); - - for (int i = 0; i < length; i++) - { - var key = i; - - switch (key) - { - case 0: - __UserId__ = reader.ReadInt32(); - break; - case 1: - __RoomId__ = reader.ReadInt32(); - break; - case 2: - __PostTime__ = formatterResolver.GetFormatterWithVerify().Deserialize(ref reader, options); - break; - case 3: - __Body__ = formatterResolver.GetFormatterWithVerify().Deserialize(ref reader, options); - break; - default: - reader.Skip(); - break; - } - } - - var ____result = new global::Message(); - ____result.UserId = __UserId__; - ____result.RoomId = __RoomId__; - ____result.PostTime = __PostTime__; - ____result.Body = __Body__; - return ____result; - } - } - - public sealed class TextMessageBodyFormatter : global::MessagePack.Formatters.IMessagePackFormatter - { - - - public void Serialize(ref MessagePackWriter writer, global::TextMessageBody value, global::MessagePack.MessagePackSerializerOptions options) - { - if (value == null) - { - writer.WriteNil(); - return; - } - - IFormatterResolver formatterResolver = options.Resolver; - writer.WriteArrayHeader(1); - formatterResolver.GetFormatterWithVerify().Serialize(ref writer, value.Text, options); - } - - public global::TextMessageBody Deserialize(ref MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - if (reader.TryReadNil()) - { - return null; - } - - IFormatterResolver formatterResolver = options.Resolver; - var length = reader.ReadArrayHeader(); - var __Text__ = default(string); - - for (int i = 0; i < length; i++) - { - var key = i; - - switch (key) - { - case 0: - __Text__ = formatterResolver.GetFormatterWithVerify().Deserialize(ref reader, options); - break; - default: - reader.Skip(); - break; - } - } - - var ____result = new global::TextMessageBody(); - ____result.Text = __Text__; - return ____result; - } - } - - public sealed class StampMessageBodyFormatter : global::MessagePack.Formatters.IMessagePackFormatter - { - - - public void Serialize(ref MessagePackWriter writer, global::StampMessageBody value, global::MessagePack.MessagePackSerializerOptions options) - { - if (value == null) - { - writer.WriteNil(); - return; - } - - IFormatterResolver formatterResolver = options.Resolver; - writer.WriteArrayHeader(1); - writer.Write(value.StampId); - } - - public global::StampMessageBody Deserialize(ref MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - if (reader.TryReadNil()) - { - return null; - } - - IFormatterResolver formatterResolver = options.Resolver; - var length = reader.ReadArrayHeader(); - var __StampId__ = default(int); - - for (int i = 0; i < length; i++) - { - var key = i; - - switch (key) - { - case 0: - __StampId__ = reader.ReadInt32(); - break; - default: - reader.Skip(); - break; - } - } - - var ____result = new global::StampMessageBody(); - ____result.StampId = __StampId__; - return ____result; - } - } - - public sealed class QuestMessageBodyFormatter : global::MessagePack.Formatters.IMessagePackFormatter - { - - - public void Serialize(ref MessagePackWriter writer, global::QuestMessageBody value, global::MessagePack.MessagePackSerializerOptions options) - { - if (value == null) - { - writer.WriteNil(); - return; - } - - IFormatterResolver formatterResolver = options.Resolver; - writer.WriteArrayHeader(2); - writer.Write(value.QuestId); - formatterResolver.GetFormatterWithVerify().Serialize(ref writer, value.Text, options); - } - - public global::QuestMessageBody Deserialize(ref MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - if (reader.TryReadNil()) - { - return null; - } - - IFormatterResolver formatterResolver = options.Resolver; - var length = reader.ReadArrayHeader(); - var __QuestId__ = default(int); - var __Text__ = default(string); - - for (int i = 0; i < length; i++) - { - var key = i; - - switch (key) - { - case 0: - __QuestId__ = reader.ReadInt32(); - break; - case 1: - __Text__ = formatterResolver.GetFormatterWithVerify().Deserialize(ref reader, options); - break; - default: - reader.Skip(); - break; - } - } - - var ____result = new global::QuestMessageBody(); - ____result.QuestId = __QuestId__; - ____result.Text = __Text__; - return ____result; - } - } - - public sealed class ArrayTestTestFormatter : global::MessagePack.Formatters.IMessagePackFormatter - { - - - public void Serialize(ref MessagePackWriter writer, global::ArrayTestTest value, global::MessagePack.MessagePackSerializerOptions options) - { - if (value == null) - { - writer.WriteNil(); - return; - } - - IFormatterResolver formatterResolver = options.Resolver; - writer.WriteArrayHeader(7); - formatterResolver.GetFormatterWithVerify().Serialize(ref writer, value.MyProperty0, options); - formatterResolver.GetFormatterWithVerify().Serialize(ref writer, value.MyProperty1, options); - formatterResolver.GetFormatterWithVerify().Serialize(ref writer, value.MyProperty2, options); - formatterResolver.GetFormatterWithVerify().Serialize(ref writer, value.MyProperty3, options); - formatterResolver.GetFormatterWithVerify().Serialize(ref writer, value.MyProperty4, options); - formatterResolver.GetFormatterWithVerify().Serialize(ref writer, value.MyProperty5, options); - formatterResolver.GetFormatterWithVerify().Serialize(ref writer, value.MyProperty6, options); - } - - public global::ArrayTestTest Deserialize(ref MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - if (reader.TryReadNil()) - { - return null; - } - - IFormatterResolver formatterResolver = options.Resolver; - var length = reader.ReadArrayHeader(); - var __MyProperty0__ = default(int[]); - var __MyProperty1__ = default(int[,]); - var __MyProperty2__ = default(global::GlobalMyEnum[,]); - var __MyProperty3__ = default(int[,,]); - var __MyProperty4__ = default(int[,,,]); - var __MyProperty5__ = default(global::GlobalMyEnum[]); - var __MyProperty6__ = default(global::QuestMessageBody[]); - - for (int i = 0; i < length; i++) - { - var key = i; - - switch (key) - { - case 0: - __MyProperty0__ = formatterResolver.GetFormatterWithVerify().Deserialize(ref reader, options); - break; - case 1: - __MyProperty1__ = formatterResolver.GetFormatterWithVerify().Deserialize(ref reader, options); - break; - case 2: - __MyProperty2__ = formatterResolver.GetFormatterWithVerify().Deserialize(ref reader, options); - break; - case 3: - __MyProperty3__ = formatterResolver.GetFormatterWithVerify().Deserialize(ref reader, options); - break; - case 4: - __MyProperty4__ = formatterResolver.GetFormatterWithVerify().Deserialize(ref reader, options); - break; - case 5: - __MyProperty5__ = formatterResolver.GetFormatterWithVerify().Deserialize(ref reader, options); - break; - case 6: - __MyProperty6__ = formatterResolver.GetFormatterWithVerify().Deserialize(ref reader, options); - break; - default: - reader.Skip(); - break; - } - } - - var ____result = new global::ArrayTestTest(); - ____result.MyProperty0 = __MyProperty0__; - ____result.MyProperty1 = __MyProperty1__; - ____result.MyProperty2 = __MyProperty2__; - ____result.MyProperty3 = __MyProperty3__; - ____result.MyProperty4 = __MyProperty4__; - ____result.MyProperty5 = __MyProperty5__; - ____result.MyProperty6 = __MyProperty6__; - return ____result; - } - } - - public sealed class SimpleModelFormatter : global::MessagePack.Formatters.IMessagePackFormatter - { - - - private readonly global::MessagePack.Internal.AutomataDictionary ____keyMapping; - private readonly byte[][] ____stringByteKeys; - - public SimpleModelFormatter() - { - this.____keyMapping = new global::MessagePack.Internal.AutomataDictionary() - { - { "Id", 0 }, - { "Name", 1 }, - { "CreatedOn", 2 }, - { "Precision", 3 }, - { "Money", 4 }, - { "Amount", 5 }, - }; - - this.____stringByteKeys = new byte[][] - { - global::MessagePack.Internal.CodeGenHelpers.GetEncodedStringBytes("Id"), - global::MessagePack.Internal.CodeGenHelpers.GetEncodedStringBytes("Name"), - global::MessagePack.Internal.CodeGenHelpers.GetEncodedStringBytes("CreatedOn"), - global::MessagePack.Internal.CodeGenHelpers.GetEncodedStringBytes("Precision"), - global::MessagePack.Internal.CodeGenHelpers.GetEncodedStringBytes("Money"), - global::MessagePack.Internal.CodeGenHelpers.GetEncodedStringBytes("Amount"), - }; - } - - public void Serialize(ref MessagePackWriter writer, global::SimpleModel value, global::MessagePack.MessagePackSerializerOptions options) - { - if (value == null) - { - writer.WriteNil(); - return; - } - - IFormatterResolver formatterResolver = options.Resolver; - writer.WriteMapHeader(6); - writer.WriteRaw(this.____stringByteKeys[0]); - writer.Write(value.Id); - writer.WriteRaw(this.____stringByteKeys[1]); - formatterResolver.GetFormatterWithVerify().Serialize(ref writer, value.Name, options); - writer.WriteRaw(this.____stringByteKeys[2]); - formatterResolver.GetFormatterWithVerify().Serialize(ref writer, value.CreatedOn, options); - writer.WriteRaw(this.____stringByteKeys[3]); - writer.Write(value.Precision); - writer.WriteRaw(this.____stringByteKeys[4]); - formatterResolver.GetFormatterWithVerify().Serialize(ref writer, value.Money, options); - writer.WriteRaw(this.____stringByteKeys[5]); - writer.Write(value.Amount); - } - - public global::SimpleModel Deserialize(ref MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - if (reader.TryReadNil()) - { - return null; - } - - IFormatterResolver formatterResolver = options.Resolver; - var length = reader.ReadMapHeader(); - var __Id__ = default(int); - var __Name__ = default(string); - var __CreatedOn__ = default(global::System.DateTime); - var __Precision__ = default(int); - var __Money__ = default(decimal); - var __Amount__ = default(long); - - for (int i = 0; i < length; i++) - { - ReadOnlySequence stringKey = reader.ReadStringSequence().Value; - int key; - if (!this.____keyMapping.TryGetValue(stringKey, out key)) - { - reader.Skip(); - continue; - } - - switch (key) - { - case 0: - __Id__ = reader.ReadInt32(); - break; - case 1: - __Name__ = formatterResolver.GetFormatterWithVerify().Deserialize(ref reader, options); - break; - case 2: - __CreatedOn__ = formatterResolver.GetFormatterWithVerify().Deserialize(ref reader, options); - break; - case 3: - __Precision__ = reader.ReadInt32(); - break; - case 4: - __Money__ = formatterResolver.GetFormatterWithVerify().Deserialize(ref reader, options); - break; - case 5: - __Amount__ = reader.ReadInt64(); - break; - default: - reader.Skip(); - break; - } - } - - var ____result = new global::SimpleModel(); - ____result.Id = __Id__; - ____result.Name = __Name__; - ____result.CreatedOn = __CreatedOn__; - ____result.Precision = __Precision__; - ____result.Money = __Money__; - return ____result; - } - } - - public sealed class ComplexModelFormatter : global::MessagePack.Formatters.IMessagePackFormatter - { - - - private readonly global::MessagePack.Internal.AutomataDictionary ____keyMapping; - private readonly byte[][] ____stringByteKeys; - - public ComplexModelFormatter() - { - this.____keyMapping = new global::MessagePack.Internal.AutomataDictionary() - { - { "AdditionalProperty", 0 }, - { "CreatedOn", 1 }, - { "Id", 2 }, - { "Name", 3 }, - { "UpdatedOn", 4 }, - { "SimpleModels", 5 }, - }; - - this.____stringByteKeys = new byte[][] - { - global::MessagePack.Internal.CodeGenHelpers.GetEncodedStringBytes("AdditionalProperty"), - global::MessagePack.Internal.CodeGenHelpers.GetEncodedStringBytes("CreatedOn"), - global::MessagePack.Internal.CodeGenHelpers.GetEncodedStringBytes("Id"), - global::MessagePack.Internal.CodeGenHelpers.GetEncodedStringBytes("Name"), - global::MessagePack.Internal.CodeGenHelpers.GetEncodedStringBytes("UpdatedOn"), - global::MessagePack.Internal.CodeGenHelpers.GetEncodedStringBytes("SimpleModels"), - }; - } - - public void Serialize(ref MessagePackWriter writer, global::ComplexModel value, global::MessagePack.MessagePackSerializerOptions options) - { - if (value == null) - { - writer.WriteNil(); - return; - } - - IFormatterResolver formatterResolver = options.Resolver; - writer.WriteMapHeader(6); - writer.WriteRaw(this.____stringByteKeys[0]); - formatterResolver.GetFormatterWithVerify>().Serialize(ref writer, value.AdditionalProperty, options); - writer.WriteRaw(this.____stringByteKeys[1]); - formatterResolver.GetFormatterWithVerify().Serialize(ref writer, value.CreatedOn, options); - writer.WriteRaw(this.____stringByteKeys[2]); - formatterResolver.GetFormatterWithVerify().Serialize(ref writer, value.Id, options); - writer.WriteRaw(this.____stringByteKeys[3]); - formatterResolver.GetFormatterWithVerify().Serialize(ref writer, value.Name, options); - writer.WriteRaw(this.____stringByteKeys[4]); - formatterResolver.GetFormatterWithVerify().Serialize(ref writer, value.UpdatedOn, options); - writer.WriteRaw(this.____stringByteKeys[5]); - formatterResolver.GetFormatterWithVerify>().Serialize(ref writer, value.SimpleModels, options); - } - - public global::ComplexModel Deserialize(ref MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - if (reader.TryReadNil()) - { - return null; - } - - IFormatterResolver formatterResolver = options.Resolver; - var length = reader.ReadMapHeader(); - var __AdditionalProperty__ = default(global::System.Collections.Generic.IDictionary); - var __CreatedOn__ = default(global::System.DateTimeOffset); - var __Id__ = default(global::System.Guid); - var __Name__ = default(string); - var __UpdatedOn__ = default(global::System.DateTimeOffset); - var __SimpleModels__ = default(global::System.Collections.Generic.IList); - - for (int i = 0; i < length; i++) - { - ReadOnlySequence stringKey = reader.ReadStringSequence().Value; - int key; - if (!this.____keyMapping.TryGetValue(stringKey, out key)) - { - reader.Skip(); - continue; - } - - switch (key) - { - case 0: - __AdditionalProperty__ = formatterResolver.GetFormatterWithVerify>().Deserialize(ref reader, options); - break; - case 1: - __CreatedOn__ = formatterResolver.GetFormatterWithVerify().Deserialize(ref reader, options); - break; - case 2: - __Id__ = formatterResolver.GetFormatterWithVerify().Deserialize(ref reader, options); - break; - case 3: - __Name__ = formatterResolver.GetFormatterWithVerify().Deserialize(ref reader, options); - break; - case 4: - __UpdatedOn__ = formatterResolver.GetFormatterWithVerify().Deserialize(ref reader, options); - break; - case 5: - __SimpleModels__ = formatterResolver.GetFormatterWithVerify>().Deserialize(ref reader, options); - break; - default: - reader.Skip(); - break; - } - } - - var ____result = new global::ComplexModel(); - ____result.CreatedOn = __CreatedOn__; - ____result.Id = __Id__; - ____result.Name = __Name__; - ____result.UpdatedOn = __UpdatedOn__; - return ____result; - } - } -} - -#pragma warning restore 168 -#pragma warning restore 414 -#pragma warning restore 618 -#pragma warning restore 612 - -#pragma warning restore SA1129 // Do not use default value type constructor -#pragma warning restore SA1200 // Using directives should be placed correctly -#pragma warning restore SA1309 // Field names should not begin with underscore -#pragma warning restore SA1312 // Variable names should begin with lower-case letter -#pragma warning restore SA1403 // File may only contain a single namespace -#pragma warning restore SA1649 // File name should match first type name - -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 168 - -#pragma warning disable SA1129 // Do not use default value type constructor -#pragma warning disable SA1200 // Using directives should be placed correctly -#pragma warning disable SA1309 // Field names should not begin with underscore -#pragma warning disable SA1312 // Variable names should begin with lower-case letter -#pragma warning disable SA1403 // File may only contain a single namespace -#pragma warning disable SA1649 // File name should match first type name - -namespace MessagePack.Formatters.PerfBenchmarkDotNet -{ - using System; - using System.Buffers; - using MessagePack; - - public sealed class StringKeySerializerTargetFormatter : global::MessagePack.Formatters.IMessagePackFormatter - { - - - private readonly global::MessagePack.Internal.AutomataDictionary ____keyMapping; - private readonly byte[][] ____stringByteKeys; - - public StringKeySerializerTargetFormatter() - { - this.____keyMapping = new global::MessagePack.Internal.AutomataDictionary() - { - { "MyProperty1", 0 }, - { "MyProperty2", 1 }, - { "MyProperty3", 2 }, - { "MyProperty4", 3 }, - { "MyProperty5", 4 }, - { "MyProperty6", 5 }, - { "MyProperty7", 6 }, - { "MyProperty8", 7 }, - { "MyProperty9", 8 }, - }; - - this.____stringByteKeys = new byte[][] - { - global::MessagePack.Internal.CodeGenHelpers.GetEncodedStringBytes("MyProperty1"), - global::MessagePack.Internal.CodeGenHelpers.GetEncodedStringBytes("MyProperty2"), - global::MessagePack.Internal.CodeGenHelpers.GetEncodedStringBytes("MyProperty3"), - global::MessagePack.Internal.CodeGenHelpers.GetEncodedStringBytes("MyProperty4"), - global::MessagePack.Internal.CodeGenHelpers.GetEncodedStringBytes("MyProperty5"), - global::MessagePack.Internal.CodeGenHelpers.GetEncodedStringBytes("MyProperty6"), - global::MessagePack.Internal.CodeGenHelpers.GetEncodedStringBytes("MyProperty7"), - global::MessagePack.Internal.CodeGenHelpers.GetEncodedStringBytes("MyProperty8"), - global::MessagePack.Internal.CodeGenHelpers.GetEncodedStringBytes("MyProperty9"), - }; - } - - public void Serialize(ref MessagePackWriter writer, global::PerfBenchmarkDotNet.StringKeySerializerTarget value, global::MessagePack.MessagePackSerializerOptions options) - { - if (value == null) - { - writer.WriteNil(); - return; - } - - IFormatterResolver formatterResolver = options.Resolver; - writer.WriteMapHeader(9); - writer.WriteRaw(this.____stringByteKeys[0]); - writer.Write(value.MyProperty1); - writer.WriteRaw(this.____stringByteKeys[1]); - writer.Write(value.MyProperty2); - writer.WriteRaw(this.____stringByteKeys[2]); - writer.Write(value.MyProperty3); - writer.WriteRaw(this.____stringByteKeys[3]); - writer.Write(value.MyProperty4); - writer.WriteRaw(this.____stringByteKeys[4]); - writer.Write(value.MyProperty5); - writer.WriteRaw(this.____stringByteKeys[5]); - writer.Write(value.MyProperty6); - writer.WriteRaw(this.____stringByteKeys[6]); - writer.Write(value.MyProperty7); - writer.WriteRaw(this.____stringByteKeys[7]); - writer.Write(value.MyProperty8); - writer.WriteRaw(this.____stringByteKeys[8]); - writer.Write(value.MyProperty9); - } - - public global::PerfBenchmarkDotNet.StringKeySerializerTarget Deserialize(ref MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - if (reader.TryReadNil()) - { - return null; - } - - IFormatterResolver formatterResolver = options.Resolver; - var length = reader.ReadMapHeader(); - var __MyProperty1__ = default(int); - var __MyProperty2__ = default(int); - var __MyProperty3__ = default(int); - var __MyProperty4__ = default(int); - var __MyProperty5__ = default(int); - var __MyProperty6__ = default(int); - var __MyProperty7__ = default(int); - var __MyProperty8__ = default(int); - var __MyProperty9__ = default(int); - - for (int i = 0; i < length; i++) - { - ReadOnlySequence stringKey = reader.ReadStringSequence().Value; - int key; - if (!this.____keyMapping.TryGetValue(stringKey, out key)) - { - reader.Skip(); - continue; - } - - switch (key) - { - case 0: - __MyProperty1__ = reader.ReadInt32(); - break; - case 1: - __MyProperty2__ = reader.ReadInt32(); - break; - case 2: - __MyProperty3__ = reader.ReadInt32(); - break; - case 3: - __MyProperty4__ = reader.ReadInt32(); - break; - case 4: - __MyProperty5__ = reader.ReadInt32(); - break; - case 5: - __MyProperty6__ = reader.ReadInt32(); - break; - case 6: - __MyProperty7__ = reader.ReadInt32(); - break; - case 7: - __MyProperty8__ = reader.ReadInt32(); - break; - case 8: - __MyProperty9__ = reader.ReadInt32(); - break; - default: - reader.Skip(); - break; - } - } - - var ____result = new global::PerfBenchmarkDotNet.StringKeySerializerTarget(); - ____result.MyProperty1 = __MyProperty1__; - ____result.MyProperty2 = __MyProperty2__; - ____result.MyProperty3 = __MyProperty3__; - ____result.MyProperty4 = __MyProperty4__; - ____result.MyProperty5 = __MyProperty5__; - ____result.MyProperty6 = __MyProperty6__; - ____result.MyProperty7 = __MyProperty7__; - ____result.MyProperty8 = __MyProperty8__; - ____result.MyProperty9 = __MyProperty9__; - return ____result; - } - } -} - -#pragma warning restore 168 -#pragma warning restore 414 -#pragma warning restore 618 -#pragma warning restore 612 - -#pragma warning restore SA1129 // Do not use default value type constructor -#pragma warning restore SA1200 // Using directives should be placed correctly -#pragma warning restore SA1309 // Field names should not begin with underscore -#pragma warning restore SA1312 // Variable names should begin with lower-case letter -#pragma warning restore SA1403 // File may only contain a single namespace -#pragma warning restore SA1649 // File name should match first type name - -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 168 - -#pragma warning disable SA1129 // Do not use default value type constructor -#pragma warning disable SA1200 // Using directives should be placed correctly -#pragma warning disable SA1309 // Field names should not begin with underscore -#pragma warning disable SA1312 // Variable names should begin with lower-case letter -#pragma warning disable SA1403 // File may only contain a single namespace -#pragma warning disable SA1649 // File name should match first type name - -namespace MessagePack.Formatters.MessagePack.Tests -{ - using System; - using System.Buffers; - using MessagePack; - - public sealed class DynamicObjectResolverConstructorTest_TestConstructor1Formatter : global::MessagePack.Formatters.IMessagePackFormatter - { - - - private readonly global::MessagePack.Internal.AutomataDictionary ____keyMapping; - private readonly byte[][] ____stringByteKeys; - - public DynamicObjectResolverConstructorTest_TestConstructor1Formatter() - { - this.____keyMapping = new global::MessagePack.Internal.AutomataDictionary() - { - { "X", 0 }, - { "Y", 1 }, - { "Z", 2 }, - }; - - this.____stringByteKeys = new byte[][] - { - global::MessagePack.Internal.CodeGenHelpers.GetEncodedStringBytes("X"), - global::MessagePack.Internal.CodeGenHelpers.GetEncodedStringBytes("Y"), - global::MessagePack.Internal.CodeGenHelpers.GetEncodedStringBytes("Z"), - }; - } - - public void Serialize(ref MessagePackWriter writer, global::MessagePack.Tests.DynamicObjectResolverConstructorTest.TestConstructor1 value, global::MessagePack.MessagePackSerializerOptions options) - { - if (value == null) - { - writer.WriteNil(); - return; - } - - IFormatterResolver formatterResolver = options.Resolver; - writer.WriteMapHeader(3); - writer.WriteRaw(this.____stringByteKeys[0]); - writer.Write(value.X); - writer.WriteRaw(this.____stringByteKeys[1]); - writer.Write(value.Y); - writer.WriteRaw(this.____stringByteKeys[2]); - writer.Write(value.Z); - } - - public global::MessagePack.Tests.DynamicObjectResolverConstructorTest.TestConstructor1 Deserialize(ref MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - if (reader.TryReadNil()) - { - return null; - } - - IFormatterResolver formatterResolver = options.Resolver; - var length = reader.ReadMapHeader(); - var __X__ = default(int); - var __Y__ = default(int); - var __Z__ = default(int); - - for (int i = 0; i < length; i++) - { - ReadOnlySequence stringKey = reader.ReadStringSequence().Value; - int key; - if (!this.____keyMapping.TryGetValue(stringKey, out key)) - { - reader.Skip(); - continue; - } - - switch (key) - { - case 0: - __X__ = reader.ReadInt32(); - break; - case 1: - __Y__ = reader.ReadInt32(); - break; - case 2: - __Z__ = reader.ReadInt32(); - break; - default: - reader.Skip(); - break; - } - } - - var ____result = new global::MessagePack.Tests.DynamicObjectResolverConstructorTest.TestConstructor1(__X__, __Y__, __Z__); - return ____result; - } - } - - public sealed class DynamicObjectResolverConstructorTest_TestConstructor2Formatter : global::MessagePack.Formatters.IMessagePackFormatter - { - - - public void Serialize(ref MessagePackWriter writer, global::MessagePack.Tests.DynamicObjectResolverConstructorTest.TestConstructor2 value, global::MessagePack.MessagePackSerializerOptions options) - { - if (value == null) - { - writer.WriteNil(); - return; - } - - IFormatterResolver formatterResolver = options.Resolver; - writer.WriteArrayHeader(3); - writer.Write(value.X); - writer.Write(value.Y); - writer.Write(value.Z); - } - - public global::MessagePack.Tests.DynamicObjectResolverConstructorTest.TestConstructor2 Deserialize(ref MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - if (reader.TryReadNil()) - { - return null; - } - - IFormatterResolver formatterResolver = options.Resolver; - var length = reader.ReadArrayHeader(); - var __X__ = default(int); - var __Y__ = default(int); - var __Z__ = default(int); - - for (int i = 0; i < length; i++) - { - var key = i; - - switch (key) - { - case 0: - __X__ = reader.ReadInt32(); - break; - case 1: - __Y__ = reader.ReadInt32(); - break; - case 2: - __Z__ = reader.ReadInt32(); - break; - default: - reader.Skip(); - break; - } - } - - var ____result = new global::MessagePack.Tests.DynamicObjectResolverConstructorTest.TestConstructor2(__X__, __Y__, __Z__); - return ____result; - } - } - - public sealed class DynamicObjectResolverConstructorTest_TestConstructor3Formatter : global::MessagePack.Formatters.IMessagePackFormatter - { - - - public void Serialize(ref MessagePackWriter writer, global::MessagePack.Tests.DynamicObjectResolverConstructorTest.TestConstructor3 value, global::MessagePack.MessagePackSerializerOptions options) - { - if (value == null) - { - writer.WriteNil(); - return; - } - - IFormatterResolver formatterResolver = options.Resolver; - writer.WriteArrayHeader(3); - writer.Write(value.X); - writer.Write(value.Y); - writer.Write(value.Z); - } - - public global::MessagePack.Tests.DynamicObjectResolverConstructorTest.TestConstructor3 Deserialize(ref MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - if (reader.TryReadNil()) - { - return null; - } - - IFormatterResolver formatterResolver = options.Resolver; - var length = reader.ReadArrayHeader(); - var __X__ = default(int); - var __Y__ = default(int); - var __Z__ = default(int); - - for (int i = 0; i < length; i++) - { - var key = i; - - switch (key) - { - case 0: - __X__ = reader.ReadInt32(); - break; - case 1: - __Y__ = reader.ReadInt32(); - break; - case 2: - __Z__ = reader.ReadInt32(); - break; - default: - reader.Skip(); - break; - } - } - - var ____result = new global::MessagePack.Tests.DynamicObjectResolverConstructorTest.TestConstructor3(__X__, __Y__); - return ____result; - } - } - - public sealed class DynamicObjectResolverOrderTest_OrderOrderFormatter : global::MessagePack.Formatters.IMessagePackFormatter - { - - - private readonly global::MessagePack.Internal.AutomataDictionary ____keyMapping; - private readonly byte[][] ____stringByteKeys; - - public DynamicObjectResolverOrderTest_OrderOrderFormatter() - { - this.____keyMapping = new global::MessagePack.Internal.AutomataDictionary() - { - { "Foo", 0 }, - { "Moge", 1 }, - { "FooBar", 2 }, - { "NoBar", 3 }, - { "Bar", 4 }, - }; - - this.____stringByteKeys = new byte[][] - { - global::MessagePack.Internal.CodeGenHelpers.GetEncodedStringBytes("Foo"), - global::MessagePack.Internal.CodeGenHelpers.GetEncodedStringBytes("Moge"), - global::MessagePack.Internal.CodeGenHelpers.GetEncodedStringBytes("FooBar"), - global::MessagePack.Internal.CodeGenHelpers.GetEncodedStringBytes("NoBar"), - global::MessagePack.Internal.CodeGenHelpers.GetEncodedStringBytes("Bar"), - }; - } - - public void Serialize(ref MessagePackWriter writer, global::MessagePack.Tests.DynamicObjectResolverOrderTest.OrderOrder value, global::MessagePack.MessagePackSerializerOptions options) - { - if (value == null) - { - writer.WriteNil(); - return; - } - - IFormatterResolver formatterResolver = options.Resolver; - writer.WriteMapHeader(5); - writer.WriteRaw(this.____stringByteKeys[0]); - writer.Write(value.Foo); - writer.WriteRaw(this.____stringByteKeys[1]); - writer.Write(value.Moge); - writer.WriteRaw(this.____stringByteKeys[2]); - writer.Write(value.FooBar); - writer.WriteRaw(this.____stringByteKeys[3]); - formatterResolver.GetFormatterWithVerify().Serialize(ref writer, value.NoBar, options); - writer.WriteRaw(this.____stringByteKeys[4]); - formatterResolver.GetFormatterWithVerify().Serialize(ref writer, value.Bar, options); - } - - public global::MessagePack.Tests.DynamicObjectResolverOrderTest.OrderOrder Deserialize(ref MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - if (reader.TryReadNil()) - { - return null; - } - - IFormatterResolver formatterResolver = options.Resolver; - var length = reader.ReadMapHeader(); - var __Foo__ = default(int); - var __Moge__ = default(int); - var __FooBar__ = default(int); - var __NoBar__ = default(string); - var __Bar__ = default(string); - - for (int i = 0; i < length; i++) - { - ReadOnlySequence stringKey = reader.ReadStringSequence().Value; - int key; - if (!this.____keyMapping.TryGetValue(stringKey, out key)) - { - reader.Skip(); - continue; - } - - switch (key) - { - case 0: - __Foo__ = reader.ReadInt32(); - break; - case 1: - __Moge__ = reader.ReadInt32(); - break; - case 2: - __FooBar__ = reader.ReadInt32(); - break; - case 3: - __NoBar__ = formatterResolver.GetFormatterWithVerify().Deserialize(ref reader, options); - break; - case 4: - __Bar__ = formatterResolver.GetFormatterWithVerify().Deserialize(ref reader, options); - break; - default: - reader.Skip(); - break; - } - } - - var ____result = new global::MessagePack.Tests.DynamicObjectResolverOrderTest.OrderOrder(); - ____result.Foo = __Foo__; - ____result.Moge = __Moge__; - ____result.FooBar = __FooBar__; - ____result.NoBar = __NoBar__; - ____result.Bar = __Bar__; - return ____result; - } - } - - public sealed class IgnoreTest_ViewModelFormatter : global::MessagePack.Formatters.IMessagePackFormatter - { - - - private readonly global::MessagePack.Internal.AutomataDictionary ____keyMapping; - private readonly byte[][] ____stringByteKeys; - - public IgnoreTest_ViewModelFormatter() - { - this.____keyMapping = new global::MessagePack.Internal.AutomataDictionary() - { - { "MyProperty1", 0 }, - { "MyProperty2", 1 }, - }; - - this.____stringByteKeys = new byte[][] - { - global::MessagePack.Internal.CodeGenHelpers.GetEncodedStringBytes("MyProperty1"), - global::MessagePack.Internal.CodeGenHelpers.GetEncodedStringBytes("MyProperty2"), - }; - } - - public void Serialize(ref MessagePackWriter writer, global::MessagePack.Tests.IgnoreTest.ViewModel value, global::MessagePack.MessagePackSerializerOptions options) - { - if (value == null) - { - writer.WriteNil(); - return; - } - - IFormatterResolver formatterResolver = options.Resolver; - writer.WriteMapHeader(2); - writer.WriteRaw(this.____stringByteKeys[0]); - writer.Write(value.MyProperty1); - writer.WriteRaw(this.____stringByteKeys[1]); - writer.Write(value.MyProperty2); - } - - public global::MessagePack.Tests.IgnoreTest.ViewModel Deserialize(ref MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - if (reader.TryReadNil()) - { - return null; - } - - IFormatterResolver formatterResolver = options.Resolver; - var length = reader.ReadMapHeader(); - var __MyProperty1__ = default(int); - var __MyProperty2__ = default(int); - - for (int i = 0; i < length; i++) - { - ReadOnlySequence stringKey = reader.ReadStringSequence().Value; - int key; - if (!this.____keyMapping.TryGetValue(stringKey, out key)) - { - reader.Skip(); - continue; - } - - switch (key) - { - case 0: - __MyProperty1__ = reader.ReadInt32(); - break; - case 1: - __MyProperty2__ = reader.ReadInt32(); - break; - default: - reader.Skip(); - break; - } - } - - var ____result = new global::MessagePack.Tests.IgnoreTest.ViewModel(); - ____result.MyProperty1 = __MyProperty1__; - ____result.MyProperty2 = __MyProperty2__; - return ____result; - } - } - - public sealed class MessagePackFormatterPerFieldTest_MyClassFormatter : global::MessagePack.Formatters.IMessagePackFormatter - { - global::MessagePack.Tests.MessagePackFormatterPerFieldTest.Int_x10Formatter __MyProperty1CustomFormatter__ = new global::MessagePack.Tests.MessagePackFormatterPerFieldTest.Int_x10Formatter(); - global::MessagePack.Tests.MessagePackFormatterPerFieldTest.String_x2Formatter __MyProperty3CustomFormatter__ = new global::MessagePack.Tests.MessagePackFormatterPerFieldTest.String_x2Formatter(); - - - public void Serialize(ref MessagePackWriter writer, global::MessagePack.Tests.MessagePackFormatterPerFieldTest.MyClass value, global::MessagePack.MessagePackSerializerOptions options) - { - if (value == null) - { - writer.WriteNil(); - return; - } - - IFormatterResolver formatterResolver = options.Resolver; - writer.WriteArrayHeader(4); - this.__MyProperty1CustomFormatter__.Serialize(ref writer, value.MyProperty1, options); - writer.Write(value.MyProperty2); - this.__MyProperty3CustomFormatter__.Serialize(ref writer, value.MyProperty3, options); - formatterResolver.GetFormatterWithVerify().Serialize(ref writer, value.MyProperty4, options); - } - - public global::MessagePack.Tests.MessagePackFormatterPerFieldTest.MyClass Deserialize(ref MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - if (reader.TryReadNil()) - { - return null; - } - - IFormatterResolver formatterResolver = options.Resolver; - var length = reader.ReadArrayHeader(); - var __MyProperty1__ = default(int); - var __MyProperty2__ = default(int); - var __MyProperty3__ = default(string); - var __MyProperty4__ = default(string); - - for (int i = 0; i < length; i++) - { - var key = i; - - switch (key) - { - case 0: - __MyProperty1__ = this.__MyProperty1CustomFormatter__.Deserialize(ref reader, options); - break; - case 1: - __MyProperty2__ = reader.ReadInt32(); - break; - case 2: - __MyProperty3__ = this.__MyProperty3CustomFormatter__.Deserialize(ref reader, options); - break; - case 3: - __MyProperty4__ = formatterResolver.GetFormatterWithVerify().Deserialize(ref reader, options); - break; - default: - reader.Skip(); - break; - } - } - - var ____result = new global::MessagePack.Tests.MessagePackFormatterPerFieldTest.MyClass(); - ____result.MyProperty1 = __MyProperty1__; - ____result.MyProperty2 = __MyProperty2__; - ____result.MyProperty3 = __MyProperty3__; - ____result.MyProperty4 = __MyProperty4__; - return ____result; - } - } - - public sealed class MessagePackFormatterPerFieldTest_MyStructFormatter : global::MessagePack.Formatters.IMessagePackFormatter - { - global::MessagePack.Tests.MessagePackFormatterPerFieldTest.Int_x10Formatter __MyProperty1CustomFormatter__ = new global::MessagePack.Tests.MessagePackFormatterPerFieldTest.Int_x10Formatter(); - global::MessagePack.Tests.MessagePackFormatterPerFieldTest.String_x2Formatter __MyProperty3CustomFormatter__ = new global::MessagePack.Tests.MessagePackFormatterPerFieldTest.String_x2Formatter(); - - - public void Serialize(ref MessagePackWriter writer, global::MessagePack.Tests.MessagePackFormatterPerFieldTest.MyStruct value, global::MessagePack.MessagePackSerializerOptions options) - { - IFormatterResolver formatterResolver = options.Resolver; - writer.WriteArrayHeader(4); - this.__MyProperty1CustomFormatter__.Serialize(ref writer, value.MyProperty1, options); - writer.Write(value.MyProperty2); - this.__MyProperty3CustomFormatter__.Serialize(ref writer, value.MyProperty3, options); - formatterResolver.GetFormatterWithVerify().Serialize(ref writer, value.MyProperty4, options); - } - - public global::MessagePack.Tests.MessagePackFormatterPerFieldTest.MyStruct Deserialize(ref MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - if (reader.TryReadNil()) - { - throw new InvalidOperationException("typecode is null, struct not supported"); - } - - IFormatterResolver formatterResolver = options.Resolver; - var length = reader.ReadArrayHeader(); - var __MyProperty1__ = default(int); - var __MyProperty2__ = default(int); - var __MyProperty3__ = default(string); - var __MyProperty4__ = default(string); - - for (int i = 0; i < length; i++) - { - var key = i; - - switch (key) - { - case 0: - __MyProperty1__ = this.__MyProperty1CustomFormatter__.Deserialize(ref reader, options); - break; - case 1: - __MyProperty2__ = reader.ReadInt32(); - break; - case 2: - __MyProperty3__ = this.__MyProperty3CustomFormatter__.Deserialize(ref reader, options); - break; - case 3: - __MyProperty4__ = formatterResolver.GetFormatterWithVerify().Deserialize(ref reader, options); - break; - default: - reader.Skip(); - break; - } - } - - var ____result = new global::MessagePack.Tests.MessagePackFormatterPerFieldTest.MyStruct(); - ____result.MyProperty1 = __MyProperty1__; - ____result.MyProperty2 = __MyProperty2__; - ____result.MyProperty3 = __MyProperty3__; - ____result.MyProperty4 = __MyProperty4__; - return ____result; - } - } - - public sealed class NewGuidFormatterTest_InClassFormatter : global::MessagePack.Formatters.IMessagePackFormatter - { - - - private readonly global::MessagePack.Internal.AutomataDictionary ____keyMapping; - private readonly byte[][] ____stringByteKeys; - - public NewGuidFormatterTest_InClassFormatter() - { - this.____keyMapping = new global::MessagePack.Internal.AutomataDictionary() - { - { "MyProperty", 0 }, - { "Guid", 1 }, - }; - - this.____stringByteKeys = new byte[][] - { - global::MessagePack.Internal.CodeGenHelpers.GetEncodedStringBytes("MyProperty"), - global::MessagePack.Internal.CodeGenHelpers.GetEncodedStringBytes("Guid"), - }; - } - - public void Serialize(ref MessagePackWriter writer, global::MessagePack.Tests.NewGuidFormatterTest.InClass value, global::MessagePack.MessagePackSerializerOptions options) - { - if (value == null) - { - writer.WriteNil(); - return; - } - - IFormatterResolver formatterResolver = options.Resolver; - writer.WriteMapHeader(2); - writer.WriteRaw(this.____stringByteKeys[0]); - writer.Write(value.MyProperty); - writer.WriteRaw(this.____stringByteKeys[1]); - formatterResolver.GetFormatterWithVerify().Serialize(ref writer, value.Guid, options); - } - - public global::MessagePack.Tests.NewGuidFormatterTest.InClass Deserialize(ref MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - if (reader.TryReadNil()) - { - return null; - } - - IFormatterResolver formatterResolver = options.Resolver; - var length = reader.ReadMapHeader(); - var __MyProperty__ = default(int); - var __Guid__ = default(global::System.Guid); - - for (int i = 0; i < length; i++) - { - ReadOnlySequence stringKey = reader.ReadStringSequence().Value; - int key; - if (!this.____keyMapping.TryGetValue(stringKey, out key)) - { - reader.Skip(); - continue; - } - - switch (key) - { - case 0: - __MyProperty__ = reader.ReadInt32(); - break; - case 1: - __Guid__ = formatterResolver.GetFormatterWithVerify().Deserialize(ref reader, options); - break; - default: - reader.Skip(); - break; - } - } - - var ____result = new global::MessagePack.Tests.NewGuidFormatterTest.InClass(); - ____result.MyProperty = __MyProperty__; - ____result.Guid = __Guid__; - return ____result; - } - } - - public sealed class FooFormatter : global::MessagePack.Formatters.IMessagePackFormatter - { - - - private readonly global::MessagePack.Internal.AutomataDictionary ____keyMapping; - private readonly byte[][] ____stringByteKeys; - - public FooFormatter() - { - this.____keyMapping = new global::MessagePack.Internal.AutomataDictionary() - { - { "Id", 0 }, - { "Value", 1 }, - }; - - this.____stringByteKeys = new byte[][] - { - global::MessagePack.Internal.CodeGenHelpers.GetEncodedStringBytes("Id"), - global::MessagePack.Internal.CodeGenHelpers.GetEncodedStringBytes("Value"), - }; - } - - public void Serialize(ref MessagePackWriter writer, global::MessagePack.Tests.Foo value, global::MessagePack.MessagePackSerializerOptions options) - { - if (value == null) - { - writer.WriteNil(); - return; - } - - IFormatterResolver formatterResolver = options.Resolver; - writer.WriteMapHeader(2); - writer.WriteRaw(this.____stringByteKeys[0]); - writer.Write(value.Id); - writer.WriteRaw(this.____stringByteKeys[1]); - formatterResolver.GetFormatterWithVerify().Serialize(ref writer, value.Value, options); - } - - public global::MessagePack.Tests.Foo Deserialize(ref MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - if (reader.TryReadNil()) - { - return null; - } - - IFormatterResolver formatterResolver = options.Resolver; - var length = reader.ReadMapHeader(); - var __Id__ = default(int); - var __Value__ = default(byte[]); - - for (int i = 0; i < length; i++) - { - ReadOnlySequence stringKey = reader.ReadStringSequence().Value; - int key; - if (!this.____keyMapping.TryGetValue(stringKey, out key)) - { - reader.Skip(); - continue; - } - - switch (key) - { - case 0: - __Id__ = reader.ReadInt32(); - break; - case 1: - __Value__ = formatterResolver.GetFormatterWithVerify().Deserialize(ref reader, options); - break; - default: - reader.Skip(); - break; - } - } - - var ____result = new global::MessagePack.Tests.Foo(); - ____result.Id = __Id__; - ____result.Value = __Value__; - return ____result; - } - } - - public sealed class PrimitivelikeFormatterTest_MyDateTimeResolverTestFormatter : global::MessagePack.Formatters.IMessagePackFormatter - { - - - public void Serialize(ref MessagePackWriter writer, global::MessagePack.Tests.PrimitivelikeFormatterTest.MyDateTimeResolverTest value, global::MessagePack.MessagePackSerializerOptions options) - { - if (value == null) - { - writer.WriteNil(); - return; - } - - IFormatterResolver formatterResolver = options.Resolver; - writer.WriteArrayHeader(1); - formatterResolver.GetFormatterWithVerify().Serialize(ref writer, value.MyProperty1, options); - } - - public global::MessagePack.Tests.PrimitivelikeFormatterTest.MyDateTimeResolverTest Deserialize(ref MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - if (reader.TryReadNil()) - { - return null; - } - - IFormatterResolver formatterResolver = options.Resolver; - var length = reader.ReadArrayHeader(); - var __MyProperty1__ = default(global::System.DateTime); - - for (int i = 0; i < length; i++) - { - var key = i; - - switch (key) - { - case 0: - __MyProperty1__ = formatterResolver.GetFormatterWithVerify().Deserialize(ref reader, options); - break; - default: - reader.Skip(); - break; - } - } - - var ____result = new global::MessagePack.Tests.PrimitivelikeFormatterTest.MyDateTimeResolverTest(); - ____result.MyProperty1 = __MyProperty1__; - return ____result; - } - } -} - -#pragma warning restore 168 -#pragma warning restore 414 -#pragma warning restore 618 -#pragma warning restore 612 - -#pragma warning restore SA1129 // Do not use default value type constructor -#pragma warning restore SA1200 // Using directives should be placed correctly -#pragma warning restore SA1309 // Field names should not begin with underscore -#pragma warning restore SA1312 // Variable names should begin with lower-case letter -#pragma warning restore SA1403 // File may only contain a single namespace -#pragma warning restore SA1649 // File name should match first type name - -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 168 - -#pragma warning disable SA1129 // Do not use default value type constructor -#pragma warning disable SA1200 // Using directives should be placed correctly -#pragma warning disable SA1309 // Field names should not begin with underscore -#pragma warning disable SA1312 // Variable names should begin with lower-case letter -#pragma warning disable SA1403 // File may only contain a single namespace -#pragma warning disable SA1649 // File name should match first type name - -namespace MessagePack.Formatters.ComplexdUnion -{ - using System; - using System.Buffers; - using MessagePack; - - public sealed class DummyForGenerateFormatter : global::MessagePack.Formatters.IMessagePackFormatter - { - - - private readonly global::MessagePack.Internal.AutomataDictionary ____keyMapping; - private readonly byte[][] ____stringByteKeys; - - public DummyForGenerateFormatter() - { - this.____keyMapping = new global::MessagePack.Internal.AutomataDictionary() - { - { "MyProperty1", 0 }, - { "MyProperty2", 1 }, - }; - - this.____stringByteKeys = new byte[][] - { - global::MessagePack.Internal.CodeGenHelpers.GetEncodedStringBytes("MyProperty1"), - global::MessagePack.Internal.CodeGenHelpers.GetEncodedStringBytes("MyProperty2"), - }; - } - - public void Serialize(ref MessagePackWriter writer, global::ComplexdUnion.DummyForGenerate value, global::MessagePack.MessagePackSerializerOptions options) - { - if (value == null) - { - writer.WriteNil(); - return; - } - - IFormatterResolver formatterResolver = options.Resolver; - writer.WriteMapHeader(2); - writer.WriteRaw(this.____stringByteKeys[0]); - formatterResolver.GetFormatterWithVerify().Serialize(ref writer, value.MyProperty1, options); - writer.WriteRaw(this.____stringByteKeys[1]); - formatterResolver.GetFormatterWithVerify().Serialize(ref writer, value.MyProperty2, options); - } - - public global::ComplexdUnion.DummyForGenerate Deserialize(ref MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - if (reader.TryReadNil()) - { - return null; - } - - IFormatterResolver formatterResolver = options.Resolver; - var length = reader.ReadMapHeader(); - var __MyProperty1__ = default(global::ComplexdUnion.A[]); - var __MyProperty2__ = default(global::ComplexdUnion.A2[]); - - for (int i = 0; i < length; i++) - { - ReadOnlySequence stringKey = reader.ReadStringSequence().Value; - int key; - if (!this.____keyMapping.TryGetValue(stringKey, out key)) - { - reader.Skip(); - continue; - } - - switch (key) - { - case 0: - __MyProperty1__ = formatterResolver.GetFormatterWithVerify().Deserialize(ref reader, options); - break; - case 1: - __MyProperty2__ = formatterResolver.GetFormatterWithVerify().Deserialize(ref reader, options); - break; - default: - reader.Skip(); - break; - } - } - - var ____result = new global::ComplexdUnion.DummyForGenerate(); - ____result.MyProperty1 = __MyProperty1__; - ____result.MyProperty2 = __MyProperty2__; - return ____result; - } - } - - public sealed class BFormatter : global::MessagePack.Formatters.IMessagePackFormatter - { - - - public void Serialize(ref MessagePackWriter writer, global::ComplexdUnion.B value, global::MessagePack.MessagePackSerializerOptions options) - { - if (value == null) - { - writer.WriteNil(); - return; - } - - IFormatterResolver formatterResolver = options.Resolver; - writer.WriteArrayHeader(2); - formatterResolver.GetFormatterWithVerify().Serialize(ref writer, value.Name, options); - writer.Write(value.Val); - } - - public global::ComplexdUnion.B Deserialize(ref MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - if (reader.TryReadNil()) - { - return null; - } - - IFormatterResolver formatterResolver = options.Resolver; - var length = reader.ReadArrayHeader(); - var __Name__ = default(string); - var __Val__ = default(int); - - for (int i = 0; i < length; i++) - { - var key = i; - - switch (key) - { - case 0: - __Name__ = formatterResolver.GetFormatterWithVerify().Deserialize(ref reader, options); - break; - case 1: - __Val__ = reader.ReadInt32(); - break; - default: - reader.Skip(); - break; - } - } - - var ____result = new global::ComplexdUnion.B(); - ____result.Name = __Name__; - ____result.Val = __Val__; - return ____result; - } - } - - public sealed class CFormatter : global::MessagePack.Formatters.IMessagePackFormatter - { - - - public void Serialize(ref MessagePackWriter writer, global::ComplexdUnion.C value, global::MessagePack.MessagePackSerializerOptions options) - { - if (value == null) - { - writer.WriteNil(); - return; - } - - IFormatterResolver formatterResolver = options.Resolver; - writer.WriteArrayHeader(3); - formatterResolver.GetFormatterWithVerify().Serialize(ref writer, value.Name, options); - writer.Write(value.Val); - writer.Write(value.Valer); - } - - public global::ComplexdUnion.C Deserialize(ref MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - if (reader.TryReadNil()) - { - return null; - } - - IFormatterResolver formatterResolver = options.Resolver; - var length = reader.ReadArrayHeader(); - var __Name__ = default(string); - var __Val__ = default(int); - var __Valer__ = default(int); - - for (int i = 0; i < length; i++) - { - var key = i; - - switch (key) - { - case 0: - __Name__ = formatterResolver.GetFormatterWithVerify().Deserialize(ref reader, options); - break; - case 1: - __Val__ = reader.ReadInt32(); - break; - case 2: - __Valer__ = reader.ReadInt32(); - break; - default: - reader.Skip(); - break; - } - } - - var ____result = new global::ComplexdUnion.C(); - ____result.Name = __Name__; - ____result.Val = __Val__; - ____result.Valer = __Valer__; - return ____result; - } - } - - public sealed class B2Formatter : global::MessagePack.Formatters.IMessagePackFormatter - { - - - public void Serialize(ref MessagePackWriter writer, global::ComplexdUnion.B2 value, global::MessagePack.MessagePackSerializerOptions options) - { - if (value == null) - { - writer.WriteNil(); - return; - } - - IFormatterResolver formatterResolver = options.Resolver; - writer.WriteArrayHeader(2); - formatterResolver.GetFormatterWithVerify().Serialize(ref writer, value.Name, options); - writer.Write(value.Val); - } - - public global::ComplexdUnion.B2 Deserialize(ref MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - if (reader.TryReadNil()) - { - return null; - } - - IFormatterResolver formatterResolver = options.Resolver; - var length = reader.ReadArrayHeader(); - var __Name__ = default(string); - var __Val__ = default(int); - - for (int i = 0; i < length; i++) - { - var key = i; - - switch (key) - { - case 0: - __Name__ = formatterResolver.GetFormatterWithVerify().Deserialize(ref reader, options); - break; - case 1: - __Val__ = reader.ReadInt32(); - break; - default: - reader.Skip(); - break; - } - } - - var ____result = new global::ComplexdUnion.B2(); - ____result.Name = __Name__; - ____result.Val = __Val__; - return ____result; - } - } - - public sealed class C2Formatter : global::MessagePack.Formatters.IMessagePackFormatter - { - - - public void Serialize(ref MessagePackWriter writer, global::ComplexdUnion.C2 value, global::MessagePack.MessagePackSerializerOptions options) - { - if (value == null) - { - writer.WriteNil(); - return; - } - - IFormatterResolver formatterResolver = options.Resolver; - writer.WriteArrayHeader(3); - formatterResolver.GetFormatterWithVerify().Serialize(ref writer, value.Name, options); - writer.Write(value.Val); - writer.Write(value.Valer); - } - - public global::ComplexdUnion.C2 Deserialize(ref MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - if (reader.TryReadNil()) - { - return null; - } - - IFormatterResolver formatterResolver = options.Resolver; - var length = reader.ReadArrayHeader(); - var __Valer__ = default(int); - var __Name__ = default(string); - var __Val__ = default(int); - - for (int i = 0; i < length; i++) - { - var key = i; - - switch (key) - { - case 2: - __Valer__ = reader.ReadInt32(); - break; - case 0: - __Name__ = formatterResolver.GetFormatterWithVerify().Deserialize(ref reader, options); - break; - case 1: - __Val__ = reader.ReadInt32(); - break; - default: - reader.Skip(); - break; - } - } - - var ____result = new global::ComplexdUnion.C2(); - ____result.Valer = __Valer__; - ____result.Name = __Name__; - ____result.Val = __Val__; - return ____result; - } - } -} - -#pragma warning restore 168 -#pragma warning restore 414 -#pragma warning restore 618 -#pragma warning restore 612 - -#pragma warning restore SA1129 // Do not use default value type constructor -#pragma warning restore SA1200 // Using directives should be placed correctly -#pragma warning restore SA1309 // Field names should not begin with underscore -#pragma warning restore SA1312 // Variable names should begin with lower-case letter -#pragma warning restore SA1403 // File may only contain a single namespace -#pragma warning restore SA1649 // File name should match first type name - -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 168 - -#pragma warning disable SA1129 // Do not use default value type constructor -#pragma warning disable SA1200 // Using directives should be placed correctly -#pragma warning disable SA1309 // Field names should not begin with underscore -#pragma warning disable SA1312 // Variable names should begin with lower-case letter -#pragma warning disable SA1403 // File may only contain a single namespace -#pragma warning disable SA1649 // File name should match first type name - -namespace MessagePack.Formatters.ClassUnion -{ - using System; - using System.Buffers; - using MessagePack; - - public sealed class SubUnionType1Formatter : global::MessagePack.Formatters.IMessagePackFormatter - { - - - public void Serialize(ref MessagePackWriter writer, global::ClassUnion.SubUnionType1 value, global::MessagePack.MessagePackSerializerOptions options) - { - if (value == null) - { - writer.WriteNil(); - return; - } - - IFormatterResolver formatterResolver = options.Resolver; - writer.WriteArrayHeader(2); - writer.Write(value.MyProperty); - writer.Write(value.MyProperty1); - } - - public global::ClassUnion.SubUnionType1 Deserialize(ref MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - if (reader.TryReadNil()) - { - return null; - } - - IFormatterResolver formatterResolver = options.Resolver; - var length = reader.ReadArrayHeader(); - var __MyProperty1__ = default(int); - var __MyProperty__ = default(int); - - for (int i = 0; i < length; i++) - { - var key = i; - - switch (key) - { - case 1: - __MyProperty1__ = reader.ReadInt32(); - break; - case 0: - __MyProperty__ = reader.ReadInt32(); - break; - default: - reader.Skip(); - break; - } - } - - var ____result = new global::ClassUnion.SubUnionType1(); - ____result.MyProperty1 = __MyProperty1__; - ____result.MyProperty = __MyProperty__; - return ____result; - } - } - - public sealed class SubUnionType2Formatter : global::MessagePack.Formatters.IMessagePackFormatter - { - - - public void Serialize(ref MessagePackWriter writer, global::ClassUnion.SubUnionType2 value, global::MessagePack.MessagePackSerializerOptions options) - { - if (value == null) - { - writer.WriteNil(); - return; - } - - IFormatterResolver formatterResolver = options.Resolver; - writer.WriteArrayHeader(2); - writer.Write(value.MyProperty); - writer.Write(value.MyProperty2); - } - - public global::ClassUnion.SubUnionType2 Deserialize(ref MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - if (reader.TryReadNil()) - { - return null; - } - - IFormatterResolver formatterResolver = options.Resolver; - var length = reader.ReadArrayHeader(); - var __MyProperty2__ = default(int); - var __MyProperty__ = default(int); - - for (int i = 0; i < length; i++) - { - var key = i; - - switch (key) - { - case 1: - __MyProperty2__ = reader.ReadInt32(); - break; - case 0: - __MyProperty__ = reader.ReadInt32(); - break; - default: - reader.Skip(); - break; - } - } - - var ____result = new global::ClassUnion.SubUnionType2(); - ____result.MyProperty2 = __MyProperty2__; - ____result.MyProperty = __MyProperty__; - return ____result; - } - } -} - -#pragma warning restore 168 -#pragma warning restore 414 -#pragma warning restore 618 -#pragma warning restore 612 - -#pragma warning restore SA1129 // Do not use default value type constructor -#pragma warning restore SA1200 // Using directives should be placed correctly -#pragma warning restore SA1309 // Field names should not begin with underscore -#pragma warning restore SA1312 // Variable names should begin with lower-case letter -#pragma warning restore SA1403 // File may only contain a single namespace -#pragma warning restore SA1649 // File name should match first type name - diff --git a/src/MessagePack.UnityClient/Assets/Scripts/Tests/Generated/GeneratedResolver.cs.meta b/src/MessagePack.UnityClient/Assets/Scripts/Tests/Generated/GeneratedResolver.cs.meta deleted file mode 100644 index e8c3ba3b8..000000000 --- a/src/MessagePack.UnityClient/Assets/Scripts/Tests/Generated/GeneratedResolver.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 83a940d45983fcc44838973ca450dd43 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/tests/MessagePack.Generator.Tests/GenerateEnumFormatterTest.cs b/tests/MessagePack.Generator.Tests/GenerateEnumFormatterTest.cs index ce4d2098d..578014a6b 100644 --- a/tests/MessagePack.Generator.Tests/GenerateEnumFormatterTest.cs +++ b/tests/MessagePack.Generator.Tests/GenerateEnumFormatterTest.cs @@ -1,37 +1,24 @@ // Copyright (c) All contributors. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -using System; -using System.Text; -using System.Threading; -using System.Threading.Tasks; -using FluentAssertions; -using Microsoft.CodeAnalysis.Text; -using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client; -using Xunit; -using Xunit.Abstractions; -using VerifyCS = CSharpSourceGeneratorVerifier; - -namespace MessagePack.Generator.Tests +public class GenerateEnumFormatterTest { - public class GenerateEnumFormatterTest - { - private readonly ITestOutputHelper testOutputHelper; + private readonly ITestOutputHelper testOutputHelper; - public GenerateEnumFormatterTest(ITestOutputHelper testOutputHelper) - { - this.testOutputHelper = testOutputHelper; - } + public GenerateEnumFormatterTest(ITestOutputHelper testOutputHelper) + { + this.testOutputHelper = testOutputHelper; + } - [Fact] - public async Task EnumFormatter() - { - string contents = """ + [Fact] + public async Task EnumFormatter() + { + string contents = """ using System; using System.Collections.Generic; using MessagePack; -namespace TempProject; +namespace MyTestNamespace; [MessagePackObject] public class MyMessagePackObject @@ -45,147 +32,12 @@ public enum MyEnum A, B, C } """; - string generated = """ -using System.Runtime.CompilerServices; -using MessagePack; - -namespace Resolvers -{ - partial class FormatterRegister - { - [ModuleInitializer] - internal static void TempProject_MyMessagePackObjectFormatterRegister() + await new VerifyCS.Test { - MessagePack.Resolvers.StaticCompositeResolver.Instance.AddGeneratedFormatter(new global::Formatters.TempProject.MyEnumFormatter()); - MessagePack.Resolvers.StaticCompositeResolver.Instance.AddGeneratedFormatter(new global::Formatters.TempProject.MyMessagePackObjectFormatter()); - } - } -} -// - -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 168 -#pragma warning disable CS1591 // document public APIs - -#pragma warning disable SA1403 // File may only contain a single namespace -#pragma warning disable SA1649 // File name should match first type name - -namespace Formatters.TempProject -{ - - public sealed class MyEnumFormatter : global::MessagePack.Formatters.IMessagePackFormatter - { - public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::TempProject.MyEnum value, global::MessagePack.MessagePackSerializerOptions options) - { - writer.Write((global::System.Int32)value); - } - - public global::TempProject.MyEnum Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - return (global::TempProject.MyEnum)reader.ReadInt32(); - } - } -} - -#pragma warning restore 168 -#pragma warning restore 414 -#pragma warning restore 618 -#pragma warning restore 612 - -#pragma warning restore SA1403 // File may only contain a single namespace -#pragma warning restore SA1649 // File name should match first type name - - -// - -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 168 -#pragma warning disable CS1591 // document public APIs - -#pragma warning disable SA1129 // Do not use default value type constructor -#pragma warning disable SA1309 // Field names should not begin with underscore -#pragma warning disable SA1312 // Variable names should begin with lower-case letter -#pragma warning disable SA1403 // File may only contain a single namespace -#pragma warning disable SA1649 // File name should match first type name - -namespace Formatters.TempProject -{ - public sealed class MyMessagePackObjectFormatter : global::MessagePack.Formatters.IMessagePackFormatter - { - - public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::TempProject.MyMessagePackObject value, global::MessagePack.MessagePackSerializerOptions options) - { - if (value == null) - { - writer.WriteNil(); - return; - } - - global::MessagePack.IFormatterResolver formatterResolver = options.Resolver; - writer.WriteArrayHeader(1); - global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Serialize(ref writer, value.EnumValue, options); - } - - public global::TempProject.MyMessagePackObject Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - if (reader.TryReadNil()) - { - return null; - } - - options.Security.DepthStep(ref reader); - global::MessagePack.IFormatterResolver formatterResolver = options.Resolver; - var length = reader.ReadArrayHeader(); - var ____result = new global::TempProject.MyMessagePackObject(); - - for (int i = 0; i < length; i++) - { - switch (i) - { - case 0: - ____result.EnumValue = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Deserialize(ref reader, options); - break; - default: - reader.Skip(); - break; - } - } - - reader.Depth--; - return ____result; - } - } - -} - -#pragma warning restore 168 -#pragma warning restore 414 -#pragma warning restore 618 -#pragma warning restore 612 - -#pragma warning restore SA1129 // Do not use default value type constructor -#pragma warning restore SA1309 // Field names should not begin with underscore -#pragma warning restore SA1312 // Variable names should begin with lower-case letter -#pragma warning restore SA1403 // File may only contain a single namespace -#pragma warning restore SA1649 // File name should match first type name - - -"""; - await new VerifyCS.Test + TestState = { - TestState = - { - Sources = { contents }, - GeneratedSources = - { - (typeof(MessagePackGenerator), "TempProject.MyMessagePackObject.MessagePackFormatter.g.cs", SourceText.From(generated, Encoding.UTF8, SourceHashAlgorithm.Sha1)), - }, - }, - }.RunAsync(); - } + Sources = { contents }, + }, + }.AddGeneratedSources().RunAsync(); } } diff --git a/tests/MessagePack.Generator.Tests/MessagePack.Generator.Tests.csproj b/tests/MessagePack.Generator.Tests/MessagePack.Generator.Tests.csproj index 7b621b055..bea4935cb 100644 --- a/tests/MessagePack.Generator.Tests/MessagePack.Generator.Tests.csproj +++ b/tests/MessagePack.Generator.Tests/MessagePack.Generator.Tests.csproj @@ -3,6 +3,7 @@ net7.0 true + enable 11 @@ -15,6 +16,11 @@ + + + + + @@ -31,4 +37,8 @@ + + + + diff --git a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter/MyTestNamespace.MyMessagePackObject.MessagePackFormatter.g.cs b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter/MyTestNamespace.MyMessagePackObject.MessagePackFormatter.g.cs new file mode 100644 index 000000000..54bb9b826 --- /dev/null +++ b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter/MyTestNamespace.MyMessagePackObject.MessagePackFormatter.g.cs @@ -0,0 +1,147 @@ +// + +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 168 + +#pragma warning disable CS1591 // document public APIs + +#pragma warning disable SA1129 // Do not use default value type constructor +#pragma warning disable SA1309 // Field names should not begin with underscore +#pragma warning disable SA1312 // Variable names should begin with lower-case letter +#pragma warning disable SA1403 // File may only contain a single namespace +#pragma warning disable SA1649 // File name should match first type name + + +namespace MessagePack.Resolvers +{ + public class GeneratedResolver : global::MessagePack.IFormatterResolver + { + public static readonly global::MessagePack.IFormatterResolver Instance = new GeneratedResolver(); + + private GeneratedResolver() + { + } + + public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() + { + return FormatterCache.Formatter; + } + + private static class FormatterCache + { + internal static readonly global::MessagePack.Formatters.IMessagePackFormatter Formatter; + + static FormatterCache() + { + var f = GeneratedResolverGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + Formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; + } + } + } + } + + internal static class GeneratedResolverGetFormatterHelper + { + private static readonly global::System.Collections.Generic.Dictionary lookup; + + static GeneratedResolverGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(2) + { + { typeof(global::MyTestNamespace.MyEnum), 0 }, + { typeof(global::MyTestNamespace.MyMessagePackObject), 1 }, + }; + } + + internal static object GetFormatter(global::System.Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + case 0: return new MessagePack.Formatters.MyTestNamespace.MyEnumFormatter(); + case 1: return new MessagePack.Formatters.MyTestNamespace.MyMessagePackObjectFormatter(); + default: return null; + } + } + } +} + + +namespace MessagePack.Formatters.MyTestNamespace +{ + + public sealed class MyEnumFormatter : global::MessagePack.Formatters.IMessagePackFormatter + { + public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::MyTestNamespace.MyEnum value, global::MessagePack.MessagePackSerializerOptions options) + { + writer.Write((global::System.Int32)value); + } + + public global::MyTestNamespace.MyEnum Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) + { + return (global::MyTestNamespace.MyEnum)reader.ReadInt32(); + } + } +} + + + +namespace MessagePack.Formatters.MyTestNamespace +{ + public sealed class MyMessagePackObjectFormatter : global::MessagePack.Formatters.IMessagePackFormatter + { + + public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::MyTestNamespace.MyMessagePackObject value, global::MessagePack.MessagePackSerializerOptions options) + { + if (value == null) + { + writer.WriteNil(); + return; + } + + global::MessagePack.IFormatterResolver formatterResolver = options.Resolver; + writer.WriteArrayHeader(1); + global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Serialize(ref writer, value.EnumValue, options); + } + + public global::MyTestNamespace.MyMessagePackObject Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) + { + if (reader.TryReadNil()) + { + return null; + } + + options.Security.DepthStep(ref reader); + global::MessagePack.IFormatterResolver formatterResolver = options.Resolver; + var length = reader.ReadArrayHeader(); + var ____result = new global::MyTestNamespace.MyMessagePackObject(); + + for (int i = 0; i < length; i++) + { + switch (i) + { + case 0: + ____result.EnumValue = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Deserialize(ref reader, options); + break; + default: + reader.Skip(); + break; + } + } + + reader.Depth--; + return ____result; + } + } + +} + diff --git a/tests/MessagePack.Generator.Tests/Usings.cs b/tests/MessagePack.Generator.Tests/Usings.cs index 67e549f86..3883a2635 100644 --- a/tests/MessagePack.Generator.Tests/Usings.cs +++ b/tests/MessagePack.Generator.Tests/Usings.cs @@ -1 +1,8 @@ -global using System.Collections.Immutable; +// Copyright (c) All contributors. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +global using System.Collections.Immutable; +global using MessagePack.Generator.CodeAnalysis; +global using Xunit; +global using Xunit.Abstractions; +global using VerifyCS = CSharpSourceGeneratorVerifier; diff --git a/tests/MessagePack.Generator.Tests/Verifiers/CSharpSourceGeneratorVerifier`1+Test.cs b/tests/MessagePack.Generator.Tests/Verifiers/CSharpSourceGeneratorVerifier`1+Test.cs index 335166eeb..831f24947 100644 --- a/tests/MessagePack.Generator.Tests/Verifiers/CSharpSourceGeneratorVerifier`1+Test.cs +++ b/tests/MessagePack.Generator.Tests/Verifiers/CSharpSourceGeneratorVerifier`1+Test.cs @@ -1,56 +1,164 @@ // Copyright (c) All contributors. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -using System.Collections.Immutable; +// Uncomment the following line to write expected files to disk +////#define WRITE_EXPECTED + +#if WRITE_EXPECTED +#warning WRITE_EXPECTED is fine for local builds, but should not be merged to the main branch. +#endif + +using System.Diagnostics; +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Text; using MessagePack; -using MessagePack.Formatters; +using MessagePack.Generator; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp.Testing; +using Microsoft.CodeAnalysis.Testing; using Microsoft.CodeAnalysis.Testing.Verifiers; public static partial class CSharpSourceGeneratorVerifier - where TSourceGenerator : ISourceGenerator, new() + where TSourceGenerator : IIncrementalGenerator, new() { - public class Test : CSharpSourceGeneratorTest + public class Test : CSharpSourceGeneratorTest { - public Test() + private readonly string? testFile; + private readonly string? testMethod; + private AnalyzerOptions options = AnalyzerOptions.Default; + + public Test([CallerFilePath] string? testFile = null, [CallerMemberName] string? testMethod = null) { - this.ReferenceAssemblies = ReferenceHelper.DefaultReferences; + this.CompilerDiagnostics = CompilerDiagnostics.Warnings; + + this.ReferenceAssemblies = ReferenceAssemblies.Net.Net60; + this.TestState.AdditionalReferences.Add(typeof(MessagePackObjectAttribute).Assembly); + this.TestState.AdditionalReferences.Add(typeof(MessagePackSerializer).Assembly); + + this.testFile = testFile; + this.testMethod = testMethod; + +#if WRITE_EXPECTED + TestBehaviors |= TestBehaviors.SkipGeneratedSourcesCheck; +#endif + } + + public LanguageVersion LanguageVersion { get; set; } = LanguageVersion.Latest; - this.SolutionTransforms.Add((solution, projectId) => + public AnalyzerOptions Options + { + get => this.options; + set { - Project project = solution.GetProject(projectId); + this.options = value; + const string filename = "/.globalconfig"; + if (this.TestState.AnalyzerConfigFiles.FirstOrDefault(t => t.filename == filename) is { } tuple) + { + this.TestState.AnalyzerConfigFiles.Remove(tuple); + } - project = project - .AddMetadataReference(MetadataReference.CreateFromFile(typeof(MessagePackObjectAttribute).Assembly.Location)) - .AddMetadataReference(MetadataReference.CreateFromFile(typeof(IMessagePackFormatter).Assembly.Location)); + this.TestState.AnalyzerConfigFiles.Add((filename, ConstructGlobalConfigString(value))); + } + } - return project.Solution; - }); + protected override IEnumerable GetSourceGenerators() + { + yield return typeof(TSourceGenerator); } protected override CompilationOptions CreateCompilationOptions() { - CompilationOptions compilationOptions = base.CreateCompilationOptions(); - return compilationOptions.WithSpecificDiagnosticOptions( - compilationOptions.SpecificDiagnosticOptions.SetItems(GetNullableWarningsFromCompiler())); + var compilationOptions = (CSharpCompilationOptions)base.CreateCompilationOptions(); + return compilationOptions + .WithAllowUnsafe(false) + .WithWarningLevel(99) + .WithSpecificDiagnosticOptions(compilationOptions.SpecificDiagnosticOptions.SetItem("CS1591", ReportDiagnostic.Suppress)); } - public LanguageVersion LanguageVersion { get; set; } = LanguageVersion.Latest; + protected override ParseOptions CreateParseOptions() + { + return ((CSharpParseOptions)base.CreateParseOptions()).WithLanguageVersion(this.LanguageVersion); + } - private static ImmutableDictionary GetNullableWarningsFromCompiler() + protected override async Task<(Compilation, ImmutableArray)> GetProjectCompilationAsync(Project project, IVerifier verifier, CancellationToken cancellationToken) { - string[] args = { "/warnaserror:nullable" }; - CSharpCommandLineArguments commandLineArguments = CSharpCommandLineParser.Default.Parse(args, baseDirectory: Environment.CurrentDirectory, sdkDirectory: Environment.CurrentDirectory); - ImmutableDictionary nullableWarnings = commandLineArguments.CompilationOptions.SpecificDiagnosticOptions; + var resourceDirectory = Path.Combine(Path.GetDirectoryName(this.testFile)!, "Resources", this.testMethod!); + + var (compilation, diagnostics) = await base.GetProjectCompilationAsync(project, verifier, cancellationToken); + var expectedNames = new HashSet(); + foreach (var tree in compilation.SyntaxTrees.Skip(project.DocumentIds.Count)) + { + WriteTreeToDiskIfNecessary(tree, resourceDirectory); + expectedNames.Add(Path.GetFileName(tree.FilePath)); + } - return nullableWarnings; + var currentTestPrefix = $"{ThisAssembly.AssemblyName}.Resources.{this.testMethod}."; + foreach (var name in this.GetType().Assembly.GetManifestResourceNames()) + { + if (!name.StartsWith(currentTestPrefix)) + { + continue; + } + + if (!expectedNames.Contains(name.Substring(currentTestPrefix.Length))) + { + throw new InvalidOperationException($"Unexpected test resource: {name.Substring(currentTestPrefix.Length)}"); + } + } + + return (compilation, diagnostics); } - protected override ParseOptions CreateParseOptions() + public Test AddGeneratedSources([CallerMemberName] string? testMethod = null) { - return ((CSharpParseOptions)base.CreateParseOptions()).WithLanguageVersion(LanguageVersion); + var expectedPrefix = $"{ThisAssembly.AssemblyName}.Resources.{testMethod}."; + foreach (var resourceName in typeof(Test).Assembly.GetManifestResourceNames()) + { + if (!resourceName.StartsWith(expectedPrefix)) + { + continue; + } + + using var resourceStream = Assembly.GetExecutingAssembly().GetManifestResourceStream(resourceName); + if (resourceStream is null) + { + throw new InvalidOperationException(); + } + + using var reader = new StreamReader(resourceStream, Encoding.UTF8, detectEncodingFromByteOrderMarks: true, bufferSize: 4096, leaveOpen: true); + var name = resourceName.Substring(expectedPrefix.Length); + this.TestState.GeneratedSources.Add((typeof(MessagePackGenerator), name, reader.ReadToEnd())); + } + + return this; + } + + [Conditional("WRITE_EXPECTED")] + private static void WriteTreeToDiskIfNecessary(SyntaxTree tree, string resourceDirectory) + { + if (tree.Encoding is null) + { + throw new ArgumentException("Syntax tree encoding was not specified"); + } + + var name = Path.GetFileName(tree.FilePath); + var filePath = Path.Combine(resourceDirectory, name); + Directory.CreateDirectory(resourceDirectory); + File.WriteAllText(filePath, tree.GetText().ToString(), tree.Encoding); + } + + private static string ConstructGlobalConfigString(AnalyzerOptions options) + { + StringBuilder globalConfigBuilder = new(); + globalConfigBuilder.AppendLine("is_global = true"); + globalConfigBuilder.AppendLine(); + globalConfigBuilder.AppendLine($"{AnalyzerOptions.MessagePackGeneratedResolverNamespace} = {options.Namespace}"); + globalConfigBuilder.AppendLine($"{AnalyzerOptions.MessagePackGeneratedUsesMapMode} = {options.UsesMapMode}"); + globalConfigBuilder.AppendLine($"{AnalyzerOptions.MessagePackGeneratedResolverName} = {options.ResolverName}"); + + return globalConfigBuilder.ToString(); } } } diff --git a/tests/MessagePack.Generator.Tests/Verifiers/ReferenceHelper.cs b/tests/MessagePack.Generator.Tests/Verifiers/ReferenceHelper.cs index b8b7104e8..d52a37c65 100644 --- a/tests/MessagePack.Generator.Tests/Verifiers/ReferenceHelper.cs +++ b/tests/MessagePack.Generator.Tests/Verifiers/ReferenceHelper.cs @@ -1,8 +1,6 @@ // Copyright (c) All contributors. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -using System.Reflection; -using MessagePack; using Microsoft.CodeAnalysis.Testing; internal static class ReferenceHelper From cf1e1d49a46cb0fe5b4c339673b308802a9a2a0c Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Tue, 21 Mar 2023 16:25:22 -0600 Subject: [PATCH 021/660] Simplify test pattern --- .../GenerateEnumFormatterTest.cs | 10 +-- .../CSharpSourceGeneratorVerifier`1+Test.cs | 61 +++++++++++-------- 2 files changed, 39 insertions(+), 32 deletions(-) diff --git a/tests/MessagePack.Generator.Tests/GenerateEnumFormatterTest.cs b/tests/MessagePack.Generator.Tests/GenerateEnumFormatterTest.cs index 578014a6b..95900217e 100644 --- a/tests/MessagePack.Generator.Tests/GenerateEnumFormatterTest.cs +++ b/tests/MessagePack.Generator.Tests/GenerateEnumFormatterTest.cs @@ -13,7 +13,7 @@ public GenerateEnumFormatterTest(ITestOutputHelper testOutputHelper) [Fact] public async Task EnumFormatter() { - string contents = """ + string testSource = """ using System; using System.Collections.Generic; using MessagePack; @@ -32,12 +32,6 @@ public enum MyEnum A, B, C } """; - await new VerifyCS.Test - { - TestState = - { - Sources = { contents }, - }, - }.AddGeneratedSources().RunAsync(); + await VerifyCS.Test.RunDefaultAsync(testSource); } } diff --git a/tests/MessagePack.Generator.Tests/Verifiers/CSharpSourceGeneratorVerifier`1+Test.cs b/tests/MessagePack.Generator.Tests/Verifiers/CSharpSourceGeneratorVerifier`1+Test.cs index 831f24947..1543da0d8 100644 --- a/tests/MessagePack.Generator.Tests/Verifiers/CSharpSourceGeneratorVerifier`1+Test.cs +++ b/tests/MessagePack.Generator.Tests/Verifiers/CSharpSourceGeneratorVerifier`1+Test.cs @@ -43,6 +43,8 @@ public Test([CallerFilePath] string? testFile = null, [CallerMemberName] string? #if WRITE_EXPECTED TestBehaviors |= TestBehaviors.SkipGeneratedSourcesCheck; #endif + + this.AddGeneratedSources(testMethod); } public LanguageVersion LanguageVersion { get; set; } = LanguageVersion.Latest; @@ -63,6 +65,41 @@ public AnalyzerOptions Options } } + public static async Task RunDefaultAsync(string testSource, [CallerFilePath] string? testFile = null, [CallerMemberName] string? testMethod = null) + { + await new Test(testFile, testMethod) + { + TestState = + { + Sources = { testSource }, + }, + }.RunAsync(); + } + + public Test AddGeneratedSources([CallerMemberName] string? testMethod = null) + { + var expectedPrefix = $"{ThisAssembly.AssemblyName}.Resources.{testMethod}."; + foreach (var resourceName in typeof(Test).Assembly.GetManifestResourceNames()) + { + if (!resourceName.StartsWith(expectedPrefix)) + { + continue; + } + + using var resourceStream = Assembly.GetExecutingAssembly().GetManifestResourceStream(resourceName); + if (resourceStream is null) + { + throw new InvalidOperationException(); + } + + using var reader = new StreamReader(resourceStream, Encoding.UTF8, detectEncodingFromByteOrderMarks: true, bufferSize: 4096, leaveOpen: true); + var name = resourceName.Substring(expectedPrefix.Length); + this.TestState.GeneratedSources.Add((typeof(MessagePackGenerator), name, reader.ReadToEnd())); + } + + return this; + } + protected override IEnumerable GetSourceGenerators() { yield return typeof(TSourceGenerator); @@ -111,30 +148,6 @@ protected override ParseOptions CreateParseOptions() return (compilation, diagnostics); } - public Test AddGeneratedSources([CallerMemberName] string? testMethod = null) - { - var expectedPrefix = $"{ThisAssembly.AssemblyName}.Resources.{testMethod}."; - foreach (var resourceName in typeof(Test).Assembly.GetManifestResourceNames()) - { - if (!resourceName.StartsWith(expectedPrefix)) - { - continue; - } - - using var resourceStream = Assembly.GetExecutingAssembly().GetManifestResourceStream(resourceName); - if (resourceStream is null) - { - throw new InvalidOperationException(); - } - - using var reader = new StreamReader(resourceStream, Encoding.UTF8, detectEncodingFromByteOrderMarks: true, bufferSize: 4096, leaveOpen: true); - var name = resourceName.Substring(expectedPrefix.Length); - this.TestState.GeneratedSources.Add((typeof(MessagePackGenerator), name, reader.ReadToEnd())); - } - - return this; - } - [Conditional("WRITE_EXPECTED")] private static void WriteTreeToDiskIfNecessary(SyntaxTree tree, string resourceDirectory) { From d6b11bbb31a8c960da556b93c6487c3d291fd52d Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Tue, 21 Mar 2023 16:26:50 -0600 Subject: [PATCH 022/660] Remove unnecessary new public API --- .../MessagePack/Resolvers/StaticCompositeResolver.cs | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Resolvers/StaticCompositeResolver.cs b/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Resolvers/StaticCompositeResolver.cs index cbe767e1d..daeab0813 100644 --- a/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Resolvers/StaticCompositeResolver.cs +++ b/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Resolvers/StaticCompositeResolver.cs @@ -110,16 +110,6 @@ public void Register(IReadOnlyList formatters, IReadOnlyL this.resolvers = resolvers; } - public void AddGeneratedFormatter(IMessagePackFormatter formatter) - { - if (this.frozen) - { - throw new InvalidOperationException("Register must call on startup(before use GetFormatter)."); - } - - this.generatedFormatters.Add(formatter); - } - /// /// Gets an instance that can serialize or deserialize some type . /// From 0069a97da3640ceb15a15c46d49a3a260c2f3da9 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Tue, 21 Mar 2023 17:20:16 -0600 Subject: [PATCH 023/660] Delete some dead code --- .../CodeAnalysis/TypeCollector.cs | 17 - src/MessagePack.Generator/CodeGenerator.cs | 312 ------------------ 2 files changed, 329 deletions(-) delete mode 100644 src/MessagePack.Generator/CodeGenerator.cs diff --git a/src/MessagePack.Generator/CodeAnalysis/TypeCollector.cs b/src/MessagePack.Generator/CodeAnalysis/TypeCollector.cs index 3e955a240..b67455ca4 100644 --- a/src/MessagePack.Generator/CodeAnalysis/TypeCollector.cs +++ b/src/MessagePack.Generator/CodeAnalysis/TypeCollector.cs @@ -4,10 +4,7 @@ #pragma warning disable SA1402 // File may only contain a single type #pragma warning disable SA1649 // File name should match first type name -using System; -using System.Collections.Generic; using System.Collections.Immutable; -using System.Linq; using System.Text; using System.Text.RegularExpressions; using Microsoft.CodeAnalysis; @@ -25,8 +22,6 @@ public MessagePackGeneratorResolveFailedException(string message) internal class ReferenceSymbols { #pragma warning disable SA1401 // Fields should be private - internal readonly INamedTypeSymbol? Task; - internal readonly INamedTypeSymbol? TaskOfT; internal readonly INamedTypeSymbol MessagePackObjectAttribute; internal readonly INamedTypeSymbol UnionAttribute; internal readonly INamedTypeSymbol SerializationConstructorAttribute; @@ -39,18 +34,6 @@ internal class ReferenceSymbols public ReferenceSymbols(Compilation compilation, Action logger) { - TaskOfT = compilation.GetTypeByMetadataName("System.Threading.Tasks.Task`1"); - if (TaskOfT == null) - { - logger("failed to get metadata of System.Threading.Tasks.Task`1"); - } - - Task = compilation.GetTypeByMetadataName("System.Threading.Tasks.Task"); - if (Task == null) - { - logger("failed to get metadata of System.Threading.Tasks.Task"); - } - MessagePackObjectAttribute = compilation.GetTypeByMetadataName("MessagePack.MessagePackObjectAttribute") ?? throw new InvalidOperationException("failed to get metadata of MessagePack.MessagePackObjectAttribute"); diff --git a/src/MessagePack.Generator/CodeGenerator.cs b/src/MessagePack.Generator/CodeGenerator.cs deleted file mode 100644 index 2290fc78d..000000000 --- a/src/MessagePack.Generator/CodeGenerator.cs +++ /dev/null @@ -1,312 +0,0 @@ -// Copyright (c) All contributors. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - -using System.Diagnostics; -using System.Text; -using MessagePack.Generator.CodeAnalysis; -using MessagePack.Generator.Transforms; -using Microsoft.CodeAnalysis; - -namespace MessagePack.Generator; - -public class CodeGenerator -{ - private static readonly HashSet InvalidFileCharSet = new(Path.GetInvalidFileNameChars()); - - private static readonly Encoding NoBomUtf8 = new UTF8Encoding(false); - - private readonly Action logger; - - public CodeGenerator(Action logger, CancellationToken cancellationToken) - { - this.logger = logger; - } - - /// - /// Generates the specialized resolver and formatters for the types that require serialization in a given compilation. - /// - /// The compilation to read types from as an input to code generation. - /// The name of the generated source file. - /// The resolver name. - /// The namespace for the generated type to be created in. May be null. - /// A boolean value that indicates whether all formatters should use property maps instead of more compact arrays. - /// A comma-delimited list of symbols that should surround redundant generated files. May be null. - /// May be null. - /// A task that indicates when generation has completed. - public async Task GenerateFileAsync( - Compilation compilation, - string output, - string resolverName, - string? @namespace, - bool useMapMode, - string? multipleIfDirectiveOutputSymbols, - string[]? externalIgnoreTypeNames) - { - var namespaceDot = string.IsNullOrWhiteSpace(@namespace) ? string.Empty : @namespace + "."; - var multipleOutputSymbols = multipleIfDirectiveOutputSymbols?.Split(',') ?? Array.Empty(); - - var sw = Stopwatch.StartNew(); - - foreach (var multiOutputSymbol in multipleOutputSymbols.Length == 0 ? new[] { string.Empty } : multipleOutputSymbols) - { - logger("Project Compilation Start:" + compilation.AssemblyName); - - var collector = new TypeCollector(compilation, true, useMapMode, externalIgnoreTypeNames, Console.WriteLine); - - logger("Project Compilation Complete:" + sw.Elapsed.ToString()); - - sw.Restart(); - logger("Method Collect Start"); - - var (objectInfo, enumInfo, genericInfo, unionInfo) = collector.Collect(); - - logger("Method Collect Complete:" + sw.Elapsed.ToString()); - - logger("Output Generation Start"); - sw.Restart(); - - if (Path.GetExtension(output) == ".cs") - { - // SingleFile Output - var fullGeneratedProgramText = GenerateSingleFileSync(resolverName, namespaceDot, objectInfo, enumInfo, unionInfo, genericInfo); - if (multiOutputSymbol == string.Empty) - { - await OutputAsync(output, fullGeneratedProgramText); - } - else - { - var fname = Path.GetFileNameWithoutExtension(output) + "." + MultiSymbolToSafeFilePath(multiOutputSymbol) + ".cs"; - var text = $"#if {multiOutputSymbol}" + Environment.NewLine + fullGeneratedProgramText + Environment.NewLine + "#endif"; - await OutputAsync(Path.Combine(Path.GetDirectoryName(output) ?? string.Empty, fname), text); - } - } - else - { - // Multiple File output - await GenerateMultipleFileAsync(output, resolverName, objectInfo, enumInfo, unionInfo, namespaceDot, multiOutputSymbol, genericInfo); - } - - if (objectInfo.Length == 0 && enumInfo.Length == 0 && genericInfo.Length == 0 && unionInfo.Length == 0) - { - logger("Generated result is empty, unexpected result?"); - } - } - - logger("Output Generation Complete:" + sw.Elapsed.ToString()); - } - - /// - /// Generates the specialized resolver and formatters for the types that require serialization in a given compilation. - /// - /// The resolver name. - /// The namespace for the generated type to be created in. - /// The ObjectSerializationInfo array which TypeCollector.Collect returns. - /// The EnumSerializationInfo array which TypeCollector.Collect returns. - /// The UnionSerializationInfo array which TypeCollector.Collect returns. - /// The GenericSerializationInfo array which TypeCollector.Collect returns. - public static string GenerateSingleFileSync(string resolverName, string namespaceDot, ObjectSerializationInfo[] objectInfo, EnumSerializationInfo[] enumInfo, UnionSerializationInfo[] unionInfo, GenericSerializationInfo[] genericInfo) - { - var objectFormatterTemplates = objectInfo - .GroupBy(x => (x.Namespace, x.IsStringKey)) - .Select(x => - { - var (nameSpace, isStringKey) = x.Key; - var objectSerializationInfos = x.ToArray(); - var ns = namespaceDot + "Formatters" + (nameSpace is null ? string.Empty : "." + nameSpace); - var template = isStringKey ? new StringKeyFormatterTemplate(ns, objectSerializationInfos) : (IFormatterTemplate)new FormatterTemplate(ns, objectSerializationInfos); - return template; - }) - .ToArray(); - - string GetNamespace(IGrouping x) - { - if (x.Key == null) - { - return namespaceDot + "Formatters"; - } - - return namespaceDot + "Formatters." + x.Key; - } - - var enumFormatterTemplates = enumInfo - .GroupBy(x => x.Namespace) - .Select(x => new EnumTemplate(GetNamespace(x), x.ToArray())) - .ToArray(); - - var unionFormatterTemplates = unionInfo - .GroupBy(x => x.Namespace) - .Select(x => new UnionTemplate(GetNamespace(x), x.ToArray())) - .ToArray(); - - var resolverTemplate = new ResolverTemplate(namespaceDot + "Resolvers", namespaceDot + "Formatters", resolverName, genericInfo.Where(x => !x.IsOpenGenericType).Cast().Concat(enumInfo).Concat(unionInfo).Concat(objectInfo.Where(x => !x.IsOpenGenericType)).ToArray()); - - var sb = new StringBuilder(); - sb.AppendLine(resolverTemplate.TransformText()); - sb.AppendLine(); - foreach (var item in enumFormatterTemplates) - { - var text = item.TransformText(); - sb.AppendLine(text); - } - - sb.AppendLine(); - foreach (var item in unionFormatterTemplates) - { - var text = item.TransformText(); - sb.AppendLine(text); - } - - sb.AppendLine(); - foreach (var item in objectFormatterTemplates) - { - var text = item.TransformText(); - sb.AppendLine(text); - } - - return sb.ToString(); - } - - private Task GenerateMultipleFileAsync(string output, string resolverName, ObjectSerializationInfo[] objectInfo, EnumSerializationInfo[] enumInfo, UnionSerializationInfo[] unionInfo, string namespaceDot, string multioutSymbol, GenericSerializationInfo[] genericInfo) - { - string GetNamespace(INamespaceInfo x) - { - if (x.Namespace == null) - { - return namespaceDot + "Formatters"; - } - - return namespaceDot + "Formatters." + x.Namespace; - } - - var waitingTasks = new Task[objectInfo.Length + enumInfo.Length + unionInfo.Length + 1]; - var waitingIndex = 0; - foreach (var x in objectInfo) - { - var ns = namespaceDot + "Formatters" + (x.Namespace is null ? string.Empty : "." + x.Namespace); - var template = x.IsStringKey ? new StringKeyFormatterTemplate(ns, new[] { x }) : (IFormatterTemplate)new FormatterTemplate(ns, new[] { x }); - var text = template.TransformText(); - waitingTasks[waitingIndex++] = OutputToDirAsync(output, template.Namespace, x.Name + "Formatter", multioutSymbol, text); - } - - foreach (var x in enumInfo) - { - var template = new EnumTemplate(GetNamespace(x), new[] { x }); - var text = template.TransformText(); - waitingTasks[waitingIndex++] = OutputToDirAsync(output, template.Namespace, x.Name + "Formatter", multioutSymbol, text); - } - - foreach (var x in unionInfo) - { - var template = new UnionTemplate(GetNamespace(x), new[] { x }); - var text = template.TransformText(); - waitingTasks[waitingIndex++] = OutputToDirAsync(output, template.Namespace, x.Name + "Formatter", multioutSymbol, text); - } - - var resolverTemplate = new ResolverTemplate(namespaceDot + "Resolvers", namespaceDot + "Formatters", resolverName, genericInfo.Where(x => !x.IsOpenGenericType).Cast().Concat(enumInfo).Concat(unionInfo).Concat(objectInfo.Where(x => !x.IsOpenGenericType)).ToArray()); - waitingTasks[waitingIndex] = OutputToDirAsync(output, resolverTemplate.ResolverNamespace, resolverTemplate.ResolverName, multioutSymbol, resolverTemplate.TransformText()); - return Task.WhenAll(waitingTasks); - } - - private Task OutputToDirAsync(string dir, string ns, string name, string multipleOutSymbol, string text) - { - var builder = new StringBuilder(); - void AppendDir(string dir) - { - if (dir.Length != 0) - { - builder.Append(dir); - if (dir[dir.Length - 1] != Path.DirectorySeparatorChar && dir[dir.Length - 1] != Path.AltDirectorySeparatorChar) - { - builder.Append(Path.DirectorySeparatorChar); - } - } - } - - void AppendChar(char c) - { - if (c == '.' || InvalidFileCharSet.Contains(c)) - { - builder.Append('_'); - } - else - { - builder.Append(c); - } - } - - void Append(string text) - { - var span = text.AsSpan(); - while (!span.IsEmpty) - { - var index = span.IndexOf("global::".AsSpan()); - if (index == -1) - { - foreach (var c in span) - { - AppendChar(c); - } - - break; - } - - if (index == 0) - { - span = span.Slice("global::".Length); - continue; - } - - foreach (var c in span.Slice(0, index)) - { - AppendChar(c); - } - - span = span.Slice(index + "global::".Length); - } - } - - AppendDir(dir); - - if (!string.IsNullOrWhiteSpace(multipleOutSymbol)) - { - text = $"#if {multipleOutSymbol}" + Environment.NewLine + text + Environment.NewLine + "#endif"; - AppendDir(MultiSymbolToSafeFilePath(multipleOutSymbol)); - } - - Append(ns); - builder.Append('_'); - Append(name); - builder.Append(".cs"); - - return OutputAsync(builder.ToString(), text); - } - - private Task OutputAsync(string path, string text) - { - path = path.Replace("global::", string.Empty); - - const string prefix = "[Out]"; - logger(prefix + path); - - var fi = new FileInfo(path); - if (fi.Directory != null && !fi.Directory.Exists) - { - fi.Directory.Create(); - } - - File.WriteAllText(path, NormalizeNewLines(text), NoBomUtf8); - return Task.CompletedTask; - } - - private static string MultiSymbolToSafeFilePath(string symbol) - { - return symbol.Replace("!", "NOT_").Replace("(", string.Empty).Replace(")", string.Empty).Replace("||", "_OR_").Replace("&&", "_AND_"); - } - - private static string NormalizeNewLines(string content) - { - // The T4 generated code may be text with mixed line ending types. (CR + CRLF) - // We need to normalize the line ending type in each Operating Systems. (e.g. Windows=CRLF, Linux/macOS=LF) - return content.Replace("\r\n", "\n").Replace("\n", Environment.NewLine); - } -} From 3c2794634b172d7c4eeeae2ed431492a7dace5be Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Wed, 22 Mar 2023 10:09:35 -0600 Subject: [PATCH 024/660] Break up the outputs into individual files This will help with cacheability. --- .../CodeAnalysis/Definitions.cs | 3 - .../MessagePackGenerator.Emit.cs | 112 ++++++------- .../MessagePack.Generator.Tests.csproj | 4 - .../MessagePack.GeneratedResolver.g.cs | 75 +++++++++ .../MessagePack.MyTestNamespace.MyEnum.g.cs | 31 ++++ ...k.MyTestNamespace.MyMessagePackObject.g.cs | 64 ++++++++ ...essagePackObject.MessagePackFormatter.g.cs | 147 ------------------ 7 files changed, 215 insertions(+), 221 deletions(-) create mode 100644 tests/MessagePack.Generator.Tests/Resources/EnumFormatter/MessagePack.GeneratedResolver.g.cs create mode 100644 tests/MessagePack.Generator.Tests/Resources/EnumFormatter/MessagePack.MyTestNamespace.MyEnum.g.cs create mode 100644 tests/MessagePack.Generator.Tests/Resources/EnumFormatter/MessagePack.MyTestNamespace.MyMessagePackObject.g.cs delete mode 100644 tests/MessagePack.Generator.Tests/Resources/EnumFormatter/MyTestNamespace.MyMessagePackObject.MessagePackFormatter.g.cs diff --git a/src/MessagePack.Generator/CodeAnalysis/Definitions.cs b/src/MessagePack.Generator/CodeAnalysis/Definitions.cs index a93a92acd..9e2436dfb 100644 --- a/src/MessagePack.Generator/CodeAnalysis/Definitions.cs +++ b/src/MessagePack.Generator/CodeAnalysis/Definitions.cs @@ -1,9 +1,6 @@ // Copyright (c) All contributors. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -using System; -using System.Collections.Generic; -using System.Linq; using MessagePack.Generator.Transforms; #pragma warning disable SA1402 // File may only contain a single type diff --git a/src/MessagePack.Generator/MessagePackGenerator.Emit.cs b/src/MessagePack.Generator/MessagePackGenerator.Emit.cs index 15db931ff..df1f32862 100644 --- a/src/MessagePack.Generator/MessagePackGenerator.Emit.cs +++ b/src/MessagePack.Generator/MessagePackGenerator.Emit.cs @@ -11,6 +11,23 @@ namespace MessagePack.Generator; public partial class MessagePackGenerator { + private const string FileHeader = """ +// + +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 168 + +#pragma warning disable CS1591 // document public APIs + +#pragma warning disable SA1129 // Do not use default value type constructor +#pragma warning disable SA1309 // Field names should not begin with underscore +#pragma warning disable SA1312 // Variable names should begin with lower-case letter +#pragma warning disable SA1403 // File may only contain a single namespace +#pragma warning disable SA1649 // File name should match first type name +"""; + private static void Generate(TypeDeclarationSyntax syntax, AnalyzerOptions analyzerOptions, Compilation compilation, IGeneratorContext context) { var semanticModel = compilation.GetSemanticModel(syntax.SyntaxTree); @@ -30,56 +47,26 @@ private static void Generate(TypeDeclarationSyntax syntax, AnalyzerOptions analy var (objectInfo, enumInfo, genericInfo, unionInfo) = collector.Collect(); - var code = GenerateFormatterSync(analyzerOptions, objectInfo, enumInfo, unionInfo, genericInfo); - - context.AddSource($"{fullType}.MessagePackFormatter.g.cs", code); + Generate(context, analyzerOptions, objectInfo, enumInfo, unionInfo, genericInfo); } /// /// Generates the specialized resolver and formatters for the types that require serialization in a given compilation. /// + /// Generator context. /// The analyzer options. /// The ObjectSerializationInfo array which TypeCollector.Collect returns. /// The EnumSerializationInfo array which TypeCollector.Collect returns. /// The UnionSerializationInfo array which TypeCollector.Collect returns. /// The GenericSerializationInfo array which TypeCollector.Collect returns. - private static string GenerateFormatterSync(AnalyzerOptions options, ObjectSerializationInfo[] objectInfo, EnumSerializationInfo[] enumInfo, UnionSerializationInfo[] unionInfo, GenericSerializationInfo[] genericInfo) + private static void Generate(IGeneratorContext context, AnalyzerOptions options, ObjectSerializationInfo[] objectInfo, EnumSerializationInfo[] enumInfo, UnionSerializationInfo[] unionInfo, GenericSerializationInfo[] genericInfo) { - var objectFormatterTemplates = objectInfo - .GroupBy(x => (x.Namespace, x.IsStringKey)) - .Select(x => - { - var (nameSpace, isStringKey) = x.Key; - var objectSerializationInfos = x.ToArray(); - string formatterNamespace = options.FormatterNamespace + "." + nameSpace; - var template = isStringKey ? new StringKeyFormatterTemplate(formatterNamespace, objectSerializationInfos) : (IFormatterTemplate)new FormatterTemplate(formatterNamespace, objectSerializationInfos); - return template; - }) - .ToArray(); - StringBuilder sb = new(); - sb.AppendLine(""" -// - -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 168 - -#pragma warning disable CS1591 // document public APIs - -#pragma warning disable SA1129 // Do not use default value type constructor -#pragma warning disable SA1309 // Field names should not begin with underscore -#pragma warning disable SA1312 // Variable names should begin with lower-case letter -#pragma warning disable SA1403 // File may only contain a single namespace -#pragma warning disable SA1649 // File name should match first type name - -"""); - - ResolverText( - sb, - options, + ResolverTemplate resolverTemplate = new( + options.ResolverNamespace, + options.FormatterNamespace, + options.ResolverName, genericInfo .Where(x => !x.IsOpenGenericType) .Cast() @@ -87,45 +74,36 @@ private static string GenerateFormatterSync(AnalyzerOptions options, ObjectSeria .Concat(unionInfo) .Concat(objectInfo.Where(x => !x.IsOpenGenericType)) .ToArray()); + AddTransform(resolverTemplate.TransformText(), "GeneratedResolver"); - var enumFormatterTemplates = enumInfo - .GroupBy(x => x.Namespace) - .Select(x => new EnumTemplate($"{options.FormatterNamespace}.{x.Key}", x.ToArray())) - .ToArray(); - - var unionFormatterTemplates = unionInfo - .GroupBy(x => x.Namespace) - .Select(x => new UnionTemplate(options.FormatterNamespace, x.ToArray())) - .ToArray(); - - foreach (var item in enumFormatterTemplates) + foreach (EnumSerializationInfo enumI in enumInfo) { - var text = item.TransformText(); - sb.AppendLine(text); + EnumTemplate transform = new($"{options.FormatterNamespace}.{enumI.Namespace}", new[] { enumI }); + AddTransform(transform.TransformText(), $"{enumI.Namespace}.{enumI.Name}"); } - sb.AppendLine(); - foreach (var item in objectFormatterTemplates) + foreach (UnionSerializationInfo union in unionInfo) { - var text = item.TransformText(); - sb.AppendLine(text); - return sb.ToString(); + UnionTemplate transform = new(options.FormatterNamespace, new[] { union }); + AddTransform(transform.TransformText(), $"Union.{union.Name}"); } - sb.AppendLine(); - foreach (var item in unionFormatterTemplates) + foreach (ObjectSerializationInfo info in objectInfo) { - var text = item.TransformText(); - sb.AppendLine(text); - return sb.ToString(); + string formatterNamespace = $"{options.FormatterNamespace}.{info.Namespace}"; + IFormatterTemplate transform = info.IsStringKey + ? new StringKeyFormatterTemplate(formatterNamespace, new[] { info }) + : new FormatterTemplate(formatterNamespace, new[] { info }); + AddTransform(transform.TransformText(), $"{info.Namespace}.{info.Name}"); } - return sb.ToString(); - } - - private static void ResolverText(StringBuilder sb, AnalyzerOptions options, IReadOnlyList registerInfos) - { - ResolverTemplate resolverTemplate = new(options.ResolverNamespace, options.FormatterNamespace, options.ResolverName, registerInfos); - sb.AppendLine(resolverTemplate.TransformText()); + void AddTransform(string transformOutput, string uniqueFileName) + { + sb.Clear(); + sb.AppendLine(FileHeader); + sb.Append(transformOutput); + context.AddSource($"MessagePack.{uniqueFileName}.g.cs", sb.ToString()); + sb.Clear(); + } } } diff --git a/tests/MessagePack.Generator.Tests/MessagePack.Generator.Tests.csproj b/tests/MessagePack.Generator.Tests/MessagePack.Generator.Tests.csproj index bea4935cb..8a68eda51 100644 --- a/tests/MessagePack.Generator.Tests/MessagePack.Generator.Tests.csproj +++ b/tests/MessagePack.Generator.Tests/MessagePack.Generator.Tests.csproj @@ -37,8 +37,4 @@ - - - - diff --git a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter/MessagePack.GeneratedResolver.g.cs b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter/MessagePack.GeneratedResolver.g.cs new file mode 100644 index 000000000..e225104a8 --- /dev/null +++ b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter/MessagePack.GeneratedResolver.g.cs @@ -0,0 +1,75 @@ +// + +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 168 + +#pragma warning disable CS1591 // document public APIs + +#pragma warning disable SA1129 // Do not use default value type constructor +#pragma warning disable SA1309 // Field names should not begin with underscore +#pragma warning disable SA1312 // Variable names should begin with lower-case letter +#pragma warning disable SA1403 // File may only contain a single namespace +#pragma warning disable SA1649 // File name should match first type name + +namespace MessagePack.Resolvers +{ + public class GeneratedResolver : global::MessagePack.IFormatterResolver + { + public static readonly global::MessagePack.IFormatterResolver Instance = new GeneratedResolver(); + + private GeneratedResolver() + { + } + + public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() + { + return FormatterCache.Formatter; + } + + private static class FormatterCache + { + internal static readonly global::MessagePack.Formatters.IMessagePackFormatter Formatter; + + static FormatterCache() + { + var f = GeneratedResolverGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + Formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; + } + } + } + } + + internal static class GeneratedResolverGetFormatterHelper + { + private static readonly global::System.Collections.Generic.Dictionary lookup; + + static GeneratedResolverGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(2) + { + { typeof(global::MyTestNamespace.MyEnum), 0 }, + { typeof(global::MyTestNamespace.MyMessagePackObject), 1 }, + }; + } + + internal static object GetFormatter(global::System.Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + case 0: return new MessagePack.Formatters.MyTestNamespace.MyEnumFormatter(); + case 1: return new MessagePack.Formatters.MyTestNamespace.MyMessagePackObjectFormatter(); + default: return null; + } + } + } +} diff --git a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter/MessagePack.MyTestNamespace.MyEnum.g.cs b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter/MessagePack.MyTestNamespace.MyEnum.g.cs new file mode 100644 index 000000000..cae38fd47 --- /dev/null +++ b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter/MessagePack.MyTestNamespace.MyEnum.g.cs @@ -0,0 +1,31 @@ +// + +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 168 + +#pragma warning disable CS1591 // document public APIs + +#pragma warning disable SA1129 // Do not use default value type constructor +#pragma warning disable SA1309 // Field names should not begin with underscore +#pragma warning disable SA1312 // Variable names should begin with lower-case letter +#pragma warning disable SA1403 // File may only contain a single namespace +#pragma warning disable SA1649 // File name should match first type name + +namespace MessagePack.Formatters.MyTestNamespace +{ + + public sealed class MyEnumFormatter : global::MessagePack.Formatters.IMessagePackFormatter + { + public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::MyTestNamespace.MyEnum value, global::MessagePack.MessagePackSerializerOptions options) + { + writer.Write((global::System.Int32)value); + } + + public global::MyTestNamespace.MyEnum Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) + { + return (global::MyTestNamespace.MyEnum)reader.ReadInt32(); + } + } +} diff --git a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter/MessagePack.MyTestNamespace.MyMessagePackObject.g.cs b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter/MessagePack.MyTestNamespace.MyMessagePackObject.g.cs new file mode 100644 index 000000000..56c15f588 --- /dev/null +++ b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter/MessagePack.MyTestNamespace.MyMessagePackObject.g.cs @@ -0,0 +1,64 @@ +// + +#pragma warning disable 618 +#pragma warning disable 612 +#pragma warning disable 414 +#pragma warning disable 168 + +#pragma warning disable CS1591 // document public APIs + +#pragma warning disable SA1129 // Do not use default value type constructor +#pragma warning disable SA1309 // Field names should not begin with underscore +#pragma warning disable SA1312 // Variable names should begin with lower-case letter +#pragma warning disable SA1403 // File may only contain a single namespace +#pragma warning disable SA1649 // File name should match first type name + +namespace MessagePack.Formatters.MyTestNamespace +{ + public sealed class MyMessagePackObjectFormatter : global::MessagePack.Formatters.IMessagePackFormatter + { + + public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::MyTestNamespace.MyMessagePackObject value, global::MessagePack.MessagePackSerializerOptions options) + { + if (value == null) + { + writer.WriteNil(); + return; + } + + global::MessagePack.IFormatterResolver formatterResolver = options.Resolver; + writer.WriteArrayHeader(1); + global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Serialize(ref writer, value.EnumValue, options); + } + + public global::MyTestNamespace.MyMessagePackObject Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) + { + if (reader.TryReadNil()) + { + return null; + } + + options.Security.DepthStep(ref reader); + global::MessagePack.IFormatterResolver formatterResolver = options.Resolver; + var length = reader.ReadArrayHeader(); + var ____result = new global::MyTestNamespace.MyMessagePackObject(); + + for (int i = 0; i < length; i++) + { + switch (i) + { + case 0: + ____result.EnumValue = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Deserialize(ref reader, options); + break; + default: + reader.Skip(); + break; + } + } + + reader.Depth--; + return ____result; + } + } + +} diff --git a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter/MyTestNamespace.MyMessagePackObject.MessagePackFormatter.g.cs b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter/MyTestNamespace.MyMessagePackObject.MessagePackFormatter.g.cs deleted file mode 100644 index 54bb9b826..000000000 --- a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter/MyTestNamespace.MyMessagePackObject.MessagePackFormatter.g.cs +++ /dev/null @@ -1,147 +0,0 @@ -// - -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 168 - -#pragma warning disable CS1591 // document public APIs - -#pragma warning disable SA1129 // Do not use default value type constructor -#pragma warning disable SA1309 // Field names should not begin with underscore -#pragma warning disable SA1312 // Variable names should begin with lower-case letter -#pragma warning disable SA1403 // File may only contain a single namespace -#pragma warning disable SA1649 // File name should match first type name - - -namespace MessagePack.Resolvers -{ - public class GeneratedResolver : global::MessagePack.IFormatterResolver - { - public static readonly global::MessagePack.IFormatterResolver Instance = new GeneratedResolver(); - - private GeneratedResolver() - { - } - - public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() - { - return FormatterCache.Formatter; - } - - private static class FormatterCache - { - internal static readonly global::MessagePack.Formatters.IMessagePackFormatter Formatter; - - static FormatterCache() - { - var f = GeneratedResolverGetFormatterHelper.GetFormatter(typeof(T)); - if (f != null) - { - Formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; - } - } - } - } - - internal static class GeneratedResolverGetFormatterHelper - { - private static readonly global::System.Collections.Generic.Dictionary lookup; - - static GeneratedResolverGetFormatterHelper() - { - lookup = new global::System.Collections.Generic.Dictionary(2) - { - { typeof(global::MyTestNamespace.MyEnum), 0 }, - { typeof(global::MyTestNamespace.MyMessagePackObject), 1 }, - }; - } - - internal static object GetFormatter(global::System.Type t) - { - int key; - if (!lookup.TryGetValue(t, out key)) - { - return null; - } - - switch (key) - { - case 0: return new MessagePack.Formatters.MyTestNamespace.MyEnumFormatter(); - case 1: return new MessagePack.Formatters.MyTestNamespace.MyMessagePackObjectFormatter(); - default: return null; - } - } - } -} - - -namespace MessagePack.Formatters.MyTestNamespace -{ - - public sealed class MyEnumFormatter : global::MessagePack.Formatters.IMessagePackFormatter - { - public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::MyTestNamespace.MyEnum value, global::MessagePack.MessagePackSerializerOptions options) - { - writer.Write((global::System.Int32)value); - } - - public global::MyTestNamespace.MyEnum Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - return (global::MyTestNamespace.MyEnum)reader.ReadInt32(); - } - } -} - - - -namespace MessagePack.Formatters.MyTestNamespace -{ - public sealed class MyMessagePackObjectFormatter : global::MessagePack.Formatters.IMessagePackFormatter - { - - public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::MyTestNamespace.MyMessagePackObject value, global::MessagePack.MessagePackSerializerOptions options) - { - if (value == null) - { - writer.WriteNil(); - return; - } - - global::MessagePack.IFormatterResolver formatterResolver = options.Resolver; - writer.WriteArrayHeader(1); - global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Serialize(ref writer, value.EnumValue, options); - } - - public global::MyTestNamespace.MyMessagePackObject Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - if (reader.TryReadNil()) - { - return null; - } - - options.Security.DepthStep(ref reader); - global::MessagePack.IFormatterResolver formatterResolver = options.Resolver; - var length = reader.ReadArrayHeader(); - var ____result = new global::MyTestNamespace.MyMessagePackObject(); - - for (int i = 0; i < length; i++) - { - switch (i) - { - case 0: - ____result.EnumValue = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Deserialize(ref reader, options); - break; - default: - reader.Skip(); - break; - } - } - - reader.Depth--; - return ____result; - } - } - -} - From 9bdd6f1917dc872fc178ec1f4a49209c70168b05 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Wed, 22 Mar 2023 10:24:22 -0600 Subject: [PATCH 025/660] Get rid of unnecessary arrays in transforms --- .../MessagePackGenerator.Emit.cs | 36 ++++---- .../Transforms/EnumTemplate.cs | 38 ++++----- .../Transforms/EnumTemplate.tt | 16 ++-- .../Transforms/FormatterTemplate.cs | 59 +++++++------ .../Transforms/FormatterTemplate.tt | 56 ++++++------- .../Transforms/IFormatterTemplate.cs | 2 +- .../StringKey/StringKeyFormatterTemplate.cs | 84 ++++++------------- .../StringKey/StringKeyFormatterTemplate.tt | 77 ++++++----------- .../Transforms/TemplatePartials.cs | 24 +++--- .../Transforms/UnionTemplate.cs | 36 ++++---- .../Transforms/UnionTemplate.tt | 30 +++---- .../MessagePack.MyTestNamespace.MyEnum.g.cs | 7 +- ...k.MyTestNamespace.MyMessagePackObject.g.cs | 1 - 13 files changed, 190 insertions(+), 276 deletions(-) diff --git a/src/MessagePack.Generator/MessagePackGenerator.Emit.cs b/src/MessagePack.Generator/MessagePackGenerator.Emit.cs index df1f32862..01fbe54fd 100644 --- a/src/MessagePack.Generator/MessagePackGenerator.Emit.cs +++ b/src/MessagePack.Generator/MessagePackGenerator.Emit.cs @@ -55,11 +55,11 @@ private static void Generate(TypeDeclarationSyntax syntax, AnalyzerOptions analy /// /// Generator context. /// The analyzer options. - /// The ObjectSerializationInfo array which TypeCollector.Collect returns. - /// The EnumSerializationInfo array which TypeCollector.Collect returns. - /// The UnionSerializationInfo array which TypeCollector.Collect returns. - /// The GenericSerializationInfo array which TypeCollector.Collect returns. - private static void Generate(IGeneratorContext context, AnalyzerOptions options, ObjectSerializationInfo[] objectInfo, EnumSerializationInfo[] enumInfo, UnionSerializationInfo[] unionInfo, GenericSerializationInfo[] genericInfo) + /// The ObjectSerializationInfo array which TypeCollector.Collect returns. + /// The EnumSerializationInfo array which TypeCollector.Collect returns. + /// The UnionSerializationInfo array which TypeCollector.Collect returns. + /// The GenericSerializationInfo array which TypeCollector.Collect returns. + private static void Generate(IGeneratorContext context, AnalyzerOptions options, ObjectSerializationInfo[] objectInfos, EnumSerializationInfo[] enumInfos, UnionSerializationInfo[] unionInfos, GenericSerializationInfo[] genericInfos) { StringBuilder sb = new(); @@ -67,33 +67,33 @@ private static void Generate(IGeneratorContext context, AnalyzerOptions options, options.ResolverNamespace, options.FormatterNamespace, options.ResolverName, - genericInfo + genericInfos .Where(x => !x.IsOpenGenericType) .Cast() - .Concat(enumInfo) - .Concat(unionInfo) - .Concat(objectInfo.Where(x => !x.IsOpenGenericType)) + .Concat(enumInfos) + .Concat(unionInfos) + .Concat(objectInfos.Where(x => !x.IsOpenGenericType)) .ToArray()); AddTransform(resolverTemplate.TransformText(), "GeneratedResolver"); - foreach (EnumSerializationInfo enumI in enumInfo) + foreach (EnumSerializationInfo info in enumInfos) { - EnumTemplate transform = new($"{options.FormatterNamespace}.{enumI.Namespace}", new[] { enumI }); - AddTransform(transform.TransformText(), $"{enumI.Namespace}.{enumI.Name}"); + EnumTemplate transform = new($"{options.FormatterNamespace}.{info.Namespace}", info); + AddTransform(transform.TransformText(), $"{info.Namespace}.{info.Name}"); } - foreach (UnionSerializationInfo union in unionInfo) + foreach (UnionSerializationInfo info in unionInfos) { - UnionTemplate transform = new(options.FormatterNamespace, new[] { union }); - AddTransform(transform.TransformText(), $"Union.{union.Name}"); + UnionTemplate transform = new(options.FormatterNamespace, info); + AddTransform(transform.TransformText(), $"Union.{info.Name}"); } - foreach (ObjectSerializationInfo info in objectInfo) + foreach (ObjectSerializationInfo info in objectInfos) { string formatterNamespace = $"{options.FormatterNamespace}.{info.Namespace}"; IFormatterTemplate transform = info.IsStringKey - ? new StringKeyFormatterTemplate(formatterNamespace, new[] { info }) - : new FormatterTemplate(formatterNamespace, new[] { info }); + ? new StringKeyFormatterTemplate(formatterNamespace, info) + : new FormatterTemplate(formatterNamespace, info); AddTransform(transform.TransformText(), $"{info.Namespace}.{info.Name}"); } diff --git a/src/MessagePack.Generator/Transforms/EnumTemplate.cs b/src/MessagePack.Generator/Transforms/EnumTemplate.cs index 09ee9bcfd..b3250ea2b 100644 --- a/src/MessagePack.Generator/Transforms/EnumTemplate.cs +++ b/src/MessagePack.Generator/Transforms/EnumTemplate.cs @@ -9,9 +9,6 @@ // ------------------------------------------------------------------------------ namespace MessagePack.Generator.Transforms { - using System.Linq; - using System.Text; - using System.Collections.Generic; using System; /// @@ -27,28 +24,23 @@ public virtual string TransformText() { this.Write("\r\nnamespace "); this.Write(this.ToStringHelper.ToStringWithCulture(Namespace)); - this.Write("\r\n{\r\n"); - foreach(var info in EnumSerializationInfos) { - this.Write("\r\n public sealed class "); - this.Write(this.ToStringHelper.ToStringWithCulture(info.Name)); - this.Write("Formatter : global::MessagePack.Formatters.IMessagePackFormatter<"); - this.Write(this.ToStringHelper.ToStringWithCulture(info.FullName)); - this.Write(">\r\n {\r\n public void Serialize(ref global::MessagePack.MessagePackWriter" + - " writer, "); - this.Write(this.ToStringHelper.ToStringWithCulture(info.FullName)); - this.Write(" value, global::MessagePack.MessagePackSerializerOptions options)\r\n {\r\n " + - " writer.Write((global::System."); - this.Write(this.ToStringHelper.ToStringWithCulture(info.UnderlyingType)); + this.Write("\r\n{\r\n using MsgPack = global::MessagePack;\r\n\r\n public sealed class "); + this.Write(this.ToStringHelper.ToStringWithCulture(Info.Name)); + this.Write("Formatter : MsgPack::Formatters.IMessagePackFormatter<"); + this.Write(this.ToStringHelper.ToStringWithCulture(Info.FullName)); + this.Write(">\r\n {\r\n public void Serialize(ref MsgPack::MessagePackWriter writer, "); + this.Write(this.ToStringHelper.ToStringWithCulture(Info.FullName)); + this.Write(" value, MsgPack::MessagePackSerializerOptions options)\r\n {\r\n wr" + + "iter.Write((global::System."); + this.Write(this.ToStringHelper.ToStringWithCulture(Info.UnderlyingType)); this.Write(")value);\r\n }\r\n\r\n public "); - this.Write(this.ToStringHelper.ToStringWithCulture(info.FullName)); - this.Write(" Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePac" + - "k.MessagePackSerializerOptions options)\r\n {\r\n return ("); - this.Write(this.ToStringHelper.ToStringWithCulture(info.FullName)); + this.Write(this.ToStringHelper.ToStringWithCulture(Info.FullName)); + this.Write(" Deserialize(ref MsgPack::MessagePackReader reader, MsgPack::MessagePackSerialize" + + "rOptions options)\r\n {\r\n return ("); + this.Write(this.ToStringHelper.ToStringWithCulture(Info.FullName)); this.Write(")reader.Read"); - this.Write(this.ToStringHelper.ToStringWithCulture(info.UnderlyingType)); - this.Write("();\r\n }\r\n }\r\n"); - } - this.Write("}\r\n"); + this.Write(this.ToStringHelper.ToStringWithCulture(Info.UnderlyingType)); + this.Write("();\r\n }\r\n }\r\n}\r\n"); return this.GenerationEnvironment.ToString(); } } diff --git a/src/MessagePack.Generator/Transforms/EnumTemplate.tt b/src/MessagePack.Generator/Transforms/EnumTemplate.tt index 6d5d1c7d4..775671726 100644 --- a/src/MessagePack.Generator/Transforms/EnumTemplate.tt +++ b/src/MessagePack.Generator/Transforms/EnumTemplate.tt @@ -1,24 +1,20 @@ <#@ template debug="false" hostspecific="false" linePragmas="false" language="C#" #> <#@ assembly name="System.Core" #> -<#@ import namespace="System.Linq" #> -<#@ import namespace="System.Text" #> -<#@ import namespace="System.Collections.Generic" #> namespace <#= Namespace #> { -<# foreach(var info in EnumSerializationInfos) { #> + using MsgPack = global::MessagePack; - public sealed class <#= info.Name #>Formatter : global::MessagePack.Formatters.IMessagePackFormatter<<#= info.FullName #>> + public sealed class <#= Info.Name #>Formatter : MsgPack::Formatters.IMessagePackFormatter<<#= Info.FullName #>> { - public void Serialize(ref global::MessagePack.MessagePackWriter writer, <#= info.FullName #> value, global::MessagePack.MessagePackSerializerOptions options) + public void Serialize(ref MsgPack::MessagePackWriter writer, <#= Info.FullName #> value, MsgPack::MessagePackSerializerOptions options) { - writer.Write((global::System.<#= info.UnderlyingType #>)value); + writer.Write((global::System.<#= Info.UnderlyingType #>)value); } - public <#= info.FullName #> Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) + public <#= Info.FullName #> Deserialize(ref MsgPack::MessagePackReader reader, MsgPack::MessagePackSerializerOptions options) { - return (<#= info.FullName #>)reader.Read<#= info.UnderlyingType #>(); + return (<#= Info.FullName #>)reader.Read<#= Info.UnderlyingType #>(); } } -<# } #> } diff --git a/src/MessagePack.Generator/Transforms/FormatterTemplate.cs b/src/MessagePack.Generator/Transforms/FormatterTemplate.cs index 54a8d4b97..940bcdc2f 100644 --- a/src/MessagePack.Generator/Transforms/FormatterTemplate.cs +++ b/src/MessagePack.Generator/Transforms/FormatterTemplate.cs @@ -28,14 +28,13 @@ public virtual string TransformText() this.Write("\r\nnamespace "); this.Write(this.ToStringHelper.ToStringWithCulture(Namespace)); this.Write("\r\n{\r\n"); - foreach (var objInfo in ObjectSerializationInfos) { - bool isFormatterResolverNecessary = ShouldUseFormatterResolverHelper.ShouldUseFormatterResolver(objInfo.Members); + bool isFormatterResolverNecessary = ShouldUseFormatterResolverHelper.ShouldUseFormatterResolver(Info.Members); this.Write(" public sealed class "); - this.Write(this.ToStringHelper.ToStringWithCulture(objInfo.FormatterNameWithoutNameSpace)); + this.Write(this.ToStringHelper.ToStringWithCulture(Info.FormatterNameWithoutNameSpace)); this.Write(" : global::MessagePack.Formatters.IMessagePackFormatter<"); - this.Write(this.ToStringHelper.ToStringWithCulture(objInfo.FullName)); + this.Write(this.ToStringHelper.ToStringWithCulture(Info.FullName)); this.Write(">\r\n"); - foreach (var typeArg in objInfo.GenericTypeParameters.Where(x => x.HasConstraints)) { + foreach (var typeArg in Info.GenericTypeParameters.Where(x => x.HasConstraints)) { this.Write(" where "); this.Write(this.ToStringHelper.ToStringWithCulture(typeArg.Name)); this.Write(" : "); @@ -43,7 +42,7 @@ public virtual string TransformText() this.Write("\r\n"); } this.Write(" {\r\n"); - foreach (var item in objInfo.Members) { + foreach (var item in Info.Members) { if (item.CustomFormatterTypeName != null) { this.Write(" private readonly "); this.Write(this.ToStringHelper.ToStringWithCulture(item.CustomFormatterTypeName)); @@ -56,9 +55,9 @@ public virtual string TransformText() } this.Write("\r\n public void Serialize(ref global::MessagePack.MessagePackWriter writer," + " "); - this.Write(this.ToStringHelper.ToStringWithCulture(objInfo.FullName)); + this.Write(this.ToStringHelper.ToStringWithCulture(Info.FullName)); this.Write(" value, global::MessagePack.MessagePackSerializerOptions options)\r\n {\r\n"); - if (objInfo.IsClass) { + if (Info.IsClass) { this.Write(" if (value == null)\r\n {\r\n writer.WriteNil();" + "\r\n return;\r\n }\r\n\r\n"); } @@ -68,8 +67,8 @@ public virtual string TransformText() "solver;\r\n"); } - if (objInfo.HasIMessagePackSerializationCallbackReceiver) { - if (objInfo.NeedsCastOnBefore) { + if (Info.HasIMessagePackSerializationCallbackReceiver) { + if (Info.NeedsCastOnBefore) { this.Write(" ((global::MessagePack.IMessagePackSerializationCallbackReceiver)value" + ").OnBeforeSerialize();\r\n"); } else { @@ -77,10 +76,10 @@ public virtual string TransformText() } } this.Write(" writer.WriteArrayHeader("); - this.Write(this.ToStringHelper.ToStringWithCulture(objInfo.MaxKey + 1)); + this.Write(this.ToStringHelper.ToStringWithCulture(Info.MaxKey + 1)); this.Write(");\r\n"); - for (var i = 0; i <= objInfo.MaxKey; i++) { - var member = objInfo.GetMember(i); + for (var i = 0; i <= Info.MaxKey; i++) { + var member = Info.GetMember(i); if (member == null) { this.Write(" writer.WriteNil();\r\n"); } else { @@ -90,20 +89,20 @@ public virtual string TransformText() } } this.Write(" }\r\n\r\n public "); - this.Write(this.ToStringHelper.ToStringWithCulture(objInfo.FullName)); + this.Write(this.ToStringHelper.ToStringWithCulture(Info.FullName)); this.Write(" Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePac" + "k.MessagePackSerializerOptions options)\r\n {\r\n if (reader.TryRe" + "adNil())\r\n {\r\n"); - if (objInfo.IsClass) { + if (Info.IsClass) { this.Write(" return null;\r\n"); } else { this.Write(" throw new global::System.InvalidOperationException(\"typecode is n" + "ull, struct not supported\");\r\n"); } this.Write(" }\r\n\r\n"); - if (objInfo.MaxKey == -1 && !objInfo.HasIMessagePackSerializationCallbackReceiver) { + if (Info.MaxKey == -1 && !Info.HasIMessagePackSerializationCallbackReceiver) { this.Write(" reader.Skip();\r\n return new "); - this.Write(this.ToStringHelper.ToStringWithCulture(objInfo.GetConstructorString())); + this.Write(this.ToStringHelper.ToStringWithCulture(Info.GetConstructorString())); this.Write(";\r\n"); } else { this.Write(" options.Security.DepthStep(ref reader);\r\n"); @@ -112,12 +111,12 @@ public virtual string TransformText() "solver;\r\n"); } this.Write(" var length = reader.ReadArrayHeader();\r\n"); - var canOverwrite = objInfo.ConstructorParameters.Length == 0; + var canOverwrite = Info.ConstructorParameters.Length == 0; if (canOverwrite) { this.Write(" var ____result = new "); - this.Write(this.ToStringHelper.ToStringWithCulture(objInfo.GetConstructorString())); + this.Write(this.ToStringHelper.ToStringWithCulture(Info.GetConstructorString())); this.Write(";\r\n"); - } else { foreach (var member in objInfo.Members) { + } else { foreach (var member in Info.Members) { this.Write(" var __"); this.Write(this.ToStringHelper.ToStringWithCulture(member.Name)); this.Write("__ = default("); @@ -127,8 +126,8 @@ public virtual string TransformText() } this.Write("\r\n for (int i = 0; i < length; i++)\r\n {\r\n sw" + "itch (i)\r\n {\r\n"); - for (var memberIndex = 0; memberIndex <= objInfo.MaxKey; memberIndex++) { - var member = objInfo.GetMember(memberIndex); + for (var memberIndex = 0; memberIndex <= Info.MaxKey; memberIndex++) { + var member = Info.GetMember(memberIndex); if (member == null) { continue; } this.Write(" case "); this.Write(this.ToStringHelper.ToStringWithCulture(member.IntKey)); @@ -158,12 +157,12 @@ public virtual string TransformText() " break;\r\n }\r\n }\r\n\r\n"); if (!canOverwrite) { this.Write(" var ____result = new "); - this.Write(this.ToStringHelper.ToStringWithCulture(objInfo.GetConstructorString())); + this.Write(this.ToStringHelper.ToStringWithCulture(Info.GetConstructorString())); this.Write(";\r\n"); bool memberAssignExists = false; - for (var memberIndex = 0; memberIndex <= objInfo.MaxKey; memberIndex++) { - var member = objInfo.GetMember(memberIndex); - if (member == null || !member.IsWritable || objInfo.ConstructorParameters.Any(p => p.Equals(member))) { continue; } + for (var memberIndex = 0; memberIndex <= Info.MaxKey; memberIndex++) { + var member = Info.GetMember(memberIndex); + if (member == null || !member.IsWritable || Info.ConstructorParameters.Any(p => p.Equals(member))) { continue; } memberAssignExists = true; this.Write(" if (length <= "); this.Write(this.ToStringHelper.ToStringWithCulture(memberIndex)); @@ -179,8 +178,8 @@ public virtual string TransformText() } } - if (objInfo.HasIMessagePackSerializationCallbackReceiver) { - if (objInfo.NeedsCastOnAfter) { + if (Info.HasIMessagePackSerializationCallbackReceiver) { + if (Info.NeedsCastOnAfter) { this.Write(" ((global::MessagePack.IMessagePackSerializationCallbackReceiver)____r" + "esult).OnAfterDeserialize();\r\n"); } else { @@ -189,9 +188,7 @@ public virtual string TransformText() } this.Write(" reader.Depth--;\r\n return ____result;\r\n"); } - this.Write(" }\r\n }\r\n\r\n"); - } - this.Write("}\r\n"); + this.Write(" }\r\n }\r\n}\r\n"); return this.GenerationEnvironment.ToString(); } } diff --git a/src/MessagePack.Generator/Transforms/FormatterTemplate.tt b/src/MessagePack.Generator/Transforms/FormatterTemplate.tt index c823e3edf..2625b11f5 100644 --- a/src/MessagePack.Generator/Transforms/FormatterTemplate.tt +++ b/src/MessagePack.Generator/Transforms/FormatterTemplate.tt @@ -6,22 +6,21 @@ namespace <#= Namespace #> { -<# foreach (var objInfo in ObjectSerializationInfos) { - bool isFormatterResolverNecessary = ShouldUseFormatterResolverHelper.ShouldUseFormatterResolver(objInfo.Members);#> - public sealed class <#= objInfo.FormatterNameWithoutNameSpace #> : global::MessagePack.Formatters.IMessagePackFormatter<<#= objInfo.FullName #>> -<# foreach (var typeArg in objInfo.GenericTypeParameters.Where(x => x.HasConstraints)) { #> +<# bool isFormatterResolverNecessary = ShouldUseFormatterResolverHelper.ShouldUseFormatterResolver(Info.Members);#> + public sealed class <#= Info.FormatterNameWithoutNameSpace #> : global::MessagePack.Formatters.IMessagePackFormatter<<#= Info.FullName #>> +<# foreach (var typeArg in Info.GenericTypeParameters.Where(x => x.HasConstraints)) { #> where <#= typeArg.Name #> : <#= typeArg.Constraints #> <# } #> { -<# foreach (var item in objInfo.Members) { #> +<# foreach (var item in Info.Members) { #> <# if (item.CustomFormatterTypeName != null) { #> private readonly <#= item.CustomFormatterTypeName #> __<#= item.Name #>CustomFormatter__ = new <#= item.CustomFormatterTypeName #>(); <# } #> <# } #> - public void Serialize(ref global::MessagePack.MessagePackWriter writer, <#= objInfo.FullName #> value, global::MessagePack.MessagePackSerializerOptions options) + public void Serialize(ref global::MessagePack.MessagePackWriter writer, <#= Info.FullName #> value, global::MessagePack.MessagePackSerializerOptions options) { -<# if (objInfo.IsClass) { #> +<# if (Info.IsClass) { #> if (value == null) { writer.WriteNil(); @@ -34,16 +33,16 @@ namespace <#= Namespace #> global::MessagePack.IFormatterResolver formatterResolver = options.Resolver; <# } - if (objInfo.HasIMessagePackSerializationCallbackReceiver) { - if (objInfo.NeedsCastOnBefore) { #> + if (Info.HasIMessagePackSerializationCallbackReceiver) { + if (Info.NeedsCastOnBefore) { #> ((global::MessagePack.IMessagePackSerializationCallbackReceiver)value).OnBeforeSerialize(); <# } else { #> value.OnBeforeSerialize(); <# } #> <# } #> - writer.WriteArrayHeader(<#= objInfo.MaxKey + 1 #>); -<# for (var i = 0; i <= objInfo.MaxKey; i++) { - var member = objInfo.GetMember(i); + writer.WriteArrayHeader(<#= Info.MaxKey + 1 #>); +<# for (var i = 0; i <= Info.MaxKey; i++) { + var member = Info.GetMember(i); if (member == null) { #> writer.WriteNil(); <# } else { #> @@ -52,30 +51,30 @@ namespace <#= Namespace #> <# } #> } - public <#= objInfo.FullName #> Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) + public <#= Info.FullName #> Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) { if (reader.TryReadNil()) { -<# if (objInfo.IsClass) { #> +<# if (Info.IsClass) { #> return null; <# } else { #> throw new global::System.InvalidOperationException("typecode is null, struct not supported"); <# } #> } -<# if (objInfo.MaxKey == -1 && !objInfo.HasIMessagePackSerializationCallbackReceiver) { #> +<# if (Info.MaxKey == -1 && !Info.HasIMessagePackSerializationCallbackReceiver) { #> reader.Skip(); - return new <#= objInfo.GetConstructorString() #>; + return new <#= Info.GetConstructorString() #>; <# } else { #> options.Security.DepthStep(ref reader); <# if (isFormatterResolverNecessary) { #> global::MessagePack.IFormatterResolver formatterResolver = options.Resolver; <# } #> var length = reader.ReadArrayHeader(); -<# var canOverwrite = objInfo.ConstructorParameters.Length == 0; +<# var canOverwrite = Info.ConstructorParameters.Length == 0; if (canOverwrite) { #> - var ____result = new <#= objInfo.GetConstructorString() #>; -<# } else { foreach (var member in objInfo.Members) { #> + var ____result = new <#= Info.GetConstructorString() #>; +<# } else { foreach (var member in Info.Members) { #> var __<#= member.Name #>__ = default(<#= member.Type #>); <# } #> <# } #> @@ -84,8 +83,8 @@ namespace <#= Namespace #> { switch (i) { -<# for (var memberIndex = 0; memberIndex <= objInfo.MaxKey; memberIndex++) { - var member = objInfo.GetMember(memberIndex); +<# for (var memberIndex = 0; memberIndex <= Info.MaxKey; memberIndex++) { + var member = Info.GetMember(memberIndex); if (member == null) { continue; } #> case <#= member.IntKey #>: <# if (canOverwrite) { @@ -106,11 +105,11 @@ namespace <#= Namespace #> } <# if (!canOverwrite) { #> - var ____result = new <#= objInfo.GetConstructorString() #>; + var ____result = new <#= Info.GetConstructorString() #>; <# bool memberAssignExists = false; - for (var memberIndex = 0; memberIndex <= objInfo.MaxKey; memberIndex++) { - var member = objInfo.GetMember(memberIndex); - if (member == null || !member.IsWritable || objInfo.ConstructorParameters.Any(p => p.Equals(member))) { continue; } + for (var memberIndex = 0; memberIndex <= Info.MaxKey; memberIndex++) { + var member = Info.GetMember(memberIndex); + if (member == null || !member.IsWritable || Info.ConstructorParameters.Any(p => p.Equals(member))) { continue; } memberAssignExists = true;#> if (length <= <#= memberIndex #>) { @@ -125,8 +124,8 @@ namespace <#= Namespace #> <# } } - if (objInfo.HasIMessagePackSerializationCallbackReceiver) { - if (objInfo.NeedsCastOnAfter) { #> + if (Info.HasIMessagePackSerializationCallbackReceiver) { + if (Info.NeedsCastOnAfter) { #> ((global::MessagePack.IMessagePackSerializationCallbackReceiver)____result).OnAfterDeserialize(); <# } else { #> ____result.OnAfterDeserialize(); @@ -137,5 +136,4 @@ namespace <#= Namespace #> <# } #> } } - -<# } #>} +} diff --git a/src/MessagePack.Generator/Transforms/IFormatterTemplate.cs b/src/MessagePack.Generator/Transforms/IFormatterTemplate.cs index e76860c13..71a3f3952 100644 --- a/src/MessagePack.Generator/Transforms/IFormatterTemplate.cs +++ b/src/MessagePack.Generator/Transforms/IFormatterTemplate.cs @@ -9,7 +9,7 @@ public interface IFormatterTemplate { string Namespace { get; } - ObjectSerializationInfo[] ObjectSerializationInfos { get; } + ObjectSerializationInfo Info { get; } string TransformText(); } diff --git a/src/MessagePack.Generator/Transforms/StringKey/StringKeyFormatterTemplate.cs b/src/MessagePack.Generator/Transforms/StringKey/StringKeyFormatterTemplate.cs index c987afa10..23160a8ae 100644 --- a/src/MessagePack.Generator/Transforms/StringKey/StringKeyFormatterTemplate.cs +++ b/src/MessagePack.Generator/Transforms/StringKey/StringKeyFormatterTemplate.cs @@ -25,40 +25,22 @@ public partial class StringKeyFormatterTemplate : StringKeyFormatterTemplateBase /// public virtual string TransformText() { - this.Write(@"// -// THIS (.cs) FILE IS GENERATED BY MPC(MessagePack-CSharp). DO NOT CHANGE IT. -// - -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 168 -#pragma warning disable CS1591 // document public APIs - -#pragma warning disable SA1129 // Do not use default value type constructor -#pragma warning disable SA1309 // Field names should not begin with underscore -#pragma warning disable SA1312 // Variable names should begin with lower-case letter -#pragma warning disable SA1403 // File may only contain a single namespace -#pragma warning disable SA1649 // File name should match first type name - -namespace "); + this.Write("\r\nnamespace "); this.Write(this.ToStringHelper.ToStringWithCulture(Namespace)); this.Write("\r\n{\r\n"); var list = new List>(); -foreach (var objInfo in ObjectSerializationInfos) { - list.Clear(); - foreach (var member in objInfo.Members) { + foreach (var member in Info.Members) { var binary = EmbedStringHelper.Utf8.GetBytes(member.StringKey); list.Add(new ValueTuple(member, binary)); } - bool isFormatterResolverNecessary = ShouldUseFormatterResolverHelper.ShouldUseFormatterResolver(objInfo.Members); + bool isFormatterResolverNecessary = ShouldUseFormatterResolverHelper.ShouldUseFormatterResolver(Info.Members); this.Write(" public sealed class "); - this.Write(this.ToStringHelper.ToStringWithCulture(objInfo.FormatterNameWithoutNameSpace)); + this.Write(this.ToStringHelper.ToStringWithCulture(Info.FormatterNameWithoutNameSpace)); this.Write(" : global::MessagePack.Formatters.IMessagePackFormatter<"); - this.Write(this.ToStringHelper.ToStringWithCulture(objInfo.FullName)); + this.Write(this.ToStringHelper.ToStringWithCulture(Info.FullName)); this.Write(">\r\n"); - foreach (var typeArg in objInfo.GenericTypeParameters.Where(x => x.HasConstraints)) { + foreach (var typeArg in Info.GenericTypeParameters.Where(x => x.HasConstraints)) { this.Write(" where "); this.Write(this.ToStringHelper.ToStringWithCulture(typeArg.Name)); this.Write(" : "); @@ -66,7 +48,7 @@ namespace "); this.Write("\r\n"); } this.Write(" {\r\n"); - foreach (var item in objInfo.Members) { + foreach (var item in Info.Members) { if (item.CustomFormatterTypeName != null) { this.Write(" private readonly "); this.Write(this.ToStringHelper.ToStringWithCulture(item.CustomFormatterTypeName)); @@ -92,9 +74,9 @@ namespace "); this.Write("\r\n"); } this.Write(" public void Serialize(ref global::MessagePack.MessagePackWriter writer, "); - this.Write(this.ToStringHelper.ToStringWithCulture(objInfo.FullName)); + this.Write(this.ToStringHelper.ToStringWithCulture(Info.FullName)); this.Write(" value, global::MessagePack.MessagePackSerializerOptions options)\r\n {\r\n"); - if (objInfo.IsClass) { + if (Info.IsClass) { this.Write(" if (value is null)\r\n {\r\n writer.WriteNil();" + "\r\n return;\r\n }\r\n\r\n"); } @@ -103,8 +85,8 @@ namespace "); this.Write(" var formatterResolver = options.Resolver;\r\n"); } - if (objInfo.HasIMessagePackSerializationCallbackReceiver) { - if (objInfo.NeedsCastOnBefore) { + if (Info.HasIMessagePackSerializationCallbackReceiver) { + if (Info.NeedsCastOnBefore) { this.Write(" ((global::MessagePack.IMessagePackSerializationCallbackReceiver)value" + ").OnBeforeSerialize();\r\n"); } else { @@ -123,20 +105,20 @@ namespace "); this.Write(";\r\n"); } this.Write(" }\r\n\r\n public "); - this.Write(this.ToStringHelper.ToStringWithCulture(objInfo.FullName)); + this.Write(this.ToStringHelper.ToStringWithCulture(Info.FullName)); this.Write(" Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePac" + "k.MessagePackSerializerOptions options)\r\n {\r\n if (reader.TryRe" + "adNil())\r\n {\r\n"); - if (objInfo.IsClass) { + if (Info.IsClass) { this.Write(" return null;\r\n"); } else { this.Write(" throw new global::System.InvalidOperationException(\"typecode is n" + "ull, struct not supported\");\r\n"); } this.Write(" }\r\n\r\n"); - if (objInfo.Members.Length == 0) { + if (Info.Members.Length == 0) { this.Write(" reader.Skip();\r\n var ____result = new "); - this.Write(this.ToStringHelper.ToStringWithCulture(objInfo.GetConstructorString())); + this.Write(this.ToStringHelper.ToStringWithCulture(Info.GetConstructorString())); this.Write(";\r\n"); } else { this.Write(" options.Security.DepthStep(ref reader);\r\n"); @@ -144,14 +126,14 @@ namespace "); this.Write(" var formatterResolver = options.Resolver;\r\n"); } this.Write(" var length = reader.ReadMapHeader();\r\n"); - var canOverwrite = objInfo.ConstructorParameters.Length == 0; + var canOverwrite = Info.ConstructorParameters.Length == 0; if (canOverwrite) { this.Write(" var ____result = new "); - this.Write(this.ToStringHelper.ToStringWithCulture(objInfo.GetConstructorString())); + this.Write(this.ToStringHelper.ToStringWithCulture(Info.GetConstructorString())); this.Write(";\r\n"); } else { - foreach (var member in objInfo.Members.Where(x => x.IsWritable || objInfo.ConstructorParameters.Any(p => p.Equals(x)))) { - if (objInfo.ConstructorParameters.All(p => !p.Equals(member))) { + foreach (var member in Info.Members.Where(x => x.IsWritable || Info.ConstructorParameters.Any(p => p.Equals(x)))) { + if (Info.ConstructorParameters.All(p => !p.Equals(member))) { this.Write(" var __"); this.Write(this.ToStringHelper.ToStringWithCulture(member.Name)); this.Write("__IsInitialized = false;\r\n"); @@ -174,13 +156,13 @@ namespace "); reader.Skip(); continue; "); - this.Write(this.ToStringHelper.ToStringWithCulture(StringKeyFormatterDeserializeHelper.Classify(objInfo, " ", canOverwrite))); + this.Write(this.ToStringHelper.ToStringWithCulture(StringKeyFormatterDeserializeHelper.Classify(Info, " ", canOverwrite))); this.Write("\r\n }\r\n }\r\n\r\n"); if (!canOverwrite) { this.Write(" var ____result = new "); - this.Write(this.ToStringHelper.ToStringWithCulture(objInfo.GetConstructorString())); + this.Write(this.ToStringHelper.ToStringWithCulture(Info.GetConstructorString())); this.Write(";\r\n"); - foreach (var member in objInfo.Members.Where(x => x.IsWritable && !objInfo.ConstructorParameters.Any(p => p.Equals(x)))) { + foreach (var member in Info.Members.Where(x => x.IsWritable && !Info.ConstructorParameters.Any(p => p.Equals(x)))) { this.Write(" if (__"); this.Write(this.ToStringHelper.ToStringWithCulture(member.Name)); this.Write("__IsInitialized)\r\n {\r\n ____result."); @@ -191,32 +173,18 @@ namespace "); } } } - if (objInfo.HasIMessagePackSerializationCallbackReceiver) { - if (objInfo.NeedsCastOnAfter) { + if (Info.HasIMessagePackSerializationCallbackReceiver) { + if (Info.NeedsCastOnAfter) { this.Write(" ((global::MessagePack.IMessagePackSerializationCallbackReceiver)____r" + "esult).OnAfterDeserialize();\r\n"); } else { this.Write(" ____result.OnAfterDeserialize();\r\n"); } } - if (objInfo.Members.Length != 0) { + if (Info.Members.Length != 0) { this.Write(" reader.Depth--;\r\n"); } - this.Write(" return ____result;\r\n }\r\n }\r\n\r\n"); - } - this.Write(@"} - -#pragma warning restore 168 -#pragma warning restore 414 -#pragma warning restore 618 -#pragma warning restore 612 - -#pragma warning restore SA1129 // Do not use default value type constructor -#pragma warning restore SA1309 // Field names should not begin with underscore -#pragma warning restore SA1312 // Variable names should begin with lower-case letter -#pragma warning restore SA1403 // File may only contain a single namespace -#pragma warning restore SA1649 // File name should match first type name -"); + this.Write(" return ____result;\r\n }\r\n }\r\n}\r\n"); return this.GenerationEnvironment.ToString(); } } diff --git a/src/MessagePack.Generator/Transforms/StringKey/StringKeyFormatterTemplate.tt b/src/MessagePack.Generator/Transforms/StringKey/StringKeyFormatterTemplate.tt index 81af93673..94d8bf0f1 100644 --- a/src/MessagePack.Generator/Transforms/StringKey/StringKeyFormatterTemplate.tt +++ b/src/MessagePack.Generator/Transforms/StringKey/StringKeyFormatterTemplate.tt @@ -4,39 +4,22 @@ <#@ import namespace="System.Linq" #> <#@ import namespace="System.Collections.Generic" #> <#@ import namespace="MessagePack.Generator.CodeAnalysis" #> -// -// THIS (.cs) FILE IS GENERATED BY MPC(MessagePack-CSharp). DO NOT CHANGE IT. -// - -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 168 -#pragma warning disable CS1591 // document public APIs - -#pragma warning disable SA1129 // Do not use default value type constructor -#pragma warning disable SA1309 // Field names should not begin with underscore -#pragma warning disable SA1312 // Variable names should begin with lower-case letter -#pragma warning disable SA1403 // File may only contain a single namespace -#pragma warning disable SA1649 // File name should match first type name namespace <#= Namespace #> { <# var list = new List>(); -foreach (var objInfo in ObjectSerializationInfos) { - list.Clear(); - foreach (var member in objInfo.Members) { + foreach (var member in Info.Members) { var binary = EmbedStringHelper.Utf8.GetBytes(member.StringKey); list.Add(new ValueTuple(member, binary)); } - bool isFormatterResolverNecessary = ShouldUseFormatterResolverHelper.ShouldUseFormatterResolver(objInfo.Members); #> - public sealed class <#= objInfo.FormatterNameWithoutNameSpace #> : global::MessagePack.Formatters.IMessagePackFormatter<<#= objInfo.FullName #>> -<# foreach (var typeArg in objInfo.GenericTypeParameters.Where(x => x.HasConstraints)) {#> + bool isFormatterResolverNecessary = ShouldUseFormatterResolverHelper.ShouldUseFormatterResolver(Info.Members); #> + public sealed class <#= Info.FormatterNameWithoutNameSpace #> : global::MessagePack.Formatters.IMessagePackFormatter<<#= Info.FullName #>> +<# foreach (var typeArg in Info.GenericTypeParameters.Where(x => x.HasConstraints)) {#> where <#= typeArg.Name #> : <#= typeArg.Constraints #> <# }#> { -<# foreach (var item in objInfo.Members) { #> +<# foreach (var item in Info.Members) { #> <# if (item.CustomFormatterTypeName != null) { #> private readonly <#= item.CustomFormatterTypeName #> __<#= item.Name #>CustomFormatter__ = new <#= item.CustomFormatterTypeName #>(); <# } #> @@ -50,9 +33,9 @@ foreach (var objInfo in ObjectSerializationInfos) { <# if (list.Count != 0) { #> <# } #> - public void Serialize(ref global::MessagePack.MessagePackWriter writer, <#= objInfo.FullName #> value, global::MessagePack.MessagePackSerializerOptions options) + public void Serialize(ref global::MessagePack.MessagePackWriter writer, <#= Info.FullName #> value, global::MessagePack.MessagePackSerializerOptions options) { -<# if (objInfo.IsClass) { #> +<# if (Info.IsClass) { #> if (value is null) { writer.WriteNil(); @@ -65,8 +48,8 @@ foreach (var objInfo in ObjectSerializationInfos) { var formatterResolver = options.Resolver; <# } - if (objInfo.HasIMessagePackSerializationCallbackReceiver) { - if (objInfo.NeedsCastOnBefore) { #> + if (Info.HasIMessagePackSerializationCallbackReceiver) { + if (Info.NeedsCastOnBefore) { #> ((global::MessagePack.IMessagePackSerializationCallbackReceiver)value).OnBeforeSerialize(); <# } else { #> value.OnBeforeSerialize(); @@ -80,32 +63,32 @@ foreach (var objInfo in ObjectSerializationInfos) { <# } #> } - public <#= objInfo.FullName #> Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) + public <#= Info.FullName #> Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) { if (reader.TryReadNil()) { -<# if (objInfo.IsClass) { #> +<# if (Info.IsClass) { #> return null; <# } else { #> throw new global::System.InvalidOperationException("typecode is null, struct not supported"); <# } #> } -<# if (objInfo.Members.Length == 0) { #> +<# if (Info.Members.Length == 0) { #> reader.Skip(); - var ____result = new <#= objInfo.GetConstructorString() #>; + var ____result = new <#= Info.GetConstructorString() #>; <# } else { #> options.Security.DepthStep(ref reader); <# if (isFormatterResolverNecessary) { #> var formatterResolver = options.Resolver; <# } #> var length = reader.ReadMapHeader(); -<# var canOverwrite = objInfo.ConstructorParameters.Length == 0; +<# var canOverwrite = Info.ConstructorParameters.Length == 0; if (canOverwrite) { #> - var ____result = new <#= objInfo.GetConstructorString() #>; + var ____result = new <#= Info.GetConstructorString() #>; <# } else { - foreach (var member in objInfo.Members.Where(x => x.IsWritable || objInfo.ConstructorParameters.Any(p => p.Equals(x)))) { #> -<# if (objInfo.ConstructorParameters.All(p => !p.Equals(member))) { #> + foreach (var member in Info.Members.Where(x => x.IsWritable || Info.ConstructorParameters.Any(p => p.Equals(x)))) { #> +<# if (Info.ConstructorParameters.All(p => !p.Equals(member))) { #> var __<#= member.Name #>__IsInitialized = false; <# } #> var __<#= member.Name #>__ = default(<#= member.Type #>); @@ -121,13 +104,13 @@ foreach (var objInfo in ObjectSerializationInfos) { FAIL: reader.Skip(); continue; -<#= StringKeyFormatterDeserializeHelper.Classify(objInfo, " ", canOverwrite) #> +<#= StringKeyFormatterDeserializeHelper.Classify(Info, " ", canOverwrite) #> } } <# if (!canOverwrite) { #> - var ____result = new <#= objInfo.GetConstructorString() #>; -<# foreach (var member in objInfo.Members.Where(x => x.IsWritable && !objInfo.ConstructorParameters.Any(p => p.Equals(x)))) { #> + var ____result = new <#= Info.GetConstructorString() #>; +<# foreach (var member in Info.Members.Where(x => x.IsWritable && !Info.ConstructorParameters.Any(p => p.Equals(x)))) { #> if (__<#= member.Name #>__IsInitialized) { ____result.<#= member.Name #> = __<#= member.Name #>__; @@ -136,29 +119,17 @@ foreach (var objInfo in ObjectSerializationInfos) { <# } #> <# } #> <# } #> -<# if (objInfo.HasIMessagePackSerializationCallbackReceiver) { - if (objInfo.NeedsCastOnAfter) { #> +<# if (Info.HasIMessagePackSerializationCallbackReceiver) { + if (Info.NeedsCastOnAfter) { #> ((global::MessagePack.IMessagePackSerializationCallbackReceiver)____result).OnAfterDeserialize(); <# } else { #> ____result.OnAfterDeserialize(); <# } #> <# } #> -<# if (objInfo.Members.Length != 0) { #> +<# if (Info.Members.Length != 0) { #> reader.Depth--; <# } #> return ____result; } } - -<# } #>} - -#pragma warning restore 168 -#pragma warning restore 414 -#pragma warning restore 618 -#pragma warning restore 612 - -#pragma warning restore SA1129 // Do not use default value type constructor -#pragma warning restore SA1309 // Field names should not begin with underscore -#pragma warning restore SA1312 // Variable names should begin with lower-case letter -#pragma warning restore SA1403 // File may only contain a single namespace -#pragma warning restore SA1649 // File name should match first type name +} diff --git a/src/MessagePack.Generator/Transforms/TemplatePartials.cs b/src/MessagePack.Generator/Transforms/TemplatePartials.cs index 680da18fc..cdd720fca 100644 --- a/src/MessagePack.Generator/Transforms/TemplatePartials.cs +++ b/src/MessagePack.Generator/Transforms/TemplatePartials.cs @@ -9,28 +9,28 @@ namespace MessagePack.Generator.Transforms; public partial class FormatterTemplate : IFormatterTemplate { - public FormatterTemplate(string @namespace, ObjectSerializationInfo[] objectSerializationInfos) + public FormatterTemplate(string @namespace, ObjectSerializationInfo info) { Namespace = @namespace; - ObjectSerializationInfos = objectSerializationInfos; + Info = info; } public string Namespace { get; } - public ObjectSerializationInfo[] ObjectSerializationInfos { get; } + public ObjectSerializationInfo Info { get; } } public partial class StringKeyFormatterTemplate : IFormatterTemplate { - public StringKeyFormatterTemplate(string @namespace, ObjectSerializationInfo[] objectSerializationInfos) + public StringKeyFormatterTemplate(string @namespace, ObjectSerializationInfo info) { Namespace = @namespace; - ObjectSerializationInfos = objectSerializationInfos; + Info = info; } public string Namespace { get; } - public ObjectSerializationInfo[] ObjectSerializationInfos { get; } + public ObjectSerializationInfo Info { get; } } public partial class ResolverTemplate @@ -54,26 +54,26 @@ public ResolverTemplate(string resolverNamespace, string formatterNamespace, str public partial class EnumTemplate { - public EnumTemplate(string @namespace, EnumSerializationInfo[] enumSerializationInfos) + public EnumTemplate(string @namespace, EnumSerializationInfo info) { Namespace = @namespace; - EnumSerializationInfos = enumSerializationInfos; + Info = info; } public string Namespace { get; } - public EnumSerializationInfo[] EnumSerializationInfos { get; } + public EnumSerializationInfo Info { get; } } public partial class UnionTemplate { - public UnionTemplate(string @namespace, UnionSerializationInfo[] unionSerializationInfos) + public UnionTemplate(string @namespace, UnionSerializationInfo info) { Namespace = @namespace; - UnionSerializationInfos = unionSerializationInfos; + Info = info; } public string Namespace { get; } - public UnionSerializationInfo[] UnionSerializationInfos { get; } + public UnionSerializationInfo Info { get; } } diff --git a/src/MessagePack.Generator/Transforms/UnionTemplate.cs b/src/MessagePack.Generator/Transforms/UnionTemplate.cs index d19631dfb..88a550664 100644 --- a/src/MessagePack.Generator/Transforms/UnionTemplate.cs +++ b/src/MessagePack.Generator/Transforms/UnionTemplate.cs @@ -27,26 +27,24 @@ public virtual string TransformText() { this.Write("\r\nnamespace "); this.Write(this.ToStringHelper.ToStringWithCulture(Namespace)); - this.Write("\r\n{\r\n"); - foreach(var info in UnionSerializationInfos) { - this.Write(" public sealed class "); - this.Write(this.ToStringHelper.ToStringWithCulture(info.Name)); + this.Write("\r\n{\r\n public sealed class "); + this.Write(this.ToStringHelper.ToStringWithCulture(Info.Name)); this.Write("Formatter : global::MessagePack.Formatters.IMessagePackFormatter<"); - this.Write(this.ToStringHelper.ToStringWithCulture(info.FullName)); + this.Write(this.ToStringHelper.ToStringWithCulture(Info.FullName)); this.Write(@"> { private readonly global::System.Collections.Generic.Dictionary> typeToKeyAndJumpMap; private readonly global::System.Collections.Generic.Dictionary keyToJumpMap; public "); - this.Write(this.ToStringHelper.ToStringWithCulture(info.Name)); + this.Write(this.ToStringHelper.ToStringWithCulture(Info.Name)); this.Write("Formatter()\r\n {\r\n this.typeToKeyAndJumpMap = new global::System" + ".Collections.Generic.Dictionary>("); - this.Write(this.ToStringHelper.ToStringWithCulture(info.SubTypes.Length)); + this.Write(this.ToStringHelper.ToStringWithCulture(Info.SubTypes.Length)); this.Write(", global::MessagePack.Internal.RuntimeTypeHandleEqualityComparer.Default)\r\n " + " {\r\n"); - for(var i = 0; i < info.SubTypes.Length; i++) { var item = info.SubTypes[i]; + for(var i = 0; i < Info.SubTypes.Length; i++) { var item = Info.SubTypes[i]; this.Write(" { typeof("); this.Write(this.ToStringHelper.ToStringWithCulture(item.Type)); this.Write(").TypeHandle, new global::System.Collections.Generic.KeyValuePair("); @@ -57,9 +55,9 @@ public virtual string TransformText() } this.Write(" };\r\n this.keyToJumpMap = new global::System.Collections.Ge" + "neric.Dictionary("); - this.Write(this.ToStringHelper.ToStringWithCulture(info.SubTypes.Length)); + this.Write(this.ToStringHelper.ToStringWithCulture(Info.SubTypes.Length)); this.Write(")\r\n {\r\n"); - for(var i = 0; i < info.SubTypes.Length; i++) { var item = info.SubTypes[i]; + for(var i = 0; i < Info.SubTypes.Length; i++) { var item = Info.SubTypes[i]; this.Write(" { "); this.Write(this.ToStringHelper.ToStringWithCulture(item.Key)); this.Write(", "); @@ -68,7 +66,7 @@ public virtual string TransformText() } this.Write(" };\r\n }\r\n\r\n public void Serialize(ref global::MessagePac" + "k.MessagePackWriter writer, "); - this.Write(this.ToStringHelper.ToStringWithCulture(info.FullName)); + this.Write(this.ToStringHelper.ToStringWithCulture(Info.FullName)); this.Write(@" value, global::MessagePack.MessagePackSerializerOptions options) { global::System.Collections.Generic.KeyValuePair keyValuePair; @@ -79,7 +77,7 @@ public virtual string TransformText() switch (keyValuePair.Value) { "); - for(var i = 0; i < info.SubTypes.Length; i++) { var item = info.SubTypes[i]; + for(var i = 0; i < Info.SubTypes.Length; i++) { var item = Info.SubTypes[i]; this.Write(" case "); this.Write(this.ToStringHelper.ToStringWithCulture(i)); this.Write(":\r\n global::MessagePack.FormatterResolverExtensions.GetFor" + @@ -92,7 +90,7 @@ public virtual string TransformText() this.Write(" default:\r\n break;\r\n }\r\n" + "\r\n return;\r\n }\r\n\r\n writer.WriteNil();\r\n " + " }\r\n\r\n public "); - this.Write(this.ToStringHelper.ToStringWithCulture(info.FullName)); + this.Write(this.ToStringHelper.ToStringWithCulture(Info.FullName)); this.Write(@" Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) { if (reader.TryReadNil()) @@ -103,18 +101,18 @@ public virtual string TransformText() if (reader.ReadArrayHeader() != 2) { throw new global::System.InvalidOperationException(""Invalid Union data was detected. Type:"); - this.Write(this.ToStringHelper.ToStringWithCulture(info.FullName)); + this.Write(this.ToStringHelper.ToStringWithCulture(Info.FullName)); this.Write("\");\r\n }\r\n\r\n options.Security.DepthStep(ref reader);\r\n " + " var key = reader.ReadInt32();\r\n\r\n if (!this.keyToJumpMap.TryGet" + "Value(key, out key))\r\n {\r\n key = -1;\r\n }\r\n\r" + "\n "); - this.Write(this.ToStringHelper.ToStringWithCulture(info.FullName)); + this.Write(this.ToStringHelper.ToStringWithCulture(Info.FullName)); this.Write(" result = null;\r\n switch (key)\r\n {\r\n"); - for(var i = 0; i < info.SubTypes.Length; i++) { var item = info.SubTypes[i]; + for(var i = 0; i < Info.SubTypes.Length; i++) { var item = Info.SubTypes[i]; this.Write(" case "); this.Write(this.ToStringHelper.ToStringWithCulture(i)); this.Write(":\r\n result = ("); - this.Write(this.ToStringHelper.ToStringWithCulture(info.FullName)); + this.Write(this.ToStringHelper.ToStringWithCulture(Info.FullName)); this.Write(")global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<"); this.Write(this.ToStringHelper.ToStringWithCulture(item.Type)); this.Write(">(options.Resolver).Deserialize(ref reader, options);\r\n break;" + @@ -122,9 +120,7 @@ public virtual string TransformText() } this.Write(" default:\r\n reader.Skip();\r\n " + " break;\r\n }\r\n\r\n reader.Depth--;\r\n return result" + - ";\r\n }\r\n }\r\n\r\n"); - } - this.Write("\r\n}\r\n"); + ";\r\n }\r\n }\r\n}\r\n"); return this.GenerationEnvironment.ToString(); } } diff --git a/src/MessagePack.Generator/Transforms/UnionTemplate.tt b/src/MessagePack.Generator/Transforms/UnionTemplate.tt index 9c805d1ee..402b00481 100644 --- a/src/MessagePack.Generator/Transforms/UnionTemplate.tt +++ b/src/MessagePack.Generator/Transforms/UnionTemplate.tt @@ -6,29 +6,28 @@ namespace <#= Namespace #> { -<# foreach(var info in UnionSerializationInfos) { #> - public sealed class <#= info.Name #>Formatter : global::MessagePack.Formatters.IMessagePackFormatter<<#= info.FullName #>> + public sealed class <#= Info.Name #>Formatter : global::MessagePack.Formatters.IMessagePackFormatter<<#= Info.FullName #>> { private readonly global::System.Collections.Generic.Dictionary> typeToKeyAndJumpMap; private readonly global::System.Collections.Generic.Dictionary keyToJumpMap; - public <#= info.Name #>Formatter() + public <#= Info.Name #>Formatter() { - this.typeToKeyAndJumpMap = new global::System.Collections.Generic.Dictionary>(<#= info.SubTypes.Length #>, global::MessagePack.Internal.RuntimeTypeHandleEqualityComparer.Default) + this.typeToKeyAndJumpMap = new global::System.Collections.Generic.Dictionary>(<#= Info.SubTypes.Length #>, global::MessagePack.Internal.RuntimeTypeHandleEqualityComparer.Default) { -<# for(var i = 0; i < info.SubTypes.Length; i++) { var item = info.SubTypes[i]; #> +<# for(var i = 0; i < Info.SubTypes.Length; i++) { var item = Info.SubTypes[i]; #> { typeof(<#= item.Type #>).TypeHandle, new global::System.Collections.Generic.KeyValuePair(<#= item.Key #>, <#= i #>) }, <# } #> }; - this.keyToJumpMap = new global::System.Collections.Generic.Dictionary(<#= info.SubTypes.Length #>) + this.keyToJumpMap = new global::System.Collections.Generic.Dictionary(<#= Info.SubTypes.Length #>) { -<# for(var i = 0; i < info.SubTypes.Length; i++) { var item = info.SubTypes[i]; #> +<# for(var i = 0; i < Info.SubTypes.Length; i++) { var item = Info.SubTypes[i]; #> { <#= item.Key #>, <#= i #> }, <# } #> }; } - public void Serialize(ref global::MessagePack.MessagePackWriter writer, <#= info.FullName #> value, global::MessagePack.MessagePackSerializerOptions options) + public void Serialize(ref global::MessagePack.MessagePackWriter writer, <#= Info.FullName #> value, global::MessagePack.MessagePackSerializerOptions options) { global::System.Collections.Generic.KeyValuePair keyValuePair; if (value != null && this.typeToKeyAndJumpMap.TryGetValue(value.GetType().TypeHandle, out keyValuePair)) @@ -37,7 +36,7 @@ namespace <#= Namespace #> writer.WriteInt32(keyValuePair.Key); switch (keyValuePair.Value) { -<# for(var i = 0; i < info.SubTypes.Length; i++) { var item = info.SubTypes[i]; #> +<# for(var i = 0; i < Info.SubTypes.Length; i++) { var item = Info.SubTypes[i]; #> case <#= i #>: global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<<#= item.Type #>>(options.Resolver).Serialize(ref writer, (<#= item.Type #>)value, options); break; @@ -52,7 +51,7 @@ namespace <#= Namespace #> writer.WriteNil(); } - public <#= info.FullName #> Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) + public <#= Info.FullName #> Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) { if (reader.TryReadNil()) { @@ -61,7 +60,7 @@ namespace <#= Namespace #> if (reader.ReadArrayHeader() != 2) { - throw new global::System.InvalidOperationException("Invalid Union data was detected. Type:<#= info.FullName #>"); + throw new global::System.InvalidOperationException("Invalid Union data was detected. Type:<#= Info.FullName #>"); } options.Security.DepthStep(ref reader); @@ -72,12 +71,12 @@ namespace <#= Namespace #> key = -1; } - <#= info.FullName #> result = null; + <#= Info.FullName #> result = null; switch (key) { -<# for(var i = 0; i < info.SubTypes.Length; i++) { var item = info.SubTypes[i]; #> +<# for(var i = 0; i < Info.SubTypes.Length; i++) { var item = Info.SubTypes[i]; #> case <#= i #>: - result = (<#= info.FullName #>)global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<<#= item.Type #>>(options.Resolver).Deserialize(ref reader, options); + result = (<#= Info.FullName #>)global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<<#= item.Type #>>(options.Resolver).Deserialize(ref reader, options); break; <# } #> default: @@ -89,7 +88,4 @@ namespace <#= Namespace #> return result; } } - -<# } #> - } diff --git a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter/MessagePack.MyTestNamespace.MyEnum.g.cs b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter/MessagePack.MyTestNamespace.MyEnum.g.cs index cae38fd47..62a184ea7 100644 --- a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter/MessagePack.MyTestNamespace.MyEnum.g.cs +++ b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter/MessagePack.MyTestNamespace.MyEnum.g.cs @@ -15,15 +15,16 @@ namespace MessagePack.Formatters.MyTestNamespace { + using MsgPack = global::MessagePack; - public sealed class MyEnumFormatter : global::MessagePack.Formatters.IMessagePackFormatter + public sealed class MyEnumFormatter : MsgPack::Formatters.IMessagePackFormatter { - public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::MyTestNamespace.MyEnum value, global::MessagePack.MessagePackSerializerOptions options) + public void Serialize(ref MsgPack::MessagePackWriter writer, global::MyTestNamespace.MyEnum value, MsgPack::MessagePackSerializerOptions options) { writer.Write((global::System.Int32)value); } - public global::MyTestNamespace.MyEnum Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) + public global::MyTestNamespace.MyEnum Deserialize(ref MsgPack::MessagePackReader reader, MsgPack::MessagePackSerializerOptions options) { return (global::MyTestNamespace.MyEnum)reader.ReadInt32(); } diff --git a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter/MessagePack.MyTestNamespace.MyMessagePackObject.g.cs b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter/MessagePack.MyTestNamespace.MyMessagePackObject.g.cs index 56c15f588..c62c07a20 100644 --- a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter/MessagePack.MyTestNamespace.MyMessagePackObject.g.cs +++ b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter/MessagePack.MyTestNamespace.MyMessagePackObject.g.cs @@ -60,5 +60,4 @@ public void Serialize(ref global::MessagePack.MessagePackWriter writer, global:: return ____result; } } - } From da6659b005b4411a78fa4285adddd4317c54536f Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Wed, 22 Mar 2023 10:38:41 -0600 Subject: [PATCH 026/660] Split out Definitions into separate files --- .../CodeAnalysis/Definitions.cs | 279 ------------------ .../CodeAnalysis/EnumSerializationInfo.cs | 25 ++ .../CodeAnalysis/GenericSerializationInfo.cs | 30 ++ .../CodeAnalysis/GenericTypeParameterInfo.cs | 20 ++ .../CodeAnalysis/INamespaceInfo.cs | 11 + .../CodeAnalysis/IResolverRegisterInfo.cs | 11 + .../CodeAnalysis/MemberSerializationInfo.cs | 81 +++++ .../CodeAnalysis/ObjectSerializationInfo.cs | 90 ++++++ .../CodeAnalysis/UnionSerializationInfo.cs | 25 ++ .../CodeAnalysis/UnionSubTypeInfo.cs | 17 ++ 10 files changed, 310 insertions(+), 279 deletions(-) delete mode 100644 src/MessagePack.Generator/CodeAnalysis/Definitions.cs create mode 100644 src/MessagePack.Generator/CodeAnalysis/EnumSerializationInfo.cs create mode 100644 src/MessagePack.Generator/CodeAnalysis/GenericSerializationInfo.cs create mode 100644 src/MessagePack.Generator/CodeAnalysis/GenericTypeParameterInfo.cs create mode 100644 src/MessagePack.Generator/CodeAnalysis/INamespaceInfo.cs create mode 100644 src/MessagePack.Generator/CodeAnalysis/IResolverRegisterInfo.cs create mode 100644 src/MessagePack.Generator/CodeAnalysis/MemberSerializationInfo.cs create mode 100644 src/MessagePack.Generator/CodeAnalysis/ObjectSerializationInfo.cs create mode 100644 src/MessagePack.Generator/CodeAnalysis/UnionSerializationInfo.cs create mode 100644 src/MessagePack.Generator/CodeAnalysis/UnionSubTypeInfo.cs diff --git a/src/MessagePack.Generator/CodeAnalysis/Definitions.cs b/src/MessagePack.Generator/CodeAnalysis/Definitions.cs deleted file mode 100644 index 9e2436dfb..000000000 --- a/src/MessagePack.Generator/CodeAnalysis/Definitions.cs +++ /dev/null @@ -1,279 +0,0 @@ -// Copyright (c) All contributors. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - -using MessagePack.Generator.Transforms; - -#pragma warning disable SA1402 // File may only contain a single type -#pragma warning disable SA1649 // File name should match first type name - -namespace MessagePack.Generator.CodeAnalysis; - -public interface INamespaceInfo -{ - string? Namespace { get; } -} - -public interface IResolverRegisterInfo -{ - string FullName { get; } - - string FormatterName { get; } -} - -public class ObjectSerializationInfo : IResolverRegisterInfo, INamespaceInfo -{ - public string Name { get; } - - public string FullName { get; } - - public string? Namespace { get; } - - public GenericTypeParameterInfo[] GenericTypeParameters { get; } - - public bool IsOpenGenericType { get; } - - public bool IsIntKey { get; } - - public bool IsStringKey - { - get { return !this.IsIntKey; } - } - - public bool IsClass { get; } - - public MemberSerializationInfo[] ConstructorParameters { get; } - - public MemberSerializationInfo[] Members { get; } - - public bool HasIMessagePackSerializationCallbackReceiver { get; } - - public bool NeedsCastOnBefore { get; } - - public bool NeedsCastOnAfter { get; } - - public string FormatterName => this.Namespace == null ? FormatterNameWithoutNameSpace : this.Namespace + "." + FormatterNameWithoutNameSpace; - - public string FormatterNameWithoutNameSpace => this.Name + "Formatter" + (this.IsOpenGenericType ? $"<{string.Join(", ", this.GenericTypeParameters.Select(x => x.Name))}>" : string.Empty); - - public int WriteCount - { - get - { - if (this.IsStringKey) - { - return this.Members.Count(x => x.IsReadable); - } - else - { - return this.MaxKey; - } - } - } - - public int MaxKey - { - get - { - return this.Members.Where(x => x.IsReadable).Select(x => x.IntKey).DefaultIfEmpty(-1).Max(); - } - } - - public MemberSerializationInfo? GetMember(int index) - { - return this.Members.FirstOrDefault(x => x.IntKey == index); - } - - public string GetConstructorString() - { - var args = string.Join(", ", this.ConstructorParameters.Select(x => "__" + x.Name + "__")); - return $"{this.FullName}({args})"; - } - - public ObjectSerializationInfo(bool isClass, bool isOpenGenericType, GenericTypeParameterInfo[] genericTypeParameterInfos, MemberSerializationInfo[] constructorParameters, bool isIntKey, MemberSerializationInfo[] members, string name, string fullName, string? @namespace, bool hasSerializationConstructor, bool needsCastOnAfter, bool needsCastOnBefore) - { - IsClass = isClass; - IsOpenGenericType = isOpenGenericType; - GenericTypeParameters = genericTypeParameterInfos; - ConstructorParameters = constructorParameters; - IsIntKey = isIntKey; - Members = members; - Name = name; - FullName = fullName; - Namespace = @namespace; - HasIMessagePackSerializationCallbackReceiver = hasSerializationConstructor; - NeedsCastOnAfter = needsCastOnAfter; - NeedsCastOnBefore = needsCastOnBefore; - } -} - -public class GenericTypeParameterInfo -{ - public string Name { get; } - - public string Constraints { get; } - - public bool HasConstraints { get; } - - public GenericTypeParameterInfo(string name, string constraints) - { - Name = name ?? throw new ArgumentNullException(nameof(name)); - Constraints = constraints ?? throw new ArgumentNullException(nameof(name)); - HasConstraints = constraints != string.Empty; - } -} - -public class MemberSerializationInfo -{ - public bool IsProperty { get; } - - public bool IsWritable { get; } - - public bool IsReadable { get; } - - public int IntKey { get; } - - public string StringKey { get; } - - public string Type { get; } - - public string Name { get; } - - public string ShortTypeName { get; } - - public string? CustomFormatterTypeName { get; } - - private readonly HashSet primitiveTypes = new(ShouldUseFormatterResolverHelper.PrimitiveTypes); - - public MemberSerializationInfo(bool isProperty, bool isWritable, bool isReadable, int intKey, string stringKey, string name, string type, string shortTypeName, string? customFormatterTypeName) - { - IsProperty = isProperty; - IsWritable = isWritable; - IsReadable = isReadable; - IntKey = intKey; - StringKey = stringKey; - Type = type; - Name = name; - ShortTypeName = shortTypeName; - CustomFormatterTypeName = customFormatterTypeName; - } - - public string GetSerializeMethodString() - { - if (CustomFormatterTypeName != null) - { - return $"this.__{this.Name}CustomFormatter__.Serialize(ref writer, value.{this.Name}, options)"; - } - else if (this.primitiveTypes.Contains(this.Type)) - { - return "writer.Write(value." + this.Name + ")"; - } - else - { - return $"global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<{this.Type}>(formatterResolver).Serialize(ref writer, value.{this.Name}, options)"; - } - } - - public string GetDeserializeMethodString() - { - if (CustomFormatterTypeName != null) - { - return $"this.__{this.Name}CustomFormatter__.Deserialize(ref reader, options)"; - } - else if (this.primitiveTypes.Contains(this.Type)) - { - if (this.Type == "byte[]") - { - return "global::MessagePack.Internal.CodeGenHelpers.GetArrayFromNullableSequence(reader.ReadBytes())"; - } - else - { - return $"reader.Read{this.ShortTypeName!.Replace("[]", "s")}()"; - } - } - else - { - return $"global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<{this.Type}>(formatterResolver).Deserialize(ref reader, options)"; - } - } -} - -public class EnumSerializationInfo : IResolverRegisterInfo, INamespaceInfo -{ - public EnumSerializationInfo(string? @namespace, string name, string fullName, string underlyingType) - { - Namespace = @namespace; - Name = name; - FullName = fullName; - UnderlyingType = underlyingType; - } - - public string? Namespace { get; } - - public string Name { get; } - - public string FullName { get; } - - public string UnderlyingType { get; } - - public string FormatterName => (this.Namespace == null ? this.Name : this.Namespace + "." + this.Name) + "Formatter"; -} - -public class GenericSerializationInfo : IResolverRegisterInfo, IEquatable -{ - public string FullName { get; } - - public string FormatterName { get; } - - public bool IsOpenGenericType { get; } - - public bool Equals(GenericSerializationInfo? other) - { - return this.FullName.Equals(other?.FullName); - } - - public override int GetHashCode() - { - return this.FullName.GetHashCode(); - } - - public GenericSerializationInfo(string fullName, string formatterName, bool isOpenGenericType) - { - FullName = fullName; - FormatterName = formatterName; - IsOpenGenericType = isOpenGenericType; - } -} - -public class UnionSerializationInfo : IResolverRegisterInfo, INamespaceInfo -{ - public string? Namespace { get; } - - public string Name { get; } - - public string FullName { get; } - - public string FormatterName => (this.Namespace == null ? this.Name : this.Namespace + "." + this.Name) + "Formatter"; - - public UnionSubTypeInfo[] SubTypes { get; } - - public UnionSerializationInfo(string? @namespace, string name, string fullName, UnionSubTypeInfo[] subTypes) - { - Namespace = @namespace; - Name = name; - FullName = fullName; - SubTypes = subTypes; - } -} - -public class UnionSubTypeInfo -{ - public UnionSubTypeInfo(int key, string type) - { - Key = key; - Type = type; - } - - public int Key { get; } - - public string Type { get; } -} diff --git a/src/MessagePack.Generator/CodeAnalysis/EnumSerializationInfo.cs b/src/MessagePack.Generator/CodeAnalysis/EnumSerializationInfo.cs new file mode 100644 index 000000000..a697146d5 --- /dev/null +++ b/src/MessagePack.Generator/CodeAnalysis/EnumSerializationInfo.cs @@ -0,0 +1,25 @@ +// Copyright (c) All contributors. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +namespace MessagePack.Generator.CodeAnalysis; + +public class EnumSerializationInfo : IResolverRegisterInfo, INamespaceInfo +{ + public EnumSerializationInfo(string? @namespace, string name, string fullName, string underlyingType) + { + Namespace = @namespace; + Name = name; + FullName = fullName; + UnderlyingType = underlyingType; + } + + public string? Namespace { get; } + + public string Name { get; } + + public string FullName { get; } + + public string UnderlyingType { get; } + + public string FormatterName => (this.Namespace == null ? this.Name : this.Namespace + "." + this.Name) + "Formatter"; +} diff --git a/src/MessagePack.Generator/CodeAnalysis/GenericSerializationInfo.cs b/src/MessagePack.Generator/CodeAnalysis/GenericSerializationInfo.cs new file mode 100644 index 000000000..f7bb3651d --- /dev/null +++ b/src/MessagePack.Generator/CodeAnalysis/GenericSerializationInfo.cs @@ -0,0 +1,30 @@ +// Copyright (c) All contributors. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +namespace MessagePack.Generator.CodeAnalysis; + +public class GenericSerializationInfo : IResolverRegisterInfo, IEquatable +{ + public string FullName { get; } + + public string FormatterName { get; } + + public bool IsOpenGenericType { get; } + + public bool Equals(GenericSerializationInfo? other) + { + return this.FullName.Equals(other?.FullName); + } + + public override int GetHashCode() + { + return this.FullName.GetHashCode(); + } + + public GenericSerializationInfo(string fullName, string formatterName, bool isOpenGenericType) + { + FullName = fullName; + FormatterName = formatterName; + IsOpenGenericType = isOpenGenericType; + } +} diff --git a/src/MessagePack.Generator/CodeAnalysis/GenericTypeParameterInfo.cs b/src/MessagePack.Generator/CodeAnalysis/GenericTypeParameterInfo.cs new file mode 100644 index 000000000..51be25ed7 --- /dev/null +++ b/src/MessagePack.Generator/CodeAnalysis/GenericTypeParameterInfo.cs @@ -0,0 +1,20 @@ +// Copyright (c) All contributors. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +namespace MessagePack.Generator.CodeAnalysis; + +public class GenericTypeParameterInfo +{ + public string Name { get; } + + public string Constraints { get; } + + public bool HasConstraints { get; } + + public GenericTypeParameterInfo(string name, string constraints) + { + Name = name ?? throw new ArgumentNullException(nameof(name)); + Constraints = constraints ?? throw new ArgumentNullException(nameof(name)); + HasConstraints = constraints != string.Empty; + } +} diff --git a/src/MessagePack.Generator/CodeAnalysis/INamespaceInfo.cs b/src/MessagePack.Generator/CodeAnalysis/INamespaceInfo.cs new file mode 100644 index 000000000..cf325424b --- /dev/null +++ b/src/MessagePack.Generator/CodeAnalysis/INamespaceInfo.cs @@ -0,0 +1,11 @@ +// Copyright (c) All contributors. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using MessagePack.Generator.Transforms; + +namespace MessagePack.Generator.CodeAnalysis; + +public interface INamespaceInfo +{ + string? Namespace { get; } +} diff --git a/src/MessagePack.Generator/CodeAnalysis/IResolverRegisterInfo.cs b/src/MessagePack.Generator/CodeAnalysis/IResolverRegisterInfo.cs new file mode 100644 index 000000000..466fc2198 --- /dev/null +++ b/src/MessagePack.Generator/CodeAnalysis/IResolverRegisterInfo.cs @@ -0,0 +1,11 @@ +// Copyright (c) All contributors. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +namespace MessagePack.Generator.CodeAnalysis; + +public interface IResolverRegisterInfo +{ + string FullName { get; } + + string FormatterName { get; } +} diff --git a/src/MessagePack.Generator/CodeAnalysis/MemberSerializationInfo.cs b/src/MessagePack.Generator/CodeAnalysis/MemberSerializationInfo.cs new file mode 100644 index 000000000..d1cf41ded --- /dev/null +++ b/src/MessagePack.Generator/CodeAnalysis/MemberSerializationInfo.cs @@ -0,0 +1,81 @@ +// Copyright (c) All contributors. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using MessagePack.Generator.Transforms; + +namespace MessagePack.Generator.CodeAnalysis; + +public class MemberSerializationInfo +{ + public bool IsProperty { get; } + + public bool IsWritable { get; } + + public bool IsReadable { get; } + + public int IntKey { get; } + + public string StringKey { get; } + + public string Type { get; } + + public string Name { get; } + + public string ShortTypeName { get; } + + public string? CustomFormatterTypeName { get; } + + private readonly HashSet primitiveTypes = new(ShouldUseFormatterResolverHelper.PrimitiveTypes); + + public MemberSerializationInfo(bool isProperty, bool isWritable, bool isReadable, int intKey, string stringKey, string name, string type, string shortTypeName, string? customFormatterTypeName) + { + IsProperty = isProperty; + IsWritable = isWritable; + IsReadable = isReadable; + IntKey = intKey; + StringKey = stringKey; + Type = type; + Name = name; + ShortTypeName = shortTypeName; + CustomFormatterTypeName = customFormatterTypeName; + } + + public string GetSerializeMethodString() + { + if (CustomFormatterTypeName != null) + { + return $"this.__{this.Name}CustomFormatter__.Serialize(ref writer, value.{this.Name}, options)"; + } + else if (this.primitiveTypes.Contains(this.Type)) + { + return "writer.Write(value." + this.Name + ")"; + } + else + { + return $"global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<{this.Type}>(formatterResolver).Serialize(ref writer, value.{this.Name}, options)"; + } + } + + public string GetDeserializeMethodString() + { + if (CustomFormatterTypeName != null) + { + return $"this.__{this.Name}CustomFormatter__.Deserialize(ref reader, options)"; + } + else if (this.primitiveTypes.Contains(this.Type)) + { + if (this.Type == "byte[]") + { + return "global::MessagePack.Internal.CodeGenHelpers.GetArrayFromNullableSequence(reader.ReadBytes())"; + } + else + { + return $"reader.Read{this.ShortTypeName!.Replace("[]", "s")}()"; + } + } + else + { + return $"global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<{this.Type}>(formatterResolver).Deserialize(ref reader, options)"; + } + } +} diff --git a/src/MessagePack.Generator/CodeAnalysis/ObjectSerializationInfo.cs b/src/MessagePack.Generator/CodeAnalysis/ObjectSerializationInfo.cs new file mode 100644 index 000000000..4f457e734 --- /dev/null +++ b/src/MessagePack.Generator/CodeAnalysis/ObjectSerializationInfo.cs @@ -0,0 +1,90 @@ +// Copyright (c) All contributors. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +namespace MessagePack.Generator.CodeAnalysis; + +public class ObjectSerializationInfo : IResolverRegisterInfo, INamespaceInfo +{ + public string Name { get; } + + public string FullName { get; } + + public string? Namespace { get; } + + public GenericTypeParameterInfo[] GenericTypeParameters { get; } + + public bool IsOpenGenericType { get; } + + public bool IsIntKey { get; } + + public bool IsStringKey + { + get { return !this.IsIntKey; } + } + + public bool IsClass { get; } + + public MemberSerializationInfo[] ConstructorParameters { get; } + + public MemberSerializationInfo[] Members { get; } + + public bool HasIMessagePackSerializationCallbackReceiver { get; } + + public bool NeedsCastOnBefore { get; } + + public bool NeedsCastOnAfter { get; } + + public string FormatterName => this.Namespace == null ? FormatterNameWithoutNameSpace : this.Namespace + "." + FormatterNameWithoutNameSpace; + + public string FormatterNameWithoutNameSpace => this.Name + "Formatter" + (this.IsOpenGenericType ? $"<{string.Join(", ", this.GenericTypeParameters.Select(x => x.Name))}>" : string.Empty); + + public int WriteCount + { + get + { + if (this.IsStringKey) + { + return this.Members.Count(x => x.IsReadable); + } + else + { + return this.MaxKey; + } + } + } + + public int MaxKey + { + get + { + return this.Members.Where(x => x.IsReadable).Select(x => x.IntKey).DefaultIfEmpty(-1).Max(); + } + } + + public MemberSerializationInfo? GetMember(int index) + { + return this.Members.FirstOrDefault(x => x.IntKey == index); + } + + public string GetConstructorString() + { + var args = string.Join(", ", this.ConstructorParameters.Select(x => "__" + x.Name + "__")); + return $"{this.FullName}({args})"; + } + + public ObjectSerializationInfo(bool isClass, bool isOpenGenericType, GenericTypeParameterInfo[] genericTypeParameterInfos, MemberSerializationInfo[] constructorParameters, bool isIntKey, MemberSerializationInfo[] members, string name, string fullName, string? @namespace, bool hasSerializationConstructor, bool needsCastOnAfter, bool needsCastOnBefore) + { + IsClass = isClass; + IsOpenGenericType = isOpenGenericType; + GenericTypeParameters = genericTypeParameterInfos; + ConstructorParameters = constructorParameters; + IsIntKey = isIntKey; + Members = members; + Name = name; + FullName = fullName; + Namespace = @namespace; + HasIMessagePackSerializationCallbackReceiver = hasSerializationConstructor; + NeedsCastOnAfter = needsCastOnAfter; + NeedsCastOnBefore = needsCastOnBefore; + } +} diff --git a/src/MessagePack.Generator/CodeAnalysis/UnionSerializationInfo.cs b/src/MessagePack.Generator/CodeAnalysis/UnionSerializationInfo.cs new file mode 100644 index 000000000..6c4b28333 --- /dev/null +++ b/src/MessagePack.Generator/CodeAnalysis/UnionSerializationInfo.cs @@ -0,0 +1,25 @@ +// Copyright (c) All contributors. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +namespace MessagePack.Generator.CodeAnalysis; + +public class UnionSerializationInfo : IResolverRegisterInfo, INamespaceInfo +{ + public string? Namespace { get; } + + public string Name { get; } + + public string FullName { get; } + + public string FormatterName => (this.Namespace == null ? this.Name : this.Namespace + "." + this.Name) + "Formatter"; + + public UnionSubTypeInfo[] SubTypes { get; } + + public UnionSerializationInfo(string? @namespace, string name, string fullName, UnionSubTypeInfo[] subTypes) + { + Namespace = @namespace; + Name = name; + FullName = fullName; + SubTypes = subTypes; + } +} diff --git a/src/MessagePack.Generator/CodeAnalysis/UnionSubTypeInfo.cs b/src/MessagePack.Generator/CodeAnalysis/UnionSubTypeInfo.cs new file mode 100644 index 000000000..ebe7e6416 --- /dev/null +++ b/src/MessagePack.Generator/CodeAnalysis/UnionSubTypeInfo.cs @@ -0,0 +1,17 @@ +// Copyright (c) All contributors. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +namespace MessagePack.Generator.CodeAnalysis; + +public class UnionSubTypeInfo +{ + public UnionSubTypeInfo(int key, string type) + { + Key = key; + Type = type; + } + + public int Key { get; } + + public string Type { get; } +} From 1098dac98aac8d2e36a831087187da08092a7b12 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Wed, 22 Mar 2023 10:39:35 -0600 Subject: [PATCH 027/660] Remove useless interface --- .../CodeAnalysis/EnumSerializationInfo.cs | 2 +- .../CodeAnalysis/INamespaceInfo.cs | 11 ----------- .../CodeAnalysis/ObjectSerializationInfo.cs | 2 +- .../CodeAnalysis/UnionSerializationInfo.cs | 2 +- 4 files changed, 3 insertions(+), 14 deletions(-) delete mode 100644 src/MessagePack.Generator/CodeAnalysis/INamespaceInfo.cs diff --git a/src/MessagePack.Generator/CodeAnalysis/EnumSerializationInfo.cs b/src/MessagePack.Generator/CodeAnalysis/EnumSerializationInfo.cs index a697146d5..eda057181 100644 --- a/src/MessagePack.Generator/CodeAnalysis/EnumSerializationInfo.cs +++ b/src/MessagePack.Generator/CodeAnalysis/EnumSerializationInfo.cs @@ -3,7 +3,7 @@ namespace MessagePack.Generator.CodeAnalysis; -public class EnumSerializationInfo : IResolverRegisterInfo, INamespaceInfo +public class EnumSerializationInfo : IResolverRegisterInfo { public EnumSerializationInfo(string? @namespace, string name, string fullName, string underlyingType) { diff --git a/src/MessagePack.Generator/CodeAnalysis/INamespaceInfo.cs b/src/MessagePack.Generator/CodeAnalysis/INamespaceInfo.cs deleted file mode 100644 index cf325424b..000000000 --- a/src/MessagePack.Generator/CodeAnalysis/INamespaceInfo.cs +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright (c) All contributors. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - -using MessagePack.Generator.Transforms; - -namespace MessagePack.Generator.CodeAnalysis; - -public interface INamespaceInfo -{ - string? Namespace { get; } -} diff --git a/src/MessagePack.Generator/CodeAnalysis/ObjectSerializationInfo.cs b/src/MessagePack.Generator/CodeAnalysis/ObjectSerializationInfo.cs index 4f457e734..dc021d5f7 100644 --- a/src/MessagePack.Generator/CodeAnalysis/ObjectSerializationInfo.cs +++ b/src/MessagePack.Generator/CodeAnalysis/ObjectSerializationInfo.cs @@ -3,7 +3,7 @@ namespace MessagePack.Generator.CodeAnalysis; -public class ObjectSerializationInfo : IResolverRegisterInfo, INamespaceInfo +public class ObjectSerializationInfo : IResolverRegisterInfo { public string Name { get; } diff --git a/src/MessagePack.Generator/CodeAnalysis/UnionSerializationInfo.cs b/src/MessagePack.Generator/CodeAnalysis/UnionSerializationInfo.cs index 6c4b28333..d64ea51ae 100644 --- a/src/MessagePack.Generator/CodeAnalysis/UnionSerializationInfo.cs +++ b/src/MessagePack.Generator/CodeAnalysis/UnionSerializationInfo.cs @@ -3,7 +3,7 @@ namespace MessagePack.Generator.CodeAnalysis; -public class UnionSerializationInfo : IResolverRegisterInfo, INamespaceInfo +public class UnionSerializationInfo : IResolverRegisterInfo { public string? Namespace { get; } From 306bf9bc2790bf3a5b4baceada41302302e0e2f4 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Wed, 22 Mar 2023 10:47:13 -0600 Subject: [PATCH 028/660] Use records for brevity --- .../CodeAnalysis/EnumSerializationInfo.cs | 18 +------ .../CodeAnalysis/GenericSerializationInfo.cs | 15 +----- .../CodeAnalysis/GenericTypeParameterInfo.cs | 15 +----- .../CodeAnalysis/MemberSerializationInfo.cs | 42 ++++----------- .../CodeAnalysis/ObjectSerializationInfo.cs | 54 +++++-------------- .../CodeAnalysis/UnionSerializationInfo.cs | 22 ++------ .../CodeAnalysis/UnionSubTypeInfo.cs | 13 +---- 7 files changed, 33 insertions(+), 146 deletions(-) diff --git a/src/MessagePack.Generator/CodeAnalysis/EnumSerializationInfo.cs b/src/MessagePack.Generator/CodeAnalysis/EnumSerializationInfo.cs index eda057181..dc2c02e7e 100644 --- a/src/MessagePack.Generator/CodeAnalysis/EnumSerializationInfo.cs +++ b/src/MessagePack.Generator/CodeAnalysis/EnumSerializationInfo.cs @@ -3,23 +3,7 @@ namespace MessagePack.Generator.CodeAnalysis; -public class EnumSerializationInfo : IResolverRegisterInfo +public sealed record EnumSerializationInfo(string? Namespace, string Name, string FullName, string UnderlyingType) : IResolverRegisterInfo { - public EnumSerializationInfo(string? @namespace, string name, string fullName, string underlyingType) - { - Namespace = @namespace; - Name = name; - FullName = fullName; - UnderlyingType = underlyingType; - } - - public string? Namespace { get; } - - public string Name { get; } - - public string FullName { get; } - - public string UnderlyingType { get; } - public string FormatterName => (this.Namespace == null ? this.Name : this.Namespace + "." + this.Name) + "Formatter"; } diff --git a/src/MessagePack.Generator/CodeAnalysis/GenericSerializationInfo.cs b/src/MessagePack.Generator/CodeAnalysis/GenericSerializationInfo.cs index f7bb3651d..2c014dfc1 100644 --- a/src/MessagePack.Generator/CodeAnalysis/GenericSerializationInfo.cs +++ b/src/MessagePack.Generator/CodeAnalysis/GenericSerializationInfo.cs @@ -3,14 +3,8 @@ namespace MessagePack.Generator.CodeAnalysis; -public class GenericSerializationInfo : IResolverRegisterInfo, IEquatable +public sealed record GenericSerializationInfo(string FullName, string FormatterName, bool IsOpenGenericType) : IResolverRegisterInfo { - public string FullName { get; } - - public string FormatterName { get; } - - public bool IsOpenGenericType { get; } - public bool Equals(GenericSerializationInfo? other) { return this.FullName.Equals(other?.FullName); @@ -20,11 +14,4 @@ public override int GetHashCode() { return this.FullName.GetHashCode(); } - - public GenericSerializationInfo(string fullName, string formatterName, bool isOpenGenericType) - { - FullName = fullName; - FormatterName = formatterName; - IsOpenGenericType = isOpenGenericType; - } } diff --git a/src/MessagePack.Generator/CodeAnalysis/GenericTypeParameterInfo.cs b/src/MessagePack.Generator/CodeAnalysis/GenericTypeParameterInfo.cs index 51be25ed7..5ae2d1a05 100644 --- a/src/MessagePack.Generator/CodeAnalysis/GenericTypeParameterInfo.cs +++ b/src/MessagePack.Generator/CodeAnalysis/GenericTypeParameterInfo.cs @@ -3,18 +3,7 @@ namespace MessagePack.Generator.CodeAnalysis; -public class GenericTypeParameterInfo +public record GenericTypeParameterInfo(string Name, string Constraints) { - public string Name { get; } - - public string Constraints { get; } - - public bool HasConstraints { get; } - - public GenericTypeParameterInfo(string name, string constraints) - { - Name = name ?? throw new ArgumentNullException(nameof(name)); - Constraints = constraints ?? throw new ArgumentNullException(nameof(name)); - HasConstraints = constraints != string.Empty; - } + public bool HasConstraints => this.Constraints.Length > 0; } diff --git a/src/MessagePack.Generator/CodeAnalysis/MemberSerializationInfo.cs b/src/MessagePack.Generator/CodeAnalysis/MemberSerializationInfo.cs index d1cf41ded..90cb9f145 100644 --- a/src/MessagePack.Generator/CodeAnalysis/MemberSerializationInfo.cs +++ b/src/MessagePack.Generator/CodeAnalysis/MemberSerializationInfo.cs @@ -5,41 +5,19 @@ namespace MessagePack.Generator.CodeAnalysis; -public class MemberSerializationInfo +public record MemberSerializationInfo( + bool IsProperty, + bool IsWritable, + bool IsReadable, + int IntKey, + string StringKey, + string Name, + string Type, + string ShortTypeName, + string? CustomFormatterTypeName) { - public bool IsProperty { get; } - - public bool IsWritable { get; } - - public bool IsReadable { get; } - - public int IntKey { get; } - - public string StringKey { get; } - - public string Type { get; } - - public string Name { get; } - - public string ShortTypeName { get; } - - public string? CustomFormatterTypeName { get; } - private readonly HashSet primitiveTypes = new(ShouldUseFormatterResolverHelper.PrimitiveTypes); - public MemberSerializationInfo(bool isProperty, bool isWritable, bool isReadable, int intKey, string stringKey, string name, string type, string shortTypeName, string? customFormatterTypeName) - { - IsProperty = isProperty; - IsWritable = isWritable; - IsReadable = isReadable; - IntKey = intKey; - StringKey = stringKey; - Type = type; - Name = name; - ShortTypeName = shortTypeName; - CustomFormatterTypeName = customFormatterTypeName; - } - public string GetSerializeMethodString() { if (CustomFormatterTypeName != null) diff --git a/src/MessagePack.Generator/CodeAnalysis/ObjectSerializationInfo.cs b/src/MessagePack.Generator/CodeAnalysis/ObjectSerializationInfo.cs index dc021d5f7..f8f9783f7 100644 --- a/src/MessagePack.Generator/CodeAnalysis/ObjectSerializationInfo.cs +++ b/src/MessagePack.Generator/CodeAnalysis/ObjectSerializationInfo.cs @@ -3,37 +3,25 @@ namespace MessagePack.Generator.CodeAnalysis; -public class ObjectSerializationInfo : IResolverRegisterInfo +public record ObjectSerializationInfo( + bool IsClass, + bool IsOpenGenericType, + GenericTypeParameterInfo[] GenericTypeParameters, + MemberSerializationInfo[] ConstructorParameters, + bool IsIntKey, + MemberSerializationInfo[] Members, + string Name, + string FullName, + string? Namespace, + bool HasIMessagePackSerializationCallbackReceiver, + bool NeedsCastOnAfter, + bool NeedsCastOnBefore) : IResolverRegisterInfo { - public string Name { get; } - - public string FullName { get; } - - public string? Namespace { get; } - - public GenericTypeParameterInfo[] GenericTypeParameters { get; } - - public bool IsOpenGenericType { get; } - - public bool IsIntKey { get; } - public bool IsStringKey { get { return !this.IsIntKey; } } - public bool IsClass { get; } - - public MemberSerializationInfo[] ConstructorParameters { get; } - - public MemberSerializationInfo[] Members { get; } - - public bool HasIMessagePackSerializationCallbackReceiver { get; } - - public bool NeedsCastOnBefore { get; } - - public bool NeedsCastOnAfter { get; } - public string FormatterName => this.Namespace == null ? FormatterNameWithoutNameSpace : this.Namespace + "." + FormatterNameWithoutNameSpace; public string FormatterNameWithoutNameSpace => this.Name + "Formatter" + (this.IsOpenGenericType ? $"<{string.Join(", ", this.GenericTypeParameters.Select(x => x.Name))}>" : string.Empty); @@ -71,20 +59,4 @@ public string GetConstructorString() var args = string.Join(", ", this.ConstructorParameters.Select(x => "__" + x.Name + "__")); return $"{this.FullName}({args})"; } - - public ObjectSerializationInfo(bool isClass, bool isOpenGenericType, GenericTypeParameterInfo[] genericTypeParameterInfos, MemberSerializationInfo[] constructorParameters, bool isIntKey, MemberSerializationInfo[] members, string name, string fullName, string? @namespace, bool hasSerializationConstructor, bool needsCastOnAfter, bool needsCastOnBefore) - { - IsClass = isClass; - IsOpenGenericType = isOpenGenericType; - GenericTypeParameters = genericTypeParameterInfos; - ConstructorParameters = constructorParameters; - IsIntKey = isIntKey; - Members = members; - Name = name; - FullName = fullName; - Namespace = @namespace; - HasIMessagePackSerializationCallbackReceiver = hasSerializationConstructor; - NeedsCastOnAfter = needsCastOnAfter; - NeedsCastOnBefore = needsCastOnBefore; - } } diff --git a/src/MessagePack.Generator/CodeAnalysis/UnionSerializationInfo.cs b/src/MessagePack.Generator/CodeAnalysis/UnionSerializationInfo.cs index d64ea51ae..0a2e07899 100644 --- a/src/MessagePack.Generator/CodeAnalysis/UnionSerializationInfo.cs +++ b/src/MessagePack.Generator/CodeAnalysis/UnionSerializationInfo.cs @@ -3,23 +3,11 @@ namespace MessagePack.Generator.CodeAnalysis; -public class UnionSerializationInfo : IResolverRegisterInfo +public record UnionSerializationInfo( + string? Namespace, + string Name, + string FullName, + UnionSubTypeInfo[] SubTypes) : IResolverRegisterInfo { - public string? Namespace { get; } - - public string Name { get; } - - public string FullName { get; } - public string FormatterName => (this.Namespace == null ? this.Name : this.Namespace + "." + this.Name) + "Formatter"; - - public UnionSubTypeInfo[] SubTypes { get; } - - public UnionSerializationInfo(string? @namespace, string name, string fullName, UnionSubTypeInfo[] subTypes) - { - Namespace = @namespace; - Name = name; - FullName = fullName; - SubTypes = subTypes; - } } diff --git a/src/MessagePack.Generator/CodeAnalysis/UnionSubTypeInfo.cs b/src/MessagePack.Generator/CodeAnalysis/UnionSubTypeInfo.cs index ebe7e6416..7b65c23f7 100644 --- a/src/MessagePack.Generator/CodeAnalysis/UnionSubTypeInfo.cs +++ b/src/MessagePack.Generator/CodeAnalysis/UnionSubTypeInfo.cs @@ -3,15 +3,4 @@ namespace MessagePack.Generator.CodeAnalysis; -public class UnionSubTypeInfo -{ - public UnionSubTypeInfo(int key, string type) - { - Key = key; - Type = type; - } - - public int Key { get; } - - public string Type { get; } -} +public record UnionSubTypeInfo(int Key, string Type); From 54a2eb2e3ec93d7988698f3de4361e6ee6b37e7a Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Wed, 22 Mar 2023 10:54:26 -0600 Subject: [PATCH 029/660] Share namespace prefixing code --- .../CodeAnalysis/CodeAnalysisUtilities.cs | 12 ++++++++++++ .../CodeAnalysis/EnumSerializationInfo.cs | 2 +- .../CodeAnalysis/ObjectSerializationInfo.cs | 4 ++-- .../CodeAnalysis/UnionSerializationInfo.cs | 2 +- .../Transforms/FormatterTemplate.cs | 2 +- .../Transforms/FormatterTemplate.tt | 2 +- .../StringKey/StringKeyFormatterTemplate.cs | 2 +- .../StringKey/StringKeyFormatterTemplate.tt | 2 +- 8 files changed, 20 insertions(+), 8 deletions(-) create mode 100644 src/MessagePack.Generator/CodeAnalysis/CodeAnalysisUtilities.cs diff --git a/src/MessagePack.Generator/CodeAnalysis/CodeAnalysisUtilities.cs b/src/MessagePack.Generator/CodeAnalysis/CodeAnalysisUtilities.cs new file mode 100644 index 000000000..83d170a9b --- /dev/null +++ b/src/MessagePack.Generator/CodeAnalysis/CodeAnalysisUtilities.cs @@ -0,0 +1,12 @@ +// Copyright (c) All contributors. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +namespace MessagePack.Generator.CodeAnalysis; + +internal static class CodeAnalysisUtilities +{ + internal static string NamespaceAndType(string typeName, string? @namespace) + { + return string.IsNullOrEmpty(@namespace) ? typeName : $"{@namespace}.{typeName}"; + } +} diff --git a/src/MessagePack.Generator/CodeAnalysis/EnumSerializationInfo.cs b/src/MessagePack.Generator/CodeAnalysis/EnumSerializationInfo.cs index dc2c02e7e..7da292813 100644 --- a/src/MessagePack.Generator/CodeAnalysis/EnumSerializationInfo.cs +++ b/src/MessagePack.Generator/CodeAnalysis/EnumSerializationInfo.cs @@ -5,5 +5,5 @@ namespace MessagePack.Generator.CodeAnalysis; public sealed record EnumSerializationInfo(string? Namespace, string Name, string FullName, string UnderlyingType) : IResolverRegisterInfo { - public string FormatterName => (this.Namespace == null ? this.Name : this.Namespace + "." + this.Name) + "Formatter"; + public string FormatterName => CodeAnalysisUtilities.NamespaceAndType(this.Name + "Formatter", this.Namespace); } diff --git a/src/MessagePack.Generator/CodeAnalysis/ObjectSerializationInfo.cs b/src/MessagePack.Generator/CodeAnalysis/ObjectSerializationInfo.cs index f8f9783f7..3b717fc28 100644 --- a/src/MessagePack.Generator/CodeAnalysis/ObjectSerializationInfo.cs +++ b/src/MessagePack.Generator/CodeAnalysis/ObjectSerializationInfo.cs @@ -22,9 +22,9 @@ public bool IsStringKey get { return !this.IsIntKey; } } - public string FormatterName => this.Namespace == null ? FormatterNameWithoutNameSpace : this.Namespace + "." + FormatterNameWithoutNameSpace; + public string FormatterName => CodeAnalysisUtilities.NamespaceAndType(this.FormatterNameWithoutNamespace, this.Namespace); - public string FormatterNameWithoutNameSpace => this.Name + "Formatter" + (this.IsOpenGenericType ? $"<{string.Join(", ", this.GenericTypeParameters.Select(x => x.Name))}>" : string.Empty); + public string FormatterNameWithoutNamespace => this.Name + "Formatter" + (this.IsOpenGenericType ? $"<{string.Join(", ", this.GenericTypeParameters.Select(x => x.Name))}>" : string.Empty); public int WriteCount { diff --git a/src/MessagePack.Generator/CodeAnalysis/UnionSerializationInfo.cs b/src/MessagePack.Generator/CodeAnalysis/UnionSerializationInfo.cs index 0a2e07899..1a835b3e7 100644 --- a/src/MessagePack.Generator/CodeAnalysis/UnionSerializationInfo.cs +++ b/src/MessagePack.Generator/CodeAnalysis/UnionSerializationInfo.cs @@ -9,5 +9,5 @@ public record UnionSerializationInfo( string FullName, UnionSubTypeInfo[] SubTypes) : IResolverRegisterInfo { - public string FormatterName => (this.Namespace == null ? this.Name : this.Namespace + "." + this.Name) + "Formatter"; + public string FormatterName => CodeAnalysisUtilities.NamespaceAndType(this.Name + "Formatter", this.Namespace); } diff --git a/src/MessagePack.Generator/Transforms/FormatterTemplate.cs b/src/MessagePack.Generator/Transforms/FormatterTemplate.cs index 940bcdc2f..00be5d883 100644 --- a/src/MessagePack.Generator/Transforms/FormatterTemplate.cs +++ b/src/MessagePack.Generator/Transforms/FormatterTemplate.cs @@ -30,7 +30,7 @@ public virtual string TransformText() this.Write("\r\n{\r\n"); bool isFormatterResolverNecessary = ShouldUseFormatterResolverHelper.ShouldUseFormatterResolver(Info.Members); this.Write(" public sealed class "); - this.Write(this.ToStringHelper.ToStringWithCulture(Info.FormatterNameWithoutNameSpace)); + this.Write(this.ToStringHelper.ToStringWithCulture(Info.FormatterNameWithoutNamespace)); this.Write(" : global::MessagePack.Formatters.IMessagePackFormatter<"); this.Write(this.ToStringHelper.ToStringWithCulture(Info.FullName)); this.Write(">\r\n"); diff --git a/src/MessagePack.Generator/Transforms/FormatterTemplate.tt b/src/MessagePack.Generator/Transforms/FormatterTemplate.tt index 2625b11f5..010299ce6 100644 --- a/src/MessagePack.Generator/Transforms/FormatterTemplate.tt +++ b/src/MessagePack.Generator/Transforms/FormatterTemplate.tt @@ -7,7 +7,7 @@ namespace <#= Namespace #> { <# bool isFormatterResolverNecessary = ShouldUseFormatterResolverHelper.ShouldUseFormatterResolver(Info.Members);#> - public sealed class <#= Info.FormatterNameWithoutNameSpace #> : global::MessagePack.Formatters.IMessagePackFormatter<<#= Info.FullName #>> + public sealed class <#= Info.FormatterNameWithoutNamespace #> : global::MessagePack.Formatters.IMessagePackFormatter<<#= Info.FullName #>> <# foreach (var typeArg in Info.GenericTypeParameters.Where(x => x.HasConstraints)) { #> where <#= typeArg.Name #> : <#= typeArg.Constraints #> <# } #> diff --git a/src/MessagePack.Generator/Transforms/StringKey/StringKeyFormatterTemplate.cs b/src/MessagePack.Generator/Transforms/StringKey/StringKeyFormatterTemplate.cs index 23160a8ae..410245601 100644 --- a/src/MessagePack.Generator/Transforms/StringKey/StringKeyFormatterTemplate.cs +++ b/src/MessagePack.Generator/Transforms/StringKey/StringKeyFormatterTemplate.cs @@ -36,7 +36,7 @@ public virtual string TransformText() bool isFormatterResolverNecessary = ShouldUseFormatterResolverHelper.ShouldUseFormatterResolver(Info.Members); this.Write(" public sealed class "); - this.Write(this.ToStringHelper.ToStringWithCulture(Info.FormatterNameWithoutNameSpace)); + this.Write(this.ToStringHelper.ToStringWithCulture(Info.FormatterNameWithoutNamespace)); this.Write(" : global::MessagePack.Formatters.IMessagePackFormatter<"); this.Write(this.ToStringHelper.ToStringWithCulture(Info.FullName)); this.Write(">\r\n"); diff --git a/src/MessagePack.Generator/Transforms/StringKey/StringKeyFormatterTemplate.tt b/src/MessagePack.Generator/Transforms/StringKey/StringKeyFormatterTemplate.tt index 94d8bf0f1..f2cf73630 100644 --- a/src/MessagePack.Generator/Transforms/StringKey/StringKeyFormatterTemplate.tt +++ b/src/MessagePack.Generator/Transforms/StringKey/StringKeyFormatterTemplate.tt @@ -14,7 +14,7 @@ namespace <#= Namespace #> } bool isFormatterResolverNecessary = ShouldUseFormatterResolverHelper.ShouldUseFormatterResolver(Info.Members); #> - public sealed class <#= Info.FormatterNameWithoutNameSpace #> : global::MessagePack.Formatters.IMessagePackFormatter<<#= Info.FullName #>> + public sealed class <#= Info.FormatterNameWithoutNamespace #> : global::MessagePack.Formatters.IMessagePackFormatter<<#= Info.FullName #>> <# foreach (var typeArg in Info.GenericTypeParameters.Where(x => x.HasConstraints)) {#> where <#= typeArg.Name #> : <#= typeArg.Constraints #> <# }#> From bb71f8c836f2e7af7d5b861efc887ab4e37ae0e5 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Wed, 22 Mar 2023 11:00:07 -0600 Subject: [PATCH 030/660] Condense #pragmas in generated code --- .../MessagePackGenerator.Emit.cs | 13 +------------ .../MessagePack.GeneratedResolver.g.cs | 13 +------------ .../MessagePack.MyTestNamespace.MyEnum.g.cs | 13 +------------ ...agePack.MyTestNamespace.MyMessagePackObject.g.cs | 13 +------------ 4 files changed, 4 insertions(+), 48 deletions(-) diff --git a/src/MessagePack.Generator/MessagePackGenerator.Emit.cs b/src/MessagePack.Generator/MessagePackGenerator.Emit.cs index 01fbe54fd..5b5a9a129 100644 --- a/src/MessagePack.Generator/MessagePackGenerator.Emit.cs +++ b/src/MessagePack.Generator/MessagePackGenerator.Emit.cs @@ -14,18 +14,7 @@ public partial class MessagePackGenerator private const string FileHeader = """ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 168 - -#pragma warning disable CS1591 // document public APIs - -#pragma warning disable SA1129 // Do not use default value type constructor -#pragma warning disable SA1309 // Field names should not begin with underscore -#pragma warning disable SA1312 // Variable names should begin with lower-case letter -#pragma warning disable SA1403 // File may only contain a single namespace -#pragma warning disable SA1649 // File name should match first type name +#pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 """; private static void Generate(TypeDeclarationSyntax syntax, AnalyzerOptions analyzerOptions, Compilation compilation, IGeneratorContext context) diff --git a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter/MessagePack.GeneratedResolver.g.cs b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter/MessagePack.GeneratedResolver.g.cs index e225104a8..3ff547744 100644 --- a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter/MessagePack.GeneratedResolver.g.cs +++ b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter/MessagePack.GeneratedResolver.g.cs @@ -1,17 +1,6 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 168 - -#pragma warning disable CS1591 // document public APIs - -#pragma warning disable SA1129 // Do not use default value type constructor -#pragma warning disable SA1309 // Field names should not begin with underscore -#pragma warning disable SA1312 // Variable names should begin with lower-case letter -#pragma warning disable SA1403 // File may only contain a single namespace -#pragma warning disable SA1649 // File name should match first type name +#pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 namespace MessagePack.Resolvers { diff --git a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter/MessagePack.MyTestNamespace.MyEnum.g.cs b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter/MessagePack.MyTestNamespace.MyEnum.g.cs index 62a184ea7..76a2d62e7 100644 --- a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter/MessagePack.MyTestNamespace.MyEnum.g.cs +++ b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter/MessagePack.MyTestNamespace.MyEnum.g.cs @@ -1,17 +1,6 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 168 - -#pragma warning disable CS1591 // document public APIs - -#pragma warning disable SA1129 // Do not use default value type constructor -#pragma warning disable SA1309 // Field names should not begin with underscore -#pragma warning disable SA1312 // Variable names should begin with lower-case letter -#pragma warning disable SA1403 // File may only contain a single namespace -#pragma warning disable SA1649 // File name should match first type name +#pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 namespace MessagePack.Formatters.MyTestNamespace { diff --git a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter/MessagePack.MyTestNamespace.MyMessagePackObject.g.cs b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter/MessagePack.MyTestNamespace.MyMessagePackObject.g.cs index c62c07a20..4dcf77988 100644 --- a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter/MessagePack.MyTestNamespace.MyMessagePackObject.g.cs +++ b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter/MessagePack.MyTestNamespace.MyMessagePackObject.g.cs @@ -1,17 +1,6 @@ // -#pragma warning disable 618 -#pragma warning disable 612 -#pragma warning disable 414 -#pragma warning disable 168 - -#pragma warning disable CS1591 // document public APIs - -#pragma warning disable SA1129 // Do not use default value type constructor -#pragma warning disable SA1309 // Field names should not begin with underscore -#pragma warning disable SA1312 // Variable names should begin with lower-case letter -#pragma warning disable SA1403 // File may only contain a single namespace -#pragma warning disable SA1649 // File name should match first type name +#pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 namespace MessagePack.Formatters.MyTestNamespace { From ff5afe215224839f60155ef9d311fc3e155e45de Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Wed, 22 Mar 2023 11:24:06 -0600 Subject: [PATCH 031/660] Capture full model in a record --- .../CodeAnalysis/FullModel.cs | 12 ++++++++ .../CodeAnalysis/TypeCollector.cs | 4 +-- .../MessagePackGenerator.Emit.cs | 30 +++++++------------ 3 files changed, 25 insertions(+), 21 deletions(-) create mode 100644 src/MessagePack.Generator/CodeAnalysis/FullModel.cs diff --git a/src/MessagePack.Generator/CodeAnalysis/FullModel.cs b/src/MessagePack.Generator/CodeAnalysis/FullModel.cs new file mode 100644 index 000000000..c0eb486a8 --- /dev/null +++ b/src/MessagePack.Generator/CodeAnalysis/FullModel.cs @@ -0,0 +1,12 @@ +// Copyright (c) All contributors. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +namespace MessagePack.Generator.CodeAnalysis; + +public record FullModel( + ObjectSerializationInfo[] ObjectInfos, + EnumSerializationInfo[] EnumInfos, + GenericSerializationInfo[] GenericInfos, + UnionSerializationInfo[] UnionInfos) +{ +} diff --git a/src/MessagePack.Generator/CodeAnalysis/TypeCollector.cs b/src/MessagePack.Generator/CodeAnalysis/TypeCollector.cs index b67455ca4..15adc7d6d 100644 --- a/src/MessagePack.Generator/CodeAnalysis/TypeCollector.cs +++ b/src/MessagePack.Generator/CodeAnalysis/TypeCollector.cs @@ -313,7 +313,7 @@ private void ResetWorkspace() } // EntryPoint - public (ObjectSerializationInfo[] ObjectInfo, EnumSerializationInfo[] EnumInfo, GenericSerializationInfo[] GenericInfo, UnionSerializationInfo[] UnionInfo) Collect() + public FullModel Collect() { this.ResetWorkspace(); @@ -322,7 +322,7 @@ private void ResetWorkspace() this.CollectCore(item); } - return ( + return new FullModel( this.collectedObjectInfo.OrderBy(x => x.FullName).ToArray(), this.collectedEnumInfo.OrderBy(x => x.FullName).ToArray(), this.collectedGenericInfo.Distinct().OrderBy(x => x.FullName).ToArray(), diff --git a/src/MessagePack.Generator/MessagePackGenerator.Emit.cs b/src/MessagePack.Generator/MessagePackGenerator.Emit.cs index 5b5a9a129..aaf54c4d2 100644 --- a/src/MessagePack.Generator/MessagePackGenerator.Emit.cs +++ b/src/MessagePack.Generator/MessagePackGenerator.Emit.cs @@ -27,16 +27,11 @@ private static void Generate(TypeDeclarationSyntax syntax, AnalyzerOptions analy return; } - var fullType = typeSymbol.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat) - .Replace("global::", string.Empty) - .Replace("<", "_") - .Replace(">", "_"); - TypeCollector collector = new(compilation, true, isForceUseMap: false, ignoreTypeNames: null, typeSymbol); - var (objectInfo, enumInfo, genericInfo, unionInfo) = collector.Collect(); + FullModel model = collector.Collect(); - Generate(context, analyzerOptions, objectInfo, enumInfo, unionInfo, genericInfo); + Generate(context, analyzerOptions, model); } /// @@ -44,11 +39,8 @@ private static void Generate(TypeDeclarationSyntax syntax, AnalyzerOptions analy /// /// Generator context. /// The analyzer options. - /// The ObjectSerializationInfo array which TypeCollector.Collect returns. - /// The EnumSerializationInfo array which TypeCollector.Collect returns. - /// The UnionSerializationInfo array which TypeCollector.Collect returns. - /// The GenericSerializationInfo array which TypeCollector.Collect returns. - private static void Generate(IGeneratorContext context, AnalyzerOptions options, ObjectSerializationInfo[] objectInfos, EnumSerializationInfo[] enumInfos, UnionSerializationInfo[] unionInfos, GenericSerializationInfo[] genericInfos) + /// The full messagepack object model. + private static void Generate(IGeneratorContext context, AnalyzerOptions options, FullModel model) { StringBuilder sb = new(); @@ -56,28 +48,28 @@ private static void Generate(IGeneratorContext context, AnalyzerOptions options, options.ResolverNamespace, options.FormatterNamespace, options.ResolverName, - genericInfos + model.GenericInfos .Where(x => !x.IsOpenGenericType) .Cast() - .Concat(enumInfos) - .Concat(unionInfos) - .Concat(objectInfos.Where(x => !x.IsOpenGenericType)) + .Concat(model.EnumInfos) + .Concat(model.UnionInfos) + .Concat(model.ObjectInfos.Where(x => !x.IsOpenGenericType)) .ToArray()); AddTransform(resolverTemplate.TransformText(), "GeneratedResolver"); - foreach (EnumSerializationInfo info in enumInfos) + foreach (EnumSerializationInfo info in model.EnumInfos) { EnumTemplate transform = new($"{options.FormatterNamespace}.{info.Namespace}", info); AddTransform(transform.TransformText(), $"{info.Namespace}.{info.Name}"); } - foreach (UnionSerializationInfo info in unionInfos) + foreach (UnionSerializationInfo info in model.UnionInfos) { UnionTemplate transform = new(options.FormatterNamespace, info); AddTransform(transform.TransformText(), $"Union.{info.Name}"); } - foreach (ObjectSerializationInfo info in objectInfos) + foreach (ObjectSerializationInfo info in model.ObjectInfos) { string formatterNamespace = $"{options.FormatterNamespace}.{info.Namespace}"; IFormatterTemplate transform = info.IsStringKey From e9ce2d60c6cb88dec2b9552287443933b3510f71 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Wed, 22 Mar 2023 17:44:13 -0600 Subject: [PATCH 032/660] Start refactoring TypeCollector --- .../MessagePackGenerator.cs | 2 + .../CodeAnalysis/TypeCollector.cs | 146 +++++++----------- .../IGeneratorContext.cs | 4 + .../MessagePackGenerator.Emit.cs | 10 +- .../MessagePackGenerator.cs | 2 + 5 files changed, 72 insertions(+), 92 deletions(-) diff --git a/src/MessagePack.Generator.Roslyn3/MessagePackGenerator.cs b/src/MessagePack.Generator.Roslyn3/MessagePackGenerator.cs index fbe6f9367..d4869f5e5 100644 --- a/src/MessagePack.Generator.Roslyn3/MessagePackGenerator.cs +++ b/src/MessagePack.Generator.Roslyn3/MessagePackGenerator.cs @@ -80,5 +80,7 @@ public GeneratorContext(GeneratorExecutionContext context) public CancellationToken CancellationToken => context.CancellationToken; public void AddSource(string hintName, string source) => context.AddSource(hintName, source); + + public void ReportDiagnostic(Diagnostic diagnostic) => context.ReportDiagnostic(diagnostic); } } diff --git a/src/MessagePack.Generator/CodeAnalysis/TypeCollector.cs b/src/MessagePack.Generator/CodeAnalysis/TypeCollector.cs index 15adc7d6d..5ad2d6104 100644 --- a/src/MessagePack.Generator/CodeAnalysis/TypeCollector.cs +++ b/src/MessagePack.Generator/CodeAnalysis/TypeCollector.cs @@ -34,31 +34,31 @@ internal class ReferenceSymbols public ReferenceSymbols(Compilation compilation, Action logger) { - MessagePackObjectAttribute = compilation.GetTypeByMetadataName("MessagePack.MessagePackObjectAttribute") + this.MessagePackObjectAttribute = compilation.GetTypeByMetadataName("MessagePack.MessagePackObjectAttribute") ?? throw new InvalidOperationException("failed to get metadata of MessagePack.MessagePackObjectAttribute"); - UnionAttribute = compilation.GetTypeByMetadataName("MessagePack.UnionAttribute") + this.UnionAttribute = compilation.GetTypeByMetadataName("MessagePack.UnionAttribute") ?? throw new InvalidOperationException("failed to get metadata of MessagePack.UnionAttribute"); - SerializationConstructorAttribute = compilation.GetTypeByMetadataName("MessagePack.SerializationConstructorAttribute") + this.SerializationConstructorAttribute = compilation.GetTypeByMetadataName("MessagePack.SerializationConstructorAttribute") ?? throw new InvalidOperationException("failed to get metadata of MessagePack.SerializationConstructorAttribute"); - KeyAttribute = compilation.GetTypeByMetadataName("MessagePack.KeyAttribute") + this.KeyAttribute = compilation.GetTypeByMetadataName("MessagePack.KeyAttribute") ?? throw new InvalidOperationException("failed to get metadata of MessagePack.KeyAttribute"); - IgnoreAttribute = compilation.GetTypeByMetadataName("MessagePack.IgnoreMemberAttribute") + this.IgnoreAttribute = compilation.GetTypeByMetadataName("MessagePack.IgnoreMemberAttribute") ?? throw new InvalidOperationException("failed to get metadata of MessagePack.IgnoreMemberAttribute"); - IgnoreDataMemberAttribute = compilation.GetTypeByMetadataName("System.Runtime.Serialization.IgnoreDataMemberAttribute"); - if (IgnoreDataMemberAttribute == null) + this.IgnoreDataMemberAttribute = compilation.GetTypeByMetadataName("System.Runtime.Serialization.IgnoreDataMemberAttribute"); + if (this.IgnoreDataMemberAttribute == null) { logger("failed to get metadata of System.Runtime.Serialization.IgnoreDataMemberAttribute"); } - IMessagePackSerializationCallbackReceiver = compilation.GetTypeByMetadataName("MessagePack.IMessagePackSerializationCallbackReceiver") + this.IMessagePackSerializationCallbackReceiver = compilation.GetTypeByMetadataName("MessagePack.IMessagePackSerializationCallbackReceiver") ?? throw new InvalidOperationException("failed to get metadata of MessagePack.IMessagePackSerializationCallbackReceiver"); - MessagePackFormatterAttribute = compilation.GetTypeByMetadataName("MessagePack.MessagePackFormatterAttribute") + this.MessagePackFormatterAttribute = compilation.GetTypeByMetadataName("MessagePack.MessagePackFormatterAttribute") ?? throw new InvalidOperationException("failed to get metadata of MessagePack.MessagePackFormatterAttribute"); } } @@ -73,10 +73,7 @@ public class TypeCollector private static readonly SymbolDisplayFormat ShortTypeNameFormat = new SymbolDisplayFormat( typeQualificationStyle: SymbolDisplayTypeQualificationStyle.NameAndContainingTypes); - private readonly bool isForceUseMap; - private readonly ReferenceSymbols typeReferences; - private readonly ITypeSymbol[] targetTypes; - private readonly HashSet embeddedTypes = new(new[] + private static readonly HashSet EmbeddedTypes = new(new[] { "short", "int", @@ -147,7 +144,7 @@ public class TypeCollector "System.Reactive.Unit", }); - private readonly Dictionary knownGenericTypes = new() + private static readonly Dictionary KnownGenericTypes = new() { #pragma warning disable SA1509 // Opening braces should not be preceded by blank line { "System.Collections.Generic.List<>", "global::MessagePack.Formatters.ListFormatter" }, @@ -223,10 +220,12 @@ public class TypeCollector #pragma warning restore SA1509 // Opening braces should not be preceded by blank line }; + private readonly bool isForceUseMap; + private readonly IGeneratorContext context; + private readonly ReferenceSymbols typeReferences; + private readonly ITypeSymbol? targetType; private readonly bool disallowInternal; - private readonly bool excludeArrayElement; - private readonly HashSet externalIgnoreTypeNames; // visitor workspace: @@ -240,67 +239,40 @@ public class TypeCollector private readonly Compilation compilation; - public TypeCollector(Compilation compilation, bool disallowInternal, bool isForceUseMap, string[]? ignoreTypeNames, Action logger) - { - this.typeReferences = new ReferenceSymbols(compilation, logger); - this.disallowInternal = disallowInternal; - this.isForceUseMap = isForceUseMap; - this.externalIgnoreTypeNames = new HashSet(ignoreTypeNames ?? Array.Empty()); - this.compilation = compilation; - - targetTypes = compilation.GetNamedTypeSymbols() - .Where(x => - { - if (x.DeclaredAccessibility == Accessibility.Public) - { - return true; - } - - if (!disallowInternal) - { - return x.DeclaredAccessibility == Accessibility.Friend; - } - - return false; - }) - .Where(x => - ((x.TypeKind == TypeKind.Interface) && x.GetAttributes().Any(x2 => x2.AttributeClass.ApproximatelyEqual(typeReferences.UnionAttribute))) - || ((x.TypeKind == TypeKind.Class && x.IsAbstract) && x.GetAttributes().Any(x2 => x2.AttributeClass.ApproximatelyEqual(typeReferences.UnionAttribute))) - || ((x.TypeKind == TypeKind.Class) && x.GetAttributes().Any(x2 => x2.AttributeClass.ApproximatelyEqual(typeReferences.MessagePackObjectAttribute))) - || ((x.TypeKind == TypeKind.Struct) && x.GetAttributes().Any(x2 => x2.AttributeClass.ApproximatelyEqual(typeReferences.MessagePackObjectAttribute)))) - .ToArray(); - } - - public TypeCollector(Compilation compilation, bool disallowInternal, bool isForceUseMap, string[]? ignoreTypeNames, ITypeSymbol targetType) + private TypeCollector(Compilation compilation, bool disallowInternal, AnalyzerOptions options, string[]? ignoreTypeNames, ITypeSymbol targetType, IGeneratorContext context) { this.typeReferences = new ReferenceSymbols(compilation, _ => { }); this.disallowInternal = disallowInternal; - this.isForceUseMap = isForceUseMap; + this.isForceUseMap = options.UsesMapMode; + this.context = context; this.externalIgnoreTypeNames = new HashSet(ignoreTypeNames ?? Array.Empty()); this.compilation = compilation; this.excludeArrayElement = true; + this.context = context; - targetTypes = new[] { targetType } - .Where(x => + if (targetType.DeclaredAccessibility == Accessibility.Public || + (!disallowInternal && targetType.DeclaredAccessibility == Accessibility.Friend)) + { + if (((targetType.TypeKind == TypeKind.Interface) && targetType.GetAttributes().Any(x2 => x2.AttributeClass.ApproximatelyEqual(this.typeReferences.UnionAttribute))) + || ((targetType.TypeKind == TypeKind.Class && targetType.IsAbstract) && targetType.GetAttributes().Any(x2 => x2.AttributeClass.ApproximatelyEqual(this.typeReferences.UnionAttribute))) + || ((targetType.TypeKind == TypeKind.Class) && targetType.GetAttributes().Any(x2 => x2.AttributeClass.ApproximatelyEqual(this.typeReferences.MessagePackObjectAttribute))) + || ((targetType.TypeKind == TypeKind.Struct) && targetType.GetAttributes().Any(x2 => x2.AttributeClass.ApproximatelyEqual(this.typeReferences.MessagePackObjectAttribute)))) { - if (x.DeclaredAccessibility == Accessibility.Public) - { - return true; - } + this.targetType = targetType; + } + } + } - if (!disallowInternal) - { - return x.DeclaredAccessibility == Accessibility.Friend; - } + public static FullModel? Collect(Compilation compilation, bool disallowInternal, AnalyzerOptions options, string[]? ignoreTypeNames, ITypeSymbol targetType, IGeneratorContext context) + { + TypeCollector collector = new(compilation, true, options, ignoreTypeNames: null, targetType, context); + if (collector.targetType is null) + { + return null; + } - return false; - }) - .Where(x => - ((x.TypeKind == TypeKind.Interface) && x.GetAttributes().Any(x2 => x2.AttributeClass.ApproximatelyEqual(typeReferences.UnionAttribute))) - || ((x.TypeKind == TypeKind.Class && x.IsAbstract) && x.GetAttributes().Any(x2 => x2.AttributeClass.ApproximatelyEqual(typeReferences.UnionAttribute))) - || ((x.TypeKind == TypeKind.Class) && x.GetAttributes().Any(x2 => x2.AttributeClass.ApproximatelyEqual(typeReferences.MessagePackObjectAttribute))) - || ((x.TypeKind == TypeKind.Struct) && x.GetAttributes().Any(x2 => x2.AttributeClass.ApproximatelyEqual(typeReferences.MessagePackObjectAttribute)))) - .ToArray(); + FullModel model = collector.Collect(); + return model; } private void ResetWorkspace() @@ -317,9 +289,9 @@ public FullModel Collect() { this.ResetWorkspace(); - foreach (var item in this.targetTypes) + if (this.targetType is not null) { - this.CollectCore(item); + this.CollectCore(this.targetType); } return new FullModel( @@ -338,7 +310,7 @@ private void CollectCore(ITypeSymbol typeSymbol) } var typeSymbolString = typeSymbol.WithNullableAnnotation(NullableAnnotation.NotAnnotated).ToString() ?? throw new InvalidOperationException(); - if (this.embeddedTypes.Contains(typeSymbolString)) + if (EmbeddedTypes.Contains(typeSymbolString)) { return; } @@ -350,7 +322,7 @@ private void CollectCore(ITypeSymbol typeSymbol) if (typeSymbol is IArrayTypeSymbol arrayTypeSymbol) { - this.CollectArray((IArrayTypeSymbol)ToTupleUnderlyingType(arrayTypeSymbol)); + this.CollectArray((IArrayTypeSymbol)this.ToTupleUnderlyingType(arrayTypeSymbol)); return; } @@ -378,7 +350,7 @@ private void CollectCore(ITypeSymbol typeSymbol) if (type.IsGenericType) { - this.CollectGeneric((INamedTypeSymbol)ToTupleUnderlyingType(type)); + this.CollectGeneric((INamedTypeSymbol)this.ToTupleUnderlyingType(type)); return; } @@ -439,9 +411,9 @@ private void CollectGenericUnion(INamedTypeSymbol type) do { var x = enumerator.Current; - if (x[1] is { Value: INamedTypeSymbol unionType } && alreadyCollected.Contains(unionType) == false) + if (x[1] is { Value: INamedTypeSymbol unionType } && this.alreadyCollected.Contains(unionType) == false) { - CollectCore(unionType); + this.CollectCore(unionType); } } while (enumerator.MoveNext()); @@ -450,7 +422,7 @@ private void CollectGenericUnion(INamedTypeSymbol type) private void CollectArray(IArrayTypeSymbol array) { ITypeSymbol elemType = array.ElementType; - if (!excludeArrayElement) + if (!this.excludeArrayElement) { this.CollectCore(elemType); } @@ -481,7 +453,7 @@ private ITypeSymbol ToTupleUnderlyingType(ITypeSymbol typeSymbol) { if (typeSymbol is IArrayTypeSymbol array) { - return compilation.CreateArrayTypeSymbol(ToTupleUnderlyingType(array.ElementType), array.Rank); + return this.compilation.CreateArrayTypeSymbol(this.ToTupleUnderlyingType(array.ElementType), array.Rank); } if (typeSymbol is not INamedTypeSymbol namedType || !namedType.IsGenericType) @@ -490,7 +462,7 @@ private ITypeSymbol ToTupleUnderlyingType(ITypeSymbol typeSymbol) } namedType = namedType.TupleUnderlyingType ?? namedType; - var newTypeArguments = namedType.TypeArguments.Select(ToTupleUnderlyingType).ToArray(); + var newTypeArguments = namedType.TypeArguments.Select(this.ToTupleUnderlyingType).ToArray(); if (!namedType.TypeArguments.SequenceEqual(newTypeArguments)) { return namedType.ConstructedFrom.Construct(newTypeArguments); @@ -504,7 +476,7 @@ private void CollectGeneric(INamedTypeSymbol type) INamedTypeSymbol genericType = type.ConstructUnboundGenericType(); var genericTypeString = genericType.ToDisplayString(); var fullName = type.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat); - var isOpenGenericType = IsOpenGenericTypeRecursively(type); + var isOpenGenericType = this.IsOpenGenericTypeRecursively(type); // special case if (fullName == "global::System.ArraySegment" || fullName == "global::System.ArraySegment?") @@ -518,7 +490,7 @@ private void CollectGeneric(INamedTypeSymbol type) var firstTypeArgument = type.TypeArguments[0]; this.CollectCore(firstTypeArgument); - if (this.embeddedTypes.Contains(firstTypeArgument.ToString()!)) + if (EmbeddedTypes.Contains(firstTypeArgument.ToString()!)) { return; } @@ -529,7 +501,7 @@ private void CollectGeneric(INamedTypeSymbol type) } // collection - if (this.knownGenericTypes.TryGetValue(genericTypeString, out var formatter)) + if (KnownGenericTypes.TryGetValue(genericTypeString, out var formatter)) { foreach (ITypeSymbol item in type.TypeArguments) { @@ -548,13 +520,13 @@ private void CollectGeneric(INamedTypeSymbol type) return; } - formatter = this.knownGenericTypes["System.Linq.IGrouping<,>"]; + formatter = KnownGenericTypes["System.Linq.IGrouping<,>"]; f = formatter.Replace("TREPLACE", typeArgs); var groupingInfo = new GenericSerializationInfo("global::System.Linq.IGrouping<" + typeArgs + ">", f, isOpenGenericType); this.collectedGenericInfo.Add(groupingInfo); - formatter = this.knownGenericTypes["System.Collections.Generic.IEnumerable<>"]; + formatter = KnownGenericTypes["System.Collections.Generic.IEnumerable<>"]; typeArgs = type.TypeArguments[1].ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat); f = formatter.Replace("TREPLACE", typeArgs); @@ -575,10 +547,10 @@ private void CollectGeneric(INamedTypeSymbol type) // Collect substituted types for the properties and fields. // NOTE: It is used to register formatters from nested generic type. // However, closed generic types such as `Foo` are not registered as a formatter. - GetObjectInfo(type); + this.GetObjectInfo(type); // Collect generic type definition, that is not collected when it is defined outside target project. - CollectCore(type.OriginalDefinition); + this.CollectCore(type.OriginalDefinition); } // Collect substituted types for the type parameters (e.g. Bar in Foo) @@ -617,8 +589,8 @@ private void CollectGeneric(INamedTypeSymbol type) private void CollectObject(INamedTypeSymbol type) { - ObjectSerializationInfo info = GetObjectInfo(type); - collectedObjectInfo.Add(info); + ObjectSerializationInfo info = this.GetObjectInfo(type); + this.collectedObjectInfo.Add(info); } private ObjectSerializationInfo GetObjectInfo(INamedTypeSymbol type) @@ -1071,6 +1043,6 @@ private bool IsAllowAccessibility(ITypeSymbol symbol) private bool IsOpenGenericTypeRecursively(INamedTypeSymbol type) { - return type.IsGenericType && type.TypeArguments.Any(x => x is ITypeParameterSymbol || (x is INamedTypeSymbol symbol && IsOpenGenericTypeRecursively(symbol))); + return type.IsGenericType && type.TypeArguments.Any(x => x is ITypeParameterSymbol || (x is INamedTypeSymbol symbol && this.IsOpenGenericTypeRecursively(symbol))); } } diff --git a/src/MessagePack.Generator/IGeneratorContext.cs b/src/MessagePack.Generator/IGeneratorContext.cs index b4fe9f3a8..b51c5acbb 100644 --- a/src/MessagePack.Generator/IGeneratorContext.cs +++ b/src/MessagePack.Generator/IGeneratorContext.cs @@ -1,6 +1,8 @@ // Copyright (c) All contributors. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. +using Microsoft.CodeAnalysis; + namespace MessagePack.Generator; public interface IGeneratorContext @@ -8,4 +10,6 @@ public interface IGeneratorContext CancellationToken CancellationToken { get; } void AddSource(string hintName, string source); + + void ReportDiagnostic(Diagnostic diagnostic); } diff --git a/src/MessagePack.Generator/MessagePackGenerator.Emit.cs b/src/MessagePack.Generator/MessagePackGenerator.Emit.cs index aaf54c4d2..63135cff4 100644 --- a/src/MessagePack.Generator/MessagePackGenerator.Emit.cs +++ b/src/MessagePack.Generator/MessagePackGenerator.Emit.cs @@ -27,11 +27,11 @@ private static void Generate(TypeDeclarationSyntax syntax, AnalyzerOptions analy return; } - TypeCollector collector = new(compilation, true, isForceUseMap: false, ignoreTypeNames: null, typeSymbol); - - FullModel model = collector.Collect(); - - Generate(context, analyzerOptions, model); + FullModel? model = TypeCollector.Collect(compilation, true, analyzerOptions, ignoreTypeNames: null, typeSymbol, context); + if (model is not null) + { + Generate(context, analyzerOptions, model); + } } /// diff --git a/src/MessagePack.Generator/MessagePackGenerator.cs b/src/MessagePack.Generator/MessagePackGenerator.cs index dc0114074..e8243dc1b 100644 --- a/src/MessagePack.Generator/MessagePackGenerator.cs +++ b/src/MessagePack.Generator/MessagePackGenerator.cs @@ -70,5 +70,7 @@ public GeneratorContext(SourceProductionContext context) public CancellationToken CancellationToken => context.CancellationToken; public void AddSource(string hintName, string source) => context.AddSource(hintName, source); + + public void ReportDiagnostic(Diagnostic diagnostic) => context.ReportDiagnostic(diagnostic); } } From c695665b365526517efb1e4e5d06a9a1062a3fbe Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Wed, 22 Mar 2023 19:43:45 -0600 Subject: [PATCH 033/660] Collect the FullModel separately from syntax generation --- .../MessagePackGenerator.cs | 6 +++- .../CodeAnalysis/AnalyzerOptions.cs | 8 ++++- .../CodeAnalysis/FullModel.cs | 3 +- .../CodeAnalysis/TypeCollector.cs | 32 +++++++++++++++---- .../MessagePackGenerator.Emit.cs | 21 ++---------- .../MessagePackGenerator.cs | 10 ++++-- 6 files changed, 48 insertions(+), 32 deletions(-) diff --git a/src/MessagePack.Generator.Roslyn3/MessagePackGenerator.cs b/src/MessagePack.Generator.Roslyn3/MessagePackGenerator.cs index d4869f5e5..7ef0ec5d2 100644 --- a/src/MessagePack.Generator.Roslyn3/MessagePackGenerator.cs +++ b/src/MessagePack.Generator.Roslyn3/MessagePackGenerator.cs @@ -30,7 +30,11 @@ public void Execute(GeneratorExecutionContext context) foreach (var syntax in receiver.ClassDeclarations) { - Generate(syntax, options, compilation, generateContext); + FullModel? model = TypeCollector.Collect(compilation, options, syntax, generateContext, context.CancellationToken); + if (model is not null) + { + Generate(generateContext, model); + } } } diff --git a/src/MessagePack.Generator/CodeAnalysis/AnalyzerOptions.cs b/src/MessagePack.Generator/CodeAnalysis/AnalyzerOptions.cs index 4b249d20b..407efcec5 100644 --- a/src/MessagePack.Generator/CodeAnalysis/AnalyzerOptions.cs +++ b/src/MessagePack.Generator/CodeAnalysis/AnalyzerOptions.cs @@ -1,11 +1,17 @@ // Copyright (c) All contributors. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. +using System.Collections.Immutable; using Microsoft.CodeAnalysis.Diagnostics; namespace MessagePack.Generator.CodeAnalysis; -public record AnalyzerOptions(string Namespace = "MessagePack", string ResolverName = "GeneratedResolver", bool UsesMapMode = false) +public record AnalyzerOptions( + string Namespace = "MessagePack", + string ResolverName = "GeneratedResolver", + bool UsesMapMode = false, + bool DisallowInternal = false, + IReadOnlyCollection? IgnoreTypeNames = null) { public const string MessagePackGeneratedResolverNamespace = "build_property.MessagePackGeneratedResolverNamespace"; public const string MessagePackGeneratedResolverName = "build_property.MessagePackGeneratedResolverName"; diff --git a/src/MessagePack.Generator/CodeAnalysis/FullModel.cs b/src/MessagePack.Generator/CodeAnalysis/FullModel.cs index c0eb486a8..f923fc214 100644 --- a/src/MessagePack.Generator/CodeAnalysis/FullModel.cs +++ b/src/MessagePack.Generator/CodeAnalysis/FullModel.cs @@ -7,6 +7,7 @@ public record FullModel( ObjectSerializationInfo[] ObjectInfos, EnumSerializationInfo[] EnumInfos, GenericSerializationInfo[] GenericInfos, - UnionSerializationInfo[] UnionInfos) + UnionSerializationInfo[] UnionInfos, + AnalyzerOptions Options) { } diff --git a/src/MessagePack.Generator/CodeAnalysis/TypeCollector.cs b/src/MessagePack.Generator/CodeAnalysis/TypeCollector.cs index 5ad2d6104..4e9076202 100644 --- a/src/MessagePack.Generator/CodeAnalysis/TypeCollector.cs +++ b/src/MessagePack.Generator/CodeAnalysis/TypeCollector.cs @@ -8,6 +8,7 @@ using System.Text; using System.Text.RegularExpressions; using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.CSharp.Syntax; namespace MessagePack.Generator.CodeAnalysis; @@ -221,7 +222,8 @@ public class TypeCollector }; private readonly bool isForceUseMap; - private readonly IGeneratorContext context; + private readonly IGeneratorContext? context; + private readonly AnalyzerOptions options; private readonly ReferenceSymbols typeReferences; private readonly ITypeSymbol? targetType; private readonly bool disallowInternal; @@ -239,13 +241,14 @@ public class TypeCollector private readonly Compilation compilation; - private TypeCollector(Compilation compilation, bool disallowInternal, AnalyzerOptions options, string[]? ignoreTypeNames, ITypeSymbol targetType, IGeneratorContext context) + private TypeCollector(Compilation compilation, AnalyzerOptions options, ITypeSymbol targetType, IGeneratorContext? context) { this.typeReferences = new ReferenceSymbols(compilation, _ => { }); - this.disallowInternal = disallowInternal; + this.disallowInternal = options.DisallowInternal; this.isForceUseMap = options.UsesMapMode; this.context = context; - this.externalIgnoreTypeNames = new HashSet(ignoreTypeNames ?? Array.Empty()); + this.options = options; + this.externalIgnoreTypeNames = new HashSet(options.IgnoreTypeNames ?? Array.Empty()); this.compilation = compilation; this.excludeArrayElement = true; this.context = context; @@ -263,9 +266,23 @@ private TypeCollector(Compilation compilation, bool disallowInternal, AnalyzerOp } } - public static FullModel? Collect(Compilation compilation, bool disallowInternal, AnalyzerOptions options, string[]? ignoreTypeNames, ITypeSymbol targetType, IGeneratorContext context) + public static FullModel? Collect(Compilation compilation, AnalyzerOptions options, TypeDeclarationSyntax typeDeclaration, IGeneratorContext? generatorContext, CancellationToken cancellationToken) { - TypeCollector collector = new(compilation, true, options, ignoreTypeNames: null, targetType, context); + SemanticModel semanticModel = compilation.GetSemanticModel(typeDeclaration.SyntaxTree); + if (semanticModel.GetDeclaredSymbol(typeDeclaration, cancellationToken) is ITypeSymbol typeSymbol) + { + if (Collect(compilation, options, typeSymbol, generatorContext) is FullModel model) + { + return model; + } + } + + return null; + } + + public static FullModel? Collect(Compilation compilation, AnalyzerOptions options, ITypeSymbol targetType, IGeneratorContext? context) + { + TypeCollector collector = new(compilation, options, targetType, context); if (collector.targetType is null) { return null; @@ -298,7 +315,8 @@ public FullModel Collect() this.collectedObjectInfo.OrderBy(x => x.FullName).ToArray(), this.collectedEnumInfo.OrderBy(x => x.FullName).ToArray(), this.collectedGenericInfo.Distinct().OrderBy(x => x.FullName).ToArray(), - this.collectedUnionInfo.OrderBy(x => x.FullName).ToArray()); + this.collectedUnionInfo.OrderBy(x => x.FullName).ToArray(), + this.options); } // Gate of recursive collect diff --git a/src/MessagePack.Generator/MessagePackGenerator.Emit.cs b/src/MessagePack.Generator/MessagePackGenerator.Emit.cs index 63135cff4..62f282b00 100644 --- a/src/MessagePack.Generator/MessagePackGenerator.Emit.cs +++ b/src/MessagePack.Generator/MessagePackGenerator.Emit.cs @@ -17,31 +17,14 @@ public partial class MessagePackGenerator #pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 """; - private static void Generate(TypeDeclarationSyntax syntax, AnalyzerOptions analyzerOptions, Compilation compilation, IGeneratorContext context) - { - var semanticModel = compilation.GetSemanticModel(syntax.SyntaxTree); - - var typeSymbol = semanticModel.GetDeclaredSymbol(syntax, context.CancellationToken) as ITypeSymbol; - if (typeSymbol == null) - { - return; - } - - FullModel? model = TypeCollector.Collect(compilation, true, analyzerOptions, ignoreTypeNames: null, typeSymbol, context); - if (model is not null) - { - Generate(context, analyzerOptions, model); - } - } - /// /// Generates the specialized resolver and formatters for the types that require serialization in a given compilation. /// /// Generator context. - /// The analyzer options. /// The full messagepack object model. - private static void Generate(IGeneratorContext context, AnalyzerOptions options, FullModel model) + private static void Generate(IGeneratorContext context, FullModel model) { + AnalyzerOptions options = model.Options; StringBuilder sb = new(); ResolverTemplate resolverTemplate = new( diff --git a/src/MessagePack.Generator/MessagePackGenerator.cs b/src/MessagePack.Generator/MessagePackGenerator.cs index e8243dc1b..be506f3b8 100644 --- a/src/MessagePack.Generator/MessagePackGenerator.cs +++ b/src/MessagePack.Generator/MessagePackGenerator.cs @@ -33,12 +33,16 @@ void Register(IncrementalValuesProvider typeDeclarations) { var source = typeDeclarations .Combine(context.CompilationProvider) - .Combine(options); + .Combine(options) + .Select(static (s, ct) => + { + return TypeCollector.Collect(s.Left.Right, s.Right, s.Left.Left, null, ct); + }) + .Where(fm => fm is not null); context.RegisterSourceOutput(source, static (context, source) => { - var ((typeDeclaration, compilation), options) = source; - Generate(typeDeclaration, options, compilation, new GeneratorContext(context)); + Generate(new GeneratorContext(context), source!); }); } } From f8f78e718d08ed489a460f6b1f42d22db754dd93 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Wed, 22 Mar 2023 20:13:57 -0600 Subject: [PATCH 034/660] Delete or restore old test code --- .../MessagePack.Generator.Tests.csproj | 2 - .../TemporaryProjectWorkarea.cs | 249 ------------------ .../TestUtilities.cs | 31 ++- 3 files changed, 18 insertions(+), 264 deletions(-) delete mode 100644 tests/MessagePack.Generator.Tests/TemporaryProjectWorkarea.cs diff --git a/tests/MessagePack.Generator.Tests/MessagePack.Generator.Tests.csproj b/tests/MessagePack.Generator.Tests/MessagePack.Generator.Tests.csproj index 8a68eda51..7f9cd9ffc 100644 --- a/tests/MessagePack.Generator.Tests/MessagePack.Generator.Tests.csproj +++ b/tests/MessagePack.Generator.Tests/MessagePack.Generator.Tests.csproj @@ -12,8 +12,6 @@ - - diff --git a/tests/MessagePack.Generator.Tests/TemporaryProjectWorkarea.cs b/tests/MessagePack.Generator.Tests/TemporaryProjectWorkarea.cs deleted file mode 100644 index 92dda215c..000000000 --- a/tests/MessagePack.Generator.Tests/TemporaryProjectWorkarea.cs +++ /dev/null @@ -1,249 +0,0 @@ -// Copyright (c) All contributors. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Reflection; -using System.Runtime.Loader; -using System.Threading.Tasks; -using MessagePack.Formatters; -using Microsoft.CodeAnalysis; -using Microsoft.CodeAnalysis.CSharp; -using Microsoft.CodeAnalysis.CSharp.Syntax; -using Nerdbank.Streams; - -namespace MessagePack.Generator.Tests -{ - /// - /// Provides a temporary work area for unit testing. - /// - public class TemporaryProjectWorkarea : IDisposable - { - private readonly string tempDirPath; - private readonly string targetCsprojFileName = "TempTargetProject.csproj"; - private readonly string referencedCsprojFileName = "TempReferencedProject.csproj"; - private readonly bool cleanOnDisposing; - - /// - /// Gets the identifier of the workarea. - /// - public Guid WorkareaId { get; } - - /// - /// Gets Generator target csproj file path. - /// - public string TargetCsProjectPath { get; } - - /// - /// Gets csproj file path Referenced from TargetProject. - /// - public string ReferencedCsProjectPath { get; } - - public string TargetProjectDirectory { get; } - - public string ReferencedProjectDirectory { get; } - - public string OutputDirectory { get; } - - public static TemporaryProjectWorkarea Create(bool cleanOnDisposing = true) - { - return new TemporaryProjectWorkarea(cleanOnDisposing); - } - - private TemporaryProjectWorkarea(bool cleanOnDisposing) - { - WorkareaId = Guid.NewGuid(); - this.cleanOnDisposing = cleanOnDisposing; - this.tempDirPath = Path.Combine(Path.GetTempPath(), $"MessagePack.Generator.Tests-{WorkareaId}"); - - TargetProjectDirectory = Path.Combine(tempDirPath, "TargetProject"); - ReferencedProjectDirectory = Path.Combine(tempDirPath, "ReferencedProject"); - OutputDirectory = Path.Combine(tempDirPath, "Output"); - - Directory.CreateDirectory(TargetProjectDirectory); - Directory.CreateDirectory(ReferencedProjectDirectory); - Directory.CreateDirectory(OutputDirectory); - Directory.CreateDirectory(Path.Combine(OutputDirectory, "bin")); - - var solutionRootDir = Path.GetFullPath(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "../../../..")); - var messagePackProjectDir = Path.Combine(solutionRootDir, "src/MessagePack/MessagePack.csproj"); - var annotationsProjectDir = Path.Combine(solutionRootDir, "src/MessagePack.Annotations/MessagePack.Annotations.csproj"); - - ReferencedCsProjectPath = Path.Combine(ReferencedProjectDirectory, referencedCsprojFileName); - var referencedCsprojContents = @" - - - netstandard2.0 - - - - - - -"; - AddFileToReferencedProject(referencedCsprojFileName, referencedCsprojContents); - - TargetCsProjectPath = Path.Combine(TargetProjectDirectory, targetCsprojFileName); - var csprojContents = @" - - - netstandard2.0 - - - - - - - - -"; - AddFileToTargetProject(targetCsprojFileName, csprojContents); - } - - /// - /// Add file to Generator target project. - /// - public void AddFileToTargetProject(string fileName, string contents) - { - File.WriteAllText(Path.Combine(TargetProjectDirectory, fileName), contents.Trim()); - } - - /// - /// Add file to project, referenced by Generator target project. - /// - public void AddFileToReferencedProject(string fileName, string contents) - { - File.WriteAllText(Path.Combine(ReferencedProjectDirectory, fileName), contents.Trim()); - } - - public OutputCompilation GetOutputCompilation() - { - var refAsmDir = Path.GetDirectoryName(typeof(object).Assembly.Location); - - var referenceCompilation = CSharpCompilation.Create(Guid.NewGuid().ToString()) - .AddSyntaxTrees( - Directory.EnumerateFiles(ReferencedProjectDirectory, "*.cs", SearchOption.AllDirectories) - .Select(x => CSharpSyntaxTree.ParseText(File.ReadAllText(x), CSharpParseOptions.Default, x))) - .AddReferences(MetadataReference.CreateFromFile(Path.Combine(refAsmDir, "System.Private.CoreLib.dll"))) - .AddReferences(MetadataReference.CreateFromFile(Path.Combine(refAsmDir, "System.Runtime.Extensions.dll"))) - .AddReferences(MetadataReference.CreateFromFile(Path.Combine(refAsmDir, "System.Collections.dll"))) - .AddReferences(MetadataReference.CreateFromFile(Path.Combine(refAsmDir, "System.Linq.dll"))) - .AddReferences(MetadataReference.CreateFromFile(Path.Combine(refAsmDir, "System.Console.dll"))) - .AddReferences(MetadataReference.CreateFromFile(Path.Combine(refAsmDir, "System.Runtime.dll"))) - .AddReferences(MetadataReference.CreateFromFile(Path.Combine(refAsmDir, "System.Memory.dll"))) - .AddReferences(MetadataReference.CreateFromFile(Path.Combine(refAsmDir, "netstandard.dll"))) - .AddReferences(MetadataReference.CreateFromFile(typeof(object).Assembly.Location)) - .AddReferences(MetadataReference.CreateFromFile(typeof(MessagePack.MessagePackObjectAttribute).Assembly.Location)) - .AddReferences(MetadataReference.CreateFromFile(typeof(IMessagePackFormatter<>).Assembly.Location)) - .WithOptions(new CSharpCompilationOptions(OutputKind.DynamicallyLinkedLibrary)); - - var compilation = CSharpCompilation.Create(Guid.NewGuid().ToString()) - .AddSyntaxTrees( - Directory.EnumerateFiles(TargetProjectDirectory, "*.cs", SearchOption.AllDirectories) - .Concat(Directory.EnumerateFiles(OutputDirectory, "*.cs", SearchOption.AllDirectories)) - .Select(x => CSharpSyntaxTree.ParseText(File.ReadAllText(x), CSharpParseOptions.Default, x))) - .AddReferences(referenceCompilation.ToMetadataReference()) - .AddReferences(MetadataReference.CreateFromFile(Path.Combine(refAsmDir, "System.Private.CoreLib.dll"))) - .AddReferences(MetadataReference.CreateFromFile(Path.Combine(refAsmDir, "System.Runtime.Extensions.dll"))) - .AddReferences(MetadataReference.CreateFromFile(Path.Combine(refAsmDir, "System.Collections.dll"))) - .AddReferences(MetadataReference.CreateFromFile(Path.Combine(refAsmDir, "System.Linq.dll"))) - .AddReferences(MetadataReference.CreateFromFile(Path.Combine(refAsmDir, "System.Console.dll"))) - .AddReferences(MetadataReference.CreateFromFile(Path.Combine(refAsmDir, "System.Runtime.dll"))) - .AddReferences(MetadataReference.CreateFromFile(Path.Combine(refAsmDir, "System.Memory.dll"))) - .AddReferences(MetadataReference.CreateFromFile(Path.Combine(refAsmDir, "netstandard.dll"))) - .AddReferences(MetadataReference.CreateFromFile(typeof(object).Assembly.Location)) - .AddReferences(MetadataReference.CreateFromFile(typeof(MessagePack.MessagePackObjectAttribute).Assembly.Location)) - .AddReferences(MetadataReference.CreateFromFile(typeof(IMessagePackFormatter<>).Assembly.Location)) - .WithOptions(new CSharpCompilationOptions(OutputKind.DynamicallyLinkedLibrary)); - - return new OutputCompilation(this, compilation); - } - - public void Dispose() - { - this.Dispose(true); - GC.SuppressFinalize(this); - } - - protected virtual void Dispose(bool disposing) - { - if (disposing) - { - if (cleanOnDisposing) - { - Directory.Delete(tempDirPath, true); - } - } - } - } - - public class OutputCompilation - { - private readonly TemporaryProjectWorkarea workarea; - - public Compilation Compilation { get; } - - public OutputCompilation(TemporaryProjectWorkarea workarea, Compilation compilation) - { - this.workarea = workarea; - this.Compilation = compilation ?? throw new ArgumentNullException(nameof(compilation)); - } - - public INamedTypeSymbol[] GetNamedTypeSymbolsFromGenerated() - { - return Compilation.SyntaxTrees - .Select(x => Compilation.GetSemanticModel(x)) - .SelectMany(semanticModel => - { - return semanticModel.SyntaxTree.GetRoot() - .DescendantNodes() - .Select(x => semanticModel.GetDeclaredSymbol(x)) - .OfType(); - }) - .ToArray(); - } - - public IReadOnlyList GetResolverKnownFormatterTypes() - { - return Compilation.SyntaxTrees - .SelectMany(x => x.GetRoot() - .DescendantNodes() - .OfType() - .Where(x => x.Identifier.ToString().EndsWith("ResolverGetFormatterHelper")) - .SelectMany(x => x.DescendantNodes()) - .OfType() - .Where(x => x.Identifier.ToString() == "GetFormatter") - .SelectMany(x => x.DescendantNodes()) - .OfType() - .SelectMany(x => x.DescendantNodes()) - .OfType() - .SelectMany(x => x.ChildNodes()) - .Where(x => x is QualifiedNameSyntax || x is IdentifierNameSyntax || x is GenericNameSyntax || x is PredefinedTypeSyntax) - .Select(x => x.ToString())) - .ToArray(); - } - - /// - /// Load the generated assembly and execute the code in that context. - /// - public void ExecuteWithGeneratedAssembly(Action action) - { - var memoryStream = new MemoryStream(); - Compilation.Emit(memoryStream); - memoryStream.Position = 0; - - var assemblyLoadContext = new AssemblyLoadContext($"TempProject-{workarea.WorkareaId}", isCollectible: true); - try - { - Assembly assembly = assemblyLoadContext.LoadFromStream(memoryStream); - action(assemblyLoadContext, assembly); - } - finally - { - assemblyLoadContext.Unload(); - } - } - } -} diff --git a/tests/MessagePack.Generator.Tests/TestUtilities.cs b/tests/MessagePack.Generator.Tests/TestUtilities.cs index ad6bb13f5..1b52703c1 100644 --- a/tests/MessagePack.Generator.Tests/TestUtilities.cs +++ b/tests/MessagePack.Generator.Tests/TestUtilities.cs @@ -2,21 +2,26 @@ // Licensed under the MIT license. See LICENSE file in the project root for full license information. using System.Reflection; +using Microsoft; -namespace MessagePack.Generator.Tests +namespace MessagePack.Generator.Tests; + +internal static class TestUtilities { - internal static class TestUtilities + /// + /// Fetches the static instance of the named resolver, by its Instance property. + /// + /// The assembly to retrieve the resolver from. + /// The full name of the resolver. + /// The resolver. + internal static IFormatterResolver GetResolverInstance(Assembly assembly, string name) { - /// - /// Fetches the static instance of the named resolver, by its Instance property. - /// - /// The assembly to retrieve the resolver from. - /// The full name of the resolver. - /// The resolver. - internal static IFormatterResolver GetResolverInstance(Assembly assembly, string name) - { - var resolverType = assembly.GetType(name); - return (IFormatterResolver)resolverType.GetField("Instance", BindingFlags.Static | BindingFlags.Public).GetValue(null); - } + Type? resolverType = assembly.GetType(name); + Requires.Argument(resolverType is not null, nameof(name), "No type with the given name found."); + FieldInfo? instanceField = resolverType.GetField("Instance", BindingFlags.Static | BindingFlags.Public); + Assert.NotNull(instanceField); + object? instanceValue = instanceField.GetValue(null); + Assert.NotNull(instanceValue); + return (IFormatterResolver)instanceValue; } } From 6ca7a2327b80f52c114c48c9c0914d4f8d82be4d Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Thu, 23 Mar 2023 12:42:24 -0600 Subject: [PATCH 035/660] Fix nested and namespace-less enums --- MessagePack.sln | 7 ++ .../CodeAnalysis/CodeAnalysisUtilities.cs | 5 ++ .../CodeAnalysis/TypeCollector.cs | 12 ++-- .../MessagePackGenerator.Emit.cs | 4 +- .../ExecutionTests.cs | 31 +++++++++ ...essagePack.Generator.ExecutionTests.csproj | 16 +++++ .../Usings.cs | 6 ++ .../GenerateEnumFormatterTest.cs | 51 ++++++++++++++- .../MessagePack.Generator.Tests.csproj | 3 +- .../MessagePack.GeneratedResolver.g.cs | 0 .../MessagePack.MyTestNamespace.MyEnum.g.cs | 0 ...k.MyTestNamespace.MyMessagePackObject.g.cs | 0 .../MessagePack..Outer_MyEnum.g.cs | 21 ++++++ ...essagePack..Outer_MyMessagePackObject.g.cs | 52 +++++++++++++++ .../MessagePack.GeneratedResolver.g.cs | 64 +++++++++++++++++++ .../MessagePack..MyEnum.g.cs | 21 ++++++ .../MessagePack..MyMessagePackObject.g.cs | 52 +++++++++++++++ .../MessagePack.GeneratedResolver.g.cs | 64 +++++++++++++++++++ tests/SourceGeneratorConsumer.props | 9 +++ 19 files changed, 409 insertions(+), 9 deletions(-) create mode 100644 tests/MessagePack.Generator.ExecutionTests/ExecutionTests.cs create mode 100644 tests/MessagePack.Generator.ExecutionTests/MessagePack.Generator.ExecutionTests.csproj create mode 100644 tests/MessagePack.Generator.ExecutionTests/Usings.cs rename tests/MessagePack.Generator.Tests/Resources/{EnumFormatter => EnumFormatter_InNamespace}/MessagePack.GeneratedResolver.g.cs (100%) rename tests/MessagePack.Generator.Tests/Resources/{EnumFormatter => EnumFormatter_InNamespace}/MessagePack.MyTestNamespace.MyEnum.g.cs (100%) rename tests/MessagePack.Generator.Tests/Resources/{EnumFormatter => EnumFormatter_InNamespace}/MessagePack.MyTestNamespace.MyMessagePackObject.g.cs (100%) create mode 100644 tests/MessagePack.Generator.Tests/Resources/EnumFormatter_Nested/MessagePack..Outer_MyEnum.g.cs create mode 100644 tests/MessagePack.Generator.Tests/Resources/EnumFormatter_Nested/MessagePack..Outer_MyMessagePackObject.g.cs create mode 100644 tests/MessagePack.Generator.Tests/Resources/EnumFormatter_Nested/MessagePack.GeneratedResolver.g.cs create mode 100644 tests/MessagePack.Generator.Tests/Resources/EnumFormatter_NoNamespace/MessagePack..MyEnum.g.cs create mode 100644 tests/MessagePack.Generator.Tests/Resources/EnumFormatter_NoNamespace/MessagePack..MyMessagePackObject.g.cs create mode 100644 tests/MessagePack.Generator.Tests/Resources/EnumFormatter_NoNamespace/MessagePack.GeneratedResolver.g.cs create mode 100644 tests/SourceGeneratorConsumer.props diff --git a/MessagePack.sln b/MessagePack.sln index 9c06b75f9..6efaad4ac 100644 --- a/MessagePack.sln +++ b/MessagePack.sln @@ -91,6 +91,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MessagePack.GeneratedCode.T EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MessagePack.Generator.Roslyn3", "src\MessagePack.Generator.Roslyn3\MessagePack.Generator.Roslyn3.csproj", "{45A72780-93EF-4CD1-9FCD-D56A42A3B966}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MessagePack.Generator.ExecutionTests", "tests\MessagePack.Generator.ExecutionTests\MessagePack.Generator.ExecutionTests.csproj", "{7908D954-15D4-4D67-B49A-4484809DA2C4}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -201,6 +203,10 @@ Global {45A72780-93EF-4CD1-9FCD-D56A42A3B966}.Debug|Any CPU.Build.0 = Debug|Any CPU {45A72780-93EF-4CD1-9FCD-D56A42A3B966}.Release|Any CPU.ActiveCfg = Release|Any CPU {45A72780-93EF-4CD1-9FCD-D56A42A3B966}.Release|Any CPU.Build.0 = Release|Any CPU + {7908D954-15D4-4D67-B49A-4484809DA2C4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {7908D954-15D4-4D67-B49A-4484809DA2C4}.Debug|Any CPU.Build.0 = Debug|Any CPU + {7908D954-15D4-4D67-B49A-4484809DA2C4}.Release|Any CPU.ActiveCfg = Release|Any CPU + {7908D954-15D4-4D67-B49A-4484809DA2C4}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -232,6 +238,7 @@ Global {8AB40D1C-1134-4D77-B39A-19AEDC729450} = {19FE674A-AC94-4E7E-B24C-2285D1D04CDE} {D4CE7347-CEBE-46E5-BD12-1319573B6C5E} = {19FE674A-AC94-4E7E-B24C-2285D1D04CDE} {45A72780-93EF-4CD1-9FCD-D56A42A3B966} = {86309CF6-0054-4CE3-BFD3-CA0AA7DB17BC} + {7908D954-15D4-4D67-B49A-4484809DA2C4} = {19FE674A-AC94-4E7E-B24C-2285D1D04CDE} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {B3911209-2DBF-47F8-98F6-BBC0EDFE63DE} diff --git a/src/MessagePack.Generator/CodeAnalysis/CodeAnalysisUtilities.cs b/src/MessagePack.Generator/CodeAnalysis/CodeAnalysisUtilities.cs index 83d170a9b..9d33cb14e 100644 --- a/src/MessagePack.Generator/CodeAnalysis/CodeAnalysisUtilities.cs +++ b/src/MessagePack.Generator/CodeAnalysis/CodeAnalysisUtilities.cs @@ -9,4 +9,9 @@ internal static string NamespaceAndType(string typeName, string? @namespace) { return string.IsNullOrEmpty(@namespace) ? typeName : $"{@namespace}.{typeName}"; } + + internal static string QualifyNames(string left, string? right) + { + return string.IsNullOrEmpty(right) ? left : $"{left}.{right}"; + } } diff --git a/src/MessagePack.Generator/CodeAnalysis/TypeCollector.cs b/src/MessagePack.Generator/CodeAnalysis/TypeCollector.cs index 4e9076202..e88c44a7f 100644 --- a/src/MessagePack.Generator/CodeAnalysis/TypeCollector.cs +++ b/src/MessagePack.Generator/CodeAnalysis/TypeCollector.cs @@ -67,9 +67,9 @@ public ReferenceSymbols(Compilation compilation, Action logger) public class TypeCollector { private static readonly SymbolDisplayFormat BinaryWriteFormat = new SymbolDisplayFormat( - genericsOptions: SymbolDisplayGenericsOptions.IncludeTypeParameters, - miscellaneousOptions: SymbolDisplayMiscellaneousOptions.ExpandNullable, - typeQualificationStyle: SymbolDisplayTypeQualificationStyle.NameOnly); + genericsOptions: SymbolDisplayGenericsOptions.IncludeTypeParameters, + miscellaneousOptions: SymbolDisplayMiscellaneousOptions.ExpandNullable, + typeQualificationStyle: SymbolDisplayTypeQualificationStyle.NameOnly); private static readonly SymbolDisplayFormat ShortTypeNameFormat = new SymbolDisplayFormat( typeQualificationStyle: SymbolDisplayTypeQualificationStyle.NameAndContainingTypes); @@ -388,7 +388,11 @@ private void CollectCore(ITypeSymbol typeSymbol) private void CollectEnum(INamedTypeSymbol type, ISymbol enumUnderlyingType) { - var info = new EnumSerializationInfo(type.ContainingNamespace.IsGlobalNamespace ? null : type.ContainingNamespace.ToDisplayString(), type.ToDisplayString(ShortTypeNameFormat).Replace(".", "_"), type.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat), enumUnderlyingType.ToDisplayString(BinaryWriteFormat)); + EnumSerializationInfo info = new( + type.ContainingNamespace.IsGlobalNamespace ? null : type.ContainingNamespace.ToDisplayString(), + type.ToDisplayString(ShortTypeNameFormat).Replace(".", "_"), + type.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat), + enumUnderlyingType.ToDisplayString(BinaryWriteFormat)); this.collectedEnumInfo.Add(info); } diff --git a/src/MessagePack.Generator/MessagePackGenerator.Emit.cs b/src/MessagePack.Generator/MessagePackGenerator.Emit.cs index 62f282b00..e34f983ca 100644 --- a/src/MessagePack.Generator/MessagePackGenerator.Emit.cs +++ b/src/MessagePack.Generator/MessagePackGenerator.Emit.cs @@ -42,7 +42,7 @@ private static void Generate(IGeneratorContext context, FullModel model) foreach (EnumSerializationInfo info in model.EnumInfos) { - EnumTemplate transform = new($"{options.FormatterNamespace}.{info.Namespace}", info); + EnumTemplate transform = new(CodeAnalysisUtilities.QualifyNames(options.FormatterNamespace, info.Namespace), info); AddTransform(transform.TransformText(), $"{info.Namespace}.{info.Name}"); } @@ -54,7 +54,7 @@ private static void Generate(IGeneratorContext context, FullModel model) foreach (ObjectSerializationInfo info in model.ObjectInfos) { - string formatterNamespace = $"{options.FormatterNamespace}.{info.Namespace}"; + string formatterNamespace = CodeAnalysisUtilities.QualifyNames(options.FormatterNamespace, info.Namespace); IFormatterTemplate transform = info.IsStringKey ? new StringKeyFormatterTemplate(formatterNamespace, info) : new FormatterTemplate(formatterNamespace, info); diff --git a/tests/MessagePack.Generator.ExecutionTests/ExecutionTests.cs b/tests/MessagePack.Generator.ExecutionTests/ExecutionTests.cs new file mode 100644 index 000000000..dee56d765 --- /dev/null +++ b/tests/MessagePack.Generator.ExecutionTests/ExecutionTests.cs @@ -0,0 +1,31 @@ +// Copyright (c) All contributors. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +public class ExecutionTests +{ + private static readonly MessagePackSerializerOptions SerializerOptions = MessagePackSerializerOptions.Standard + .WithResolver(GeneratedResolver.Instance); + + [Fact] + public void ClassWithEnumProperty() + { + MyMessagePackObject before = new() { EnumValue = MyEnum.B }; + byte[] serialized = MessagePackSerializer.Serialize(before, SerializerOptions); + MyMessagePackObject after = MessagePackSerializer.Deserialize(serialized, SerializerOptions); + Assert.Equal(before, after); + } + + [MessagePackObject] + public class MyMessagePackObject + { + [Key(0)] + public MyEnum EnumValue { get; set; } + } + + public enum MyEnum + { + A, + B, + C, + } +} diff --git a/tests/MessagePack.Generator.ExecutionTests/MessagePack.Generator.ExecutionTests.csproj b/tests/MessagePack.Generator.ExecutionTests/MessagePack.Generator.ExecutionTests.csproj new file mode 100644 index 000000000..e2f8045dc --- /dev/null +++ b/tests/MessagePack.Generator.ExecutionTests/MessagePack.Generator.ExecutionTests.csproj @@ -0,0 +1,16 @@ + + + + + net7.0 + enable + enable + + + + + + + + + diff --git a/tests/MessagePack.Generator.ExecutionTests/Usings.cs b/tests/MessagePack.Generator.ExecutionTests/Usings.cs new file mode 100644 index 000000000..526d97666 --- /dev/null +++ b/tests/MessagePack.Generator.ExecutionTests/Usings.cs @@ -0,0 +1,6 @@ +// Copyright (c) All contributors. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +global using MessagePack; +global using MessagePack.Resolvers; +global using Xunit; diff --git a/tests/MessagePack.Generator.Tests/GenerateEnumFormatterTest.cs b/tests/MessagePack.Generator.Tests/GenerateEnumFormatterTest.cs index 95900217e..b6b091777 100644 --- a/tests/MessagePack.Generator.Tests/GenerateEnumFormatterTest.cs +++ b/tests/MessagePack.Generator.Tests/GenerateEnumFormatterTest.cs @@ -11,7 +11,7 @@ public GenerateEnumFormatterTest(ITestOutputHelper testOutputHelper) } [Fact] - public async Task EnumFormatter() + public async Task EnumFormatter_InNamespace() { string testSource = """ using System; @@ -27,6 +27,55 @@ public class MyMessagePackObject public MyEnum EnumValue { get; set; } } +public enum MyEnum +{ + A, B, C +} +"""; + await VerifyCS.Test.RunDefaultAsync(testSource); + } + + [Fact] + public async Task EnumFormatter_Nested() + { + string testSource = """ +using System; +using System.Collections.Generic; +using MessagePack; + +public class Outer +{ + [MessagePackObject] + public class MyMessagePackObject + { + [Key(0)] + public MyEnum EnumValue { get; set; } + } + + public enum MyEnum + { + A, B, C + } +} +"""; + await VerifyCS.Test.RunDefaultAsync(testSource); + } + + [Fact] + public async Task EnumFormatter_NoNamespace() + { + string testSource = """ +using System; +using System.Collections.Generic; +using MessagePack; + +[MessagePackObject] +public class MyMessagePackObject +{ + [Key(0)] + public MyEnum EnumValue { get; set; } +} + public enum MyEnum { A, B, C diff --git a/tests/MessagePack.Generator.Tests/MessagePack.Generator.Tests.csproj b/tests/MessagePack.Generator.Tests/MessagePack.Generator.Tests.csproj index 7f9cd9ffc..debac28f3 100644 --- a/tests/MessagePack.Generator.Tests/MessagePack.Generator.Tests.csproj +++ b/tests/MessagePack.Generator.Tests/MessagePack.Generator.Tests.csproj @@ -2,7 +2,7 @@ net7.0 - true + enable enable 11 @@ -30,7 +30,6 @@ - diff --git a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter/MessagePack.GeneratedResolver.g.cs b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter_InNamespace/MessagePack.GeneratedResolver.g.cs similarity index 100% rename from tests/MessagePack.Generator.Tests/Resources/EnumFormatter/MessagePack.GeneratedResolver.g.cs rename to tests/MessagePack.Generator.Tests/Resources/EnumFormatter_InNamespace/MessagePack.GeneratedResolver.g.cs diff --git a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter/MessagePack.MyTestNamespace.MyEnum.g.cs b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter_InNamespace/MessagePack.MyTestNamespace.MyEnum.g.cs similarity index 100% rename from tests/MessagePack.Generator.Tests/Resources/EnumFormatter/MessagePack.MyTestNamespace.MyEnum.g.cs rename to tests/MessagePack.Generator.Tests/Resources/EnumFormatter_InNamespace/MessagePack.MyTestNamespace.MyEnum.g.cs diff --git a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter/MessagePack.MyTestNamespace.MyMessagePackObject.g.cs b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter_InNamespace/MessagePack.MyTestNamespace.MyMessagePackObject.g.cs similarity index 100% rename from tests/MessagePack.Generator.Tests/Resources/EnumFormatter/MessagePack.MyTestNamespace.MyMessagePackObject.g.cs rename to tests/MessagePack.Generator.Tests/Resources/EnumFormatter_InNamespace/MessagePack.MyTestNamespace.MyMessagePackObject.g.cs diff --git a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter_Nested/MessagePack..Outer_MyEnum.g.cs b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter_Nested/MessagePack..Outer_MyEnum.g.cs new file mode 100644 index 000000000..83499cb8c --- /dev/null +++ b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter_Nested/MessagePack..Outer_MyEnum.g.cs @@ -0,0 +1,21 @@ +// + +#pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 + +namespace MessagePack.Formatters +{ + using MsgPack = global::MessagePack; + + public sealed class Outer_MyEnumFormatter : MsgPack::Formatters.IMessagePackFormatter + { + public void Serialize(ref MsgPack::MessagePackWriter writer, global::Outer.MyEnum value, MsgPack::MessagePackSerializerOptions options) + { + writer.Write((global::System.Int32)value); + } + + public global::Outer.MyEnum Deserialize(ref MsgPack::MessagePackReader reader, MsgPack::MessagePackSerializerOptions options) + { + return (global::Outer.MyEnum)reader.ReadInt32(); + } + } +} diff --git a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter_Nested/MessagePack..Outer_MyMessagePackObject.g.cs b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter_Nested/MessagePack..Outer_MyMessagePackObject.g.cs new file mode 100644 index 000000000..3e8551c91 --- /dev/null +++ b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter_Nested/MessagePack..Outer_MyMessagePackObject.g.cs @@ -0,0 +1,52 @@ +// + +#pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 + +namespace MessagePack.Formatters +{ + public sealed class Outer_MyMessagePackObjectFormatter : global::MessagePack.Formatters.IMessagePackFormatter + { + + public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::Outer.MyMessagePackObject value, global::MessagePack.MessagePackSerializerOptions options) + { + if (value == null) + { + writer.WriteNil(); + return; + } + + global::MessagePack.IFormatterResolver formatterResolver = options.Resolver; + writer.WriteArrayHeader(1); + global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Serialize(ref writer, value.EnumValue, options); + } + + public global::Outer.MyMessagePackObject Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) + { + if (reader.TryReadNil()) + { + return null; + } + + options.Security.DepthStep(ref reader); + global::MessagePack.IFormatterResolver formatterResolver = options.Resolver; + var length = reader.ReadArrayHeader(); + var ____result = new global::Outer.MyMessagePackObject(); + + for (int i = 0; i < length; i++) + { + switch (i) + { + case 0: + ____result.EnumValue = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Deserialize(ref reader, options); + break; + default: + reader.Skip(); + break; + } + } + + reader.Depth--; + return ____result; + } + } +} diff --git a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter_Nested/MessagePack.GeneratedResolver.g.cs b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter_Nested/MessagePack.GeneratedResolver.g.cs new file mode 100644 index 000000000..aacf30b65 --- /dev/null +++ b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter_Nested/MessagePack.GeneratedResolver.g.cs @@ -0,0 +1,64 @@ +// + +#pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 + +namespace MessagePack.Resolvers +{ + public class GeneratedResolver : global::MessagePack.IFormatterResolver + { + public static readonly global::MessagePack.IFormatterResolver Instance = new GeneratedResolver(); + + private GeneratedResolver() + { + } + + public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() + { + return FormatterCache.Formatter; + } + + private static class FormatterCache + { + internal static readonly global::MessagePack.Formatters.IMessagePackFormatter Formatter; + + static FormatterCache() + { + var f = GeneratedResolverGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + Formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; + } + } + } + } + + internal static class GeneratedResolverGetFormatterHelper + { + private static readonly global::System.Collections.Generic.Dictionary lookup; + + static GeneratedResolverGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(2) + { + { typeof(global::Outer.MyEnum), 0 }, + { typeof(global::Outer.MyMessagePackObject), 1 }, + }; + } + + internal static object GetFormatter(global::System.Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + case 0: return new MessagePack.Formatters.Outer_MyEnumFormatter(); + case 1: return new MessagePack.Formatters.Outer_MyMessagePackObjectFormatter(); + default: return null; + } + } + } +} diff --git a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter_NoNamespace/MessagePack..MyEnum.g.cs b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter_NoNamespace/MessagePack..MyEnum.g.cs new file mode 100644 index 000000000..3492f6232 --- /dev/null +++ b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter_NoNamespace/MessagePack..MyEnum.g.cs @@ -0,0 +1,21 @@ +// + +#pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 + +namespace MessagePack.Formatters +{ + using MsgPack = global::MessagePack; + + public sealed class MyEnumFormatter : MsgPack::Formatters.IMessagePackFormatter + { + public void Serialize(ref MsgPack::MessagePackWriter writer, global::MyEnum value, MsgPack::MessagePackSerializerOptions options) + { + writer.Write((global::System.Int32)value); + } + + public global::MyEnum Deserialize(ref MsgPack::MessagePackReader reader, MsgPack::MessagePackSerializerOptions options) + { + return (global::MyEnum)reader.ReadInt32(); + } + } +} diff --git a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter_NoNamespace/MessagePack..MyMessagePackObject.g.cs b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter_NoNamespace/MessagePack..MyMessagePackObject.g.cs new file mode 100644 index 000000000..3f5cf5e30 --- /dev/null +++ b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter_NoNamespace/MessagePack..MyMessagePackObject.g.cs @@ -0,0 +1,52 @@ +// + +#pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 + +namespace MessagePack.Formatters +{ + public sealed class MyMessagePackObjectFormatter : global::MessagePack.Formatters.IMessagePackFormatter + { + + public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::MyMessagePackObject value, global::MessagePack.MessagePackSerializerOptions options) + { + if (value == null) + { + writer.WriteNil(); + return; + } + + global::MessagePack.IFormatterResolver formatterResolver = options.Resolver; + writer.WriteArrayHeader(1); + global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Serialize(ref writer, value.EnumValue, options); + } + + public global::MyMessagePackObject Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) + { + if (reader.TryReadNil()) + { + return null; + } + + options.Security.DepthStep(ref reader); + global::MessagePack.IFormatterResolver formatterResolver = options.Resolver; + var length = reader.ReadArrayHeader(); + var ____result = new global::MyMessagePackObject(); + + for (int i = 0; i < length; i++) + { + switch (i) + { + case 0: + ____result.EnumValue = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Deserialize(ref reader, options); + break; + default: + reader.Skip(); + break; + } + } + + reader.Depth--; + return ____result; + } + } +} diff --git a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter_NoNamespace/MessagePack.GeneratedResolver.g.cs b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter_NoNamespace/MessagePack.GeneratedResolver.g.cs new file mode 100644 index 000000000..cc0839c4f --- /dev/null +++ b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter_NoNamespace/MessagePack.GeneratedResolver.g.cs @@ -0,0 +1,64 @@ +// + +#pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 + +namespace MessagePack.Resolvers +{ + public class GeneratedResolver : global::MessagePack.IFormatterResolver + { + public static readonly global::MessagePack.IFormatterResolver Instance = new GeneratedResolver(); + + private GeneratedResolver() + { + } + + public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() + { + return FormatterCache.Formatter; + } + + private static class FormatterCache + { + internal static readonly global::MessagePack.Formatters.IMessagePackFormatter Formatter; + + static FormatterCache() + { + var f = GeneratedResolverGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + Formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; + } + } + } + } + + internal static class GeneratedResolverGetFormatterHelper + { + private static readonly global::System.Collections.Generic.Dictionary lookup; + + static GeneratedResolverGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(2) + { + { typeof(global::MyEnum), 0 }, + { typeof(global::MyMessagePackObject), 1 }, + }; + } + + internal static object GetFormatter(global::System.Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + case 0: return new MessagePack.Formatters.MyEnumFormatter(); + case 1: return new MessagePack.Formatters.MyMessagePackObjectFormatter(); + default: return null; + } + } + } +} diff --git a/tests/SourceGeneratorConsumer.props b/tests/SourceGeneratorConsumer.props new file mode 100644 index 000000000..b9fccf195 --- /dev/null +++ b/tests/SourceGeneratorConsumer.props @@ -0,0 +1,9 @@ + + + + + + + + + From 62518240051137d3dc1793b679a8a59257f1f1d6 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Thu, 23 Mar 2023 12:50:43 -0600 Subject: [PATCH 036/660] Fix execution test to use by-value equality --- tests/MessagePack.Generator.ExecutionTests/ExecutionTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/MessagePack.Generator.ExecutionTests/ExecutionTests.cs b/tests/MessagePack.Generator.ExecutionTests/ExecutionTests.cs index dee56d765..9c93adfb7 100644 --- a/tests/MessagePack.Generator.ExecutionTests/ExecutionTests.cs +++ b/tests/MessagePack.Generator.ExecutionTests/ExecutionTests.cs @@ -16,7 +16,7 @@ public void ClassWithEnumProperty() } [MessagePackObject] - public class MyMessagePackObject + public record MyMessagePackObject { [Key(0)] public MyEnum EnumValue { get; set; } From 055bbaeb716a53c683308a95b3a2ff67298cfd1b Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Thu, 23 Mar 2023 13:08:35 -0600 Subject: [PATCH 037/660] Log serialized form in execution tests --- .../ExecutionTests.cs | 21 +++++++++++++++---- .../Usings.cs | 1 + 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/tests/MessagePack.Generator.ExecutionTests/ExecutionTests.cs b/tests/MessagePack.Generator.ExecutionTests/ExecutionTests.cs index 9c93adfb7..312c14883 100644 --- a/tests/MessagePack.Generator.ExecutionTests/ExecutionTests.cs +++ b/tests/MessagePack.Generator.ExecutionTests/ExecutionTests.cs @@ -6,13 +6,26 @@ public class ExecutionTests private static readonly MessagePackSerializerOptions SerializerOptions = MessagePackSerializerOptions.Standard .WithResolver(GeneratedResolver.Instance); + private readonly ITestOutputHelper logger; + + public ExecutionTests(ITestOutputHelper logger) + { + this.logger = logger; + } + [Fact] public void ClassWithEnumProperty() { - MyMessagePackObject before = new() { EnumValue = MyEnum.B }; - byte[] serialized = MessagePackSerializer.Serialize(before, SerializerOptions); - MyMessagePackObject after = MessagePackSerializer.Deserialize(serialized, SerializerOptions); - Assert.Equal(before, after); + this.AssertRoundtrip(new MyMessagePackObject { EnumValue = MyEnum.B }); + } + + private T AssertRoundtrip(T value) + { + byte[] serialized = MessagePackSerializer.Serialize(value, SerializerOptions); + this.logger.WriteLine(MessagePackSerializer.ConvertToJson(serialized, SerializerOptions)); + T after = MessagePackSerializer.Deserialize(serialized, SerializerOptions); + Assert.Equal(value, after); + return after; } [MessagePackObject] diff --git a/tests/MessagePack.Generator.ExecutionTests/Usings.cs b/tests/MessagePack.Generator.ExecutionTests/Usings.cs index 526d97666..6ccd9011b 100644 --- a/tests/MessagePack.Generator.ExecutionTests/Usings.cs +++ b/tests/MessagePack.Generator.ExecutionTests/Usings.cs @@ -4,3 +4,4 @@ global using MessagePack; global using MessagePack.Resolvers; global using Xunit; +global using Xunit.Abstractions; From 92064ee1122316e24a7ef3a94fd0e9a0b498e90a Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Thu, 23 Mar 2023 15:50:38 -0600 Subject: [PATCH 038/660] Translate old style testing to new style --- .../ExecutionTests.cs | 38 ++++ .../GenerateEnumFormatterTest.cs | 6 - .../GenerateKeyedFormatterTest.cs | 164 ------------------ .../MessagePack.Generator.Tests.csproj | 1 - 4 files changed, 38 insertions(+), 171 deletions(-) delete mode 100644 tests/MessagePack.Generator.Tests/GenerateKeyedFormatterTest.cs diff --git a/tests/MessagePack.Generator.ExecutionTests/ExecutionTests.cs b/tests/MessagePack.Generator.ExecutionTests/ExecutionTests.cs index 312c14883..62ca8c9cf 100644 --- a/tests/MessagePack.Generator.ExecutionTests/ExecutionTests.cs +++ b/tests/MessagePack.Generator.ExecutionTests/ExecutionTests.cs @@ -19,6 +19,18 @@ public void ClassWithEnumProperty() this.AssertRoundtrip(new MyMessagePackObject { EnumValue = MyEnum.B }); } + [Fact] + public void ClassWithPropertiesWithGetterAndSetter() + { + this.AssertRoundtrip(new HasPropertiesWithGetterAndSetter { A = 1, B = "hi" }); + } + + [Fact] + public void ClassWithPropertiesWithGetterAndCtor() + { + this.AssertRoundtrip(new HasPropertiesWithGetterAndCtor(1, "hi")); + } + private T AssertRoundtrip(T value) { byte[] serialized = MessagePackSerializer.Serialize(value, SerializerOptions); @@ -35,6 +47,32 @@ public record MyMessagePackObject public MyEnum EnumValue { get; set; } } + [MessagePackObject(false)] + public record HasPropertiesWithGetterAndSetter + { + [Key(0)] + public int A { get; set; } + + [Key(1)] + public string? B { get; set; } + } + + [MessagePackObject(false)] + public record HasPropertiesWithGetterAndCtor + { + [Key(0)] + public int A { get; } + + [Key(1)] + public string B { get; } + + public HasPropertiesWithGetterAndCtor(int a, string b) + { + A = a; + B = b; + } + } + public enum MyEnum { A, diff --git a/tests/MessagePack.Generator.Tests/GenerateEnumFormatterTest.cs b/tests/MessagePack.Generator.Tests/GenerateEnumFormatterTest.cs index b6b091777..9116e1f76 100644 --- a/tests/MessagePack.Generator.Tests/GenerateEnumFormatterTest.cs +++ b/tests/MessagePack.Generator.Tests/GenerateEnumFormatterTest.cs @@ -14,8 +14,6 @@ public GenerateEnumFormatterTest(ITestOutputHelper testOutputHelper) public async Task EnumFormatter_InNamespace() { string testSource = """ -using System; -using System.Collections.Generic; using MessagePack; namespace MyTestNamespace; @@ -39,8 +37,6 @@ public enum MyEnum public async Task EnumFormatter_Nested() { string testSource = """ -using System; -using System.Collections.Generic; using MessagePack; public class Outer @@ -65,8 +61,6 @@ public enum MyEnum public async Task EnumFormatter_NoNamespace() { string testSource = """ -using System; -using System.Collections.Generic; using MessagePack; [MessagePackObject] diff --git a/tests/MessagePack.Generator.Tests/GenerateKeyedFormatterTest.cs b/tests/MessagePack.Generator.Tests/GenerateKeyedFormatterTest.cs deleted file mode 100644 index 502093263..000000000 --- a/tests/MessagePack.Generator.Tests/GenerateKeyedFormatterTest.cs +++ /dev/null @@ -1,164 +0,0 @@ -// Copyright (c) All contributors. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - -using System; -using System.Buffers; -using System.Threading; -using System.Threading.Tasks; -using FluentAssertions; -using MessagePack.Resolvers; -using Microsoft.CodeAnalysis; -using Nerdbank.Streams; -using Xunit; -using Xunit.Abstractions; - -namespace MessagePack.Generator.Tests -{ - public class GenerateKeyedFormatterTest - { - private readonly ITestOutputHelper testOutputHelper; - - public GenerateKeyedFormatterTest(ITestOutputHelper testOutputHelper) - { - this.testOutputHelper = testOutputHelper; - } - - [Fact] - public async Task PropertiesGetterSetter() - { - using var tempWorkarea = TemporaryProjectWorkarea.Create(); - var contents = @" -using System; -using System.Collections.Generic; -using MessagePack; - -namespace TempProject -{ - [MessagePackObject(false)] - public class MyMessagePackObject - { - [Key(0)] - public int A { get; set; } - [Key(1)] - public string B { get; set; } - } -} - "; - tempWorkarea.AddFileToTargetProject("MyMessagePackObject.cs", contents); - - var compiler = new MessagePackCompiler.CodeGenerator(testOutputHelper.WriteLine, CancellationToken.None); - await compiler.GenerateFileAsync( - tempWorkarea.GetOutputCompilation().Compilation, - tempWorkarea.OutputDirectory, - "TempProjectResolver", - "TempProject.Generated", - false, - string.Empty, - Array.Empty()); - - var compilation = tempWorkarea.GetOutputCompilation(); - compilation.Compilation.GetDiagnostics().Should().NotContain(x => x.Severity == DiagnosticSeverity.Error); - - // Run tests with the generated resolver/formatter assembly. - compilation.ExecuteWithGeneratedAssembly((ctx, assembly) => - { - var mpoType = assembly.GetType("TempProject.MyMessagePackObject"); - var options = MessagePackSerializerOptions.Standard - .WithResolver(CompositeResolver.Create( - StandardResolver.Instance, - TestUtilities.GetResolverInstance(assembly, "TempProject.Generated.Resolvers.TempProjectResolver"))); - - // Build `[]` - var seq = new Sequence(); - var writer = new MessagePackWriter(seq); - writer.WriteArrayHeader(0); - writer.Flush(); - - dynamic result = MessagePackSerializer.Deserialize(mpoType, seq, options); - - // The deserialized object has default values. - ((int)result.A).Should().Be(0); - ((string)result.B).Should().BeNull(); - - // Verify round trip serialization/deserialization. - result.A = 123; - result.B = "foobar"; - - var serialized = MessagePackSerializer.Serialize(mpoType, (object)result, options); - dynamic result2 = MessagePackSerializer.Deserialize(mpoType, serialized, options); - ((int)result2.A).Should().Be(123); - ((string)result2.B).Should().Be("foobar"); - }); - } - - [Fact] - public async Task PropertiesGetterOnlyWithParameterizedConstructor() - { - using var tempWorkarea = TemporaryProjectWorkarea.Create(); - var contents = @" -using System; -using System.Collections.Generic; -using MessagePack; - -namespace TempProject -{ - [MessagePackObject(false)] - public class MyMessagePackObject - { - [Key(0)] - public int A { get; } - [Key(1)] - public string B { get; } - - public MyMessagePackObject(int a, string b) - { - A = a; - B = b; - } - } -} - "; - tempWorkarea.AddFileToTargetProject("MyMessagePackObject.cs", contents); - - var compiler = new MessagePackCompiler.CodeGenerator(testOutputHelper.WriteLine, CancellationToken.None); - await compiler.GenerateFileAsync( - tempWorkarea.GetOutputCompilation().Compilation, - tempWorkarea.OutputDirectory, - "TempProjectResolver", - "TempProject.Generated", - false, - string.Empty, - Array.Empty()); - - var compilation = tempWorkarea.GetOutputCompilation(); - compilation.Compilation.GetDiagnostics().Should().NotContain(x => x.Severity == DiagnosticSeverity.Error); - - // Run tests with the generated resolver/formatter assembly. - compilation.ExecuteWithGeneratedAssembly((ctx, assembly) => - { - var mpoType = assembly.GetType("TempProject.MyMessagePackObject"); - var options = MessagePackSerializerOptions.Standard - .WithResolver(CompositeResolver.Create( - StandardResolver.Instance, - TestUtilities.GetResolverInstance(assembly, "TempProject.Generated.Resolvers.TempProjectResolver"))); - - // Build `[-1, "foobar"]` - var seq = new Sequence(); - var writer = new MessagePackWriter(seq); - writer.WriteArrayHeader(2); - writer.Write(-1); - writer.Write("foobar"); - writer.Flush(); - - // Verify deserialization - dynamic result = MessagePackSerializer.Deserialize(mpoType, seq, options); - ((int)result.A).Should().Be(-1); - ((string)result.B).Should().Be("foobar"); - - // Verify serialization - var serialized = MessagePackSerializer.Serialize(mpoType, (object)result, options); - serialized.Should().BeEquivalentTo(seq.AsReadOnlySequence.ToArray()); - }); - } - } -} diff --git a/tests/MessagePack.Generator.Tests/MessagePack.Generator.Tests.csproj b/tests/MessagePack.Generator.Tests/MessagePack.Generator.Tests.csproj index debac28f3..bff877e25 100644 --- a/tests/MessagePack.Generator.Tests/MessagePack.Generator.Tests.csproj +++ b/tests/MessagePack.Generator.Tests/MessagePack.Generator.Tests.csproj @@ -9,7 +9,6 @@ - From 3ea170fa5784fd91e3aa885f90b382612e55d54d Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Thu, 23 Mar 2023 16:13:54 -0600 Subject: [PATCH 039/660] Simplify tests --- Directory.Packages.props | 1 + .../ContainerKind.cs | 20 +++++++ .../GenerateEnumFormatterTest.cs | 57 ++----------------- .../MessagePack.Generator.Tests.csproj | 1 + .../MessagePack.GeneratedResolver.g.cs | 0 .../MessagePack.MyTestNamespace.MyEnum.g.cs | 0 ...k.MyTestNamespace.MyMessagePackObject.g.cs | 0 .../MessagePack..ContainingClass_MyEnum.g.cs | 21 +++++++ ....ContainingClass_MyMessagePackObject.g.cs} | 12 ++-- .../MessagePack.GeneratedResolver.g.cs | 8 +-- .../MessagePack..MyEnum.g.cs | 0 .../MessagePack..MyMessagePackObject.g.cs | 0 .../MessagePack.GeneratedResolver.g.cs | 0 .../MessagePack..Outer_MyEnum.g.cs | 21 ------- .../TestUtilities.cs | 26 +++++++++ 15 files changed, 85 insertions(+), 82 deletions(-) create mode 100644 tests/MessagePack.Generator.Tests/ContainerKind.cs rename tests/MessagePack.Generator.Tests/Resources/{EnumFormatter_InNamespace => EnumFormatter(Namespace)}/MessagePack.GeneratedResolver.g.cs (100%) rename tests/MessagePack.Generator.Tests/Resources/{EnumFormatter_InNamespace => EnumFormatter(Namespace)}/MessagePack.MyTestNamespace.MyEnum.g.cs (100%) rename tests/MessagePack.Generator.Tests/Resources/{EnumFormatter_InNamespace => EnumFormatter(Namespace)}/MessagePack.MyTestNamespace.MyMessagePackObject.g.cs (100%) create mode 100644 tests/MessagePack.Generator.Tests/Resources/EnumFormatter(NestingClass)/MessagePack..ContainingClass_MyEnum.g.cs rename tests/MessagePack.Generator.Tests/Resources/{EnumFormatter_Nested/MessagePack..Outer_MyMessagePackObject.g.cs => EnumFormatter(NestingClass)/MessagePack..ContainingClass_MyMessagePackObject.g.cs} (63%) rename tests/MessagePack.Generator.Tests/Resources/{EnumFormatter_Nested => EnumFormatter(NestingClass)}/MessagePack.GeneratedResolver.g.cs (83%) rename tests/MessagePack.Generator.Tests/Resources/{EnumFormatter_NoNamespace => EnumFormatter(None)}/MessagePack..MyEnum.g.cs (100%) rename tests/MessagePack.Generator.Tests/Resources/{EnumFormatter_NoNamespace => EnumFormatter(None)}/MessagePack..MyMessagePackObject.g.cs (100%) rename tests/MessagePack.Generator.Tests/Resources/{EnumFormatter_NoNamespace => EnumFormatter(None)}/MessagePack.GeneratedResolver.g.cs (100%) delete mode 100644 tests/MessagePack.Generator.Tests/Resources/EnumFormatter_Nested/MessagePack..Outer_MyEnum.g.cs diff --git a/Directory.Packages.props b/Directory.Packages.props index a272bdda2..b1f122460 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -60,6 +60,7 @@ + diff --git a/tests/MessagePack.Generator.Tests/ContainerKind.cs b/tests/MessagePack.Generator.Tests/ContainerKind.cs new file mode 100644 index 000000000..f0e4c72d9 --- /dev/null +++ b/tests/MessagePack.Generator.Tests/ContainerKind.cs @@ -0,0 +1,20 @@ +// Copyright (c) All contributors. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +public enum ContainerKind +{ + /// + /// The type to be serialized is declared in the global namespace. + /// + None, + + /// + /// The type to be serialized is declared in a non-global namespace. + /// + Namespace, + + /// + /// The type to be serialized is declared as nested within another class. + /// + NestingClass, +} diff --git a/tests/MessagePack.Generator.Tests/GenerateEnumFormatterTest.cs b/tests/MessagePack.Generator.Tests/GenerateEnumFormatterTest.cs index 9116e1f76..f3ef10520 100644 --- a/tests/MessagePack.Generator.Tests/GenerateEnumFormatterTest.cs +++ b/tests/MessagePack.Generator.Tests/GenerateEnumFormatterTest.cs @@ -1,6 +1,8 @@ // Copyright (c) All contributors. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. +using MessagePack.Generator.Tests; + public class GenerateEnumFormatterTest { private readonly ITestOutputHelper testOutputHelper; @@ -10,14 +12,10 @@ public GenerateEnumFormatterTest(ITestOutputHelper testOutputHelper) this.testOutputHelper = testOutputHelper; } - [Fact] - public async Task EnumFormatter_InNamespace() + [Theory, CombinatorialData] + public async Task EnumFormatter(ContainerKind container) { string testSource = """ -using MessagePack; - -namespace MyTestNamespace; - [MessagePackObject] public class MyMessagePackObject { @@ -30,51 +28,8 @@ public enum MyEnum A, B, C } """; - await VerifyCS.Test.RunDefaultAsync(testSource); - } - - [Fact] - public async Task EnumFormatter_Nested() - { - string testSource = """ -using MessagePack; - -public class Outer -{ - [MessagePackObject] - public class MyMessagePackObject - { - [Key(0)] - public MyEnum EnumValue { get; set; } - } - - public enum MyEnum - { - A, B, C - } -} -"""; - await VerifyCS.Test.RunDefaultAsync(testSource); - } - - [Fact] - public async Task EnumFormatter_NoNamespace() - { - string testSource = """ -using MessagePack; - -[MessagePackObject] -public class MyMessagePackObject -{ - [Key(0)] - public MyEnum EnumValue { get; set; } -} + testSource = TestUtilities.WrapTestSource(testSource, container); -public enum MyEnum -{ - A, B, C -} -"""; - await VerifyCS.Test.RunDefaultAsync(testSource); + await VerifyCS.Test.RunDefaultAsync(testSource, testMethod: $"{nameof(EnumFormatter)}({container})"); } } diff --git a/tests/MessagePack.Generator.Tests/MessagePack.Generator.Tests.csproj b/tests/MessagePack.Generator.Tests/MessagePack.Generator.Tests.csproj index bff877e25..4319132e9 100644 --- a/tests/MessagePack.Generator.Tests/MessagePack.Generator.Tests.csproj +++ b/tests/MessagePack.Generator.Tests/MessagePack.Generator.Tests.csproj @@ -25,6 +25,7 @@ + diff --git a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter_InNamespace/MessagePack.GeneratedResolver.g.cs b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(Namespace)/MessagePack.GeneratedResolver.g.cs similarity index 100% rename from tests/MessagePack.Generator.Tests/Resources/EnumFormatter_InNamespace/MessagePack.GeneratedResolver.g.cs rename to tests/MessagePack.Generator.Tests/Resources/EnumFormatter(Namespace)/MessagePack.GeneratedResolver.g.cs diff --git a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter_InNamespace/MessagePack.MyTestNamespace.MyEnum.g.cs b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(Namespace)/MessagePack.MyTestNamespace.MyEnum.g.cs similarity index 100% rename from tests/MessagePack.Generator.Tests/Resources/EnumFormatter_InNamespace/MessagePack.MyTestNamespace.MyEnum.g.cs rename to tests/MessagePack.Generator.Tests/Resources/EnumFormatter(Namespace)/MessagePack.MyTestNamespace.MyEnum.g.cs diff --git a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter_InNamespace/MessagePack.MyTestNamespace.MyMessagePackObject.g.cs b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(Namespace)/MessagePack.MyTestNamespace.MyMessagePackObject.g.cs similarity index 100% rename from tests/MessagePack.Generator.Tests/Resources/EnumFormatter_InNamespace/MessagePack.MyTestNamespace.MyMessagePackObject.g.cs rename to tests/MessagePack.Generator.Tests/Resources/EnumFormatter(Namespace)/MessagePack.MyTestNamespace.MyMessagePackObject.g.cs diff --git a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(NestingClass)/MessagePack..ContainingClass_MyEnum.g.cs b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(NestingClass)/MessagePack..ContainingClass_MyEnum.g.cs new file mode 100644 index 000000000..fa50c3ab7 --- /dev/null +++ b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(NestingClass)/MessagePack..ContainingClass_MyEnum.g.cs @@ -0,0 +1,21 @@ +// + +#pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 + +namespace MessagePack.Formatters +{ + using MsgPack = global::MessagePack; + + public sealed class ContainingClass_MyEnumFormatter : MsgPack::Formatters.IMessagePackFormatter + { + public void Serialize(ref MsgPack::MessagePackWriter writer, global::ContainingClass.MyEnum value, MsgPack::MessagePackSerializerOptions options) + { + writer.Write((global::System.Int32)value); + } + + public global::ContainingClass.MyEnum Deserialize(ref MsgPack::MessagePackReader reader, MsgPack::MessagePackSerializerOptions options) + { + return (global::ContainingClass.MyEnum)reader.ReadInt32(); + } + } +} diff --git a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter_Nested/MessagePack..Outer_MyMessagePackObject.g.cs b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(NestingClass)/MessagePack..ContainingClass_MyMessagePackObject.g.cs similarity index 63% rename from tests/MessagePack.Generator.Tests/Resources/EnumFormatter_Nested/MessagePack..Outer_MyMessagePackObject.g.cs rename to tests/MessagePack.Generator.Tests/Resources/EnumFormatter(NestingClass)/MessagePack..ContainingClass_MyMessagePackObject.g.cs index 3e8551c91..3d5c9d4c8 100644 --- a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter_Nested/MessagePack..Outer_MyMessagePackObject.g.cs +++ b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(NestingClass)/MessagePack..ContainingClass_MyMessagePackObject.g.cs @@ -4,10 +4,10 @@ namespace MessagePack.Formatters { - public sealed class Outer_MyMessagePackObjectFormatter : global::MessagePack.Formatters.IMessagePackFormatter + public sealed class ContainingClass_MyMessagePackObjectFormatter : global::MessagePack.Formatters.IMessagePackFormatter { - public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::Outer.MyMessagePackObject value, global::MessagePack.MessagePackSerializerOptions options) + public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::ContainingClass.MyMessagePackObject value, global::MessagePack.MessagePackSerializerOptions options) { if (value == null) { @@ -17,10 +17,10 @@ public void Serialize(ref global::MessagePack.MessagePackWriter writer, global:: global::MessagePack.IFormatterResolver formatterResolver = options.Resolver; writer.WriteArrayHeader(1); - global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Serialize(ref writer, value.EnumValue, options); + global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Serialize(ref writer, value.EnumValue, options); } - public global::Outer.MyMessagePackObject Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) + public global::ContainingClass.MyMessagePackObject Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) { if (reader.TryReadNil()) { @@ -30,14 +30,14 @@ public void Serialize(ref global::MessagePack.MessagePackWriter writer, global:: options.Security.DepthStep(ref reader); global::MessagePack.IFormatterResolver formatterResolver = options.Resolver; var length = reader.ReadArrayHeader(); - var ____result = new global::Outer.MyMessagePackObject(); + var ____result = new global::ContainingClass.MyMessagePackObject(); for (int i = 0; i < length; i++) { switch (i) { case 0: - ____result.EnumValue = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Deserialize(ref reader, options); + ____result.EnumValue = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Deserialize(ref reader, options); break; default: reader.Skip(); diff --git a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter_Nested/MessagePack.GeneratedResolver.g.cs b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(NestingClass)/MessagePack.GeneratedResolver.g.cs similarity index 83% rename from tests/MessagePack.Generator.Tests/Resources/EnumFormatter_Nested/MessagePack.GeneratedResolver.g.cs rename to tests/MessagePack.Generator.Tests/Resources/EnumFormatter(NestingClass)/MessagePack.GeneratedResolver.g.cs index aacf30b65..a88fcdb4d 100644 --- a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter_Nested/MessagePack.GeneratedResolver.g.cs +++ b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(NestingClass)/MessagePack.GeneratedResolver.g.cs @@ -40,8 +40,8 @@ static GeneratedResolverGetFormatterHelper() { lookup = new global::System.Collections.Generic.Dictionary(2) { - { typeof(global::Outer.MyEnum), 0 }, - { typeof(global::Outer.MyMessagePackObject), 1 }, + { typeof(global::ContainingClass.MyEnum), 0 }, + { typeof(global::ContainingClass.MyMessagePackObject), 1 }, }; } @@ -55,8 +55,8 @@ internal static object GetFormatter(global::System.Type t) switch (key) { - case 0: return new MessagePack.Formatters.Outer_MyEnumFormatter(); - case 1: return new MessagePack.Formatters.Outer_MyMessagePackObjectFormatter(); + case 0: return new MessagePack.Formatters.ContainingClass_MyEnumFormatter(); + case 1: return new MessagePack.Formatters.ContainingClass_MyMessagePackObjectFormatter(); default: return null; } } diff --git a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter_NoNamespace/MessagePack..MyEnum.g.cs b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(None)/MessagePack..MyEnum.g.cs similarity index 100% rename from tests/MessagePack.Generator.Tests/Resources/EnumFormatter_NoNamespace/MessagePack..MyEnum.g.cs rename to tests/MessagePack.Generator.Tests/Resources/EnumFormatter(None)/MessagePack..MyEnum.g.cs diff --git a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter_NoNamespace/MessagePack..MyMessagePackObject.g.cs b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(None)/MessagePack..MyMessagePackObject.g.cs similarity index 100% rename from tests/MessagePack.Generator.Tests/Resources/EnumFormatter_NoNamespace/MessagePack..MyMessagePackObject.g.cs rename to tests/MessagePack.Generator.Tests/Resources/EnumFormatter(None)/MessagePack..MyMessagePackObject.g.cs diff --git a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter_NoNamespace/MessagePack.GeneratedResolver.g.cs b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(None)/MessagePack.GeneratedResolver.g.cs similarity index 100% rename from tests/MessagePack.Generator.Tests/Resources/EnumFormatter_NoNamespace/MessagePack.GeneratedResolver.g.cs rename to tests/MessagePack.Generator.Tests/Resources/EnumFormatter(None)/MessagePack.GeneratedResolver.g.cs diff --git a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter_Nested/MessagePack..Outer_MyEnum.g.cs b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter_Nested/MessagePack..Outer_MyEnum.g.cs deleted file mode 100644 index 83499cb8c..000000000 --- a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter_Nested/MessagePack..Outer_MyEnum.g.cs +++ /dev/null @@ -1,21 +0,0 @@ -// - -#pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 - -namespace MessagePack.Formatters -{ - using MsgPack = global::MessagePack; - - public sealed class Outer_MyEnumFormatter : MsgPack::Formatters.IMessagePackFormatter - { - public void Serialize(ref MsgPack::MessagePackWriter writer, global::Outer.MyEnum value, MsgPack::MessagePackSerializerOptions options) - { - writer.Write((global::System.Int32)value); - } - - public global::Outer.MyEnum Deserialize(ref MsgPack::MessagePackReader reader, MsgPack::MessagePackSerializerOptions options) - { - return (global::Outer.MyEnum)reader.ReadInt32(); - } - } -} diff --git a/tests/MessagePack.Generator.Tests/TestUtilities.cs b/tests/MessagePack.Generator.Tests/TestUtilities.cs index 1b52703c1..d0afd4c8d 100644 --- a/tests/MessagePack.Generator.Tests/TestUtilities.cs +++ b/tests/MessagePack.Generator.Tests/TestUtilities.cs @@ -1,7 +1,9 @@ // Copyright (c) All contributors. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. +using System.ComponentModel; using System.Reflection; +using System.Text; using Microsoft; namespace MessagePack.Generator.Tests; @@ -24,4 +26,28 @@ internal static IFormatterResolver GetResolverInstance(Assembly assembly, string Assert.NotNull(instanceValue); return (IFormatterResolver)instanceValue; } + + internal static string WrapTestSource(string source, ContainerKind containerKind) + { + StringBuilder testSource = new(); + testSource.AppendLine("using MessagePack;"); + switch (containerKind) + { + case ContainerKind.Namespace: + testSource.AppendLine("namespace MyTestNamespace {"); + break; + case ContainerKind.NestingClass: + testSource.AppendLine("public class ContainingClass {"); + break; + } + + testSource.AppendLine(source); + + if (containerKind != ContainerKind.None) + { + testSource.AppendLine("}"); + } + + return testSource.ToString(); + } } From 82ab8e932e456d406ce287b4ab0f08f2e459ea62 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Thu, 23 Mar 2023 16:19:01 -0600 Subject: [PATCH 040/660] Add functional test for multiple types (it fails) --- .../MultipleTypesTests.cs | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 tests/MessagePack.Generator.Tests/MultipleTypesTests.cs diff --git a/tests/MessagePack.Generator.Tests/MultipleTypesTests.cs b/tests/MessagePack.Generator.Tests/MultipleTypesTests.cs new file mode 100644 index 000000000..b64e11d21 --- /dev/null +++ b/tests/MessagePack.Generator.Tests/MultipleTypesTests.cs @@ -0,0 +1,33 @@ +// Copyright (c) All contributors. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using MessagePack.Generator.Tests; + +public class MultipleTypesTests +{ + private readonly ITestOutputHelper testOutputHelper; + + public MultipleTypesTests(ITestOutputHelper testOutputHelper) + { + this.testOutputHelper = testOutputHelper; + } + + [Fact] + public async Task TwoTypes() + { + string testSource = """ +using MessagePack; + +[MessagePackObject] +public class Object1 +{ +} + +[MessagePackObject] +public class Object2 +{ +} +"""; + await VerifyCS.Test.RunDefaultAsync(testSource); + } +} From adaea96bb8554c05b2ee5d19562f6e0fc518d0ce Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Thu, 23 Mar 2023 18:45:37 -0600 Subject: [PATCH 041/660] Fix test replay to handle parentheses in test name --- .../Verifiers/CSharpSourceGeneratorVerifier`1+Test.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/MessagePack.Generator.Tests/Verifiers/CSharpSourceGeneratorVerifier`1+Test.cs b/tests/MessagePack.Generator.Tests/Verifiers/CSharpSourceGeneratorVerifier`1+Test.cs index 1543da0d8..fd2f6c4bf 100644 --- a/tests/MessagePack.Generator.Tests/Verifiers/CSharpSourceGeneratorVerifier`1+Test.cs +++ b/tests/MessagePack.Generator.Tests/Verifiers/CSharpSourceGeneratorVerifier`1+Test.cs @@ -78,7 +78,10 @@ public static async Task RunDefaultAsync(string testSource, [CallerFilePath] str public Test AddGeneratedSources([CallerMemberName] string? testMethod = null) { - var expectedPrefix = $"{ThisAssembly.AssemblyName}.Resources.{testMethod}."; + string expectedPrefix = $"{ThisAssembly.AssemblyName}.Resources.{testMethod}." + .Replace('(', '_') + .Replace(')', '_'); + foreach (var resourceName in typeof(Test).Assembly.GetManifestResourceNames()) { if (!resourceName.StartsWith(expectedPrefix)) From 99df8185b1a6aa6abb1cc98aa7f4c0245f8d9012 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Tue, 28 Mar 2023 15:53:46 -0600 Subject: [PATCH 042/660] Move `dotnet-coverage` to repo-level tool --- .config/dotnet-tools.json | 8 ++++- azure-pipelines/Merge-CodeCoverage.ps1 | 46 +++++++++++++------------- 2 files changed, 30 insertions(+), 24 deletions(-) diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json index 2599e26ad..610b59c97 100644 --- a/.config/dotnet-tools.json +++ b/.config/dotnet-tools.json @@ -13,6 +13,12 @@ "commands": [ "dotnet-format" ] + }, + "dotnet-coverage": { + "version": "17.6.11", + "commands": [ + "dotnet-coverage" + ] } } -} \ No newline at end of file +} diff --git a/azure-pipelines/Merge-CodeCoverage.ps1 b/azure-pipelines/Merge-CodeCoverage.ps1 index 02ff12b00..5ecabbc9b 100644 --- a/azure-pipelines/Merge-CodeCoverage.ps1 +++ b/azure-pipelines/Merge-CodeCoverage.ps1 @@ -20,32 +20,32 @@ Param( ) $RepoRoot = [string](Resolve-Path $PSScriptRoot/..) - -if (!(Test-Path $RepoRoot/obj/dotnet-coverage*)) { - dotnet tool install --tool-path $RepoRoot/obj dotnet-coverage --version 17.4.3 --configfile $PSScriptRoot/justnugetorg.nuget.config -} - -Write-Verbose "Searching $Path for *.cobertura.xml files" -$reports = Get-ChildItem -Recurse $Path -Filter *.cobertura.xml - -if ($reports) { - $reports |% { $_.FullName } |% { - # In addition to replacing {reporoot}, we also normalize on one kind of slash so that the report aggregates data for a file whether data was collected on Windows or not. - $xml = [xml](Get-Content -Path $_) - $xml.coverage.packages.package.classes.class |? { $_.filename} |% { - $_.filename = $_.filename.Replace('{reporoot}', $RepoRoot).Replace([IO.Path]::AltDirectorySeparatorChar, [IO.Path]::DirectorySeparatorChar) +Push-Location $RepoRoot +try { + Write-Verbose "Searching $Path for *.cobertura.xml files" + $reports = Get-ChildItem -Recurse $Path -Filter *.cobertura.xml + + if ($reports) { + $reports |% { $_.FullName } |% { + # In addition to replacing {reporoot}, we also normalize on one kind of slash so that the report aggregates data for a file whether data was collected on Windows or not. + $xml = [xml](Get-Content -Path $_) + $xml.coverage.packages.package.classes.class |? { $_.filename} |% { + $_.filename = $_.filename.Replace('{reporoot}', $RepoRoot).Replace([IO.Path]::AltDirectorySeparatorChar, [IO.Path]::DirectorySeparatorChar) + } + + $xml.Save($_) } - $xml.Save($_) - } + $Inputs = $reports |% { Resolve-Path -relative $_.FullName } - $Inputs = $reports |% { Resolve-Path -relative $_.FullName } + if ((Split-Path $OutputFile) -and -not (Test-Path (Split-Path $OutputFile))) { + New-Item -Type Directory -Path (Split-Path $OutputFile) | Out-Null + } - if ((Split-Path $OutputFile) -and -not (Test-Path (Split-Path $OutputFile))) { - New-Item -Type Directory -Path (Split-Path $OutputFile) | Out-Null + & dotnet tool run dotnet-coverage merge $Inputs -o $OutputFile -f cobertura + } else { + Write-Error "No reports found to merge." } - - & "$RepoRoot/obj/dotnet-coverage" merge $Inputs -o $OutputFile -f cobertura -} else { - Write-Error "No reports found to merge." +} finally { + Pop-Location } From 14699417fbde409397e7efec56c1b33268ed3634 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Tue, 28 Mar 2023 15:58:33 -0600 Subject: [PATCH 043/660] Move `nbgv` into dotnet-tools.json --- .config/dotnet-tools.json | 6 ++++++ azure-pipelines/Get-nbgv.ps1 | 24 ------------------------ azure-pipelines/build.yml | 2 +- 3 files changed, 7 insertions(+), 25 deletions(-) delete mode 100644 azure-pipelines/Get-nbgv.ps1 diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json index 610b59c97..5d3dae876 100644 --- a/.config/dotnet-tools.json +++ b/.config/dotnet-tools.json @@ -19,6 +19,12 @@ "commands": [ "dotnet-coverage" ] + }, + "nbgv": { + "version": "3.5.119", + "commands": [ + "nbgv" + ] } } } diff --git a/azure-pipelines/Get-nbgv.ps1 b/azure-pipelines/Get-nbgv.ps1 deleted file mode 100644 index a5be2cf7c..000000000 --- a/azure-pipelines/Get-nbgv.ps1 +++ /dev/null @@ -1,24 +0,0 @@ -<# -.SYNOPSIS - Gets the path to the nbgv CLI tool, installing it if necessary. -#> -Param( -) - -$existingTool = Get-Command "nbgv" -ErrorAction SilentlyContinue -if ($existingTool) { - return $existingTool.Path -} - -$toolInstallDir = & "$PSScriptRoot/Get-TempToolsPath.ps1" - -$toolPath = "$toolInstallDir/nbgv" -if (!(Test-Path $toolInstallDir)) { New-Item -Path $toolInstallDir -ItemType Directory | Out-Null } - -if (!(Get-Command $toolPath -ErrorAction SilentlyContinue)) { - Write-Host "Installing nbgv to $toolInstallDir" - dotnet tool install --tool-path "$toolInstallDir" nbgv --configfile "$PSScriptRoot/justnugetorg.nuget.config" | Out-Null -} - -# Normalize the path on the way out. -return (Get-Command $toolPath).Path diff --git a/azure-pipelines/build.yml b/azure-pipelines/build.yml index c8687859b..2e2f426e0 100644 --- a/azure-pipelines/build.yml +++ b/azure-pipelines/build.yml @@ -17,7 +17,7 @@ jobs: clean: true - template: install-dependencies.yml - - powershell: '& (./azure-pipelines/Get-nbgv.ps1) cloud -c' + - script: dotnet tool run nbgv cloud -c displayName: ⚙ Set build number - template: dotnet.yml From 3f1e85823fac9136c058aaf48f4b8febed1d0843 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Tue, 28 Mar 2023 16:34:38 -0600 Subject: [PATCH 044/660] Install tools except when `-NoToolRestore` is specified --- init.ps1 | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/init.ps1 b/init.ps1 index 5bace1e62..6211304f8 100755 --- a/init.ps1 +++ b/init.ps1 @@ -28,6 +28,8 @@ No effect if -NoPrerequisites is specified. .PARAMETER NoRestore Skips the package restore step. +.PARAMETER NoToolRestore + Skips the dotnet tool restore step. .PARAMETER AccessToken An optional access token for authenticating to Azure Artifacts authenticated feeds. .PARAMETER Interactive @@ -46,6 +48,8 @@ Param ( [Parameter()] [switch]$NoRestore, [Parameter()] + [switch]$NoToolRestore, + [Parameter()] [string]$AccessToken, [Parameter()] [switch]$Interactive @@ -91,11 +95,13 @@ try { if ($lastexitcode -ne 0) { throw "Failure while restoring packages." } + } - dotnet tool restore @RestoreArguments - if ($lastexitcode -ne 0) { - throw "Failure while restoring dotnet CLI tools." - } + if (!$NoToolRestore -and $PSCmdlet.ShouldProcess("dotnet tool", "restore")) { + dotnet tool restore @RestoreArguments + if ($lastexitcode -ne 0) { + throw "Failure while restoring dotnet CLI tools." + } } & "$PSScriptRoot/tools/Set-EnvVars.ps1" -Variables $EnvVars -PrependPath $PrependPath | Out-Null From c798159ae434e01548fdf6db3467d124d564f34b Mon Sep 17 00:00:00 2001 From: Sergey Andreev Date: Wed, 29 Mar 2023 16:07:28 +0200 Subject: [PATCH 045/660] Improved UnityShims for better code sharing --- src/MessagePack.UnityShims/Shims.cs | 145 +++++++++++++++++++++++++--- 1 file changed, 131 insertions(+), 14 deletions(-) diff --git a/src/MessagePack.UnityShims/Shims.cs b/src/MessagePack.UnityShims/Shims.cs index bd0ac10d3..ce4176a11 100644 --- a/src/MessagePack.UnityShims/Shims.cs +++ b/src/MessagePack.UnityShims/Shims.cs @@ -1,6 +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. +using System; using MessagePack; #pragma warning disable SA1307 // Field should begin with upper-case letter @@ -13,23 +14,56 @@ namespace UnityEngine { [MessagePackObject] - public struct Vector2 + public struct Vector2 : IEquatable { [Key(0)] public float x; [Key(1)] public float y; + private static readonly Vector2 zeroVector = new(0.0f, 0.0f); + private static readonly Vector2 oneVector = new(1f, 1f); + private static readonly Vector2 upVector = new(0.0f, 1f); + private static readonly Vector2 downVector = new(0.0f, -1f); + private static readonly Vector2 leftVector = new(-1f, 0.0f); + private static readonly Vector2 rightVector = new(1f, 0.0f); + [SerializationConstructor] public Vector2(float x, float y) { this.x = x; this.y = y; } + + public override bool Equals(object other) => other is Vector2 other1 && this.Equals(other1); + public bool Equals(Vector2 other) => this.x == (double)other.x && this.y == (double)other.y; + + public static Vector2 zero = zeroVector; + public static Vector2 one => oneVector; + public static Vector2 up => upVector; + public static Vector2 down => downVector; + public static Vector2 left => leftVector; + public static Vector2 right => rightVector; + + public static Vector2 operator +(Vector2 a, Vector2 b) => new(a.x + b.x, a.y + b.y); + public static Vector2 operator -(Vector2 a, Vector2 b) => new(a.x - b.x, a.y - b.y); + public static Vector2 operator *(Vector2 a, Vector2 b) => new(a.x * b.x, a.y * b.y); + public static Vector2 operator /(Vector2 a, Vector2 b) => new(a.x / b.x, a.y / b.y); + public static Vector2 operator -(Vector2 a) => new(-a.x, -a.y); + public static Vector2 operator *(Vector2 a, float d) => new(a.x * d, a.y * d); + public static Vector2 operator *(float d, Vector2 a) => new(a.x * d, a.y * d); + public static Vector2 operator /(Vector2 a, float d) => new(a.x / d, a.y / d); + public static bool operator ==(Vector2 lhs, Vector2 rhs) + { + float num1 = lhs.x - rhs.x; + float num2 = lhs.y - rhs.y; + return num1 * (double)num1 + num2 * (double)num2 < 9.9999994396249292E-11; + } + public static bool operator !=(Vector2 lhs, Vector2 rhs) => !(lhs == rhs); } [MessagePackObject] - public struct Vector3 + public struct Vector3 : IEquatable { [Key(0)] public float x; @@ -38,6 +72,15 @@ public struct Vector3 [Key(2)] public float z; + private static readonly Vector3 zeroVector = new(0.0f, 0.0f, 0.0f); + private static readonly Vector3 oneVector = new(1f, 1f, 1f); + private static readonly Vector3 upVector = new(0.0f, 1f, 0.0f); + private static readonly Vector3 downVector = new(0.0f, -1f, 0.0f); + private static readonly Vector3 leftVector = new(-1f, 0.0f, 0.0f); + private static readonly Vector3 rightVector = new(1f, 0.0f, 0.0f); + private static readonly Vector3 forwardVector = new(0.0f, 0.0f, 1f); + private static readonly Vector3 backVector = new(0.0f, 0.0f, -1f); + [SerializationConstructor] public Vector3(float x, float y, float z) { @@ -46,23 +89,44 @@ public Vector3(float x, float y, float z) this.z = z; } - public static Vector3 operator *(Vector3 a, float d) + public override bool Equals(object other) => other is Vector3 other1 && this.Equals(other1); + public bool Equals(Vector3 other) => this.x == (double)other.x && this.y == (double)other.y && this.z == (double)other.z; + + public static Vector3 zero => zeroVector; + public static Vector3 one => oneVector; + public static Vector3 forward => forwardVector; + public static Vector3 back => backVector; + public static Vector3 up => upVector; + public static Vector3 down => downVector; + public static Vector3 left => leftVector; + public static Vector3 right => rightVector; + + public static Vector3 operator +(Vector3 a, Vector3 b) => new(a.x + b.x, a.y + b.y, a.z + b.z); + public static Vector3 operator -(Vector3 a, Vector3 b) => new(a.x - b.x, a.y - b.y, a.z - b.z); + public static Vector3 operator -(Vector3 a) => new(-a.x, -a.y, -a.z); + public static Vector3 operator *(Vector3 a, float d) => new(a.x * d, a.y * d, a.z * d); + public static Vector3 operator *(float d, Vector3 a) => new(a.x * d, a.y * d, a.z * d); + public static Vector3 operator /(Vector3 a, float d) => new(a.x / d, a.y / d, a.z / d); + public static bool operator ==(Vector3 lhs, Vector3 rhs) { - return new Vector3(a.x * d, a.y * d, a.z * d); + float num1 = lhs.x - rhs.x; + float num2 = lhs.y - rhs.y; + float num3 = lhs.z - rhs.z; + return num1 * (double)num1 + num2 * (double)num2 + num3 * (double)num3 < 9.9999994396249292E-11; } + public static bool operator !=(Vector3 lhs, Vector3 rhs) => !(lhs == rhs); } [MessagePackObject] - public struct Vector4 + public struct Vector4 : IEquatable { - [Key(0)] - public float x; - [Key(1)] - public float y; - [Key(2)] - public float z; - [Key(3)] - public float w; + [Key(0)] public float x; + [Key(1)] public float y; + [Key(2)] public float z; + [Key(3)] public float w; + + private static readonly Vector4 zeroVector = new(0.0f, 0.0f, 0.0f, 0.0f); + private static readonly Vector4 oneVector = new(1f, 1f, 1f, 1f); [SerializationConstructor] public Vector4(float x, float y, float z, float w) @@ -72,6 +136,29 @@ public Vector4(float x, float y, float z, float w) this.z = z; this.w = w; } + + public override bool Equals(object other) => other is Vector4 other1 && this.Equals(other1); + public bool Equals(Vector4 other) => this.x == (double)other.x && this.y == (double)other.y && this.z == (double)other.z && this.w == (double)other.w; + + public static Vector4 zero => zeroVector; + public static Vector4 one = oneVector; + + public static Vector4 operator +(Vector4 a, Vector4 b) => new(a.x + b.x, a.y + b.y, a.z + b.z, a.w + b.w); + public static Vector4 operator -(Vector4 a, Vector4 b) => new(a.x - b.x, a.y - b.y, a.z - b.z, a.w - b.w); + public static Vector4 operator -(Vector4 a) => new(-a.x, -a.y, -a.z, -a.w); + public static Vector4 operator *(Vector4 a, float d) => new(a.x * d, a.y * d, a.z * d, a.w * d); + public static Vector4 operator *(float d, Vector4 a) => new(a.x * d, a.y * d, a.z * d, a.w * d); + public static Vector4 operator /(Vector4 a, float d) => new(a.x / d, a.y / d, a.z / d, a.w / d); + public static bool operator ==(Vector4 lhs, Vector4 rhs) + { + float num1 = lhs.x - rhs.x; + float num2 = lhs.y - rhs.y; + float num3 = lhs.z - rhs.z; + float num4 = lhs.w - rhs.w; + return num1 * (double)num1 + num2 * (double)num2 + num3 * (double)num3 + + num4 * (double)num4 < 9.9999994396249292E-11; + } + public static bool operator !=(Vector4 lhs, Vector4 rhs) => !(lhs == rhs); } [MessagePackObject] @@ -86,6 +173,8 @@ public struct Quaternion [Key(3)] public float w; + private static readonly Quaternion identityQuaternion = new(0.0f, 0.0f, 0.0f, 1f); + [SerializationConstructor] public Quaternion(float x, float y, float z, float w) { @@ -94,10 +183,12 @@ public Quaternion(float x, float y, float z, float w) this.z = z; this.w = w; } + + public static Quaternion identity => identityQuaternion; } [MessagePackObject] - public struct Color + public struct Color : IEquatable { [Key(0)] public float r; @@ -121,6 +212,32 @@ public Color(float r, float g, float b, float a) this.b = b; this.a = a; } + + public override bool Equals(object other) => other is Color other1 && this.Equals(other1); + public bool Equals(Color other) => this.r.Equals(other.r) && this.g.Equals(other.g) && this.b.Equals(other.b) && this.a.Equals(other.a); + + public static Color operator +(Color a, Color b) => new(a.r + b.r, a.g + b.g, a.b + b.b, a.a + b.a); + public static Color operator -(Color a, Color b) => new(a.r - b.r, a.g - b.g, a.b - b.b, a.a - b.a); + public static Color operator *(Color a, Color b) => new(a.r * b.r, a.g * b.g, a.b * b.b, a.a * b.a); + public static Color operator *(Color a, float b) => new(a.r * b, a.g * b, a.b * b, a.a * b); + public static Color operator *(float b, Color a) => new(a.r * b, a.g * b, a.b * b, a.a * b); + public static Color operator /(Color a, float b) => new(a.r / b, a.g / b, a.b / b, a.a / b); + public static bool operator ==(Color lhs, Color rhs) => (Vector4)lhs == (Vector4)rhs; + public static bool operator !=(Color lhs, Color rhs) => !(lhs == rhs); + + public static Color red => new(1f, 0.0f, 0.0f, 1f); + public static Color green => new(0.0f, 1f, 0.0f, 1f); + public static Color blue => new(0.0f, 0.0f, 1f, 1f); + public static Color white => new(1f, 1f, 1f, 1f); + public static Color black => new(0.0f, 0.0f, 0.0f, 1f); + public static Color yellow => new(1f, 0.921568632f, 0.0156862754f, 1f); + public static Color cyan => new(0.0f, 1f, 1f, 1f); + public static Color magenta => new(1f, 0.0f, 1f, 1f); + public static Color gray => new(0.5f, 0.5f, 0.5f, 1f); + public static Color clear => new(0.0f, 0.0f, 0.0f, 0.0f); + + public static implicit operator Vector4(Color c) => new(c.r, c.g, c.b, c.a); + public static implicit operator Color(Vector4 v) => new(v.x, v.y, v.z, v.w); } [MessagePackObject] From 5b05f24f549f714ee65453c2f8116666dac35f91 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Wed, 29 Mar 2023 17:34:45 -0600 Subject: [PATCH 046/660] Fix generation of multiple formatters --- .../CodeAnalysis/FullModel.cs | 44 +++++++++++-- .../ResolverRegisterInfoComparer.cs | 15 +++++ .../CodeAnalysis/TypeCollector.cs | 16 ++--- .../MessagePackGenerator.Emit.cs | 34 ++++++---- .../MessagePackGenerator.cs | 52 ++++++++++----- .../ExecutionTests.cs | 10 +-- .../TwoTypes/MessagePack..Object1.g.cs | 32 ++++++++++ .../TwoTypes/MessagePack..Object2.g.cs | 32 ++++++++++ .../MessagePack.GeneratedResolver.g.cs | 64 +++++++++++++++++++ 9 files changed, 254 insertions(+), 45 deletions(-) create mode 100644 src/MessagePack.Generator/CodeAnalysis/ResolverRegisterInfoComparer.cs create mode 100644 tests/MessagePack.Generator.Tests/Resources/TwoTypes/MessagePack..Object1.g.cs create mode 100644 tests/MessagePack.Generator.Tests/Resources/TwoTypes/MessagePack..Object2.g.cs create mode 100644 tests/MessagePack.Generator.Tests/Resources/TwoTypes/MessagePack.GeneratedResolver.g.cs diff --git a/src/MessagePack.Generator/CodeAnalysis/FullModel.cs b/src/MessagePack.Generator/CodeAnalysis/FullModel.cs index f923fc214..85d63e79b 100644 --- a/src/MessagePack.Generator/CodeAnalysis/FullModel.cs +++ b/src/MessagePack.Generator/CodeAnalysis/FullModel.cs @@ -1,13 +1,49 @@ // Copyright (c) All contributors. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. +using System.Collections.Immutable; + namespace MessagePack.Generator.CodeAnalysis; public record FullModel( - ObjectSerializationInfo[] ObjectInfos, - EnumSerializationInfo[] EnumInfos, - GenericSerializationInfo[] GenericInfos, - UnionSerializationInfo[] UnionInfos, + ImmutableSortedSet ObjectInfos, + ImmutableSortedSet EnumInfos, + ImmutableSortedSet GenericInfos, + ImmutableSortedSet UnionInfos, AnalyzerOptions Options) { + /// + /// Returns a new model that contains all the content of a collection of models. + /// + /// The models to be combined. + /// The new, combined model. + /// Thrown if is not equal between any two models. + public static FullModel Combine(ImmutableArray models) + { + AnalyzerOptions options = models[0].Options; + var objectInfos = ImmutableSortedSet.CreateBuilder(ResolverRegisterInfoComparer.Default); + var enumInfos = ImmutableSortedSet.CreateBuilder(ResolverRegisterInfoComparer.Default); + var genericInfos = ImmutableSortedSet.CreateBuilder(ResolverRegisterInfoComparer.Default); + var unionInfos = ImmutableSortedSet.CreateBuilder(ResolverRegisterInfoComparer.Default); + + foreach (FullModel model in models) + { + objectInfos.UnionWith(model.ObjectInfos); + enumInfos.UnionWith(model.EnumInfos); + genericInfos.UnionWith(model.GenericInfos); + unionInfos.UnionWith(model.UnionInfos); + + if (options != model.Options) + { + throw new NotSupportedException("Options must be equal."); + } + } + + return new FullModel( + objectInfos.ToImmutable(), + enumInfos.ToImmutable(), + genericInfos.ToImmutable(), + unionInfos.ToImmutable(), + options); + } } diff --git a/src/MessagePack.Generator/CodeAnalysis/ResolverRegisterInfoComparer.cs b/src/MessagePack.Generator/CodeAnalysis/ResolverRegisterInfoComparer.cs new file mode 100644 index 000000000..d409b19fa --- /dev/null +++ b/src/MessagePack.Generator/CodeAnalysis/ResolverRegisterInfoComparer.cs @@ -0,0 +1,15 @@ +// Copyright (c) All contributors. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +namespace MessagePack.Generator.CodeAnalysis; + +internal class ResolverRegisterInfoComparer : IComparer +{ + internal static readonly ResolverRegisterInfoComparer Default = new(); + + private ResolverRegisterInfoComparer() + { + } + + public int Compare(IResolverRegisterInfo x, IResolverRegisterInfo y) => StringComparer.Ordinal.Compare(x.FullName, y.FullName); +} diff --git a/src/MessagePack.Generator/CodeAnalysis/TypeCollector.cs b/src/MessagePack.Generator/CodeAnalysis/TypeCollector.cs index e88c44a7f..9b5268b90 100644 --- a/src/MessagePack.Generator/CodeAnalysis/TypeCollector.cs +++ b/src/MessagePack.Generator/CodeAnalysis/TypeCollector.cs @@ -234,10 +234,10 @@ public class TypeCollector #pragma warning disable RS1024 // Compare symbols correctly (https://github.com/dotnet/roslyn-analyzers/issues/5246) private readonly HashSet alreadyCollected = new(SymbolEqualityComparer.Default); #pragma warning restore RS1024 // Compare symbols correctly - private readonly List collectedObjectInfo = new(); - private readonly List collectedEnumInfo = new(); - private readonly List collectedGenericInfo = new(); - private readonly List collectedUnionInfo = new(); + private readonly ImmutableSortedSet.Builder collectedObjectInfo = ImmutableSortedSet.CreateBuilder(ResolverRegisterInfoComparer.Default); + private readonly ImmutableSortedSet.Builder collectedEnumInfo = ImmutableSortedSet.CreateBuilder(ResolverRegisterInfoComparer.Default); + private readonly ImmutableSortedSet.Builder collectedGenericInfo = ImmutableSortedSet.CreateBuilder(ResolverRegisterInfoComparer.Default); + private readonly ImmutableSortedSet.Builder collectedUnionInfo = ImmutableSortedSet.CreateBuilder(ResolverRegisterInfoComparer.Default); private readonly Compilation compilation; @@ -312,10 +312,10 @@ public FullModel Collect() } return new FullModel( - this.collectedObjectInfo.OrderBy(x => x.FullName).ToArray(), - this.collectedEnumInfo.OrderBy(x => x.FullName).ToArray(), - this.collectedGenericInfo.Distinct().OrderBy(x => x.FullName).ToArray(), - this.collectedUnionInfo.OrderBy(x => x.FullName).ToArray(), + this.collectedObjectInfo.ToImmutable(), + this.collectedEnumInfo.ToImmutable(), + this.collectedGenericInfo.ToImmutable(), + this.collectedUnionInfo.ToImmutable(), this.options); } diff --git a/src/MessagePack.Generator/MessagePackGenerator.Emit.cs b/src/MessagePack.Generator/MessagePackGenerator.Emit.cs index e34f983ca..6d175b618 100644 --- a/src/MessagePack.Generator/MessagePackGenerator.Emit.cs +++ b/src/MessagePack.Generator/MessagePackGenerator.Emit.cs @@ -27,19 +27,6 @@ private static void Generate(IGeneratorContext context, FullModel model) AnalyzerOptions options = model.Options; StringBuilder sb = new(); - ResolverTemplate resolverTemplate = new( - options.ResolverNamespace, - options.FormatterNamespace, - options.ResolverName, - model.GenericInfos - .Where(x => !x.IsOpenGenericType) - .Cast() - .Concat(model.EnumInfos) - .Concat(model.UnionInfos) - .Concat(model.ObjectInfos.Where(x => !x.IsOpenGenericType)) - .ToArray()); - AddTransform(resolverTemplate.TransformText(), "GeneratedResolver"); - foreach (EnumSerializationInfo info in model.EnumInfos) { EnumTemplate transform = new(CodeAnalysisUtilities.QualifyNames(options.FormatterNamespace, info.Namespace), info); @@ -70,4 +57,25 @@ void AddTransform(string transformOutput, string uniqueFileName) sb.Clear(); } } + + private static void GenerateResolver(IGeneratorContext context, FullModel model) + { + AnalyzerOptions options = model.Options; + StringBuilder sb = new(); + + ResolverTemplate resolverTemplate = new( + options.ResolverNamespace, + options.FormatterNamespace, + options.ResolverName, + model.GenericInfos + .Where(x => !x.IsOpenGenericType) + .Cast() + .Concat(model.EnumInfos) + .Concat(model.UnionInfos) + .Concat(model.ObjectInfos.Where(x => !x.IsOpenGenericType)) + .ToArray()); + sb.AppendLine(FileHeader); + sb.Append(resolverTemplate.TransformText()); + context.AddSource($"MessagePack.GeneratedResolver.g.cs", sb.ToString()); + } } diff --git a/src/MessagePack.Generator/MessagePackGenerator.cs b/src/MessagePack.Generator/MessagePackGenerator.cs index be506f3b8..8fd9d9da9 100644 --- a/src/MessagePack.Generator/MessagePackGenerator.cs +++ b/src/MessagePack.Generator/MessagePackGenerator.cs @@ -1,6 +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. +using System.Collections.Immutable; using MessagePack.Generator.CodeAnalysis; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp.Syntax; @@ -21,30 +22,51 @@ public void Initialize(IncrementalGeneratorInitializationContext context) MessagePackObjectAttributeFullName, predicate: static (node, _) => node is TypeDeclarationSyntax, transform: static (context, _) => (TypeDeclarationSyntax)context.TargetNode); - Register(messagePackObjectTypes); var unionTypes = context.SyntaxProvider.ForAttributeWithMetadataName( MessagePackUnionAttributeFullName, predicate: static (node, _) => node is InterfaceDeclarationSyntax, transform: static (context, _) => (TypeDeclarationSyntax)context.TargetNode); - Register(unionTypes); - void Register(IncrementalValuesProvider typeDeclarations) - { - var source = typeDeclarations - .Combine(context.CompilationProvider) - .Combine(options) - .Select(static (s, ct) => - { - return TypeCollector.Collect(s.Left.Right, s.Right, s.Left.Left, null, ct); - }) - .Where(fm => fm is not null); + var combined = + messagePackObjectTypes.Collect().Combine(unionTypes.Collect()); - context.RegisterSourceOutput(source, static (context, source) => + var source = combined + .Combine(context.CompilationProvider) + .Combine(options) + .Select(static (s, ct) => { - Generate(new GeneratorContext(context), source!); + List modelPerType = new(); + void Collect(TypeDeclarationSyntax typeDecl) + { + if (TypeCollector.Collect(s.Left.Right, s.Right, typeDecl, null, ct) is FullModel model) + { + modelPerType.Add(model); + } + } + + foreach (TypeDeclarationSyntax typeDecl in s.Left.Left.Left) + { + Collect(typeDecl); + } + + foreach (TypeDeclarationSyntax typeDecl in s.Left.Left.Right) + { + Collect(typeDecl); + } + + return FullModel.Combine(modelPerType.ToImmutableArray()); }); - } + + context.RegisterSourceOutput(source, static (context, source) => + { + Generate(new GeneratorContext(context), source!); + }); + + context.RegisterSourceOutput(source, static (context, source) => + { + GenerateResolver(new GeneratorContext(context), source!); + }); } private class Comparer : IEqualityComparer<(TypeDeclarationSyntax, Compilation)> diff --git a/tests/MessagePack.Generator.ExecutionTests/ExecutionTests.cs b/tests/MessagePack.Generator.ExecutionTests/ExecutionTests.cs index 62ca8c9cf..e4c6d71b2 100644 --- a/tests/MessagePack.Generator.ExecutionTests/ExecutionTests.cs +++ b/tests/MessagePack.Generator.ExecutionTests/ExecutionTests.cs @@ -22,13 +22,13 @@ public void ClassWithEnumProperty() [Fact] public void ClassWithPropertiesWithGetterAndSetter() { - this.AssertRoundtrip(new HasPropertiesWithGetterAndSetter { A = 1, B = "hi" }); + this.AssertRoundtrip(new HasPropertiesWithGetterAndSetter { A = 1, B = 4 }); } [Fact] public void ClassWithPropertiesWithGetterAndCtor() { - this.AssertRoundtrip(new HasPropertiesWithGetterAndCtor(1, "hi")); + this.AssertRoundtrip(new HasPropertiesWithGetterAndCtor(1, 4)); } private T AssertRoundtrip(T value) @@ -54,7 +54,7 @@ public record HasPropertiesWithGetterAndSetter public int A { get; set; } [Key(1)] - public string? B { get; set; } + public int B { get; set; } } [MessagePackObject(false)] @@ -64,9 +64,9 @@ public record HasPropertiesWithGetterAndCtor public int A { get; } [Key(1)] - public string B { get; } + public int B { get; } - public HasPropertiesWithGetterAndCtor(int a, string b) + public HasPropertiesWithGetterAndCtor(int a, int b) { A = a; B = b; diff --git a/tests/MessagePack.Generator.Tests/Resources/TwoTypes/MessagePack..Object1.g.cs b/tests/MessagePack.Generator.Tests/Resources/TwoTypes/MessagePack..Object1.g.cs new file mode 100644 index 000000000..cedff3969 --- /dev/null +++ b/tests/MessagePack.Generator.Tests/Resources/TwoTypes/MessagePack..Object1.g.cs @@ -0,0 +1,32 @@ +// + +#pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 + +namespace MessagePack.Formatters +{ + public sealed class Object1Formatter : global::MessagePack.Formatters.IMessagePackFormatter + { + + public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::Object1 value, global::MessagePack.MessagePackSerializerOptions options) + { + if (value == null) + { + writer.WriteNil(); + return; + } + + writer.WriteArrayHeader(0); + } + + public global::Object1 Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) + { + if (reader.TryReadNil()) + { + return null; + } + + reader.Skip(); + return new global::Object1(); + } + } +} diff --git a/tests/MessagePack.Generator.Tests/Resources/TwoTypes/MessagePack..Object2.g.cs b/tests/MessagePack.Generator.Tests/Resources/TwoTypes/MessagePack..Object2.g.cs new file mode 100644 index 000000000..d169ed4be --- /dev/null +++ b/tests/MessagePack.Generator.Tests/Resources/TwoTypes/MessagePack..Object2.g.cs @@ -0,0 +1,32 @@ +// + +#pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 + +namespace MessagePack.Formatters +{ + public sealed class Object2Formatter : global::MessagePack.Formatters.IMessagePackFormatter + { + + public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::Object2 value, global::MessagePack.MessagePackSerializerOptions options) + { + if (value == null) + { + writer.WriteNil(); + return; + } + + writer.WriteArrayHeader(0); + } + + public global::Object2 Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) + { + if (reader.TryReadNil()) + { + return null; + } + + reader.Skip(); + return new global::Object2(); + } + } +} diff --git a/tests/MessagePack.Generator.Tests/Resources/TwoTypes/MessagePack.GeneratedResolver.g.cs b/tests/MessagePack.Generator.Tests/Resources/TwoTypes/MessagePack.GeneratedResolver.g.cs new file mode 100644 index 000000000..730bf1126 --- /dev/null +++ b/tests/MessagePack.Generator.Tests/Resources/TwoTypes/MessagePack.GeneratedResolver.g.cs @@ -0,0 +1,64 @@ +// + +#pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 + +namespace MessagePack.Resolvers +{ + public class GeneratedResolver : global::MessagePack.IFormatterResolver + { + public static readonly global::MessagePack.IFormatterResolver Instance = new GeneratedResolver(); + + private GeneratedResolver() + { + } + + public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() + { + return FormatterCache.Formatter; + } + + private static class FormatterCache + { + internal static readonly global::MessagePack.Formatters.IMessagePackFormatter Formatter; + + static FormatterCache() + { + var f = GeneratedResolverGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + Formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; + } + } + } + } + + internal static class GeneratedResolverGetFormatterHelper + { + private static readonly global::System.Collections.Generic.Dictionary lookup; + + static GeneratedResolverGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(2) + { + { typeof(global::Object1), 0 }, + { typeof(global::Object2), 1 }, + }; + } + + internal static object GetFormatter(global::System.Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + case 0: return new MessagePack.Formatters.Object1Formatter(); + case 1: return new MessagePack.Formatters.Object2Formatter(); + default: return null; + } + } + } +} From 3a07b307cf7c0afde50188fa2192143fc8ef04f2 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Wed, 29 Mar 2023 17:39:11 -0600 Subject: [PATCH 047/660] Fix double-periods in generated filenames --- src/MessagePack.Generator/MessagePackGenerator.Emit.cs | 4 ++-- ...g.cs => MessagePack.Formatter.MyTestNamespace.MyEnum.g.cs} | 0 ...gePack.Formatter.MyTestNamespace.MyMessagePackObject.g.cs} | 0 ....cs => MessagePack.Formatter..ContainingClass_MyEnum.g.cs} | 0 ...gePack.Formatter.ContainingClass_MyMessagePackObject.g.cs} | 0 ...gePack..MyEnum.g.cs => MessagePack.Formatter..MyEnum.g.cs} | 0 ...ct.g.cs => MessagePack.Formatter.MyMessagePackObject.g.cs} | 0 ...ePack..Object1.g.cs => MessagePack.Formatter.Object1.g.cs} | 0 ...ePack..Object2.g.cs => MessagePack.Formatter.Object2.g.cs} | 0 9 files changed, 2 insertions(+), 2 deletions(-) rename tests/MessagePack.Generator.Tests/Resources/EnumFormatter(Namespace)/{MessagePack.MyTestNamespace.MyEnum.g.cs => MessagePack.Formatter.MyTestNamespace.MyEnum.g.cs} (100%) rename tests/MessagePack.Generator.Tests/Resources/EnumFormatter(Namespace)/{MessagePack.MyTestNamespace.MyMessagePackObject.g.cs => MessagePack.Formatter.MyTestNamespace.MyMessagePackObject.g.cs} (100%) rename tests/MessagePack.Generator.Tests/Resources/EnumFormatter(NestingClass)/{MessagePack..ContainingClass_MyEnum.g.cs => MessagePack.Formatter..ContainingClass_MyEnum.g.cs} (100%) rename tests/MessagePack.Generator.Tests/Resources/EnumFormatter(NestingClass)/{MessagePack..ContainingClass_MyMessagePackObject.g.cs => MessagePack.Formatter.ContainingClass_MyMessagePackObject.g.cs} (100%) rename tests/MessagePack.Generator.Tests/Resources/EnumFormatter(None)/{MessagePack..MyEnum.g.cs => MessagePack.Formatter..MyEnum.g.cs} (100%) rename tests/MessagePack.Generator.Tests/Resources/EnumFormatter(None)/{MessagePack..MyMessagePackObject.g.cs => MessagePack.Formatter.MyMessagePackObject.g.cs} (100%) rename tests/MessagePack.Generator.Tests/Resources/TwoTypes/{MessagePack..Object1.g.cs => MessagePack.Formatter.Object1.g.cs} (100%) rename tests/MessagePack.Generator.Tests/Resources/TwoTypes/{MessagePack..Object2.g.cs => MessagePack.Formatter.Object2.g.cs} (100%) diff --git a/src/MessagePack.Generator/MessagePackGenerator.Emit.cs b/src/MessagePack.Generator/MessagePackGenerator.Emit.cs index 6d175b618..c9ba16861 100644 --- a/src/MessagePack.Generator/MessagePackGenerator.Emit.cs +++ b/src/MessagePack.Generator/MessagePackGenerator.Emit.cs @@ -45,7 +45,7 @@ private static void Generate(IGeneratorContext context, FullModel model) IFormatterTemplate transform = info.IsStringKey ? new StringKeyFormatterTemplate(formatterNamespace, info) : new FormatterTemplate(formatterNamespace, info); - AddTransform(transform.TransformText(), $"{info.Namespace}.{info.Name}"); + AddTransform(transform.TransformText(), CodeAnalysisUtilities.NamespaceAndType(info.Name, info.Namespace)); } void AddTransform(string transformOutput, string uniqueFileName) @@ -53,7 +53,7 @@ void AddTransform(string transformOutput, string uniqueFileName) sb.Clear(); sb.AppendLine(FileHeader); sb.Append(transformOutput); - context.AddSource($"MessagePack.{uniqueFileName}.g.cs", sb.ToString()); + context.AddSource($"MessagePack.Formatter.{uniqueFileName}.g.cs", sb.ToString()); sb.Clear(); } } diff --git a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(Namespace)/MessagePack.MyTestNamespace.MyEnum.g.cs b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(Namespace)/MessagePack.Formatter.MyTestNamespace.MyEnum.g.cs similarity index 100% rename from tests/MessagePack.Generator.Tests/Resources/EnumFormatter(Namespace)/MessagePack.MyTestNamespace.MyEnum.g.cs rename to tests/MessagePack.Generator.Tests/Resources/EnumFormatter(Namespace)/MessagePack.Formatter.MyTestNamespace.MyEnum.g.cs diff --git a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(Namespace)/MessagePack.MyTestNamespace.MyMessagePackObject.g.cs b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(Namespace)/MessagePack.Formatter.MyTestNamespace.MyMessagePackObject.g.cs similarity index 100% rename from tests/MessagePack.Generator.Tests/Resources/EnumFormatter(Namespace)/MessagePack.MyTestNamespace.MyMessagePackObject.g.cs rename to tests/MessagePack.Generator.Tests/Resources/EnumFormatter(Namespace)/MessagePack.Formatter.MyTestNamespace.MyMessagePackObject.g.cs diff --git a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(NestingClass)/MessagePack..ContainingClass_MyEnum.g.cs b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(NestingClass)/MessagePack.Formatter..ContainingClass_MyEnum.g.cs similarity index 100% rename from tests/MessagePack.Generator.Tests/Resources/EnumFormatter(NestingClass)/MessagePack..ContainingClass_MyEnum.g.cs rename to tests/MessagePack.Generator.Tests/Resources/EnumFormatter(NestingClass)/MessagePack.Formatter..ContainingClass_MyEnum.g.cs diff --git a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(NestingClass)/MessagePack..ContainingClass_MyMessagePackObject.g.cs b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(NestingClass)/MessagePack.Formatter.ContainingClass_MyMessagePackObject.g.cs similarity index 100% rename from tests/MessagePack.Generator.Tests/Resources/EnumFormatter(NestingClass)/MessagePack..ContainingClass_MyMessagePackObject.g.cs rename to tests/MessagePack.Generator.Tests/Resources/EnumFormatter(NestingClass)/MessagePack.Formatter.ContainingClass_MyMessagePackObject.g.cs diff --git a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(None)/MessagePack..MyEnum.g.cs b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(None)/MessagePack.Formatter..MyEnum.g.cs similarity index 100% rename from tests/MessagePack.Generator.Tests/Resources/EnumFormatter(None)/MessagePack..MyEnum.g.cs rename to tests/MessagePack.Generator.Tests/Resources/EnumFormatter(None)/MessagePack.Formatter..MyEnum.g.cs diff --git a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(None)/MessagePack..MyMessagePackObject.g.cs b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(None)/MessagePack.Formatter.MyMessagePackObject.g.cs similarity index 100% rename from tests/MessagePack.Generator.Tests/Resources/EnumFormatter(None)/MessagePack..MyMessagePackObject.g.cs rename to tests/MessagePack.Generator.Tests/Resources/EnumFormatter(None)/MessagePack.Formatter.MyMessagePackObject.g.cs diff --git a/tests/MessagePack.Generator.Tests/Resources/TwoTypes/MessagePack..Object1.g.cs b/tests/MessagePack.Generator.Tests/Resources/TwoTypes/MessagePack.Formatter.Object1.g.cs similarity index 100% rename from tests/MessagePack.Generator.Tests/Resources/TwoTypes/MessagePack..Object1.g.cs rename to tests/MessagePack.Generator.Tests/Resources/TwoTypes/MessagePack.Formatter.Object1.g.cs diff --git a/tests/MessagePack.Generator.Tests/Resources/TwoTypes/MessagePack..Object2.g.cs b/tests/MessagePack.Generator.Tests/Resources/TwoTypes/MessagePack.Formatter.Object2.g.cs similarity index 100% rename from tests/MessagePack.Generator.Tests/Resources/TwoTypes/MessagePack..Object2.g.cs rename to tests/MessagePack.Generator.Tests/Resources/TwoTypes/MessagePack.Formatter.Object2.g.cs From 1edfa247c95abfdb356d73c87b863d8e43f6e795 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Thu, 30 Mar 2023 08:50:51 -0600 Subject: [PATCH 048/660] Test with built-in resolvers mixed in --- .../Transforms/ResolverTemplate.cs | 6 ++- .../Transforms/ResolverTemplate.tt | 2 + .../MessagePack/Resolvers/StandardResolver.cs | 44 +++++++++++++++++-- .../net6.0/PublicAPI.Unshipped.txt | 2 + .../netstandard2.0/PublicAPI.Unshipped.txt | 2 + .../ExecutionTests.cs | 10 ++--- .../MessagePack.GeneratedResolver.g.cs | 2 + .../MessagePack.GeneratedResolver.g.cs | 2 + .../MessagePack.GeneratedResolver.g.cs | 2 + .../MessagePack.GeneratedResolver.g.cs | 2 + 10 files changed, 64 insertions(+), 10 deletions(-) diff --git a/src/MessagePack.Generator/Transforms/ResolverTemplate.cs b/src/MessagePack.Generator/Transforms/ResolverTemplate.cs index 380839526..8896146cc 100644 --- a/src/MessagePack.Generator/Transforms/ResolverTemplate.cs +++ b/src/MessagePack.Generator/Transforms/ResolverTemplate.cs @@ -32,7 +32,11 @@ public virtual string TransformText() this.Write(" : global::MessagePack.IFormatterResolver\r\n {\r\n public static readonly " + "global::MessagePack.IFormatterResolver Instance = new "); this.Write(this.ToStringHelper.ToStringWithCulture(ResolverName)); - this.Write("();\r\n\r\n private "); + this.Write(@"(); + + public static readonly global::MessagePack.IFormatterResolver InstanceWithStandardAotResolver = global::MessagePack.Resolvers.CompositeResolver.Create(Instance, global::MessagePack.Resolvers.StandardAotResolver.Instance); + + private "); this.Write(this.ToStringHelper.ToStringWithCulture(ResolverName)); this.Write(@"() { diff --git a/src/MessagePack.Generator/Transforms/ResolverTemplate.tt b/src/MessagePack.Generator/Transforms/ResolverTemplate.tt index d553524d2..fa1608ead 100644 --- a/src/MessagePack.Generator/Transforms/ResolverTemplate.tt +++ b/src/MessagePack.Generator/Transforms/ResolverTemplate.tt @@ -10,6 +10,8 @@ namespace <#= ResolverNamespace #> { public static readonly global::MessagePack.IFormatterResolver Instance = new <#= ResolverName #>(); + public static readonly global::MessagePack.IFormatterResolver InstanceWithStandardAotResolver = global::MessagePack.Resolvers.CompositeResolver.Create(Instance, global::MessagePack.Resolvers.StandardAotResolver.Instance); + private <#= ResolverName #>() { } diff --git a/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Resolvers/StandardResolver.cs b/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Resolvers/StandardResolver.cs index 7a2389fc9..b245767a2 100644 --- a/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Resolvers/StandardResolver.cs +++ b/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Resolvers/StandardResolver.cs @@ -22,7 +22,7 @@ public sealed class StandardResolver : IFormatterResolver public static readonly StandardResolver Instance; /// - /// A instance with this formatter pre-configured. + /// A instance with this resolver pre-configured. /// public static readonly MessagePackSerializerOptions Options; @@ -79,6 +79,42 @@ static FormatterCache() } } + /// + /// The standard resolver to use when targeting AOT platforms or when avoiding runtime code generation is undesirable for perf reasons. + /// + /// + /// + /// This resolver may invoke reflection at runtime, but only for types that are not known at compile time. + /// + /// + /// This resolver is meant to be combined with a GeneratedResolver produced by our source generator. + /// This is done automatically in the GeneratedResolver.InstanceWithStandardAotResolver property. + /// + /// + public static class StandardAotResolver + { + /// + /// The singleton instance that can be used. + /// + public static readonly IFormatterResolver Instance = CompositeResolver.Create( + new IMessagePackFormatter[] + { + ExpandoObjectFormatter.Instance, + }, + new IFormatterResolver[] + { + BuiltinResolver.Instance, // Try Builtin + AttributeFormatterResolver.Instance, // Try use [MessagePackFormatter] +#if UNITY_2018_3_OR_NEWER + MessagePack.Unity.UnityResolver.Instance, +#endif + ImmutableCollection.ImmutableCollectionResolver.Instance, +#if !ENABLE_IL2CPP + DynamicGenericResolver.Instance, // Try Array, Tuple, Collection, Enum(Generic Fallback) +#endif + }); + } + public sealed class ContractlessStandardResolver : IFormatterResolver { /// @@ -87,7 +123,7 @@ public sealed class ContractlessStandardResolver : IFormatterResolver public static readonly ContractlessStandardResolver Instance; /// - /// A instance with this formatter pre-configured. + /// A instance with this resolver pre-configured. /// public static readonly MessagePackSerializerOptions Options; @@ -153,7 +189,7 @@ public sealed class StandardResolverAllowPrivate : IFormatterResolver public static readonly StandardResolverAllowPrivate Instance; /// - /// A instance with this formatter pre-configured. + /// A instance with this resolver pre-configured. /// public static readonly MessagePackSerializerOptions Options; @@ -218,7 +254,7 @@ public sealed class ContractlessStandardResolverAllowPrivate : IFormatterResolve public static readonly ContractlessStandardResolverAllowPrivate Instance; /// - /// A instance with this formatter pre-configured. + /// A instance with this resolver pre-configured. /// public static readonly MessagePackSerializerOptions Options; diff --git a/src/MessagePack/net6.0/PublicAPI.Unshipped.txt b/src/MessagePack/net6.0/PublicAPI.Unshipped.txt index 432231fd1..239b0d860 100644 --- a/src/MessagePack/net6.0/PublicAPI.Unshipped.txt +++ b/src/MessagePack/net6.0/PublicAPI.Unshipped.txt @@ -12,7 +12,9 @@ MessagePack.MessagePackSerializerOptions.CompressionMinLength.get -> int MessagePack.MessagePackSerializerOptions.SuggestedContiguousMemorySize.get -> int MessagePack.MessagePackSerializerOptions.WithCompressionMinLength(int compressionMinLength) -> MessagePack.MessagePackSerializerOptions! MessagePack.MessagePackSerializerOptions.WithSuggestedContiguousMemorySize(int suggestedContiguousMemorySize) -> MessagePack.MessagePackSerializerOptions! +MessagePack.Resolvers.StandardAotResolver static MessagePack.MessagePackWriter.GetEncodedLength(long value) -> int static MessagePack.MessagePackWriter.GetEncodedLength(ulong value) -> int static readonly MessagePack.Formatters.DateOnlyFormatter.Instance -> MessagePack.Formatters.DateOnlyFormatter! static readonly MessagePack.Formatters.TimeOnlyFormatter.Instance -> MessagePack.Formatters.TimeOnlyFormatter! +static readonly MessagePack.Resolvers.StandardAotResolver.Instance -> MessagePack.IFormatterResolver! diff --git a/src/MessagePack/netstandard2.0/PublicAPI.Unshipped.txt b/src/MessagePack/netstandard2.0/PublicAPI.Unshipped.txt index d78a588a7..6fcde9306 100644 --- a/src/MessagePack/netstandard2.0/PublicAPI.Unshipped.txt +++ b/src/MessagePack/netstandard2.0/PublicAPI.Unshipped.txt @@ -6,5 +6,7 @@ MessagePack.MessagePackSerializerOptions.CompressionMinLength.get -> int MessagePack.MessagePackSerializerOptions.SuggestedContiguousMemorySize.get -> int MessagePack.MessagePackSerializerOptions.WithCompressionMinLength(int compressionMinLength) -> MessagePack.MessagePackSerializerOptions! MessagePack.MessagePackSerializerOptions.WithSuggestedContiguousMemorySize(int suggestedContiguousMemorySize) -> MessagePack.MessagePackSerializerOptions! +MessagePack.Resolvers.StandardAotResolver static MessagePack.MessagePackWriter.GetEncodedLength(long value) -> int static MessagePack.MessagePackWriter.GetEncodedLength(ulong value) -> int +static readonly MessagePack.Resolvers.StandardAotResolver.Instance -> MessagePack.IFormatterResolver! diff --git a/tests/MessagePack.Generator.ExecutionTests/ExecutionTests.cs b/tests/MessagePack.Generator.ExecutionTests/ExecutionTests.cs index e4c6d71b2..2f28ea4c4 100644 --- a/tests/MessagePack.Generator.ExecutionTests/ExecutionTests.cs +++ b/tests/MessagePack.Generator.ExecutionTests/ExecutionTests.cs @@ -4,7 +4,7 @@ public class ExecutionTests { private static readonly MessagePackSerializerOptions SerializerOptions = MessagePackSerializerOptions.Standard - .WithResolver(GeneratedResolver.Instance); + .WithResolver(GeneratedResolver.InstanceWithStandardAotResolver); private readonly ITestOutputHelper logger; @@ -28,7 +28,7 @@ public void ClassWithPropertiesWithGetterAndSetter() [Fact] public void ClassWithPropertiesWithGetterAndCtor() { - this.AssertRoundtrip(new HasPropertiesWithGetterAndCtor(1, 4)); + this.AssertRoundtrip(new HasPropertiesWithGetterAndCtor(1, "four")); } private T AssertRoundtrip(T value) @@ -54,7 +54,7 @@ public record HasPropertiesWithGetterAndSetter public int A { get; set; } [Key(1)] - public int B { get; set; } + public int? B { get; set; } } [MessagePackObject(false)] @@ -64,9 +64,9 @@ public record HasPropertiesWithGetterAndCtor public int A { get; } [Key(1)] - public int B { get; } + public string? B { get; } - public HasPropertiesWithGetterAndCtor(int a, int b) + public HasPropertiesWithGetterAndCtor(int a, string? b) { A = a; B = b; diff --git a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(Namespace)/MessagePack.GeneratedResolver.g.cs b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(Namespace)/MessagePack.GeneratedResolver.g.cs index 3ff547744..bc9584261 100644 --- a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(Namespace)/MessagePack.GeneratedResolver.g.cs +++ b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(Namespace)/MessagePack.GeneratedResolver.g.cs @@ -8,6 +8,8 @@ public class GeneratedResolver : global::MessagePack.IFormatterResolver { public static readonly global::MessagePack.IFormatterResolver Instance = new GeneratedResolver(); + public static readonly global::MessagePack.IFormatterResolver InstanceWithStandardAotResolver = global::MessagePack.Resolvers.CompositeResolver.Create(Instance, global::MessagePack.Resolvers.StandardAotResolver.Instance); + private GeneratedResolver() { } diff --git a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(NestingClass)/MessagePack.GeneratedResolver.g.cs b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(NestingClass)/MessagePack.GeneratedResolver.g.cs index a88fcdb4d..cc8bd0ad1 100644 --- a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(NestingClass)/MessagePack.GeneratedResolver.g.cs +++ b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(NestingClass)/MessagePack.GeneratedResolver.g.cs @@ -8,6 +8,8 @@ public class GeneratedResolver : global::MessagePack.IFormatterResolver { public static readonly global::MessagePack.IFormatterResolver Instance = new GeneratedResolver(); + public static readonly global::MessagePack.IFormatterResolver InstanceWithStandardAotResolver = global::MessagePack.Resolvers.CompositeResolver.Create(Instance, global::MessagePack.Resolvers.StandardAotResolver.Instance); + private GeneratedResolver() { } diff --git a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(None)/MessagePack.GeneratedResolver.g.cs b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(None)/MessagePack.GeneratedResolver.g.cs index cc0839c4f..e7eb631de 100644 --- a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(None)/MessagePack.GeneratedResolver.g.cs +++ b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(None)/MessagePack.GeneratedResolver.g.cs @@ -8,6 +8,8 @@ public class GeneratedResolver : global::MessagePack.IFormatterResolver { public static readonly global::MessagePack.IFormatterResolver Instance = new GeneratedResolver(); + public static readonly global::MessagePack.IFormatterResolver InstanceWithStandardAotResolver = global::MessagePack.Resolvers.CompositeResolver.Create(Instance, global::MessagePack.Resolvers.StandardAotResolver.Instance); + private GeneratedResolver() { } diff --git a/tests/MessagePack.Generator.Tests/Resources/TwoTypes/MessagePack.GeneratedResolver.g.cs b/tests/MessagePack.Generator.Tests/Resources/TwoTypes/MessagePack.GeneratedResolver.g.cs index 730bf1126..9544a4a33 100644 --- a/tests/MessagePack.Generator.Tests/Resources/TwoTypes/MessagePack.GeneratedResolver.g.cs +++ b/tests/MessagePack.Generator.Tests/Resources/TwoTypes/MessagePack.GeneratedResolver.g.cs @@ -8,6 +8,8 @@ public class GeneratedResolver : global::MessagePack.IFormatterResolver { public static readonly global::MessagePack.IFormatterResolver Instance = new GeneratedResolver(); + public static readonly global::MessagePack.IFormatterResolver InstanceWithStandardAotResolver = global::MessagePack.Resolvers.CompositeResolver.Create(Instance, global::MessagePack.Resolvers.StandardAotResolver.Instance); + private GeneratedResolver() { } From aa14d54e13fdcecdec246fcedfe2967ee35e20e6 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Thu, 30 Mar 2023 08:53:39 -0600 Subject: [PATCH 049/660] Use MsgPack namespace alias for shorter generated files --- .../Transforms/FormatterTemplate.cs | 29 +++++++++---------- .../Transforms/FormatterTemplate.tt | 16 +++++----- .../Transforms/ResolverTemplate.cs | 20 ++++++------- .../Transforms/ResolverTemplate.tt | 14 +++++---- .../Transforms/UnionTemplate.cs | 21 +++++++------- .../Transforms/UnionTemplate.tt | 14 +++++---- ...r.MyTestNamespace.MyMessagePackObject.g.cs | 12 ++++---- .../MessagePack.GeneratedResolver.g.cs | 14 +++++---- ...r.ContainingClass_MyMessagePackObject.g.cs | 12 ++++---- .../MessagePack.GeneratedResolver.g.cs | 14 +++++---- ...agePack.Formatter.MyMessagePackObject.g.cs | 12 ++++---- .../MessagePack.GeneratedResolver.g.cs | 14 +++++---- .../MessagePack.Formatter.Object1.g.cs | 8 +++-- .../MessagePack.Formatter.Object2.g.cs | 8 +++-- .../MessagePack.GeneratedResolver.g.cs | 14 +++++---- 15 files changed, 120 insertions(+), 102 deletions(-) diff --git a/src/MessagePack.Generator/Transforms/FormatterTemplate.cs b/src/MessagePack.Generator/Transforms/FormatterTemplate.cs index 00be5d883..76ae6db56 100644 --- a/src/MessagePack.Generator/Transforms/FormatterTemplate.cs +++ b/src/MessagePack.Generator/Transforms/FormatterTemplate.cs @@ -27,11 +27,11 @@ public virtual string TransformText() { this.Write("\r\nnamespace "); this.Write(this.ToStringHelper.ToStringWithCulture(Namespace)); - this.Write("\r\n{\r\n"); + this.Write("\r\n{\r\n using MsgPack = global::MessagePack;\r\n\r\n"); bool isFormatterResolverNecessary = ShouldUseFormatterResolverHelper.ShouldUseFormatterResolver(Info.Members); this.Write(" public sealed class "); this.Write(this.ToStringHelper.ToStringWithCulture(Info.FormatterNameWithoutNamespace)); - this.Write(" : global::MessagePack.Formatters.IMessagePackFormatter<"); + this.Write(" : MsgPack::Formatters.IMessagePackFormatter<"); this.Write(this.ToStringHelper.ToStringWithCulture(Info.FullName)); this.Write(">\r\n"); foreach (var typeArg in Info.GenericTypeParameters.Where(x => x.HasConstraints)) { @@ -53,24 +53,22 @@ public virtual string TransformText() this.Write("();\r\n"); } } - this.Write("\r\n public void Serialize(ref global::MessagePack.MessagePackWriter writer," + - " "); + this.Write("\r\n public void Serialize(ref MsgPack::MessagePackWriter writer, "); this.Write(this.ToStringHelper.ToStringWithCulture(Info.FullName)); - this.Write(" value, global::MessagePack.MessagePackSerializerOptions options)\r\n {\r\n"); + this.Write(" value, MsgPack::MessagePackSerializerOptions options)\r\n {\r\n"); if (Info.IsClass) { this.Write(" if (value == null)\r\n {\r\n writer.WriteNil();" + "\r\n return;\r\n }\r\n\r\n"); } if (isFormatterResolverNecessary) { - this.Write(" global::MessagePack.IFormatterResolver formatterResolver = options.Re" + - "solver;\r\n"); + this.Write(" MsgPack::IFormatterResolver formatterResolver = options.Resolver;\r\n"); } if (Info.HasIMessagePackSerializationCallbackReceiver) { if (Info.NeedsCastOnBefore) { - this.Write(" ((global::MessagePack.IMessagePackSerializationCallbackReceiver)value" + - ").OnBeforeSerialize();\r\n"); + this.Write(" ((MsgPack::IMessagePackSerializationCallbackReceiver)value).OnBeforeS" + + "erialize();\r\n"); } else { this.Write(" value.OnBeforeSerialize();\r\n"); } @@ -90,9 +88,9 @@ public virtual string TransformText() } this.Write(" }\r\n\r\n public "); this.Write(this.ToStringHelper.ToStringWithCulture(Info.FullName)); - this.Write(" Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePac" + - "k.MessagePackSerializerOptions options)\r\n {\r\n if (reader.TryRe" + - "adNil())\r\n {\r\n"); + this.Write(" Deserialize(ref MsgPack::MessagePackReader reader, MsgPack::MessagePackSerialize" + + "rOptions options)\r\n {\r\n if (reader.TryReadNil())\r\n " + + "{\r\n"); if (Info.IsClass) { this.Write(" return null;\r\n"); } else { @@ -107,8 +105,7 @@ public virtual string TransformText() } else { this.Write(" options.Security.DepthStep(ref reader);\r\n"); if (isFormatterResolverNecessary) { - this.Write(" global::MessagePack.IFormatterResolver formatterResolver = options.Re" + - "solver;\r\n"); + this.Write(" MsgPack::IFormatterResolver formatterResolver = options.Resolver;\r\n"); } this.Write(" var length = reader.ReadArrayHeader();\r\n"); var canOverwrite = Info.ConstructorParameters.Length == 0; @@ -180,8 +177,8 @@ public virtual string TransformText() if (Info.HasIMessagePackSerializationCallbackReceiver) { if (Info.NeedsCastOnAfter) { - this.Write(" ((global::MessagePack.IMessagePackSerializationCallbackReceiver)____r" + - "esult).OnAfterDeserialize();\r\n"); + this.Write(" ((MsgPack::IMessagePackSerializationCallbackReceiver)____result).OnAf" + + "terDeserialize();\r\n"); } else { this.Write(" ____result.OnAfterDeserialize();\r\n"); } diff --git a/src/MessagePack.Generator/Transforms/FormatterTemplate.tt b/src/MessagePack.Generator/Transforms/FormatterTemplate.tt index 010299ce6..9e903d83e 100644 --- a/src/MessagePack.Generator/Transforms/FormatterTemplate.tt +++ b/src/MessagePack.Generator/Transforms/FormatterTemplate.tt @@ -6,8 +6,10 @@ namespace <#= Namespace #> { + using MsgPack = global::MessagePack; + <# bool isFormatterResolverNecessary = ShouldUseFormatterResolverHelper.ShouldUseFormatterResolver(Info.Members);#> - public sealed class <#= Info.FormatterNameWithoutNamespace #> : global::MessagePack.Formatters.IMessagePackFormatter<<#= Info.FullName #>> + public sealed class <#= Info.FormatterNameWithoutNamespace #> : MsgPack::Formatters.IMessagePackFormatter<<#= Info.FullName #>> <# foreach (var typeArg in Info.GenericTypeParameters.Where(x => x.HasConstraints)) { #> where <#= typeArg.Name #> : <#= typeArg.Constraints #> <# } #> @@ -18,7 +20,7 @@ namespace <#= Namespace #> <# } #> <# } #> - public void Serialize(ref global::MessagePack.MessagePackWriter writer, <#= Info.FullName #> value, global::MessagePack.MessagePackSerializerOptions options) + public void Serialize(ref MsgPack::MessagePackWriter writer, <#= Info.FullName #> value, MsgPack::MessagePackSerializerOptions options) { <# if (Info.IsClass) { #> if (value == null) @@ -30,12 +32,12 @@ namespace <#= Namespace #> <# } if (isFormatterResolverNecessary) { #> - global::MessagePack.IFormatterResolver formatterResolver = options.Resolver; + MsgPack::IFormatterResolver formatterResolver = options.Resolver; <# } if (Info.HasIMessagePackSerializationCallbackReceiver) { if (Info.NeedsCastOnBefore) { #> - ((global::MessagePack.IMessagePackSerializationCallbackReceiver)value).OnBeforeSerialize(); + ((MsgPack::IMessagePackSerializationCallbackReceiver)value).OnBeforeSerialize(); <# } else { #> value.OnBeforeSerialize(); <# } #> @@ -51,7 +53,7 @@ namespace <#= Namespace #> <# } #> } - public <#= Info.FullName #> Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) + public <#= Info.FullName #> Deserialize(ref MsgPack::MessagePackReader reader, MsgPack::MessagePackSerializerOptions options) { if (reader.TryReadNil()) { @@ -68,7 +70,7 @@ namespace <#= Namespace #> <# } else { #> options.Security.DepthStep(ref reader); <# if (isFormatterResolverNecessary) { #> - global::MessagePack.IFormatterResolver formatterResolver = options.Resolver; + MsgPack::IFormatterResolver formatterResolver = options.Resolver; <# } #> var length = reader.ReadArrayHeader(); <# var canOverwrite = Info.ConstructorParameters.Length == 0; @@ -126,7 +128,7 @@ namespace <#= Namespace #> if (Info.HasIMessagePackSerializationCallbackReceiver) { if (Info.NeedsCastOnAfter) { #> - ((global::MessagePack.IMessagePackSerializationCallbackReceiver)____result).OnAfterDeserialize(); + ((MsgPack::IMessagePackSerializationCallbackReceiver)____result).OnAfterDeserialize(); <# } else { #> ____result.OnAfterDeserialize(); <# } #> diff --git a/src/MessagePack.Generator/Transforms/ResolverTemplate.cs b/src/MessagePack.Generator/Transforms/ResolverTemplate.cs index 8896146cc..42b37fac3 100644 --- a/src/MessagePack.Generator/Transforms/ResolverTemplate.cs +++ b/src/MessagePack.Generator/Transforms/ResolverTemplate.cs @@ -27,29 +27,27 @@ public virtual string TransformText() { this.Write("\r\nnamespace "); this.Write(this.ToStringHelper.ToStringWithCulture(ResolverNamespace)); - this.Write("\r\n{\r\n public class "); + this.Write("\r\n{\r\n using MsgPack = global::MessagePack;\r\n\r\n public class "); this.Write(this.ToStringHelper.ToStringWithCulture(ResolverName)); - this.Write(" : global::MessagePack.IFormatterResolver\r\n {\r\n public static readonly " + - "global::MessagePack.IFormatterResolver Instance = new "); + this.Write(" : MsgPack::IFormatterResolver\r\n {\r\n public static readonly MsgPack::IF" + + "ormatterResolver Instance = new "); this.Write(this.ToStringHelper.ToStringWithCulture(ResolverName)); - this.Write(@"(); - - public static readonly global::MessagePack.IFormatterResolver InstanceWithStandardAotResolver = global::MessagePack.Resolvers.CompositeResolver.Create(Instance, global::MessagePack.Resolvers.StandardAotResolver.Instance); - - private "); + this.Write("();\r\n\r\n public static readonly MsgPack::IFormatterResolver InstanceWithSta" + + "ndardAotResolver = MsgPack::Resolvers.CompositeResolver.Create(Instance, MsgPack" + + "::Resolvers.StandardAotResolver.Instance);\r\n\r\n private "); this.Write(this.ToStringHelper.ToStringWithCulture(ResolverName)); this.Write(@"() { } - public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() + public MsgPack::Formatters.IMessagePackFormatter GetFormatter() { return FormatterCache.Formatter; } private static class FormatterCache { - internal static readonly global::MessagePack.Formatters.IMessagePackFormatter Formatter; + internal static readonly MsgPack::Formatters.IMessagePackFormatter Formatter; static FormatterCache() { @@ -58,7 +56,7 @@ static FormatterCache() this.Write(@"GetFormatterHelper.GetFormatter(typeof(T)); if (f != null) { - Formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; + Formatter = (MsgPack::Formatters.IMessagePackFormatter)f; } } } diff --git a/src/MessagePack.Generator/Transforms/ResolverTemplate.tt b/src/MessagePack.Generator/Transforms/ResolverTemplate.tt index fa1608ead..1758fa076 100644 --- a/src/MessagePack.Generator/Transforms/ResolverTemplate.tt +++ b/src/MessagePack.Generator/Transforms/ResolverTemplate.tt @@ -6,31 +6,33 @@ namespace <#= ResolverNamespace #> { - public class <#= ResolverName #> : global::MessagePack.IFormatterResolver + using MsgPack = global::MessagePack; + + public class <#= ResolverName #> : MsgPack::IFormatterResolver { - public static readonly global::MessagePack.IFormatterResolver Instance = new <#= ResolverName #>(); + public static readonly MsgPack::IFormatterResolver Instance = new <#= ResolverName #>(); - public static readonly global::MessagePack.IFormatterResolver InstanceWithStandardAotResolver = global::MessagePack.Resolvers.CompositeResolver.Create(Instance, global::MessagePack.Resolvers.StandardAotResolver.Instance); + public static readonly MsgPack::IFormatterResolver InstanceWithStandardAotResolver = MsgPack::Resolvers.CompositeResolver.Create(Instance, MsgPack::Resolvers.StandardAotResolver.Instance); private <#= ResolverName #>() { } - public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() + public MsgPack::Formatters.IMessagePackFormatter GetFormatter() { return FormatterCache.Formatter; } private static class FormatterCache { - internal static readonly global::MessagePack.Formatters.IMessagePackFormatter Formatter; + internal static readonly MsgPack::Formatters.IMessagePackFormatter Formatter; static FormatterCache() { var f = <#= ResolverName #>GetFormatterHelper.GetFormatter(typeof(T)); if (f != null) { - Formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; + Formatter = (MsgPack::Formatters.IMessagePackFormatter)f; } } } diff --git a/src/MessagePack.Generator/Transforms/UnionTemplate.cs b/src/MessagePack.Generator/Transforms/UnionTemplate.cs index 88a550664..ba999bef8 100644 --- a/src/MessagePack.Generator/Transforms/UnionTemplate.cs +++ b/src/MessagePack.Generator/Transforms/UnionTemplate.cs @@ -27,9 +27,9 @@ public virtual string TransformText() { this.Write("\r\nnamespace "); this.Write(this.ToStringHelper.ToStringWithCulture(Namespace)); - this.Write("\r\n{\r\n public sealed class "); + this.Write("\r\n{\r\n using MsgPack = global::MessagePack;\r\n\r\n public sealed class "); this.Write(this.ToStringHelper.ToStringWithCulture(Info.Name)); - this.Write("Formatter : global::MessagePack.Formatters.IMessagePackFormatter<"); + this.Write("Formatter : MsgPack::Formatters.IMessagePackFormatter<"); this.Write(this.ToStringHelper.ToStringWithCulture(Info.FullName)); this.Write(@"> { @@ -42,8 +42,7 @@ public virtual string TransformText() ".Collections.Generic.Dictionary>("); this.Write(this.ToStringHelper.ToStringWithCulture(Info.SubTypes.Length)); - this.Write(", global::MessagePack.Internal.RuntimeTypeHandleEqualityComparer.Default)\r\n " + - " {\r\n"); + this.Write(", MsgPack::Internal.RuntimeTypeHandleEqualityComparer.Default)\r\n {\r\n"); for(var i = 0; i < Info.SubTypes.Length; i++) { var item = Info.SubTypes[i]; this.Write(" { typeof("); this.Write(this.ToStringHelper.ToStringWithCulture(item.Type)); @@ -64,10 +63,10 @@ public virtual string TransformText() this.Write(this.ToStringHelper.ToStringWithCulture(i)); this.Write(" },\r\n"); } - this.Write(" };\r\n }\r\n\r\n public void Serialize(ref global::MessagePac" + - "k.MessagePackWriter writer, "); + this.Write(" };\r\n }\r\n\r\n public void Serialize(ref MsgPack::MessagePa" + + "ckWriter writer, "); this.Write(this.ToStringHelper.ToStringWithCulture(Info.FullName)); - this.Write(@" value, global::MessagePack.MessagePackSerializerOptions options) + this.Write(@" value, MsgPack::MessagePackSerializerOptions options) { global::System.Collections.Generic.KeyValuePair keyValuePair; if (value != null && this.typeToKeyAndJumpMap.TryGetValue(value.GetType().TypeHandle, out keyValuePair)) @@ -80,8 +79,8 @@ public virtual string TransformText() for(var i = 0; i < Info.SubTypes.Length; i++) { var item = Info.SubTypes[i]; this.Write(" case "); this.Write(this.ToStringHelper.ToStringWithCulture(i)); - this.Write(":\r\n global::MessagePack.FormatterResolverExtensions.GetFor" + - "matterWithVerify<"); + this.Write(":\r\n MsgPack::FormatterResolverExtensions.GetFormatterWithV" + + "erify<"); this.Write(this.ToStringHelper.ToStringWithCulture(item.Type)); this.Write(">(options.Resolver).Serialize(ref writer, ("); this.Write(this.ToStringHelper.ToStringWithCulture(item.Type)); @@ -91,7 +90,7 @@ public virtual string TransformText() "\r\n return;\r\n }\r\n\r\n writer.WriteNil();\r\n " + " }\r\n\r\n public "); this.Write(this.ToStringHelper.ToStringWithCulture(Info.FullName)); - this.Write(@" Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) + this.Write(@" Deserialize(ref MsgPack::MessagePackReader reader, MsgPack::MessagePackSerializerOptions options) { if (reader.TryReadNil()) { @@ -113,7 +112,7 @@ public virtual string TransformText() this.Write(this.ToStringHelper.ToStringWithCulture(i)); this.Write(":\r\n result = ("); this.Write(this.ToStringHelper.ToStringWithCulture(Info.FullName)); - this.Write(")global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<"); + this.Write(")MsgPack::FormatterResolverExtensions.GetFormatterWithVerify<"); this.Write(this.ToStringHelper.ToStringWithCulture(item.Type)); this.Write(">(options.Resolver).Deserialize(ref reader, options);\r\n break;" + "\r\n"); diff --git a/src/MessagePack.Generator/Transforms/UnionTemplate.tt b/src/MessagePack.Generator/Transforms/UnionTemplate.tt index 402b00481..b3b0ccf49 100644 --- a/src/MessagePack.Generator/Transforms/UnionTemplate.tt +++ b/src/MessagePack.Generator/Transforms/UnionTemplate.tt @@ -6,14 +6,16 @@ namespace <#= Namespace #> { - public sealed class <#= Info.Name #>Formatter : global::MessagePack.Formatters.IMessagePackFormatter<<#= Info.FullName #>> + using MsgPack = global::MessagePack; + + public sealed class <#= Info.Name #>Formatter : MsgPack::Formatters.IMessagePackFormatter<<#= Info.FullName #>> { private readonly global::System.Collections.Generic.Dictionary> typeToKeyAndJumpMap; private readonly global::System.Collections.Generic.Dictionary keyToJumpMap; public <#= Info.Name #>Formatter() { - this.typeToKeyAndJumpMap = new global::System.Collections.Generic.Dictionary>(<#= Info.SubTypes.Length #>, global::MessagePack.Internal.RuntimeTypeHandleEqualityComparer.Default) + this.typeToKeyAndJumpMap = new global::System.Collections.Generic.Dictionary>(<#= Info.SubTypes.Length #>, MsgPack::Internal.RuntimeTypeHandleEqualityComparer.Default) { <# for(var i = 0; i < Info.SubTypes.Length; i++) { var item = Info.SubTypes[i]; #> { typeof(<#= item.Type #>).TypeHandle, new global::System.Collections.Generic.KeyValuePair(<#= item.Key #>, <#= i #>) }, @@ -27,7 +29,7 @@ namespace <#= Namespace #> }; } - public void Serialize(ref global::MessagePack.MessagePackWriter writer, <#= Info.FullName #> value, global::MessagePack.MessagePackSerializerOptions options) + public void Serialize(ref MsgPack::MessagePackWriter writer, <#= Info.FullName #> value, MsgPack::MessagePackSerializerOptions options) { global::System.Collections.Generic.KeyValuePair keyValuePair; if (value != null && this.typeToKeyAndJumpMap.TryGetValue(value.GetType().TypeHandle, out keyValuePair)) @@ -38,7 +40,7 @@ namespace <#= Namespace #> { <# for(var i = 0; i < Info.SubTypes.Length; i++) { var item = Info.SubTypes[i]; #> case <#= i #>: - global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<<#= item.Type #>>(options.Resolver).Serialize(ref writer, (<#= item.Type #>)value, options); + MsgPack::FormatterResolverExtensions.GetFormatterWithVerify<<#= item.Type #>>(options.Resolver).Serialize(ref writer, (<#= item.Type #>)value, options); break; <# } #> default: @@ -51,7 +53,7 @@ namespace <#= Namespace #> writer.WriteNil(); } - public <#= Info.FullName #> Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) + public <#= Info.FullName #> Deserialize(ref MsgPack::MessagePackReader reader, MsgPack::MessagePackSerializerOptions options) { if (reader.TryReadNil()) { @@ -76,7 +78,7 @@ namespace <#= Namespace #> { <# for(var i = 0; i < Info.SubTypes.Length; i++) { var item = Info.SubTypes[i]; #> case <#= i #>: - result = (<#= Info.FullName #>)global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<<#= item.Type #>>(options.Resolver).Deserialize(ref reader, options); + result = (<#= Info.FullName #>)MsgPack::FormatterResolverExtensions.GetFormatterWithVerify<<#= item.Type #>>(options.Resolver).Deserialize(ref reader, options); break; <# } #> default: diff --git a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(Namespace)/MessagePack.Formatter.MyTestNamespace.MyMessagePackObject.g.cs b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(Namespace)/MessagePack.Formatter.MyTestNamespace.MyMessagePackObject.g.cs index 4dcf77988..9d4b4eb4a 100644 --- a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(Namespace)/MessagePack.Formatter.MyTestNamespace.MyMessagePackObject.g.cs +++ b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(Namespace)/MessagePack.Formatter.MyTestNamespace.MyMessagePackObject.g.cs @@ -4,10 +4,12 @@ namespace MessagePack.Formatters.MyTestNamespace { - public sealed class MyMessagePackObjectFormatter : global::MessagePack.Formatters.IMessagePackFormatter + using MsgPack = global::MessagePack; + + public sealed class MyMessagePackObjectFormatter : MsgPack::Formatters.IMessagePackFormatter { - public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::MyTestNamespace.MyMessagePackObject value, global::MessagePack.MessagePackSerializerOptions options) + public void Serialize(ref MsgPack::MessagePackWriter writer, global::MyTestNamespace.MyMessagePackObject value, MsgPack::MessagePackSerializerOptions options) { if (value == null) { @@ -15,12 +17,12 @@ public void Serialize(ref global::MessagePack.MessagePackWriter writer, global:: return; } - global::MessagePack.IFormatterResolver formatterResolver = options.Resolver; + MsgPack::IFormatterResolver formatterResolver = options.Resolver; writer.WriteArrayHeader(1); global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Serialize(ref writer, value.EnumValue, options); } - public global::MyTestNamespace.MyMessagePackObject Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) + public global::MyTestNamespace.MyMessagePackObject Deserialize(ref MsgPack::MessagePackReader reader, MsgPack::MessagePackSerializerOptions options) { if (reader.TryReadNil()) { @@ -28,7 +30,7 @@ public void Serialize(ref global::MessagePack.MessagePackWriter writer, global:: } options.Security.DepthStep(ref reader); - global::MessagePack.IFormatterResolver formatterResolver = options.Resolver; + MsgPack::IFormatterResolver formatterResolver = options.Resolver; var length = reader.ReadArrayHeader(); var ____result = new global::MyTestNamespace.MyMessagePackObject(); diff --git a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(Namespace)/MessagePack.GeneratedResolver.g.cs b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(Namespace)/MessagePack.GeneratedResolver.g.cs index bc9584261..87c964a55 100644 --- a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(Namespace)/MessagePack.GeneratedResolver.g.cs +++ b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(Namespace)/MessagePack.GeneratedResolver.g.cs @@ -4,31 +4,33 @@ namespace MessagePack.Resolvers { - public class GeneratedResolver : global::MessagePack.IFormatterResolver + using MsgPack = global::MessagePack; + + public class GeneratedResolver : MsgPack::IFormatterResolver { - public static readonly global::MessagePack.IFormatterResolver Instance = new GeneratedResolver(); + public static readonly MsgPack::IFormatterResolver Instance = new GeneratedResolver(); - public static readonly global::MessagePack.IFormatterResolver InstanceWithStandardAotResolver = global::MessagePack.Resolvers.CompositeResolver.Create(Instance, global::MessagePack.Resolvers.StandardAotResolver.Instance); + public static readonly MsgPack::IFormatterResolver InstanceWithStandardAotResolver = MsgPack::Resolvers.CompositeResolver.Create(Instance, MsgPack::Resolvers.StandardAotResolver.Instance); private GeneratedResolver() { } - public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() + public MsgPack::Formatters.IMessagePackFormatter GetFormatter() { return FormatterCache.Formatter; } private static class FormatterCache { - internal static readonly global::MessagePack.Formatters.IMessagePackFormatter Formatter; + internal static readonly MsgPack::Formatters.IMessagePackFormatter Formatter; static FormatterCache() { var f = GeneratedResolverGetFormatterHelper.GetFormatter(typeof(T)); if (f != null) { - Formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; + Formatter = (MsgPack::Formatters.IMessagePackFormatter)f; } } } diff --git a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(NestingClass)/MessagePack.Formatter.ContainingClass_MyMessagePackObject.g.cs b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(NestingClass)/MessagePack.Formatter.ContainingClass_MyMessagePackObject.g.cs index 3d5c9d4c8..9ef1df1fa 100644 --- a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(NestingClass)/MessagePack.Formatter.ContainingClass_MyMessagePackObject.g.cs +++ b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(NestingClass)/MessagePack.Formatter.ContainingClass_MyMessagePackObject.g.cs @@ -4,10 +4,12 @@ namespace MessagePack.Formatters { - public sealed class ContainingClass_MyMessagePackObjectFormatter : global::MessagePack.Formatters.IMessagePackFormatter + using MsgPack = global::MessagePack; + + public sealed class ContainingClass_MyMessagePackObjectFormatter : MsgPack::Formatters.IMessagePackFormatter { - public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::ContainingClass.MyMessagePackObject value, global::MessagePack.MessagePackSerializerOptions options) + public void Serialize(ref MsgPack::MessagePackWriter writer, global::ContainingClass.MyMessagePackObject value, MsgPack::MessagePackSerializerOptions options) { if (value == null) { @@ -15,12 +17,12 @@ public void Serialize(ref global::MessagePack.MessagePackWriter writer, global:: return; } - global::MessagePack.IFormatterResolver formatterResolver = options.Resolver; + MsgPack::IFormatterResolver formatterResolver = options.Resolver; writer.WriteArrayHeader(1); global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Serialize(ref writer, value.EnumValue, options); } - public global::ContainingClass.MyMessagePackObject Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) + public global::ContainingClass.MyMessagePackObject Deserialize(ref MsgPack::MessagePackReader reader, MsgPack::MessagePackSerializerOptions options) { if (reader.TryReadNil()) { @@ -28,7 +30,7 @@ public void Serialize(ref global::MessagePack.MessagePackWriter writer, global:: } options.Security.DepthStep(ref reader); - global::MessagePack.IFormatterResolver formatterResolver = options.Resolver; + MsgPack::IFormatterResolver formatterResolver = options.Resolver; var length = reader.ReadArrayHeader(); var ____result = new global::ContainingClass.MyMessagePackObject(); diff --git a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(NestingClass)/MessagePack.GeneratedResolver.g.cs b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(NestingClass)/MessagePack.GeneratedResolver.g.cs index cc8bd0ad1..7b35af62c 100644 --- a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(NestingClass)/MessagePack.GeneratedResolver.g.cs +++ b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(NestingClass)/MessagePack.GeneratedResolver.g.cs @@ -4,31 +4,33 @@ namespace MessagePack.Resolvers { - public class GeneratedResolver : global::MessagePack.IFormatterResolver + using MsgPack = global::MessagePack; + + public class GeneratedResolver : MsgPack::IFormatterResolver { - public static readonly global::MessagePack.IFormatterResolver Instance = new GeneratedResolver(); + public static readonly MsgPack::IFormatterResolver Instance = new GeneratedResolver(); - public static readonly global::MessagePack.IFormatterResolver InstanceWithStandardAotResolver = global::MessagePack.Resolvers.CompositeResolver.Create(Instance, global::MessagePack.Resolvers.StandardAotResolver.Instance); + public static readonly MsgPack::IFormatterResolver InstanceWithStandardAotResolver = MsgPack::Resolvers.CompositeResolver.Create(Instance, MsgPack::Resolvers.StandardAotResolver.Instance); private GeneratedResolver() { } - public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() + public MsgPack::Formatters.IMessagePackFormatter GetFormatter() { return FormatterCache.Formatter; } private static class FormatterCache { - internal static readonly global::MessagePack.Formatters.IMessagePackFormatter Formatter; + internal static readonly MsgPack::Formatters.IMessagePackFormatter Formatter; static FormatterCache() { var f = GeneratedResolverGetFormatterHelper.GetFormatter(typeof(T)); if (f != null) { - Formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; + Formatter = (MsgPack::Formatters.IMessagePackFormatter)f; } } } diff --git a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(None)/MessagePack.Formatter.MyMessagePackObject.g.cs b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(None)/MessagePack.Formatter.MyMessagePackObject.g.cs index 3f5cf5e30..1e9c6bad9 100644 --- a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(None)/MessagePack.Formatter.MyMessagePackObject.g.cs +++ b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(None)/MessagePack.Formatter.MyMessagePackObject.g.cs @@ -4,10 +4,12 @@ namespace MessagePack.Formatters { - public sealed class MyMessagePackObjectFormatter : global::MessagePack.Formatters.IMessagePackFormatter + using MsgPack = global::MessagePack; + + public sealed class MyMessagePackObjectFormatter : MsgPack::Formatters.IMessagePackFormatter { - public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::MyMessagePackObject value, global::MessagePack.MessagePackSerializerOptions options) + public void Serialize(ref MsgPack::MessagePackWriter writer, global::MyMessagePackObject value, MsgPack::MessagePackSerializerOptions options) { if (value == null) { @@ -15,12 +17,12 @@ public void Serialize(ref global::MessagePack.MessagePackWriter writer, global:: return; } - global::MessagePack.IFormatterResolver formatterResolver = options.Resolver; + MsgPack::IFormatterResolver formatterResolver = options.Resolver; writer.WriteArrayHeader(1); global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Serialize(ref writer, value.EnumValue, options); } - public global::MyMessagePackObject Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) + public global::MyMessagePackObject Deserialize(ref MsgPack::MessagePackReader reader, MsgPack::MessagePackSerializerOptions options) { if (reader.TryReadNil()) { @@ -28,7 +30,7 @@ public void Serialize(ref global::MessagePack.MessagePackWriter writer, global:: } options.Security.DepthStep(ref reader); - global::MessagePack.IFormatterResolver formatterResolver = options.Resolver; + MsgPack::IFormatterResolver formatterResolver = options.Resolver; var length = reader.ReadArrayHeader(); var ____result = new global::MyMessagePackObject(); diff --git a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(None)/MessagePack.GeneratedResolver.g.cs b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(None)/MessagePack.GeneratedResolver.g.cs index e7eb631de..d29d2c837 100644 --- a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(None)/MessagePack.GeneratedResolver.g.cs +++ b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(None)/MessagePack.GeneratedResolver.g.cs @@ -4,31 +4,33 @@ namespace MessagePack.Resolvers { - public class GeneratedResolver : global::MessagePack.IFormatterResolver + using MsgPack = global::MessagePack; + + public class GeneratedResolver : MsgPack::IFormatterResolver { - public static readonly global::MessagePack.IFormatterResolver Instance = new GeneratedResolver(); + public static readonly MsgPack::IFormatterResolver Instance = new GeneratedResolver(); - public static readonly global::MessagePack.IFormatterResolver InstanceWithStandardAotResolver = global::MessagePack.Resolvers.CompositeResolver.Create(Instance, global::MessagePack.Resolvers.StandardAotResolver.Instance); + public static readonly MsgPack::IFormatterResolver InstanceWithStandardAotResolver = MsgPack::Resolvers.CompositeResolver.Create(Instance, MsgPack::Resolvers.StandardAotResolver.Instance); private GeneratedResolver() { } - public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() + public MsgPack::Formatters.IMessagePackFormatter GetFormatter() { return FormatterCache.Formatter; } private static class FormatterCache { - internal static readonly global::MessagePack.Formatters.IMessagePackFormatter Formatter; + internal static readonly MsgPack::Formatters.IMessagePackFormatter Formatter; static FormatterCache() { var f = GeneratedResolverGetFormatterHelper.GetFormatter(typeof(T)); if (f != null) { - Formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; + Formatter = (MsgPack::Formatters.IMessagePackFormatter)f; } } } diff --git a/tests/MessagePack.Generator.Tests/Resources/TwoTypes/MessagePack.Formatter.Object1.g.cs b/tests/MessagePack.Generator.Tests/Resources/TwoTypes/MessagePack.Formatter.Object1.g.cs index cedff3969..7228bb8ac 100644 --- a/tests/MessagePack.Generator.Tests/Resources/TwoTypes/MessagePack.Formatter.Object1.g.cs +++ b/tests/MessagePack.Generator.Tests/Resources/TwoTypes/MessagePack.Formatter.Object1.g.cs @@ -4,10 +4,12 @@ namespace MessagePack.Formatters { - public sealed class Object1Formatter : global::MessagePack.Formatters.IMessagePackFormatter + using MsgPack = global::MessagePack; + + public sealed class Object1Formatter : MsgPack::Formatters.IMessagePackFormatter { - public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::Object1 value, global::MessagePack.MessagePackSerializerOptions options) + public void Serialize(ref MsgPack::MessagePackWriter writer, global::Object1 value, MsgPack::MessagePackSerializerOptions options) { if (value == null) { @@ -18,7 +20,7 @@ public void Serialize(ref global::MessagePack.MessagePackWriter writer, global:: writer.WriteArrayHeader(0); } - public global::Object1 Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) + public global::Object1 Deserialize(ref MsgPack::MessagePackReader reader, MsgPack::MessagePackSerializerOptions options) { if (reader.TryReadNil()) { diff --git a/tests/MessagePack.Generator.Tests/Resources/TwoTypes/MessagePack.Formatter.Object2.g.cs b/tests/MessagePack.Generator.Tests/Resources/TwoTypes/MessagePack.Formatter.Object2.g.cs index d169ed4be..f59226c33 100644 --- a/tests/MessagePack.Generator.Tests/Resources/TwoTypes/MessagePack.Formatter.Object2.g.cs +++ b/tests/MessagePack.Generator.Tests/Resources/TwoTypes/MessagePack.Formatter.Object2.g.cs @@ -4,10 +4,12 @@ namespace MessagePack.Formatters { - public sealed class Object2Formatter : global::MessagePack.Formatters.IMessagePackFormatter + using MsgPack = global::MessagePack; + + public sealed class Object2Formatter : MsgPack::Formatters.IMessagePackFormatter { - public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::Object2 value, global::MessagePack.MessagePackSerializerOptions options) + public void Serialize(ref MsgPack::MessagePackWriter writer, global::Object2 value, MsgPack::MessagePackSerializerOptions options) { if (value == null) { @@ -18,7 +20,7 @@ public void Serialize(ref global::MessagePack.MessagePackWriter writer, global:: writer.WriteArrayHeader(0); } - public global::Object2 Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) + public global::Object2 Deserialize(ref MsgPack::MessagePackReader reader, MsgPack::MessagePackSerializerOptions options) { if (reader.TryReadNil()) { diff --git a/tests/MessagePack.Generator.Tests/Resources/TwoTypes/MessagePack.GeneratedResolver.g.cs b/tests/MessagePack.Generator.Tests/Resources/TwoTypes/MessagePack.GeneratedResolver.g.cs index 9544a4a33..63c168d62 100644 --- a/tests/MessagePack.Generator.Tests/Resources/TwoTypes/MessagePack.GeneratedResolver.g.cs +++ b/tests/MessagePack.Generator.Tests/Resources/TwoTypes/MessagePack.GeneratedResolver.g.cs @@ -4,31 +4,33 @@ namespace MessagePack.Resolvers { - public class GeneratedResolver : global::MessagePack.IFormatterResolver + using MsgPack = global::MessagePack; + + public class GeneratedResolver : MsgPack::IFormatterResolver { - public static readonly global::MessagePack.IFormatterResolver Instance = new GeneratedResolver(); + public static readonly MsgPack::IFormatterResolver Instance = new GeneratedResolver(); - public static readonly global::MessagePack.IFormatterResolver InstanceWithStandardAotResolver = global::MessagePack.Resolvers.CompositeResolver.Create(Instance, global::MessagePack.Resolvers.StandardAotResolver.Instance); + public static readonly MsgPack::IFormatterResolver InstanceWithStandardAotResolver = MsgPack::Resolvers.CompositeResolver.Create(Instance, MsgPack::Resolvers.StandardAotResolver.Instance); private GeneratedResolver() { } - public global::MessagePack.Formatters.IMessagePackFormatter GetFormatter() + public MsgPack::Formatters.IMessagePackFormatter GetFormatter() { return FormatterCache.Formatter; } private static class FormatterCache { - internal static readonly global::MessagePack.Formatters.IMessagePackFormatter Formatter; + internal static readonly MsgPack::Formatters.IMessagePackFormatter Formatter; static FormatterCache() { var f = GeneratedResolverGetFormatterHelper.GetFormatter(typeof(T)); if (f != null) { - Formatter = (global::MessagePack.Formatters.IMessagePackFormatter)f; + Formatter = (MsgPack::Formatters.IMessagePackFormatter)f; } } } From 18e525c610ab9364fbe460dc23ea06469f5b864e Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Thu, 30 Mar 2023 09:07:17 -0600 Subject: [PATCH 050/660] Shorten syntax for casting an enum to its base type --- .../CodeAnalysis/EnumSerializationInfo.cs | 15 ++++++++++++++- ...sagePack.Formatter.MyTestNamespace.MyEnum.g.cs | 2 +- ...agePack.Formatter..ContainingClass_MyEnum.g.cs | 2 +- .../MessagePack.Formatter..MyEnum.g.cs | 2 +- 4 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/MessagePack.Generator/CodeAnalysis/EnumSerializationInfo.cs b/src/MessagePack.Generator/CodeAnalysis/EnumSerializationInfo.cs index 7da292813..9e882eb7b 100644 --- a/src/MessagePack.Generator/CodeAnalysis/EnumSerializationInfo.cs +++ b/src/MessagePack.Generator/CodeAnalysis/EnumSerializationInfo.cs @@ -3,7 +3,20 @@ namespace MessagePack.Generator.CodeAnalysis; -public sealed record EnumSerializationInfo(string? Namespace, string Name, string FullName, string UnderlyingType) : IResolverRegisterInfo +public sealed record EnumSerializationInfo(string? Namespace, string Name, string FullName, string UnderlyingTypeName) : IResolverRegisterInfo { public string FormatterName => CodeAnalysisUtilities.NamespaceAndType(this.Name + "Formatter", this.Namespace); + + public string UnderlyingTypeKeyword => this.UnderlyingTypeName switch + { + "SByte" => "sbyte", + "Byte" => "byte", + "Int16" => "short", + "UInt16" => "ushort", + "Int32" => "int", + "UInt32" => "uint", + "Int64" => "long", + "UInt64" => "ulong", + _ => this.UnderlyingTypeName, + }; } diff --git a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(Namespace)/MessagePack.Formatter.MyTestNamespace.MyEnum.g.cs b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(Namespace)/MessagePack.Formatter.MyTestNamespace.MyEnum.g.cs index 76a2d62e7..cf869a527 100644 --- a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(Namespace)/MessagePack.Formatter.MyTestNamespace.MyEnum.g.cs +++ b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(Namespace)/MessagePack.Formatter.MyTestNamespace.MyEnum.g.cs @@ -10,7 +10,7 @@ public sealed class MyEnumFormatter : MsgPack::Formatters.IMessagePackFormatter< { public void Serialize(ref MsgPack::MessagePackWriter writer, global::MyTestNamespace.MyEnum value, MsgPack::MessagePackSerializerOptions options) { - writer.Write((global::System.Int32)value); + writer.Write((int)value); } public global::MyTestNamespace.MyEnum Deserialize(ref MsgPack::MessagePackReader reader, MsgPack::MessagePackSerializerOptions options) diff --git a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(NestingClass)/MessagePack.Formatter..ContainingClass_MyEnum.g.cs b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(NestingClass)/MessagePack.Formatter..ContainingClass_MyEnum.g.cs index fa50c3ab7..f6a50c11d 100644 --- a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(NestingClass)/MessagePack.Formatter..ContainingClass_MyEnum.g.cs +++ b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(NestingClass)/MessagePack.Formatter..ContainingClass_MyEnum.g.cs @@ -10,7 +10,7 @@ public sealed class ContainingClass_MyEnumFormatter : MsgPack::Formatters.IMessa { public void Serialize(ref MsgPack::MessagePackWriter writer, global::ContainingClass.MyEnum value, MsgPack::MessagePackSerializerOptions options) { - writer.Write((global::System.Int32)value); + writer.Write((int)value); } public global::ContainingClass.MyEnum Deserialize(ref MsgPack::MessagePackReader reader, MsgPack::MessagePackSerializerOptions options) diff --git a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(None)/MessagePack.Formatter..MyEnum.g.cs b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(None)/MessagePack.Formatter..MyEnum.g.cs index 3492f6232..e8fcd435d 100644 --- a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(None)/MessagePack.Formatter..MyEnum.g.cs +++ b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(None)/MessagePack.Formatter..MyEnum.g.cs @@ -10,7 +10,7 @@ public sealed class MyEnumFormatter : MsgPack::Formatters.IMessagePackFormatter< { public void Serialize(ref MsgPack::MessagePackWriter writer, global::MyEnum value, MsgPack::MessagePackSerializerOptions options) { - writer.Write((global::System.Int32)value); + writer.Write((int)value); } public global::MyEnum Deserialize(ref MsgPack::MessagePackReader reader, MsgPack::MessagePackSerializerOptions options) From 2bafc9de6773df10446095f9318df5df79e59080 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Thu, 30 Mar 2023 09:11:30 -0600 Subject: [PATCH 051/660] Use tabs instead of spaces in generated files This makes for shorter strings and thus more performant source generation. --- .../Transforms/.editorconfig | 3 + .../Transforms/EnumTemplate.cs | 17 ++- .../Transforms/EnumTemplate.tt | 24 ++-- .../Transforms/FormatterTemplate.cs | 91 ++++++------ .../Transforms/FormatterTemplate.tt | 120 ++++++++-------- .../Transforms/ResolverTemplate.cs | 82 +++++------ .../Transforms/ResolverTemplate.tt | 98 ++++++------- .../Transforms/UnionTemplate.cs | 96 ++++++------- .../Transforms/UnionTemplate.tt | 130 +++++++++--------- ...Pack.Formatter.MyTestNamespace.MyEnum.g.cs | 24 ++-- ...r.MyTestNamespace.MyMessagePackObject.g.cs | 94 ++++++------- .../MessagePack.GeneratedResolver.g.cs | 102 +++++++------- ...ack.Formatter..ContainingClass_MyEnum.g.cs | 24 ++-- ...r.ContainingClass_MyMessagePackObject.g.cs | 94 ++++++------- .../MessagePack.GeneratedResolver.g.cs | 102 +++++++------- .../MessagePack.Formatter..MyEnum.g.cs | 24 ++-- ...agePack.Formatter.MyMessagePackObject.g.cs | 94 ++++++------- .../MessagePack.GeneratedResolver.g.cs | 102 +++++++------- .../MessagePack.Formatter.Object1.g.cs | 44 +++--- .../MessagePack.Formatter.Object2.g.cs | 44 +++--- .../MessagePack.GeneratedResolver.g.cs | 102 +++++++------- 21 files changed, 742 insertions(+), 769 deletions(-) create mode 100644 src/MessagePack.Generator/Transforms/.editorconfig diff --git a/src/MessagePack.Generator/Transforms/.editorconfig b/src/MessagePack.Generator/Transforms/.editorconfig new file mode 100644 index 000000000..e27bead64 --- /dev/null +++ b/src/MessagePack.Generator/Transforms/.editorconfig @@ -0,0 +1,3 @@ +[*.tt] +indent_size = 4 +indent_style = tab diff --git a/src/MessagePack.Generator/Transforms/EnumTemplate.cs b/src/MessagePack.Generator/Transforms/EnumTemplate.cs index b3250ea2b..8ac950d11 100644 --- a/src/MessagePack.Generator/Transforms/EnumTemplate.cs +++ b/src/MessagePack.Generator/Transforms/EnumTemplate.cs @@ -24,23 +24,22 @@ public virtual string TransformText() { this.Write("\r\nnamespace "); this.Write(this.ToStringHelper.ToStringWithCulture(Namespace)); - this.Write("\r\n{\r\n using MsgPack = global::MessagePack;\r\n\r\n public sealed class "); + this.Write("\r\n{\r\n\tusing MsgPack = global::MessagePack;\r\n\r\n\tpublic sealed class "); this.Write(this.ToStringHelper.ToStringWithCulture(Info.Name)); this.Write("Formatter : MsgPack::Formatters.IMessagePackFormatter<"); this.Write(this.ToStringHelper.ToStringWithCulture(Info.FullName)); - this.Write(">\r\n {\r\n public void Serialize(ref MsgPack::MessagePackWriter writer, "); + this.Write(">\r\n\t{\r\n\t\tpublic void Serialize(ref MsgPack::MessagePackWriter writer, "); this.Write(this.ToStringHelper.ToStringWithCulture(Info.FullName)); - this.Write(" value, MsgPack::MessagePackSerializerOptions options)\r\n {\r\n wr" + - "iter.Write((global::System."); - this.Write(this.ToStringHelper.ToStringWithCulture(Info.UnderlyingType)); - this.Write(")value);\r\n }\r\n\r\n public "); + this.Write(" value, MsgPack::MessagePackSerializerOptions options)\r\n\t\t{\r\n\t\t\twriter.Write(("); + this.Write(this.ToStringHelper.ToStringWithCulture(Info.UnderlyingTypeKeyword)); + this.Write(")value);\r\n\t\t}\r\n\r\n\t\tpublic "); this.Write(this.ToStringHelper.ToStringWithCulture(Info.FullName)); this.Write(" Deserialize(ref MsgPack::MessagePackReader reader, MsgPack::MessagePackSerialize" + - "rOptions options)\r\n {\r\n return ("); + "rOptions options)\r\n\t\t{\r\n\t\t\treturn ("); this.Write(this.ToStringHelper.ToStringWithCulture(Info.FullName)); this.Write(")reader.Read"); - this.Write(this.ToStringHelper.ToStringWithCulture(Info.UnderlyingType)); - this.Write("();\r\n }\r\n }\r\n}\r\n"); + this.Write(this.ToStringHelper.ToStringWithCulture(Info.UnderlyingTypeName)); + this.Write("();\r\n\t\t}\r\n\t}\r\n}\r\n"); return this.GenerationEnvironment.ToString(); } } diff --git a/src/MessagePack.Generator/Transforms/EnumTemplate.tt b/src/MessagePack.Generator/Transforms/EnumTemplate.tt index 775671726..273458fc7 100644 --- a/src/MessagePack.Generator/Transforms/EnumTemplate.tt +++ b/src/MessagePack.Generator/Transforms/EnumTemplate.tt @@ -3,18 +3,18 @@ namespace <#= Namespace #> { - using MsgPack = global::MessagePack; + using MsgPack = global::MessagePack; - public sealed class <#= Info.Name #>Formatter : MsgPack::Formatters.IMessagePackFormatter<<#= Info.FullName #>> - { - public void Serialize(ref MsgPack::MessagePackWriter writer, <#= Info.FullName #> value, MsgPack::MessagePackSerializerOptions options) - { - writer.Write((global::System.<#= Info.UnderlyingType #>)value); - } + public sealed class <#= Info.Name #>Formatter : MsgPack::Formatters.IMessagePackFormatter<<#= Info.FullName #>> + { + public void Serialize(ref MsgPack::MessagePackWriter writer, <#= Info.FullName #> value, MsgPack::MessagePackSerializerOptions options) + { + writer.Write((<#= Info.UnderlyingTypeKeyword #>)value); + } - public <#= Info.FullName #> Deserialize(ref MsgPack::MessagePackReader reader, MsgPack::MessagePackSerializerOptions options) - { - return (<#= Info.FullName #>)reader.Read<#= Info.UnderlyingType #>(); - } - } + public <#= Info.FullName #> Deserialize(ref MsgPack::MessagePackReader reader, MsgPack::MessagePackSerializerOptions options) + { + return (<#= Info.FullName #>)reader.Read<#= Info.UnderlyingTypeName #>(); + } + } } diff --git a/src/MessagePack.Generator/Transforms/FormatterTemplate.cs b/src/MessagePack.Generator/Transforms/FormatterTemplate.cs index 76ae6db56..bbfade7fd 100644 --- a/src/MessagePack.Generator/Transforms/FormatterTemplate.cs +++ b/src/MessagePack.Generator/Transforms/FormatterTemplate.cs @@ -27,24 +27,24 @@ public virtual string TransformText() { this.Write("\r\nnamespace "); this.Write(this.ToStringHelper.ToStringWithCulture(Namespace)); - this.Write("\r\n{\r\n using MsgPack = global::MessagePack;\r\n\r\n"); + this.Write("\r\n{\r\n\tusing MsgPack = global::MessagePack;\r\n\r\n"); bool isFormatterResolverNecessary = ShouldUseFormatterResolverHelper.ShouldUseFormatterResolver(Info.Members); - this.Write(" public sealed class "); + this.Write("\tpublic sealed class "); this.Write(this.ToStringHelper.ToStringWithCulture(Info.FormatterNameWithoutNamespace)); this.Write(" : MsgPack::Formatters.IMessagePackFormatter<"); this.Write(this.ToStringHelper.ToStringWithCulture(Info.FullName)); this.Write(">\r\n"); foreach (var typeArg in Info.GenericTypeParameters.Where(x => x.HasConstraints)) { - this.Write(" where "); + this.Write("\t\twhere "); this.Write(this.ToStringHelper.ToStringWithCulture(typeArg.Name)); this.Write(" : "); this.Write(this.ToStringHelper.ToStringWithCulture(typeArg.Constraints)); this.Write("\r\n"); } - this.Write(" {\r\n"); + this.Write("\t{\r\n"); foreach (var item in Info.Members) { if (item.CustomFormatterTypeName != null) { - this.Write(" private readonly "); + this.Write("\t\tprivate readonly "); this.Write(this.ToStringHelper.ToStringWithCulture(item.CustomFormatterTypeName)); this.Write(" __"); this.Write(this.ToStringHelper.ToStringWithCulture(item.Name)); @@ -53,107 +53,103 @@ public virtual string TransformText() this.Write("();\r\n"); } } - this.Write("\r\n public void Serialize(ref MsgPack::MessagePackWriter writer, "); + this.Write("\r\n\t\tpublic void Serialize(ref MsgPack::MessagePackWriter writer, "); this.Write(this.ToStringHelper.ToStringWithCulture(Info.FullName)); - this.Write(" value, MsgPack::MessagePackSerializerOptions options)\r\n {\r\n"); + this.Write(" value, MsgPack::MessagePackSerializerOptions options)\r\n\t\t{\r\n"); if (Info.IsClass) { - this.Write(" if (value == null)\r\n {\r\n writer.WriteNil();" + - "\r\n return;\r\n }\r\n\r\n"); + this.Write("\t\t\tif (value == null)\r\n\t\t\t{\r\n\t\t\t\twriter.WriteNil();\r\n\t\t\t\treturn;\r\n\t\t\t}\r\n\r\n"); } if (isFormatterResolverNecessary) { - this.Write(" MsgPack::IFormatterResolver formatterResolver = options.Resolver;\r\n"); + this.Write("\t\t\tMsgPack::IFormatterResolver formatterResolver = options.Resolver;\r\n"); } if (Info.HasIMessagePackSerializationCallbackReceiver) { if (Info.NeedsCastOnBefore) { - this.Write(" ((MsgPack::IMessagePackSerializationCallbackReceiver)value).OnBeforeS" + - "erialize();\r\n"); + this.Write("\t\t\t((MsgPack::IMessagePackSerializationCallbackReceiver)value).OnBeforeSerialize(" + + ");\r\n"); } else { - this.Write(" value.OnBeforeSerialize();\r\n"); + this.Write("\t\t\tvalue.OnBeforeSerialize();\r\n"); } } - this.Write(" writer.WriteArrayHeader("); + this.Write("\t\t\twriter.WriteArrayHeader("); this.Write(this.ToStringHelper.ToStringWithCulture(Info.MaxKey + 1)); this.Write(");\r\n"); for (var i = 0; i <= Info.MaxKey; i++) { var member = Info.GetMember(i); if (member == null) { - this.Write(" writer.WriteNil();\r\n"); + this.Write("\t\t\twriter.WriteNil();\r\n"); } else { - this.Write(" "); + this.Write("\t\t\t"); this.Write(this.ToStringHelper.ToStringWithCulture(member.GetSerializeMethodString())); this.Write(";\r\n"); } } - this.Write(" }\r\n\r\n public "); + this.Write("\t\t}\r\n\r\n\t\tpublic "); this.Write(this.ToStringHelper.ToStringWithCulture(Info.FullName)); this.Write(" Deserialize(ref MsgPack::MessagePackReader reader, MsgPack::MessagePackSerialize" + - "rOptions options)\r\n {\r\n if (reader.TryReadNil())\r\n " + - "{\r\n"); + "rOptions options)\r\n\t\t{\r\n\t\t\tif (reader.TryReadNil())\r\n\t\t\t{\r\n"); if (Info.IsClass) { - this.Write(" return null;\r\n"); + this.Write("\t\t\t\treturn null;\r\n"); } else { - this.Write(" throw new global::System.InvalidOperationException(\"typecode is n" + - "ull, struct not supported\");\r\n"); + this.Write("\t\t\t\tthrow new global::System.InvalidOperationException(\"typecode is null, struct " + + "not supported\");\r\n"); } - this.Write(" }\r\n\r\n"); + this.Write("\t\t\t}\r\n\r\n"); if (Info.MaxKey == -1 && !Info.HasIMessagePackSerializationCallbackReceiver) { - this.Write(" reader.Skip();\r\n return new "); + this.Write("\t\t\treader.Skip();\r\n\t\t\treturn new "); this.Write(this.ToStringHelper.ToStringWithCulture(Info.GetConstructorString())); this.Write(";\r\n"); } else { - this.Write(" options.Security.DepthStep(ref reader);\r\n"); + this.Write("\t\t\toptions.Security.DepthStep(ref reader);\r\n"); if (isFormatterResolverNecessary) { - this.Write(" MsgPack::IFormatterResolver formatterResolver = options.Resolver;\r\n"); + this.Write("\t\t\tMsgPack::IFormatterResolver formatterResolver = options.Resolver;\r\n"); } - this.Write(" var length = reader.ReadArrayHeader();\r\n"); + this.Write("\t\t\tvar length = reader.ReadArrayHeader();\r\n"); var canOverwrite = Info.ConstructorParameters.Length == 0; if (canOverwrite) { - this.Write(" var ____result = new "); + this.Write("\t\t\tvar ____result = new "); this.Write(this.ToStringHelper.ToStringWithCulture(Info.GetConstructorString())); this.Write(";\r\n"); } else { foreach (var member in Info.Members) { - this.Write(" var __"); + this.Write("\t\t\tvar __"); this.Write(this.ToStringHelper.ToStringWithCulture(member.Name)); this.Write("__ = default("); this.Write(this.ToStringHelper.ToStringWithCulture(member.Type)); this.Write(");\r\n"); } } - this.Write("\r\n for (int i = 0; i < length; i++)\r\n {\r\n sw" + - "itch (i)\r\n {\r\n"); + this.Write("\r\n\t\t\tfor (int i = 0; i < length; i++)\r\n\t\t\t{\r\n\t\t\t\tswitch (i)\r\n\t\t\t\t{\r\n"); for (var memberIndex = 0; memberIndex <= Info.MaxKey; memberIndex++) { var member = Info.GetMember(memberIndex); if (member == null) { continue; } - this.Write(" case "); + this.Write("\t\t\t\t\tcase "); this.Write(this.ToStringHelper.ToStringWithCulture(member.IntKey)); this.Write(":\r\n"); if (canOverwrite) { if (member.IsWritable) { - this.Write(" ____result."); + this.Write("\t\t\t\t\t\t____result."); this.Write(this.ToStringHelper.ToStringWithCulture(member.Name)); this.Write(" = "); this.Write(this.ToStringHelper.ToStringWithCulture(member.GetDeserializeMethodString())); this.Write(";\r\n"); } else { - this.Write(" "); + this.Write("\t\t\t\t\t\t"); this.Write(this.ToStringHelper.ToStringWithCulture(member.GetDeserializeMethodString())); this.Write(";\r\n"); } } else { - this.Write(" __"); + this.Write("\t\t\t\t\t\t__"); this.Write(this.ToStringHelper.ToStringWithCulture(member.Name)); this.Write("__ = "); this.Write(this.ToStringHelper.ToStringWithCulture(member.GetDeserializeMethodString())); this.Write(";\r\n"); } - this.Write(" break;\r\n"); + this.Write("\t\t\t\t\t\tbreak;\r\n"); } - this.Write(" default:\r\n reader.Skip();\r\n " + - " break;\r\n }\r\n }\r\n\r\n"); + this.Write("\t\t\t\t\tdefault:\r\n\t\t\t\t\t\treader.Skip();\r\n\t\t\t\t\t\tbreak;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n"); if (!canOverwrite) { - this.Write(" var ____result = new "); + this.Write("\t\t\tvar ____result = new "); this.Write(this.ToStringHelper.ToStringWithCulture(Info.GetConstructorString())); this.Write(";\r\n"); bool memberAssignExists = false; @@ -161,31 +157,30 @@ public virtual string TransformText() var member = Info.GetMember(memberIndex); if (member == null || !member.IsWritable || Info.ConstructorParameters.Any(p => p.Equals(member))) { continue; } memberAssignExists = true; - this.Write(" if (length <= "); + this.Write("\t\t\tif (length <= "); this.Write(this.ToStringHelper.ToStringWithCulture(memberIndex)); - this.Write(")\r\n {\r\n goto MEMBER_ASSIGNMENT_END;\r\n }\r\n\r\n " + - " ____result."); + this.Write(")\r\n\t\t\t{\r\n\t\t\t\tgoto MEMBER_ASSIGNMENT_END;\r\n\t\t\t}\r\n\r\n\t\t\t____result."); this.Write(this.ToStringHelper.ToStringWithCulture(member.Name)); this.Write(" = __"); this.Write(this.ToStringHelper.ToStringWithCulture(member.Name)); this.Write("__;\r\n"); } if (memberAssignExists) { - this.Write("\r\n MEMBER_ASSIGNMENT_END:\r\n"); + this.Write("\r\n\t\tMEMBER_ASSIGNMENT_END:\r\n"); } } if (Info.HasIMessagePackSerializationCallbackReceiver) { if (Info.NeedsCastOnAfter) { - this.Write(" ((MsgPack::IMessagePackSerializationCallbackReceiver)____result).OnAf" + - "terDeserialize();\r\n"); + this.Write("\t\t\t((MsgPack::IMessagePackSerializationCallbackReceiver)____result).OnAfterDeseri" + + "alize();\r\n"); } else { - this.Write(" ____result.OnAfterDeserialize();\r\n"); + this.Write("\t\t\t____result.OnAfterDeserialize();\r\n"); } } - this.Write(" reader.Depth--;\r\n return ____result;\r\n"); + this.Write("\t\t\treader.Depth--;\r\n\t\t\treturn ____result;\r\n"); } - this.Write(" }\r\n }\r\n}\r\n"); + this.Write("\t\t}\r\n\t}\r\n}\r\n"); return this.GenerationEnvironment.ToString(); } } diff --git a/src/MessagePack.Generator/Transforms/FormatterTemplate.tt b/src/MessagePack.Generator/Transforms/FormatterTemplate.tt index 9e903d83e..04a276dab 100644 --- a/src/MessagePack.Generator/Transforms/FormatterTemplate.tt +++ b/src/MessagePack.Generator/Transforms/FormatterTemplate.tt @@ -6,136 +6,136 @@ namespace <#= Namespace #> { - using MsgPack = global::MessagePack; + using MsgPack = global::MessagePack; <# bool isFormatterResolverNecessary = ShouldUseFormatterResolverHelper.ShouldUseFormatterResolver(Info.Members);#> - public sealed class <#= Info.FormatterNameWithoutNamespace #> : MsgPack::Formatters.IMessagePackFormatter<<#= Info.FullName #>> + public sealed class <#= Info.FormatterNameWithoutNamespace #> : MsgPack::Formatters.IMessagePackFormatter<<#= Info.FullName #>> <# foreach (var typeArg in Info.GenericTypeParameters.Where(x => x.HasConstraints)) { #> - where <#= typeArg.Name #> : <#= typeArg.Constraints #> + where <#= typeArg.Name #> : <#= typeArg.Constraints #> <# } #> - { + { <# foreach (var item in Info.Members) { #> <# if (item.CustomFormatterTypeName != null) { #> - private readonly <#= item.CustomFormatterTypeName #> __<#= item.Name #>CustomFormatter__ = new <#= item.CustomFormatterTypeName #>(); + private readonly <#= item.CustomFormatterTypeName #> __<#= item.Name #>CustomFormatter__ = new <#= item.CustomFormatterTypeName #>(); <# } #> <# } #> - public void Serialize(ref MsgPack::MessagePackWriter writer, <#= Info.FullName #> value, MsgPack::MessagePackSerializerOptions options) - { + public void Serialize(ref MsgPack::MessagePackWriter writer, <#= Info.FullName #> value, MsgPack::MessagePackSerializerOptions options) + { <# if (Info.IsClass) { #> - if (value == null) - { - writer.WriteNil(); - return; - } + if (value == null) + { + writer.WriteNil(); + return; + } <# } if (isFormatterResolverNecessary) { #> - MsgPack::IFormatterResolver formatterResolver = options.Resolver; + MsgPack::IFormatterResolver formatterResolver = options.Resolver; <# } if (Info.HasIMessagePackSerializationCallbackReceiver) { if (Info.NeedsCastOnBefore) { #> - ((MsgPack::IMessagePackSerializationCallbackReceiver)value).OnBeforeSerialize(); + ((MsgPack::IMessagePackSerializationCallbackReceiver)value).OnBeforeSerialize(); <# } else { #> - value.OnBeforeSerialize(); + value.OnBeforeSerialize(); <# } #> <# } #> - writer.WriteArrayHeader(<#= Info.MaxKey + 1 #>); + writer.WriteArrayHeader(<#= Info.MaxKey + 1 #>); <# for (var i = 0; i <= Info.MaxKey; i++) { var member = Info.GetMember(i); if (member == null) { #> - writer.WriteNil(); + writer.WriteNil(); <# } else { #> - <#= member.GetSerializeMethodString() #>; + <#= member.GetSerializeMethodString() #>; <# } #> <# } #> - } + } - public <#= Info.FullName #> Deserialize(ref MsgPack::MessagePackReader reader, MsgPack::MessagePackSerializerOptions options) - { - if (reader.TryReadNil()) - { + public <#= Info.FullName #> Deserialize(ref MsgPack::MessagePackReader reader, MsgPack::MessagePackSerializerOptions options) + { + if (reader.TryReadNil()) + { <# if (Info.IsClass) { #> - return null; + return null; <# } else { #> - throw new global::System.InvalidOperationException("typecode is null, struct not supported"); + throw new global::System.InvalidOperationException("typecode is null, struct not supported"); <# } #> - } + } <# if (Info.MaxKey == -1 && !Info.HasIMessagePackSerializationCallbackReceiver) { #> - reader.Skip(); - return new <#= Info.GetConstructorString() #>; + reader.Skip(); + return new <#= Info.GetConstructorString() #>; <# } else { #> - options.Security.DepthStep(ref reader); + options.Security.DepthStep(ref reader); <# if (isFormatterResolverNecessary) { #> - MsgPack::IFormatterResolver formatterResolver = options.Resolver; + MsgPack::IFormatterResolver formatterResolver = options.Resolver; <# } #> - var length = reader.ReadArrayHeader(); + var length = reader.ReadArrayHeader(); <# var canOverwrite = Info.ConstructorParameters.Length == 0; if (canOverwrite) { #> - var ____result = new <#= Info.GetConstructorString() #>; + var ____result = new <#= Info.GetConstructorString() #>; <# } else { foreach (var member in Info.Members) { #> - var __<#= member.Name #>__ = default(<#= member.Type #>); + var __<#= member.Name #>__ = default(<#= member.Type #>); <# } #> <# } #> - for (int i = 0; i < length; i++) - { - switch (i) - { + for (int i = 0; i < length; i++) + { + switch (i) + { <# for (var memberIndex = 0; memberIndex <= Info.MaxKey; memberIndex++) { var member = Info.GetMember(memberIndex); if (member == null) { continue; } #> - case <#= member.IntKey #>: + case <#= member.IntKey #>: <# if (canOverwrite) { if (member.IsWritable) { #> - ____result.<#= member.Name #> = <#= member.GetDeserializeMethodString() #>; + ____result.<#= member.Name #> = <#= member.GetDeserializeMethodString() #>; <# } else { #> - <#= member.GetDeserializeMethodString() #>; + <#= member.GetDeserializeMethodString() #>; <# } #> <# } else {#> - __<#= member.Name #>__ = <#= member.GetDeserializeMethodString() #>; + __<#= member.Name #>__ = <#= member.GetDeserializeMethodString() #>; <# } #> - break; + break; <# } #> - default: - reader.Skip(); - break; - } - } + default: + reader.Skip(); + break; + } + } <# if (!canOverwrite) { #> - var ____result = new <#= Info.GetConstructorString() #>; + var ____result = new <#= Info.GetConstructorString() #>; <# bool memberAssignExists = false; for (var memberIndex = 0; memberIndex <= Info.MaxKey; memberIndex++) { var member = Info.GetMember(memberIndex); if (member == null || !member.IsWritable || Info.ConstructorParameters.Any(p => p.Equals(member))) { continue; } memberAssignExists = true;#> - if (length <= <#= memberIndex #>) - { - goto MEMBER_ASSIGNMENT_END; - } + if (length <= <#= memberIndex #>) + { + goto MEMBER_ASSIGNMENT_END; + } - ____result.<#= member.Name #> = __<#= member.Name #>__; + ____result.<#= member.Name #> = __<#= member.Name #>__; <# } #> <# if (memberAssignExists) { #> - MEMBER_ASSIGNMENT_END: + MEMBER_ASSIGNMENT_END: <# } } if (Info.HasIMessagePackSerializationCallbackReceiver) { if (Info.NeedsCastOnAfter) { #> - ((MsgPack::IMessagePackSerializationCallbackReceiver)____result).OnAfterDeserialize(); + ((MsgPack::IMessagePackSerializationCallbackReceiver)____result).OnAfterDeserialize(); <# } else { #> - ____result.OnAfterDeserialize(); + ____result.OnAfterDeserialize(); <# } #> <# } #> - reader.Depth--; - return ____result; + reader.Depth--; + return ____result; <# } #> - } - } + } + } } diff --git a/src/MessagePack.Generator/Transforms/ResolverTemplate.cs b/src/MessagePack.Generator/Transforms/ResolverTemplate.cs index 42b37fac3..3a87fbe12 100644 --- a/src/MessagePack.Generator/Transforms/ResolverTemplate.cs +++ b/src/MessagePack.Generator/Transforms/ResolverTemplate.cs @@ -27,79 +27,61 @@ public virtual string TransformText() { this.Write("\r\nnamespace "); this.Write(this.ToStringHelper.ToStringWithCulture(ResolverNamespace)); - this.Write("\r\n{\r\n using MsgPack = global::MessagePack;\r\n\r\n public class "); + this.Write("\r\n{\r\n\tusing MsgPack = global::MessagePack;\r\n\r\n\tpublic class "); this.Write(this.ToStringHelper.ToStringWithCulture(ResolverName)); - this.Write(" : MsgPack::IFormatterResolver\r\n {\r\n public static readonly MsgPack::IF" + - "ormatterResolver Instance = new "); + this.Write(" : MsgPack::IFormatterResolver\r\n\t{\r\n\t\tpublic static readonly MsgPack::IFormatterR" + + "esolver Instance = new "); this.Write(this.ToStringHelper.ToStringWithCulture(ResolverName)); - this.Write("();\r\n\r\n public static readonly MsgPack::IFormatterResolver InstanceWithSta" + - "ndardAotResolver = MsgPack::Resolvers.CompositeResolver.Create(Instance, MsgPack" + - "::Resolvers.StandardAotResolver.Instance);\r\n\r\n private "); + this.Write("();\r\n\r\n\t\tpublic static readonly MsgPack::IFormatterResolver InstanceWithStandardA" + + "otResolver = MsgPack::Resolvers.CompositeResolver.Create(Instance, MsgPack::Reso" + + "lvers.StandardAotResolver.Instance);\r\n\r\n\t\tprivate "); this.Write(this.ToStringHelper.ToStringWithCulture(ResolverName)); this.Write(@"() - { - } + { + } - public MsgPack::Formatters.IMessagePackFormatter GetFormatter() - { - return FormatterCache.Formatter; - } + public MsgPack::Formatters.IMessagePackFormatter GetFormatter() + { + return FormatterCache.Formatter; + } - private static class FormatterCache - { - internal static readonly MsgPack::Formatters.IMessagePackFormatter Formatter; + private static class FormatterCache + { + internal static readonly MsgPack::Formatters.IMessagePackFormatter Formatter; - static FormatterCache() - { - var f = "); + static FormatterCache() + { + var f = "); this.Write(this.ToStringHelper.ToStringWithCulture(ResolverName)); - this.Write(@"GetFormatterHelper.GetFormatter(typeof(T)); - if (f != null) - { - Formatter = (MsgPack::Formatters.IMessagePackFormatter)f; - } - } - } - } - - internal static class "); + this.Write("GetFormatterHelper.GetFormatter(typeof(T));\r\n\t\t\t\tif (f != null)\r\n\t\t\t\t{\r\n\t\t\t\t\tForm" + + "atter = (MsgPack::Formatters.IMessagePackFormatter)f;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n" + + "\r\n\tinternal static class "); this.Write(this.ToStringHelper.ToStringWithCulture(ResolverName)); - this.Write("GetFormatterHelper\r\n {\r\n private static readonly global::System.Collect" + - "ions.Generic.Dictionary lookup;\r\n\r\n static "); + this.Write("GetFormatterHelper\r\n\t{\r\n\t\tprivate static readonly global::System.Collections.Gene" + + "ric.Dictionary lookup;\r\n\r\n\t\tstatic "); this.Write(this.ToStringHelper.ToStringWithCulture(ResolverName)); - this.Write("GetFormatterHelper()\r\n {\r\n lookup = new global::System.Collecti" + - "ons.Generic.Dictionary("); + this.Write("GetFormatterHelper()\r\n\t\t{\r\n\t\t\tlookup = new global::System.Collections.Generic.Dic" + + "tionary("); this.Write(this.ToStringHelper.ToStringWithCulture(RegisterInfos.Count)); - this.Write(")\r\n {\r\n"); + this.Write(")\r\n\t\t\t{\r\n"); for(var i = 0; i < RegisterInfos.Count; i++) { var x = RegisterInfos[i]; - this.Write(" { typeof("); + this.Write("\t\t\t\t{ typeof("); this.Write(this.ToStringHelper.ToStringWithCulture(x.FullName)); this.Write("), "); this.Write(this.ToStringHelper.ToStringWithCulture(i)); this.Write(" },\r\n"); } - this.Write(@" }; - } - - internal static object GetFormatter(global::System.Type t) - { - int key; - if (!lookup.TryGetValue(t, out key)) - { - return null; - } - - switch (key) - { -"); + this.Write("\t\t\t};\r\n\t\t}\r\n\r\n\t\tinternal static object GetFormatter(global::System.Type t)\r\n\t\t{\r\n" + + "\t\t\tint key;\r\n\t\t\tif (!lookup.TryGetValue(t, out key))\r\n\t\t\t{\r\n\t\t\t\treturn null;\r\n\t\t" + + "\t}\r\n\r\n\t\t\tswitch (key)\r\n\t\t\t{\r\n"); for(var i = 0; i < RegisterInfos.Count; i++) { var x = RegisterInfos[i]; - this.Write(" case "); + this.Write("\t\t\t\tcase "); this.Write(this.ToStringHelper.ToStringWithCulture(i)); this.Write(": return new "); this.Write(this.ToStringHelper.ToStringWithCulture(x.FormatterName.StartsWith("global::") ? x.FormatterName : (FormatterNamespace + "." + x.FormatterName))); this.Write("();\r\n"); } - this.Write(" default: return null;\r\n }\r\n }\r\n }\r\n}\r\n"); + this.Write("\t\t\t\tdefault: return null;\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n}\r\n"); return this.GenerationEnvironment.ToString(); } } diff --git a/src/MessagePack.Generator/Transforms/ResolverTemplate.tt b/src/MessagePack.Generator/Transforms/ResolverTemplate.tt index 1758fa076..2ec180933 100644 --- a/src/MessagePack.Generator/Transforms/ResolverTemplate.tt +++ b/src/MessagePack.Generator/Transforms/ResolverTemplate.tt @@ -6,67 +6,67 @@ namespace <#= ResolverNamespace #> { - using MsgPack = global::MessagePack; + using MsgPack = global::MessagePack; - public class <#= ResolverName #> : MsgPack::IFormatterResolver - { - public static readonly MsgPack::IFormatterResolver Instance = new <#= ResolverName #>(); + public class <#= ResolverName #> : MsgPack::IFormatterResolver + { + public static readonly MsgPack::IFormatterResolver Instance = new <#= ResolverName #>(); - public static readonly MsgPack::IFormatterResolver InstanceWithStandardAotResolver = MsgPack::Resolvers.CompositeResolver.Create(Instance, MsgPack::Resolvers.StandardAotResolver.Instance); + public static readonly MsgPack::IFormatterResolver InstanceWithStandardAotResolver = MsgPack::Resolvers.CompositeResolver.Create(Instance, MsgPack::Resolvers.StandardAotResolver.Instance); - private <#= ResolverName #>() - { - } + private <#= ResolverName #>() + { + } - public MsgPack::Formatters.IMessagePackFormatter GetFormatter() - { - return FormatterCache.Formatter; - } + public MsgPack::Formatters.IMessagePackFormatter GetFormatter() + { + return FormatterCache.Formatter; + } - private static class FormatterCache - { - internal static readonly MsgPack::Formatters.IMessagePackFormatter Formatter; + private static class FormatterCache + { + internal static readonly MsgPack::Formatters.IMessagePackFormatter Formatter; - static FormatterCache() - { - var f = <#= ResolverName #>GetFormatterHelper.GetFormatter(typeof(T)); - if (f != null) - { - Formatter = (MsgPack::Formatters.IMessagePackFormatter)f; - } - } - } - } + static FormatterCache() + { + var f = <#= ResolverName #>GetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + Formatter = (MsgPack::Formatters.IMessagePackFormatter)f; + } + } + } + } - internal static class <#= ResolverName #>GetFormatterHelper - { - private static readonly global::System.Collections.Generic.Dictionary lookup; + internal static class <#= ResolverName #>GetFormatterHelper + { + private static readonly global::System.Collections.Generic.Dictionary lookup; - static <#= ResolverName #>GetFormatterHelper() - { - lookup = new global::System.Collections.Generic.Dictionary(<#= RegisterInfos.Count #>) - { + static <#= ResolverName #>GetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(<#= RegisterInfos.Count #>) + { <# for(var i = 0; i < RegisterInfos.Count; i++) { var x = RegisterInfos[i]; #> - { typeof(<#= x.FullName #>), <#= i #> }, + { typeof(<#= x.FullName #>), <#= i #> }, <# } #> - }; - } + }; + } - internal static object GetFormatter(global::System.Type t) - { - int key; - if (!lookup.TryGetValue(t, out key)) - { - return null; - } + internal static object GetFormatter(global::System.Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } - switch (key) - { + switch (key) + { <# for(var i = 0; i < RegisterInfos.Count; i++) { var x = RegisterInfos[i]; #> - case <#= i #>: return new <#= x.FormatterName.StartsWith("global::") ? x.FormatterName : (FormatterNamespace + "." + x.FormatterName) #>(); + case <#= i #>: return new <#= x.FormatterName.StartsWith("global::") ? x.FormatterName : (FormatterNamespace + "." + x.FormatterName) #>(); <# } #> - default: return null; - } - } - } + default: return null; + } + } + } } diff --git a/src/MessagePack.Generator/Transforms/UnionTemplate.cs b/src/MessagePack.Generator/Transforms/UnionTemplate.cs index ba999bef8..fc6371ce0 100644 --- a/src/MessagePack.Generator/Transforms/UnionTemplate.cs +++ b/src/MessagePack.Generator/Transforms/UnionTemplate.cs @@ -27,24 +27,24 @@ public virtual string TransformText() { this.Write("\r\nnamespace "); this.Write(this.ToStringHelper.ToStringWithCulture(Namespace)); - this.Write("\r\n{\r\n using MsgPack = global::MessagePack;\r\n\r\n public sealed class "); + this.Write("\r\n{\r\n\tusing MsgPack = global::MessagePack;\r\n\r\n\tpublic sealed class "); this.Write(this.ToStringHelper.ToStringWithCulture(Info.Name)); this.Write("Formatter : MsgPack::Formatters.IMessagePackFormatter<"); this.Write(this.ToStringHelper.ToStringWithCulture(Info.FullName)); this.Write(@"> - { - private readonly global::System.Collections.Generic.Dictionary> typeToKeyAndJumpMap; - private readonly global::System.Collections.Generic.Dictionary keyToJumpMap; + { + private readonly global::System.Collections.Generic.Dictionary> typeToKeyAndJumpMap; + private readonly global::System.Collections.Generic.Dictionary keyToJumpMap; - public "); + public "); this.Write(this.ToStringHelper.ToStringWithCulture(Info.Name)); - this.Write("Formatter()\r\n {\r\n this.typeToKeyAndJumpMap = new global::System" + - ".Collections.Generic.Dictionary>("); + this.Write("Formatter()\r\n\t\t{\r\n\t\t\tthis.typeToKeyAndJumpMap = new global::System.Collections.Ge" + + "neric.Dictionary>("); this.Write(this.ToStringHelper.ToStringWithCulture(Info.SubTypes.Length)); - this.Write(", MsgPack::Internal.RuntimeTypeHandleEqualityComparer.Default)\r\n {\r\n"); + this.Write(", MsgPack::Internal.RuntimeTypeHandleEqualityComparer.Default)\r\n\t\t\t{\r\n"); for(var i = 0; i < Info.SubTypes.Length; i++) { var item = Info.SubTypes[i]; - this.Write(" { typeof("); + this.Write("\t\t\t\t{ typeof("); this.Write(this.ToStringHelper.ToStringWithCulture(item.Type)); this.Write(").TypeHandle, new global::System.Collections.Generic.KeyValuePair("); this.Write(this.ToStringHelper.ToStringWithCulture(item.Key)); @@ -52,74 +52,68 @@ public virtual string TransformText() this.Write(this.ToStringHelper.ToStringWithCulture(i)); this.Write(") },\r\n"); } - this.Write(" };\r\n this.keyToJumpMap = new global::System.Collections.Ge" + - "neric.Dictionary("); + this.Write("\t\t\t};\r\n\t\t\tthis.keyToJumpMap = new global::System.Collections.Generic.Dictionary("); this.Write(this.ToStringHelper.ToStringWithCulture(Info.SubTypes.Length)); - this.Write(")\r\n {\r\n"); + this.Write(")\r\n\t\t\t{\r\n"); for(var i = 0; i < Info.SubTypes.Length; i++) { var item = Info.SubTypes[i]; - this.Write(" { "); + this.Write("\t\t\t\t{ "); this.Write(this.ToStringHelper.ToStringWithCulture(item.Key)); this.Write(", "); this.Write(this.ToStringHelper.ToStringWithCulture(i)); this.Write(" },\r\n"); } - this.Write(" };\r\n }\r\n\r\n public void Serialize(ref MsgPack::MessagePa" + - "ckWriter writer, "); + this.Write("\t\t\t};\r\n\t\t}\r\n\r\n\t\tpublic void Serialize(ref MsgPack::MessagePackWriter writer, "); this.Write(this.ToStringHelper.ToStringWithCulture(Info.FullName)); this.Write(@" value, MsgPack::MessagePackSerializerOptions options) - { - global::System.Collections.Generic.KeyValuePair keyValuePair; - if (value != null && this.typeToKeyAndJumpMap.TryGetValue(value.GetType().TypeHandle, out keyValuePair)) - { - writer.WriteArrayHeader(2); - writer.WriteInt32(keyValuePair.Key); - switch (keyValuePair.Value) - { + { + global::System.Collections.Generic.KeyValuePair keyValuePair; + if (value != null && this.typeToKeyAndJumpMap.TryGetValue(value.GetType().TypeHandle, out keyValuePair)) + { + writer.WriteArrayHeader(2); + writer.WriteInt32(keyValuePair.Key); + switch (keyValuePair.Value) + { "); for(var i = 0; i < Info.SubTypes.Length; i++) { var item = Info.SubTypes[i]; - this.Write(" case "); + this.Write("\t\t\t\t\tcase "); this.Write(this.ToStringHelper.ToStringWithCulture(i)); - this.Write(":\r\n MsgPack::FormatterResolverExtensions.GetFormatterWithV" + - "erify<"); + this.Write(":\r\n\t\t\t\t\t\tMsgPack::FormatterResolverExtensions.GetFormatterWithVerify<"); this.Write(this.ToStringHelper.ToStringWithCulture(item.Type)); this.Write(">(options.Resolver).Serialize(ref writer, ("); this.Write(this.ToStringHelper.ToStringWithCulture(item.Type)); - this.Write(")value, options);\r\n break;\r\n"); + this.Write(")value, options);\r\n\t\t\t\t\t\tbreak;\r\n"); } - this.Write(" default:\r\n break;\r\n }\r\n" + - "\r\n return;\r\n }\r\n\r\n writer.WriteNil();\r\n " + - " }\r\n\r\n public "); + this.Write("\t\t\t\t\tdefault:\r\n\t\t\t\t\t\tbreak;\r\n\t\t\t\t}\r\n\r\n\t\t\t\treturn;\r\n\t\t\t}\r\n\r\n\t\t\twriter.WriteNil();\r" + + "\n\t\t}\r\n\r\n\t\tpublic "); this.Write(this.ToStringHelper.ToStringWithCulture(Info.FullName)); this.Write(@" Deserialize(ref MsgPack::MessagePackReader reader, MsgPack::MessagePackSerializerOptions options) - { - if (reader.TryReadNil()) - { - return null; - } + { + if (reader.TryReadNil()) + { + return null; + } - if (reader.ReadArrayHeader() != 2) - { - throw new global::System.InvalidOperationException(""Invalid Union data was detected. Type:"); + if (reader.ReadArrayHeader() != 2) + { + throw new global::System.InvalidOperationException(""Invalid Union data was detected. Type:"); this.Write(this.ToStringHelper.ToStringWithCulture(Info.FullName)); - this.Write("\");\r\n }\r\n\r\n options.Security.DepthStep(ref reader);\r\n " + - " var key = reader.ReadInt32();\r\n\r\n if (!this.keyToJumpMap.TryGet" + - "Value(key, out key))\r\n {\r\n key = -1;\r\n }\r\n\r" + - "\n "); + this.Write("\");\r\n\t\t\t}\r\n\r\n\t\t\toptions.Security.DepthStep(ref reader);\r\n\t\t\tvar key = reader.Read" + + "Int32();\r\n\r\n\t\t\tif (!this.keyToJumpMap.TryGetValue(key, out key))\r\n\t\t\t{\r\n\t\t\t\tkey " + + "= -1;\r\n\t\t\t}\r\n\r\n\t\t\t"); this.Write(this.ToStringHelper.ToStringWithCulture(Info.FullName)); - this.Write(" result = null;\r\n switch (key)\r\n {\r\n"); + this.Write(" result = null;\r\n\t\t\tswitch (key)\r\n\t\t\t{\r\n"); for(var i = 0; i < Info.SubTypes.Length; i++) { var item = Info.SubTypes[i]; - this.Write(" case "); + this.Write("\t\t\t\tcase "); this.Write(this.ToStringHelper.ToStringWithCulture(i)); - this.Write(":\r\n result = ("); + this.Write(":\r\n\t\t\t\t\tresult = ("); this.Write(this.ToStringHelper.ToStringWithCulture(Info.FullName)); this.Write(")MsgPack::FormatterResolverExtensions.GetFormatterWithVerify<"); this.Write(this.ToStringHelper.ToStringWithCulture(item.Type)); - this.Write(">(options.Resolver).Deserialize(ref reader, options);\r\n break;" + - "\r\n"); + this.Write(">(options.Resolver).Deserialize(ref reader, options);\r\n\t\t\t\t\tbreak;\r\n"); } - this.Write(" default:\r\n reader.Skip();\r\n " + - " break;\r\n }\r\n\r\n reader.Depth--;\r\n return result" + - ";\r\n }\r\n }\r\n}\r\n"); + this.Write("\t\t\t\tdefault:\r\n\t\t\t\t\treader.Skip();\r\n\t\t\t\t\tbreak;\r\n\t\t\t}\r\n\r\n\t\t\treader.Depth--;\r\n\t\t\tre" + + "turn result;\r\n\t\t}\r\n\t}\r\n}\r\n"); return this.GenerationEnvironment.ToString(); } } diff --git a/src/MessagePack.Generator/Transforms/UnionTemplate.tt b/src/MessagePack.Generator/Transforms/UnionTemplate.tt index b3b0ccf49..bf04c6a8b 100644 --- a/src/MessagePack.Generator/Transforms/UnionTemplate.tt +++ b/src/MessagePack.Generator/Transforms/UnionTemplate.tt @@ -6,88 +6,88 @@ namespace <#= Namespace #> { - using MsgPack = global::MessagePack; + using MsgPack = global::MessagePack; - public sealed class <#= Info.Name #>Formatter : MsgPack::Formatters.IMessagePackFormatter<<#= Info.FullName #>> - { - private readonly global::System.Collections.Generic.Dictionary> typeToKeyAndJumpMap; - private readonly global::System.Collections.Generic.Dictionary keyToJumpMap; + public sealed class <#= Info.Name #>Formatter : MsgPack::Formatters.IMessagePackFormatter<<#= Info.FullName #>> + { + private readonly global::System.Collections.Generic.Dictionary> typeToKeyAndJumpMap; + private readonly global::System.Collections.Generic.Dictionary keyToJumpMap; - public <#= Info.Name #>Formatter() - { - this.typeToKeyAndJumpMap = new global::System.Collections.Generic.Dictionary>(<#= Info.SubTypes.Length #>, MsgPack::Internal.RuntimeTypeHandleEqualityComparer.Default) - { + public <#= Info.Name #>Formatter() + { + this.typeToKeyAndJumpMap = new global::System.Collections.Generic.Dictionary>(<#= Info.SubTypes.Length #>, MsgPack::Internal.RuntimeTypeHandleEqualityComparer.Default) + { <# for(var i = 0; i < Info.SubTypes.Length; i++) { var item = Info.SubTypes[i]; #> - { typeof(<#= item.Type #>).TypeHandle, new global::System.Collections.Generic.KeyValuePair(<#= item.Key #>, <#= i #>) }, + { typeof(<#= item.Type #>).TypeHandle, new global::System.Collections.Generic.KeyValuePair(<#= item.Key #>, <#= i #>) }, <# } #> - }; - this.keyToJumpMap = new global::System.Collections.Generic.Dictionary(<#= Info.SubTypes.Length #>) - { + }; + this.keyToJumpMap = new global::System.Collections.Generic.Dictionary(<#= Info.SubTypes.Length #>) + { <# for(var i = 0; i < Info.SubTypes.Length; i++) { var item = Info.SubTypes[i]; #> - { <#= item.Key #>, <#= i #> }, + { <#= item.Key #>, <#= i #> }, <# } #> - }; - } + }; + } - public void Serialize(ref MsgPack::MessagePackWriter writer, <#= Info.FullName #> value, MsgPack::MessagePackSerializerOptions options) - { - global::System.Collections.Generic.KeyValuePair keyValuePair; - if (value != null && this.typeToKeyAndJumpMap.TryGetValue(value.GetType().TypeHandle, out keyValuePair)) - { - writer.WriteArrayHeader(2); - writer.WriteInt32(keyValuePair.Key); - switch (keyValuePair.Value) - { + public void Serialize(ref MsgPack::MessagePackWriter writer, <#= Info.FullName #> value, MsgPack::MessagePackSerializerOptions options) + { + global::System.Collections.Generic.KeyValuePair keyValuePair; + if (value != null && this.typeToKeyAndJumpMap.TryGetValue(value.GetType().TypeHandle, out keyValuePair)) + { + writer.WriteArrayHeader(2); + writer.WriteInt32(keyValuePair.Key); + switch (keyValuePair.Value) + { <# for(var i = 0; i < Info.SubTypes.Length; i++) { var item = Info.SubTypes[i]; #> - case <#= i #>: - MsgPack::FormatterResolverExtensions.GetFormatterWithVerify<<#= item.Type #>>(options.Resolver).Serialize(ref writer, (<#= item.Type #>)value, options); - break; + case <#= i #>: + MsgPack::FormatterResolverExtensions.GetFormatterWithVerify<<#= item.Type #>>(options.Resolver).Serialize(ref writer, (<#= item.Type #>)value, options); + break; <# } #> - default: - break; - } + default: + break; + } - return; - } + return; + } - writer.WriteNil(); - } + writer.WriteNil(); + } - public <#= Info.FullName #> Deserialize(ref MsgPack::MessagePackReader reader, MsgPack::MessagePackSerializerOptions options) - { - if (reader.TryReadNil()) - { - return null; - } + public <#= Info.FullName #> Deserialize(ref MsgPack::MessagePackReader reader, MsgPack::MessagePackSerializerOptions options) + { + if (reader.TryReadNil()) + { + return null; + } - if (reader.ReadArrayHeader() != 2) - { - throw new global::System.InvalidOperationException("Invalid Union data was detected. Type:<#= Info.FullName #>"); - } + if (reader.ReadArrayHeader() != 2) + { + throw new global::System.InvalidOperationException("Invalid Union data was detected. Type:<#= Info.FullName #>"); + } - options.Security.DepthStep(ref reader); - var key = reader.ReadInt32(); + options.Security.DepthStep(ref reader); + var key = reader.ReadInt32(); - if (!this.keyToJumpMap.TryGetValue(key, out key)) - { - key = -1; - } + if (!this.keyToJumpMap.TryGetValue(key, out key)) + { + key = -1; + } - <#= Info.FullName #> result = null; - switch (key) - { + <#= Info.FullName #> result = null; + switch (key) + { <# for(var i = 0; i < Info.SubTypes.Length; i++) { var item = Info.SubTypes[i]; #> - case <#= i #>: - result = (<#= Info.FullName #>)MsgPack::FormatterResolverExtensions.GetFormatterWithVerify<<#= item.Type #>>(options.Resolver).Deserialize(ref reader, options); - break; + case <#= i #>: + result = (<#= Info.FullName #>)MsgPack::FormatterResolverExtensions.GetFormatterWithVerify<<#= item.Type #>>(options.Resolver).Deserialize(ref reader, options); + break; <# } #> - default: - reader.Skip(); - break; - } + default: + reader.Skip(); + break; + } - reader.Depth--; - return result; - } - } + reader.Depth--; + return result; + } + } } diff --git a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(Namespace)/MessagePack.Formatter.MyTestNamespace.MyEnum.g.cs b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(Namespace)/MessagePack.Formatter.MyTestNamespace.MyEnum.g.cs index cf869a527..d8498c4a5 100644 --- a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(Namespace)/MessagePack.Formatter.MyTestNamespace.MyEnum.g.cs +++ b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(Namespace)/MessagePack.Formatter.MyTestNamespace.MyEnum.g.cs @@ -4,18 +4,18 @@ namespace MessagePack.Formatters.MyTestNamespace { - using MsgPack = global::MessagePack; + using MsgPack = global::MessagePack; - public sealed class MyEnumFormatter : MsgPack::Formatters.IMessagePackFormatter - { - public void Serialize(ref MsgPack::MessagePackWriter writer, global::MyTestNamespace.MyEnum value, MsgPack::MessagePackSerializerOptions options) - { - writer.Write((int)value); - } + public sealed class MyEnumFormatter : MsgPack::Formatters.IMessagePackFormatter + { + public void Serialize(ref MsgPack::MessagePackWriter writer, global::MyTestNamespace.MyEnum value, MsgPack::MessagePackSerializerOptions options) + { + writer.Write((int)value); + } - public global::MyTestNamespace.MyEnum Deserialize(ref MsgPack::MessagePackReader reader, MsgPack::MessagePackSerializerOptions options) - { - return (global::MyTestNamespace.MyEnum)reader.ReadInt32(); - } - } + public global::MyTestNamespace.MyEnum Deserialize(ref MsgPack::MessagePackReader reader, MsgPack::MessagePackSerializerOptions options) + { + return (global::MyTestNamespace.MyEnum)reader.ReadInt32(); + } + } } diff --git a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(Namespace)/MessagePack.Formatter.MyTestNamespace.MyMessagePackObject.g.cs b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(Namespace)/MessagePack.Formatter.MyTestNamespace.MyMessagePackObject.g.cs index 9d4b4eb4a..b9877985f 100644 --- a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(Namespace)/MessagePack.Formatter.MyTestNamespace.MyMessagePackObject.g.cs +++ b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(Namespace)/MessagePack.Formatter.MyTestNamespace.MyMessagePackObject.g.cs @@ -4,51 +4,51 @@ namespace MessagePack.Formatters.MyTestNamespace { - using MsgPack = global::MessagePack; - - public sealed class MyMessagePackObjectFormatter : MsgPack::Formatters.IMessagePackFormatter - { - - public void Serialize(ref MsgPack::MessagePackWriter writer, global::MyTestNamespace.MyMessagePackObject value, MsgPack::MessagePackSerializerOptions options) - { - if (value == null) - { - writer.WriteNil(); - return; - } - - MsgPack::IFormatterResolver formatterResolver = options.Resolver; - writer.WriteArrayHeader(1); - global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Serialize(ref writer, value.EnumValue, options); - } - - public global::MyTestNamespace.MyMessagePackObject Deserialize(ref MsgPack::MessagePackReader reader, MsgPack::MessagePackSerializerOptions options) - { - if (reader.TryReadNil()) - { - return null; - } - - options.Security.DepthStep(ref reader); - MsgPack::IFormatterResolver formatterResolver = options.Resolver; - var length = reader.ReadArrayHeader(); - var ____result = new global::MyTestNamespace.MyMessagePackObject(); - - for (int i = 0; i < length; i++) - { - switch (i) - { - case 0: - ____result.EnumValue = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Deserialize(ref reader, options); - break; - default: - reader.Skip(); - break; - } - } - - reader.Depth--; - return ____result; - } - } + using MsgPack = global::MessagePack; + + public sealed class MyMessagePackObjectFormatter : MsgPack::Formatters.IMessagePackFormatter + { + + public void Serialize(ref MsgPack::MessagePackWriter writer, global::MyTestNamespace.MyMessagePackObject value, MsgPack::MessagePackSerializerOptions options) + { + if (value == null) + { + writer.WriteNil(); + return; + } + + MsgPack::IFormatterResolver formatterResolver = options.Resolver; + writer.WriteArrayHeader(1); + global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Serialize(ref writer, value.EnumValue, options); + } + + public global::MyTestNamespace.MyMessagePackObject Deserialize(ref MsgPack::MessagePackReader reader, MsgPack::MessagePackSerializerOptions options) + { + if (reader.TryReadNil()) + { + return null; + } + + options.Security.DepthStep(ref reader); + MsgPack::IFormatterResolver formatterResolver = options.Resolver; + var length = reader.ReadArrayHeader(); + var ____result = new global::MyTestNamespace.MyMessagePackObject(); + + for (int i = 0; i < length; i++) + { + switch (i) + { + case 0: + ____result.EnumValue = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Deserialize(ref reader, options); + break; + default: + reader.Skip(); + break; + } + } + + reader.Depth--; + return ____result; + } + } } diff --git a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(Namespace)/MessagePack.GeneratedResolver.g.cs b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(Namespace)/MessagePack.GeneratedResolver.g.cs index 87c964a55..58147457d 100644 --- a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(Namespace)/MessagePack.GeneratedResolver.g.cs +++ b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(Namespace)/MessagePack.GeneratedResolver.g.cs @@ -4,65 +4,65 @@ namespace MessagePack.Resolvers { - using MsgPack = global::MessagePack; + using MsgPack = global::MessagePack; - public class GeneratedResolver : MsgPack::IFormatterResolver - { - public static readonly MsgPack::IFormatterResolver Instance = new GeneratedResolver(); + public class GeneratedResolver : MsgPack::IFormatterResolver + { + public static readonly MsgPack::IFormatterResolver Instance = new GeneratedResolver(); - public static readonly MsgPack::IFormatterResolver InstanceWithStandardAotResolver = MsgPack::Resolvers.CompositeResolver.Create(Instance, MsgPack::Resolvers.StandardAotResolver.Instance); + public static readonly MsgPack::IFormatterResolver InstanceWithStandardAotResolver = MsgPack::Resolvers.CompositeResolver.Create(Instance, MsgPack::Resolvers.StandardAotResolver.Instance); - private GeneratedResolver() - { - } + private GeneratedResolver() + { + } - public MsgPack::Formatters.IMessagePackFormatter GetFormatter() - { - return FormatterCache.Formatter; - } + public MsgPack::Formatters.IMessagePackFormatter GetFormatter() + { + return FormatterCache.Formatter; + } - private static class FormatterCache - { - internal static readonly MsgPack::Formatters.IMessagePackFormatter Formatter; + private static class FormatterCache + { + internal static readonly MsgPack::Formatters.IMessagePackFormatter Formatter; - static FormatterCache() - { - var f = GeneratedResolverGetFormatterHelper.GetFormatter(typeof(T)); - if (f != null) - { - Formatter = (MsgPack::Formatters.IMessagePackFormatter)f; - } - } - } - } + static FormatterCache() + { + var f = GeneratedResolverGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + Formatter = (MsgPack::Formatters.IMessagePackFormatter)f; + } + } + } + } - internal static class GeneratedResolverGetFormatterHelper - { - private static readonly global::System.Collections.Generic.Dictionary lookup; + internal static class GeneratedResolverGetFormatterHelper + { + private static readonly global::System.Collections.Generic.Dictionary lookup; - static GeneratedResolverGetFormatterHelper() - { - lookup = new global::System.Collections.Generic.Dictionary(2) - { - { typeof(global::MyTestNamespace.MyEnum), 0 }, - { typeof(global::MyTestNamespace.MyMessagePackObject), 1 }, - }; - } + static GeneratedResolverGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(2) + { + { typeof(global::MyTestNamespace.MyEnum), 0 }, + { typeof(global::MyTestNamespace.MyMessagePackObject), 1 }, + }; + } - internal static object GetFormatter(global::System.Type t) - { - int key; - if (!lookup.TryGetValue(t, out key)) - { - return null; - } + internal static object GetFormatter(global::System.Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } - switch (key) - { - case 0: return new MessagePack.Formatters.MyTestNamespace.MyEnumFormatter(); - case 1: return new MessagePack.Formatters.MyTestNamespace.MyMessagePackObjectFormatter(); - default: return null; - } - } - } + switch (key) + { + case 0: return new MessagePack.Formatters.MyTestNamespace.MyEnumFormatter(); + case 1: return new MessagePack.Formatters.MyTestNamespace.MyMessagePackObjectFormatter(); + default: return null; + } + } + } } diff --git a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(NestingClass)/MessagePack.Formatter..ContainingClass_MyEnum.g.cs b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(NestingClass)/MessagePack.Formatter..ContainingClass_MyEnum.g.cs index f6a50c11d..84955bdc0 100644 --- a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(NestingClass)/MessagePack.Formatter..ContainingClass_MyEnum.g.cs +++ b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(NestingClass)/MessagePack.Formatter..ContainingClass_MyEnum.g.cs @@ -4,18 +4,18 @@ namespace MessagePack.Formatters { - using MsgPack = global::MessagePack; + using MsgPack = global::MessagePack; - public sealed class ContainingClass_MyEnumFormatter : MsgPack::Formatters.IMessagePackFormatter - { - public void Serialize(ref MsgPack::MessagePackWriter writer, global::ContainingClass.MyEnum value, MsgPack::MessagePackSerializerOptions options) - { - writer.Write((int)value); - } + public sealed class ContainingClass_MyEnumFormatter : MsgPack::Formatters.IMessagePackFormatter + { + public void Serialize(ref MsgPack::MessagePackWriter writer, global::ContainingClass.MyEnum value, MsgPack::MessagePackSerializerOptions options) + { + writer.Write((int)value); + } - public global::ContainingClass.MyEnum Deserialize(ref MsgPack::MessagePackReader reader, MsgPack::MessagePackSerializerOptions options) - { - return (global::ContainingClass.MyEnum)reader.ReadInt32(); - } - } + public global::ContainingClass.MyEnum Deserialize(ref MsgPack::MessagePackReader reader, MsgPack::MessagePackSerializerOptions options) + { + return (global::ContainingClass.MyEnum)reader.ReadInt32(); + } + } } diff --git a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(NestingClass)/MessagePack.Formatter.ContainingClass_MyMessagePackObject.g.cs b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(NestingClass)/MessagePack.Formatter.ContainingClass_MyMessagePackObject.g.cs index 9ef1df1fa..0f56f0989 100644 --- a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(NestingClass)/MessagePack.Formatter.ContainingClass_MyMessagePackObject.g.cs +++ b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(NestingClass)/MessagePack.Formatter.ContainingClass_MyMessagePackObject.g.cs @@ -4,51 +4,51 @@ namespace MessagePack.Formatters { - using MsgPack = global::MessagePack; - - public sealed class ContainingClass_MyMessagePackObjectFormatter : MsgPack::Formatters.IMessagePackFormatter - { - - public void Serialize(ref MsgPack::MessagePackWriter writer, global::ContainingClass.MyMessagePackObject value, MsgPack::MessagePackSerializerOptions options) - { - if (value == null) - { - writer.WriteNil(); - return; - } - - MsgPack::IFormatterResolver formatterResolver = options.Resolver; - writer.WriteArrayHeader(1); - global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Serialize(ref writer, value.EnumValue, options); - } - - public global::ContainingClass.MyMessagePackObject Deserialize(ref MsgPack::MessagePackReader reader, MsgPack::MessagePackSerializerOptions options) - { - if (reader.TryReadNil()) - { - return null; - } - - options.Security.DepthStep(ref reader); - MsgPack::IFormatterResolver formatterResolver = options.Resolver; - var length = reader.ReadArrayHeader(); - var ____result = new global::ContainingClass.MyMessagePackObject(); - - for (int i = 0; i < length; i++) - { - switch (i) - { - case 0: - ____result.EnumValue = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Deserialize(ref reader, options); - break; - default: - reader.Skip(); - break; - } - } - - reader.Depth--; - return ____result; - } - } + using MsgPack = global::MessagePack; + + public sealed class ContainingClass_MyMessagePackObjectFormatter : MsgPack::Formatters.IMessagePackFormatter + { + + public void Serialize(ref MsgPack::MessagePackWriter writer, global::ContainingClass.MyMessagePackObject value, MsgPack::MessagePackSerializerOptions options) + { + if (value == null) + { + writer.WriteNil(); + return; + } + + MsgPack::IFormatterResolver formatterResolver = options.Resolver; + writer.WriteArrayHeader(1); + global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Serialize(ref writer, value.EnumValue, options); + } + + public global::ContainingClass.MyMessagePackObject Deserialize(ref MsgPack::MessagePackReader reader, MsgPack::MessagePackSerializerOptions options) + { + if (reader.TryReadNil()) + { + return null; + } + + options.Security.DepthStep(ref reader); + MsgPack::IFormatterResolver formatterResolver = options.Resolver; + var length = reader.ReadArrayHeader(); + var ____result = new global::ContainingClass.MyMessagePackObject(); + + for (int i = 0; i < length; i++) + { + switch (i) + { + case 0: + ____result.EnumValue = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Deserialize(ref reader, options); + break; + default: + reader.Skip(); + break; + } + } + + reader.Depth--; + return ____result; + } + } } diff --git a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(NestingClass)/MessagePack.GeneratedResolver.g.cs b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(NestingClass)/MessagePack.GeneratedResolver.g.cs index 7b35af62c..c04dd2799 100644 --- a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(NestingClass)/MessagePack.GeneratedResolver.g.cs +++ b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(NestingClass)/MessagePack.GeneratedResolver.g.cs @@ -4,65 +4,65 @@ namespace MessagePack.Resolvers { - using MsgPack = global::MessagePack; + using MsgPack = global::MessagePack; - public class GeneratedResolver : MsgPack::IFormatterResolver - { - public static readonly MsgPack::IFormatterResolver Instance = new GeneratedResolver(); + public class GeneratedResolver : MsgPack::IFormatterResolver + { + public static readonly MsgPack::IFormatterResolver Instance = new GeneratedResolver(); - public static readonly MsgPack::IFormatterResolver InstanceWithStandardAotResolver = MsgPack::Resolvers.CompositeResolver.Create(Instance, MsgPack::Resolvers.StandardAotResolver.Instance); + public static readonly MsgPack::IFormatterResolver InstanceWithStandardAotResolver = MsgPack::Resolvers.CompositeResolver.Create(Instance, MsgPack::Resolvers.StandardAotResolver.Instance); - private GeneratedResolver() - { - } + private GeneratedResolver() + { + } - public MsgPack::Formatters.IMessagePackFormatter GetFormatter() - { - return FormatterCache.Formatter; - } + public MsgPack::Formatters.IMessagePackFormatter GetFormatter() + { + return FormatterCache.Formatter; + } - private static class FormatterCache - { - internal static readonly MsgPack::Formatters.IMessagePackFormatter Formatter; + private static class FormatterCache + { + internal static readonly MsgPack::Formatters.IMessagePackFormatter Formatter; - static FormatterCache() - { - var f = GeneratedResolverGetFormatterHelper.GetFormatter(typeof(T)); - if (f != null) - { - Formatter = (MsgPack::Formatters.IMessagePackFormatter)f; - } - } - } - } + static FormatterCache() + { + var f = GeneratedResolverGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + Formatter = (MsgPack::Formatters.IMessagePackFormatter)f; + } + } + } + } - internal static class GeneratedResolverGetFormatterHelper - { - private static readonly global::System.Collections.Generic.Dictionary lookup; + internal static class GeneratedResolverGetFormatterHelper + { + private static readonly global::System.Collections.Generic.Dictionary lookup; - static GeneratedResolverGetFormatterHelper() - { - lookup = new global::System.Collections.Generic.Dictionary(2) - { - { typeof(global::ContainingClass.MyEnum), 0 }, - { typeof(global::ContainingClass.MyMessagePackObject), 1 }, - }; - } + static GeneratedResolverGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(2) + { + { typeof(global::ContainingClass.MyEnum), 0 }, + { typeof(global::ContainingClass.MyMessagePackObject), 1 }, + }; + } - internal static object GetFormatter(global::System.Type t) - { - int key; - if (!lookup.TryGetValue(t, out key)) - { - return null; - } + internal static object GetFormatter(global::System.Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } - switch (key) - { - case 0: return new MessagePack.Formatters.ContainingClass_MyEnumFormatter(); - case 1: return new MessagePack.Formatters.ContainingClass_MyMessagePackObjectFormatter(); - default: return null; - } - } - } + switch (key) + { + case 0: return new MessagePack.Formatters.ContainingClass_MyEnumFormatter(); + case 1: return new MessagePack.Formatters.ContainingClass_MyMessagePackObjectFormatter(); + default: return null; + } + } + } } diff --git a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(None)/MessagePack.Formatter..MyEnum.g.cs b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(None)/MessagePack.Formatter..MyEnum.g.cs index e8fcd435d..57ff867ef 100644 --- a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(None)/MessagePack.Formatter..MyEnum.g.cs +++ b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(None)/MessagePack.Formatter..MyEnum.g.cs @@ -4,18 +4,18 @@ namespace MessagePack.Formatters { - using MsgPack = global::MessagePack; + using MsgPack = global::MessagePack; - public sealed class MyEnumFormatter : MsgPack::Formatters.IMessagePackFormatter - { - public void Serialize(ref MsgPack::MessagePackWriter writer, global::MyEnum value, MsgPack::MessagePackSerializerOptions options) - { - writer.Write((int)value); - } + public sealed class MyEnumFormatter : MsgPack::Formatters.IMessagePackFormatter + { + public void Serialize(ref MsgPack::MessagePackWriter writer, global::MyEnum value, MsgPack::MessagePackSerializerOptions options) + { + writer.Write((int)value); + } - public global::MyEnum Deserialize(ref MsgPack::MessagePackReader reader, MsgPack::MessagePackSerializerOptions options) - { - return (global::MyEnum)reader.ReadInt32(); - } - } + public global::MyEnum Deserialize(ref MsgPack::MessagePackReader reader, MsgPack::MessagePackSerializerOptions options) + { + return (global::MyEnum)reader.ReadInt32(); + } + } } diff --git a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(None)/MessagePack.Formatter.MyMessagePackObject.g.cs b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(None)/MessagePack.Formatter.MyMessagePackObject.g.cs index 1e9c6bad9..c238c420a 100644 --- a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(None)/MessagePack.Formatter.MyMessagePackObject.g.cs +++ b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(None)/MessagePack.Formatter.MyMessagePackObject.g.cs @@ -4,51 +4,51 @@ namespace MessagePack.Formatters { - using MsgPack = global::MessagePack; - - public sealed class MyMessagePackObjectFormatter : MsgPack::Formatters.IMessagePackFormatter - { - - public void Serialize(ref MsgPack::MessagePackWriter writer, global::MyMessagePackObject value, MsgPack::MessagePackSerializerOptions options) - { - if (value == null) - { - writer.WriteNil(); - return; - } - - MsgPack::IFormatterResolver formatterResolver = options.Resolver; - writer.WriteArrayHeader(1); - global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Serialize(ref writer, value.EnumValue, options); - } - - public global::MyMessagePackObject Deserialize(ref MsgPack::MessagePackReader reader, MsgPack::MessagePackSerializerOptions options) - { - if (reader.TryReadNil()) - { - return null; - } - - options.Security.DepthStep(ref reader); - MsgPack::IFormatterResolver formatterResolver = options.Resolver; - var length = reader.ReadArrayHeader(); - var ____result = new global::MyMessagePackObject(); - - for (int i = 0; i < length; i++) - { - switch (i) - { - case 0: - ____result.EnumValue = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Deserialize(ref reader, options); - break; - default: - reader.Skip(); - break; - } - } - - reader.Depth--; - return ____result; - } - } + using MsgPack = global::MessagePack; + + public sealed class MyMessagePackObjectFormatter : MsgPack::Formatters.IMessagePackFormatter + { + + public void Serialize(ref MsgPack::MessagePackWriter writer, global::MyMessagePackObject value, MsgPack::MessagePackSerializerOptions options) + { + if (value == null) + { + writer.WriteNil(); + return; + } + + MsgPack::IFormatterResolver formatterResolver = options.Resolver; + writer.WriteArrayHeader(1); + global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Serialize(ref writer, value.EnumValue, options); + } + + public global::MyMessagePackObject Deserialize(ref MsgPack::MessagePackReader reader, MsgPack::MessagePackSerializerOptions options) + { + if (reader.TryReadNil()) + { + return null; + } + + options.Security.DepthStep(ref reader); + MsgPack::IFormatterResolver formatterResolver = options.Resolver; + var length = reader.ReadArrayHeader(); + var ____result = new global::MyMessagePackObject(); + + for (int i = 0; i < length; i++) + { + switch (i) + { + case 0: + ____result.EnumValue = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Deserialize(ref reader, options); + break; + default: + reader.Skip(); + break; + } + } + + reader.Depth--; + return ____result; + } + } } diff --git a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(None)/MessagePack.GeneratedResolver.g.cs b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(None)/MessagePack.GeneratedResolver.g.cs index d29d2c837..db796ddc1 100644 --- a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(None)/MessagePack.GeneratedResolver.g.cs +++ b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(None)/MessagePack.GeneratedResolver.g.cs @@ -4,65 +4,65 @@ namespace MessagePack.Resolvers { - using MsgPack = global::MessagePack; + using MsgPack = global::MessagePack; - public class GeneratedResolver : MsgPack::IFormatterResolver - { - public static readonly MsgPack::IFormatterResolver Instance = new GeneratedResolver(); + public class GeneratedResolver : MsgPack::IFormatterResolver + { + public static readonly MsgPack::IFormatterResolver Instance = new GeneratedResolver(); - public static readonly MsgPack::IFormatterResolver InstanceWithStandardAotResolver = MsgPack::Resolvers.CompositeResolver.Create(Instance, MsgPack::Resolvers.StandardAotResolver.Instance); + public static readonly MsgPack::IFormatterResolver InstanceWithStandardAotResolver = MsgPack::Resolvers.CompositeResolver.Create(Instance, MsgPack::Resolvers.StandardAotResolver.Instance); - private GeneratedResolver() - { - } + private GeneratedResolver() + { + } - public MsgPack::Formatters.IMessagePackFormatter GetFormatter() - { - return FormatterCache.Formatter; - } + public MsgPack::Formatters.IMessagePackFormatter GetFormatter() + { + return FormatterCache.Formatter; + } - private static class FormatterCache - { - internal static readonly MsgPack::Formatters.IMessagePackFormatter Formatter; + private static class FormatterCache + { + internal static readonly MsgPack::Formatters.IMessagePackFormatter Formatter; - static FormatterCache() - { - var f = GeneratedResolverGetFormatterHelper.GetFormatter(typeof(T)); - if (f != null) - { - Formatter = (MsgPack::Formatters.IMessagePackFormatter)f; - } - } - } - } + static FormatterCache() + { + var f = GeneratedResolverGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + Formatter = (MsgPack::Formatters.IMessagePackFormatter)f; + } + } + } + } - internal static class GeneratedResolverGetFormatterHelper - { - private static readonly global::System.Collections.Generic.Dictionary lookup; + internal static class GeneratedResolverGetFormatterHelper + { + private static readonly global::System.Collections.Generic.Dictionary lookup; - static GeneratedResolverGetFormatterHelper() - { - lookup = new global::System.Collections.Generic.Dictionary(2) - { - { typeof(global::MyEnum), 0 }, - { typeof(global::MyMessagePackObject), 1 }, - }; - } + static GeneratedResolverGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(2) + { + { typeof(global::MyEnum), 0 }, + { typeof(global::MyMessagePackObject), 1 }, + }; + } - internal static object GetFormatter(global::System.Type t) - { - int key; - if (!lookup.TryGetValue(t, out key)) - { - return null; - } + internal static object GetFormatter(global::System.Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } - switch (key) - { - case 0: return new MessagePack.Formatters.MyEnumFormatter(); - case 1: return new MessagePack.Formatters.MyMessagePackObjectFormatter(); - default: return null; - } - } - } + switch (key) + { + case 0: return new MessagePack.Formatters.MyEnumFormatter(); + case 1: return new MessagePack.Formatters.MyMessagePackObjectFormatter(); + default: return null; + } + } + } } diff --git a/tests/MessagePack.Generator.Tests/Resources/TwoTypes/MessagePack.Formatter.Object1.g.cs b/tests/MessagePack.Generator.Tests/Resources/TwoTypes/MessagePack.Formatter.Object1.g.cs index 7228bb8ac..c84450fd0 100644 --- a/tests/MessagePack.Generator.Tests/Resources/TwoTypes/MessagePack.Formatter.Object1.g.cs +++ b/tests/MessagePack.Generator.Tests/Resources/TwoTypes/MessagePack.Formatter.Object1.g.cs @@ -4,31 +4,31 @@ namespace MessagePack.Formatters { - using MsgPack = global::MessagePack; + using MsgPack = global::MessagePack; - public sealed class Object1Formatter : MsgPack::Formatters.IMessagePackFormatter - { + public sealed class Object1Formatter : MsgPack::Formatters.IMessagePackFormatter + { - public void Serialize(ref MsgPack::MessagePackWriter writer, global::Object1 value, MsgPack::MessagePackSerializerOptions options) - { - if (value == null) - { - writer.WriteNil(); - return; - } + public void Serialize(ref MsgPack::MessagePackWriter writer, global::Object1 value, MsgPack::MessagePackSerializerOptions options) + { + if (value == null) + { + writer.WriteNil(); + return; + } - writer.WriteArrayHeader(0); - } + writer.WriteArrayHeader(0); + } - public global::Object1 Deserialize(ref MsgPack::MessagePackReader reader, MsgPack::MessagePackSerializerOptions options) - { - if (reader.TryReadNil()) - { - return null; - } + public global::Object1 Deserialize(ref MsgPack::MessagePackReader reader, MsgPack::MessagePackSerializerOptions options) + { + if (reader.TryReadNil()) + { + return null; + } - reader.Skip(); - return new global::Object1(); - } - } + reader.Skip(); + return new global::Object1(); + } + } } diff --git a/tests/MessagePack.Generator.Tests/Resources/TwoTypes/MessagePack.Formatter.Object2.g.cs b/tests/MessagePack.Generator.Tests/Resources/TwoTypes/MessagePack.Formatter.Object2.g.cs index f59226c33..96e60d630 100644 --- a/tests/MessagePack.Generator.Tests/Resources/TwoTypes/MessagePack.Formatter.Object2.g.cs +++ b/tests/MessagePack.Generator.Tests/Resources/TwoTypes/MessagePack.Formatter.Object2.g.cs @@ -4,31 +4,31 @@ namespace MessagePack.Formatters { - using MsgPack = global::MessagePack; + using MsgPack = global::MessagePack; - public sealed class Object2Formatter : MsgPack::Formatters.IMessagePackFormatter - { + public sealed class Object2Formatter : MsgPack::Formatters.IMessagePackFormatter + { - public void Serialize(ref MsgPack::MessagePackWriter writer, global::Object2 value, MsgPack::MessagePackSerializerOptions options) - { - if (value == null) - { - writer.WriteNil(); - return; - } + public void Serialize(ref MsgPack::MessagePackWriter writer, global::Object2 value, MsgPack::MessagePackSerializerOptions options) + { + if (value == null) + { + writer.WriteNil(); + return; + } - writer.WriteArrayHeader(0); - } + writer.WriteArrayHeader(0); + } - public global::Object2 Deserialize(ref MsgPack::MessagePackReader reader, MsgPack::MessagePackSerializerOptions options) - { - if (reader.TryReadNil()) - { - return null; - } + public global::Object2 Deserialize(ref MsgPack::MessagePackReader reader, MsgPack::MessagePackSerializerOptions options) + { + if (reader.TryReadNil()) + { + return null; + } - reader.Skip(); - return new global::Object2(); - } - } + reader.Skip(); + return new global::Object2(); + } + } } diff --git a/tests/MessagePack.Generator.Tests/Resources/TwoTypes/MessagePack.GeneratedResolver.g.cs b/tests/MessagePack.Generator.Tests/Resources/TwoTypes/MessagePack.GeneratedResolver.g.cs index 63c168d62..a74021ae2 100644 --- a/tests/MessagePack.Generator.Tests/Resources/TwoTypes/MessagePack.GeneratedResolver.g.cs +++ b/tests/MessagePack.Generator.Tests/Resources/TwoTypes/MessagePack.GeneratedResolver.g.cs @@ -4,65 +4,65 @@ namespace MessagePack.Resolvers { - using MsgPack = global::MessagePack; + using MsgPack = global::MessagePack; - public class GeneratedResolver : MsgPack::IFormatterResolver - { - public static readonly MsgPack::IFormatterResolver Instance = new GeneratedResolver(); + public class GeneratedResolver : MsgPack::IFormatterResolver + { + public static readonly MsgPack::IFormatterResolver Instance = new GeneratedResolver(); - public static readonly MsgPack::IFormatterResolver InstanceWithStandardAotResolver = MsgPack::Resolvers.CompositeResolver.Create(Instance, MsgPack::Resolvers.StandardAotResolver.Instance); + public static readonly MsgPack::IFormatterResolver InstanceWithStandardAotResolver = MsgPack::Resolvers.CompositeResolver.Create(Instance, MsgPack::Resolvers.StandardAotResolver.Instance); - private GeneratedResolver() - { - } + private GeneratedResolver() + { + } - public MsgPack::Formatters.IMessagePackFormatter GetFormatter() - { - return FormatterCache.Formatter; - } + public MsgPack::Formatters.IMessagePackFormatter GetFormatter() + { + return FormatterCache.Formatter; + } - private static class FormatterCache - { - internal static readonly MsgPack::Formatters.IMessagePackFormatter Formatter; + private static class FormatterCache + { + internal static readonly MsgPack::Formatters.IMessagePackFormatter Formatter; - static FormatterCache() - { - var f = GeneratedResolverGetFormatterHelper.GetFormatter(typeof(T)); - if (f != null) - { - Formatter = (MsgPack::Formatters.IMessagePackFormatter)f; - } - } - } - } + static FormatterCache() + { + var f = GeneratedResolverGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + Formatter = (MsgPack::Formatters.IMessagePackFormatter)f; + } + } + } + } - internal static class GeneratedResolverGetFormatterHelper - { - private static readonly global::System.Collections.Generic.Dictionary lookup; + internal static class GeneratedResolverGetFormatterHelper + { + private static readonly global::System.Collections.Generic.Dictionary lookup; - static GeneratedResolverGetFormatterHelper() - { - lookup = new global::System.Collections.Generic.Dictionary(2) - { - { typeof(global::Object1), 0 }, - { typeof(global::Object2), 1 }, - }; - } + static GeneratedResolverGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(2) + { + { typeof(global::Object1), 0 }, + { typeof(global::Object2), 1 }, + }; + } - internal static object GetFormatter(global::System.Type t) - { - int key; - if (!lookup.TryGetValue(t, out key)) - { - return null; - } + internal static object GetFormatter(global::System.Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } - switch (key) - { - case 0: return new MessagePack.Formatters.Object1Formatter(); - case 1: return new MessagePack.Formatters.Object2Formatter(); - default: return null; - } - } - } + switch (key) + { + case 0: return new MessagePack.Formatters.Object1Formatter(); + case 1: return new MessagePack.Formatters.Object2Formatter(); + default: return null; + } + } + } } From 0471bcb4646cdffbc394ac9e846c88e00ed27fee Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Thu, 30 Mar 2023 09:15:50 -0600 Subject: [PATCH 052/660] Further shorten generated syntax --- .../CodeAnalysis/MemberSerializationInfo.cs | 6 +++--- .../Transforms/EnumTemplate.cs | 14 +++++++++----- .../Transforms/EnumTemplate.tt | 9 +++++---- ...ssagePack.Formatter.MyTestNamespace.MyEnum.g.cs | 9 +++++---- ...matter.MyTestNamespace.MyMessagePackObject.g.cs | 4 ++-- ...sagePack.Formatter..ContainingClass_MyEnum.g.cs | 9 +++++---- ...matter.ContainingClass_MyMessagePackObject.g.cs | 4 ++-- .../MessagePack.Formatter..MyEnum.g.cs | 9 +++++---- .../MessagePack.Formatter.MyMessagePackObject.g.cs | 4 ++-- 9 files changed, 38 insertions(+), 30 deletions(-) diff --git a/src/MessagePack.Generator/CodeAnalysis/MemberSerializationInfo.cs b/src/MessagePack.Generator/CodeAnalysis/MemberSerializationInfo.cs index 90cb9f145..2f9ad94c7 100644 --- a/src/MessagePack.Generator/CodeAnalysis/MemberSerializationInfo.cs +++ b/src/MessagePack.Generator/CodeAnalysis/MemberSerializationInfo.cs @@ -30,7 +30,7 @@ public string GetSerializeMethodString() } else { - return $"global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<{this.Type}>(formatterResolver).Serialize(ref writer, value.{this.Name}, options)"; + return $"MsgPack::FormatterResolverExtensions.GetFormatterWithVerify<{this.Type}>(formatterResolver).Serialize(ref writer, value.{this.Name}, options)"; } } @@ -44,7 +44,7 @@ public string GetDeserializeMethodString() { if (this.Type == "byte[]") { - return "global::MessagePack.Internal.CodeGenHelpers.GetArrayFromNullableSequence(reader.ReadBytes())"; + return "MsgPack::Internal.CodeGenHelpers.GetArrayFromNullableSequence(reader.ReadBytes())"; } else { @@ -53,7 +53,7 @@ public string GetDeserializeMethodString() } else { - return $"global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify<{this.Type}>(formatterResolver).Deserialize(ref reader, options)"; + return $"MsgPack::FormatterResolverExtensions.GetFormatterWithVerify<{this.Type}>(formatterResolver).Deserialize(ref reader, options)"; } } } diff --git a/src/MessagePack.Generator/Transforms/EnumTemplate.cs b/src/MessagePack.Generator/Transforms/EnumTemplate.cs index 8ac950d11..dedb1636d 100644 --- a/src/MessagePack.Generator/Transforms/EnumTemplate.cs +++ b/src/MessagePack.Generator/Transforms/EnumTemplate.cs @@ -24,19 +24,23 @@ public virtual string TransformText() { this.Write("\r\nnamespace "); this.Write(this.ToStringHelper.ToStringWithCulture(Namespace)); - this.Write("\r\n{\r\n\tusing MsgPack = global::MessagePack;\r\n\r\n\tpublic sealed class "); + this.Write("\r\n{\r\n\tusing MsgPack = global::MessagePack;\r\n\tusing "); this.Write(this.ToStringHelper.ToStringWithCulture(Info.Name)); - this.Write("Formatter : MsgPack::Formatters.IMessagePackFormatter<"); + this.Write(" = "); this.Write(this.ToStringHelper.ToStringWithCulture(Info.FullName)); + this.Write(";\r\n\r\n\tpublic sealed class "); + this.Write(this.ToStringHelper.ToStringWithCulture(Info.Name)); + this.Write("Formatter : MsgPack::Formatters.IMessagePackFormatter<"); + this.Write(this.ToStringHelper.ToStringWithCulture(Info.Name)); this.Write(">\r\n\t{\r\n\t\tpublic void Serialize(ref MsgPack::MessagePackWriter writer, "); - this.Write(this.ToStringHelper.ToStringWithCulture(Info.FullName)); + this.Write(this.ToStringHelper.ToStringWithCulture(Info.Name)); this.Write(" value, MsgPack::MessagePackSerializerOptions options)\r\n\t\t{\r\n\t\t\twriter.Write(("); this.Write(this.ToStringHelper.ToStringWithCulture(Info.UnderlyingTypeKeyword)); this.Write(")value);\r\n\t\t}\r\n\r\n\t\tpublic "); - this.Write(this.ToStringHelper.ToStringWithCulture(Info.FullName)); + this.Write(this.ToStringHelper.ToStringWithCulture(Info.Name)); this.Write(" Deserialize(ref MsgPack::MessagePackReader reader, MsgPack::MessagePackSerialize" + "rOptions options)\r\n\t\t{\r\n\t\t\treturn ("); - this.Write(this.ToStringHelper.ToStringWithCulture(Info.FullName)); + this.Write(this.ToStringHelper.ToStringWithCulture(Info.Name)); this.Write(")reader.Read"); this.Write(this.ToStringHelper.ToStringWithCulture(Info.UnderlyingTypeName)); this.Write("();\r\n\t\t}\r\n\t}\r\n}\r\n"); diff --git a/src/MessagePack.Generator/Transforms/EnumTemplate.tt b/src/MessagePack.Generator/Transforms/EnumTemplate.tt index 273458fc7..877c01bf2 100644 --- a/src/MessagePack.Generator/Transforms/EnumTemplate.tt +++ b/src/MessagePack.Generator/Transforms/EnumTemplate.tt @@ -4,17 +4,18 @@ namespace <#= Namespace #> { using MsgPack = global::MessagePack; + using <#= Info.Name #> = <#= Info.FullName #>; - public sealed class <#= Info.Name #>Formatter : MsgPack::Formatters.IMessagePackFormatter<<#= Info.FullName #>> + public sealed class <#= Info.Name #>Formatter : MsgPack::Formatters.IMessagePackFormatter<<#= Info.Name #>> { - public void Serialize(ref MsgPack::MessagePackWriter writer, <#= Info.FullName #> value, MsgPack::MessagePackSerializerOptions options) + public void Serialize(ref MsgPack::MessagePackWriter writer, <#= Info.Name #> value, MsgPack::MessagePackSerializerOptions options) { writer.Write((<#= Info.UnderlyingTypeKeyword #>)value); } - public <#= Info.FullName #> Deserialize(ref MsgPack::MessagePackReader reader, MsgPack::MessagePackSerializerOptions options) + public <#= Info.Name #> Deserialize(ref MsgPack::MessagePackReader reader, MsgPack::MessagePackSerializerOptions options) { - return (<#= Info.FullName #>)reader.Read<#= Info.UnderlyingTypeName #>(); + return (<#= Info.Name #>)reader.Read<#= Info.UnderlyingTypeName #>(); } } } diff --git a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(Namespace)/MessagePack.Formatter.MyTestNamespace.MyEnum.g.cs b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(Namespace)/MessagePack.Formatter.MyTestNamespace.MyEnum.g.cs index d8498c4a5..a8e33176a 100644 --- a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(Namespace)/MessagePack.Formatter.MyTestNamespace.MyEnum.g.cs +++ b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(Namespace)/MessagePack.Formatter.MyTestNamespace.MyEnum.g.cs @@ -5,17 +5,18 @@ namespace MessagePack.Formatters.MyTestNamespace { using MsgPack = global::MessagePack; + using MyEnum = global::MyTestNamespace.MyEnum; - public sealed class MyEnumFormatter : MsgPack::Formatters.IMessagePackFormatter + public sealed class MyEnumFormatter : MsgPack::Formatters.IMessagePackFormatter { - public void Serialize(ref MsgPack::MessagePackWriter writer, global::MyTestNamespace.MyEnum value, MsgPack::MessagePackSerializerOptions options) + public void Serialize(ref MsgPack::MessagePackWriter writer, MyEnum value, MsgPack::MessagePackSerializerOptions options) { writer.Write((int)value); } - public global::MyTestNamespace.MyEnum Deserialize(ref MsgPack::MessagePackReader reader, MsgPack::MessagePackSerializerOptions options) + public MyEnum Deserialize(ref MsgPack::MessagePackReader reader, MsgPack::MessagePackSerializerOptions options) { - return (global::MyTestNamespace.MyEnum)reader.ReadInt32(); + return (MyEnum)reader.ReadInt32(); } } } diff --git a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(Namespace)/MessagePack.Formatter.MyTestNamespace.MyMessagePackObject.g.cs b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(Namespace)/MessagePack.Formatter.MyTestNamespace.MyMessagePackObject.g.cs index b9877985f..2f12c1e1f 100644 --- a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(Namespace)/MessagePack.Formatter.MyTestNamespace.MyMessagePackObject.g.cs +++ b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(Namespace)/MessagePack.Formatter.MyTestNamespace.MyMessagePackObject.g.cs @@ -19,7 +19,7 @@ public void Serialize(ref MsgPack::MessagePackWriter writer, global::MyTestNames MsgPack::IFormatterResolver formatterResolver = options.Resolver; writer.WriteArrayHeader(1); - global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Serialize(ref writer, value.EnumValue, options); + MsgPack::FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Serialize(ref writer, value.EnumValue, options); } public global::MyTestNamespace.MyMessagePackObject Deserialize(ref MsgPack::MessagePackReader reader, MsgPack::MessagePackSerializerOptions options) @@ -39,7 +39,7 @@ public void Serialize(ref MsgPack::MessagePackWriter writer, global::MyTestNames switch (i) { case 0: - ____result.EnumValue = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Deserialize(ref reader, options); + ____result.EnumValue = MsgPack::FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Deserialize(ref reader, options); break; default: reader.Skip(); diff --git a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(NestingClass)/MessagePack.Formatter..ContainingClass_MyEnum.g.cs b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(NestingClass)/MessagePack.Formatter..ContainingClass_MyEnum.g.cs index 84955bdc0..31874e68d 100644 --- a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(NestingClass)/MessagePack.Formatter..ContainingClass_MyEnum.g.cs +++ b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(NestingClass)/MessagePack.Formatter..ContainingClass_MyEnum.g.cs @@ -5,17 +5,18 @@ namespace MessagePack.Formatters { using MsgPack = global::MessagePack; + using ContainingClass_MyEnum = global::ContainingClass.MyEnum; - public sealed class ContainingClass_MyEnumFormatter : MsgPack::Formatters.IMessagePackFormatter + public sealed class ContainingClass_MyEnumFormatter : MsgPack::Formatters.IMessagePackFormatter { - public void Serialize(ref MsgPack::MessagePackWriter writer, global::ContainingClass.MyEnum value, MsgPack::MessagePackSerializerOptions options) + public void Serialize(ref MsgPack::MessagePackWriter writer, ContainingClass_MyEnum value, MsgPack::MessagePackSerializerOptions options) { writer.Write((int)value); } - public global::ContainingClass.MyEnum Deserialize(ref MsgPack::MessagePackReader reader, MsgPack::MessagePackSerializerOptions options) + public ContainingClass_MyEnum Deserialize(ref MsgPack::MessagePackReader reader, MsgPack::MessagePackSerializerOptions options) { - return (global::ContainingClass.MyEnum)reader.ReadInt32(); + return (ContainingClass_MyEnum)reader.ReadInt32(); } } } diff --git a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(NestingClass)/MessagePack.Formatter.ContainingClass_MyMessagePackObject.g.cs b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(NestingClass)/MessagePack.Formatter.ContainingClass_MyMessagePackObject.g.cs index 0f56f0989..02d72f585 100644 --- a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(NestingClass)/MessagePack.Formatter.ContainingClass_MyMessagePackObject.g.cs +++ b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(NestingClass)/MessagePack.Formatter.ContainingClass_MyMessagePackObject.g.cs @@ -19,7 +19,7 @@ public void Serialize(ref MsgPack::MessagePackWriter writer, global::ContainingC MsgPack::IFormatterResolver formatterResolver = options.Resolver; writer.WriteArrayHeader(1); - global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Serialize(ref writer, value.EnumValue, options); + MsgPack::FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Serialize(ref writer, value.EnumValue, options); } public global::ContainingClass.MyMessagePackObject Deserialize(ref MsgPack::MessagePackReader reader, MsgPack::MessagePackSerializerOptions options) @@ -39,7 +39,7 @@ public void Serialize(ref MsgPack::MessagePackWriter writer, global::ContainingC switch (i) { case 0: - ____result.EnumValue = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Deserialize(ref reader, options); + ____result.EnumValue = MsgPack::FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Deserialize(ref reader, options); break; default: reader.Skip(); diff --git a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(None)/MessagePack.Formatter..MyEnum.g.cs b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(None)/MessagePack.Formatter..MyEnum.g.cs index 57ff867ef..7a38011f2 100644 --- a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(None)/MessagePack.Formatter..MyEnum.g.cs +++ b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(None)/MessagePack.Formatter..MyEnum.g.cs @@ -5,17 +5,18 @@ namespace MessagePack.Formatters { using MsgPack = global::MessagePack; + using MyEnum = global::MyEnum; - public sealed class MyEnumFormatter : MsgPack::Formatters.IMessagePackFormatter + public sealed class MyEnumFormatter : MsgPack::Formatters.IMessagePackFormatter { - public void Serialize(ref MsgPack::MessagePackWriter writer, global::MyEnum value, MsgPack::MessagePackSerializerOptions options) + public void Serialize(ref MsgPack::MessagePackWriter writer, MyEnum value, MsgPack::MessagePackSerializerOptions options) { writer.Write((int)value); } - public global::MyEnum Deserialize(ref MsgPack::MessagePackReader reader, MsgPack::MessagePackSerializerOptions options) + public MyEnum Deserialize(ref MsgPack::MessagePackReader reader, MsgPack::MessagePackSerializerOptions options) { - return (global::MyEnum)reader.ReadInt32(); + return (MyEnum)reader.ReadInt32(); } } } diff --git a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(None)/MessagePack.Formatter.MyMessagePackObject.g.cs b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(None)/MessagePack.Formatter.MyMessagePackObject.g.cs index c238c420a..b93284ded 100644 --- a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(None)/MessagePack.Formatter.MyMessagePackObject.g.cs +++ b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(None)/MessagePack.Formatter.MyMessagePackObject.g.cs @@ -19,7 +19,7 @@ public void Serialize(ref MsgPack::MessagePackWriter writer, global::MyMessagePa MsgPack::IFormatterResolver formatterResolver = options.Resolver; writer.WriteArrayHeader(1); - global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Serialize(ref writer, value.EnumValue, options); + MsgPack::FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Serialize(ref writer, value.EnumValue, options); } public global::MyMessagePackObject Deserialize(ref MsgPack::MessagePackReader reader, MsgPack::MessagePackSerializerOptions options) @@ -39,7 +39,7 @@ public void Serialize(ref MsgPack::MessagePackWriter writer, global::MyMessagePa switch (i) { case 0: - ____result.EnumValue = global::MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Deserialize(ref reader, options); + ____result.EnumValue = MsgPack::FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Deserialize(ref reader, options); break; default: reader.Skip(); From 27627dec8fc7cf73e108e7173da96602b77f811b Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Thu, 30 Mar 2023 09:24:33 -0600 Subject: [PATCH 053/660] Test and fix UsesMapMode --- .../StringKey/StringKeyFormatterTemplate.cs | 128 +++++++-------- .../StringKey/StringKeyFormatterTemplate.tt | 146 +++++++++--------- .../GenerateEnumFormatterTest.cs | 6 +- .../MultipleTypesTests.cs | 7 +- ...Pack.Formatter.MyTestNamespace.MyEnum.g.cs | 0 ...r.MyTestNamespace.MyMessagePackObject.g.cs | 0 .../MessagePack.GeneratedResolver.g.cs | 0 ...Pack.Formatter.MyTestNamespace.MyEnum.g.cs | 22 +++ ...r.MyTestNamespace.MyMessagePackObject.g.cs | 62 ++++++++ .../MessagePack.GeneratedResolver.g.cs | 68 ++++++++ ...ack.Formatter..ContainingClass_MyEnum.g.cs | 0 ...r.ContainingClass_MyMessagePackObject.g.cs | 0 .../MessagePack.GeneratedResolver.g.cs | 0 ...ack.Formatter..ContainingClass_MyEnum.g.cs | 22 +++ ...r.ContainingClass_MyMessagePackObject.g.cs | 62 ++++++++ .../MessagePack.GeneratedResolver.g.cs | 68 ++++++++ .../MessagePack.Formatter..MyEnum.g.cs | 0 ...agePack.Formatter.MyMessagePackObject.g.cs | 0 .../MessagePack.GeneratedResolver.g.cs | 0 .../MessagePack.Formatter..MyEnum.g.cs | 22 +++ ...agePack.Formatter.MyMessagePackObject.g.cs | 62 ++++++++ .../MessagePack.GeneratedResolver.g.cs | 68 ++++++++ .../MessagePack.Formatter.Object1.g.cs | 0 .../MessagePack.Formatter.Object2.g.cs | 0 .../MessagePack.GeneratedResolver.g.cs | 0 .../MessagePack.Formatter.Object1.g.cs | 34 ++++ .../MessagePack.Formatter.Object2.g.cs | 34 ++++ .../MessagePack.GeneratedResolver.g.cs | 68 ++++++++ .../CSharpSourceGeneratorVerifier`1+Test.cs | 5 +- 29 files changed, 737 insertions(+), 147 deletions(-) rename tests/MessagePack.Generator.Tests/Resources/{EnumFormatter(Namespace) => EnumFormatter(Namespace, False)}/MessagePack.Formatter.MyTestNamespace.MyEnum.g.cs (100%) rename tests/MessagePack.Generator.Tests/Resources/{EnumFormatter(Namespace) => EnumFormatter(Namespace, False)}/MessagePack.Formatter.MyTestNamespace.MyMessagePackObject.g.cs (100%) rename tests/MessagePack.Generator.Tests/Resources/{EnumFormatter(Namespace) => EnumFormatter(Namespace, False)}/MessagePack.GeneratedResolver.g.cs (100%) create mode 100644 tests/MessagePack.Generator.Tests/Resources/EnumFormatter(Namespace, True)/MessagePack.Formatter.MyTestNamespace.MyEnum.g.cs create mode 100644 tests/MessagePack.Generator.Tests/Resources/EnumFormatter(Namespace, True)/MessagePack.Formatter.MyTestNamespace.MyMessagePackObject.g.cs create mode 100644 tests/MessagePack.Generator.Tests/Resources/EnumFormatter(Namespace, True)/MessagePack.GeneratedResolver.g.cs rename tests/MessagePack.Generator.Tests/Resources/{EnumFormatter(NestingClass) => EnumFormatter(NestingClass, False)}/MessagePack.Formatter..ContainingClass_MyEnum.g.cs (100%) rename tests/MessagePack.Generator.Tests/Resources/{EnumFormatter(NestingClass) => EnumFormatter(NestingClass, False)}/MessagePack.Formatter.ContainingClass_MyMessagePackObject.g.cs (100%) rename tests/MessagePack.Generator.Tests/Resources/{EnumFormatter(NestingClass) => EnumFormatter(NestingClass, False)}/MessagePack.GeneratedResolver.g.cs (100%) create mode 100644 tests/MessagePack.Generator.Tests/Resources/EnumFormatter(NestingClass, True)/MessagePack.Formatter..ContainingClass_MyEnum.g.cs create mode 100644 tests/MessagePack.Generator.Tests/Resources/EnumFormatter(NestingClass, True)/MessagePack.Formatter.ContainingClass_MyMessagePackObject.g.cs create mode 100644 tests/MessagePack.Generator.Tests/Resources/EnumFormatter(NestingClass, True)/MessagePack.GeneratedResolver.g.cs rename tests/MessagePack.Generator.Tests/Resources/{EnumFormatter(None) => EnumFormatter(None, False)}/MessagePack.Formatter..MyEnum.g.cs (100%) rename tests/MessagePack.Generator.Tests/Resources/{EnumFormatter(None) => EnumFormatter(None, False)}/MessagePack.Formatter.MyMessagePackObject.g.cs (100%) rename tests/MessagePack.Generator.Tests/Resources/{EnumFormatter(None) => EnumFormatter(None, False)}/MessagePack.GeneratedResolver.g.cs (100%) create mode 100644 tests/MessagePack.Generator.Tests/Resources/EnumFormatter(None, True)/MessagePack.Formatter..MyEnum.g.cs create mode 100644 tests/MessagePack.Generator.Tests/Resources/EnumFormatter(None, True)/MessagePack.Formatter.MyMessagePackObject.g.cs create mode 100644 tests/MessagePack.Generator.Tests/Resources/EnumFormatter(None, True)/MessagePack.GeneratedResolver.g.cs rename tests/MessagePack.Generator.Tests/Resources/{TwoTypes => TwoTypes(False)}/MessagePack.Formatter.Object1.g.cs (100%) rename tests/MessagePack.Generator.Tests/Resources/{TwoTypes => TwoTypes(False)}/MessagePack.Formatter.Object2.g.cs (100%) rename tests/MessagePack.Generator.Tests/Resources/{TwoTypes => TwoTypes(False)}/MessagePack.GeneratedResolver.g.cs (100%) create mode 100644 tests/MessagePack.Generator.Tests/Resources/TwoTypes(True)/MessagePack.Formatter.Object1.g.cs create mode 100644 tests/MessagePack.Generator.Tests/Resources/TwoTypes(True)/MessagePack.Formatter.Object2.g.cs create mode 100644 tests/MessagePack.Generator.Tests/Resources/TwoTypes(True)/MessagePack.GeneratedResolver.g.cs diff --git a/src/MessagePack.Generator/Transforms/StringKey/StringKeyFormatterTemplate.cs b/src/MessagePack.Generator/Transforms/StringKey/StringKeyFormatterTemplate.cs index 410245601..23108bc60 100644 --- a/src/MessagePack.Generator/Transforms/StringKey/StringKeyFormatterTemplate.cs +++ b/src/MessagePack.Generator/Transforms/StringKey/StringKeyFormatterTemplate.cs @@ -27,30 +27,30 @@ public virtual string TransformText() { this.Write("\r\nnamespace "); this.Write(this.ToStringHelper.ToStringWithCulture(Namespace)); - this.Write("\r\n{\r\n"); + this.Write("\r\n{\r\n\tusing MsgPack = global::MessagePack;\r\n\r\n"); var list = new List>(); - foreach (var member in Info.Members) { - var binary = EmbedStringHelper.Utf8.GetBytes(member.StringKey); - list.Add(new ValueTuple(member, binary)); - } + foreach (var member in Info.Members) { + var binary = EmbedStringHelper.Utf8.GetBytes(member.StringKey); + list.Add(new ValueTuple(member, binary)); + } - bool isFormatterResolverNecessary = ShouldUseFormatterResolverHelper.ShouldUseFormatterResolver(Info.Members); - this.Write(" public sealed class "); + bool isFormatterResolverNecessary = ShouldUseFormatterResolverHelper.ShouldUseFormatterResolver(Info.Members); + this.Write("\tpublic sealed class "); this.Write(this.ToStringHelper.ToStringWithCulture(Info.FormatterNameWithoutNamespace)); this.Write(" : global::MessagePack.Formatters.IMessagePackFormatter<"); this.Write(this.ToStringHelper.ToStringWithCulture(Info.FullName)); this.Write(">\r\n"); foreach (var typeArg in Info.GenericTypeParameters.Where(x => x.HasConstraints)) { - this.Write(" where "); + this.Write("\t\twhere "); this.Write(this.ToStringHelper.ToStringWithCulture(typeArg.Name)); this.Write(" : "); this.Write(this.ToStringHelper.ToStringWithCulture(typeArg.Constraints)); this.Write("\r\n"); } - this.Write(" {\r\n"); + this.Write("\t{\r\n"); foreach (var item in Info.Members) { if (item.CustomFormatterTypeName != null) { - this.Write(" private readonly "); + this.Write("\t\tprivate readonly "); this.Write(this.ToStringHelper.ToStringWithCulture(item.CustomFormatterTypeName)); this.Write(" __"); this.Write(this.ToStringHelper.ToStringWithCulture(item.Name)); @@ -60,11 +60,11 @@ public virtual string TransformText() } } for (var i = 0; i < list.Count; i++) { - var member = list[i].Item1; - var binary = list[i].Item2; - this.Write(" // "); + var member = list[i].Item1; + var binary = list[i].Item2; + this.Write("\t\t// "); this.Write(this.ToStringHelper.ToStringWithCulture(member.StringKey)); - this.Write("\r\n private static global::System.ReadOnlySpan GetSpan_"); + this.Write("\r\n\t\tprivate static global::System.ReadOnlySpan GetSpan_"); this.Write(this.ToStringHelper.ToStringWithCulture(member.Name)); this.Write("() => "); this.Write(this.ToStringHelper.ToStringWithCulture(EmbedStringHelper.ToByteArrayString(binary))); @@ -73,118 +73,110 @@ public virtual string TransformText() if (list.Count != 0) { this.Write("\r\n"); } - this.Write(" public void Serialize(ref global::MessagePack.MessagePackWriter writer, "); + this.Write("\t\tpublic void Serialize(ref global::MessagePack.MessagePackWriter writer, "); this.Write(this.ToStringHelper.ToStringWithCulture(Info.FullName)); - this.Write(" value, global::MessagePack.MessagePackSerializerOptions options)\r\n {\r\n"); + this.Write(" value, global::MessagePack.MessagePackSerializerOptions options)\r\n\t\t{\r\n"); if (Info.IsClass) { - this.Write(" if (value is null)\r\n {\r\n writer.WriteNil();" + - "\r\n return;\r\n }\r\n\r\n"); + this.Write("\t\t\tif (value is null)\r\n\t\t\t{\r\n\t\t\t\twriter.WriteNil();\r\n\t\t\t\treturn;\r\n\t\t\t}\r\n\r\n"); } - if (isFormatterResolverNecessary) { - this.Write(" var formatterResolver = options.Resolver;\r\n"); + if (isFormatterResolverNecessary) { + this.Write("\t\t\tvar formatterResolver = options.Resolver;\r\n"); } - if (Info.HasIMessagePackSerializationCallbackReceiver) { - if (Info.NeedsCastOnBefore) { - this.Write(" ((global::MessagePack.IMessagePackSerializationCallbackReceiver)value" + - ").OnBeforeSerialize();\r\n"); + if (Info.HasIMessagePackSerializationCallbackReceiver) { + if (Info.NeedsCastOnBefore) { + this.Write("\t\t\t((global::MessagePack.IMessagePackSerializationCallbackReceiver)value).OnBefor" + + "eSerialize();\r\n"); } else { - this.Write(" value.OnBeforeSerialize();\r\n"); + this.Write("\t\t\tvalue.OnBeforeSerialize();\r\n"); } } - this.Write(" writer.WriteMapHeader("); + this.Write("\t\t\twriter.WriteMapHeader("); this.Write(this.ToStringHelper.ToStringWithCulture(list.Count)); this.Write(");\r\n"); foreach (var memberAndBinary in list) { - var member = memberAndBinary.Item1; - this.Write(" writer.WriteRaw(GetSpan_"); + var member = memberAndBinary.Item1; + this.Write("\t\t\twriter.WriteRaw(GetSpan_"); this.Write(this.ToStringHelper.ToStringWithCulture(member.Name)); - this.Write("());\r\n "); + this.Write("());\r\n\t\t\t"); this.Write(this.ToStringHelper.ToStringWithCulture(member.GetSerializeMethodString())); this.Write(";\r\n"); } - this.Write(" }\r\n\r\n public "); + this.Write("\t\t}\r\n\r\n\t\tpublic "); this.Write(this.ToStringHelper.ToStringWithCulture(Info.FullName)); this.Write(" Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePac" + - "k.MessagePackSerializerOptions options)\r\n {\r\n if (reader.TryRe" + - "adNil())\r\n {\r\n"); + "k.MessagePackSerializerOptions options)\r\n\t\t{\r\n\t\t\tif (reader.TryReadNil())\r\n\t\t\t{\r" + + "\n"); if (Info.IsClass) { - this.Write(" return null;\r\n"); + this.Write("\t\t\t\treturn null;\r\n"); } else { - this.Write(" throw new global::System.InvalidOperationException(\"typecode is n" + - "ull, struct not supported\");\r\n"); + this.Write("\t\t\t\tthrow new global::System.InvalidOperationException(\"typecode is null, struct " + + "not supported\");\r\n"); } - this.Write(" }\r\n\r\n"); + this.Write("\t\t\t}\r\n\r\n"); if (Info.Members.Length == 0) { - this.Write(" reader.Skip();\r\n var ____result = new "); + this.Write("\t\t\treader.Skip();\r\n\t\t\tvar ____result = new "); this.Write(this.ToStringHelper.ToStringWithCulture(Info.GetConstructorString())); this.Write(";\r\n"); } else { - this.Write(" options.Security.DepthStep(ref reader);\r\n"); + this.Write("\t\t\toptions.Security.DepthStep(ref reader);\r\n"); if (isFormatterResolverNecessary) { - this.Write(" var formatterResolver = options.Resolver;\r\n"); + this.Write("\t\t\tvar formatterResolver = options.Resolver;\r\n"); } - this.Write(" var length = reader.ReadMapHeader();\r\n"); + this.Write("\t\t\tvar length = reader.ReadMapHeader();\r\n"); var canOverwrite = Info.ConstructorParameters.Length == 0; - if (canOverwrite) { - this.Write(" var ____result = new "); + if (canOverwrite) { + this.Write("\t\t\tvar ____result = new "); this.Write(this.ToStringHelper.ToStringWithCulture(Info.GetConstructorString())); this.Write(";\r\n"); } else { - foreach (var member in Info.Members.Where(x => x.IsWritable || Info.ConstructorParameters.Any(p => p.Equals(x)))) { + foreach (var member in Info.Members.Where(x => x.IsWritable || Info.ConstructorParameters.Any(p => p.Equals(x)))) { if (Info.ConstructorParameters.All(p => !p.Equals(member))) { - this.Write(" var __"); + this.Write("\t\t\tvar __"); this.Write(this.ToStringHelper.ToStringWithCulture(member.Name)); this.Write("__IsInitialized = false;\r\n"); } - this.Write(" var __"); + this.Write("\t\t\tvar __"); this.Write(this.ToStringHelper.ToStringWithCulture(member.Name)); this.Write("__ = default("); this.Write(this.ToStringHelper.ToStringWithCulture(member.Type)); this.Write(");\r\n"); } } - this.Write(@" - for (int i = 0; i < length; i++) - { - var stringKey = global::MessagePack.Internal.CodeGenHelpers.ReadStringSpan(ref reader); - switch (stringKey.Length) - { - default: - FAIL: - reader.Skip(); - continue; -"); - this.Write(this.ToStringHelper.ToStringWithCulture(StringKeyFormatterDeserializeHelper.Classify(Info, " ", canOverwrite))); - this.Write("\r\n }\r\n }\r\n\r\n"); + this.Write("\r\n\t\t\tfor (int i = 0; i < length; i++)\r\n\t\t\t{\r\n\t\t\t\tvar stringKey = global::MessageP" + + "ack.Internal.CodeGenHelpers.ReadStringSpan(ref reader);\r\n\t\t\t\tswitch (stringKey.L" + + "ength)\r\n\t\t\t\t{\r\n\t\t\t\t\tdefault:\r\n\t\t\t\t\tFAIL:\r\n\t\t\t\t\t reader.Skip();\r\n\t\t\t\t\t continue" + + ";\r\n"); + this.Write(this.ToStringHelper.ToStringWithCulture(StringKeyFormatterDeserializeHelper.Classify(Info, " ", canOverwrite))); + this.Write("\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n"); if (!canOverwrite) { - this.Write(" var ____result = new "); + this.Write("\t\t\tvar ____result = new "); this.Write(this.ToStringHelper.ToStringWithCulture(Info.GetConstructorString())); this.Write(";\r\n"); foreach (var member in Info.Members.Where(x => x.IsWritable && !Info.ConstructorParameters.Any(p => p.Equals(x)))) { - this.Write(" if (__"); + this.Write("\t\t\tif (__"); this.Write(this.ToStringHelper.ToStringWithCulture(member.Name)); - this.Write("__IsInitialized)\r\n {\r\n ____result."); + this.Write("__IsInitialized)\r\n\t\t\t{\r\n\t\t\t\t____result."); this.Write(this.ToStringHelper.ToStringWithCulture(member.Name)); this.Write(" = __"); this.Write(this.ToStringHelper.ToStringWithCulture(member.Name)); - this.Write("__;\r\n }\r\n\r\n"); + this.Write("__;\r\n\t\t\t}\r\n\r\n"); } } } if (Info.HasIMessagePackSerializationCallbackReceiver) { - if (Info.NeedsCastOnAfter) { - this.Write(" ((global::MessagePack.IMessagePackSerializationCallbackReceiver)____r" + - "esult).OnAfterDeserialize();\r\n"); + if (Info.NeedsCastOnAfter) { + this.Write("\t\t\t((global::MessagePack.IMessagePackSerializationCallbackReceiver)____result).On" + + "AfterDeserialize();\r\n"); } else { - this.Write(" ____result.OnAfterDeserialize();\r\n"); + this.Write("\t\t\t____result.OnAfterDeserialize();\r\n"); } } if (Info.Members.Length != 0) { - this.Write(" reader.Depth--;\r\n"); + this.Write("\t\t\treader.Depth--;\r\n"); } - this.Write(" return ____result;\r\n }\r\n }\r\n}\r\n"); + this.Write("\t\t\treturn ____result;\r\n\t\t}\r\n\t}\r\n}\r\n"); return this.GenerationEnvironment.ToString(); } } diff --git a/src/MessagePack.Generator/Transforms/StringKey/StringKeyFormatterTemplate.tt b/src/MessagePack.Generator/Transforms/StringKey/StringKeyFormatterTemplate.tt index f2cf73630..203f99df8 100644 --- a/src/MessagePack.Generator/Transforms/StringKey/StringKeyFormatterTemplate.tt +++ b/src/MessagePack.Generator/Transforms/StringKey/StringKeyFormatterTemplate.tt @@ -7,129 +7,131 @@ namespace <#= Namespace #> { + using MsgPack = global::MessagePack; + <# var list = new List>(); - foreach (var member in Info.Members) { - var binary = EmbedStringHelper.Utf8.GetBytes(member.StringKey); - list.Add(new ValueTuple(member, binary)); - } + foreach (var member in Info.Members) { + var binary = EmbedStringHelper.Utf8.GetBytes(member.StringKey); + list.Add(new ValueTuple(member, binary)); + } - bool isFormatterResolverNecessary = ShouldUseFormatterResolverHelper.ShouldUseFormatterResolver(Info.Members); #> - public sealed class <#= Info.FormatterNameWithoutNamespace #> : global::MessagePack.Formatters.IMessagePackFormatter<<#= Info.FullName #>> + bool isFormatterResolverNecessary = ShouldUseFormatterResolverHelper.ShouldUseFormatterResolver(Info.Members); #> + public sealed class <#= Info.FormatterNameWithoutNamespace #> : global::MessagePack.Formatters.IMessagePackFormatter<<#= Info.FullName #>> <# foreach (var typeArg in Info.GenericTypeParameters.Where(x => x.HasConstraints)) {#> - where <#= typeArg.Name #> : <#= typeArg.Constraints #> + where <#= typeArg.Name #> : <#= typeArg.Constraints #> <# }#> - { + { <# foreach (var item in Info.Members) { #> <# if (item.CustomFormatterTypeName != null) { #> - private readonly <#= item.CustomFormatterTypeName #> __<#= item.Name #>CustomFormatter__ = new <#= item.CustomFormatterTypeName #>(); + private readonly <#= item.CustomFormatterTypeName #> __<#= item.Name #>CustomFormatter__ = new <#= item.CustomFormatterTypeName #>(); <# } #> <# } #> <# for (var i = 0; i < list.Count; i++) { - var member = list[i].Item1; - var binary = list[i].Item2; #> - // <#= member.StringKey #> - private static global::System.ReadOnlySpan GetSpan_<#= member.Name #>() => <#= EmbedStringHelper.ToByteArrayString(binary) #>; + var member = list[i].Item1; + var binary = list[i].Item2; #> + // <#= member.StringKey #> + private static global::System.ReadOnlySpan GetSpan_<#= member.Name #>() => <#= EmbedStringHelper.ToByteArrayString(binary) #>; <# } #> <# if (list.Count != 0) { #> <# } #> - public void Serialize(ref global::MessagePack.MessagePackWriter writer, <#= Info.FullName #> value, global::MessagePack.MessagePackSerializerOptions options) - { + public void Serialize(ref global::MessagePack.MessagePackWriter writer, <#= Info.FullName #> value, global::MessagePack.MessagePackSerializerOptions options) + { <# if (Info.IsClass) { #> - if (value is null) - { - writer.WriteNil(); - return; - } + if (value is null) + { + writer.WriteNil(); + return; + } <# } - if (isFormatterResolverNecessary) { #> - var formatterResolver = options.Resolver; + if (isFormatterResolverNecessary) { #> + var formatterResolver = options.Resolver; <# } - if (Info.HasIMessagePackSerializationCallbackReceiver) { - if (Info.NeedsCastOnBefore) { #> - ((global::MessagePack.IMessagePackSerializationCallbackReceiver)value).OnBeforeSerialize(); + if (Info.HasIMessagePackSerializationCallbackReceiver) { + if (Info.NeedsCastOnBefore) { #> + ((global::MessagePack.IMessagePackSerializationCallbackReceiver)value).OnBeforeSerialize(); <# } else { #> - value.OnBeforeSerialize(); + value.OnBeforeSerialize(); <# } #> <# } #> - writer.WriteMapHeader(<#= list.Count #>); + writer.WriteMapHeader(<#= list.Count #>); <# foreach (var memberAndBinary in list) { - var member = memberAndBinary.Item1; #> - writer.WriteRaw(GetSpan_<#= member.Name #>()); - <#= member.GetSerializeMethodString() #>; + var member = memberAndBinary.Item1; #> + writer.WriteRaw(GetSpan_<#= member.Name #>()); + <#= member.GetSerializeMethodString() #>; <# } #> - } + } - public <#= Info.FullName #> Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) - { - if (reader.TryReadNil()) - { + public <#= Info.FullName #> Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) + { + if (reader.TryReadNil()) + { <# if (Info.IsClass) { #> - return null; + return null; <# } else { #> - throw new global::System.InvalidOperationException("typecode is null, struct not supported"); + throw new global::System.InvalidOperationException("typecode is null, struct not supported"); <# } #> - } + } <# if (Info.Members.Length == 0) { #> - reader.Skip(); - var ____result = new <#= Info.GetConstructorString() #>; + reader.Skip(); + var ____result = new <#= Info.GetConstructorString() #>; <# } else { #> - options.Security.DepthStep(ref reader); + options.Security.DepthStep(ref reader); <# if (isFormatterResolverNecessary) { #> - var formatterResolver = options.Resolver; + var formatterResolver = options.Resolver; <# } #> - var length = reader.ReadMapHeader(); + var length = reader.ReadMapHeader(); <# var canOverwrite = Info.ConstructorParameters.Length == 0; - if (canOverwrite) { #> - var ____result = new <#= Info.GetConstructorString() #>; + if (canOverwrite) { #> + var ____result = new <#= Info.GetConstructorString() #>; <# } else { - foreach (var member in Info.Members.Where(x => x.IsWritable || Info.ConstructorParameters.Any(p => p.Equals(x)))) { #> + foreach (var member in Info.Members.Where(x => x.IsWritable || Info.ConstructorParameters.Any(p => p.Equals(x)))) { #> <# if (Info.ConstructorParameters.All(p => !p.Equals(member))) { #> - var __<#= member.Name #>__IsInitialized = false; + var __<#= member.Name #>__IsInitialized = false; <# } #> - var __<#= member.Name #>__ = default(<#= member.Type #>); + var __<#= member.Name #>__ = default(<#= member.Type #>); <# } #> <# } #> - for (int i = 0; i < length; i++) - { - var stringKey = global::MessagePack.Internal.CodeGenHelpers.ReadStringSpan(ref reader); - switch (stringKey.Length) - { - default: - FAIL: - reader.Skip(); - continue; -<#= StringKeyFormatterDeserializeHelper.Classify(Info, " ", canOverwrite) #> - } - } + for (int i = 0; i < length; i++) + { + var stringKey = global::MessagePack.Internal.CodeGenHelpers.ReadStringSpan(ref reader); + switch (stringKey.Length) + { + default: + FAIL: + reader.Skip(); + continue; +<#= StringKeyFormatterDeserializeHelper.Classify(Info, " ", canOverwrite) #> + } + } <# if (!canOverwrite) { #> - var ____result = new <#= Info.GetConstructorString() #>; + var ____result = new <#= Info.GetConstructorString() #>; <# foreach (var member in Info.Members.Where(x => x.IsWritable && !Info.ConstructorParameters.Any(p => p.Equals(x)))) { #> - if (__<#= member.Name #>__IsInitialized) - { - ____result.<#= member.Name #> = __<#= member.Name #>__; - } + if (__<#= member.Name #>__IsInitialized) + { + ____result.<#= member.Name #> = __<#= member.Name #>__; + } <# } #> <# } #> <# } #> <# if (Info.HasIMessagePackSerializationCallbackReceiver) { - if (Info.NeedsCastOnAfter) { #> - ((global::MessagePack.IMessagePackSerializationCallbackReceiver)____result).OnAfterDeserialize(); + if (Info.NeedsCastOnAfter) { #> + ((global::MessagePack.IMessagePackSerializationCallbackReceiver)____result).OnAfterDeserialize(); <# } else { #> - ____result.OnAfterDeserialize(); + ____result.OnAfterDeserialize(); <# } #> <# } #> <# if (Info.Members.Length != 0) { #> - reader.Depth--; + reader.Depth--; <# } #> - return ____result; - } - } + return ____result; + } + } } diff --git a/tests/MessagePack.Generator.Tests/GenerateEnumFormatterTest.cs b/tests/MessagePack.Generator.Tests/GenerateEnumFormatterTest.cs index f3ef10520..1e612a8a4 100644 --- a/tests/MessagePack.Generator.Tests/GenerateEnumFormatterTest.cs +++ b/tests/MessagePack.Generator.Tests/GenerateEnumFormatterTest.cs @@ -12,8 +12,8 @@ public GenerateEnumFormatterTest(ITestOutputHelper testOutputHelper) this.testOutputHelper = testOutputHelper; } - [Theory, CombinatorialData] - public async Task EnumFormatter(ContainerKind container) + [Theory, PairwiseData] + public async Task EnumFormatter(ContainerKind container, bool usesMapMode) { string testSource = """ [MessagePackObject] @@ -30,6 +30,6 @@ public enum MyEnum """; testSource = TestUtilities.WrapTestSource(testSource, container); - await VerifyCS.Test.RunDefaultAsync(testSource, testMethod: $"{nameof(EnumFormatter)}({container})"); + await VerifyCS.Test.RunDefaultAsync(testSource, options: AnalyzerOptions.Default with { UsesMapMode = usesMapMode }, testMethod: $"{nameof(EnumFormatter)}({container}, {usesMapMode})"); } } diff --git a/tests/MessagePack.Generator.Tests/MultipleTypesTests.cs b/tests/MessagePack.Generator.Tests/MultipleTypesTests.cs index b64e11d21..3161e29f7 100644 --- a/tests/MessagePack.Generator.Tests/MultipleTypesTests.cs +++ b/tests/MessagePack.Generator.Tests/MultipleTypesTests.cs @@ -1,6 +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. +using System.ComponentModel; using MessagePack.Generator.Tests; public class MultipleTypesTests @@ -12,8 +13,8 @@ public MultipleTypesTests(ITestOutputHelper testOutputHelper) this.testOutputHelper = testOutputHelper; } - [Fact] - public async Task TwoTypes() + [Theory, PairwiseData] + public async Task TwoTypes(bool usesMapMode) { string testSource = """ using MessagePack; @@ -28,6 +29,6 @@ public class Object2 { } """; - await VerifyCS.Test.RunDefaultAsync(testSource); + await VerifyCS.Test.RunDefaultAsync(testSource, options: AnalyzerOptions.Default with { UsesMapMode = usesMapMode }, testMethod: $"{nameof(TwoTypes)}({usesMapMode})"); } } diff --git a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(Namespace)/MessagePack.Formatter.MyTestNamespace.MyEnum.g.cs b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(Namespace, False)/MessagePack.Formatter.MyTestNamespace.MyEnum.g.cs similarity index 100% rename from tests/MessagePack.Generator.Tests/Resources/EnumFormatter(Namespace)/MessagePack.Formatter.MyTestNamespace.MyEnum.g.cs rename to tests/MessagePack.Generator.Tests/Resources/EnumFormatter(Namespace, False)/MessagePack.Formatter.MyTestNamespace.MyEnum.g.cs diff --git a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(Namespace)/MessagePack.Formatter.MyTestNamespace.MyMessagePackObject.g.cs b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(Namespace, False)/MessagePack.Formatter.MyTestNamespace.MyMessagePackObject.g.cs similarity index 100% rename from tests/MessagePack.Generator.Tests/Resources/EnumFormatter(Namespace)/MessagePack.Formatter.MyTestNamespace.MyMessagePackObject.g.cs rename to tests/MessagePack.Generator.Tests/Resources/EnumFormatter(Namespace, False)/MessagePack.Formatter.MyTestNamespace.MyMessagePackObject.g.cs diff --git a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(Namespace)/MessagePack.GeneratedResolver.g.cs b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(Namespace, False)/MessagePack.GeneratedResolver.g.cs similarity index 100% rename from tests/MessagePack.Generator.Tests/Resources/EnumFormatter(Namespace)/MessagePack.GeneratedResolver.g.cs rename to tests/MessagePack.Generator.Tests/Resources/EnumFormatter(Namespace, False)/MessagePack.GeneratedResolver.g.cs diff --git a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(Namespace, True)/MessagePack.Formatter.MyTestNamespace.MyEnum.g.cs b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(Namespace, True)/MessagePack.Formatter.MyTestNamespace.MyEnum.g.cs new file mode 100644 index 000000000..a8e33176a --- /dev/null +++ b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(Namespace, True)/MessagePack.Formatter.MyTestNamespace.MyEnum.g.cs @@ -0,0 +1,22 @@ +// + +#pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 + +namespace MessagePack.Formatters.MyTestNamespace +{ + using MsgPack = global::MessagePack; + using MyEnum = global::MyTestNamespace.MyEnum; + + public sealed class MyEnumFormatter : MsgPack::Formatters.IMessagePackFormatter + { + public void Serialize(ref MsgPack::MessagePackWriter writer, MyEnum value, MsgPack::MessagePackSerializerOptions options) + { + writer.Write((int)value); + } + + public MyEnum Deserialize(ref MsgPack::MessagePackReader reader, MsgPack::MessagePackSerializerOptions options) + { + return (MyEnum)reader.ReadInt32(); + } + } +} diff --git a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(Namespace, True)/MessagePack.Formatter.MyTestNamespace.MyMessagePackObject.g.cs b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(Namespace, True)/MessagePack.Formatter.MyTestNamespace.MyMessagePackObject.g.cs new file mode 100644 index 000000000..74202871f --- /dev/null +++ b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(Namespace, True)/MessagePack.Formatter.MyTestNamespace.MyMessagePackObject.g.cs @@ -0,0 +1,62 @@ +// + +#pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 + +namespace MessagePack.Formatters.MyTestNamespace +{ + using MsgPack = global::MessagePack; + + public sealed class MyMessagePackObjectFormatter : global::MessagePack.Formatters.IMessagePackFormatter + { + // EnumValue + private static global::System.ReadOnlySpan GetSpan_EnumValue() => new byte[1 + 9] { 169, 69, 110, 117, 109, 86, 97, 108, 117, 101 }; + + public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::MyTestNamespace.MyMessagePackObject value, global::MessagePack.MessagePackSerializerOptions options) + { + if (value is null) + { + writer.WriteNil(); + return; + } + + var formatterResolver = options.Resolver; + writer.WriteMapHeader(1); + writer.WriteRaw(GetSpan_EnumValue()); + MsgPack::FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Serialize(ref writer, value.EnumValue, options); + } + + public global::MyTestNamespace.MyMessagePackObject Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) + { + if (reader.TryReadNil()) + { + return null; + } + + options.Security.DepthStep(ref reader); + var formatterResolver = options.Resolver; + var length = reader.ReadMapHeader(); + var ____result = new global::MyTestNamespace.MyMessagePackObject(); + + for (int i = 0; i < length; i++) + { + var stringKey = global::MessagePack.Internal.CodeGenHelpers.ReadStringSpan(ref reader); + switch (stringKey.Length) + { + default: + FAIL: + reader.Skip(); + continue; + case 9: + if (!global::System.MemoryExtensions.SequenceEqual(stringKey, GetSpan_EnumValue().Slice(1))) { goto FAIL; } + + ____result.EnumValue = MsgPack::FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Deserialize(ref reader, options); + continue; + + } + } + + reader.Depth--; + return ____result; + } + } +} diff --git a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(Namespace, True)/MessagePack.GeneratedResolver.g.cs b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(Namespace, True)/MessagePack.GeneratedResolver.g.cs new file mode 100644 index 000000000..58147457d --- /dev/null +++ b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(Namespace, True)/MessagePack.GeneratedResolver.g.cs @@ -0,0 +1,68 @@ +// + +#pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 + +namespace MessagePack.Resolvers +{ + using MsgPack = global::MessagePack; + + public class GeneratedResolver : MsgPack::IFormatterResolver + { + public static readonly MsgPack::IFormatterResolver Instance = new GeneratedResolver(); + + public static readonly MsgPack::IFormatterResolver InstanceWithStandardAotResolver = MsgPack::Resolvers.CompositeResolver.Create(Instance, MsgPack::Resolvers.StandardAotResolver.Instance); + + private GeneratedResolver() + { + } + + public MsgPack::Formatters.IMessagePackFormatter GetFormatter() + { + return FormatterCache.Formatter; + } + + private static class FormatterCache + { + internal static readonly MsgPack::Formatters.IMessagePackFormatter Formatter; + + static FormatterCache() + { + var f = GeneratedResolverGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + Formatter = (MsgPack::Formatters.IMessagePackFormatter)f; + } + } + } + } + + internal static class GeneratedResolverGetFormatterHelper + { + private static readonly global::System.Collections.Generic.Dictionary lookup; + + static GeneratedResolverGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(2) + { + { typeof(global::MyTestNamespace.MyEnum), 0 }, + { typeof(global::MyTestNamespace.MyMessagePackObject), 1 }, + }; + } + + internal static object GetFormatter(global::System.Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + case 0: return new MessagePack.Formatters.MyTestNamespace.MyEnumFormatter(); + case 1: return new MessagePack.Formatters.MyTestNamespace.MyMessagePackObjectFormatter(); + default: return null; + } + } + } +} diff --git a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(NestingClass)/MessagePack.Formatter..ContainingClass_MyEnum.g.cs b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(NestingClass, False)/MessagePack.Formatter..ContainingClass_MyEnum.g.cs similarity index 100% rename from tests/MessagePack.Generator.Tests/Resources/EnumFormatter(NestingClass)/MessagePack.Formatter..ContainingClass_MyEnum.g.cs rename to tests/MessagePack.Generator.Tests/Resources/EnumFormatter(NestingClass, False)/MessagePack.Formatter..ContainingClass_MyEnum.g.cs diff --git a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(NestingClass)/MessagePack.Formatter.ContainingClass_MyMessagePackObject.g.cs b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(NestingClass, False)/MessagePack.Formatter.ContainingClass_MyMessagePackObject.g.cs similarity index 100% rename from tests/MessagePack.Generator.Tests/Resources/EnumFormatter(NestingClass)/MessagePack.Formatter.ContainingClass_MyMessagePackObject.g.cs rename to tests/MessagePack.Generator.Tests/Resources/EnumFormatter(NestingClass, False)/MessagePack.Formatter.ContainingClass_MyMessagePackObject.g.cs diff --git a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(NestingClass)/MessagePack.GeneratedResolver.g.cs b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(NestingClass, False)/MessagePack.GeneratedResolver.g.cs similarity index 100% rename from tests/MessagePack.Generator.Tests/Resources/EnumFormatter(NestingClass)/MessagePack.GeneratedResolver.g.cs rename to tests/MessagePack.Generator.Tests/Resources/EnumFormatter(NestingClass, False)/MessagePack.GeneratedResolver.g.cs diff --git a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(NestingClass, True)/MessagePack.Formatter..ContainingClass_MyEnum.g.cs b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(NestingClass, True)/MessagePack.Formatter..ContainingClass_MyEnum.g.cs new file mode 100644 index 000000000..31874e68d --- /dev/null +++ b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(NestingClass, True)/MessagePack.Formatter..ContainingClass_MyEnum.g.cs @@ -0,0 +1,22 @@ +// + +#pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 + +namespace MessagePack.Formatters +{ + using MsgPack = global::MessagePack; + using ContainingClass_MyEnum = global::ContainingClass.MyEnum; + + public sealed class ContainingClass_MyEnumFormatter : MsgPack::Formatters.IMessagePackFormatter + { + public void Serialize(ref MsgPack::MessagePackWriter writer, ContainingClass_MyEnum value, MsgPack::MessagePackSerializerOptions options) + { + writer.Write((int)value); + } + + public ContainingClass_MyEnum Deserialize(ref MsgPack::MessagePackReader reader, MsgPack::MessagePackSerializerOptions options) + { + return (ContainingClass_MyEnum)reader.ReadInt32(); + } + } +} diff --git a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(NestingClass, True)/MessagePack.Formatter.ContainingClass_MyMessagePackObject.g.cs b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(NestingClass, True)/MessagePack.Formatter.ContainingClass_MyMessagePackObject.g.cs new file mode 100644 index 000000000..4790f9f3c --- /dev/null +++ b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(NestingClass, True)/MessagePack.Formatter.ContainingClass_MyMessagePackObject.g.cs @@ -0,0 +1,62 @@ +// + +#pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 + +namespace MessagePack.Formatters +{ + using MsgPack = global::MessagePack; + + public sealed class ContainingClass_MyMessagePackObjectFormatter : global::MessagePack.Formatters.IMessagePackFormatter + { + // EnumValue + private static global::System.ReadOnlySpan GetSpan_EnumValue() => new byte[1 + 9] { 169, 69, 110, 117, 109, 86, 97, 108, 117, 101 }; + + public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::ContainingClass.MyMessagePackObject value, global::MessagePack.MessagePackSerializerOptions options) + { + if (value is null) + { + writer.WriteNil(); + return; + } + + var formatterResolver = options.Resolver; + writer.WriteMapHeader(1); + writer.WriteRaw(GetSpan_EnumValue()); + MsgPack::FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Serialize(ref writer, value.EnumValue, options); + } + + public global::ContainingClass.MyMessagePackObject Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) + { + if (reader.TryReadNil()) + { + return null; + } + + options.Security.DepthStep(ref reader); + var formatterResolver = options.Resolver; + var length = reader.ReadMapHeader(); + var ____result = new global::ContainingClass.MyMessagePackObject(); + + for (int i = 0; i < length; i++) + { + var stringKey = global::MessagePack.Internal.CodeGenHelpers.ReadStringSpan(ref reader); + switch (stringKey.Length) + { + default: + FAIL: + reader.Skip(); + continue; + case 9: + if (!global::System.MemoryExtensions.SequenceEqual(stringKey, GetSpan_EnumValue().Slice(1))) { goto FAIL; } + + ____result.EnumValue = MsgPack::FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Deserialize(ref reader, options); + continue; + + } + } + + reader.Depth--; + return ____result; + } + } +} diff --git a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(NestingClass, True)/MessagePack.GeneratedResolver.g.cs b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(NestingClass, True)/MessagePack.GeneratedResolver.g.cs new file mode 100644 index 000000000..c04dd2799 --- /dev/null +++ b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(NestingClass, True)/MessagePack.GeneratedResolver.g.cs @@ -0,0 +1,68 @@ +// + +#pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 + +namespace MessagePack.Resolvers +{ + using MsgPack = global::MessagePack; + + public class GeneratedResolver : MsgPack::IFormatterResolver + { + public static readonly MsgPack::IFormatterResolver Instance = new GeneratedResolver(); + + public static readonly MsgPack::IFormatterResolver InstanceWithStandardAotResolver = MsgPack::Resolvers.CompositeResolver.Create(Instance, MsgPack::Resolvers.StandardAotResolver.Instance); + + private GeneratedResolver() + { + } + + public MsgPack::Formatters.IMessagePackFormatter GetFormatter() + { + return FormatterCache.Formatter; + } + + private static class FormatterCache + { + internal static readonly MsgPack::Formatters.IMessagePackFormatter Formatter; + + static FormatterCache() + { + var f = GeneratedResolverGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + Formatter = (MsgPack::Formatters.IMessagePackFormatter)f; + } + } + } + } + + internal static class GeneratedResolverGetFormatterHelper + { + private static readonly global::System.Collections.Generic.Dictionary lookup; + + static GeneratedResolverGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(2) + { + { typeof(global::ContainingClass.MyEnum), 0 }, + { typeof(global::ContainingClass.MyMessagePackObject), 1 }, + }; + } + + internal static object GetFormatter(global::System.Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + case 0: return new MessagePack.Formatters.ContainingClass_MyEnumFormatter(); + case 1: return new MessagePack.Formatters.ContainingClass_MyMessagePackObjectFormatter(); + default: return null; + } + } + } +} diff --git a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(None)/MessagePack.Formatter..MyEnum.g.cs b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(None, False)/MessagePack.Formatter..MyEnum.g.cs similarity index 100% rename from tests/MessagePack.Generator.Tests/Resources/EnumFormatter(None)/MessagePack.Formatter..MyEnum.g.cs rename to tests/MessagePack.Generator.Tests/Resources/EnumFormatter(None, False)/MessagePack.Formatter..MyEnum.g.cs diff --git a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(None)/MessagePack.Formatter.MyMessagePackObject.g.cs b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(None, False)/MessagePack.Formatter.MyMessagePackObject.g.cs similarity index 100% rename from tests/MessagePack.Generator.Tests/Resources/EnumFormatter(None)/MessagePack.Formatter.MyMessagePackObject.g.cs rename to tests/MessagePack.Generator.Tests/Resources/EnumFormatter(None, False)/MessagePack.Formatter.MyMessagePackObject.g.cs diff --git a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(None)/MessagePack.GeneratedResolver.g.cs b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(None, False)/MessagePack.GeneratedResolver.g.cs similarity index 100% rename from tests/MessagePack.Generator.Tests/Resources/EnumFormatter(None)/MessagePack.GeneratedResolver.g.cs rename to tests/MessagePack.Generator.Tests/Resources/EnumFormatter(None, False)/MessagePack.GeneratedResolver.g.cs diff --git a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(None, True)/MessagePack.Formatter..MyEnum.g.cs b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(None, True)/MessagePack.Formatter..MyEnum.g.cs new file mode 100644 index 000000000..7a38011f2 --- /dev/null +++ b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(None, True)/MessagePack.Formatter..MyEnum.g.cs @@ -0,0 +1,22 @@ +// + +#pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 + +namespace MessagePack.Formatters +{ + using MsgPack = global::MessagePack; + using MyEnum = global::MyEnum; + + public sealed class MyEnumFormatter : MsgPack::Formatters.IMessagePackFormatter + { + public void Serialize(ref MsgPack::MessagePackWriter writer, MyEnum value, MsgPack::MessagePackSerializerOptions options) + { + writer.Write((int)value); + } + + public MyEnum Deserialize(ref MsgPack::MessagePackReader reader, MsgPack::MessagePackSerializerOptions options) + { + return (MyEnum)reader.ReadInt32(); + } + } +} diff --git a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(None, True)/MessagePack.Formatter.MyMessagePackObject.g.cs b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(None, True)/MessagePack.Formatter.MyMessagePackObject.g.cs new file mode 100644 index 000000000..1994b806c --- /dev/null +++ b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(None, True)/MessagePack.Formatter.MyMessagePackObject.g.cs @@ -0,0 +1,62 @@ +// + +#pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 + +namespace MessagePack.Formatters +{ + using MsgPack = global::MessagePack; + + public sealed class MyMessagePackObjectFormatter : global::MessagePack.Formatters.IMessagePackFormatter + { + // EnumValue + private static global::System.ReadOnlySpan GetSpan_EnumValue() => new byte[1 + 9] { 169, 69, 110, 117, 109, 86, 97, 108, 117, 101 }; + + public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::MyMessagePackObject value, global::MessagePack.MessagePackSerializerOptions options) + { + if (value is null) + { + writer.WriteNil(); + return; + } + + var formatterResolver = options.Resolver; + writer.WriteMapHeader(1); + writer.WriteRaw(GetSpan_EnumValue()); + MsgPack::FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Serialize(ref writer, value.EnumValue, options); + } + + public global::MyMessagePackObject Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) + { + if (reader.TryReadNil()) + { + return null; + } + + options.Security.DepthStep(ref reader); + var formatterResolver = options.Resolver; + var length = reader.ReadMapHeader(); + var ____result = new global::MyMessagePackObject(); + + for (int i = 0; i < length; i++) + { + var stringKey = global::MessagePack.Internal.CodeGenHelpers.ReadStringSpan(ref reader); + switch (stringKey.Length) + { + default: + FAIL: + reader.Skip(); + continue; + case 9: + if (!global::System.MemoryExtensions.SequenceEqual(stringKey, GetSpan_EnumValue().Slice(1))) { goto FAIL; } + + ____result.EnumValue = MsgPack::FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Deserialize(ref reader, options); + continue; + + } + } + + reader.Depth--; + return ____result; + } + } +} diff --git a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(None, True)/MessagePack.GeneratedResolver.g.cs b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(None, True)/MessagePack.GeneratedResolver.g.cs new file mode 100644 index 000000000..db796ddc1 --- /dev/null +++ b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(None, True)/MessagePack.GeneratedResolver.g.cs @@ -0,0 +1,68 @@ +// + +#pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 + +namespace MessagePack.Resolvers +{ + using MsgPack = global::MessagePack; + + public class GeneratedResolver : MsgPack::IFormatterResolver + { + public static readonly MsgPack::IFormatterResolver Instance = new GeneratedResolver(); + + public static readonly MsgPack::IFormatterResolver InstanceWithStandardAotResolver = MsgPack::Resolvers.CompositeResolver.Create(Instance, MsgPack::Resolvers.StandardAotResolver.Instance); + + private GeneratedResolver() + { + } + + public MsgPack::Formatters.IMessagePackFormatter GetFormatter() + { + return FormatterCache.Formatter; + } + + private static class FormatterCache + { + internal static readonly MsgPack::Formatters.IMessagePackFormatter Formatter; + + static FormatterCache() + { + var f = GeneratedResolverGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + Formatter = (MsgPack::Formatters.IMessagePackFormatter)f; + } + } + } + } + + internal static class GeneratedResolverGetFormatterHelper + { + private static readonly global::System.Collections.Generic.Dictionary lookup; + + static GeneratedResolverGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(2) + { + { typeof(global::MyEnum), 0 }, + { typeof(global::MyMessagePackObject), 1 }, + }; + } + + internal static object GetFormatter(global::System.Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + case 0: return new MessagePack.Formatters.MyEnumFormatter(); + case 1: return new MessagePack.Formatters.MyMessagePackObjectFormatter(); + default: return null; + } + } + } +} diff --git a/tests/MessagePack.Generator.Tests/Resources/TwoTypes/MessagePack.Formatter.Object1.g.cs b/tests/MessagePack.Generator.Tests/Resources/TwoTypes(False)/MessagePack.Formatter.Object1.g.cs similarity index 100% rename from tests/MessagePack.Generator.Tests/Resources/TwoTypes/MessagePack.Formatter.Object1.g.cs rename to tests/MessagePack.Generator.Tests/Resources/TwoTypes(False)/MessagePack.Formatter.Object1.g.cs diff --git a/tests/MessagePack.Generator.Tests/Resources/TwoTypes/MessagePack.Formatter.Object2.g.cs b/tests/MessagePack.Generator.Tests/Resources/TwoTypes(False)/MessagePack.Formatter.Object2.g.cs similarity index 100% rename from tests/MessagePack.Generator.Tests/Resources/TwoTypes/MessagePack.Formatter.Object2.g.cs rename to tests/MessagePack.Generator.Tests/Resources/TwoTypes(False)/MessagePack.Formatter.Object2.g.cs diff --git a/tests/MessagePack.Generator.Tests/Resources/TwoTypes/MessagePack.GeneratedResolver.g.cs b/tests/MessagePack.Generator.Tests/Resources/TwoTypes(False)/MessagePack.GeneratedResolver.g.cs similarity index 100% rename from tests/MessagePack.Generator.Tests/Resources/TwoTypes/MessagePack.GeneratedResolver.g.cs rename to tests/MessagePack.Generator.Tests/Resources/TwoTypes(False)/MessagePack.GeneratedResolver.g.cs diff --git a/tests/MessagePack.Generator.Tests/Resources/TwoTypes(True)/MessagePack.Formatter.Object1.g.cs b/tests/MessagePack.Generator.Tests/Resources/TwoTypes(True)/MessagePack.Formatter.Object1.g.cs new file mode 100644 index 000000000..172cea3db --- /dev/null +++ b/tests/MessagePack.Generator.Tests/Resources/TwoTypes(True)/MessagePack.Formatter.Object1.g.cs @@ -0,0 +1,34 @@ +// + +#pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 + +namespace MessagePack.Formatters +{ + using MsgPack = global::MessagePack; + + public sealed class Object1Formatter : global::MessagePack.Formatters.IMessagePackFormatter + { + public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::Object1 value, global::MessagePack.MessagePackSerializerOptions options) + { + if (value is null) + { + writer.WriteNil(); + return; + } + + writer.WriteMapHeader(0); + } + + public global::Object1 Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) + { + if (reader.TryReadNil()) + { + return null; + } + + reader.Skip(); + var ____result = new global::Object1(); + return ____result; + } + } +} diff --git a/tests/MessagePack.Generator.Tests/Resources/TwoTypes(True)/MessagePack.Formatter.Object2.g.cs b/tests/MessagePack.Generator.Tests/Resources/TwoTypes(True)/MessagePack.Formatter.Object2.g.cs new file mode 100644 index 000000000..7465d59d8 --- /dev/null +++ b/tests/MessagePack.Generator.Tests/Resources/TwoTypes(True)/MessagePack.Formatter.Object2.g.cs @@ -0,0 +1,34 @@ +// + +#pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 + +namespace MessagePack.Formatters +{ + using MsgPack = global::MessagePack; + + public sealed class Object2Formatter : global::MessagePack.Formatters.IMessagePackFormatter + { + public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::Object2 value, global::MessagePack.MessagePackSerializerOptions options) + { + if (value is null) + { + writer.WriteNil(); + return; + } + + writer.WriteMapHeader(0); + } + + public global::Object2 Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) + { + if (reader.TryReadNil()) + { + return null; + } + + reader.Skip(); + var ____result = new global::Object2(); + return ____result; + } + } +} diff --git a/tests/MessagePack.Generator.Tests/Resources/TwoTypes(True)/MessagePack.GeneratedResolver.g.cs b/tests/MessagePack.Generator.Tests/Resources/TwoTypes(True)/MessagePack.GeneratedResolver.g.cs new file mode 100644 index 000000000..a74021ae2 --- /dev/null +++ b/tests/MessagePack.Generator.Tests/Resources/TwoTypes(True)/MessagePack.GeneratedResolver.g.cs @@ -0,0 +1,68 @@ +// + +#pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 + +namespace MessagePack.Resolvers +{ + using MsgPack = global::MessagePack; + + public class GeneratedResolver : MsgPack::IFormatterResolver + { + public static readonly MsgPack::IFormatterResolver Instance = new GeneratedResolver(); + + public static readonly MsgPack::IFormatterResolver InstanceWithStandardAotResolver = MsgPack::Resolvers.CompositeResolver.Create(Instance, MsgPack::Resolvers.StandardAotResolver.Instance); + + private GeneratedResolver() + { + } + + public MsgPack::Formatters.IMessagePackFormatter GetFormatter() + { + return FormatterCache.Formatter; + } + + private static class FormatterCache + { + internal static readonly MsgPack::Formatters.IMessagePackFormatter Formatter; + + static FormatterCache() + { + var f = GeneratedResolverGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + Formatter = (MsgPack::Formatters.IMessagePackFormatter)f; + } + } + } + } + + internal static class GeneratedResolverGetFormatterHelper + { + private static readonly global::System.Collections.Generic.Dictionary lookup; + + static GeneratedResolverGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(2) + { + { typeof(global::Object1), 0 }, + { typeof(global::Object2), 1 }, + }; + } + + internal static object GetFormatter(global::System.Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + case 0: return new MessagePack.Formatters.Object1Formatter(); + case 1: return new MessagePack.Formatters.Object2Formatter(); + default: return null; + } + } + } +} diff --git a/tests/MessagePack.Generator.Tests/Verifiers/CSharpSourceGeneratorVerifier`1+Test.cs b/tests/MessagePack.Generator.Tests/Verifiers/CSharpSourceGeneratorVerifier`1+Test.cs index fd2f6c4bf..6a0852499 100644 --- a/tests/MessagePack.Generator.Tests/Verifiers/CSharpSourceGeneratorVerifier`1+Test.cs +++ b/tests/MessagePack.Generator.Tests/Verifiers/CSharpSourceGeneratorVerifier`1+Test.cs @@ -65,7 +65,7 @@ public AnalyzerOptions Options } } - public static async Task RunDefaultAsync(string testSource, [CallerFilePath] string? testFile = null, [CallerMemberName] string? testMethod = null) + public static async Task RunDefaultAsync(string testSource, AnalyzerOptions? options = null, [CallerFilePath] string? testFile = null, [CallerMemberName] string? testMethod = null) { await new Test(testFile, testMethod) { @@ -73,12 +73,15 @@ public static async Task RunDefaultAsync(string testSource, [CallerFilePath] str { Sources = { testSource }, }, + Options = options ?? AnalyzerOptions.Default, }.RunAsync(); } public Test AddGeneratedSources([CallerMemberName] string? testMethod = null) { string expectedPrefix = $"{ThisAssembly.AssemblyName}.Resources.{testMethod}." + .Replace(' ', '_') + .Replace(',', '_') .Replace('(', '_') .Replace(')', '_'); From 47290398c5aa8f2a3f556355f8df0fb76149208f Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Thu, 30 Mar 2023 09:31:25 -0600 Subject: [PATCH 054/660] Add execution tests for map mode --- MessagePack.sln | 12 ++++++++++- ...ack.Generator.MapModeExecutionTests.csproj | 21 +++++++++++++++++++ tests/SourceGeneratorConsumer.props | 5 ++++- 3 files changed, 36 insertions(+), 2 deletions(-) create mode 100644 tests/MessagePack.Generator.MapModeExecutionTests/MessagePack.Generator.MapModeExecutionTests.csproj diff --git a/MessagePack.sln b/MessagePack.sln index 6efaad4ac..795a4b11b 100644 --- a/MessagePack.sln +++ b/MessagePack.sln @@ -12,6 +12,9 @@ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MessagePack", "src\MessagePack\MessagePack.csproj", "{7ABB33EE-A2F1-492B-8DAF-5DF89F0F0B79}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{19FE674A-AC94-4E7E-B24C-2285D1D04CDE}" + ProjectSection(SolutionItems) = preProject + tests\SourceGeneratorConsumer.props = tests\SourceGeneratorConsumer.props + EndProjectSection EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MessagePack.Tests", "tests\MessagePack.Tests\MessagePack.Tests.csproj", "{9E1A55CA-711D-4F58-A332-735960E3434C}" EndProject @@ -91,7 +94,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MessagePack.GeneratedCode.T EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MessagePack.Generator.Roslyn3", "src\MessagePack.Generator.Roslyn3\MessagePack.Generator.Roslyn3.csproj", "{45A72780-93EF-4CD1-9FCD-D56A42A3B966}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MessagePack.Generator.ExecutionTests", "tests\MessagePack.Generator.ExecutionTests\MessagePack.Generator.ExecutionTests.csproj", "{7908D954-15D4-4D67-B49A-4484809DA2C4}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MessagePack.Generator.ExecutionTests", "tests\MessagePack.Generator.ExecutionTests\MessagePack.Generator.ExecutionTests.csproj", "{7908D954-15D4-4D67-B49A-4484809DA2C4}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MessagePack.Generator.MapModeExecutionTests", "tests\MessagePack.Generator.MapModeExecutionTests\MessagePack.Generator.MapModeExecutionTests.csproj", "{EDBA7DDC-69AF-4D5B-A8F6-3B508F8CC0FC}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -207,6 +212,10 @@ Global {7908D954-15D4-4D67-B49A-4484809DA2C4}.Debug|Any CPU.Build.0 = Debug|Any CPU {7908D954-15D4-4D67-B49A-4484809DA2C4}.Release|Any CPU.ActiveCfg = Release|Any CPU {7908D954-15D4-4D67-B49A-4484809DA2C4}.Release|Any CPU.Build.0 = Release|Any CPU + {EDBA7DDC-69AF-4D5B-A8F6-3B508F8CC0FC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {EDBA7DDC-69AF-4D5B-A8F6-3B508F8CC0FC}.Debug|Any CPU.Build.0 = Debug|Any CPU + {EDBA7DDC-69AF-4D5B-A8F6-3B508F8CC0FC}.Release|Any CPU.ActiveCfg = Release|Any CPU + {EDBA7DDC-69AF-4D5B-A8F6-3B508F8CC0FC}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -239,6 +248,7 @@ Global {D4CE7347-CEBE-46E5-BD12-1319573B6C5E} = {19FE674A-AC94-4E7E-B24C-2285D1D04CDE} {45A72780-93EF-4CD1-9FCD-D56A42A3B966} = {86309CF6-0054-4CE3-BFD3-CA0AA7DB17BC} {7908D954-15D4-4D67-B49A-4484809DA2C4} = {19FE674A-AC94-4E7E-B24C-2285D1D04CDE} + {EDBA7DDC-69AF-4D5B-A8F6-3B508F8CC0FC} = {19FE674A-AC94-4E7E-B24C-2285D1D04CDE} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {B3911209-2DBF-47F8-98F6-BBC0EDFE63DE} diff --git a/tests/MessagePack.Generator.MapModeExecutionTests/MessagePack.Generator.MapModeExecutionTests.csproj b/tests/MessagePack.Generator.MapModeExecutionTests/MessagePack.Generator.MapModeExecutionTests.csproj new file mode 100644 index 000000000..38ef99c6f --- /dev/null +++ b/tests/MessagePack.Generator.MapModeExecutionTests/MessagePack.Generator.MapModeExecutionTests.csproj @@ -0,0 +1,21 @@ + + + + + net7.0 + enable + enable + true + + + + + + + + + + + + + diff --git a/tests/SourceGeneratorConsumer.props b/tests/SourceGeneratorConsumer.props index b9fccf195..bfd9551bf 100644 --- a/tests/SourceGeneratorConsumer.props +++ b/tests/SourceGeneratorConsumer.props @@ -2,7 +2,10 @@ - + + Analyzer + false + From 6de627f252923d17f742529503356b46ccf43a55 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Thu, 30 Mar 2023 10:05:37 -0600 Subject: [PATCH 055/660] Fix up source generator nuget package metadata so it actually works --- .../MessagePack.Generator.csproj | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/MessagePack.Generator/MessagePack.Generator.csproj b/src/MessagePack.Generator/MessagePack.Generator.csproj index a6dfbf5d8..bd7ed5201 100644 --- a/src/MessagePack.Generator/MessagePack.Generator.csproj +++ b/src/MessagePack.Generator/MessagePack.Generator.csproj @@ -8,9 +8,13 @@ cs + true false + embedded false true + true + $(TargetsForTfmSpecificContentInPackage);PackBuildOutputs MessagePack.Generator @@ -96,4 +100,13 @@ + + + + + + + + + From 14ecf2a0a37f7955d41f155125298a9e9371f39b Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Thu, 30 Mar 2023 10:14:15 -0600 Subject: [PATCH 056/660] Support internal types --- .../CodeAnalysis/AnalyzerOptions.cs | 1 - .../CodeAnalysis/TypeCollector.cs | 41 ++++++++----------- .../Transforms/EnumTemplate.cs | 2 +- .../Transforms/EnumTemplate.tt | 2 +- .../Transforms/FormatterTemplate.cs | 2 +- .../Transforms/FormatterTemplate.tt | 2 +- .../Transforms/ResolverTemplate.cs | 18 +++++--- .../Transforms/ResolverTemplate.tt | 5 ++- .../StringKey/StringKeyFormatterTemplate.cs | 2 +- .../StringKey/StringKeyFormatterTemplate.tt | 2 +- .../Transforms/UnionTemplate.cs | 2 +- .../Transforms/UnionTemplate.tt | 2 +- .../GenerateEnumFormatterTest.cs | 6 +-- .../MultipleTypesTests.cs | 7 +--- ...Pack.Formatter.MyTestNamespace.MyEnum.g.cs | 2 +- ...r.MyTestNamespace.MyMessagePackObject.g.cs | 2 +- .../MessagePack.GeneratedResolver.g.cs | 5 ++- ...Pack.Formatter.MyTestNamespace.MyEnum.g.cs | 2 +- ...r.MyTestNamespace.MyMessagePackObject.g.cs | 2 +- .../MessagePack.GeneratedResolver.g.cs | 5 ++- ...ack.Formatter..ContainingClass_MyEnum.g.cs | 2 +- ...r.ContainingClass_MyMessagePackObject.g.cs | 2 +- .../MessagePack.GeneratedResolver.g.cs | 5 ++- ...ack.Formatter..ContainingClass_MyEnum.g.cs | 2 +- ...r.ContainingClass_MyMessagePackObject.g.cs | 2 +- .../MessagePack.GeneratedResolver.g.cs | 5 ++- .../MessagePack.Formatter..MyEnum.g.cs | 2 +- ...agePack.Formatter.MyMessagePackObject.g.cs | 2 +- .../MessagePack.GeneratedResolver.g.cs | 5 ++- .../MessagePack.Formatter..MyEnum.g.cs | 2 +- ...agePack.Formatter.MyMessagePackObject.g.cs | 2 +- .../MessagePack.GeneratedResolver.g.cs | 5 ++- .../MessagePack.Formatter.Object1.g.cs | 2 +- .../MessagePack.Formatter.Object2.g.cs | 2 +- .../MessagePack.GeneratedResolver.g.cs | 5 ++- .../MessagePack.Formatter.Object1.g.cs | 2 +- .../MessagePack.Formatter.Object2.g.cs | 2 +- .../MessagePack.GeneratedResolver.g.cs | 5 ++- 38 files changed, 93 insertions(+), 73 deletions(-) diff --git a/src/MessagePack.Generator/CodeAnalysis/AnalyzerOptions.cs b/src/MessagePack.Generator/CodeAnalysis/AnalyzerOptions.cs index 407efcec5..5e1dfa32f 100644 --- a/src/MessagePack.Generator/CodeAnalysis/AnalyzerOptions.cs +++ b/src/MessagePack.Generator/CodeAnalysis/AnalyzerOptions.cs @@ -10,7 +10,6 @@ public record AnalyzerOptions( string Namespace = "MessagePack", string ResolverName = "GeneratedResolver", bool UsesMapMode = false, - bool DisallowInternal = false, IReadOnlyCollection? IgnoreTypeNames = null) { public const string MessagePackGeneratedResolverNamespace = "build_property.MessagePackGeneratedResolverNamespace"; diff --git a/src/MessagePack.Generator/CodeAnalysis/TypeCollector.cs b/src/MessagePack.Generator/CodeAnalysis/TypeCollector.cs index 9b5268b90..33093fdb5 100644 --- a/src/MessagePack.Generator/CodeAnalysis/TypeCollector.cs +++ b/src/MessagePack.Generator/CodeAnalysis/TypeCollector.cs @@ -226,7 +226,6 @@ public class TypeCollector private readonly AnalyzerOptions options; private readonly ReferenceSymbols typeReferences; private readonly ITypeSymbol? targetType; - private readonly bool disallowInternal; private readonly bool excludeArrayElement; private readonly HashSet externalIgnoreTypeNames; @@ -244,7 +243,6 @@ public class TypeCollector private TypeCollector(Compilation compilation, AnalyzerOptions options, ITypeSymbol targetType, IGeneratorContext? context) { this.typeReferences = new ReferenceSymbols(compilation, _ => { }); - this.disallowInternal = options.DisallowInternal; this.isForceUseMap = options.UsesMapMode; this.context = context; this.options = options; @@ -253,8 +251,7 @@ private TypeCollector(Compilation compilation, AnalyzerOptions options, ITypeSym this.excludeArrayElement = true; this.context = context; - if (targetType.DeclaredAccessibility == Accessibility.Public || - (!disallowInternal && targetType.DeclaredAccessibility == Accessibility.Friend)) + if (IsAllowedAccessibility(targetType.DeclaredAccessibility)) { if (((targetType.TypeKind == TypeKind.Interface) && targetType.GetAttributes().Any(x2 => x2.AttributeClass.ApproximatelyEqual(this.typeReferences.UnionAttribute))) || ((targetType.TypeKind == TypeKind.Class && targetType.IsAbstract) && targetType.GetAttributes().Any(x2 => x2.AttributeClass.ApproximatelyEqual(this.typeReferences.UnionAttribute))) @@ -641,8 +638,8 @@ private ObjectSerializationInfo GetObjectInfo(INamedTypeSymbol type) continue; } - var isReadable = item.GetMethod != null && item.GetMethod.DeclaredAccessibility == Accessibility.Public && !item.IsStatic; - var isWritable = item.SetMethod != null && item.SetMethod.DeclaredAccessibility == Accessibility.Public && !item.IsStatic; + var isReadable = item.GetMethod != null && IsAllowedAccessibility(item.GetMethod.DeclaredAccessibility) && !item.IsStatic; + var isWritable = item.SetMethod != null && IsAllowedAccessibility(item.SetMethod.DeclaredAccessibility) && !item.IsStatic; if (!isReadable && !isWritable) { continue; @@ -667,8 +664,8 @@ private ObjectSerializationInfo GetObjectInfo(INamedTypeSymbol type) continue; } - var isReadable = item.DeclaredAccessibility == Accessibility.Public && !item.IsStatic; - var isWritable = item.DeclaredAccessibility == Accessibility.Public && !item.IsReadOnly && !item.IsStatic; + var isReadable = IsAllowedAccessibility(item.DeclaredAccessibility) && !item.IsStatic; + var isWritable = IsAllowedAccessibility(item.DeclaredAccessibility) && !item.IsReadOnly && !item.IsStatic; if (!isReadable && !isWritable) { continue; @@ -702,8 +699,8 @@ private ObjectSerializationInfo GetObjectInfo(INamedTypeSymbol type) continue; } - var isReadable = item.GetMethod != null && item.GetMethod.DeclaredAccessibility == Accessibility.Public && !item.IsStatic; - var isWritable = item.SetMethod != null && item.SetMethod.DeclaredAccessibility == Accessibility.Public && !item.IsStatic; + var isReadable = item.GetMethod != null && IsAllowedAccessibility(item.GetMethod.DeclaredAccessibility) && !item.IsStatic; + var isWritable = item.SetMethod != null && IsAllowedAccessibility(item.SetMethod.DeclaredAccessibility) && !item.IsStatic; if (!isReadable && !isWritable) { continue; @@ -774,8 +771,8 @@ private ObjectSerializationInfo GetObjectInfo(INamedTypeSymbol type) continue; } - var isReadable = item.DeclaredAccessibility == Accessibility.Public && !item.IsStatic; - var isWritable = item.DeclaredAccessibility == Accessibility.Public && !item.IsReadOnly && !item.IsStatic; + var isReadable = IsAllowedAccessibility(item.DeclaredAccessibility) && !item.IsStatic; + var isWritable = IsAllowedAccessibility(item.DeclaredAccessibility) && !item.IsReadOnly && !item.IsStatic; if (!isReadable && !isWritable) { continue; @@ -832,10 +829,10 @@ private ObjectSerializationInfo GetObjectInfo(INamedTypeSymbol type) // GetConstructor var ctorEnumerator = default(IEnumerator); - var ctor = type.Constructors.Where(x => x.DeclaredAccessibility == Accessibility.Public).SingleOrDefault(x => x.GetAttributes().Any(y => y.AttributeClass != null && y.AttributeClass.ApproximatelyEqual(this.typeReferences.SerializationConstructorAttribute))); + var ctor = type.Constructors.Where(x => IsAllowedAccessibility(x.DeclaredAccessibility)).SingleOrDefault(x => x.GetAttributes().Any(y => y.AttributeClass != null && y.AttributeClass.ApproximatelyEqual(this.typeReferences.SerializationConstructorAttribute))); if (ctor == null) { - ctorEnumerator = type.Constructors.Where(x => x.DeclaredAccessibility == Accessibility.Public).OrderByDescending(x => x.Parameters.Length).GetEnumerator(); + ctorEnumerator = type.Constructors.Where(x => IsAllowedAccessibility(x.DeclaredAccessibility)).OrderByDescending(x => x.Parameters.Length).GetEnumerator(); if (ctorEnumerator.MoveNext()) { @@ -1039,26 +1036,20 @@ private static bool TryGetNextConstructor(IEnumerator? ctorEnumer } } + private static bool IsAllowedAccessibility(Accessibility accessibility) => accessibility is Accessibility.Public or Accessibility.Internal; + private bool IsAllowAccessibility(ITypeSymbol symbol) { do { - if (symbol.DeclaredAccessibility != Accessibility.Public) + if (!IsAllowedAccessibility(symbol.DeclaredAccessibility)) { - if (this.disallowInternal) - { - return false; - } - - if (symbol.DeclaredAccessibility != Accessibility.Internal) - { - return true; - } + return false; } symbol = symbol.ContainingType; } - while (symbol != null); + while (symbol is not null); return true; } diff --git a/src/MessagePack.Generator/Transforms/EnumTemplate.cs b/src/MessagePack.Generator/Transforms/EnumTemplate.cs index dedb1636d..00e1e08a5 100644 --- a/src/MessagePack.Generator/Transforms/EnumTemplate.cs +++ b/src/MessagePack.Generator/Transforms/EnumTemplate.cs @@ -28,7 +28,7 @@ public virtual string TransformText() this.Write(this.ToStringHelper.ToStringWithCulture(Info.Name)); this.Write(" = "); this.Write(this.ToStringHelper.ToStringWithCulture(Info.FullName)); - this.Write(";\r\n\r\n\tpublic sealed class "); + this.Write(";\r\n\r\n\tinternal sealed class "); this.Write(this.ToStringHelper.ToStringWithCulture(Info.Name)); this.Write("Formatter : MsgPack::Formatters.IMessagePackFormatter<"); this.Write(this.ToStringHelper.ToStringWithCulture(Info.Name)); diff --git a/src/MessagePack.Generator/Transforms/EnumTemplate.tt b/src/MessagePack.Generator/Transforms/EnumTemplate.tt index 877c01bf2..1e6a20e88 100644 --- a/src/MessagePack.Generator/Transforms/EnumTemplate.tt +++ b/src/MessagePack.Generator/Transforms/EnumTemplate.tt @@ -6,7 +6,7 @@ namespace <#= Namespace #> using MsgPack = global::MessagePack; using <#= Info.Name #> = <#= Info.FullName #>; - public sealed class <#= Info.Name #>Formatter : MsgPack::Formatters.IMessagePackFormatter<<#= Info.Name #>> + internal sealed class <#= Info.Name #>Formatter : MsgPack::Formatters.IMessagePackFormatter<<#= Info.Name #>> { public void Serialize(ref MsgPack::MessagePackWriter writer, <#= Info.Name #> value, MsgPack::MessagePackSerializerOptions options) { diff --git a/src/MessagePack.Generator/Transforms/FormatterTemplate.cs b/src/MessagePack.Generator/Transforms/FormatterTemplate.cs index bbfade7fd..2b67e8a96 100644 --- a/src/MessagePack.Generator/Transforms/FormatterTemplate.cs +++ b/src/MessagePack.Generator/Transforms/FormatterTemplate.cs @@ -29,7 +29,7 @@ public virtual string TransformText() this.Write(this.ToStringHelper.ToStringWithCulture(Namespace)); this.Write("\r\n{\r\n\tusing MsgPack = global::MessagePack;\r\n\r\n"); bool isFormatterResolverNecessary = ShouldUseFormatterResolverHelper.ShouldUseFormatterResolver(Info.Members); - this.Write("\tpublic sealed class "); + this.Write("\tinternal sealed class "); this.Write(this.ToStringHelper.ToStringWithCulture(Info.FormatterNameWithoutNamespace)); this.Write(" : MsgPack::Formatters.IMessagePackFormatter<"); this.Write(this.ToStringHelper.ToStringWithCulture(Info.FullName)); diff --git a/src/MessagePack.Generator/Transforms/FormatterTemplate.tt b/src/MessagePack.Generator/Transforms/FormatterTemplate.tt index 04a276dab..7575a71f5 100644 --- a/src/MessagePack.Generator/Transforms/FormatterTemplate.tt +++ b/src/MessagePack.Generator/Transforms/FormatterTemplate.tt @@ -9,7 +9,7 @@ namespace <#= Namespace #> using MsgPack = global::MessagePack; <# bool isFormatterResolverNecessary = ShouldUseFormatterResolverHelper.ShouldUseFormatterResolver(Info.Members);#> - public sealed class <#= Info.FormatterNameWithoutNamespace #> : MsgPack::Formatters.IMessagePackFormatter<<#= Info.FullName #>> + internal sealed class <#= Info.FormatterNameWithoutNamespace #> : MsgPack::Formatters.IMessagePackFormatter<<#= Info.FullName #>> <# foreach (var typeArg in Info.GenericTypeParameters.Where(x => x.HasConstraints)) { #> where <#= typeArg.Name #> : <#= typeArg.Constraints #> <# } #> diff --git a/src/MessagePack.Generator/Transforms/ResolverTemplate.cs b/src/MessagePack.Generator/Transforms/ResolverTemplate.cs index 3a87fbe12..991967a6a 100644 --- a/src/MessagePack.Generator/Transforms/ResolverTemplate.cs +++ b/src/MessagePack.Generator/Transforms/ResolverTemplate.cs @@ -27,14 +27,20 @@ public virtual string TransformText() { this.Write("\r\nnamespace "); this.Write(this.ToStringHelper.ToStringWithCulture(ResolverNamespace)); - this.Write("\r\n{\r\n\tusing MsgPack = global::MessagePack;\r\n\r\n\tpublic class "); + this.Write("\r\n{\r\n\tusing MsgPack = global::MessagePack;\r\n\r\n\t/// A MessagePack resolve" + + "r that uses generated formatters for types in this assembly.\r\n\tinterna" + + "l class "); this.Write(this.ToStringHelper.ToStringWithCulture(ResolverName)); - this.Write(" : MsgPack::IFormatterResolver\r\n\t{\r\n\t\tpublic static readonly MsgPack::IFormatterR" + - "esolver Instance = new "); + this.Write(" : MsgPack::IFormatterResolver\r\n\t{\r\n\t\t/// An instance of this resolver t" + + "hat only returns formatters specifically generated for types in this assembly.\r\n\t\tpublic static readonly MsgPack::IFormatterResolver Instance = new "); this.Write(this.ToStringHelper.ToStringWithCulture(ResolverName)); - this.Write("();\r\n\r\n\t\tpublic static readonly MsgPack::IFormatterResolver InstanceWithStandardA" + - "otResolver = MsgPack::Resolvers.CompositeResolver.Create(Instance, MsgPack::Reso" + - "lvers.StandardAotResolver.Instance);\r\n\r\n\t\tprivate "); + this.Write(@"(); + + /// An instance of this resolver that returns standard AOT-compatible formatters as well as formatters specifically generated for types in this assembly. + public static readonly MsgPack::IFormatterResolver InstanceWithStandardAotResolver = MsgPack::Resolvers.CompositeResolver.Create(Instance, MsgPack::Resolvers.StandardAotResolver.Instance); + + private "); this.Write(this.ToStringHelper.ToStringWithCulture(ResolverName)); this.Write(@"() { diff --git a/src/MessagePack.Generator/Transforms/ResolverTemplate.tt b/src/MessagePack.Generator/Transforms/ResolverTemplate.tt index 2ec180933..199ebe088 100644 --- a/src/MessagePack.Generator/Transforms/ResolverTemplate.tt +++ b/src/MessagePack.Generator/Transforms/ResolverTemplate.tt @@ -8,10 +8,13 @@ namespace <#= ResolverNamespace #> { using MsgPack = global::MessagePack; - public class <#= ResolverName #> : MsgPack::IFormatterResolver + /// A MessagePack resolver that uses generated formatters for types in this assembly. + internal class <#= ResolverName #> : MsgPack::IFormatterResolver { + /// An instance of this resolver that only returns formatters specifically generated for types in this assembly. public static readonly MsgPack::IFormatterResolver Instance = new <#= ResolverName #>(); + /// An instance of this resolver that returns standard AOT-compatible formatters as well as formatters specifically generated for types in this assembly. public static readonly MsgPack::IFormatterResolver InstanceWithStandardAotResolver = MsgPack::Resolvers.CompositeResolver.Create(Instance, MsgPack::Resolvers.StandardAotResolver.Instance); private <#= ResolverName #>() diff --git a/src/MessagePack.Generator/Transforms/StringKey/StringKeyFormatterTemplate.cs b/src/MessagePack.Generator/Transforms/StringKey/StringKeyFormatterTemplate.cs index 23108bc60..25e88fd1c 100644 --- a/src/MessagePack.Generator/Transforms/StringKey/StringKeyFormatterTemplate.cs +++ b/src/MessagePack.Generator/Transforms/StringKey/StringKeyFormatterTemplate.cs @@ -35,7 +35,7 @@ public virtual string TransformText() } bool isFormatterResolverNecessary = ShouldUseFormatterResolverHelper.ShouldUseFormatterResolver(Info.Members); - this.Write("\tpublic sealed class "); + this.Write("\tinternal sealed class "); this.Write(this.ToStringHelper.ToStringWithCulture(Info.FormatterNameWithoutNamespace)); this.Write(" : global::MessagePack.Formatters.IMessagePackFormatter<"); this.Write(this.ToStringHelper.ToStringWithCulture(Info.FullName)); diff --git a/src/MessagePack.Generator/Transforms/StringKey/StringKeyFormatterTemplate.tt b/src/MessagePack.Generator/Transforms/StringKey/StringKeyFormatterTemplate.tt index 203f99df8..78664fb78 100644 --- a/src/MessagePack.Generator/Transforms/StringKey/StringKeyFormatterTemplate.tt +++ b/src/MessagePack.Generator/Transforms/StringKey/StringKeyFormatterTemplate.tt @@ -16,7 +16,7 @@ namespace <#= Namespace #> } bool isFormatterResolverNecessary = ShouldUseFormatterResolverHelper.ShouldUseFormatterResolver(Info.Members); #> - public sealed class <#= Info.FormatterNameWithoutNamespace #> : global::MessagePack.Formatters.IMessagePackFormatter<<#= Info.FullName #>> + internal sealed class <#= Info.FormatterNameWithoutNamespace #> : global::MessagePack.Formatters.IMessagePackFormatter<<#= Info.FullName #>> <# foreach (var typeArg in Info.GenericTypeParameters.Where(x => x.HasConstraints)) {#> where <#= typeArg.Name #> : <#= typeArg.Constraints #> <# }#> diff --git a/src/MessagePack.Generator/Transforms/UnionTemplate.cs b/src/MessagePack.Generator/Transforms/UnionTemplate.cs index fc6371ce0..86f1bca10 100644 --- a/src/MessagePack.Generator/Transforms/UnionTemplate.cs +++ b/src/MessagePack.Generator/Transforms/UnionTemplate.cs @@ -27,7 +27,7 @@ public virtual string TransformText() { this.Write("\r\nnamespace "); this.Write(this.ToStringHelper.ToStringWithCulture(Namespace)); - this.Write("\r\n{\r\n\tusing MsgPack = global::MessagePack;\r\n\r\n\tpublic sealed class "); + this.Write("\r\n{\r\n\tusing MsgPack = global::MessagePack;\r\n\r\n\tinternal sealed class "); this.Write(this.ToStringHelper.ToStringWithCulture(Info.Name)); this.Write("Formatter : MsgPack::Formatters.IMessagePackFormatter<"); this.Write(this.ToStringHelper.ToStringWithCulture(Info.FullName)); diff --git a/src/MessagePack.Generator/Transforms/UnionTemplate.tt b/src/MessagePack.Generator/Transforms/UnionTemplate.tt index bf04c6a8b..930c4046c 100644 --- a/src/MessagePack.Generator/Transforms/UnionTemplate.tt +++ b/src/MessagePack.Generator/Transforms/UnionTemplate.tt @@ -8,7 +8,7 @@ namespace <#= Namespace #> { using MsgPack = global::MessagePack; - public sealed class <#= Info.Name #>Formatter : MsgPack::Formatters.IMessagePackFormatter<<#= Info.FullName #>> + internal sealed class <#= Info.Name #>Formatter : MsgPack::Formatters.IMessagePackFormatter<<#= Info.FullName #>> { private readonly global::System.Collections.Generic.Dictionary> typeToKeyAndJumpMap; private readonly global::System.Collections.Generic.Dictionary keyToJumpMap; diff --git a/tests/MessagePack.Generator.Tests/GenerateEnumFormatterTest.cs b/tests/MessagePack.Generator.Tests/GenerateEnumFormatterTest.cs index 1e612a8a4..7a49c5917 100644 --- a/tests/MessagePack.Generator.Tests/GenerateEnumFormatterTest.cs +++ b/tests/MessagePack.Generator.Tests/GenerateEnumFormatterTest.cs @@ -17,13 +17,13 @@ public async Task EnumFormatter(ContainerKind container, bool usesMapMode) { string testSource = """ [MessagePackObject] -public class MyMessagePackObject +internal class MyMessagePackObject { [Key(0)] - public MyEnum EnumValue { get; set; } + internal MyEnum EnumValue { get; set; } } -public enum MyEnum +internal enum MyEnum { A, B, C } diff --git a/tests/MessagePack.Generator.Tests/MultipleTypesTests.cs b/tests/MessagePack.Generator.Tests/MultipleTypesTests.cs index 3161e29f7..2b34a7507 100644 --- a/tests/MessagePack.Generator.Tests/MultipleTypesTests.cs +++ b/tests/MessagePack.Generator.Tests/MultipleTypesTests.cs @@ -1,9 +1,6 @@ // Copyright (c) All contributors. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -using System.ComponentModel; -using MessagePack.Generator.Tests; - public class MultipleTypesTests { private readonly ITestOutputHelper testOutputHelper; @@ -20,12 +17,12 @@ public async Task TwoTypes(bool usesMapMode) using MessagePack; [MessagePackObject] -public class Object1 +class Object1 { } [MessagePackObject] -public class Object2 +class Object2 { } """; diff --git a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(Namespace, False)/MessagePack.Formatter.MyTestNamespace.MyEnum.g.cs b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(Namespace, False)/MessagePack.Formatter.MyTestNamespace.MyEnum.g.cs index a8e33176a..c4194470d 100644 --- a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(Namespace, False)/MessagePack.Formatter.MyTestNamespace.MyEnum.g.cs +++ b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(Namespace, False)/MessagePack.Formatter.MyTestNamespace.MyEnum.g.cs @@ -7,7 +7,7 @@ namespace MessagePack.Formatters.MyTestNamespace using MsgPack = global::MessagePack; using MyEnum = global::MyTestNamespace.MyEnum; - public sealed class MyEnumFormatter : MsgPack::Formatters.IMessagePackFormatter + internal sealed class MyEnumFormatter : MsgPack::Formatters.IMessagePackFormatter { public void Serialize(ref MsgPack::MessagePackWriter writer, MyEnum value, MsgPack::MessagePackSerializerOptions options) { diff --git a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(Namespace, False)/MessagePack.Formatter.MyTestNamespace.MyMessagePackObject.g.cs b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(Namespace, False)/MessagePack.Formatter.MyTestNamespace.MyMessagePackObject.g.cs index 2f12c1e1f..25ad12f34 100644 --- a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(Namespace, False)/MessagePack.Formatter.MyTestNamespace.MyMessagePackObject.g.cs +++ b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(Namespace, False)/MessagePack.Formatter.MyTestNamespace.MyMessagePackObject.g.cs @@ -6,7 +6,7 @@ namespace MessagePack.Formatters.MyTestNamespace { using MsgPack = global::MessagePack; - public sealed class MyMessagePackObjectFormatter : MsgPack::Formatters.IMessagePackFormatter + internal sealed class MyMessagePackObjectFormatter : MsgPack::Formatters.IMessagePackFormatter { public void Serialize(ref MsgPack::MessagePackWriter writer, global::MyTestNamespace.MyMessagePackObject value, MsgPack::MessagePackSerializerOptions options) diff --git a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(Namespace, False)/MessagePack.GeneratedResolver.g.cs b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(Namespace, False)/MessagePack.GeneratedResolver.g.cs index 58147457d..9f0ccb375 100644 --- a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(Namespace, False)/MessagePack.GeneratedResolver.g.cs +++ b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(Namespace, False)/MessagePack.GeneratedResolver.g.cs @@ -6,10 +6,13 @@ namespace MessagePack.Resolvers { using MsgPack = global::MessagePack; - public class GeneratedResolver : MsgPack::IFormatterResolver + /// A MessagePack resolver that uses generated formatters for types in this assembly. + internal class GeneratedResolver : MsgPack::IFormatterResolver { + /// An instance of this resolver that only returns formatters specifically generated for types in this assembly. public static readonly MsgPack::IFormatterResolver Instance = new GeneratedResolver(); + /// An instance of this resolver that returns standard AOT-compatible formatters as well as formatters specifically generated for types in this assembly. public static readonly MsgPack::IFormatterResolver InstanceWithStandardAotResolver = MsgPack::Resolvers.CompositeResolver.Create(Instance, MsgPack::Resolvers.StandardAotResolver.Instance); private GeneratedResolver() diff --git a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(Namespace, True)/MessagePack.Formatter.MyTestNamespace.MyEnum.g.cs b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(Namespace, True)/MessagePack.Formatter.MyTestNamespace.MyEnum.g.cs index a8e33176a..c4194470d 100644 --- a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(Namespace, True)/MessagePack.Formatter.MyTestNamespace.MyEnum.g.cs +++ b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(Namespace, True)/MessagePack.Formatter.MyTestNamespace.MyEnum.g.cs @@ -7,7 +7,7 @@ namespace MessagePack.Formatters.MyTestNamespace using MsgPack = global::MessagePack; using MyEnum = global::MyTestNamespace.MyEnum; - public sealed class MyEnumFormatter : MsgPack::Formatters.IMessagePackFormatter + internal sealed class MyEnumFormatter : MsgPack::Formatters.IMessagePackFormatter { public void Serialize(ref MsgPack::MessagePackWriter writer, MyEnum value, MsgPack::MessagePackSerializerOptions options) { diff --git a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(Namespace, True)/MessagePack.Formatter.MyTestNamespace.MyMessagePackObject.g.cs b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(Namespace, True)/MessagePack.Formatter.MyTestNamespace.MyMessagePackObject.g.cs index 74202871f..bfd59b201 100644 --- a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(Namespace, True)/MessagePack.Formatter.MyTestNamespace.MyMessagePackObject.g.cs +++ b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(Namespace, True)/MessagePack.Formatter.MyTestNamespace.MyMessagePackObject.g.cs @@ -6,7 +6,7 @@ namespace MessagePack.Formatters.MyTestNamespace { using MsgPack = global::MessagePack; - public sealed class MyMessagePackObjectFormatter : global::MessagePack.Formatters.IMessagePackFormatter + internal sealed class MyMessagePackObjectFormatter : global::MessagePack.Formatters.IMessagePackFormatter { // EnumValue private static global::System.ReadOnlySpan GetSpan_EnumValue() => new byte[1 + 9] { 169, 69, 110, 117, 109, 86, 97, 108, 117, 101 }; diff --git a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(Namespace, True)/MessagePack.GeneratedResolver.g.cs b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(Namespace, True)/MessagePack.GeneratedResolver.g.cs index 58147457d..9f0ccb375 100644 --- a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(Namespace, True)/MessagePack.GeneratedResolver.g.cs +++ b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(Namespace, True)/MessagePack.GeneratedResolver.g.cs @@ -6,10 +6,13 @@ namespace MessagePack.Resolvers { using MsgPack = global::MessagePack; - public class GeneratedResolver : MsgPack::IFormatterResolver + /// A MessagePack resolver that uses generated formatters for types in this assembly. + internal class GeneratedResolver : MsgPack::IFormatterResolver { + /// An instance of this resolver that only returns formatters specifically generated for types in this assembly. public static readonly MsgPack::IFormatterResolver Instance = new GeneratedResolver(); + /// An instance of this resolver that returns standard AOT-compatible formatters as well as formatters specifically generated for types in this assembly. public static readonly MsgPack::IFormatterResolver InstanceWithStandardAotResolver = MsgPack::Resolvers.CompositeResolver.Create(Instance, MsgPack::Resolvers.StandardAotResolver.Instance); private GeneratedResolver() diff --git a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(NestingClass, False)/MessagePack.Formatter..ContainingClass_MyEnum.g.cs b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(NestingClass, False)/MessagePack.Formatter..ContainingClass_MyEnum.g.cs index 31874e68d..82eb466bd 100644 --- a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(NestingClass, False)/MessagePack.Formatter..ContainingClass_MyEnum.g.cs +++ b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(NestingClass, False)/MessagePack.Formatter..ContainingClass_MyEnum.g.cs @@ -7,7 +7,7 @@ namespace MessagePack.Formatters using MsgPack = global::MessagePack; using ContainingClass_MyEnum = global::ContainingClass.MyEnum; - public sealed class ContainingClass_MyEnumFormatter : MsgPack::Formatters.IMessagePackFormatter + internal sealed class ContainingClass_MyEnumFormatter : MsgPack::Formatters.IMessagePackFormatter { public void Serialize(ref MsgPack::MessagePackWriter writer, ContainingClass_MyEnum value, MsgPack::MessagePackSerializerOptions options) { diff --git a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(NestingClass, False)/MessagePack.Formatter.ContainingClass_MyMessagePackObject.g.cs b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(NestingClass, False)/MessagePack.Formatter.ContainingClass_MyMessagePackObject.g.cs index 02d72f585..8e96eb928 100644 --- a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(NestingClass, False)/MessagePack.Formatter.ContainingClass_MyMessagePackObject.g.cs +++ b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(NestingClass, False)/MessagePack.Formatter.ContainingClass_MyMessagePackObject.g.cs @@ -6,7 +6,7 @@ namespace MessagePack.Formatters { using MsgPack = global::MessagePack; - public sealed class ContainingClass_MyMessagePackObjectFormatter : MsgPack::Formatters.IMessagePackFormatter + internal sealed class ContainingClass_MyMessagePackObjectFormatter : MsgPack::Formatters.IMessagePackFormatter { public void Serialize(ref MsgPack::MessagePackWriter writer, global::ContainingClass.MyMessagePackObject value, MsgPack::MessagePackSerializerOptions options) diff --git a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(NestingClass, False)/MessagePack.GeneratedResolver.g.cs b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(NestingClass, False)/MessagePack.GeneratedResolver.g.cs index c04dd2799..1e08f2cdf 100644 --- a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(NestingClass, False)/MessagePack.GeneratedResolver.g.cs +++ b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(NestingClass, False)/MessagePack.GeneratedResolver.g.cs @@ -6,10 +6,13 @@ namespace MessagePack.Resolvers { using MsgPack = global::MessagePack; - public class GeneratedResolver : MsgPack::IFormatterResolver + /// A MessagePack resolver that uses generated formatters for types in this assembly. + internal class GeneratedResolver : MsgPack::IFormatterResolver { + /// An instance of this resolver that only returns formatters specifically generated for types in this assembly. public static readonly MsgPack::IFormatterResolver Instance = new GeneratedResolver(); + /// An instance of this resolver that returns standard AOT-compatible formatters as well as formatters specifically generated for types in this assembly. public static readonly MsgPack::IFormatterResolver InstanceWithStandardAotResolver = MsgPack::Resolvers.CompositeResolver.Create(Instance, MsgPack::Resolvers.StandardAotResolver.Instance); private GeneratedResolver() diff --git a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(NestingClass, True)/MessagePack.Formatter..ContainingClass_MyEnum.g.cs b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(NestingClass, True)/MessagePack.Formatter..ContainingClass_MyEnum.g.cs index 31874e68d..82eb466bd 100644 --- a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(NestingClass, True)/MessagePack.Formatter..ContainingClass_MyEnum.g.cs +++ b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(NestingClass, True)/MessagePack.Formatter..ContainingClass_MyEnum.g.cs @@ -7,7 +7,7 @@ namespace MessagePack.Formatters using MsgPack = global::MessagePack; using ContainingClass_MyEnum = global::ContainingClass.MyEnum; - public sealed class ContainingClass_MyEnumFormatter : MsgPack::Formatters.IMessagePackFormatter + internal sealed class ContainingClass_MyEnumFormatter : MsgPack::Formatters.IMessagePackFormatter { public void Serialize(ref MsgPack::MessagePackWriter writer, ContainingClass_MyEnum value, MsgPack::MessagePackSerializerOptions options) { diff --git a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(NestingClass, True)/MessagePack.Formatter.ContainingClass_MyMessagePackObject.g.cs b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(NestingClass, True)/MessagePack.Formatter.ContainingClass_MyMessagePackObject.g.cs index 4790f9f3c..8886d57bc 100644 --- a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(NestingClass, True)/MessagePack.Formatter.ContainingClass_MyMessagePackObject.g.cs +++ b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(NestingClass, True)/MessagePack.Formatter.ContainingClass_MyMessagePackObject.g.cs @@ -6,7 +6,7 @@ namespace MessagePack.Formatters { using MsgPack = global::MessagePack; - public sealed class ContainingClass_MyMessagePackObjectFormatter : global::MessagePack.Formatters.IMessagePackFormatter + internal sealed class ContainingClass_MyMessagePackObjectFormatter : global::MessagePack.Formatters.IMessagePackFormatter { // EnumValue private static global::System.ReadOnlySpan GetSpan_EnumValue() => new byte[1 + 9] { 169, 69, 110, 117, 109, 86, 97, 108, 117, 101 }; diff --git a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(NestingClass, True)/MessagePack.GeneratedResolver.g.cs b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(NestingClass, True)/MessagePack.GeneratedResolver.g.cs index c04dd2799..1e08f2cdf 100644 --- a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(NestingClass, True)/MessagePack.GeneratedResolver.g.cs +++ b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(NestingClass, True)/MessagePack.GeneratedResolver.g.cs @@ -6,10 +6,13 @@ namespace MessagePack.Resolvers { using MsgPack = global::MessagePack; - public class GeneratedResolver : MsgPack::IFormatterResolver + /// A MessagePack resolver that uses generated formatters for types in this assembly. + internal class GeneratedResolver : MsgPack::IFormatterResolver { + /// An instance of this resolver that only returns formatters specifically generated for types in this assembly. public static readonly MsgPack::IFormatterResolver Instance = new GeneratedResolver(); + /// An instance of this resolver that returns standard AOT-compatible formatters as well as formatters specifically generated for types in this assembly. public static readonly MsgPack::IFormatterResolver InstanceWithStandardAotResolver = MsgPack::Resolvers.CompositeResolver.Create(Instance, MsgPack::Resolvers.StandardAotResolver.Instance); private GeneratedResolver() diff --git a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(None, False)/MessagePack.Formatter..MyEnum.g.cs b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(None, False)/MessagePack.Formatter..MyEnum.g.cs index 7a38011f2..f14da8860 100644 --- a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(None, False)/MessagePack.Formatter..MyEnum.g.cs +++ b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(None, False)/MessagePack.Formatter..MyEnum.g.cs @@ -7,7 +7,7 @@ namespace MessagePack.Formatters using MsgPack = global::MessagePack; using MyEnum = global::MyEnum; - public sealed class MyEnumFormatter : MsgPack::Formatters.IMessagePackFormatter + internal sealed class MyEnumFormatter : MsgPack::Formatters.IMessagePackFormatter { public void Serialize(ref MsgPack::MessagePackWriter writer, MyEnum value, MsgPack::MessagePackSerializerOptions options) { diff --git a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(None, False)/MessagePack.Formatter.MyMessagePackObject.g.cs b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(None, False)/MessagePack.Formatter.MyMessagePackObject.g.cs index b93284ded..3f76060dd 100644 --- a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(None, False)/MessagePack.Formatter.MyMessagePackObject.g.cs +++ b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(None, False)/MessagePack.Formatter.MyMessagePackObject.g.cs @@ -6,7 +6,7 @@ namespace MessagePack.Formatters { using MsgPack = global::MessagePack; - public sealed class MyMessagePackObjectFormatter : MsgPack::Formatters.IMessagePackFormatter + internal sealed class MyMessagePackObjectFormatter : MsgPack::Formatters.IMessagePackFormatter { public void Serialize(ref MsgPack::MessagePackWriter writer, global::MyMessagePackObject value, MsgPack::MessagePackSerializerOptions options) diff --git a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(None, False)/MessagePack.GeneratedResolver.g.cs b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(None, False)/MessagePack.GeneratedResolver.g.cs index db796ddc1..7a4648d67 100644 --- a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(None, False)/MessagePack.GeneratedResolver.g.cs +++ b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(None, False)/MessagePack.GeneratedResolver.g.cs @@ -6,10 +6,13 @@ namespace MessagePack.Resolvers { using MsgPack = global::MessagePack; - public class GeneratedResolver : MsgPack::IFormatterResolver + /// A MessagePack resolver that uses generated formatters for types in this assembly. + internal class GeneratedResolver : MsgPack::IFormatterResolver { + /// An instance of this resolver that only returns formatters specifically generated for types in this assembly. public static readonly MsgPack::IFormatterResolver Instance = new GeneratedResolver(); + /// An instance of this resolver that returns standard AOT-compatible formatters as well as formatters specifically generated for types in this assembly. public static readonly MsgPack::IFormatterResolver InstanceWithStandardAotResolver = MsgPack::Resolvers.CompositeResolver.Create(Instance, MsgPack::Resolvers.StandardAotResolver.Instance); private GeneratedResolver() diff --git a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(None, True)/MessagePack.Formatter..MyEnum.g.cs b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(None, True)/MessagePack.Formatter..MyEnum.g.cs index 7a38011f2..f14da8860 100644 --- a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(None, True)/MessagePack.Formatter..MyEnum.g.cs +++ b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(None, True)/MessagePack.Formatter..MyEnum.g.cs @@ -7,7 +7,7 @@ namespace MessagePack.Formatters using MsgPack = global::MessagePack; using MyEnum = global::MyEnum; - public sealed class MyEnumFormatter : MsgPack::Formatters.IMessagePackFormatter + internal sealed class MyEnumFormatter : MsgPack::Formatters.IMessagePackFormatter { public void Serialize(ref MsgPack::MessagePackWriter writer, MyEnum value, MsgPack::MessagePackSerializerOptions options) { diff --git a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(None, True)/MessagePack.Formatter.MyMessagePackObject.g.cs b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(None, True)/MessagePack.Formatter.MyMessagePackObject.g.cs index 1994b806c..947b6c53b 100644 --- a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(None, True)/MessagePack.Formatter.MyMessagePackObject.g.cs +++ b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(None, True)/MessagePack.Formatter.MyMessagePackObject.g.cs @@ -6,7 +6,7 @@ namespace MessagePack.Formatters { using MsgPack = global::MessagePack; - public sealed class MyMessagePackObjectFormatter : global::MessagePack.Formatters.IMessagePackFormatter + internal sealed class MyMessagePackObjectFormatter : global::MessagePack.Formatters.IMessagePackFormatter { // EnumValue private static global::System.ReadOnlySpan GetSpan_EnumValue() => new byte[1 + 9] { 169, 69, 110, 117, 109, 86, 97, 108, 117, 101 }; diff --git a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(None, True)/MessagePack.GeneratedResolver.g.cs b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(None, True)/MessagePack.GeneratedResolver.g.cs index db796ddc1..7a4648d67 100644 --- a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(None, True)/MessagePack.GeneratedResolver.g.cs +++ b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(None, True)/MessagePack.GeneratedResolver.g.cs @@ -6,10 +6,13 @@ namespace MessagePack.Resolvers { using MsgPack = global::MessagePack; - public class GeneratedResolver : MsgPack::IFormatterResolver + /// A MessagePack resolver that uses generated formatters for types in this assembly. + internal class GeneratedResolver : MsgPack::IFormatterResolver { + /// An instance of this resolver that only returns formatters specifically generated for types in this assembly. public static readonly MsgPack::IFormatterResolver Instance = new GeneratedResolver(); + /// An instance of this resolver that returns standard AOT-compatible formatters as well as formatters specifically generated for types in this assembly. public static readonly MsgPack::IFormatterResolver InstanceWithStandardAotResolver = MsgPack::Resolvers.CompositeResolver.Create(Instance, MsgPack::Resolvers.StandardAotResolver.Instance); private GeneratedResolver() diff --git a/tests/MessagePack.Generator.Tests/Resources/TwoTypes(False)/MessagePack.Formatter.Object1.g.cs b/tests/MessagePack.Generator.Tests/Resources/TwoTypes(False)/MessagePack.Formatter.Object1.g.cs index c84450fd0..5e47fabba 100644 --- a/tests/MessagePack.Generator.Tests/Resources/TwoTypes(False)/MessagePack.Formatter.Object1.g.cs +++ b/tests/MessagePack.Generator.Tests/Resources/TwoTypes(False)/MessagePack.Formatter.Object1.g.cs @@ -6,7 +6,7 @@ namespace MessagePack.Formatters { using MsgPack = global::MessagePack; - public sealed class Object1Formatter : MsgPack::Formatters.IMessagePackFormatter + internal sealed class Object1Formatter : MsgPack::Formatters.IMessagePackFormatter { public void Serialize(ref MsgPack::MessagePackWriter writer, global::Object1 value, MsgPack::MessagePackSerializerOptions options) diff --git a/tests/MessagePack.Generator.Tests/Resources/TwoTypes(False)/MessagePack.Formatter.Object2.g.cs b/tests/MessagePack.Generator.Tests/Resources/TwoTypes(False)/MessagePack.Formatter.Object2.g.cs index 96e60d630..3d6417743 100644 --- a/tests/MessagePack.Generator.Tests/Resources/TwoTypes(False)/MessagePack.Formatter.Object2.g.cs +++ b/tests/MessagePack.Generator.Tests/Resources/TwoTypes(False)/MessagePack.Formatter.Object2.g.cs @@ -6,7 +6,7 @@ namespace MessagePack.Formatters { using MsgPack = global::MessagePack; - public sealed class Object2Formatter : MsgPack::Formatters.IMessagePackFormatter + internal sealed class Object2Formatter : MsgPack::Formatters.IMessagePackFormatter { public void Serialize(ref MsgPack::MessagePackWriter writer, global::Object2 value, MsgPack::MessagePackSerializerOptions options) diff --git a/tests/MessagePack.Generator.Tests/Resources/TwoTypes(False)/MessagePack.GeneratedResolver.g.cs b/tests/MessagePack.Generator.Tests/Resources/TwoTypes(False)/MessagePack.GeneratedResolver.g.cs index a74021ae2..c36139d0b 100644 --- a/tests/MessagePack.Generator.Tests/Resources/TwoTypes(False)/MessagePack.GeneratedResolver.g.cs +++ b/tests/MessagePack.Generator.Tests/Resources/TwoTypes(False)/MessagePack.GeneratedResolver.g.cs @@ -6,10 +6,13 @@ namespace MessagePack.Resolvers { using MsgPack = global::MessagePack; - public class GeneratedResolver : MsgPack::IFormatterResolver + /// A MessagePack resolver that uses generated formatters for types in this assembly. + internal class GeneratedResolver : MsgPack::IFormatterResolver { + /// An instance of this resolver that only returns formatters specifically generated for types in this assembly. public static readonly MsgPack::IFormatterResolver Instance = new GeneratedResolver(); + /// An instance of this resolver that returns standard AOT-compatible formatters as well as formatters specifically generated for types in this assembly. public static readonly MsgPack::IFormatterResolver InstanceWithStandardAotResolver = MsgPack::Resolvers.CompositeResolver.Create(Instance, MsgPack::Resolvers.StandardAotResolver.Instance); private GeneratedResolver() diff --git a/tests/MessagePack.Generator.Tests/Resources/TwoTypes(True)/MessagePack.Formatter.Object1.g.cs b/tests/MessagePack.Generator.Tests/Resources/TwoTypes(True)/MessagePack.Formatter.Object1.g.cs index 172cea3db..1b4083f1e 100644 --- a/tests/MessagePack.Generator.Tests/Resources/TwoTypes(True)/MessagePack.Formatter.Object1.g.cs +++ b/tests/MessagePack.Generator.Tests/Resources/TwoTypes(True)/MessagePack.Formatter.Object1.g.cs @@ -6,7 +6,7 @@ namespace MessagePack.Formatters { using MsgPack = global::MessagePack; - public sealed class Object1Formatter : global::MessagePack.Formatters.IMessagePackFormatter + internal sealed class Object1Formatter : global::MessagePack.Formatters.IMessagePackFormatter { public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::Object1 value, global::MessagePack.MessagePackSerializerOptions options) { diff --git a/tests/MessagePack.Generator.Tests/Resources/TwoTypes(True)/MessagePack.Formatter.Object2.g.cs b/tests/MessagePack.Generator.Tests/Resources/TwoTypes(True)/MessagePack.Formatter.Object2.g.cs index 7465d59d8..accf2fc40 100644 --- a/tests/MessagePack.Generator.Tests/Resources/TwoTypes(True)/MessagePack.Formatter.Object2.g.cs +++ b/tests/MessagePack.Generator.Tests/Resources/TwoTypes(True)/MessagePack.Formatter.Object2.g.cs @@ -6,7 +6,7 @@ namespace MessagePack.Formatters { using MsgPack = global::MessagePack; - public sealed class Object2Formatter : global::MessagePack.Formatters.IMessagePackFormatter + internal sealed class Object2Formatter : global::MessagePack.Formatters.IMessagePackFormatter { public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::Object2 value, global::MessagePack.MessagePackSerializerOptions options) { diff --git a/tests/MessagePack.Generator.Tests/Resources/TwoTypes(True)/MessagePack.GeneratedResolver.g.cs b/tests/MessagePack.Generator.Tests/Resources/TwoTypes(True)/MessagePack.GeneratedResolver.g.cs index a74021ae2..c36139d0b 100644 --- a/tests/MessagePack.Generator.Tests/Resources/TwoTypes(True)/MessagePack.GeneratedResolver.g.cs +++ b/tests/MessagePack.Generator.Tests/Resources/TwoTypes(True)/MessagePack.GeneratedResolver.g.cs @@ -6,10 +6,13 @@ namespace MessagePack.Resolvers { using MsgPack = global::MessagePack; - public class GeneratedResolver : MsgPack::IFormatterResolver + /// A MessagePack resolver that uses generated formatters for types in this assembly. + internal class GeneratedResolver : MsgPack::IFormatterResolver { + /// An instance of this resolver that only returns formatters specifically generated for types in this assembly. public static readonly MsgPack::IFormatterResolver Instance = new GeneratedResolver(); + /// An instance of this resolver that returns standard AOT-compatible formatters as well as formatters specifically generated for types in this assembly. public static readonly MsgPack::IFormatterResolver InstanceWithStandardAotResolver = MsgPack::Resolvers.CompositeResolver.Create(Instance, MsgPack::Resolvers.StandardAotResolver.Instance); private GeneratedResolver() From fb6eec06919a0fdc564b35e4679166d46e29d651 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Thu, 30 Mar 2023 10:20:14 -0600 Subject: [PATCH 057/660] Fix source generator to quietly no-op when no attributes are discovered --- src/MessagePack.Generator/CodeAnalysis/FullModel.cs | 12 ++++++++++++ .../MessagePackGenerator.Emit.cs | 5 +++++ .../MultipleTypesTests.cs | 9 +++++++++ 3 files changed, 26 insertions(+) diff --git a/src/MessagePack.Generator/CodeAnalysis/FullModel.cs b/src/MessagePack.Generator/CodeAnalysis/FullModel.cs index 85d63e79b..c7678b6d8 100644 --- a/src/MessagePack.Generator/CodeAnalysis/FullModel.cs +++ b/src/MessagePack.Generator/CodeAnalysis/FullModel.cs @@ -12,6 +12,8 @@ public record FullModel( ImmutableSortedSet UnionInfos, AnalyzerOptions Options) { + public bool IsEmpty => this.ObjectInfos.IsEmpty && this.EnumInfos.IsEmpty && this.GenericInfos.IsEmpty && this.UnionInfos.IsEmpty; + /// /// Returns a new model that contains all the content of a collection of models. /// @@ -20,6 +22,16 @@ public record FullModel( /// Thrown if is not equal between any two models. public static FullModel Combine(ImmutableArray models) { + if (models.Length == 0) + { + return new FullModel( + ImmutableSortedSet.Create(ResolverRegisterInfoComparer.Default), + ImmutableSortedSet.Create(ResolverRegisterInfoComparer.Default), + ImmutableSortedSet.Create(ResolverRegisterInfoComparer.Default), + ImmutableSortedSet.Create(ResolverRegisterInfoComparer.Default), + AnalyzerOptions.Default); + } + AnalyzerOptions options = models[0].Options; var objectInfos = ImmutableSortedSet.CreateBuilder(ResolverRegisterInfoComparer.Default); var enumInfos = ImmutableSortedSet.CreateBuilder(ResolverRegisterInfoComparer.Default); diff --git a/src/MessagePack.Generator/MessagePackGenerator.Emit.cs b/src/MessagePack.Generator/MessagePackGenerator.Emit.cs index c9ba16861..c98ced6d9 100644 --- a/src/MessagePack.Generator/MessagePackGenerator.Emit.cs +++ b/src/MessagePack.Generator/MessagePackGenerator.Emit.cs @@ -60,6 +60,11 @@ void AddTransform(string transformOutput, string uniqueFileName) private static void GenerateResolver(IGeneratorContext context, FullModel model) { + if (model.IsEmpty) + { + return; + } + AnalyzerOptions options = model.Options; StringBuilder sb = new(); diff --git a/tests/MessagePack.Generator.Tests/MultipleTypesTests.cs b/tests/MessagePack.Generator.Tests/MultipleTypesTests.cs index 2b34a7507..2d60fdf86 100644 --- a/tests/MessagePack.Generator.Tests/MultipleTypesTests.cs +++ b/tests/MessagePack.Generator.Tests/MultipleTypesTests.cs @@ -28,4 +28,13 @@ class Object2 """; await VerifyCS.Test.RunDefaultAsync(testSource, options: AnalyzerOptions.Default with { UsesMapMode = usesMapMode }, testMethod: $"{nameof(TwoTypes)}({usesMapMode})"); } + + [Fact] + public async Task ZeroTypes() + { + string testSource = """ +using MessagePack; +"""; + await VerifyCS.Test.RunDefaultAsync(testSource); + } } From 45ed723a9cae3ec4a15854ebbd0a0f0770dd20bb Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Thu, 30 Mar 2023 12:09:18 -0600 Subject: [PATCH 058/660] Enable public resolvers --- Directory.Packages.props | 1 + MessagePack.sln | 1 + .../MessagePack.Generator.Roslyn3.csproj | 1 + .../CodeAnalysis/AnalyzerOptions.cs | 34 ++++++++++++++----- .../CodeAnalysis/CodeAnalysisUtilities.cs | 6 ++-- .../CodeAnalysis/EnumSerializationInfo.cs | 2 +- .../CodeAnalysis/ObjectSerializationInfo.cs | 2 +- .../CodeAnalysis/UnionSerializationInfo.cs | 2 +- .../MessagePack.Generator.csproj | 1 + .../MessagePackGenerator.Emit.cs | 26 +++++++------- .../Transforms/ResolverTemplate.cs | 13 ++++--- .../Transforms/ResolverTemplate.tt | 5 +-- .../Transforms/TemplatePartials.cs | 18 ++++------ .../build/MessagePack.Generator.props | 9 +++-- .../build/MessagePack.Generator.targets | 6 ++++ .../ExecutionTests.cs | 2 +- ...essagePack.Generator.ExecutionTests.csproj | 8 ++++- ...ack.Generator.MapModeExecutionTests.csproj | 5 +++ ...ters.MyTestNamespace.MyEnumFormatter.g.cs} | 2 +- ...mespace.MyMessagePackObjectFormatter.g.cs} | 2 +- ...agePack.GeneratedMessagePackResolver.g.cs} | 19 ++++++----- ...ters.MyTestNamespace.MyEnumFormatter.g.cs} | 2 +- ...mespace.MyMessagePackObjectFormatter.g.cs} | 2 +- ...agePack.GeneratedMessagePackResolver.g.cs} | 19 ++++++----- ...ters.ContainingClass_MyEnumFormatter.g.cs} | 2 +- ...ngClass_MyMessagePackObjectFormatter.g.cs} | 2 +- ...agePack.GeneratedMessagePackResolver.g.cs} | 19 ++++++----- ...ters.ContainingClass_MyEnumFormatter.g.cs} | 2 +- ...ngClass_MyMessagePackObjectFormatter.g.cs} | 2 +- ...agePack.GeneratedMessagePackResolver.g.cs} | 19 ++++++----- ...m.g.cs => Formatters.MyEnumFormatter.g.cs} | 2 +- ...matters.MyMessagePackObjectFormatter.g.cs} | 2 +- ...agePack.GeneratedMessagePackResolver.g.cs} | 19 ++++++----- ...m.g.cs => Formatters.MyEnumFormatter.g.cs} | 2 +- ...matters.MyMessagePackObjectFormatter.g.cs} | 2 +- ...agePack.GeneratedMessagePackResolver.g.cs} | 19 ++++++----- ....g.cs => Formatters.Object1Formatter.g.cs} | 2 +- ....g.cs => Formatters.Object2Formatter.g.cs} | 2 +- ...agePack.GeneratedMessagePackResolver.g.cs} | 19 ++++++----- ....g.cs => Formatters.Object1Formatter.g.cs} | 2 +- ....g.cs => Formatters.Object2Formatter.g.cs} | 2 +- ...agePack.GeneratedMessagePackResolver.g.cs} | 19 ++++++----- .../CSharpSourceGeneratorVerifier`1+Test.cs | 6 ++-- tests/SourceGeneratorConsumer.targets | 3 ++ 44 files changed, 194 insertions(+), 141 deletions(-) create mode 100644 src/MessagePack.Generator/build/MessagePack.Generator.targets rename tests/MessagePack.Generator.Tests/Resources/EnumFormatter(Namespace, False)/{MessagePack.Formatter.MyTestNamespace.MyEnum.g.cs => Formatters.MyTestNamespace.MyEnumFormatter.g.cs} (92%) rename tests/MessagePack.Generator.Tests/Resources/EnumFormatter(Namespace, False)/{MessagePack.Formatter.MyTestNamespace.MyMessagePackObject.g.cs => Formatters.MyTestNamespace.MyMessagePackObjectFormatter.g.cs} (97%) rename tests/MessagePack.Generator.Tests/Resources/EnumFormatter(Namespace, False)/{MessagePack.GeneratedResolver.g.cs => MessagePack.GeneratedMessagePackResolver.g.cs} (75%) rename tests/MessagePack.Generator.Tests/Resources/EnumFormatter(Namespace, True)/{MessagePack.Formatter.MyTestNamespace.MyEnum.g.cs => Formatters.MyTestNamespace.MyEnumFormatter.g.cs} (92%) rename tests/MessagePack.Generator.Tests/Resources/EnumFormatter(Namespace, True)/{MessagePack.Formatter.MyTestNamespace.MyMessagePackObject.g.cs => Formatters.MyTestNamespace.MyMessagePackObjectFormatter.g.cs} (97%) rename tests/MessagePack.Generator.Tests/Resources/EnumFormatter(Namespace, True)/{MessagePack.GeneratedResolver.g.cs => MessagePack.GeneratedMessagePackResolver.g.cs} (75%) rename tests/MessagePack.Generator.Tests/Resources/EnumFormatter(NestingClass, False)/{MessagePack.Formatter..ContainingClass_MyEnum.g.cs => Formatters.ContainingClass_MyEnumFormatter.g.cs} (95%) rename tests/MessagePack.Generator.Tests/Resources/EnumFormatter(NestingClass, False)/{MessagePack.Formatter.ContainingClass_MyMessagePackObject.g.cs => Formatters.ContainingClass_MyMessagePackObjectFormatter.g.cs} (98%) rename tests/MessagePack.Generator.Tests/Resources/{EnumFormatter(NestingClass, True)/MessagePack.GeneratedResolver.g.cs => EnumFormatter(NestingClass, False)/MessagePack.GeneratedMessagePackResolver.g.cs} (75%) rename tests/MessagePack.Generator.Tests/Resources/EnumFormatter(NestingClass, True)/{MessagePack.Formatter..ContainingClass_MyEnum.g.cs => Formatters.ContainingClass_MyEnumFormatter.g.cs} (95%) rename tests/MessagePack.Generator.Tests/Resources/EnumFormatter(NestingClass, True)/{MessagePack.Formatter.ContainingClass_MyMessagePackObject.g.cs => Formatters.ContainingClass_MyMessagePackObjectFormatter.g.cs} (98%) rename tests/MessagePack.Generator.Tests/Resources/{EnumFormatter(NestingClass, False)/MessagePack.GeneratedResolver.g.cs => EnumFormatter(NestingClass, True)/MessagePack.GeneratedMessagePackResolver.g.cs} (75%) rename tests/MessagePack.Generator.Tests/Resources/EnumFormatter(None, False)/{MessagePack.Formatter..MyEnum.g.cs => Formatters.MyEnumFormatter.g.cs} (94%) rename tests/MessagePack.Generator.Tests/Resources/EnumFormatter(None, False)/{MessagePack.Formatter.MyMessagePackObject.g.cs => Formatters.MyMessagePackObjectFormatter.g.cs} (97%) rename tests/MessagePack.Generator.Tests/Resources/EnumFormatter(None, False)/{MessagePack.GeneratedResolver.g.cs => MessagePack.GeneratedMessagePackResolver.g.cs} (76%) rename tests/MessagePack.Generator.Tests/Resources/EnumFormatter(None, True)/{MessagePack.Formatter..MyEnum.g.cs => Formatters.MyEnumFormatter.g.cs} (94%) rename tests/MessagePack.Generator.Tests/Resources/EnumFormatter(None, True)/{MessagePack.Formatter.MyMessagePackObject.g.cs => Formatters.MyMessagePackObjectFormatter.g.cs} (98%) rename tests/MessagePack.Generator.Tests/Resources/EnumFormatter(None, True)/{MessagePack.GeneratedResolver.g.cs => MessagePack.GeneratedMessagePackResolver.g.cs} (76%) rename tests/MessagePack.Generator.Tests/Resources/TwoTypes(False)/{MessagePack.Formatter.Object1.g.cs => Formatters.Object1Formatter.g.cs} (95%) rename tests/MessagePack.Generator.Tests/Resources/TwoTypes(False)/{MessagePack.Formatter.Object2.g.cs => Formatters.Object2Formatter.g.cs} (95%) rename tests/MessagePack.Generator.Tests/Resources/TwoTypes(False)/{MessagePack.GeneratedResolver.g.cs => MessagePack.GeneratedMessagePackResolver.g.cs} (76%) rename tests/MessagePack.Generator.Tests/Resources/TwoTypes(True)/{MessagePack.Formatter.Object1.g.cs => Formatters.Object1Formatter.g.cs} (96%) rename tests/MessagePack.Generator.Tests/Resources/TwoTypes(True)/{MessagePack.Formatter.Object2.g.cs => Formatters.Object2Formatter.g.cs} (96%) rename tests/MessagePack.Generator.Tests/Resources/TwoTypes(True)/{MessagePack.GeneratedResolver.g.cs => MessagePack.GeneratedMessagePackResolver.g.cs} (76%) create mode 100644 tests/SourceGeneratorConsumer.targets diff --git a/Directory.Packages.props b/Directory.Packages.props index b1f122460..4857713f9 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -49,6 +49,7 @@ + diff --git a/MessagePack.sln b/MessagePack.sln index 795a4b11b..d418d7b99 100644 --- a/MessagePack.sln +++ b/MessagePack.sln @@ -14,6 +14,7 @@ EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{19FE674A-AC94-4E7E-B24C-2285D1D04CDE}" ProjectSection(SolutionItems) = preProject tests\SourceGeneratorConsumer.props = tests\SourceGeneratorConsumer.props + tests\SourceGeneratorConsumer.targets = tests\SourceGeneratorConsumer.targets EndProjectSection EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MessagePack.Tests", "tests\MessagePack.Tests\MessagePack.Tests.csproj", "{9E1A55CA-711D-4F58-A332-735960E3434C}" diff --git a/src/MessagePack.Generator.Roslyn3/MessagePack.Generator.Roslyn3.csproj b/src/MessagePack.Generator.Roslyn3/MessagePack.Generator.Roslyn3.csproj index c55019f87..8a8643362 100644 --- a/src/MessagePack.Generator.Roslyn3/MessagePack.Generator.Roslyn3.csproj +++ b/src/MessagePack.Generator.Roslyn3/MessagePack.Generator.Roslyn3.csproj @@ -21,6 +21,7 @@ + diff --git a/src/MessagePack.Generator/CodeAnalysis/AnalyzerOptions.cs b/src/MessagePack.Generator/CodeAnalysis/AnalyzerOptions.cs index 5e1dfa32f..22e018ac2 100644 --- a/src/MessagePack.Generator/CodeAnalysis/AnalyzerOptions.cs +++ b/src/MessagePack.Generator/CodeAnalysis/AnalyzerOptions.cs @@ -1,32 +1,38 @@ // Copyright (c) All contributors. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -using System.Collections.Immutable; using Microsoft.CodeAnalysis.Diagnostics; namespace MessagePack.Generator.CodeAnalysis; public record AnalyzerOptions( - string Namespace = "MessagePack", - string ResolverName = "GeneratedResolver", + string ResolverNamespace = "MessagePack", + string ResolverName = "GeneratedMessagePackResolver", + string ProjectRootNamespace = "", + bool PublicResolver = false, bool UsesMapMode = false, IReadOnlyCollection? IgnoreTypeNames = null) { + public const string RootNamespace = "build_property.RootNamespace"; + public const string PublicMessagePackGeneratedResolver = "build_property.PublicMessagePackGeneratedResolver"; public const string MessagePackGeneratedResolverNamespace = "build_property.MessagePackGeneratedResolverNamespace"; public const string MessagePackGeneratedResolverName = "build_property.MessagePackGeneratedResolverName"; public const string MessagePackGeneratedUsesMapMode = "build_property.MessagePackGeneratedUsesMapMode"; public static readonly AnalyzerOptions Default = new AnalyzerOptions(); - public string ResolverNamespace => $"{Namespace}.Resolvers"; - - public string FormatterNamespace => $"{Namespace}.Formatters"; + public string FormatterNamespace => CodeAnalysisUtilities.QualifyWithOptionalNamespace("Formatters", this.ProjectRootNamespace); public static AnalyzerOptions Parse(AnalyzerConfigOptions options) { - if (!options.TryGetValue(MessagePackGeneratedResolverNamespace, out string? @namespace)) + if (!options.TryGetValue(RootNamespace, out string? projectRootNamespace)) + { + projectRootNamespace = Default.ProjectRootNamespace; + } + + if (!options.TryGetValue(MessagePackGeneratedResolverNamespace, out string? resolverNamespace)) { - @namespace = Default.Namespace; + resolverNamespace = Default.ResolverNamespace; } if (!options.TryGetValue(MessagePackGeneratedResolverName, out string? resolverName)) @@ -39,6 +45,16 @@ public static AnalyzerOptions Parse(AnalyzerConfigOptions options) usesMapMode = Default.UsesMapMode ? "true" : "false"; } - return new AnalyzerOptions(@namespace, resolverName, string.Equals(usesMapMode, "true", StringComparison.OrdinalIgnoreCase)); + if (!options.TryGetValue(PublicMessagePackGeneratedResolver, out string? publicResolver)) + { + publicResolver = Default.PublicResolver ? "true" : "false"; + } + + return new AnalyzerOptions( + ResolverNamespace: resolverNamespace, + ResolverName: resolverName, + ProjectRootNamespace: projectRootNamespace, + PublicResolver: string.Equals(publicResolver, "true", StringComparison.OrdinalIgnoreCase), + UsesMapMode: string.Equals(usesMapMode, "true", StringComparison.OrdinalIgnoreCase)); } } diff --git a/src/MessagePack.Generator/CodeAnalysis/CodeAnalysisUtilities.cs b/src/MessagePack.Generator/CodeAnalysis/CodeAnalysisUtilities.cs index 9d33cb14e..1b901b8ee 100644 --- a/src/MessagePack.Generator/CodeAnalysis/CodeAnalysisUtilities.cs +++ b/src/MessagePack.Generator/CodeAnalysis/CodeAnalysisUtilities.cs @@ -5,12 +5,12 @@ namespace MessagePack.Generator.CodeAnalysis; internal static class CodeAnalysisUtilities { - internal static string NamespaceAndType(string typeName, string? @namespace) + internal static string QualifyWithOptionalNamespace(string leafTypeOrNamespace, string? baseNamespace) { - return string.IsNullOrEmpty(@namespace) ? typeName : $"{@namespace}.{typeName}"; + return string.IsNullOrEmpty(baseNamespace) ? leafTypeOrNamespace : $"{baseNamespace}.{leafTypeOrNamespace}"; } - internal static string QualifyNames(string left, string? right) + internal static string AppendNameToNamespace(string left, string? right) { return string.IsNullOrEmpty(right) ? left : $"{left}.{right}"; } diff --git a/src/MessagePack.Generator/CodeAnalysis/EnumSerializationInfo.cs b/src/MessagePack.Generator/CodeAnalysis/EnumSerializationInfo.cs index 9e882eb7b..91c154e19 100644 --- a/src/MessagePack.Generator/CodeAnalysis/EnumSerializationInfo.cs +++ b/src/MessagePack.Generator/CodeAnalysis/EnumSerializationInfo.cs @@ -5,7 +5,7 @@ namespace MessagePack.Generator.CodeAnalysis; public sealed record EnumSerializationInfo(string? Namespace, string Name, string FullName, string UnderlyingTypeName) : IResolverRegisterInfo { - public string FormatterName => CodeAnalysisUtilities.NamespaceAndType(this.Name + "Formatter", this.Namespace); + public string FormatterName => CodeAnalysisUtilities.QualifyWithOptionalNamespace(this.Name + "Formatter", this.Namespace); public string UnderlyingTypeKeyword => this.UnderlyingTypeName switch { diff --git a/src/MessagePack.Generator/CodeAnalysis/ObjectSerializationInfo.cs b/src/MessagePack.Generator/CodeAnalysis/ObjectSerializationInfo.cs index 3b717fc28..8acad4063 100644 --- a/src/MessagePack.Generator/CodeAnalysis/ObjectSerializationInfo.cs +++ b/src/MessagePack.Generator/CodeAnalysis/ObjectSerializationInfo.cs @@ -22,7 +22,7 @@ public bool IsStringKey get { return !this.IsIntKey; } } - public string FormatterName => CodeAnalysisUtilities.NamespaceAndType(this.FormatterNameWithoutNamespace, this.Namespace); + public string FormatterName => CodeAnalysisUtilities.QualifyWithOptionalNamespace(this.FormatterNameWithoutNamespace, this.Namespace); public string FormatterNameWithoutNamespace => this.Name + "Formatter" + (this.IsOpenGenericType ? $"<{string.Join(", ", this.GenericTypeParameters.Select(x => x.Name))}>" : string.Empty); diff --git a/src/MessagePack.Generator/CodeAnalysis/UnionSerializationInfo.cs b/src/MessagePack.Generator/CodeAnalysis/UnionSerializationInfo.cs index 1a835b3e7..b0626e078 100644 --- a/src/MessagePack.Generator/CodeAnalysis/UnionSerializationInfo.cs +++ b/src/MessagePack.Generator/CodeAnalysis/UnionSerializationInfo.cs @@ -9,5 +9,5 @@ public record UnionSerializationInfo( string FullName, UnionSubTypeInfo[] SubTypes) : IResolverRegisterInfo { - public string FormatterName => CodeAnalysisUtilities.NamespaceAndType(this.Name + "Formatter", this.Namespace); + public string FormatterName => CodeAnalysisUtilities.QualifyWithOptionalNamespace(this.Name + "Formatter", this.Namespace); } diff --git a/src/MessagePack.Generator/MessagePack.Generator.csproj b/src/MessagePack.Generator/MessagePack.Generator.csproj index bd7ed5201..1b0dff562 100644 --- a/src/MessagePack.Generator/MessagePack.Generator.csproj +++ b/src/MessagePack.Generator/MessagePack.Generator.csproj @@ -26,6 +26,7 @@ + diff --git a/src/MessagePack.Generator/MessagePackGenerator.Emit.cs b/src/MessagePack.Generator/MessagePackGenerator.Emit.cs index c98ced6d9..e9fe5b1d5 100644 --- a/src/MessagePack.Generator/MessagePackGenerator.Emit.cs +++ b/src/MessagePack.Generator/MessagePackGenerator.Emit.cs @@ -29,23 +29,23 @@ private static void Generate(IGeneratorContext context, FullModel model) foreach (EnumSerializationInfo info in model.EnumInfos) { - EnumTemplate transform = new(CodeAnalysisUtilities.QualifyNames(options.FormatterNamespace, info.Namespace), info); - AddTransform(transform.TransformText(), $"{info.Namespace}.{info.Name}"); + EnumTemplate transform = new(CodeAnalysisUtilities.AppendNameToNamespace(options.FormatterNamespace, info.Namespace), info); + AddTransform(transform.TransformText(), CodeAnalysisUtilities.QualifyWithOptionalNamespace(info.FormatterName, options.FormatterNamespace)); } foreach (UnionSerializationInfo info in model.UnionInfos) { UnionTemplate transform = new(options.FormatterNamespace, info); - AddTransform(transform.TransformText(), $"Union.{info.Name}"); + AddTransform(transform.TransformText(), CodeAnalysisUtilities.QualifyWithOptionalNamespace(info.FormatterName, options.FormatterNamespace)); } foreach (ObjectSerializationInfo info in model.ObjectInfos) { - string formatterNamespace = CodeAnalysisUtilities.QualifyNames(options.FormatterNamespace, info.Namespace); + string formatterNamespace = CodeAnalysisUtilities.AppendNameToNamespace(options.FormatterNamespace, info.Namespace); IFormatterTemplate transform = info.IsStringKey ? new StringKeyFormatterTemplate(formatterNamespace, info) : new FormatterTemplate(formatterNamespace, info); - AddTransform(transform.TransformText(), CodeAnalysisUtilities.NamespaceAndType(info.Name, info.Namespace)); + AddTransform(transform.TransformText(), CodeAnalysisUtilities.QualifyWithOptionalNamespace(info.FormatterName, options.FormatterNamespace)); } void AddTransform(string transformOutput, string uniqueFileName) @@ -53,7 +53,7 @@ void AddTransform(string transformOutput, string uniqueFileName) sb.Clear(); sb.AppendLine(FileHeader); sb.Append(transformOutput); - context.AddSource($"MessagePack.Formatter.{uniqueFileName}.g.cs", sb.ToString()); + context.AddSource($"{uniqueFileName}.g.cs", sb.ToString()); sb.Clear(); } } @@ -68,19 +68,19 @@ private static void GenerateResolver(IGeneratorContext context, FullModel model) AnalyzerOptions options = model.Options; StringBuilder sb = new(); - ResolverTemplate resolverTemplate = new( - options.ResolverNamespace, - options.FormatterNamespace, - options.ResolverName, - model.GenericInfos + ResolverTemplate resolverTemplate = new() + { + Options = options, + RegisterInfos = model.GenericInfos .Where(x => !x.IsOpenGenericType) .Cast() .Concat(model.EnumInfos) .Concat(model.UnionInfos) .Concat(model.ObjectInfos.Where(x => !x.IsOpenGenericType)) - .ToArray()); + .ToArray(), + }; sb.AppendLine(FileHeader); sb.Append(resolverTemplate.TransformText()); - context.AddSource($"MessagePack.GeneratedResolver.g.cs", sb.ToString()); + context.AddSource($"{CodeAnalysisUtilities.QualifyWithOptionalNamespace(options.ResolverName, options.ResolverNamespace)}.g.cs", sb.ToString()); } } diff --git a/src/MessagePack.Generator/Transforms/ResolverTemplate.cs b/src/MessagePack.Generator/Transforms/ResolverTemplate.cs index 991967a6a..0254f0f7c 100644 --- a/src/MessagePack.Generator/Transforms/ResolverTemplate.cs +++ b/src/MessagePack.Generator/Transforms/ResolverTemplate.cs @@ -27,9 +27,12 @@ public virtual string TransformText() { this.Write("\r\nnamespace "); this.Write(this.ToStringHelper.ToStringWithCulture(ResolverNamespace)); - this.Write("\r\n{\r\n\tusing MsgPack = global::MessagePack;\r\n\r\n\t/// A MessagePack resolve" + - "r that uses generated formatters for types in this assembly.\r\n\tinterna" + - "l class "); + this.Write("\r\n{\r\n\tusing MsgPack = global::MessagePack;\r\n\tusing Formatters = global::"); + this.Write(this.ToStringHelper.ToStringWithCulture(FormatterNamespace)); + this.Write(";\r\n\r\n\t/// A MessagePack resolver that uses generated formatters for type" + + "s in this assembly.\r\n\t"); + this.Write(this.ToStringHelper.ToStringWithCulture(PublicResolver ? "public" : "internal")); + this.Write(" class "); this.Write(this.ToStringHelper.ToStringWithCulture(ResolverName)); this.Write(" : MsgPack::IFormatterResolver\r\n\t{\r\n\t\t/// An instance of this resolver t" + "hat only returns formatters specifically generated for types in this assembly. { using MsgPack = global::MessagePack; + using Formatters = global::<#= FormatterNamespace #>; /// A MessagePack resolver that uses generated formatters for types in this assembly. - internal class <#= ResolverName #> : MsgPack::IFormatterResolver + <#= PublicResolver ? "public" : "internal" #> class <#= ResolverName #> : MsgPack::IFormatterResolver { /// An instance of this resolver that only returns formatters specifically generated for types in this assembly. public static readonly MsgPack::IFormatterResolver Instance = new <#= ResolverName #>(); @@ -66,7 +67,7 @@ namespace <#= ResolverNamespace #> switch (key) { <# for(var i = 0; i < RegisterInfos.Count; i++) { var x = RegisterInfos[i]; #> - case <#= i #>: return new <#= x.FormatterName.StartsWith("global::") ? x.FormatterName : (FormatterNamespace + "." + x.FormatterName) #>(); + case <#= i #>: return new Formatters::<#= x.FormatterName #>(); <# } #> default: return null; } diff --git a/src/MessagePack.Generator/Transforms/TemplatePartials.cs b/src/MessagePack.Generator/Transforms/TemplatePartials.cs index cdd720fca..3defdd8a9 100644 --- a/src/MessagePack.Generator/Transforms/TemplatePartials.cs +++ b/src/MessagePack.Generator/Transforms/TemplatePartials.cs @@ -35,21 +35,17 @@ public StringKeyFormatterTemplate(string @namespace, ObjectSerializationInfo inf public partial class ResolverTemplate { - public ResolverTemplate(string resolverNamespace, string formatterNamespace, string resolverName, IReadOnlyList registerInfos) - { - ResolverNamespace = resolverNamespace; - FormatterNamespace = formatterNamespace; - ResolverName = resolverName; - RegisterInfos = registerInfos; - } + required public AnalyzerOptions Options { get; init; } + + public string ResolverNamespace => this.Options.ResolverNamespace; - public string ResolverNamespace { get; } + public string FormatterNamespace => this.Options.FormatterNamespace; - public string FormatterNamespace { get; } + public string ResolverName => this.Options.ResolverName; - public string ResolverName { get; } + public bool PublicResolver => this.Options.PublicResolver; - public IReadOnlyList RegisterInfos { get; } + required public IReadOnlyList RegisterInfos { get; init; } } public partial class EnumTemplate diff --git a/src/MessagePack.Generator/build/MessagePack.Generator.props b/src/MessagePack.Generator/build/MessagePack.Generator.props index 25d918e23..c16131410 100644 --- a/src/MessagePack.Generator/build/MessagePack.Generator.props +++ b/src/MessagePack.Generator/build/MessagePack.Generator.props @@ -1,11 +1,14 @@ - + - MessagePack - GeneratedResolver + + false + GeneratedMessagePackResolver false + + diff --git a/src/MessagePack.Generator/build/MessagePack.Generator.targets b/src/MessagePack.Generator/build/MessagePack.Generator.targets new file mode 100644 index 000000000..cc1576181 --- /dev/null +++ b/src/MessagePack.Generator/build/MessagePack.Generator.targets @@ -0,0 +1,6 @@ + + + $(RootNamespace) + MessagePack + + \ No newline at end of file diff --git a/tests/MessagePack.Generator.ExecutionTests/ExecutionTests.cs b/tests/MessagePack.Generator.ExecutionTests/ExecutionTests.cs index 2f28ea4c4..0698a970f 100644 --- a/tests/MessagePack.Generator.ExecutionTests/ExecutionTests.cs +++ b/tests/MessagePack.Generator.ExecutionTests/ExecutionTests.cs @@ -4,7 +4,7 @@ public class ExecutionTests { private static readonly MessagePackSerializerOptions SerializerOptions = MessagePackSerializerOptions.Standard - .WithResolver(GeneratedResolver.InstanceWithStandardAotResolver); + .WithResolver(GeneratedMessagePackResolver.InstanceWithStandardAotResolver); private readonly ITestOutputHelper logger; diff --git a/tests/MessagePack.Generator.ExecutionTests/MessagePack.Generator.ExecutionTests.csproj b/tests/MessagePack.Generator.ExecutionTests/MessagePack.Generator.ExecutionTests.csproj index e2f8045dc..3fbe1cbb1 100644 --- a/tests/MessagePack.Generator.ExecutionTests/MessagePack.Generator.ExecutionTests.csproj +++ b/tests/MessagePack.Generator.ExecutionTests/MessagePack.Generator.ExecutionTests.csproj @@ -1,16 +1,22 @@ - + net7.0 enable enable + true + + + + + diff --git a/tests/MessagePack.Generator.MapModeExecutionTests/MessagePack.Generator.MapModeExecutionTests.csproj b/tests/MessagePack.Generator.MapModeExecutionTests/MessagePack.Generator.MapModeExecutionTests.csproj index 38ef99c6f..50966af31 100644 --- a/tests/MessagePack.Generator.MapModeExecutionTests/MessagePack.Generator.MapModeExecutionTests.csproj +++ b/tests/MessagePack.Generator.MapModeExecutionTests/MessagePack.Generator.MapModeExecutionTests.csproj @@ -12,10 +12,15 @@ + + + + + diff --git a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(Namespace, False)/MessagePack.Formatter.MyTestNamespace.MyEnum.g.cs b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(Namespace, False)/Formatters.MyTestNamespace.MyEnumFormatter.g.cs similarity index 92% rename from tests/MessagePack.Generator.Tests/Resources/EnumFormatter(Namespace, False)/MessagePack.Formatter.MyTestNamespace.MyEnum.g.cs rename to tests/MessagePack.Generator.Tests/Resources/EnumFormatter(Namespace, False)/Formatters.MyTestNamespace.MyEnumFormatter.g.cs index c4194470d..a8c971ee9 100644 --- a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(Namespace, False)/MessagePack.Formatter.MyTestNamespace.MyEnum.g.cs +++ b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(Namespace, False)/Formatters.MyTestNamespace.MyEnumFormatter.g.cs @@ -2,7 +2,7 @@ #pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 -namespace MessagePack.Formatters.MyTestNamespace +namespace Formatters.MyTestNamespace { using MsgPack = global::MessagePack; using MyEnum = global::MyTestNamespace.MyEnum; diff --git a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(Namespace, False)/MessagePack.Formatter.MyTestNamespace.MyMessagePackObject.g.cs b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(Namespace, False)/Formatters.MyTestNamespace.MyMessagePackObjectFormatter.g.cs similarity index 97% rename from tests/MessagePack.Generator.Tests/Resources/EnumFormatter(Namespace, False)/MessagePack.Formatter.MyTestNamespace.MyMessagePackObject.g.cs rename to tests/MessagePack.Generator.Tests/Resources/EnumFormatter(Namespace, False)/Formatters.MyTestNamespace.MyMessagePackObjectFormatter.g.cs index 25ad12f34..1529eb9fd 100644 --- a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(Namespace, False)/MessagePack.Formatter.MyTestNamespace.MyMessagePackObject.g.cs +++ b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(Namespace, False)/Formatters.MyTestNamespace.MyMessagePackObjectFormatter.g.cs @@ -2,7 +2,7 @@ #pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 -namespace MessagePack.Formatters.MyTestNamespace +namespace Formatters.MyTestNamespace { using MsgPack = global::MessagePack; diff --git a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(Namespace, False)/MessagePack.GeneratedResolver.g.cs b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(Namespace, False)/MessagePack.GeneratedMessagePackResolver.g.cs similarity index 75% rename from tests/MessagePack.Generator.Tests/Resources/EnumFormatter(Namespace, False)/MessagePack.GeneratedResolver.g.cs rename to tests/MessagePack.Generator.Tests/Resources/EnumFormatter(Namespace, False)/MessagePack.GeneratedMessagePackResolver.g.cs index 9f0ccb375..8432ec408 100644 --- a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(Namespace, False)/MessagePack.GeneratedResolver.g.cs +++ b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(Namespace, False)/MessagePack.GeneratedMessagePackResolver.g.cs @@ -2,20 +2,21 @@ #pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 -namespace MessagePack.Resolvers +namespace MessagePack { using MsgPack = global::MessagePack; + using Formatters = global::Formatters; /// A MessagePack resolver that uses generated formatters for types in this assembly. - internal class GeneratedResolver : MsgPack::IFormatterResolver + internal class GeneratedMessagePackResolver : MsgPack::IFormatterResolver { /// An instance of this resolver that only returns formatters specifically generated for types in this assembly. - public static readonly MsgPack::IFormatterResolver Instance = new GeneratedResolver(); + public static readonly MsgPack::IFormatterResolver Instance = new GeneratedMessagePackResolver(); /// An instance of this resolver that returns standard AOT-compatible formatters as well as formatters specifically generated for types in this assembly. public static readonly MsgPack::IFormatterResolver InstanceWithStandardAotResolver = MsgPack::Resolvers.CompositeResolver.Create(Instance, MsgPack::Resolvers.StandardAotResolver.Instance); - private GeneratedResolver() + private GeneratedMessagePackResolver() { } @@ -30,7 +31,7 @@ private static class FormatterCache static FormatterCache() { - var f = GeneratedResolverGetFormatterHelper.GetFormatter(typeof(T)); + var f = GeneratedMessagePackResolverGetFormatterHelper.GetFormatter(typeof(T)); if (f != null) { Formatter = (MsgPack::Formatters.IMessagePackFormatter)f; @@ -39,11 +40,11 @@ static FormatterCache() } } - internal static class GeneratedResolverGetFormatterHelper + internal static class GeneratedMessagePackResolverGetFormatterHelper { private static readonly global::System.Collections.Generic.Dictionary lookup; - static GeneratedResolverGetFormatterHelper() + static GeneratedMessagePackResolverGetFormatterHelper() { lookup = new global::System.Collections.Generic.Dictionary(2) { @@ -62,8 +63,8 @@ internal static object GetFormatter(global::System.Type t) switch (key) { - case 0: return new MessagePack.Formatters.MyTestNamespace.MyEnumFormatter(); - case 1: return new MessagePack.Formatters.MyTestNamespace.MyMessagePackObjectFormatter(); + case 0: return new Formatters::MyTestNamespace.MyEnumFormatter(); + case 1: return new Formatters::MyTestNamespace.MyMessagePackObjectFormatter(); default: return null; } } diff --git a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(Namespace, True)/MessagePack.Formatter.MyTestNamespace.MyEnum.g.cs b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(Namespace, True)/Formatters.MyTestNamespace.MyEnumFormatter.g.cs similarity index 92% rename from tests/MessagePack.Generator.Tests/Resources/EnumFormatter(Namespace, True)/MessagePack.Formatter.MyTestNamespace.MyEnum.g.cs rename to tests/MessagePack.Generator.Tests/Resources/EnumFormatter(Namespace, True)/Formatters.MyTestNamespace.MyEnumFormatter.g.cs index c4194470d..a8c971ee9 100644 --- a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(Namespace, True)/MessagePack.Formatter.MyTestNamespace.MyEnum.g.cs +++ b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(Namespace, True)/Formatters.MyTestNamespace.MyEnumFormatter.g.cs @@ -2,7 +2,7 @@ #pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 -namespace MessagePack.Formatters.MyTestNamespace +namespace Formatters.MyTestNamespace { using MsgPack = global::MessagePack; using MyEnum = global::MyTestNamespace.MyEnum; diff --git a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(Namespace, True)/MessagePack.Formatter.MyTestNamespace.MyMessagePackObject.g.cs b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(Namespace, True)/Formatters.MyTestNamespace.MyMessagePackObjectFormatter.g.cs similarity index 97% rename from tests/MessagePack.Generator.Tests/Resources/EnumFormatter(Namespace, True)/MessagePack.Formatter.MyTestNamespace.MyMessagePackObject.g.cs rename to tests/MessagePack.Generator.Tests/Resources/EnumFormatter(Namespace, True)/Formatters.MyTestNamespace.MyMessagePackObjectFormatter.g.cs index bfd59b201..9e3f35407 100644 --- a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(Namespace, True)/MessagePack.Formatter.MyTestNamespace.MyMessagePackObject.g.cs +++ b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(Namespace, True)/Formatters.MyTestNamespace.MyMessagePackObjectFormatter.g.cs @@ -2,7 +2,7 @@ #pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 -namespace MessagePack.Formatters.MyTestNamespace +namespace Formatters.MyTestNamespace { using MsgPack = global::MessagePack; diff --git a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(Namespace, True)/MessagePack.GeneratedResolver.g.cs b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(Namespace, True)/MessagePack.GeneratedMessagePackResolver.g.cs similarity index 75% rename from tests/MessagePack.Generator.Tests/Resources/EnumFormatter(Namespace, True)/MessagePack.GeneratedResolver.g.cs rename to tests/MessagePack.Generator.Tests/Resources/EnumFormatter(Namespace, True)/MessagePack.GeneratedMessagePackResolver.g.cs index 9f0ccb375..8432ec408 100644 --- a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(Namespace, True)/MessagePack.GeneratedResolver.g.cs +++ b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(Namespace, True)/MessagePack.GeneratedMessagePackResolver.g.cs @@ -2,20 +2,21 @@ #pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 -namespace MessagePack.Resolvers +namespace MessagePack { using MsgPack = global::MessagePack; + using Formatters = global::Formatters; /// A MessagePack resolver that uses generated formatters for types in this assembly. - internal class GeneratedResolver : MsgPack::IFormatterResolver + internal class GeneratedMessagePackResolver : MsgPack::IFormatterResolver { /// An instance of this resolver that only returns formatters specifically generated for types in this assembly. - public static readonly MsgPack::IFormatterResolver Instance = new GeneratedResolver(); + public static readonly MsgPack::IFormatterResolver Instance = new GeneratedMessagePackResolver(); /// An instance of this resolver that returns standard AOT-compatible formatters as well as formatters specifically generated for types in this assembly. public static readonly MsgPack::IFormatterResolver InstanceWithStandardAotResolver = MsgPack::Resolvers.CompositeResolver.Create(Instance, MsgPack::Resolvers.StandardAotResolver.Instance); - private GeneratedResolver() + private GeneratedMessagePackResolver() { } @@ -30,7 +31,7 @@ private static class FormatterCache static FormatterCache() { - var f = GeneratedResolverGetFormatterHelper.GetFormatter(typeof(T)); + var f = GeneratedMessagePackResolverGetFormatterHelper.GetFormatter(typeof(T)); if (f != null) { Formatter = (MsgPack::Formatters.IMessagePackFormatter)f; @@ -39,11 +40,11 @@ static FormatterCache() } } - internal static class GeneratedResolverGetFormatterHelper + internal static class GeneratedMessagePackResolverGetFormatterHelper { private static readonly global::System.Collections.Generic.Dictionary lookup; - static GeneratedResolverGetFormatterHelper() + static GeneratedMessagePackResolverGetFormatterHelper() { lookup = new global::System.Collections.Generic.Dictionary(2) { @@ -62,8 +63,8 @@ internal static object GetFormatter(global::System.Type t) switch (key) { - case 0: return new MessagePack.Formatters.MyTestNamespace.MyEnumFormatter(); - case 1: return new MessagePack.Formatters.MyTestNamespace.MyMessagePackObjectFormatter(); + case 0: return new Formatters::MyTestNamespace.MyEnumFormatter(); + case 1: return new Formatters::MyTestNamespace.MyMessagePackObjectFormatter(); default: return null; } } diff --git a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(NestingClass, False)/MessagePack.Formatter..ContainingClass_MyEnum.g.cs b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(NestingClass, False)/Formatters.ContainingClass_MyEnumFormatter.g.cs similarity index 95% rename from tests/MessagePack.Generator.Tests/Resources/EnumFormatter(NestingClass, False)/MessagePack.Formatter..ContainingClass_MyEnum.g.cs rename to tests/MessagePack.Generator.Tests/Resources/EnumFormatter(NestingClass, False)/Formatters.ContainingClass_MyEnumFormatter.g.cs index 82eb466bd..48de649c6 100644 --- a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(NestingClass, False)/MessagePack.Formatter..ContainingClass_MyEnum.g.cs +++ b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(NestingClass, False)/Formatters.ContainingClass_MyEnumFormatter.g.cs @@ -2,7 +2,7 @@ #pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 -namespace MessagePack.Formatters +namespace Formatters { using MsgPack = global::MessagePack; using ContainingClass_MyEnum = global::ContainingClass.MyEnum; diff --git a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(NestingClass, False)/MessagePack.Formatter.ContainingClass_MyMessagePackObject.g.cs b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(NestingClass, False)/Formatters.ContainingClass_MyMessagePackObjectFormatter.g.cs similarity index 98% rename from tests/MessagePack.Generator.Tests/Resources/EnumFormatter(NestingClass, False)/MessagePack.Formatter.ContainingClass_MyMessagePackObject.g.cs rename to tests/MessagePack.Generator.Tests/Resources/EnumFormatter(NestingClass, False)/Formatters.ContainingClass_MyMessagePackObjectFormatter.g.cs index 8e96eb928..94af15ad3 100644 --- a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(NestingClass, False)/MessagePack.Formatter.ContainingClass_MyMessagePackObject.g.cs +++ b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(NestingClass, False)/Formatters.ContainingClass_MyMessagePackObjectFormatter.g.cs @@ -2,7 +2,7 @@ #pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 -namespace MessagePack.Formatters +namespace Formatters { using MsgPack = global::MessagePack; diff --git a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(NestingClass, True)/MessagePack.GeneratedResolver.g.cs b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(NestingClass, False)/MessagePack.GeneratedMessagePackResolver.g.cs similarity index 75% rename from tests/MessagePack.Generator.Tests/Resources/EnumFormatter(NestingClass, True)/MessagePack.GeneratedResolver.g.cs rename to tests/MessagePack.Generator.Tests/Resources/EnumFormatter(NestingClass, False)/MessagePack.GeneratedMessagePackResolver.g.cs index 1e08f2cdf..6c0b67ae1 100644 --- a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(NestingClass, True)/MessagePack.GeneratedResolver.g.cs +++ b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(NestingClass, False)/MessagePack.GeneratedMessagePackResolver.g.cs @@ -2,20 +2,21 @@ #pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 -namespace MessagePack.Resolvers +namespace MessagePack { using MsgPack = global::MessagePack; + using Formatters = global::Formatters; /// A MessagePack resolver that uses generated formatters for types in this assembly. - internal class GeneratedResolver : MsgPack::IFormatterResolver + internal class GeneratedMessagePackResolver : MsgPack::IFormatterResolver { /// An instance of this resolver that only returns formatters specifically generated for types in this assembly. - public static readonly MsgPack::IFormatterResolver Instance = new GeneratedResolver(); + public static readonly MsgPack::IFormatterResolver Instance = new GeneratedMessagePackResolver(); /// An instance of this resolver that returns standard AOT-compatible formatters as well as formatters specifically generated for types in this assembly. public static readonly MsgPack::IFormatterResolver InstanceWithStandardAotResolver = MsgPack::Resolvers.CompositeResolver.Create(Instance, MsgPack::Resolvers.StandardAotResolver.Instance); - private GeneratedResolver() + private GeneratedMessagePackResolver() { } @@ -30,7 +31,7 @@ private static class FormatterCache static FormatterCache() { - var f = GeneratedResolverGetFormatterHelper.GetFormatter(typeof(T)); + var f = GeneratedMessagePackResolverGetFormatterHelper.GetFormatter(typeof(T)); if (f != null) { Formatter = (MsgPack::Formatters.IMessagePackFormatter)f; @@ -39,11 +40,11 @@ static FormatterCache() } } - internal static class GeneratedResolverGetFormatterHelper + internal static class GeneratedMessagePackResolverGetFormatterHelper { private static readonly global::System.Collections.Generic.Dictionary lookup; - static GeneratedResolverGetFormatterHelper() + static GeneratedMessagePackResolverGetFormatterHelper() { lookup = new global::System.Collections.Generic.Dictionary(2) { @@ -62,8 +63,8 @@ internal static object GetFormatter(global::System.Type t) switch (key) { - case 0: return new MessagePack.Formatters.ContainingClass_MyEnumFormatter(); - case 1: return new MessagePack.Formatters.ContainingClass_MyMessagePackObjectFormatter(); + case 0: return new Formatters::ContainingClass_MyEnumFormatter(); + case 1: return new Formatters::ContainingClass_MyMessagePackObjectFormatter(); default: return null; } } diff --git a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(NestingClass, True)/MessagePack.Formatter..ContainingClass_MyEnum.g.cs b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(NestingClass, True)/Formatters.ContainingClass_MyEnumFormatter.g.cs similarity index 95% rename from tests/MessagePack.Generator.Tests/Resources/EnumFormatter(NestingClass, True)/MessagePack.Formatter..ContainingClass_MyEnum.g.cs rename to tests/MessagePack.Generator.Tests/Resources/EnumFormatter(NestingClass, True)/Formatters.ContainingClass_MyEnumFormatter.g.cs index 82eb466bd..48de649c6 100644 --- a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(NestingClass, True)/MessagePack.Formatter..ContainingClass_MyEnum.g.cs +++ b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(NestingClass, True)/Formatters.ContainingClass_MyEnumFormatter.g.cs @@ -2,7 +2,7 @@ #pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 -namespace MessagePack.Formatters +namespace Formatters { using MsgPack = global::MessagePack; using ContainingClass_MyEnum = global::ContainingClass.MyEnum; diff --git a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(NestingClass, True)/MessagePack.Formatter.ContainingClass_MyMessagePackObject.g.cs b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(NestingClass, True)/Formatters.ContainingClass_MyMessagePackObjectFormatter.g.cs similarity index 98% rename from tests/MessagePack.Generator.Tests/Resources/EnumFormatter(NestingClass, True)/MessagePack.Formatter.ContainingClass_MyMessagePackObject.g.cs rename to tests/MessagePack.Generator.Tests/Resources/EnumFormatter(NestingClass, True)/Formatters.ContainingClass_MyMessagePackObjectFormatter.g.cs index 8886d57bc..36e122cfa 100644 --- a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(NestingClass, True)/MessagePack.Formatter.ContainingClass_MyMessagePackObject.g.cs +++ b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(NestingClass, True)/Formatters.ContainingClass_MyMessagePackObjectFormatter.g.cs @@ -2,7 +2,7 @@ #pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 -namespace MessagePack.Formatters +namespace Formatters { using MsgPack = global::MessagePack; diff --git a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(NestingClass, False)/MessagePack.GeneratedResolver.g.cs b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(NestingClass, True)/MessagePack.GeneratedMessagePackResolver.g.cs similarity index 75% rename from tests/MessagePack.Generator.Tests/Resources/EnumFormatter(NestingClass, False)/MessagePack.GeneratedResolver.g.cs rename to tests/MessagePack.Generator.Tests/Resources/EnumFormatter(NestingClass, True)/MessagePack.GeneratedMessagePackResolver.g.cs index 1e08f2cdf..6c0b67ae1 100644 --- a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(NestingClass, False)/MessagePack.GeneratedResolver.g.cs +++ b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(NestingClass, True)/MessagePack.GeneratedMessagePackResolver.g.cs @@ -2,20 +2,21 @@ #pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 -namespace MessagePack.Resolvers +namespace MessagePack { using MsgPack = global::MessagePack; + using Formatters = global::Formatters; /// A MessagePack resolver that uses generated formatters for types in this assembly. - internal class GeneratedResolver : MsgPack::IFormatterResolver + internal class GeneratedMessagePackResolver : MsgPack::IFormatterResolver { /// An instance of this resolver that only returns formatters specifically generated for types in this assembly. - public static readonly MsgPack::IFormatterResolver Instance = new GeneratedResolver(); + public static readonly MsgPack::IFormatterResolver Instance = new GeneratedMessagePackResolver(); /// An instance of this resolver that returns standard AOT-compatible formatters as well as formatters specifically generated for types in this assembly. public static readonly MsgPack::IFormatterResolver InstanceWithStandardAotResolver = MsgPack::Resolvers.CompositeResolver.Create(Instance, MsgPack::Resolvers.StandardAotResolver.Instance); - private GeneratedResolver() + private GeneratedMessagePackResolver() { } @@ -30,7 +31,7 @@ private static class FormatterCache static FormatterCache() { - var f = GeneratedResolverGetFormatterHelper.GetFormatter(typeof(T)); + var f = GeneratedMessagePackResolverGetFormatterHelper.GetFormatter(typeof(T)); if (f != null) { Formatter = (MsgPack::Formatters.IMessagePackFormatter)f; @@ -39,11 +40,11 @@ static FormatterCache() } } - internal static class GeneratedResolverGetFormatterHelper + internal static class GeneratedMessagePackResolverGetFormatterHelper { private static readonly global::System.Collections.Generic.Dictionary lookup; - static GeneratedResolverGetFormatterHelper() + static GeneratedMessagePackResolverGetFormatterHelper() { lookup = new global::System.Collections.Generic.Dictionary(2) { @@ -62,8 +63,8 @@ internal static object GetFormatter(global::System.Type t) switch (key) { - case 0: return new MessagePack.Formatters.ContainingClass_MyEnumFormatter(); - case 1: return new MessagePack.Formatters.ContainingClass_MyMessagePackObjectFormatter(); + case 0: return new Formatters::ContainingClass_MyEnumFormatter(); + case 1: return new Formatters::ContainingClass_MyMessagePackObjectFormatter(); default: return null; } } diff --git a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(None, False)/MessagePack.Formatter..MyEnum.g.cs b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(None, False)/Formatters.MyEnumFormatter.g.cs similarity index 94% rename from tests/MessagePack.Generator.Tests/Resources/EnumFormatter(None, False)/MessagePack.Formatter..MyEnum.g.cs rename to tests/MessagePack.Generator.Tests/Resources/EnumFormatter(None, False)/Formatters.MyEnumFormatter.g.cs index f14da8860..622326597 100644 --- a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(None, False)/MessagePack.Formatter..MyEnum.g.cs +++ b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(None, False)/Formatters.MyEnumFormatter.g.cs @@ -2,7 +2,7 @@ #pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 -namespace MessagePack.Formatters +namespace Formatters { using MsgPack = global::MessagePack; using MyEnum = global::MyEnum; diff --git a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(None, False)/MessagePack.Formatter.MyMessagePackObject.g.cs b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(None, False)/Formatters.MyMessagePackObjectFormatter.g.cs similarity index 97% rename from tests/MessagePack.Generator.Tests/Resources/EnumFormatter(None, False)/MessagePack.Formatter.MyMessagePackObject.g.cs rename to tests/MessagePack.Generator.Tests/Resources/EnumFormatter(None, False)/Formatters.MyMessagePackObjectFormatter.g.cs index 3f76060dd..983bb67c4 100644 --- a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(None, False)/MessagePack.Formatter.MyMessagePackObject.g.cs +++ b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(None, False)/Formatters.MyMessagePackObjectFormatter.g.cs @@ -2,7 +2,7 @@ #pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 -namespace MessagePack.Formatters +namespace Formatters { using MsgPack = global::MessagePack; diff --git a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(None, False)/MessagePack.GeneratedResolver.g.cs b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(None, False)/MessagePack.GeneratedMessagePackResolver.g.cs similarity index 76% rename from tests/MessagePack.Generator.Tests/Resources/EnumFormatter(None, False)/MessagePack.GeneratedResolver.g.cs rename to tests/MessagePack.Generator.Tests/Resources/EnumFormatter(None, False)/MessagePack.GeneratedMessagePackResolver.g.cs index 7a4648d67..60d62a493 100644 --- a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(None, False)/MessagePack.GeneratedResolver.g.cs +++ b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(None, False)/MessagePack.GeneratedMessagePackResolver.g.cs @@ -2,20 +2,21 @@ #pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 -namespace MessagePack.Resolvers +namespace MessagePack { using MsgPack = global::MessagePack; + using Formatters = global::Formatters; /// A MessagePack resolver that uses generated formatters for types in this assembly. - internal class GeneratedResolver : MsgPack::IFormatterResolver + internal class GeneratedMessagePackResolver : MsgPack::IFormatterResolver { /// An instance of this resolver that only returns formatters specifically generated for types in this assembly. - public static readonly MsgPack::IFormatterResolver Instance = new GeneratedResolver(); + public static readonly MsgPack::IFormatterResolver Instance = new GeneratedMessagePackResolver(); /// An instance of this resolver that returns standard AOT-compatible formatters as well as formatters specifically generated for types in this assembly. public static readonly MsgPack::IFormatterResolver InstanceWithStandardAotResolver = MsgPack::Resolvers.CompositeResolver.Create(Instance, MsgPack::Resolvers.StandardAotResolver.Instance); - private GeneratedResolver() + private GeneratedMessagePackResolver() { } @@ -30,7 +31,7 @@ private static class FormatterCache static FormatterCache() { - var f = GeneratedResolverGetFormatterHelper.GetFormatter(typeof(T)); + var f = GeneratedMessagePackResolverGetFormatterHelper.GetFormatter(typeof(T)); if (f != null) { Formatter = (MsgPack::Formatters.IMessagePackFormatter)f; @@ -39,11 +40,11 @@ static FormatterCache() } } - internal static class GeneratedResolverGetFormatterHelper + internal static class GeneratedMessagePackResolverGetFormatterHelper { private static readonly global::System.Collections.Generic.Dictionary lookup; - static GeneratedResolverGetFormatterHelper() + static GeneratedMessagePackResolverGetFormatterHelper() { lookup = new global::System.Collections.Generic.Dictionary(2) { @@ -62,8 +63,8 @@ internal static object GetFormatter(global::System.Type t) switch (key) { - case 0: return new MessagePack.Formatters.MyEnumFormatter(); - case 1: return new MessagePack.Formatters.MyMessagePackObjectFormatter(); + case 0: return new Formatters::MyEnumFormatter(); + case 1: return new Formatters::MyMessagePackObjectFormatter(); default: return null; } } diff --git a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(None, True)/MessagePack.Formatter..MyEnum.g.cs b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(None, True)/Formatters.MyEnumFormatter.g.cs similarity index 94% rename from tests/MessagePack.Generator.Tests/Resources/EnumFormatter(None, True)/MessagePack.Formatter..MyEnum.g.cs rename to tests/MessagePack.Generator.Tests/Resources/EnumFormatter(None, True)/Formatters.MyEnumFormatter.g.cs index f14da8860..622326597 100644 --- a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(None, True)/MessagePack.Formatter..MyEnum.g.cs +++ b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(None, True)/Formatters.MyEnumFormatter.g.cs @@ -2,7 +2,7 @@ #pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 -namespace MessagePack.Formatters +namespace Formatters { using MsgPack = global::MessagePack; using MyEnum = global::MyEnum; diff --git a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(None, True)/MessagePack.Formatter.MyMessagePackObject.g.cs b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(None, True)/Formatters.MyMessagePackObjectFormatter.g.cs similarity index 98% rename from tests/MessagePack.Generator.Tests/Resources/EnumFormatter(None, True)/MessagePack.Formatter.MyMessagePackObject.g.cs rename to tests/MessagePack.Generator.Tests/Resources/EnumFormatter(None, True)/Formatters.MyMessagePackObjectFormatter.g.cs index 947b6c53b..ba514d180 100644 --- a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(None, True)/MessagePack.Formatter.MyMessagePackObject.g.cs +++ b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(None, True)/Formatters.MyMessagePackObjectFormatter.g.cs @@ -2,7 +2,7 @@ #pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 -namespace MessagePack.Formatters +namespace Formatters { using MsgPack = global::MessagePack; diff --git a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(None, True)/MessagePack.GeneratedResolver.g.cs b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(None, True)/MessagePack.GeneratedMessagePackResolver.g.cs similarity index 76% rename from tests/MessagePack.Generator.Tests/Resources/EnumFormatter(None, True)/MessagePack.GeneratedResolver.g.cs rename to tests/MessagePack.Generator.Tests/Resources/EnumFormatter(None, True)/MessagePack.GeneratedMessagePackResolver.g.cs index 7a4648d67..60d62a493 100644 --- a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(None, True)/MessagePack.GeneratedResolver.g.cs +++ b/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(None, True)/MessagePack.GeneratedMessagePackResolver.g.cs @@ -2,20 +2,21 @@ #pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 -namespace MessagePack.Resolvers +namespace MessagePack { using MsgPack = global::MessagePack; + using Formatters = global::Formatters; /// A MessagePack resolver that uses generated formatters for types in this assembly. - internal class GeneratedResolver : MsgPack::IFormatterResolver + internal class GeneratedMessagePackResolver : MsgPack::IFormatterResolver { /// An instance of this resolver that only returns formatters specifically generated for types in this assembly. - public static readonly MsgPack::IFormatterResolver Instance = new GeneratedResolver(); + public static readonly MsgPack::IFormatterResolver Instance = new GeneratedMessagePackResolver(); /// An instance of this resolver that returns standard AOT-compatible formatters as well as formatters specifically generated for types in this assembly. public static readonly MsgPack::IFormatterResolver InstanceWithStandardAotResolver = MsgPack::Resolvers.CompositeResolver.Create(Instance, MsgPack::Resolvers.StandardAotResolver.Instance); - private GeneratedResolver() + private GeneratedMessagePackResolver() { } @@ -30,7 +31,7 @@ private static class FormatterCache static FormatterCache() { - var f = GeneratedResolverGetFormatterHelper.GetFormatter(typeof(T)); + var f = GeneratedMessagePackResolverGetFormatterHelper.GetFormatter(typeof(T)); if (f != null) { Formatter = (MsgPack::Formatters.IMessagePackFormatter)f; @@ -39,11 +40,11 @@ static FormatterCache() } } - internal static class GeneratedResolverGetFormatterHelper + internal static class GeneratedMessagePackResolverGetFormatterHelper { private static readonly global::System.Collections.Generic.Dictionary lookup; - static GeneratedResolverGetFormatterHelper() + static GeneratedMessagePackResolverGetFormatterHelper() { lookup = new global::System.Collections.Generic.Dictionary(2) { @@ -62,8 +63,8 @@ internal static object GetFormatter(global::System.Type t) switch (key) { - case 0: return new MessagePack.Formatters.MyEnumFormatter(); - case 1: return new MessagePack.Formatters.MyMessagePackObjectFormatter(); + case 0: return new Formatters::MyEnumFormatter(); + case 1: return new Formatters::MyMessagePackObjectFormatter(); default: return null; } } diff --git a/tests/MessagePack.Generator.Tests/Resources/TwoTypes(False)/MessagePack.Formatter.Object1.g.cs b/tests/MessagePack.Generator.Tests/Resources/TwoTypes(False)/Formatters.Object1Formatter.g.cs similarity index 95% rename from tests/MessagePack.Generator.Tests/Resources/TwoTypes(False)/MessagePack.Formatter.Object1.g.cs rename to tests/MessagePack.Generator.Tests/Resources/TwoTypes(False)/Formatters.Object1Formatter.g.cs index 5e47fabba..385db3fc4 100644 --- a/tests/MessagePack.Generator.Tests/Resources/TwoTypes(False)/MessagePack.Formatter.Object1.g.cs +++ b/tests/MessagePack.Generator.Tests/Resources/TwoTypes(False)/Formatters.Object1Formatter.g.cs @@ -2,7 +2,7 @@ #pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 -namespace MessagePack.Formatters +namespace Formatters { using MsgPack = global::MessagePack; diff --git a/tests/MessagePack.Generator.Tests/Resources/TwoTypes(False)/MessagePack.Formatter.Object2.g.cs b/tests/MessagePack.Generator.Tests/Resources/TwoTypes(False)/Formatters.Object2Formatter.g.cs similarity index 95% rename from tests/MessagePack.Generator.Tests/Resources/TwoTypes(False)/MessagePack.Formatter.Object2.g.cs rename to tests/MessagePack.Generator.Tests/Resources/TwoTypes(False)/Formatters.Object2Formatter.g.cs index 3d6417743..86061d386 100644 --- a/tests/MessagePack.Generator.Tests/Resources/TwoTypes(False)/MessagePack.Formatter.Object2.g.cs +++ b/tests/MessagePack.Generator.Tests/Resources/TwoTypes(False)/Formatters.Object2Formatter.g.cs @@ -2,7 +2,7 @@ #pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 -namespace MessagePack.Formatters +namespace Formatters { using MsgPack = global::MessagePack; diff --git a/tests/MessagePack.Generator.Tests/Resources/TwoTypes(False)/MessagePack.GeneratedResolver.g.cs b/tests/MessagePack.Generator.Tests/Resources/TwoTypes(False)/MessagePack.GeneratedMessagePackResolver.g.cs similarity index 76% rename from tests/MessagePack.Generator.Tests/Resources/TwoTypes(False)/MessagePack.GeneratedResolver.g.cs rename to tests/MessagePack.Generator.Tests/Resources/TwoTypes(False)/MessagePack.GeneratedMessagePackResolver.g.cs index c36139d0b..92150c816 100644 --- a/tests/MessagePack.Generator.Tests/Resources/TwoTypes(False)/MessagePack.GeneratedResolver.g.cs +++ b/tests/MessagePack.Generator.Tests/Resources/TwoTypes(False)/MessagePack.GeneratedMessagePackResolver.g.cs @@ -2,20 +2,21 @@ #pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 -namespace MessagePack.Resolvers +namespace MessagePack { using MsgPack = global::MessagePack; + using Formatters = global::Formatters; /// A MessagePack resolver that uses generated formatters for types in this assembly. - internal class GeneratedResolver : MsgPack::IFormatterResolver + internal class GeneratedMessagePackResolver : MsgPack::IFormatterResolver { /// An instance of this resolver that only returns formatters specifically generated for types in this assembly. - public static readonly MsgPack::IFormatterResolver Instance = new GeneratedResolver(); + public static readonly MsgPack::IFormatterResolver Instance = new GeneratedMessagePackResolver(); /// An instance of this resolver that returns standard AOT-compatible formatters as well as formatters specifically generated for types in this assembly. public static readonly MsgPack::IFormatterResolver InstanceWithStandardAotResolver = MsgPack::Resolvers.CompositeResolver.Create(Instance, MsgPack::Resolvers.StandardAotResolver.Instance); - private GeneratedResolver() + private GeneratedMessagePackResolver() { } @@ -30,7 +31,7 @@ private static class FormatterCache static FormatterCache() { - var f = GeneratedResolverGetFormatterHelper.GetFormatter(typeof(T)); + var f = GeneratedMessagePackResolverGetFormatterHelper.GetFormatter(typeof(T)); if (f != null) { Formatter = (MsgPack::Formatters.IMessagePackFormatter)f; @@ -39,11 +40,11 @@ static FormatterCache() } } - internal static class GeneratedResolverGetFormatterHelper + internal static class GeneratedMessagePackResolverGetFormatterHelper { private static readonly global::System.Collections.Generic.Dictionary lookup; - static GeneratedResolverGetFormatterHelper() + static GeneratedMessagePackResolverGetFormatterHelper() { lookup = new global::System.Collections.Generic.Dictionary(2) { @@ -62,8 +63,8 @@ internal static object GetFormatter(global::System.Type t) switch (key) { - case 0: return new MessagePack.Formatters.Object1Formatter(); - case 1: return new MessagePack.Formatters.Object2Formatter(); + case 0: return new Formatters::Object1Formatter(); + case 1: return new Formatters::Object2Formatter(); default: return null; } } diff --git a/tests/MessagePack.Generator.Tests/Resources/TwoTypes(True)/MessagePack.Formatter.Object1.g.cs b/tests/MessagePack.Generator.Tests/Resources/TwoTypes(True)/Formatters.Object1Formatter.g.cs similarity index 96% rename from tests/MessagePack.Generator.Tests/Resources/TwoTypes(True)/MessagePack.Formatter.Object1.g.cs rename to tests/MessagePack.Generator.Tests/Resources/TwoTypes(True)/Formatters.Object1Formatter.g.cs index 1b4083f1e..2a105b887 100644 --- a/tests/MessagePack.Generator.Tests/Resources/TwoTypes(True)/MessagePack.Formatter.Object1.g.cs +++ b/tests/MessagePack.Generator.Tests/Resources/TwoTypes(True)/Formatters.Object1Formatter.g.cs @@ -2,7 +2,7 @@ #pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 -namespace MessagePack.Formatters +namespace Formatters { using MsgPack = global::MessagePack; diff --git a/tests/MessagePack.Generator.Tests/Resources/TwoTypes(True)/MessagePack.Formatter.Object2.g.cs b/tests/MessagePack.Generator.Tests/Resources/TwoTypes(True)/Formatters.Object2Formatter.g.cs similarity index 96% rename from tests/MessagePack.Generator.Tests/Resources/TwoTypes(True)/MessagePack.Formatter.Object2.g.cs rename to tests/MessagePack.Generator.Tests/Resources/TwoTypes(True)/Formatters.Object2Formatter.g.cs index accf2fc40..09720b027 100644 --- a/tests/MessagePack.Generator.Tests/Resources/TwoTypes(True)/MessagePack.Formatter.Object2.g.cs +++ b/tests/MessagePack.Generator.Tests/Resources/TwoTypes(True)/Formatters.Object2Formatter.g.cs @@ -2,7 +2,7 @@ #pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 -namespace MessagePack.Formatters +namespace Formatters { using MsgPack = global::MessagePack; diff --git a/tests/MessagePack.Generator.Tests/Resources/TwoTypes(True)/MessagePack.GeneratedResolver.g.cs b/tests/MessagePack.Generator.Tests/Resources/TwoTypes(True)/MessagePack.GeneratedMessagePackResolver.g.cs similarity index 76% rename from tests/MessagePack.Generator.Tests/Resources/TwoTypes(True)/MessagePack.GeneratedResolver.g.cs rename to tests/MessagePack.Generator.Tests/Resources/TwoTypes(True)/MessagePack.GeneratedMessagePackResolver.g.cs index c36139d0b..92150c816 100644 --- a/tests/MessagePack.Generator.Tests/Resources/TwoTypes(True)/MessagePack.GeneratedResolver.g.cs +++ b/tests/MessagePack.Generator.Tests/Resources/TwoTypes(True)/MessagePack.GeneratedMessagePackResolver.g.cs @@ -2,20 +2,21 @@ #pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 -namespace MessagePack.Resolvers +namespace MessagePack { using MsgPack = global::MessagePack; + using Formatters = global::Formatters; /// A MessagePack resolver that uses generated formatters for types in this assembly. - internal class GeneratedResolver : MsgPack::IFormatterResolver + internal class GeneratedMessagePackResolver : MsgPack::IFormatterResolver { /// An instance of this resolver that only returns formatters specifically generated for types in this assembly. - public static readonly MsgPack::IFormatterResolver Instance = new GeneratedResolver(); + public static readonly MsgPack::IFormatterResolver Instance = new GeneratedMessagePackResolver(); /// An instance of this resolver that returns standard AOT-compatible formatters as well as formatters specifically generated for types in this assembly. public static readonly MsgPack::IFormatterResolver InstanceWithStandardAotResolver = MsgPack::Resolvers.CompositeResolver.Create(Instance, MsgPack::Resolvers.StandardAotResolver.Instance); - private GeneratedResolver() + private GeneratedMessagePackResolver() { } @@ -30,7 +31,7 @@ private static class FormatterCache static FormatterCache() { - var f = GeneratedResolverGetFormatterHelper.GetFormatter(typeof(T)); + var f = GeneratedMessagePackResolverGetFormatterHelper.GetFormatter(typeof(T)); if (f != null) { Formatter = (MsgPack::Formatters.IMessagePackFormatter)f; @@ -39,11 +40,11 @@ static FormatterCache() } } - internal static class GeneratedResolverGetFormatterHelper + internal static class GeneratedMessagePackResolverGetFormatterHelper { private static readonly global::System.Collections.Generic.Dictionary lookup; - static GeneratedResolverGetFormatterHelper() + static GeneratedMessagePackResolverGetFormatterHelper() { lookup = new global::System.Collections.Generic.Dictionary(2) { @@ -62,8 +63,8 @@ internal static object GetFormatter(global::System.Type t) switch (key) { - case 0: return new MessagePack.Formatters.Object1Formatter(); - case 1: return new MessagePack.Formatters.Object2Formatter(); + case 0: return new Formatters::Object1Formatter(); + case 1: return new Formatters::Object2Formatter(); default: return null; } } diff --git a/tests/MessagePack.Generator.Tests/Verifiers/CSharpSourceGeneratorVerifier`1+Test.cs b/tests/MessagePack.Generator.Tests/Verifiers/CSharpSourceGeneratorVerifier`1+Test.cs index 6a0852499..b53ec1874 100644 --- a/tests/MessagePack.Generator.Tests/Verifiers/CSharpSourceGeneratorVerifier`1+Test.cs +++ b/tests/MessagePack.Generator.Tests/Verifiers/CSharpSourceGeneratorVerifier`1+Test.cs @@ -173,9 +173,11 @@ private static string ConstructGlobalConfigString(AnalyzerOptions options) StringBuilder globalConfigBuilder = new(); globalConfigBuilder.AppendLine("is_global = true"); globalConfigBuilder.AppendLine(); - globalConfigBuilder.AppendLine($"{AnalyzerOptions.MessagePackGeneratedResolverNamespace} = {options.Namespace}"); - globalConfigBuilder.AppendLine($"{AnalyzerOptions.MessagePackGeneratedUsesMapMode} = {options.UsesMapMode}"); + globalConfigBuilder.AppendLine($"{AnalyzerOptions.RootNamespace} = {options.ProjectRootNamespace}"); + globalConfigBuilder.AppendLine($"{AnalyzerOptions.PublicMessagePackGeneratedResolver} = {options.PublicResolver}"); + globalConfigBuilder.AppendLine($"{AnalyzerOptions.MessagePackGeneratedResolverNamespace} = {options.ResolverNamespace}"); globalConfigBuilder.AppendLine($"{AnalyzerOptions.MessagePackGeneratedResolverName} = {options.ResolverName}"); + globalConfigBuilder.AppendLine($"{AnalyzerOptions.MessagePackGeneratedUsesMapMode} = {options.UsesMapMode}"); return globalConfigBuilder.ToString(); } diff --git a/tests/SourceGeneratorConsumer.targets b/tests/SourceGeneratorConsumer.targets new file mode 100644 index 000000000..655ac3cba --- /dev/null +++ b/tests/SourceGeneratorConsumer.targets @@ -0,0 +1,3 @@ + + + From 8526bd2e0f5d0823d94f01a8d17800bbb1bffc9d Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Thu, 30 Mar 2023 12:14:39 -0600 Subject: [PATCH 059/660] Normalize construction of T4 transforms --- .../MessagePackGenerator.Emit.cs | 29 +++++++--------- .../Transforms/TemplatePartials.cs | 34 +++++++++++-------- 2 files changed, 32 insertions(+), 31 deletions(-) diff --git a/src/MessagePack.Generator/MessagePackGenerator.Emit.cs b/src/MessagePack.Generator/MessagePackGenerator.Emit.cs index e9fe5b1d5..36f6b7726 100644 --- a/src/MessagePack.Generator/MessagePackGenerator.Emit.cs +++ b/src/MessagePack.Generator/MessagePackGenerator.Emit.cs @@ -5,7 +5,6 @@ using MessagePack.Generator.CodeAnalysis; using MessagePack.Generator.Transforms; using Microsoft.CodeAnalysis; -using Microsoft.CodeAnalysis.CSharp.Syntax; namespace MessagePack.Generator; @@ -29,22 +28,21 @@ private static void Generate(IGeneratorContext context, FullModel model) foreach (EnumSerializationInfo info in model.EnumInfos) { - EnumTemplate transform = new(CodeAnalysisUtilities.AppendNameToNamespace(options.FormatterNamespace, info.Namespace), info); + EnumTemplate transform = new(options, info); AddTransform(transform.TransformText(), CodeAnalysisUtilities.QualifyWithOptionalNamespace(info.FormatterName, options.FormatterNamespace)); } foreach (UnionSerializationInfo info in model.UnionInfos) { - UnionTemplate transform = new(options.FormatterNamespace, info); + UnionTemplate transform = new(options, info); AddTransform(transform.TransformText(), CodeAnalysisUtilities.QualifyWithOptionalNamespace(info.FormatterName, options.FormatterNamespace)); } foreach (ObjectSerializationInfo info in model.ObjectInfos) { - string formatterNamespace = CodeAnalysisUtilities.AppendNameToNamespace(options.FormatterNamespace, info.Namespace); IFormatterTemplate transform = info.IsStringKey - ? new StringKeyFormatterTemplate(formatterNamespace, info) - : new FormatterTemplate(formatterNamespace, info); + ? new StringKeyFormatterTemplate(options, info) + : new FormatterTemplate(options, info); AddTransform(transform.TransformText(), CodeAnalysisUtilities.QualifyWithOptionalNamespace(info.FormatterName, options.FormatterNamespace)); } @@ -68,17 +66,14 @@ private static void GenerateResolver(IGeneratorContext context, FullModel model) AnalyzerOptions options = model.Options; StringBuilder sb = new(); - ResolverTemplate resolverTemplate = new() - { - Options = options, - RegisterInfos = model.GenericInfos - .Where(x => !x.IsOpenGenericType) - .Cast() - .Concat(model.EnumInfos) - .Concat(model.UnionInfos) - .Concat(model.ObjectInfos.Where(x => !x.IsOpenGenericType)) - .ToArray(), - }; + IResolverRegisterInfo[] registerInfos = model.GenericInfos + .Where(x => !x.IsOpenGenericType) + .Cast() + .Concat(model.EnumInfos) + .Concat(model.UnionInfos) + .Concat(model.ObjectInfos.Where(x => !x.IsOpenGenericType)) + .ToArray(); + ResolverTemplate resolverTemplate = new(options, registerInfos); sb.AppendLine(FileHeader); sb.Append(resolverTemplate.TransformText()); context.AddSource($"{CodeAnalysisUtilities.QualifyWithOptionalNamespace(options.ResolverName, options.ResolverNamespace)}.g.cs", sb.ToString()); diff --git a/src/MessagePack.Generator/Transforms/TemplatePartials.cs b/src/MessagePack.Generator/Transforms/TemplatePartials.cs index 3defdd8a9..cf1a06937 100644 --- a/src/MessagePack.Generator/Transforms/TemplatePartials.cs +++ b/src/MessagePack.Generator/Transforms/TemplatePartials.cs @@ -9,10 +9,10 @@ namespace MessagePack.Generator.Transforms; public partial class FormatterTemplate : IFormatterTemplate { - public FormatterTemplate(string @namespace, ObjectSerializationInfo info) + public FormatterTemplate(AnalyzerOptions options, ObjectSerializationInfo info) { - Namespace = @namespace; - Info = info; + this.Namespace = CodeAnalysisUtilities.AppendNameToNamespace(options.FormatterNamespace, info.Namespace); + this.Info = info; } public string Namespace { get; } @@ -22,10 +22,10 @@ public FormatterTemplate(string @namespace, ObjectSerializationInfo info) public partial class StringKeyFormatterTemplate : IFormatterTemplate { - public StringKeyFormatterTemplate(string @namespace, ObjectSerializationInfo info) + public StringKeyFormatterTemplate(AnalyzerOptions options, ObjectSerializationInfo info) { - Namespace = @namespace; - Info = info; + this.Namespace = CodeAnalysisUtilities.AppendNameToNamespace(options.FormatterNamespace, info.Namespace); + this.Info = info; } public string Namespace { get; } @@ -35,7 +35,13 @@ public StringKeyFormatterTemplate(string @namespace, ObjectSerializationInfo inf public partial class ResolverTemplate { - required public AnalyzerOptions Options { get; init; } + public ResolverTemplate(AnalyzerOptions options, IReadOnlyList registerInfos) + { + this.Options = options; + this.RegisterInfos = registerInfos; + } + + public AnalyzerOptions Options { get; init; } public string ResolverNamespace => this.Options.ResolverNamespace; @@ -45,15 +51,15 @@ public partial class ResolverTemplate public bool PublicResolver => this.Options.PublicResolver; - required public IReadOnlyList RegisterInfos { get; init; } + public IReadOnlyList RegisterInfos { get; } } public partial class EnumTemplate { - public EnumTemplate(string @namespace, EnumSerializationInfo info) + public EnumTemplate(AnalyzerOptions options, EnumSerializationInfo info) { - Namespace = @namespace; - Info = info; + this.Namespace = CodeAnalysisUtilities.AppendNameToNamespace(options.FormatterNamespace, info.Namespace); + this.Info = info; } public string Namespace { get; } @@ -63,10 +69,10 @@ public EnumTemplate(string @namespace, EnumSerializationInfo info) public partial class UnionTemplate { - public UnionTemplate(string @namespace, UnionSerializationInfo info) + public UnionTemplate(AnalyzerOptions options, UnionSerializationInfo info) { - Namespace = @namespace; - Info = info; + this.Namespace = options.FormatterNamespace; + this.Info = info; } public string Namespace { get; } From c176c3728c0c6a775de7275dda252b59bb6ceb15 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Thu, 30 Mar 2023 12:51:57 -0600 Subject: [PATCH 060/660] Test and fix union formatter generation --- .../MessagePackGenerator.Emit.cs | 10 +- .../Transforms/IFormatterTemplate.cs | 2 + .../Transforms/TemplatePartials.cs | 24 ++++- .../ExecutionTests.cs | 51 +++++++++-- ...numFormatterTest.cs => GenerationTests.cs} | 32 ++++++- ...ers.MyTestNamespace.Derived1Formatter.g.cs | 34 +++++++ ...ers.MyTestNamespace.Derived2Formatter.g.cs | 34 +++++++ ...ters.MyTestNamespace.IMyTypeFormatter.g.cs | 91 +++++++++++++++++++ ...amespace.MyMessagePackObjectFormatter.g.cs | 54 +++++++++++ ...sagePack.GeneratedMessagePackResolver.g.cs | 76 ++++++++++++++++ ...ers.ContainingClass_Derived1Formatter.g.cs | 34 +++++++ ...ers.ContainingClass_Derived2Formatter.g.cs | 34 +++++++ ...ingClass_MyMessagePackObjectFormatter.g.cs | 54 +++++++++++ .../Formatters.IMyTypeFormatter.g.cs | 91 +++++++++++++++++++ ...sagePack.GeneratedMessagePackResolver.g.cs | 76 ++++++++++++++++ .../Formatters.Derived1Formatter.g.cs | 34 +++++++ .../Formatters.Derived2Formatter.g.cs | 34 +++++++ .../Formatters.IMyTypeFormatter.g.cs | 91 +++++++++++++++++++ ...rmatters.MyMessagePackObjectFormatter.g.cs | 54 +++++++++++ ...sagePack.GeneratedMessagePackResolver.g.cs | 76 ++++++++++++++++ 20 files changed, 968 insertions(+), 18 deletions(-) rename tests/MessagePack.Generator.Tests/{GenerateEnumFormatterTest.cs => GenerationTests.cs} (54%) create mode 100644 tests/MessagePack.Generator.Tests/Resources/UnionFormatter(Namespace)/Formatters.MyTestNamespace.Derived1Formatter.g.cs create mode 100644 tests/MessagePack.Generator.Tests/Resources/UnionFormatter(Namespace)/Formatters.MyTestNamespace.Derived2Formatter.g.cs create mode 100644 tests/MessagePack.Generator.Tests/Resources/UnionFormatter(Namespace)/Formatters.MyTestNamespace.IMyTypeFormatter.g.cs create mode 100644 tests/MessagePack.Generator.Tests/Resources/UnionFormatter(Namespace)/Formatters.MyTestNamespace.MyMessagePackObjectFormatter.g.cs create mode 100644 tests/MessagePack.Generator.Tests/Resources/UnionFormatter(Namespace)/MessagePack.GeneratedMessagePackResolver.g.cs create mode 100644 tests/MessagePack.Generator.Tests/Resources/UnionFormatter(NestingClass)/Formatters.ContainingClass_Derived1Formatter.g.cs create mode 100644 tests/MessagePack.Generator.Tests/Resources/UnionFormatter(NestingClass)/Formatters.ContainingClass_Derived2Formatter.g.cs create mode 100644 tests/MessagePack.Generator.Tests/Resources/UnionFormatter(NestingClass)/Formatters.ContainingClass_MyMessagePackObjectFormatter.g.cs create mode 100644 tests/MessagePack.Generator.Tests/Resources/UnionFormatter(NestingClass)/Formatters.IMyTypeFormatter.g.cs create mode 100644 tests/MessagePack.Generator.Tests/Resources/UnionFormatter(NestingClass)/MessagePack.GeneratedMessagePackResolver.g.cs create mode 100644 tests/MessagePack.Generator.Tests/Resources/UnionFormatter(None)/Formatters.Derived1Formatter.g.cs create mode 100644 tests/MessagePack.Generator.Tests/Resources/UnionFormatter(None)/Formatters.Derived2Formatter.g.cs create mode 100644 tests/MessagePack.Generator.Tests/Resources/UnionFormatter(None)/Formatters.IMyTypeFormatter.g.cs create mode 100644 tests/MessagePack.Generator.Tests/Resources/UnionFormatter(None)/Formatters.MyMessagePackObjectFormatter.g.cs create mode 100644 tests/MessagePack.Generator.Tests/Resources/UnionFormatter(None)/MessagePack.GeneratedMessagePackResolver.g.cs diff --git a/src/MessagePack.Generator/MessagePackGenerator.Emit.cs b/src/MessagePack.Generator/MessagePackGenerator.Emit.cs index 36f6b7726..280f0c1fc 100644 --- a/src/MessagePack.Generator/MessagePackGenerator.Emit.cs +++ b/src/MessagePack.Generator/MessagePackGenerator.Emit.cs @@ -29,13 +29,13 @@ private static void Generate(IGeneratorContext context, FullModel model) foreach (EnumSerializationInfo info in model.EnumInfos) { EnumTemplate transform = new(options, info); - AddTransform(transform.TransformText(), CodeAnalysisUtilities.QualifyWithOptionalNamespace(info.FormatterName, options.FormatterNamespace)); + AddTransform(transform.TransformText(), transform.FileName); } foreach (UnionSerializationInfo info in model.UnionInfos) { UnionTemplate transform = new(options, info); - AddTransform(transform.TransformText(), CodeAnalysisUtilities.QualifyWithOptionalNamespace(info.FormatterName, options.FormatterNamespace)); + AddTransform(transform.TransformText(), transform.FileName); } foreach (ObjectSerializationInfo info in model.ObjectInfos) @@ -43,7 +43,7 @@ private static void Generate(IGeneratorContext context, FullModel model) IFormatterTemplate transform = info.IsStringKey ? new StringKeyFormatterTemplate(options, info) : new FormatterTemplate(options, info); - AddTransform(transform.TransformText(), CodeAnalysisUtilities.QualifyWithOptionalNamespace(info.FormatterName, options.FormatterNamespace)); + AddTransform(transform.TransformText(), transform.FileName); } void AddTransform(string transformOutput, string uniqueFileName) @@ -51,7 +51,7 @@ void AddTransform(string transformOutput, string uniqueFileName) sb.Clear(); sb.AppendLine(FileHeader); sb.Append(transformOutput); - context.AddSource($"{uniqueFileName}.g.cs", sb.ToString()); + context.AddSource(uniqueFileName, sb.ToString()); sb.Clear(); } } @@ -76,6 +76,6 @@ private static void GenerateResolver(IGeneratorContext context, FullModel model) ResolverTemplate resolverTemplate = new(options, registerInfos); sb.AppendLine(FileHeader); sb.Append(resolverTemplate.TransformText()); - context.AddSource($"{CodeAnalysisUtilities.QualifyWithOptionalNamespace(options.ResolverName, options.ResolverNamespace)}.g.cs", sb.ToString()); + context.AddSource(resolverTemplate.FileName, sb.ToString()); } } diff --git a/src/MessagePack.Generator/Transforms/IFormatterTemplate.cs b/src/MessagePack.Generator/Transforms/IFormatterTemplate.cs index 71a3f3952..e1fd2a67f 100644 --- a/src/MessagePack.Generator/Transforms/IFormatterTemplate.cs +++ b/src/MessagePack.Generator/Transforms/IFormatterTemplate.cs @@ -7,6 +7,8 @@ namespace MessagePack.Generator.Transforms; public interface IFormatterTemplate { + string FileName { get; } + string Namespace { get; } ObjectSerializationInfo Info { get; } diff --git a/src/MessagePack.Generator/Transforms/TemplatePartials.cs b/src/MessagePack.Generator/Transforms/TemplatePartials.cs index cf1a06937..994132fb7 100644 --- a/src/MessagePack.Generator/Transforms/TemplatePartials.cs +++ b/src/MessagePack.Generator/Transforms/TemplatePartials.cs @@ -12,12 +12,17 @@ public partial class FormatterTemplate : IFormatterTemplate public FormatterTemplate(AnalyzerOptions options, ObjectSerializationInfo info) { this.Namespace = CodeAnalysisUtilities.AppendNameToNamespace(options.FormatterNamespace, info.Namespace); + this.Options = options; this.Info = info; } public string Namespace { get; } + public AnalyzerOptions Options { get; } + public ObjectSerializationInfo Info { get; } + + public string FileName => $"{CodeAnalysisUtilities.QualifyWithOptionalNamespace(this.Info.FormatterName, this.Options.FormatterNamespace)}.g.cs"; } public partial class StringKeyFormatterTemplate : IFormatterTemplate @@ -25,12 +30,17 @@ public partial class StringKeyFormatterTemplate : IFormatterTemplate public StringKeyFormatterTemplate(AnalyzerOptions options, ObjectSerializationInfo info) { this.Namespace = CodeAnalysisUtilities.AppendNameToNamespace(options.FormatterNamespace, info.Namespace); + this.Options = options; this.Info = info; } public string Namespace { get; } + public AnalyzerOptions Options { get; } + public ObjectSerializationInfo Info { get; } + + public string FileName => $"{CodeAnalysisUtilities.QualifyWithOptionalNamespace(this.Info.FormatterName, this.Options.FormatterNamespace)}.g.cs"; } public partial class ResolverTemplate @@ -52,6 +62,8 @@ public ResolverTemplate(AnalyzerOptions options, IReadOnlyList this.Options.PublicResolver; public IReadOnlyList RegisterInfos { get; } + + public string FileName => $"{CodeAnalysisUtilities.QualifyWithOptionalNamespace(this.Options.ResolverName, this.Options.ResolverNamespace)}.g.cs"; } public partial class EnumTemplate @@ -59,23 +71,33 @@ public partial class EnumTemplate public EnumTemplate(AnalyzerOptions options, EnumSerializationInfo info) { this.Namespace = CodeAnalysisUtilities.AppendNameToNamespace(options.FormatterNamespace, info.Namespace); + this.Options = options; this.Info = info; } public string Namespace { get; } + public AnalyzerOptions Options { get; } + public EnumSerializationInfo Info { get; } + + public string FileName => $"{CodeAnalysisUtilities.QualifyWithOptionalNamespace(this.Info.FormatterName, this.Options.FormatterNamespace)}.g.cs"; } public partial class UnionTemplate { public UnionTemplate(AnalyzerOptions options, UnionSerializationInfo info) { - this.Namespace = options.FormatterNamespace; + this.Namespace = CodeAnalysisUtilities.AppendNameToNamespace(options.FormatterNamespace, info.Namespace); + this.Options = options; this.Info = info; } public string Namespace { get; } + public AnalyzerOptions Options { get; } + public UnionSerializationInfo Info { get; } + + public string FileName => $"{CodeAnalysisUtilities.QualifyWithOptionalNamespace(this.Info.FormatterName, this.Options.FormatterNamespace)}.g.cs"; } diff --git a/tests/MessagePack.Generator.ExecutionTests/ExecutionTests.cs b/tests/MessagePack.Generator.ExecutionTests/ExecutionTests.cs index 0698a970f..a48dbd63a 100644 --- a/tests/MessagePack.Generator.ExecutionTests/ExecutionTests.cs +++ b/tests/MessagePack.Generator.ExecutionTests/ExecutionTests.cs @@ -31,6 +31,14 @@ public void ClassWithPropertiesWithGetterAndCtor() this.AssertRoundtrip(new HasPropertiesWithGetterAndCtor(1, "four")); } + [Fact] + public void ClassWithUnionProperty() + { + this.AssertRoundtrip(new UnionContainer { Value = null }); + this.AssertRoundtrip(new UnionContainer { Value = new Derived1() }); + this.AssertRoundtrip(new UnionContainer { Value = new Derived2() }); + } + private T AssertRoundtrip(T value) { byte[] serialized = MessagePackSerializer.Serialize(value, SerializerOptions); @@ -41,39 +49,62 @@ private T AssertRoundtrip(T value) } [MessagePackObject] - public record MyMessagePackObject + internal record MyMessagePackObject { [Key(0)] - public MyEnum EnumValue { get; set; } + internal MyEnum EnumValue { get; set; } } [MessagePackObject(false)] - public record HasPropertiesWithGetterAndSetter + internal record HasPropertiesWithGetterAndSetter { [Key(0)] - public int A { get; set; } + internal int A { get; set; } [Key(1)] - public int? B { get; set; } + internal int? B { get; set; } } [MessagePackObject(false)] - public record HasPropertiesWithGetterAndCtor + internal record HasPropertiesWithGetterAndCtor { [Key(0)] - public int A { get; } + internal int A { get; } [Key(1)] - public string? B { get; } + internal string? B { get; } - public HasPropertiesWithGetterAndCtor(int a, string? b) + internal HasPropertiesWithGetterAndCtor(int a, string? b) { A = a; B = b; } } - public enum MyEnum + [Union(0, typeof(Derived1))] + [Union(1, typeof(Derived2))] + internal interface IMyType + { + } + + [MessagePackObject] + internal record Derived1 : IMyType + { + } + + [MessagePackObject] + internal record Derived2 : IMyType + { + } + + [MessagePackObject] + internal record UnionContainer + { + [Key(0)] + internal IMyType? Value { get; set; } + } + + internal enum MyEnum { A, B, diff --git a/tests/MessagePack.Generator.Tests/GenerateEnumFormatterTest.cs b/tests/MessagePack.Generator.Tests/GenerationTests.cs similarity index 54% rename from tests/MessagePack.Generator.Tests/GenerateEnumFormatterTest.cs rename to tests/MessagePack.Generator.Tests/GenerationTests.cs index 7a49c5917..632f9cacf 100644 --- a/tests/MessagePack.Generator.Tests/GenerateEnumFormatterTest.cs +++ b/tests/MessagePack.Generator.Tests/GenerationTests.cs @@ -3,11 +3,11 @@ using MessagePack.Generator.Tests; -public class GenerateEnumFormatterTest +public class GenerationTests { private readonly ITestOutputHelper testOutputHelper; - public GenerateEnumFormatterTest(ITestOutputHelper testOutputHelper) + public GenerationTests(ITestOutputHelper testOutputHelper) { this.testOutputHelper = testOutputHelper; } @@ -32,4 +32,32 @@ internal enum MyEnum await VerifyCS.Test.RunDefaultAsync(testSource, options: AnalyzerOptions.Default with { UsesMapMode = usesMapMode }, testMethod: $"{nameof(EnumFormatter)}({container}, {usesMapMode})"); } + + [Theory, PairwiseData] + public async Task UnionFormatter(ContainerKind container) + { + string testSource = """ +[Union(0, typeof(Derived1))] +[Union(1, typeof(Derived2))] +internal interface IMyType +{ +} + +[MessagePackObject] +internal class Derived1 : IMyType {} + +[MessagePackObject] +internal class Derived2 : IMyType {} + +[MessagePackObject] +internal class MyMessagePackObject +{ + [Key(0)] + internal IMyType UnionValue { get; set; } +} +"""; + testSource = TestUtilities.WrapTestSource(testSource, container); + + await VerifyCS.Test.RunDefaultAsync(testSource, testMethod: $"{nameof(UnionFormatter)}({container})"); + } } diff --git a/tests/MessagePack.Generator.Tests/Resources/UnionFormatter(Namespace)/Formatters.MyTestNamespace.Derived1Formatter.g.cs b/tests/MessagePack.Generator.Tests/Resources/UnionFormatter(Namespace)/Formatters.MyTestNamespace.Derived1Formatter.g.cs new file mode 100644 index 000000000..9f6ec3997 --- /dev/null +++ b/tests/MessagePack.Generator.Tests/Resources/UnionFormatter(Namespace)/Formatters.MyTestNamespace.Derived1Formatter.g.cs @@ -0,0 +1,34 @@ +// + +#pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 + +namespace Formatters.MyTestNamespace +{ + using MsgPack = global::MessagePack; + + internal sealed class Derived1Formatter : MsgPack::Formatters.IMessagePackFormatter + { + + public void Serialize(ref MsgPack::MessagePackWriter writer, global::MyTestNamespace.Derived1 value, MsgPack::MessagePackSerializerOptions options) + { + if (value == null) + { + writer.WriteNil(); + return; + } + + writer.WriteArrayHeader(0); + } + + public global::MyTestNamespace.Derived1 Deserialize(ref MsgPack::MessagePackReader reader, MsgPack::MessagePackSerializerOptions options) + { + if (reader.TryReadNil()) + { + return null; + } + + reader.Skip(); + return new global::MyTestNamespace.Derived1(); + } + } +} diff --git a/tests/MessagePack.Generator.Tests/Resources/UnionFormatter(Namespace)/Formatters.MyTestNamespace.Derived2Formatter.g.cs b/tests/MessagePack.Generator.Tests/Resources/UnionFormatter(Namespace)/Formatters.MyTestNamespace.Derived2Formatter.g.cs new file mode 100644 index 000000000..d352bddaa --- /dev/null +++ b/tests/MessagePack.Generator.Tests/Resources/UnionFormatter(Namespace)/Formatters.MyTestNamespace.Derived2Formatter.g.cs @@ -0,0 +1,34 @@ +// + +#pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 + +namespace Formatters.MyTestNamespace +{ + using MsgPack = global::MessagePack; + + internal sealed class Derived2Formatter : MsgPack::Formatters.IMessagePackFormatter + { + + public void Serialize(ref MsgPack::MessagePackWriter writer, global::MyTestNamespace.Derived2 value, MsgPack::MessagePackSerializerOptions options) + { + if (value == null) + { + writer.WriteNil(); + return; + } + + writer.WriteArrayHeader(0); + } + + public global::MyTestNamespace.Derived2 Deserialize(ref MsgPack::MessagePackReader reader, MsgPack::MessagePackSerializerOptions options) + { + if (reader.TryReadNil()) + { + return null; + } + + reader.Skip(); + return new global::MyTestNamespace.Derived2(); + } + } +} diff --git a/tests/MessagePack.Generator.Tests/Resources/UnionFormatter(Namespace)/Formatters.MyTestNamespace.IMyTypeFormatter.g.cs b/tests/MessagePack.Generator.Tests/Resources/UnionFormatter(Namespace)/Formatters.MyTestNamespace.IMyTypeFormatter.g.cs new file mode 100644 index 000000000..447f71c93 --- /dev/null +++ b/tests/MessagePack.Generator.Tests/Resources/UnionFormatter(Namespace)/Formatters.MyTestNamespace.IMyTypeFormatter.g.cs @@ -0,0 +1,91 @@ +// + +#pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 + +namespace Formatters.MyTestNamespace +{ + using MsgPack = global::MessagePack; + + internal sealed class IMyTypeFormatter : MsgPack::Formatters.IMessagePackFormatter + { + private readonly global::System.Collections.Generic.Dictionary> typeToKeyAndJumpMap; + private readonly global::System.Collections.Generic.Dictionary keyToJumpMap; + + public IMyTypeFormatter() + { + this.typeToKeyAndJumpMap = new global::System.Collections.Generic.Dictionary>(2, MsgPack::Internal.RuntimeTypeHandleEqualityComparer.Default) + { + { typeof(global::MyTestNamespace.Derived1).TypeHandle, new global::System.Collections.Generic.KeyValuePair(0, 0) }, + { typeof(global::MyTestNamespace.Derived2).TypeHandle, new global::System.Collections.Generic.KeyValuePair(1, 1) }, + }; + this.keyToJumpMap = new global::System.Collections.Generic.Dictionary(2) + { + { 0, 0 }, + { 1, 1 }, + }; + } + + public void Serialize(ref MsgPack::MessagePackWriter writer, global::MyTestNamespace.IMyType value, MsgPack::MessagePackSerializerOptions options) + { + global::System.Collections.Generic.KeyValuePair keyValuePair; + if (value != null && this.typeToKeyAndJumpMap.TryGetValue(value.GetType().TypeHandle, out keyValuePair)) + { + writer.WriteArrayHeader(2); + writer.WriteInt32(keyValuePair.Key); + switch (keyValuePair.Value) + { + case 0: + MsgPack::FormatterResolverExtensions.GetFormatterWithVerify(options.Resolver).Serialize(ref writer, (global::MyTestNamespace.Derived1)value, options); + break; + case 1: + MsgPack::FormatterResolverExtensions.GetFormatterWithVerify(options.Resolver).Serialize(ref writer, (global::MyTestNamespace.Derived2)value, options); + break; + default: + break; + } + + return; + } + + writer.WriteNil(); + } + + public global::MyTestNamespace.IMyType Deserialize(ref MsgPack::MessagePackReader reader, MsgPack::MessagePackSerializerOptions options) + { + if (reader.TryReadNil()) + { + return null; + } + + if (reader.ReadArrayHeader() != 2) + { + throw new global::System.InvalidOperationException("Invalid Union data was detected. Type:global::MyTestNamespace.IMyType"); + } + + options.Security.DepthStep(ref reader); + var key = reader.ReadInt32(); + + if (!this.keyToJumpMap.TryGetValue(key, out key)) + { + key = -1; + } + + global::MyTestNamespace.IMyType result = null; + switch (key) + { + case 0: + result = (global::MyTestNamespace.IMyType)MsgPack::FormatterResolverExtensions.GetFormatterWithVerify(options.Resolver).Deserialize(ref reader, options); + break; + case 1: + result = (global::MyTestNamespace.IMyType)MsgPack::FormatterResolverExtensions.GetFormatterWithVerify(options.Resolver).Deserialize(ref reader, options); + break; + default: + reader.Skip(); + break; + } + + reader.Depth--; + return result; + } + } +} diff --git a/tests/MessagePack.Generator.Tests/Resources/UnionFormatter(Namespace)/Formatters.MyTestNamespace.MyMessagePackObjectFormatter.g.cs b/tests/MessagePack.Generator.Tests/Resources/UnionFormatter(Namespace)/Formatters.MyTestNamespace.MyMessagePackObjectFormatter.g.cs new file mode 100644 index 000000000..2599523bf --- /dev/null +++ b/tests/MessagePack.Generator.Tests/Resources/UnionFormatter(Namespace)/Formatters.MyTestNamespace.MyMessagePackObjectFormatter.g.cs @@ -0,0 +1,54 @@ +// + +#pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 + +namespace Formatters.MyTestNamespace +{ + using MsgPack = global::MessagePack; + + internal sealed class MyMessagePackObjectFormatter : MsgPack::Formatters.IMessagePackFormatter + { + + public void Serialize(ref MsgPack::MessagePackWriter writer, global::MyTestNamespace.MyMessagePackObject value, MsgPack::MessagePackSerializerOptions options) + { + if (value == null) + { + writer.WriteNil(); + return; + } + + MsgPack::IFormatterResolver formatterResolver = options.Resolver; + writer.WriteArrayHeader(1); + MsgPack::FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Serialize(ref writer, value.UnionValue, options); + } + + public global::MyTestNamespace.MyMessagePackObject Deserialize(ref MsgPack::MessagePackReader reader, MsgPack::MessagePackSerializerOptions options) + { + if (reader.TryReadNil()) + { + return null; + } + + options.Security.DepthStep(ref reader); + MsgPack::IFormatterResolver formatterResolver = options.Resolver; + var length = reader.ReadArrayHeader(); + var ____result = new global::MyTestNamespace.MyMessagePackObject(); + + for (int i = 0; i < length; i++) + { + switch (i) + { + case 0: + ____result.UnionValue = MsgPack::FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Deserialize(ref reader, options); + break; + default: + reader.Skip(); + break; + } + } + + reader.Depth--; + return ____result; + } + } +} diff --git a/tests/MessagePack.Generator.Tests/Resources/UnionFormatter(Namespace)/MessagePack.GeneratedMessagePackResolver.g.cs b/tests/MessagePack.Generator.Tests/Resources/UnionFormatter(Namespace)/MessagePack.GeneratedMessagePackResolver.g.cs new file mode 100644 index 000000000..3fc43d0fd --- /dev/null +++ b/tests/MessagePack.Generator.Tests/Resources/UnionFormatter(Namespace)/MessagePack.GeneratedMessagePackResolver.g.cs @@ -0,0 +1,76 @@ +// + +#pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 + +namespace MessagePack +{ + using MsgPack = global::MessagePack; + using Formatters = global::Formatters; + + /// A MessagePack resolver that uses generated formatters for types in this assembly. + internal class GeneratedMessagePackResolver : MsgPack::IFormatterResolver + { + /// An instance of this resolver that only returns formatters specifically generated for types in this assembly. + public static readonly MsgPack::IFormatterResolver Instance = new GeneratedMessagePackResolver(); + + /// An instance of this resolver that returns standard AOT-compatible formatters as well as formatters specifically generated for types in this assembly. + public static readonly MsgPack::IFormatterResolver InstanceWithStandardAotResolver = MsgPack::Resolvers.CompositeResolver.Create(Instance, MsgPack::Resolvers.StandardAotResolver.Instance); + + private GeneratedMessagePackResolver() + { + } + + public MsgPack::Formatters.IMessagePackFormatter GetFormatter() + { + return FormatterCache.Formatter; + } + + private static class FormatterCache + { + internal static readonly MsgPack::Formatters.IMessagePackFormatter Formatter; + + static FormatterCache() + { + var f = GeneratedMessagePackResolverGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + Formatter = (MsgPack::Formatters.IMessagePackFormatter)f; + } + } + } + } + + internal static class GeneratedMessagePackResolverGetFormatterHelper + { + private static readonly global::System.Collections.Generic.Dictionary lookup; + + static GeneratedMessagePackResolverGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(4) + { + { typeof(global::MyTestNamespace.IMyType), 0 }, + { typeof(global::MyTestNamespace.Derived1), 1 }, + { typeof(global::MyTestNamespace.Derived2), 2 }, + { typeof(global::MyTestNamespace.MyMessagePackObject), 3 }, + }; + } + + internal static object GetFormatter(global::System.Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + case 0: return new Formatters::MyTestNamespace.IMyTypeFormatter(); + case 1: return new Formatters::MyTestNamespace.Derived1Formatter(); + case 2: return new Formatters::MyTestNamespace.Derived2Formatter(); + case 3: return new Formatters::MyTestNamespace.MyMessagePackObjectFormatter(); + default: return null; + } + } + } +} diff --git a/tests/MessagePack.Generator.Tests/Resources/UnionFormatter(NestingClass)/Formatters.ContainingClass_Derived1Formatter.g.cs b/tests/MessagePack.Generator.Tests/Resources/UnionFormatter(NestingClass)/Formatters.ContainingClass_Derived1Formatter.g.cs new file mode 100644 index 000000000..ea3ee42d9 --- /dev/null +++ b/tests/MessagePack.Generator.Tests/Resources/UnionFormatter(NestingClass)/Formatters.ContainingClass_Derived1Formatter.g.cs @@ -0,0 +1,34 @@ +// + +#pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 + +namespace Formatters +{ + using MsgPack = global::MessagePack; + + internal sealed class ContainingClass_Derived1Formatter : MsgPack::Formatters.IMessagePackFormatter + { + + public void Serialize(ref MsgPack::MessagePackWriter writer, global::ContainingClass.Derived1 value, MsgPack::MessagePackSerializerOptions options) + { + if (value == null) + { + writer.WriteNil(); + return; + } + + writer.WriteArrayHeader(0); + } + + public global::ContainingClass.Derived1 Deserialize(ref MsgPack::MessagePackReader reader, MsgPack::MessagePackSerializerOptions options) + { + if (reader.TryReadNil()) + { + return null; + } + + reader.Skip(); + return new global::ContainingClass.Derived1(); + } + } +} diff --git a/tests/MessagePack.Generator.Tests/Resources/UnionFormatter(NestingClass)/Formatters.ContainingClass_Derived2Formatter.g.cs b/tests/MessagePack.Generator.Tests/Resources/UnionFormatter(NestingClass)/Formatters.ContainingClass_Derived2Formatter.g.cs new file mode 100644 index 000000000..155680fea --- /dev/null +++ b/tests/MessagePack.Generator.Tests/Resources/UnionFormatter(NestingClass)/Formatters.ContainingClass_Derived2Formatter.g.cs @@ -0,0 +1,34 @@ +// + +#pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 + +namespace Formatters +{ + using MsgPack = global::MessagePack; + + internal sealed class ContainingClass_Derived2Formatter : MsgPack::Formatters.IMessagePackFormatter + { + + public void Serialize(ref MsgPack::MessagePackWriter writer, global::ContainingClass.Derived2 value, MsgPack::MessagePackSerializerOptions options) + { + if (value == null) + { + writer.WriteNil(); + return; + } + + writer.WriteArrayHeader(0); + } + + public global::ContainingClass.Derived2 Deserialize(ref MsgPack::MessagePackReader reader, MsgPack::MessagePackSerializerOptions options) + { + if (reader.TryReadNil()) + { + return null; + } + + reader.Skip(); + return new global::ContainingClass.Derived2(); + } + } +} diff --git a/tests/MessagePack.Generator.Tests/Resources/UnionFormatter(NestingClass)/Formatters.ContainingClass_MyMessagePackObjectFormatter.g.cs b/tests/MessagePack.Generator.Tests/Resources/UnionFormatter(NestingClass)/Formatters.ContainingClass_MyMessagePackObjectFormatter.g.cs new file mode 100644 index 000000000..86965a9cf --- /dev/null +++ b/tests/MessagePack.Generator.Tests/Resources/UnionFormatter(NestingClass)/Formatters.ContainingClass_MyMessagePackObjectFormatter.g.cs @@ -0,0 +1,54 @@ +// + +#pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 + +namespace Formatters +{ + using MsgPack = global::MessagePack; + + internal sealed class ContainingClass_MyMessagePackObjectFormatter : MsgPack::Formatters.IMessagePackFormatter + { + + public void Serialize(ref MsgPack::MessagePackWriter writer, global::ContainingClass.MyMessagePackObject value, MsgPack::MessagePackSerializerOptions options) + { + if (value == null) + { + writer.WriteNil(); + return; + } + + MsgPack::IFormatterResolver formatterResolver = options.Resolver; + writer.WriteArrayHeader(1); + MsgPack::FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Serialize(ref writer, value.UnionValue, options); + } + + public global::ContainingClass.MyMessagePackObject Deserialize(ref MsgPack::MessagePackReader reader, MsgPack::MessagePackSerializerOptions options) + { + if (reader.TryReadNil()) + { + return null; + } + + options.Security.DepthStep(ref reader); + MsgPack::IFormatterResolver formatterResolver = options.Resolver; + var length = reader.ReadArrayHeader(); + var ____result = new global::ContainingClass.MyMessagePackObject(); + + for (int i = 0; i < length; i++) + { + switch (i) + { + case 0: + ____result.UnionValue = MsgPack::FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Deserialize(ref reader, options); + break; + default: + reader.Skip(); + break; + } + } + + reader.Depth--; + return ____result; + } + } +} diff --git a/tests/MessagePack.Generator.Tests/Resources/UnionFormatter(NestingClass)/Formatters.IMyTypeFormatter.g.cs b/tests/MessagePack.Generator.Tests/Resources/UnionFormatter(NestingClass)/Formatters.IMyTypeFormatter.g.cs new file mode 100644 index 000000000..c49d7d80e --- /dev/null +++ b/tests/MessagePack.Generator.Tests/Resources/UnionFormatter(NestingClass)/Formatters.IMyTypeFormatter.g.cs @@ -0,0 +1,91 @@ +// + +#pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 + +namespace Formatters +{ + using MsgPack = global::MessagePack; + + internal sealed class IMyTypeFormatter : MsgPack::Formatters.IMessagePackFormatter + { + private readonly global::System.Collections.Generic.Dictionary> typeToKeyAndJumpMap; + private readonly global::System.Collections.Generic.Dictionary keyToJumpMap; + + public IMyTypeFormatter() + { + this.typeToKeyAndJumpMap = new global::System.Collections.Generic.Dictionary>(2, MsgPack::Internal.RuntimeTypeHandleEqualityComparer.Default) + { + { typeof(global::ContainingClass.Derived1).TypeHandle, new global::System.Collections.Generic.KeyValuePair(0, 0) }, + { typeof(global::ContainingClass.Derived2).TypeHandle, new global::System.Collections.Generic.KeyValuePair(1, 1) }, + }; + this.keyToJumpMap = new global::System.Collections.Generic.Dictionary(2) + { + { 0, 0 }, + { 1, 1 }, + }; + } + + public void Serialize(ref MsgPack::MessagePackWriter writer, global::ContainingClass.IMyType value, MsgPack::MessagePackSerializerOptions options) + { + global::System.Collections.Generic.KeyValuePair keyValuePair; + if (value != null && this.typeToKeyAndJumpMap.TryGetValue(value.GetType().TypeHandle, out keyValuePair)) + { + writer.WriteArrayHeader(2); + writer.WriteInt32(keyValuePair.Key); + switch (keyValuePair.Value) + { + case 0: + MsgPack::FormatterResolverExtensions.GetFormatterWithVerify(options.Resolver).Serialize(ref writer, (global::ContainingClass.Derived1)value, options); + break; + case 1: + MsgPack::FormatterResolverExtensions.GetFormatterWithVerify(options.Resolver).Serialize(ref writer, (global::ContainingClass.Derived2)value, options); + break; + default: + break; + } + + return; + } + + writer.WriteNil(); + } + + public global::ContainingClass.IMyType Deserialize(ref MsgPack::MessagePackReader reader, MsgPack::MessagePackSerializerOptions options) + { + if (reader.TryReadNil()) + { + return null; + } + + if (reader.ReadArrayHeader() != 2) + { + throw new global::System.InvalidOperationException("Invalid Union data was detected. Type:global::ContainingClass.IMyType"); + } + + options.Security.DepthStep(ref reader); + var key = reader.ReadInt32(); + + if (!this.keyToJumpMap.TryGetValue(key, out key)) + { + key = -1; + } + + global::ContainingClass.IMyType result = null; + switch (key) + { + case 0: + result = (global::ContainingClass.IMyType)MsgPack::FormatterResolverExtensions.GetFormatterWithVerify(options.Resolver).Deserialize(ref reader, options); + break; + case 1: + result = (global::ContainingClass.IMyType)MsgPack::FormatterResolverExtensions.GetFormatterWithVerify(options.Resolver).Deserialize(ref reader, options); + break; + default: + reader.Skip(); + break; + } + + reader.Depth--; + return result; + } + } +} diff --git a/tests/MessagePack.Generator.Tests/Resources/UnionFormatter(NestingClass)/MessagePack.GeneratedMessagePackResolver.g.cs b/tests/MessagePack.Generator.Tests/Resources/UnionFormatter(NestingClass)/MessagePack.GeneratedMessagePackResolver.g.cs new file mode 100644 index 000000000..3df34767e --- /dev/null +++ b/tests/MessagePack.Generator.Tests/Resources/UnionFormatter(NestingClass)/MessagePack.GeneratedMessagePackResolver.g.cs @@ -0,0 +1,76 @@ +// + +#pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 + +namespace MessagePack +{ + using MsgPack = global::MessagePack; + using Formatters = global::Formatters; + + /// A MessagePack resolver that uses generated formatters for types in this assembly. + internal class GeneratedMessagePackResolver : MsgPack::IFormatterResolver + { + /// An instance of this resolver that only returns formatters specifically generated for types in this assembly. + public static readonly MsgPack::IFormatterResolver Instance = new GeneratedMessagePackResolver(); + + /// An instance of this resolver that returns standard AOT-compatible formatters as well as formatters specifically generated for types in this assembly. + public static readonly MsgPack::IFormatterResolver InstanceWithStandardAotResolver = MsgPack::Resolvers.CompositeResolver.Create(Instance, MsgPack::Resolvers.StandardAotResolver.Instance); + + private GeneratedMessagePackResolver() + { + } + + public MsgPack::Formatters.IMessagePackFormatter GetFormatter() + { + return FormatterCache.Formatter; + } + + private static class FormatterCache + { + internal static readonly MsgPack::Formatters.IMessagePackFormatter Formatter; + + static FormatterCache() + { + var f = GeneratedMessagePackResolverGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + Formatter = (MsgPack::Formatters.IMessagePackFormatter)f; + } + } + } + } + + internal static class GeneratedMessagePackResolverGetFormatterHelper + { + private static readonly global::System.Collections.Generic.Dictionary lookup; + + static GeneratedMessagePackResolverGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(4) + { + { typeof(global::ContainingClass.IMyType), 0 }, + { typeof(global::ContainingClass.Derived1), 1 }, + { typeof(global::ContainingClass.Derived2), 2 }, + { typeof(global::ContainingClass.MyMessagePackObject), 3 }, + }; + } + + internal static object GetFormatter(global::System.Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + case 0: return new Formatters::IMyTypeFormatter(); + case 1: return new Formatters::ContainingClass_Derived1Formatter(); + case 2: return new Formatters::ContainingClass_Derived2Formatter(); + case 3: return new Formatters::ContainingClass_MyMessagePackObjectFormatter(); + default: return null; + } + } + } +} diff --git a/tests/MessagePack.Generator.Tests/Resources/UnionFormatter(None)/Formatters.Derived1Formatter.g.cs b/tests/MessagePack.Generator.Tests/Resources/UnionFormatter(None)/Formatters.Derived1Formatter.g.cs new file mode 100644 index 000000000..081056c25 --- /dev/null +++ b/tests/MessagePack.Generator.Tests/Resources/UnionFormatter(None)/Formatters.Derived1Formatter.g.cs @@ -0,0 +1,34 @@ +// + +#pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 + +namespace Formatters +{ + using MsgPack = global::MessagePack; + + internal sealed class Derived1Formatter : MsgPack::Formatters.IMessagePackFormatter + { + + public void Serialize(ref MsgPack::MessagePackWriter writer, global::Derived1 value, MsgPack::MessagePackSerializerOptions options) + { + if (value == null) + { + writer.WriteNil(); + return; + } + + writer.WriteArrayHeader(0); + } + + public global::Derived1 Deserialize(ref MsgPack::MessagePackReader reader, MsgPack::MessagePackSerializerOptions options) + { + if (reader.TryReadNil()) + { + return null; + } + + reader.Skip(); + return new global::Derived1(); + } + } +} diff --git a/tests/MessagePack.Generator.Tests/Resources/UnionFormatter(None)/Formatters.Derived2Formatter.g.cs b/tests/MessagePack.Generator.Tests/Resources/UnionFormatter(None)/Formatters.Derived2Formatter.g.cs new file mode 100644 index 000000000..d5e4cf09d --- /dev/null +++ b/tests/MessagePack.Generator.Tests/Resources/UnionFormatter(None)/Formatters.Derived2Formatter.g.cs @@ -0,0 +1,34 @@ +// + +#pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 + +namespace Formatters +{ + using MsgPack = global::MessagePack; + + internal sealed class Derived2Formatter : MsgPack::Formatters.IMessagePackFormatter + { + + public void Serialize(ref MsgPack::MessagePackWriter writer, global::Derived2 value, MsgPack::MessagePackSerializerOptions options) + { + if (value == null) + { + writer.WriteNil(); + return; + } + + writer.WriteArrayHeader(0); + } + + public global::Derived2 Deserialize(ref MsgPack::MessagePackReader reader, MsgPack::MessagePackSerializerOptions options) + { + if (reader.TryReadNil()) + { + return null; + } + + reader.Skip(); + return new global::Derived2(); + } + } +} diff --git a/tests/MessagePack.Generator.Tests/Resources/UnionFormatter(None)/Formatters.IMyTypeFormatter.g.cs b/tests/MessagePack.Generator.Tests/Resources/UnionFormatter(None)/Formatters.IMyTypeFormatter.g.cs new file mode 100644 index 000000000..735071dc3 --- /dev/null +++ b/tests/MessagePack.Generator.Tests/Resources/UnionFormatter(None)/Formatters.IMyTypeFormatter.g.cs @@ -0,0 +1,91 @@ +// + +#pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 + +namespace Formatters +{ + using MsgPack = global::MessagePack; + + internal sealed class IMyTypeFormatter : MsgPack::Formatters.IMessagePackFormatter + { + private readonly global::System.Collections.Generic.Dictionary> typeToKeyAndJumpMap; + private readonly global::System.Collections.Generic.Dictionary keyToJumpMap; + + public IMyTypeFormatter() + { + this.typeToKeyAndJumpMap = new global::System.Collections.Generic.Dictionary>(2, MsgPack::Internal.RuntimeTypeHandleEqualityComparer.Default) + { + { typeof(global::Derived1).TypeHandle, new global::System.Collections.Generic.KeyValuePair(0, 0) }, + { typeof(global::Derived2).TypeHandle, new global::System.Collections.Generic.KeyValuePair(1, 1) }, + }; + this.keyToJumpMap = new global::System.Collections.Generic.Dictionary(2) + { + { 0, 0 }, + { 1, 1 }, + }; + } + + public void Serialize(ref MsgPack::MessagePackWriter writer, global::IMyType value, MsgPack::MessagePackSerializerOptions options) + { + global::System.Collections.Generic.KeyValuePair keyValuePair; + if (value != null && this.typeToKeyAndJumpMap.TryGetValue(value.GetType().TypeHandle, out keyValuePair)) + { + writer.WriteArrayHeader(2); + writer.WriteInt32(keyValuePair.Key); + switch (keyValuePair.Value) + { + case 0: + MsgPack::FormatterResolverExtensions.GetFormatterWithVerify(options.Resolver).Serialize(ref writer, (global::Derived1)value, options); + break; + case 1: + MsgPack::FormatterResolverExtensions.GetFormatterWithVerify(options.Resolver).Serialize(ref writer, (global::Derived2)value, options); + break; + default: + break; + } + + return; + } + + writer.WriteNil(); + } + + public global::IMyType Deserialize(ref MsgPack::MessagePackReader reader, MsgPack::MessagePackSerializerOptions options) + { + if (reader.TryReadNil()) + { + return null; + } + + if (reader.ReadArrayHeader() != 2) + { + throw new global::System.InvalidOperationException("Invalid Union data was detected. Type:global::IMyType"); + } + + options.Security.DepthStep(ref reader); + var key = reader.ReadInt32(); + + if (!this.keyToJumpMap.TryGetValue(key, out key)) + { + key = -1; + } + + global::IMyType result = null; + switch (key) + { + case 0: + result = (global::IMyType)MsgPack::FormatterResolverExtensions.GetFormatterWithVerify(options.Resolver).Deserialize(ref reader, options); + break; + case 1: + result = (global::IMyType)MsgPack::FormatterResolverExtensions.GetFormatterWithVerify(options.Resolver).Deserialize(ref reader, options); + break; + default: + reader.Skip(); + break; + } + + reader.Depth--; + return result; + } + } +} diff --git a/tests/MessagePack.Generator.Tests/Resources/UnionFormatter(None)/Formatters.MyMessagePackObjectFormatter.g.cs b/tests/MessagePack.Generator.Tests/Resources/UnionFormatter(None)/Formatters.MyMessagePackObjectFormatter.g.cs new file mode 100644 index 000000000..e2e339afe --- /dev/null +++ b/tests/MessagePack.Generator.Tests/Resources/UnionFormatter(None)/Formatters.MyMessagePackObjectFormatter.g.cs @@ -0,0 +1,54 @@ +// + +#pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 + +namespace Formatters +{ + using MsgPack = global::MessagePack; + + internal sealed class MyMessagePackObjectFormatter : MsgPack::Formatters.IMessagePackFormatter + { + + public void Serialize(ref MsgPack::MessagePackWriter writer, global::MyMessagePackObject value, MsgPack::MessagePackSerializerOptions options) + { + if (value == null) + { + writer.WriteNil(); + return; + } + + MsgPack::IFormatterResolver formatterResolver = options.Resolver; + writer.WriteArrayHeader(1); + MsgPack::FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Serialize(ref writer, value.UnionValue, options); + } + + public global::MyMessagePackObject Deserialize(ref MsgPack::MessagePackReader reader, MsgPack::MessagePackSerializerOptions options) + { + if (reader.TryReadNil()) + { + return null; + } + + options.Security.DepthStep(ref reader); + MsgPack::IFormatterResolver formatterResolver = options.Resolver; + var length = reader.ReadArrayHeader(); + var ____result = new global::MyMessagePackObject(); + + for (int i = 0; i < length; i++) + { + switch (i) + { + case 0: + ____result.UnionValue = MsgPack::FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Deserialize(ref reader, options); + break; + default: + reader.Skip(); + break; + } + } + + reader.Depth--; + return ____result; + } + } +} diff --git a/tests/MessagePack.Generator.Tests/Resources/UnionFormatter(None)/MessagePack.GeneratedMessagePackResolver.g.cs b/tests/MessagePack.Generator.Tests/Resources/UnionFormatter(None)/MessagePack.GeneratedMessagePackResolver.g.cs new file mode 100644 index 000000000..f2a945dbf --- /dev/null +++ b/tests/MessagePack.Generator.Tests/Resources/UnionFormatter(None)/MessagePack.GeneratedMessagePackResolver.g.cs @@ -0,0 +1,76 @@ +// + +#pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 + +namespace MessagePack +{ + using MsgPack = global::MessagePack; + using Formatters = global::Formatters; + + /// A MessagePack resolver that uses generated formatters for types in this assembly. + internal class GeneratedMessagePackResolver : MsgPack::IFormatterResolver + { + /// An instance of this resolver that only returns formatters specifically generated for types in this assembly. + public static readonly MsgPack::IFormatterResolver Instance = new GeneratedMessagePackResolver(); + + /// An instance of this resolver that returns standard AOT-compatible formatters as well as formatters specifically generated for types in this assembly. + public static readonly MsgPack::IFormatterResolver InstanceWithStandardAotResolver = MsgPack::Resolvers.CompositeResolver.Create(Instance, MsgPack::Resolvers.StandardAotResolver.Instance); + + private GeneratedMessagePackResolver() + { + } + + public MsgPack::Formatters.IMessagePackFormatter GetFormatter() + { + return FormatterCache.Formatter; + } + + private static class FormatterCache + { + internal static readonly MsgPack::Formatters.IMessagePackFormatter Formatter; + + static FormatterCache() + { + var f = GeneratedMessagePackResolverGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + Formatter = (MsgPack::Formatters.IMessagePackFormatter)f; + } + } + } + } + + internal static class GeneratedMessagePackResolverGetFormatterHelper + { + private static readonly global::System.Collections.Generic.Dictionary lookup; + + static GeneratedMessagePackResolverGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(4) + { + { typeof(global::IMyType), 0 }, + { typeof(global::Derived1), 1 }, + { typeof(global::Derived2), 2 }, + { typeof(global::MyMessagePackObject), 3 }, + }; + } + + internal static object GetFormatter(global::System.Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + case 0: return new Formatters::IMyTypeFormatter(); + case 1: return new Formatters::Derived1Formatter(); + case 2: return new Formatters::Derived2Formatter(); + case 3: return new Formatters::MyMessagePackObjectFormatter(); + default: return null; + } + } + } +} From 318d8a7870dbe306e4cb45782e71dd7d4832fed9 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Thu, 30 Mar 2023 12:59:26 -0600 Subject: [PATCH 061/660] Break out test classes into their own files --- .../Derived1.cs | 7 +++ .../Derived2.cs | 7 +++ .../ExecutionTests.cs | 63 ------------------- .../HasPropertiesWithGetterAndCtor.cs | 18 ++++++ .../HasPropertiesWithGetterAndSetter.cs | 12 ++++ .../IMyType.cs | 8 +++ .../MyEnum.cs | 9 +++ .../MyMessagePackObject.cs | 9 +++ .../UnionContainer.cs | 9 +++ 9 files changed, 79 insertions(+), 63 deletions(-) create mode 100644 tests/MessagePack.Generator.ExecutionTests/Derived1.cs create mode 100644 tests/MessagePack.Generator.ExecutionTests/Derived2.cs create mode 100644 tests/MessagePack.Generator.ExecutionTests/HasPropertiesWithGetterAndCtor.cs create mode 100644 tests/MessagePack.Generator.ExecutionTests/HasPropertiesWithGetterAndSetter.cs create mode 100644 tests/MessagePack.Generator.ExecutionTests/IMyType.cs create mode 100644 tests/MessagePack.Generator.ExecutionTests/MyEnum.cs create mode 100644 tests/MessagePack.Generator.ExecutionTests/MyMessagePackObject.cs create mode 100644 tests/MessagePack.Generator.ExecutionTests/UnionContainer.cs diff --git a/tests/MessagePack.Generator.ExecutionTests/Derived1.cs b/tests/MessagePack.Generator.ExecutionTests/Derived1.cs new file mode 100644 index 000000000..ce7ec4cd1 --- /dev/null +++ b/tests/MessagePack.Generator.ExecutionTests/Derived1.cs @@ -0,0 +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. + +[MessagePackObject] +internal record Derived1 : IMyType +{ +} diff --git a/tests/MessagePack.Generator.ExecutionTests/Derived2.cs b/tests/MessagePack.Generator.ExecutionTests/Derived2.cs new file mode 100644 index 000000000..839f039cd --- /dev/null +++ b/tests/MessagePack.Generator.ExecutionTests/Derived2.cs @@ -0,0 +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. + +[MessagePackObject] +internal record Derived2 : IMyType +{ +} diff --git a/tests/MessagePack.Generator.ExecutionTests/ExecutionTests.cs b/tests/MessagePack.Generator.ExecutionTests/ExecutionTests.cs index a48dbd63a..fe11f0711 100644 --- a/tests/MessagePack.Generator.ExecutionTests/ExecutionTests.cs +++ b/tests/MessagePack.Generator.ExecutionTests/ExecutionTests.cs @@ -47,67 +47,4 @@ private T AssertRoundtrip(T value) Assert.Equal(value, after); return after; } - - [MessagePackObject] - internal record MyMessagePackObject - { - [Key(0)] - internal MyEnum EnumValue { get; set; } - } - - [MessagePackObject(false)] - internal record HasPropertiesWithGetterAndSetter - { - [Key(0)] - internal int A { get; set; } - - [Key(1)] - internal int? B { get; set; } - } - - [MessagePackObject(false)] - internal record HasPropertiesWithGetterAndCtor - { - [Key(0)] - internal int A { get; } - - [Key(1)] - internal string? B { get; } - - internal HasPropertiesWithGetterAndCtor(int a, string? b) - { - A = a; - B = b; - } - } - - [Union(0, typeof(Derived1))] - [Union(1, typeof(Derived2))] - internal interface IMyType - { - } - - [MessagePackObject] - internal record Derived1 : IMyType - { - } - - [MessagePackObject] - internal record Derived2 : IMyType - { - } - - [MessagePackObject] - internal record UnionContainer - { - [Key(0)] - internal IMyType? Value { get; set; } - } - - internal enum MyEnum - { - A, - B, - C, - } } diff --git a/tests/MessagePack.Generator.ExecutionTests/HasPropertiesWithGetterAndCtor.cs b/tests/MessagePack.Generator.ExecutionTests/HasPropertiesWithGetterAndCtor.cs new file mode 100644 index 000000000..c6b237038 --- /dev/null +++ b/tests/MessagePack.Generator.ExecutionTests/HasPropertiesWithGetterAndCtor.cs @@ -0,0 +1,18 @@ +// Copyright (c) All contributors. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +[MessagePackObject(false)] +internal record HasPropertiesWithGetterAndCtor +{ + [Key(0)] + internal int A { get; } + + [Key(1)] + internal string? B { get; } + + internal HasPropertiesWithGetterAndCtor(int a, string? b) + { + A = a; + B = b; + } +} diff --git a/tests/MessagePack.Generator.ExecutionTests/HasPropertiesWithGetterAndSetter.cs b/tests/MessagePack.Generator.ExecutionTests/HasPropertiesWithGetterAndSetter.cs new file mode 100644 index 000000000..f80ff18bb --- /dev/null +++ b/tests/MessagePack.Generator.ExecutionTests/HasPropertiesWithGetterAndSetter.cs @@ -0,0 +1,12 @@ +// Copyright (c) All contributors. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +[MessagePackObject(false)] +internal record HasPropertiesWithGetterAndSetter +{ + [Key(0)] + internal int A { get; set; } + + [Key(1)] + internal int? B { get; set; } +} diff --git a/tests/MessagePack.Generator.ExecutionTests/IMyType.cs b/tests/MessagePack.Generator.ExecutionTests/IMyType.cs new file mode 100644 index 000000000..44809141a --- /dev/null +++ b/tests/MessagePack.Generator.ExecutionTests/IMyType.cs @@ -0,0 +1,8 @@ +// Copyright (c) All contributors. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +[Union(0, typeof(Derived1))] +[Union(1, typeof(Derived2))] +internal interface IMyType +{ +} diff --git a/tests/MessagePack.Generator.ExecutionTests/MyEnum.cs b/tests/MessagePack.Generator.ExecutionTests/MyEnum.cs new file mode 100644 index 000000000..96ed23b86 --- /dev/null +++ b/tests/MessagePack.Generator.ExecutionTests/MyEnum.cs @@ -0,0 +1,9 @@ +// Copyright (c) All contributors. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +internal enum MyEnum +{ + A, + B, + C, +} diff --git a/tests/MessagePack.Generator.ExecutionTests/MyMessagePackObject.cs b/tests/MessagePack.Generator.ExecutionTests/MyMessagePackObject.cs new file mode 100644 index 000000000..488e1a8f8 --- /dev/null +++ b/tests/MessagePack.Generator.ExecutionTests/MyMessagePackObject.cs @@ -0,0 +1,9 @@ +// Copyright (c) All contributors. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +[MessagePackObject] +internal record MyMessagePackObject +{ + [Key(0)] + internal MyEnum EnumValue { get; set; } +} diff --git a/tests/MessagePack.Generator.ExecutionTests/UnionContainer.cs b/tests/MessagePack.Generator.ExecutionTests/UnionContainer.cs new file mode 100644 index 000000000..43a4c0b19 --- /dev/null +++ b/tests/MessagePack.Generator.ExecutionTests/UnionContainer.cs @@ -0,0 +1,9 @@ +// Copyright (c) All contributors. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +[MessagePackObject] +internal record UnionContainer +{ + [Key(0)] + internal IMyType? Value { get; set; } +} From 18a0ad3e5ec817767eda76e100490aa9d10b357c Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Thu, 30 Mar 2023 14:27:27 -0600 Subject: [PATCH 062/660] Fix generation of custom formatter attributed properties in map mode --- .../CodeAnalysis/TypeCollector.cs | 10 ++- .../CustomFormatterRecord.cs | 8 +++ .../CustomFormatterRecordFormatter.cs | 17 +++++ .../ExecutionTests.cs | 12 ++++ ...HasPropertyWithCustomFormatterAttribute.cs | 9 +++ .../HasPropertyWithTypeWithCustomFormatter.cs | 9 +++ .../UnserializableRecord.cs | 7 ++ .../UnserializableRecordFormatter.cs | 17 +++++ .../GenerationTests.cs | 36 ++++++++++ ...WithCustomFormatterAttributeFormatter.g.cs | 53 ++++++++++++++ ...sagePack.GeneratedMessagePackResolver.g.cs | 70 +++++++++++++++++++ ...WithCustomFormatterAttributeFormatter.g.cs | 61 ++++++++++++++++ ...sagePack.GeneratedMessagePackResolver.g.cs | 70 +++++++++++++++++++ 13 files changed, 377 insertions(+), 2 deletions(-) create mode 100644 tests/MessagePack.Generator.ExecutionTests/CustomFormatterRecord.cs create mode 100644 tests/MessagePack.Generator.ExecutionTests/CustomFormatterRecordFormatter.cs create mode 100644 tests/MessagePack.Generator.ExecutionTests/HasPropertyWithCustomFormatterAttribute.cs create mode 100644 tests/MessagePack.Generator.ExecutionTests/HasPropertyWithTypeWithCustomFormatter.cs create mode 100644 tests/MessagePack.Generator.ExecutionTests/UnserializableRecord.cs create mode 100644 tests/MessagePack.Generator.ExecutionTests/UnserializableRecordFormatter.cs create mode 100644 tests/MessagePack.Generator.Tests/Resources/CustomFormatterViaAttributeOnProperty(False)/Formatters.HasPropertyWithCustomFormatterAttributeFormatter.g.cs create mode 100644 tests/MessagePack.Generator.Tests/Resources/CustomFormatterViaAttributeOnProperty(False)/MessagePack.GeneratedMessagePackResolver.g.cs create mode 100644 tests/MessagePack.Generator.Tests/Resources/CustomFormatterViaAttributeOnProperty(True)/Formatters.HasPropertyWithCustomFormatterAttributeFormatter.g.cs create mode 100644 tests/MessagePack.Generator.Tests/Resources/CustomFormatterViaAttributeOnProperty(True)/MessagePack.GeneratedMessagePackResolver.g.cs diff --git a/src/MessagePack.Generator/CodeAnalysis/TypeCollector.cs b/src/MessagePack.Generator/CodeAnalysis/TypeCollector.cs index 33093fdb5..fb5cfb515 100644 --- a/src/MessagePack.Generator/CodeAnalysis/TypeCollector.cs +++ b/src/MessagePack.Generator/CodeAnalysis/TypeCollector.cs @@ -649,7 +649,10 @@ private ObjectSerializationInfo GetObjectInfo(INamedTypeSymbol type) var member = new MemberSerializationInfo(true, isWritable, isReadable, hiddenIntKey++, item.Name, item.Name, item.Type.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat), item.Type.ToDisplayString(BinaryWriteFormat), customFormatterAttr?.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat)); stringMembers.Add(member.StringKey, member); - this.CollectCore(item.Type); // recursive collect + if (customFormatterAttr == null) + { + this.CollectCore(item.Type); // recursive collect + } } foreach (IFieldSymbol item in type.GetAllMembers().OfType()) @@ -674,7 +677,10 @@ private ObjectSerializationInfo GetObjectInfo(INamedTypeSymbol type) var customFormatterAttr = item.GetAttributes().FirstOrDefault(x => x.AttributeClass.ApproximatelyEqual(this.typeReferences.MessagePackFormatterAttribute))?.ConstructorArguments[0].Value as INamedTypeSymbol; var member = new MemberSerializationInfo(false, isWritable, isReadable, hiddenIntKey++, item.Name, item.Name, item.Type.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat), item.Type.ToDisplayString(BinaryWriteFormat), customFormatterAttr?.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat)); stringMembers.Add(member.StringKey, member); - this.CollectCore(item.Type); // recursive collect + if (customFormatterAttr == null) + { + this.CollectCore(item.Type); // recursive collect + } } } else diff --git a/tests/MessagePack.Generator.ExecutionTests/CustomFormatterRecord.cs b/tests/MessagePack.Generator.ExecutionTests/CustomFormatterRecord.cs new file mode 100644 index 000000000..af1b7f0bb --- /dev/null +++ b/tests/MessagePack.Generator.ExecutionTests/CustomFormatterRecord.cs @@ -0,0 +1,8 @@ +// Copyright (c) All contributors. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +[MessagePackFormatter(typeof(CustomFormatterRecordFormatter))] +internal record CustomFormatterRecord +{ + internal int Value { get; set; } +} diff --git a/tests/MessagePack.Generator.ExecutionTests/CustomFormatterRecordFormatter.cs b/tests/MessagePack.Generator.ExecutionTests/CustomFormatterRecordFormatter.cs new file mode 100644 index 000000000..68ae155ef --- /dev/null +++ b/tests/MessagePack.Generator.ExecutionTests/CustomFormatterRecordFormatter.cs @@ -0,0 +1,17 @@ +// Copyright (c) All contributors. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using MessagePack.Formatters; + +internal class CustomFormatterRecordFormatter : IMessagePackFormatter +{ + public void Serialize(ref MessagePackWriter writer, CustomFormatterRecord value, MessagePackSerializerOptions options) + { + writer.WriteInt32(value.Value); + } + + public CustomFormatterRecord Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options) + { + return new CustomFormatterRecord { Value = reader.ReadInt32() }; + } +} diff --git a/tests/MessagePack.Generator.ExecutionTests/ExecutionTests.cs b/tests/MessagePack.Generator.ExecutionTests/ExecutionTests.cs index fe11f0711..1e5dca5c5 100644 --- a/tests/MessagePack.Generator.ExecutionTests/ExecutionTests.cs +++ b/tests/MessagePack.Generator.ExecutionTests/ExecutionTests.cs @@ -39,6 +39,18 @@ public void ClassWithUnionProperty() this.AssertRoundtrip(new UnionContainer { Value = new Derived2() }); } + [Fact] + public void ClassWithPropertyWithTypeWithCustomFormatter() + { + this.AssertRoundtrip(new HasPropertyWithTypeWithCustomFormatter { CustomValue = new() { Value = 3 } }); + } + + [Fact] + public void ClassWithPropertyWithCustomFormatterAttribute() + { + this.AssertRoundtrip(new HasPropertyWithCustomFormatterAttribute { CustomValue = new() { Value = 3 } }); + } + private T AssertRoundtrip(T value) { byte[] serialized = MessagePackSerializer.Serialize(value, SerializerOptions); diff --git a/tests/MessagePack.Generator.ExecutionTests/HasPropertyWithCustomFormatterAttribute.cs b/tests/MessagePack.Generator.ExecutionTests/HasPropertyWithCustomFormatterAttribute.cs new file mode 100644 index 000000000..6f6470758 --- /dev/null +++ b/tests/MessagePack.Generator.ExecutionTests/HasPropertyWithCustomFormatterAttribute.cs @@ -0,0 +1,9 @@ +// Copyright (c) All contributors. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +[MessagePackObject] +internal record HasPropertyWithCustomFormatterAttribute +{ + [Key(0), MessagePackFormatter(typeof(UnserializableRecordFormatter))] + internal UnserializableRecord? CustomValue { get; set; } +} diff --git a/tests/MessagePack.Generator.ExecutionTests/HasPropertyWithTypeWithCustomFormatter.cs b/tests/MessagePack.Generator.ExecutionTests/HasPropertyWithTypeWithCustomFormatter.cs new file mode 100644 index 000000000..5a3da9e7a --- /dev/null +++ b/tests/MessagePack.Generator.ExecutionTests/HasPropertyWithTypeWithCustomFormatter.cs @@ -0,0 +1,9 @@ +// Copyright (c) All contributors. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +[MessagePackObject] +internal record HasPropertyWithTypeWithCustomFormatter +{ + [Key(0)] + internal CustomFormatterRecord? CustomValue { get; set; } +} diff --git a/tests/MessagePack.Generator.ExecutionTests/UnserializableRecord.cs b/tests/MessagePack.Generator.ExecutionTests/UnserializableRecord.cs new file mode 100644 index 000000000..e62ba616a --- /dev/null +++ b/tests/MessagePack.Generator.ExecutionTests/UnserializableRecord.cs @@ -0,0 +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. + +internal record UnserializableRecord +{ + internal int Value { get; set; } +} diff --git a/tests/MessagePack.Generator.ExecutionTests/UnserializableRecordFormatter.cs b/tests/MessagePack.Generator.ExecutionTests/UnserializableRecordFormatter.cs new file mode 100644 index 000000000..24d320e67 --- /dev/null +++ b/tests/MessagePack.Generator.ExecutionTests/UnserializableRecordFormatter.cs @@ -0,0 +1,17 @@ +// Copyright (c) All contributors. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using MessagePack.Formatters; + +internal class UnserializableRecordFormatter : IMessagePackFormatter +{ + public void Serialize(ref MessagePackWriter writer, UnserializableRecord value, MessagePackSerializerOptions options) + { + writer.WriteInt32(value.Value); + } + + public UnserializableRecord Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options) + { + return new UnserializableRecord { Value = reader.ReadInt32() }; + } +} diff --git a/tests/MessagePack.Generator.Tests/GenerationTests.cs b/tests/MessagePack.Generator.Tests/GenerationTests.cs index 632f9cacf..7c3ff5e9f 100644 --- a/tests/MessagePack.Generator.Tests/GenerationTests.cs +++ b/tests/MessagePack.Generator.Tests/GenerationTests.cs @@ -1,6 +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. +using System.ComponentModel; using MessagePack.Generator.Tests; public class GenerationTests @@ -33,6 +34,41 @@ internal enum MyEnum await VerifyCS.Test.RunDefaultAsync(testSource, options: AnalyzerOptions.Default with { UsesMapMode = usesMapMode }, testMethod: $"{nameof(EnumFormatter)}({container}, {usesMapMode})"); } + [Theory, PairwiseData] + public async Task CustomFormatterViaAttributeOnProperty(bool usesMapMode) + { + string testSource = """ +using MessagePack; +using MessagePack.Formatters; + +[MessagePackObject] +internal record HasPropertyWithCustomFormatterAttribute +{ + [Key(0), MessagePackFormatter(typeof(UnserializableRecordFormatter))] + internal UnserializableRecord CustomValue { get; set; } +} + +record UnserializableRecord +{ + internal int Value { get; set; } +} + +class UnserializableRecordFormatter : IMessagePackFormatter +{ + public void Serialize(ref MessagePackWriter writer, UnserializableRecord value, MessagePackSerializerOptions options) + { + writer.WriteInt32(value.Value); + } + + public UnserializableRecord Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options) + { + return new UnserializableRecord { Value = reader.ReadInt32() }; + } +} +"""; + await VerifyCS.Test.RunDefaultAsync(testSource, options: AnalyzerOptions.Default with { UsesMapMode = usesMapMode }, testMethod: $"{nameof(CustomFormatterViaAttributeOnProperty)}({usesMapMode})"); + } + [Theory, PairwiseData] public async Task UnionFormatter(ContainerKind container) { diff --git a/tests/MessagePack.Generator.Tests/Resources/CustomFormatterViaAttributeOnProperty(False)/Formatters.HasPropertyWithCustomFormatterAttributeFormatter.g.cs b/tests/MessagePack.Generator.Tests/Resources/CustomFormatterViaAttributeOnProperty(False)/Formatters.HasPropertyWithCustomFormatterAttributeFormatter.g.cs new file mode 100644 index 000000000..3f227685c --- /dev/null +++ b/tests/MessagePack.Generator.Tests/Resources/CustomFormatterViaAttributeOnProperty(False)/Formatters.HasPropertyWithCustomFormatterAttributeFormatter.g.cs @@ -0,0 +1,53 @@ +// + +#pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 + +namespace Formatters +{ + using MsgPack = global::MessagePack; + + internal sealed class HasPropertyWithCustomFormatterAttributeFormatter : MsgPack::Formatters.IMessagePackFormatter + { + private readonly global::UnserializableRecordFormatter __CustomValueCustomFormatter__ = new global::UnserializableRecordFormatter(); + + public void Serialize(ref MsgPack::MessagePackWriter writer, global::HasPropertyWithCustomFormatterAttribute value, MsgPack::MessagePackSerializerOptions options) + { + if (value == null) + { + writer.WriteNil(); + return; + } + + writer.WriteArrayHeader(1); + this.__CustomValueCustomFormatter__.Serialize(ref writer, value.CustomValue, options); + } + + public global::HasPropertyWithCustomFormatterAttribute Deserialize(ref MsgPack::MessagePackReader reader, MsgPack::MessagePackSerializerOptions options) + { + if (reader.TryReadNil()) + { + return null; + } + + options.Security.DepthStep(ref reader); + var length = reader.ReadArrayHeader(); + var ____result = new global::HasPropertyWithCustomFormatterAttribute(); + + for (int i = 0; i < length; i++) + { + switch (i) + { + case 0: + ____result.CustomValue = this.__CustomValueCustomFormatter__.Deserialize(ref reader, options); + break; + default: + reader.Skip(); + break; + } + } + + reader.Depth--; + return ____result; + } + } +} diff --git a/tests/MessagePack.Generator.Tests/Resources/CustomFormatterViaAttributeOnProperty(False)/MessagePack.GeneratedMessagePackResolver.g.cs b/tests/MessagePack.Generator.Tests/Resources/CustomFormatterViaAttributeOnProperty(False)/MessagePack.GeneratedMessagePackResolver.g.cs new file mode 100644 index 000000000..4105a0db3 --- /dev/null +++ b/tests/MessagePack.Generator.Tests/Resources/CustomFormatterViaAttributeOnProperty(False)/MessagePack.GeneratedMessagePackResolver.g.cs @@ -0,0 +1,70 @@ +// + +#pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 + +namespace MessagePack +{ + using MsgPack = global::MessagePack; + using Formatters = global::Formatters; + + /// A MessagePack resolver that uses generated formatters for types in this assembly. + internal class GeneratedMessagePackResolver : MsgPack::IFormatterResolver + { + /// An instance of this resolver that only returns formatters specifically generated for types in this assembly. + public static readonly MsgPack::IFormatterResolver Instance = new GeneratedMessagePackResolver(); + + /// An instance of this resolver that returns standard AOT-compatible formatters as well as formatters specifically generated for types in this assembly. + public static readonly MsgPack::IFormatterResolver InstanceWithStandardAotResolver = MsgPack::Resolvers.CompositeResolver.Create(Instance, MsgPack::Resolvers.StandardAotResolver.Instance); + + private GeneratedMessagePackResolver() + { + } + + public MsgPack::Formatters.IMessagePackFormatter GetFormatter() + { + return FormatterCache.Formatter; + } + + private static class FormatterCache + { + internal static readonly MsgPack::Formatters.IMessagePackFormatter Formatter; + + static FormatterCache() + { + var f = GeneratedMessagePackResolverGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + Formatter = (MsgPack::Formatters.IMessagePackFormatter)f; + } + } + } + } + + internal static class GeneratedMessagePackResolverGetFormatterHelper + { + private static readonly global::System.Collections.Generic.Dictionary lookup; + + static GeneratedMessagePackResolverGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(1) + { + { typeof(global::HasPropertyWithCustomFormatterAttribute), 0 }, + }; + } + + internal static object GetFormatter(global::System.Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + case 0: return new Formatters::HasPropertyWithCustomFormatterAttributeFormatter(); + default: return null; + } + } + } +} diff --git a/tests/MessagePack.Generator.Tests/Resources/CustomFormatterViaAttributeOnProperty(True)/Formatters.HasPropertyWithCustomFormatterAttributeFormatter.g.cs b/tests/MessagePack.Generator.Tests/Resources/CustomFormatterViaAttributeOnProperty(True)/Formatters.HasPropertyWithCustomFormatterAttributeFormatter.g.cs new file mode 100644 index 000000000..ab14f0853 --- /dev/null +++ b/tests/MessagePack.Generator.Tests/Resources/CustomFormatterViaAttributeOnProperty(True)/Formatters.HasPropertyWithCustomFormatterAttributeFormatter.g.cs @@ -0,0 +1,61 @@ +// + +#pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 + +namespace Formatters +{ + using MsgPack = global::MessagePack; + + internal sealed class HasPropertyWithCustomFormatterAttributeFormatter : global::MessagePack.Formatters.IMessagePackFormatter + { + private readonly global::UnserializableRecordFormatter __CustomValueCustomFormatter__ = new global::UnserializableRecordFormatter(); + // CustomValue + private static global::System.ReadOnlySpan GetSpan_CustomValue() => new byte[1 + 11] { 171, 67, 117, 115, 116, 111, 109, 86, 97, 108, 117, 101 }; + + public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::HasPropertyWithCustomFormatterAttribute value, global::MessagePack.MessagePackSerializerOptions options) + { + if (value is null) + { + writer.WriteNil(); + return; + } + + writer.WriteMapHeader(1); + writer.WriteRaw(GetSpan_CustomValue()); + this.__CustomValueCustomFormatter__.Serialize(ref writer, value.CustomValue, options); + } + + public global::HasPropertyWithCustomFormatterAttribute Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) + { + if (reader.TryReadNil()) + { + return null; + } + + options.Security.DepthStep(ref reader); + var length = reader.ReadMapHeader(); + var ____result = new global::HasPropertyWithCustomFormatterAttribute(); + + for (int i = 0; i < length; i++) + { + var stringKey = global::MessagePack.Internal.CodeGenHelpers.ReadStringSpan(ref reader); + switch (stringKey.Length) + { + default: + FAIL: + reader.Skip(); + continue; + case 11: + if (!global::System.MemoryExtensions.SequenceEqual(stringKey, GetSpan_CustomValue().Slice(1))) { goto FAIL; } + + ____result.CustomValue = this.__CustomValueCustomFormatter__.Deserialize(ref reader, options); + continue; + + } + } + + reader.Depth--; + return ____result; + } + } +} diff --git a/tests/MessagePack.Generator.Tests/Resources/CustomFormatterViaAttributeOnProperty(True)/MessagePack.GeneratedMessagePackResolver.g.cs b/tests/MessagePack.Generator.Tests/Resources/CustomFormatterViaAttributeOnProperty(True)/MessagePack.GeneratedMessagePackResolver.g.cs new file mode 100644 index 000000000..4105a0db3 --- /dev/null +++ b/tests/MessagePack.Generator.Tests/Resources/CustomFormatterViaAttributeOnProperty(True)/MessagePack.GeneratedMessagePackResolver.g.cs @@ -0,0 +1,70 @@ +// + +#pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 + +namespace MessagePack +{ + using MsgPack = global::MessagePack; + using Formatters = global::Formatters; + + /// A MessagePack resolver that uses generated formatters for types in this assembly. + internal class GeneratedMessagePackResolver : MsgPack::IFormatterResolver + { + /// An instance of this resolver that only returns formatters specifically generated for types in this assembly. + public static readonly MsgPack::IFormatterResolver Instance = new GeneratedMessagePackResolver(); + + /// An instance of this resolver that returns standard AOT-compatible formatters as well as formatters specifically generated for types in this assembly. + public static readonly MsgPack::IFormatterResolver InstanceWithStandardAotResolver = MsgPack::Resolvers.CompositeResolver.Create(Instance, MsgPack::Resolvers.StandardAotResolver.Instance); + + private GeneratedMessagePackResolver() + { + } + + public MsgPack::Formatters.IMessagePackFormatter GetFormatter() + { + return FormatterCache.Formatter; + } + + private static class FormatterCache + { + internal static readonly MsgPack::Formatters.IMessagePackFormatter Formatter; + + static FormatterCache() + { + var f = GeneratedMessagePackResolverGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + Formatter = (MsgPack::Formatters.IMessagePackFormatter)f; + } + } + } + } + + internal static class GeneratedMessagePackResolverGetFormatterHelper + { + private static readonly global::System.Collections.Generic.Dictionary lookup; + + static GeneratedMessagePackResolverGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(1) + { + { typeof(global::HasPropertyWithCustomFormatterAttribute), 0 }, + }; + } + + internal static object GetFormatter(global::System.Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + case 0: return new Formatters::HasPropertyWithCustomFormatterAttributeFormatter(); + default: return null; + } + } + } +} From 542f0b945bde3b7e54e740e26ad0804a89f2b926 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Thu, 30 Mar 2023 16:27:09 -0600 Subject: [PATCH 063/660] Test and fix arrays --- .../CodeAnalysis/AnalyzerOptions.cs | 2 +- .../CodeAnalysis/CodeAnalysisUtilities.cs | 2 +- .../CodeAnalysis/EnumSerializationInfo.cs | 6 +- .../CodeAnalysis/ObjectSerializationInfo.cs | 4 +- .../CodeAnalysis/TypeCollector.cs | 154 +++++++++--------- .../CodeAnalysis/UnionSerializationInfo.cs | 6 +- .../Transforms/ResolverTemplate.cs | 2 +- .../Transforms/ResolverTemplate.tt | 2 +- .../Transforms/TemplatePartials.cs | 8 +- .../MessagePack/Resolvers/StandardResolver.cs | 3 - .../GenerationTests.cs | 21 +++ .../Formatters.ContainerObjectFormatter.g.cs | 54 ++++++ .../Formatters.SubObjectFormatter.g.cs | 34 ++++ ...sagePack.GeneratedMessagePackResolver.g.cs | 74 +++++++++ .../CSharpSourceGeneratorVerifier`1+Test.cs | 2 +- 15 files changed, 284 insertions(+), 90 deletions(-) create mode 100644 tests/MessagePack.Generator.Tests/Resources/ArrayTypedProperty/Formatters.ContainerObjectFormatter.g.cs create mode 100644 tests/MessagePack.Generator.Tests/Resources/ArrayTypedProperty/Formatters.SubObjectFormatter.g.cs create mode 100644 tests/MessagePack.Generator.Tests/Resources/ArrayTypedProperty/MessagePack.GeneratedMessagePackResolver.g.cs diff --git a/src/MessagePack.Generator/CodeAnalysis/AnalyzerOptions.cs b/src/MessagePack.Generator/CodeAnalysis/AnalyzerOptions.cs index 22e018ac2..d46eced72 100644 --- a/src/MessagePack.Generator/CodeAnalysis/AnalyzerOptions.cs +++ b/src/MessagePack.Generator/CodeAnalysis/AnalyzerOptions.cs @@ -21,7 +21,7 @@ public record AnalyzerOptions( public static readonly AnalyzerOptions Default = new AnalyzerOptions(); - public string FormatterNamespace => CodeAnalysisUtilities.QualifyWithOptionalNamespace("Formatters", this.ProjectRootNamespace); + public string FormatterNamespace => "Formatters"; public static AnalyzerOptions Parse(AnalyzerConfigOptions options) { diff --git a/src/MessagePack.Generator/CodeAnalysis/CodeAnalysisUtilities.cs b/src/MessagePack.Generator/CodeAnalysis/CodeAnalysisUtilities.cs index 1b901b8ee..d2ff319b7 100644 --- a/src/MessagePack.Generator/CodeAnalysis/CodeAnalysisUtilities.cs +++ b/src/MessagePack.Generator/CodeAnalysis/CodeAnalysisUtilities.cs @@ -7,7 +7,7 @@ internal static class CodeAnalysisUtilities { internal static string QualifyWithOptionalNamespace(string leafTypeOrNamespace, string? baseNamespace) { - return string.IsNullOrEmpty(baseNamespace) ? leafTypeOrNamespace : $"{baseNamespace}.{leafTypeOrNamespace}"; + return string.IsNullOrEmpty(baseNamespace) ? leafTypeOrNamespace : (baseNamespace!.EndsWith("::") ? $"{baseNamespace}{leafTypeOrNamespace}" : $"{baseNamespace}.{leafTypeOrNamespace}"); } internal static string AppendNameToNamespace(string left, string? right) diff --git a/src/MessagePack.Generator/CodeAnalysis/EnumSerializationInfo.cs b/src/MessagePack.Generator/CodeAnalysis/EnumSerializationInfo.cs index 91c154e19..9201a79c6 100644 --- a/src/MessagePack.Generator/CodeAnalysis/EnumSerializationInfo.cs +++ b/src/MessagePack.Generator/CodeAnalysis/EnumSerializationInfo.cs @@ -5,7 +5,11 @@ namespace MessagePack.Generator.CodeAnalysis; public sealed record EnumSerializationInfo(string? Namespace, string Name, string FullName, string UnderlyingTypeName) : IResolverRegisterInfo { - public string FormatterName => CodeAnalysisUtilities.QualifyWithOptionalNamespace(this.Name + "Formatter", this.Namespace); + public string FileNameHint => $"{CodeAnalysisUtilities.AppendNameToNamespace("Formatters", this.Namespace)}.{this.FormatterNameWithoutNamespace}"; + + public string FormatterName => CodeAnalysisUtilities.QualifyWithOptionalNamespace(this.FormatterNameWithoutNamespace, $"Formatters::{this.Namespace}"); + + public string FormatterNameWithoutNamespace => this.Name + "Formatter"; public string UnderlyingTypeKeyword => this.UnderlyingTypeName switch { diff --git a/src/MessagePack.Generator/CodeAnalysis/ObjectSerializationInfo.cs b/src/MessagePack.Generator/CodeAnalysis/ObjectSerializationInfo.cs index 8acad4063..f8d792445 100644 --- a/src/MessagePack.Generator/CodeAnalysis/ObjectSerializationInfo.cs +++ b/src/MessagePack.Generator/CodeAnalysis/ObjectSerializationInfo.cs @@ -22,7 +22,9 @@ public bool IsStringKey get { return !this.IsIntKey; } } - public string FormatterName => CodeAnalysisUtilities.QualifyWithOptionalNamespace(this.FormatterNameWithoutNamespace, this.Namespace); + public string FileNameHint => $"{CodeAnalysisUtilities.AppendNameToNamespace("Formatters", this.Namespace)}.{this.FormatterNameWithoutNamespace}"; + + public string FormatterName => CodeAnalysisUtilities.QualifyWithOptionalNamespace(this.FormatterNameWithoutNamespace, $"Formatters::{this.Namespace}"); public string FormatterNameWithoutNamespace => this.Name + "Formatter" + (this.IsOpenGenericType ? $"<{string.Join(", ", this.GenericTypeParameters.Select(x => x.Name))}>" : string.Empty); diff --git a/src/MessagePack.Generator/CodeAnalysis/TypeCollector.cs b/src/MessagePack.Generator/CodeAnalysis/TypeCollector.cs index fb5cfb515..cbb7c48f0 100644 --- a/src/MessagePack.Generator/CodeAnalysis/TypeCollector.cs +++ b/src/MessagePack.Generator/CodeAnalysis/TypeCollector.cs @@ -148,76 +148,76 @@ public class TypeCollector private static readonly Dictionary KnownGenericTypes = new() { #pragma warning disable SA1509 // Opening braces should not be preceded by blank line - { "System.Collections.Generic.List<>", "global::MessagePack.Formatters.ListFormatter" }, - { "System.Collections.Generic.LinkedList<>", "global::MessagePack.Formatters.LinkedListFormatter" }, - { "System.Collections.Generic.Queue<>", "global::MessagePack.Formatters.QueueFormatter" }, - { "System.Collections.Generic.Stack<>", "global::MessagePack.Formatters.StackFormatter" }, - { "System.Collections.Generic.HashSet<>", "global::MessagePack.Formatters.HashSetFormatter" }, - { "System.Collections.ObjectModel.ReadOnlyCollection<>", "global::MessagePack.Formatters.ReadOnlyCollectionFormatter" }, - { "System.Collections.Generic.IList<>", "global::MessagePack.Formatters.InterfaceListFormatter2" }, - { "System.Collections.Generic.ICollection<>", "global::MessagePack.Formatters.InterfaceCollectionFormatter2" }, - { "System.Collections.Generic.IEnumerable<>", "global::MessagePack.Formatters.InterfaceEnumerableFormatter" }, - { "System.Collections.Generic.Dictionary<,>", "global::MessagePack.Formatters.DictionaryFormatter" }, - { "System.Collections.Generic.IDictionary<,>", "global::MessagePack.Formatters.InterfaceDictionaryFormatter" }, - { "System.Collections.Generic.SortedDictionary<,>", "global::MessagePack.Formatters.SortedDictionaryFormatter" }, - { "System.Collections.Generic.SortedList<,>", "global::MessagePack.Formatters.SortedListFormatter" }, - { "System.Linq.ILookup<,>", "global::MessagePack.Formatters.InterfaceLookupFormatter" }, - { "System.Linq.IGrouping<,>", "global::MessagePack.Formatters.InterfaceGroupingFormatter" }, - { "System.Collections.ObjectModel.ObservableCollection<>", "global::MessagePack.Formatters.ObservableCollectionFormatter" }, - { "System.Collections.ObjectModel.ReadOnlyObservableCollection<>", "global::MessagePack.Formatters.ReadOnlyObservableCollectionFormatter" }, - { "System.Collections.Generic.IReadOnlyList<>", "global::MessagePack.Formatters.InterfaceReadOnlyListFormatter" }, - { "System.Collections.Generic.IReadOnlyCollection<>", "global::MessagePack.Formatters.InterfaceReadOnlyCollectionFormatter" }, - { "System.Collections.Generic.ISet<>", "global::MessagePack.Formatters.InterfaceSetFormatter" }, - { "System.Collections.Concurrent.ConcurrentBag<>", "global::MessagePack.Formatters.ConcurrentBagFormatter" }, - { "System.Collections.Concurrent.ConcurrentQueue<>", "global::MessagePack.Formatters.ConcurrentQueueFormatter" }, - { "System.Collections.Concurrent.ConcurrentStack<>", "global::MessagePack.Formatters.ConcurrentStackFormatter" }, - { "System.Collections.ObjectModel.ReadOnlyDictionary<,>", "global::MessagePack.Formatters.ReadOnlyDictionaryFormatter" }, - { "System.Collections.Generic.IReadOnlyDictionary<,>", "global::MessagePack.Formatters.InterfaceReadOnlyDictionaryFormatter" }, - { "System.Collections.Concurrent.ConcurrentDictionary<,>", "global::MessagePack.Formatters.ConcurrentDictionaryFormatter" }, - { "System.Lazy<>", "global::MessagePack.Formatters.LazyFormatter" }, - { "System.Threading.Tasks<>", "global::MessagePack.Formatters.TaskValueFormatter" }, - - { "System.Tuple<>", "global::MessagePack.Formatters.TupleFormatter" }, - { "System.Tuple<,>", "global::MessagePack.Formatters.TupleFormatter" }, - { "System.Tuple<,,>", "global::MessagePack.Formatters.TupleFormatter" }, - { "System.Tuple<,,,>", "global::MessagePack.Formatters.TupleFormatter" }, - { "System.Tuple<,,,,>", "global::MessagePack.Formatters.TupleFormatter" }, - { "System.Tuple<,,,,,>", "global::MessagePack.Formatters.TupleFormatter" }, - { "System.Tuple<,,,,,,>", "global::MessagePack.Formatters.TupleFormatter" }, - { "System.Tuple<,,,,,,,>", "global::MessagePack.Formatters.TupleFormatter" }, - - { "System.ValueTuple<>", "global::MessagePack.Formatters.ValueTupleFormatter" }, - { "System.ValueTuple<,>", "global::MessagePack.Formatters.ValueTupleFormatter" }, - { "System.ValueTuple<,,>", "global::MessagePack.Formatters.ValueTupleFormatter" }, - { "System.ValueTuple<,,,>", "global::MessagePack.Formatters.ValueTupleFormatter" }, - { "System.ValueTuple<,,,,>", "global::MessagePack.Formatters.ValueTupleFormatter" }, - { "System.ValueTuple<,,,,,>", "global::MessagePack.Formatters.ValueTupleFormatter" }, - { "System.ValueTuple<,,,,,,>", "global::MessagePack.Formatters.ValueTupleFormatter" }, - { "System.ValueTuple<,,,,,,,>", "global::MessagePack.Formatters.ValueTupleFormatter" }, - - { "System.Collections.Generic.KeyValuePair<,>", "global::MessagePack.Formatters.KeyValuePairFormatter" }, - { "System.Threading.Tasks.ValueTask<>", "global::MessagePack.Formatters.KeyValuePairFormatter" }, - { "System.ArraySegment<>", "global::MessagePack.Formatters.ArraySegmentFormatter" }, + { "System.Collections.Generic.List<>", "MsgPack::Formatters.ListFormatter" }, + { "System.Collections.Generic.LinkedList<>", "MsgPack::Formatters.LinkedListFormatter" }, + { "System.Collections.Generic.Queue<>", "MsgPack::Formatters.QueueFormatter" }, + { "System.Collections.Generic.Stack<>", "MsgPack::Formatters.StackFormatter" }, + { "System.Collections.Generic.HashSet<>", "MsgPack::Formatters.HashSetFormatter" }, + { "System.Collections.ObjectModel.ReadOnlyCollection<>", "MsgPack::Formatters.ReadOnlyCollectionFormatter" }, + { "System.Collections.Generic.IList<>", "MsgPack::Formatters.InterfaceListFormatter2" }, + { "System.Collections.Generic.ICollection<>", "MsgPack::Formatters.InterfaceCollectionFormatter2" }, + { "System.Collections.Generic.IEnumerable<>", "MsgPack::Formatters.InterfaceEnumerableFormatter" }, + { "System.Collections.Generic.Dictionary<,>", "MsgPack::Formatters.DictionaryFormatter" }, + { "System.Collections.Generic.IDictionary<,>", "MsgPack::Formatters.InterfaceDictionaryFormatter" }, + { "System.Collections.Generic.SortedDictionary<,>", "MsgPack::Formatters.SortedDictionaryFormatter" }, + { "System.Collections.Generic.SortedList<,>", "MsgPack::Formatters.SortedListFormatter" }, + { "System.Linq.ILookup<,>", "MsgPack::Formatters.InterfaceLookupFormatter" }, + { "System.Linq.IGrouping<,>", "MsgPack::Formatters.InterfaceGroupingFormatter" }, + { "System.Collections.ObjectModel.ObservableCollection<>", "MsgPack::Formatters.ObservableCollectionFormatter" }, + { "System.Collections.ObjectModel.ReadOnlyObservableCollection<>", "MsgPack::Formatters.ReadOnlyObservableCollectionFormatter" }, + { "System.Collections.Generic.IReadOnlyList<>", "MsgPack::Formatters.InterfaceReadOnlyListFormatter" }, + { "System.Collections.Generic.IReadOnlyCollection<>", "MsgPack::Formatters.InterfaceReadOnlyCollectionFormatter" }, + { "System.Collections.Generic.ISet<>", "MsgPack::Formatters.InterfaceSetFormatter" }, + { "System.Collections.Concurrent.ConcurrentBag<>", "MsgPack::Formatters.ConcurrentBagFormatter" }, + { "System.Collections.Concurrent.ConcurrentQueue<>", "MsgPack::Formatters.ConcurrentQueueFormatter" }, + { "System.Collections.Concurrent.ConcurrentStack<>", "MsgPack::Formatters.ConcurrentStackFormatter" }, + { "System.Collections.ObjectModel.ReadOnlyDictionary<,>", "MsgPack::Formatters.ReadOnlyDictionaryFormatter" }, + { "System.Collections.Generic.IReadOnlyDictionary<,>", "MsgPack::Formatters.InterfaceReadOnlyDictionaryFormatter" }, + { "System.Collections.Concurrent.ConcurrentDictionary<,>", "MsgPack::Formatters.ConcurrentDictionaryFormatter" }, + { "System.Lazy<>", "MsgPack::Formatters.LazyFormatter" }, + { "System.Threading.Tasks<>", "MsgPack::Formatters.TaskValueFormatter" }, + + { "System.Tuple<>", "MsgPack::Formatters.TupleFormatter" }, + { "System.Tuple<,>", "MsgPack::Formatters.TupleFormatter" }, + { "System.Tuple<,,>", "MsgPack::Formatters.TupleFormatter" }, + { "System.Tuple<,,,>", "MsgPack::Formatters.TupleFormatter" }, + { "System.Tuple<,,,,>", "MsgPack::Formatters.TupleFormatter" }, + { "System.Tuple<,,,,,>", "MsgPack::Formatters.TupleFormatter" }, + { "System.Tuple<,,,,,,>", "MsgPack::Formatters.TupleFormatter" }, + { "System.Tuple<,,,,,,,>", "MsgPack::Formatters.TupleFormatter" }, + + { "System.ValueTuple<>", "MsgPack::Formatters.ValueTupleFormatter" }, + { "System.ValueTuple<,>", "MsgPack::Formatters.ValueTupleFormatter" }, + { "System.ValueTuple<,,>", "MsgPack::Formatters.ValueTupleFormatter" }, + { "System.ValueTuple<,,,>", "MsgPack::Formatters.ValueTupleFormatter" }, + { "System.ValueTuple<,,,,>", "MsgPack::Formatters.ValueTupleFormatter" }, + { "System.ValueTuple<,,,,,>", "MsgPack::Formatters.ValueTupleFormatter" }, + { "System.ValueTuple<,,,,,,>", "MsgPack::Formatters.ValueTupleFormatter" }, + { "System.ValueTuple<,,,,,,,>", "MsgPack::Formatters.ValueTupleFormatter" }, + + { "System.Collections.Generic.KeyValuePair<,>", "MsgPack::Formatters.KeyValuePairFormatter" }, + { "System.Threading.Tasks.ValueTask<>", "MsgPack::Formatters.KeyValuePairFormatter" }, + { "System.ArraySegment<>", "MsgPack::Formatters.ArraySegmentFormatter" }, // extensions - { "System.Collections.Immutable.ImmutableArray<>", "global::MessagePack.ImmutableCollection.ImmutableArrayFormatter" }, - { "System.Collections.Immutable.ImmutableList<>", "global::MessagePack.ImmutableCollection.ImmutableListFormatter" }, - { "System.Collections.Immutable.ImmutableDictionary<,>", "global::MessagePack.ImmutableCollection.ImmutableDictionaryFormatter" }, - { "System.Collections.Immutable.ImmutableHashSet<>", "global::MessagePack.ImmutableCollection.ImmutableHashSetFormatter" }, - { "System.Collections.Immutable.ImmutableSortedDictionary<,>", "global::MessagePack.ImmutableCollection.ImmutableSortedDictionaryFormatter" }, - { "System.Collections.Immutable.ImmutableSortedSet<>", "global::MessagePack.ImmutableCollection.ImmutableSortedSetFormatter" }, - { "System.Collections.Immutable.ImmutableQueue<>", "global::MessagePack.ImmutableCollection.ImmutableQueueFormatter" }, - { "System.Collections.Immutable.ImmutableStack<>", "global::MessagePack.ImmutableCollection.ImmutableStackFormatter" }, - { "System.Collections.Immutable.IImmutableList<>", "global::MessagePack.ImmutableCollection.InterfaceImmutableListFormatter" }, - { "System.Collections.Immutable.IImmutableDictionary<,>", "global::MessagePack.ImmutableCollection.InterfaceImmutableDictionaryFormatter" }, - { "System.Collections.Immutable.IImmutableQueue<>", "global::MessagePack.ImmutableCollection.InterfaceImmutableQueueFormatter" }, - { "System.Collections.Immutable.IImmutableSet<>", "global::MessagePack.ImmutableCollection.InterfaceImmutableSetFormatter" }, - { "System.Collections.Immutable.IImmutableStack<>", "global::MessagePack.ImmutableCollection.InterfaceImmutableStackFormatter" }, - - { "Reactive.Bindings.ReactiveProperty<>", "global::MessagePack.ReactivePropertyExtension.ReactivePropertyFormatter" }, - { "Reactive.Bindings.IReactiveProperty<>", "global::MessagePack.ReactivePropertyExtension.InterfaceReactivePropertyFormatter" }, - { "Reactive.Bindings.IReadOnlyReactiveProperty<>", "global::MessagePack.ReactivePropertyExtension.InterfaceReadOnlyReactivePropertyFormatter" }, - { "Reactive.Bindings.ReactiveCollection<>", "global::MessagePack.ReactivePropertyExtension.ReactiveCollectionFormatter" }, + { "System.Collections.Immutable.ImmutableArray<>", "MsgPack::ImmutableCollection.ImmutableArrayFormatter" }, + { "System.Collections.Immutable.ImmutableList<>", "MsgPack::ImmutableCollection.ImmutableListFormatter" }, + { "System.Collections.Immutable.ImmutableDictionary<,>", "MsgPack::ImmutableCollection.ImmutableDictionaryFormatter" }, + { "System.Collections.Immutable.ImmutableHashSet<>", "MsgPack::ImmutableCollection.ImmutableHashSetFormatter" }, + { "System.Collections.Immutable.ImmutableSortedDictionary<,>", "MsgPack::ImmutableCollection.ImmutableSortedDictionaryFormatter" }, + { "System.Collections.Immutable.ImmutableSortedSet<>", "MsgPack::ImmutableCollection.ImmutableSortedSetFormatter" }, + { "System.Collections.Immutable.ImmutableQueue<>", "MsgPack::ImmutableCollection.ImmutableQueueFormatter" }, + { "System.Collections.Immutable.ImmutableStack<>", "MsgPack::ImmutableCollection.ImmutableStackFormatter" }, + { "System.Collections.Immutable.IImmutableList<>", "MsgPack::ImmutableCollection.InterfaceImmutableListFormatter" }, + { "System.Collections.Immutable.IImmutableDictionary<,>", "MsgPack::ImmutableCollection.InterfaceImmutableDictionaryFormatter" }, + { "System.Collections.Immutable.IImmutableQueue<>", "MsgPack::ImmutableCollection.InterfaceImmutableQueueFormatter" }, + { "System.Collections.Immutable.IImmutableSet<>", "MsgPack::ImmutableCollection.InterfaceImmutableSetFormatter" }, + { "System.Collections.Immutable.IImmutableStack<>", "MsgPack::ImmutableCollection.InterfaceImmutableStackFormatter" }, + + { "Reactive.Bindings.ReactiveProperty<>", "MsgPack::ReactivePropertyExtension.ReactivePropertyFormatter" }, + { "Reactive.Bindings.IReactiveProperty<>", "MsgPack::ReactivePropertyExtension.InterfaceReactivePropertyFormatter" }, + { "Reactive.Bindings.IReadOnlyReactiveProperty<>", "MsgPack::ReactivePropertyExtension.InterfaceReadOnlyReactivePropertyFormatter" }, + { "Reactive.Bindings.ReactiveCollection<>", "MsgPack::ReactivePropertyExtension.ReactiveCollectionFormatter" }, #pragma warning restore SA1509 // Opening braces should not be preceded by blank line }; @@ -413,7 +413,11 @@ UnionSubTypeInfo UnionSubTypeInfoSelector(ImmutableArray x) return new UnionSubTypeInfo(key, typeName); } - var info = new UnionSerializationInfo(type.ContainingNamespace.IsGlobalNamespace ? null : type.ContainingNamespace.ToDisplayString(), type.Name, type.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat), unionAttrs.Select(UnionSubTypeInfoSelector).OrderBy(x => x.Key).ToArray()); + var info = new UnionSerializationInfo( + type.ContainingNamespace.IsGlobalNamespace ? null : type.ContainingNamespace.ToDisplayString(), + type.Name, + type.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat), + unionAttrs.Select(UnionSubTypeInfoSelector).OrderBy(x => x.Key).ToArray()); this.collectedUnionInfo.Add(info); } @@ -451,15 +455,15 @@ private void CollectArray(IArrayTypeSymbol array) string formatterName; if (array.IsSZArray) { - formatterName = "global::MessagePack.Formatters.ArrayFormatter<" + elementTypeDisplayName + ">"; + formatterName = "MsgPack::Formatters.ArrayFormatter<" + elementTypeDisplayName + ">"; } else { formatterName = array.Rank switch { - 2 => "global::MessagePack.Formatters.TwoDimensionalArrayFormatter<" + elementTypeDisplayName + ">", - 3 => "global::MessagePack.Formatters.ThreeDimensionalArrayFormatter<" + elementTypeDisplayName + ">", - 4 => "global::MessagePack.Formatters.FourDimensionalArrayFormatter<" + elementTypeDisplayName + ">", + 2 => "MsgPack::Formatters.TwoDimensionalArrayFormatter<" + elementTypeDisplayName + ">", + 3 => "MsgPack::Formatters.ThreeDimensionalArrayFormatter<" + elementTypeDisplayName + ">", + 4 => "MsgPack::Formatters.FourDimensionalArrayFormatter<" + elementTypeDisplayName + ">", _ => throw new InvalidOperationException("does not supports array dimension, " + fullName), }; } @@ -514,7 +518,7 @@ private void CollectGeneric(INamedTypeSymbol type) return; } - var info = new GenericSerializationInfo(type.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat), "global::MessagePack.Formatters.NullableFormatter<" + firstTypeArgument.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat) + ">", isOpenGenericType); + var info = new GenericSerializationInfo(type.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat), "MsgPack::Formatters.NullableFormatter<" + firstTypeArgument.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat) + ">", isOpenGenericType); this.collectedGenericInfo.Add(info); return; } @@ -602,7 +606,7 @@ private void CollectGeneric(INamedTypeSymbol type) formatterBuilder.Append('>'); - var genericSerializationInfo = new GenericSerializationInfo(type.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat), formatterBuilder.ToString(), isOpenGenericType); + var genericSerializationInfo = new GenericSerializationInfo(type.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat), $"Formatters::{formatterBuilder}", isOpenGenericType); this.collectedGenericInfo.Add(genericSerializationInfo); } diff --git a/src/MessagePack.Generator/CodeAnalysis/UnionSerializationInfo.cs b/src/MessagePack.Generator/CodeAnalysis/UnionSerializationInfo.cs index b0626e078..3165877e3 100644 --- a/src/MessagePack.Generator/CodeAnalysis/UnionSerializationInfo.cs +++ b/src/MessagePack.Generator/CodeAnalysis/UnionSerializationInfo.cs @@ -9,5 +9,9 @@ public record UnionSerializationInfo( string FullName, UnionSubTypeInfo[] SubTypes) : IResolverRegisterInfo { - public string FormatterName => CodeAnalysisUtilities.QualifyWithOptionalNamespace(this.Name + "Formatter", this.Namespace); + public string FileNameHint => $"{CodeAnalysisUtilities.AppendNameToNamespace("Formatters", this.Namespace)}.{this.FormatterNameWithoutNamespace}"; + + public string FormatterName => CodeAnalysisUtilities.QualifyWithOptionalNamespace(FormatterNameWithoutNamespace, $"Formatters::{this.Namespace}"); + + public string FormatterNameWithoutNamespace => this.Name + "Formatter"; } diff --git a/src/MessagePack.Generator/Transforms/ResolverTemplate.cs b/src/MessagePack.Generator/Transforms/ResolverTemplate.cs index 0254f0f7c..a490462a4 100644 --- a/src/MessagePack.Generator/Transforms/ResolverTemplate.cs +++ b/src/MessagePack.Generator/Transforms/ResolverTemplate.cs @@ -86,7 +86,7 @@ static FormatterCache() for(var i = 0; i < RegisterInfos.Count; i++) { var x = RegisterInfos[i]; this.Write("\t\t\t\tcase "); this.Write(this.ToStringHelper.ToStringWithCulture(i)); - this.Write(": return new Formatters::"); + this.Write(": return new "); this.Write(this.ToStringHelper.ToStringWithCulture(x.FormatterName)); this.Write("();\r\n"); } diff --git a/src/MessagePack.Generator/Transforms/ResolverTemplate.tt b/src/MessagePack.Generator/Transforms/ResolverTemplate.tt index 12d5b95a8..8334a638f 100644 --- a/src/MessagePack.Generator/Transforms/ResolverTemplate.tt +++ b/src/MessagePack.Generator/Transforms/ResolverTemplate.tt @@ -67,7 +67,7 @@ namespace <#= ResolverNamespace #> switch (key) { <# for(var i = 0; i < RegisterInfos.Count; i++) { var x = RegisterInfos[i]; #> - case <#= i #>: return new Formatters::<#= x.FormatterName #>(); + case <#= i #>: return new <#= x.FormatterName #>(); <# } #> default: return null; } diff --git a/src/MessagePack.Generator/Transforms/TemplatePartials.cs b/src/MessagePack.Generator/Transforms/TemplatePartials.cs index 994132fb7..1b09ccd0f 100644 --- a/src/MessagePack.Generator/Transforms/TemplatePartials.cs +++ b/src/MessagePack.Generator/Transforms/TemplatePartials.cs @@ -22,7 +22,7 @@ public FormatterTemplate(AnalyzerOptions options, ObjectSerializationInfo info) public ObjectSerializationInfo Info { get; } - public string FileName => $"{CodeAnalysisUtilities.QualifyWithOptionalNamespace(this.Info.FormatterName, this.Options.FormatterNamespace)}.g.cs"; + public string FileName => $"{this.Info.FileNameHint}.g.cs"; } public partial class StringKeyFormatterTemplate : IFormatterTemplate @@ -40,7 +40,7 @@ public StringKeyFormatterTemplate(AnalyzerOptions options, ObjectSerializationIn public ObjectSerializationInfo Info { get; } - public string FileName => $"{CodeAnalysisUtilities.QualifyWithOptionalNamespace(this.Info.FormatterName, this.Options.FormatterNamespace)}.g.cs"; + public string FileName => $"{this.Info.FileNameHint}.g.cs"; } public partial class ResolverTemplate @@ -81,7 +81,7 @@ public EnumTemplate(AnalyzerOptions options, EnumSerializationInfo info) public EnumSerializationInfo Info { get; } - public string FileName => $"{CodeAnalysisUtilities.QualifyWithOptionalNamespace(this.Info.FormatterName, this.Options.FormatterNamespace)}.g.cs"; + public string FileName => $"{this.Info.FileNameHint}.g.cs"; } public partial class UnionTemplate @@ -99,5 +99,5 @@ public UnionTemplate(AnalyzerOptions options, UnionSerializationInfo info) public UnionSerializationInfo Info { get; } - public string FileName => $"{CodeAnalysisUtilities.QualifyWithOptionalNamespace(this.Info.FormatterName, this.Options.FormatterNamespace)}.g.cs"; + public string FileName => $"{this.Info.FileNameHint}.g.cs"; } diff --git a/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Resolvers/StandardResolver.cs b/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Resolvers/StandardResolver.cs index b245767a2..6beb2271f 100644 --- a/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Resolvers/StandardResolver.cs +++ b/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Resolvers/StandardResolver.cs @@ -109,9 +109,6 @@ public static class StandardAotResolver MessagePack.Unity.UnityResolver.Instance, #endif ImmutableCollection.ImmutableCollectionResolver.Instance, -#if !ENABLE_IL2CPP - DynamicGenericResolver.Instance, // Try Array, Tuple, Collection, Enum(Generic Fallback) -#endif }); } diff --git a/tests/MessagePack.Generator.Tests/GenerationTests.cs b/tests/MessagePack.Generator.Tests/GenerationTests.cs index 7c3ff5e9f..bc231c50f 100644 --- a/tests/MessagePack.Generator.Tests/GenerationTests.cs +++ b/tests/MessagePack.Generator.Tests/GenerationTests.cs @@ -96,4 +96,25 @@ internal class MyMessagePackObject await VerifyCS.Test.RunDefaultAsync(testSource, testMethod: $"{nameof(UnionFormatter)}({container})"); } + + [Fact] + public async Task ArrayTypedProperty() + { + string testSource = """ +using MessagePack; + +[MessagePackObject] +internal class ContainerObject +{ + [Key(0)] + internal SubObject[] ArrayOfCustomObjects { get; set; } +} + +[MessagePackObject] +internal class SubObject +{ +} +"""; + await VerifyCS.Test.RunDefaultAsync(testSource); + } } diff --git a/tests/MessagePack.Generator.Tests/Resources/ArrayTypedProperty/Formatters.ContainerObjectFormatter.g.cs b/tests/MessagePack.Generator.Tests/Resources/ArrayTypedProperty/Formatters.ContainerObjectFormatter.g.cs new file mode 100644 index 000000000..00d014009 --- /dev/null +++ b/tests/MessagePack.Generator.Tests/Resources/ArrayTypedProperty/Formatters.ContainerObjectFormatter.g.cs @@ -0,0 +1,54 @@ +// + +#pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 + +namespace Formatters +{ + using MsgPack = global::MessagePack; + + internal sealed class ContainerObjectFormatter : MsgPack::Formatters.IMessagePackFormatter + { + + public void Serialize(ref MsgPack::MessagePackWriter writer, global::ContainerObject value, MsgPack::MessagePackSerializerOptions options) + { + if (value == null) + { + writer.WriteNil(); + return; + } + + MsgPack::IFormatterResolver formatterResolver = options.Resolver; + writer.WriteArrayHeader(1); + MsgPack::FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Serialize(ref writer, value.ArrayOfCustomObjects, options); + } + + public global::ContainerObject Deserialize(ref MsgPack::MessagePackReader reader, MsgPack::MessagePackSerializerOptions options) + { + if (reader.TryReadNil()) + { + return null; + } + + options.Security.DepthStep(ref reader); + MsgPack::IFormatterResolver formatterResolver = options.Resolver; + var length = reader.ReadArrayHeader(); + var ____result = new global::ContainerObject(); + + for (int i = 0; i < length; i++) + { + switch (i) + { + case 0: + ____result.ArrayOfCustomObjects = MsgPack::FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Deserialize(ref reader, options); + break; + default: + reader.Skip(); + break; + } + } + + reader.Depth--; + return ____result; + } + } +} diff --git a/tests/MessagePack.Generator.Tests/Resources/ArrayTypedProperty/Formatters.SubObjectFormatter.g.cs b/tests/MessagePack.Generator.Tests/Resources/ArrayTypedProperty/Formatters.SubObjectFormatter.g.cs new file mode 100644 index 000000000..f8fa45ce1 --- /dev/null +++ b/tests/MessagePack.Generator.Tests/Resources/ArrayTypedProperty/Formatters.SubObjectFormatter.g.cs @@ -0,0 +1,34 @@ +// + +#pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 + +namespace Formatters +{ + using MsgPack = global::MessagePack; + + internal sealed class SubObjectFormatter : MsgPack::Formatters.IMessagePackFormatter + { + + public void Serialize(ref MsgPack::MessagePackWriter writer, global::SubObject value, MsgPack::MessagePackSerializerOptions options) + { + if (value == null) + { + writer.WriteNil(); + return; + } + + writer.WriteArrayHeader(0); + } + + public global::SubObject Deserialize(ref MsgPack::MessagePackReader reader, MsgPack::MessagePackSerializerOptions options) + { + if (reader.TryReadNil()) + { + return null; + } + + reader.Skip(); + return new global::SubObject(); + } + } +} diff --git a/tests/MessagePack.Generator.Tests/Resources/ArrayTypedProperty/MessagePack.GeneratedMessagePackResolver.g.cs b/tests/MessagePack.Generator.Tests/Resources/ArrayTypedProperty/MessagePack.GeneratedMessagePackResolver.g.cs new file mode 100644 index 000000000..6dba79ef5 --- /dev/null +++ b/tests/MessagePack.Generator.Tests/Resources/ArrayTypedProperty/MessagePack.GeneratedMessagePackResolver.g.cs @@ -0,0 +1,74 @@ +// + +#pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 + +namespace MessagePack +{ + using MsgPack = global::MessagePack; + using Formatters = global::Formatters; + + /// A MessagePack resolver that uses generated formatters for types in this assembly. + internal class GeneratedMessagePackResolver : MsgPack::IFormatterResolver + { + /// An instance of this resolver that only returns formatters specifically generated for types in this assembly. + public static readonly MsgPack::IFormatterResolver Instance = new GeneratedMessagePackResolver(); + + /// An instance of this resolver that returns standard AOT-compatible formatters as well as formatters specifically generated for types in this assembly. + public static readonly MsgPack::IFormatterResolver InstanceWithStandardAotResolver = MsgPack::Resolvers.CompositeResolver.Create(Instance, MsgPack::Resolvers.StandardAotResolver.Instance); + + private GeneratedMessagePackResolver() + { + } + + public MsgPack::Formatters.IMessagePackFormatter GetFormatter() + { + return FormatterCache.Formatter; + } + + private static class FormatterCache + { + internal static readonly MsgPack::Formatters.IMessagePackFormatter Formatter; + + static FormatterCache() + { + var f = GeneratedMessagePackResolverGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + Formatter = (MsgPack::Formatters.IMessagePackFormatter)f; + } + } + } + } + + internal static class GeneratedMessagePackResolverGetFormatterHelper + { + private static readonly global::System.Collections.Generic.Dictionary lookup; + + static GeneratedMessagePackResolverGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(3) + { + { typeof(global::SubObject[]), 0 }, + { typeof(global::ContainerObject), 1 }, + { typeof(global::SubObject), 2 }, + }; + } + + internal static object GetFormatter(global::System.Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + case 0: return new MsgPack::Formatters.ArrayFormatter(); + case 1: return new Formatters::ContainerObjectFormatter(); + case 2: return new Formatters::SubObjectFormatter(); + default: return null; + } + } + } +} diff --git a/tests/MessagePack.Generator.Tests/Verifiers/CSharpSourceGeneratorVerifier`1+Test.cs b/tests/MessagePack.Generator.Tests/Verifiers/CSharpSourceGeneratorVerifier`1+Test.cs index b53ec1874..f67a6bc6f 100644 --- a/tests/MessagePack.Generator.Tests/Verifiers/CSharpSourceGeneratorVerifier`1+Test.cs +++ b/tests/MessagePack.Generator.Tests/Verifiers/CSharpSourceGeneratorVerifier`1+Test.cs @@ -73,7 +73,7 @@ public static async Task RunDefaultAsync(string testSource, AnalyzerOptions? opt { Sources = { testSource }, }, - Options = options ?? AnalyzerOptions.Default, + Options = options ?? AnalyzerOptions.Default with { ProjectRootNamespace = "TestRootNamespace" }, }.RunAsync(); } From c2920ef198771698bf3a3b3263456454b09c938a Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Thu, 30 Mar 2023 16:46:54 -0600 Subject: [PATCH 064/660] Test and fix generic type formatter generation --- .../CodeAnalysis/CodeAnalysisUtilities.cs | 11 +++ .../MessagePackGenerator.Emit.cs | 2 +- .../GenerationTests.cs | 24 +++++++ .../Formatters.ContainerObjectFormatter.g.cs | 54 ++++++++++++++ .../Formatters.MyGenericTypeFormatter_T_.g.cs | 54 ++++++++++++++ ...sagePack.GeneratedMessagePackResolver.g.cs | 72 +++++++++++++++++++ 6 files changed, 216 insertions(+), 1 deletion(-) create mode 100644 tests/MessagePack.Generator.Tests/Resources/GenericType/Formatters.ContainerObjectFormatter.g.cs create mode 100644 tests/MessagePack.Generator.Tests/Resources/GenericType/Formatters.MyGenericTypeFormatter_T_.g.cs create mode 100644 tests/MessagePack.Generator.Tests/Resources/GenericType/MessagePack.GeneratedMessagePackResolver.g.cs diff --git a/src/MessagePack.Generator/CodeAnalysis/CodeAnalysisUtilities.cs b/src/MessagePack.Generator/CodeAnalysis/CodeAnalysisUtilities.cs index d2ff319b7..6b2705696 100644 --- a/src/MessagePack.Generator/CodeAnalysis/CodeAnalysisUtilities.cs +++ b/src/MessagePack.Generator/CodeAnalysis/CodeAnalysisUtilities.cs @@ -14,4 +14,15 @@ internal static string AppendNameToNamespace(string left, string? right) { return string.IsNullOrEmpty(right) ? left : $"{left}.{right}"; } + + internal static string GetSanitizedFileName(string fileName) + { + char[] invalidChars = Path.GetInvalidFileNameChars(); + foreach (char c in invalidChars) + { + fileName = fileName.Replace(c, '_'); + } + + return fileName; + } } diff --git a/src/MessagePack.Generator/MessagePackGenerator.Emit.cs b/src/MessagePack.Generator/MessagePackGenerator.Emit.cs index 280f0c1fc..21928734f 100644 --- a/src/MessagePack.Generator/MessagePackGenerator.Emit.cs +++ b/src/MessagePack.Generator/MessagePackGenerator.Emit.cs @@ -51,7 +51,7 @@ void AddTransform(string transformOutput, string uniqueFileName) sb.Clear(); sb.AppendLine(FileHeader); sb.Append(transformOutput); - context.AddSource(uniqueFileName, sb.ToString()); + context.AddSource(CodeAnalysisUtilities.GetSanitizedFileName(uniqueFileName), sb.ToString()); sb.Clear(); } } diff --git a/tests/MessagePack.Generator.Tests/GenerationTests.cs b/tests/MessagePack.Generator.Tests/GenerationTests.cs index bc231c50f..128dfba16 100644 --- a/tests/MessagePack.Generator.Tests/GenerationTests.cs +++ b/tests/MessagePack.Generator.Tests/GenerationTests.cs @@ -114,6 +114,30 @@ internal class ContainerObject internal class SubObject { } +"""; + await VerifyCS.Test.RunDefaultAsync(testSource); + } + + [Fact] + public async Task GenericType() + { + string testSource = """ +using MessagePack; +using System; + +[MessagePackObject] +internal class ContainerObject +{ + [Key(0)] + internal MyGenericType TupleProperty { get; set; } +} + +[MessagePackObject] +internal class MyGenericType +{ + [Key(0)] + internal T Value { get; set; } +} """; await VerifyCS.Test.RunDefaultAsync(testSource); } diff --git a/tests/MessagePack.Generator.Tests/Resources/GenericType/Formatters.ContainerObjectFormatter.g.cs b/tests/MessagePack.Generator.Tests/Resources/GenericType/Formatters.ContainerObjectFormatter.g.cs new file mode 100644 index 000000000..85ba4f7b2 --- /dev/null +++ b/tests/MessagePack.Generator.Tests/Resources/GenericType/Formatters.ContainerObjectFormatter.g.cs @@ -0,0 +1,54 @@ +// + +#pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 + +namespace Formatters +{ + using MsgPack = global::MessagePack; + + internal sealed class ContainerObjectFormatter : MsgPack::Formatters.IMessagePackFormatter + { + + public void Serialize(ref MsgPack::MessagePackWriter writer, global::ContainerObject value, MsgPack::MessagePackSerializerOptions options) + { + if (value == null) + { + writer.WriteNil(); + return; + } + + MsgPack::IFormatterResolver formatterResolver = options.Resolver; + writer.WriteArrayHeader(1); + MsgPack::FormatterResolverExtensions.GetFormatterWithVerify>(formatterResolver).Serialize(ref writer, value.TupleProperty, options); + } + + public global::ContainerObject Deserialize(ref MsgPack::MessagePackReader reader, MsgPack::MessagePackSerializerOptions options) + { + if (reader.TryReadNil()) + { + return null; + } + + options.Security.DepthStep(ref reader); + MsgPack::IFormatterResolver formatterResolver = options.Resolver; + var length = reader.ReadArrayHeader(); + var ____result = new global::ContainerObject(); + + for (int i = 0; i < length; i++) + { + switch (i) + { + case 0: + ____result.TupleProperty = MsgPack::FormatterResolverExtensions.GetFormatterWithVerify>(formatterResolver).Deserialize(ref reader, options); + break; + default: + reader.Skip(); + break; + } + } + + reader.Depth--; + return ____result; + } + } +} diff --git a/tests/MessagePack.Generator.Tests/Resources/GenericType/Formatters.MyGenericTypeFormatter_T_.g.cs b/tests/MessagePack.Generator.Tests/Resources/GenericType/Formatters.MyGenericTypeFormatter_T_.g.cs new file mode 100644 index 000000000..4a7c9e968 --- /dev/null +++ b/tests/MessagePack.Generator.Tests/Resources/GenericType/Formatters.MyGenericTypeFormatter_T_.g.cs @@ -0,0 +1,54 @@ +// + +#pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 + +namespace Formatters +{ + using MsgPack = global::MessagePack; + + internal sealed class MyGenericTypeFormatter : MsgPack::Formatters.IMessagePackFormatter> + { + + public void Serialize(ref MsgPack::MessagePackWriter writer, global::MyGenericType value, MsgPack::MessagePackSerializerOptions options) + { + if (value == null) + { + writer.WriteNil(); + return; + } + + MsgPack::IFormatterResolver formatterResolver = options.Resolver; + writer.WriteArrayHeader(1); + MsgPack::FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Serialize(ref writer, value.Value, options); + } + + public global::MyGenericType Deserialize(ref MsgPack::MessagePackReader reader, MsgPack::MessagePackSerializerOptions options) + { + if (reader.TryReadNil()) + { + return null; + } + + options.Security.DepthStep(ref reader); + MsgPack::IFormatterResolver formatterResolver = options.Resolver; + var length = reader.ReadArrayHeader(); + var ____result = new global::MyGenericType(); + + for (int i = 0; i < length; i++) + { + switch (i) + { + case 0: + ____result.Value = MsgPack::FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Deserialize(ref reader, options); + break; + default: + reader.Skip(); + break; + } + } + + reader.Depth--; + return ____result; + } + } +} diff --git a/tests/MessagePack.Generator.Tests/Resources/GenericType/MessagePack.GeneratedMessagePackResolver.g.cs b/tests/MessagePack.Generator.Tests/Resources/GenericType/MessagePack.GeneratedMessagePackResolver.g.cs new file mode 100644 index 000000000..a78f70bd4 --- /dev/null +++ b/tests/MessagePack.Generator.Tests/Resources/GenericType/MessagePack.GeneratedMessagePackResolver.g.cs @@ -0,0 +1,72 @@ +// + +#pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 + +namespace MessagePack +{ + using MsgPack = global::MessagePack; + using Formatters = global::Formatters; + + /// A MessagePack resolver that uses generated formatters for types in this assembly. + internal class GeneratedMessagePackResolver : MsgPack::IFormatterResolver + { + /// An instance of this resolver that only returns formatters specifically generated for types in this assembly. + public static readonly MsgPack::IFormatterResolver Instance = new GeneratedMessagePackResolver(); + + /// An instance of this resolver that returns standard AOT-compatible formatters as well as formatters specifically generated for types in this assembly. + public static readonly MsgPack::IFormatterResolver InstanceWithStandardAotResolver = MsgPack::Resolvers.CompositeResolver.Create(Instance, MsgPack::Resolvers.StandardAotResolver.Instance); + + private GeneratedMessagePackResolver() + { + } + + public MsgPack::Formatters.IMessagePackFormatter GetFormatter() + { + return FormatterCache.Formatter; + } + + private static class FormatterCache + { + internal static readonly MsgPack::Formatters.IMessagePackFormatter Formatter; + + static FormatterCache() + { + var f = GeneratedMessagePackResolverGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + Formatter = (MsgPack::Formatters.IMessagePackFormatter)f; + } + } + } + } + + internal static class GeneratedMessagePackResolverGetFormatterHelper + { + private static readonly global::System.Collections.Generic.Dictionary lookup; + + static GeneratedMessagePackResolverGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(2) + { + { typeof(global::MyGenericType), 0 }, + { typeof(global::ContainerObject), 1 }, + }; + } + + internal static object GetFormatter(global::System.Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + case 0: return new Formatters::MyGenericTypeFormatter(); + case 1: return new Formatters::ContainerObjectFormatter(); + default: return null; + } + } + } +} From 579552ed3cb8b7e14ed079333031db7b01fba7fc Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Thu, 30 Mar 2023 16:47:18 -0600 Subject: [PATCH 065/660] Get Sandbox, SharedData and their tests building and passing --- sandbox/Sandbox/Sandbox.csproj | 4 +++- sandbox/SharedData/SharedData.csproj | 7 ++++--- .../MissingPropertiesTest.cs | 7 +++++-- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/sandbox/Sandbox/Sandbox.csproj b/sandbox/Sandbox/Sandbox.csproj index 5ab57a0ce..7353010c0 100644 --- a/sandbox/Sandbox/Sandbox.csproj +++ b/sandbox/Sandbox/Sandbox.csproj @@ -1,9 +1,11 @@  + Exe net6.0 True + true @@ -16,8 +18,8 @@ - + diff --git a/sandbox/SharedData/SharedData.csproj b/sandbox/SharedData/SharedData.csproj index f0264075c..4cf40d8d1 100644 --- a/sandbox/SharedData/SharedData.csproj +++ b/sandbox/SharedData/SharedData.csproj @@ -1,13 +1,14 @@  + + netstandard2.0 + true - - - + diff --git a/tests/MessagePack.GeneratedCode.Tests/MissingPropertiesTest.cs b/tests/MessagePack.GeneratedCode.Tests/MissingPropertiesTest.cs index 0db93add3..73eb43f77 100644 --- a/tests/MessagePack.GeneratedCode.Tests/MissingPropertiesTest.cs +++ b/tests/MessagePack.GeneratedCode.Tests/MissingPropertiesTest.cs @@ -14,8 +14,11 @@ public class MissingPropertiesTest public MissingPropertiesTest() { - var resolver = CompositeResolver.Create(GeneratedResolver.Instance, StandardResolver.Instance); - options = MessagePackSerializerOptions.Standard.WithResolver(resolver); + options = MessagePackSerializerOptions.Standard.WithResolver( + CompositeResolver.Create( + Sandbox.GeneratedMessagePackResolver.Instance, + SharedData.GeneratedMessagePackResolver.Instance, + StandardAotResolver.Instance)); } [Fact] From 217313ab1e5e7de793a7473e43042d87551d3284 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Wed, 5 Apr 2023 10:41:52 -0600 Subject: [PATCH 066/660] Get analyzer tests passing --- Directory.Packages.props | 10 +++-- src/MessagePackAnalyzer/ReferenceSymbols.cs | 8 +--- src/MessagePackAnalyzer/TypeCollector.cs | 8 ++-- .../Helpers/CSharpCodeFixVerifier`2+Test.cs | 24 +++++++----- .../Helpers/ReferencesHelper.cs | 2 +- .../MessagePackAnalyzerTests.cs | 37 +++++++++++-------- 6 files changed, 49 insertions(+), 40 deletions(-) diff --git a/Directory.Packages.props b/Directory.Packages.props index 4857713f9..bc9f10212 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -8,7 +8,8 @@ 4.3.0 - 4.5.0 + 4.3.0 + 1.1.2-beta1.23163.2 @@ -28,12 +29,12 @@ - + - + - + @@ -44,6 +45,7 @@ + diff --git a/src/MessagePackAnalyzer/ReferenceSymbols.cs b/src/MessagePackAnalyzer/ReferenceSymbols.cs index 36787e73c..6ded9965f 100644 --- a/src/MessagePackAnalyzer/ReferenceSymbols.cs +++ b/src/MessagePackAnalyzer/ReferenceSymbols.cs @@ -15,7 +15,7 @@ private ReferenceSymbols( INamedTypeSymbol ignoreAttribute, INamedTypeSymbol formatterAttribute, INamedTypeSymbol messagePackFormatter, - INamedTypeSymbol ignoreDataMemberAttribute) + INamedTypeSymbol? ignoreDataMemberAttribute) { this.MessagePackObjectAttribute = messagePackObjectAttribute; this.UnionAttribute = unionAttribute; @@ -38,7 +38,7 @@ private ReferenceSymbols( internal INamedTypeSymbol MessagePackFormatter { get; } - internal INamedTypeSymbol IgnoreDataMemberAttribute { get; } + internal INamedTypeSymbol? IgnoreDataMemberAttribute { get; } public static bool TryCreate(Compilation compilation, [NotNullWhen(true)] out ReferenceSymbols? instance) { @@ -81,10 +81,6 @@ public static bool TryCreate(Compilation compilation, [NotNullWhen(true)] out Re } var ignoreDataMemberAttribute = compilation.GetTypeByMetadataName("System.Runtime.Serialization.IgnoreDataMemberAttribute"); - if (ignoreDataMemberAttribute is null) - { - return false; - } instance = new ReferenceSymbols( messagePackObjectAttribute, diff --git a/src/MessagePackAnalyzer/TypeCollector.cs b/src/MessagePackAnalyzer/TypeCollector.cs index 9fc8984fa..5f16569a5 100644 --- a/src/MessagePackAnalyzer/TypeCollector.cs +++ b/src/MessagePackAnalyzer/TypeCollector.cs @@ -220,7 +220,7 @@ private void CollectObject(INamedTypeSymbol type, ISymbol? callerSymbol) foreach (IPropertySymbol item in type.GetAllMembers().OfType()) { - if (item.GetAttributes().Any(x => SymbolEqualityComparer.Default.Equals(x.AttributeClass, this.typeReferences.IgnoreAttribute) || SymbolEqualityComparer.Default.Equals(x.AttributeClass, this.typeReferences.IgnoreDataMemberAttribute))) + if (item.GetAttributes().Any(x => SymbolEqualityComparer.Default.Equals(x.AttributeClass, this.typeReferences.IgnoreAttribute) || (this.typeReferences.IgnoreDataMemberAttribute is not null && SymbolEqualityComparer.Default.Equals(x.AttributeClass, this.typeReferences.IgnoreDataMemberAttribute)))) { continue; } @@ -239,7 +239,7 @@ private void CollectObject(INamedTypeSymbol type, ISymbol? callerSymbol) foreach (IFieldSymbol item in type.GetAllMembers().OfType()) { - if (item.GetAttributes().Any(x => SymbolEqualityComparer.Default.Equals(x.AttributeClass, this.typeReferences.IgnoreAttribute) || SymbolEqualityComparer.Default.Equals(x.AttributeClass, this.typeReferences.IgnoreDataMemberAttribute))) + if (item.GetAttributes().Any(x => SymbolEqualityComparer.Default.Equals(x.AttributeClass, this.typeReferences.IgnoreAttribute) || (this.typeReferences.IgnoreDataMemberAttribute is not null && SymbolEqualityComparer.Default.Equals(x.AttributeClass, this.typeReferences.IgnoreDataMemberAttribute)))) { continue; } @@ -268,7 +268,7 @@ private void CollectObject(INamedTypeSymbol type, ISymbol? callerSymbol) foreach (IPropertySymbol item in type.GetAllMembers().OfType()) { - if (item.GetAttributes().Any(x => SymbolEqualityComparer.Default.Equals(x.AttributeClass, this.typeReferences.IgnoreAttribute) || SymbolEqualityComparer.Default.Equals(x.AttributeClass, this.typeReferences.IgnoreDataMemberAttribute))) + if (item.GetAttributes().Any(x => SymbolEqualityComparer.Default.Equals(x.AttributeClass, this.typeReferences.IgnoreAttribute) || (this.typeReferences.IgnoreDataMemberAttribute is not null && SymbolEqualityComparer.Default.Equals(x.AttributeClass, this.typeReferences.IgnoreDataMemberAttribute)))) { continue; } @@ -337,7 +337,7 @@ private void CollectObject(INamedTypeSymbol type, ISymbol? callerSymbol) foreach (IFieldSymbol item in type.GetAllMembers().OfType()) { - if (item.GetAttributes().Any(x => SymbolEqualityComparer.Default.Equals(x.AttributeClass, this.typeReferences.IgnoreAttribute) || SymbolEqualityComparer.Default.Equals(x.AttributeClass, this.typeReferences.IgnoreDataMemberAttribute))) + if (item.GetAttributes().Any(x => SymbolEqualityComparer.Default.Equals(x.AttributeClass, this.typeReferences.IgnoreAttribute) || (this.typeReferences.IgnoreDataMemberAttribute is not null && SymbolEqualityComparer.Default.Equals(x.AttributeClass, this.typeReferences.IgnoreDataMemberAttribute)))) { continue; } diff --git a/tests/MessagePackAnalyzer.Tests/Helpers/CSharpCodeFixVerifier`2+Test.cs b/tests/MessagePackAnalyzer.Tests/Helpers/CSharpCodeFixVerifier`2+Test.cs index e56501516..834dfe0bc 100644 --- a/tests/MessagePackAnalyzer.Tests/Helpers/CSharpCodeFixVerifier`2+Test.cs +++ b/tests/MessagePackAnalyzer.Tests/Helpers/CSharpCodeFixVerifier`2+Test.cs @@ -19,16 +19,7 @@ public class Test : CSharpCodeFixTest public Test() { this.ReferenceAssemblies = ReferencesHelper.DefaultReferences; - this.TestBehaviors |= Microsoft.CodeAnalysis.Testing.TestBehaviors.SkipGeneratedCodeCheck; - - this.SolutionTransforms.Add((solution, projectId) => - { - var parseOptions = (CSharpParseOptions?)solution.GetProject(projectId)?.ParseOptions; - Assert.NotNull(parseOptions); - solution = solution.WithProjectParseOptions(projectId, parseOptions.WithLanguageVersion(LanguageVersion.CSharp7_3)); - - return solution; - }); + this.CompilerDiagnostics = Microsoft.CodeAnalysis.Testing.CompilerDiagnostics.Warnings; this.TestState.AdditionalFilesFactories.Add(() => { @@ -40,6 +31,19 @@ where resourceName.StartsWith(additionalFilePrefix, StringComparison.Ordinal) }); } + protected override ParseOptions CreateParseOptions() + { + return ((CSharpParseOptions)base.CreateParseOptions()).WithLanguageVersion(LanguageVersion.CSharp10); + } + + protected override CompilationOptions CreateCompilationOptions() + { + var compilationOptions = (CSharpCompilationOptions)base.CreateCompilationOptions(); + return compilationOptions + .WithWarningLevel(99) + .WithSpecificDiagnosticOptions(compilationOptions.SpecificDiagnosticOptions.SetItem("CS1591", ReportDiagnostic.Suppress)); + } + private static string ReadManifestResource(Assembly assembly, string resourceName) { using (var reader = new StreamReader(assembly.GetManifestResourceStream(resourceName) ?? throw new ArgumentException("No such resource stream", nameof(resourceName)))) diff --git a/tests/MessagePackAnalyzer.Tests/Helpers/ReferencesHelper.cs b/tests/MessagePackAnalyzer.Tests/Helpers/ReferencesHelper.cs index ea48105dc..0b2885331 100644 --- a/tests/MessagePackAnalyzer.Tests/Helpers/ReferencesHelper.cs +++ b/tests/MessagePackAnalyzer.Tests/Helpers/ReferencesHelper.cs @@ -7,6 +7,6 @@ internal static class ReferencesHelper { internal static ReferenceAssemblies DefaultReferences = ReferenceAssemblies.NetFramework.Net472.Default - .WithPackages(ImmutableArray.Create( + .AddPackages(ImmutableArray.Create( new PackageIdentity("MessagePack", "2.0.335"))); } diff --git a/tests/MessagePackAnalyzer.Tests/MessagePackAnalyzerTests.cs b/tests/MessagePackAnalyzer.Tests/MessagePackAnalyzerTests.cs index 8fc4c65f9..dfaed11be 100644 --- a/tests/MessagePackAnalyzer.Tests/MessagePackAnalyzerTests.cs +++ b/tests/MessagePackAnalyzer.Tests/MessagePackAnalyzerTests.cs @@ -155,33 +155,30 @@ public class Bar [Fact] public async Task CodeFixAppliesAcrossFiles() { - var inputs = new string[] - { - @" + string source1 = @" public class Foo { public int {|MsgPack004:Member1|} { get; set; } } -", - @"using MessagePack; +"; + + string source2 = @"using MessagePack; [MessagePackObject] public class Bar : Foo { public int {|MsgPack004:Member2|} { get; set; } } -", - }; - var outputs = new string[] - { - @" +"; + + string output1 = @" public class Foo { [MessagePack.Key(1)] public int Member1 { get; set; } } -", - @"using MessagePack; +"; + string output2 = @"using MessagePack; [MessagePackObject] public class Bar : Foo @@ -189,9 +186,19 @@ public class Bar : Foo [Key(0)] public int Member2 { get; set; } } -", - }; +"; - await VerifyCS.VerifyCodeFixAsync(inputs, outputs); + await new VerifyCS.Test + { + CodeFixTestBehaviors = CodeFixTestBehaviors.SkipLocalDiagnosticCheck, // BUGBUG: move diagnostic to `Foo` reference in Bar's base type list. + TestState = + { + Sources = { source1, source2 }, + }, + FixedState = + { + Sources = { output1, output2 }, + }, + }.RunAsync(); } } From 48cbbac8485b2c1abdcec496f295777cd6ab0d92 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Wed, 5 Apr 2023 10:49:20 -0600 Subject: [PATCH 067/660] Drop codegen_diff job in Azure Pipelines We don't need it any more since the code is generated during compilation. --- azure-pipelines/build.yml | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/azure-pipelines/build.yml b/azure-pipelines/build.yml index 4021879d8..d5c5635f7 100644 --- a/azure-pipelines/build.yml +++ b/azure-pipelines/build.yml @@ -49,26 +49,6 @@ jobs: parameters: RunTests: ${{ parameters.RunTests }} -# This job ensures that we're running mpc regularly on the generated code that we check in. -# It also helps exercise mpc so bugs don't go unnoticed. -- job: codegen_diff - pool: - vmImage: ubuntu-22.04 - steps: - - checkout: self - clean: true - - template: install-dependencies.yml - - pwsh: sandbox/codegen.ps1 - displayName: 🏭 Regenerate checked-in code - - bash: | - git add -u . # compare after applying git EOL normalization - git diff --cached --exit-code --stat \ - || (echo "##[error] found changed files after build. Please run 'sandbox/codegen.ps1'" \ - "and check in all changes" \ - && git diff --cached \ - && exit 1) - displayName: 🔍 Check for uncommitted changes - - job: WrapUp dependsOn: - Windows From a1686508ae9a287f65880797267f61c1968b8807 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Wed, 5 Apr 2023 11:35:37 -0600 Subject: [PATCH 068/660] Fix generation on linux --- .../CodeAnalysis/CodeAnalysisUtilities.cs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/MessagePack.Generator/CodeAnalysis/CodeAnalysisUtilities.cs b/src/MessagePack.Generator/CodeAnalysis/CodeAnalysisUtilities.cs index 6b2705696..70675b330 100644 --- a/src/MessagePack.Generator/CodeAnalysis/CodeAnalysisUtilities.cs +++ b/src/MessagePack.Generator/CodeAnalysis/CodeAnalysisUtilities.cs @@ -5,6 +5,15 @@ namespace MessagePack.Generator.CodeAnalysis; internal static class CodeAnalysisUtilities { + private static readonly HashSet InvalidFileNameChars = new(Path.GetInvalidFileNameChars()); + + static CodeAnalysisUtilities() + { + // Roslyn really doesn't like angle brackets in file names, even on operating systems that allow them (e.g. linux). + InvalidFileNameChars.Add('<'); + InvalidFileNameChars.Add('>'); + } + internal static string QualifyWithOptionalNamespace(string leafTypeOrNamespace, string? baseNamespace) { return string.IsNullOrEmpty(baseNamespace) ? leafTypeOrNamespace : (baseNamespace!.EndsWith("::") ? $"{baseNamespace}{leafTypeOrNamespace}" : $"{baseNamespace}.{leafTypeOrNamespace}"); @@ -17,8 +26,7 @@ internal static string AppendNameToNamespace(string left, string? right) internal static string GetSanitizedFileName(string fileName) { - char[] invalidChars = Path.GetInvalidFileNameChars(); - foreach (char c in invalidChars) + foreach (char c in InvalidFileNameChars) { fileName = fileName.Replace(c, '_'); } From d0bcb3d89577b36dea620d606a08c6d405f02ed7 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Wed, 5 Apr 2023 11:36:44 -0600 Subject: [PATCH 069/660] Add Directory.Packages.props as a solution item --- MessagePack.sln | 1 + 1 file changed, 1 insertion(+) diff --git a/MessagePack.sln b/MessagePack.sln index d418d7b99..530c8b42b 100644 --- a/MessagePack.sln +++ b/MessagePack.sln @@ -56,6 +56,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "build", "build", "{301F812B azure-pipelines.yml = azure-pipelines.yml azure-pipelines\build.yml = azure-pipelines\build.yml Directory.Build.props = Directory.Build.props + Directory.Packages.props = Directory.Packages.props global.json = global.json nuget.config = nuget.config stylecop.json = stylecop.json From 43f67ba6c79cc7d27a5ed97c7fb50b172cfa79e9 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Wed, 5 Apr 2023 11:54:39 -0600 Subject: [PATCH 070/660] Fix line endings so they are consistent across OSs --- src/MessagePack.Generator/Transforms/.gitattributes | 3 +++ tests/MessagePack.Generator.Tests/Resources/.gitattributes | 2 ++ 2 files changed, 5 insertions(+) create mode 100644 src/MessagePack.Generator/Transforms/.gitattributes create mode 100644 tests/MessagePack.Generator.Tests/Resources/.gitattributes diff --git a/src/MessagePack.Generator/Transforms/.gitattributes b/src/MessagePack.Generator/Transforms/.gitattributes new file mode 100644 index 000000000..5d5e98bd2 --- /dev/null +++ b/src/MessagePack.Generator/Transforms/.gitattributes @@ -0,0 +1,3 @@ +# Always check out .tt files with CRLF line endings so the code-behind file, which captures these, remains consistent with the .tt file. +# LF line endings don't trigger T4's automatic empty line removal, so CRLF is preferable. +*.tt eol=crlf diff --git a/tests/MessagePack.Generator.Tests/Resources/.gitattributes b/tests/MessagePack.Generator.Tests/Resources/.gitattributes new file mode 100644 index 000000000..5e765d624 --- /dev/null +++ b/tests/MessagePack.Generator.Tests/Resources/.gitattributes @@ -0,0 +1,2 @@ +# Always check out recorded files with CRLF line endings to match what the source generator is expected to produce. +*.g.cs eol=crlf From f5979be3aeae6261d6a587e0afdd57c717e2c31c Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Wed, 5 Apr 2023 12:11:09 -0600 Subject: [PATCH 071/660] Update UnsafeMemory.tt to match a change manually made to its generated file --- src/MessagePack/Internal/UnsafeMemory.tt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/MessagePack/Internal/UnsafeMemory.tt b/src/MessagePack/Internal/UnsafeMemory.tt index cace009d7..416acb2a2 100644 --- a/src/MessagePack/Internal/UnsafeMemory.tt +++ b/src/MessagePack/Internal/UnsafeMemory.tt @@ -15,6 +15,8 @@ #if !UNITY_2018_3_OR_NEWER +#pragma warning disable SA1402 // File may only contain a single type + using System; using System.Buffers; using System.Runtime.CompilerServices; From 0f0603232c447f9c72960cd88bc9fc1929af35c5 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Wed, 5 Apr 2023 12:29:54 -0600 Subject: [PATCH 072/660] Fix more line ending issues --- src/MessagePack.Generator/MessagePackGenerator.Emit.cs | 9 +++++---- src/MessagePack.Generator/Transforms/.gitattributes | 3 +++ 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/MessagePack.Generator/MessagePackGenerator.Emit.cs b/src/MessagePack.Generator/MessagePackGenerator.Emit.cs index 21928734f..71b73c2cb 100644 --- a/src/MessagePack.Generator/MessagePackGenerator.Emit.cs +++ b/src/MessagePack.Generator/MessagePackGenerator.Emit.cs @@ -10,11 +10,12 @@ namespace MessagePack.Generator; public partial class MessagePackGenerator { - private const string FileHeader = """ + private static readonly string FileHeader = """ // #pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 -"""; + +""".Replace(Environment.NewLine, "\r\n"); /// /// Generates the specialized resolver and formatters for the types that require serialization in a given compilation. @@ -49,7 +50,7 @@ private static void Generate(IGeneratorContext context, FullModel model) void AddTransform(string transformOutput, string uniqueFileName) { sb.Clear(); - sb.AppendLine(FileHeader); + sb.Append(FileHeader); sb.Append(transformOutput); context.AddSource(CodeAnalysisUtilities.GetSanitizedFileName(uniqueFileName), sb.ToString()); sb.Clear(); @@ -74,7 +75,7 @@ private static void GenerateResolver(IGeneratorContext context, FullModel model) .Concat(model.ObjectInfos.Where(x => !x.IsOpenGenericType)) .ToArray(); ResolverTemplate resolverTemplate = new(options, registerInfos); - sb.AppendLine(FileHeader); + sb.Append(FileHeader); sb.Append(resolverTemplate.TransformText()); context.AddSource(resolverTemplate.FileName, sb.ToString()); } diff --git a/src/MessagePack.Generator/Transforms/.gitattributes b/src/MessagePack.Generator/Transforms/.gitattributes index 5d5e98bd2..f707ed105 100644 --- a/src/MessagePack.Generator/Transforms/.gitattributes +++ b/src/MessagePack.Generator/Transforms/.gitattributes @@ -1,3 +1,6 @@ # Always check out .tt files with CRLF line endings so the code-behind file, which captures these, remains consistent with the .tt file. # LF line endings don't trigger T4's automatic empty line removal, so CRLF is preferable. *.tt eol=crlf + +# Even the T4-generated transform source can include line endings within C# strings, so we need to ensure that the .cs files are checked out with CRLF line endings too. +*.cs eol=crlf From 91616ea4293127ffc3397c17a8d733ea2e5d3ac3 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Wed, 5 Apr 2023 14:42:29 -0600 Subject: [PATCH 073/660] Touch-ups --- README.md | 75 ++++++++++++++----- doc/msbuildtask.md | 59 --------------- .../CodeAnalysis/CodeAnalysisUtilities.cs | 1 + .../Utils/RoslynExtensions.cs | 16 +--- .../Resolvers/StaticCompositeResolver.cs | 11 --- .../Utils/RoslynAnalyzerExtensions.cs | 18 ----- .../TestUtilities.cs | 20 ----- 7 files changed, 60 insertions(+), 140 deletions(-) delete mode 100644 doc/msbuildtask.md diff --git a/README.md b/README.md index b187f7896..699a10dd7 100644 --- a/README.md +++ b/README.md @@ -1576,7 +1576,8 @@ If you want to share a class between Unity and a server, you can use `SharedProj ## AOT Code Generation (support for Unity/Xamarin) -By default, MessagePack for C# serializes custom objects by [generating IL](https://msdn.microsoft.com/en-us/library/system.reflection.emit.ilgenerator.aspx) on the fly at runtime to create custom, highly tuned formatters for each type. This code generation has a minor upfront performance cost. +By default, MessagePack for C# serializes custom objects by [generating IL](https://learn.microsoft.com/dotnet/api/system.reflection.emit.ilgenerator) on the fly at runtime to create custom, highly tuned formatters for each type. +This code generation has a minor upfront performance cost. Because strict-AOT environments such as Xamarin and Unity IL2CPP forbid runtime code generation, MessagePack provides a way for you to run a code generator ahead of time as well. > Note: When using Unity, dynamic code generation only works when targeting .NET Framework 4.x + mono runtime. @@ -1584,11 +1585,62 @@ For all other Unity targets, AOT is required. If you want to avoid the upfront dynamic generation cost or you need to run on Xamarin or Unity, you need AOT code generation. -``` +```ps1 dotnet add package MessagePack.Generator ``` -The source generator generates the resolver as `MessagePack.Resolvers.GeneratedResolver` and formatters as`MessagePack.Formatters.*`. +This package adds a roslyn Source Generator that produces `IMessagePackFormatter` implementing classes for each of your `[MessagePackObject]` classes. + +These formatters are aggregated into a generated `IMessagePackResolver` class named `GeneratedMessagePackResolver`. +This class will be generated into the `$(RootNamespace)` of your project, or the `MessagePack` namespace if `RootNamespace` is empty or undefined. + +Leveraging these formatters at runtime requires that you opt-in, which typically looks like this: + +```cs +/// Options to use MessagePack with AOT-generated formatters. +private static readonly MessagePackSerializerOptions SerializerOptions = MessagePackSerializerOptions.Standard + .WithResolver(GeneratedMessagePackResolver.InstanceWithStandardAotResolver); + +// Serialize and deserialize using the AOT option. +byte[] serialized = MessagePackSerializer.Serialize(value, SerializerOptions); +T after = MessagePackSerializer.Deserialize(serialized, SerializerOptions); +``` + +Alternatively if you run in a highly-focused process, you can set the default options, and then use the simpler overloads to serialize. +Do NOT do this if you're in a shared process where other code may be using MessagePack with their own options. + +```cs +MessagePackSerializer.DefaultOptions = SerializerOptions; // WARNING: mutates a static shared by all MessagePack users in the process +byte[] serialized = MessagePackSerializer.Serialize(value); +T after = MessagePackSerializer.Deserialize(serialized); +``` + +### Customizations + +A few MSBuild properties can be set in your project to customize source generation: + +Property | Purpose | Default value +--|--|-- +`PublicMessagePackGeneratedResolver` | A boolean value indicating whether the generated resolver should be `public`. This is useful for shared libraries so their consumers can leverage the AOT formatters (which are always `internal`) in the library. | `false` +`MessagePackGeneratedResolverNamespace` | The namespace to use for the generated resolver class. | The `$(RootNamespace)` of the project, or `MessagePack` if the root namespace is empty. +`MessagePackGeneratedResolverName` | The name of the generated resolver type. | `GeneratedMessagePackResolver` +`MessagePackGeneratedUsesMapMode` | A boolean value that indicates whether all formatters should use property maps instead of more compact arrays. | `false` + +For example you could add this xml to your project file to set each of the above properties (in this example, to their default values): + +```xml + + false + $(RootNamespace) + GeneratedMessagePackResolver + false + +``` + +When exposing the generated resolver publicly, consumers outside the library should aggregate the resolver using its `Instance` property, which contains *only* the generated formatters. +The `InstanceWithStandardAotResolver` property is a convenience for callers that will not be aggregating the resolver with those from other libraries, since it aggregates built-in AOT friendly resolvers from the MessagePack library itself. + +### Unity-specific AOT concerns Here is the full sample code to register a generated resolver in Unity. @@ -1599,7 +1651,7 @@ using UnityEngine; public class Startup { - static bool serializerRegistered = false; + static bool serializerRegistered; [RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSceneLoad)] static void Initialize() @@ -1607,7 +1659,7 @@ public class Startup if (!serializerRegistered) { StaticCompositeResolver.Instance.Register( - MessagePack.Resolvers.GeneratedResolver.Instance, + GeneratedMessagePackResolver.Instance, MessagePack.Resolvers.StandardResolver.Instance ); @@ -1620,7 +1672,6 @@ public class Startup #if UNITY_EDITOR - [UnityEditor.InitializeOnLoadMethod] static void EditorInitialize() { @@ -1631,18 +1682,6 @@ public class Startup } ``` -In Unity, you can use MessagePack CodeGen windows at `Windows -> MessagePack -> CodeGenerator`. - -![](https://user-images.githubusercontent.com/46207/69414381-f14da400-0d55-11ea-9f8d-9af448d347dc.png) - -Install the .NET Core runtime, install mpc (as a .NET Core Tool as described above), and execute `dotnet mpc`. Currently this tool is experimental so please tell me your opinion. - -In Xamarin, you can install the [the `MessagePack.MSBuild.Tasks` NuGet package](doc/msbuildtask.md) into your projects to pre-compile fast serialization code and run in environments where JIT compilation is not allowed. - -## RPC - -MessagePack advocated [MessagePack RPC](https://github.com/msgpack-rpc/msgpack-rpc), but work on it has stopped and it is not widely used. - ### MagicOnion I've created a gRPC based MessagePack HTTP/2 RPC streaming framework called [MagicOnion](https://github.com/Cysharp/MagicOnion). gRPC usually communicates with Protocol Buffers using IDL. But MagicOnion uses MessagePack for C# and does not need IDL. When communicating C# to C#, schemaless (or rather C# classes as schema) is better than using IDL. diff --git a/doc/msbuildtask.md b/doc/msbuildtask.md deleted file mode 100644 index a7cabf1d8..000000000 --- a/doc/msbuildtask.md +++ /dev/null @@ -1,59 +0,0 @@ -# MessagePack Compiler via MSBuild Task - -Cold startup performance and AOT environments can benefit by pre-compiling the specialized code -for serializing and deserializing your custom types. - -Install the `MessagePack.Generator` NuGet package in your project: - [![NuGet](https://img.shields.io/nuget/v/MessagePack.Generator.svg)](https://www.nuget.org/packages/MessagePack.Generator) - -This package automatically gets the MessagePack source generator to run during the build to produce a source file in the intermediate directory and adds it to the compilation, consumable in the normal way: - -```cs -using System; -using MessagePack; -using MessagePack.Resolvers; - -class Program -{ - static void Main(string[] args) - { - var o = new SomeObject { SomeMember = "hi" }; - - var options = MessagePackSerializerOptions.Standard.WithResolver( - CompositeResolver.Create( - GeneratedResolver.Instance, - StandardResolver.Instance - )); - byte[] b = MessagePackSerializer.Serialize(o, options); - var o2 = MessagePackSerializer.Deserialize(b, options); - Console.WriteLine(o2.SomeMember); - } -} - -[MessagePackObject] -public class SomeObject -{ - [Key(0)] - public string SomeMember { get; set; } -} -``` - -## Customizations - -A few MSBuild properties can be set in your project to customize mpc: - -Property | Purpose | Default value ---|--|-- -`MessagePackGeneratedResolverNamespace` | The prefix for the namespace under which code will be generated. `.Formatters` is always appended to this value. | `MessagePack` -`MessagePackGeneratedResolverName` | The name of the generated type. | `GeneratedResolver` -`MessagePackGeneratedUsesMapMode` | A boolean value that indicates whether all formatters should use property maps instead of more compact arrays. | `false` - -For example you could add this xml to your project file to set each of the above properties (in this example, to their default values): - -```xml - - MessagePack - GeneratedResolver - false - -``` diff --git a/src/MessagePack.Generator/CodeAnalysis/CodeAnalysisUtilities.cs b/src/MessagePack.Generator/CodeAnalysis/CodeAnalysisUtilities.cs index 70675b330..3c422e9f6 100644 --- a/src/MessagePack.Generator/CodeAnalysis/CodeAnalysisUtilities.cs +++ b/src/MessagePack.Generator/CodeAnalysis/CodeAnalysisUtilities.cs @@ -10,6 +10,7 @@ internal static class CodeAnalysisUtilities static CodeAnalysisUtilities() { // Roslyn really doesn't like angle brackets in file names, even on operating systems that allow them (e.g. linux). + // See https://github.com/dotnet/roslyn/issues/67653 InvalidFileNameChars.Add('<'); InvalidFileNameChars.Add('>'); } diff --git a/src/MessagePack.Generator/Utils/RoslynExtensions.cs b/src/MessagePack.Generator/Utils/RoslynExtensions.cs index 6a1649fc9..a3df190c4 100644 --- a/src/MessagePack.Generator/Utils/RoslynExtensions.cs +++ b/src/MessagePack.Generator/Utils/RoslynExtensions.cs @@ -8,19 +8,7 @@ namespace MessagePack.Generator; // Utility and Extension methods for Roslyn internal static class RoslynExtensions { - public static IEnumerable GetNamedTypeSymbols(this Compilation compilation) - { - return compilation.SyntaxTrees.SelectMany(syntaxTree => - { - var semModel = compilation.GetSemanticModel(syntaxTree); - return syntaxTree.GetRoot() - .DescendantNodes() - .Select(x => semModel.GetDeclaredSymbol(x)) - .OfType(); - }); - } - - public static IEnumerable GetAllMembers(this ITypeSymbol symbol) + internal static IEnumerable GetAllMembers(this ITypeSymbol symbol) { var t = symbol; while (t != null) @@ -34,7 +22,7 @@ public static IEnumerable GetAllMembers(this ITypeSymbol symbol) } } - public static bool ApproximatelyEqual(this INamedTypeSymbol? left, INamedTypeSymbol? right) + internal static bool ApproximatelyEqual(this INamedTypeSymbol? left, INamedTypeSymbol? right) { if (left is IErrorTypeSymbol || right is IErrorTypeSymbol) { diff --git a/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Resolvers/StaticCompositeResolver.cs b/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Resolvers/StaticCompositeResolver.cs index daeab0813..a652056e3 100644 --- a/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Resolvers/StaticCompositeResolver.cs +++ b/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Resolvers/StaticCompositeResolver.cs @@ -2,7 +2,6 @@ // Licensed under the MIT license. See LICENSE file in the project root for full license information. using System; -using System.Collections.Concurrent; using System.Collections.Generic; using MessagePack.Formatters; @@ -16,7 +15,6 @@ public class StaticCompositeResolver : IFormatterResolver public static readonly StaticCompositeResolver Instance = new StaticCompositeResolver(); private bool frozen; - private ConcurrentBag generatedFormatters = new ConcurrentBag(); private IReadOnlyList formatters; private IReadOnlyList resolvers; @@ -127,15 +125,6 @@ private static class Cache static Cache() { Instance.frozen = true; - foreach (var item in Instance.generatedFormatters) - { - if (item is IMessagePackFormatter f) - { - Formatter = f; - return; - } - } - foreach (var item in Instance.formatters) { if (item is IMessagePackFormatter f) diff --git a/src/MessagePackAnalyzer/Utils/RoslynAnalyzerExtensions.cs b/src/MessagePackAnalyzer/Utils/RoslynAnalyzerExtensions.cs index 7fa200fa4..d682330e4 100644 --- a/src/MessagePackAnalyzer/Utils/RoslynAnalyzerExtensions.cs +++ b/src/MessagePackAnalyzer/Utils/RoslynAnalyzerExtensions.cs @@ -17,24 +17,6 @@ namespace MessagePackAnalyzer // Utility and Extension methods for Roslyn internal static class RoslynAnalyzerExtensions { - public static IEnumerable GetNamedTypeSymbols(this Compilation compilation) - { - foreach (SyntaxTree syntaxTree in compilation.SyntaxTrees) - { - SemanticModel semModel = compilation.GetSemanticModel(syntaxTree); - - foreach (ISymbol? item in syntaxTree.GetRoot() - .DescendantNodes() - .Select(x => semModel.GetDeclaredSymbol(x))) - { - if (item is INamedTypeSymbol namedType) - { - yield return namedType; - } - } - } - } - public static IEnumerable EnumerateBaseType(this ITypeSymbol symbol) { INamedTypeSymbol? t = symbol.BaseType; diff --git a/tests/MessagePack.Generator.Tests/TestUtilities.cs b/tests/MessagePack.Generator.Tests/TestUtilities.cs index d0afd4c8d..cdef00023 100644 --- a/tests/MessagePack.Generator.Tests/TestUtilities.cs +++ b/tests/MessagePack.Generator.Tests/TestUtilities.cs @@ -1,32 +1,12 @@ // Copyright (c) All contributors. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -using System.ComponentModel; -using System.Reflection; using System.Text; -using Microsoft; namespace MessagePack.Generator.Tests; internal static class TestUtilities { - /// - /// Fetches the static instance of the named resolver, by its Instance property. - /// - /// The assembly to retrieve the resolver from. - /// The full name of the resolver. - /// The resolver. - internal static IFormatterResolver GetResolverInstance(Assembly assembly, string name) - { - Type? resolverType = assembly.GetType(name); - Requires.Argument(resolverType is not null, nameof(name), "No type with the given name found."); - FieldInfo? instanceField = resolverType.GetField("Instance", BindingFlags.Static | BindingFlags.Public); - Assert.NotNull(instanceField); - object? instanceValue = instanceField.GetValue(null); - Assert.NotNull(instanceValue); - return (IFormatterResolver)instanceValue; - } - internal static string WrapTestSource(string source, ContainerKind containerKind) { StringBuilder testSource = new(); From 4876d74f9f3c72580fabe94c39bd90f156192b37 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Wed, 5 Apr 2023 19:36:56 -0600 Subject: [PATCH 074/660] Got Roslyn3 tests running --- MessagePack.sln | 7 ++++ README.md | 6 +++ .../MessagePackGenerator.cs | 11 ++++-- ...MessagePack.Generator.Roslyn3.Tests.csproj | 39 +++++++++++++++++++ .../CSharpSourceGeneratorVerifier`1+Test.cs | 4 ++ 5 files changed, 64 insertions(+), 3 deletions(-) create mode 100644 tests/MessagePack.Generator.Roslyn3.Tests/MessagePack.Generator.Roslyn3.Tests.csproj diff --git a/MessagePack.sln b/MessagePack.sln index 530c8b42b..0784b9aea 100644 --- a/MessagePack.sln +++ b/MessagePack.sln @@ -100,6 +100,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MessagePack.Generator.Execu EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MessagePack.Generator.MapModeExecutionTests", "tests\MessagePack.Generator.MapModeExecutionTests\MessagePack.Generator.MapModeExecutionTests.csproj", "{EDBA7DDC-69AF-4D5B-A8F6-3B508F8CC0FC}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MessagePack.Generator.Roslyn3.Tests", "tests\MessagePack.Generator.Roslyn3.Tests\MessagePack.Generator.Roslyn3.Tests.csproj", "{EAC1B79C-F77D-4DEF-BF53-75E700A301A4}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -218,6 +220,10 @@ Global {EDBA7DDC-69AF-4D5B-A8F6-3B508F8CC0FC}.Debug|Any CPU.Build.0 = Debug|Any CPU {EDBA7DDC-69AF-4D5B-A8F6-3B508F8CC0FC}.Release|Any CPU.ActiveCfg = Release|Any CPU {EDBA7DDC-69AF-4D5B-A8F6-3B508F8CC0FC}.Release|Any CPU.Build.0 = Release|Any CPU + {EAC1B79C-F77D-4DEF-BF53-75E700A301A4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {EAC1B79C-F77D-4DEF-BF53-75E700A301A4}.Debug|Any CPU.Build.0 = Debug|Any CPU + {EAC1B79C-F77D-4DEF-BF53-75E700A301A4}.Release|Any CPU.ActiveCfg = Release|Any CPU + {EAC1B79C-F77D-4DEF-BF53-75E700A301A4}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -251,6 +257,7 @@ Global {45A72780-93EF-4CD1-9FCD-D56A42A3B966} = {86309CF6-0054-4CE3-BFD3-CA0AA7DB17BC} {7908D954-15D4-4D67-B49A-4484809DA2C4} = {19FE674A-AC94-4E7E-B24C-2285D1D04CDE} {EDBA7DDC-69AF-4D5B-A8F6-3B508F8CC0FC} = {19FE674A-AC94-4E7E-B24C-2285D1D04CDE} + {EAC1B79C-F77D-4DEF-BF53-75E700A301A4} = {19FE674A-AC94-4E7E-B24C-2285D1D04CDE} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {B3911209-2DBF-47F8-98F6-BBC0EDFE63DE} diff --git a/README.md b/README.md index 699a10dd7..b860293e5 100644 --- a/README.md +++ b/README.md @@ -1589,6 +1589,12 @@ If you want to avoid the upfront dynamic generation cost or you need to run on X dotnet add package MessagePack.Generator ``` +Or for Unity, use the source generator that targets the older Roslyn compiler: + +```ps1 +dotnet add package MessagePack.Generator.Roslyn3 +``` + This package adds a roslyn Source Generator that produces `IMessagePackFormatter` implementing classes for each of your `[MessagePackObject]` classes. These formatters are aggregated into a generated `IMessagePackResolver` class named `GeneratedMessagePackResolver`. diff --git a/src/MessagePack.Generator.Roslyn3/MessagePackGenerator.cs b/src/MessagePack.Generator.Roslyn3/MessagePackGenerator.cs index 7ef0ec5d2..f80c5aa6f 100644 --- a/src/MessagePack.Generator.Roslyn3/MessagePackGenerator.cs +++ b/src/MessagePack.Generator.Roslyn3/MessagePackGenerator.cs @@ -1,6 +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. +using System.Collections.Immutable; using MessagePack.Generator.CodeAnalysis; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp.Syntax; @@ -28,14 +29,18 @@ public void Execute(GeneratorExecutionContext context) GeneratorContext generateContext = new(context); AnalyzerOptions options = AnalyzerOptions.Parse(context.AnalyzerConfigOptions.GlobalOptions); + List modelPerType = new(); foreach (var syntax in receiver.ClassDeclarations) { - FullModel? model = TypeCollector.Collect(compilation, options, syntax, generateContext, context.CancellationToken); - if (model is not null) + if (TypeCollector.Collect(compilation, options, syntax, generateContext, context.CancellationToken) is FullModel model) { - Generate(generateContext, model); + modelPerType.Add(model); } } + + FullModel fullModel = FullModel.Combine(modelPerType.ToImmutableArray()); + Generate(generateContext, fullModel); + GenerateResolver(generateContext, fullModel); } private class SyntaxContextReceiver : ISyntaxContextReceiver diff --git a/tests/MessagePack.Generator.Roslyn3.Tests/MessagePack.Generator.Roslyn3.Tests.csproj b/tests/MessagePack.Generator.Roslyn3.Tests/MessagePack.Generator.Roslyn3.Tests.csproj new file mode 100644 index 000000000..e3666803e --- /dev/null +++ b/tests/MessagePack.Generator.Roslyn3.Tests/MessagePack.Generator.Roslyn3.Tests.csproj @@ -0,0 +1,39 @@ + + + + net7.0 + enable + enable + 11 + $(DefineConstants);Roslyn3 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/MessagePack.Generator.Tests/Verifiers/CSharpSourceGeneratorVerifier`1+Test.cs b/tests/MessagePack.Generator.Tests/Verifiers/CSharpSourceGeneratorVerifier`1+Test.cs index f67a6bc6f..64e48b086 100644 --- a/tests/MessagePack.Generator.Tests/Verifiers/CSharpSourceGeneratorVerifier`1+Test.cs +++ b/tests/MessagePack.Generator.Tests/Verifiers/CSharpSourceGeneratorVerifier`1+Test.cs @@ -21,7 +21,11 @@ using Microsoft.CodeAnalysis.Testing.Verifiers; public static partial class CSharpSourceGeneratorVerifier +#if Roslyn3 + where TSourceGenerator : ISourceGenerator, new() +#else where TSourceGenerator : IIncrementalGenerator, new() +#endif { public class Test : CSharpSourceGeneratorTest { From 8353a776b7a1375e0ef1eb011a172ff924f00e57 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Wed, 5 Apr 2023 20:08:01 -0600 Subject: [PATCH 075/660] Implement by-value equality comparison for incremental source generation --- .../CodeAnalysis/FullModel.cs | 26 +++++++++ .../CodeAnalysis/MemberSerializationInfo.cs | 6 +-- .../CodeAnalysis/ObjectSerializationInfo.cs | 34 ++++++++++++ .../ResolverRegisterInfoComparer.cs | 4 +- .../CodeAnalysis/UnionSerializationInfo.cs | 22 ++++++++ .../EnumSerializationInfoTests.cs | 16 ++++++ .../CodeAnalysis/FullModelTests.cs | 46 ++++++++++++++++ .../GenericSerializationInfoTests.cs | 18 +++++++ .../MemberSerializationInfoTests.cs | 46 ++++++++++++++++ .../ObjectSerializationInfoTests.cs | 54 +++++++++++++++++++ .../UnionSerializationInfoTests.cs | 16 ++++++ 11 files changed, 283 insertions(+), 5 deletions(-) create mode 100644 tests/MessagePack.Generator.Tests/CodeAnalysis/EnumSerializationInfoTests.cs create mode 100644 tests/MessagePack.Generator.Tests/CodeAnalysis/FullModelTests.cs create mode 100644 tests/MessagePack.Generator.Tests/CodeAnalysis/GenericSerializationInfoTests.cs create mode 100644 tests/MessagePack.Generator.Tests/CodeAnalysis/MemberSerializationInfoTests.cs create mode 100644 tests/MessagePack.Generator.Tests/CodeAnalysis/ObjectSerializationInfoTests.cs create mode 100644 tests/MessagePack.Generator.Tests/CodeAnalysis/UnionSerializationInfoTests.cs diff --git a/src/MessagePack.Generator/CodeAnalysis/FullModel.cs b/src/MessagePack.Generator/CodeAnalysis/FullModel.cs index c7678b6d8..d7fb5a478 100644 --- a/src/MessagePack.Generator/CodeAnalysis/FullModel.cs +++ b/src/MessagePack.Generator/CodeAnalysis/FullModel.cs @@ -58,4 +58,30 @@ public static FullModel Combine(ImmutableArray models) unionInfos.ToImmutable(), options); } + + public virtual bool Equals(FullModel? other) + { + if (other is null) + { + return false; + } + + if (ReferenceEquals(this, other)) + { + return true; + } + + if (this.GetType() != other.GetType()) + { + return false; + } + + return ObjectInfos.SequenceEqual(other.ObjectInfos) + && EnumInfos.SequenceEqual(other.EnumInfos) + && GenericInfos.SequenceEqual(other.GenericInfos) + && UnionInfos.SequenceEqual(other.UnionInfos) + && Options.Equals(other.Options); + } + + public override int GetHashCode() => throw new NotImplementedException(); } diff --git a/src/MessagePack.Generator/CodeAnalysis/MemberSerializationInfo.cs b/src/MessagePack.Generator/CodeAnalysis/MemberSerializationInfo.cs index 2f9ad94c7..5cb6ac03a 100644 --- a/src/MessagePack.Generator/CodeAnalysis/MemberSerializationInfo.cs +++ b/src/MessagePack.Generator/CodeAnalysis/MemberSerializationInfo.cs @@ -16,7 +16,7 @@ public record MemberSerializationInfo( string ShortTypeName, string? CustomFormatterTypeName) { - private readonly HashSet primitiveTypes = new(ShouldUseFormatterResolverHelper.PrimitiveTypes); + private static readonly IReadOnlyCollection PrimitiveTypes = new HashSet(ShouldUseFormatterResolverHelper.PrimitiveTypes); public string GetSerializeMethodString() { @@ -24,7 +24,7 @@ public string GetSerializeMethodString() { return $"this.__{this.Name}CustomFormatter__.Serialize(ref writer, value.{this.Name}, options)"; } - else if (this.primitiveTypes.Contains(this.Type)) + else if (PrimitiveTypes.Contains(this.Type)) { return "writer.Write(value." + this.Name + ")"; } @@ -40,7 +40,7 @@ public string GetDeserializeMethodString() { return $"this.__{this.Name}CustomFormatter__.Deserialize(ref reader, options)"; } - else if (this.primitiveTypes.Contains(this.Type)) + else if (PrimitiveTypes.Contains(this.Type)) { if (this.Type == "byte[]") { diff --git a/src/MessagePack.Generator/CodeAnalysis/ObjectSerializationInfo.cs b/src/MessagePack.Generator/CodeAnalysis/ObjectSerializationInfo.cs index f8d792445..194940a33 100644 --- a/src/MessagePack.Generator/CodeAnalysis/ObjectSerializationInfo.cs +++ b/src/MessagePack.Generator/CodeAnalysis/ObjectSerializationInfo.cs @@ -61,4 +61,38 @@ public string GetConstructorString() var args = string.Join(", ", this.ConstructorParameters.Select(x => "__" + x.Name + "__")); return $"{this.FullName}({args})"; } + + public virtual bool Equals(ObjectSerializationInfo? other) + { + if (other == null) + { + return false; + } + + if (ReferenceEquals(this, other)) + { + return true; + } + + if (this.GetType() != other.GetType()) + { + return false; + } + + // Compare all the properties by value + return IsClass == other.IsClass && + IsOpenGenericType == other.IsOpenGenericType && + GenericTypeParameters.SequenceEqual(other.GenericTypeParameters) && + ConstructorParameters.SequenceEqual(other.ConstructorParameters) && + IsIntKey == other.IsIntKey && + Members.SequenceEqual(other.Members) && + Name == other.Name && + FullName == other.FullName && + Namespace == other.Namespace && + HasIMessagePackSerializationCallbackReceiver == other.HasIMessagePackSerializationCallbackReceiver && + NeedsCastOnAfter == other.NeedsCastOnAfter && + NeedsCastOnBefore == other.NeedsCastOnBefore; + } + + public override int GetHashCode() => throw new NotImplementedException(); } diff --git a/src/MessagePack.Generator/CodeAnalysis/ResolverRegisterInfoComparer.cs b/src/MessagePack.Generator/CodeAnalysis/ResolverRegisterInfoComparer.cs index d409b19fa..03b62040c 100644 --- a/src/MessagePack.Generator/CodeAnalysis/ResolverRegisterInfoComparer.cs +++ b/src/MessagePack.Generator/CodeAnalysis/ResolverRegisterInfoComparer.cs @@ -3,9 +3,9 @@ namespace MessagePack.Generator.CodeAnalysis; -internal class ResolverRegisterInfoComparer : IComparer +public class ResolverRegisterInfoComparer : IComparer { - internal static readonly ResolverRegisterInfoComparer Default = new(); + public static readonly ResolverRegisterInfoComparer Default = new(); private ResolverRegisterInfoComparer() { diff --git a/src/MessagePack.Generator/CodeAnalysis/UnionSerializationInfo.cs b/src/MessagePack.Generator/CodeAnalysis/UnionSerializationInfo.cs index 3165877e3..ccce69505 100644 --- a/src/MessagePack.Generator/CodeAnalysis/UnionSerializationInfo.cs +++ b/src/MessagePack.Generator/CodeAnalysis/UnionSerializationInfo.cs @@ -1,6 +1,8 @@ // Copyright (c) All contributors. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. +using System.Xml.Linq; + namespace MessagePack.Generator.CodeAnalysis; public record UnionSerializationInfo( @@ -14,4 +16,24 @@ public record UnionSerializationInfo( public string FormatterName => CodeAnalysisUtilities.QualifyWithOptionalNamespace(FormatterNameWithoutNamespace, $"Formatters::{this.Namespace}"); public string FormatterNameWithoutNamespace => this.Name + "Formatter"; + + public virtual bool Equals(UnionSerializationInfo? other) + { + if (other is null) + { + return false; + } + + if (ReferenceEquals(this, other)) + { + return true; + } + + return FullName == other.FullName + && Name == other.Name + && Namespace == other.Namespace + && SubTypes.SequenceEqual(other.SubTypes); + } + + public override int GetHashCode() => throw new NotImplementedException(); } diff --git a/tests/MessagePack.Generator.Tests/CodeAnalysis/EnumSerializationInfoTests.cs b/tests/MessagePack.Generator.Tests/CodeAnalysis/EnumSerializationInfoTests.cs new file mode 100644 index 000000000..a4e72ff6e --- /dev/null +++ b/tests/MessagePack.Generator.Tests/CodeAnalysis/EnumSerializationInfoTests.cs @@ -0,0 +1,16 @@ +// Copyright (c) All contributors. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +public class EnumSerializationInfoTests +{ + [Fact] + public void Equals_ByValue() + { + EnumSerializationInfo info1a = new(null, "name", "full.name", "System.Int32"); + EnumSerializationInfo info1b = new(null, "name", "full.name", "System.Int32"); + EnumSerializationInfo info2 = new(null, "name", "full.name", "System.Int16"); + + Assert.Equal(info1a, info1b); + Assert.NotEqual(info1a, info2); + } +} diff --git a/tests/MessagePack.Generator.Tests/CodeAnalysis/FullModelTests.cs b/tests/MessagePack.Generator.Tests/CodeAnalysis/FullModelTests.cs new file mode 100644 index 000000000..28c9ab79d --- /dev/null +++ b/tests/MessagePack.Generator.Tests/CodeAnalysis/FullModelTests.cs @@ -0,0 +1,46 @@ +// Copyright (c) All contributors. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +public class FullModelTests +{ + [Fact] + public void Equals_Null() + { + FullModel model1 = new( + ImmutableSortedSet.Create(ResolverRegisterInfoComparer.Default), + ImmutableSortedSet.Create(ResolverRegisterInfoComparer.Default), + ImmutableSortedSet.Create(ResolverRegisterInfoComparer.Default), + ImmutableSortedSet.Create(ResolverRegisterInfoComparer.Default), + AnalyzerOptions.Default); + + Assert.False(model1.Equals(null)); + } + + [Fact] + public void Equals_ByValue() + { + // Construct a FullModel with a non-default value for each property. + FullModel model1a = new( + ImmutableSortedSet.Create(ResolverRegisterInfoComparer.Default), + ImmutableSortedSet.Create(ResolverRegisterInfoComparer.Default).Add(new(null, "MyEnum", "My.MyEnum", "System.Int32")), + ImmutableSortedSet.Create(ResolverRegisterInfoComparer.Default), + ImmutableSortedSet.Create(ResolverRegisterInfoComparer.Default), + AnalyzerOptions.Default); + FullModel model1b = new( + ImmutableSortedSet.Create(ResolverRegisterInfoComparer.Default), + ImmutableSortedSet.Create(ResolverRegisterInfoComparer.Default).Add(new(null, "MyEnum", "My.MyEnum", "System.Int32")), + ImmutableSortedSet.Create(ResolverRegisterInfoComparer.Default), + ImmutableSortedSet.Create(ResolverRegisterInfoComparer.Default), + AnalyzerOptions.Default); + + FullModel model2 = new( + ImmutableSortedSet.Create(ResolverRegisterInfoComparer.Default), + ImmutableSortedSet.Create(ResolverRegisterInfoComparer.Default), + ImmutableSortedSet.Create(ResolverRegisterInfoComparer.Default), + ImmutableSortedSet.Create(ResolverRegisterInfoComparer.Default), + AnalyzerOptions.Default); + + Assert.Equal(model1b, model1a); + Assert.NotEqual(model2, model1a); + } +} diff --git a/tests/MessagePack.Generator.Tests/CodeAnalysis/GenericSerializationInfoTests.cs b/tests/MessagePack.Generator.Tests/CodeAnalysis/GenericSerializationInfoTests.cs new file mode 100644 index 000000000..97d8a09d6 --- /dev/null +++ b/tests/MessagePack.Generator.Tests/CodeAnalysis/GenericSerializationInfoTests.cs @@ -0,0 +1,18 @@ +// Copyright (c) All contributors. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using System.Reflection; + +public class GenericSerializationInfoTests +{ + [Fact] + public void Equals_ByValue() + { + GenericSerializationInfo info1a = new("full.name", "FullNameFormatter", false); + GenericSerializationInfo info1b = new("full.name", "FullNameFormatter", false); + GenericSerializationInfo info2 = new("full.Name", "FullNameFormatter", false); + + Assert.Equal(info1b, info1a); + Assert.NotEqual(info2, info1a); + } +} diff --git a/tests/MessagePack.Generator.Tests/CodeAnalysis/MemberSerializationInfoTests.cs b/tests/MessagePack.Generator.Tests/CodeAnalysis/MemberSerializationInfoTests.cs new file mode 100644 index 000000000..044162bf3 --- /dev/null +++ b/tests/MessagePack.Generator.Tests/CodeAnalysis/MemberSerializationInfoTests.cs @@ -0,0 +1,46 @@ +// Copyright (c) All contributors. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using System.Reflection; + +public class MemberSerializationInfoTests +{ + [Fact] + public void Equals_ByValue() + { + MemberSerializationInfo info1a = new( + true, + false, + true, + 1, + "Hi", + "name", + "SomeType", + "shortName", + null); + MemberSerializationInfo info1b = new( + true, + false, + true, + 1, + "Hi", + "name", + "SomeType", + "shortName", + null); + + MemberSerializationInfo info2 = new( + false, + false, + true, + 1, + "Hi", + "name", + "SomeType", + "shortName", + null); + + Assert.Equal(info1b, info1a); + Assert.NotEqual(info2, info1a); + } +} diff --git a/tests/MessagePack.Generator.Tests/CodeAnalysis/ObjectSerializationInfoTests.cs b/tests/MessagePack.Generator.Tests/CodeAnalysis/ObjectSerializationInfoTests.cs new file mode 100644 index 000000000..5081f7546 --- /dev/null +++ b/tests/MessagePack.Generator.Tests/CodeAnalysis/ObjectSerializationInfoTests.cs @@ -0,0 +1,54 @@ +// Copyright (c) All contributors. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +public class ObjectSerializationInfoTests +{ + [Fact] + public void Equals_ByValue() + { + // Initialize an object with non-default data. + ObjectSerializationInfo info1a = new( + true, + true, + new GenericTypeParameterInfo[0], + new MemberSerializationInfo[0], + false, + new MemberSerializationInfo[0], + "name", + "full.name", + null, + false, + false, + false); + ObjectSerializationInfo info1b = new( + true, + true, + new GenericTypeParameterInfo[0], + new MemberSerializationInfo[0], + false, + new MemberSerializationInfo[0], + "name", + "full.name", + null, + false, + false, + false); + + ObjectSerializationInfo info2 = new( + true, + false, + new GenericTypeParameterInfo[0], + new MemberSerializationInfo[0], + false, + new MemberSerializationInfo[0], + "name", + "full.name", + null, + false, + false, + false); + + Assert.Equal(info1a, info1b); + Assert.NotEqual(info1a, info2); + } +} diff --git a/tests/MessagePack.Generator.Tests/CodeAnalysis/UnionSerializationInfoTests.cs b/tests/MessagePack.Generator.Tests/CodeAnalysis/UnionSerializationInfoTests.cs new file mode 100644 index 000000000..e10997790 --- /dev/null +++ b/tests/MessagePack.Generator.Tests/CodeAnalysis/UnionSerializationInfoTests.cs @@ -0,0 +1,16 @@ +// Copyright (c) All contributors. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +public class UnionSerializationInfoTests +{ + [Fact] + public void Equals_ByValue() + { + UnionSerializationInfo info1a = new(null, "name", "full.name", new UnionSubTypeInfo[0]); + UnionSerializationInfo info1b = new(null, "name", "full.name", new UnionSubTypeInfo[0]); + UnionSerializationInfo info2 = new(null, "name", "full.name", new UnionSubTypeInfo[] { new(1, "String") }); + + Assert.Equal(info1a, info1b); + Assert.NotEqual(info1a, info2); + } +} From 140dd892805ee01654cb84a0d0724285a58fd60b Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Thu, 6 Apr 2023 06:12:23 -0600 Subject: [PATCH 076/660] Copy a few analyzer tests to the source generator and get them working The most important part of this is that authoring errors are no longer fatal to the source generator. They are merely reported as diagnostics, and the code that *can* be emitted is still emitted. --- .../MessagePack.Generator.Roslyn3.csproj | 5 + .../AnalyzerReleases.Shipped.md | 3 + .../AnalyzerReleases.Unshipped.md | 10 + .../CodeAnalysis/EnumSerializationInfo.cs | 4 + .../CodeAnalysis/GenericSerializationInfo.cs | 4 + .../CodeAnalysis/IResolverRegisterInfo.cs | 4 + .../CodeAnalysis/ObjectSerializationInfo.cs | 4 + .../CodeAnalysis/TypeCollector.cs | 196 ++++++++++++------ .../CodeAnalysis/UnionSerializationInfo.cs | 3 + .../MessagePack.Generator.csproj | 10 + .../MessagePackGenerator.Emit.cs | 11 + .../GenerationTests.cs | 55 +++++ .../Formatters.BarFormatter.g.cs | 54 +++++ .../Formatters.FooFormatter.g.cs | 34 +++ ...sagePack.GeneratedMessagePackResolver.g.cs | 72 +++++++ .../Formatters.FooFormatter.g.cs | 34 +++ ...sagePack.GeneratedMessagePackResolver.g.cs | 70 +++++++ .../Formatters.FooFormatter.g.cs | 34 +++ ...sagePack.GeneratedMessagePackResolver.g.cs | 70 +++++++ 19 files changed, 612 insertions(+), 65 deletions(-) create mode 100644 src/MessagePack.Generator/AnalyzerReleases.Shipped.md create mode 100644 src/MessagePack.Generator/AnalyzerReleases.Unshipped.md create mode 100644 tests/MessagePack.Generator.Tests/Resources/AddAttributeToType/Formatters.BarFormatter.g.cs create mode 100644 tests/MessagePack.Generator.Tests/Resources/AddAttributeToType/Formatters.FooFormatter.g.cs create mode 100644 tests/MessagePack.Generator.Tests/Resources/AddAttributeToType/MessagePack.GeneratedMessagePackResolver.g.cs create mode 100644 tests/MessagePack.Generator.Tests/Resources/MembersNeedAttributes/Formatters.FooFormatter.g.cs create mode 100644 tests/MessagePack.Generator.Tests/Resources/MembersNeedAttributes/MessagePack.GeneratedMessagePackResolver.g.cs create mode 100644 tests/MessagePack.Generator.Tests/Resources/NullStringKey/Formatters.FooFormatter.g.cs create mode 100644 tests/MessagePack.Generator.Tests/Resources/NullStringKey/MessagePack.GeneratedMessagePackResolver.g.cs diff --git a/src/MessagePack.Generator.Roslyn3/MessagePack.Generator.Roslyn3.csproj b/src/MessagePack.Generator.Roslyn3/MessagePack.Generator.Roslyn3.csproj index 8a8643362..c5e5b9cc3 100644 --- a/src/MessagePack.Generator.Roslyn3/MessagePack.Generator.Roslyn3.csproj +++ b/src/MessagePack.Generator.Roslyn3/MessagePack.Generator.Roslyn3.csproj @@ -37,4 +37,9 @@ + + + + + diff --git a/src/MessagePack.Generator/AnalyzerReleases.Shipped.md b/src/MessagePack.Generator/AnalyzerReleases.Shipped.md new file mode 100644 index 000000000..60b59dd99 --- /dev/null +++ b/src/MessagePack.Generator/AnalyzerReleases.Shipped.md @@ -0,0 +1,3 @@ +; Shipped analyzer releases +; https://github.com/dotnet/roslyn-analyzers/blob/main/src/Microsoft.CodeAnalysis.Analyzers/ReleaseTrackingAnalyzers.Help.md + diff --git a/src/MessagePack.Generator/AnalyzerReleases.Unshipped.md b/src/MessagePack.Generator/AnalyzerReleases.Unshipped.md new file mode 100644 index 000000000..35209f679 --- /dev/null +++ b/src/MessagePack.Generator/AnalyzerReleases.Unshipped.md @@ -0,0 +1,10 @@ +; Unshipped analyzer release +; https://github.com/dotnet/roslyn-analyzers/blob/main/src/Microsoft.CodeAnalysis.Analyzers/ReleaseTrackingAnalyzers.Help.md + +### New Rules + +Rule ID | Category | Severity | Notes +--------|----------|----------|------- +MsgPack003 | Usage | Error | Source generator +MsgPack004 | Usage | Error | Source generator +MsgPack005 | Usage | Error | Source generator \ No newline at end of file diff --git a/src/MessagePack.Generator/CodeAnalysis/EnumSerializationInfo.cs b/src/MessagePack.Generator/CodeAnalysis/EnumSerializationInfo.cs index 9201a79c6..be88cb15c 100644 --- a/src/MessagePack.Generator/CodeAnalysis/EnumSerializationInfo.cs +++ b/src/MessagePack.Generator/CodeAnalysis/EnumSerializationInfo.cs @@ -1,10 +1,14 @@ // Copyright (c) All contributors. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. +using Microsoft.CodeAnalysis; + namespace MessagePack.Generator.CodeAnalysis; public sealed record EnumSerializationInfo(string? Namespace, string Name, string FullName, string UnderlyingTypeName) : IResolverRegisterInfo { + public IReadOnlyCollection Diagnostics { get; init; } = Array.Empty(); + public string FileNameHint => $"{CodeAnalysisUtilities.AppendNameToNamespace("Formatters", this.Namespace)}.{this.FormatterNameWithoutNamespace}"; public string FormatterName => CodeAnalysisUtilities.QualifyWithOptionalNamespace(this.FormatterNameWithoutNamespace, $"Formatters::{this.Namespace}"); diff --git a/src/MessagePack.Generator/CodeAnalysis/GenericSerializationInfo.cs b/src/MessagePack.Generator/CodeAnalysis/GenericSerializationInfo.cs index 2c014dfc1..9401f8481 100644 --- a/src/MessagePack.Generator/CodeAnalysis/GenericSerializationInfo.cs +++ b/src/MessagePack.Generator/CodeAnalysis/GenericSerializationInfo.cs @@ -1,10 +1,14 @@ // Copyright (c) All contributors. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. +using Microsoft.CodeAnalysis; + namespace MessagePack.Generator.CodeAnalysis; public sealed record GenericSerializationInfo(string FullName, string FormatterName, bool IsOpenGenericType) : IResolverRegisterInfo { + public IReadOnlyCollection Diagnostics { get; init; } = Array.Empty(); + public bool Equals(GenericSerializationInfo? other) { return this.FullName.Equals(other?.FullName); diff --git a/src/MessagePack.Generator/CodeAnalysis/IResolverRegisterInfo.cs b/src/MessagePack.Generator/CodeAnalysis/IResolverRegisterInfo.cs index 466fc2198..f56b6664e 100644 --- a/src/MessagePack.Generator/CodeAnalysis/IResolverRegisterInfo.cs +++ b/src/MessagePack.Generator/CodeAnalysis/IResolverRegisterInfo.cs @@ -1,6 +1,8 @@ // Copyright (c) All contributors. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. +using Microsoft.CodeAnalysis; + namespace MessagePack.Generator.CodeAnalysis; public interface IResolverRegisterInfo @@ -8,4 +10,6 @@ public interface IResolverRegisterInfo string FullName { get; } string FormatterName { get; } + + IReadOnlyCollection Diagnostics { get; } } diff --git a/src/MessagePack.Generator/CodeAnalysis/ObjectSerializationInfo.cs b/src/MessagePack.Generator/CodeAnalysis/ObjectSerializationInfo.cs index 194940a33..a866cb4a7 100644 --- a/src/MessagePack.Generator/CodeAnalysis/ObjectSerializationInfo.cs +++ b/src/MessagePack.Generator/CodeAnalysis/ObjectSerializationInfo.cs @@ -1,6 +1,8 @@ // Copyright (c) All contributors. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. +using Microsoft.CodeAnalysis; + namespace MessagePack.Generator.CodeAnalysis; public record ObjectSerializationInfo( @@ -51,6 +53,8 @@ public int MaxKey } } + public IReadOnlyCollection Diagnostics { get; init; } = Array.Empty(); + public MemberSerializationInfo? GetMember(int index) { return this.Members.FirstOrDefault(x => x.IntKey == index); diff --git a/src/MessagePack.Generator/CodeAnalysis/TypeCollector.cs b/src/MessagePack.Generator/CodeAnalysis/TypeCollector.cs index cbb7c48f0..f040f8da4 100644 --- a/src/MessagePack.Generator/CodeAnalysis/TypeCollector.cs +++ b/src/MessagePack.Generator/CodeAnalysis/TypeCollector.cs @@ -64,8 +64,48 @@ public ReferenceSymbols(Compilation compilation, Action logger) } } +internal static class AnalyzerUtilities +{ + internal static string GetHelpLink(string diagnosticId) => $"https://github.com/neuecc/MessagePack-CSharp/blob/master/doc/analyzers/{diagnosticId}.md"; +} + public class TypeCollector { + public const string UseMessagePackObjectAttributeId = "MsgPack003"; + public const string AttributeMessagePackObjectMembersId = "MsgPack004"; + public const string InvalidMessagePackObjectId = "MsgPack005"; + internal const string Category = "Usage"; + + internal static readonly DiagnosticDescriptor TypeMustBeMessagePackObject = new DiagnosticDescriptor( + id: UseMessagePackObjectAttributeId, + title: "Use MessagePackObjectAttribute", + category: Category, + messageFormat: "Type must be marked with MessagePackObjectAttribute. {0}.", // type.Name + description: "Type must be marked with MessagePackObjectAttribute.", + defaultSeverity: DiagnosticSeverity.Error, + isEnabledByDefault: true, + helpLinkUri: AnalyzerUtilities.GetHelpLink(UseMessagePackObjectAttributeId)); + + internal static readonly DiagnosticDescriptor PublicMemberNeedsKey = new DiagnosticDescriptor( + id: AttributeMessagePackObjectMembersId, + title: "Attribute public members of MessagePack objects", + category: Category, + messageFormat: "Public members of MessagePackObject-attributed types require either KeyAttribute or IgnoreMemberAttribute. {0}.{1}.", // type.Name + "." + item.Name + description: "Public member must be marked with KeyAttribute or IgnoreMemberAttribute.", + defaultSeverity: DiagnosticSeverity.Error, + isEnabledByDefault: true, + helpLinkUri: AnalyzerUtilities.GetHelpLink(AttributeMessagePackObjectMembersId)); + + internal static readonly DiagnosticDescriptor BothStringAndIntKeyAreNull = new DiagnosticDescriptor( + id: InvalidMessagePackObjectId, + title: "Attribute public members of MessagePack objects", + category: Category, + messageFormat: "Both int and string keys are null. {0}.{1}.", // type.Name + "." + item.Name + description: "An int or string key must be supplied to the KeyAttribute.", + defaultSeverity: DiagnosticSeverity.Error, + isEnabledByDefault: true, + helpLinkUri: AnalyzerUtilities.GetHelpLink(AttributeMessagePackObjectMembersId)); + private static readonly SymbolDisplayFormat BinaryWriteFormat = new SymbolDisplayFormat( genericsOptions: SymbolDisplayGenericsOptions.IncludeTypeParameters, miscellaneousOptions: SymbolDisplayMiscellaneousOptions.ExpandNullable, @@ -612,23 +652,30 @@ private void CollectGeneric(INamedTypeSymbol type) private void CollectObject(INamedTypeSymbol type) { - ObjectSerializationInfo info = this.GetObjectInfo(type); - this.collectedObjectInfo.Add(info); + ObjectSerializationInfo? info = this.GetObjectInfo(type); + if (info is not null) + { + this.collectedObjectInfo.Add(info); + } } - private ObjectSerializationInfo GetObjectInfo(INamedTypeSymbol type) + private ObjectSerializationInfo? GetObjectInfo(INamedTypeSymbol type) { + List diagnostics = new(); var isClass = !type.IsValueType; var isOpenGenericType = type.IsGenericType; - AttributeData contractAttr = type.GetAttributes().FirstOrDefault(x => x.AttributeClass.ApproximatelyEqual(this.typeReferences.MessagePackObjectAttribute)) - ?? throw new MessagePackGeneratorResolveFailedException("Serialization Object must mark MessagePackObjectAttribute." + " type: " + type.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat)); + AttributeData? contractAttr = type.GetAttributes().FirstOrDefault(x => x.AttributeClass.ApproximatelyEqual(this.typeReferences.MessagePackObjectAttribute)); + if (contractAttr is null) + { + diagnostics.Add(Diagnostic.Create(TypeMustBeMessagePackObject, ((BaseTypeDeclarationSyntax)type.DeclaringSyntaxReferences[0].GetSyntax()).Identifier.GetLocation(), type.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat))); + } var isIntKey = true; var intMembers = new Dictionary(); var stringMembers = new Dictionary(); - if (this.isForceUseMap || (contractAttr.ConstructorArguments[0] is { Value: bool firstConstructorArgument } && firstConstructorArgument)) + if (this.isForceUseMap || (contractAttr?.ConstructorArguments[0] is { Value: bool firstConstructorArgument } && firstConstructorArgument)) { // All public members are serialize target except [Ignore] member. isIntKey = false; @@ -717,48 +764,56 @@ private ObjectSerializationInfo GetObjectInfo(INamedTypeSymbol type) } var customFormatterAttr = item.GetAttributes().FirstOrDefault(x => x.AttributeClass.ApproximatelyEqual(this.typeReferences.MessagePackFormatterAttribute))?.ConstructorArguments[0].Value as INamedTypeSymbol; - var key = item.GetAttributes().FirstOrDefault(x => x.AttributeClass.ApproximatelyEqual(this.typeReferences.KeyAttribute))?.ConstructorArguments[0] - ?? throw new MessagePackGeneratorResolveFailedException("all public members must mark KeyAttribute or IgnoreMemberAttribute." + " type: " + type.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat) + " member:" + item.Name); - - var intKey = key is { Value: int intKeyValue } ? intKeyValue : default(int?); - var stringKey = key is { Value: string stringKeyValue } ? stringKeyValue : default; - if (intKey == null && stringKey == null) - { - throw new MessagePackGeneratorResolveFailedException("both IntKey and StringKey are null." + " type: " + type.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat) + " member:" + item.Name); - } - - if (searchFirst) + TypedConstant? key = item.GetAttributes().FirstOrDefault(x => x.AttributeClass.ApproximatelyEqual(this.typeReferences.KeyAttribute))?.ConstructorArguments[0]; + if (key is null) { - searchFirst = false; - isIntKey = intKey != null; + if (contractAttr is not null) + { + diagnostics.Add(Diagnostic.Create(PublicMemberNeedsKey, ((PropertyDeclarationSyntax)item.DeclaringSyntaxReferences[0].GetSyntax()).Identifier.GetLocation(), type.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat), item.Name)); + } } else { - if ((isIntKey && intKey == null) || (!isIntKey && stringKey == null)) + var intKey = key is { Value: int intKeyValue } ? intKeyValue : default(int?); + var stringKey = key is { Value: string stringKeyValue } ? stringKeyValue : default; + if (intKey == null && stringKey == null) { - throw new MessagePackGeneratorResolveFailedException("all members key type must be same." + " type: " + type.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat) + " member:" + item.Name); + diagnostics.Add(Diagnostic.Create(BothStringAndIntKeyAreNull, ((PropertyDeclarationSyntax)item.DeclaringSyntaxReferences[0].GetSyntax()).Identifier.GetLocation(), type.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat), item.Name)); } - } - if (isIntKey) - { - if (intMembers.ContainsKey(intKey!.Value)) + if (searchFirst) { - throw new MessagePackGeneratorResolveFailedException("key is duplicated, all members key must be unique." + " type: " + type.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat) + " member:" + item.Name); + searchFirst = false; + isIntKey = intKey != null; + } + else + { + if ((isIntKey && intKey == null) || (!isIntKey && stringKey == null)) + { + throw new MessagePackGeneratorResolveFailedException("all members key type must be same." + " type: " + type.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat) + " member:" + item.Name); + } } - var member = new MemberSerializationInfo(true, isWritable, isReadable, intKey!.Value, item.Name, item.Name, item.Type.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat), item.Type.ToDisplayString(BinaryWriteFormat), customFormatterAttr?.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat)); - intMembers.Add(member.IntKey, member); - } - else - { - if (stringMembers.ContainsKey(stringKey!)) + if (isIntKey) { - throw new MessagePackGeneratorResolveFailedException("key is duplicated, all members key must be unique." + " type: " + type.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat) + " member:" + item.Name); + if (intMembers.ContainsKey(intKey!.Value)) + { + throw new MessagePackGeneratorResolveFailedException("key is duplicated, all members key must be unique." + " type: " + type.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat) + " member:" + item.Name); + } + + var member = new MemberSerializationInfo(true, isWritable, isReadable, intKey!.Value, item.Name, item.Name, item.Type.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat), item.Type.ToDisplayString(BinaryWriteFormat), customFormatterAttr?.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat)); + intMembers.Add(member.IntKey, member); } + else if (stringKey is not null) + { + if (stringMembers.ContainsKey(stringKey!)) + { + throw new MessagePackGeneratorResolveFailedException("key is duplicated, all members key must be unique." + " type: " + type.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat) + " member:" + item.Name); + } - var member = new MemberSerializationInfo(true, isWritable, isReadable, hiddenIntKey++, stringKey!, item.Name, item.Type.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat), item.Type.ToDisplayString(BinaryWriteFormat), customFormatterAttr?.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat)); - stringMembers.Add(member.StringKey, member); + var member = new MemberSerializationInfo(true, isWritable, isReadable, hiddenIntKey++, stringKey!, item.Name, item.Type.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat), item.Type.ToDisplayString(BinaryWriteFormat), customFormatterAttr?.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat)); + stringMembers.Add(member.StringKey, member); + } } var messagePackFormatter = item.GetAttributes().FirstOrDefault(x => x.AttributeClass.ApproximatelyEqual(this.typeReferences.MessagePackFormatterAttribute))?.ConstructorArguments[0]; @@ -789,48 +844,56 @@ private ObjectSerializationInfo GetObjectInfo(INamedTypeSymbol type) } var customFormatterAttr = item.GetAttributes().FirstOrDefault(x => x.AttributeClass.ApproximatelyEqual(this.typeReferences.MessagePackFormatterAttribute))?.ConstructorArguments[0].Value as INamedTypeSymbol; - var key = item.GetAttributes().FirstOrDefault(x => x.AttributeClass.ApproximatelyEqual(this.typeReferences.KeyAttribute))?.ConstructorArguments[0] - ?? throw new MessagePackGeneratorResolveFailedException("all public members must mark KeyAttribute or IgnoreMemberAttribute." + " type: " + type.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat) + " member:" + item.Name); - - var intKey = key is { Value: int intKeyValue } ? intKeyValue : default(int?); - var stringKey = key is { Value: string stringKeyValue } ? stringKeyValue : default; - if (intKey == null && stringKey == null) + TypedConstant? key = item.GetAttributes().FirstOrDefault(x => x.AttributeClass.ApproximatelyEqual(this.typeReferences.KeyAttribute))?.ConstructorArguments[0]; + if (key is null) { - throw new MessagePackGeneratorResolveFailedException("both IntKey and StringKey are null." + " type: " + type.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat) + " member:" + item.Name); - } - - if (searchFirst) - { - searchFirst = false; - isIntKey = intKey != null; + if (contractAttr is not null) + { + diagnostics.Add(Diagnostic.Create(PublicMemberNeedsKey, item.DeclaringSyntaxReferences[0].GetSyntax().GetLocation(), type.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat), item.Name)); + } } else { - if ((isIntKey && intKey == null) || (!isIntKey && stringKey == null)) + var intKey = key is { Value: int intKeyValue } ? intKeyValue : default(int?); + var stringKey = key is { Value: string stringKeyValue } ? stringKeyValue : default; + if (intKey == null && stringKey == null) { - throw new MessagePackGeneratorResolveFailedException("all members key type must be same." + " type: " + type.Name + " member:" + item.Name); + throw new MessagePackGeneratorResolveFailedException("both IntKey and StringKey are null." + " type: " + type.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat) + " member:" + item.Name); } - } - if (isIntKey) - { - if (intMembers.ContainsKey(intKey!.Value)) + if (searchFirst) { - throw new MessagePackGeneratorResolveFailedException("key is duplicated, all members key must be unique." + " type: " + type.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat) + " member:" + item.Name); + searchFirst = false; + isIntKey = intKey != null; + } + else + { + if ((isIntKey && intKey == null) || (!isIntKey && stringKey == null)) + { + throw new MessagePackGeneratorResolveFailedException("all members key type must be same." + " type: " + type.Name + " member:" + item.Name); + } } - var member = new MemberSerializationInfo(true, isWritable, isReadable, intKey!.Value, item.Name, item.Name, item.Type.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat), item.Type.ToDisplayString(BinaryWriteFormat), customFormatterAttr?.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat)); - intMembers.Add(member.IntKey, member); - } - else - { - if (stringMembers.ContainsKey(stringKey!)) + if (isIntKey) { - throw new MessagePackGeneratorResolveFailedException("key is duplicated, all members key must be unique." + " type: " + type.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat) + " member:" + item.Name); + if (intMembers.ContainsKey(intKey!.Value)) + { + throw new MessagePackGeneratorResolveFailedException("key is duplicated, all members key must be unique." + " type: " + type.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat) + " member:" + item.Name); + } + + var member = new MemberSerializationInfo(true, isWritable, isReadable, intKey!.Value, item.Name, item.Name, item.Type.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat), item.Type.ToDisplayString(BinaryWriteFormat), customFormatterAttr?.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat)); + intMembers.Add(member.IntKey, member); } + else + { + if (stringMembers.ContainsKey(stringKey!)) + { + throw new MessagePackGeneratorResolveFailedException("key is duplicated, all members key must be unique." + " type: " + type.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat) + " member:" + item.Name); + } - var member = new MemberSerializationInfo(true, isWritable, isReadable, hiddenIntKey++, stringKey!, item.Name, item.Type.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat), item.Type.ToDisplayString(BinaryWriteFormat), customFormatterAttr?.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat)); - stringMembers.Add(member.StringKey, member); + var member = new MemberSerializationInfo(true, isWritable, isReadable, hiddenIntKey++, stringKey!, item.Name, item.Type.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat), item.Type.ToDisplayString(BinaryWriteFormat), customFormatterAttr?.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat)); + stringMembers.Add(member.StringKey, member); + } } this.CollectCore(item.Type); // recursive collect @@ -969,7 +1032,10 @@ private ObjectSerializationInfo GetObjectInfo(INamedTypeSymbol type) needsCastOnAfter = !type.GetMembers("OnAfterDeserialize").Any(); } - var info = new ObjectSerializationInfo(isClass, isOpenGenericType, isOpenGenericType ? type.TypeParameters.Select(ToGenericTypeParameterInfo).ToArray() : Array.Empty(), constructorParameters.ToArray(), isIntKey, isIntKey ? intMembers.Values.ToArray() : stringMembers.Values.ToArray(), isOpenGenericType ? GetGenericFormatterClassName(type) : GetMinimallyQualifiedClassName(type), type.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat), type.ContainingNamespace.IsGlobalNamespace ? null : type.ContainingNamespace.ToDisplayString(), hasSerializationConstructor, needsCastOnAfter, needsCastOnBefore); + ObjectSerializationInfo info = new(isClass, isOpenGenericType, isOpenGenericType ? type.TypeParameters.Select(ToGenericTypeParameterInfo).ToArray() : Array.Empty(), constructorParameters.ToArray(), isIntKey, isIntKey ? intMembers.Values.ToArray() : stringMembers.Values.ToArray(), isOpenGenericType ? GetGenericFormatterClassName(type) : GetMinimallyQualifiedClassName(type), type.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat), type.ContainingNamespace.IsGlobalNamespace ? null : type.ContainingNamespace.ToDisplayString(), hasSerializationConstructor, needsCastOnAfter, needsCastOnBefore) + { + Diagnostics = diagnostics, + }; return info; } diff --git a/src/MessagePack.Generator/CodeAnalysis/UnionSerializationInfo.cs b/src/MessagePack.Generator/CodeAnalysis/UnionSerializationInfo.cs index ccce69505..25bab861e 100644 --- a/src/MessagePack.Generator/CodeAnalysis/UnionSerializationInfo.cs +++ b/src/MessagePack.Generator/CodeAnalysis/UnionSerializationInfo.cs @@ -2,6 +2,7 @@ // Licensed under the MIT license. See LICENSE file in the project root for full license information. using System.Xml.Linq; +using Microsoft.CodeAnalysis; namespace MessagePack.Generator.CodeAnalysis; @@ -11,6 +12,8 @@ public record UnionSerializationInfo( string FullName, UnionSubTypeInfo[] SubTypes) : IResolverRegisterInfo { + public IReadOnlyCollection Diagnostics { get; init; } = Array.Empty(); + public string FileNameHint => $"{CodeAnalysisUtilities.AppendNameToNamespace("Formatters", this.Namespace)}.{this.FormatterNameWithoutNamespace}"; public string FormatterName => CodeAnalysisUtilities.QualifyWithOptionalNamespace(FormatterNameWithoutNamespace, $"Formatters::{this.Namespace}"); diff --git a/src/MessagePack.Generator/MessagePack.Generator.csproj b/src/MessagePack.Generator/MessagePack.Generator.csproj index 1b0dff562..2365156d2 100644 --- a/src/MessagePack.Generator/MessagePack.Generator.csproj +++ b/src/MessagePack.Generator/MessagePack.Generator.csproj @@ -38,6 +38,16 @@ + + + + + + + + + + diff --git a/src/MessagePack.Generator/MessagePackGenerator.Emit.cs b/src/MessagePack.Generator/MessagePackGenerator.Emit.cs index 71b73c2cb..4332d2a7c 100644 --- a/src/MessagePack.Generator/MessagePackGenerator.Emit.cs +++ b/src/MessagePack.Generator/MessagePackGenerator.Emit.cs @@ -31,12 +31,14 @@ private static void Generate(IGeneratorContext context, FullModel model) { EnumTemplate transform = new(options, info); AddTransform(transform.TransformText(), transform.FileName); + TransferDiagnostics(info); } foreach (UnionSerializationInfo info in model.UnionInfos) { UnionTemplate transform = new(options, info); AddTransform(transform.TransformText(), transform.FileName); + TransferDiagnostics(info); } foreach (ObjectSerializationInfo info in model.ObjectInfos) @@ -45,6 +47,15 @@ private static void Generate(IGeneratorContext context, FullModel model) ? new StringKeyFormatterTemplate(options, info) : new FormatterTemplate(options, info); AddTransform(transform.TransformText(), transform.FileName); + TransferDiagnostics(info); + } + + void TransferDiagnostics(IResolverRegisterInfo info) + { + foreach (Diagnostic diagnostic in info.Diagnostics) + { + context.ReportDiagnostic(diagnostic); + } } void AddTransform(string transformOutput, string uniqueFileName) diff --git a/tests/MessagePack.Generator.Tests/GenerationTests.cs b/tests/MessagePack.Generator.Tests/GenerationTests.cs index 128dfba16..54638ab22 100644 --- a/tests/MessagePack.Generator.Tests/GenerationTests.cs +++ b/tests/MessagePack.Generator.Tests/GenerationTests.cs @@ -6,6 +6,10 @@ public class GenerationTests { + private const string Preamble = @" +using MessagePack; +"; + private readonly ITestOutputHelper testOutputHelper; public GenerationTests(ITestOutputHelper testOutputHelper) @@ -141,4 +145,55 @@ internal class MyGenericType """; await VerifyCS.Test.RunDefaultAsync(testSource); } + + [Fact] + public async Task NullStringKey() + { + string testSource = Preamble + @" +[MessagePackObject] +public class Foo +{ + [Key(null)] + public string {|MsgPack005:Member|} { get; set; } +} +"; + + await VerifyCS.Test.RunDefaultAsync(testSource); + } + + [Fact] + public async Task MembersNeedAttributes() + { + string testSource = Preamble + @" +[MessagePackObject] +public class Foo +{ + public string {|MsgPack004:Member1|} { get; set; } + public string {|MsgPack004:Member2|} { get; set; } +} +"; + + await VerifyCS.Test.RunDefaultAsync(testSource); + } + + [Fact] + public async Task AddAttributeToType() + { + // Don't use Preamble because we want to test that it works without a using statement at the top. + string testSource = @" +public class {|MsgPack003:Foo|} +{ + public string Member { get; set; } +} + +[MessagePack.MessagePackObject] +public class Bar +{ + [MessagePack.Key(0)] + public Foo Member { get; set; } +} +"; + + await VerifyCS.Test.RunDefaultAsync(testSource); + } } diff --git a/tests/MessagePack.Generator.Tests/Resources/AddAttributeToType/Formatters.BarFormatter.g.cs b/tests/MessagePack.Generator.Tests/Resources/AddAttributeToType/Formatters.BarFormatter.g.cs new file mode 100644 index 000000000..62821ed0a --- /dev/null +++ b/tests/MessagePack.Generator.Tests/Resources/AddAttributeToType/Formatters.BarFormatter.g.cs @@ -0,0 +1,54 @@ +// + +#pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 + +namespace Formatters +{ + using MsgPack = global::MessagePack; + + internal sealed class BarFormatter : MsgPack::Formatters.IMessagePackFormatter + { + + public void Serialize(ref MsgPack::MessagePackWriter writer, global::Bar value, MsgPack::MessagePackSerializerOptions options) + { + if (value == null) + { + writer.WriteNil(); + return; + } + + MsgPack::IFormatterResolver formatterResolver = options.Resolver; + writer.WriteArrayHeader(1); + MsgPack::FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Serialize(ref writer, value.Member, options); + } + + public global::Bar Deserialize(ref MsgPack::MessagePackReader reader, MsgPack::MessagePackSerializerOptions options) + { + if (reader.TryReadNil()) + { + return null; + } + + options.Security.DepthStep(ref reader); + MsgPack::IFormatterResolver formatterResolver = options.Resolver; + var length = reader.ReadArrayHeader(); + var ____result = new global::Bar(); + + for (int i = 0; i < length; i++) + { + switch (i) + { + case 0: + ____result.Member = MsgPack::FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Deserialize(ref reader, options); + break; + default: + reader.Skip(); + break; + } + } + + reader.Depth--; + return ____result; + } + } +} diff --git a/tests/MessagePack.Generator.Tests/Resources/AddAttributeToType/Formatters.FooFormatter.g.cs b/tests/MessagePack.Generator.Tests/Resources/AddAttributeToType/Formatters.FooFormatter.g.cs new file mode 100644 index 000000000..51d60277d --- /dev/null +++ b/tests/MessagePack.Generator.Tests/Resources/AddAttributeToType/Formatters.FooFormatter.g.cs @@ -0,0 +1,34 @@ +// + +#pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 + +namespace Formatters +{ + using MsgPack = global::MessagePack; + + internal sealed class FooFormatter : MsgPack::Formatters.IMessagePackFormatter + { + + public void Serialize(ref MsgPack::MessagePackWriter writer, global::Foo value, MsgPack::MessagePackSerializerOptions options) + { + if (value == null) + { + writer.WriteNil(); + return; + } + + writer.WriteArrayHeader(0); + } + + public global::Foo Deserialize(ref MsgPack::MessagePackReader reader, MsgPack::MessagePackSerializerOptions options) + { + if (reader.TryReadNil()) + { + return null; + } + + reader.Skip(); + return new global::Foo(); + } + } +} diff --git a/tests/MessagePack.Generator.Tests/Resources/AddAttributeToType/MessagePack.GeneratedMessagePackResolver.g.cs b/tests/MessagePack.Generator.Tests/Resources/AddAttributeToType/MessagePack.GeneratedMessagePackResolver.g.cs new file mode 100644 index 000000000..e4b9452a9 --- /dev/null +++ b/tests/MessagePack.Generator.Tests/Resources/AddAttributeToType/MessagePack.GeneratedMessagePackResolver.g.cs @@ -0,0 +1,72 @@ +// + +#pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 + +namespace MessagePack +{ + using MsgPack = global::MessagePack; + using Formatters = global::Formatters; + + /// A MessagePack resolver that uses generated formatters for types in this assembly. + internal class GeneratedMessagePackResolver : MsgPack::IFormatterResolver + { + /// An instance of this resolver that only returns formatters specifically generated for types in this assembly. + public static readonly MsgPack::IFormatterResolver Instance = new GeneratedMessagePackResolver(); + + /// An instance of this resolver that returns standard AOT-compatible formatters as well as formatters specifically generated for types in this assembly. + public static readonly MsgPack::IFormatterResolver InstanceWithStandardAotResolver = MsgPack::Resolvers.CompositeResolver.Create(Instance, MsgPack::Resolvers.StandardAotResolver.Instance); + + private GeneratedMessagePackResolver() + { + } + + public MsgPack::Formatters.IMessagePackFormatter GetFormatter() + { + return FormatterCache.Formatter; + } + + private static class FormatterCache + { + internal static readonly MsgPack::Formatters.IMessagePackFormatter Formatter; + + static FormatterCache() + { + var f = GeneratedMessagePackResolverGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + Formatter = (MsgPack::Formatters.IMessagePackFormatter)f; + } + } + } + } + + internal static class GeneratedMessagePackResolverGetFormatterHelper + { + private static readonly global::System.Collections.Generic.Dictionary lookup; + + static GeneratedMessagePackResolverGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(2) + { + { typeof(global::Bar), 0 }, + { typeof(global::Foo), 1 }, + }; + } + + internal static object GetFormatter(global::System.Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + case 0: return new Formatters::BarFormatter(); + case 1: return new Formatters::FooFormatter(); + default: return null; + } + } + } +} diff --git a/tests/MessagePack.Generator.Tests/Resources/MembersNeedAttributes/Formatters.FooFormatter.g.cs b/tests/MessagePack.Generator.Tests/Resources/MembersNeedAttributes/Formatters.FooFormatter.g.cs new file mode 100644 index 000000000..51d60277d --- /dev/null +++ b/tests/MessagePack.Generator.Tests/Resources/MembersNeedAttributes/Formatters.FooFormatter.g.cs @@ -0,0 +1,34 @@ +// + +#pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 + +namespace Formatters +{ + using MsgPack = global::MessagePack; + + internal sealed class FooFormatter : MsgPack::Formatters.IMessagePackFormatter + { + + public void Serialize(ref MsgPack::MessagePackWriter writer, global::Foo value, MsgPack::MessagePackSerializerOptions options) + { + if (value == null) + { + writer.WriteNil(); + return; + } + + writer.WriteArrayHeader(0); + } + + public global::Foo Deserialize(ref MsgPack::MessagePackReader reader, MsgPack::MessagePackSerializerOptions options) + { + if (reader.TryReadNil()) + { + return null; + } + + reader.Skip(); + return new global::Foo(); + } + } +} diff --git a/tests/MessagePack.Generator.Tests/Resources/MembersNeedAttributes/MessagePack.GeneratedMessagePackResolver.g.cs b/tests/MessagePack.Generator.Tests/Resources/MembersNeedAttributes/MessagePack.GeneratedMessagePackResolver.g.cs new file mode 100644 index 000000000..cf20c2721 --- /dev/null +++ b/tests/MessagePack.Generator.Tests/Resources/MembersNeedAttributes/MessagePack.GeneratedMessagePackResolver.g.cs @@ -0,0 +1,70 @@ +// + +#pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 + +namespace MessagePack +{ + using MsgPack = global::MessagePack; + using Formatters = global::Formatters; + + /// A MessagePack resolver that uses generated formatters for types in this assembly. + internal class GeneratedMessagePackResolver : MsgPack::IFormatterResolver + { + /// An instance of this resolver that only returns formatters specifically generated for types in this assembly. + public static readonly MsgPack::IFormatterResolver Instance = new GeneratedMessagePackResolver(); + + /// An instance of this resolver that returns standard AOT-compatible formatters as well as formatters specifically generated for types in this assembly. + public static readonly MsgPack::IFormatterResolver InstanceWithStandardAotResolver = MsgPack::Resolvers.CompositeResolver.Create(Instance, MsgPack::Resolvers.StandardAotResolver.Instance); + + private GeneratedMessagePackResolver() + { + } + + public MsgPack::Formatters.IMessagePackFormatter GetFormatter() + { + return FormatterCache.Formatter; + } + + private static class FormatterCache + { + internal static readonly MsgPack::Formatters.IMessagePackFormatter Formatter; + + static FormatterCache() + { + var f = GeneratedMessagePackResolverGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + Formatter = (MsgPack::Formatters.IMessagePackFormatter)f; + } + } + } + } + + internal static class GeneratedMessagePackResolverGetFormatterHelper + { + private static readonly global::System.Collections.Generic.Dictionary lookup; + + static GeneratedMessagePackResolverGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(1) + { + { typeof(global::Foo), 0 }, + }; + } + + internal static object GetFormatter(global::System.Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + case 0: return new Formatters::FooFormatter(); + default: return null; + } + } + } +} diff --git a/tests/MessagePack.Generator.Tests/Resources/NullStringKey/Formatters.FooFormatter.g.cs b/tests/MessagePack.Generator.Tests/Resources/NullStringKey/Formatters.FooFormatter.g.cs new file mode 100644 index 000000000..78d614fe2 --- /dev/null +++ b/tests/MessagePack.Generator.Tests/Resources/NullStringKey/Formatters.FooFormatter.g.cs @@ -0,0 +1,34 @@ +// + +#pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 + +namespace Formatters +{ + using MsgPack = global::MessagePack; + + internal sealed class FooFormatter : global::MessagePack.Formatters.IMessagePackFormatter + { + public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::Foo value, global::MessagePack.MessagePackSerializerOptions options) + { + if (value is null) + { + writer.WriteNil(); + return; + } + + writer.WriteMapHeader(0); + } + + public global::Foo Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) + { + if (reader.TryReadNil()) + { + return null; + } + + reader.Skip(); + var ____result = new global::Foo(); + return ____result; + } + } +} diff --git a/tests/MessagePack.Generator.Tests/Resources/NullStringKey/MessagePack.GeneratedMessagePackResolver.g.cs b/tests/MessagePack.Generator.Tests/Resources/NullStringKey/MessagePack.GeneratedMessagePackResolver.g.cs new file mode 100644 index 000000000..cf20c2721 --- /dev/null +++ b/tests/MessagePack.Generator.Tests/Resources/NullStringKey/MessagePack.GeneratedMessagePackResolver.g.cs @@ -0,0 +1,70 @@ +// + +#pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 + +namespace MessagePack +{ + using MsgPack = global::MessagePack; + using Formatters = global::Formatters; + + /// A MessagePack resolver that uses generated formatters for types in this assembly. + internal class GeneratedMessagePackResolver : MsgPack::IFormatterResolver + { + /// An instance of this resolver that only returns formatters specifically generated for types in this assembly. + public static readonly MsgPack::IFormatterResolver Instance = new GeneratedMessagePackResolver(); + + /// An instance of this resolver that returns standard AOT-compatible formatters as well as formatters specifically generated for types in this assembly. + public static readonly MsgPack::IFormatterResolver InstanceWithStandardAotResolver = MsgPack::Resolvers.CompositeResolver.Create(Instance, MsgPack::Resolvers.StandardAotResolver.Instance); + + private GeneratedMessagePackResolver() + { + } + + public MsgPack::Formatters.IMessagePackFormatter GetFormatter() + { + return FormatterCache.Formatter; + } + + private static class FormatterCache + { + internal static readonly MsgPack::Formatters.IMessagePackFormatter Formatter; + + static FormatterCache() + { + var f = GeneratedMessagePackResolverGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + Formatter = (MsgPack::Formatters.IMessagePackFormatter)f; + } + } + } + } + + internal static class GeneratedMessagePackResolverGetFormatterHelper + { + private static readonly global::System.Collections.Generic.Dictionary lookup; + + static GeneratedMessagePackResolverGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(1) + { + { typeof(global::Foo), 0 }, + }; + } + + internal static object GetFormatter(global::System.Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + case 0: return new Formatters::FooFormatter(); + default: return null; + } + } + } +} From eefab662ff8bde4674fdbc7bb4eb2ac1bec29753 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Thu, 6 Apr 2023 06:48:46 -0600 Subject: [PATCH 077/660] Fix up roslyn3 package to contain all the necessary files --- MessagePack.sln | 1 + .../MessagePack.Generator.Roslyn3.csproj | 27 ++++++++------ .../MessagePack.Generator.csproj | 35 +----------------- src/SourceGenerator.props | 37 +++++++++++++++++++ 4 files changed, 56 insertions(+), 44 deletions(-) create mode 100644 src/SourceGenerator.props diff --git a/MessagePack.sln b/MessagePack.sln index 0784b9aea..f3447a9a8 100644 --- a/MessagePack.sln +++ b/MessagePack.sln @@ -7,6 +7,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{86309CF6-005 ProjectSection(SolutionItems) = preProject src\Directory.Build.props = src\Directory.Build.props src\Directory.Build.targets = src\Directory.Build.targets + src\SourceGenerator.props = src\SourceGenerator.props EndProjectSection EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MessagePack", "src\MessagePack\MessagePack.csproj", "{7ABB33EE-A2F1-492B-8DAF-5DF89F0F0B79}" diff --git a/src/MessagePack.Generator.Roslyn3/MessagePack.Generator.Roslyn3.csproj b/src/MessagePack.Generator.Roslyn3/MessagePack.Generator.Roslyn3.csproj index c5e5b9cc3..f7df5cb00 100644 --- a/src/MessagePack.Generator.Roslyn3/MessagePack.Generator.Roslyn3.csproj +++ b/src/MessagePack.Generator.Roslyn3/MessagePack.Generator.Roslyn3.csproj @@ -1,28 +1,33 @@  + + - netstandard2.0 - 11 - enable - enable ROSLYN3 - cs 3.9.0 - MessagePack.Generator MessagePack Code Generator MessagePack standalone code generator. - MsgPack;MessagePack;Serialization;Formatter;Serializer;Unity;Xamarin + $(PackageTags);Unity;Xamarin - - - - + + true + build\ + + + build\$(PackageId).props + + + build\$(PackageId).targets + + + + diff --git a/src/MessagePack.Generator/MessagePack.Generator.csproj b/src/MessagePack.Generator/MessagePack.Generator.csproj index 2365156d2..431aef6c3 100644 --- a/src/MessagePack.Generator/MessagePack.Generator.csproj +++ b/src/MessagePack.Generator/MessagePack.Generator.csproj @@ -1,37 +1,15 @@  + + - netstandard2.0 - 11 - enable - enable - cs - - - true - false - embedded - false - true - true - $(TargetsForTfmSpecificContentInPackage);PackBuildOutputs - MessagePack.Generator MessagePack Code Generator MessagePack C# source generator. - MsgPack;MessagePack;Serialization;Formatter;Serializer;Unity;Xamarin - - - - - - - - true build\ @@ -111,13 +89,4 @@ - - - - - - - - - diff --git a/src/SourceGenerator.props b/src/SourceGenerator.props new file mode 100644 index 000000000..c80383429 --- /dev/null +++ b/src/SourceGenerator.props @@ -0,0 +1,37 @@ + + + netstandard2.0 + 11 + enable + enable + cs + + + true + false + embedded + false + true + true + $(TargetsForTfmSpecificContentInPackage);PackBuildOutputs + + MsgPack;MessagePack;Serialization;Formatter;Serializer + + + + + + + + + + + + + + + + + + + From 14f5628d5a2fcc684536b4212495c06e56c6abce Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Thu, 6 Apr 2023 06:52:07 -0600 Subject: [PATCH 078/660] Clean up generator project files a bit more --- .../MessagePack.Generator.Roslyn3.csproj | 7 +------ src/MessagePack.Generator/MessagePack.Generator.csproj | 5 +---- src/SourceGenerator.props | 1 + 3 files changed, 3 insertions(+), 10 deletions(-) diff --git a/src/MessagePack.Generator.Roslyn3/MessagePack.Generator.Roslyn3.csproj b/src/MessagePack.Generator.Roslyn3/MessagePack.Generator.Roslyn3.csproj index f7df5cb00..2ea7210f5 100644 --- a/src/MessagePack.Generator.Roslyn3/MessagePack.Generator.Roslyn3.csproj +++ b/src/MessagePack.Generator.Roslyn3/MessagePack.Generator.Roslyn3.csproj @@ -9,8 +9,7 @@ 3.9.0 - MessagePack Code Generator - MessagePack standalone code generator. + MessagePack Source Generator for Unity $(PackageTags);Unity;Xamarin @@ -27,10 +26,6 @@ - - - - diff --git a/src/MessagePack.Generator/MessagePack.Generator.csproj b/src/MessagePack.Generator/MessagePack.Generator.csproj index 431aef6c3..730b55daf 100644 --- a/src/MessagePack.Generator/MessagePack.Generator.csproj +++ b/src/MessagePack.Generator/MessagePack.Generator.csproj @@ -3,10 +3,7 @@ - - - MessagePack Code Generator - MessagePack C# source generator. + MessagePack Source Generator diff --git a/src/SourceGenerator.props b/src/SourceGenerator.props index c80383429..b7d5a949d 100644 --- a/src/SourceGenerator.props +++ b/src/SourceGenerator.props @@ -16,6 +16,7 @@ $(TargetsForTfmSpecificContentInPackage);PackBuildOutputs MsgPack;MessagePack;Serialization;Formatter;Serializer + A roslyn source generator for AOT or faster startup of applications that use the MessagePack nuget package. From 8eb42aa84aad6b92326ccd9b9de90b711ee4f9b0 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Thu, 6 Apr 2023 06:55:48 -0600 Subject: [PATCH 079/660] Downgrade unity package to Roslyn 3.8 --- .../MessagePack.Generator.Roslyn3.csproj | 2 +- .../MessagePackGenerator.cs | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/MessagePack.Generator.Roslyn3/MessagePack.Generator.Roslyn3.csproj b/src/MessagePack.Generator.Roslyn3/MessagePack.Generator.Roslyn3.csproj index 2ea7210f5..b65471b3f 100644 --- a/src/MessagePack.Generator.Roslyn3/MessagePack.Generator.Roslyn3.csproj +++ b/src/MessagePack.Generator.Roslyn3/MessagePack.Generator.Roslyn3.csproj @@ -6,7 +6,7 @@ ROSLYN3 - 3.9.0 + 3.8.0 MessagePack Source Generator for Unity diff --git a/src/MessagePack.Generator.Roslyn3/MessagePackGenerator.cs b/src/MessagePack.Generator.Roslyn3/MessagePackGenerator.cs index f80c5aa6f..687b7609d 100644 --- a/src/MessagePack.Generator.Roslyn3/MessagePackGenerator.cs +++ b/src/MessagePack.Generator.Roslyn3/MessagePackGenerator.cs @@ -8,7 +8,7 @@ namespace MessagePack.Generator; -[Generator(LanguageNames.CSharp)] +[Generator] public partial class MessagePackGenerator : ISourceGenerator { public const string MessagePackObjectAttributeFullName = "MessagePack.MessagePackObjectAttribute"; @@ -20,7 +20,7 @@ public void Initialize(GeneratorInitializationContext context) public void Execute(GeneratorExecutionContext context) { - if (context.SyntaxContextReceiver is not SyntaxContextReceiver receiver || receiver.ClassDeclarations.Count == 0) + if (context.SyntaxReceiver is not SyntaxContextReceiver receiver || receiver.ClassDeclarations.Count == 0) { return; } @@ -43,18 +43,18 @@ public void Execute(GeneratorExecutionContext context) GenerateResolver(generateContext, fullModel); } - private class SyntaxContextReceiver : ISyntaxContextReceiver + private class SyntaxContextReceiver : ISyntaxReceiver { - internal static ISyntaxContextReceiver Create() + internal static ISyntaxReceiver Create() { return new SyntaxContextReceiver(); } public HashSet ClassDeclarations { get; } = new(); - public void OnVisitSyntaxNode(GeneratorSyntaxContext context) + public void OnVisitSyntaxNode(SyntaxNode context) { - if (context.Node is TypeDeclarationSyntax typeSyntax) + if (context is TypeDeclarationSyntax typeSyntax) { if (typeSyntax.AttributeLists.Count > 0) { From 8673cd6eee185e3a63f6ed60373974b9c9703982 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Thu, 6 Apr 2023 09:43:08 -0600 Subject: [PATCH 080/660] Add built-in formatters for several more System.Numerics types --- .../StandardClassLibraryFormatter.cs | 206 ++++++++++++++++-- .../MessagePack/Resolvers/BuiltinResolver.cs | 12 + .../net6.0/PublicAPI.Unshipped.txt | 24 ++ .../netstandard2.0/PublicAPI.Unshipped.txt | 24 ++ 4 files changed, 253 insertions(+), 13 deletions(-) diff --git a/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Formatters/StandardClassLibraryFormatter.cs b/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Formatters/StandardClassLibraryFormatter.cs index 9bceeacdb..ede8e3f3b 100644 --- a/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Formatters/StandardClassLibraryFormatter.cs +++ b/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Formatters/StandardClassLibraryFormatter.cs @@ -6,6 +6,7 @@ using System.Collections; using System.Collections.Generic; using System.Globalization; +using System.Numerics; using System.Text; using MessagePack.Internal; @@ -488,15 +489,15 @@ public void Serialize(ref MessagePackWriter writer, BitArray? value, MessagePack } } - public sealed class BigIntegerFormatter : IMessagePackFormatter + public sealed class BigIntegerFormatter : IMessagePackFormatter { - public static readonly IMessagePackFormatter Instance = new BigIntegerFormatter(); + public static readonly IMessagePackFormatter Instance = new BigIntegerFormatter(); private BigIntegerFormatter() { } - public void Serialize(ref MessagePackWriter writer, System.Numerics.BigInteger value, MessagePackSerializerOptions options) + public void Serialize(ref MessagePackWriter writer, BigInteger value, MessagePackSerializerOptions options) { #if NETCOREAPP if (!writer.OldSpec) @@ -523,13 +524,13 @@ public void Serialize(ref MessagePackWriter writer, System.Numerics.BigInteger v return; } - public System.Numerics.BigInteger Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options) + public BigInteger Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options) { - ReadOnlySequence bytes = reader.ReadBytes() ?? throw MessagePackSerializationException.ThrowUnexpectedNilWhileDeserializing(); + ReadOnlySequence bytes = reader.ReadBytes() ?? throw MessagePackSerializationException.ThrowUnexpectedNilWhileDeserializing(); #if NETCOREAPP if (bytes.IsSingleSegment) { - return new System.Numerics.BigInteger(bytes.First.Span); + return new BigInteger(bytes.First.Span); } else { @@ -537,7 +538,7 @@ public System.Numerics.BigInteger Deserialize(ref MessagePackReader reader, Mess try { bytes.CopyTo(bytesArray); - return new System.Numerics.BigInteger(bytesArray.AsSpan(0, (int)bytes.Length)); + return new BigInteger(bytesArray.AsSpan(0, (int)bytes.Length)); } finally { @@ -545,20 +546,20 @@ public System.Numerics.BigInteger Deserialize(ref MessagePackReader reader, Mess } } #else - return new System.Numerics.BigInteger(bytes.ToArray()); + return new BigInteger(bytes.ToArray()); #endif } } - public sealed class ComplexFormatter : IMessagePackFormatter + public sealed class ComplexFormatter : IMessagePackFormatter { - public static readonly IMessagePackFormatter Instance = new ComplexFormatter(); + public static readonly IMessagePackFormatter Instance = new ComplexFormatter(); private ComplexFormatter() { } - public void Serialize(ref MessagePackWriter writer, System.Numerics.Complex value, MessagePackSerializerOptions options) + public void Serialize(ref MessagePackWriter writer, Complex value, MessagePackSerializerOptions options) { writer.WriteArrayHeader(2); writer.Write(value.Real); @@ -566,7 +567,7 @@ public void Serialize(ref MessagePackWriter writer, System.Numerics.Complex valu return; } - public System.Numerics.Complex Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options) + public Complex Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options) { var count = reader.ReadArrayHeader(); @@ -579,7 +580,186 @@ public System.Numerics.Complex Deserialize(ref MessagePackReader reader, Message var imaginary = reader.ReadDouble(); - return new System.Numerics.Complex(real, imaginary); + return new Complex(real, imaginary); + } + } + + public sealed class Vector2Formatter : IMessagePackFormatter + { + public static readonly IMessagePackFormatter Instance = new Vector2Formatter(); + + private Vector2Formatter() + { + } + + public void Serialize(ref MessagePackWriter writer, Vector2 value, MessagePackSerializerOptions options) + { + writer.WriteArrayHeader(2); + writer.Write(value.X); + writer.Write(value.Y); + } + + public Vector2 Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options) + { + if (reader.ReadArrayHeader() != 2) + { + throw new MessagePackSerializationException("Invalid Vector2 data."); + } + + return new Vector2(reader.ReadSingle(), reader.ReadSingle()); + } + } + + public sealed class Vector3Formatter : IMessagePackFormatter + { + public static readonly IMessagePackFormatter Instance = new Vector3Formatter(); + + private Vector3Formatter() + { + } + + public void Serialize(ref MessagePackWriter writer, Vector3 value, MessagePackSerializerOptions options) + { + writer.WriteArrayHeader(3); + writer.Write(value.X); + writer.Write(value.Y); + writer.Write(value.Z); + } + + public Vector3 Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options) + { + if (reader.ReadArrayHeader() != 3) + { + throw new MessagePackSerializationException("Invalid Vector3 data."); + } + + return new Vector3(reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle()); + } + } + + public sealed class Vector4Formatter : IMessagePackFormatter + { + public static readonly IMessagePackFormatter Instance = new Vector4Formatter(); + + private Vector4Formatter() + { + } + + public void Serialize(ref MessagePackWriter writer, Vector4 value, MessagePackSerializerOptions options) + { + writer.WriteArrayHeader(4); + writer.Write(value.X); + writer.Write(value.Y); + writer.Write(value.Z); + writer.Write(value.W); + } + + public Vector4 Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options) + { + if (reader.ReadArrayHeader() != 4) + { + throw new MessagePackSerializationException("Invalid Vector4 data."); + } + + return new Vector4(reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle()); + } + } + + public sealed class QuaternionFormatter : IMessagePackFormatter + { + public static readonly IMessagePackFormatter Instance = new QuaternionFormatter(); + + private QuaternionFormatter() + { + } + + public void Serialize(ref MessagePackWriter writer, Quaternion value, MessagePackSerializerOptions options) + { + writer.WriteArrayHeader(4); + writer.Write(value.X); + writer.Write(value.Y); + writer.Write(value.Z); + writer.Write(value.W); + } + + public Quaternion Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options) + { + if (reader.ReadArrayHeader() != 4) + { + throw new MessagePackSerializationException("Invalid Quaternion data."); + } + + return new Quaternion(reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle()); + } + } + + public sealed class Matrix3x2Formatter : IMessagePackFormatter + { + public static readonly IMessagePackFormatter Instance = new Matrix3x2Formatter(); + + private Matrix3x2Formatter() + { + } + + public void Serialize(ref MessagePackWriter writer, Matrix3x2 value, MessagePackSerializerOptions options) + { + writer.WriteArrayHeader(6); + writer.Write(value.M11); + writer.Write(value.M12); + writer.Write(value.M21); + writer.Write(value.M22); + writer.Write(value.M31); + writer.Write(value.M32); + } + + public Matrix3x2 Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options) + { + if (reader.ReadArrayHeader() != 6) + { + throw new MessagePackSerializationException("Invalid Matrix3x2 data."); + } + + return new Matrix3x2(reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle()); + } + } + + public sealed class Matrix4x4Formatter : IMessagePackFormatter + { + public static readonly IMessagePackFormatter Instance = new Matrix4x4Formatter(); + + private Matrix4x4Formatter() + { + } + + public void Serialize(ref MessagePackWriter writer, Matrix4x4 value, MessagePackSerializerOptions options) + { + writer.WriteArrayHeader(16); + writer.Write(value.M11); + writer.Write(value.M12); + writer.Write(value.M13); + writer.Write(value.M14); + writer.Write(value.M21); + writer.Write(value.M22); + writer.Write(value.M23); + writer.Write(value.M24); + writer.Write(value.M31); + writer.Write(value.M32); + writer.Write(value.M33); + writer.Write(value.M34); + writer.Write(value.M41); + writer.Write(value.M42); + writer.Write(value.M43); + writer.Write(value.M44); + } + + public Matrix4x4 Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options) + { + if (reader.ReadArrayHeader() != 16) + { + throw new MessagePackSerializationException("Invalid Matrix4x4 data."); + } + + return new Matrix4x4(reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle()); } } diff --git a/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Resolvers/BuiltinResolver.cs b/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Resolvers/BuiltinResolver.cs index edf82e28c..1f5da3a47 100644 --- a/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Resolvers/BuiltinResolver.cs +++ b/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Resolvers/BuiltinResolver.cs @@ -156,6 +156,18 @@ internal static class BuiltinResolverGetFormatterHelper { typeof(System.Numerics.BigInteger?), new StaticNullableFormatter(BigIntegerFormatter.Instance) }, { typeof(System.Numerics.Complex), ComplexFormatter.Instance }, { typeof(System.Numerics.Complex?), new StaticNullableFormatter(ComplexFormatter.Instance) }, + { typeof(System.Numerics.Vector2), Vector2Formatter.Instance }, + { typeof(System.Numerics.Vector2?), new StaticNullableFormatter(Vector2Formatter.Instance) }, + { typeof(System.Numerics.Vector3), Vector3Formatter.Instance }, + { typeof(System.Numerics.Vector3?), new StaticNullableFormatter(Vector3Formatter.Instance) }, + { typeof(System.Numerics.Vector4), Vector4Formatter.Instance }, + { typeof(System.Numerics.Vector4?), new StaticNullableFormatter(Vector4Formatter.Instance) }, + { typeof(System.Numerics.Quaternion), QuaternionFormatter.Instance }, + { typeof(System.Numerics.Quaternion?), new StaticNullableFormatter(QuaternionFormatter.Instance) }, + { typeof(System.Numerics.Matrix3x2), Matrix3x2Formatter.Instance }, + { typeof(System.Numerics.Matrix3x2?), new StaticNullableFormatter(Matrix3x2Formatter.Instance) }, + { typeof(System.Numerics.Matrix4x4), Matrix4x4Formatter.Instance }, + { typeof(System.Numerics.Matrix4x4?), new StaticNullableFormatter(Matrix4x4Formatter.Instance) }, #if NET5_0_OR_GREATER { typeof(System.Half), HalfFormatter.Instance }, diff --git a/src/MessagePack/net6.0/PublicAPI.Unshipped.txt b/src/MessagePack/net6.0/PublicAPI.Unshipped.txt index 432231fd1..c43d3b317 100644 --- a/src/MessagePack/net6.0/PublicAPI.Unshipped.txt +++ b/src/MessagePack/net6.0/PublicAPI.Unshipped.txt @@ -1,6 +1,15 @@ MessagePack.Formatters.DateOnlyFormatter MessagePack.Formatters.DateOnlyFormatter.Deserialize(ref MessagePack.MessagePackReader reader, MessagePack.MessagePackSerializerOptions! options) -> System.DateOnly MessagePack.Formatters.DateOnlyFormatter.Serialize(ref MessagePack.MessagePackWriter writer, System.DateOnly value, MessagePack.MessagePackSerializerOptions! options) -> void +MessagePack.Formatters.Matrix3x2Formatter +MessagePack.Formatters.Matrix3x2Formatter.Deserialize(ref MessagePack.MessagePackReader reader, MessagePack.MessagePackSerializerOptions! options) -> System.Numerics.Matrix3x2 +MessagePack.Formatters.Matrix3x2Formatter.Serialize(ref MessagePack.MessagePackWriter writer, System.Numerics.Matrix3x2 value, MessagePack.MessagePackSerializerOptions! options) -> void +MessagePack.Formatters.Matrix4x4Formatter +MessagePack.Formatters.Matrix4x4Formatter.Deserialize(ref MessagePack.MessagePackReader reader, MessagePack.MessagePackSerializerOptions! options) -> System.Numerics.Matrix4x4 +MessagePack.Formatters.Matrix4x4Formatter.Serialize(ref MessagePack.MessagePackWriter writer, System.Numerics.Matrix4x4 value, MessagePack.MessagePackSerializerOptions! options) -> void +MessagePack.Formatters.QuaternionFormatter +MessagePack.Formatters.QuaternionFormatter.Deserialize(ref MessagePack.MessagePackReader reader, MessagePack.MessagePackSerializerOptions! options) -> System.Numerics.Quaternion +MessagePack.Formatters.QuaternionFormatter.Serialize(ref MessagePack.MessagePackWriter writer, System.Numerics.Quaternion value, MessagePack.MessagePackSerializerOptions! options) -> void MessagePack.Formatters.StringInterningFormatter MessagePack.Formatters.StringInterningFormatter.Deserialize(ref MessagePack.MessagePackReader reader, MessagePack.MessagePackSerializerOptions! options) -> string? MessagePack.Formatters.StringInterningFormatter.Serialize(ref MessagePack.MessagePackWriter writer, string? value, MessagePack.MessagePackSerializerOptions! options) -> void @@ -8,6 +17,15 @@ MessagePack.Formatters.StringInterningFormatter.StringInterningFormatter() -> vo MessagePack.Formatters.TimeOnlyFormatter MessagePack.Formatters.TimeOnlyFormatter.Deserialize(ref MessagePack.MessagePackReader reader, MessagePack.MessagePackSerializerOptions! options) -> System.TimeOnly MessagePack.Formatters.TimeOnlyFormatter.Serialize(ref MessagePack.MessagePackWriter writer, System.TimeOnly value, MessagePack.MessagePackSerializerOptions! options) -> void +MessagePack.Formatters.Vector2Formatter +MessagePack.Formatters.Vector2Formatter.Deserialize(ref MessagePack.MessagePackReader reader, MessagePack.MessagePackSerializerOptions! options) -> System.Numerics.Vector2 +MessagePack.Formatters.Vector2Formatter.Serialize(ref MessagePack.MessagePackWriter writer, System.Numerics.Vector2 value, MessagePack.MessagePackSerializerOptions! options) -> void +MessagePack.Formatters.Vector3Formatter +MessagePack.Formatters.Vector3Formatter.Deserialize(ref MessagePack.MessagePackReader reader, MessagePack.MessagePackSerializerOptions! options) -> System.Numerics.Vector3 +MessagePack.Formatters.Vector3Formatter.Serialize(ref MessagePack.MessagePackWriter writer, System.Numerics.Vector3 value, MessagePack.MessagePackSerializerOptions! options) -> void +MessagePack.Formatters.Vector4Formatter +MessagePack.Formatters.Vector4Formatter.Deserialize(ref MessagePack.MessagePackReader reader, MessagePack.MessagePackSerializerOptions! options) -> System.Numerics.Vector4 +MessagePack.Formatters.Vector4Formatter.Serialize(ref MessagePack.MessagePackWriter writer, System.Numerics.Vector4 value, MessagePack.MessagePackSerializerOptions! options) -> void MessagePack.MessagePackSerializerOptions.CompressionMinLength.get -> int MessagePack.MessagePackSerializerOptions.SuggestedContiguousMemorySize.get -> int MessagePack.MessagePackSerializerOptions.WithCompressionMinLength(int compressionMinLength) -> MessagePack.MessagePackSerializerOptions! @@ -15,4 +33,10 @@ MessagePack.MessagePackSerializerOptions.WithSuggestedContiguousMemorySize(int s static MessagePack.MessagePackWriter.GetEncodedLength(long value) -> int static MessagePack.MessagePackWriter.GetEncodedLength(ulong value) -> int static readonly MessagePack.Formatters.DateOnlyFormatter.Instance -> MessagePack.Formatters.DateOnlyFormatter! +static readonly MessagePack.Formatters.Matrix3x2Formatter.Instance -> MessagePack.Formatters.IMessagePackFormatter! +static readonly MessagePack.Formatters.Matrix4x4Formatter.Instance -> MessagePack.Formatters.IMessagePackFormatter! +static readonly MessagePack.Formatters.QuaternionFormatter.Instance -> MessagePack.Formatters.IMessagePackFormatter! static readonly MessagePack.Formatters.TimeOnlyFormatter.Instance -> MessagePack.Formatters.TimeOnlyFormatter! +static readonly MessagePack.Formatters.Vector2Formatter.Instance -> MessagePack.Formatters.IMessagePackFormatter! +static readonly MessagePack.Formatters.Vector3Formatter.Instance -> MessagePack.Formatters.IMessagePackFormatter! +static readonly MessagePack.Formatters.Vector4Formatter.Instance -> MessagePack.Formatters.IMessagePackFormatter! diff --git a/src/MessagePack/netstandard2.0/PublicAPI.Unshipped.txt b/src/MessagePack/netstandard2.0/PublicAPI.Unshipped.txt index d78a588a7..4fd955dda 100644 --- a/src/MessagePack/netstandard2.0/PublicAPI.Unshipped.txt +++ b/src/MessagePack/netstandard2.0/PublicAPI.Unshipped.txt @@ -1,10 +1,34 @@ +MessagePack.Formatters.Matrix3x2Formatter +MessagePack.Formatters.Matrix3x2Formatter.Deserialize(ref MessagePack.MessagePackReader reader, MessagePack.MessagePackSerializerOptions! options) -> System.Numerics.Matrix3x2 +MessagePack.Formatters.Matrix3x2Formatter.Serialize(ref MessagePack.MessagePackWriter writer, System.Numerics.Matrix3x2 value, MessagePack.MessagePackSerializerOptions! options) -> void +MessagePack.Formatters.Matrix4x4Formatter +MessagePack.Formatters.Matrix4x4Formatter.Deserialize(ref MessagePack.MessagePackReader reader, MessagePack.MessagePackSerializerOptions! options) -> System.Numerics.Matrix4x4 +MessagePack.Formatters.Matrix4x4Formatter.Serialize(ref MessagePack.MessagePackWriter writer, System.Numerics.Matrix4x4 value, MessagePack.MessagePackSerializerOptions! options) -> void +MessagePack.Formatters.QuaternionFormatter +MessagePack.Formatters.QuaternionFormatter.Deserialize(ref MessagePack.MessagePackReader reader, MessagePack.MessagePackSerializerOptions! options) -> System.Numerics.Quaternion +MessagePack.Formatters.QuaternionFormatter.Serialize(ref MessagePack.MessagePackWriter writer, System.Numerics.Quaternion value, MessagePack.MessagePackSerializerOptions! options) -> void MessagePack.Formatters.StringInterningFormatter MessagePack.Formatters.StringInterningFormatter.Deserialize(ref MessagePack.MessagePackReader reader, MessagePack.MessagePackSerializerOptions! options) -> string? MessagePack.Formatters.StringInterningFormatter.Serialize(ref MessagePack.MessagePackWriter writer, string? value, MessagePack.MessagePackSerializerOptions! options) -> void MessagePack.Formatters.StringInterningFormatter.StringInterningFormatter() -> void +MessagePack.Formatters.Vector2Formatter +MessagePack.Formatters.Vector2Formatter.Deserialize(ref MessagePack.MessagePackReader reader, MessagePack.MessagePackSerializerOptions! options) -> System.Numerics.Vector2 +MessagePack.Formatters.Vector2Formatter.Serialize(ref MessagePack.MessagePackWriter writer, System.Numerics.Vector2 value, MessagePack.MessagePackSerializerOptions! options) -> void +MessagePack.Formatters.Vector3Formatter +MessagePack.Formatters.Vector3Formatter.Deserialize(ref MessagePack.MessagePackReader reader, MessagePack.MessagePackSerializerOptions! options) -> System.Numerics.Vector3 +MessagePack.Formatters.Vector3Formatter.Serialize(ref MessagePack.MessagePackWriter writer, System.Numerics.Vector3 value, MessagePack.MessagePackSerializerOptions! options) -> void +MessagePack.Formatters.Vector4Formatter +MessagePack.Formatters.Vector4Formatter.Deserialize(ref MessagePack.MessagePackReader reader, MessagePack.MessagePackSerializerOptions! options) -> System.Numerics.Vector4 +MessagePack.Formatters.Vector4Formatter.Serialize(ref MessagePack.MessagePackWriter writer, System.Numerics.Vector4 value, MessagePack.MessagePackSerializerOptions! options) -> void MessagePack.MessagePackSerializerOptions.CompressionMinLength.get -> int MessagePack.MessagePackSerializerOptions.SuggestedContiguousMemorySize.get -> int MessagePack.MessagePackSerializerOptions.WithCompressionMinLength(int compressionMinLength) -> MessagePack.MessagePackSerializerOptions! MessagePack.MessagePackSerializerOptions.WithSuggestedContiguousMemorySize(int suggestedContiguousMemorySize) -> MessagePack.MessagePackSerializerOptions! static MessagePack.MessagePackWriter.GetEncodedLength(long value) -> int static MessagePack.MessagePackWriter.GetEncodedLength(ulong value) -> int +static readonly MessagePack.Formatters.Matrix3x2Formatter.Instance -> MessagePack.Formatters.IMessagePackFormatter! +static readonly MessagePack.Formatters.Matrix4x4Formatter.Instance -> MessagePack.Formatters.IMessagePackFormatter! +static readonly MessagePack.Formatters.QuaternionFormatter.Instance -> MessagePack.Formatters.IMessagePackFormatter! +static readonly MessagePack.Formatters.Vector2Formatter.Instance -> MessagePack.Formatters.IMessagePackFormatter! +static readonly MessagePack.Formatters.Vector3Formatter.Instance -> MessagePack.Formatters.IMessagePackFormatter! +static readonly MessagePack.Formatters.Vector4Formatter.Instance -> MessagePack.Formatters.IMessagePackFormatter! From fc17be08acaea9d7ba87b60be20fa19c53263d5e Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Fri, 7 Apr 2023 16:18:27 -0600 Subject: [PATCH 081/660] Fix unity source generator so it actually works --- Directory.Packages.props | 4 ++++ .../MessagePack.Generator.Roslyn3.csproj | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/Directory.Packages.props b/Directory.Packages.props index bc9f10212..899ba7667 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -70,6 +70,10 @@ + + + + diff --git a/src/MessagePack.Generator.Roslyn3/MessagePack.Generator.Roslyn3.csproj b/src/MessagePack.Generator.Roslyn3/MessagePack.Generator.Roslyn3.csproj index b65471b3f..d1442a69f 100644 --- a/src/MessagePack.Generator.Roslyn3/MessagePack.Generator.Roslyn3.csproj +++ b/src/MessagePack.Generator.Roslyn3/MessagePack.Generator.Roslyn3.csproj @@ -3,7 +3,7 @@ - ROSLYN3 + $(DefineConstants);ROSLYN3 3.8.0 From 9d54f443f033263e197c4d009e13df1aab4f27d4 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Fri, 7 Apr 2023 21:05:22 -0600 Subject: [PATCH 082/660] Use a .zip instead of a nuget package for the unity source generator --- README.md | 9 ++++---- .../MessagePack.Generator.Roslyn3.csproj | 22 ++++++++++++++----- .../MessagePack.Generator.csproj | 20 +++++++++++++++++ src/SourceGenerator.props | 22 ------------------- 4 files changed, 40 insertions(+), 33 deletions(-) diff --git a/README.md b/README.md index b860293e5..00ed533c1 100644 --- a/README.md +++ b/README.md @@ -1589,11 +1589,10 @@ If you want to avoid the upfront dynamic generation cost or you need to run on X dotnet add package MessagePack.Generator ``` -Or for Unity, use the source generator that targets the older Roslyn compiler: - -```ps1 -dotnet add package MessagePack.Generator.Roslyn3 -``` +Or for Unity, use the source generator that targets the older Roslyn compiler. +[Setting up a source generator for unity](https://docs.unity3d.com/Manual/roslyn-analyzers.html) is a bit more involved. +The unity instructions describe copying the analyzer .dll into your unity project. +You should get the analyzer .dll from the the unity source generator .zip file uploaded on our GitHub releases page. This package adds a roslyn Source Generator that produces `IMessagePackFormatter` implementing classes for each of your `[MessagePackObject]` classes. diff --git a/src/MessagePack.Generator.Roslyn3/MessagePack.Generator.Roslyn3.csproj b/src/MessagePack.Generator.Roslyn3/MessagePack.Generator.Roslyn3.csproj index d1442a69f..3174755de 100644 --- a/src/MessagePack.Generator.Roslyn3/MessagePack.Generator.Roslyn3.csproj +++ b/src/MessagePack.Generator.Roslyn3/MessagePack.Generator.Roslyn3.csproj @@ -4,13 +4,10 @@ $(DefineConstants);ROSLYN3 - + false + 3.8.0 - - - MessagePack Source Generator for Unity - $(PackageTags);Unity;Xamarin @@ -42,4 +39,17 @@ - + + + + + + $(IntermediateOutputPath)zip + + + + + \ No newline at end of file diff --git a/src/MessagePack.Generator/MessagePack.Generator.csproj b/src/MessagePack.Generator/MessagePack.Generator.csproj index 730b55daf..a2d2c7050 100644 --- a/src/MessagePack.Generator/MessagePack.Generator.csproj +++ b/src/MessagePack.Generator/MessagePack.Generator.csproj @@ -3,7 +3,18 @@ + + true + false + embedded + false + true + true + $(TargetsForTfmSpecificContentInPackage);PackBuildOutputs + MessagePack Source Generator + A roslyn source generator for AOT or faster startup of applications that use the MessagePack nuget package. + MsgPack;MessagePack;Serialization;Formatter;Serializer @@ -86,4 +97,13 @@ + + + + + + + + + diff --git a/src/SourceGenerator.props b/src/SourceGenerator.props index b7d5a949d..c0a752887 100644 --- a/src/SourceGenerator.props +++ b/src/SourceGenerator.props @@ -5,19 +5,6 @@ enable enable cs - - - true - false - embedded - false - true - true - $(TargetsForTfmSpecificContentInPackage);PackBuildOutputs - - MsgPack;MessagePack;Serialization;Formatter;Serializer - A roslyn source generator for AOT or faster startup of applications that use the MessagePack nuget package. - @@ -26,13 +13,4 @@ - - - - - - - - - From 85efcfd93ef81abe7d0ba0609c83ba0b576b843d Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Fri, 7 Apr 2023 21:07:57 -0600 Subject: [PATCH 083/660] Rename Roslyn3 projects to Unity --- MessagePack.sln | 4 ++-- .../.editorconfig | 0 .../MessagePack.Generator.Unity.csproj} | 17 ++--------------- .../MessagePackGenerator.cs | 0 .../CSharpSourceGeneratorVerifier`1+Test.cs | 2 +- .../MessagePack.Generator.Unity.Tests.csproj} | 4 ++-- 6 files changed, 7 insertions(+), 20 deletions(-) rename src/{MessagePack.Generator.Roslyn3 => MessagePack.Generator.Unity}/.editorconfig (100%) rename src/{MessagePack.Generator.Roslyn3/MessagePack.Generator.Roslyn3.csproj => MessagePack.Generator.Unity/MessagePack.Generator.Unity.csproj} (78%) rename src/{MessagePack.Generator.Roslyn3 => MessagePack.Generator.Unity}/MessagePackGenerator.cs (100%) rename tests/{MessagePack.Generator.Roslyn3.Tests/MessagePack.Generator.Roslyn3.Tests.csproj => MessagePack.Generator.Unity.Tests/MessagePack.Generator.Unity.Tests.csproj} (89%) diff --git a/MessagePack.sln b/MessagePack.sln index f3447a9a8..e2ebc5fb5 100644 --- a/MessagePack.sln +++ b/MessagePack.sln @@ -95,13 +95,13 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MessagePack.Experimental.Te EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MessagePack.GeneratedCode.Tests", "tests\MessagePack.GeneratedCode.Tests\MessagePack.GeneratedCode.Tests.csproj", "{D4CE7347-CEBE-46E5-BD12-1319573B6C5E}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MessagePack.Generator.Roslyn3", "src\MessagePack.Generator.Roslyn3\MessagePack.Generator.Roslyn3.csproj", "{45A72780-93EF-4CD1-9FCD-D56A42A3B966}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MessagePack.Generator.Unity", "src\MessagePack.Generator.Unity\MessagePack.Generator.Unity.csproj", "{45A72780-93EF-4CD1-9FCD-D56A42A3B966}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MessagePack.Generator.ExecutionTests", "tests\MessagePack.Generator.ExecutionTests\MessagePack.Generator.ExecutionTests.csproj", "{7908D954-15D4-4D67-B49A-4484809DA2C4}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MessagePack.Generator.MapModeExecutionTests", "tests\MessagePack.Generator.MapModeExecutionTests\MessagePack.Generator.MapModeExecutionTests.csproj", "{EDBA7DDC-69AF-4D5B-A8F6-3B508F8CC0FC}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MessagePack.Generator.Roslyn3.Tests", "tests\MessagePack.Generator.Roslyn3.Tests\MessagePack.Generator.Roslyn3.Tests.csproj", "{EAC1B79C-F77D-4DEF-BF53-75E700A301A4}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MessagePack.Generator.Unity.Tests", "tests\MessagePack.Generator.Unity.Tests\MessagePack.Generator.Unity.Tests.csproj", "{EAC1B79C-F77D-4DEF-BF53-75E700A301A4}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution diff --git a/src/MessagePack.Generator.Roslyn3/.editorconfig b/src/MessagePack.Generator.Unity/.editorconfig similarity index 100% rename from src/MessagePack.Generator.Roslyn3/.editorconfig rename to src/MessagePack.Generator.Unity/.editorconfig diff --git a/src/MessagePack.Generator.Roslyn3/MessagePack.Generator.Roslyn3.csproj b/src/MessagePack.Generator.Unity/MessagePack.Generator.Unity.csproj similarity index 78% rename from src/MessagePack.Generator.Roslyn3/MessagePack.Generator.Roslyn3.csproj rename to src/MessagePack.Generator.Unity/MessagePack.Generator.Unity.csproj index 3174755de..687ccedf0 100644 --- a/src/MessagePack.Generator.Roslyn3/MessagePack.Generator.Roslyn3.csproj +++ b/src/MessagePack.Generator.Unity/MessagePack.Generator.Unity.csproj @@ -3,26 +3,13 @@ - $(DefineConstants);ROSLYN3 + $(DefineConstants);UNITY false 3.8.0 - - - true - build\ - - - build\$(PackageId).props - - - build\$(PackageId).targets - - - @@ -52,4 +39,4 @@ DestinationFile="$(PackageOutputPath)MessagePack.SourceGenerator.Unity.zip" Overwrite="true"/> - \ No newline at end of file + diff --git a/src/MessagePack.Generator.Roslyn3/MessagePackGenerator.cs b/src/MessagePack.Generator.Unity/MessagePackGenerator.cs similarity index 100% rename from src/MessagePack.Generator.Roslyn3/MessagePackGenerator.cs rename to src/MessagePack.Generator.Unity/MessagePackGenerator.cs diff --git a/tests/MessagePack.Generator.Tests/Verifiers/CSharpSourceGeneratorVerifier`1+Test.cs b/tests/MessagePack.Generator.Tests/Verifiers/CSharpSourceGeneratorVerifier`1+Test.cs index 64e48b086..dd0dcf6b5 100644 --- a/tests/MessagePack.Generator.Tests/Verifiers/CSharpSourceGeneratorVerifier`1+Test.cs +++ b/tests/MessagePack.Generator.Tests/Verifiers/CSharpSourceGeneratorVerifier`1+Test.cs @@ -21,7 +21,7 @@ using Microsoft.CodeAnalysis.Testing.Verifiers; public static partial class CSharpSourceGeneratorVerifier -#if Roslyn3 +#if UNITY where TSourceGenerator : ISourceGenerator, new() #else where TSourceGenerator : IIncrementalGenerator, new() diff --git a/tests/MessagePack.Generator.Roslyn3.Tests/MessagePack.Generator.Roslyn3.Tests.csproj b/tests/MessagePack.Generator.Unity.Tests/MessagePack.Generator.Unity.Tests.csproj similarity index 89% rename from tests/MessagePack.Generator.Roslyn3.Tests/MessagePack.Generator.Roslyn3.Tests.csproj rename to tests/MessagePack.Generator.Unity.Tests/MessagePack.Generator.Unity.Tests.csproj index e3666803e..5d1b1df28 100644 --- a/tests/MessagePack.Generator.Roslyn3.Tests/MessagePack.Generator.Roslyn3.Tests.csproj +++ b/tests/MessagePack.Generator.Unity.Tests/MessagePack.Generator.Unity.Tests.csproj @@ -5,7 +5,7 @@ enable enable 11 - $(DefineConstants);Roslyn3 + $(DefineConstants);UNITY @@ -32,7 +32,7 @@ - + From 4e1843afafe3de8415507ce36860096a02b80e9a Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Fri, 7 Apr 2023 21:10:52 -0600 Subject: [PATCH 084/660] Fix PackZip target to depend on build --- .../MessagePack.Generator.Unity.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/MessagePack.Generator.Unity/MessagePack.Generator.Unity.csproj b/src/MessagePack.Generator.Unity/MessagePack.Generator.Unity.csproj index 687ccedf0..09f41f3e8 100644 --- a/src/MessagePack.Generator.Unity/MessagePack.Generator.Unity.csproj +++ b/src/MessagePack.Generator.Unity/MessagePack.Generator.Unity.csproj @@ -26,7 +26,7 @@ - + From 1fc6716ca265afbacccb489a2d70b5cf0876b2d3 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Sat, 8 Apr 2023 08:51:50 -0600 Subject: [PATCH 085/660] Build precise assembly versions for the IDE assemblies --- Directory.Build.props | 3 --- src/MessagePack.Generator.Unity/version.json | 7 +++++++ src/MessagePack.Generator/version.json | 7 +++++++ src/MessagePackAnalyzer/version.json | 7 +++++++ 4 files changed, 21 insertions(+), 3 deletions(-) create mode 100644 src/MessagePack.Generator.Unity/version.json create mode 100644 src/MessagePack.Generator/version.json create mode 100644 src/MessagePackAnalyzer/version.json diff --git a/Directory.Build.props b/Directory.Build.props index 2508970e4..54fddd00e 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -18,9 +18,6 @@ false - - $(MSBuildThisFileDirectory) - embedded diff --git a/src/MessagePack.Generator.Unity/version.json b/src/MessagePack.Generator.Unity/version.json new file mode 100644 index 000000000..7142e661f --- /dev/null +++ b/src/MessagePack.Generator.Unity/version.json @@ -0,0 +1,7 @@ +{ + "$schema": "https://raw.githubusercontent.com/dotnet/Nerdbank.GitVersioning/master/src/NerdBank.GitVersioning/version.schema.json", + "inherit": true, + "assemblyVersion": { + "precision": "revision" + } +} diff --git a/src/MessagePack.Generator/version.json b/src/MessagePack.Generator/version.json new file mode 100644 index 000000000..7142e661f --- /dev/null +++ b/src/MessagePack.Generator/version.json @@ -0,0 +1,7 @@ +{ + "$schema": "https://raw.githubusercontent.com/dotnet/Nerdbank.GitVersioning/master/src/NerdBank.GitVersioning/version.schema.json", + "inherit": true, + "assemblyVersion": { + "precision": "revision" + } +} diff --git a/src/MessagePackAnalyzer/version.json b/src/MessagePackAnalyzer/version.json new file mode 100644 index 000000000..7142e661f --- /dev/null +++ b/src/MessagePackAnalyzer/version.json @@ -0,0 +1,7 @@ +{ + "$schema": "https://raw.githubusercontent.com/dotnet/Nerdbank.GitVersioning/master/src/NerdBank.GitVersioning/version.schema.json", + "inherit": true, + "assemblyVersion": { + "precision": "revision" + } +} From be726b582b6b0fb4cc9262fcd2b90c897fcb6e2c Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Sun, 9 Apr 2023 08:06:37 -0600 Subject: [PATCH 086/660] Add missing .cs.meta file --- .gitignore | 1 - .../MessagePack/Internal/AutomataKeyGen.cs.meta | 11 +++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Internal/AutomataKeyGen.cs.meta diff --git a/.gitignore b/.gitignore index 7e74065d1..692107f29 100644 --- a/.gitignore +++ b/.gitignore @@ -65,7 +65,6 @@ StyleCopReport.xml *_p.c *_h.h *.ilk -*.meta *.obj *.iobj *.pch diff --git a/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Internal/AutomataKeyGen.cs.meta b/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Internal/AutomataKeyGen.cs.meta new file mode 100644 index 000000000..ecf5f8da0 --- /dev/null +++ b/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Internal/AutomataKeyGen.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 916217f90cfa97445ac151032ba0a721 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: From fedd3bed97c6d055ae1cf730ac64dd42138d9b8a Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Mon, 10 Apr 2023 08:55:39 -0600 Subject: [PATCH 087/660] Rename MessagePack.Generator package to MessagePack.SourceGenerator This is to avoid repurposing the dotnet CLI tool package that carried the removed mpc tool. --- MessagePack.sln | 12 +-- .../.editorconfig | 0 .../MessagePack.SourceGenerator.Unity.csproj} | 16 ++-- .../MessagePackGenerator.cs | 4 +- .../version.json | 0 .../.editorconfig | 0 .../AnalyzerReleases.Shipped.md | 0 .../AnalyzerReleases.Unshipped.md | 0 .../CodeAnalysis/AnalyzerOptions.cs | 2 +- .../CodeAnalysis/CodeAnalysisUtilities.cs | 2 +- .../CodeAnalysis/EnumSerializationInfo.cs | 2 +- .../CodeAnalysis/FullModel.cs | 2 +- .../CodeAnalysis/GenericSerializationInfo.cs | 2 +- .../CodeAnalysis/GenericTypeParameterInfo.cs | 2 +- .../CodeAnalysis/IResolverRegisterInfo.cs | 2 +- .../CodeAnalysis/MemberSerializationInfo.cs | 4 +- .../CodeAnalysis/ObjectSerializationInfo.cs | 2 +- .../ResolverRegisterInfoComparer.cs | 2 +- .../CodeAnalysis/TypeCollector.cs | 2 +- .../CodeAnalysis/UnionSerializationInfo.cs | 2 +- .../CodeAnalysis/UnionSubTypeInfo.cs | 2 +- .../IGeneratorContext.cs | 2 +- .../MessagePack.SourceGenerator.csproj} | 0 .../MessagePackGenerator.Emit.cs | 6 +- .../MessagePackGenerator.cs | 4 +- .../Transforms/.editorconfig | 0 .../Transforms/.gitattributes | 0 .../Transforms/EnumTemplate.cs | 8 +- .../Transforms/EnumTemplate.tt | 0 .../Transforms/FormatterTemplate.cs | 90 +++++++++--------- .../Transforms/FormatterTemplate.tt | 0 .../Transforms/IFormatterTemplate.cs | 4 +- .../Transforms/ResolverTemplate.cs | 16 ++-- .../Transforms/ResolverTemplate.tt | 0 .../ShouldUseFormatterResolverHelper.cs | 4 +- .../Transforms/StringKey/EmbedStringHelper.cs | 2 +- .../StringKeyFormatterDeserializeHelper.cs | 4 +- .../StringKey/StringKeyFormatterTemplate.cs | 92 +++++++++---------- .../StringKey/StringKeyFormatterTemplate.tt | 0 .../Transforms/TemplatePartials.cs | 4 +- .../Transforms/UnionTemplate.cs | 24 ++--- .../Transforms/UnionTemplate.tt | 0 .../Utils/RoslynExtensions.cs | 2 +- .../build/MessagePack.SourceGenerator.props} | 0 .../MessagePack.SourceGenerator.targets} | 0 .../version.json | 0 .../CustomFormatterRecord.cs | 0 .../CustomFormatterRecordFormatter.cs | 0 .../Derived1.cs | 0 .../Derived2.cs | 0 .../ExecutionTests.cs | 0 .../HasPropertiesWithGetterAndCtor.cs | 0 .../HasPropertiesWithGetterAndSetter.cs | 0 ...HasPropertyWithCustomFormatterAttribute.cs | 0 .../HasPropertyWithTypeWithCustomFormatter.cs | 0 .../IMyType.cs | 0 ...ack.SourceGenerator.ExecutionTests.csproj} | 0 .../MyEnum.cs | 0 .../MyMessagePackObject.cs | 0 .../UnionContainer.cs | 0 .../UnserializableRecord.cs | 0 .../UnserializableRecordFormatter.cs | 0 .../Usings.cs | 0 ...rceGenerator.MapModeExecutionTests.csproj} | 6 +- .../EnumSerializationInfoTests.cs | 0 .../CodeAnalysis/FullModelTests.cs | 0 .../GenericSerializationInfoTests.cs | 0 .../MemberSerializationInfoTests.cs | 0 .../ObjectSerializationInfoTests.cs | 0 .../UnionSerializationInfoTests.cs | 0 .../ContainerKind.cs | 0 .../GenerateGenericsFormatterTest.cs | 2 +- .../GenerateMessagePackFormatterAttrTest.cs | 2 +- .../GenerateStringKeyedFormatterTest.cs | 2 +- .../GenerationTests.cs | 2 +- .../MessagePack.SourceGenerator.Tests.csproj} | 4 +- .../MultipleTypesTests.cs | 0 .../Resources/.gitattributes | 0 .../Formatters.BarFormatter.g.cs | 0 .../Formatters.FooFormatter.g.cs | 0 ...sagePack.GeneratedMessagePackResolver.g.cs | 0 .../Formatters.ContainerObjectFormatter.g.cs | 0 .../Formatters.SubObjectFormatter.g.cs | 0 ...sagePack.GeneratedMessagePackResolver.g.cs | 0 ...WithCustomFormatterAttributeFormatter.g.cs | 0 ...sagePack.GeneratedMessagePackResolver.g.cs | 0 ...WithCustomFormatterAttributeFormatter.g.cs | 0 ...sagePack.GeneratedMessagePackResolver.g.cs | 0 ...tters.MyTestNamespace.MyEnumFormatter.g.cs | 0 ...amespace.MyMessagePackObjectFormatter.g.cs | 0 ...sagePack.GeneratedMessagePackResolver.g.cs | 0 ...tters.MyTestNamespace.MyEnumFormatter.g.cs | 0 ...amespace.MyMessagePackObjectFormatter.g.cs | 0 ...sagePack.GeneratedMessagePackResolver.g.cs | 0 ...tters.ContainingClass_MyEnumFormatter.g.cs | 0 ...ingClass_MyMessagePackObjectFormatter.g.cs | 0 ...sagePack.GeneratedMessagePackResolver.g.cs | 0 ...tters.ContainingClass_MyEnumFormatter.g.cs | 0 ...ingClass_MyMessagePackObjectFormatter.g.cs | 0 ...sagePack.GeneratedMessagePackResolver.g.cs | 0 .../Formatters.MyEnumFormatter.g.cs | 0 ...rmatters.MyMessagePackObjectFormatter.g.cs | 0 ...sagePack.GeneratedMessagePackResolver.g.cs | 0 .../Formatters.MyEnumFormatter.g.cs | 0 ...rmatters.MyMessagePackObjectFormatter.g.cs | 0 ...sagePack.GeneratedMessagePackResolver.g.cs | 0 .../Formatters.ContainerObjectFormatter.g.cs | 0 .../Formatters.MyGenericTypeFormatter_T_.g.cs | 0 ...sagePack.GeneratedMessagePackResolver.g.cs | 0 .../Formatters.FooFormatter.g.cs | 0 ...sagePack.GeneratedMessagePackResolver.g.cs | 0 .../Formatters.FooFormatter.g.cs | 0 ...sagePack.GeneratedMessagePackResolver.g.cs | 0 .../Formatters.Object1Formatter.g.cs | 0 .../Formatters.Object2Formatter.g.cs | 0 ...sagePack.GeneratedMessagePackResolver.g.cs | 0 .../Formatters.Object1Formatter.g.cs | 0 .../Formatters.Object2Formatter.g.cs | 0 ...sagePack.GeneratedMessagePackResolver.g.cs | 0 ...ers.MyTestNamespace.Derived1Formatter.g.cs | 0 ...ers.MyTestNamespace.Derived2Formatter.g.cs | 0 ...ters.MyTestNamespace.IMyTypeFormatter.g.cs | 0 ...amespace.MyMessagePackObjectFormatter.g.cs | 0 ...sagePack.GeneratedMessagePackResolver.g.cs | 0 ...ers.ContainingClass_Derived1Formatter.g.cs | 0 ...ers.ContainingClass_Derived2Formatter.g.cs | 0 ...ingClass_MyMessagePackObjectFormatter.g.cs | 0 .../Formatters.IMyTypeFormatter.g.cs | 0 ...sagePack.GeneratedMessagePackResolver.g.cs | 0 .../Formatters.Derived1Formatter.g.cs | 0 .../Formatters.Derived2Formatter.g.cs | 0 .../Formatters.IMyTypeFormatter.g.cs | 0 ...rmatters.MyMessagePackObjectFormatter.g.cs | 0 ...sagePack.GeneratedMessagePackResolver.g.cs | 0 .../TestUtilities.cs | 2 +- .../Usings.cs | 4 +- .../CSharpSourceGeneratorVerifier`1+Test.cs | 2 +- .../Verifiers/ReferenceHelper.cs | 0 ...gePack.SourceGenerator.Unity.Tests.csproj} | 2 +- tests/SourceGeneratorConsumer.props | 4 +- tests/SourceGeneratorConsumer.targets | 2 +- 141 files changed, 178 insertions(+), 178 deletions(-) rename src/{MessagePack.Generator.Unity => MessagePack.SourceGenerator.Unity}/.editorconfig (100%) rename src/{MessagePack.Generator.Unity/MessagePack.Generator.Unity.csproj => MessagePack.SourceGenerator.Unity/MessagePack.SourceGenerator.Unity.csproj} (65%) rename src/{MessagePack.Generator.Unity => MessagePack.SourceGenerator.Unity}/MessagePackGenerator.cs (97%) rename src/{MessagePack.Generator.Unity => MessagePack.SourceGenerator.Unity}/version.json (100%) rename src/{MessagePack.Generator => MessagePack.SourceGenerator}/.editorconfig (100%) rename src/{MessagePack.Generator => MessagePack.SourceGenerator}/AnalyzerReleases.Shipped.md (100%) rename src/{MessagePack.Generator => MessagePack.SourceGenerator}/AnalyzerReleases.Unshipped.md (100%) rename src/{MessagePack.Generator => MessagePack.SourceGenerator}/CodeAnalysis/AnalyzerOptions.cs (97%) rename src/{MessagePack.Generator => MessagePack.SourceGenerator}/CodeAnalysis/CodeAnalysisUtilities.cs (96%) rename src/{MessagePack.Generator => MessagePack.SourceGenerator}/CodeAnalysis/EnumSerializationInfo.cs (95%) rename src/{MessagePack.Generator => MessagePack.SourceGenerator}/CodeAnalysis/FullModel.cs (98%) rename src/{MessagePack.Generator => MessagePack.SourceGenerator}/CodeAnalysis/GenericSerializationInfo.cs (92%) rename src/{MessagePack.Generator => MessagePack.SourceGenerator}/CodeAnalysis/GenericTypeParameterInfo.cs (85%) rename src/{MessagePack.Generator => MessagePack.SourceGenerator}/CodeAnalysis/IResolverRegisterInfo.cs (87%) rename src/{MessagePack.Generator => MessagePack.SourceGenerator}/CodeAnalysis/MemberSerializationInfo.cs (95%) rename src/{MessagePack.Generator => MessagePack.SourceGenerator}/CodeAnalysis/ObjectSerializationInfo.cs (98%) rename src/{MessagePack.Generator => MessagePack.SourceGenerator}/CodeAnalysis/ResolverRegisterInfoComparer.cs (90%) rename src/{MessagePack.Generator => MessagePack.SourceGenerator}/CodeAnalysis/TypeCollector.cs (99%) rename src/{MessagePack.Generator => MessagePack.SourceGenerator}/CodeAnalysis/UnionSerializationInfo.cs (96%) rename src/{MessagePack.Generator => MessagePack.SourceGenerator}/CodeAnalysis/UnionSubTypeInfo.cs (80%) rename src/{MessagePack.Generator => MessagePack.SourceGenerator}/IGeneratorContext.cs (90%) rename src/{MessagePack.Generator/MessagePack.Generator.csproj => MessagePack.SourceGenerator/MessagePack.SourceGenerator.csproj} (100%) rename src/{MessagePack.Generator => MessagePack.SourceGenerator}/MessagePackGenerator.Emit.cs (95%) rename src/{MessagePack.Generator => MessagePack.SourceGenerator}/MessagePackGenerator.cs (97%) rename src/{MessagePack.Generator => MessagePack.SourceGenerator}/Transforms/.editorconfig (100%) rename src/{MessagePack.Generator => MessagePack.SourceGenerator}/Transforms/.gitattributes (100%) rename src/{MessagePack.Generator => MessagePack.SourceGenerator}/Transforms/EnumTemplate.cs (99%) rename src/{MessagePack.Generator => MessagePack.SourceGenerator}/Transforms/EnumTemplate.tt (100%) rename src/{MessagePack.Generator => MessagePack.SourceGenerator}/Transforms/FormatterTemplate.cs (95%) rename src/{MessagePack.Generator => MessagePack.SourceGenerator}/Transforms/FormatterTemplate.tt (100%) rename src/{MessagePack.Generator => MessagePack.SourceGenerator}/Transforms/IFormatterTemplate.cs (77%) rename src/{MessagePack.Generator => MessagePack.SourceGenerator}/Transforms/ResolverTemplate.cs (99%) rename src/{MessagePack.Generator => MessagePack.SourceGenerator}/Transforms/ResolverTemplate.tt (100%) rename src/{MessagePack.Generator => MessagePack.SourceGenerator}/Transforms/ShouldUseFormatterResolverHelper.cs (93%) rename src/{MessagePack.Generator => MessagePack.SourceGenerator}/Transforms/StringKey/EmbedStringHelper.cs (98%) rename src/{MessagePack.Generator => MessagePack.SourceGenerator}/Transforms/StringKey/StringKeyFormatterDeserializeHelper.cs (98%) rename src/{MessagePack.Generator => MessagePack.SourceGenerator}/Transforms/StringKey/StringKeyFormatterTemplate.cs (94%) rename src/{MessagePack.Generator => MessagePack.SourceGenerator}/Transforms/StringKey/StringKeyFormatterTemplate.tt (100%) rename src/{MessagePack.Generator => MessagePack.SourceGenerator}/Transforms/TemplatePartials.cs (96%) rename src/{MessagePack.Generator => MessagePack.SourceGenerator}/Transforms/UnionTemplate.cs (98%) rename src/{MessagePack.Generator => MessagePack.SourceGenerator}/Transforms/UnionTemplate.tt (100%) rename src/{MessagePack.Generator => MessagePack.SourceGenerator}/Utils/RoslynExtensions.cs (96%) rename src/{MessagePack.Generator/build/MessagePack.Generator.props => MessagePack.SourceGenerator/build/MessagePack.SourceGenerator.props} (100%) rename src/{MessagePack.Generator/build/MessagePack.Generator.targets => MessagePack.SourceGenerator/build/MessagePack.SourceGenerator.targets} (100%) rename src/{MessagePack.Generator => MessagePack.SourceGenerator}/version.json (100%) rename tests/{MessagePack.Generator.ExecutionTests => MessagePack.SourceGenerator.ExecutionTests}/CustomFormatterRecord.cs (100%) rename tests/{MessagePack.Generator.ExecutionTests => MessagePack.SourceGenerator.ExecutionTests}/CustomFormatterRecordFormatter.cs (100%) rename tests/{MessagePack.Generator.ExecutionTests => MessagePack.SourceGenerator.ExecutionTests}/Derived1.cs (100%) rename tests/{MessagePack.Generator.ExecutionTests => MessagePack.SourceGenerator.ExecutionTests}/Derived2.cs (100%) rename tests/{MessagePack.Generator.ExecutionTests => MessagePack.SourceGenerator.ExecutionTests}/ExecutionTests.cs (100%) rename tests/{MessagePack.Generator.ExecutionTests => MessagePack.SourceGenerator.ExecutionTests}/HasPropertiesWithGetterAndCtor.cs (100%) rename tests/{MessagePack.Generator.ExecutionTests => MessagePack.SourceGenerator.ExecutionTests}/HasPropertiesWithGetterAndSetter.cs (100%) rename tests/{MessagePack.Generator.ExecutionTests => MessagePack.SourceGenerator.ExecutionTests}/HasPropertyWithCustomFormatterAttribute.cs (100%) rename tests/{MessagePack.Generator.ExecutionTests => MessagePack.SourceGenerator.ExecutionTests}/HasPropertyWithTypeWithCustomFormatter.cs (100%) rename tests/{MessagePack.Generator.ExecutionTests => MessagePack.SourceGenerator.ExecutionTests}/IMyType.cs (100%) rename tests/{MessagePack.Generator.ExecutionTests/MessagePack.Generator.ExecutionTests.csproj => MessagePack.SourceGenerator.ExecutionTests/MessagePack.SourceGenerator.ExecutionTests.csproj} (100%) rename tests/{MessagePack.Generator.ExecutionTests => MessagePack.SourceGenerator.ExecutionTests}/MyEnum.cs (100%) rename tests/{MessagePack.Generator.ExecutionTests => MessagePack.SourceGenerator.ExecutionTests}/MyMessagePackObject.cs (100%) rename tests/{MessagePack.Generator.ExecutionTests => MessagePack.SourceGenerator.ExecutionTests}/UnionContainer.cs (100%) rename tests/{MessagePack.Generator.ExecutionTests => MessagePack.SourceGenerator.ExecutionTests}/UnserializableRecord.cs (100%) rename tests/{MessagePack.Generator.ExecutionTests => MessagePack.SourceGenerator.ExecutionTests}/UnserializableRecordFormatter.cs (100%) rename tests/{MessagePack.Generator.ExecutionTests => MessagePack.SourceGenerator.ExecutionTests}/Usings.cs (100%) rename tests/{MessagePack.Generator.MapModeExecutionTests/MessagePack.Generator.MapModeExecutionTests.csproj => MessagePack.SourceGenerator.MapModeExecutionTests/MessagePack.SourceGenerator.MapModeExecutionTests.csproj} (89%) rename tests/{MessagePack.Generator.Tests => MessagePack.SourceGenerator.Tests}/CodeAnalysis/EnumSerializationInfoTests.cs (100%) rename tests/{MessagePack.Generator.Tests => MessagePack.SourceGenerator.Tests}/CodeAnalysis/FullModelTests.cs (100%) rename tests/{MessagePack.Generator.Tests => MessagePack.SourceGenerator.Tests}/CodeAnalysis/GenericSerializationInfoTests.cs (100%) rename tests/{MessagePack.Generator.Tests => MessagePack.SourceGenerator.Tests}/CodeAnalysis/MemberSerializationInfoTests.cs (100%) rename tests/{MessagePack.Generator.Tests => MessagePack.SourceGenerator.Tests}/CodeAnalysis/ObjectSerializationInfoTests.cs (100%) rename tests/{MessagePack.Generator.Tests => MessagePack.SourceGenerator.Tests}/CodeAnalysis/UnionSerializationInfoTests.cs (100%) rename tests/{MessagePack.Generator.Tests => MessagePack.SourceGenerator.Tests}/ContainerKind.cs (100%) rename tests/{MessagePack.Generator.Tests => MessagePack.SourceGenerator.Tests}/GenerateGenericsFormatterTest.cs (99%) rename tests/{MessagePack.Generator.Tests => MessagePack.SourceGenerator.Tests}/GenerateMessagePackFormatterAttrTest.cs (98%) rename tests/{MessagePack.Generator.Tests => MessagePack.SourceGenerator.Tests}/GenerateStringKeyedFormatterTest.cs (99%) rename tests/{MessagePack.Generator.Tests => MessagePack.SourceGenerator.Tests}/GenerationTests.cs (99%) rename tests/{MessagePack.Generator.Tests/MessagePack.Generator.Tests.csproj => MessagePack.SourceGenerator.Tests/MessagePack.SourceGenerator.Tests.csproj} (91%) rename tests/{MessagePack.Generator.Tests => MessagePack.SourceGenerator.Tests}/MultipleTypesTests.cs (100%) rename tests/{MessagePack.Generator.Tests => MessagePack.SourceGenerator.Tests}/Resources/.gitattributes (100%) rename tests/{MessagePack.Generator.Tests => MessagePack.SourceGenerator.Tests}/Resources/AddAttributeToType/Formatters.BarFormatter.g.cs (100%) rename tests/{MessagePack.Generator.Tests => MessagePack.SourceGenerator.Tests}/Resources/AddAttributeToType/Formatters.FooFormatter.g.cs (100%) rename tests/{MessagePack.Generator.Tests => MessagePack.SourceGenerator.Tests}/Resources/AddAttributeToType/MessagePack.GeneratedMessagePackResolver.g.cs (100%) rename tests/{MessagePack.Generator.Tests => MessagePack.SourceGenerator.Tests}/Resources/ArrayTypedProperty/Formatters.ContainerObjectFormatter.g.cs (100%) rename tests/{MessagePack.Generator.Tests => MessagePack.SourceGenerator.Tests}/Resources/ArrayTypedProperty/Formatters.SubObjectFormatter.g.cs (100%) rename tests/{MessagePack.Generator.Tests => MessagePack.SourceGenerator.Tests}/Resources/ArrayTypedProperty/MessagePack.GeneratedMessagePackResolver.g.cs (100%) rename tests/{MessagePack.Generator.Tests => MessagePack.SourceGenerator.Tests}/Resources/CustomFormatterViaAttributeOnProperty(False)/Formatters.HasPropertyWithCustomFormatterAttributeFormatter.g.cs (100%) rename tests/{MessagePack.Generator.Tests => MessagePack.SourceGenerator.Tests}/Resources/CustomFormatterViaAttributeOnProperty(False)/MessagePack.GeneratedMessagePackResolver.g.cs (100%) rename tests/{MessagePack.Generator.Tests => MessagePack.SourceGenerator.Tests}/Resources/CustomFormatterViaAttributeOnProperty(True)/Formatters.HasPropertyWithCustomFormatterAttributeFormatter.g.cs (100%) rename tests/{MessagePack.Generator.Tests => MessagePack.SourceGenerator.Tests}/Resources/CustomFormatterViaAttributeOnProperty(True)/MessagePack.GeneratedMessagePackResolver.g.cs (100%) rename tests/{MessagePack.Generator.Tests => MessagePack.SourceGenerator.Tests}/Resources/EnumFormatter(Namespace, False)/Formatters.MyTestNamespace.MyEnumFormatter.g.cs (100%) rename tests/{MessagePack.Generator.Tests => MessagePack.SourceGenerator.Tests}/Resources/EnumFormatter(Namespace, False)/Formatters.MyTestNamespace.MyMessagePackObjectFormatter.g.cs (100%) rename tests/{MessagePack.Generator.Tests => MessagePack.SourceGenerator.Tests}/Resources/EnumFormatter(Namespace, False)/MessagePack.GeneratedMessagePackResolver.g.cs (100%) rename tests/{MessagePack.Generator.Tests => MessagePack.SourceGenerator.Tests}/Resources/EnumFormatter(Namespace, True)/Formatters.MyTestNamespace.MyEnumFormatter.g.cs (100%) rename tests/{MessagePack.Generator.Tests => MessagePack.SourceGenerator.Tests}/Resources/EnumFormatter(Namespace, True)/Formatters.MyTestNamespace.MyMessagePackObjectFormatter.g.cs (100%) rename tests/{MessagePack.Generator.Tests => MessagePack.SourceGenerator.Tests}/Resources/EnumFormatter(Namespace, True)/MessagePack.GeneratedMessagePackResolver.g.cs (100%) rename tests/{MessagePack.Generator.Tests => MessagePack.SourceGenerator.Tests}/Resources/EnumFormatter(NestingClass, False)/Formatters.ContainingClass_MyEnumFormatter.g.cs (100%) rename tests/{MessagePack.Generator.Tests => MessagePack.SourceGenerator.Tests}/Resources/EnumFormatter(NestingClass, False)/Formatters.ContainingClass_MyMessagePackObjectFormatter.g.cs (100%) rename tests/{MessagePack.Generator.Tests => MessagePack.SourceGenerator.Tests}/Resources/EnumFormatter(NestingClass, False)/MessagePack.GeneratedMessagePackResolver.g.cs (100%) rename tests/{MessagePack.Generator.Tests => MessagePack.SourceGenerator.Tests}/Resources/EnumFormatter(NestingClass, True)/Formatters.ContainingClass_MyEnumFormatter.g.cs (100%) rename tests/{MessagePack.Generator.Tests => MessagePack.SourceGenerator.Tests}/Resources/EnumFormatter(NestingClass, True)/Formatters.ContainingClass_MyMessagePackObjectFormatter.g.cs (100%) rename tests/{MessagePack.Generator.Tests => MessagePack.SourceGenerator.Tests}/Resources/EnumFormatter(NestingClass, True)/MessagePack.GeneratedMessagePackResolver.g.cs (100%) rename tests/{MessagePack.Generator.Tests => MessagePack.SourceGenerator.Tests}/Resources/EnumFormatter(None, False)/Formatters.MyEnumFormatter.g.cs (100%) rename tests/{MessagePack.Generator.Tests => MessagePack.SourceGenerator.Tests}/Resources/EnumFormatter(None, False)/Formatters.MyMessagePackObjectFormatter.g.cs (100%) rename tests/{MessagePack.Generator.Tests => MessagePack.SourceGenerator.Tests}/Resources/EnumFormatter(None, False)/MessagePack.GeneratedMessagePackResolver.g.cs (100%) rename tests/{MessagePack.Generator.Tests => MessagePack.SourceGenerator.Tests}/Resources/EnumFormatter(None, True)/Formatters.MyEnumFormatter.g.cs (100%) rename tests/{MessagePack.Generator.Tests => MessagePack.SourceGenerator.Tests}/Resources/EnumFormatter(None, True)/Formatters.MyMessagePackObjectFormatter.g.cs (100%) rename tests/{MessagePack.Generator.Tests => MessagePack.SourceGenerator.Tests}/Resources/EnumFormatter(None, True)/MessagePack.GeneratedMessagePackResolver.g.cs (100%) rename tests/{MessagePack.Generator.Tests => MessagePack.SourceGenerator.Tests}/Resources/GenericType/Formatters.ContainerObjectFormatter.g.cs (100%) rename tests/{MessagePack.Generator.Tests => MessagePack.SourceGenerator.Tests}/Resources/GenericType/Formatters.MyGenericTypeFormatter_T_.g.cs (100%) rename tests/{MessagePack.Generator.Tests => MessagePack.SourceGenerator.Tests}/Resources/GenericType/MessagePack.GeneratedMessagePackResolver.g.cs (100%) rename tests/{MessagePack.Generator.Tests => MessagePack.SourceGenerator.Tests}/Resources/MembersNeedAttributes/Formatters.FooFormatter.g.cs (100%) rename tests/{MessagePack.Generator.Tests => MessagePack.SourceGenerator.Tests}/Resources/MembersNeedAttributes/MessagePack.GeneratedMessagePackResolver.g.cs (100%) rename tests/{MessagePack.Generator.Tests => MessagePack.SourceGenerator.Tests}/Resources/NullStringKey/Formatters.FooFormatter.g.cs (100%) rename tests/{MessagePack.Generator.Tests => MessagePack.SourceGenerator.Tests}/Resources/NullStringKey/MessagePack.GeneratedMessagePackResolver.g.cs (100%) rename tests/{MessagePack.Generator.Tests => MessagePack.SourceGenerator.Tests}/Resources/TwoTypes(False)/Formatters.Object1Formatter.g.cs (100%) rename tests/{MessagePack.Generator.Tests => MessagePack.SourceGenerator.Tests}/Resources/TwoTypes(False)/Formatters.Object2Formatter.g.cs (100%) rename tests/{MessagePack.Generator.Tests => MessagePack.SourceGenerator.Tests}/Resources/TwoTypes(False)/MessagePack.GeneratedMessagePackResolver.g.cs (100%) rename tests/{MessagePack.Generator.Tests => MessagePack.SourceGenerator.Tests}/Resources/TwoTypes(True)/Formatters.Object1Formatter.g.cs (100%) rename tests/{MessagePack.Generator.Tests => MessagePack.SourceGenerator.Tests}/Resources/TwoTypes(True)/Formatters.Object2Formatter.g.cs (100%) rename tests/{MessagePack.Generator.Tests => MessagePack.SourceGenerator.Tests}/Resources/TwoTypes(True)/MessagePack.GeneratedMessagePackResolver.g.cs (100%) rename tests/{MessagePack.Generator.Tests => MessagePack.SourceGenerator.Tests}/Resources/UnionFormatter(Namespace)/Formatters.MyTestNamespace.Derived1Formatter.g.cs (100%) rename tests/{MessagePack.Generator.Tests => MessagePack.SourceGenerator.Tests}/Resources/UnionFormatter(Namespace)/Formatters.MyTestNamespace.Derived2Formatter.g.cs (100%) rename tests/{MessagePack.Generator.Tests => MessagePack.SourceGenerator.Tests}/Resources/UnionFormatter(Namespace)/Formatters.MyTestNamespace.IMyTypeFormatter.g.cs (100%) rename tests/{MessagePack.Generator.Tests => MessagePack.SourceGenerator.Tests}/Resources/UnionFormatter(Namespace)/Formatters.MyTestNamespace.MyMessagePackObjectFormatter.g.cs (100%) rename tests/{MessagePack.Generator.Tests => MessagePack.SourceGenerator.Tests}/Resources/UnionFormatter(Namespace)/MessagePack.GeneratedMessagePackResolver.g.cs (100%) rename tests/{MessagePack.Generator.Tests => MessagePack.SourceGenerator.Tests}/Resources/UnionFormatter(NestingClass)/Formatters.ContainingClass_Derived1Formatter.g.cs (100%) rename tests/{MessagePack.Generator.Tests => MessagePack.SourceGenerator.Tests}/Resources/UnionFormatter(NestingClass)/Formatters.ContainingClass_Derived2Formatter.g.cs (100%) rename tests/{MessagePack.Generator.Tests => MessagePack.SourceGenerator.Tests}/Resources/UnionFormatter(NestingClass)/Formatters.ContainingClass_MyMessagePackObjectFormatter.g.cs (100%) rename tests/{MessagePack.Generator.Tests => MessagePack.SourceGenerator.Tests}/Resources/UnionFormatter(NestingClass)/Formatters.IMyTypeFormatter.g.cs (100%) rename tests/{MessagePack.Generator.Tests => MessagePack.SourceGenerator.Tests}/Resources/UnionFormatter(NestingClass)/MessagePack.GeneratedMessagePackResolver.g.cs (100%) rename tests/{MessagePack.Generator.Tests => MessagePack.SourceGenerator.Tests}/Resources/UnionFormatter(None)/Formatters.Derived1Formatter.g.cs (100%) rename tests/{MessagePack.Generator.Tests => MessagePack.SourceGenerator.Tests}/Resources/UnionFormatter(None)/Formatters.Derived2Formatter.g.cs (100%) rename tests/{MessagePack.Generator.Tests => MessagePack.SourceGenerator.Tests}/Resources/UnionFormatter(None)/Formatters.IMyTypeFormatter.g.cs (100%) rename tests/{MessagePack.Generator.Tests => MessagePack.SourceGenerator.Tests}/Resources/UnionFormatter(None)/Formatters.MyMessagePackObjectFormatter.g.cs (100%) rename tests/{MessagePack.Generator.Tests => MessagePack.SourceGenerator.Tests}/Resources/UnionFormatter(None)/MessagePack.GeneratedMessagePackResolver.g.cs (100%) rename tests/{MessagePack.Generator.Tests => MessagePack.SourceGenerator.Tests}/TestUtilities.cs (95%) rename tests/{MessagePack.Generator.Tests => MessagePack.SourceGenerator.Tests}/Usings.cs (77%) rename tests/{MessagePack.Generator.Tests => MessagePack.SourceGenerator.Tests}/Verifiers/CSharpSourceGeneratorVerifier`1+Test.cs (99%) rename tests/{MessagePack.Generator.Tests => MessagePack.SourceGenerator.Tests}/Verifiers/ReferenceHelper.cs (100%) rename tests/{MessagePack.Generator.Unity.Tests/MessagePack.Generator.Unity.Tests.csproj => MessagePack.SourceGenerator.Unity.Tests/MessagePack.SourceGenerator.Unity.Tests.csproj} (92%) diff --git a/MessagePack.sln b/MessagePack.sln index e2ebc5fb5..32d11a746 100644 --- a/MessagePack.sln +++ b/MessagePack.sln @@ -81,11 +81,11 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MessagePack.Internal", "san EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MessagePack.Internal.Tests", "tests\MessagePack.Internal.Tests\MessagePack.Internal.Tests.csproj", "{8D9FD130-7905-47D8-A25C-7FDEE28EA0E8}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MessagePack.Generator", "src\MessagePack.Generator\MessagePack.Generator.csproj", "{32C91908-5CAD-4C95-B240-ACBBACAC9476}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MessagePack.SourceGenerator", "src\MessagePack.SourceGenerator\MessagePack.SourceGenerator.csproj", "{32C91908-5CAD-4C95-B240-ACBBACAC9476}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MessagePackAnalyzer.Tests", "tests\MessagePackAnalyzer.Tests\MessagePackAnalyzer.Tests.csproj", "{7E5FB4B9-A0F5-4B10-A1F3-03AC0BC8265A}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MessagePack.Generator.Tests", "tests\MessagePack.Generator.Tests\MessagePack.Generator.Tests.csproj", "{6AC51E68-4681-463A-B4B6-BD53517244B2}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MessagePack.SourceGenerator.Tests", "tests\MessagePack.SourceGenerator.Tests\MessagePack.SourceGenerator.Tests.csproj", "{6AC51E68-4681-463A-B4B6-BD53517244B2}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ExperimentalBenchmark", "benchmark\ExperimentalBenchmark\ExperimentalBenchmark.csproj", "{4C9BB260-62D8-49CD-9F9C-9AA6A8BFC637}" EndProject @@ -95,13 +95,13 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MessagePack.Experimental.Te EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MessagePack.GeneratedCode.Tests", "tests\MessagePack.GeneratedCode.Tests\MessagePack.GeneratedCode.Tests.csproj", "{D4CE7347-CEBE-46E5-BD12-1319573B6C5E}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MessagePack.Generator.Unity", "src\MessagePack.Generator.Unity\MessagePack.Generator.Unity.csproj", "{45A72780-93EF-4CD1-9FCD-D56A42A3B966}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MessagePack.SourceGenerator.Unity", "src\MessagePack.SourceGenerator.Unity\MessagePack.SourceGenerator.Unity.csproj", "{45A72780-93EF-4CD1-9FCD-D56A42A3B966}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MessagePack.Generator.ExecutionTests", "tests\MessagePack.Generator.ExecutionTests\MessagePack.Generator.ExecutionTests.csproj", "{7908D954-15D4-4D67-B49A-4484809DA2C4}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MessagePack.SourceGenerator.ExecutionTests", "tests\MessagePack.SourceGenerator.ExecutionTests\MessagePack.SourceGenerator.ExecutionTests.csproj", "{7908D954-15D4-4D67-B49A-4484809DA2C4}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MessagePack.Generator.MapModeExecutionTests", "tests\MessagePack.Generator.MapModeExecutionTests\MessagePack.Generator.MapModeExecutionTests.csproj", "{EDBA7DDC-69AF-4D5B-A8F6-3B508F8CC0FC}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MessagePack.SourceGenerator.MapModeExecutionTests", "tests\MessagePack.SourceGenerator.MapModeExecutionTests\MessagePack.SourceGenerator.MapModeExecutionTests.csproj", "{EDBA7DDC-69AF-4D5B-A8F6-3B508F8CC0FC}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MessagePack.Generator.Unity.Tests", "tests\MessagePack.Generator.Unity.Tests\MessagePack.Generator.Unity.Tests.csproj", "{EAC1B79C-F77D-4DEF-BF53-75E700A301A4}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MessagePack.SourceGenerator.Unity.Tests", "tests\MessagePack.SourceGenerator.Unity.Tests\MessagePack.SourceGenerator.Unity.Tests.csproj", "{EAC1B79C-F77D-4DEF-BF53-75E700A301A4}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution diff --git a/src/MessagePack.Generator.Unity/.editorconfig b/src/MessagePack.SourceGenerator.Unity/.editorconfig similarity index 100% rename from src/MessagePack.Generator.Unity/.editorconfig rename to src/MessagePack.SourceGenerator.Unity/.editorconfig diff --git a/src/MessagePack.Generator.Unity/MessagePack.Generator.Unity.csproj b/src/MessagePack.SourceGenerator.Unity/MessagePack.SourceGenerator.Unity.csproj similarity index 65% rename from src/MessagePack.Generator.Unity/MessagePack.Generator.Unity.csproj rename to src/MessagePack.SourceGenerator.Unity/MessagePack.SourceGenerator.Unity.csproj index 09f41f3e8..1021e6f92 100644 --- a/src/MessagePack.Generator.Unity/MessagePack.Generator.Unity.csproj +++ b/src/MessagePack.SourceGenerator.Unity/MessagePack.SourceGenerator.Unity.csproj @@ -11,19 +11,19 @@ - - - - - + + + + + - - + + @@ -36,7 +36,7 @@ diff --git a/src/MessagePack.Generator.Unity/MessagePackGenerator.cs b/src/MessagePack.SourceGenerator.Unity/MessagePackGenerator.cs similarity index 97% rename from src/MessagePack.Generator.Unity/MessagePackGenerator.cs rename to src/MessagePack.SourceGenerator.Unity/MessagePackGenerator.cs index 687b7609d..9d63b2df0 100644 --- a/src/MessagePack.Generator.Unity/MessagePackGenerator.cs +++ b/src/MessagePack.SourceGenerator.Unity/MessagePackGenerator.cs @@ -2,11 +2,11 @@ // Licensed under the MIT license. See LICENSE file in the project root for full license information. using System.Collections.Immutable; -using MessagePack.Generator.CodeAnalysis; +using MessagePack.SourceGenerator.CodeAnalysis; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp.Syntax; -namespace MessagePack.Generator; +namespace MessagePack.SourceGenerator; [Generator] public partial class MessagePackGenerator : ISourceGenerator diff --git a/src/MessagePack.Generator.Unity/version.json b/src/MessagePack.SourceGenerator.Unity/version.json similarity index 100% rename from src/MessagePack.Generator.Unity/version.json rename to src/MessagePack.SourceGenerator.Unity/version.json diff --git a/src/MessagePack.Generator/.editorconfig b/src/MessagePack.SourceGenerator/.editorconfig similarity index 100% rename from src/MessagePack.Generator/.editorconfig rename to src/MessagePack.SourceGenerator/.editorconfig diff --git a/src/MessagePack.Generator/AnalyzerReleases.Shipped.md b/src/MessagePack.SourceGenerator/AnalyzerReleases.Shipped.md similarity index 100% rename from src/MessagePack.Generator/AnalyzerReleases.Shipped.md rename to src/MessagePack.SourceGenerator/AnalyzerReleases.Shipped.md diff --git a/src/MessagePack.Generator/AnalyzerReleases.Unshipped.md b/src/MessagePack.SourceGenerator/AnalyzerReleases.Unshipped.md similarity index 100% rename from src/MessagePack.Generator/AnalyzerReleases.Unshipped.md rename to src/MessagePack.SourceGenerator/AnalyzerReleases.Unshipped.md diff --git a/src/MessagePack.Generator/CodeAnalysis/AnalyzerOptions.cs b/src/MessagePack.SourceGenerator/CodeAnalysis/AnalyzerOptions.cs similarity index 97% rename from src/MessagePack.Generator/CodeAnalysis/AnalyzerOptions.cs rename to src/MessagePack.SourceGenerator/CodeAnalysis/AnalyzerOptions.cs index d46eced72..3ae40962c 100644 --- a/src/MessagePack.Generator/CodeAnalysis/AnalyzerOptions.cs +++ b/src/MessagePack.SourceGenerator/CodeAnalysis/AnalyzerOptions.cs @@ -3,7 +3,7 @@ using Microsoft.CodeAnalysis.Diagnostics; -namespace MessagePack.Generator.CodeAnalysis; +namespace MessagePack.SourceGenerator.CodeAnalysis; public record AnalyzerOptions( string ResolverNamespace = "MessagePack", diff --git a/src/MessagePack.Generator/CodeAnalysis/CodeAnalysisUtilities.cs b/src/MessagePack.SourceGenerator/CodeAnalysis/CodeAnalysisUtilities.cs similarity index 96% rename from src/MessagePack.Generator/CodeAnalysis/CodeAnalysisUtilities.cs rename to src/MessagePack.SourceGenerator/CodeAnalysis/CodeAnalysisUtilities.cs index 3c422e9f6..30b90df95 100644 --- a/src/MessagePack.Generator/CodeAnalysis/CodeAnalysisUtilities.cs +++ b/src/MessagePack.SourceGenerator/CodeAnalysis/CodeAnalysisUtilities.cs @@ -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. -namespace MessagePack.Generator.CodeAnalysis; +namespace MessagePack.SourceGenerator.CodeAnalysis; internal static class CodeAnalysisUtilities { diff --git a/src/MessagePack.Generator/CodeAnalysis/EnumSerializationInfo.cs b/src/MessagePack.SourceGenerator/CodeAnalysis/EnumSerializationInfo.cs similarity index 95% rename from src/MessagePack.Generator/CodeAnalysis/EnumSerializationInfo.cs rename to src/MessagePack.SourceGenerator/CodeAnalysis/EnumSerializationInfo.cs index be88cb15c..7e782947f 100644 --- a/src/MessagePack.Generator/CodeAnalysis/EnumSerializationInfo.cs +++ b/src/MessagePack.SourceGenerator/CodeAnalysis/EnumSerializationInfo.cs @@ -3,7 +3,7 @@ using Microsoft.CodeAnalysis; -namespace MessagePack.Generator.CodeAnalysis; +namespace MessagePack.SourceGenerator.CodeAnalysis; public sealed record EnumSerializationInfo(string? Namespace, string Name, string FullName, string UnderlyingTypeName) : IResolverRegisterInfo { diff --git a/src/MessagePack.Generator/CodeAnalysis/FullModel.cs b/src/MessagePack.SourceGenerator/CodeAnalysis/FullModel.cs similarity index 98% rename from src/MessagePack.Generator/CodeAnalysis/FullModel.cs rename to src/MessagePack.SourceGenerator/CodeAnalysis/FullModel.cs index d7fb5a478..54d1f9542 100644 --- a/src/MessagePack.Generator/CodeAnalysis/FullModel.cs +++ b/src/MessagePack.SourceGenerator/CodeAnalysis/FullModel.cs @@ -3,7 +3,7 @@ using System.Collections.Immutable; -namespace MessagePack.Generator.CodeAnalysis; +namespace MessagePack.SourceGenerator.CodeAnalysis; public record FullModel( ImmutableSortedSet ObjectInfos, diff --git a/src/MessagePack.Generator/CodeAnalysis/GenericSerializationInfo.cs b/src/MessagePack.SourceGenerator/CodeAnalysis/GenericSerializationInfo.cs similarity index 92% rename from src/MessagePack.Generator/CodeAnalysis/GenericSerializationInfo.cs rename to src/MessagePack.SourceGenerator/CodeAnalysis/GenericSerializationInfo.cs index 9401f8481..709eba5c6 100644 --- a/src/MessagePack.Generator/CodeAnalysis/GenericSerializationInfo.cs +++ b/src/MessagePack.SourceGenerator/CodeAnalysis/GenericSerializationInfo.cs @@ -3,7 +3,7 @@ using Microsoft.CodeAnalysis; -namespace MessagePack.Generator.CodeAnalysis; +namespace MessagePack.SourceGenerator.CodeAnalysis; public sealed record GenericSerializationInfo(string FullName, string FormatterName, bool IsOpenGenericType) : IResolverRegisterInfo { diff --git a/src/MessagePack.Generator/CodeAnalysis/GenericTypeParameterInfo.cs b/src/MessagePack.SourceGenerator/CodeAnalysis/GenericTypeParameterInfo.cs similarity index 85% rename from src/MessagePack.Generator/CodeAnalysis/GenericTypeParameterInfo.cs rename to src/MessagePack.SourceGenerator/CodeAnalysis/GenericTypeParameterInfo.cs index 5ae2d1a05..9268ff41c 100644 --- a/src/MessagePack.Generator/CodeAnalysis/GenericTypeParameterInfo.cs +++ b/src/MessagePack.SourceGenerator/CodeAnalysis/GenericTypeParameterInfo.cs @@ -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. -namespace MessagePack.Generator.CodeAnalysis; +namespace MessagePack.SourceGenerator.CodeAnalysis; public record GenericTypeParameterInfo(string Name, string Constraints) { diff --git a/src/MessagePack.Generator/CodeAnalysis/IResolverRegisterInfo.cs b/src/MessagePack.SourceGenerator/CodeAnalysis/IResolverRegisterInfo.cs similarity index 87% rename from src/MessagePack.Generator/CodeAnalysis/IResolverRegisterInfo.cs rename to src/MessagePack.SourceGenerator/CodeAnalysis/IResolverRegisterInfo.cs index f56b6664e..3922d6900 100644 --- a/src/MessagePack.Generator/CodeAnalysis/IResolverRegisterInfo.cs +++ b/src/MessagePack.SourceGenerator/CodeAnalysis/IResolverRegisterInfo.cs @@ -3,7 +3,7 @@ using Microsoft.CodeAnalysis; -namespace MessagePack.Generator.CodeAnalysis; +namespace MessagePack.SourceGenerator.CodeAnalysis; public interface IResolverRegisterInfo { diff --git a/src/MessagePack.Generator/CodeAnalysis/MemberSerializationInfo.cs b/src/MessagePack.SourceGenerator/CodeAnalysis/MemberSerializationInfo.cs similarity index 95% rename from src/MessagePack.Generator/CodeAnalysis/MemberSerializationInfo.cs rename to src/MessagePack.SourceGenerator/CodeAnalysis/MemberSerializationInfo.cs index 5cb6ac03a..558cdbc92 100644 --- a/src/MessagePack.Generator/CodeAnalysis/MemberSerializationInfo.cs +++ b/src/MessagePack.SourceGenerator/CodeAnalysis/MemberSerializationInfo.cs @@ -1,9 +1,9 @@ // Copyright (c) All contributors. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -using MessagePack.Generator.Transforms; +using MessagePack.SourceGenerator.Transforms; -namespace MessagePack.Generator.CodeAnalysis; +namespace MessagePack.SourceGenerator.CodeAnalysis; public record MemberSerializationInfo( bool IsProperty, diff --git a/src/MessagePack.Generator/CodeAnalysis/ObjectSerializationInfo.cs b/src/MessagePack.SourceGenerator/CodeAnalysis/ObjectSerializationInfo.cs similarity index 98% rename from src/MessagePack.Generator/CodeAnalysis/ObjectSerializationInfo.cs rename to src/MessagePack.SourceGenerator/CodeAnalysis/ObjectSerializationInfo.cs index a866cb4a7..69c2c67cb 100644 --- a/src/MessagePack.Generator/CodeAnalysis/ObjectSerializationInfo.cs +++ b/src/MessagePack.SourceGenerator/CodeAnalysis/ObjectSerializationInfo.cs @@ -3,7 +3,7 @@ using Microsoft.CodeAnalysis; -namespace MessagePack.Generator.CodeAnalysis; +namespace MessagePack.SourceGenerator.CodeAnalysis; public record ObjectSerializationInfo( bool IsClass, diff --git a/src/MessagePack.Generator/CodeAnalysis/ResolverRegisterInfoComparer.cs b/src/MessagePack.SourceGenerator/CodeAnalysis/ResolverRegisterInfoComparer.cs similarity index 90% rename from src/MessagePack.Generator/CodeAnalysis/ResolverRegisterInfoComparer.cs rename to src/MessagePack.SourceGenerator/CodeAnalysis/ResolverRegisterInfoComparer.cs index 03b62040c..9d6247f24 100644 --- a/src/MessagePack.Generator/CodeAnalysis/ResolverRegisterInfoComparer.cs +++ b/src/MessagePack.SourceGenerator/CodeAnalysis/ResolverRegisterInfoComparer.cs @@ -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. -namespace MessagePack.Generator.CodeAnalysis; +namespace MessagePack.SourceGenerator.CodeAnalysis; public class ResolverRegisterInfoComparer : IComparer { diff --git a/src/MessagePack.Generator/CodeAnalysis/TypeCollector.cs b/src/MessagePack.SourceGenerator/CodeAnalysis/TypeCollector.cs similarity index 99% rename from src/MessagePack.Generator/CodeAnalysis/TypeCollector.cs rename to src/MessagePack.SourceGenerator/CodeAnalysis/TypeCollector.cs index f040f8da4..778773b4f 100644 --- a/src/MessagePack.Generator/CodeAnalysis/TypeCollector.cs +++ b/src/MessagePack.SourceGenerator/CodeAnalysis/TypeCollector.cs @@ -10,7 +10,7 @@ using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp.Syntax; -namespace MessagePack.Generator.CodeAnalysis; +namespace MessagePack.SourceGenerator.CodeAnalysis; public class MessagePackGeneratorResolveFailedException : Exception { diff --git a/src/MessagePack.Generator/CodeAnalysis/UnionSerializationInfo.cs b/src/MessagePack.SourceGenerator/CodeAnalysis/UnionSerializationInfo.cs similarity index 96% rename from src/MessagePack.Generator/CodeAnalysis/UnionSerializationInfo.cs rename to src/MessagePack.SourceGenerator/CodeAnalysis/UnionSerializationInfo.cs index 25bab861e..598ea2e01 100644 --- a/src/MessagePack.Generator/CodeAnalysis/UnionSerializationInfo.cs +++ b/src/MessagePack.SourceGenerator/CodeAnalysis/UnionSerializationInfo.cs @@ -4,7 +4,7 @@ using System.Xml.Linq; using Microsoft.CodeAnalysis; -namespace MessagePack.Generator.CodeAnalysis; +namespace MessagePack.SourceGenerator.CodeAnalysis; public record UnionSerializationInfo( string? Namespace, diff --git a/src/MessagePack.Generator/CodeAnalysis/UnionSubTypeInfo.cs b/src/MessagePack.SourceGenerator/CodeAnalysis/UnionSubTypeInfo.cs similarity index 80% rename from src/MessagePack.Generator/CodeAnalysis/UnionSubTypeInfo.cs rename to src/MessagePack.SourceGenerator/CodeAnalysis/UnionSubTypeInfo.cs index 7b65c23f7..88eaecaa1 100644 --- a/src/MessagePack.Generator/CodeAnalysis/UnionSubTypeInfo.cs +++ b/src/MessagePack.SourceGenerator/CodeAnalysis/UnionSubTypeInfo.cs @@ -1,6 +1,6 @@ // Copyright (c) All contributors. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace MessagePack.Generator.CodeAnalysis; +namespace MessagePack.SourceGenerator.CodeAnalysis; public record UnionSubTypeInfo(int Key, string Type); diff --git a/src/MessagePack.Generator/IGeneratorContext.cs b/src/MessagePack.SourceGenerator/IGeneratorContext.cs similarity index 90% rename from src/MessagePack.Generator/IGeneratorContext.cs rename to src/MessagePack.SourceGenerator/IGeneratorContext.cs index b51c5acbb..d3b6bf4ac 100644 --- a/src/MessagePack.Generator/IGeneratorContext.cs +++ b/src/MessagePack.SourceGenerator/IGeneratorContext.cs @@ -3,7 +3,7 @@ using Microsoft.CodeAnalysis; -namespace MessagePack.Generator; +namespace MessagePack.SourceGenerator; public interface IGeneratorContext { diff --git a/src/MessagePack.Generator/MessagePack.Generator.csproj b/src/MessagePack.SourceGenerator/MessagePack.SourceGenerator.csproj similarity index 100% rename from src/MessagePack.Generator/MessagePack.Generator.csproj rename to src/MessagePack.SourceGenerator/MessagePack.SourceGenerator.csproj diff --git a/src/MessagePack.Generator/MessagePackGenerator.Emit.cs b/src/MessagePack.SourceGenerator/MessagePackGenerator.Emit.cs similarity index 95% rename from src/MessagePack.Generator/MessagePackGenerator.Emit.cs rename to src/MessagePack.SourceGenerator/MessagePackGenerator.Emit.cs index 4332d2a7c..9ec90a3d0 100644 --- a/src/MessagePack.Generator/MessagePackGenerator.Emit.cs +++ b/src/MessagePack.SourceGenerator/MessagePackGenerator.Emit.cs @@ -2,11 +2,11 @@ // Licensed under the MIT license. See LICENSE file in the project root for full license information. using System.Text; -using MessagePack.Generator.CodeAnalysis; -using MessagePack.Generator.Transforms; +using MessagePack.SourceGenerator.CodeAnalysis; +using MessagePack.SourceGenerator.Transforms; using Microsoft.CodeAnalysis; -namespace MessagePack.Generator; +namespace MessagePack.SourceGenerator; public partial class MessagePackGenerator { diff --git a/src/MessagePack.Generator/MessagePackGenerator.cs b/src/MessagePack.SourceGenerator/MessagePackGenerator.cs similarity index 97% rename from src/MessagePack.Generator/MessagePackGenerator.cs rename to src/MessagePack.SourceGenerator/MessagePackGenerator.cs index 8fd9d9da9..38c6820ae 100644 --- a/src/MessagePack.Generator/MessagePackGenerator.cs +++ b/src/MessagePack.SourceGenerator/MessagePackGenerator.cs @@ -2,11 +2,11 @@ // Licensed under the MIT license. See LICENSE file in the project root for full license information. using System.Collections.Immutable; -using MessagePack.Generator.CodeAnalysis; +using MessagePack.SourceGenerator.CodeAnalysis; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp.Syntax; -namespace MessagePack.Generator; +namespace MessagePack.SourceGenerator; [Generator(LanguageNames.CSharp)] public partial class MessagePackGenerator : IIncrementalGenerator diff --git a/src/MessagePack.Generator/Transforms/.editorconfig b/src/MessagePack.SourceGenerator/Transforms/.editorconfig similarity index 100% rename from src/MessagePack.Generator/Transforms/.editorconfig rename to src/MessagePack.SourceGenerator/Transforms/.editorconfig diff --git a/src/MessagePack.Generator/Transforms/.gitattributes b/src/MessagePack.SourceGenerator/Transforms/.gitattributes similarity index 100% rename from src/MessagePack.Generator/Transforms/.gitattributes rename to src/MessagePack.SourceGenerator/Transforms/.gitattributes diff --git a/src/MessagePack.Generator/Transforms/EnumTemplate.cs b/src/MessagePack.SourceGenerator/Transforms/EnumTemplate.cs similarity index 99% rename from src/MessagePack.Generator/Transforms/EnumTemplate.cs rename to src/MessagePack.SourceGenerator/Transforms/EnumTemplate.cs index 00e1e08a5..2ddc5bc36 100644 --- a/src/MessagePack.Generator/Transforms/EnumTemplate.cs +++ b/src/MessagePack.SourceGenerator/Transforms/EnumTemplate.cs @@ -2,15 +2,15 @@ // // This code was generated by a tool. // Runtime Version: 17.0.0.0 -// +// // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. // // ------------------------------------------------------------------------------ -namespace MessagePack.Generator.Transforms +namespace MessagePack.SourceGenerator.Transforms { using System; - + /// /// Class to produce the template output /// @@ -146,7 +146,7 @@ public void Write(string textToAppend) } // If we're starting off, or if the previous text ended with a newline, // we have to append the current indent first. - if (((this.GenerationEnvironment.Length == 0) + if (((this.GenerationEnvironment.Length == 0) || this.endsWithNewline)) { this.GenerationEnvironment.Append(this.currentIndentField); diff --git a/src/MessagePack.Generator/Transforms/EnumTemplate.tt b/src/MessagePack.SourceGenerator/Transforms/EnumTemplate.tt similarity index 100% rename from src/MessagePack.Generator/Transforms/EnumTemplate.tt rename to src/MessagePack.SourceGenerator/Transforms/EnumTemplate.tt diff --git a/src/MessagePack.Generator/Transforms/FormatterTemplate.cs b/src/MessagePack.SourceGenerator/Transforms/FormatterTemplate.cs similarity index 95% rename from src/MessagePack.Generator/Transforms/FormatterTemplate.cs rename to src/MessagePack.SourceGenerator/Transforms/FormatterTemplate.cs index 2b67e8a96..f23b57956 100644 --- a/src/MessagePack.Generator/Transforms/FormatterTemplate.cs +++ b/src/MessagePack.SourceGenerator/Transforms/FormatterTemplate.cs @@ -2,18 +2,18 @@ // // This code was generated by a tool. // Runtime Version: 17.0.0.0 -// +// // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. // // ------------------------------------------------------------------------------ -namespace MessagePack.Generator.Transforms +namespace MessagePack.SourceGenerator.Transforms { using System.Linq; using System.Text; using System.Collections.Generic; using System; - + /// /// Class to produce the template output /// @@ -34,16 +34,16 @@ public virtual string TransformText() this.Write(" : MsgPack::Formatters.IMessagePackFormatter<"); this.Write(this.ToStringHelper.ToStringWithCulture(Info.FullName)); this.Write(">\r\n"); - foreach (var typeArg in Info.GenericTypeParameters.Where(x => x.HasConstraints)) { + foreach (var typeArg in Info.GenericTypeParameters.Where(x => x.HasConstraints)) { this.Write("\t\twhere "); this.Write(this.ToStringHelper.ToStringWithCulture(typeArg.Name)); this.Write(" : "); this.Write(this.ToStringHelper.ToStringWithCulture(typeArg.Constraints)); this.Write("\r\n"); - } + } this.Write("\t{\r\n"); - foreach (var item in Info.Members) { - if (item.CustomFormatterTypeName != null) { + foreach (var item in Info.Members) { + if (item.CustomFormatterTypeName != null) { this.Write("\t\tprivate readonly "); this.Write(this.ToStringHelper.ToStringWithCulture(item.CustomFormatterTypeName)); this.Write(" __"); @@ -51,104 +51,104 @@ public virtual string TransformText() this.Write("CustomFormatter__ = new "); this.Write(this.ToStringHelper.ToStringWithCulture(item.CustomFormatterTypeName)); this.Write("();\r\n"); - } - } + } + } this.Write("\r\n\t\tpublic void Serialize(ref MsgPack::MessagePackWriter writer, "); this.Write(this.ToStringHelper.ToStringWithCulture(Info.FullName)); this.Write(" value, MsgPack::MessagePackSerializerOptions options)\r\n\t\t{\r\n"); - if (Info.IsClass) { + if (Info.IsClass) { this.Write("\t\t\tif (value == null)\r\n\t\t\t{\r\n\t\t\t\twriter.WriteNil();\r\n\t\t\t\treturn;\r\n\t\t\t}\r\n\r\n"); } - if (isFormatterResolverNecessary) { + if (isFormatterResolverNecessary) { this.Write("\t\t\tMsgPack::IFormatterResolver formatterResolver = options.Resolver;\r\n"); } if (Info.HasIMessagePackSerializationCallbackReceiver) { - if (Info.NeedsCastOnBefore) { + if (Info.NeedsCastOnBefore) { this.Write("\t\t\t((MsgPack::IMessagePackSerializationCallbackReceiver)value).OnBeforeSerialize(" + ");\r\n"); - } else { + } else { this.Write("\t\t\tvalue.OnBeforeSerialize();\r\n"); - } - } + } + } this.Write("\t\t\twriter.WriteArrayHeader("); this.Write(this.ToStringHelper.ToStringWithCulture(Info.MaxKey + 1)); this.Write(");\r\n"); for (var i = 0; i <= Info.MaxKey; i++) { var member = Info.GetMember(i); - if (member == null) { + if (member == null) { this.Write("\t\t\twriter.WriteNil();\r\n"); - } else { + } else { this.Write("\t\t\t"); this.Write(this.ToStringHelper.ToStringWithCulture(member.GetSerializeMethodString())); this.Write(";\r\n"); - } - } + } + } this.Write("\t\t}\r\n\r\n\t\tpublic "); this.Write(this.ToStringHelper.ToStringWithCulture(Info.FullName)); this.Write(" Deserialize(ref MsgPack::MessagePackReader reader, MsgPack::MessagePackSerialize" + "rOptions options)\r\n\t\t{\r\n\t\t\tif (reader.TryReadNil())\r\n\t\t\t{\r\n"); - if (Info.IsClass) { + if (Info.IsClass) { this.Write("\t\t\t\treturn null;\r\n"); - } else { + } else { this.Write("\t\t\t\tthrow new global::System.InvalidOperationException(\"typecode is null, struct " + "not supported\");\r\n"); - } + } this.Write("\t\t\t}\r\n\r\n"); - if (Info.MaxKey == -1 && !Info.HasIMessagePackSerializationCallbackReceiver) { + if (Info.MaxKey == -1 && !Info.HasIMessagePackSerializationCallbackReceiver) { this.Write("\t\t\treader.Skip();\r\n\t\t\treturn new "); this.Write(this.ToStringHelper.ToStringWithCulture(Info.GetConstructorString())); this.Write(";\r\n"); - } else { + } else { this.Write("\t\t\toptions.Security.DepthStep(ref reader);\r\n"); - if (isFormatterResolverNecessary) { + if (isFormatterResolverNecessary) { this.Write("\t\t\tMsgPack::IFormatterResolver formatterResolver = options.Resolver;\r\n"); - } + } this.Write("\t\t\tvar length = reader.ReadArrayHeader();\r\n"); var canOverwrite = Info.ConstructorParameters.Length == 0; - if (canOverwrite) { + if (canOverwrite) { this.Write("\t\t\tvar ____result = new "); this.Write(this.ToStringHelper.ToStringWithCulture(Info.GetConstructorString())); this.Write(";\r\n"); - } else { foreach (var member in Info.Members) { + } else { foreach (var member in Info.Members) { this.Write("\t\t\tvar __"); this.Write(this.ToStringHelper.ToStringWithCulture(member.Name)); this.Write("__ = default("); this.Write(this.ToStringHelper.ToStringWithCulture(member.Type)); this.Write(");\r\n"); - } - } + } + } this.Write("\r\n\t\t\tfor (int i = 0; i < length; i++)\r\n\t\t\t{\r\n\t\t\t\tswitch (i)\r\n\t\t\t\t{\r\n"); for (var memberIndex = 0; memberIndex <= Info.MaxKey; memberIndex++) { var member = Info.GetMember(memberIndex); - if (member == null) { continue; } + if (member == null) { continue; } this.Write("\t\t\t\t\tcase "); this.Write(this.ToStringHelper.ToStringWithCulture(member.IntKey)); this.Write(":\r\n"); if (canOverwrite) { - if (member.IsWritable) { + if (member.IsWritable) { this.Write("\t\t\t\t\t\t____result."); this.Write(this.ToStringHelper.ToStringWithCulture(member.Name)); this.Write(" = "); this.Write(this.ToStringHelper.ToStringWithCulture(member.GetDeserializeMethodString())); this.Write(";\r\n"); - } else { + } else { this.Write("\t\t\t\t\t\t"); this.Write(this.ToStringHelper.ToStringWithCulture(member.GetDeserializeMethodString())); this.Write(";\r\n"); - } + } } else { this.Write("\t\t\t\t\t\t__"); this.Write(this.ToStringHelper.ToStringWithCulture(member.Name)); this.Write("__ = "); this.Write(this.ToStringHelper.ToStringWithCulture(member.GetDeserializeMethodString())); this.Write(";\r\n"); - } + } this.Write("\t\t\t\t\t\tbreak;\r\n"); - } + } this.Write("\t\t\t\t\tdefault:\r\n\t\t\t\t\t\treader.Skip();\r\n\t\t\t\t\t\tbreak;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n"); - if (!canOverwrite) { + if (!canOverwrite) { this.Write("\t\t\tvar ____result = new "); this.Write(this.ToStringHelper.ToStringWithCulture(Info.GetConstructorString())); this.Write(";\r\n"); @@ -164,22 +164,22 @@ public virtual string TransformText() this.Write(" = __"); this.Write(this.ToStringHelper.ToStringWithCulture(member.Name)); this.Write("__;\r\n"); - } - if (memberAssignExists) { + } + if (memberAssignExists) { this.Write("\r\n\t\tMEMBER_ASSIGNMENT_END:\r\n"); } } if (Info.HasIMessagePackSerializationCallbackReceiver) { - if (Info.NeedsCastOnAfter) { + if (Info.NeedsCastOnAfter) { this.Write("\t\t\t((MsgPack::IMessagePackSerializationCallbackReceiver)____result).OnAfterDeseri" + "alize();\r\n"); - } else { + } else { this.Write("\t\t\t____result.OnAfterDeserialize();\r\n"); - } - } + } + } this.Write("\t\t\treader.Depth--;\r\n\t\t\treturn ____result;\r\n"); - } + } this.Write("\t\t}\r\n\t}\r\n}\r\n"); return this.GenerationEnvironment.ToString(); } @@ -283,7 +283,7 @@ public void Write(string textToAppend) } // If we're starting off, or if the previous text ended with a newline, // we have to append the current indent first. - if (((this.GenerationEnvironment.Length == 0) + if (((this.GenerationEnvironment.Length == 0) || this.endsWithNewline)) { this.GenerationEnvironment.Append(this.currentIndentField); diff --git a/src/MessagePack.Generator/Transforms/FormatterTemplate.tt b/src/MessagePack.SourceGenerator/Transforms/FormatterTemplate.tt similarity index 100% rename from src/MessagePack.Generator/Transforms/FormatterTemplate.tt rename to src/MessagePack.SourceGenerator/Transforms/FormatterTemplate.tt diff --git a/src/MessagePack.Generator/Transforms/IFormatterTemplate.cs b/src/MessagePack.SourceGenerator/Transforms/IFormatterTemplate.cs similarity index 77% rename from src/MessagePack.Generator/Transforms/IFormatterTemplate.cs rename to src/MessagePack.SourceGenerator/Transforms/IFormatterTemplate.cs index e1fd2a67f..18d8e63d4 100644 --- a/src/MessagePack.Generator/Transforms/IFormatterTemplate.cs +++ b/src/MessagePack.SourceGenerator/Transforms/IFormatterTemplate.cs @@ -1,9 +1,9 @@ // Copyright (c) All contributors. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -using MessagePack.Generator.CodeAnalysis; +using MessagePack.SourceGenerator.CodeAnalysis; -namespace MessagePack.Generator.Transforms; +namespace MessagePack.SourceGenerator.Transforms; public interface IFormatterTemplate { diff --git a/src/MessagePack.Generator/Transforms/ResolverTemplate.cs b/src/MessagePack.SourceGenerator/Transforms/ResolverTemplate.cs similarity index 99% rename from src/MessagePack.Generator/Transforms/ResolverTemplate.cs rename to src/MessagePack.SourceGenerator/Transforms/ResolverTemplate.cs index a490462a4..f1ff98243 100644 --- a/src/MessagePack.Generator/Transforms/ResolverTemplate.cs +++ b/src/MessagePack.SourceGenerator/Transforms/ResolverTemplate.cs @@ -2,18 +2,18 @@ // // This code was generated by a tool. // Runtime Version: 17.0.0.0 -// +// // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. // // ------------------------------------------------------------------------------ -namespace MessagePack.Generator.Transforms +namespace MessagePack.SourceGenerator.Transforms { using System.Linq; using System.Text; using System.Collections.Generic; using System; - + /// /// Class to produce the template output /// @@ -73,23 +73,23 @@ static FormatterCache() "tionary("); this.Write(this.ToStringHelper.ToStringWithCulture(RegisterInfos.Count)); this.Write(")\r\n\t\t\t{\r\n"); - for(var i = 0; i < RegisterInfos.Count; i++) { var x = RegisterInfos[i]; + for(var i = 0; i < RegisterInfos.Count; i++) { var x = RegisterInfos[i]; this.Write("\t\t\t\t{ typeof("); this.Write(this.ToStringHelper.ToStringWithCulture(x.FullName)); this.Write("), "); this.Write(this.ToStringHelper.ToStringWithCulture(i)); this.Write(" },\r\n"); - } + } this.Write("\t\t\t};\r\n\t\t}\r\n\r\n\t\tinternal static object GetFormatter(global::System.Type t)\r\n\t\t{\r\n" + "\t\t\tint key;\r\n\t\t\tif (!lookup.TryGetValue(t, out key))\r\n\t\t\t{\r\n\t\t\t\treturn null;\r\n\t\t" + "\t}\r\n\r\n\t\t\tswitch (key)\r\n\t\t\t{\r\n"); - for(var i = 0; i < RegisterInfos.Count; i++) { var x = RegisterInfos[i]; + for(var i = 0; i < RegisterInfos.Count; i++) { var x = RegisterInfos[i]; this.Write("\t\t\t\tcase "); this.Write(this.ToStringHelper.ToStringWithCulture(i)); this.Write(": return new "); this.Write(this.ToStringHelper.ToStringWithCulture(x.FormatterName)); this.Write("();\r\n"); - } + } this.Write("\t\t\t\tdefault: return null;\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n}\r\n"); return this.GenerationEnvironment.ToString(); } @@ -193,7 +193,7 @@ public void Write(string textToAppend) } // If we're starting off, or if the previous text ended with a newline, // we have to append the current indent first. - if (((this.GenerationEnvironment.Length == 0) + if (((this.GenerationEnvironment.Length == 0) || this.endsWithNewline)) { this.GenerationEnvironment.Append(this.currentIndentField); diff --git a/src/MessagePack.Generator/Transforms/ResolverTemplate.tt b/src/MessagePack.SourceGenerator/Transforms/ResolverTemplate.tt similarity index 100% rename from src/MessagePack.Generator/Transforms/ResolverTemplate.tt rename to src/MessagePack.SourceGenerator/Transforms/ResolverTemplate.tt diff --git a/src/MessagePack.Generator/Transforms/ShouldUseFormatterResolverHelper.cs b/src/MessagePack.SourceGenerator/Transforms/ShouldUseFormatterResolverHelper.cs similarity index 93% rename from src/MessagePack.Generator/Transforms/ShouldUseFormatterResolverHelper.cs rename to src/MessagePack.SourceGenerator/Transforms/ShouldUseFormatterResolverHelper.cs index f9d718734..e6de0a828 100644 --- a/src/MessagePack.Generator/Transforms/ShouldUseFormatterResolverHelper.cs +++ b/src/MessagePack.SourceGenerator/Transforms/ShouldUseFormatterResolverHelper.cs @@ -1,9 +1,9 @@ // Copyright (c) All contributors. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -using MessagePack.Generator.CodeAnalysis; +using MessagePack.SourceGenerator.CodeAnalysis; -namespace MessagePack.Generator.Transforms; +namespace MessagePack.SourceGenerator.Transforms; public static class ShouldUseFormatterResolverHelper { diff --git a/src/MessagePack.Generator/Transforms/StringKey/EmbedStringHelper.cs b/src/MessagePack.SourceGenerator/Transforms/StringKey/EmbedStringHelper.cs similarity index 98% rename from src/MessagePack.Generator/Transforms/StringKey/EmbedStringHelper.cs rename to src/MessagePack.SourceGenerator/Transforms/StringKey/EmbedStringHelper.cs index 40b879b2e..590f9e53c 100644 --- a/src/MessagePack.Generator/Transforms/StringKey/EmbedStringHelper.cs +++ b/src/MessagePack.SourceGenerator/Transforms/StringKey/EmbedStringHelper.cs @@ -3,7 +3,7 @@ using System.Text; -namespace MessagePack.Generator.Transforms; +namespace MessagePack.SourceGenerator.Transforms; public static class EmbedStringHelper { diff --git a/src/MessagePack.Generator/Transforms/StringKey/StringKeyFormatterDeserializeHelper.cs b/src/MessagePack.SourceGenerator/Transforms/StringKey/StringKeyFormatterDeserializeHelper.cs similarity index 98% rename from src/MessagePack.Generator/Transforms/StringKey/StringKeyFormatterDeserializeHelper.cs rename to src/MessagePack.SourceGenerator/Transforms/StringKey/StringKeyFormatterDeserializeHelper.cs index 7801b06eb..428fd6605 100644 --- a/src/MessagePack.Generator/Transforms/StringKey/StringKeyFormatterDeserializeHelper.cs +++ b/src/MessagePack.SourceGenerator/Transforms/StringKey/StringKeyFormatterDeserializeHelper.cs @@ -2,10 +2,10 @@ // Licensed under the MIT license. See LICENSE file in the project root for full license information. using System.Text; -using MessagePack.Generator.CodeAnalysis; using MessagePack.Internal; +using MessagePack.SourceGenerator.CodeAnalysis; -namespace MessagePack.Generator.Transforms; +namespace MessagePack.SourceGenerator.Transforms; internal static class StringKeyFormatterDeserializeHelper { diff --git a/src/MessagePack.Generator/Transforms/StringKey/StringKeyFormatterTemplate.cs b/src/MessagePack.SourceGenerator/Transforms/StringKey/StringKeyFormatterTemplate.cs similarity index 94% rename from src/MessagePack.Generator/Transforms/StringKey/StringKeyFormatterTemplate.cs rename to src/MessagePack.SourceGenerator/Transforms/StringKey/StringKeyFormatterTemplate.cs index 25e88fd1c..4312c0a4b 100644 --- a/src/MessagePack.Generator/Transforms/StringKey/StringKeyFormatterTemplate.cs +++ b/src/MessagePack.SourceGenerator/Transforms/StringKey/StringKeyFormatterTemplate.cs @@ -2,18 +2,18 @@ // // This code was generated by a tool. // Runtime Version: 17.0.0.0 -// +// // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. // // ------------------------------------------------------------------------------ -namespace MessagePack.Generator.Transforms +namespace MessagePack.SourceGenerator.Transforms { using System; using System.Linq; using System.Collections.Generic; - using MessagePack.Generator.CodeAnalysis; - + using MessagePack.SourceGenerator.CodeAnalysis; + /// /// Class to produce the template output /// @@ -34,7 +34,7 @@ public virtual string TransformText() list.Add(new ValueTuple(member, binary)); } - bool isFormatterResolverNecessary = ShouldUseFormatterResolverHelper.ShouldUseFormatterResolver(Info.Members); + bool isFormatterResolverNecessary = ShouldUseFormatterResolverHelper.ShouldUseFormatterResolver(Info.Members); this.Write("\tinternal sealed class "); this.Write(this.ToStringHelper.ToStringWithCulture(Info.FormatterNameWithoutNamespace)); this.Write(" : global::MessagePack.Formatters.IMessagePackFormatter<"); @@ -48,8 +48,8 @@ public virtual string TransformText() this.Write("\r\n"); } this.Write("\t{\r\n"); - foreach (var item in Info.Members) { - if (item.CustomFormatterTypeName != null) { + foreach (var item in Info.Members) { + if (item.CustomFormatterTypeName != null) { this.Write("\t\tprivate readonly "); this.Write(this.ToStringHelper.ToStringWithCulture(item.CustomFormatterTypeName)); this.Write(" __"); @@ -57,11 +57,11 @@ public virtual string TransformText() this.Write("CustomFormatter__ = new "); this.Write(this.ToStringHelper.ToStringWithCulture(item.CustomFormatterTypeName)); this.Write("();\r\n"); - } - } + } + } for (var i = 0; i < list.Count; i++) { var member = list[i].Item1; - var binary = list[i].Item2; + var binary = list[i].Item2; this.Write("\t\t// "); this.Write(this.ToStringHelper.ToStringWithCulture(member.StringKey)); this.Write("\r\n\t\tprivate static global::System.ReadOnlySpan GetSpan_"); @@ -69,92 +69,92 @@ public virtual string TransformText() this.Write("() => "); this.Write(this.ToStringHelper.ToStringWithCulture(EmbedStringHelper.ToByteArrayString(binary))); this.Write(";\r\n"); - } - if (list.Count != 0) { + } + if (list.Count != 0) { this.Write("\r\n"); - } + } this.Write("\t\tpublic void Serialize(ref global::MessagePack.MessagePackWriter writer, "); this.Write(this.ToStringHelper.ToStringWithCulture(Info.FullName)); this.Write(" value, global::MessagePack.MessagePackSerializerOptions options)\r\n\t\t{\r\n"); - if (Info.IsClass) { + if (Info.IsClass) { this.Write("\t\t\tif (value is null)\r\n\t\t\t{\r\n\t\t\t\twriter.WriteNil();\r\n\t\t\t\treturn;\r\n\t\t\t}\r\n\r\n"); } - if (isFormatterResolverNecessary) { + if (isFormatterResolverNecessary) { this.Write("\t\t\tvar formatterResolver = options.Resolver;\r\n"); } if (Info.HasIMessagePackSerializationCallbackReceiver) { - if (Info.NeedsCastOnBefore) { + if (Info.NeedsCastOnBefore) { this.Write("\t\t\t((global::MessagePack.IMessagePackSerializationCallbackReceiver)value).OnBefor" + "eSerialize();\r\n"); - } else { + } else { this.Write("\t\t\tvalue.OnBeforeSerialize();\r\n"); - } - } + } + } this.Write("\t\t\twriter.WriteMapHeader("); this.Write(this.ToStringHelper.ToStringWithCulture(list.Count)); this.Write(");\r\n"); foreach (var memberAndBinary in list) { - var member = memberAndBinary.Item1; + var member = memberAndBinary.Item1; this.Write("\t\t\twriter.WriteRaw(GetSpan_"); this.Write(this.ToStringHelper.ToStringWithCulture(member.Name)); this.Write("());\r\n\t\t\t"); this.Write(this.ToStringHelper.ToStringWithCulture(member.GetSerializeMethodString())); this.Write(";\r\n"); - } + } this.Write("\t\t}\r\n\r\n\t\tpublic "); this.Write(this.ToStringHelper.ToStringWithCulture(Info.FullName)); this.Write(" Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePac" + "k.MessagePackSerializerOptions options)\r\n\t\t{\r\n\t\t\tif (reader.TryReadNil())\r\n\t\t\t{\r" + "\n"); - if (Info.IsClass) { + if (Info.IsClass) { this.Write("\t\t\t\treturn null;\r\n"); - } else { + } else { this.Write("\t\t\t\tthrow new global::System.InvalidOperationException(\"typecode is null, struct " + "not supported\");\r\n"); - } + } this.Write("\t\t\t}\r\n\r\n"); - if (Info.Members.Length == 0) { + if (Info.Members.Length == 0) { this.Write("\t\t\treader.Skip();\r\n\t\t\tvar ____result = new "); this.Write(this.ToStringHelper.ToStringWithCulture(Info.GetConstructorString())); this.Write(";\r\n"); - } else { + } else { this.Write("\t\t\toptions.Security.DepthStep(ref reader);\r\n"); - if (isFormatterResolverNecessary) { + if (isFormatterResolverNecessary) { this.Write("\t\t\tvar formatterResolver = options.Resolver;\r\n"); - } + } this.Write("\t\t\tvar length = reader.ReadMapHeader();\r\n"); var canOverwrite = Info.ConstructorParameters.Length == 0; - if (canOverwrite) { + if (canOverwrite) { this.Write("\t\t\tvar ____result = new "); this.Write(this.ToStringHelper.ToStringWithCulture(Info.GetConstructorString())); this.Write(";\r\n"); } else { - foreach (var member in Info.Members.Where(x => x.IsWritable || Info.ConstructorParameters.Any(p => p.Equals(x)))) { - if (Info.ConstructorParameters.All(p => !p.Equals(member))) { + foreach (var member in Info.Members.Where(x => x.IsWritable || Info.ConstructorParameters.Any(p => p.Equals(x)))) { + if (Info.ConstructorParameters.All(p => !p.Equals(member))) { this.Write("\t\t\tvar __"); this.Write(this.ToStringHelper.ToStringWithCulture(member.Name)); this.Write("__IsInitialized = false;\r\n"); - } + } this.Write("\t\t\tvar __"); this.Write(this.ToStringHelper.ToStringWithCulture(member.Name)); this.Write("__ = default("); this.Write(this.ToStringHelper.ToStringWithCulture(member.Type)); this.Write(");\r\n"); - } - } + } + } this.Write("\r\n\t\t\tfor (int i = 0; i < length; i++)\r\n\t\t\t{\r\n\t\t\t\tvar stringKey = global::MessageP" + "ack.Internal.CodeGenHelpers.ReadStringSpan(ref reader);\r\n\t\t\t\tswitch (stringKey.L" + "ength)\r\n\t\t\t\t{\r\n\t\t\t\t\tdefault:\r\n\t\t\t\t\tFAIL:\r\n\t\t\t\t\t reader.Skip();\r\n\t\t\t\t\t continue" + ";\r\n"); this.Write(this.ToStringHelper.ToStringWithCulture(StringKeyFormatterDeserializeHelper.Classify(Info, " ", canOverwrite))); this.Write("\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n"); - if (!canOverwrite) { + if (!canOverwrite) { this.Write("\t\t\tvar ____result = new "); this.Write(this.ToStringHelper.ToStringWithCulture(Info.GetConstructorString())); this.Write(";\r\n"); - foreach (var member in Info.Members.Where(x => x.IsWritable && !Info.ConstructorParameters.Any(p => p.Equals(x)))) { + foreach (var member in Info.Members.Where(x => x.IsWritable && !Info.ConstructorParameters.Any(p => p.Equals(x)))) { this.Write("\t\t\tif (__"); this.Write(this.ToStringHelper.ToStringWithCulture(member.Name)); this.Write("__IsInitialized)\r\n\t\t\t{\r\n\t\t\t\t____result."); @@ -162,20 +162,20 @@ public virtual string TransformText() this.Write(" = __"); this.Write(this.ToStringHelper.ToStringWithCulture(member.Name)); this.Write("__;\r\n\t\t\t}\r\n\r\n"); - } - } - } + } + } + } if (Info.HasIMessagePackSerializationCallbackReceiver) { - if (Info.NeedsCastOnAfter) { + if (Info.NeedsCastOnAfter) { this.Write("\t\t\t((global::MessagePack.IMessagePackSerializationCallbackReceiver)____result).On" + "AfterDeserialize();\r\n"); - } else { + } else { this.Write("\t\t\t____result.OnAfterDeserialize();\r\n"); - } - } - if (Info.Members.Length != 0) { + } + } + if (Info.Members.Length != 0) { this.Write("\t\t\treader.Depth--;\r\n"); - } + } this.Write("\t\t\treturn ____result;\r\n\t\t}\r\n\t}\r\n}\r\n"); return this.GenerationEnvironment.ToString(); } @@ -279,7 +279,7 @@ public void Write(string textToAppend) } // If we're starting off, or if the previous text ended with a newline, // we have to append the current indent first. - if (((this.GenerationEnvironment.Length == 0) + if (((this.GenerationEnvironment.Length == 0) || this.endsWithNewline)) { this.GenerationEnvironment.Append(this.currentIndentField); diff --git a/src/MessagePack.Generator/Transforms/StringKey/StringKeyFormatterTemplate.tt b/src/MessagePack.SourceGenerator/Transforms/StringKey/StringKeyFormatterTemplate.tt similarity index 100% rename from src/MessagePack.Generator/Transforms/StringKey/StringKeyFormatterTemplate.tt rename to src/MessagePack.SourceGenerator/Transforms/StringKey/StringKeyFormatterTemplate.tt diff --git a/src/MessagePack.Generator/Transforms/TemplatePartials.cs b/src/MessagePack.SourceGenerator/Transforms/TemplatePartials.cs similarity index 96% rename from src/MessagePack.Generator/Transforms/TemplatePartials.cs rename to src/MessagePack.SourceGenerator/Transforms/TemplatePartials.cs index 1b09ccd0f..cd9f8dc67 100644 --- a/src/MessagePack.Generator/Transforms/TemplatePartials.cs +++ b/src/MessagePack.SourceGenerator/Transforms/TemplatePartials.cs @@ -3,9 +3,9 @@ #pragma warning disable SA1402 // File may only contain a single type -using MessagePack.Generator.CodeAnalysis; +using MessagePack.SourceGenerator.CodeAnalysis; -namespace MessagePack.Generator.Transforms; +namespace MessagePack.SourceGenerator.Transforms; public partial class FormatterTemplate : IFormatterTemplate { diff --git a/src/MessagePack.Generator/Transforms/UnionTemplate.cs b/src/MessagePack.SourceGenerator/Transforms/UnionTemplate.cs similarity index 98% rename from src/MessagePack.Generator/Transforms/UnionTemplate.cs rename to src/MessagePack.SourceGenerator/Transforms/UnionTemplate.cs index 86f1bca10..dd14ede45 100644 --- a/src/MessagePack.Generator/Transforms/UnionTemplate.cs +++ b/src/MessagePack.SourceGenerator/Transforms/UnionTemplate.cs @@ -2,18 +2,18 @@ // // This code was generated by a tool. // Runtime Version: 17.0.0.0 -// +// // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. // // ------------------------------------------------------------------------------ -namespace MessagePack.Generator.Transforms +namespace MessagePack.SourceGenerator.Transforms { using System.Linq; using System.Text; using System.Collections.Generic; using System; - + /// /// Class to produce the template output /// @@ -43,7 +43,7 @@ public virtual string TransformText() "neric.KeyValuePair>("); this.Write(this.ToStringHelper.ToStringWithCulture(Info.SubTypes.Length)); this.Write(", MsgPack::Internal.RuntimeTypeHandleEqualityComparer.Default)\r\n\t\t\t{\r\n"); - for(var i = 0; i < Info.SubTypes.Length; i++) { var item = Info.SubTypes[i]; + for(var i = 0; i < Info.SubTypes.Length; i++) { var item = Info.SubTypes[i]; this.Write("\t\t\t\t{ typeof("); this.Write(this.ToStringHelper.ToStringWithCulture(item.Type)); this.Write(").TypeHandle, new global::System.Collections.Generic.KeyValuePair("); @@ -51,18 +51,18 @@ public virtual string TransformText() this.Write(", "); this.Write(this.ToStringHelper.ToStringWithCulture(i)); this.Write(") },\r\n"); - } + } this.Write("\t\t\t};\r\n\t\t\tthis.keyToJumpMap = new global::System.Collections.Generic.Dictionary("); this.Write(this.ToStringHelper.ToStringWithCulture(Info.SubTypes.Length)); this.Write(")\r\n\t\t\t{\r\n"); - for(var i = 0; i < Info.SubTypes.Length; i++) { var item = Info.SubTypes[i]; + for(var i = 0; i < Info.SubTypes.Length; i++) { var item = Info.SubTypes[i]; this.Write("\t\t\t\t{ "); this.Write(this.ToStringHelper.ToStringWithCulture(item.Key)); this.Write(", "); this.Write(this.ToStringHelper.ToStringWithCulture(i)); this.Write(" },\r\n"); - } + } this.Write("\t\t\t};\r\n\t\t}\r\n\r\n\t\tpublic void Serialize(ref MsgPack::MessagePackWriter writer, "); this.Write(this.ToStringHelper.ToStringWithCulture(Info.FullName)); this.Write(@" value, MsgPack::MessagePackSerializerOptions options) @@ -75,7 +75,7 @@ public virtual string TransformText() switch (keyValuePair.Value) { "); - for(var i = 0; i < Info.SubTypes.Length; i++) { var item = Info.SubTypes[i]; + for(var i = 0; i < Info.SubTypes.Length; i++) { var item = Info.SubTypes[i]; this.Write("\t\t\t\t\tcase "); this.Write(this.ToStringHelper.ToStringWithCulture(i)); this.Write(":\r\n\t\t\t\t\t\tMsgPack::FormatterResolverExtensions.GetFormatterWithVerify<"); @@ -83,7 +83,7 @@ public virtual string TransformText() this.Write(">(options.Resolver).Serialize(ref writer, ("); this.Write(this.ToStringHelper.ToStringWithCulture(item.Type)); this.Write(")value, options);\r\n\t\t\t\t\t\tbreak;\r\n"); - } + } this.Write("\t\t\t\t\tdefault:\r\n\t\t\t\t\t\tbreak;\r\n\t\t\t\t}\r\n\r\n\t\t\t\treturn;\r\n\t\t\t}\r\n\r\n\t\t\twriter.WriteNil();\r" + "\n\t\t}\r\n\r\n\t\tpublic "); this.Write(this.ToStringHelper.ToStringWithCulture(Info.FullName)); @@ -103,7 +103,7 @@ public virtual string TransformText() "= -1;\r\n\t\t\t}\r\n\r\n\t\t\t"); this.Write(this.ToStringHelper.ToStringWithCulture(Info.FullName)); this.Write(" result = null;\r\n\t\t\tswitch (key)\r\n\t\t\t{\r\n"); - for(var i = 0; i < Info.SubTypes.Length; i++) { var item = Info.SubTypes[i]; + for(var i = 0; i < Info.SubTypes.Length; i++) { var item = Info.SubTypes[i]; this.Write("\t\t\t\tcase "); this.Write(this.ToStringHelper.ToStringWithCulture(i)); this.Write(":\r\n\t\t\t\t\tresult = ("); @@ -111,7 +111,7 @@ public virtual string TransformText() this.Write(")MsgPack::FormatterResolverExtensions.GetFormatterWithVerify<"); this.Write(this.ToStringHelper.ToStringWithCulture(item.Type)); this.Write(">(options.Resolver).Deserialize(ref reader, options);\r\n\t\t\t\t\tbreak;\r\n"); - } + } this.Write("\t\t\t\tdefault:\r\n\t\t\t\t\treader.Skip();\r\n\t\t\t\t\tbreak;\r\n\t\t\t}\r\n\r\n\t\t\treader.Depth--;\r\n\t\t\tre" + "turn result;\r\n\t\t}\r\n\t}\r\n}\r\n"); return this.GenerationEnvironment.ToString(); @@ -216,7 +216,7 @@ public void Write(string textToAppend) } // If we're starting off, or if the previous text ended with a newline, // we have to append the current indent first. - if (((this.GenerationEnvironment.Length == 0) + if (((this.GenerationEnvironment.Length == 0) || this.endsWithNewline)) { this.GenerationEnvironment.Append(this.currentIndentField); diff --git a/src/MessagePack.Generator/Transforms/UnionTemplate.tt b/src/MessagePack.SourceGenerator/Transforms/UnionTemplate.tt similarity index 100% rename from src/MessagePack.Generator/Transforms/UnionTemplate.tt rename to src/MessagePack.SourceGenerator/Transforms/UnionTemplate.tt diff --git a/src/MessagePack.Generator/Utils/RoslynExtensions.cs b/src/MessagePack.SourceGenerator/Utils/RoslynExtensions.cs similarity index 96% rename from src/MessagePack.Generator/Utils/RoslynExtensions.cs rename to src/MessagePack.SourceGenerator/Utils/RoslynExtensions.cs index a3df190c4..4d932c7f2 100644 --- a/src/MessagePack.Generator/Utils/RoslynExtensions.cs +++ b/src/MessagePack.SourceGenerator/Utils/RoslynExtensions.cs @@ -3,7 +3,7 @@ using Microsoft.CodeAnalysis; -namespace MessagePack.Generator; +namespace MessagePack.SourceGenerator; // Utility and Extension methods for Roslyn internal static class RoslynExtensions diff --git a/src/MessagePack.Generator/build/MessagePack.Generator.props b/src/MessagePack.SourceGenerator/build/MessagePack.SourceGenerator.props similarity index 100% rename from src/MessagePack.Generator/build/MessagePack.Generator.props rename to src/MessagePack.SourceGenerator/build/MessagePack.SourceGenerator.props diff --git a/src/MessagePack.Generator/build/MessagePack.Generator.targets b/src/MessagePack.SourceGenerator/build/MessagePack.SourceGenerator.targets similarity index 100% rename from src/MessagePack.Generator/build/MessagePack.Generator.targets rename to src/MessagePack.SourceGenerator/build/MessagePack.SourceGenerator.targets diff --git a/src/MessagePack.Generator/version.json b/src/MessagePack.SourceGenerator/version.json similarity index 100% rename from src/MessagePack.Generator/version.json rename to src/MessagePack.SourceGenerator/version.json diff --git a/tests/MessagePack.Generator.ExecutionTests/CustomFormatterRecord.cs b/tests/MessagePack.SourceGenerator.ExecutionTests/CustomFormatterRecord.cs similarity index 100% rename from tests/MessagePack.Generator.ExecutionTests/CustomFormatterRecord.cs rename to tests/MessagePack.SourceGenerator.ExecutionTests/CustomFormatterRecord.cs diff --git a/tests/MessagePack.Generator.ExecutionTests/CustomFormatterRecordFormatter.cs b/tests/MessagePack.SourceGenerator.ExecutionTests/CustomFormatterRecordFormatter.cs similarity index 100% rename from tests/MessagePack.Generator.ExecutionTests/CustomFormatterRecordFormatter.cs rename to tests/MessagePack.SourceGenerator.ExecutionTests/CustomFormatterRecordFormatter.cs diff --git a/tests/MessagePack.Generator.ExecutionTests/Derived1.cs b/tests/MessagePack.SourceGenerator.ExecutionTests/Derived1.cs similarity index 100% rename from tests/MessagePack.Generator.ExecutionTests/Derived1.cs rename to tests/MessagePack.SourceGenerator.ExecutionTests/Derived1.cs diff --git a/tests/MessagePack.Generator.ExecutionTests/Derived2.cs b/tests/MessagePack.SourceGenerator.ExecutionTests/Derived2.cs similarity index 100% rename from tests/MessagePack.Generator.ExecutionTests/Derived2.cs rename to tests/MessagePack.SourceGenerator.ExecutionTests/Derived2.cs diff --git a/tests/MessagePack.Generator.ExecutionTests/ExecutionTests.cs b/tests/MessagePack.SourceGenerator.ExecutionTests/ExecutionTests.cs similarity index 100% rename from tests/MessagePack.Generator.ExecutionTests/ExecutionTests.cs rename to tests/MessagePack.SourceGenerator.ExecutionTests/ExecutionTests.cs diff --git a/tests/MessagePack.Generator.ExecutionTests/HasPropertiesWithGetterAndCtor.cs b/tests/MessagePack.SourceGenerator.ExecutionTests/HasPropertiesWithGetterAndCtor.cs similarity index 100% rename from tests/MessagePack.Generator.ExecutionTests/HasPropertiesWithGetterAndCtor.cs rename to tests/MessagePack.SourceGenerator.ExecutionTests/HasPropertiesWithGetterAndCtor.cs diff --git a/tests/MessagePack.Generator.ExecutionTests/HasPropertiesWithGetterAndSetter.cs b/tests/MessagePack.SourceGenerator.ExecutionTests/HasPropertiesWithGetterAndSetter.cs similarity index 100% rename from tests/MessagePack.Generator.ExecutionTests/HasPropertiesWithGetterAndSetter.cs rename to tests/MessagePack.SourceGenerator.ExecutionTests/HasPropertiesWithGetterAndSetter.cs diff --git a/tests/MessagePack.Generator.ExecutionTests/HasPropertyWithCustomFormatterAttribute.cs b/tests/MessagePack.SourceGenerator.ExecutionTests/HasPropertyWithCustomFormatterAttribute.cs similarity index 100% rename from tests/MessagePack.Generator.ExecutionTests/HasPropertyWithCustomFormatterAttribute.cs rename to tests/MessagePack.SourceGenerator.ExecutionTests/HasPropertyWithCustomFormatterAttribute.cs diff --git a/tests/MessagePack.Generator.ExecutionTests/HasPropertyWithTypeWithCustomFormatter.cs b/tests/MessagePack.SourceGenerator.ExecutionTests/HasPropertyWithTypeWithCustomFormatter.cs similarity index 100% rename from tests/MessagePack.Generator.ExecutionTests/HasPropertyWithTypeWithCustomFormatter.cs rename to tests/MessagePack.SourceGenerator.ExecutionTests/HasPropertyWithTypeWithCustomFormatter.cs diff --git a/tests/MessagePack.Generator.ExecutionTests/IMyType.cs b/tests/MessagePack.SourceGenerator.ExecutionTests/IMyType.cs similarity index 100% rename from tests/MessagePack.Generator.ExecutionTests/IMyType.cs rename to tests/MessagePack.SourceGenerator.ExecutionTests/IMyType.cs diff --git a/tests/MessagePack.Generator.ExecutionTests/MessagePack.Generator.ExecutionTests.csproj b/tests/MessagePack.SourceGenerator.ExecutionTests/MessagePack.SourceGenerator.ExecutionTests.csproj similarity index 100% rename from tests/MessagePack.Generator.ExecutionTests/MessagePack.Generator.ExecutionTests.csproj rename to tests/MessagePack.SourceGenerator.ExecutionTests/MessagePack.SourceGenerator.ExecutionTests.csproj diff --git a/tests/MessagePack.Generator.ExecutionTests/MyEnum.cs b/tests/MessagePack.SourceGenerator.ExecutionTests/MyEnum.cs similarity index 100% rename from tests/MessagePack.Generator.ExecutionTests/MyEnum.cs rename to tests/MessagePack.SourceGenerator.ExecutionTests/MyEnum.cs diff --git a/tests/MessagePack.Generator.ExecutionTests/MyMessagePackObject.cs b/tests/MessagePack.SourceGenerator.ExecutionTests/MyMessagePackObject.cs similarity index 100% rename from tests/MessagePack.Generator.ExecutionTests/MyMessagePackObject.cs rename to tests/MessagePack.SourceGenerator.ExecutionTests/MyMessagePackObject.cs diff --git a/tests/MessagePack.Generator.ExecutionTests/UnionContainer.cs b/tests/MessagePack.SourceGenerator.ExecutionTests/UnionContainer.cs similarity index 100% rename from tests/MessagePack.Generator.ExecutionTests/UnionContainer.cs rename to tests/MessagePack.SourceGenerator.ExecutionTests/UnionContainer.cs diff --git a/tests/MessagePack.Generator.ExecutionTests/UnserializableRecord.cs b/tests/MessagePack.SourceGenerator.ExecutionTests/UnserializableRecord.cs similarity index 100% rename from tests/MessagePack.Generator.ExecutionTests/UnserializableRecord.cs rename to tests/MessagePack.SourceGenerator.ExecutionTests/UnserializableRecord.cs diff --git a/tests/MessagePack.Generator.ExecutionTests/UnserializableRecordFormatter.cs b/tests/MessagePack.SourceGenerator.ExecutionTests/UnserializableRecordFormatter.cs similarity index 100% rename from tests/MessagePack.Generator.ExecutionTests/UnserializableRecordFormatter.cs rename to tests/MessagePack.SourceGenerator.ExecutionTests/UnserializableRecordFormatter.cs diff --git a/tests/MessagePack.Generator.ExecutionTests/Usings.cs b/tests/MessagePack.SourceGenerator.ExecutionTests/Usings.cs similarity index 100% rename from tests/MessagePack.Generator.ExecutionTests/Usings.cs rename to tests/MessagePack.SourceGenerator.ExecutionTests/Usings.cs diff --git a/tests/MessagePack.Generator.MapModeExecutionTests/MessagePack.Generator.MapModeExecutionTests.csproj b/tests/MessagePack.SourceGenerator.MapModeExecutionTests/MessagePack.SourceGenerator.MapModeExecutionTests.csproj similarity index 89% rename from tests/MessagePack.Generator.MapModeExecutionTests/MessagePack.Generator.MapModeExecutionTests.csproj rename to tests/MessagePack.SourceGenerator.MapModeExecutionTests/MessagePack.SourceGenerator.MapModeExecutionTests.csproj index 50966af31..d9a3c0c40 100644 --- a/tests/MessagePack.Generator.MapModeExecutionTests/MessagePack.Generator.MapModeExecutionTests.csproj +++ b/tests/MessagePack.SourceGenerator.MapModeExecutionTests/MessagePack.SourceGenerator.MapModeExecutionTests.csproj @@ -9,13 +9,13 @@ - + - + - + diff --git a/tests/MessagePack.Generator.Tests/CodeAnalysis/EnumSerializationInfoTests.cs b/tests/MessagePack.SourceGenerator.Tests/CodeAnalysis/EnumSerializationInfoTests.cs similarity index 100% rename from tests/MessagePack.Generator.Tests/CodeAnalysis/EnumSerializationInfoTests.cs rename to tests/MessagePack.SourceGenerator.Tests/CodeAnalysis/EnumSerializationInfoTests.cs diff --git a/tests/MessagePack.Generator.Tests/CodeAnalysis/FullModelTests.cs b/tests/MessagePack.SourceGenerator.Tests/CodeAnalysis/FullModelTests.cs similarity index 100% rename from tests/MessagePack.Generator.Tests/CodeAnalysis/FullModelTests.cs rename to tests/MessagePack.SourceGenerator.Tests/CodeAnalysis/FullModelTests.cs diff --git a/tests/MessagePack.Generator.Tests/CodeAnalysis/GenericSerializationInfoTests.cs b/tests/MessagePack.SourceGenerator.Tests/CodeAnalysis/GenericSerializationInfoTests.cs similarity index 100% rename from tests/MessagePack.Generator.Tests/CodeAnalysis/GenericSerializationInfoTests.cs rename to tests/MessagePack.SourceGenerator.Tests/CodeAnalysis/GenericSerializationInfoTests.cs diff --git a/tests/MessagePack.Generator.Tests/CodeAnalysis/MemberSerializationInfoTests.cs b/tests/MessagePack.SourceGenerator.Tests/CodeAnalysis/MemberSerializationInfoTests.cs similarity index 100% rename from tests/MessagePack.Generator.Tests/CodeAnalysis/MemberSerializationInfoTests.cs rename to tests/MessagePack.SourceGenerator.Tests/CodeAnalysis/MemberSerializationInfoTests.cs diff --git a/tests/MessagePack.Generator.Tests/CodeAnalysis/ObjectSerializationInfoTests.cs b/tests/MessagePack.SourceGenerator.Tests/CodeAnalysis/ObjectSerializationInfoTests.cs similarity index 100% rename from tests/MessagePack.Generator.Tests/CodeAnalysis/ObjectSerializationInfoTests.cs rename to tests/MessagePack.SourceGenerator.Tests/CodeAnalysis/ObjectSerializationInfoTests.cs diff --git a/tests/MessagePack.Generator.Tests/CodeAnalysis/UnionSerializationInfoTests.cs b/tests/MessagePack.SourceGenerator.Tests/CodeAnalysis/UnionSerializationInfoTests.cs similarity index 100% rename from tests/MessagePack.Generator.Tests/CodeAnalysis/UnionSerializationInfoTests.cs rename to tests/MessagePack.SourceGenerator.Tests/CodeAnalysis/UnionSerializationInfoTests.cs diff --git a/tests/MessagePack.Generator.Tests/ContainerKind.cs b/tests/MessagePack.SourceGenerator.Tests/ContainerKind.cs similarity index 100% rename from tests/MessagePack.Generator.Tests/ContainerKind.cs rename to tests/MessagePack.SourceGenerator.Tests/ContainerKind.cs diff --git a/tests/MessagePack.Generator.Tests/GenerateGenericsFormatterTest.cs b/tests/MessagePack.SourceGenerator.Tests/GenerateGenericsFormatterTest.cs similarity index 99% rename from tests/MessagePack.Generator.Tests/GenerateGenericsFormatterTest.cs rename to tests/MessagePack.SourceGenerator.Tests/GenerateGenericsFormatterTest.cs index 4fb6a0eb1..938a3d1aa 100644 --- a/tests/MessagePack.Generator.Tests/GenerateGenericsFormatterTest.cs +++ b/tests/MessagePack.SourceGenerator.Tests/GenerateGenericsFormatterTest.cs @@ -12,7 +12,7 @@ using Xunit.Abstractions; using SymbolDisplayFormat = Microsoft.CodeAnalysis.SymbolDisplayFormat; -namespace MessagePack.Generator.Tests +namespace MessagePack.SourceGenerator.Tests { public class GenerateGenericsFormatterTest { diff --git a/tests/MessagePack.Generator.Tests/GenerateMessagePackFormatterAttrTest.cs b/tests/MessagePack.SourceGenerator.Tests/GenerateMessagePackFormatterAttrTest.cs similarity index 98% rename from tests/MessagePack.Generator.Tests/GenerateMessagePackFormatterAttrTest.cs rename to tests/MessagePack.SourceGenerator.Tests/GenerateMessagePackFormatterAttrTest.cs index 38e08f67b..afec7c0da 100644 --- a/tests/MessagePack.Generator.Tests/GenerateMessagePackFormatterAttrTest.cs +++ b/tests/MessagePack.SourceGenerator.Tests/GenerateMessagePackFormatterAttrTest.cs @@ -7,7 +7,7 @@ using Xunit; using Xunit.Abstractions; -namespace MessagePack.Generator.Tests +namespace MessagePack.SourceGenerator.Tests { public class GenerateMessagePackFormatterAttrTest { diff --git a/tests/MessagePack.Generator.Tests/GenerateStringKeyedFormatterTest.cs b/tests/MessagePack.SourceGenerator.Tests/GenerateStringKeyedFormatterTest.cs similarity index 99% rename from tests/MessagePack.Generator.Tests/GenerateStringKeyedFormatterTest.cs rename to tests/MessagePack.SourceGenerator.Tests/GenerateStringKeyedFormatterTest.cs index 1719fb5fa..ffd1d2df6 100644 --- a/tests/MessagePack.Generator.Tests/GenerateStringKeyedFormatterTest.cs +++ b/tests/MessagePack.SourceGenerator.Tests/GenerateStringKeyedFormatterTest.cs @@ -15,7 +15,7 @@ using Xunit; using Xunit.Abstractions; -namespace MessagePack.Generator.Tests +namespace MessagePack.SourceGenerator.Tests { public class GenerateStringKeyedFormatterTest { diff --git a/tests/MessagePack.Generator.Tests/GenerationTests.cs b/tests/MessagePack.SourceGenerator.Tests/GenerationTests.cs similarity index 99% rename from tests/MessagePack.Generator.Tests/GenerationTests.cs rename to tests/MessagePack.SourceGenerator.Tests/GenerationTests.cs index 54638ab22..236537715 100644 --- a/tests/MessagePack.Generator.Tests/GenerationTests.cs +++ b/tests/MessagePack.SourceGenerator.Tests/GenerationTests.cs @@ -2,7 +2,7 @@ // Licensed under the MIT license. See LICENSE file in the project root for full license information. using System.ComponentModel; -using MessagePack.Generator.Tests; +using MessagePack.SourceGenerator.Tests; public class GenerationTests { diff --git a/tests/MessagePack.Generator.Tests/MessagePack.Generator.Tests.csproj b/tests/MessagePack.SourceGenerator.Tests/MessagePack.SourceGenerator.Tests.csproj similarity index 91% rename from tests/MessagePack.Generator.Tests/MessagePack.Generator.Tests.csproj rename to tests/MessagePack.SourceGenerator.Tests/MessagePack.SourceGenerator.Tests.csproj index 4319132e9..b612b5876 100644 --- a/tests/MessagePack.Generator.Tests/MessagePack.Generator.Tests.csproj +++ b/tests/MessagePack.SourceGenerator.Tests/MessagePack.SourceGenerator.Tests.csproj @@ -17,7 +17,7 @@ - + @@ -30,7 +30,7 @@ - + diff --git a/tests/MessagePack.Generator.Tests/MultipleTypesTests.cs b/tests/MessagePack.SourceGenerator.Tests/MultipleTypesTests.cs similarity index 100% rename from tests/MessagePack.Generator.Tests/MultipleTypesTests.cs rename to tests/MessagePack.SourceGenerator.Tests/MultipleTypesTests.cs diff --git a/tests/MessagePack.Generator.Tests/Resources/.gitattributes b/tests/MessagePack.SourceGenerator.Tests/Resources/.gitattributes similarity index 100% rename from tests/MessagePack.Generator.Tests/Resources/.gitattributes rename to tests/MessagePack.SourceGenerator.Tests/Resources/.gitattributes diff --git a/tests/MessagePack.Generator.Tests/Resources/AddAttributeToType/Formatters.BarFormatter.g.cs b/tests/MessagePack.SourceGenerator.Tests/Resources/AddAttributeToType/Formatters.BarFormatter.g.cs similarity index 100% rename from tests/MessagePack.Generator.Tests/Resources/AddAttributeToType/Formatters.BarFormatter.g.cs rename to tests/MessagePack.SourceGenerator.Tests/Resources/AddAttributeToType/Formatters.BarFormatter.g.cs diff --git a/tests/MessagePack.Generator.Tests/Resources/AddAttributeToType/Formatters.FooFormatter.g.cs b/tests/MessagePack.SourceGenerator.Tests/Resources/AddAttributeToType/Formatters.FooFormatter.g.cs similarity index 100% rename from tests/MessagePack.Generator.Tests/Resources/AddAttributeToType/Formatters.FooFormatter.g.cs rename to tests/MessagePack.SourceGenerator.Tests/Resources/AddAttributeToType/Formatters.FooFormatter.g.cs diff --git a/tests/MessagePack.Generator.Tests/Resources/AddAttributeToType/MessagePack.GeneratedMessagePackResolver.g.cs b/tests/MessagePack.SourceGenerator.Tests/Resources/AddAttributeToType/MessagePack.GeneratedMessagePackResolver.g.cs similarity index 100% rename from tests/MessagePack.Generator.Tests/Resources/AddAttributeToType/MessagePack.GeneratedMessagePackResolver.g.cs rename to tests/MessagePack.SourceGenerator.Tests/Resources/AddAttributeToType/MessagePack.GeneratedMessagePackResolver.g.cs diff --git a/tests/MessagePack.Generator.Tests/Resources/ArrayTypedProperty/Formatters.ContainerObjectFormatter.g.cs b/tests/MessagePack.SourceGenerator.Tests/Resources/ArrayTypedProperty/Formatters.ContainerObjectFormatter.g.cs similarity index 100% rename from tests/MessagePack.Generator.Tests/Resources/ArrayTypedProperty/Formatters.ContainerObjectFormatter.g.cs rename to tests/MessagePack.SourceGenerator.Tests/Resources/ArrayTypedProperty/Formatters.ContainerObjectFormatter.g.cs diff --git a/tests/MessagePack.Generator.Tests/Resources/ArrayTypedProperty/Formatters.SubObjectFormatter.g.cs b/tests/MessagePack.SourceGenerator.Tests/Resources/ArrayTypedProperty/Formatters.SubObjectFormatter.g.cs similarity index 100% rename from tests/MessagePack.Generator.Tests/Resources/ArrayTypedProperty/Formatters.SubObjectFormatter.g.cs rename to tests/MessagePack.SourceGenerator.Tests/Resources/ArrayTypedProperty/Formatters.SubObjectFormatter.g.cs diff --git a/tests/MessagePack.Generator.Tests/Resources/ArrayTypedProperty/MessagePack.GeneratedMessagePackResolver.g.cs b/tests/MessagePack.SourceGenerator.Tests/Resources/ArrayTypedProperty/MessagePack.GeneratedMessagePackResolver.g.cs similarity index 100% rename from tests/MessagePack.Generator.Tests/Resources/ArrayTypedProperty/MessagePack.GeneratedMessagePackResolver.g.cs rename to tests/MessagePack.SourceGenerator.Tests/Resources/ArrayTypedProperty/MessagePack.GeneratedMessagePackResolver.g.cs diff --git a/tests/MessagePack.Generator.Tests/Resources/CustomFormatterViaAttributeOnProperty(False)/Formatters.HasPropertyWithCustomFormatterAttributeFormatter.g.cs b/tests/MessagePack.SourceGenerator.Tests/Resources/CustomFormatterViaAttributeOnProperty(False)/Formatters.HasPropertyWithCustomFormatterAttributeFormatter.g.cs similarity index 100% rename from tests/MessagePack.Generator.Tests/Resources/CustomFormatterViaAttributeOnProperty(False)/Formatters.HasPropertyWithCustomFormatterAttributeFormatter.g.cs rename to tests/MessagePack.SourceGenerator.Tests/Resources/CustomFormatterViaAttributeOnProperty(False)/Formatters.HasPropertyWithCustomFormatterAttributeFormatter.g.cs diff --git a/tests/MessagePack.Generator.Tests/Resources/CustomFormatterViaAttributeOnProperty(False)/MessagePack.GeneratedMessagePackResolver.g.cs b/tests/MessagePack.SourceGenerator.Tests/Resources/CustomFormatterViaAttributeOnProperty(False)/MessagePack.GeneratedMessagePackResolver.g.cs similarity index 100% rename from tests/MessagePack.Generator.Tests/Resources/CustomFormatterViaAttributeOnProperty(False)/MessagePack.GeneratedMessagePackResolver.g.cs rename to tests/MessagePack.SourceGenerator.Tests/Resources/CustomFormatterViaAttributeOnProperty(False)/MessagePack.GeneratedMessagePackResolver.g.cs diff --git a/tests/MessagePack.Generator.Tests/Resources/CustomFormatterViaAttributeOnProperty(True)/Formatters.HasPropertyWithCustomFormatterAttributeFormatter.g.cs b/tests/MessagePack.SourceGenerator.Tests/Resources/CustomFormatterViaAttributeOnProperty(True)/Formatters.HasPropertyWithCustomFormatterAttributeFormatter.g.cs similarity index 100% rename from tests/MessagePack.Generator.Tests/Resources/CustomFormatterViaAttributeOnProperty(True)/Formatters.HasPropertyWithCustomFormatterAttributeFormatter.g.cs rename to tests/MessagePack.SourceGenerator.Tests/Resources/CustomFormatterViaAttributeOnProperty(True)/Formatters.HasPropertyWithCustomFormatterAttributeFormatter.g.cs diff --git a/tests/MessagePack.Generator.Tests/Resources/CustomFormatterViaAttributeOnProperty(True)/MessagePack.GeneratedMessagePackResolver.g.cs b/tests/MessagePack.SourceGenerator.Tests/Resources/CustomFormatterViaAttributeOnProperty(True)/MessagePack.GeneratedMessagePackResolver.g.cs similarity index 100% rename from tests/MessagePack.Generator.Tests/Resources/CustomFormatterViaAttributeOnProperty(True)/MessagePack.GeneratedMessagePackResolver.g.cs rename to tests/MessagePack.SourceGenerator.Tests/Resources/CustomFormatterViaAttributeOnProperty(True)/MessagePack.GeneratedMessagePackResolver.g.cs diff --git a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(Namespace, False)/Formatters.MyTestNamespace.MyEnumFormatter.g.cs b/tests/MessagePack.SourceGenerator.Tests/Resources/EnumFormatter(Namespace, False)/Formatters.MyTestNamespace.MyEnumFormatter.g.cs similarity index 100% rename from tests/MessagePack.Generator.Tests/Resources/EnumFormatter(Namespace, False)/Formatters.MyTestNamespace.MyEnumFormatter.g.cs rename to tests/MessagePack.SourceGenerator.Tests/Resources/EnumFormatter(Namespace, False)/Formatters.MyTestNamespace.MyEnumFormatter.g.cs diff --git a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(Namespace, False)/Formatters.MyTestNamespace.MyMessagePackObjectFormatter.g.cs b/tests/MessagePack.SourceGenerator.Tests/Resources/EnumFormatter(Namespace, False)/Formatters.MyTestNamespace.MyMessagePackObjectFormatter.g.cs similarity index 100% rename from tests/MessagePack.Generator.Tests/Resources/EnumFormatter(Namespace, False)/Formatters.MyTestNamespace.MyMessagePackObjectFormatter.g.cs rename to tests/MessagePack.SourceGenerator.Tests/Resources/EnumFormatter(Namespace, False)/Formatters.MyTestNamespace.MyMessagePackObjectFormatter.g.cs diff --git a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(Namespace, False)/MessagePack.GeneratedMessagePackResolver.g.cs b/tests/MessagePack.SourceGenerator.Tests/Resources/EnumFormatter(Namespace, False)/MessagePack.GeneratedMessagePackResolver.g.cs similarity index 100% rename from tests/MessagePack.Generator.Tests/Resources/EnumFormatter(Namespace, False)/MessagePack.GeneratedMessagePackResolver.g.cs rename to tests/MessagePack.SourceGenerator.Tests/Resources/EnumFormatter(Namespace, False)/MessagePack.GeneratedMessagePackResolver.g.cs diff --git a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(Namespace, True)/Formatters.MyTestNamespace.MyEnumFormatter.g.cs b/tests/MessagePack.SourceGenerator.Tests/Resources/EnumFormatter(Namespace, True)/Formatters.MyTestNamespace.MyEnumFormatter.g.cs similarity index 100% rename from tests/MessagePack.Generator.Tests/Resources/EnumFormatter(Namespace, True)/Formatters.MyTestNamespace.MyEnumFormatter.g.cs rename to tests/MessagePack.SourceGenerator.Tests/Resources/EnumFormatter(Namespace, True)/Formatters.MyTestNamespace.MyEnumFormatter.g.cs diff --git a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(Namespace, True)/Formatters.MyTestNamespace.MyMessagePackObjectFormatter.g.cs b/tests/MessagePack.SourceGenerator.Tests/Resources/EnumFormatter(Namespace, True)/Formatters.MyTestNamespace.MyMessagePackObjectFormatter.g.cs similarity index 100% rename from tests/MessagePack.Generator.Tests/Resources/EnumFormatter(Namespace, True)/Formatters.MyTestNamespace.MyMessagePackObjectFormatter.g.cs rename to tests/MessagePack.SourceGenerator.Tests/Resources/EnumFormatter(Namespace, True)/Formatters.MyTestNamespace.MyMessagePackObjectFormatter.g.cs diff --git a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(Namespace, True)/MessagePack.GeneratedMessagePackResolver.g.cs b/tests/MessagePack.SourceGenerator.Tests/Resources/EnumFormatter(Namespace, True)/MessagePack.GeneratedMessagePackResolver.g.cs similarity index 100% rename from tests/MessagePack.Generator.Tests/Resources/EnumFormatter(Namespace, True)/MessagePack.GeneratedMessagePackResolver.g.cs rename to tests/MessagePack.SourceGenerator.Tests/Resources/EnumFormatter(Namespace, True)/MessagePack.GeneratedMessagePackResolver.g.cs diff --git a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(NestingClass, False)/Formatters.ContainingClass_MyEnumFormatter.g.cs b/tests/MessagePack.SourceGenerator.Tests/Resources/EnumFormatter(NestingClass, False)/Formatters.ContainingClass_MyEnumFormatter.g.cs similarity index 100% rename from tests/MessagePack.Generator.Tests/Resources/EnumFormatter(NestingClass, False)/Formatters.ContainingClass_MyEnumFormatter.g.cs rename to tests/MessagePack.SourceGenerator.Tests/Resources/EnumFormatter(NestingClass, False)/Formatters.ContainingClass_MyEnumFormatter.g.cs diff --git a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(NestingClass, False)/Formatters.ContainingClass_MyMessagePackObjectFormatter.g.cs b/tests/MessagePack.SourceGenerator.Tests/Resources/EnumFormatter(NestingClass, False)/Formatters.ContainingClass_MyMessagePackObjectFormatter.g.cs similarity index 100% rename from tests/MessagePack.Generator.Tests/Resources/EnumFormatter(NestingClass, False)/Formatters.ContainingClass_MyMessagePackObjectFormatter.g.cs rename to tests/MessagePack.SourceGenerator.Tests/Resources/EnumFormatter(NestingClass, False)/Formatters.ContainingClass_MyMessagePackObjectFormatter.g.cs diff --git a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(NestingClass, False)/MessagePack.GeneratedMessagePackResolver.g.cs b/tests/MessagePack.SourceGenerator.Tests/Resources/EnumFormatter(NestingClass, False)/MessagePack.GeneratedMessagePackResolver.g.cs similarity index 100% rename from tests/MessagePack.Generator.Tests/Resources/EnumFormatter(NestingClass, False)/MessagePack.GeneratedMessagePackResolver.g.cs rename to tests/MessagePack.SourceGenerator.Tests/Resources/EnumFormatter(NestingClass, False)/MessagePack.GeneratedMessagePackResolver.g.cs diff --git a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(NestingClass, True)/Formatters.ContainingClass_MyEnumFormatter.g.cs b/tests/MessagePack.SourceGenerator.Tests/Resources/EnumFormatter(NestingClass, True)/Formatters.ContainingClass_MyEnumFormatter.g.cs similarity index 100% rename from tests/MessagePack.Generator.Tests/Resources/EnumFormatter(NestingClass, True)/Formatters.ContainingClass_MyEnumFormatter.g.cs rename to tests/MessagePack.SourceGenerator.Tests/Resources/EnumFormatter(NestingClass, True)/Formatters.ContainingClass_MyEnumFormatter.g.cs diff --git a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(NestingClass, True)/Formatters.ContainingClass_MyMessagePackObjectFormatter.g.cs b/tests/MessagePack.SourceGenerator.Tests/Resources/EnumFormatter(NestingClass, True)/Formatters.ContainingClass_MyMessagePackObjectFormatter.g.cs similarity index 100% rename from tests/MessagePack.Generator.Tests/Resources/EnumFormatter(NestingClass, True)/Formatters.ContainingClass_MyMessagePackObjectFormatter.g.cs rename to tests/MessagePack.SourceGenerator.Tests/Resources/EnumFormatter(NestingClass, True)/Formatters.ContainingClass_MyMessagePackObjectFormatter.g.cs diff --git a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(NestingClass, True)/MessagePack.GeneratedMessagePackResolver.g.cs b/tests/MessagePack.SourceGenerator.Tests/Resources/EnumFormatter(NestingClass, True)/MessagePack.GeneratedMessagePackResolver.g.cs similarity index 100% rename from tests/MessagePack.Generator.Tests/Resources/EnumFormatter(NestingClass, True)/MessagePack.GeneratedMessagePackResolver.g.cs rename to tests/MessagePack.SourceGenerator.Tests/Resources/EnumFormatter(NestingClass, True)/MessagePack.GeneratedMessagePackResolver.g.cs diff --git a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(None, False)/Formatters.MyEnumFormatter.g.cs b/tests/MessagePack.SourceGenerator.Tests/Resources/EnumFormatter(None, False)/Formatters.MyEnumFormatter.g.cs similarity index 100% rename from tests/MessagePack.Generator.Tests/Resources/EnumFormatter(None, False)/Formatters.MyEnumFormatter.g.cs rename to tests/MessagePack.SourceGenerator.Tests/Resources/EnumFormatter(None, False)/Formatters.MyEnumFormatter.g.cs diff --git a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(None, False)/Formatters.MyMessagePackObjectFormatter.g.cs b/tests/MessagePack.SourceGenerator.Tests/Resources/EnumFormatter(None, False)/Formatters.MyMessagePackObjectFormatter.g.cs similarity index 100% rename from tests/MessagePack.Generator.Tests/Resources/EnumFormatter(None, False)/Formatters.MyMessagePackObjectFormatter.g.cs rename to tests/MessagePack.SourceGenerator.Tests/Resources/EnumFormatter(None, False)/Formatters.MyMessagePackObjectFormatter.g.cs diff --git a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(None, False)/MessagePack.GeneratedMessagePackResolver.g.cs b/tests/MessagePack.SourceGenerator.Tests/Resources/EnumFormatter(None, False)/MessagePack.GeneratedMessagePackResolver.g.cs similarity index 100% rename from tests/MessagePack.Generator.Tests/Resources/EnumFormatter(None, False)/MessagePack.GeneratedMessagePackResolver.g.cs rename to tests/MessagePack.SourceGenerator.Tests/Resources/EnumFormatter(None, False)/MessagePack.GeneratedMessagePackResolver.g.cs diff --git a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(None, True)/Formatters.MyEnumFormatter.g.cs b/tests/MessagePack.SourceGenerator.Tests/Resources/EnumFormatter(None, True)/Formatters.MyEnumFormatter.g.cs similarity index 100% rename from tests/MessagePack.Generator.Tests/Resources/EnumFormatter(None, True)/Formatters.MyEnumFormatter.g.cs rename to tests/MessagePack.SourceGenerator.Tests/Resources/EnumFormatter(None, True)/Formatters.MyEnumFormatter.g.cs diff --git a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(None, True)/Formatters.MyMessagePackObjectFormatter.g.cs b/tests/MessagePack.SourceGenerator.Tests/Resources/EnumFormatter(None, True)/Formatters.MyMessagePackObjectFormatter.g.cs similarity index 100% rename from tests/MessagePack.Generator.Tests/Resources/EnumFormatter(None, True)/Formatters.MyMessagePackObjectFormatter.g.cs rename to tests/MessagePack.SourceGenerator.Tests/Resources/EnumFormatter(None, True)/Formatters.MyMessagePackObjectFormatter.g.cs diff --git a/tests/MessagePack.Generator.Tests/Resources/EnumFormatter(None, True)/MessagePack.GeneratedMessagePackResolver.g.cs b/tests/MessagePack.SourceGenerator.Tests/Resources/EnumFormatter(None, True)/MessagePack.GeneratedMessagePackResolver.g.cs similarity index 100% rename from tests/MessagePack.Generator.Tests/Resources/EnumFormatter(None, True)/MessagePack.GeneratedMessagePackResolver.g.cs rename to tests/MessagePack.SourceGenerator.Tests/Resources/EnumFormatter(None, True)/MessagePack.GeneratedMessagePackResolver.g.cs diff --git a/tests/MessagePack.Generator.Tests/Resources/GenericType/Formatters.ContainerObjectFormatter.g.cs b/tests/MessagePack.SourceGenerator.Tests/Resources/GenericType/Formatters.ContainerObjectFormatter.g.cs similarity index 100% rename from tests/MessagePack.Generator.Tests/Resources/GenericType/Formatters.ContainerObjectFormatter.g.cs rename to tests/MessagePack.SourceGenerator.Tests/Resources/GenericType/Formatters.ContainerObjectFormatter.g.cs diff --git a/tests/MessagePack.Generator.Tests/Resources/GenericType/Formatters.MyGenericTypeFormatter_T_.g.cs b/tests/MessagePack.SourceGenerator.Tests/Resources/GenericType/Formatters.MyGenericTypeFormatter_T_.g.cs similarity index 100% rename from tests/MessagePack.Generator.Tests/Resources/GenericType/Formatters.MyGenericTypeFormatter_T_.g.cs rename to tests/MessagePack.SourceGenerator.Tests/Resources/GenericType/Formatters.MyGenericTypeFormatter_T_.g.cs diff --git a/tests/MessagePack.Generator.Tests/Resources/GenericType/MessagePack.GeneratedMessagePackResolver.g.cs b/tests/MessagePack.SourceGenerator.Tests/Resources/GenericType/MessagePack.GeneratedMessagePackResolver.g.cs similarity index 100% rename from tests/MessagePack.Generator.Tests/Resources/GenericType/MessagePack.GeneratedMessagePackResolver.g.cs rename to tests/MessagePack.SourceGenerator.Tests/Resources/GenericType/MessagePack.GeneratedMessagePackResolver.g.cs diff --git a/tests/MessagePack.Generator.Tests/Resources/MembersNeedAttributes/Formatters.FooFormatter.g.cs b/tests/MessagePack.SourceGenerator.Tests/Resources/MembersNeedAttributes/Formatters.FooFormatter.g.cs similarity index 100% rename from tests/MessagePack.Generator.Tests/Resources/MembersNeedAttributes/Formatters.FooFormatter.g.cs rename to tests/MessagePack.SourceGenerator.Tests/Resources/MembersNeedAttributes/Formatters.FooFormatter.g.cs diff --git a/tests/MessagePack.Generator.Tests/Resources/MembersNeedAttributes/MessagePack.GeneratedMessagePackResolver.g.cs b/tests/MessagePack.SourceGenerator.Tests/Resources/MembersNeedAttributes/MessagePack.GeneratedMessagePackResolver.g.cs similarity index 100% rename from tests/MessagePack.Generator.Tests/Resources/MembersNeedAttributes/MessagePack.GeneratedMessagePackResolver.g.cs rename to tests/MessagePack.SourceGenerator.Tests/Resources/MembersNeedAttributes/MessagePack.GeneratedMessagePackResolver.g.cs diff --git a/tests/MessagePack.Generator.Tests/Resources/NullStringKey/Formatters.FooFormatter.g.cs b/tests/MessagePack.SourceGenerator.Tests/Resources/NullStringKey/Formatters.FooFormatter.g.cs similarity index 100% rename from tests/MessagePack.Generator.Tests/Resources/NullStringKey/Formatters.FooFormatter.g.cs rename to tests/MessagePack.SourceGenerator.Tests/Resources/NullStringKey/Formatters.FooFormatter.g.cs diff --git a/tests/MessagePack.Generator.Tests/Resources/NullStringKey/MessagePack.GeneratedMessagePackResolver.g.cs b/tests/MessagePack.SourceGenerator.Tests/Resources/NullStringKey/MessagePack.GeneratedMessagePackResolver.g.cs similarity index 100% rename from tests/MessagePack.Generator.Tests/Resources/NullStringKey/MessagePack.GeneratedMessagePackResolver.g.cs rename to tests/MessagePack.SourceGenerator.Tests/Resources/NullStringKey/MessagePack.GeneratedMessagePackResolver.g.cs diff --git a/tests/MessagePack.Generator.Tests/Resources/TwoTypes(False)/Formatters.Object1Formatter.g.cs b/tests/MessagePack.SourceGenerator.Tests/Resources/TwoTypes(False)/Formatters.Object1Formatter.g.cs similarity index 100% rename from tests/MessagePack.Generator.Tests/Resources/TwoTypes(False)/Formatters.Object1Formatter.g.cs rename to tests/MessagePack.SourceGenerator.Tests/Resources/TwoTypes(False)/Formatters.Object1Formatter.g.cs diff --git a/tests/MessagePack.Generator.Tests/Resources/TwoTypes(False)/Formatters.Object2Formatter.g.cs b/tests/MessagePack.SourceGenerator.Tests/Resources/TwoTypes(False)/Formatters.Object2Formatter.g.cs similarity index 100% rename from tests/MessagePack.Generator.Tests/Resources/TwoTypes(False)/Formatters.Object2Formatter.g.cs rename to tests/MessagePack.SourceGenerator.Tests/Resources/TwoTypes(False)/Formatters.Object2Formatter.g.cs diff --git a/tests/MessagePack.Generator.Tests/Resources/TwoTypes(False)/MessagePack.GeneratedMessagePackResolver.g.cs b/tests/MessagePack.SourceGenerator.Tests/Resources/TwoTypes(False)/MessagePack.GeneratedMessagePackResolver.g.cs similarity index 100% rename from tests/MessagePack.Generator.Tests/Resources/TwoTypes(False)/MessagePack.GeneratedMessagePackResolver.g.cs rename to tests/MessagePack.SourceGenerator.Tests/Resources/TwoTypes(False)/MessagePack.GeneratedMessagePackResolver.g.cs diff --git a/tests/MessagePack.Generator.Tests/Resources/TwoTypes(True)/Formatters.Object1Formatter.g.cs b/tests/MessagePack.SourceGenerator.Tests/Resources/TwoTypes(True)/Formatters.Object1Formatter.g.cs similarity index 100% rename from tests/MessagePack.Generator.Tests/Resources/TwoTypes(True)/Formatters.Object1Formatter.g.cs rename to tests/MessagePack.SourceGenerator.Tests/Resources/TwoTypes(True)/Formatters.Object1Formatter.g.cs diff --git a/tests/MessagePack.Generator.Tests/Resources/TwoTypes(True)/Formatters.Object2Formatter.g.cs b/tests/MessagePack.SourceGenerator.Tests/Resources/TwoTypes(True)/Formatters.Object2Formatter.g.cs similarity index 100% rename from tests/MessagePack.Generator.Tests/Resources/TwoTypes(True)/Formatters.Object2Formatter.g.cs rename to tests/MessagePack.SourceGenerator.Tests/Resources/TwoTypes(True)/Formatters.Object2Formatter.g.cs diff --git a/tests/MessagePack.Generator.Tests/Resources/TwoTypes(True)/MessagePack.GeneratedMessagePackResolver.g.cs b/tests/MessagePack.SourceGenerator.Tests/Resources/TwoTypes(True)/MessagePack.GeneratedMessagePackResolver.g.cs similarity index 100% rename from tests/MessagePack.Generator.Tests/Resources/TwoTypes(True)/MessagePack.GeneratedMessagePackResolver.g.cs rename to tests/MessagePack.SourceGenerator.Tests/Resources/TwoTypes(True)/MessagePack.GeneratedMessagePackResolver.g.cs diff --git a/tests/MessagePack.Generator.Tests/Resources/UnionFormatter(Namespace)/Formatters.MyTestNamespace.Derived1Formatter.g.cs b/tests/MessagePack.SourceGenerator.Tests/Resources/UnionFormatter(Namespace)/Formatters.MyTestNamespace.Derived1Formatter.g.cs similarity index 100% rename from tests/MessagePack.Generator.Tests/Resources/UnionFormatter(Namespace)/Formatters.MyTestNamespace.Derived1Formatter.g.cs rename to tests/MessagePack.SourceGenerator.Tests/Resources/UnionFormatter(Namespace)/Formatters.MyTestNamespace.Derived1Formatter.g.cs diff --git a/tests/MessagePack.Generator.Tests/Resources/UnionFormatter(Namespace)/Formatters.MyTestNamespace.Derived2Formatter.g.cs b/tests/MessagePack.SourceGenerator.Tests/Resources/UnionFormatter(Namespace)/Formatters.MyTestNamespace.Derived2Formatter.g.cs similarity index 100% rename from tests/MessagePack.Generator.Tests/Resources/UnionFormatter(Namespace)/Formatters.MyTestNamespace.Derived2Formatter.g.cs rename to tests/MessagePack.SourceGenerator.Tests/Resources/UnionFormatter(Namespace)/Formatters.MyTestNamespace.Derived2Formatter.g.cs diff --git a/tests/MessagePack.Generator.Tests/Resources/UnionFormatter(Namespace)/Formatters.MyTestNamespace.IMyTypeFormatter.g.cs b/tests/MessagePack.SourceGenerator.Tests/Resources/UnionFormatter(Namespace)/Formatters.MyTestNamespace.IMyTypeFormatter.g.cs similarity index 100% rename from tests/MessagePack.Generator.Tests/Resources/UnionFormatter(Namespace)/Formatters.MyTestNamespace.IMyTypeFormatter.g.cs rename to tests/MessagePack.SourceGenerator.Tests/Resources/UnionFormatter(Namespace)/Formatters.MyTestNamespace.IMyTypeFormatter.g.cs diff --git a/tests/MessagePack.Generator.Tests/Resources/UnionFormatter(Namespace)/Formatters.MyTestNamespace.MyMessagePackObjectFormatter.g.cs b/tests/MessagePack.SourceGenerator.Tests/Resources/UnionFormatter(Namespace)/Formatters.MyTestNamespace.MyMessagePackObjectFormatter.g.cs similarity index 100% rename from tests/MessagePack.Generator.Tests/Resources/UnionFormatter(Namespace)/Formatters.MyTestNamespace.MyMessagePackObjectFormatter.g.cs rename to tests/MessagePack.SourceGenerator.Tests/Resources/UnionFormatter(Namespace)/Formatters.MyTestNamespace.MyMessagePackObjectFormatter.g.cs diff --git a/tests/MessagePack.Generator.Tests/Resources/UnionFormatter(Namespace)/MessagePack.GeneratedMessagePackResolver.g.cs b/tests/MessagePack.SourceGenerator.Tests/Resources/UnionFormatter(Namespace)/MessagePack.GeneratedMessagePackResolver.g.cs similarity index 100% rename from tests/MessagePack.Generator.Tests/Resources/UnionFormatter(Namespace)/MessagePack.GeneratedMessagePackResolver.g.cs rename to tests/MessagePack.SourceGenerator.Tests/Resources/UnionFormatter(Namespace)/MessagePack.GeneratedMessagePackResolver.g.cs diff --git a/tests/MessagePack.Generator.Tests/Resources/UnionFormatter(NestingClass)/Formatters.ContainingClass_Derived1Formatter.g.cs b/tests/MessagePack.SourceGenerator.Tests/Resources/UnionFormatter(NestingClass)/Formatters.ContainingClass_Derived1Formatter.g.cs similarity index 100% rename from tests/MessagePack.Generator.Tests/Resources/UnionFormatter(NestingClass)/Formatters.ContainingClass_Derived1Formatter.g.cs rename to tests/MessagePack.SourceGenerator.Tests/Resources/UnionFormatter(NestingClass)/Formatters.ContainingClass_Derived1Formatter.g.cs diff --git a/tests/MessagePack.Generator.Tests/Resources/UnionFormatter(NestingClass)/Formatters.ContainingClass_Derived2Formatter.g.cs b/tests/MessagePack.SourceGenerator.Tests/Resources/UnionFormatter(NestingClass)/Formatters.ContainingClass_Derived2Formatter.g.cs similarity index 100% rename from tests/MessagePack.Generator.Tests/Resources/UnionFormatter(NestingClass)/Formatters.ContainingClass_Derived2Formatter.g.cs rename to tests/MessagePack.SourceGenerator.Tests/Resources/UnionFormatter(NestingClass)/Formatters.ContainingClass_Derived2Formatter.g.cs diff --git a/tests/MessagePack.Generator.Tests/Resources/UnionFormatter(NestingClass)/Formatters.ContainingClass_MyMessagePackObjectFormatter.g.cs b/tests/MessagePack.SourceGenerator.Tests/Resources/UnionFormatter(NestingClass)/Formatters.ContainingClass_MyMessagePackObjectFormatter.g.cs similarity index 100% rename from tests/MessagePack.Generator.Tests/Resources/UnionFormatter(NestingClass)/Formatters.ContainingClass_MyMessagePackObjectFormatter.g.cs rename to tests/MessagePack.SourceGenerator.Tests/Resources/UnionFormatter(NestingClass)/Formatters.ContainingClass_MyMessagePackObjectFormatter.g.cs diff --git a/tests/MessagePack.Generator.Tests/Resources/UnionFormatter(NestingClass)/Formatters.IMyTypeFormatter.g.cs b/tests/MessagePack.SourceGenerator.Tests/Resources/UnionFormatter(NestingClass)/Formatters.IMyTypeFormatter.g.cs similarity index 100% rename from tests/MessagePack.Generator.Tests/Resources/UnionFormatter(NestingClass)/Formatters.IMyTypeFormatter.g.cs rename to tests/MessagePack.SourceGenerator.Tests/Resources/UnionFormatter(NestingClass)/Formatters.IMyTypeFormatter.g.cs diff --git a/tests/MessagePack.Generator.Tests/Resources/UnionFormatter(NestingClass)/MessagePack.GeneratedMessagePackResolver.g.cs b/tests/MessagePack.SourceGenerator.Tests/Resources/UnionFormatter(NestingClass)/MessagePack.GeneratedMessagePackResolver.g.cs similarity index 100% rename from tests/MessagePack.Generator.Tests/Resources/UnionFormatter(NestingClass)/MessagePack.GeneratedMessagePackResolver.g.cs rename to tests/MessagePack.SourceGenerator.Tests/Resources/UnionFormatter(NestingClass)/MessagePack.GeneratedMessagePackResolver.g.cs diff --git a/tests/MessagePack.Generator.Tests/Resources/UnionFormatter(None)/Formatters.Derived1Formatter.g.cs b/tests/MessagePack.SourceGenerator.Tests/Resources/UnionFormatter(None)/Formatters.Derived1Formatter.g.cs similarity index 100% rename from tests/MessagePack.Generator.Tests/Resources/UnionFormatter(None)/Formatters.Derived1Formatter.g.cs rename to tests/MessagePack.SourceGenerator.Tests/Resources/UnionFormatter(None)/Formatters.Derived1Formatter.g.cs diff --git a/tests/MessagePack.Generator.Tests/Resources/UnionFormatter(None)/Formatters.Derived2Formatter.g.cs b/tests/MessagePack.SourceGenerator.Tests/Resources/UnionFormatter(None)/Formatters.Derived2Formatter.g.cs similarity index 100% rename from tests/MessagePack.Generator.Tests/Resources/UnionFormatter(None)/Formatters.Derived2Formatter.g.cs rename to tests/MessagePack.SourceGenerator.Tests/Resources/UnionFormatter(None)/Formatters.Derived2Formatter.g.cs diff --git a/tests/MessagePack.Generator.Tests/Resources/UnionFormatter(None)/Formatters.IMyTypeFormatter.g.cs b/tests/MessagePack.SourceGenerator.Tests/Resources/UnionFormatter(None)/Formatters.IMyTypeFormatter.g.cs similarity index 100% rename from tests/MessagePack.Generator.Tests/Resources/UnionFormatter(None)/Formatters.IMyTypeFormatter.g.cs rename to tests/MessagePack.SourceGenerator.Tests/Resources/UnionFormatter(None)/Formatters.IMyTypeFormatter.g.cs diff --git a/tests/MessagePack.Generator.Tests/Resources/UnionFormatter(None)/Formatters.MyMessagePackObjectFormatter.g.cs b/tests/MessagePack.SourceGenerator.Tests/Resources/UnionFormatter(None)/Formatters.MyMessagePackObjectFormatter.g.cs similarity index 100% rename from tests/MessagePack.Generator.Tests/Resources/UnionFormatter(None)/Formatters.MyMessagePackObjectFormatter.g.cs rename to tests/MessagePack.SourceGenerator.Tests/Resources/UnionFormatter(None)/Formatters.MyMessagePackObjectFormatter.g.cs diff --git a/tests/MessagePack.Generator.Tests/Resources/UnionFormatter(None)/MessagePack.GeneratedMessagePackResolver.g.cs b/tests/MessagePack.SourceGenerator.Tests/Resources/UnionFormatter(None)/MessagePack.GeneratedMessagePackResolver.g.cs similarity index 100% rename from tests/MessagePack.Generator.Tests/Resources/UnionFormatter(None)/MessagePack.GeneratedMessagePackResolver.g.cs rename to tests/MessagePack.SourceGenerator.Tests/Resources/UnionFormatter(None)/MessagePack.GeneratedMessagePackResolver.g.cs diff --git a/tests/MessagePack.Generator.Tests/TestUtilities.cs b/tests/MessagePack.SourceGenerator.Tests/TestUtilities.cs similarity index 95% rename from tests/MessagePack.Generator.Tests/TestUtilities.cs rename to tests/MessagePack.SourceGenerator.Tests/TestUtilities.cs index cdef00023..31ef1344d 100644 --- a/tests/MessagePack.Generator.Tests/TestUtilities.cs +++ b/tests/MessagePack.SourceGenerator.Tests/TestUtilities.cs @@ -3,7 +3,7 @@ using System.Text; -namespace MessagePack.Generator.Tests; +namespace MessagePack.SourceGenerator.Tests; internal static class TestUtilities { diff --git a/tests/MessagePack.Generator.Tests/Usings.cs b/tests/MessagePack.SourceGenerator.Tests/Usings.cs similarity index 77% rename from tests/MessagePack.Generator.Tests/Usings.cs rename to tests/MessagePack.SourceGenerator.Tests/Usings.cs index 3883a2635..bdbb23d64 100644 --- a/tests/MessagePack.Generator.Tests/Usings.cs +++ b/tests/MessagePack.SourceGenerator.Tests/Usings.cs @@ -2,7 +2,7 @@ // Licensed under the MIT license. See LICENSE file in the project root for full license information. global using System.Collections.Immutable; -global using MessagePack.Generator.CodeAnalysis; +global using MessagePack.SourceGenerator.CodeAnalysis; global using Xunit; global using Xunit.Abstractions; -global using VerifyCS = CSharpSourceGeneratorVerifier; +global using VerifyCS = CSharpSourceGeneratorVerifier; diff --git a/tests/MessagePack.Generator.Tests/Verifiers/CSharpSourceGeneratorVerifier`1+Test.cs b/tests/MessagePack.SourceGenerator.Tests/Verifiers/CSharpSourceGeneratorVerifier`1+Test.cs similarity index 99% rename from tests/MessagePack.Generator.Tests/Verifiers/CSharpSourceGeneratorVerifier`1+Test.cs rename to tests/MessagePack.SourceGenerator.Tests/Verifiers/CSharpSourceGeneratorVerifier`1+Test.cs index dd0dcf6b5..774a8fb2c 100644 --- a/tests/MessagePack.Generator.Tests/Verifiers/CSharpSourceGeneratorVerifier`1+Test.cs +++ b/tests/MessagePack.SourceGenerator.Tests/Verifiers/CSharpSourceGeneratorVerifier`1+Test.cs @@ -13,7 +13,7 @@ using System.Runtime.CompilerServices; using System.Text; using MessagePack; -using MessagePack.Generator; +using MessagePack.SourceGenerator; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp.Testing; diff --git a/tests/MessagePack.Generator.Tests/Verifiers/ReferenceHelper.cs b/tests/MessagePack.SourceGenerator.Tests/Verifiers/ReferenceHelper.cs similarity index 100% rename from tests/MessagePack.Generator.Tests/Verifiers/ReferenceHelper.cs rename to tests/MessagePack.SourceGenerator.Tests/Verifiers/ReferenceHelper.cs diff --git a/tests/MessagePack.Generator.Unity.Tests/MessagePack.Generator.Unity.Tests.csproj b/tests/MessagePack.SourceGenerator.Unity.Tests/MessagePack.SourceGenerator.Unity.Tests.csproj similarity index 92% rename from tests/MessagePack.Generator.Unity.Tests/MessagePack.Generator.Unity.Tests.csproj rename to tests/MessagePack.SourceGenerator.Unity.Tests/MessagePack.SourceGenerator.Unity.Tests.csproj index 5d1b1df28..249b240ca 100644 --- a/tests/MessagePack.Generator.Unity.Tests/MessagePack.Generator.Unity.Tests.csproj +++ b/tests/MessagePack.SourceGenerator.Unity.Tests/MessagePack.SourceGenerator.Unity.Tests.csproj @@ -32,7 +32,7 @@ - + diff --git a/tests/SourceGeneratorConsumer.props b/tests/SourceGeneratorConsumer.props index bfd9551bf..8c966be87 100644 --- a/tests/SourceGeneratorConsumer.props +++ b/tests/SourceGeneratorConsumer.props @@ -1,8 +1,8 @@ - + - + Analyzer false diff --git a/tests/SourceGeneratorConsumer.targets b/tests/SourceGeneratorConsumer.targets index 655ac3cba..509b7ae23 100644 --- a/tests/SourceGeneratorConsumer.targets +++ b/tests/SourceGeneratorConsumer.targets @@ -1,3 +1,3 @@ - + From e681197b839e919855bcef907c38df121a9af17c Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Mon, 10 Apr 2023 08:57:14 -0600 Subject: [PATCH 088/660] Fix build break when `bin\packages\debug` doesn't exist yet --- .../MessagePack.SourceGenerator.Unity.csproj | 1 + 1 file changed, 1 insertion(+) diff --git a/src/MessagePack.SourceGenerator.Unity/MessagePack.SourceGenerator.Unity.csproj b/src/MessagePack.SourceGenerator.Unity/MessagePack.SourceGenerator.Unity.csproj index 1021e6f92..a8fb6ce61 100644 --- a/src/MessagePack.SourceGenerator.Unity/MessagePack.SourceGenerator.Unity.csproj +++ b/src/MessagePack.SourceGenerator.Unity/MessagePack.SourceGenerator.Unity.csproj @@ -34,6 +34,7 @@ $(IntermediateOutputPath)zip + Date: Tue, 11 Apr 2023 17:41:25 -0600 Subject: [PATCH 089/660] Refactor interactions between source generator and analyzer * Consolidate `TypeCollector` across analyzer and source generator. * Use `System.Text.Json` instead of `TinyJsonReader`. * Remove all diagnostic reporting from the source generator. * Make the source generator depend on the analyzer, so that user gets diagnostics while using source generator by way of the analyzer. --- Directory.Packages.props | 8 +- .../MessagePack.SourceGenerator.Unity.csproj | 18 +- .../MessagePackGenerator.cs | 13 +- .../AnalyzerReleases.Shipped.md | 3 - .../AnalyzerReleases.Unshipped.md | 10 - .../MessagePack.SourceGenerator.csproj | 25 +- .../MessagePack.SourceGenerator.targets | 14 + .../MessagePackGenerator.Emit.cs | 2 +- .../MessagePackGenerator.cs | 14 +- .../Transforms/FormatterTemplate.cs | 89 +-- .../Transforms/FormatterTemplate.tt | 1 + .../Transforms/IFormatterTemplate.cs | 2 +- .../StringKeyFormatterDeserializeHelper.cs | 2 +- .../StringKey/StringKeyFormatterTemplate.cs | 91 +-- .../StringKey/StringKeyFormatterTemplate.tt | 3 +- .../Transforms/TemplatePartials.cs | 2 +- .../Utils/RoslynExtensions.cs | 36 - src/MessagePackAnalyzer/AnalyzerUtilities.cs | 10 - .../CodeAnalysis/AnalyzerOptions.cs | 46 +- .../CodeAnalysis/CodeAnalysisUtilities.cs | 10 +- .../CodeAnalysis/EnumSerializationInfo.cs | 2 +- .../CodeAnalysis/FullModel.cs | 2 +- .../CodeAnalysis/GenericSerializationInfo.cs | 2 +- .../CodeAnalysis/GenericTypeParameterInfo.cs | 2 +- .../CodeAnalysis/IResolverRegisterInfo.cs | 2 +- .../CodeAnalysis/MemberSerializationInfo.cs | 4 +- .../CodeAnalysis/ObjectSerializationInfo.cs | 2 +- .../CodeAnalysis/ReferenceSymbols.cs | 86 +++ .../ResolverRegisterInfoComparer.cs | 2 +- .../CodeAnalysis/TypeCollector.cs | 278 ++++---- .../CodeAnalysis/UnionSerializationInfo.cs | 3 +- .../CodeAnalysis/UnionSubTypeInfo.cs | 2 +- .../MessagePackAnalyzer.cs | 109 --- .../MessagePackAnalyzer.csproj | 5 + .../MessagePackCodeFixProvider.cs | 33 +- .../MsgPack00xMessagePackAnalyzer.cs | 125 ++++ src/MessagePackAnalyzer/ReferenceSymbols.cs | 96 --- .../ShouldUseFormatterResolverHelper.cs | 4 +- src/MessagePackAnalyzer/TypeCollector.cs | 419 ----------- src/MessagePackAnalyzer/Usings.cs | 4 + .../Utils/AnalyzerUtilities.cs | 9 + .../Utils/ConfigurationLoader.cs | 51 -- .../Utils/DiagnosticsReportContext.cs | 44 -- .../Utils/RoslynAnalyzerExtensions.cs | 165 ++--- .../Utils/TinyJsonReader.cs | 669 ------------------ src/SourceGenerator.props | 13 +- .../GenerationTests.cs | 51 +- .../MessagePack.SourceGenerator.Tests.csproj | 1 + ...matters.GenericClassFormatter_T1, T2_.g.cs | 58 ++ ...sagePack.GeneratedMessagePackResolver.g.cs | 68 ++ .../Usings.cs | 2 +- ...agePack.SourceGenerator.Unity.Tests.csproj | 13 +- .../MessagePackAnalyzerTests.cs | 10 +- tests/SourceGeneratorConsumer.props | 12 + 54 files changed, 851 insertions(+), 1896 deletions(-) delete mode 100644 src/MessagePack.SourceGenerator/AnalyzerReleases.Shipped.md delete mode 100644 src/MessagePack.SourceGenerator/AnalyzerReleases.Unshipped.md create mode 100644 src/MessagePack.SourceGenerator/MessagePack.SourceGenerator.targets delete mode 100644 src/MessagePack.SourceGenerator/Utils/RoslynExtensions.cs delete mode 100644 src/MessagePackAnalyzer/AnalyzerUtilities.cs rename src/{MessagePack.SourceGenerator => MessagePackAnalyzer}/CodeAnalysis/AnalyzerOptions.cs (55%) rename src/{MessagePack.SourceGenerator => MessagePackAnalyzer}/CodeAnalysis/CodeAnalysisUtilities.cs (74%) rename src/{MessagePack.SourceGenerator => MessagePackAnalyzer}/CodeAnalysis/EnumSerializationInfo.cs (95%) rename src/{MessagePack.SourceGenerator => MessagePackAnalyzer}/CodeAnalysis/FullModel.cs (98%) rename src/{MessagePack.SourceGenerator => MessagePackAnalyzer}/CodeAnalysis/GenericSerializationInfo.cs (92%) rename src/{MessagePack.SourceGenerator => MessagePackAnalyzer}/CodeAnalysis/GenericTypeParameterInfo.cs (85%) rename src/{MessagePack.SourceGenerator => MessagePackAnalyzer}/CodeAnalysis/IResolverRegisterInfo.cs (87%) rename src/{MessagePack.SourceGenerator => MessagePackAnalyzer}/CodeAnalysis/MemberSerializationInfo.cs (95%) rename src/{MessagePack.SourceGenerator => MessagePackAnalyzer}/CodeAnalysis/ObjectSerializationInfo.cs (98%) create mode 100644 src/MessagePackAnalyzer/CodeAnalysis/ReferenceSymbols.cs rename src/{MessagePack.SourceGenerator => MessagePackAnalyzer}/CodeAnalysis/ResolverRegisterInfoComparer.cs (90%) rename src/{MessagePack.SourceGenerator => MessagePackAnalyzer}/CodeAnalysis/TypeCollector.cs (85%) rename src/{MessagePack.SourceGenerator => MessagePackAnalyzer}/CodeAnalysis/UnionSerializationInfo.cs (94%) rename src/{MessagePack.SourceGenerator => MessagePackAnalyzer}/CodeAnalysis/UnionSubTypeInfo.cs (80%) delete mode 100644 src/MessagePackAnalyzer/MessagePackAnalyzer.cs create mode 100644 src/MessagePackAnalyzer/MsgPack00xMessagePackAnalyzer.cs delete mode 100644 src/MessagePackAnalyzer/ReferenceSymbols.cs rename src/{MessagePack.SourceGenerator => MessagePackAnalyzer}/Transforms/ShouldUseFormatterResolverHelper.cs (93%) delete mode 100644 src/MessagePackAnalyzer/TypeCollector.cs create mode 100644 src/MessagePackAnalyzer/Usings.cs create mode 100644 src/MessagePackAnalyzer/Utils/AnalyzerUtilities.cs delete mode 100644 src/MessagePackAnalyzer/Utils/ConfigurationLoader.cs delete mode 100644 src/MessagePackAnalyzer/Utils/DiagnosticsReportContext.cs delete mode 100644 src/MessagePackAnalyzer/Utils/TinyJsonReader.cs create mode 100644 tests/MessagePack.SourceGenerator.Tests/Resources/GenericTypeArg/Formatters.GenericClassFormatter_T1, T2_.g.cs create mode 100644 tests/MessagePack.SourceGenerator.Tests/Resources/GenericTypeArg/MessagePack.GeneratedMessagePackResolver.g.cs diff --git a/Directory.Packages.props b/Directory.Packages.props index 899ba7667..912b501f4 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -10,6 +10,9 @@ 4.3.0 4.3.0 1.1.2-beta1.23163.2 + + + 3.8.0 @@ -59,7 +62,7 @@ - + @@ -70,9 +73,10 @@ - + + diff --git a/src/MessagePack.SourceGenerator.Unity/MessagePack.SourceGenerator.Unity.csproj b/src/MessagePack.SourceGenerator.Unity/MessagePack.SourceGenerator.Unity.csproj index a8fb6ce61..a5b6894d6 100644 --- a/src/MessagePack.SourceGenerator.Unity/MessagePack.SourceGenerator.Unity.csproj +++ b/src/MessagePack.SourceGenerator.Unity/MessagePack.SourceGenerator.Unity.csproj @@ -1,19 +1,16 @@  - + $(DefineConstants);UNITY false - - - 3.8.0 + $(CodeAnalysisVersionForUnity) - @@ -21,23 +18,16 @@ - - - - - + $(IntermediateOutputPath)zip - + diff --git a/src/MessagePack.SourceGenerator.Unity/MessagePackGenerator.cs b/src/MessagePack.SourceGenerator.Unity/MessagePackGenerator.cs index 9d63b2df0..7a2ac60f8 100644 --- a/src/MessagePack.SourceGenerator.Unity/MessagePackGenerator.cs +++ b/src/MessagePack.SourceGenerator.Unity/MessagePackGenerator.cs @@ -2,7 +2,7 @@ // Licensed under the MIT license. See LICENSE file in the project root for full license information. using System.Collections.Immutable; -using MessagePack.SourceGenerator.CodeAnalysis; +using MessagePackAnalyzer.CodeAnalysis; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp.Syntax; @@ -26,19 +26,24 @@ public void Execute(GeneratorExecutionContext context) } Compilation compilation = context.Compilation; - GeneratorContext generateContext = new(context); - AnalyzerOptions options = AnalyzerOptions.Parse(context.AnalyzerConfigOptions.GlobalOptions); + if (!ReferenceSymbols.TryCreate(compilation, out ReferenceSymbols? referenceSymbols)) + { + return; + } + + AnalyzerOptions options = AnalyzerOptions.Parse(context.AnalyzerConfigOptions.GlobalOptions, context.AdditionalFiles); List modelPerType = new(); foreach (var syntax in receiver.ClassDeclarations) { - if (TypeCollector.Collect(compilation, options, syntax, generateContext, context.CancellationToken) is FullModel model) + if (TypeCollector.Collect(compilation, options, referenceSymbols, null, syntax, context.CancellationToken) is FullModel model) { modelPerType.Add(model); } } FullModel fullModel = FullModel.Combine(modelPerType.ToImmutableArray()); + GeneratorContext generateContext = new(context); Generate(generateContext, fullModel); GenerateResolver(generateContext, fullModel); } diff --git a/src/MessagePack.SourceGenerator/AnalyzerReleases.Shipped.md b/src/MessagePack.SourceGenerator/AnalyzerReleases.Shipped.md deleted file mode 100644 index 60b59dd99..000000000 --- a/src/MessagePack.SourceGenerator/AnalyzerReleases.Shipped.md +++ /dev/null @@ -1,3 +0,0 @@ -; Shipped analyzer releases -; https://github.com/dotnet/roslyn-analyzers/blob/main/src/Microsoft.CodeAnalysis.Analyzers/ReleaseTrackingAnalyzers.Help.md - diff --git a/src/MessagePack.SourceGenerator/AnalyzerReleases.Unshipped.md b/src/MessagePack.SourceGenerator/AnalyzerReleases.Unshipped.md deleted file mode 100644 index 35209f679..000000000 --- a/src/MessagePack.SourceGenerator/AnalyzerReleases.Unshipped.md +++ /dev/null @@ -1,10 +0,0 @@ -; Unshipped analyzer release -; https://github.com/dotnet/roslyn-analyzers/blob/main/src/Microsoft.CodeAnalysis.Analyzers/ReleaseTrackingAnalyzers.Help.md - -### New Rules - -Rule ID | Category | Severity | Notes ---------|----------|----------|------- -MsgPack003 | Usage | Error | Source generator -MsgPack004 | Usage | Error | Source generator -MsgPack005 | Usage | Error | Source generator \ No newline at end of file diff --git a/src/MessagePack.SourceGenerator/MessagePack.SourceGenerator.csproj b/src/MessagePack.SourceGenerator/MessagePack.SourceGenerator.csproj index a2d2c7050..d22589512 100644 --- a/src/MessagePack.SourceGenerator/MessagePack.SourceGenerator.csproj +++ b/src/MessagePack.SourceGenerator/MessagePack.SourceGenerator.csproj @@ -1,6 +1,6 @@  - + @@ -9,8 +9,8 @@ embedded false true - true $(TargetsForTfmSpecificContentInPackage);PackBuildOutputs + $(NoWarn);NU5128 MessagePack Source Generator A roslyn source generator for AOT or faster startup of applications that use the MessagePack nuget package. @@ -24,16 +24,6 @@ - - - - - - - - - - @@ -86,7 +76,7 @@ StringKeyFormatterTemplate.cs TextTemplatingFilePreprocessor - MessagePack.Generator.Transforms + MessagePack.SourceGenerator.Transforms UnionTemplate.cs @@ -98,12 +88,5 @@ - - - - - - - - + diff --git a/src/MessagePack.SourceGenerator/MessagePack.SourceGenerator.targets b/src/MessagePack.SourceGenerator/MessagePack.SourceGenerator.targets new file mode 100644 index 000000000..b621a73cd --- /dev/null +++ b/src/MessagePack.SourceGenerator/MessagePack.SourceGenerator.targets @@ -0,0 +1,14 @@ + + + + + + + + + + diff --git a/src/MessagePack.SourceGenerator/MessagePackGenerator.Emit.cs b/src/MessagePack.SourceGenerator/MessagePackGenerator.Emit.cs index 9ec90a3d0..29ad5236b 100644 --- a/src/MessagePack.SourceGenerator/MessagePackGenerator.Emit.cs +++ b/src/MessagePack.SourceGenerator/MessagePackGenerator.Emit.cs @@ -2,8 +2,8 @@ // Licensed under the MIT license. See LICENSE file in the project root for full license information. using System.Text; -using MessagePack.SourceGenerator.CodeAnalysis; using MessagePack.SourceGenerator.Transforms; +using MessagePackAnalyzer.CodeAnalysis; using Microsoft.CodeAnalysis; namespace MessagePack.SourceGenerator; diff --git a/src/MessagePack.SourceGenerator/MessagePackGenerator.cs b/src/MessagePack.SourceGenerator/MessagePackGenerator.cs index 38c6820ae..bc01c19b2 100644 --- a/src/MessagePack.SourceGenerator/MessagePackGenerator.cs +++ b/src/MessagePack.SourceGenerator/MessagePackGenerator.cs @@ -2,9 +2,11 @@ // Licensed under the MIT license. See LICENSE file in the project root for full license information. using System.Collections.Immutable; -using MessagePack.SourceGenerator.CodeAnalysis; +using MessagePackAnalyzer.CodeAnalysis; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp.Syntax; +using Microsoft.CodeAnalysis.Diagnostics; +using AnalyzerOptions = MessagePackAnalyzer.CodeAnalysis.AnalyzerOptions; namespace MessagePack.SourceGenerator; @@ -16,7 +18,8 @@ public partial class MessagePackGenerator : IIncrementalGenerator public void Initialize(IncrementalGeneratorInitializationContext context) { - IncrementalValueProvider options = context.AnalyzerConfigOptionsProvider.Select((provider, ct) => AnalyzerOptions.Parse(provider.GlobalOptions)); + var options = context.AdditionalTextsProvider.Collect().Combine(context.AnalyzerConfigOptionsProvider).Select( + ((ImmutableArray AdditionalFiles, AnalyzerConfigOptionsProvider Options) t, CancellationToken ct) => AnalyzerOptions.Parse(t.Options.GlobalOptions, t.AdditionalFiles)); var messagePackObjectTypes = context.SyntaxProvider.ForAttributeWithMetadataName( MessagePackObjectAttributeFullName, @@ -36,10 +39,15 @@ public void Initialize(IncrementalGeneratorInitializationContext context) .Combine(options) .Select(static (s, ct) => { + if (!ReferenceSymbols.TryCreate(s.Left.Right, out ReferenceSymbols? referenceSymbols)) + { + return null; + } + List modelPerType = new(); void Collect(TypeDeclarationSyntax typeDecl) { - if (TypeCollector.Collect(s.Left.Right, s.Right, typeDecl, null, ct) is FullModel model) + if (TypeCollector.Collect(s.Left.Right, s.Right, referenceSymbols, reportDiagnostic: null, typeDecl, ct) is FullModel model) { modelPerType.Add(model); } diff --git a/src/MessagePack.SourceGenerator/Transforms/FormatterTemplate.cs b/src/MessagePack.SourceGenerator/Transforms/FormatterTemplate.cs index f23b57956..659232f88 100644 --- a/src/MessagePack.SourceGenerator/Transforms/FormatterTemplate.cs +++ b/src/MessagePack.SourceGenerator/Transforms/FormatterTemplate.cs @@ -2,7 +2,7 @@ // // This code was generated by a tool. // Runtime Version: 17.0.0.0 -// +// // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. // @@ -12,8 +12,9 @@ namespace MessagePack.SourceGenerator.Transforms using System.Linq; using System.Text; using System.Collections.Generic; + using MessagePackAnalyzer.Transforms; using System; - + /// /// Class to produce the template output /// @@ -34,16 +35,16 @@ public virtual string TransformText() this.Write(" : MsgPack::Formatters.IMessagePackFormatter<"); this.Write(this.ToStringHelper.ToStringWithCulture(Info.FullName)); this.Write(">\r\n"); - foreach (var typeArg in Info.GenericTypeParameters.Where(x => x.HasConstraints)) { + foreach (var typeArg in Info.GenericTypeParameters.Where(x => x.HasConstraints)) { this.Write("\t\twhere "); this.Write(this.ToStringHelper.ToStringWithCulture(typeArg.Name)); this.Write(" : "); this.Write(this.ToStringHelper.ToStringWithCulture(typeArg.Constraints)); this.Write("\r\n"); - } + } this.Write("\t{\r\n"); - foreach (var item in Info.Members) { - if (item.CustomFormatterTypeName != null) { + foreach (var item in Info.Members) { + if (item.CustomFormatterTypeName != null) { this.Write("\t\tprivate readonly "); this.Write(this.ToStringHelper.ToStringWithCulture(item.CustomFormatterTypeName)); this.Write(" __"); @@ -51,104 +52,104 @@ public virtual string TransformText() this.Write("CustomFormatter__ = new "); this.Write(this.ToStringHelper.ToStringWithCulture(item.CustomFormatterTypeName)); this.Write("();\r\n"); - } - } + } + } this.Write("\r\n\t\tpublic void Serialize(ref MsgPack::MessagePackWriter writer, "); this.Write(this.ToStringHelper.ToStringWithCulture(Info.FullName)); this.Write(" value, MsgPack::MessagePackSerializerOptions options)\r\n\t\t{\r\n"); - if (Info.IsClass) { + if (Info.IsClass) { this.Write("\t\t\tif (value == null)\r\n\t\t\t{\r\n\t\t\t\twriter.WriteNil();\r\n\t\t\t\treturn;\r\n\t\t\t}\r\n\r\n"); } - if (isFormatterResolverNecessary) { + if (isFormatterResolverNecessary) { this.Write("\t\t\tMsgPack::IFormatterResolver formatterResolver = options.Resolver;\r\n"); } if (Info.HasIMessagePackSerializationCallbackReceiver) { - if (Info.NeedsCastOnBefore) { + if (Info.NeedsCastOnBefore) { this.Write("\t\t\t((MsgPack::IMessagePackSerializationCallbackReceiver)value).OnBeforeSerialize(" + ");\r\n"); - } else { + } else { this.Write("\t\t\tvalue.OnBeforeSerialize();\r\n"); - } - } + } + } this.Write("\t\t\twriter.WriteArrayHeader("); this.Write(this.ToStringHelper.ToStringWithCulture(Info.MaxKey + 1)); this.Write(");\r\n"); for (var i = 0; i <= Info.MaxKey; i++) { var member = Info.GetMember(i); - if (member == null) { + if (member == null) { this.Write("\t\t\twriter.WriteNil();\r\n"); - } else { + } else { this.Write("\t\t\t"); this.Write(this.ToStringHelper.ToStringWithCulture(member.GetSerializeMethodString())); this.Write(";\r\n"); - } - } + } + } this.Write("\t\t}\r\n\r\n\t\tpublic "); this.Write(this.ToStringHelper.ToStringWithCulture(Info.FullName)); this.Write(" Deserialize(ref MsgPack::MessagePackReader reader, MsgPack::MessagePackSerialize" + "rOptions options)\r\n\t\t{\r\n\t\t\tif (reader.TryReadNil())\r\n\t\t\t{\r\n"); - if (Info.IsClass) { + if (Info.IsClass) { this.Write("\t\t\t\treturn null;\r\n"); - } else { + } else { this.Write("\t\t\t\tthrow new global::System.InvalidOperationException(\"typecode is null, struct " + "not supported\");\r\n"); - } + } this.Write("\t\t\t}\r\n\r\n"); - if (Info.MaxKey == -1 && !Info.HasIMessagePackSerializationCallbackReceiver) { + if (Info.MaxKey == -1 && !Info.HasIMessagePackSerializationCallbackReceiver) { this.Write("\t\t\treader.Skip();\r\n\t\t\treturn new "); this.Write(this.ToStringHelper.ToStringWithCulture(Info.GetConstructorString())); this.Write(";\r\n"); - } else { + } else { this.Write("\t\t\toptions.Security.DepthStep(ref reader);\r\n"); - if (isFormatterResolverNecessary) { + if (isFormatterResolverNecessary) { this.Write("\t\t\tMsgPack::IFormatterResolver formatterResolver = options.Resolver;\r\n"); - } + } this.Write("\t\t\tvar length = reader.ReadArrayHeader();\r\n"); var canOverwrite = Info.ConstructorParameters.Length == 0; - if (canOverwrite) { + if (canOverwrite) { this.Write("\t\t\tvar ____result = new "); this.Write(this.ToStringHelper.ToStringWithCulture(Info.GetConstructorString())); this.Write(";\r\n"); - } else { foreach (var member in Info.Members) { + } else { foreach (var member in Info.Members) { this.Write("\t\t\tvar __"); this.Write(this.ToStringHelper.ToStringWithCulture(member.Name)); this.Write("__ = default("); this.Write(this.ToStringHelper.ToStringWithCulture(member.Type)); this.Write(");\r\n"); - } - } + } + } this.Write("\r\n\t\t\tfor (int i = 0; i < length; i++)\r\n\t\t\t{\r\n\t\t\t\tswitch (i)\r\n\t\t\t\t{\r\n"); for (var memberIndex = 0; memberIndex <= Info.MaxKey; memberIndex++) { var member = Info.GetMember(memberIndex); - if (member == null) { continue; } + if (member == null) { continue; } this.Write("\t\t\t\t\tcase "); this.Write(this.ToStringHelper.ToStringWithCulture(member.IntKey)); this.Write(":\r\n"); if (canOverwrite) { - if (member.IsWritable) { + if (member.IsWritable) { this.Write("\t\t\t\t\t\t____result."); this.Write(this.ToStringHelper.ToStringWithCulture(member.Name)); this.Write(" = "); this.Write(this.ToStringHelper.ToStringWithCulture(member.GetDeserializeMethodString())); this.Write(";\r\n"); - } else { + } else { this.Write("\t\t\t\t\t\t"); this.Write(this.ToStringHelper.ToStringWithCulture(member.GetDeserializeMethodString())); this.Write(";\r\n"); - } + } } else { this.Write("\t\t\t\t\t\t__"); this.Write(this.ToStringHelper.ToStringWithCulture(member.Name)); this.Write("__ = "); this.Write(this.ToStringHelper.ToStringWithCulture(member.GetDeserializeMethodString())); this.Write(";\r\n"); - } + } this.Write("\t\t\t\t\t\tbreak;\r\n"); - } + } this.Write("\t\t\t\t\tdefault:\r\n\t\t\t\t\t\treader.Skip();\r\n\t\t\t\t\t\tbreak;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n"); - if (!canOverwrite) { + if (!canOverwrite) { this.Write("\t\t\tvar ____result = new "); this.Write(this.ToStringHelper.ToStringWithCulture(Info.GetConstructorString())); this.Write(";\r\n"); @@ -164,22 +165,22 @@ public virtual string TransformText() this.Write(" = __"); this.Write(this.ToStringHelper.ToStringWithCulture(member.Name)); this.Write("__;\r\n"); - } - if (memberAssignExists) { + } + if (memberAssignExists) { this.Write("\r\n\t\tMEMBER_ASSIGNMENT_END:\r\n"); } } if (Info.HasIMessagePackSerializationCallbackReceiver) { - if (Info.NeedsCastOnAfter) { + if (Info.NeedsCastOnAfter) { this.Write("\t\t\t((MsgPack::IMessagePackSerializationCallbackReceiver)____result).OnAfterDeseri" + "alize();\r\n"); - } else { + } else { this.Write("\t\t\t____result.OnAfterDeserialize();\r\n"); - } - } + } + } this.Write("\t\t\treader.Depth--;\r\n\t\t\treturn ____result;\r\n"); - } + } this.Write("\t\t}\r\n\t}\r\n}\r\n"); return this.GenerationEnvironment.ToString(); } @@ -283,7 +284,7 @@ public void Write(string textToAppend) } // If we're starting off, or if the previous text ended with a newline, // we have to append the current indent first. - if (((this.GenerationEnvironment.Length == 0) + if (((this.GenerationEnvironment.Length == 0) || this.endsWithNewline)) { this.GenerationEnvironment.Append(this.currentIndentField); diff --git a/src/MessagePack.SourceGenerator/Transforms/FormatterTemplate.tt b/src/MessagePack.SourceGenerator/Transforms/FormatterTemplate.tt index 7575a71f5..e63dc69e7 100644 --- a/src/MessagePack.SourceGenerator/Transforms/FormatterTemplate.tt +++ b/src/MessagePack.SourceGenerator/Transforms/FormatterTemplate.tt @@ -3,6 +3,7 @@ <#@ import namespace="System.Linq" #> <#@ import namespace="System.Text" #> <#@ import namespace="System.Collections.Generic" #> +<#@ import namespace="MessagePackAnalyzer.Transforms" #> namespace <#= Namespace #> { diff --git a/src/MessagePack.SourceGenerator/Transforms/IFormatterTemplate.cs b/src/MessagePack.SourceGenerator/Transforms/IFormatterTemplate.cs index 18d8e63d4..45316bcde 100644 --- a/src/MessagePack.SourceGenerator/Transforms/IFormatterTemplate.cs +++ b/src/MessagePack.SourceGenerator/Transforms/IFormatterTemplate.cs @@ -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. -using MessagePack.SourceGenerator.CodeAnalysis; +using MessagePackAnalyzer.CodeAnalysis; namespace MessagePack.SourceGenerator.Transforms; diff --git a/src/MessagePack.SourceGenerator/Transforms/StringKey/StringKeyFormatterDeserializeHelper.cs b/src/MessagePack.SourceGenerator/Transforms/StringKey/StringKeyFormatterDeserializeHelper.cs index 428fd6605..ec51953fd 100644 --- a/src/MessagePack.SourceGenerator/Transforms/StringKey/StringKeyFormatterDeserializeHelper.cs +++ b/src/MessagePack.SourceGenerator/Transforms/StringKey/StringKeyFormatterDeserializeHelper.cs @@ -3,7 +3,7 @@ using System.Text; using MessagePack.Internal; -using MessagePack.SourceGenerator.CodeAnalysis; +using MessagePackAnalyzer.CodeAnalysis; namespace MessagePack.SourceGenerator.Transforms; diff --git a/src/MessagePack.SourceGenerator/Transforms/StringKey/StringKeyFormatterTemplate.cs b/src/MessagePack.SourceGenerator/Transforms/StringKey/StringKeyFormatterTemplate.cs index 4312c0a4b..905d37a48 100644 --- a/src/MessagePack.SourceGenerator/Transforms/StringKey/StringKeyFormatterTemplate.cs +++ b/src/MessagePack.SourceGenerator/Transforms/StringKey/StringKeyFormatterTemplate.cs @@ -2,7 +2,7 @@ // // This code was generated by a tool. // Runtime Version: 17.0.0.0 -// +// // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. // @@ -12,8 +12,9 @@ namespace MessagePack.SourceGenerator.Transforms using System; using System.Linq; using System.Collections.Generic; - using MessagePack.SourceGenerator.CodeAnalysis; - + using MessagePackAnalyzer.CodeAnalysis; + using MessagePackAnalyzer.Transforms; + /// /// Class to produce the template output /// @@ -34,7 +35,7 @@ public virtual string TransformText() list.Add(new ValueTuple(member, binary)); } - bool isFormatterResolverNecessary = ShouldUseFormatterResolverHelper.ShouldUseFormatterResolver(Info.Members); + bool isFormatterResolverNecessary = ShouldUseFormatterResolverHelper.ShouldUseFormatterResolver(Info.Members); this.Write("\tinternal sealed class "); this.Write(this.ToStringHelper.ToStringWithCulture(Info.FormatterNameWithoutNamespace)); this.Write(" : global::MessagePack.Formatters.IMessagePackFormatter<"); @@ -48,8 +49,8 @@ public virtual string TransformText() this.Write("\r\n"); } this.Write("\t{\r\n"); - foreach (var item in Info.Members) { - if (item.CustomFormatterTypeName != null) { + foreach (var item in Info.Members) { + if (item.CustomFormatterTypeName != null) { this.Write("\t\tprivate readonly "); this.Write(this.ToStringHelper.ToStringWithCulture(item.CustomFormatterTypeName)); this.Write(" __"); @@ -57,11 +58,11 @@ public virtual string TransformText() this.Write("CustomFormatter__ = new "); this.Write(this.ToStringHelper.ToStringWithCulture(item.CustomFormatterTypeName)); this.Write("();\r\n"); - } - } + } + } for (var i = 0; i < list.Count; i++) { var member = list[i].Item1; - var binary = list[i].Item2; + var binary = list[i].Item2; this.Write("\t\t// "); this.Write(this.ToStringHelper.ToStringWithCulture(member.StringKey)); this.Write("\r\n\t\tprivate static global::System.ReadOnlySpan GetSpan_"); @@ -69,92 +70,92 @@ public virtual string TransformText() this.Write("() => "); this.Write(this.ToStringHelper.ToStringWithCulture(EmbedStringHelper.ToByteArrayString(binary))); this.Write(";\r\n"); - } - if (list.Count != 0) { + } + if (list.Count != 0) { this.Write("\r\n"); - } + } this.Write("\t\tpublic void Serialize(ref global::MessagePack.MessagePackWriter writer, "); this.Write(this.ToStringHelper.ToStringWithCulture(Info.FullName)); this.Write(" value, global::MessagePack.MessagePackSerializerOptions options)\r\n\t\t{\r\n"); - if (Info.IsClass) { + if (Info.IsClass) { this.Write("\t\t\tif (value is null)\r\n\t\t\t{\r\n\t\t\t\twriter.WriteNil();\r\n\t\t\t\treturn;\r\n\t\t\t}\r\n\r\n"); } - if (isFormatterResolverNecessary) { + if (isFormatterResolverNecessary) { this.Write("\t\t\tvar formatterResolver = options.Resolver;\r\n"); } if (Info.HasIMessagePackSerializationCallbackReceiver) { - if (Info.NeedsCastOnBefore) { + if (Info.NeedsCastOnBefore) { this.Write("\t\t\t((global::MessagePack.IMessagePackSerializationCallbackReceiver)value).OnBefor" + "eSerialize();\r\n"); - } else { + } else { this.Write("\t\t\tvalue.OnBeforeSerialize();\r\n"); - } - } + } + } this.Write("\t\t\twriter.WriteMapHeader("); this.Write(this.ToStringHelper.ToStringWithCulture(list.Count)); this.Write(");\r\n"); foreach (var memberAndBinary in list) { - var member = memberAndBinary.Item1; + var member = memberAndBinary.Item1; this.Write("\t\t\twriter.WriteRaw(GetSpan_"); this.Write(this.ToStringHelper.ToStringWithCulture(member.Name)); this.Write("());\r\n\t\t\t"); this.Write(this.ToStringHelper.ToStringWithCulture(member.GetSerializeMethodString())); this.Write(";\r\n"); - } + } this.Write("\t\t}\r\n\r\n\t\tpublic "); this.Write(this.ToStringHelper.ToStringWithCulture(Info.FullName)); this.Write(" Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePac" + "k.MessagePackSerializerOptions options)\r\n\t\t{\r\n\t\t\tif (reader.TryReadNil())\r\n\t\t\t{\r" + "\n"); - if (Info.IsClass) { + if (Info.IsClass) { this.Write("\t\t\t\treturn null;\r\n"); - } else { + } else { this.Write("\t\t\t\tthrow new global::System.InvalidOperationException(\"typecode is null, struct " + "not supported\");\r\n"); - } + } this.Write("\t\t\t}\r\n\r\n"); - if (Info.Members.Length == 0) { + if (Info.Members.Length == 0) { this.Write("\t\t\treader.Skip();\r\n\t\t\tvar ____result = new "); this.Write(this.ToStringHelper.ToStringWithCulture(Info.GetConstructorString())); this.Write(";\r\n"); - } else { + } else { this.Write("\t\t\toptions.Security.DepthStep(ref reader);\r\n"); - if (isFormatterResolverNecessary) { + if (isFormatterResolverNecessary) { this.Write("\t\t\tvar formatterResolver = options.Resolver;\r\n"); - } + } this.Write("\t\t\tvar length = reader.ReadMapHeader();\r\n"); var canOverwrite = Info.ConstructorParameters.Length == 0; - if (canOverwrite) { + if (canOverwrite) { this.Write("\t\t\tvar ____result = new "); this.Write(this.ToStringHelper.ToStringWithCulture(Info.GetConstructorString())); this.Write(";\r\n"); } else { - foreach (var member in Info.Members.Where(x => x.IsWritable || Info.ConstructorParameters.Any(p => p.Equals(x)))) { - if (Info.ConstructorParameters.All(p => !p.Equals(member))) { + foreach (var member in Info.Members.Where(x => x.IsWritable || Info.ConstructorParameters.Any(p => p.Equals(x)))) { + if (Info.ConstructorParameters.All(p => !p.Equals(member))) { this.Write("\t\t\tvar __"); this.Write(this.ToStringHelper.ToStringWithCulture(member.Name)); this.Write("__IsInitialized = false;\r\n"); - } + } this.Write("\t\t\tvar __"); this.Write(this.ToStringHelper.ToStringWithCulture(member.Name)); this.Write("__ = default("); this.Write(this.ToStringHelper.ToStringWithCulture(member.Type)); this.Write(");\r\n"); - } - } + } + } this.Write("\r\n\t\t\tfor (int i = 0; i < length; i++)\r\n\t\t\t{\r\n\t\t\t\tvar stringKey = global::MessageP" + "ack.Internal.CodeGenHelpers.ReadStringSpan(ref reader);\r\n\t\t\t\tswitch (stringKey.L" + "ength)\r\n\t\t\t\t{\r\n\t\t\t\t\tdefault:\r\n\t\t\t\t\tFAIL:\r\n\t\t\t\t\t reader.Skip();\r\n\t\t\t\t\t continue" + ";\r\n"); this.Write(this.ToStringHelper.ToStringWithCulture(StringKeyFormatterDeserializeHelper.Classify(Info, " ", canOverwrite))); this.Write("\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n"); - if (!canOverwrite) { + if (!canOverwrite) { this.Write("\t\t\tvar ____result = new "); this.Write(this.ToStringHelper.ToStringWithCulture(Info.GetConstructorString())); this.Write(";\r\n"); - foreach (var member in Info.Members.Where(x => x.IsWritable && !Info.ConstructorParameters.Any(p => p.Equals(x)))) { + foreach (var member in Info.Members.Where(x => x.IsWritable && !Info.ConstructorParameters.Any(p => p.Equals(x)))) { this.Write("\t\t\tif (__"); this.Write(this.ToStringHelper.ToStringWithCulture(member.Name)); this.Write("__IsInitialized)\r\n\t\t\t{\r\n\t\t\t\t____result."); @@ -162,20 +163,20 @@ public virtual string TransformText() this.Write(" = __"); this.Write(this.ToStringHelper.ToStringWithCulture(member.Name)); this.Write("__;\r\n\t\t\t}\r\n\r\n"); - } - } - } + } + } + } if (Info.HasIMessagePackSerializationCallbackReceiver) { - if (Info.NeedsCastOnAfter) { + if (Info.NeedsCastOnAfter) { this.Write("\t\t\t((global::MessagePack.IMessagePackSerializationCallbackReceiver)____result).On" + "AfterDeserialize();\r\n"); - } else { + } else { this.Write("\t\t\t____result.OnAfterDeserialize();\r\n"); - } - } - if (Info.Members.Length != 0) { + } + } + if (Info.Members.Length != 0) { this.Write("\t\t\treader.Depth--;\r\n"); - } + } this.Write("\t\t\treturn ____result;\r\n\t\t}\r\n\t}\r\n}\r\n"); return this.GenerationEnvironment.ToString(); } @@ -279,7 +280,7 @@ public void Write(string textToAppend) } // If we're starting off, or if the previous text ended with a newline, // we have to append the current indent first. - if (((this.GenerationEnvironment.Length == 0) + if (((this.GenerationEnvironment.Length == 0) || this.endsWithNewline)) { this.GenerationEnvironment.Append(this.currentIndentField); diff --git a/src/MessagePack.SourceGenerator/Transforms/StringKey/StringKeyFormatterTemplate.tt b/src/MessagePack.SourceGenerator/Transforms/StringKey/StringKeyFormatterTemplate.tt index 78664fb78..33421f2bd 100644 --- a/src/MessagePack.SourceGenerator/Transforms/StringKey/StringKeyFormatterTemplate.tt +++ b/src/MessagePack.SourceGenerator/Transforms/StringKey/StringKeyFormatterTemplate.tt @@ -3,7 +3,8 @@ <#@ import namespace="System" #> <#@ import namespace="System.Linq" #> <#@ import namespace="System.Collections.Generic" #> -<#@ import namespace="MessagePack.Generator.CodeAnalysis" #> +<#@ import namespace="MessagePackAnalyzer.CodeAnalysis" #> +<#@ import namespace="MessagePackAnalyzer.Transforms" #> namespace <#= Namespace #> { diff --git a/src/MessagePack.SourceGenerator/Transforms/TemplatePartials.cs b/src/MessagePack.SourceGenerator/Transforms/TemplatePartials.cs index cd9f8dc67..0a16cf5de 100644 --- a/src/MessagePack.SourceGenerator/Transforms/TemplatePartials.cs +++ b/src/MessagePack.SourceGenerator/Transforms/TemplatePartials.cs @@ -3,7 +3,7 @@ #pragma warning disable SA1402 // File may only contain a single type -using MessagePack.SourceGenerator.CodeAnalysis; +using MessagePackAnalyzer.CodeAnalysis; namespace MessagePack.SourceGenerator.Transforms; diff --git a/src/MessagePack.SourceGenerator/Utils/RoslynExtensions.cs b/src/MessagePack.SourceGenerator/Utils/RoslynExtensions.cs deleted file mode 100644 index 4d932c7f2..000000000 --- a/src/MessagePack.SourceGenerator/Utils/RoslynExtensions.cs +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright (c) All contributors. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - -using Microsoft.CodeAnalysis; - -namespace MessagePack.SourceGenerator; - -// Utility and Extension methods for Roslyn -internal static class RoslynExtensions -{ - internal static IEnumerable GetAllMembers(this ITypeSymbol symbol) - { - var t = symbol; - while (t != null) - { - foreach (var item in t.GetMembers()) - { - yield return item; - } - - t = t.BaseType; - } - } - - internal static bool ApproximatelyEqual(this INamedTypeSymbol? left, INamedTypeSymbol? right) - { - if (left is IErrorTypeSymbol || right is IErrorTypeSymbol) - { - return left?.ToDisplayString() == right?.ToDisplayString(); - } - else - { - return SymbolEqualityComparer.Default.Equals(left, right); - } - } -} diff --git a/src/MessagePackAnalyzer/AnalyzerUtilities.cs b/src/MessagePackAnalyzer/AnalyzerUtilities.cs deleted file mode 100644 index 5f9714b23..000000000 --- a/src/MessagePackAnalyzer/AnalyzerUtilities.cs +++ /dev/null @@ -1,10 +0,0 @@ -// Copyright (c) All contributors. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - -namespace MessagePackAnalyzer -{ - internal static class AnalyzerUtilities - { - internal static string GetHelpLink(string diagnosticId) => $"https://github.com/neuecc/MessagePack-CSharp/blob/master/doc/analyzers/{diagnosticId}.md"; - } -} diff --git a/src/MessagePack.SourceGenerator/CodeAnalysis/AnalyzerOptions.cs b/src/MessagePackAnalyzer/CodeAnalysis/AnalyzerOptions.cs similarity index 55% rename from src/MessagePack.SourceGenerator/CodeAnalysis/AnalyzerOptions.cs rename to src/MessagePackAnalyzer/CodeAnalysis/AnalyzerOptions.cs index 3ae40962c..d8affc15d 100644 --- a/src/MessagePack.SourceGenerator/CodeAnalysis/AnalyzerOptions.cs +++ b/src/MessagePackAnalyzer/CodeAnalysis/AnalyzerOptions.cs @@ -1,9 +1,12 @@ // Copyright (c) All contributors. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. +using System.Collections.Immutable; +using System.Text.Json; +using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.Diagnostics; -namespace MessagePack.SourceGenerator.CodeAnalysis; +namespace MessagePackAnalyzer.CodeAnalysis; public record AnalyzerOptions( string ResolverNamespace = "MessagePack", @@ -11,19 +14,21 @@ public record AnalyzerOptions( string ProjectRootNamespace = "", bool PublicResolver = false, bool UsesMapMode = false, - IReadOnlyCollection? IgnoreTypeNames = null) + IReadOnlyCollection? IgnoreTypeNames = null, + IReadOnlyCollection? AdditionalAllowTypes = null) { public const string RootNamespace = "build_property.RootNamespace"; public const string PublicMessagePackGeneratedResolver = "build_property.PublicMessagePackGeneratedResolver"; public const string MessagePackGeneratedResolverNamespace = "build_property.MessagePackGeneratedResolverNamespace"; public const string MessagePackGeneratedResolverName = "build_property.MessagePackGeneratedResolverName"; public const string MessagePackGeneratedUsesMapMode = "build_property.MessagePackGeneratedUsesMapMode"; + private const string JsonOptionsFileName = "MessagePackAnalyzer.json"; public static readonly AnalyzerOptions Default = new AnalyzerOptions(); public string FormatterNamespace => "Formatters"; - public static AnalyzerOptions Parse(AnalyzerConfigOptions options) + public static AnalyzerOptions Parse(Microsoft.CodeAnalysis.Diagnostics.AnalyzerConfigOptions options, ImmutableArray additionalTexts) { if (!options.TryGetValue(RootNamespace, out string? projectRootNamespace)) { @@ -55,6 +60,39 @@ public static AnalyzerOptions Parse(AnalyzerConfigOptions options) ResolverName: resolverName, ProjectRootNamespace: projectRootNamespace, PublicResolver: string.Equals(publicResolver, "true", StringComparison.OrdinalIgnoreCase), - UsesMapMode: string.Equals(usesMapMode, "true", StringComparison.OrdinalIgnoreCase)); + UsesMapMode: string.Equals(usesMapMode, "true", StringComparison.OrdinalIgnoreCase), + AdditionalAllowTypes: GetAdditionalAllowTypes(additionalTexts)); + } + + private static IReadOnlyCollection GetAdditionalAllowTypes(ImmutableArray additionalTexts) + { + Microsoft.CodeAnalysis.AdditionalText? config = additionalTexts.FirstOrDefault(x => string.Equals(Path.GetFileName(x.Path), JsonOptionsFileName, StringComparison.OrdinalIgnoreCase)); + if (config is null) + { + return Array.Empty(); + } + + try + { + JsonDocument json = JsonDocument.Parse(config.GetText()?.ToString() ?? string.Empty, new JsonDocumentOptions { AllowTrailingCommas = true, CommentHandling = JsonCommentHandling.Skip, MaxDepth = 5 }); + List allowTypes = new(); + if (json.RootElement.ValueKind == JsonValueKind.Array) + { + foreach (var element in json.RootElement.EnumerateArray()) + { + if (element.GetString() is string { Length: > 0 } allowType) + { + allowTypes.Add(allowType); + } + } + } + + return allowTypes; + } + catch (Exception ex) + { + System.Diagnostics.Debug.WriteLine("Can't load MessagePackAnalyzer.json: " + ex); + return Array.Empty(); + } } } diff --git a/src/MessagePack.SourceGenerator/CodeAnalysis/CodeAnalysisUtilities.cs b/src/MessagePackAnalyzer/CodeAnalysis/CodeAnalysisUtilities.cs similarity index 74% rename from src/MessagePack.SourceGenerator/CodeAnalysis/CodeAnalysisUtilities.cs rename to src/MessagePackAnalyzer/CodeAnalysis/CodeAnalysisUtilities.cs index 30b90df95..05e8d9ab8 100644 --- a/src/MessagePack.SourceGenerator/CodeAnalysis/CodeAnalysisUtilities.cs +++ b/src/MessagePackAnalyzer/CodeAnalysis/CodeAnalysisUtilities.cs @@ -1,9 +1,9 @@ // Copyright (c) All contributors. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace MessagePack.SourceGenerator.CodeAnalysis; +namespace MessagePackAnalyzer.CodeAnalysis; -internal static class CodeAnalysisUtilities +public static class CodeAnalysisUtilities { private static readonly HashSet InvalidFileNameChars = new(Path.GetInvalidFileNameChars()); @@ -15,17 +15,17 @@ static CodeAnalysisUtilities() InvalidFileNameChars.Add('>'); } - internal static string QualifyWithOptionalNamespace(string leafTypeOrNamespace, string? baseNamespace) + public static string QualifyWithOptionalNamespace(string leafTypeOrNamespace, string? baseNamespace) { return string.IsNullOrEmpty(baseNamespace) ? leafTypeOrNamespace : (baseNamespace!.EndsWith("::") ? $"{baseNamespace}{leafTypeOrNamespace}" : $"{baseNamespace}.{leafTypeOrNamespace}"); } - internal static string AppendNameToNamespace(string left, string? right) + public static string AppendNameToNamespace(string left, string? right) { return string.IsNullOrEmpty(right) ? left : $"{left}.{right}"; } - internal static string GetSanitizedFileName(string fileName) + public static string GetSanitizedFileName(string fileName) { foreach (char c in InvalidFileNameChars) { diff --git a/src/MessagePack.SourceGenerator/CodeAnalysis/EnumSerializationInfo.cs b/src/MessagePackAnalyzer/CodeAnalysis/EnumSerializationInfo.cs similarity index 95% rename from src/MessagePack.SourceGenerator/CodeAnalysis/EnumSerializationInfo.cs rename to src/MessagePackAnalyzer/CodeAnalysis/EnumSerializationInfo.cs index 7e782947f..317cef3e9 100644 --- a/src/MessagePack.SourceGenerator/CodeAnalysis/EnumSerializationInfo.cs +++ b/src/MessagePackAnalyzer/CodeAnalysis/EnumSerializationInfo.cs @@ -3,7 +3,7 @@ using Microsoft.CodeAnalysis; -namespace MessagePack.SourceGenerator.CodeAnalysis; +namespace MessagePackAnalyzer.CodeAnalysis; public sealed record EnumSerializationInfo(string? Namespace, string Name, string FullName, string UnderlyingTypeName) : IResolverRegisterInfo { diff --git a/src/MessagePack.SourceGenerator/CodeAnalysis/FullModel.cs b/src/MessagePackAnalyzer/CodeAnalysis/FullModel.cs similarity index 98% rename from src/MessagePack.SourceGenerator/CodeAnalysis/FullModel.cs rename to src/MessagePackAnalyzer/CodeAnalysis/FullModel.cs index 54d1f9542..a70c1fc77 100644 --- a/src/MessagePack.SourceGenerator/CodeAnalysis/FullModel.cs +++ b/src/MessagePackAnalyzer/CodeAnalysis/FullModel.cs @@ -3,7 +3,7 @@ using System.Collections.Immutable; -namespace MessagePack.SourceGenerator.CodeAnalysis; +namespace MessagePackAnalyzer.CodeAnalysis; public record FullModel( ImmutableSortedSet ObjectInfos, diff --git a/src/MessagePack.SourceGenerator/CodeAnalysis/GenericSerializationInfo.cs b/src/MessagePackAnalyzer/CodeAnalysis/GenericSerializationInfo.cs similarity index 92% rename from src/MessagePack.SourceGenerator/CodeAnalysis/GenericSerializationInfo.cs rename to src/MessagePackAnalyzer/CodeAnalysis/GenericSerializationInfo.cs index 709eba5c6..cfa405848 100644 --- a/src/MessagePack.SourceGenerator/CodeAnalysis/GenericSerializationInfo.cs +++ b/src/MessagePackAnalyzer/CodeAnalysis/GenericSerializationInfo.cs @@ -3,7 +3,7 @@ using Microsoft.CodeAnalysis; -namespace MessagePack.SourceGenerator.CodeAnalysis; +namespace MessagePackAnalyzer.CodeAnalysis; public sealed record GenericSerializationInfo(string FullName, string FormatterName, bool IsOpenGenericType) : IResolverRegisterInfo { diff --git a/src/MessagePack.SourceGenerator/CodeAnalysis/GenericTypeParameterInfo.cs b/src/MessagePackAnalyzer/CodeAnalysis/GenericTypeParameterInfo.cs similarity index 85% rename from src/MessagePack.SourceGenerator/CodeAnalysis/GenericTypeParameterInfo.cs rename to src/MessagePackAnalyzer/CodeAnalysis/GenericTypeParameterInfo.cs index 9268ff41c..30da7aad8 100644 --- a/src/MessagePack.SourceGenerator/CodeAnalysis/GenericTypeParameterInfo.cs +++ b/src/MessagePackAnalyzer/CodeAnalysis/GenericTypeParameterInfo.cs @@ -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. -namespace MessagePack.SourceGenerator.CodeAnalysis; +namespace MessagePackAnalyzer.CodeAnalysis; public record GenericTypeParameterInfo(string Name, string Constraints) { diff --git a/src/MessagePack.SourceGenerator/CodeAnalysis/IResolverRegisterInfo.cs b/src/MessagePackAnalyzer/CodeAnalysis/IResolverRegisterInfo.cs similarity index 87% rename from src/MessagePack.SourceGenerator/CodeAnalysis/IResolverRegisterInfo.cs rename to src/MessagePackAnalyzer/CodeAnalysis/IResolverRegisterInfo.cs index 3922d6900..f36faef3b 100644 --- a/src/MessagePack.SourceGenerator/CodeAnalysis/IResolverRegisterInfo.cs +++ b/src/MessagePackAnalyzer/CodeAnalysis/IResolverRegisterInfo.cs @@ -3,7 +3,7 @@ using Microsoft.CodeAnalysis; -namespace MessagePack.SourceGenerator.CodeAnalysis; +namespace MessagePackAnalyzer.CodeAnalysis; public interface IResolverRegisterInfo { diff --git a/src/MessagePack.SourceGenerator/CodeAnalysis/MemberSerializationInfo.cs b/src/MessagePackAnalyzer/CodeAnalysis/MemberSerializationInfo.cs similarity index 95% rename from src/MessagePack.SourceGenerator/CodeAnalysis/MemberSerializationInfo.cs rename to src/MessagePackAnalyzer/CodeAnalysis/MemberSerializationInfo.cs index 558cdbc92..d441c66d0 100644 --- a/src/MessagePack.SourceGenerator/CodeAnalysis/MemberSerializationInfo.cs +++ b/src/MessagePackAnalyzer/CodeAnalysis/MemberSerializationInfo.cs @@ -1,9 +1,9 @@ // Copyright (c) All contributors. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -using MessagePack.SourceGenerator.Transforms; +using MessagePackAnalyzer.Transforms; -namespace MessagePack.SourceGenerator.CodeAnalysis; +namespace MessagePackAnalyzer.CodeAnalysis; public record MemberSerializationInfo( bool IsProperty, diff --git a/src/MessagePack.SourceGenerator/CodeAnalysis/ObjectSerializationInfo.cs b/src/MessagePackAnalyzer/CodeAnalysis/ObjectSerializationInfo.cs similarity index 98% rename from src/MessagePack.SourceGenerator/CodeAnalysis/ObjectSerializationInfo.cs rename to src/MessagePackAnalyzer/CodeAnalysis/ObjectSerializationInfo.cs index 69c2c67cb..675514e45 100644 --- a/src/MessagePack.SourceGenerator/CodeAnalysis/ObjectSerializationInfo.cs +++ b/src/MessagePackAnalyzer/CodeAnalysis/ObjectSerializationInfo.cs @@ -3,7 +3,7 @@ using Microsoft.CodeAnalysis; -namespace MessagePack.SourceGenerator.CodeAnalysis; +namespace MessagePackAnalyzer.CodeAnalysis; public record ObjectSerializationInfo( bool IsClass, diff --git a/src/MessagePackAnalyzer/CodeAnalysis/ReferenceSymbols.cs b/src/MessagePackAnalyzer/CodeAnalysis/ReferenceSymbols.cs new file mode 100644 index 000000000..5178bd6e9 --- /dev/null +++ b/src/MessagePackAnalyzer/CodeAnalysis/ReferenceSymbols.cs @@ -0,0 +1,86 @@ +// Copyright (c) All contributors. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using System.Diagnostics.CodeAnalysis; +using Microsoft.CodeAnalysis; + +namespace MessagePackAnalyzer.CodeAnalysis; + +public record ReferenceSymbols( + INamedTypeSymbol MessagePackObjectAttribute, + INamedTypeSymbol UnionAttribute, + INamedTypeSymbol SerializationConstructorAttribute, + INamedTypeSymbol KeyAttribute, + INamedTypeSymbol IgnoreAttribute, + INamedTypeSymbol FormatterAttribute, + INamedTypeSymbol MessagePackFormatter, + INamedTypeSymbol? IgnoreDataMemberAttribute, + INamedTypeSymbol IMessagePackSerializationCallbackReceiver) +{ + public static bool TryCreate(Compilation compilation, [NotNullWhen(true)] out ReferenceSymbols? instance) + { + instance = null; + + INamedTypeSymbol? messagePackObjectAttribute = compilation.GetTypeByMetadataName("MessagePack.MessagePackObjectAttribute"); + if (messagePackObjectAttribute is null) + { + return false; + } + + INamedTypeSymbol? unionAttribute = compilation.GetTypeByMetadataName("MessagePack.UnionAttribute"); + if (unionAttribute is null) + { + return false; + } + + INamedTypeSymbol? serializationConstructor = compilation.GetTypeByMetadataName("MessagePack.SerializationConstructorAttribute"); + if (serializationConstructor is null) + { + return false; + } + + INamedTypeSymbol? keyAttribute = compilation.GetTypeByMetadataName("MessagePack.KeyAttribute"); + if (keyAttribute is null) + { + return false; + } + + INamedTypeSymbol? ignoreAttribute = compilation.GetTypeByMetadataName("MessagePack.IgnoreMemberAttribute"); + if (ignoreAttribute is null) + { + return false; + } + + INamedTypeSymbol? formatterAttribute = compilation.GetTypeByMetadataName("MessagePack.MessagePackFormatterAttribute"); + if (formatterAttribute is null) + { + return false; + } + + INamedTypeSymbol? messageFormatter = compilation.GetTypeByMetadataName("MessagePack.Formatters.IMessagePackFormatter"); + if (messageFormatter is null) + { + return false; + } + + INamedTypeSymbol? ignoreDataMemberAttribute = compilation.GetTypeByMetadataName("System.Runtime.Serialization.IgnoreDataMemberAttribute"); + + INamedTypeSymbol? messagePackSerializationCallbackReceiver = compilation.GetTypeByMetadataName("MessagePack.IMessagePackSerializationCallbackReceiver"); + if (messagePackSerializationCallbackReceiver is null) + { + return false; + } + + instance = new ReferenceSymbols( + messagePackObjectAttribute, + unionAttribute, + serializationConstructor, + keyAttribute, + ignoreAttribute, + formatterAttribute, + messageFormatter, + ignoreDataMemberAttribute, + messagePackSerializationCallbackReceiver); + return true; + } +} diff --git a/src/MessagePack.SourceGenerator/CodeAnalysis/ResolverRegisterInfoComparer.cs b/src/MessagePackAnalyzer/CodeAnalysis/ResolverRegisterInfoComparer.cs similarity index 90% rename from src/MessagePack.SourceGenerator/CodeAnalysis/ResolverRegisterInfoComparer.cs rename to src/MessagePackAnalyzer/CodeAnalysis/ResolverRegisterInfoComparer.cs index 9d6247f24..5ab54e75c 100644 --- a/src/MessagePack.SourceGenerator/CodeAnalysis/ResolverRegisterInfoComparer.cs +++ b/src/MessagePackAnalyzer/CodeAnalysis/ResolverRegisterInfoComparer.cs @@ -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. -namespace MessagePack.SourceGenerator.CodeAnalysis; +namespace MessagePackAnalyzer.CodeAnalysis; public class ResolverRegisterInfoComparer : IComparer { diff --git a/src/MessagePack.SourceGenerator/CodeAnalysis/TypeCollector.cs b/src/MessagePackAnalyzer/CodeAnalysis/TypeCollector.cs similarity index 85% rename from src/MessagePack.SourceGenerator/CodeAnalysis/TypeCollector.cs rename to src/MessagePackAnalyzer/CodeAnalysis/TypeCollector.cs index 778773b4f..50062ec83 100644 --- a/src/MessagePack.SourceGenerator/CodeAnalysis/TypeCollector.cs +++ b/src/MessagePackAnalyzer/CodeAnalysis/TypeCollector.cs @@ -10,7 +10,7 @@ using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp.Syntax; -namespace MessagePack.SourceGenerator.CodeAnalysis; +namespace MessagePackAnalyzer.CodeAnalysis; public class MessagePackGeneratorResolveFailedException : Exception { @@ -20,50 +20,6 @@ public MessagePackGeneratorResolveFailedException(string message) } } -internal class ReferenceSymbols -{ -#pragma warning disable SA1401 // Fields should be private - internal readonly INamedTypeSymbol MessagePackObjectAttribute; - internal readonly INamedTypeSymbol UnionAttribute; - internal readonly INamedTypeSymbol SerializationConstructorAttribute; - internal readonly INamedTypeSymbol KeyAttribute; - internal readonly INamedTypeSymbol IgnoreAttribute; - internal readonly INamedTypeSymbol? IgnoreDataMemberAttribute; - internal readonly INamedTypeSymbol IMessagePackSerializationCallbackReceiver; - internal readonly INamedTypeSymbol MessagePackFormatterAttribute; -#pragma warning restore SA1401 // Fields should be private - - public ReferenceSymbols(Compilation compilation, Action logger) - { - this.MessagePackObjectAttribute = compilation.GetTypeByMetadataName("MessagePack.MessagePackObjectAttribute") - ?? throw new InvalidOperationException("failed to get metadata of MessagePack.MessagePackObjectAttribute"); - - this.UnionAttribute = compilation.GetTypeByMetadataName("MessagePack.UnionAttribute") - ?? throw new InvalidOperationException("failed to get metadata of MessagePack.UnionAttribute"); - - this.SerializationConstructorAttribute = compilation.GetTypeByMetadataName("MessagePack.SerializationConstructorAttribute") - ?? throw new InvalidOperationException("failed to get metadata of MessagePack.SerializationConstructorAttribute"); - - this.KeyAttribute = compilation.GetTypeByMetadataName("MessagePack.KeyAttribute") - ?? throw new InvalidOperationException("failed to get metadata of MessagePack.KeyAttribute"); - - this.IgnoreAttribute = compilation.GetTypeByMetadataName("MessagePack.IgnoreMemberAttribute") - ?? throw new InvalidOperationException("failed to get metadata of MessagePack.IgnoreMemberAttribute"); - - this.IgnoreDataMemberAttribute = compilation.GetTypeByMetadataName("System.Runtime.Serialization.IgnoreDataMemberAttribute"); - if (this.IgnoreDataMemberAttribute == null) - { - logger("failed to get metadata of System.Runtime.Serialization.IgnoreDataMemberAttribute"); - } - - this.IMessagePackSerializationCallbackReceiver = compilation.GetTypeByMetadataName("MessagePack.IMessagePackSerializationCallbackReceiver") - ?? throw new InvalidOperationException("failed to get metadata of MessagePack.IMessagePackSerializationCallbackReceiver"); - - this.MessagePackFormatterAttribute = compilation.GetTypeByMetadataName("MessagePack.MessagePackFormatterAttribute") - ?? throw new InvalidOperationException("failed to get metadata of MessagePack.MessagePackFormatterAttribute"); - } -} - internal static class AnalyzerUtilities { internal static string GetHelpLink(string diagnosticId) => $"https://github.com/neuecc/MessagePack-CSharp/blob/master/doc/analyzers/{diagnosticId}.md"; @@ -71,41 +27,6 @@ internal static class AnalyzerUtilities public class TypeCollector { - public const string UseMessagePackObjectAttributeId = "MsgPack003"; - public const string AttributeMessagePackObjectMembersId = "MsgPack004"; - public const string InvalidMessagePackObjectId = "MsgPack005"; - internal const string Category = "Usage"; - - internal static readonly DiagnosticDescriptor TypeMustBeMessagePackObject = new DiagnosticDescriptor( - id: UseMessagePackObjectAttributeId, - title: "Use MessagePackObjectAttribute", - category: Category, - messageFormat: "Type must be marked with MessagePackObjectAttribute. {0}.", // type.Name - description: "Type must be marked with MessagePackObjectAttribute.", - defaultSeverity: DiagnosticSeverity.Error, - isEnabledByDefault: true, - helpLinkUri: AnalyzerUtilities.GetHelpLink(UseMessagePackObjectAttributeId)); - - internal static readonly DiagnosticDescriptor PublicMemberNeedsKey = new DiagnosticDescriptor( - id: AttributeMessagePackObjectMembersId, - title: "Attribute public members of MessagePack objects", - category: Category, - messageFormat: "Public members of MessagePackObject-attributed types require either KeyAttribute or IgnoreMemberAttribute. {0}.{1}.", // type.Name + "." + item.Name - description: "Public member must be marked with KeyAttribute or IgnoreMemberAttribute.", - defaultSeverity: DiagnosticSeverity.Error, - isEnabledByDefault: true, - helpLinkUri: AnalyzerUtilities.GetHelpLink(AttributeMessagePackObjectMembersId)); - - internal static readonly DiagnosticDescriptor BothStringAndIntKeyAreNull = new DiagnosticDescriptor( - id: InvalidMessagePackObjectId, - title: "Attribute public members of MessagePack objects", - category: Category, - messageFormat: "Both int and string keys are null. {0}.{1}.", // type.Name + "." + item.Name - description: "An int or string key must be supplied to the KeyAttribute.", - defaultSeverity: DiagnosticSeverity.Error, - isEnabledByDefault: true, - helpLinkUri: AnalyzerUtilities.GetHelpLink(AttributeMessagePackObjectMembersId)); - private static readonly SymbolDisplayFormat BinaryWriteFormat = new SymbolDisplayFormat( genericsOptions: SymbolDisplayGenericsOptions.IncludeTypeParameters, miscellaneousOptions: SymbolDisplayMiscellaneousOptions.ExpandNullable, @@ -262,16 +183,16 @@ public class TypeCollector }; private readonly bool isForceUseMap; - private readonly IGeneratorContext? context; private readonly AnalyzerOptions options; private readonly ReferenceSymbols typeReferences; + private readonly Action? reportDiagnostic; private readonly ITypeSymbol? targetType; private readonly bool excludeArrayElement; private readonly HashSet externalIgnoreTypeNames; // visitor workspace: #pragma warning disable RS1024 // Compare symbols correctly (https://github.com/dotnet/roslyn-analyzers/issues/5246) - private readonly HashSet alreadyCollected = new(SymbolEqualityComparer.Default); + private readonly Dictionary alreadyCollected = new(SymbolEqualityComparer.Default); #pragma warning restore RS1024 // Compare symbols correctly private readonly ImmutableSortedSet.Builder collectedObjectInfo = ImmutableSortedSet.CreateBuilder(ResolverRegisterInfoComparer.Default); private readonly ImmutableSortedSet.Builder collectedEnumInfo = ImmutableSortedSet.CreateBuilder(ResolverRegisterInfoComparer.Default); @@ -280,16 +201,15 @@ public class TypeCollector private readonly Compilation compilation; - private TypeCollector(Compilation compilation, AnalyzerOptions options, ITypeSymbol targetType, IGeneratorContext? context) + private TypeCollector(Compilation compilation, AnalyzerOptions options, ReferenceSymbols referenceSymbols, ITypeSymbol targetType, Action? reportDiagnostic) { - this.typeReferences = new ReferenceSymbols(compilation, _ => { }); + this.typeReferences = referenceSymbols; + this.reportDiagnostic = reportDiagnostic; this.isForceUseMap = options.UsesMapMode; - this.context = context; this.options = options; this.externalIgnoreTypeNames = new HashSet(options.IgnoreTypeNames ?? Array.Empty()); this.compilation = compilation; this.excludeArrayElement = true; - this.context = context; if (IsAllowedAccessibility(targetType.DeclaredAccessibility)) { @@ -303,12 +223,12 @@ private TypeCollector(Compilation compilation, AnalyzerOptions options, ITypeSym } } - public static FullModel? Collect(Compilation compilation, AnalyzerOptions options, TypeDeclarationSyntax typeDeclaration, IGeneratorContext? generatorContext, CancellationToken cancellationToken) + public static FullModel? Collect(Compilation compilation, AnalyzerOptions options, ReferenceSymbols referenceSymbols, Action? reportDiagnostic, TypeDeclarationSyntax typeDeclaration, CancellationToken cancellationToken) { SemanticModel semanticModel = compilation.GetSemanticModel(typeDeclaration.SyntaxTree); if (semanticModel.GetDeclaredSymbol(typeDeclaration, cancellationToken) is ITypeSymbol typeSymbol) { - if (Collect(compilation, options, typeSymbol, generatorContext) is FullModel model) + if (Collect(compilation, options, referenceSymbols, reportDiagnostic, typeSymbol) is FullModel model) { return model; } @@ -317,9 +237,9 @@ private TypeCollector(Compilation compilation, AnalyzerOptions options, ITypeSym return null; } - public static FullModel? Collect(Compilation compilation, AnalyzerOptions options, ITypeSymbol targetType, IGeneratorContext? context) + public static FullModel? Collect(Compilation compilation, AnalyzerOptions options, ReferenceSymbols referenceSymbols, Action? reportDiagnostic, ITypeSymbol targetType) { - TypeCollector collector = new(compilation, options, targetType, context); + TypeCollector collector = new(compilation, options, referenceSymbols, targetType, reportDiagnostic); if (collector.targetType is null) { return null; @@ -357,73 +277,99 @@ public FullModel Collect() } // Gate of recursive collect - private void CollectCore(ITypeSymbol typeSymbol) + private bool CollectCore(ITypeSymbol typeSymbol) { - if (!this.alreadyCollected.Add(typeSymbol)) + if (this.alreadyCollected.TryGetValue(typeSymbol, out bool result)) { - return; + return result; } var typeSymbolString = typeSymbol.WithNullableAnnotation(NullableAnnotation.NotAnnotated).ToString() ?? throw new InvalidOperationException(); if (EmbeddedTypes.Contains(typeSymbolString)) { - return; + result = true; + this.alreadyCollected.Add(typeSymbol, result); + return result; } if (this.externalIgnoreTypeNames.Contains(typeSymbolString)) { - return; + result = true; + this.alreadyCollected.Add(typeSymbol, result); + return result; } if (typeSymbol is IArrayTypeSymbol arrayTypeSymbol) { - this.CollectArray((IArrayTypeSymbol)this.ToTupleUnderlyingType(arrayTypeSymbol)); - return; + result = this.CollectArray((IArrayTypeSymbol)this.ToTupleUnderlyingType(arrayTypeSymbol)); + this.alreadyCollected.Add(typeSymbol, result); + return result; + } + + if (typeSymbol is ITypeParameterSymbol) + { + result = true; + this.alreadyCollected.Add(typeSymbol, result); + return result; } if (!this.IsAllowAccessibility(typeSymbol)) { - return; + result = false; + this.alreadyCollected.Add(typeSymbol, result); + return result; } if (!(typeSymbol is INamedTypeSymbol type)) { - return; + result = false; + this.alreadyCollected.Add(typeSymbol, result); + return result; } - var customFormatterAttr = typeSymbol.GetAttributes().FirstOrDefault(x => x.AttributeClass.ApproximatelyEqual(this.typeReferences.MessagePackFormatterAttribute)); + var customFormatterAttr = typeSymbol.GetAttributes().FirstOrDefault(x => x.AttributeClass.ApproximatelyEqual(this.typeReferences.FormatterAttribute)); if (customFormatterAttr != null) { - return; + this.CheckValidMessagePackFormatterAttribute(customFormatterAttr); + result = true; + this.alreadyCollected.Add(typeSymbol, result); + return result; } if (type.EnumUnderlyingType != null) { - this.CollectEnum(type, type.EnumUnderlyingType); - return; + result = this.CollectEnum(type, type.EnumUnderlyingType); + this.alreadyCollected.Add(typeSymbol, result); + return result; } if (type.IsGenericType) { - this.CollectGeneric((INamedTypeSymbol)this.ToTupleUnderlyingType(type)); - return; + result = this.CollectGeneric((INamedTypeSymbol)this.ToTupleUnderlyingType(type)); + this.alreadyCollected.Add(typeSymbol, result); + return result; } if (type.Locations[0].IsInMetadata) { - return; + result = true; + this.alreadyCollected.Add(typeSymbol, result); + return result; } if (type.TypeKind == TypeKind.Interface || (type.TypeKind == TypeKind.Class && type.IsAbstract)) { - this.CollectUnion(type); - return; + result = this.CollectUnion(type); + this.alreadyCollected.Add(typeSymbol, result); + return result; } - this.CollectObject(type); + result = this.CollectObject(type); + this.alreadyCollected.Add(typeSymbol, result); + return result; } - private void CollectEnum(INamedTypeSymbol type, ISymbol enumUnderlyingType) + private bool CollectEnum(INamedTypeSymbol type, ISymbol enumUnderlyingType) { EnumSerializationInfo info = new( type.ContainingNamespace.IsGlobalNamespace ? null : type.ContainingNamespace.ToDisplayString(), @@ -431,9 +377,10 @@ private void CollectEnum(INamedTypeSymbol type, ISymbol enumUnderlyingType) type.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat), enumUnderlyingType.ToDisplayString(BinaryWriteFormat)); this.collectedEnumInfo.Add(info); + return true; } - private void CollectUnion(INamedTypeSymbol type) + private bool CollectUnion(INamedTypeSymbol type) { ImmutableArray[] unionAttrs = type.GetAttributes().Where(x => x.AttributeClass.ApproximatelyEqual(this.typeReferences.UnionAttribute)).Select(x => x.ConstructorArguments).ToArray(); if (unionAttrs.Length == 0) @@ -460,6 +407,7 @@ UnionSubTypeInfo UnionSubTypeInfoSelector(ImmutableArray x) unionAttrs.Select(UnionSubTypeInfoSelector).OrderBy(x => x.Key).ToArray()); this.collectedUnionInfo.Add(info); + return true; } private void CollectGenericUnion(INamedTypeSymbol type) @@ -474,7 +422,7 @@ private void CollectGenericUnion(INamedTypeSymbol type) do { var x = enumerator.Current; - if (x[1] is { Value: INamedTypeSymbol unionType } && this.alreadyCollected.Contains(unionType) == false) + if (x[1] is { Value: INamedTypeSymbol unionType } && !this.alreadyCollected.ContainsKey(unionType)) { this.CollectCore(unionType); } @@ -482,12 +430,15 @@ private void CollectGenericUnion(INamedTypeSymbol type) while (enumerator.MoveNext()); } - private void CollectArray(IArrayTypeSymbol array) + private bool CollectArray(IArrayTypeSymbol array) { ITypeSymbol elemType = array.ElementType; if (!this.excludeArrayElement) { - this.CollectCore(elemType); + if (!this.CollectCore(elemType)) + { + return false; + } } var fullName = array.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat); @@ -510,6 +461,7 @@ private void CollectArray(IArrayTypeSymbol array) var info = new GenericSerializationInfo(fullName, formatterName, elemType is ITypeParameterSymbol); this.collectedGenericInfo.Add(info); + return true; } private ITypeSymbol ToTupleUnderlyingType(ITypeSymbol typeSymbol) @@ -534,7 +486,7 @@ private ITypeSymbol ToTupleUnderlyingType(ITypeSymbol typeSymbol) return namedType; } - private void CollectGeneric(INamedTypeSymbol type) + private bool CollectGeneric(INamedTypeSymbol type) { INamedTypeSymbol genericType = type.ConstructUnboundGenericType(); var genericTypeString = genericType.ToDisplayString(); @@ -544,23 +496,26 @@ private void CollectGeneric(INamedTypeSymbol type) // special case if (fullName == "global::System.ArraySegment" || fullName == "global::System.ArraySegment?") { - return; + return true; } // nullable if (genericTypeString == "T?") { var firstTypeArgument = type.TypeArguments[0]; - this.CollectCore(firstTypeArgument); + if (!this.CollectCore(firstTypeArgument)) + { + return false; + } if (EmbeddedTypes.Contains(firstTypeArgument.ToString()!)) { - return; + return true; } var info = new GenericSerializationInfo(type.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat), "MsgPack::Formatters.NullableFormatter<" + firstTypeArgument.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat) + ">", isOpenGenericType); this.collectedGenericInfo.Add(info); - return; + return true; } // collection @@ -580,7 +535,7 @@ private void CollectGeneric(INamedTypeSymbol type) if (genericTypeString != "System.Linq.ILookup<,>") { - return; + return true; } formatter = KnownGenericTypes["System.Linq.IGrouping<,>"]; @@ -595,7 +550,7 @@ private void CollectGeneric(INamedTypeSymbol type) var enumerableInfo = new GenericSerializationInfo("global::System.Collections.Generic.IEnumerable<" + typeArgs + ">", f, isOpenGenericType); this.collectedGenericInfo.Add(enumerableInfo); - return; + return true; } // Generic types @@ -603,7 +558,7 @@ private void CollectGeneric(INamedTypeSymbol type) { this.CollectGenericUnion(type); this.CollectObject(type); - return; + return true; } else { @@ -619,7 +574,10 @@ private void CollectGeneric(INamedTypeSymbol type) // Collect substituted types for the type parameters (e.g. Bar in Foo) foreach (var item in type.TypeArguments) { - this.CollectCore(item); + if (!this.CollectCore(item)) + { + return false; + } } var formatterBuilder = new StringBuilder(); @@ -648,27 +606,48 @@ private void CollectGeneric(INamedTypeSymbol type) var genericSerializationInfo = new GenericSerializationInfo(type.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat), $"Formatters::{formatterBuilder}", isOpenGenericType); this.collectedGenericInfo.Add(genericSerializationInfo); + return true; } - private void CollectObject(INamedTypeSymbol type) + private bool CollectObject(INamedTypeSymbol type) { ObjectSerializationInfo? info = this.GetObjectInfo(type); if (info is not null) { this.collectedObjectInfo.Add(info); } + + return info is not null; + } + + private bool CheckValidMessagePackFormatterAttribute(AttributeData formatterAttribute) + { + if (formatterAttribute.ConstructorArguments[0].Value is ITypeSymbol formatterType) + { + // Validate that the typed formatter is actually of `IMessagePackFormatter` + bool isMessagePackFormatter = formatterType.AllInterfaces.Any(x => SymbolEqualityComparer.Default.Equals(x, this.typeReferences.MessagePackFormatter)); + if (!isMessagePackFormatter) + { + Location? location = ((AttributeSyntax?)formatterAttribute.ApplicationSyntaxReference?.GetSyntax())?.ArgumentList?.Arguments[0].GetLocation(); + ImmutableDictionary typeInfo = ImmutableDictionary.Create().Add("type", formatterType.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat)); + this.reportDiagnostic?.Invoke(Diagnostic.Create(MsgPack00xMessagePackAnalyzer.MessageFormatterMustBeMessagePackFormatter, location, typeInfo)); + } + + return isMessagePackFormatter; + } + + return false; } private ObjectSerializationInfo? GetObjectInfo(INamedTypeSymbol type) { - List diagnostics = new(); var isClass = !type.IsValueType; var isOpenGenericType = type.IsGenericType; AttributeData? contractAttr = type.GetAttributes().FirstOrDefault(x => x.AttributeClass.ApproximatelyEqual(this.typeReferences.MessagePackObjectAttribute)); if (contractAttr is null) { - diagnostics.Add(Diagnostic.Create(TypeMustBeMessagePackObject, ((BaseTypeDeclarationSyntax)type.DeclaringSyntaxReferences[0].GetSyntax()).Identifier.GetLocation(), type.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat))); + ////this.reportDiagnostic?.Invoke(Diagnostic.Create(MsgPack00xMessagePackAnalyzer.TypeMustBeMessagePackObject, ((BaseTypeDeclarationSyntax)type.DeclaringSyntaxReferences[0].GetSyntax()).Identifier.GetLocation(), type.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat))); } var isIntKey = true; @@ -696,7 +675,7 @@ private void CollectObject(INamedTypeSymbol type) continue; } - var customFormatterAttr = item.GetAttributes().FirstOrDefault(x => x.AttributeClass.ApproximatelyEqual(this.typeReferences.MessagePackFormatterAttribute))?.ConstructorArguments[0].Value as INamedTypeSymbol; + var customFormatterAttr = item.GetAttributes().FirstOrDefault(x => x.AttributeClass.ApproximatelyEqual(this.typeReferences.FormatterAttribute))?.ConstructorArguments[0].Value as INamedTypeSymbol; var member = new MemberSerializationInfo(true, isWritable, isReadable, hiddenIntKey++, item.Name, item.Name, item.Type.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat), item.Type.ToDisplayString(BinaryWriteFormat), customFormatterAttr?.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat)); stringMembers.Add(member.StringKey, member); @@ -725,7 +704,7 @@ private void CollectObject(INamedTypeSymbol type) continue; } - var customFormatterAttr = item.GetAttributes().FirstOrDefault(x => x.AttributeClass.ApproximatelyEqual(this.typeReferences.MessagePackFormatterAttribute))?.ConstructorArguments[0].Value as INamedTypeSymbol; + var customFormatterAttr = item.GetAttributes().FirstOrDefault(x => x.AttributeClass.ApproximatelyEqual(this.typeReferences.FormatterAttribute))?.ConstructorArguments[0].Value as INamedTypeSymbol; var member = new MemberSerializationInfo(false, isWritable, isReadable, hiddenIntKey++, item.Name, item.Name, item.Type.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat), item.Type.ToDisplayString(BinaryWriteFormat), customFormatterAttr?.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat)); stringMembers.Add(member.StringKey, member); if (customFormatterAttr == null) @@ -763,13 +742,30 @@ private void CollectObject(INamedTypeSymbol type) continue; } - var customFormatterAttr = item.GetAttributes().FirstOrDefault(x => x.AttributeClass.ApproximatelyEqual(this.typeReferences.MessagePackFormatterAttribute))?.ConstructorArguments[0].Value as INamedTypeSymbol; + var customFormatterAttr = item.GetAttributes().FirstOrDefault(x => x.AttributeClass.ApproximatelyEqual(this.typeReferences.FormatterAttribute))?.ConstructorArguments[0].Value as INamedTypeSymbol; TypedConstant? key = item.GetAttributes().FirstOrDefault(x => x.AttributeClass.ApproximatelyEqual(this.typeReferences.KeyAttribute))?.ConstructorArguments[0]; if (key is null) { if (contractAttr is not null) { - diagnostics.Add(Diagnostic.Create(PublicMemberNeedsKey, ((PropertyDeclarationSyntax)item.DeclaringSyntaxReferences[0].GetSyntax()).Identifier.GetLocation(), type.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat), item.Name)); + if (SymbolEqualityComparer.Default.Equals(item.ContainingType, type)) + { + this.reportDiagnostic?.Invoke(Diagnostic.Create(MsgPack00xMessagePackAnalyzer.PublicMemberNeedsKey, ((PropertyDeclarationSyntax)item.DeclaringSyntaxReferences[0].GetSyntax()).Identifier.GetLocation(), type.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat), item.Name)); + } + else if (type.BaseType is not null) + { + // The member was inherited, so we raise a special error at the location of the base type reference. + BaseTypeSyntax? baseSyntax = type.DeclaringSyntaxReferences.SelectMany(sr => (IEnumerable?)((BaseTypeDeclarationSyntax)sr.GetSyntax()).BaseList?.Types ?? Array.Empty()) + .FirstOrDefault(bt => SymbolEqualityComparer.Default.Equals(this.compilation.GetSemanticModel(bt.SyntaxTree).GetTypeInfo(bt.Type).Type, item.ContainingType)); + if (baseSyntax is not null) + { + this.reportDiagnostic?.Invoke(Diagnostic.Create( + MsgPack00xMessagePackAnalyzer.BaseTypeContainsUnattributedPublicMembers, + baseSyntax.GetLocation(), + item.ContainingType.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat), + item.Name)); + } + } } } else @@ -778,7 +774,7 @@ private void CollectObject(INamedTypeSymbol type) var stringKey = key is { Value: string stringKeyValue } ? stringKeyValue : default; if (intKey == null && stringKey == null) { - diagnostics.Add(Diagnostic.Create(BothStringAndIntKeyAreNull, ((PropertyDeclarationSyntax)item.DeclaringSyntaxReferences[0].GetSyntax()).Identifier.GetLocation(), type.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat), item.Name)); + this.reportDiagnostic?.Invoke(Diagnostic.Create(MsgPack00xMessagePackAnalyzer.BothStringAndIntKeyAreNull, ((PropertyDeclarationSyntax)item.DeclaringSyntaxReferences[0].GetSyntax()).Identifier.GetLocation(), type.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat), item.Name)); } if (searchFirst) @@ -816,11 +812,16 @@ private void CollectObject(INamedTypeSymbol type) } } - var messagePackFormatter = item.GetAttributes().FirstOrDefault(x => x.AttributeClass.ApproximatelyEqual(this.typeReferences.MessagePackFormatterAttribute))?.ConstructorArguments[0]; + var messagePackFormatter = item.GetAttributes().FirstOrDefault(x => x.AttributeClass.ApproximatelyEqual(this.typeReferences.FormatterAttribute))?.ConstructorArguments[0]; if (messagePackFormatter == null) { - this.CollectCore(item.Type); // recursive collect + // recursive collect + if (!this.CollectCore(item.Type)) + { + // TODO: add the declaration of the referenced type as an additional location. + this.reportDiagnostic?.Invoke(Diagnostic.Create(MsgPack00xMessagePackAnalyzer.TypeMustBeMessagePackObject, (item.DeclaringSyntaxReferences.FirstOrDefault()?.GetSyntax() as PropertyDeclarationSyntax)?.Type.GetLocation(), item.Type.ToDisplayString(ShortTypeNameFormat))); + } } } @@ -843,13 +844,13 @@ private void CollectObject(INamedTypeSymbol type) continue; } - var customFormatterAttr = item.GetAttributes().FirstOrDefault(x => x.AttributeClass.ApproximatelyEqual(this.typeReferences.MessagePackFormatterAttribute))?.ConstructorArguments[0].Value as INamedTypeSymbol; + var customFormatterAttr = item.GetAttributes().FirstOrDefault(x => x.AttributeClass.ApproximatelyEqual(this.typeReferences.FormatterAttribute))?.ConstructorArguments[0].Value as INamedTypeSymbol; TypedConstant? key = item.GetAttributes().FirstOrDefault(x => x.AttributeClass.ApproximatelyEqual(this.typeReferences.KeyAttribute))?.ConstructorArguments[0]; if (key is null) { if (contractAttr is not null) { - diagnostics.Add(Diagnostic.Create(PublicMemberNeedsKey, item.DeclaringSyntaxReferences[0].GetSyntax().GetLocation(), type.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat), item.Name)); + this.reportDiagnostic?.Invoke(Diagnostic.Create(MsgPack00xMessagePackAnalyzer.PublicMemberNeedsKey, item.DeclaringSyntaxReferences[0].GetSyntax().GetLocation(), type.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat), item.Name)); } } else @@ -1032,9 +1033,14 @@ private void CollectObject(INamedTypeSymbol type) needsCastOnAfter = !type.GetMembers("OnAfterDeserialize").Any(); } + if (contractAttr is null) + { + // Indicate to our caller that we don't have a valid object. + return null; + } + ObjectSerializationInfo info = new(isClass, isOpenGenericType, isOpenGenericType ? type.TypeParameters.Select(ToGenericTypeParameterInfo).ToArray() : Array.Empty(), constructorParameters.ToArray(), isIntKey, isIntKey ? intMembers.Values.ToArray() : stringMembers.Values.ToArray(), isOpenGenericType ? GetGenericFormatterClassName(type) : GetMinimallyQualifiedClassName(type), type.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat), type.ContainingNamespace.IsGlobalNamespace ? null : type.ContainingNamespace.ToDisplayString(), hasSerializationConstructor, needsCastOnAfter, needsCastOnBefore) { - Diagnostics = diagnostics, }; return info; diff --git a/src/MessagePack.SourceGenerator/CodeAnalysis/UnionSerializationInfo.cs b/src/MessagePackAnalyzer/CodeAnalysis/UnionSerializationInfo.cs similarity index 94% rename from src/MessagePack.SourceGenerator/CodeAnalysis/UnionSerializationInfo.cs rename to src/MessagePackAnalyzer/CodeAnalysis/UnionSerializationInfo.cs index 598ea2e01..a95b39d8f 100644 --- a/src/MessagePack.SourceGenerator/CodeAnalysis/UnionSerializationInfo.cs +++ b/src/MessagePackAnalyzer/CodeAnalysis/UnionSerializationInfo.cs @@ -1,10 +1,9 @@ // Copyright (c) All contributors. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -using System.Xml.Linq; using Microsoft.CodeAnalysis; -namespace MessagePack.SourceGenerator.CodeAnalysis; +namespace MessagePackAnalyzer.CodeAnalysis; public record UnionSerializationInfo( string? Namespace, diff --git a/src/MessagePack.SourceGenerator/CodeAnalysis/UnionSubTypeInfo.cs b/src/MessagePackAnalyzer/CodeAnalysis/UnionSubTypeInfo.cs similarity index 80% rename from src/MessagePack.SourceGenerator/CodeAnalysis/UnionSubTypeInfo.cs rename to src/MessagePackAnalyzer/CodeAnalysis/UnionSubTypeInfo.cs index 88eaecaa1..2be99b87c 100644 --- a/src/MessagePack.SourceGenerator/CodeAnalysis/UnionSubTypeInfo.cs +++ b/src/MessagePackAnalyzer/CodeAnalysis/UnionSubTypeInfo.cs @@ -1,6 +1,6 @@ // Copyright (c) All contributors. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace MessagePack.SourceGenerator.CodeAnalysis; +namespace MessagePackAnalyzer.CodeAnalysis; public record UnionSubTypeInfo(int Key, string Type); diff --git a/src/MessagePackAnalyzer/MessagePackAnalyzer.cs b/src/MessagePackAnalyzer/MessagePackAnalyzer.cs deleted file mode 100644 index e903c57ad..000000000 --- a/src/MessagePackAnalyzer/MessagePackAnalyzer.cs +++ /dev/null @@ -1,109 +0,0 @@ -// Copyright (c) All contributors. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - -using System.Collections.Immutable; -using System.Linq; -using Microsoft.CodeAnalysis; -using Microsoft.CodeAnalysis.CSharp; -using Microsoft.CodeAnalysis.CSharp.Syntax; -using Microsoft.CodeAnalysis.Diagnostics; - -namespace MessagePackAnalyzer -{ - [DiagnosticAnalyzer(LanguageNames.CSharp)] - public class MessagePackAnalyzer : DiagnosticAnalyzer - { - public const string UseMessagePackObjectAttributeId = "MsgPack003"; - public const string AttributeMessagePackObjectMembersId = "MsgPack004"; - public const string InvalidMessagePackObjectId = "MsgPack005"; - public const string MessagePackFormatterMustBeMessagePackFormatterId = "MsgPack006"; - - internal const string Category = "Usage"; - - internal const string MessagePackObjectAttributeShortName = "MessagePackObjectAttribute"; - internal const string KeyAttributeShortName = "KeyAttribute"; - internal const string IgnoreShortName = "IgnoreMemberAttribute"; - internal const string IgnoreDataMemberShortName = "IgnoreDataMemberAttribute"; - internal const string UnionAttributeShortName = "UnionAttribute"; - - internal static readonly DiagnosticDescriptor TypeMustBeMessagePackObject = new DiagnosticDescriptor( - id: UseMessagePackObjectAttributeId, - title: "Use MessagePackObjectAttribute", - category: Category, - messageFormat: "Type must be marked with MessagePackObjectAttribute. {0}.", // type.Name - description: "Type must be marked with MessagePackObjectAttribute.", - defaultSeverity: DiagnosticSeverity.Error, - isEnabledByDefault: true, - helpLinkUri: AnalyzerUtilities.GetHelpLink(UseMessagePackObjectAttributeId)); - - internal static readonly DiagnosticDescriptor MessageFormatterMustBeMessagePackFormatter = new DiagnosticDescriptor( - id: MessagePackFormatterMustBeMessagePackFormatterId, - title: "Must be IMessageFormatter", - category: Category, - messageFormat: "Type must be of IMessagePackFormatter. {0}.", // type.Name - description: "Type must be of IMessagePackFormatter.", - defaultSeverity: DiagnosticSeverity.Error, - isEnabledByDefault: true, - helpLinkUri: AnalyzerUtilities.GetHelpLink(UseMessagePackObjectAttributeId)); - - internal static readonly DiagnosticDescriptor PublicMemberNeedsKey = new DiagnosticDescriptor( - id: AttributeMessagePackObjectMembersId, - title: "Attribute public members of MessagePack objects", - category: Category, - messageFormat: "Public members of MessagePackObject-attributed types require either KeyAttribute or IgnoreMemberAttribute. {0}.{1}.", // type.Name + "." + item.Name - description: "Public member must be marked with KeyAttribute or IgnoreMemberAttribute.", - defaultSeverity: DiagnosticSeverity.Error, - isEnabledByDefault: true, - helpLinkUri: AnalyzerUtilities.GetHelpLink(AttributeMessagePackObjectMembersId)); - - internal static readonly DiagnosticDescriptor InvalidMessagePackObject = new DiagnosticDescriptor( - id: InvalidMessagePackObjectId, - title: "MessagePackObject validation", - category: Category, - messageFormat: "Invalid MessagePackObject definition: {0}", // details - description: "Invalid MessagePackObject definition.", - defaultSeverity: DiagnosticSeverity.Error, - isEnabledByDefault: true, - helpLinkUri: AnalyzerUtilities.GetHelpLink(InvalidMessagePackObjectId)); - - public override ImmutableArray SupportedDiagnostics { get; } = ImmutableArray.Create( - TypeMustBeMessagePackObject, - PublicMemberNeedsKey, - InvalidMessagePackObject, - MessageFormatterMustBeMessagePackFormatter); - - public override void Initialize(AnalysisContext context) - { - context.EnableConcurrentExecution(); - context.ConfigureGeneratedCodeAnalysis(GeneratedCodeAnalysisFlags.Analyze | GeneratedCodeAnalysisFlags.ReportDiagnostics); - context.RegisterCompilationStartAction(ctxt => - { - if (ReferenceSymbols.TryCreate(ctxt.Compilation, out ReferenceSymbols? typeReferences)) - { - ctxt.RegisterSyntaxNodeAction(c => Analyze(c, typeReferences), SyntaxKind.ClassDeclaration, SyntaxKind.StructDeclaration, SyntaxKind.InterfaceDeclaration); - } - }); - } - - private static void Analyze(SyntaxNodeAnalysisContext context, ReferenceSymbols typeReferences) - { - TypeDeclarationSyntax typeDeclaration = (TypeDeclarationSyntax)context.Node; - INamedTypeSymbol? declaredSymbol = context.SemanticModel.GetDeclaredSymbol(typeDeclaration); - if (declaredSymbol is null) - { - return; - } - - if ( - ((declaredSymbol.TypeKind == TypeKind.Interface) && declaredSymbol.GetAttributes().Any(x2 => SymbolEqualityComparer.Default.Equals(x2.AttributeClass, typeReferences.UnionAttribute))) - || ((declaredSymbol.TypeKind == TypeKind.Class) && declaredSymbol.GetAttributes().Any(x2 => SymbolEqualityComparer.Default.Equals(x2.AttributeClass, typeReferences.MessagePackObjectAttribute))) - || ((declaredSymbol.TypeKind == TypeKind.Struct) && declaredSymbol.GetAttributes().Any(x2 => SymbolEqualityComparer.Default.Equals(x2.AttributeClass, typeReferences.MessagePackObjectAttribute)))) - { - var reportContext = new DiagnosticsReportContext(context); - var collector = new TypeCollector(reportContext, typeReferences); - collector.CollectCore(declaredSymbol); - reportContext.ReportAll(); - } - } - } -} diff --git a/src/MessagePackAnalyzer/MessagePackAnalyzer.csproj b/src/MessagePackAnalyzer/MessagePackAnalyzer.csproj index 18b3579d5..59e1e5ada 100644 --- a/src/MessagePackAnalyzer/MessagePackAnalyzer.csproj +++ b/src/MessagePackAnalyzer/MessagePackAnalyzer.csproj @@ -1,6 +1,7 @@  netstandard2.0 + enable Analyzer of MessagePack for C#, verify rule for [MessagePackObject] and code fix for [Key]. MsgPack;MessagePack;Serialization;Formatter;Analyzer @@ -9,6 +10,8 @@ true false true + + $(CodeAnalysisVersionForUnity) @@ -19,8 +22,10 @@ + + diff --git a/src/MessagePackAnalyzer/MessagePackCodeFixProvider.cs b/src/MessagePackAnalyzer/MessagePackCodeFixProvider.cs index c4b7c1028..f210acc06 100644 --- a/src/MessagePackAnalyzer/MessagePackCodeFixProvider.cs +++ b/src/MessagePackAnalyzer/MessagePackCodeFixProvider.cs @@ -24,8 +24,8 @@ public sealed override ImmutableArray FixableDiagnosticIds get { return ImmutableArray.Create( - MessagePackAnalyzer.PublicMemberNeedsKey.Id, - MessagePackAnalyzer.TypeMustBeMessagePackObject.Id); + MsgPack00xMessagePackAnalyzer.PublicMemberNeedsKey.Id, + MsgPack00xMessagePackAnalyzer.TypeMustBeMessagePackObject.Id); } } @@ -43,18 +43,25 @@ public sealed override async Task RegisterCodeFixesAsync(CodeFixContext context) } SemanticModel? model = await context.Document.GetSemanticModelAsync(context.CancellationToken).ConfigureAwait(false); + if (model is null) + { + return; + } + + SyntaxNode targetNode = root.FindNode(context.Span); + TypeInfo myTypeInfo = model.GetTypeInfo(targetNode, context.CancellationToken); - var typeInfo = context.Diagnostics[0]?.Properties.GetValueOrDefault("type", null); - INamedTypeSymbol? namedSymbol = typeInfo is not null - ? model?.Compilation.GetTypeByMetadataName(typeInfo.Replace("global::", string.Empty)) - : null; + string? typeName = context.Diagnostics[0]?.Properties.GetValueOrDefault("type", null); + INamedTypeSymbol? namedSymbol = + myTypeInfo.Type as INamedTypeSymbol ?? + (typeName is not null ? model.Compilation.GetTypeByMetadataName(typeName.Replace("global::", string.Empty)) : null); if (namedSymbol is null) { - SyntaxNode targetNode = root.FindNode(context.Span); var property = targetNode as PropertyDeclarationSyntax; var field = targetNode as FieldDeclarationSyntax; var dec = targetNode as VariableDeclaratorSyntax; + IdentifierNameSyntax? identifierName = targetNode as IdentifierNameSyntax; ITypeSymbol? targetType = null; if (property == null && field == null) @@ -67,7 +74,7 @@ public sealed override async Task RegisterCodeFixesAsync(CodeFixContext context) else if (dec != null) { var fieldOrProperty = model.GetDeclaredSymbol(dec) as ISymbol; - if (context.Diagnostics[0].Id == MessagePackAnalyzer.TypeMustBeMessagePackObject.Id) + if (context.Diagnostics[0].Id == MsgPack00xMessagePackAnalyzer.TypeMustBeMessagePackObject.Id) { targetType = (fieldOrProperty as IPropertySymbol)?.Type; if (targetType == null) @@ -87,7 +94,7 @@ public sealed override async Task RegisterCodeFixesAsync(CodeFixContext context) } else { - if (context.Diagnostics[0].Id == MessagePackAnalyzer.TypeMustBeMessagePackObject.Id) + if (context.Diagnostics[0].Id == MsgPack00xMessagePackAnalyzer.TypeMustBeMessagePackObject.Id) { targetType = (property != null) ? (model.GetDeclaredSymbol(property) as IPropertySymbol)?.Type @@ -129,7 +136,7 @@ private static async Task AddKeyAttributeAsync(Document document, INam ISymbol[] targets = type.GetAllMembers() .Where(x => x.Kind == SymbolKind.Property || x.Kind == SymbolKind.Field) - .Where(x => x.GetAttributes().FindAttributeShortName(MessagePackAnalyzer.IgnoreShortName) == null && x.GetAttributes().FindAttributeShortName(MessagePackAnalyzer.IgnoreDataMemberShortName) == null) + .Where(x => x.GetAttributes().FindAttributeShortName(MsgPack00xMessagePackAnalyzer.IgnoreShortName) == null && x.GetAttributes().FindAttributeShortName(MsgPack00xMessagePackAnalyzer.IgnoreDataMemberShortName) == null) .Where(x => !x.IsStatic) .Where(x => { @@ -143,7 +150,7 @@ private static async Task AddKeyAttributeAsync(Document document, INam .ToArray(); var startOrder = targets - .Select(x => x.GetAttributes().FindAttributeShortName(MessagePackAnalyzer.KeyAttributeShortName)) + .Select(x => x.GetAttributes().FindAttributeShortName(MsgPack00xMessagePackAnalyzer.KeyAttributeShortName)) .Where(x => x != null) .Select(x => x.ConstructorArguments[0]) .Where(x => !x.IsNull) @@ -154,7 +161,7 @@ private static async Task AddKeyAttributeAsync(Document document, INam foreach (ISymbol member in targets) { - if (member.GetAttributes().FindAttributeShortName(MessagePackAnalyzer.KeyAttributeShortName) is null) + if (member.GetAttributes().FindAttributeShortName(MsgPack00xMessagePackAnalyzer.KeyAttributeShortName) is null) { SyntaxNode node = await member.DeclaringSyntaxReferences[0].GetSyntaxAsync(cancellationToken).ConfigureAwait(false); var documentEditor = await solutionEditor.GetDocumentEditorAsync(document.Project.Solution.GetDocumentId(node.SyntaxTree), cancellationToken).ConfigureAwait(false); @@ -163,7 +170,7 @@ private static async Task AddKeyAttributeAsync(Document document, INam } } - if (type.GetAttributes().FindAttributeShortName(MessagePackAnalyzer.MessagePackObjectAttributeShortName) == null) + if (type.GetAttributes().FindAttributeShortName(MsgPack00xMessagePackAnalyzer.MessagePackObjectAttributeShortName) == null) { SyntaxNode node = await type.DeclaringSyntaxReferences[0].GetSyntaxAsync(cancellationToken).ConfigureAwait(false); var documentEditor = await solutionEditor.GetDocumentEditorAsync(document.Project.Solution.GetDocumentId(node.SyntaxTree), cancellationToken).ConfigureAwait(false); diff --git a/src/MessagePackAnalyzer/MsgPack00xMessagePackAnalyzer.cs b/src/MessagePackAnalyzer/MsgPack00xMessagePackAnalyzer.cs new file mode 100644 index 000000000..597fb3d7a --- /dev/null +++ b/src/MessagePackAnalyzer/MsgPack00xMessagePackAnalyzer.cs @@ -0,0 +1,125 @@ +// Copyright (c) All contributors. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using System.Collections.Immutable; +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.CSharp; +using Microsoft.CodeAnalysis.CSharp.Syntax; +using Microsoft.CodeAnalysis.Diagnostics; + +namespace MessagePackAnalyzer; + +[DiagnosticAnalyzer(LanguageNames.CSharp)] +public class MsgPack00xMessagePackAnalyzer : DiagnosticAnalyzer +{ + public const string UseMessagePackObjectAttributeId = "MsgPack003"; + public const string AttributeMessagePackObjectMembersId = "MsgPack004"; + public const string InvalidMessagePackObjectId = "MsgPack005"; + public const string MessagePackFormatterMustBeMessagePackFormatterId = "MsgPack006"; + + internal const string Category = "Usage"; + + internal const string MessagePackObjectAttributeShortName = "MessagePackObjectAttribute"; + internal const string KeyAttributeShortName = "KeyAttribute"; + internal const string IgnoreShortName = "IgnoreMemberAttribute"; + internal const string IgnoreDataMemberShortName = "IgnoreDataMemberAttribute"; + internal const string UnionAttributeShortName = "UnionAttribute"; + + internal static readonly DiagnosticDescriptor TypeMustBeMessagePackObject = new DiagnosticDescriptor( + id: UseMessagePackObjectAttributeId, + title: "Use MessagePackObjectAttribute", + category: Category, + messageFormat: "Type must be marked with MessagePackObjectAttribute: {0}", // type.Name + description: "Type must be marked with MessagePackObjectAttribute.", + defaultSeverity: DiagnosticSeverity.Error, + isEnabledByDefault: true, + helpLinkUri: AnalyzerUtilities.GetHelpLink(UseMessagePackObjectAttributeId)); + + internal static readonly DiagnosticDescriptor MessageFormatterMustBeMessagePackFormatter = new DiagnosticDescriptor( + id: MessagePackFormatterMustBeMessagePackFormatterId, + title: "Must be IMessageFormatter", + category: Category, + messageFormat: "Type must be of IMessagePackFormatter: {0}", // type.Name + description: "Type must be of IMessagePackFormatter.", + defaultSeverity: DiagnosticSeverity.Error, + isEnabledByDefault: true, + helpLinkUri: AnalyzerUtilities.GetHelpLink(MessagePackFormatterMustBeMessagePackFormatterId)); + + internal static readonly DiagnosticDescriptor PublicMemberNeedsKey = new DiagnosticDescriptor( + id: AttributeMessagePackObjectMembersId, + title: "Attribute public members of MessagePack objects", + category: Category, + messageFormat: "Public members of MessagePackObject-attributed types require either KeyAttribute or IgnoreMemberAttribute: {0}.{1}", // type.Name + "." + item.Name + description: "Public member must be marked with KeyAttribute or IgnoreMemberAttribute.", + defaultSeverity: DiagnosticSeverity.Error, + isEnabledByDefault: true, + helpLinkUri: AnalyzerUtilities.GetHelpLink(AttributeMessagePackObjectMembersId)); + + internal static readonly DiagnosticDescriptor BaseTypeContainsUnattributedPublicMembers = new DiagnosticDescriptor( + id: AttributeMessagePackObjectMembersId, + title: "Attribute public members of MessagePack objects", + category: Category, + messageFormat: "Public members of base types of MessagePackObject-attributed types require either KeyAttribute or IgnoreMemberAttribute: {0}.{1}", // type.Name + "." + item.Name + description: "Public member must be marked with KeyAttribute or IgnoreMemberAttribute.", + defaultSeverity: DiagnosticSeverity.Error, + isEnabledByDefault: true, + helpLinkUri: AnalyzerUtilities.GetHelpLink(AttributeMessagePackObjectMembersId)); + + internal static readonly DiagnosticDescriptor InvalidMessagePackObject = new DiagnosticDescriptor( + id: InvalidMessagePackObjectId, + title: "MessagePackObject validation", + category: Category, + messageFormat: "Invalid MessagePackObject definition: {0}", // details + description: "Invalid MessagePackObject definition.", + defaultSeverity: DiagnosticSeverity.Error, + isEnabledByDefault: true, + helpLinkUri: AnalyzerUtilities.GetHelpLink(InvalidMessagePackObjectId)); + + internal static readonly DiagnosticDescriptor BothStringAndIntKeyAreNull = new DiagnosticDescriptor( + id: InvalidMessagePackObjectId, + title: "Attribute public members of MessagePack objects", + category: Category, + messageFormat: "Both int and string keys are null: {0}.{1}", // type.Name + "." + item.Name + description: "An int or string key must be supplied to the KeyAttribute.", + defaultSeverity: DiagnosticSeverity.Error, + isEnabledByDefault: true, + helpLinkUri: AnalyzerUtilities.GetHelpLink(InvalidMessagePackObjectId)); + + public override ImmutableArray SupportedDiagnostics { get; } = ImmutableArray.Create( + TypeMustBeMessagePackObject, + PublicMemberNeedsKey, + InvalidMessagePackObject, + MessageFormatterMustBeMessagePackFormatter); + + public override void Initialize(AnalysisContext context) + { + context.EnableConcurrentExecution(); + context.ConfigureGeneratedCodeAnalysis(GeneratedCodeAnalysisFlags.Analyze | GeneratedCodeAnalysisFlags.ReportDiagnostics); + context.RegisterCompilationStartAction(ctxt => + { + CodeAnalysis.AnalyzerOptions options = CodeAnalysis.AnalyzerOptions.Parse(ctxt.Options.AnalyzerConfigOptionsProvider.GlobalOptions, ctxt.Options.AdditionalFiles); + if (ReferenceSymbols.TryCreate(ctxt.Compilation, out ReferenceSymbols? typeReferences)) + { + ctxt.RegisterSyntaxNodeAction(c => Analyze(c, typeReferences, options), SyntaxKind.ClassDeclaration, SyntaxKind.StructDeclaration, SyntaxKind.InterfaceDeclaration); + } + }); + } + + private static void Analyze(SyntaxNodeAnalysisContext context, ReferenceSymbols typeReferences, CodeAnalysis.AnalyzerOptions options) + { + TypeDeclarationSyntax typeDeclaration = (TypeDeclarationSyntax)context.Node; + INamedTypeSymbol? declaredSymbol = context.SemanticModel.GetDeclaredSymbol(typeDeclaration); + if (declaredSymbol is null) + { + return; + } + + if ( + ((declaredSymbol.TypeKind == TypeKind.Interface) && declaredSymbol.GetAttributes().Any(x2 => SymbolEqualityComparer.Default.Equals(x2.AttributeClass, typeReferences.UnionAttribute))) + || ((declaredSymbol.TypeKind == TypeKind.Class) && declaredSymbol.GetAttributes().Any(x2 => SymbolEqualityComparer.Default.Equals(x2.AttributeClass, typeReferences.MessagePackObjectAttribute))) + || ((declaredSymbol.TypeKind == TypeKind.Struct) && declaredSymbol.GetAttributes().Any(x2 => SymbolEqualityComparer.Default.Equals(x2.AttributeClass, typeReferences.MessagePackObjectAttribute)))) + { + TypeCollector.Collect(context.Compilation, options, typeReferences, context.ReportDiagnostic, declaredSymbol); + } + } +} diff --git a/src/MessagePackAnalyzer/ReferenceSymbols.cs b/src/MessagePackAnalyzer/ReferenceSymbols.cs deleted file mode 100644 index 6ded9965f..000000000 --- a/src/MessagePackAnalyzer/ReferenceSymbols.cs +++ /dev/null @@ -1,96 +0,0 @@ -// Copyright (c) All contributors. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - -using System.Diagnostics.CodeAnalysis; -using Microsoft.CodeAnalysis; - -namespace MessagePackAnalyzer -{ - public class ReferenceSymbols - { - private ReferenceSymbols( - INamedTypeSymbol messagePackObjectAttribute, - INamedTypeSymbol unionAttribute, - INamedTypeSymbol keyAttribute, - INamedTypeSymbol ignoreAttribute, - INamedTypeSymbol formatterAttribute, - INamedTypeSymbol messagePackFormatter, - INamedTypeSymbol? ignoreDataMemberAttribute) - { - this.MessagePackObjectAttribute = messagePackObjectAttribute; - this.UnionAttribute = unionAttribute; - this.KeyAttribute = keyAttribute; - this.IgnoreAttribute = ignoreAttribute; - this.FormatterAttribute = formatterAttribute; - this.MessagePackFormatter = messagePackFormatter; - this.IgnoreDataMemberAttribute = ignoreDataMemberAttribute; - } - - internal INamedTypeSymbol MessagePackObjectAttribute { get; } - - internal INamedTypeSymbol UnionAttribute { get; } - - internal INamedTypeSymbol KeyAttribute { get; } - - internal INamedTypeSymbol IgnoreAttribute { get; } - - internal INamedTypeSymbol FormatterAttribute { get; } - - internal INamedTypeSymbol MessagePackFormatter { get; } - - internal INamedTypeSymbol? IgnoreDataMemberAttribute { get; } - - public static bool TryCreate(Compilation compilation, [NotNullWhen(true)] out ReferenceSymbols? instance) - { - instance = null; - - var messagePackObjectAttribute = compilation.GetTypeByMetadataName("MessagePack.MessagePackObjectAttribute"); - if (messagePackObjectAttribute is null) - { - return false; - } - - var unionAttribute = compilation.GetTypeByMetadataName("MessagePack.UnionAttribute"); - if (unionAttribute is null) - { - return false; - } - - var keyAttribute = compilation.GetTypeByMetadataName("MessagePack.KeyAttribute"); - if (keyAttribute is null) - { - return false; - } - - var ignoreAttribute = compilation.GetTypeByMetadataName("MessagePack.IgnoreMemberAttribute"); - if (ignoreAttribute is null) - { - return false; - } - - var formatterAttribute = compilation.GetTypeByMetadataName("MessagePack.MessagePackFormatterAttribute"); - if (formatterAttribute is null) - { - return false; - } - - var messageFormatter = compilation.GetTypeByMetadataName("MessagePack.Formatters.IMessagePackFormatter"); - if (messageFormatter is null) - { - return false; - } - - var ignoreDataMemberAttribute = compilation.GetTypeByMetadataName("System.Runtime.Serialization.IgnoreDataMemberAttribute"); - - instance = new ReferenceSymbols( - messagePackObjectAttribute, - unionAttribute, - keyAttribute, - ignoreAttribute, - formatterAttribute, - messageFormatter, - ignoreDataMemberAttribute); - return true; - } - } -} diff --git a/src/MessagePack.SourceGenerator/Transforms/ShouldUseFormatterResolverHelper.cs b/src/MessagePackAnalyzer/Transforms/ShouldUseFormatterResolverHelper.cs similarity index 93% rename from src/MessagePack.SourceGenerator/Transforms/ShouldUseFormatterResolverHelper.cs rename to src/MessagePackAnalyzer/Transforms/ShouldUseFormatterResolverHelper.cs index e6de0a828..7852e3533 100644 --- a/src/MessagePack.SourceGenerator/Transforms/ShouldUseFormatterResolverHelper.cs +++ b/src/MessagePackAnalyzer/Transforms/ShouldUseFormatterResolverHelper.cs @@ -1,9 +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. -using MessagePack.SourceGenerator.CodeAnalysis; - -namespace MessagePack.SourceGenerator.Transforms; +namespace MessagePackAnalyzer.Transforms; public static class ShouldUseFormatterResolverHelper { diff --git a/src/MessagePackAnalyzer/TypeCollector.cs b/src/MessagePackAnalyzer/TypeCollector.cs deleted file mode 100644 index 5f16569a5..000000000 --- a/src/MessagePackAnalyzer/TypeCollector.cs +++ /dev/null @@ -1,419 +0,0 @@ -// Copyright (c) All contributors. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - -using System.Collections.Generic; -using System.Collections.Immutable; -using System.Linq; -using Microsoft.CodeAnalysis; - -namespace MessagePackAnalyzer -{ - internal class TypeCollector - { - private readonly ReferenceSymbols typeReferences; - private static readonly HashSet EmbeddedTypes = new HashSet(new string[] - { - "short", - "int", - "long", - "ushort", - "uint", - "ulong", - "float", - "double", - "bool", - "byte", - "sbyte", - "decimal", - "char", - "System.Guid", - "System.TimeSpan", - "System.DateTime", - "System.DateTimeOffset", - }); - - private static readonly Dictionary KnownGenericTypes = new Dictionary - { - { "System.Collections.Generic.List<>", "global::MessagePack.Formatters.ListFormatter" }, - { "System.Collections.Generic.LinkedList<>", "global::MessagePack.Formatters.LinkedListFormatter" }, - { "System.Collections.Generic.Queue<>", "global::MessagePack.Formatters.QueueFormatter" }, - { "System.Collections.Generic.Stack<>", "global::MessagePack.Formatters.StackFormatter" }, - { "System.Collections.Generic.HashSet<>", "global::MessagePack.Formatters.HashSetFormatter" }, - { "System.Collections.ObjectModel.ReadOnlyCollection<>", "global::MessagePack.Formatters.ReadOnlyCollectionFormatter" }, - { "System.Collections.Generic.IList<>", "global::MessagePack.Formatters.InterfaceListFormatter2" }, - { "System.Collections.Generic.ICollection<>", "global::MessagePack.Formatters.InterfaceCollectionFormatter2" }, - { "System.Collections.Generic.IEnumerable<>", "global::MessagePack.Formatters.InterfaceEnumerableFormatter" }, - { "System.Collections.Generic.Dictionary<,>", "global::MessagePack.Formatters.DictionaryFormatter" }, - { "System.Collections.Generic.IDictionary<,>", "global::MessagePack.Formatters.InterfaceDictionaryFormatter" }, - { "System.Collections.Generic.SortedDictionary<,>", "global::MessagePack.Formatters.SortedDictionaryFormatter" }, - { "System.Collections.Generic.SortedList<,>", "global::MessagePack.Formatters.SortedListFormatter" }, - { "System.Linq.ILookup<,>", "global::MessagePack.Formatters.InterfaceLookupFormatter" }, - { "System.Linq.IGrouping<,>", "global::MessagePack.Formatters.InterfaceGroupingFormatter" }, - { "System.Collections.ObjectModel.ObservableCollection<>", "global::MessagePack.Formatters.ObservableCollectionFormatter" }, - { "System.Collections.ObjectModel.ReadOnlyObservableCollection<>", "global::MessagePack.Formatters.ReadOnlyObservableCollectionFormatter" }, - { "System.Collections.Generic.IReadOnlyList<>", "global::MessagePack.Formatters.InterfaceReadOnlyListFormatter" }, - { "System.Collections.Generic.IReadOnlyCollection<>", "global::MessagePack.Formatters.InterfaceReadOnlyCollectionFormatter" }, - { "System.Collections.Generic.ISet<>", "global::MessagePack.Formatters.InterfaceSetFormatter" }, - { "System.Collections.Concurrent.ConcurrentBag<>", "global::MessagePack.Formatters.ConcurrentBagFormatter" }, - { "System.Collections.Concurrent.ConcurrentQueue<>", "global::MessagePack.Formatters.ConcurrentQueueFormatter" }, - { "System.Collections.Concurrent.ConcurrentStack<>", "global::MessagePack.Formatters.ConcurrentStackFormatter" }, - { "System.Collections.ObjectModel.ReadOnlyDictionary<,>", "global::MessagePack.Formatters.ReadOnlyDictionaryFormatter" }, - { "System.Collections.Generic.IReadOnlyDictionary<,>", "global::MessagePack.Formatters.InterfaceReadOnlyDictionaryFormatter" }, - { "System.Collections.Concurrent.ConcurrentDictionary<,>", "global::MessagePack.Formatters.ConcurrentDictionaryFormatter" }, - { "System.Lazy<>", "global::MessagePack.Formatters.LazyFormatter" }, - { "System.Threading.Tasks<>", "global::MessagePack.Formatters.TaskValueFormatter" }, - /* Tuple */ - { "System.Tuple<>", "global::MessagePack.Formatters.TupleFormatter" }, - { "System.Tuple<,>", "global::MessagePack.Formatters.TupleFormatter" }, - { "System.Tuple<,,>", "global::MessagePack.Formatters.TupleFormatter" }, - { "System.Tuple<,,,>", "global::MessagePack.Formatters.TupleFormatter" }, - { "System.Tuple<,,,,>", "global::MessagePack.Formatters.TupleFormatter" }, - { "System.Tuple<,,,,,>", "global::MessagePack.Formatters.TupleFormatter" }, - { "System.Tuple<,,,,,,>", "global::MessagePack.Formatters.TupleFormatter" }, - { "System.Tuple<,,,,,,,>", "global::MessagePack.Formatters.TupleFormatter" }, - /* ValueTuple */ - { "System.ValueTuple<>", "global::MessagePack.Formatters.ValueTupleFormatter" }, - { "System.ValueTuple<,>", "global::MessagePack.Formatters.ValueTupleFormatter" }, - { "System.ValueTuple<,,>", "global::MessagePack.Formatters.ValueTupleFormatter" }, - { "System.ValueTuple<,,,>", "global::MessagePack.Formatters.ValueTupleFormatter" }, - { "System.ValueTuple<,,,,>", "global::MessagePack.Formatters.ValueTupleFormatter" }, - { "System.ValueTuple<,,,,,>", "global::MessagePack.Formatters.ValueTupleFormatter" }, - { "System.ValueTuple<,,,,,,>", "global::MessagePack.Formatters.ValueTupleFormatter" }, - { "System.ValueTuple<,,,,,,,>", "global::MessagePack.Formatters.ValueTupleFormatter" }, - /* other */ - { "System.Collections.Generic.KeyValuePair<,>", "global::MessagePack.Formatters.KeyValuePairFormatter" }, - { "System.Threading.Tasks.ValueTask<>", "global::MessagePack.Formatters.KeyValuePairFormatter" }, - { "System.ArraySegment<>", "global::MessagePack.Formatters.ArraySegmentFormatter" }, - - /* extensions */ - { "System.Collections.Immutable.ImmutableArray<>", "global::MessagePack.ImmutableCollection.ImmutableArrayFormatter" }, - { "System.Collections.Immutable.ImmutableList<>", "global::MessagePack.ImmutableCollection.ImmutableListFormatter" }, - { "System.Collections.Immutable.ImmutableDictionary<,>", "global::MessagePack.ImmutableCollection.ImmutableDictionaryFormatter" }, - { "System.Collections.Immutable.ImmutableHashSet<>", "global::MessagePack.ImmutableCollection.ImmutableHashSetFormatter" }, - { "System.Collections.Immutable.ImmutableSortedDictionary<,>", "global::MessagePack.ImmutableCollection.ImmutableSortedDictionaryFormatter" }, - { "System.Collections.Immutable.ImmutableSortedSet<>", "global::MessagePack.ImmutableCollection.ImmutableSortedSetFormatter" }, - { "System.Collections.Immutable.ImmutableQueue<>", "global::MessagePack.ImmutableCollection.ImmutableQueueFormatter" }, - { "System.Collections.Immutable.ImmutableStack<>", "global::MessagePack.ImmutableCollection.ImmutableStackFormatter" }, - { "System.Collections.Immutable.IImmutableList<>", "global::MessagePack.ImmutableCollection.InterfaceImmutableListFormatter" }, - { "System.Collections.Immutable.IImmutableDictionary<,>", "global::MessagePack.ImmutableCollection.InterfaceImmutableDictionaryFormatter" }, - { "System.Collections.Immutable.IImmutableQueue<>", "global::MessagePack.ImmutableCollection.InterfaceImmutableQueueFormatter" }, - { "System.Collections.Immutable.IImmutableSet<>", "global::MessagePack.ImmutableCollection.InterfaceImmutableSetFormatter" }, - { "System.Collections.Immutable.IImmutableStack<>", "global::MessagePack.ImmutableCollection.InterfaceImmutableStackFormatter" }, - /* Reactive bindings */ - { "Reactive.Bindings.ReactiveProperty<>", "global::MessagePack.ReactivePropertyExtension.ReactivePropertyFormatter" }, - { "Reactive.Bindings.IReactiveProperty<>", "global::MessagePack.ReactivePropertyExtension.InterfaceReactivePropertyFormatter" }, - { "Reactive.Bindings.IReadOnlyReactiveProperty<>", "global::MessagePack.ReactivePropertyExtension.InterfaceReadOnlyReactivePropertyFormatter" }, - { "Reactive.Bindings.ReactiveCollection<>", "global::MessagePack.ReactivePropertyExtension.ReactiveCollectionFormatter" }, - }; - - private HashSet alreadyCollected = new HashSet(SymbolEqualityComparer.Default); - - public DiagnosticsReportContext ReportContext { get; set; } - - public TypeCollector(DiagnosticsReportContext reportContext, ReferenceSymbols typeReferences) - { - this.typeReferences = typeReferences; - this.ReportContext = reportContext; - } - - // Gate of recursive collect - public void CollectCore(ITypeSymbol typeSymbol, ISymbol? callerSymbol = null) - { - if (typeSymbol.TypeKind == TypeKind.Array) - { - var array = (IArrayTypeSymbol)typeSymbol; - ITypeSymbol t = array.ElementType; - this.CollectCore(t, callerSymbol); - return; - } - - var type = typeSymbol as INamedTypeSymbol; - - if (type == null) - { - return; - } - - if (!this.alreadyCollected.Add(typeSymbol)) - { - return; - } - - if (EmbeddedTypes.Contains(type.ToString())) - { - return; - } - - if (this.ReportContext.AdditionalAllowTypes.Contains(type.ToDisplayString())) - { - return; - } - - if (type.TypeKind == TypeKind.Enum) - { - return; - } - - if (type.IsGenericType) - { - foreach (ITypeSymbol item in type.TypeArguments) - { - this.CollectCore(item, callerSymbol); - } - - return; - } - - if (type.Locations[0].IsInMetadata) - { - return; - } - - if (type.TypeKind == TypeKind.Interface) - { - return; - } - - // only do object:) - this.CollectObject(type, callerSymbol); - return; - } - - private void CollectObject(INamedTypeSymbol type, ISymbol? callerSymbol) - { - var isClass = !type.IsValueType; - - AttributeData? formatterAttr = type.GetAttributes().FirstOrDefault(x => SymbolEqualityComparer.Default.Equals(x.AttributeClass, this.typeReferences.FormatterAttribute)); - if (formatterAttr is not null && formatterAttr.ConstructorArguments[0].Value is ITypeSymbol formatterType) - { - // Validate that the typed formatter is actually of `IMessagePackFormatter` - bool isMessagePackFormatter = formatterType.AllInterfaces.Any(x => SymbolEqualityComparer.Default.Equals(x, this.typeReferences.MessagePackFormatter)) is true; - if (!isMessagePackFormatter) - { - var location = formatterAttr.ApplicationSyntaxReference?.SyntaxTree.GetLocation(formatterAttr.ApplicationSyntaxReference.Span); - var typeInfo = ImmutableDictionary.Create().Add("type", formatterType.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat)); - this.ReportContext.Add(Diagnostic.Create(MessagePackAnalyzer.MessageFormatterMustBeMessagePackFormatter, location, typeInfo)); - } - - return; - } - - AttributeData? contractAttr = type.GetAttributes().FirstOrDefault(x => SymbolEqualityComparer.Default.Equals(x.AttributeClass, this.typeReferences.MessagePackObjectAttribute)); - if (contractAttr == null) - { - Location location = callerSymbol != null ? callerSymbol.Locations[0] : type.Locations[0]; - var targetName = callerSymbol != null ? callerSymbol.ContainingType.Name + "." + callerSymbol.Name : type.Name; - - ImmutableDictionary typeInfo = ImmutableDictionary.Create().Add("type", type.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat)); - this.ReportContext.Add(Diagnostic.Create(MessagePackAnalyzer.TypeMustBeMessagePackObject, location, typeInfo, targetName)); - return; - } - - var isIntKey = true; - var intMembers = new HashSet(); - var stringMembers = new HashSet(); - - if (contractAttr.ConstructorArguments[0].Value is true) - { - // Opt-out: All public members are serialize target except [Ignore] member. - isIntKey = false; - - foreach (IPropertySymbol item in type.GetAllMembers().OfType()) - { - if (item.GetAttributes().Any(x => SymbolEqualityComparer.Default.Equals(x.AttributeClass, this.typeReferences.IgnoreAttribute) || (this.typeReferences.IgnoreDataMemberAttribute is not null && SymbolEqualityComparer.Default.Equals(x.AttributeClass, this.typeReferences.IgnoreDataMemberAttribute)))) - { - continue; - } - - var isReadable = (item.GetMethod != null) && item.GetMethod.DeclaredAccessibility == Accessibility.Public && !item.IsStatic; - var isWritable = (item.SetMethod != null) && item.SetMethod.DeclaredAccessibility == Accessibility.Public && !item.IsStatic; - - if (!isReadable && !isWritable) - { - continue; - } - - stringMembers.Add(item.Name); - this.CollectCore(item.Type, item); // recursive collect - } - - foreach (IFieldSymbol item in type.GetAllMembers().OfType()) - { - if (item.GetAttributes().Any(x => SymbolEqualityComparer.Default.Equals(x.AttributeClass, this.typeReferences.IgnoreAttribute) || (this.typeReferences.IgnoreDataMemberAttribute is not null && SymbolEqualityComparer.Default.Equals(x.AttributeClass, this.typeReferences.IgnoreDataMemberAttribute)))) - { - continue; - } - - if (item.IsImplicitlyDeclared) - { - continue; - } - - var isReadable = item.DeclaredAccessibility == Accessibility.Public && !item.IsStatic; - var isWritable = item.DeclaredAccessibility == Accessibility.Public && !item.IsReadOnly && !item.IsStatic; - - if (!isReadable && !isWritable) - { - continue; - } - - stringMembers.Add(item.Name); - this.CollectCore(item.Type, item); // recursive collect - } - } - else - { - // Opt-in: Only KeyAttribute members - var searchFirst = true; - - foreach (IPropertySymbol item in type.GetAllMembers().OfType()) - { - if (item.GetAttributes().Any(x => SymbolEqualityComparer.Default.Equals(x.AttributeClass, this.typeReferences.IgnoreAttribute) || (this.typeReferences.IgnoreDataMemberAttribute is not null && SymbolEqualityComparer.Default.Equals(x.AttributeClass, this.typeReferences.IgnoreDataMemberAttribute)))) - { - continue; - } - - var isReadable = (item.GetMethod != null) && item.GetMethod.DeclaredAccessibility == Accessibility.Public && !item.IsStatic; - var isWritable = (item.SetMethod != null) && item.SetMethod.DeclaredAccessibility == Accessibility.Public && !item.IsStatic; - var name = item.Name; - if (!isReadable && !isWritable) - { - continue; - } - - TypedConstant? key = item.GetAttributes().FirstOrDefault(x => SymbolEqualityComparer.Default.Equals(x.AttributeClass, this.typeReferences.KeyAttribute))?.ConstructorArguments[0]; - if (key == null) - { - ImmutableDictionary typeInfo = ImmutableDictionary.Create().Add("type", type.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat)); - this.ReportContext.Add(Diagnostic.Create(MessagePackAnalyzer.PublicMemberNeedsKey, item.Locations[0], typeInfo, type.Name, item.Name)); - continue; - } - - var intKey = (key.Value.Value is int) ? (int)key.Value.Value : (int?)null; - var stringKey = (key.Value.Value is string) ? (string)key.Value.Value : null; - if (intKey == null && stringKey == null) - { - this.ReportInvalid(item, "both IntKey and StringKey are null." + " type: " + type.Name + " member:" + item.Name); - break; - } - - if (searchFirst) - { - searchFirst = false; - isIntKey = intKey != null; - } - else - { - if ((isIntKey && intKey == null) || (!isIntKey && stringKey == null)) - { - this.ReportInvalid(item, "all members key type must be same." + " type: " + type.Name + " member:" + item.Name); - break; - } - } - - if (isIntKey) - { - if (intMembers.Contains(intKey!.Value)) - { - this.ReportInvalid(item, "key is duplicated, all members key must be unique." + " type: " + type.Name + " member:" + item.Name); - return; - } - - intMembers.Add((int)intKey); - } - else - { - if (stringMembers.Contains(stringKey!)) - { - this.ReportInvalid(item, "key is duplicated, all members key must be unique." + " type: " + type.Name + " member:" + item.Name); - return; - } - - stringMembers.Add(stringKey!); - } - - this.CollectCore(item.Type, item); // recursive collect - } - - foreach (IFieldSymbol item in type.GetAllMembers().OfType()) - { - if (item.GetAttributes().Any(x => SymbolEqualityComparer.Default.Equals(x.AttributeClass, this.typeReferences.IgnoreAttribute) || (this.typeReferences.IgnoreDataMemberAttribute is not null && SymbolEqualityComparer.Default.Equals(x.AttributeClass, this.typeReferences.IgnoreDataMemberAttribute)))) - { - continue; - } - - if (item.IsImplicitlyDeclared) - { - continue; - } - - var isReadable = item.DeclaredAccessibility == Accessibility.Public && !item.IsStatic; - var isWritable = item.DeclaredAccessibility == Accessibility.Public && !item.IsReadOnly && !item.IsStatic; - var name = item.Name; - if (!isReadable && !isWritable) - { - continue; - } - - TypedConstant? key = item.GetAttributes().FirstOrDefault(x => SymbolEqualityComparer.Default.Equals(x.AttributeClass, this.typeReferences.KeyAttribute))?.ConstructorArguments[0]; - if (key == null) - { - ImmutableDictionary typeInfo = ImmutableDictionary.Create().Add("type", type.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat)); - this.ReportContext.Add(Diagnostic.Create(MessagePackAnalyzer.PublicMemberNeedsKey, item.Locations[0], typeInfo, type.Name, item.Name)); - continue; - } - - var intKey = key.Value.Value is int i ? (int?)i : null; - var stringKey = key.Value.Value as string; - if (intKey == null && stringKey == null) - { - this.ReportInvalid(item, "both IntKey and StringKey are null." + " type: " + type.Name + " member:" + item.Name); - return; - } - - if (searchFirst) - { - searchFirst = false; - isIntKey = intKey != null; - } - else - { - if ((isIntKey && intKey == null) || (!isIntKey && stringKey == null)) - { - this.ReportInvalid(item, "all members key type must be same." + " type: " + type.Name + " member:" + item.Name); - return; - } - } - - if (intKey.HasValue) - { - if (intMembers.Contains(intKey.Value)) - { - this.ReportInvalid(item, "key is duplicated, all members key must be unique." + " type: " + type.Name + " member:" + item.Name); - return; - } - - intMembers.Add(intKey.Value); - } - else if (stringKey is object) - { - if (stringMembers.Contains(stringKey)) - { - this.ReportInvalid(item, "key is duplicated, all members key must be unique." + " type: " + type.Name + " member:" + item.Name); - return; - } - - stringMembers.Add(stringKey); - } - - this.CollectCore(item.Type, item); // recursive collect - } - } - } - - private void ReportInvalid(ISymbol symbol, string message) - { - this.ReportContext.Add(Diagnostic.Create(MessagePackAnalyzer.InvalidMessagePackObject, symbol.Locations[0], message)); - } - } -} diff --git a/src/MessagePackAnalyzer/Usings.cs b/src/MessagePackAnalyzer/Usings.cs new file mode 100644 index 000000000..303bcb34f --- /dev/null +++ b/src/MessagePackAnalyzer/Usings.cs @@ -0,0 +1,4 @@ +// Copyright (c) All contributors. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +global using MessagePackAnalyzer.CodeAnalysis; diff --git a/src/MessagePackAnalyzer/Utils/AnalyzerUtilities.cs b/src/MessagePackAnalyzer/Utils/AnalyzerUtilities.cs new file mode 100644 index 000000000..9e423f2fd --- /dev/null +++ b/src/MessagePackAnalyzer/Utils/AnalyzerUtilities.cs @@ -0,0 +1,9 @@ +// Copyright (c) All contributors. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +namespace MessagePackAnalyzer; + +internal static class AnalyzerUtilities +{ + internal static string GetHelpLink(string diagnosticId) => $"https://github.com/neuecc/MessagePack-CSharp/blob/master/doc/analyzers/{diagnosticId}.md"; +} diff --git a/src/MessagePackAnalyzer/Utils/ConfigurationLoader.cs b/src/MessagePackAnalyzer/Utils/ConfigurationLoader.cs deleted file mode 100644 index 60b7da6d2..000000000 --- a/src/MessagePackAnalyzer/Utils/ConfigurationLoader.cs +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright (c) All contributors. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Microsoft.CodeAnalysis.Diagnostics; - -namespace MessagePackAnalyzer -{ - public static class ConfigurationLoader - { - public static System.Collections.Generic.IReadOnlyList GetAdditionalAllowTypes(this AnalyzerOptions option) - { - Microsoft.CodeAnalysis.AdditionalText? config = option.AdditionalFiles.FirstOrDefault(x => System.IO.Path.GetFileName(x.Path).Equals("MessagePackAnalyzer.json", StringComparison.OrdinalIgnoreCase)); - if (config != null) - { - try - { - var l = new List(); - var raw = config.GetText()?.ToString() ?? string.Empty; - using (var sr = new StringReader(raw)) - using (var tr = new TinyJsonReader(sr)) - { - while (tr.Read()) - { - if (tr.TokenType == TinyJsonToken.String) - { - l.Add((string)tr.Value!); - } - } - } - - return l; - } - catch (Exception ex) - { - System.Diagnostics.Debug.WriteLine("Can't load MessagePackAnalyzer.json:" + ex.ToString()); - return Array.Empty(); - } - } - else - { - return Array.Empty(); - } - } - } -} diff --git a/src/MessagePackAnalyzer/Utils/DiagnosticsReportContext.cs b/src/MessagePackAnalyzer/Utils/DiagnosticsReportContext.cs deleted file mode 100644 index 633440670..000000000 --- a/src/MessagePackAnalyzer/Utils/DiagnosticsReportContext.cs +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright (c) All contributors. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Microsoft.CodeAnalysis; -using Microsoft.CodeAnalysis.CodeFixes; -using Microsoft.CodeAnalysis.Diagnostics; - -namespace MessagePackAnalyzer -{ - // Store multiple errors. - internal class DiagnosticsReportContext - { - private readonly List diagnostics = new List(); - private readonly SyntaxNodeAnalysisContext context; - - public IReadOnlyList Diagnostics => this.diagnostics; - - public IReadOnlyList AdditionalAllowTypes { get; } - - public DiagnosticsReportContext(SyntaxNodeAnalysisContext context) - { - this.context = context; - this.AdditionalAllowTypes = this.context.Options.GetAdditionalAllowTypes(); - } - - public void Add(Diagnostic diagnostic) - { - this.diagnostics.Add(diagnostic); - } - - public void ReportAll() - { - foreach (Diagnostic item in this.diagnostics) - { - this.context.ReportDiagnostic(item); - } - } - } -} diff --git a/src/MessagePackAnalyzer/Utils/RoslynAnalyzerExtensions.cs b/src/MessagePackAnalyzer/Utils/RoslynAnalyzerExtensions.cs index d682330e4..2583b5412 100644 --- a/src/MessagePackAnalyzer/Utils/RoslynAnalyzerExtensions.cs +++ b/src/MessagePackAnalyzer/Utils/RoslynAnalyzerExtensions.cs @@ -1,123 +1,126 @@ // Copyright (c) All contributors. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Xml.Linq; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp.Syntax; -namespace MessagePackAnalyzer +namespace MessagePackAnalyzer; + +public static class RoslynAnalyzerExtensions { - // Utility and Extension methods for Roslyn - internal static class RoslynAnalyzerExtensions + public static bool ApproximatelyEqual(this INamedTypeSymbol? left, INamedTypeSymbol? right) { - public static IEnumerable EnumerateBaseType(this ITypeSymbol symbol) + if (left is IErrorTypeSymbol || right is IErrorTypeSymbol) { - INamedTypeSymbol? t = symbol.BaseType; - while (t != null) - { - yield return t; - t = t.BaseType; - } + return left?.ToDisplayString() == right?.ToDisplayString(); } - - public static AttributeData FindAttribute(this IEnumerable attributeDataList, string typeName) + else { - return attributeDataList - .Where(x => x.AttributeClass?.ToDisplayString() == typeName) - .FirstOrDefault(); + return SymbolEqualityComparer.Default.Equals(left, right); } + } - public static AttributeData FindAttributeShortName(this IEnumerable attributeDataList, string typeName) + public static IEnumerable EnumerateBaseType(this ITypeSymbol symbol) + { + INamedTypeSymbol? t = symbol.BaseType; + while (t != null) { - return attributeDataList - .Where(x => x.AttributeClass?.Name == typeName) - .FirstOrDefault(); + yield return t; + t = t.BaseType; } + } + + public static AttributeData FindAttribute(this IEnumerable attributeDataList, string typeName) + { + return attributeDataList + .Where(x => x.AttributeClass?.ToDisplayString() == typeName) + .FirstOrDefault(); + } - public static AttributeData? FindAttributeIncludeBasePropertyShortName(this IPropertySymbol property, string typeName) + public static AttributeData FindAttributeShortName(this IEnumerable attributeDataList, string typeName) + { + return attributeDataList + .Where(x => x.AttributeClass?.Name == typeName) + .FirstOrDefault(); + } + + public static AttributeData? FindAttributeIncludeBasePropertyShortName(this IPropertySymbol property, string typeName) + { + IPropertySymbol? loopingProperty = property; + do { - IPropertySymbol? loopingProperty = property; - do + AttributeData data = FindAttributeShortName(loopingProperty.GetAttributes(), typeName); + if (data != null) { - AttributeData data = FindAttributeShortName(loopingProperty.GetAttributes(), typeName); - if (data != null) - { - return data; - } - - loopingProperty = loopingProperty.OverriddenProperty; + return data; } - while (loopingProperty != null); - return null; + loopingProperty = loopingProperty.OverriddenProperty; } + while (loopingProperty != null); - public static AttributeSyntax FindAttribute(this BaseTypeDeclarationSyntax typeDeclaration, SemanticModel model, string typeName) - { - return typeDeclaration.AttributeLists - .SelectMany(x => x.Attributes) - .Where(x => model.GetTypeInfo(x).Type?.ToDisplayString() == typeName) - .FirstOrDefault(); - } + return null; + } - public static INamedTypeSymbol FindBaseTargetType(this ITypeSymbol symbol, string typeName) - { - return symbol.EnumerateBaseType() - .Where(x => x.OriginalDefinition?.ToDisplayString() == typeName) - .FirstOrDefault(); - } + public static AttributeSyntax FindAttribute(this BaseTypeDeclarationSyntax typeDeclaration, SemanticModel model, string typeName) + { + return typeDeclaration.AttributeLists + .SelectMany(x => x.Attributes) + .Where(x => model.GetTypeInfo(x).Type?.ToDisplayString() == typeName) + .FirstOrDefault(); + } + + public static INamedTypeSymbol FindBaseTargetType(this ITypeSymbol symbol, string typeName) + { + return symbol.EnumerateBaseType() + .Where(x => x.OriginalDefinition?.ToDisplayString() == typeName) + .FirstOrDefault(); + } - public static object? GetSingleNamedArgumentValue(this AttributeData attribute, string key) + public static object? GetSingleNamedArgumentValue(this AttributeData attribute, string key) + { + foreach (KeyValuePair item in attribute.NamedArguments) { - foreach (KeyValuePair item in attribute.NamedArguments) + if (item.Key == key) { - if (item.Key == key) - { - return item.Value.Value; - } + return item.Value.Value; } - - return null; } - public static bool IsNullable(this INamedTypeSymbol symbol) + return null; + } + + public static bool IsNullable(this INamedTypeSymbol symbol) + { + if (symbol.IsGenericType) { - if (symbol.IsGenericType) + if (symbol.ConstructUnboundGenericType().ToDisplayString() == "T?") { - if (symbol.ConstructUnboundGenericType().ToDisplayString() == "T?") - { - return true; - } + return true; } - - return false; } - public static IEnumerable GetAllMembers(this ITypeSymbol symbol) + return false; + } + + public static IEnumerable GetAllMembers(this ITypeSymbol symbol) + { + ITypeSymbol? t = symbol; + while (t != null) { - ITypeSymbol? t = symbol; - while (t != null) + foreach (ISymbol item in t.GetMembers()) { - foreach (ISymbol item in t.GetMembers()) - { - yield return item; - } - - t = t.BaseType; + yield return item; } - } - public static IEnumerable GetAllInterfaceMembers(this ITypeSymbol symbol) - { - return symbol.GetMembers() - .Concat(symbol.AllInterfaces.SelectMany(x => x.GetMembers())); + t = t.BaseType; } } + + public static IEnumerable GetAllInterfaceMembers(this ITypeSymbol symbol) + { + return symbol.GetMembers() + .Concat(symbol.AllInterfaces.SelectMany(x => x.GetMembers())); + } } diff --git a/src/MessagePackAnalyzer/Utils/TinyJsonReader.cs b/src/MessagePackAnalyzer/Utils/TinyJsonReader.cs deleted file mode 100644 index aab8bee7d..000000000 --- a/src/MessagePackAnalyzer/Utils/TinyJsonReader.cs +++ /dev/null @@ -1,669 +0,0 @@ -// Copyright (c) All contributors. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - -using System; -using System.Collections; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.IO; -using System.Reflection; -using System.Text; - -/* TinyJson is handmade Json reader/writer library. - * It no needs JSON.NET dependency. */ - -#pragma warning disable SA1402 // File may only contain a single type -#pragma warning disable SA1649 // File name should match first type name - -namespace MessagePackAnalyzer -{ - public class TinyJsonException : Exception - { - public TinyJsonException(string message) - : base(message) - { - } - } - - public class KnownTypeSerializer - { - private readonly Dictionary> serializers = new Dictionary>(); - private readonly Dictionary> deserializers = new Dictionary>(); - - public static readonly KnownTypeSerializer Default = new KnownTypeSerializer(); - - public KnownTypeSerializer() - { - this.serializers.Add(typeof(DateTime), x => ((DateTime)x).ToString("o")); - this.deserializers.Add(typeof(DateTime), x => DateTime.Parse(x)); - this.serializers.Add(typeof(DateTimeOffset), x => ((DateTimeOffset)x).ToString("o")); - this.deserializers.Add(typeof(DateTimeOffset), x => DateTimeOffset.Parse(x)); - this.serializers.Add(typeof(Uri), x => ((Uri)x).ToString()); - this.deserializers.Add(typeof(Uri), x => new Uri(x)); - this.serializers.Add(typeof(Guid), x => ((Guid)x).ToString()); - this.deserializers.Add(typeof(Guid), x => new Guid(x)); - } - - public bool Contains(Type type) - { - return this.serializers.ContainsKey(type); - } - - public void Register(Type type, Func serializer, Func deserializer) - { - this.serializers[type] = serializer; - this.deserializers[type] = deserializer; - } - - public bool TrySerialize(Type type, object obj, [NotNullWhen(true)] out string? result) - { - if (type != null && this.serializers.TryGetValue(type, out Func? serializer)) - { - result = serializer(obj); - return true; - } - else - { - result = null; - return false; - } - } - - public bool TryDeserialize(Type type, string json, out object? result) - { - if (type != null && this.deserializers.TryGetValue(type, out Func? deserializer)) - { - result = deserializer(json); - return true; - } - else - { - result = null; - return false; - } - } - } - - public enum TinyJsonToken - { - None, - StartObject, // { - EndObject, // } - StartArray, // [ - EndArray, // ] - Number, // -0~9 - String, // "___" - True, // true - False, // false - Null, // null - } - - public class TinyJsonReader : IDisposable - { - private readonly TextReader reader; - private readonly bool disposeInnerReader; - - public TinyJsonToken TokenType { get; private set; } - - public object? Value { get; private set; } - - public TinyJsonReader(TextReader reader, bool disposeInnerReader = true) - { - this.reader = reader; - this.disposeInnerReader = disposeInnerReader; - } - - public bool Read() - { - this.ReadNextToken(); - this.ReadValue(); - return this.TokenType != TinyJsonToken.None; - } - - public void Dispose() - { - if (this.reader != null && this.disposeInnerReader) - { - this.reader.Dispose(); - } - - this.TokenType = TinyJsonToken.None; - this.Value = null; - } - - private void SkipWhiteSpace() - { - var c = this.reader.Peek(); - while (c != -1 && Char.IsWhiteSpace((char)c)) - { - this.reader.Read(); - c = this.reader.Peek(); - } - } - - private char ReadChar() - { - return (char)this.reader.Read(); - } - - private static bool IsWordBreak(char c) - { - switch (c) - { - case ' ': - case '{': - case '}': - case '[': - case ']': - case ',': - case ':': - case '\"': - return true; - default: - return false; - } - } - - private void ReadNextToken() - { - this.SkipWhiteSpace(); - - var intChar = this.reader.Peek(); - if (intChar == -1) - { - this.TokenType = TinyJsonToken.None; - return; - } - - var c = (char)intChar; - switch (c) - { - case '{': - this.TokenType = TinyJsonToken.StartObject; - return; - case '}': - this.TokenType = TinyJsonToken.EndObject; - return; - case '[': - this.TokenType = TinyJsonToken.StartArray; - return; - case ']': - this.TokenType = TinyJsonToken.EndArray; - return; - case '"': - this.TokenType = TinyJsonToken.String; - return; - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - case '-': - this.TokenType = TinyJsonToken.Number; - return; - case 't': - this.TokenType = TinyJsonToken.True; - return; - case 'f': - this.TokenType = TinyJsonToken.False; - return; - case 'n': - this.TokenType = TinyJsonToken.Null; - return; - case ',': - case ':': - this.reader.Read(); - this.ReadNextToken(); - return; - default: - throw new TinyJsonException("Invalid String:" + c); - } - } - - private void ReadValue() - { - this.Value = null; - - switch (this.TokenType) - { - case TinyJsonToken.None: - break; - case TinyJsonToken.StartObject: - case TinyJsonToken.EndObject: - case TinyJsonToken.StartArray: - case TinyJsonToken.EndArray: - this.reader.Read(); - break; - case TinyJsonToken.Number: - this.ReadNumber(); - break; - case TinyJsonToken.String: - this.ReadString(); - break; - case TinyJsonToken.True: - if (this.ReadChar() != 't') - { - throw new TinyJsonException("Invalid Token"); - } - - if (this.ReadChar() != 'r') - { - throw new TinyJsonException("Invalid Token"); - } - - if (this.ReadChar() != 'u') - { - throw new TinyJsonException("Invalid Token"); - } - - if (this.ReadChar() != 'e') - { - throw new TinyJsonException("Invalid Token"); - } - - this.Value = true; - break; - case TinyJsonToken.False: - if (this.ReadChar() != 'f') - { - throw new TinyJsonException("Invalid Token"); - } - - if (this.ReadChar() != 'a') - { - throw new TinyJsonException("Invalid Token"); - } - - if (this.ReadChar() != 'l') - { - throw new TinyJsonException("Invalid Token"); - } - - if (this.ReadChar() != 's') - { - throw new TinyJsonException("Invalid Token"); - } - - if (this.ReadChar() != 'e') - { - throw new TinyJsonException("Invalid Token"); - } - - this.Value = false; - break; - case TinyJsonToken.Null: - if (this.ReadChar() != 'n') - { - throw new TinyJsonException("Invalid Token"); - } - - if (this.ReadChar() != 'u') - { - throw new TinyJsonException("Invalid Token"); - } - - if (this.ReadChar() != 'l') - { - throw new TinyJsonException("Invalid Token"); - } - - if (this.ReadChar() != 'l') - { - throw new TinyJsonException("Invalid Token"); - } - - this.Value = null; - break; - default: - throw new ArgumentException("InvalidTokenState:" + this.TokenType); - } - } - - private void ReadNumber() - { - var numberWord = new StringBuilder(); - - var isDouble = false; - var intChar = this.reader.Peek(); - while (intChar != -1 && !IsWordBreak((char)intChar)) - { - var c = this.ReadChar(); - numberWord.Append(c); - if (c == '.') - { - isDouble = true; - } - - intChar = this.reader.Peek(); - } - - var number = numberWord.ToString(); - if (isDouble) - { - double parsedDouble; - Double.TryParse(number, out parsedDouble); - this.Value = parsedDouble; - } - else - { - long parsedInt; - if (Int64.TryParse(number, out parsedInt)) - { - this.Value = parsedInt; - return; - } - - ulong parsedULong; - if (ulong.TryParse(number, out parsedULong)) - { - this.Value = parsedULong; - return; - } - - Decimal parsedDecimal; - if (decimal.TryParse(number, out parsedDecimal)) - { - this.Value = parsedDecimal; - return; - } - } - } - - private void ReadString() - { - this.reader.Read(); // skip ["] - - var sb = new StringBuilder(); - while (true) - { - if (this.reader.Peek() == -1) - { - throw new TinyJsonException("Invalid Json String"); - } - - var c = this.ReadChar(); - switch (c) - { - case '"': // endtoken - goto END; - case '\\': // escape character - if (this.reader.Peek() == -1) - { - throw new TinyJsonException("Invalid Json String"); - } - - c = this.ReadChar(); - switch (c) - { - case '"': - case '\\': - case '/': - sb.Append(c); - break; - case 'b': - sb.Append('\b'); - break; - case 'f': - sb.Append('\f'); - break; - case 'n': - sb.Append('\n'); - break; - case 'r': - sb.Append('\r'); - break; - case 't': - sb.Append('\t'); - break; - case 'u': - var hex = new char[4]; - hex[0] = this.ReadChar(); - hex[1] = this.ReadChar(); - hex[2] = this.ReadChar(); - hex[3] = this.ReadChar(); - sb.Append((char)Convert.ToInt32(new string(hex), 16)); - break; - } - - break; - default: // string - sb.Append(c); - break; - } - } - -END: - this.Value = sb.ToString(); - } - } - - public class TinyJsonWriter : IDisposable - { - private enum WritingState - { - Value, - ArrayStart, - ObjectStart, - Array, - Object, - ObjectPropertyName, - } - - private readonly TextWriter writer; - private readonly Stack state; - private readonly bool disposeInnerWriter; - - public TinyJsonWriter(TextWriter writer, bool disposeInnerWriter = true) - { - this.writer = writer; - this.disposeInnerWriter = disposeInnerWriter; - this.state = new Stack(); - this.state.Push(WritingState.Value); - } - - public void WriteStartObject() - { - this.WritePrefix(); - this.writer.Write('{'); - this.state.Push(WritingState.ObjectStart); - } - - public void WriteEndObject() - { - this.writer.Write('}'); - this.state.Pop(); - } - - public void WriteStartArray() - { - this.WritePrefix(); - this.writer.Write('['); - this.state.Push(WritingState.ArrayStart); - } - - public void WriteEndArray() - { - this.writer.Write(']'); - this.state.Pop(); - } - - public void WritePropertyName(string name) - { - this.WritePrefix(); - this.state.Push(WritingState.ObjectPropertyName); - this.WriteString(name); - } - - public void WriteValue(object obj) - { - this.WriteValue(obj, KnownTypeSerializer.Default); - } - - public void WriteValue(object obj, KnownTypeSerializer serializer) - { - this.WritePrefix(); - - // write value - if (obj == null) - { - this.writer.Write("null"); - } - else if (obj is string) - { - this.WriteString((string)obj); - } - else if (obj is bool) - { - this.writer.Write(((bool)obj) ? "true" : "false"); - } - else - { - Type t = obj.GetType(); - if (t.GetTypeInfo().IsEnum) - { - var eValue = Convert.ChangeType(obj, Enum.GetUnderlyingType(t)); - this.writer.Write(eValue); // Enum as WriteNumber - return; - } - - if (t == typeof(sbyte)) - { - this.writer.Write((sbyte)obj); - } - else if (t == typeof(byte)) - { - this.writer.Write((byte)obj); - } - else if (t == typeof(Int16)) - { - this.writer.Write((Int16)obj); - } - else if (t == typeof(UInt16)) - { - this.writer.Write((UInt16)obj); - } - else if (t == typeof(Int32)) - { - this.writer.Write((Int32)obj); - } - else if (t == typeof(UInt32)) - { - this.writer.Write((UInt32)obj); - } - else if (t == typeof(Int64)) - { - this.writer.Write((Int64)obj); - } - else if (t == typeof(UInt64)) - { - this.writer.Write((UInt64)obj); - } - else if (t == typeof(Single)) - { - this.writer.Write((Single)obj); - } - else if (t == typeof(Double)) - { - this.writer.Write((Double)obj); - } - else if (t == typeof(Decimal)) - { - this.writer.Write((Decimal)obj); - } - else - { - string? result; - if (serializer.TrySerialize(t, obj, out result)) - { - this.WriteString(result); - } - else - { - this.WriteString(obj.ToString() ?? string.Empty); - } - } - } - } - - private void WritePrefix() - { - // write prefix by state - WritingState currentState = this.state.Peek(); - switch (currentState) - { - case WritingState.Value: - break; - case WritingState.ArrayStart: - this.state.Pop(); - this.state.Push(WritingState.Array); - break; - case WritingState.ObjectStart: - this.state.Pop(); - this.state.Push(WritingState.Object); - break; - case WritingState.Array: - case WritingState.Object: - this.writer.Write(','); - break; - case WritingState.ObjectPropertyName: - this.state.Pop(); - this.writer.Write(':'); - break; - default: - break; - } - } - - private void WriteString(string o) - { - this.writer.Write('\"'); - - for (int i = 0; i < o.Length; i++) - { - var c = o[i]; - switch (c) - { - case '"': - this.writer.Write("\\\""); - break; - case '\\': - this.writer.Write("\\\\"); - break; - case '\b': - this.writer.Write("\\b"); - break; - case '\f': - this.writer.Write("\\f"); - break; - case '\n': - this.writer.Write("\\n"); - break; - case '\r': - this.writer.Write("\\r"); - break; - case '\t': - this.writer.Write("\\t"); - break; - default: - this.writer.Write(c); - break; - } - } - - this.writer.Write('\"'); - } - - public void Dispose() - { - if (this.writer != null && this.disposeInnerWriter) - { - this.writer.Dispose(); - } - } - } -} diff --git a/src/SourceGenerator.props b/src/SourceGenerator.props index c0a752887..6fd180d89 100644 --- a/src/SourceGenerator.props +++ b/src/SourceGenerator.props @@ -8,9 +8,14 @@ - - - - + + + + + + + + + diff --git a/tests/MessagePack.SourceGenerator.Tests/GenerationTests.cs b/tests/MessagePack.SourceGenerator.Tests/GenerationTests.cs index 236537715..be98ce9f0 100644 --- a/tests/MessagePack.SourceGenerator.Tests/GenerationTests.cs +++ b/tests/MessagePack.SourceGenerator.Tests/GenerationTests.cs @@ -147,53 +147,22 @@ internal class MyGenericType } [Fact] - public async Task NullStringKey() + public async Task GenericTypeArg() { - string testSource = Preamble + @" -[MessagePackObject] -public class Foo -{ - [Key(null)] - public string {|MsgPack005:Member|} { get; set; } -} -"; - - await VerifyCS.Test.RunDefaultAsync(testSource); - } + string testSource = """ +using MessagePack; +using System; - [Fact] - public async Task MembersNeedAttributes() - { - string testSource = Preamble + @" [MessagePackObject] -public class Foo +public class GenericClass { - public string {|MsgPack004:Member1|} { get; set; } - public string {|MsgPack004:Member2|} { get; set; } -} -"; - - await VerifyCS.Test.RunDefaultAsync(testSource); - } - - [Fact] - public async Task AddAttributeToType() - { - // Don't use Preamble because we want to test that it works without a using statement at the top. - string testSource = @" -public class {|MsgPack003:Foo|} -{ - public string Member { get; set; } -} + [Key(0)] + public T1 MyProperty0 { get; set; } -[MessagePack.MessagePackObject] -public class Bar -{ - [MessagePack.Key(0)] - public Foo Member { get; set; } + [Key(1)] + public T2 MyProperty1 { get; set; } } -"; - +"""; await VerifyCS.Test.RunDefaultAsync(testSource); } } diff --git a/tests/MessagePack.SourceGenerator.Tests/MessagePack.SourceGenerator.Tests.csproj b/tests/MessagePack.SourceGenerator.Tests/MessagePack.SourceGenerator.Tests.csproj index b612b5876..47e33e61b 100644 --- a/tests/MessagePack.SourceGenerator.Tests/MessagePack.SourceGenerator.Tests.csproj +++ b/tests/MessagePack.SourceGenerator.Tests/MessagePack.SourceGenerator.Tests.csproj @@ -31,6 +31,7 @@ + diff --git a/tests/MessagePack.SourceGenerator.Tests/Resources/GenericTypeArg/Formatters.GenericClassFormatter_T1, T2_.g.cs b/tests/MessagePack.SourceGenerator.Tests/Resources/GenericTypeArg/Formatters.GenericClassFormatter_T1, T2_.g.cs new file mode 100644 index 000000000..aeedc3a32 --- /dev/null +++ b/tests/MessagePack.SourceGenerator.Tests/Resources/GenericTypeArg/Formatters.GenericClassFormatter_T1, T2_.g.cs @@ -0,0 +1,58 @@ +// + +#pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 + +namespace Formatters +{ + using MsgPack = global::MessagePack; + + internal sealed class GenericClassFormatter : MsgPack::Formatters.IMessagePackFormatter> + { + + public void Serialize(ref MsgPack::MessagePackWriter writer, global::GenericClass value, MsgPack::MessagePackSerializerOptions options) + { + if (value == null) + { + writer.WriteNil(); + return; + } + + MsgPack::IFormatterResolver formatterResolver = options.Resolver; + writer.WriteArrayHeader(2); + MsgPack::FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Serialize(ref writer, value.MyProperty0, options); + MsgPack::FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Serialize(ref writer, value.MyProperty1, options); + } + + public global::GenericClass Deserialize(ref MsgPack::MessagePackReader reader, MsgPack::MessagePackSerializerOptions options) + { + if (reader.TryReadNil()) + { + return null; + } + + options.Security.DepthStep(ref reader); + MsgPack::IFormatterResolver formatterResolver = options.Resolver; + var length = reader.ReadArrayHeader(); + var ____result = new global::GenericClass(); + + for (int i = 0; i < length; i++) + { + switch (i) + { + case 0: + ____result.MyProperty0 = MsgPack::FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Deserialize(ref reader, options); + break; + case 1: + ____result.MyProperty1 = MsgPack::FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Deserialize(ref reader, options); + break; + default: + reader.Skip(); + break; + } + } + + reader.Depth--; + return ____result; + } + } +} diff --git a/tests/MessagePack.SourceGenerator.Tests/Resources/GenericTypeArg/MessagePack.GeneratedMessagePackResolver.g.cs b/tests/MessagePack.SourceGenerator.Tests/Resources/GenericTypeArg/MessagePack.GeneratedMessagePackResolver.g.cs new file mode 100644 index 000000000..e5a757c0b --- /dev/null +++ b/tests/MessagePack.SourceGenerator.Tests/Resources/GenericTypeArg/MessagePack.GeneratedMessagePackResolver.g.cs @@ -0,0 +1,68 @@ +// + +#pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 + +namespace MessagePack +{ + using MsgPack = global::MessagePack; + using Formatters = global::Formatters; + + /// A MessagePack resolver that uses generated formatters for types in this assembly. + internal class GeneratedMessagePackResolver : MsgPack::IFormatterResolver + { + /// An instance of this resolver that only returns formatters specifically generated for types in this assembly. + public static readonly MsgPack::IFormatterResolver Instance = new GeneratedMessagePackResolver(); + + /// An instance of this resolver that returns standard AOT-compatible formatters as well as formatters specifically generated for types in this assembly. + public static readonly MsgPack::IFormatterResolver InstanceWithStandardAotResolver = MsgPack::Resolvers.CompositeResolver.Create(Instance, MsgPack::Resolvers.StandardAotResolver.Instance); + + private GeneratedMessagePackResolver() + { + } + + public MsgPack::Formatters.IMessagePackFormatter GetFormatter() + { + return FormatterCache.Formatter; + } + + private static class FormatterCache + { + internal static readonly MsgPack::Formatters.IMessagePackFormatter Formatter; + + static FormatterCache() + { + var f = GeneratedMessagePackResolverGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + Formatter = (MsgPack::Formatters.IMessagePackFormatter)f; + } + } + } + } + + internal static class GeneratedMessagePackResolverGetFormatterHelper + { + private static readonly global::System.Collections.Generic.Dictionary lookup; + + static GeneratedMessagePackResolverGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(0) + { + }; + } + + internal static object GetFormatter(global::System.Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + default: return null; + } + } + } +} diff --git a/tests/MessagePack.SourceGenerator.Tests/Usings.cs b/tests/MessagePack.SourceGenerator.Tests/Usings.cs index bdbb23d64..b02988250 100644 --- a/tests/MessagePack.SourceGenerator.Tests/Usings.cs +++ b/tests/MessagePack.SourceGenerator.Tests/Usings.cs @@ -2,7 +2,7 @@ // Licensed under the MIT license. See LICENSE file in the project root for full license information. global using System.Collections.Immutable; -global using MessagePack.SourceGenerator.CodeAnalysis; +global using MessagePackAnalyzer.CodeAnalysis; global using Xunit; global using Xunit.Abstractions; global using VerifyCS = CSharpSourceGeneratorVerifier; diff --git a/tests/MessagePack.SourceGenerator.Unity.Tests/MessagePack.SourceGenerator.Unity.Tests.csproj b/tests/MessagePack.SourceGenerator.Unity.Tests/MessagePack.SourceGenerator.Unity.Tests.csproj index 249b240ca..bde2c7d67 100644 --- a/tests/MessagePack.SourceGenerator.Unity.Tests/MessagePack.SourceGenerator.Unity.Tests.csproj +++ b/tests/MessagePack.SourceGenerator.Unity.Tests/MessagePack.SourceGenerator.Unity.Tests.csproj @@ -9,15 +9,15 @@ - - - - + + + + - - + + @@ -33,6 +33,7 @@ + diff --git a/tests/MessagePackAnalyzer.Tests/MessagePackAnalyzerTests.cs b/tests/MessagePackAnalyzer.Tests/MessagePackAnalyzerTests.cs index dfaed11be..9589b75b0 100644 --- a/tests/MessagePackAnalyzer.Tests/MessagePackAnalyzerTests.cs +++ b/tests/MessagePackAnalyzer.Tests/MessagePackAnalyzerTests.cs @@ -6,7 +6,7 @@ using Microsoft.CodeAnalysis.Testing; using Xunit; using VerifyCS = - CSharpCodeFixVerifier; + CSharpCodeFixVerifier; public class MessagePackAnalyzerTests { @@ -59,7 +59,7 @@ public async Task InvalidMessageFormatterType() public class InvalidMessageFormatter { } -[{|MsgPack006:MessagePackFormatter(typeof(InvalidMessageFormatter))|}] +[MessagePackFormatter({|MsgPack006:typeof(InvalidMessageFormatter)|})] public struct Foo { } @@ -129,7 +129,7 @@ public class Foo public class Bar { [MessagePack.Key(0)] - public Foo {|MsgPack003:Member|} { get; set; } + public {|MsgPack003:Foo|} Member { get; set; } } "; @@ -158,14 +158,14 @@ public async Task CodeFixAppliesAcrossFiles() string source1 = @" public class Foo { - public int {|MsgPack004:Member1|} { get; set; } + public int Member1 { get; set; } } "; string source2 = @"using MessagePack; [MessagePackObject] -public class Bar : Foo +public class Bar : {|MsgPack004:Foo|} { public int {|MsgPack004:Member2|} { get; set; } } diff --git a/tests/SourceGeneratorConsumer.props b/tests/SourceGeneratorConsumer.props index 8c966be87..354485d0c 100644 --- a/tests/SourceGeneratorConsumer.props +++ b/tests/SourceGeneratorConsumer.props @@ -6,7 +6,19 @@ Analyzer false + + Analyzer + false + + + + + + + + + From 0d0e63e5e04126a760593c68d70b792dcfc56556 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Wed, 12 Apr 2023 06:17:11 -0600 Subject: [PATCH 090/660] Migrated 1 of 3 old test files --- .../CodeAnalysis/TypeCollector.cs | 28 +- .../GenerateGenericsFormatterTest.cs | 977 ------------------ .../GenerationTests.cs | 1 - .../GenericsFormatterTests.cs | 491 +++++++++ .../MessagePack.SourceGenerator.Tests.csproj | 1 - ...ject.MyGenericObjectFormatter_T1, T2_.g.cs | 58 ++ ...matters.TempProject.MyObjectFormatter.g.cs | 54 + ...s.TempProject.MyObjectNestedFormatter.g.cs | 54 + ...sagePack.GeneratedMessagePackResolver.g.cs | 76 ++ ...mpProject.MyGenericObjectFormatter_T_.g.cs | 54 + ...matters.TempProject.MyObjectFormatter.g.cs | 54 + ...s.TempProject.MyObjectNestedFormatter.g.cs | 54 + ...sagePack.GeneratedMessagePackResolver.g.cs | 76 ++ ...mpProject.MyGenericObjectFormatter_T_.g.cs | 54 + ...sagePack.GeneratedMessagePackResolver.g.cs | 68 ++ ...mpProject.MyGenericObjectFormatter_T_.g.cs | 58 ++ ...atters.TempProject.MyObject2Formatter.g.cs | 34 + ...matters.TempProject.MyObjectFormatter.g.cs | 58 ++ ...sagePack.GeneratedMessagePackResolver.g.cs | 76 ++ ...tters.TempProject.WrapperFormatter_T_.g.cs | 54 + ...sagePack.GeneratedMessagePackResolver.g.cs | 76 ++ ...mpProject.MyGenericObjectFormatter_T_.g.cs | 54 + ...ject.MyInnerGenericObjectFormatter_T_.g.cs | 34 + ...tters.TempProject.WrapperFormatter_T_.g.cs | 58 ++ ...sagePack.GeneratedMessagePackResolver.g.cs | 94 ++ ...enericObjectFormatter_T1, T2, T3, T4_.g.cs | 70 ++ ...sagePack.GeneratedMessagePackResolver.g.cs | 68 ++ ...enericObjectFormatter_T1, T2, T3, T4_.g.cs | 58 ++ ...sagePack.GeneratedMessagePackResolver.g.cs | 68 ++ ...ject.MyGenericObjectFormatter_T1, T2_.g.cs | 60 ++ ...sagePack.GeneratedMessagePackResolver.g.cs | 68 ++ ...mpProject.MyGenericObjectFormatter_T_.g.cs | 55 + ...sagePack.GeneratedMessagePackResolver.g.cs | 68 ++ ...mpProject.MyGenericObjectFormatter_T_.g.cs | 55 + ...sagePack.GeneratedMessagePackResolver.g.cs | 68 ++ ...matters.TempProject.MyObjectFormatter.g.cs | 54 + ...s.TempProject.MyObjectNestedFormatter.g.cs | 54 + ...sagePack.GeneratedMessagePackResolver.g.cs | 76 ++ ...mpProject.MyGenericObjectFormatter_T_.g.cs | 58 ++ ...ject.MyInnerGenericObjectFormatter_T_.g.cs | 34 + ...atters.TempProject.MyObject2Formatter.g.cs | 34 + ...matters.TempProject.MyObjectFormatter.g.cs | 58 ++ ...tters.TempProject.WrapperFormatter_T_.g.cs | 58 ++ ...sagePack.GeneratedMessagePackResolver.g.cs | 80 ++ ...ormatters.TempProject.MyEnumFormatter.g.cs | 22 + ...matters.TempProject.MyObjectFormatter.g.cs | 62 ++ ...sagePack.GeneratedMessagePackResolver.g.cs | 78 ++ ...matters.TempProject.MyObjectFormatter.g.cs | 62 ++ ...sagePack.GeneratedMessagePackResolver.g.cs | 76 ++ ...agePack.SourceGenerator.Unity.Tests.csproj | 1 - 50 files changed, 3146 insertions(+), 995 deletions(-) delete mode 100644 tests/MessagePack.SourceGenerator.Tests/GenerateGenericsFormatterTest.cs create mode 100644 tests/MessagePack.SourceGenerator.Tests/GenericsFormatterTests.cs create mode 100644 tests/MessagePack.SourceGenerator.Tests/Resources/GenericsOfT1T2Formatter/Formatters.TempProject.MyGenericObjectFormatter_T1, T2_.g.cs create mode 100644 tests/MessagePack.SourceGenerator.Tests/Resources/GenericsOfT1T2Formatter/Formatters.TempProject.MyObjectFormatter.g.cs create mode 100644 tests/MessagePack.SourceGenerator.Tests/Resources/GenericsOfT1T2Formatter/Formatters.TempProject.MyObjectNestedFormatter.g.cs create mode 100644 tests/MessagePack.SourceGenerator.Tests/Resources/GenericsOfT1T2Formatter/MessagePack.GeneratedMessagePackResolver.g.cs create mode 100644 tests/MessagePack.SourceGenerator.Tests/Resources/GenericsOfTFormatter/Formatters.TempProject.MyGenericObjectFormatter_T_.g.cs create mode 100644 tests/MessagePack.SourceGenerator.Tests/Resources/GenericsOfTFormatter/Formatters.TempProject.MyObjectFormatter.g.cs create mode 100644 tests/MessagePack.SourceGenerator.Tests/Resources/GenericsOfTFormatter/Formatters.TempProject.MyObjectNestedFormatter.g.cs create mode 100644 tests/MessagePack.SourceGenerator.Tests/Resources/GenericsOfTFormatter/MessagePack.GeneratedMessagePackResolver.g.cs create mode 100644 tests/MessagePack.SourceGenerator.Tests/Resources/GenericsOfTFormatter_FormatterOnly/Formatters.TempProject.MyGenericObjectFormatter_T_.g.cs create mode 100644 tests/MessagePack.SourceGenerator.Tests/Resources/GenericsOfTFormatter_FormatterOnly/MessagePack.GeneratedMessagePackResolver.g.cs create mode 100644 tests/MessagePack.SourceGenerator.Tests/Resources/GenericsOfTFormatter_WithKnownTypes/Formatters.TempProject.MyGenericObjectFormatter_T_.g.cs create mode 100644 tests/MessagePack.SourceGenerator.Tests/Resources/GenericsOfTFormatter_WithKnownTypes/Formatters.TempProject.MyObject2Formatter.g.cs create mode 100644 tests/MessagePack.SourceGenerator.Tests/Resources/GenericsOfTFormatter_WithKnownTypes/Formatters.TempProject.MyObjectFormatter.g.cs create mode 100644 tests/MessagePack.SourceGenerator.Tests/Resources/GenericsOfTFormatter_WithKnownTypes/MessagePack.GeneratedMessagePackResolver.g.cs create mode 100644 tests/MessagePack.SourceGenerator.Tests/Resources/GenericsUnionFormatter/Formatters.TempProject.WrapperFormatter_T_.g.cs create mode 100644 tests/MessagePack.SourceGenerator.Tests/Resources/GenericsUnionFormatter/MessagePack.GeneratedMessagePackResolver.g.cs create mode 100644 tests/MessagePack.SourceGenerator.Tests/Resources/GenericsUnionFormatter_Nested/Formatters.TempProject.MyGenericObjectFormatter_T_.g.cs create mode 100644 tests/MessagePack.SourceGenerator.Tests/Resources/GenericsUnionFormatter_Nested/Formatters.TempProject.MyInnerGenericObjectFormatter_T_.g.cs create mode 100644 tests/MessagePack.SourceGenerator.Tests/Resources/GenericsUnionFormatter_Nested/Formatters.TempProject.WrapperFormatter_T_.g.cs create mode 100644 tests/MessagePack.SourceGenerator.Tests/Resources/GenericsUnionFormatter_Nested/MessagePack.GeneratedMessagePackResolver.g.cs create mode 100644 tests/MessagePack.SourceGenerator.Tests/Resources/Generics_Constraints_Multiple/Formatters.TempProject.MyGenericObjectFormatter_T1, T2, T3, T4_.g.cs create mode 100644 tests/MessagePack.SourceGenerator.Tests/Resources/Generics_Constraints_Multiple/MessagePack.GeneratedMessagePackResolver.g.cs create mode 100644 tests/MessagePack.SourceGenerator.Tests/Resources/Generics_Constraints_NullableReferenceType/Formatters.TempProject.MyGenericObjectFormatter_T1, T2, T3, T4_.g.cs create mode 100644 tests/MessagePack.SourceGenerator.Tests/Resources/Generics_Constraints_NullableReferenceType/MessagePack.GeneratedMessagePackResolver.g.cs create mode 100644 tests/MessagePack.SourceGenerator.Tests/Resources/Generics_Constraints_ReferenceType_Nullable/Formatters.TempProject.MyGenericObjectFormatter_T1, T2_.g.cs create mode 100644 tests/MessagePack.SourceGenerator.Tests/Resources/Generics_Constraints_ReferenceType_Nullable/MessagePack.GeneratedMessagePackResolver.g.cs create mode 100644 tests/MessagePack.SourceGenerator.Tests/Resources/Generics_Constraints_Struct/Formatters.TempProject.MyGenericObjectFormatter_T_.g.cs create mode 100644 tests/MessagePack.SourceGenerator.Tests/Resources/Generics_Constraints_Struct/MessagePack.GeneratedMessagePackResolver.g.cs create mode 100644 tests/MessagePack.SourceGenerator.Tests/Resources/Generics_Constraints_Type/Formatters.TempProject.MyGenericObjectFormatter_T_.g.cs create mode 100644 tests/MessagePack.SourceGenerator.Tests/Resources/Generics_Constraints_Type/MessagePack.GeneratedMessagePackResolver.g.cs create mode 100644 tests/MessagePack.SourceGenerator.Tests/Resources/Generics_Defined_In_ReferencedProject/Formatters.TempProject.MyObjectFormatter.g.cs create mode 100644 tests/MessagePack.SourceGenerator.Tests/Resources/Generics_Defined_In_ReferencedProject/Formatters.TempProject.MyObjectNestedFormatter.g.cs create mode 100644 tests/MessagePack.SourceGenerator.Tests/Resources/Generics_Defined_In_ReferencedProject/MessagePack.GeneratedMessagePackResolver.g.cs create mode 100644 tests/MessagePack.SourceGenerator.Tests/Resources/NestedGenericTypes/Formatters.TempProject.MyGenericObjectFormatter_T_.g.cs create mode 100644 tests/MessagePack.SourceGenerator.Tests/Resources/NestedGenericTypes/Formatters.TempProject.MyInnerGenericObjectFormatter_T_.g.cs create mode 100644 tests/MessagePack.SourceGenerator.Tests/Resources/NestedGenericTypes/Formatters.TempProject.MyObject2Formatter.g.cs create mode 100644 tests/MessagePack.SourceGenerator.Tests/Resources/NestedGenericTypes/Formatters.TempProject.MyObjectFormatter.g.cs create mode 100644 tests/MessagePack.SourceGenerator.Tests/Resources/NestedGenericTypes/Formatters.TempProject.WrapperFormatter_T_.g.cs create mode 100644 tests/MessagePack.SourceGenerator.Tests/Resources/NestedGenericTypes/MessagePack.GeneratedMessagePackResolver.g.cs create mode 100644 tests/MessagePack.SourceGenerator.Tests/Resources/NullableFormatter/Formatters.TempProject.MyEnumFormatter.g.cs create mode 100644 tests/MessagePack.SourceGenerator.Tests/Resources/NullableFormatter/Formatters.TempProject.MyObjectFormatter.g.cs create mode 100644 tests/MessagePack.SourceGenerator.Tests/Resources/NullableFormatter/MessagePack.GeneratedMessagePackResolver.g.cs create mode 100644 tests/MessagePack.SourceGenerator.Tests/Resources/WellKnownGenericsFormatter/Formatters.TempProject.MyObjectFormatter.g.cs create mode 100644 tests/MessagePack.SourceGenerator.Tests/Resources/WellKnownGenericsFormatter/MessagePack.GeneratedMessagePackResolver.g.cs diff --git a/src/MessagePackAnalyzer/CodeAnalysis/TypeCollector.cs b/src/MessagePackAnalyzer/CodeAnalysis/TypeCollector.cs index 50062ec83..b6ae23211 100644 --- a/src/MessagePackAnalyzer/CodeAnalysis/TypeCollector.cs +++ b/src/MessagePackAnalyzer/CodeAnalysis/TypeCollector.cs @@ -301,9 +301,7 @@ private bool CollectCore(ITypeSymbol typeSymbol) if (typeSymbol is IArrayTypeSymbol arrayTypeSymbol) { - result = this.CollectArray((IArrayTypeSymbol)this.ToTupleUnderlyingType(arrayTypeSymbol)); - this.alreadyCollected.Add(typeSymbol, result); - return result; + return RecursiveProtection(() => this.CollectArray((IArrayTypeSymbol)this.ToTupleUnderlyingType(arrayTypeSymbol))); } if (typeSymbol is ITypeParameterSymbol) @@ -338,16 +336,12 @@ private bool CollectCore(ITypeSymbol typeSymbol) if (type.EnumUnderlyingType != null) { - result = this.CollectEnum(type, type.EnumUnderlyingType); - this.alreadyCollected.Add(typeSymbol, result); - return result; + return RecursiveProtection(() => this.CollectEnum(type, type.EnumUnderlyingType)); } if (type.IsGenericType) { - result = this.CollectGeneric((INamedTypeSymbol)this.ToTupleUnderlyingType(type)); - this.alreadyCollected.Add(typeSymbol, result); - return result; + return RecursiveProtection(() => this.CollectGeneric((INamedTypeSymbol)this.ToTupleUnderlyingType(type))); } if (type.Locations[0].IsInMetadata) @@ -359,14 +353,18 @@ private bool CollectCore(ITypeSymbol typeSymbol) if (type.TypeKind == TypeKind.Interface || (type.TypeKind == TypeKind.Class && type.IsAbstract)) { - result = this.CollectUnion(type); - this.alreadyCollected.Add(typeSymbol, result); - return result; + return RecursiveProtection(() => this.CollectUnion(type)); } - result = this.CollectObject(type); - this.alreadyCollected.Add(typeSymbol, result); - return result; + return RecursiveProtection(() => this.CollectObject(type)); + + bool RecursiveProtection(Func func) + { + this.alreadyCollected.Add(typeSymbol, true); + bool result = func(); + this.alreadyCollected[typeSymbol] = result; + return result; + } } private bool CollectEnum(INamedTypeSymbol type, ISymbol enumUnderlyingType) diff --git a/tests/MessagePack.SourceGenerator.Tests/GenerateGenericsFormatterTest.cs b/tests/MessagePack.SourceGenerator.Tests/GenerateGenericsFormatterTest.cs deleted file mode 100644 index 938a3d1aa..000000000 --- a/tests/MessagePack.SourceGenerator.Tests/GenerateGenericsFormatterTest.cs +++ /dev/null @@ -1,977 +0,0 @@ -// Copyright (c) All contributors. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - -using System; -using System.IO; -using System.Linq; -using System.Threading; -using System.Threading.Tasks; -using FluentAssertions; -using Microsoft.CodeAnalysis; -using Xunit; -using Xunit.Abstractions; -using SymbolDisplayFormat = Microsoft.CodeAnalysis.SymbolDisplayFormat; - -namespace MessagePack.SourceGenerator.Tests -{ - public class GenerateGenericsFormatterTest - { - private readonly ITestOutputHelper testOutputHelper; - - public GenerateGenericsFormatterTest(ITestOutputHelper testOutputHelper) - { - this.testOutputHelper = testOutputHelper; - } - - [Theory] - [InlineData(true)] - [InlineData(false)] - public async Task NullableFormatter(bool isSingleFileOutput) - { - using var tempWorkarea = TemporaryProjectWorkarea.Create(false); - var contents = @" -using System; -using System.Collections.Generic; -using MessagePack; - -namespace TempProject -{ - [MessagePackObject] - public class MyObject - { - [Key(0)] - public int? ValueNullableInt { get; set; } - [Key(1)] - public MyEnum? ValueNullableEnum { get; set; } - [Key(2)] - public ValueTuple? ValueNullableStruct { get; set; } - } - - public enum MyEnum - { - A, B, C - } -} - "; - tempWorkarea.AddFileToTargetProject("MyMessagePackObject.cs", contents); - - var compiler = new MessagePackCompiler.CodeGenerator(testOutputHelper.WriteLine, CancellationToken.None); - await compiler.GenerateFileAsync( - tempWorkarea.GetOutputCompilation().Compilation, - isSingleFileOutput ? Path.Combine(tempWorkarea.OutputDirectory, "Generated.cs") : tempWorkarea.OutputDirectory, - "TempProjectResolver", - "TempProject.Generated", - false, - string.Empty, - Array.Empty()); - - var compilation = tempWorkarea.GetOutputCompilation(); - compilation.Compilation.GetDiagnostics().Where(x => x.WarningLevel == 0).Should().BeEmpty(); - - compilation.GetResolverKnownFormatterTypes().Should().Contain(new[] - { - "global::MessagePack.Formatters.NullableFormatter<(int, long)>", - "global::MessagePack.Formatters.NullableFormatter", - }); - } - - [Theory] - [InlineData(true)] - [InlineData(false)] - public async Task WellKnownGenericsFormatter(bool isSingleFileOutput) - { - using var tempWorkarea = TemporaryProjectWorkarea.Create(false); - var contents = @" -using System; -using System.Collections.Generic; -using MessagePack; - -namespace TempProject -{ - [MessagePackObject] - public class MyObject - { - [Key(0)] - public List ValueList { get; set; } - [Key(1)] - public List> ValueListNested { get; set; } - [Key(2)] - public ValueTuple ValueValueTuple { get; set; } - } -} - "; - tempWorkarea.AddFileToTargetProject("MyMessagePackObject.cs", contents); - - var compiler = new MessagePackCompiler.CodeGenerator(testOutputHelper.WriteLine, CancellationToken.None); - await compiler.GenerateFileAsync( - tempWorkarea.GetOutputCompilation().Compilation, - isSingleFileOutput ? Path.Combine(tempWorkarea.OutputDirectory, "Generated.cs") : tempWorkarea.OutputDirectory, - "TempProjectResolver", - "TempProject.Generated", - false, - string.Empty, - Array.Empty()); - - var compilation = tempWorkarea.GetOutputCompilation(); - compilation.Compilation.GetDiagnostics().Where(x => x.WarningLevel == 0).Should().BeEmpty(); - - compilation.GetResolverKnownFormatterTypes().Should().Contain(new[] - { - "global::MessagePack.Formatters.ListFormatter", - "global::MessagePack.Formatters.ListFormatter>", - "global::MessagePack.Formatters.ValueTupleFormatter", - "TempProject.Generated.Formatters.TempProject.MyObjectFormatter", - }); - } - - [Theory] - [InlineData(true)] - [InlineData(false)] - public async Task GenericsUnionFormatter(bool isSingleFileOutput) - { - using var tempWorkarea = TemporaryProjectWorkarea.Create(false); - var contents = @" -using System; -using System.Collections.Generic; -using MessagePack; - -namespace TempProject -{ - [MessagePackObject] - [Union(0, typeof(Wrapper))] - [Union(1, typeof(Wrapper))] - [Union(2, typeof(Wrapper>))] - public class Wrapper - { - [Key(0)] - public T Content { get; set; } - } -} - "; - tempWorkarea.AddFileToTargetProject("MyMessagePackObject.cs", contents); - - var compiler = new MessagePackCompiler.CodeGenerator(testOutputHelper.WriteLine, CancellationToken.None); - await compiler.GenerateFileAsync( - tempWorkarea.GetOutputCompilation().Compilation, - isSingleFileOutput ? Path.Combine(tempWorkarea.OutputDirectory, "Generated.cs") : tempWorkarea.OutputDirectory, - "TempProjectResolver", - "TempProject.Generated", - false, - string.Empty, - Array.Empty()); - - var compilation = tempWorkarea.GetOutputCompilation(); - compilation.Compilation.GetDiagnostics().Where(x => x.WarningLevel == 0).Should().BeEmpty(); - - var symbols = compilation.GetNamedTypeSymbolsFromGenerated(); - var formatters = symbols.SelectMany(x => x.Interfaces).Select(x => x.ToDisplayString()).ToArray(); - formatters.Should().Contain("MessagePack.Formatters.IMessagePackFormatter>"); - - compilation.GetResolverKnownFormatterTypes().Should().Contain(new[] - { - "TempProject.Generated.Formatters.TempProject.WrapperFormatter>", - "TempProject.Generated.Formatters.TempProject.WrapperFormatter", - "TempProject.Generated.Formatters.TempProject.WrapperFormatter", - }); - } - - [Theory] - [InlineData(true)] - [InlineData(false)] - public async Task GenericsUnionFormatter_Nested(bool isSingleFileOutput) - { - using var tempWorkarea = TemporaryProjectWorkarea.Create(false); - var contents = @" -using System; -using System.Collections.Generic; -using MessagePack; - -namespace TempProject -{ - [MessagePackObject] - [Union(0, typeof(Wrapper))] - [Union(1, typeof(Wrapper))] - [Union(2, typeof(Wrapper>))] - public class Wrapper - { - [Key(0)] - public List Content1 { get; set; } - [Key(1)] - public MyGenericObject Content2 { get; set; } - } - - [MessagePackObject] - public class MyGenericObject - { - [Key(0)] - public MyInnerGenericObject Content { get; set; } - } - - [MessagePackObject] - public class MyInnerGenericObject - { - } -} - "; - tempWorkarea.AddFileToTargetProject("MyMessagePackObject.cs", contents); - - var compiler = new MessagePackCompiler.CodeGenerator(testOutputHelper.WriteLine, CancellationToken.None); - await compiler.GenerateFileAsync( - tempWorkarea.GetOutputCompilation().Compilation, - isSingleFileOutput ? Path.Combine(tempWorkarea.OutputDirectory, "Generated.cs") : tempWorkarea.OutputDirectory, - "TempProjectResolver", - "TempProject.Generated", - false, - string.Empty, - Array.Empty()); - - var compilation = tempWorkarea.GetOutputCompilation(); - compilation.Compilation.GetDiagnostics().Where(x => x.WarningLevel == 0).Should().BeEmpty(); - - var symbols = compilation.GetNamedTypeSymbolsFromGenerated(); - var formatters = symbols.SelectMany(x => x.Interfaces).Select(x => x.ToDisplayString()).ToArray(); - formatters.Should().Contain(new[] - { - "MessagePack.Formatters.IMessagePackFormatter>", - "MessagePack.Formatters.IMessagePackFormatter>", - "MessagePack.Formatters.IMessagePackFormatter>", - }); - - compilation.GetResolverKnownFormatterTypes().Should().Contain(new[] - { - "TempProject.Generated.Formatters.TempProject.WrapperFormatter>", - "TempProject.Generated.Formatters.TempProject.WrapperFormatter", - "TempProject.Generated.Formatters.TempProject.WrapperFormatter", - "TempProject.Generated.Formatters.TempProject.MyGenericObjectFormatter>", - "TempProject.Generated.Formatters.TempProject.MyGenericObjectFormatter", - "TempProject.Generated.Formatters.TempProject.MyGenericObjectFormatter", - "TempProject.Generated.Formatters.TempProject.MyInnerGenericObjectFormatter>", - "TempProject.Generated.Formatters.TempProject.MyInnerGenericObjectFormatter", - "TempProject.Generated.Formatters.TempProject.MyInnerGenericObjectFormatter", - }); - } - - [Theory] - [InlineData(true)] - [InlineData(false)] - public async Task NestedGenericTypes(bool isSingleFileOutput) - { - using var tempWorkarea = TemporaryProjectWorkarea.Create(false); - var contents = @" -using System; -using System.Collections.Generic; -using MessagePack; - -namespace TempProject -{ - [MessagePackObject] - public class MyObject : Wrapper - { - } - - [MessagePackObject] - public class MyObject2 - {} - - [MessagePackObject] - public class Wrapper - { - [Key(0)] - public List Content1 { get; set; } - [Key(1)] - public MyGenericObject Content2 { get; set; } - } - - [MessagePackObject] - public class MyGenericObject - { - [Key(0)] - public MyInnerGenericObject Content { get; set; } - [Key(1)] - public T[] Content2 { get; set; } - } - - [MessagePackObject] - public class MyInnerGenericObject - { - } -} - "; - tempWorkarea.AddFileToTargetProject("MyMessagePackObject.cs", contents); - - var compiler = new MessagePackCompiler.CodeGenerator(testOutputHelper.WriteLine, CancellationToken.None); - await compiler.GenerateFileAsync( - tempWorkarea.GetOutputCompilation().Compilation, - isSingleFileOutput ? Path.Combine(tempWorkarea.OutputDirectory, "Generated.cs") : tempWorkarea.OutputDirectory, - "TempProjectResolver", - "TempProject.Generated", - false, - string.Empty, - Array.Empty()); - - var compilation = tempWorkarea.GetOutputCompilation(); - compilation.Compilation.GetDiagnostics().Where(x => x.WarningLevel == 0).Should().BeEmpty(); - - var symbols = compilation.GetNamedTypeSymbolsFromGenerated(); - var formatters = symbols.SelectMany(x => x.Interfaces).Select(x => x.ToDisplayString()).ToArray(); - formatters.Should().Contain(new[] - { - "MessagePack.Formatters.IMessagePackFormatter", - "MessagePack.Formatters.IMessagePackFormatter", - "MessagePack.Formatters.IMessagePackFormatter>", - "MessagePack.Formatters.IMessagePackFormatter>", - "MessagePack.Formatters.IMessagePackFormatter>", - }); - - compilation.GetResolverKnownFormatterTypes().Should().Contain(new[] - { - // "TempProject.Generated.Formatters.TempProject.WrapperFormatter", // Wrapper is not used as a property/field in the code. The generated resolver can ignore it. - "TempProject.Generated.Formatters.TempProject.MyGenericObjectFormatter", - "TempProject.Generated.Formatters.TempProject.MyInnerGenericObjectFormatter", - "global::MessagePack.Formatters.ListFormatter", - "global::MessagePack.Formatters.ArrayFormatter", - }); - } - - [Theory] - [InlineData(true)] - [InlineData(false)] - public async Task GenericsOfTFormatter_WithKnownTypes(bool isSingleFileOutput) - { - using var tempWorkarea = TemporaryProjectWorkarea.Create(false); - var contents = @" -using System; -using System.Collections.Generic; -using MessagePack; - -namespace TempProject -{ - [MessagePackObject] - public class MyObject : MyGenericObject - { - } - - [MessagePackObject] - public class MyObject2 - { } - - [MessagePackObject] - public class MyGenericObject - { - [Key(0)] - public List Content1 { get; set; } - [Key(1)] - public T[] Content2 { get; set; } - } -} - "; - tempWorkarea.AddFileToTargetProject("MyMessagePackObject.cs", contents); - - var compiler = new MessagePackCompiler.CodeGenerator(testOutputHelper.WriteLine, CancellationToken.None); - await compiler.GenerateFileAsync( - tempWorkarea.GetOutputCompilation().Compilation, - isSingleFileOutput ? Path.Combine(tempWorkarea.OutputDirectory, "Generated.cs") : tempWorkarea.OutputDirectory, - "TempProjectResolver", - "TempProject.Generated", - false, - string.Empty, - Array.Empty()); - - var compilation = tempWorkarea.GetOutputCompilation(); - compilation.Compilation.GetDiagnostics().Where(x => x.WarningLevel == 0).Should().BeEmpty(); - - var symbols = compilation.GetNamedTypeSymbolsFromGenerated(); - var formatters = symbols.SelectMany(x => x.Interfaces).Select(x => x.ToDisplayString()).ToArray(); - formatters.Should().Contain(new[] - { - "MessagePack.Formatters.IMessagePackFormatter", - "MessagePack.Formatters.IMessagePackFormatter", - "MessagePack.Formatters.IMessagePackFormatter>", - }); - - compilation.GetResolverKnownFormatterTypes().Should().Contain(new[] - { - "global::MessagePack.Formatters.ListFormatter", - "global::MessagePack.Formatters.ArrayFormatter", - - // "TempProject.Generated.Formatters.TempProject.MyGenericObjectFormatter", // MyGenericObjectFormatter is not used as a property/field in the code. The generated resolver can ignore it. - "TempProject.Generated.Formatters.TempProject.MyObjectFormatter", - "TempProject.Generated.Formatters.TempProject.MyObject2Formatter", - }); - } - - [Theory] - [InlineData(true)] - [InlineData(false)] - public async Task GenericsOfTFormatter(bool isSingleFileOutput) - { - using var tempWorkarea = TemporaryProjectWorkarea.Create(); - var contents = @" -using System; -using System.Collections.Generic; -using MessagePack; - -namespace TempProject -{ - [MessagePackObject] - public class MyGenericObject - { - [Key(0)] - public T Content { get; set; } - } - - [MessagePackObject] - public class MyObject - { - [Key(0)] - public MyGenericObject Value { get; set; } - } - - [MessagePackObject] - public class MyObjectNested - { - [Key(0)] - public MyGenericObject> Value { get; set; } - } -} - "; - tempWorkarea.AddFileToTargetProject("MyMessagePackObject.cs", contents); - - var compiler = new MessagePackCompiler.CodeGenerator(testOutputHelper.WriteLine, CancellationToken.None); - await compiler.GenerateFileAsync( - tempWorkarea.GetOutputCompilation().Compilation, - isSingleFileOutput ? Path.Combine(tempWorkarea.OutputDirectory, "Generated.cs") : tempWorkarea.OutputDirectory, - "TempProjectResolver", - "TempProject.Generated", - false, - string.Empty, - Array.Empty()); - - var compilation = tempWorkarea.GetOutputCompilation(); - compilation.Compilation.GetDiagnostics().Where(x => x.WarningLevel == 0).Should().BeEmpty(); - - var symbols = compilation.GetNamedTypeSymbolsFromGenerated(); - - var types = symbols.Select(x => x.ToDisplayString()).ToArray(); - types.Should().Contain("TempProject.Generated.Formatters.TempProject.MyGenericObjectFormatter"); - - var formatters = symbols.SelectMany(x => x.Interfaces).Select(x => x.ToDisplayString()).ToArray(); - formatters.Should().Contain("MessagePack.Formatters.IMessagePackFormatter>"); - - compilation.GetResolverKnownFormatterTypes().Should().Contain(new[] - { - "TempProject.Generated.Formatters.TempProject.MyGenericObjectFormatter>", - "TempProject.Generated.Formatters.TempProject.MyGenericObjectFormatter", - "TempProject.Generated.Formatters.TempProject.MyObjectFormatter", - "TempProject.Generated.Formatters.TempProject.MyObjectNestedFormatter", - }); - } - - [Theory] - [InlineData(true)] - [InlineData(false)] - public async Task GenericsOfT1T2Formatter(bool isSingleFileOutput) - { - using var tempWorkarea = TemporaryProjectWorkarea.Create(); - var contents = @" -using System; -using System.Collections.Generic; -using MessagePack; - -namespace TempProject -{ - [MessagePackObject] - public class MyGenericObject - { - [Key(0)] - public T1 ValueA { get; set; } - [Key(1)] - public T2 ValueB { get; set; } - } - - [MessagePackObject] - public class MyObject - { - [Key(0)] - public MyGenericObject Value { get; set; } - } - - [MessagePackObject] - public class MyObjectNested - { - [Key(0)] - public MyGenericObject, MyGenericObject> Value { get; set; } - } -} - "; - tempWorkarea.AddFileToTargetProject("MyMessagePackObject.cs", contents); - - var compiler = new MessagePackCompiler.CodeGenerator(testOutputHelper.WriteLine, CancellationToken.None); - await compiler.GenerateFileAsync( - tempWorkarea.GetOutputCompilation().Compilation, - isSingleFileOutput ? Path.Combine(tempWorkarea.OutputDirectory, "Generated.cs") : tempWorkarea.OutputDirectory, - "TempProjectResolver", - "TempProject.Generated", - false, - string.Empty, - Array.Empty()); - - var compilation = tempWorkarea.GetOutputCompilation(); - compilation.Compilation.GetDiagnostics().Where(x => x.WarningLevel == 0).Should().BeEmpty(); - - var symbols = compilation.GetNamedTypeSymbolsFromGenerated(); - - var types = symbols.Select(x => x.ToDisplayString()).ToArray(); - types.Should().Contain("TempProject.Generated.Formatters.TempProject.MyGenericObjectFormatter"); - - var formatters = symbols.SelectMany(x => x.Interfaces).Select(x => x.ToDisplayString()).ToArray(); - formatters.Should().Contain("MessagePack.Formatters.IMessagePackFormatter>"); - - compilation.GetResolverKnownFormatterTypes().Should().Contain(new[] - { - "TempProject.Generated.Formatters.TempProject.MyGenericObjectFormatter, global::TempProject.MyGenericObject>", - "TempProject.Generated.Formatters.TempProject.MyGenericObjectFormatter", - "TempProject.Generated.Formatters.TempProject.MyObjectFormatter", - "TempProject.Generated.Formatters.TempProject.MyObjectNestedFormatter", - }); - } - - [Theory] - [InlineData(true)] - [InlineData(false)] - public async Task GenericsOfTFormatter_FormatterOnly(bool isSingleFileOutput) - { - using var tempWorkarea = TemporaryProjectWorkarea.Create(); - var contents = @" -using System; -using System.Collections.Generic; -using MessagePack; - -namespace TempProject -{ - // This type is not used by the project. - // It may be referenced by other projects. - [MessagePackObject] - public class MyGenericObject - { - [Key(0)] - public T Content { get; set; } - } -} - "; - tempWorkarea.AddFileToTargetProject("MyMessagePackObject.cs", contents); - - var compiler = new MessagePackCompiler.CodeGenerator(testOutputHelper.WriteLine, CancellationToken.None); - await compiler.GenerateFileAsync( - tempWorkarea.GetOutputCompilation().Compilation, - isSingleFileOutput ? Path.Combine(tempWorkarea.OutputDirectory, "Generated.cs") : tempWorkarea.OutputDirectory, - "TempProjectResolver", - "TempProject.Generated", - false, - string.Empty, - Array.Empty()); - - var compilation = tempWorkarea.GetOutputCompilation(); - compilation.Compilation.GetDiagnostics().Where(x => x.WarningLevel == 0).Should().BeEmpty(); - - var symbols = compilation.GetNamedTypeSymbolsFromGenerated(); - - var types = symbols.Select(x => x.ToDisplayString()).ToArray(); - types.Should().Contain("TempProject.Generated.Formatters.TempProject.MyGenericObjectFormatter"); - - var formatters = symbols.SelectMany(x => x.Interfaces).Select(x => x.ToDisplayString()).ToArray(); - formatters.Should().Contain("MessagePack.Formatters.IMessagePackFormatter>"); - - // The generated resolver doesn't know closed-type generic formatter. - compilation.GetResolverKnownFormatterTypes().Should().BeEmpty(); - } - - [Theory] - [InlineData(true)] - [InlineData(false)] - public async Task Generics_Constraints_Type(bool isSingleFileOutput) - { - using var tempWorkarea = TemporaryProjectWorkarea.Create(); - var contents = @" -using System; -using System.Collections.Generic; -using MessagePack; - -namespace TempProject -{ - [MessagePackObject] - public class MyGenericObject - where T : IDisposable - { - [Key(0)] - public T Content { get; set; } - } -} - "; - tempWorkarea.AddFileToTargetProject("MyMessagePackObject.cs", contents); - - var compiler = new MessagePackCompiler.CodeGenerator(testOutputHelper.WriteLine, CancellationToken.None); - await compiler.GenerateFileAsync( - tempWorkarea.GetOutputCompilation().Compilation, - isSingleFileOutput ? Path.Combine(tempWorkarea.OutputDirectory, "Generated.cs") : tempWorkarea.OutputDirectory, - "TempProjectResolver", - "TempProject.Generated", - false, - string.Empty, - Array.Empty()); - - var compilation = tempWorkarea.GetOutputCompilation(); - compilation.Compilation.GetDiagnostics().Where(x => x.WarningLevel == 0).Should().BeEmpty(); - - var symbols = compilation.GetNamedTypeSymbolsFromGenerated(); - - var formatterType = symbols.FirstOrDefault(x => x.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat) == "global::TempProject.Generated.Formatters.TempProject.MyGenericObjectFormatter"); - formatterType.Should().NotBeNull(); - - // IDisposable - formatterType.TypeParameters[0].HasReferenceTypeConstraint.Should().BeFalse(); - formatterType.TypeParameters[0].HasValueTypeConstraint.Should().BeFalse(); - formatterType.TypeParameters[0].HasConstructorConstraint.Should().BeFalse(); - formatterType.TypeParameters[0].HasNotNullConstraint.Should().BeFalse(); - formatterType.TypeParameters[0].HasUnmanagedTypeConstraint.Should().BeFalse(); - formatterType.TypeParameters[0].ConstraintTypes.Should().Contain(x => x.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat) == "global::System.IDisposable"); - } - - [Theory] - [InlineData(true)] - [InlineData(false)] - public async Task Generics_Constraints_NullableReferenceType(bool isSingleFileOutput) - { - using var tempWorkarea = TemporaryProjectWorkarea.Create(); - var contents = @" -using System; -using System.Collections.Generic; -using MessagePack; - -namespace TempProject -{ - [MessagePackObject] - public class MyGenericObject - where T1 : MyClass? - where T2 : MyClass - where T3 : MyGenericClass?>? - where T4 : MyClass, IMyInterface? - { - [Key(0)] - public T1 Content { get; set; } - } - - public class MyClass {} - public class MyGenericClass {} - public interface IMyInterface {} -} - "; - tempWorkarea.AddFileToTargetProject("MyMessagePackObject.cs", contents); - - var compiler = new MessagePackCompiler.CodeGenerator(testOutputHelper.WriteLine, CancellationToken.None); - await compiler.GenerateFileAsync( - tempWorkarea.GetOutputCompilation().Compilation, - isSingleFileOutput ? Path.Combine(tempWorkarea.OutputDirectory, "Generated.cs") : tempWorkarea.OutputDirectory, - "TempProjectResolver", - "TempProject.Generated", - false, - string.Empty, - Array.Empty()); - - var compilation = tempWorkarea.GetOutputCompilation(); - compilation.Compilation.GetDiagnostics().Where(x => x.WarningLevel == 0).Should().BeEmpty(); - - var symbols = compilation.GetNamedTypeSymbolsFromGenerated(); - - var displayFormat = SymbolDisplayFormat.FullyQualifiedFormat.WithMiscellaneousOptions(SymbolDisplayMiscellaneousOptions.IncludeNullableReferenceTypeModifier); - var formatterType = symbols.FirstOrDefault(x => x.ToDisplayString(displayFormat) == "global::TempProject.Generated.Formatters.TempProject.MyGenericObjectFormatter"); - formatterType.Should().NotBeNull(); - - // MyClass? - formatterType.TypeParameters[0].ConstraintTypes.Should().Contain(x => x.ToDisplayString(displayFormat) == "global::TempProject.MyClass?"); - formatterType.TypeParameters[0].ConstraintNullableAnnotations[0].Should().Be(NullableAnnotation.Annotated); - - // MyClass - formatterType.TypeParameters[1].ConstraintTypes.Should().Contain(x => x.ToDisplayString(displayFormat) == "global::TempProject.MyClass"); - formatterType.TypeParameters[1].ConstraintNullableAnnotations[0].Should().Be(NullableAnnotation.None); - - // MyGenericClass?>? - formatterType.TypeParameters[2].ConstraintTypes.Should().Contain(x => x.ToDisplayString(displayFormat) == "global::TempProject.MyGenericClass?>?"); - formatterType.TypeParameters[2].ConstraintNullableAnnotations[0].Should().Be(NullableAnnotation.Annotated); - - // MyClass, IMyInterface? - formatterType.TypeParameters[3].ConstraintTypes.Should().Contain(x => x.ToDisplayString(displayFormat) == "global::TempProject.MyClass"); - formatterType.TypeParameters[3].ConstraintTypes.Should().Contain(x => x.ToDisplayString(displayFormat) == "global::TempProject.IMyInterface?"); - formatterType.TypeParameters[3].ConstraintNullableAnnotations[0].Should().Be(NullableAnnotation.None); - formatterType.TypeParameters[3].ConstraintNullableAnnotations[1].Should().Be(NullableAnnotation.Annotated); - } - - [Theory] - [InlineData(true)] - [InlineData(false)] - public async Task Generics_Constraints_Struct(bool isSingleFileOutput) - { - using var tempWorkarea = TemporaryProjectWorkarea.Create(); - var contents = @" -using System; -using System.Collections.Generic; -using MessagePack; - -namespace TempProject -{ - [MessagePackObject] - public class MyGenericObject - where T : struct - { - [Key(0)] - public T Content { get; set; } - } -} - "; - tempWorkarea.AddFileToTargetProject("MyMessagePackObject.cs", contents); - - var compiler = new MessagePackCompiler.CodeGenerator(testOutputHelper.WriteLine, CancellationToken.None); - await compiler.GenerateFileAsync( - tempWorkarea.GetOutputCompilation().Compilation, - isSingleFileOutput ? Path.Combine(tempWorkarea.OutputDirectory, "Generated.cs") : tempWorkarea.OutputDirectory, - "TempProjectResolver", - "TempProject.Generated", - false, - string.Empty, - Array.Empty()); - - var compilation = tempWorkarea.GetOutputCompilation(); - compilation.Compilation.GetDiagnostics().Where(x => x.WarningLevel == 0).Should().BeEmpty(); - - var symbols = compilation.GetNamedTypeSymbolsFromGenerated(); - - var formatterType = symbols.FirstOrDefault(x => x.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat) == "global::TempProject.Generated.Formatters.TempProject.MyGenericObjectFormatter"); - formatterType.Should().NotBeNull(); - - // struct - formatterType.TypeParameters[0].HasReferenceTypeConstraint.Should().BeFalse(); - formatterType.TypeParameters[0].HasValueTypeConstraint.Should().BeTrue(); - formatterType.TypeParameters[0].HasConstructorConstraint.Should().BeFalse(); - formatterType.TypeParameters[0].HasNotNullConstraint.Should().BeFalse(); - formatterType.TypeParameters[0].HasUnmanagedTypeConstraint.Should().BeFalse(); - formatterType.TypeParameters[0].ConstraintTypes.Should().BeEmpty(); - } - - [Theory] - [InlineData(true)] - [InlineData(false)] - public async Task Generics_Constraints_Multiple(bool isSingleFileOutput) - { - using var tempWorkarea = TemporaryProjectWorkarea.Create(); - var contents = @" -using System; -using System.Collections.Generic; -using MessagePack; - -namespace TempProject -{ - [MessagePackObject] - public class MyGenericObject - where T1 : struct - where T2 : IDisposable, new() - where T3 : notnull - where T4 : unmanaged - { - [Key(0)] - public T1 Content1 { get; set; } - [Key(1)] - public T2 Content2 { get; set; } - [Key(2)] - public T3 Content3 { get; set; } - [Key(3)] - public T4 Content4 { get; set; } - } -} - "; - tempWorkarea.AddFileToTargetProject("MyMessagePackObject.cs", contents); - - var compiler = new MessagePackCompiler.CodeGenerator(testOutputHelper.WriteLine, CancellationToken.None); - await compiler.GenerateFileAsync( - tempWorkarea.GetOutputCompilation().Compilation, - isSingleFileOutput ? Path.Combine(tempWorkarea.OutputDirectory, "Generated.cs") : tempWorkarea.OutputDirectory, - "TempProjectResolver", - "TempProject.Generated", - false, - string.Empty, - Array.Empty()); - - var compilation = tempWorkarea.GetOutputCompilation(); - compilation.Compilation.GetDiagnostics().Where(x => x.WarningLevel == 0).Should().BeEmpty(); - - var symbols = compilation.GetNamedTypeSymbolsFromGenerated(); - - var formatterType = symbols.FirstOrDefault(x => x.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat) == "global::TempProject.Generated.Formatters.TempProject.MyGenericObjectFormatter"); - formatterType.Should().NotBeNull(); - - // struct - formatterType.TypeParameters[0].HasReferenceTypeConstraint.Should().BeFalse(); - formatterType.TypeParameters[0].HasValueTypeConstraint.Should().BeTrue(); - formatterType.TypeParameters[0].HasConstructorConstraint.Should().BeFalse(); - formatterType.TypeParameters[0].HasNotNullConstraint.Should().BeFalse(); - formatterType.TypeParameters[0].HasUnmanagedTypeConstraint.Should().BeFalse(); - formatterType.TypeParameters[0].ConstraintTypes.Should().BeEmpty(); - - // IDisposable, new() - formatterType.TypeParameters[1].HasReferenceTypeConstraint.Should().BeFalse(); - formatterType.TypeParameters[1].HasValueTypeConstraint.Should().BeFalse(); - formatterType.TypeParameters[1].HasConstructorConstraint.Should().BeTrue(); - formatterType.TypeParameters[1].HasNotNullConstraint.Should().BeFalse(); - formatterType.TypeParameters[1].HasUnmanagedTypeConstraint.Should().BeFalse(); - formatterType.TypeParameters[1].ConstraintTypes.Should().Contain(x => x.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat) == "global::System.IDisposable"); - - // notnull - formatterType.TypeParameters[2].HasReferenceTypeConstraint.Should().BeFalse(); - formatterType.TypeParameters[2].HasValueTypeConstraint.Should().BeFalse(); - formatterType.TypeParameters[2].HasConstructorConstraint.Should().BeFalse(); - formatterType.TypeParameters[2].HasNotNullConstraint.Should().BeTrue(); - formatterType.TypeParameters[2].HasUnmanagedTypeConstraint.Should().BeFalse(); - formatterType.TypeParameters[2].ConstraintTypes.Should().BeEmpty(); - - // unmanaged - formatterType.TypeParameters[3].HasReferenceTypeConstraint.Should().BeFalse(); - formatterType.TypeParameters[3].HasValueTypeConstraint.Should().BeTrue(); // unmanaged constraint includes value-type constraint - formatterType.TypeParameters[3].HasConstructorConstraint.Should().BeFalse(); - formatterType.TypeParameters[3].HasNotNullConstraint.Should().BeFalse(); - formatterType.TypeParameters[3].HasUnmanagedTypeConstraint.Should().BeTrue(); - formatterType.TypeParameters[3].ConstraintTypes.Should().BeEmpty(); - } - - [Theory] - [InlineData(true)] - [InlineData(false)] - public async Task Generics_Constraints_ReferenceType_Nullable(bool isSingleFileOutput) - { - using var tempWorkarea = TemporaryProjectWorkarea.Create(); - var contents = @" -using System; -using System.Collections.Generic; -using MessagePack; - -namespace TempProject -{ - [MessagePackObject] - public class MyGenericObject - where T1 : class? - where T2 : class - { - [Key(0)] - public T1 Content1 { get; set; } - [Key(1)] - public T2 Content2 { get; set; } - } -} - "; - tempWorkarea.AddFileToTargetProject("MyMessagePackObject.cs", contents); - - var compiler = new MessagePackCompiler.CodeGenerator(testOutputHelper.WriteLine, CancellationToken.None); - await compiler.GenerateFileAsync( - tempWorkarea.GetOutputCompilation().Compilation, - isSingleFileOutput ? Path.Combine(tempWorkarea.OutputDirectory, "Generated.cs") : tempWorkarea.OutputDirectory, - "TempProjectResolver", - "TempProject.Generated", - false, - string.Empty, - Array.Empty()); - - var compilation = tempWorkarea.GetOutputCompilation(); - compilation.Compilation.GetDiagnostics().Where(x => x.WarningLevel == 0).Should().BeEmpty(); - - var symbols = compilation.GetNamedTypeSymbolsFromGenerated(); - - var formatterType = symbols.FirstOrDefault(x => x.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat) == "global::TempProject.Generated.Formatters.TempProject.MyGenericObjectFormatter"); - formatterType.Should().NotBeNull(); - - // class? - formatterType.TypeParameters[0].HasReferenceTypeConstraint.Should().BeTrue(); - formatterType.TypeParameters[0].ConstraintTypes.Should().BeEmpty(); - formatterType.TypeParameters[0].ReferenceTypeConstraintNullableAnnotation.Should().Be(NullableAnnotation.Annotated); - - // class - formatterType.TypeParameters[1].HasReferenceTypeConstraint.Should().BeTrue(); - formatterType.TypeParameters[1].ConstraintTypes.Should().BeEmpty(); - formatterType.TypeParameters[1].ReferenceTypeConstraintNullableAnnotation.Should().Be(NullableAnnotation.None); - } - - [Theory] - [InlineData(true)] - [InlineData(false)] - public async Task Generics_Defined_In_ReferencedProject(bool isSingleFileOutput) - { - using var tempWorkarea = TemporaryProjectWorkarea.Create(); - var defineContents = @" -using System; -using System.Collections.Generic; -using MessagePack; - -namespace TempProject -{ - [MessagePackObject] - public class MyGenericObject - { - [Key(0)] - public T Content { get; set; } - } -} - "; - tempWorkarea.AddFileToReferencedProject("MyGenericObject.cs", defineContents); - - var usageContents = @" -using System; -using System.Collections.Generic; -using MessagePack; - -namespace TempProject -{ - [MessagePackObject] - public class MyObject - { - [Key(0)] - public MyGenericObject Value { get; set; } - } - - [MessagePackObject] - public class MyObjectNested - { - [Key(0)] - public MyGenericObject> Value { get; set; } - } -} - "; - tempWorkarea.AddFileToTargetProject("MyObject.cs", usageContents); - - var compiler = new MessagePackCompiler.CodeGenerator(testOutputHelper.WriteLine, CancellationToken.None); - await compiler.GenerateFileAsync( - tempWorkarea.GetOutputCompilation().Compilation, - isSingleFileOutput ? Path.Combine(tempWorkarea.OutputDirectory, "Generated.cs") : tempWorkarea.OutputDirectory, - "TempProjectResolver", - "TempProject.Generated", - false, - string.Empty, - Array.Empty()); - - var compilation = tempWorkarea.GetOutputCompilation(); - compilation.Compilation.GetDiagnostics().Where(x => x.WarningLevel == 0).Should().BeEmpty(); - - var symbols = compilation.GetNamedTypeSymbolsFromGenerated(); - - var types = symbols.Select(x => x.ToDisplayString()).ToArray(); - types.Should().Contain("TempProject.Generated.Formatters.TempProject.MyGenericObjectFormatter"); - - var formatters = symbols.SelectMany(x => x.Interfaces).Select(x => x.ToDisplayString()).ToArray(); - formatters.Should().Contain("MessagePack.Formatters.IMessagePackFormatter>"); - - compilation.GetResolverKnownFormatterTypes().Should().Contain(new[] - { - "TempProject.Generated.Formatters.TempProject.MyGenericObjectFormatter>", - "TempProject.Generated.Formatters.TempProject.MyGenericObjectFormatter", - "TempProject.Generated.Formatters.TempProject.MyObjectFormatter", - "TempProject.Generated.Formatters.TempProject.MyObjectNestedFormatter", - }); - } - } -} diff --git a/tests/MessagePack.SourceGenerator.Tests/GenerationTests.cs b/tests/MessagePack.SourceGenerator.Tests/GenerationTests.cs index be98ce9f0..41d84a339 100644 --- a/tests/MessagePack.SourceGenerator.Tests/GenerationTests.cs +++ b/tests/MessagePack.SourceGenerator.Tests/GenerationTests.cs @@ -1,7 +1,6 @@ // Copyright (c) All contributors. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -using System.ComponentModel; using MessagePack.SourceGenerator.Tests; public class GenerationTests diff --git a/tests/MessagePack.SourceGenerator.Tests/GenericsFormatterTests.cs b/tests/MessagePack.SourceGenerator.Tests/GenericsFormatterTests.cs new file mode 100644 index 000000000..84ed2fe29 --- /dev/null +++ b/tests/MessagePack.SourceGenerator.Tests/GenericsFormatterTests.cs @@ -0,0 +1,491 @@ +// Copyright (c) All contributors. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using Microsoft.CodeAnalysis; + +public class GenericsFormatterTests +{ + [Fact] + public async Task NullableFormatter() + { + string testSource = """ +using System; +using System.Collections.Generic; +using MessagePack; + +namespace TempProject +{ + [MessagePackObject] + public class MyObject + { + [Key(0)] + public int? ValueNullableInt { get; set; } + [Key(1)] + public MyEnum? ValueNullableEnum { get; set; } + [Key(2)] + public ValueTuple? ValueNullableStruct { get; set; } + } + + public enum MyEnum + { + A, B, C + } +} +"""; + await VerifyCS.Test.RunDefaultAsync(testSource); + } + + [Fact] + public async Task WellKnownGenericsFormatter() + { + string testSource = """ +using System; +using System.Collections.Generic; +using MessagePack; + +namespace TempProject +{ + [MessagePackObject] + public class MyObject + { + [Key(0)] + public List ValueList { get; set; } + [Key(1)] + public List> ValueListNested { get; set; } + [Key(2)] + public ValueTuple ValueValueTuple { get; set; } + } +} +"""; + await VerifyCS.Test.RunDefaultAsync(testSource); + } + + [Fact] + public async Task GenericsUnionFormatter() + { + string testSource = """ +using System; +using System.Collections.Generic; +using MessagePack; + +namespace TempProject +{ + [MessagePackObject] + [Union(0, typeof(Wrapper))] + [Union(1, typeof(Wrapper))] + [Union(2, typeof(Wrapper>))] + public class Wrapper + { + [Key(0)] + public T Content { get; set; } + } +} +"""; + await VerifyCS.Test.RunDefaultAsync(testSource); + } + + [Fact] + public async Task GenericsUnionFormatter_Nested() + { + string testSource = """ +using System; +using System.Collections.Generic; +using MessagePack; + +namespace TempProject +{ + [MessagePackObject] + [Union(0, typeof(Wrapper))] + [Union(1, typeof(Wrapper))] + [Union(2, typeof(Wrapper>))] + public class Wrapper + { + [Key(0)] + public List Content1 { get; set; } + [Key(1)] + public MyGenericObject Content2 { get; set; } + } + + [MessagePackObject] + public class MyGenericObject + { + [Key(0)] + public MyInnerGenericObject Content { get; set; } + } + + [MessagePackObject] + public class MyInnerGenericObject + { + } +} +"""; + await VerifyCS.Test.RunDefaultAsync(testSource); + } + + [Fact] + public async Task NestedGenericTypes() + { + string testSource = """ +using System; +using System.Collections.Generic; +using MessagePack; + +namespace TempProject +{ + [MessagePackObject] + public class MyObject : Wrapper + { + } + + [MessagePackObject] + public class MyObject2 + {} + + [MessagePackObject] + public class Wrapper + { + [Key(0)] + public List Content1 { get; set; } + [Key(1)] + public MyGenericObject Content2 { get; set; } + } + + [MessagePackObject] + public class MyGenericObject + { + [Key(0)] + public MyInnerGenericObject Content { get; set; } + [Key(1)] + public T[] Content2 { get; set; } + } + + [MessagePackObject] + public class MyInnerGenericObject + { + } +} +"""; + await VerifyCS.Test.RunDefaultAsync(testSource); + } + + [Fact] + public async Task GenericsOfTFormatter_WithKnownTypes() + { + string testSource = """ +using System; +using System.Collections.Generic; +using MessagePack; + +namespace TempProject +{ + [MessagePackObject] + public class MyObject : MyGenericObject + { + } + + [MessagePackObject] + public class MyObject2 + { } + + [MessagePackObject] + public class MyGenericObject + { + [Key(0)] + public List Content1 { get; set; } + [Key(1)] + public T[] Content2 { get; set; } + } +} +"""; + await VerifyCS.Test.RunDefaultAsync(testSource); + } + + [Fact] + public async Task GenericsOfTFormatter() + { + string testSource = """ +using System; +using System.Collections.Generic; +using MessagePack; + +namespace TempProject +{ + [MessagePackObject] + public class MyGenericObject + { + [Key(0)] + public T Content { get; set; } + } + + [MessagePackObject] + public class MyObject + { + [Key(0)] + public MyGenericObject Value { get; set; } + } + + [MessagePackObject] + public class MyObjectNested + { + [Key(0)] + public MyGenericObject> Value { get; set; } + } +} +"""; + await VerifyCS.Test.RunDefaultAsync(testSource); + } + + [Fact] + public async Task GenericsOfT1T2Formatter() + { + string testSource = """ +using System; +using System.Collections.Generic; +using MessagePack; + +namespace TempProject +{ + [MessagePackObject] + public class MyGenericObject + { + [Key(0)] + public T1 ValueA { get; set; } + [Key(1)] + public T2 ValueB { get; set; } + } + + [MessagePackObject] + public class MyObject + { + [Key(0)] + public MyGenericObject Value { get; set; } + } + + [MessagePackObject] + public class MyObjectNested + { + [Key(0)] + public MyGenericObject, MyGenericObject> Value { get; set; } + } +} +"""; + await VerifyCS.Test.RunDefaultAsync(testSource); + } + + [Fact] + public async Task GenericsOfTFormatter_FormatterOnly() + { + string testSource = """ +using System; +using System.Collections.Generic; +using MessagePack; + +namespace TempProject +{ + // This type is not used by the project. + // It may be referenced by other projects. + [MessagePackObject] + public class MyGenericObject + { + [Key(0)] + public T Content { get; set; } + } +} +"""; + await VerifyCS.Test.RunDefaultAsync(testSource); + } + + [Fact] + public async Task Generics_Constraints_Type() + { + string testSource = """ +using System; +using System.Collections.Generic; +using MessagePack; + +namespace TempProject +{ + [MessagePackObject] + public class MyGenericObject + where T : IDisposable + { + [Key(0)] + public T Content { get; set; } + } +} +"""; + await VerifyCS.Test.RunDefaultAsync(testSource); + } + + [Fact] + public async Task Generics_Constraints_NullableReferenceType() + { + string testSource = """ +#nullable enable + +using System; +using System.Collections.Generic; +using MessagePack; + +namespace TempProject +{ + [MessagePackObject] + public class MyGenericObject + where T1 : MyClass? + where T2 : MyClass + where T3 : MyGenericClass?>? + where T4 : MyClass, IMyInterface? + { + [Key(0)] + public T1? Content { get; set; } + } + + public class MyClass {} + public class MyGenericClass {} + public interface IMyInterface {} +} +"""; + await VerifyCS.Test.RunDefaultAsync(testSource); + } + + [Fact] + public async Task Generics_Constraints_Struct() + { + string testSource = """ +using System; +using System.Collections.Generic; +using MessagePack; + +namespace TempProject +{ + [MessagePackObject] + public class MyGenericObject + where T : struct + { + [Key(0)] + public T Content { get; set; } + } +} +"""; + await VerifyCS.Test.RunDefaultAsync(testSource); + } + + [Fact] + public async Task Generics_Constraints_Multiple() + { + string testSource = """ +using System; +using System.Collections.Generic; +using MessagePack; + +namespace TempProject +{ + [MessagePackObject] + public class MyGenericObject + where T1 : struct + where T2 : IDisposable, new() + where T3 : notnull + where T4 : unmanaged + { + [Key(0)] + public T1 Content1 { get; set; } + [Key(1)] + public T2 Content2 { get; set; } + [Key(2)] + public T3 Content3 { get; set; } + [Key(3)] + public T4 Content4 { get; set; } + } +} +"""; + await VerifyCS.Test.RunDefaultAsync(testSource); + } + + [Fact] + public async Task Generics_Constraints_ReferenceType_Nullable() + { + string testSource = """ +#nullable enable + +using System; +using System.Collections.Generic; +using MessagePack; + +namespace TempProject +{ + [MessagePackObject] + public class MyGenericObject + where T1 : class? + where T2 : class + { + [Key(0)] + public T1? Content1 { get; set; } + [Key(1)] + public T2? Content2 { get; set; } + } +} +"""; + await VerifyCS.Test.RunDefaultAsync(testSource); + } + + [Fact] + public async Task Generics_Defined_In_ReferencedProject() + { + string defineSource = """ +using System; +using System.Collections.Generic; +using MessagePack; + +namespace TempProject +{ + [MessagePackObject] + public class MyGenericObject + { + [Key(0)] + public T Content { get; set; } + } +} +"""; + + string usageSource = """ +using System; +using System.Collections.Generic; +using MessagePack; + +namespace TempProject +{ + [MessagePackObject] + public class MyObject + { + [Key(0)] + public MyGenericObject Value { get; set; } + } + + [MessagePackObject] + public class MyObjectNested + { + [Key(0)] + public MyGenericObject> Value { get; set; } + } +} +"""; + await new VerifyCS.Test + { + TestState = + { + Sources = { usageSource }, + AdditionalProjects = + { + { + "DefiningProject", + new Microsoft.CodeAnalysis.Testing.ProjectState("DefiningProject", LanguageNames.CSharp, string.Empty, ".cs") + { + Sources = { defineSource }, + } + }, + }, + AdditionalProjectReferences = { "DefiningProject" }, + }, + }.RunAsync(); + } +} diff --git a/tests/MessagePack.SourceGenerator.Tests/MessagePack.SourceGenerator.Tests.csproj b/tests/MessagePack.SourceGenerator.Tests/MessagePack.SourceGenerator.Tests.csproj index 47e33e61b..231e762a7 100644 --- a/tests/MessagePack.SourceGenerator.Tests/MessagePack.SourceGenerator.Tests.csproj +++ b/tests/MessagePack.SourceGenerator.Tests/MessagePack.SourceGenerator.Tests.csproj @@ -8,7 +8,6 @@ - diff --git a/tests/MessagePack.SourceGenerator.Tests/Resources/GenericsOfT1T2Formatter/Formatters.TempProject.MyGenericObjectFormatter_T1, T2_.g.cs b/tests/MessagePack.SourceGenerator.Tests/Resources/GenericsOfT1T2Formatter/Formatters.TempProject.MyGenericObjectFormatter_T1, T2_.g.cs new file mode 100644 index 000000000..b4ba2263f --- /dev/null +++ b/tests/MessagePack.SourceGenerator.Tests/Resources/GenericsOfT1T2Formatter/Formatters.TempProject.MyGenericObjectFormatter_T1, T2_.g.cs @@ -0,0 +1,58 @@ +// + +#pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 + +namespace Formatters.TempProject +{ + using MsgPack = global::MessagePack; + + internal sealed class MyGenericObjectFormatter : MsgPack::Formatters.IMessagePackFormatter> + { + + public void Serialize(ref MsgPack::MessagePackWriter writer, global::TempProject.MyGenericObject value, MsgPack::MessagePackSerializerOptions options) + { + if (value == null) + { + writer.WriteNil(); + return; + } + + MsgPack::IFormatterResolver formatterResolver = options.Resolver; + writer.WriteArrayHeader(2); + MsgPack::FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Serialize(ref writer, value.ValueA, options); + MsgPack::FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Serialize(ref writer, value.ValueB, options); + } + + public global::TempProject.MyGenericObject Deserialize(ref MsgPack::MessagePackReader reader, MsgPack::MessagePackSerializerOptions options) + { + if (reader.TryReadNil()) + { + return null; + } + + options.Security.DepthStep(ref reader); + MsgPack::IFormatterResolver formatterResolver = options.Resolver; + var length = reader.ReadArrayHeader(); + var ____result = new global::TempProject.MyGenericObject(); + + for (int i = 0; i < length; i++) + { + switch (i) + { + case 0: + ____result.ValueA = MsgPack::FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Deserialize(ref reader, options); + break; + case 1: + ____result.ValueB = MsgPack::FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Deserialize(ref reader, options); + break; + default: + reader.Skip(); + break; + } + } + + reader.Depth--; + return ____result; + } + } +} diff --git a/tests/MessagePack.SourceGenerator.Tests/Resources/GenericsOfT1T2Formatter/Formatters.TempProject.MyObjectFormatter.g.cs b/tests/MessagePack.SourceGenerator.Tests/Resources/GenericsOfT1T2Formatter/Formatters.TempProject.MyObjectFormatter.g.cs new file mode 100644 index 000000000..6e23fac50 --- /dev/null +++ b/tests/MessagePack.SourceGenerator.Tests/Resources/GenericsOfT1T2Formatter/Formatters.TempProject.MyObjectFormatter.g.cs @@ -0,0 +1,54 @@ +// + +#pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 + +namespace Formatters.TempProject +{ + using MsgPack = global::MessagePack; + + internal sealed class MyObjectFormatter : MsgPack::Formatters.IMessagePackFormatter + { + + public void Serialize(ref MsgPack::MessagePackWriter writer, global::TempProject.MyObject value, MsgPack::MessagePackSerializerOptions options) + { + if (value == null) + { + writer.WriteNil(); + return; + } + + MsgPack::IFormatterResolver formatterResolver = options.Resolver; + writer.WriteArrayHeader(1); + MsgPack::FormatterResolverExtensions.GetFormatterWithVerify>(formatterResolver).Serialize(ref writer, value.Value, options); + } + + public global::TempProject.MyObject Deserialize(ref MsgPack::MessagePackReader reader, MsgPack::MessagePackSerializerOptions options) + { + if (reader.TryReadNil()) + { + return null; + } + + options.Security.DepthStep(ref reader); + MsgPack::IFormatterResolver formatterResolver = options.Resolver; + var length = reader.ReadArrayHeader(); + var ____result = new global::TempProject.MyObject(); + + for (int i = 0; i < length; i++) + { + switch (i) + { + case 0: + ____result.Value = MsgPack::FormatterResolverExtensions.GetFormatterWithVerify>(formatterResolver).Deserialize(ref reader, options); + break; + default: + reader.Skip(); + break; + } + } + + reader.Depth--; + return ____result; + } + } +} diff --git a/tests/MessagePack.SourceGenerator.Tests/Resources/GenericsOfT1T2Formatter/Formatters.TempProject.MyObjectNestedFormatter.g.cs b/tests/MessagePack.SourceGenerator.Tests/Resources/GenericsOfT1T2Formatter/Formatters.TempProject.MyObjectNestedFormatter.g.cs new file mode 100644 index 000000000..b96019006 --- /dev/null +++ b/tests/MessagePack.SourceGenerator.Tests/Resources/GenericsOfT1T2Formatter/Formatters.TempProject.MyObjectNestedFormatter.g.cs @@ -0,0 +1,54 @@ +// + +#pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 + +namespace Formatters.TempProject +{ + using MsgPack = global::MessagePack; + + internal sealed class MyObjectNestedFormatter : MsgPack::Formatters.IMessagePackFormatter + { + + public void Serialize(ref MsgPack::MessagePackWriter writer, global::TempProject.MyObjectNested value, MsgPack::MessagePackSerializerOptions options) + { + if (value == null) + { + writer.WriteNil(); + return; + } + + MsgPack::IFormatterResolver formatterResolver = options.Resolver; + writer.WriteArrayHeader(1); + MsgPack::FormatterResolverExtensions.GetFormatterWithVerify, global::TempProject.MyGenericObject>>(formatterResolver).Serialize(ref writer, value.Value, options); + } + + public global::TempProject.MyObjectNested Deserialize(ref MsgPack::MessagePackReader reader, MsgPack::MessagePackSerializerOptions options) + { + if (reader.TryReadNil()) + { + return null; + } + + options.Security.DepthStep(ref reader); + MsgPack::IFormatterResolver formatterResolver = options.Resolver; + var length = reader.ReadArrayHeader(); + var ____result = new global::TempProject.MyObjectNested(); + + for (int i = 0; i < length; i++) + { + switch (i) + { + case 0: + ____result.Value = MsgPack::FormatterResolverExtensions.GetFormatterWithVerify, global::TempProject.MyGenericObject>>(formatterResolver).Deserialize(ref reader, options); + break; + default: + reader.Skip(); + break; + } + } + + reader.Depth--; + return ____result; + } + } +} diff --git a/tests/MessagePack.SourceGenerator.Tests/Resources/GenericsOfT1T2Formatter/MessagePack.GeneratedMessagePackResolver.g.cs b/tests/MessagePack.SourceGenerator.Tests/Resources/GenericsOfT1T2Formatter/MessagePack.GeneratedMessagePackResolver.g.cs new file mode 100644 index 000000000..8db2e3ea9 --- /dev/null +++ b/tests/MessagePack.SourceGenerator.Tests/Resources/GenericsOfT1T2Formatter/MessagePack.GeneratedMessagePackResolver.g.cs @@ -0,0 +1,76 @@ +// + +#pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 + +namespace MessagePack +{ + using MsgPack = global::MessagePack; + using Formatters = global::Formatters; + + /// A MessagePack resolver that uses generated formatters for types in this assembly. + internal class GeneratedMessagePackResolver : MsgPack::IFormatterResolver + { + /// An instance of this resolver that only returns formatters specifically generated for types in this assembly. + public static readonly MsgPack::IFormatterResolver Instance = new GeneratedMessagePackResolver(); + + /// An instance of this resolver that returns standard AOT-compatible formatters as well as formatters specifically generated for types in this assembly. + public static readonly MsgPack::IFormatterResolver InstanceWithStandardAotResolver = MsgPack::Resolvers.CompositeResolver.Create(Instance, MsgPack::Resolvers.StandardAotResolver.Instance); + + private GeneratedMessagePackResolver() + { + } + + public MsgPack::Formatters.IMessagePackFormatter GetFormatter() + { + return FormatterCache.Formatter; + } + + private static class FormatterCache + { + internal static readonly MsgPack::Formatters.IMessagePackFormatter Formatter; + + static FormatterCache() + { + var f = GeneratedMessagePackResolverGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + Formatter = (MsgPack::Formatters.IMessagePackFormatter)f; + } + } + } + } + + internal static class GeneratedMessagePackResolverGetFormatterHelper + { + private static readonly global::System.Collections.Generic.Dictionary lookup; + + static GeneratedMessagePackResolverGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(4) + { + { typeof(global::TempProject.MyGenericObject, global::TempProject.MyGenericObject>), 0 }, + { typeof(global::TempProject.MyGenericObject), 1 }, + { typeof(global::TempProject.MyObject), 2 }, + { typeof(global::TempProject.MyObjectNested), 3 }, + }; + } + + internal static object GetFormatter(global::System.Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + case 0: return new Formatters::TempProject.MyGenericObjectFormatter, global::TempProject.MyGenericObject>(); + case 1: return new Formatters::TempProject.MyGenericObjectFormatter(); + case 2: return new Formatters::TempProject.MyObjectFormatter(); + case 3: return new Formatters::TempProject.MyObjectNestedFormatter(); + default: return null; + } + } + } +} diff --git a/tests/MessagePack.SourceGenerator.Tests/Resources/GenericsOfTFormatter/Formatters.TempProject.MyGenericObjectFormatter_T_.g.cs b/tests/MessagePack.SourceGenerator.Tests/Resources/GenericsOfTFormatter/Formatters.TempProject.MyGenericObjectFormatter_T_.g.cs new file mode 100644 index 000000000..0c6c03f50 --- /dev/null +++ b/tests/MessagePack.SourceGenerator.Tests/Resources/GenericsOfTFormatter/Formatters.TempProject.MyGenericObjectFormatter_T_.g.cs @@ -0,0 +1,54 @@ +// + +#pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 + +namespace Formatters.TempProject +{ + using MsgPack = global::MessagePack; + + internal sealed class MyGenericObjectFormatter : MsgPack::Formatters.IMessagePackFormatter> + { + + public void Serialize(ref MsgPack::MessagePackWriter writer, global::TempProject.MyGenericObject value, MsgPack::MessagePackSerializerOptions options) + { + if (value == null) + { + writer.WriteNil(); + return; + } + + MsgPack::IFormatterResolver formatterResolver = options.Resolver; + writer.WriteArrayHeader(1); + MsgPack::FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Serialize(ref writer, value.Content, options); + } + + public global::TempProject.MyGenericObject Deserialize(ref MsgPack::MessagePackReader reader, MsgPack::MessagePackSerializerOptions options) + { + if (reader.TryReadNil()) + { + return null; + } + + options.Security.DepthStep(ref reader); + MsgPack::IFormatterResolver formatterResolver = options.Resolver; + var length = reader.ReadArrayHeader(); + var ____result = new global::TempProject.MyGenericObject(); + + for (int i = 0; i < length; i++) + { + switch (i) + { + case 0: + ____result.Content = MsgPack::FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Deserialize(ref reader, options); + break; + default: + reader.Skip(); + break; + } + } + + reader.Depth--; + return ____result; + } + } +} diff --git a/tests/MessagePack.SourceGenerator.Tests/Resources/GenericsOfTFormatter/Formatters.TempProject.MyObjectFormatter.g.cs b/tests/MessagePack.SourceGenerator.Tests/Resources/GenericsOfTFormatter/Formatters.TempProject.MyObjectFormatter.g.cs new file mode 100644 index 000000000..d1e3f850d --- /dev/null +++ b/tests/MessagePack.SourceGenerator.Tests/Resources/GenericsOfTFormatter/Formatters.TempProject.MyObjectFormatter.g.cs @@ -0,0 +1,54 @@ +// + +#pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 + +namespace Formatters.TempProject +{ + using MsgPack = global::MessagePack; + + internal sealed class MyObjectFormatter : MsgPack::Formatters.IMessagePackFormatter + { + + public void Serialize(ref MsgPack::MessagePackWriter writer, global::TempProject.MyObject value, MsgPack::MessagePackSerializerOptions options) + { + if (value == null) + { + writer.WriteNil(); + return; + } + + MsgPack::IFormatterResolver formatterResolver = options.Resolver; + writer.WriteArrayHeader(1); + MsgPack::FormatterResolverExtensions.GetFormatterWithVerify>(formatterResolver).Serialize(ref writer, value.Value, options); + } + + public global::TempProject.MyObject Deserialize(ref MsgPack::MessagePackReader reader, MsgPack::MessagePackSerializerOptions options) + { + if (reader.TryReadNil()) + { + return null; + } + + options.Security.DepthStep(ref reader); + MsgPack::IFormatterResolver formatterResolver = options.Resolver; + var length = reader.ReadArrayHeader(); + var ____result = new global::TempProject.MyObject(); + + for (int i = 0; i < length; i++) + { + switch (i) + { + case 0: + ____result.Value = MsgPack::FormatterResolverExtensions.GetFormatterWithVerify>(formatterResolver).Deserialize(ref reader, options); + break; + default: + reader.Skip(); + break; + } + } + + reader.Depth--; + return ____result; + } + } +} diff --git a/tests/MessagePack.SourceGenerator.Tests/Resources/GenericsOfTFormatter/Formatters.TempProject.MyObjectNestedFormatter.g.cs b/tests/MessagePack.SourceGenerator.Tests/Resources/GenericsOfTFormatter/Formatters.TempProject.MyObjectNestedFormatter.g.cs new file mode 100644 index 000000000..2589b533c --- /dev/null +++ b/tests/MessagePack.SourceGenerator.Tests/Resources/GenericsOfTFormatter/Formatters.TempProject.MyObjectNestedFormatter.g.cs @@ -0,0 +1,54 @@ +// + +#pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 + +namespace Formatters.TempProject +{ + using MsgPack = global::MessagePack; + + internal sealed class MyObjectNestedFormatter : MsgPack::Formatters.IMessagePackFormatter + { + + public void Serialize(ref MsgPack::MessagePackWriter writer, global::TempProject.MyObjectNested value, MsgPack::MessagePackSerializerOptions options) + { + if (value == null) + { + writer.WriteNil(); + return; + } + + MsgPack::IFormatterResolver formatterResolver = options.Resolver; + writer.WriteArrayHeader(1); + MsgPack::FormatterResolverExtensions.GetFormatterWithVerify>>(formatterResolver).Serialize(ref writer, value.Value, options); + } + + public global::TempProject.MyObjectNested Deserialize(ref MsgPack::MessagePackReader reader, MsgPack::MessagePackSerializerOptions options) + { + if (reader.TryReadNil()) + { + return null; + } + + options.Security.DepthStep(ref reader); + MsgPack::IFormatterResolver formatterResolver = options.Resolver; + var length = reader.ReadArrayHeader(); + var ____result = new global::TempProject.MyObjectNested(); + + for (int i = 0; i < length; i++) + { + switch (i) + { + case 0: + ____result.Value = MsgPack::FormatterResolverExtensions.GetFormatterWithVerify>>(formatterResolver).Deserialize(ref reader, options); + break; + default: + reader.Skip(); + break; + } + } + + reader.Depth--; + return ____result; + } + } +} diff --git a/tests/MessagePack.SourceGenerator.Tests/Resources/GenericsOfTFormatter/MessagePack.GeneratedMessagePackResolver.g.cs b/tests/MessagePack.SourceGenerator.Tests/Resources/GenericsOfTFormatter/MessagePack.GeneratedMessagePackResolver.g.cs new file mode 100644 index 000000000..059e46fd0 --- /dev/null +++ b/tests/MessagePack.SourceGenerator.Tests/Resources/GenericsOfTFormatter/MessagePack.GeneratedMessagePackResolver.g.cs @@ -0,0 +1,76 @@ +// + +#pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 + +namespace MessagePack +{ + using MsgPack = global::MessagePack; + using Formatters = global::Formatters; + + /// A MessagePack resolver that uses generated formatters for types in this assembly. + internal class GeneratedMessagePackResolver : MsgPack::IFormatterResolver + { + /// An instance of this resolver that only returns formatters specifically generated for types in this assembly. + public static readonly MsgPack::IFormatterResolver Instance = new GeneratedMessagePackResolver(); + + /// An instance of this resolver that returns standard AOT-compatible formatters as well as formatters specifically generated for types in this assembly. + public static readonly MsgPack::IFormatterResolver InstanceWithStandardAotResolver = MsgPack::Resolvers.CompositeResolver.Create(Instance, MsgPack::Resolvers.StandardAotResolver.Instance); + + private GeneratedMessagePackResolver() + { + } + + public MsgPack::Formatters.IMessagePackFormatter GetFormatter() + { + return FormatterCache.Formatter; + } + + private static class FormatterCache + { + internal static readonly MsgPack::Formatters.IMessagePackFormatter Formatter; + + static FormatterCache() + { + var f = GeneratedMessagePackResolverGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + Formatter = (MsgPack::Formatters.IMessagePackFormatter)f; + } + } + } + } + + internal static class GeneratedMessagePackResolverGetFormatterHelper + { + private static readonly global::System.Collections.Generic.Dictionary lookup; + + static GeneratedMessagePackResolverGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(4) + { + { typeof(global::TempProject.MyGenericObject>), 0 }, + { typeof(global::TempProject.MyGenericObject), 1 }, + { typeof(global::TempProject.MyObject), 2 }, + { typeof(global::TempProject.MyObjectNested), 3 }, + }; + } + + internal static object GetFormatter(global::System.Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + case 0: return new Formatters::TempProject.MyGenericObjectFormatter>(); + case 1: return new Formatters::TempProject.MyGenericObjectFormatter(); + case 2: return new Formatters::TempProject.MyObjectFormatter(); + case 3: return new Formatters::TempProject.MyObjectNestedFormatter(); + default: return null; + } + } + } +} diff --git a/tests/MessagePack.SourceGenerator.Tests/Resources/GenericsOfTFormatter_FormatterOnly/Formatters.TempProject.MyGenericObjectFormatter_T_.g.cs b/tests/MessagePack.SourceGenerator.Tests/Resources/GenericsOfTFormatter_FormatterOnly/Formatters.TempProject.MyGenericObjectFormatter_T_.g.cs new file mode 100644 index 000000000..0c6c03f50 --- /dev/null +++ b/tests/MessagePack.SourceGenerator.Tests/Resources/GenericsOfTFormatter_FormatterOnly/Formatters.TempProject.MyGenericObjectFormatter_T_.g.cs @@ -0,0 +1,54 @@ +// + +#pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 + +namespace Formatters.TempProject +{ + using MsgPack = global::MessagePack; + + internal sealed class MyGenericObjectFormatter : MsgPack::Formatters.IMessagePackFormatter> + { + + public void Serialize(ref MsgPack::MessagePackWriter writer, global::TempProject.MyGenericObject value, MsgPack::MessagePackSerializerOptions options) + { + if (value == null) + { + writer.WriteNil(); + return; + } + + MsgPack::IFormatterResolver formatterResolver = options.Resolver; + writer.WriteArrayHeader(1); + MsgPack::FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Serialize(ref writer, value.Content, options); + } + + public global::TempProject.MyGenericObject Deserialize(ref MsgPack::MessagePackReader reader, MsgPack::MessagePackSerializerOptions options) + { + if (reader.TryReadNil()) + { + return null; + } + + options.Security.DepthStep(ref reader); + MsgPack::IFormatterResolver formatterResolver = options.Resolver; + var length = reader.ReadArrayHeader(); + var ____result = new global::TempProject.MyGenericObject(); + + for (int i = 0; i < length; i++) + { + switch (i) + { + case 0: + ____result.Content = MsgPack::FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Deserialize(ref reader, options); + break; + default: + reader.Skip(); + break; + } + } + + reader.Depth--; + return ____result; + } + } +} diff --git a/tests/MessagePack.SourceGenerator.Tests/Resources/GenericsOfTFormatter_FormatterOnly/MessagePack.GeneratedMessagePackResolver.g.cs b/tests/MessagePack.SourceGenerator.Tests/Resources/GenericsOfTFormatter_FormatterOnly/MessagePack.GeneratedMessagePackResolver.g.cs new file mode 100644 index 000000000..e5a757c0b --- /dev/null +++ b/tests/MessagePack.SourceGenerator.Tests/Resources/GenericsOfTFormatter_FormatterOnly/MessagePack.GeneratedMessagePackResolver.g.cs @@ -0,0 +1,68 @@ +// + +#pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 + +namespace MessagePack +{ + using MsgPack = global::MessagePack; + using Formatters = global::Formatters; + + /// A MessagePack resolver that uses generated formatters for types in this assembly. + internal class GeneratedMessagePackResolver : MsgPack::IFormatterResolver + { + /// An instance of this resolver that only returns formatters specifically generated for types in this assembly. + public static readonly MsgPack::IFormatterResolver Instance = new GeneratedMessagePackResolver(); + + /// An instance of this resolver that returns standard AOT-compatible formatters as well as formatters specifically generated for types in this assembly. + public static readonly MsgPack::IFormatterResolver InstanceWithStandardAotResolver = MsgPack::Resolvers.CompositeResolver.Create(Instance, MsgPack::Resolvers.StandardAotResolver.Instance); + + private GeneratedMessagePackResolver() + { + } + + public MsgPack::Formatters.IMessagePackFormatter GetFormatter() + { + return FormatterCache.Formatter; + } + + private static class FormatterCache + { + internal static readonly MsgPack::Formatters.IMessagePackFormatter Formatter; + + static FormatterCache() + { + var f = GeneratedMessagePackResolverGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + Formatter = (MsgPack::Formatters.IMessagePackFormatter)f; + } + } + } + } + + internal static class GeneratedMessagePackResolverGetFormatterHelper + { + private static readonly global::System.Collections.Generic.Dictionary lookup; + + static GeneratedMessagePackResolverGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(0) + { + }; + } + + internal static object GetFormatter(global::System.Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + default: return null; + } + } + } +} diff --git a/tests/MessagePack.SourceGenerator.Tests/Resources/GenericsOfTFormatter_WithKnownTypes/Formatters.TempProject.MyGenericObjectFormatter_T_.g.cs b/tests/MessagePack.SourceGenerator.Tests/Resources/GenericsOfTFormatter_WithKnownTypes/Formatters.TempProject.MyGenericObjectFormatter_T_.g.cs new file mode 100644 index 000000000..db81f0058 --- /dev/null +++ b/tests/MessagePack.SourceGenerator.Tests/Resources/GenericsOfTFormatter_WithKnownTypes/Formatters.TempProject.MyGenericObjectFormatter_T_.g.cs @@ -0,0 +1,58 @@ +// + +#pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 + +namespace Formatters.TempProject +{ + using MsgPack = global::MessagePack; + + internal sealed class MyGenericObjectFormatter : MsgPack::Formatters.IMessagePackFormatter> + { + + public void Serialize(ref MsgPack::MessagePackWriter writer, global::TempProject.MyGenericObject value, MsgPack::MessagePackSerializerOptions options) + { + if (value == null) + { + writer.WriteNil(); + return; + } + + MsgPack::IFormatterResolver formatterResolver = options.Resolver; + writer.WriteArrayHeader(2); + MsgPack::FormatterResolverExtensions.GetFormatterWithVerify>(formatterResolver).Serialize(ref writer, value.Content1, options); + MsgPack::FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Serialize(ref writer, value.Content2, options); + } + + public global::TempProject.MyGenericObject Deserialize(ref MsgPack::MessagePackReader reader, MsgPack::MessagePackSerializerOptions options) + { + if (reader.TryReadNil()) + { + return null; + } + + options.Security.DepthStep(ref reader); + MsgPack::IFormatterResolver formatterResolver = options.Resolver; + var length = reader.ReadArrayHeader(); + var ____result = new global::TempProject.MyGenericObject(); + + for (int i = 0; i < length; i++) + { + switch (i) + { + case 0: + ____result.Content1 = MsgPack::FormatterResolverExtensions.GetFormatterWithVerify>(formatterResolver).Deserialize(ref reader, options); + break; + case 1: + ____result.Content2 = MsgPack::FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Deserialize(ref reader, options); + break; + default: + reader.Skip(); + break; + } + } + + reader.Depth--; + return ____result; + } + } +} diff --git a/tests/MessagePack.SourceGenerator.Tests/Resources/GenericsOfTFormatter_WithKnownTypes/Formatters.TempProject.MyObject2Formatter.g.cs b/tests/MessagePack.SourceGenerator.Tests/Resources/GenericsOfTFormatter_WithKnownTypes/Formatters.TempProject.MyObject2Formatter.g.cs new file mode 100644 index 000000000..1b380326a --- /dev/null +++ b/tests/MessagePack.SourceGenerator.Tests/Resources/GenericsOfTFormatter_WithKnownTypes/Formatters.TempProject.MyObject2Formatter.g.cs @@ -0,0 +1,34 @@ +// + +#pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 + +namespace Formatters.TempProject +{ + using MsgPack = global::MessagePack; + + internal sealed class MyObject2Formatter : MsgPack::Formatters.IMessagePackFormatter + { + + public void Serialize(ref MsgPack::MessagePackWriter writer, global::TempProject.MyObject2 value, MsgPack::MessagePackSerializerOptions options) + { + if (value == null) + { + writer.WriteNil(); + return; + } + + writer.WriteArrayHeader(0); + } + + public global::TempProject.MyObject2 Deserialize(ref MsgPack::MessagePackReader reader, MsgPack::MessagePackSerializerOptions options) + { + if (reader.TryReadNil()) + { + return null; + } + + reader.Skip(); + return new global::TempProject.MyObject2(); + } + } +} diff --git a/tests/MessagePack.SourceGenerator.Tests/Resources/GenericsOfTFormatter_WithKnownTypes/Formatters.TempProject.MyObjectFormatter.g.cs b/tests/MessagePack.SourceGenerator.Tests/Resources/GenericsOfTFormatter_WithKnownTypes/Formatters.TempProject.MyObjectFormatter.g.cs new file mode 100644 index 000000000..0199bf628 --- /dev/null +++ b/tests/MessagePack.SourceGenerator.Tests/Resources/GenericsOfTFormatter_WithKnownTypes/Formatters.TempProject.MyObjectFormatter.g.cs @@ -0,0 +1,58 @@ +// + +#pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 + +namespace Formatters.TempProject +{ + using MsgPack = global::MessagePack; + + internal sealed class MyObjectFormatter : MsgPack::Formatters.IMessagePackFormatter + { + + public void Serialize(ref MsgPack::MessagePackWriter writer, global::TempProject.MyObject value, MsgPack::MessagePackSerializerOptions options) + { + if (value == null) + { + writer.WriteNil(); + return; + } + + MsgPack::IFormatterResolver formatterResolver = options.Resolver; + writer.WriteArrayHeader(2); + MsgPack::FormatterResolverExtensions.GetFormatterWithVerify>(formatterResolver).Serialize(ref writer, value.Content1, options); + MsgPack::FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Serialize(ref writer, value.Content2, options); + } + + public global::TempProject.MyObject Deserialize(ref MsgPack::MessagePackReader reader, MsgPack::MessagePackSerializerOptions options) + { + if (reader.TryReadNil()) + { + return null; + } + + options.Security.DepthStep(ref reader); + MsgPack::IFormatterResolver formatterResolver = options.Resolver; + var length = reader.ReadArrayHeader(); + var ____result = new global::TempProject.MyObject(); + + for (int i = 0; i < length; i++) + { + switch (i) + { + case 0: + ____result.Content1 = MsgPack::FormatterResolverExtensions.GetFormatterWithVerify>(formatterResolver).Deserialize(ref reader, options); + break; + case 1: + ____result.Content2 = MsgPack::FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Deserialize(ref reader, options); + break; + default: + reader.Skip(); + break; + } + } + + reader.Depth--; + return ____result; + } + } +} diff --git a/tests/MessagePack.SourceGenerator.Tests/Resources/GenericsOfTFormatter_WithKnownTypes/MessagePack.GeneratedMessagePackResolver.g.cs b/tests/MessagePack.SourceGenerator.Tests/Resources/GenericsOfTFormatter_WithKnownTypes/MessagePack.GeneratedMessagePackResolver.g.cs new file mode 100644 index 000000000..5b0cad507 --- /dev/null +++ b/tests/MessagePack.SourceGenerator.Tests/Resources/GenericsOfTFormatter_WithKnownTypes/MessagePack.GeneratedMessagePackResolver.g.cs @@ -0,0 +1,76 @@ +// + +#pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 + +namespace MessagePack +{ + using MsgPack = global::MessagePack; + using Formatters = global::Formatters; + + /// A MessagePack resolver that uses generated formatters for types in this assembly. + internal class GeneratedMessagePackResolver : MsgPack::IFormatterResolver + { + /// An instance of this resolver that only returns formatters specifically generated for types in this assembly. + public static readonly MsgPack::IFormatterResolver Instance = new GeneratedMessagePackResolver(); + + /// An instance of this resolver that returns standard AOT-compatible formatters as well as formatters specifically generated for types in this assembly. + public static readonly MsgPack::IFormatterResolver InstanceWithStandardAotResolver = MsgPack::Resolvers.CompositeResolver.Create(Instance, MsgPack::Resolvers.StandardAotResolver.Instance); + + private GeneratedMessagePackResolver() + { + } + + public MsgPack::Formatters.IMessagePackFormatter GetFormatter() + { + return FormatterCache.Formatter; + } + + private static class FormatterCache + { + internal static readonly MsgPack::Formatters.IMessagePackFormatter Formatter; + + static FormatterCache() + { + var f = GeneratedMessagePackResolverGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + Formatter = (MsgPack::Formatters.IMessagePackFormatter)f; + } + } + } + } + + internal static class GeneratedMessagePackResolverGetFormatterHelper + { + private static readonly global::System.Collections.Generic.Dictionary lookup; + + static GeneratedMessagePackResolverGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(4) + { + { typeof(global::System.Collections.Generic.List), 0 }, + { typeof(global::TempProject.MyObject2[]), 1 }, + { typeof(global::TempProject.MyObject), 2 }, + { typeof(global::TempProject.MyObject2), 3 }, + }; + } + + internal static object GetFormatter(global::System.Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + case 0: return new MsgPack::Formatters.ListFormatter(); + case 1: return new MsgPack::Formatters.ArrayFormatter(); + case 2: return new Formatters::TempProject.MyObjectFormatter(); + case 3: return new Formatters::TempProject.MyObject2Formatter(); + default: return null; + } + } + } +} diff --git a/tests/MessagePack.SourceGenerator.Tests/Resources/GenericsUnionFormatter/Formatters.TempProject.WrapperFormatter_T_.g.cs b/tests/MessagePack.SourceGenerator.Tests/Resources/GenericsUnionFormatter/Formatters.TempProject.WrapperFormatter_T_.g.cs new file mode 100644 index 000000000..af008ec5c --- /dev/null +++ b/tests/MessagePack.SourceGenerator.Tests/Resources/GenericsUnionFormatter/Formatters.TempProject.WrapperFormatter_T_.g.cs @@ -0,0 +1,54 @@ +// + +#pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 + +namespace Formatters.TempProject +{ + using MsgPack = global::MessagePack; + + internal sealed class WrapperFormatter : MsgPack::Formatters.IMessagePackFormatter> + { + + public void Serialize(ref MsgPack::MessagePackWriter writer, global::TempProject.Wrapper value, MsgPack::MessagePackSerializerOptions options) + { + if (value == null) + { + writer.WriteNil(); + return; + } + + MsgPack::IFormatterResolver formatterResolver = options.Resolver; + writer.WriteArrayHeader(1); + MsgPack::FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Serialize(ref writer, value.Content, options); + } + + public global::TempProject.Wrapper Deserialize(ref MsgPack::MessagePackReader reader, MsgPack::MessagePackSerializerOptions options) + { + if (reader.TryReadNil()) + { + return null; + } + + options.Security.DepthStep(ref reader); + MsgPack::IFormatterResolver formatterResolver = options.Resolver; + var length = reader.ReadArrayHeader(); + var ____result = new global::TempProject.Wrapper(); + + for (int i = 0; i < length; i++) + { + switch (i) + { + case 0: + ____result.Content = MsgPack::FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Deserialize(ref reader, options); + break; + default: + reader.Skip(); + break; + } + } + + reader.Depth--; + return ____result; + } + } +} diff --git a/tests/MessagePack.SourceGenerator.Tests/Resources/GenericsUnionFormatter/MessagePack.GeneratedMessagePackResolver.g.cs b/tests/MessagePack.SourceGenerator.Tests/Resources/GenericsUnionFormatter/MessagePack.GeneratedMessagePackResolver.g.cs new file mode 100644 index 000000000..190c83c99 --- /dev/null +++ b/tests/MessagePack.SourceGenerator.Tests/Resources/GenericsUnionFormatter/MessagePack.GeneratedMessagePackResolver.g.cs @@ -0,0 +1,76 @@ +// + +#pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 + +namespace MessagePack +{ + using MsgPack = global::MessagePack; + using Formatters = global::Formatters; + + /// A MessagePack resolver that uses generated formatters for types in this assembly. + internal class GeneratedMessagePackResolver : MsgPack::IFormatterResolver + { + /// An instance of this resolver that only returns formatters specifically generated for types in this assembly. + public static readonly MsgPack::IFormatterResolver Instance = new GeneratedMessagePackResolver(); + + /// An instance of this resolver that returns standard AOT-compatible formatters as well as formatters specifically generated for types in this assembly. + public static readonly MsgPack::IFormatterResolver InstanceWithStandardAotResolver = MsgPack::Resolvers.CompositeResolver.Create(Instance, MsgPack::Resolvers.StandardAotResolver.Instance); + + private GeneratedMessagePackResolver() + { + } + + public MsgPack::Formatters.IMessagePackFormatter GetFormatter() + { + return FormatterCache.Formatter; + } + + private static class FormatterCache + { + internal static readonly MsgPack::Formatters.IMessagePackFormatter Formatter; + + static FormatterCache() + { + var f = GeneratedMessagePackResolverGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + Formatter = (MsgPack::Formatters.IMessagePackFormatter)f; + } + } + } + } + + internal static class GeneratedMessagePackResolverGetFormatterHelper + { + private static readonly global::System.Collections.Generic.Dictionary lookup; + + static GeneratedMessagePackResolverGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(4) + { + { typeof(global::System.Collections.Generic.IEnumerable), 0 }, + { typeof(global::TempProject.Wrapper>), 1 }, + { typeof(global::TempProject.Wrapper), 2 }, + { typeof(global::TempProject.Wrapper), 3 }, + }; + } + + internal static object GetFormatter(global::System.Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + case 0: return new MsgPack::Formatters.InterfaceEnumerableFormatter(); + case 1: return new Formatters::TempProject.WrapperFormatter>(); + case 2: return new Formatters::TempProject.WrapperFormatter(); + case 3: return new Formatters::TempProject.WrapperFormatter(); + default: return null; + } + } + } +} diff --git a/tests/MessagePack.SourceGenerator.Tests/Resources/GenericsUnionFormatter_Nested/Formatters.TempProject.MyGenericObjectFormatter_T_.g.cs b/tests/MessagePack.SourceGenerator.Tests/Resources/GenericsUnionFormatter_Nested/Formatters.TempProject.MyGenericObjectFormatter_T_.g.cs new file mode 100644 index 000000000..7c6ce378f --- /dev/null +++ b/tests/MessagePack.SourceGenerator.Tests/Resources/GenericsUnionFormatter_Nested/Formatters.TempProject.MyGenericObjectFormatter_T_.g.cs @@ -0,0 +1,54 @@ +// + +#pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 + +namespace Formatters.TempProject +{ + using MsgPack = global::MessagePack; + + internal sealed class MyGenericObjectFormatter : MsgPack::Formatters.IMessagePackFormatter> + { + + public void Serialize(ref MsgPack::MessagePackWriter writer, global::TempProject.MyGenericObject value, MsgPack::MessagePackSerializerOptions options) + { + if (value == null) + { + writer.WriteNil(); + return; + } + + MsgPack::IFormatterResolver formatterResolver = options.Resolver; + writer.WriteArrayHeader(1); + MsgPack::FormatterResolverExtensions.GetFormatterWithVerify>(formatterResolver).Serialize(ref writer, value.Content, options); + } + + public global::TempProject.MyGenericObject Deserialize(ref MsgPack::MessagePackReader reader, MsgPack::MessagePackSerializerOptions options) + { + if (reader.TryReadNil()) + { + return null; + } + + options.Security.DepthStep(ref reader); + MsgPack::IFormatterResolver formatterResolver = options.Resolver; + var length = reader.ReadArrayHeader(); + var ____result = new global::TempProject.MyGenericObject(); + + for (int i = 0; i < length; i++) + { + switch (i) + { + case 0: + ____result.Content = MsgPack::FormatterResolverExtensions.GetFormatterWithVerify>(formatterResolver).Deserialize(ref reader, options); + break; + default: + reader.Skip(); + break; + } + } + + reader.Depth--; + return ____result; + } + } +} diff --git a/tests/MessagePack.SourceGenerator.Tests/Resources/GenericsUnionFormatter_Nested/Formatters.TempProject.MyInnerGenericObjectFormatter_T_.g.cs b/tests/MessagePack.SourceGenerator.Tests/Resources/GenericsUnionFormatter_Nested/Formatters.TempProject.MyInnerGenericObjectFormatter_T_.g.cs new file mode 100644 index 000000000..0fc28a2b0 --- /dev/null +++ b/tests/MessagePack.SourceGenerator.Tests/Resources/GenericsUnionFormatter_Nested/Formatters.TempProject.MyInnerGenericObjectFormatter_T_.g.cs @@ -0,0 +1,34 @@ +// + +#pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 + +namespace Formatters.TempProject +{ + using MsgPack = global::MessagePack; + + internal sealed class MyInnerGenericObjectFormatter : MsgPack::Formatters.IMessagePackFormatter> + { + + public void Serialize(ref MsgPack::MessagePackWriter writer, global::TempProject.MyInnerGenericObject value, MsgPack::MessagePackSerializerOptions options) + { + if (value == null) + { + writer.WriteNil(); + return; + } + + writer.WriteArrayHeader(0); + } + + public global::TempProject.MyInnerGenericObject Deserialize(ref MsgPack::MessagePackReader reader, MsgPack::MessagePackSerializerOptions options) + { + if (reader.TryReadNil()) + { + return null; + } + + reader.Skip(); + return new global::TempProject.MyInnerGenericObject(); + } + } +} diff --git a/tests/MessagePack.SourceGenerator.Tests/Resources/GenericsUnionFormatter_Nested/Formatters.TempProject.WrapperFormatter_T_.g.cs b/tests/MessagePack.SourceGenerator.Tests/Resources/GenericsUnionFormatter_Nested/Formatters.TempProject.WrapperFormatter_T_.g.cs new file mode 100644 index 000000000..900f7ec45 --- /dev/null +++ b/tests/MessagePack.SourceGenerator.Tests/Resources/GenericsUnionFormatter_Nested/Formatters.TempProject.WrapperFormatter_T_.g.cs @@ -0,0 +1,58 @@ +// + +#pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 + +namespace Formatters.TempProject +{ + using MsgPack = global::MessagePack; + + internal sealed class WrapperFormatter : MsgPack::Formatters.IMessagePackFormatter> + { + + public void Serialize(ref MsgPack::MessagePackWriter writer, global::TempProject.Wrapper value, MsgPack::MessagePackSerializerOptions options) + { + if (value == null) + { + writer.WriteNil(); + return; + } + + MsgPack::IFormatterResolver formatterResolver = options.Resolver; + writer.WriteArrayHeader(2); + MsgPack::FormatterResolverExtensions.GetFormatterWithVerify>(formatterResolver).Serialize(ref writer, value.Content1, options); + MsgPack::FormatterResolverExtensions.GetFormatterWithVerify>(formatterResolver).Serialize(ref writer, value.Content2, options); + } + + public global::TempProject.Wrapper Deserialize(ref MsgPack::MessagePackReader reader, MsgPack::MessagePackSerializerOptions options) + { + if (reader.TryReadNil()) + { + return null; + } + + options.Security.DepthStep(ref reader); + MsgPack::IFormatterResolver formatterResolver = options.Resolver; + var length = reader.ReadArrayHeader(); + var ____result = new global::TempProject.Wrapper(); + + for (int i = 0; i < length; i++) + { + switch (i) + { + case 0: + ____result.Content1 = MsgPack::FormatterResolverExtensions.GetFormatterWithVerify>(formatterResolver).Deserialize(ref reader, options); + break; + case 1: + ____result.Content2 = MsgPack::FormatterResolverExtensions.GetFormatterWithVerify>(formatterResolver).Deserialize(ref reader, options); + break; + default: + reader.Skip(); + break; + } + } + + reader.Depth--; + return ____result; + } + } +} diff --git a/tests/MessagePack.SourceGenerator.Tests/Resources/GenericsUnionFormatter_Nested/MessagePack.GeneratedMessagePackResolver.g.cs b/tests/MessagePack.SourceGenerator.Tests/Resources/GenericsUnionFormatter_Nested/MessagePack.GeneratedMessagePackResolver.g.cs new file mode 100644 index 000000000..f87674ed1 --- /dev/null +++ b/tests/MessagePack.SourceGenerator.Tests/Resources/GenericsUnionFormatter_Nested/MessagePack.GeneratedMessagePackResolver.g.cs @@ -0,0 +1,94 @@ +// + +#pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 + +namespace MessagePack +{ + using MsgPack = global::MessagePack; + using Formatters = global::Formatters; + + /// A MessagePack resolver that uses generated formatters for types in this assembly. + internal class GeneratedMessagePackResolver : MsgPack::IFormatterResolver + { + /// An instance of this resolver that only returns formatters specifically generated for types in this assembly. + public static readonly MsgPack::IFormatterResolver Instance = new GeneratedMessagePackResolver(); + + /// An instance of this resolver that returns standard AOT-compatible formatters as well as formatters specifically generated for types in this assembly. + public static readonly MsgPack::IFormatterResolver InstanceWithStandardAotResolver = MsgPack::Resolvers.CompositeResolver.Create(Instance, MsgPack::Resolvers.StandardAotResolver.Instance); + + private GeneratedMessagePackResolver() + { + } + + public MsgPack::Formatters.IMessagePackFormatter GetFormatter() + { + return FormatterCache.Formatter; + } + + private static class FormatterCache + { + internal static readonly MsgPack::Formatters.IMessagePackFormatter Formatter; + + static FormatterCache() + { + var f = GeneratedMessagePackResolverGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + Formatter = (MsgPack::Formatters.IMessagePackFormatter)f; + } + } + } + } + + internal static class GeneratedMessagePackResolverGetFormatterHelper + { + private static readonly global::System.Collections.Generic.Dictionary lookup; + + static GeneratedMessagePackResolverGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(13) + { + { typeof(global::System.Collections.Generic.IEnumerable), 0 }, + { typeof(global::System.Collections.Generic.List>), 1 }, + { typeof(global::System.Collections.Generic.List), 2 }, + { typeof(global::System.Collections.Generic.List), 3 }, + { typeof(global::TempProject.MyGenericObject>), 4 }, + { typeof(global::TempProject.MyGenericObject), 5 }, + { typeof(global::TempProject.MyGenericObject), 6 }, + { typeof(global::TempProject.MyInnerGenericObject>), 7 }, + { typeof(global::TempProject.MyInnerGenericObject), 8 }, + { typeof(global::TempProject.MyInnerGenericObject), 9 }, + { typeof(global::TempProject.Wrapper>), 10 }, + { typeof(global::TempProject.Wrapper), 11 }, + { typeof(global::TempProject.Wrapper), 12 }, + }; + } + + internal static object GetFormatter(global::System.Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + case 0: return new MsgPack::Formatters.InterfaceEnumerableFormatter(); + case 1: return new MsgPack::Formatters.ListFormatter>(); + case 2: return new MsgPack::Formatters.ListFormatter(); + case 3: return new MsgPack::Formatters.ListFormatter(); + case 4: return new Formatters::TempProject.MyGenericObjectFormatter>(); + case 5: return new Formatters::TempProject.MyGenericObjectFormatter(); + case 6: return new Formatters::TempProject.MyGenericObjectFormatter(); + case 7: return new Formatters::TempProject.MyInnerGenericObjectFormatter>(); + case 8: return new Formatters::TempProject.MyInnerGenericObjectFormatter(); + case 9: return new Formatters::TempProject.MyInnerGenericObjectFormatter(); + case 10: return new Formatters::TempProject.WrapperFormatter>(); + case 11: return new Formatters::TempProject.WrapperFormatter(); + case 12: return new Formatters::TempProject.WrapperFormatter(); + default: return null; + } + } + } +} diff --git a/tests/MessagePack.SourceGenerator.Tests/Resources/Generics_Constraints_Multiple/Formatters.TempProject.MyGenericObjectFormatter_T1, T2, T3, T4_.g.cs b/tests/MessagePack.SourceGenerator.Tests/Resources/Generics_Constraints_Multiple/Formatters.TempProject.MyGenericObjectFormatter_T1, T2, T3, T4_.g.cs new file mode 100644 index 000000000..c5bedd308 --- /dev/null +++ b/tests/MessagePack.SourceGenerator.Tests/Resources/Generics_Constraints_Multiple/Formatters.TempProject.MyGenericObjectFormatter_T1, T2, T3, T4_.g.cs @@ -0,0 +1,70 @@ +// + +#pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 + +namespace Formatters.TempProject +{ + using MsgPack = global::MessagePack; + + internal sealed class MyGenericObjectFormatter : MsgPack::Formatters.IMessagePackFormatter> + where T1 : struct + where T2 : global::System.IDisposable, new() + where T3 : notnull + where T4 : unmanaged + { + + public void Serialize(ref MsgPack::MessagePackWriter writer, global::TempProject.MyGenericObject value, MsgPack::MessagePackSerializerOptions options) + { + if (value == null) + { + writer.WriteNil(); + return; + } + + MsgPack::IFormatterResolver formatterResolver = options.Resolver; + writer.WriteArrayHeader(4); + MsgPack::FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Serialize(ref writer, value.Content1, options); + MsgPack::FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Serialize(ref writer, value.Content2, options); + MsgPack::FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Serialize(ref writer, value.Content3, options); + MsgPack::FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Serialize(ref writer, value.Content4, options); + } + + public global::TempProject.MyGenericObject Deserialize(ref MsgPack::MessagePackReader reader, MsgPack::MessagePackSerializerOptions options) + { + if (reader.TryReadNil()) + { + return null; + } + + options.Security.DepthStep(ref reader); + MsgPack::IFormatterResolver formatterResolver = options.Resolver; + var length = reader.ReadArrayHeader(); + var ____result = new global::TempProject.MyGenericObject(); + + for (int i = 0; i < length; i++) + { + switch (i) + { + case 0: + ____result.Content1 = MsgPack::FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Deserialize(ref reader, options); + break; + case 1: + ____result.Content2 = MsgPack::FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Deserialize(ref reader, options); + break; + case 2: + ____result.Content3 = MsgPack::FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Deserialize(ref reader, options); + break; + case 3: + ____result.Content4 = MsgPack::FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Deserialize(ref reader, options); + break; + default: + reader.Skip(); + break; + } + } + + reader.Depth--; + return ____result; + } + } +} diff --git a/tests/MessagePack.SourceGenerator.Tests/Resources/Generics_Constraints_Multiple/MessagePack.GeneratedMessagePackResolver.g.cs b/tests/MessagePack.SourceGenerator.Tests/Resources/Generics_Constraints_Multiple/MessagePack.GeneratedMessagePackResolver.g.cs new file mode 100644 index 000000000..e5a757c0b --- /dev/null +++ b/tests/MessagePack.SourceGenerator.Tests/Resources/Generics_Constraints_Multiple/MessagePack.GeneratedMessagePackResolver.g.cs @@ -0,0 +1,68 @@ +// + +#pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 + +namespace MessagePack +{ + using MsgPack = global::MessagePack; + using Formatters = global::Formatters; + + /// A MessagePack resolver that uses generated formatters for types in this assembly. + internal class GeneratedMessagePackResolver : MsgPack::IFormatterResolver + { + /// An instance of this resolver that only returns formatters specifically generated for types in this assembly. + public static readonly MsgPack::IFormatterResolver Instance = new GeneratedMessagePackResolver(); + + /// An instance of this resolver that returns standard AOT-compatible formatters as well as formatters specifically generated for types in this assembly. + public static readonly MsgPack::IFormatterResolver InstanceWithStandardAotResolver = MsgPack::Resolvers.CompositeResolver.Create(Instance, MsgPack::Resolvers.StandardAotResolver.Instance); + + private GeneratedMessagePackResolver() + { + } + + public MsgPack::Formatters.IMessagePackFormatter GetFormatter() + { + return FormatterCache.Formatter; + } + + private static class FormatterCache + { + internal static readonly MsgPack::Formatters.IMessagePackFormatter Formatter; + + static FormatterCache() + { + var f = GeneratedMessagePackResolverGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + Formatter = (MsgPack::Formatters.IMessagePackFormatter)f; + } + } + } + } + + internal static class GeneratedMessagePackResolverGetFormatterHelper + { + private static readonly global::System.Collections.Generic.Dictionary lookup; + + static GeneratedMessagePackResolverGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(0) + { + }; + } + + internal static object GetFormatter(global::System.Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + default: return null; + } + } + } +} diff --git a/tests/MessagePack.SourceGenerator.Tests/Resources/Generics_Constraints_NullableReferenceType/Formatters.TempProject.MyGenericObjectFormatter_T1, T2, T3, T4_.g.cs b/tests/MessagePack.SourceGenerator.Tests/Resources/Generics_Constraints_NullableReferenceType/Formatters.TempProject.MyGenericObjectFormatter_T1, T2, T3, T4_.g.cs new file mode 100644 index 000000000..a56f4d6e5 --- /dev/null +++ b/tests/MessagePack.SourceGenerator.Tests/Resources/Generics_Constraints_NullableReferenceType/Formatters.TempProject.MyGenericObjectFormatter_T1, T2, T3, T4_.g.cs @@ -0,0 +1,58 @@ +// + +#pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 + +namespace Formatters.TempProject +{ + using MsgPack = global::MessagePack; + + internal sealed class MyGenericObjectFormatter : MsgPack::Formatters.IMessagePackFormatter> + where T1 : global::TempProject.MyClass? + where T2 : global::TempProject.MyClass + where T3 : global::TempProject.MyGenericClass?>? + where T4 : global::TempProject.MyClass, global::TempProject.IMyInterface? + { + + public void Serialize(ref MsgPack::MessagePackWriter writer, global::TempProject.MyGenericObject value, MsgPack::MessagePackSerializerOptions options) + { + if (value == null) + { + writer.WriteNil(); + return; + } + + MsgPack::IFormatterResolver formatterResolver = options.Resolver; + writer.WriteArrayHeader(1); + MsgPack::FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Serialize(ref writer, value.Content, options); + } + + public global::TempProject.MyGenericObject Deserialize(ref MsgPack::MessagePackReader reader, MsgPack::MessagePackSerializerOptions options) + { + if (reader.TryReadNil()) + { + return null; + } + + options.Security.DepthStep(ref reader); + MsgPack::IFormatterResolver formatterResolver = options.Resolver; + var length = reader.ReadArrayHeader(); + var ____result = new global::TempProject.MyGenericObject(); + + for (int i = 0; i < length; i++) + { + switch (i) + { + case 0: + ____result.Content = MsgPack::FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Deserialize(ref reader, options); + break; + default: + reader.Skip(); + break; + } + } + + reader.Depth--; + return ____result; + } + } +} diff --git a/tests/MessagePack.SourceGenerator.Tests/Resources/Generics_Constraints_NullableReferenceType/MessagePack.GeneratedMessagePackResolver.g.cs b/tests/MessagePack.SourceGenerator.Tests/Resources/Generics_Constraints_NullableReferenceType/MessagePack.GeneratedMessagePackResolver.g.cs new file mode 100644 index 000000000..e5a757c0b --- /dev/null +++ b/tests/MessagePack.SourceGenerator.Tests/Resources/Generics_Constraints_NullableReferenceType/MessagePack.GeneratedMessagePackResolver.g.cs @@ -0,0 +1,68 @@ +// + +#pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 + +namespace MessagePack +{ + using MsgPack = global::MessagePack; + using Formatters = global::Formatters; + + /// A MessagePack resolver that uses generated formatters for types in this assembly. + internal class GeneratedMessagePackResolver : MsgPack::IFormatterResolver + { + /// An instance of this resolver that only returns formatters specifically generated for types in this assembly. + public static readonly MsgPack::IFormatterResolver Instance = new GeneratedMessagePackResolver(); + + /// An instance of this resolver that returns standard AOT-compatible formatters as well as formatters specifically generated for types in this assembly. + public static readonly MsgPack::IFormatterResolver InstanceWithStandardAotResolver = MsgPack::Resolvers.CompositeResolver.Create(Instance, MsgPack::Resolvers.StandardAotResolver.Instance); + + private GeneratedMessagePackResolver() + { + } + + public MsgPack::Formatters.IMessagePackFormatter GetFormatter() + { + return FormatterCache.Formatter; + } + + private static class FormatterCache + { + internal static readonly MsgPack::Formatters.IMessagePackFormatter Formatter; + + static FormatterCache() + { + var f = GeneratedMessagePackResolverGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + Formatter = (MsgPack::Formatters.IMessagePackFormatter)f; + } + } + } + } + + internal static class GeneratedMessagePackResolverGetFormatterHelper + { + private static readonly global::System.Collections.Generic.Dictionary lookup; + + static GeneratedMessagePackResolverGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(0) + { + }; + } + + internal static object GetFormatter(global::System.Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + default: return null; + } + } + } +} diff --git a/tests/MessagePack.SourceGenerator.Tests/Resources/Generics_Constraints_ReferenceType_Nullable/Formatters.TempProject.MyGenericObjectFormatter_T1, T2_.g.cs b/tests/MessagePack.SourceGenerator.Tests/Resources/Generics_Constraints_ReferenceType_Nullable/Formatters.TempProject.MyGenericObjectFormatter_T1, T2_.g.cs new file mode 100644 index 000000000..e5ac4d4fc --- /dev/null +++ b/tests/MessagePack.SourceGenerator.Tests/Resources/Generics_Constraints_ReferenceType_Nullable/Formatters.TempProject.MyGenericObjectFormatter_T1, T2_.g.cs @@ -0,0 +1,60 @@ +// + +#pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 + +namespace Formatters.TempProject +{ + using MsgPack = global::MessagePack; + + internal sealed class MyGenericObjectFormatter : MsgPack::Formatters.IMessagePackFormatter> + where T1 : class? + where T2 : class + { + + public void Serialize(ref MsgPack::MessagePackWriter writer, global::TempProject.MyGenericObject value, MsgPack::MessagePackSerializerOptions options) + { + if (value == null) + { + writer.WriteNil(); + return; + } + + MsgPack::IFormatterResolver formatterResolver = options.Resolver; + writer.WriteArrayHeader(2); + MsgPack::FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Serialize(ref writer, value.Content1, options); + MsgPack::FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Serialize(ref writer, value.Content2, options); + } + + public global::TempProject.MyGenericObject Deserialize(ref MsgPack::MessagePackReader reader, MsgPack::MessagePackSerializerOptions options) + { + if (reader.TryReadNil()) + { + return null; + } + + options.Security.DepthStep(ref reader); + MsgPack::IFormatterResolver formatterResolver = options.Resolver; + var length = reader.ReadArrayHeader(); + var ____result = new global::TempProject.MyGenericObject(); + + for (int i = 0; i < length; i++) + { + switch (i) + { + case 0: + ____result.Content1 = MsgPack::FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Deserialize(ref reader, options); + break; + case 1: + ____result.Content2 = MsgPack::FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Deserialize(ref reader, options); + break; + default: + reader.Skip(); + break; + } + } + + reader.Depth--; + return ____result; + } + } +} diff --git a/tests/MessagePack.SourceGenerator.Tests/Resources/Generics_Constraints_ReferenceType_Nullable/MessagePack.GeneratedMessagePackResolver.g.cs b/tests/MessagePack.SourceGenerator.Tests/Resources/Generics_Constraints_ReferenceType_Nullable/MessagePack.GeneratedMessagePackResolver.g.cs new file mode 100644 index 000000000..e5a757c0b --- /dev/null +++ b/tests/MessagePack.SourceGenerator.Tests/Resources/Generics_Constraints_ReferenceType_Nullable/MessagePack.GeneratedMessagePackResolver.g.cs @@ -0,0 +1,68 @@ +// + +#pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 + +namespace MessagePack +{ + using MsgPack = global::MessagePack; + using Formatters = global::Formatters; + + /// A MessagePack resolver that uses generated formatters for types in this assembly. + internal class GeneratedMessagePackResolver : MsgPack::IFormatterResolver + { + /// An instance of this resolver that only returns formatters specifically generated for types in this assembly. + public static readonly MsgPack::IFormatterResolver Instance = new GeneratedMessagePackResolver(); + + /// An instance of this resolver that returns standard AOT-compatible formatters as well as formatters specifically generated for types in this assembly. + public static readonly MsgPack::IFormatterResolver InstanceWithStandardAotResolver = MsgPack::Resolvers.CompositeResolver.Create(Instance, MsgPack::Resolvers.StandardAotResolver.Instance); + + private GeneratedMessagePackResolver() + { + } + + public MsgPack::Formatters.IMessagePackFormatter GetFormatter() + { + return FormatterCache.Formatter; + } + + private static class FormatterCache + { + internal static readonly MsgPack::Formatters.IMessagePackFormatter Formatter; + + static FormatterCache() + { + var f = GeneratedMessagePackResolverGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + Formatter = (MsgPack::Formatters.IMessagePackFormatter)f; + } + } + } + } + + internal static class GeneratedMessagePackResolverGetFormatterHelper + { + private static readonly global::System.Collections.Generic.Dictionary lookup; + + static GeneratedMessagePackResolverGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(0) + { + }; + } + + internal static object GetFormatter(global::System.Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + default: return null; + } + } + } +} diff --git a/tests/MessagePack.SourceGenerator.Tests/Resources/Generics_Constraints_Struct/Formatters.TempProject.MyGenericObjectFormatter_T_.g.cs b/tests/MessagePack.SourceGenerator.Tests/Resources/Generics_Constraints_Struct/Formatters.TempProject.MyGenericObjectFormatter_T_.g.cs new file mode 100644 index 000000000..2766f17a6 --- /dev/null +++ b/tests/MessagePack.SourceGenerator.Tests/Resources/Generics_Constraints_Struct/Formatters.TempProject.MyGenericObjectFormatter_T_.g.cs @@ -0,0 +1,55 @@ +// + +#pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 + +namespace Formatters.TempProject +{ + using MsgPack = global::MessagePack; + + internal sealed class MyGenericObjectFormatter : MsgPack::Formatters.IMessagePackFormatter> + where T : struct + { + + public void Serialize(ref MsgPack::MessagePackWriter writer, global::TempProject.MyGenericObject value, MsgPack::MessagePackSerializerOptions options) + { + if (value == null) + { + writer.WriteNil(); + return; + } + + MsgPack::IFormatterResolver formatterResolver = options.Resolver; + writer.WriteArrayHeader(1); + MsgPack::FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Serialize(ref writer, value.Content, options); + } + + public global::TempProject.MyGenericObject Deserialize(ref MsgPack::MessagePackReader reader, MsgPack::MessagePackSerializerOptions options) + { + if (reader.TryReadNil()) + { + return null; + } + + options.Security.DepthStep(ref reader); + MsgPack::IFormatterResolver formatterResolver = options.Resolver; + var length = reader.ReadArrayHeader(); + var ____result = new global::TempProject.MyGenericObject(); + + for (int i = 0; i < length; i++) + { + switch (i) + { + case 0: + ____result.Content = MsgPack::FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Deserialize(ref reader, options); + break; + default: + reader.Skip(); + break; + } + } + + reader.Depth--; + return ____result; + } + } +} diff --git a/tests/MessagePack.SourceGenerator.Tests/Resources/Generics_Constraints_Struct/MessagePack.GeneratedMessagePackResolver.g.cs b/tests/MessagePack.SourceGenerator.Tests/Resources/Generics_Constraints_Struct/MessagePack.GeneratedMessagePackResolver.g.cs new file mode 100644 index 000000000..e5a757c0b --- /dev/null +++ b/tests/MessagePack.SourceGenerator.Tests/Resources/Generics_Constraints_Struct/MessagePack.GeneratedMessagePackResolver.g.cs @@ -0,0 +1,68 @@ +// + +#pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 + +namespace MessagePack +{ + using MsgPack = global::MessagePack; + using Formatters = global::Formatters; + + /// A MessagePack resolver that uses generated formatters for types in this assembly. + internal class GeneratedMessagePackResolver : MsgPack::IFormatterResolver + { + /// An instance of this resolver that only returns formatters specifically generated for types in this assembly. + public static readonly MsgPack::IFormatterResolver Instance = new GeneratedMessagePackResolver(); + + /// An instance of this resolver that returns standard AOT-compatible formatters as well as formatters specifically generated for types in this assembly. + public static readonly MsgPack::IFormatterResolver InstanceWithStandardAotResolver = MsgPack::Resolvers.CompositeResolver.Create(Instance, MsgPack::Resolvers.StandardAotResolver.Instance); + + private GeneratedMessagePackResolver() + { + } + + public MsgPack::Formatters.IMessagePackFormatter GetFormatter() + { + return FormatterCache.Formatter; + } + + private static class FormatterCache + { + internal static readonly MsgPack::Formatters.IMessagePackFormatter Formatter; + + static FormatterCache() + { + var f = GeneratedMessagePackResolverGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + Formatter = (MsgPack::Formatters.IMessagePackFormatter)f; + } + } + } + } + + internal static class GeneratedMessagePackResolverGetFormatterHelper + { + private static readonly global::System.Collections.Generic.Dictionary lookup; + + static GeneratedMessagePackResolverGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(0) + { + }; + } + + internal static object GetFormatter(global::System.Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + default: return null; + } + } + } +} diff --git a/tests/MessagePack.SourceGenerator.Tests/Resources/Generics_Constraints_Type/Formatters.TempProject.MyGenericObjectFormatter_T_.g.cs b/tests/MessagePack.SourceGenerator.Tests/Resources/Generics_Constraints_Type/Formatters.TempProject.MyGenericObjectFormatter_T_.g.cs new file mode 100644 index 000000000..6372a561f --- /dev/null +++ b/tests/MessagePack.SourceGenerator.Tests/Resources/Generics_Constraints_Type/Formatters.TempProject.MyGenericObjectFormatter_T_.g.cs @@ -0,0 +1,55 @@ +// + +#pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 + +namespace Formatters.TempProject +{ + using MsgPack = global::MessagePack; + + internal sealed class MyGenericObjectFormatter : MsgPack::Formatters.IMessagePackFormatter> + where T : global::System.IDisposable + { + + public void Serialize(ref MsgPack::MessagePackWriter writer, global::TempProject.MyGenericObject value, MsgPack::MessagePackSerializerOptions options) + { + if (value == null) + { + writer.WriteNil(); + return; + } + + MsgPack::IFormatterResolver formatterResolver = options.Resolver; + writer.WriteArrayHeader(1); + MsgPack::FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Serialize(ref writer, value.Content, options); + } + + public global::TempProject.MyGenericObject Deserialize(ref MsgPack::MessagePackReader reader, MsgPack::MessagePackSerializerOptions options) + { + if (reader.TryReadNil()) + { + return null; + } + + options.Security.DepthStep(ref reader); + MsgPack::IFormatterResolver formatterResolver = options.Resolver; + var length = reader.ReadArrayHeader(); + var ____result = new global::TempProject.MyGenericObject(); + + for (int i = 0; i < length; i++) + { + switch (i) + { + case 0: + ____result.Content = MsgPack::FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Deserialize(ref reader, options); + break; + default: + reader.Skip(); + break; + } + } + + reader.Depth--; + return ____result; + } + } +} diff --git a/tests/MessagePack.SourceGenerator.Tests/Resources/Generics_Constraints_Type/MessagePack.GeneratedMessagePackResolver.g.cs b/tests/MessagePack.SourceGenerator.Tests/Resources/Generics_Constraints_Type/MessagePack.GeneratedMessagePackResolver.g.cs new file mode 100644 index 000000000..e5a757c0b --- /dev/null +++ b/tests/MessagePack.SourceGenerator.Tests/Resources/Generics_Constraints_Type/MessagePack.GeneratedMessagePackResolver.g.cs @@ -0,0 +1,68 @@ +// + +#pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 + +namespace MessagePack +{ + using MsgPack = global::MessagePack; + using Formatters = global::Formatters; + + /// A MessagePack resolver that uses generated formatters for types in this assembly. + internal class GeneratedMessagePackResolver : MsgPack::IFormatterResolver + { + /// An instance of this resolver that only returns formatters specifically generated for types in this assembly. + public static readonly MsgPack::IFormatterResolver Instance = new GeneratedMessagePackResolver(); + + /// An instance of this resolver that returns standard AOT-compatible formatters as well as formatters specifically generated for types in this assembly. + public static readonly MsgPack::IFormatterResolver InstanceWithStandardAotResolver = MsgPack::Resolvers.CompositeResolver.Create(Instance, MsgPack::Resolvers.StandardAotResolver.Instance); + + private GeneratedMessagePackResolver() + { + } + + public MsgPack::Formatters.IMessagePackFormatter GetFormatter() + { + return FormatterCache.Formatter; + } + + private static class FormatterCache + { + internal static readonly MsgPack::Formatters.IMessagePackFormatter Formatter; + + static FormatterCache() + { + var f = GeneratedMessagePackResolverGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + Formatter = (MsgPack::Formatters.IMessagePackFormatter)f; + } + } + } + } + + internal static class GeneratedMessagePackResolverGetFormatterHelper + { + private static readonly global::System.Collections.Generic.Dictionary lookup; + + static GeneratedMessagePackResolverGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(0) + { + }; + } + + internal static object GetFormatter(global::System.Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + default: return null; + } + } + } +} diff --git a/tests/MessagePack.SourceGenerator.Tests/Resources/Generics_Defined_In_ReferencedProject/Formatters.TempProject.MyObjectFormatter.g.cs b/tests/MessagePack.SourceGenerator.Tests/Resources/Generics_Defined_In_ReferencedProject/Formatters.TempProject.MyObjectFormatter.g.cs new file mode 100644 index 000000000..d1e3f850d --- /dev/null +++ b/tests/MessagePack.SourceGenerator.Tests/Resources/Generics_Defined_In_ReferencedProject/Formatters.TempProject.MyObjectFormatter.g.cs @@ -0,0 +1,54 @@ +// + +#pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 + +namespace Formatters.TempProject +{ + using MsgPack = global::MessagePack; + + internal sealed class MyObjectFormatter : MsgPack::Formatters.IMessagePackFormatter + { + + public void Serialize(ref MsgPack::MessagePackWriter writer, global::TempProject.MyObject value, MsgPack::MessagePackSerializerOptions options) + { + if (value == null) + { + writer.WriteNil(); + return; + } + + MsgPack::IFormatterResolver formatterResolver = options.Resolver; + writer.WriteArrayHeader(1); + MsgPack::FormatterResolverExtensions.GetFormatterWithVerify>(formatterResolver).Serialize(ref writer, value.Value, options); + } + + public global::TempProject.MyObject Deserialize(ref MsgPack::MessagePackReader reader, MsgPack::MessagePackSerializerOptions options) + { + if (reader.TryReadNil()) + { + return null; + } + + options.Security.DepthStep(ref reader); + MsgPack::IFormatterResolver formatterResolver = options.Resolver; + var length = reader.ReadArrayHeader(); + var ____result = new global::TempProject.MyObject(); + + for (int i = 0; i < length; i++) + { + switch (i) + { + case 0: + ____result.Value = MsgPack::FormatterResolverExtensions.GetFormatterWithVerify>(formatterResolver).Deserialize(ref reader, options); + break; + default: + reader.Skip(); + break; + } + } + + reader.Depth--; + return ____result; + } + } +} diff --git a/tests/MessagePack.SourceGenerator.Tests/Resources/Generics_Defined_In_ReferencedProject/Formatters.TempProject.MyObjectNestedFormatter.g.cs b/tests/MessagePack.SourceGenerator.Tests/Resources/Generics_Defined_In_ReferencedProject/Formatters.TempProject.MyObjectNestedFormatter.g.cs new file mode 100644 index 000000000..2589b533c --- /dev/null +++ b/tests/MessagePack.SourceGenerator.Tests/Resources/Generics_Defined_In_ReferencedProject/Formatters.TempProject.MyObjectNestedFormatter.g.cs @@ -0,0 +1,54 @@ +// + +#pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 + +namespace Formatters.TempProject +{ + using MsgPack = global::MessagePack; + + internal sealed class MyObjectNestedFormatter : MsgPack::Formatters.IMessagePackFormatter + { + + public void Serialize(ref MsgPack::MessagePackWriter writer, global::TempProject.MyObjectNested value, MsgPack::MessagePackSerializerOptions options) + { + if (value == null) + { + writer.WriteNil(); + return; + } + + MsgPack::IFormatterResolver formatterResolver = options.Resolver; + writer.WriteArrayHeader(1); + MsgPack::FormatterResolverExtensions.GetFormatterWithVerify>>(formatterResolver).Serialize(ref writer, value.Value, options); + } + + public global::TempProject.MyObjectNested Deserialize(ref MsgPack::MessagePackReader reader, MsgPack::MessagePackSerializerOptions options) + { + if (reader.TryReadNil()) + { + return null; + } + + options.Security.DepthStep(ref reader); + MsgPack::IFormatterResolver formatterResolver = options.Resolver; + var length = reader.ReadArrayHeader(); + var ____result = new global::TempProject.MyObjectNested(); + + for (int i = 0; i < length; i++) + { + switch (i) + { + case 0: + ____result.Value = MsgPack::FormatterResolverExtensions.GetFormatterWithVerify>>(formatterResolver).Deserialize(ref reader, options); + break; + default: + reader.Skip(); + break; + } + } + + reader.Depth--; + return ____result; + } + } +} diff --git a/tests/MessagePack.SourceGenerator.Tests/Resources/Generics_Defined_In_ReferencedProject/MessagePack.GeneratedMessagePackResolver.g.cs b/tests/MessagePack.SourceGenerator.Tests/Resources/Generics_Defined_In_ReferencedProject/MessagePack.GeneratedMessagePackResolver.g.cs new file mode 100644 index 000000000..059e46fd0 --- /dev/null +++ b/tests/MessagePack.SourceGenerator.Tests/Resources/Generics_Defined_In_ReferencedProject/MessagePack.GeneratedMessagePackResolver.g.cs @@ -0,0 +1,76 @@ +// + +#pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 + +namespace MessagePack +{ + using MsgPack = global::MessagePack; + using Formatters = global::Formatters; + + /// A MessagePack resolver that uses generated formatters for types in this assembly. + internal class GeneratedMessagePackResolver : MsgPack::IFormatterResolver + { + /// An instance of this resolver that only returns formatters specifically generated for types in this assembly. + public static readonly MsgPack::IFormatterResolver Instance = new GeneratedMessagePackResolver(); + + /// An instance of this resolver that returns standard AOT-compatible formatters as well as formatters specifically generated for types in this assembly. + public static readonly MsgPack::IFormatterResolver InstanceWithStandardAotResolver = MsgPack::Resolvers.CompositeResolver.Create(Instance, MsgPack::Resolvers.StandardAotResolver.Instance); + + private GeneratedMessagePackResolver() + { + } + + public MsgPack::Formatters.IMessagePackFormatter GetFormatter() + { + return FormatterCache.Formatter; + } + + private static class FormatterCache + { + internal static readonly MsgPack::Formatters.IMessagePackFormatter Formatter; + + static FormatterCache() + { + var f = GeneratedMessagePackResolverGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + Formatter = (MsgPack::Formatters.IMessagePackFormatter)f; + } + } + } + } + + internal static class GeneratedMessagePackResolverGetFormatterHelper + { + private static readonly global::System.Collections.Generic.Dictionary lookup; + + static GeneratedMessagePackResolverGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(4) + { + { typeof(global::TempProject.MyGenericObject>), 0 }, + { typeof(global::TempProject.MyGenericObject), 1 }, + { typeof(global::TempProject.MyObject), 2 }, + { typeof(global::TempProject.MyObjectNested), 3 }, + }; + } + + internal static object GetFormatter(global::System.Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + case 0: return new Formatters::TempProject.MyGenericObjectFormatter>(); + case 1: return new Formatters::TempProject.MyGenericObjectFormatter(); + case 2: return new Formatters::TempProject.MyObjectFormatter(); + case 3: return new Formatters::TempProject.MyObjectNestedFormatter(); + default: return null; + } + } + } +} diff --git a/tests/MessagePack.SourceGenerator.Tests/Resources/NestedGenericTypes/Formatters.TempProject.MyGenericObjectFormatter_T_.g.cs b/tests/MessagePack.SourceGenerator.Tests/Resources/NestedGenericTypes/Formatters.TempProject.MyGenericObjectFormatter_T_.g.cs new file mode 100644 index 000000000..c1799f8d1 --- /dev/null +++ b/tests/MessagePack.SourceGenerator.Tests/Resources/NestedGenericTypes/Formatters.TempProject.MyGenericObjectFormatter_T_.g.cs @@ -0,0 +1,58 @@ +// + +#pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 + +namespace Formatters.TempProject +{ + using MsgPack = global::MessagePack; + + internal sealed class MyGenericObjectFormatter : MsgPack::Formatters.IMessagePackFormatter> + { + + public void Serialize(ref MsgPack::MessagePackWriter writer, global::TempProject.MyGenericObject value, MsgPack::MessagePackSerializerOptions options) + { + if (value == null) + { + writer.WriteNil(); + return; + } + + MsgPack::IFormatterResolver formatterResolver = options.Resolver; + writer.WriteArrayHeader(2); + MsgPack::FormatterResolverExtensions.GetFormatterWithVerify>(formatterResolver).Serialize(ref writer, value.Content, options); + MsgPack::FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Serialize(ref writer, value.Content2, options); + } + + public global::TempProject.MyGenericObject Deserialize(ref MsgPack::MessagePackReader reader, MsgPack::MessagePackSerializerOptions options) + { + if (reader.TryReadNil()) + { + return null; + } + + options.Security.DepthStep(ref reader); + MsgPack::IFormatterResolver formatterResolver = options.Resolver; + var length = reader.ReadArrayHeader(); + var ____result = new global::TempProject.MyGenericObject(); + + for (int i = 0; i < length; i++) + { + switch (i) + { + case 0: + ____result.Content = MsgPack::FormatterResolverExtensions.GetFormatterWithVerify>(formatterResolver).Deserialize(ref reader, options); + break; + case 1: + ____result.Content2 = MsgPack::FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Deserialize(ref reader, options); + break; + default: + reader.Skip(); + break; + } + } + + reader.Depth--; + return ____result; + } + } +} diff --git a/tests/MessagePack.SourceGenerator.Tests/Resources/NestedGenericTypes/Formatters.TempProject.MyInnerGenericObjectFormatter_T_.g.cs b/tests/MessagePack.SourceGenerator.Tests/Resources/NestedGenericTypes/Formatters.TempProject.MyInnerGenericObjectFormatter_T_.g.cs new file mode 100644 index 000000000..0fc28a2b0 --- /dev/null +++ b/tests/MessagePack.SourceGenerator.Tests/Resources/NestedGenericTypes/Formatters.TempProject.MyInnerGenericObjectFormatter_T_.g.cs @@ -0,0 +1,34 @@ +// + +#pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 + +namespace Formatters.TempProject +{ + using MsgPack = global::MessagePack; + + internal sealed class MyInnerGenericObjectFormatter : MsgPack::Formatters.IMessagePackFormatter> + { + + public void Serialize(ref MsgPack::MessagePackWriter writer, global::TempProject.MyInnerGenericObject value, MsgPack::MessagePackSerializerOptions options) + { + if (value == null) + { + writer.WriteNil(); + return; + } + + writer.WriteArrayHeader(0); + } + + public global::TempProject.MyInnerGenericObject Deserialize(ref MsgPack::MessagePackReader reader, MsgPack::MessagePackSerializerOptions options) + { + if (reader.TryReadNil()) + { + return null; + } + + reader.Skip(); + return new global::TempProject.MyInnerGenericObject(); + } + } +} diff --git a/tests/MessagePack.SourceGenerator.Tests/Resources/NestedGenericTypes/Formatters.TempProject.MyObject2Formatter.g.cs b/tests/MessagePack.SourceGenerator.Tests/Resources/NestedGenericTypes/Formatters.TempProject.MyObject2Formatter.g.cs new file mode 100644 index 000000000..1b380326a --- /dev/null +++ b/tests/MessagePack.SourceGenerator.Tests/Resources/NestedGenericTypes/Formatters.TempProject.MyObject2Formatter.g.cs @@ -0,0 +1,34 @@ +// + +#pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 + +namespace Formatters.TempProject +{ + using MsgPack = global::MessagePack; + + internal sealed class MyObject2Formatter : MsgPack::Formatters.IMessagePackFormatter + { + + public void Serialize(ref MsgPack::MessagePackWriter writer, global::TempProject.MyObject2 value, MsgPack::MessagePackSerializerOptions options) + { + if (value == null) + { + writer.WriteNil(); + return; + } + + writer.WriteArrayHeader(0); + } + + public global::TempProject.MyObject2 Deserialize(ref MsgPack::MessagePackReader reader, MsgPack::MessagePackSerializerOptions options) + { + if (reader.TryReadNil()) + { + return null; + } + + reader.Skip(); + return new global::TempProject.MyObject2(); + } + } +} diff --git a/tests/MessagePack.SourceGenerator.Tests/Resources/NestedGenericTypes/Formatters.TempProject.MyObjectFormatter.g.cs b/tests/MessagePack.SourceGenerator.Tests/Resources/NestedGenericTypes/Formatters.TempProject.MyObjectFormatter.g.cs new file mode 100644 index 000000000..8ef0f2ea2 --- /dev/null +++ b/tests/MessagePack.SourceGenerator.Tests/Resources/NestedGenericTypes/Formatters.TempProject.MyObjectFormatter.g.cs @@ -0,0 +1,58 @@ +// + +#pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 + +namespace Formatters.TempProject +{ + using MsgPack = global::MessagePack; + + internal sealed class MyObjectFormatter : MsgPack::Formatters.IMessagePackFormatter + { + + public void Serialize(ref MsgPack::MessagePackWriter writer, global::TempProject.MyObject value, MsgPack::MessagePackSerializerOptions options) + { + if (value == null) + { + writer.WriteNil(); + return; + } + + MsgPack::IFormatterResolver formatterResolver = options.Resolver; + writer.WriteArrayHeader(2); + MsgPack::FormatterResolverExtensions.GetFormatterWithVerify>(formatterResolver).Serialize(ref writer, value.Content1, options); + MsgPack::FormatterResolverExtensions.GetFormatterWithVerify>(formatterResolver).Serialize(ref writer, value.Content2, options); + } + + public global::TempProject.MyObject Deserialize(ref MsgPack::MessagePackReader reader, MsgPack::MessagePackSerializerOptions options) + { + if (reader.TryReadNil()) + { + return null; + } + + options.Security.DepthStep(ref reader); + MsgPack::IFormatterResolver formatterResolver = options.Resolver; + var length = reader.ReadArrayHeader(); + var ____result = new global::TempProject.MyObject(); + + for (int i = 0; i < length; i++) + { + switch (i) + { + case 0: + ____result.Content1 = MsgPack::FormatterResolverExtensions.GetFormatterWithVerify>(formatterResolver).Deserialize(ref reader, options); + break; + case 1: + ____result.Content2 = MsgPack::FormatterResolverExtensions.GetFormatterWithVerify>(formatterResolver).Deserialize(ref reader, options); + break; + default: + reader.Skip(); + break; + } + } + + reader.Depth--; + return ____result; + } + } +} diff --git a/tests/MessagePack.SourceGenerator.Tests/Resources/NestedGenericTypes/Formatters.TempProject.WrapperFormatter_T_.g.cs b/tests/MessagePack.SourceGenerator.Tests/Resources/NestedGenericTypes/Formatters.TempProject.WrapperFormatter_T_.g.cs new file mode 100644 index 000000000..900f7ec45 --- /dev/null +++ b/tests/MessagePack.SourceGenerator.Tests/Resources/NestedGenericTypes/Formatters.TempProject.WrapperFormatter_T_.g.cs @@ -0,0 +1,58 @@ +// + +#pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 + +namespace Formatters.TempProject +{ + using MsgPack = global::MessagePack; + + internal sealed class WrapperFormatter : MsgPack::Formatters.IMessagePackFormatter> + { + + public void Serialize(ref MsgPack::MessagePackWriter writer, global::TempProject.Wrapper value, MsgPack::MessagePackSerializerOptions options) + { + if (value == null) + { + writer.WriteNil(); + return; + } + + MsgPack::IFormatterResolver formatterResolver = options.Resolver; + writer.WriteArrayHeader(2); + MsgPack::FormatterResolverExtensions.GetFormatterWithVerify>(formatterResolver).Serialize(ref writer, value.Content1, options); + MsgPack::FormatterResolverExtensions.GetFormatterWithVerify>(formatterResolver).Serialize(ref writer, value.Content2, options); + } + + public global::TempProject.Wrapper Deserialize(ref MsgPack::MessagePackReader reader, MsgPack::MessagePackSerializerOptions options) + { + if (reader.TryReadNil()) + { + return null; + } + + options.Security.DepthStep(ref reader); + MsgPack::IFormatterResolver formatterResolver = options.Resolver; + var length = reader.ReadArrayHeader(); + var ____result = new global::TempProject.Wrapper(); + + for (int i = 0; i < length; i++) + { + switch (i) + { + case 0: + ____result.Content1 = MsgPack::FormatterResolverExtensions.GetFormatterWithVerify>(formatterResolver).Deserialize(ref reader, options); + break; + case 1: + ____result.Content2 = MsgPack::FormatterResolverExtensions.GetFormatterWithVerify>(formatterResolver).Deserialize(ref reader, options); + break; + default: + reader.Skip(); + break; + } + } + + reader.Depth--; + return ____result; + } + } +} diff --git a/tests/MessagePack.SourceGenerator.Tests/Resources/NestedGenericTypes/MessagePack.GeneratedMessagePackResolver.g.cs b/tests/MessagePack.SourceGenerator.Tests/Resources/NestedGenericTypes/MessagePack.GeneratedMessagePackResolver.g.cs new file mode 100644 index 000000000..d353281de --- /dev/null +++ b/tests/MessagePack.SourceGenerator.Tests/Resources/NestedGenericTypes/MessagePack.GeneratedMessagePackResolver.g.cs @@ -0,0 +1,80 @@ +// + +#pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 + +namespace MessagePack +{ + using MsgPack = global::MessagePack; + using Formatters = global::Formatters; + + /// A MessagePack resolver that uses generated formatters for types in this assembly. + internal class GeneratedMessagePackResolver : MsgPack::IFormatterResolver + { + /// An instance of this resolver that only returns formatters specifically generated for types in this assembly. + public static readonly MsgPack::IFormatterResolver Instance = new GeneratedMessagePackResolver(); + + /// An instance of this resolver that returns standard AOT-compatible formatters as well as formatters specifically generated for types in this assembly. + public static readonly MsgPack::IFormatterResolver InstanceWithStandardAotResolver = MsgPack::Resolvers.CompositeResolver.Create(Instance, MsgPack::Resolvers.StandardAotResolver.Instance); + + private GeneratedMessagePackResolver() + { + } + + public MsgPack::Formatters.IMessagePackFormatter GetFormatter() + { + return FormatterCache.Formatter; + } + + private static class FormatterCache + { + internal static readonly MsgPack::Formatters.IMessagePackFormatter Formatter; + + static FormatterCache() + { + var f = GeneratedMessagePackResolverGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + Formatter = (MsgPack::Formatters.IMessagePackFormatter)f; + } + } + } + } + + internal static class GeneratedMessagePackResolverGetFormatterHelper + { + private static readonly global::System.Collections.Generic.Dictionary lookup; + + static GeneratedMessagePackResolverGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(6) + { + { typeof(global::System.Collections.Generic.List), 0 }, + { typeof(global::TempProject.MyGenericObject), 1 }, + { typeof(global::TempProject.MyInnerGenericObject), 2 }, + { typeof(global::TempProject.MyObject2[]), 3 }, + { typeof(global::TempProject.MyObject), 4 }, + { typeof(global::TempProject.MyObject2), 5 }, + }; + } + + internal static object GetFormatter(global::System.Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + case 0: return new MsgPack::Formatters.ListFormatter(); + case 1: return new Formatters::TempProject.MyGenericObjectFormatter(); + case 2: return new Formatters::TempProject.MyInnerGenericObjectFormatter(); + case 3: return new MsgPack::Formatters.ArrayFormatter(); + case 4: return new Formatters::TempProject.MyObjectFormatter(); + case 5: return new Formatters::TempProject.MyObject2Formatter(); + default: return null; + } + } + } +} diff --git a/tests/MessagePack.SourceGenerator.Tests/Resources/NullableFormatter/Formatters.TempProject.MyEnumFormatter.g.cs b/tests/MessagePack.SourceGenerator.Tests/Resources/NullableFormatter/Formatters.TempProject.MyEnumFormatter.g.cs new file mode 100644 index 000000000..3bf04afb5 --- /dev/null +++ b/tests/MessagePack.SourceGenerator.Tests/Resources/NullableFormatter/Formatters.TempProject.MyEnumFormatter.g.cs @@ -0,0 +1,22 @@ +// + +#pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 + +namespace Formatters.TempProject +{ + using MsgPack = global::MessagePack; + using MyEnum = global::TempProject.MyEnum; + + internal sealed class MyEnumFormatter : MsgPack::Formatters.IMessagePackFormatter + { + public void Serialize(ref MsgPack::MessagePackWriter writer, MyEnum value, MsgPack::MessagePackSerializerOptions options) + { + writer.Write((int)value); + } + + public MyEnum Deserialize(ref MsgPack::MessagePackReader reader, MsgPack::MessagePackSerializerOptions options) + { + return (MyEnum)reader.ReadInt32(); + } + } +} diff --git a/tests/MessagePack.SourceGenerator.Tests/Resources/NullableFormatter/Formatters.TempProject.MyObjectFormatter.g.cs b/tests/MessagePack.SourceGenerator.Tests/Resources/NullableFormatter/Formatters.TempProject.MyObjectFormatter.g.cs new file mode 100644 index 000000000..b3d337ecd --- /dev/null +++ b/tests/MessagePack.SourceGenerator.Tests/Resources/NullableFormatter/Formatters.TempProject.MyObjectFormatter.g.cs @@ -0,0 +1,62 @@ +// + +#pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 + +namespace Formatters.TempProject +{ + using MsgPack = global::MessagePack; + + internal sealed class MyObjectFormatter : MsgPack::Formatters.IMessagePackFormatter + { + + public void Serialize(ref MsgPack::MessagePackWriter writer, global::TempProject.MyObject value, MsgPack::MessagePackSerializerOptions options) + { + if (value == null) + { + writer.WriteNil(); + return; + } + + MsgPack::IFormatterResolver formatterResolver = options.Resolver; + writer.WriteArrayHeader(3); + MsgPack::FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Serialize(ref writer, value.ValueNullableInt, options); + MsgPack::FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Serialize(ref writer, value.ValueNullableEnum, options); + MsgPack::FormatterResolverExtensions.GetFormatterWithVerify<(int, long)?>(formatterResolver).Serialize(ref writer, value.ValueNullableStruct, options); + } + + public global::TempProject.MyObject Deserialize(ref MsgPack::MessagePackReader reader, MsgPack::MessagePackSerializerOptions options) + { + if (reader.TryReadNil()) + { + return null; + } + + options.Security.DepthStep(ref reader); + MsgPack::IFormatterResolver formatterResolver = options.Resolver; + var length = reader.ReadArrayHeader(); + var ____result = new global::TempProject.MyObject(); + + for (int i = 0; i < length; i++) + { + switch (i) + { + case 0: + ____result.ValueNullableInt = MsgPack::FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Deserialize(ref reader, options); + break; + case 1: + ____result.ValueNullableEnum = MsgPack::FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Deserialize(ref reader, options); + break; + case 2: + ____result.ValueNullableStruct = MsgPack::FormatterResolverExtensions.GetFormatterWithVerify<(int, long)?>(formatterResolver).Deserialize(ref reader, options); + break; + default: + reader.Skip(); + break; + } + } + + reader.Depth--; + return ____result; + } + } +} diff --git a/tests/MessagePack.SourceGenerator.Tests/Resources/NullableFormatter/MessagePack.GeneratedMessagePackResolver.g.cs b/tests/MessagePack.SourceGenerator.Tests/Resources/NullableFormatter/MessagePack.GeneratedMessagePackResolver.g.cs new file mode 100644 index 000000000..8bd26c47d --- /dev/null +++ b/tests/MessagePack.SourceGenerator.Tests/Resources/NullableFormatter/MessagePack.GeneratedMessagePackResolver.g.cs @@ -0,0 +1,78 @@ +// + +#pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 + +namespace MessagePack +{ + using MsgPack = global::MessagePack; + using Formatters = global::Formatters; + + /// A MessagePack resolver that uses generated formatters for types in this assembly. + internal class GeneratedMessagePackResolver : MsgPack::IFormatterResolver + { + /// An instance of this resolver that only returns formatters specifically generated for types in this assembly. + public static readonly MsgPack::IFormatterResolver Instance = new GeneratedMessagePackResolver(); + + /// An instance of this resolver that returns standard AOT-compatible formatters as well as formatters specifically generated for types in this assembly. + public static readonly MsgPack::IFormatterResolver InstanceWithStandardAotResolver = MsgPack::Resolvers.CompositeResolver.Create(Instance, MsgPack::Resolvers.StandardAotResolver.Instance); + + private GeneratedMessagePackResolver() + { + } + + public MsgPack::Formatters.IMessagePackFormatter GetFormatter() + { + return FormatterCache.Formatter; + } + + private static class FormatterCache + { + internal static readonly MsgPack::Formatters.IMessagePackFormatter Formatter; + + static FormatterCache() + { + var f = GeneratedMessagePackResolverGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + Formatter = (MsgPack::Formatters.IMessagePackFormatter)f; + } + } + } + } + + internal static class GeneratedMessagePackResolverGetFormatterHelper + { + private static readonly global::System.Collections.Generic.Dictionary lookup; + + static GeneratedMessagePackResolverGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(5) + { + { typeof((int, long)), 0 }, + { typeof((int, long)?), 1 }, + { typeof(global::TempProject.MyEnum?), 2 }, + { typeof(global::TempProject.MyEnum), 3 }, + { typeof(global::TempProject.MyObject), 4 }, + }; + } + + internal static object GetFormatter(global::System.Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + case 0: return new MsgPack::Formatters.ValueTupleFormatter(); + case 1: return new MsgPack::Formatters.NullableFormatter<(int, long)>(); + case 2: return new MsgPack::Formatters.NullableFormatter(); + case 3: return new Formatters::TempProject.MyEnumFormatter(); + case 4: return new Formatters::TempProject.MyObjectFormatter(); + default: return null; + } + } + } +} diff --git a/tests/MessagePack.SourceGenerator.Tests/Resources/WellKnownGenericsFormatter/Formatters.TempProject.MyObjectFormatter.g.cs b/tests/MessagePack.SourceGenerator.Tests/Resources/WellKnownGenericsFormatter/Formatters.TempProject.MyObjectFormatter.g.cs new file mode 100644 index 000000000..a39e9ea47 --- /dev/null +++ b/tests/MessagePack.SourceGenerator.Tests/Resources/WellKnownGenericsFormatter/Formatters.TempProject.MyObjectFormatter.g.cs @@ -0,0 +1,62 @@ +// + +#pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 + +namespace Formatters.TempProject +{ + using MsgPack = global::MessagePack; + + internal sealed class MyObjectFormatter : MsgPack::Formatters.IMessagePackFormatter + { + + public void Serialize(ref MsgPack::MessagePackWriter writer, global::TempProject.MyObject value, MsgPack::MessagePackSerializerOptions options) + { + if (value == null) + { + writer.WriteNil(); + return; + } + + MsgPack::IFormatterResolver formatterResolver = options.Resolver; + writer.WriteArrayHeader(3); + MsgPack::FormatterResolverExtensions.GetFormatterWithVerify>(formatterResolver).Serialize(ref writer, value.ValueList, options); + MsgPack::FormatterResolverExtensions.GetFormatterWithVerify>>(formatterResolver).Serialize(ref writer, value.ValueListNested, options); + MsgPack::FormatterResolverExtensions.GetFormatterWithVerify<(int, string, long)>(formatterResolver).Serialize(ref writer, value.ValueValueTuple, options); + } + + public global::TempProject.MyObject Deserialize(ref MsgPack::MessagePackReader reader, MsgPack::MessagePackSerializerOptions options) + { + if (reader.TryReadNil()) + { + return null; + } + + options.Security.DepthStep(ref reader); + MsgPack::IFormatterResolver formatterResolver = options.Resolver; + var length = reader.ReadArrayHeader(); + var ____result = new global::TempProject.MyObject(); + + for (int i = 0; i < length; i++) + { + switch (i) + { + case 0: + ____result.ValueList = MsgPack::FormatterResolverExtensions.GetFormatterWithVerify>(formatterResolver).Deserialize(ref reader, options); + break; + case 1: + ____result.ValueListNested = MsgPack::FormatterResolverExtensions.GetFormatterWithVerify>>(formatterResolver).Deserialize(ref reader, options); + break; + case 2: + ____result.ValueValueTuple = MsgPack::FormatterResolverExtensions.GetFormatterWithVerify<(int, string, long)>(formatterResolver).Deserialize(ref reader, options); + break; + default: + reader.Skip(); + break; + } + } + + reader.Depth--; + return ____result; + } + } +} diff --git a/tests/MessagePack.SourceGenerator.Tests/Resources/WellKnownGenericsFormatter/MessagePack.GeneratedMessagePackResolver.g.cs b/tests/MessagePack.SourceGenerator.Tests/Resources/WellKnownGenericsFormatter/MessagePack.GeneratedMessagePackResolver.g.cs new file mode 100644 index 000000000..f3e486314 --- /dev/null +++ b/tests/MessagePack.SourceGenerator.Tests/Resources/WellKnownGenericsFormatter/MessagePack.GeneratedMessagePackResolver.g.cs @@ -0,0 +1,76 @@ +// + +#pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 + +namespace MessagePack +{ + using MsgPack = global::MessagePack; + using Formatters = global::Formatters; + + /// A MessagePack resolver that uses generated formatters for types in this assembly. + internal class GeneratedMessagePackResolver : MsgPack::IFormatterResolver + { + /// An instance of this resolver that only returns formatters specifically generated for types in this assembly. + public static readonly MsgPack::IFormatterResolver Instance = new GeneratedMessagePackResolver(); + + /// An instance of this resolver that returns standard AOT-compatible formatters as well as formatters specifically generated for types in this assembly. + public static readonly MsgPack::IFormatterResolver InstanceWithStandardAotResolver = MsgPack::Resolvers.CompositeResolver.Create(Instance, MsgPack::Resolvers.StandardAotResolver.Instance); + + private GeneratedMessagePackResolver() + { + } + + public MsgPack::Formatters.IMessagePackFormatter GetFormatter() + { + return FormatterCache.Formatter; + } + + private static class FormatterCache + { + internal static readonly MsgPack::Formatters.IMessagePackFormatter Formatter; + + static FormatterCache() + { + var f = GeneratedMessagePackResolverGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + Formatter = (MsgPack::Formatters.IMessagePackFormatter)f; + } + } + } + } + + internal static class GeneratedMessagePackResolverGetFormatterHelper + { + private static readonly global::System.Collections.Generic.Dictionary lookup; + + static GeneratedMessagePackResolverGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(4) + { + { typeof((int, string, long)), 0 }, + { typeof(global::System.Collections.Generic.List>), 1 }, + { typeof(global::System.Collections.Generic.List), 2 }, + { typeof(global::TempProject.MyObject), 3 }, + }; + } + + internal static object GetFormatter(global::System.Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + case 0: return new MsgPack::Formatters.ValueTupleFormatter(); + case 1: return new MsgPack::Formatters.ListFormatter>(); + case 2: return new MsgPack::Formatters.ListFormatter(); + case 3: return new Formatters::TempProject.MyObjectFormatter(); + default: return null; + } + } + } +} diff --git a/tests/MessagePack.SourceGenerator.Unity.Tests/MessagePack.SourceGenerator.Unity.Tests.csproj b/tests/MessagePack.SourceGenerator.Unity.Tests/MessagePack.SourceGenerator.Unity.Tests.csproj index bde2c7d67..4a3df258c 100644 --- a/tests/MessagePack.SourceGenerator.Unity.Tests/MessagePack.SourceGenerator.Unity.Tests.csproj +++ b/tests/MessagePack.SourceGenerator.Unity.Tests/MessagePack.SourceGenerator.Unity.Tests.csproj @@ -10,7 +10,6 @@ - From 88640ce6ba08e8ec2630505f3bd2d45e2ef7a59e Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Wed, 12 Apr 2023 06:38:42 -0600 Subject: [PATCH 091/660] Migrate second of 3 tests --- .../GenerateMessagePackFormatterAttrTest.cs | 74 ------------------- .../MessagePack.SourceGenerator.Tests.csproj | 1 - .../MessagePackFormatterAttributeTests.cs | 46 ++++++++++++ .../Formatters.TempProject.BarFormatter.g.cs | 54 ++++++++++++++ ...sagePack.GeneratedMessagePackResolver.g.cs | 70 ++++++++++++++++++ ...agePack.SourceGenerator.Unity.Tests.csproj | 1 - 6 files changed, 170 insertions(+), 76 deletions(-) delete mode 100644 tests/MessagePack.SourceGenerator.Tests/GenerateMessagePackFormatterAttrTest.cs create mode 100644 tests/MessagePack.SourceGenerator.Tests/MessagePackFormatterAttributeTests.cs create mode 100644 tests/MessagePack.SourceGenerator.Tests/Resources/CanGenerateMessagePackFormatterAttr/Formatters.TempProject.BarFormatter.g.cs create mode 100644 tests/MessagePack.SourceGenerator.Tests/Resources/CanGenerateMessagePackFormatterAttr/MessagePack.GeneratedMessagePackResolver.g.cs diff --git a/tests/MessagePack.SourceGenerator.Tests/GenerateMessagePackFormatterAttrTest.cs b/tests/MessagePack.SourceGenerator.Tests/GenerateMessagePackFormatterAttrTest.cs deleted file mode 100644 index afec7c0da..000000000 --- a/tests/MessagePack.SourceGenerator.Tests/GenerateMessagePackFormatterAttrTest.cs +++ /dev/null @@ -1,74 +0,0 @@ -// Copyright (c) All contributors. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - -using System; -using System.Threading; -using System.Threading.Tasks; -using Xunit; -using Xunit.Abstractions; - -namespace MessagePack.SourceGenerator.Tests -{ - public class GenerateMessagePackFormatterAttrTest - { - private readonly ITestOutputHelper testOutputHelper; - - public GenerateMessagePackFormatterAttrTest(ITestOutputHelper testOutputHelper) - { - this.testOutputHelper = testOutputHelper; - } - - [Fact] - public async Task CanGenerateMessagePackFormatterAttr() - { - using var tempWorkarea = TemporaryProjectWorkarea.Create(); - var contents = @" -using System; -using System.Collections.Generic; -using MessagePack; - -namespace TempProject -{ - [MessagePackFormatter(typeof(MyFormatter))] - public class MyMessagePackObject - { - public int Foo { get; set; } - - public class MyFormatter : IMessagePackFormatter - { - public MyMessagePackObject Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options) - { - throw new NotImplementedException(); - } - - public void Serialize(ref MessagePackWriter writer, MyMessagePackObject value, MessagePackSerializerOptions options) - { - throw new NotImplementedException(); - } - } - } - - [MessagePackObject] - public class Bar - { - [Key(0)] - public MyMessagePackObject Baz { get; set; } - } -} - "; - tempWorkarea.AddFileToTargetProject("MyMessagePackObject.cs", contents); - - var compiler = new MessagePackCompiler.CodeGenerator(testOutputHelper.WriteLine, CancellationToken.None); - - // can compile(does not throw MessagePackGeneratorResolveFailedException : Serialization Object must mark MessagePackObjectAttribute. type: global::TempProject.MyMessagePackObject) - await compiler.GenerateFileAsync( - tempWorkarea.GetOutputCompilation().Compilation, - tempWorkarea.OutputDirectory, - "TempProjectResolver", - "TempProject.Generated", - false, - string.Empty, - Array.Empty()); - } - } -} diff --git a/tests/MessagePack.SourceGenerator.Tests/MessagePack.SourceGenerator.Tests.csproj b/tests/MessagePack.SourceGenerator.Tests/MessagePack.SourceGenerator.Tests.csproj index 231e762a7..c9933f335 100644 --- a/tests/MessagePack.SourceGenerator.Tests/MessagePack.SourceGenerator.Tests.csproj +++ b/tests/MessagePack.SourceGenerator.Tests/MessagePack.SourceGenerator.Tests.csproj @@ -8,7 +8,6 @@ - diff --git a/tests/MessagePack.SourceGenerator.Tests/MessagePackFormatterAttributeTests.cs b/tests/MessagePack.SourceGenerator.Tests/MessagePackFormatterAttributeTests.cs new file mode 100644 index 000000000..0836bf944 --- /dev/null +++ b/tests/MessagePack.SourceGenerator.Tests/MessagePackFormatterAttributeTests.cs @@ -0,0 +1,46 @@ +// Copyright (c) All contributors. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +public class MessagePackFormatterAttributeTests +{ + [Fact] + public async Task CanGenerateMessagePackFormatterAttr() + { + string testSource = """ +using System; +using System.Collections.Generic; +using MessagePack; +using MessagePack.Formatters; + +namespace TempProject +{ + [MessagePackFormatter(typeof(MyFormatter))] + public class MyMessagePackObject + { + public int Foo { get; set; } + + public class MyFormatter : IMessagePackFormatter + { + public MyMessagePackObject Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options) + { + throw new NotImplementedException(); + } + + public void Serialize(ref MessagePackWriter writer, MyMessagePackObject value, MessagePackSerializerOptions options) + { + throw new NotImplementedException(); + } + } + } + + [MessagePackObject] + public class Bar + { + [Key(0)] + public MyMessagePackObject Baz { get; set; } + } +} +"""; + await VerifyCS.Test.RunDefaultAsync(testSource); + } +} diff --git a/tests/MessagePack.SourceGenerator.Tests/Resources/CanGenerateMessagePackFormatterAttr/Formatters.TempProject.BarFormatter.g.cs b/tests/MessagePack.SourceGenerator.Tests/Resources/CanGenerateMessagePackFormatterAttr/Formatters.TempProject.BarFormatter.g.cs new file mode 100644 index 000000000..240e394d0 --- /dev/null +++ b/tests/MessagePack.SourceGenerator.Tests/Resources/CanGenerateMessagePackFormatterAttr/Formatters.TempProject.BarFormatter.g.cs @@ -0,0 +1,54 @@ +// + +#pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 + +namespace Formatters.TempProject +{ + using MsgPack = global::MessagePack; + + internal sealed class BarFormatter : MsgPack::Formatters.IMessagePackFormatter + { + + public void Serialize(ref MsgPack::MessagePackWriter writer, global::TempProject.Bar value, MsgPack::MessagePackSerializerOptions options) + { + if (value == null) + { + writer.WriteNil(); + return; + } + + MsgPack::IFormatterResolver formatterResolver = options.Resolver; + writer.WriteArrayHeader(1); + MsgPack::FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Serialize(ref writer, value.Baz, options); + } + + public global::TempProject.Bar Deserialize(ref MsgPack::MessagePackReader reader, MsgPack::MessagePackSerializerOptions options) + { + if (reader.TryReadNil()) + { + return null; + } + + options.Security.DepthStep(ref reader); + MsgPack::IFormatterResolver formatterResolver = options.Resolver; + var length = reader.ReadArrayHeader(); + var ____result = new global::TempProject.Bar(); + + for (int i = 0; i < length; i++) + { + switch (i) + { + case 0: + ____result.Baz = MsgPack::FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Deserialize(ref reader, options); + break; + default: + reader.Skip(); + break; + } + } + + reader.Depth--; + return ____result; + } + } +} diff --git a/tests/MessagePack.SourceGenerator.Tests/Resources/CanGenerateMessagePackFormatterAttr/MessagePack.GeneratedMessagePackResolver.g.cs b/tests/MessagePack.SourceGenerator.Tests/Resources/CanGenerateMessagePackFormatterAttr/MessagePack.GeneratedMessagePackResolver.g.cs new file mode 100644 index 000000000..a1671a91c --- /dev/null +++ b/tests/MessagePack.SourceGenerator.Tests/Resources/CanGenerateMessagePackFormatterAttr/MessagePack.GeneratedMessagePackResolver.g.cs @@ -0,0 +1,70 @@ +// + +#pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 + +namespace MessagePack +{ + using MsgPack = global::MessagePack; + using Formatters = global::Formatters; + + /// A MessagePack resolver that uses generated formatters for types in this assembly. + internal class GeneratedMessagePackResolver : MsgPack::IFormatterResolver + { + /// An instance of this resolver that only returns formatters specifically generated for types in this assembly. + public static readonly MsgPack::IFormatterResolver Instance = new GeneratedMessagePackResolver(); + + /// An instance of this resolver that returns standard AOT-compatible formatters as well as formatters specifically generated for types in this assembly. + public static readonly MsgPack::IFormatterResolver InstanceWithStandardAotResolver = MsgPack::Resolvers.CompositeResolver.Create(Instance, MsgPack::Resolvers.StandardAotResolver.Instance); + + private GeneratedMessagePackResolver() + { + } + + public MsgPack::Formatters.IMessagePackFormatter GetFormatter() + { + return FormatterCache.Formatter; + } + + private static class FormatterCache + { + internal static readonly MsgPack::Formatters.IMessagePackFormatter Formatter; + + static FormatterCache() + { + var f = GeneratedMessagePackResolverGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + Formatter = (MsgPack::Formatters.IMessagePackFormatter)f; + } + } + } + } + + internal static class GeneratedMessagePackResolverGetFormatterHelper + { + private static readonly global::System.Collections.Generic.Dictionary lookup; + + static GeneratedMessagePackResolverGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(1) + { + { typeof(global::TempProject.Bar), 0 }, + }; + } + + internal static object GetFormatter(global::System.Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + case 0: return new Formatters::TempProject.BarFormatter(); + default: return null; + } + } + } +} diff --git a/tests/MessagePack.SourceGenerator.Unity.Tests/MessagePack.SourceGenerator.Unity.Tests.csproj b/tests/MessagePack.SourceGenerator.Unity.Tests/MessagePack.SourceGenerator.Unity.Tests.csproj index 4a3df258c..f65134d53 100644 --- a/tests/MessagePack.SourceGenerator.Unity.Tests/MessagePack.SourceGenerator.Unity.Tests.csproj +++ b/tests/MessagePack.SourceGenerator.Unity.Tests/MessagePack.SourceGenerator.Unity.Tests.csproj @@ -10,7 +10,6 @@ - From 3753c27ab37c1c00f7fac68cefbfc4bd1add33a3 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Wed, 12 Apr 2023 06:47:12 -0600 Subject: [PATCH 092/660] Migrate last of the tests --- .../GenerateStringKeyedFormatterTest.cs | 867 ------------------ .../MessagePack.SourceGenerator.Tests.csproj | 4 - ...pProject.MyMessagePackObjectFormatter.g.cs | 72 ++ ...sagePack.GeneratedMessagePackResolver.g.cs | 70 ++ ...pProject.MyMessagePackObjectFormatter.g.cs | 72 ++ ...sagePack.GeneratedMessagePackResolver.g.cs | 70 ++ ...pProject.MyMessagePackObjectFormatter.g.cs | 72 ++ ...sagePack.GeneratedMessagePackResolver.g.cs | 70 ++ ...pProject.MyMessagePackObjectFormatter.g.cs | 74 ++ ...sagePack.GeneratedMessagePackResolver.g.cs | 70 ++ ...pProject.MyMessagePackObjectFormatter.g.cs | 73 ++ ...sagePack.GeneratedMessagePackResolver.g.cs | 70 ++ ...pProject.MyMessagePackObjectFormatter.g.cs | 73 ++ ...sagePack.GeneratedMessagePackResolver.g.cs | 70 ++ ...pProject.MyMessagePackObjectFormatter.g.cs | 72 ++ ...sagePack.GeneratedMessagePackResolver.g.cs | 70 ++ ...pProject.MyMessagePackObjectFormatter.g.cs | 72 ++ ...sagePack.GeneratedMessagePackResolver.g.cs | 70 ++ ...pProject.MyMessagePackObjectFormatter.g.cs | 72 ++ ...sagePack.GeneratedMessagePackResolver.g.cs | 70 ++ ...pProject.MyMessagePackObjectFormatter.g.cs | 74 ++ ...sagePack.GeneratedMessagePackResolver.g.cs | 70 ++ ...pProject.MyMessagePackObjectFormatter.g.cs | 81 ++ ...sagePack.GeneratedMessagePackResolver.g.cs | 70 ++ ...pProject.MyMessagePackObjectFormatter.g.cs | 61 ++ ...sagePack.GeneratedMessagePackResolver.g.cs | 70 ++ ...pProject.MyMessagePackObjectFormatter.g.cs | 81 ++ ...sagePack.GeneratedMessagePackResolver.g.cs | 70 ++ .../StringKeyedFormatterTests.cs | 315 +++++++ ...agePack.SourceGenerator.Unity.Tests.csproj | 1 - 30 files changed, 2174 insertions(+), 872 deletions(-) delete mode 100644 tests/MessagePack.SourceGenerator.Tests/GenerateStringKeyedFormatterTest.cs create mode 100644 tests/MessagePack.SourceGenerator.Tests/Resources/PropertiesGetterOnlyDefaultValue/Formatters.TempProject.MyMessagePackObjectFormatter.g.cs create mode 100644 tests/MessagePack.SourceGenerator.Tests/Resources/PropertiesGetterOnlyDefaultValue/MessagePack.GeneratedMessagePackResolver.g.cs create mode 100644 tests/MessagePack.SourceGenerator.Tests/Resources/PropertiesGetterOnlyIgnore/Formatters.TempProject.MyMessagePackObjectFormatter.g.cs create mode 100644 tests/MessagePack.SourceGenerator.Tests/Resources/PropertiesGetterOnlyIgnore/MessagePack.GeneratedMessagePackResolver.g.cs create mode 100644 tests/MessagePack.SourceGenerator.Tests/Resources/PropertiesGetterOnlyMixed/Formatters.TempProject.MyMessagePackObjectFormatter.g.cs create mode 100644 tests/MessagePack.SourceGenerator.Tests/Resources/PropertiesGetterOnlyMixed/MessagePack.GeneratedMessagePackResolver.g.cs create mode 100644 tests/MessagePack.SourceGenerator.Tests/Resources/PropertiesGetterOnlyWithParameterizedConstructor/Formatters.TempProject.MyMessagePackObjectFormatter.g.cs create mode 100644 tests/MessagePack.SourceGenerator.Tests/Resources/PropertiesGetterOnlyWithParameterizedConstructor/MessagePack.GeneratedMessagePackResolver.g.cs create mode 100644 tests/MessagePack.SourceGenerator.Tests/Resources/PropertiesGetterOnlyWithParameterizedConstructorDefaultValue/Formatters.TempProject.MyMessagePackObjectFormatter.g.cs create mode 100644 tests/MessagePack.SourceGenerator.Tests/Resources/PropertiesGetterOnlyWithParameterizedConstructorDefaultValue/MessagePack.GeneratedMessagePackResolver.g.cs create mode 100644 tests/MessagePack.SourceGenerator.Tests/Resources/PropertiesGetterOnlyWithParameterizedConstructorPartially/Formatters.TempProject.MyMessagePackObjectFormatter.g.cs create mode 100644 tests/MessagePack.SourceGenerator.Tests/Resources/PropertiesGetterOnlyWithParameterizedConstructorPartially/MessagePack.GeneratedMessagePackResolver.g.cs create mode 100644 tests/MessagePack.SourceGenerator.Tests/Resources/PropertiesGetterSetter/Formatters.TempProject.MyMessagePackObjectFormatter.g.cs create mode 100644 tests/MessagePack.SourceGenerator.Tests/Resources/PropertiesGetterSetter/MessagePack.GeneratedMessagePackResolver.g.cs create mode 100644 tests/MessagePack.SourceGenerator.Tests/Resources/PropertiesGetterSetterWithDefaultValue/Formatters.TempProject.MyMessagePackObjectFormatter.g.cs create mode 100644 tests/MessagePack.SourceGenerator.Tests/Resources/PropertiesGetterSetterWithDefaultValue/MessagePack.GeneratedMessagePackResolver.g.cs create mode 100644 tests/MessagePack.SourceGenerator.Tests/Resources/PropertiesGetterSetterWithDefaultValueInputPartially/Formatters.TempProject.MyMessagePackObjectFormatter.g.cs create mode 100644 tests/MessagePack.SourceGenerator.Tests/Resources/PropertiesGetterSetterWithDefaultValueInputPartially/MessagePack.GeneratedMessagePackResolver.g.cs create mode 100644 tests/MessagePack.SourceGenerator.Tests/Resources/PropertiesGetterSetterWithParameterizedConstructor/Formatters.TempProject.MyMessagePackObjectFormatter.g.cs create mode 100644 tests/MessagePack.SourceGenerator.Tests/Resources/PropertiesGetterSetterWithParameterizedConstructor/MessagePack.GeneratedMessagePackResolver.g.cs create mode 100644 tests/MessagePack.SourceGenerator.Tests/Resources/PropertiesGetterSetterWithParameterizedConstructorAndDefaultValue/Formatters.TempProject.MyMessagePackObjectFormatter.g.cs create mode 100644 tests/MessagePack.SourceGenerator.Tests/Resources/PropertiesGetterSetterWithParameterizedConstructorAndDefaultValue/MessagePack.GeneratedMessagePackResolver.g.cs create mode 100644 tests/MessagePack.SourceGenerator.Tests/Resources/PropertiesGetterSetterWithParameterizedConstructorDoNotUseSetter/Formatters.TempProject.MyMessagePackObjectFormatter.g.cs create mode 100644 tests/MessagePack.SourceGenerator.Tests/Resources/PropertiesGetterSetterWithParameterizedConstructorDoNotUseSetter/MessagePack.GeneratedMessagePackResolver.g.cs create mode 100644 tests/MessagePack.SourceGenerator.Tests/Resources/PropertiesGetterSetterWithParameterizedConstructorPartially/Formatters.TempProject.MyMessagePackObjectFormatter.g.cs create mode 100644 tests/MessagePack.SourceGenerator.Tests/Resources/PropertiesGetterSetterWithParameterizedConstructorPartially/MessagePack.GeneratedMessagePackResolver.g.cs create mode 100644 tests/MessagePack.SourceGenerator.Tests/StringKeyedFormatterTests.cs diff --git a/tests/MessagePack.SourceGenerator.Tests/GenerateStringKeyedFormatterTest.cs b/tests/MessagePack.SourceGenerator.Tests/GenerateStringKeyedFormatterTest.cs deleted file mode 100644 index ffd1d2df6..000000000 --- a/tests/MessagePack.SourceGenerator.Tests/GenerateStringKeyedFormatterTest.cs +++ /dev/null @@ -1,867 +0,0 @@ -// Copyright (c) All contributors. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - -using System; -using System.Buffers; -using System.IO; -using System.Linq; -using System.Runtime.Loader; -using System.Threading; -using System.Threading.Tasks; -using FluentAssertions; -using MessagePack.Resolvers; -using Microsoft.CodeAnalysis; -using Nerdbank.Streams; -using Xunit; -using Xunit.Abstractions; - -namespace MessagePack.SourceGenerator.Tests -{ - public class GenerateStringKeyedFormatterTest - { - private readonly ITestOutputHelper testOutputHelper; - - public GenerateStringKeyedFormatterTest(ITestOutputHelper testOutputHelper) - { - this.testOutputHelper = testOutputHelper; - } - - [Fact] - public async Task PropertiesGetterSetter() - { - using var tempWorkarea = TemporaryProjectWorkarea.Create(); - var contents = @" -using System; -using System.Collections.Generic; -using MessagePack; - -namespace TempProject -{ - [MessagePackObject(true)] - public class MyMessagePackObject - { - public int A { get; set; } - public string B { get; set; } - } -} - "; - tempWorkarea.AddFileToTargetProject("MyMessagePackObject.cs", contents); - - var compiler = new MessagePackCompiler.CodeGenerator(testOutputHelper.WriteLine, CancellationToken.None); - await compiler.GenerateFileAsync( - tempWorkarea.GetOutputCompilation().Compilation, - tempWorkarea.OutputDirectory, - "TempProjectResolver", - "TempProject.Generated", - false, - string.Empty, - Array.Empty()); - - var compilation = tempWorkarea.GetOutputCompilation(); - compilation.Compilation.GetDiagnostics().Should().NotContain(x => x.Severity == DiagnosticSeverity.Error); - - // Run tests with the generated resolver/formatter assembly. - compilation.ExecuteWithGeneratedAssembly((ctx, assembly) => - { - var mpoType = assembly.GetType("TempProject.MyMessagePackObject"); - var options = MessagePackSerializerOptions.Standard - .WithResolver(CompositeResolver.Create( - StandardResolver.Instance, - TestUtilities.GetResolverInstance(assembly, "TempProject.Generated.Resolvers.TempProjectResolver"))); - - // Build `{ }`. - var seq = new Sequence(); - var writer = new MessagePackWriter(seq); - writer.WriteMapHeader(0); - writer.Flush(); - - // Verify deserialization - dynamic result = MessagePackSerializer.Deserialize(mpoType, seq, options); - ((int)result.A).Should().Be(0); - ((string)result.B).Should().BeNull(); - - // Verify round trip serialization/deserialization. - result.A = 123; - result.B = "foobar"; - - var serialized = MessagePackSerializer.Serialize(mpoType, (object)result, options); - dynamic result2 = MessagePackSerializer.Deserialize(mpoType, serialized, options); - ((int)result2.A).Should().Be(123); - ((string)result2.B).Should().Be("foobar"); - }); - } - - [Fact] - public async Task PropertiesGetterOnlyMixed() - { - using var tempWorkarea = TemporaryProjectWorkarea.Create(); - var contents = @" -using System; -using System.Collections.Generic; -using MessagePack; - -namespace TempProject -{ - [MessagePackObject(true)] - public class MyMessagePackObject - { - public int A { get; } - public string B { get; set; } - } -} - "; - tempWorkarea.AddFileToTargetProject("MyMessagePackObject.cs", contents); - - var compiler = new MessagePackCompiler.CodeGenerator(testOutputHelper.WriteLine, CancellationToken.None); - await compiler.GenerateFileAsync( - tempWorkarea.GetOutputCompilation().Compilation, - tempWorkarea.OutputDirectory, - "TempProjectResolver", - "TempProject.Generated", - false, - string.Empty, - Array.Empty()); - - var compilation = tempWorkarea.GetOutputCompilation(); - compilation.Compilation.GetDiagnostics().Should().NotContain(x => x.Severity == DiagnosticSeverity.Error); - - // Run tests with the generated resolver/formatter assembly. - compilation.ExecuteWithGeneratedAssembly((ctx, assembly) => - { - var mpoType = assembly.GetType("TempProject.MyMessagePackObject"); - var options = MessagePackSerializerOptions.Standard - .WithResolver(CompositeResolver.Create( - StandardResolver.Instance, - TestUtilities.GetResolverInstance(assembly, "TempProject.Generated.Resolvers.TempProjectResolver"))); - - // Build `{ "A": -1, "B": "foobar" }`. - var seq = new Sequence(); - var writer = new MessagePackWriter(seq); - writer.WriteMapHeader(2); - writer.Write("A"); - writer.Write(-1); - writer.Write("B"); - writer.Write("foobar"); - writer.Flush(); - - // Verify deserialization - dynamic result = MessagePackSerializer.Deserialize(mpoType, seq, options); - ((int)result.A).Should().Be(0); // default - ((string)result.B).Should().Be("foobar"); // from input - }); - } - - [Fact] - public async Task PropertiesGetterOnlyIgnore() - { - using var tempWorkarea = TemporaryProjectWorkarea.Create(); - var contents = @" -using System; -using System.Collections.Generic; -using MessagePack; - -namespace TempProject -{ - [MessagePackObject(true)] - public class MyMessagePackObject - { - public int A { get; } - public string B { get; } - } -} - "; - tempWorkarea.AddFileToTargetProject("MyMessagePackObject.cs", contents); - - var compiler = new MessagePackCompiler.CodeGenerator(testOutputHelper.WriteLine, CancellationToken.None); - await compiler.GenerateFileAsync( - tempWorkarea.GetOutputCompilation().Compilation, - tempWorkarea.OutputDirectory, - "TempProjectResolver", - "TempProject.Generated", - false, - string.Empty, - Array.Empty()); - - var compilation = tempWorkarea.GetOutputCompilation(); - compilation.Compilation.GetDiagnostics().Should().NotContain(x => x.Severity == DiagnosticSeverity.Error); - - // Run tests with the generated resolver/formatter assembly. - compilation.ExecuteWithGeneratedAssembly((ctx, assembly) => - { - var mpoType = assembly.GetType("TempProject.MyMessagePackObject"); - var options = MessagePackSerializerOptions.Standard - .WithResolver(CompositeResolver.Create( - StandardResolver.Instance, - TestUtilities.GetResolverInstance(assembly, "TempProject.Generated.Resolvers.TempProjectResolver"))); - - // Build `{ "A": -1, "B": "foobar" }`. - var seq = new Sequence(); - var writer = new MessagePackWriter(seq); - writer.WriteMapHeader(2); - writer.Write("A"); - writer.Write(-1); - writer.Write("B"); - writer.Write("foobar"); - writer.Flush(); - - // Verify deserialization - dynamic result = MessagePackSerializer.Deserialize(mpoType, seq, options); - ((int)result.A).Should().Be(0); - ((string)result.B).Should().BeNull(); - }); - } - - [Fact] - public async Task PropertiesGetterOnlyDefaultValue() - { - using var tempWorkarea = TemporaryProjectWorkarea.Create(); - var contents = @" -using System; -using System.Collections.Generic; -using MessagePack; - -namespace TempProject -{ - [MessagePackObject(true)] - public class MyMessagePackObject - { - public int A { get; } = 123; - public string B { get; } = ""foobar""; - } -} - "; - tempWorkarea.AddFileToTargetProject("MyMessagePackObject.cs", contents); - - var compiler = new MessagePackCompiler.CodeGenerator(testOutputHelper.WriteLine, CancellationToken.None); - await compiler.GenerateFileAsync( - tempWorkarea.GetOutputCompilation().Compilation, - tempWorkarea.OutputDirectory, - "TempProjectResolver", - "TempProject.Generated", - false, - string.Empty, - Array.Empty()); - - var compilation = tempWorkarea.GetOutputCompilation(); - compilation.Compilation.GetDiagnostics().Should().NotContain(x => x.Severity == DiagnosticSeverity.Error); - - // Run tests with the generated resolver/formatter assembly. - compilation.ExecuteWithGeneratedAssembly((ctx, assembly) => - { - var mpoType = assembly.GetType("TempProject.MyMessagePackObject"); - var options = MessagePackSerializerOptions.Standard - .WithResolver(CompositeResolver.Create( - StandardResolver.Instance, - TestUtilities.GetResolverInstance(assembly, "TempProject.Generated.Resolvers.TempProjectResolver"))); - - // Build `{ }`. - var seq = new Sequence(); - var writer = new MessagePackWriter(seq); - writer.WriteMapHeader(0); - writer.Flush(); - - // Verify deserialization - // The deserialized object has default values. - dynamic result = MessagePackSerializer.Deserialize(mpoType, seq, options); - ((int)result.A).Should().Be(123); - ((string)result.B).Should().Be("foobar"); - }); - } - - [Fact] - public async Task PropertiesGetterSetterWithDefaultValue() - { - using var tempWorkarea = TemporaryProjectWorkarea.Create(); - var contents = @" -using System; -using System.Collections.Generic; -using MessagePack; - -namespace TempProject -{ - [MessagePackObject(true)] - public class MyMessagePackObject - { - public int A { get; set; } = 123; - public string B { get; set; } = ""foobar""; - } -} - "; - tempWorkarea.AddFileToTargetProject("MyMessagePackObject.cs", contents); - - var compiler = new MessagePackCompiler.CodeGenerator(testOutputHelper.WriteLine, CancellationToken.None); - await compiler.GenerateFileAsync( - tempWorkarea.GetOutputCompilation().Compilation, - tempWorkarea.OutputDirectory, - "TempProjectResolver", - "TempProject.Generated", - false, - string.Empty, - Array.Empty()); - - var compilation = tempWorkarea.GetOutputCompilation(); - compilation.Compilation.GetDiagnostics().Should().NotContain(x => x.Severity == DiagnosticSeverity.Error); - - // Run tests with the generated resolver/formatter assembly. - compilation.ExecuteWithGeneratedAssembly((ctx, assembly) => - { - var mpoType = assembly.GetType("TempProject.MyMessagePackObject"); - var options = MessagePackSerializerOptions.Standard - .WithResolver(CompositeResolver.Create( - StandardResolver.Instance, - TestUtilities.GetResolverInstance(assembly, "TempProject.Generated.Resolvers.TempProjectResolver"))); - - // Build an empty data. - var seq = new Sequence(); - var writer = new MessagePackWriter(seq); - writer.WriteMapHeader(0); - writer.Flush(); - - // Verify deserialization - // The deserialized object has default values. - dynamic result = MessagePackSerializer.Deserialize(mpoType, seq, options); - ((int)result.A).Should().Be(123); - ((string)result.B).Should().Be("foobar"); - - // Verify round trip serialization/deserialization. - result.A = 456; - result.B = "baz"; - - var serialized = MessagePackSerializer.Serialize(mpoType, (object)result, options); - dynamic result2 = MessagePackSerializer.Deserialize(mpoType, serialized, options); - ((int)result2.A).Should().Be(456); - ((string)result2.B).Should().Be("baz"); - }); - } - - [Fact] - public async Task PropertiesGetterSetterWithDefaultValueInputPartially() - { - using var tempWorkarea = TemporaryProjectWorkarea.Create(); - var contents = @" -using System; -using System.Collections.Generic; -using MessagePack; - -namespace TempProject -{ - [MessagePackObject(true)] - public class MyMessagePackObject - { - public int A { get; set; } = 123; - public string B { get; set; } = ""foobar""; - } -} - "; - tempWorkarea.AddFileToTargetProject("MyMessagePackObject.cs", contents); - - var compiler = new MessagePackCompiler.CodeGenerator(testOutputHelper.WriteLine, CancellationToken.None); - await compiler.GenerateFileAsync( - tempWorkarea.GetOutputCompilation().Compilation, - tempWorkarea.OutputDirectory, - "TempProjectResolver", - "TempProject.Generated", - false, - string.Empty, - Array.Empty()); - - var compilation = tempWorkarea.GetOutputCompilation(); - compilation.Compilation.GetDiagnostics().Should().NotContain(x => x.Severity == DiagnosticSeverity.Error); - - // Run tests with the generated resolver/formatter assembly. - compilation.ExecuteWithGeneratedAssembly((ctx, assembly) => - { - var mpoType = assembly.GetType("TempProject.MyMessagePackObject"); - var options = MessagePackSerializerOptions.Standard - .WithResolver(CompositeResolver.Create( - StandardResolver.Instance, - TestUtilities.GetResolverInstance(assembly, "TempProject.Generated.Resolvers.TempProjectResolver"))); - - // Build `{ "A": -1 }` - var seq = new Sequence(); - var writer = new MessagePackWriter(seq); - writer.WriteMapHeader(1); - writer.Write("A"); - writer.Write(-1); - writer.Flush(); - - // Verify deserialization - // The deserialized object has default value and should preserve it. - dynamic result = MessagePackSerializer.Deserialize(mpoType, seq, options); - ((int)result.A).Should().Be(-1); // from input - ((string)result.B).Should().Be("foobar"); // default value - - // Verify round trip serialization/deserialization. - result.A = 456; - result.B = "baz"; - - var serialized = MessagePackSerializer.Serialize(mpoType, (object)result, options); - dynamic result2 = MessagePackSerializer.Deserialize(mpoType, serialized, options); - ((int)result2.A).Should().Be(456); - ((string)result2.B).Should().Be("baz"); - }); - } - - [Fact] - public async Task PropertiesGetterOnlyWithParameterizedConstructor() - { - using var tempWorkarea = TemporaryProjectWorkarea.Create(); - var contents = @" -using System; -using System.Collections.Generic; -using MessagePack; - -namespace TempProject -{ - [MessagePackObject(true)] - public class MyMessagePackObject - { - public int A { get; } - public string B { get; } - - public MyMessagePackObject(int a, string b) - { - A = a; - B = b; - } - } -} - "; - tempWorkarea.AddFileToTargetProject("MyMessagePackObject.cs", contents); - - var compiler = new MessagePackCompiler.CodeGenerator(testOutputHelper.WriteLine, CancellationToken.None); - await compiler.GenerateFileAsync( - tempWorkarea.GetOutputCompilation().Compilation, - tempWorkarea.OutputDirectory, - "TempProjectResolver", - "TempProject.Generated", - false, - string.Empty, - Array.Empty()); - - var compilation = tempWorkarea.GetOutputCompilation(); - compilation.Compilation.GetDiagnostics().Should().NotContain(x => x.Severity == DiagnosticSeverity.Error); - - // Run tests with the generated resolver/formatter assembly. - compilation.ExecuteWithGeneratedAssembly((ctx, assembly) => - { - var mpoType = assembly.GetType("TempProject.MyMessagePackObject"); - var options = MessagePackSerializerOptions.Standard - .WithResolver(CompositeResolver.Create( - StandardResolver.Instance, - TestUtilities.GetResolverInstance(assembly, "TempProject.Generated.Resolvers.TempProjectResolver"))); - - // Build `{ "A": -1, "B": "foobar" }` - var seq = new Sequence(); - var writer = new MessagePackWriter(seq); - writer.WriteMapHeader(2); - writer.Write("A"); - writer.Write(-1); - writer.Write("B"); - writer.Write("foobar"); - writer.Flush(); - - // Verify deserialization - dynamic result = MessagePackSerializer.Deserialize(mpoType, seq, options); - ((int)result.A).Should().Be(-1); // from input - ((string)result.B).Should().Be("foobar"); // from input - - // Verify serialization - var serialized = MessagePackSerializer.Serialize(mpoType, (object)result, options); - serialized.Should().BeEquivalentTo(seq.AsReadOnlySequence.ToArray()); - }); - } - - [Fact] - public async Task PropertiesGetterOnlyWithParameterizedConstructorPartially() - { - using var tempWorkarea = TemporaryProjectWorkarea.Create(); - var contents = @" -using System; -using System.Collections.Generic; -using MessagePack; - -namespace TempProject -{ - [MessagePackObject(true)] - public class MyMessagePackObject - { - public int A { get; } - public string B { get; } - - public MyMessagePackObject(string b) - { - B = b; - } - } -} - "; - tempWorkarea.AddFileToTargetProject("MyMessagePackObject.cs", contents); - - var compiler = new MessagePackCompiler.CodeGenerator(testOutputHelper.WriteLine, CancellationToken.None); - await compiler.GenerateFileAsync( - tempWorkarea.GetOutputCompilation().Compilation, - tempWorkarea.OutputDirectory, - "TempProjectResolver", - "TempProject.Generated", - false, - string.Empty, - Array.Empty()); - - var compilation = tempWorkarea.GetOutputCompilation(); - compilation.Compilation.GetDiagnostics().Should().NotContain(x => x.Severity == DiagnosticSeverity.Error); - - // Run tests with the generated resolver/formatter assembly. - compilation.ExecuteWithGeneratedAssembly((ctx, assembly) => - { - var mpoType = assembly.GetType("TempProject.MyMessagePackObject"); - var options = MessagePackSerializerOptions.Standard - .WithResolver(CompositeResolver.Create( - StandardResolver.Instance, - TestUtilities.GetResolverInstance(assembly, "TempProject.Generated.Resolvers.TempProjectResolver"))); - - // Build `{ "A": -1, "B": "foobar" }` - var seq = new Sequence(); - var writer = new MessagePackWriter(seq); - writer.WriteMapHeader(2); - writer.Write("A"); - writer.Write(-1); - writer.Write("B"); - writer.Write("foobar"); - writer.Flush(); - - // Verify deserialization - dynamic result = MessagePackSerializer.Deserialize(mpoType, seq, options); - ((int)result.A).Should().Be(0); // default value - ((string)result.B).Should().Be("foobar"); // from input - }); - } - - [Fact] - public async Task PropertiesGetterOnlyWithParameterizedConstructorDefaultValue() - { - using var tempWorkarea = TemporaryProjectWorkarea.Create(); - var contents = @" -using System; -using System.Collections.Generic; -using MessagePack; - -namespace TempProject -{ - [MessagePackObject(true)] - public class MyMessagePackObject - { - public int A { get; } = 12345; - public string B { get; } = ""some""; - - public MyMessagePackObject(string b) - { - B = b; - } - } -} - "; - tempWorkarea.AddFileToTargetProject("MyMessagePackObject.cs", contents); - - var compiler = new MessagePackCompiler.CodeGenerator(testOutputHelper.WriteLine, CancellationToken.None); - await compiler.GenerateFileAsync( - tempWorkarea.GetOutputCompilation().Compilation, - tempWorkarea.OutputDirectory, - "TempProjectResolver", - "TempProject.Generated", - false, - string.Empty, - Array.Empty()); - - var compilation = tempWorkarea.GetOutputCompilation(); - compilation.Compilation.GetDiagnostics().Should().NotContain(x => x.Severity == DiagnosticSeverity.Error); - - // Run tests with the generated resolver/formatter assembly. - compilation.ExecuteWithGeneratedAssembly((ctx, assembly) => - { - var mpoType = assembly.GetType("TempProject.MyMessagePackObject"); - var options = MessagePackSerializerOptions.Standard - .WithResolver(CompositeResolver.Create( - StandardResolver.Instance, - TestUtilities.GetResolverInstance(assembly, "TempProject.Generated.Resolvers.TempProjectResolver"))); - - // Build `{ "A": -1, "B": "foobar" }` - var seq = new Sequence(); - var writer = new MessagePackWriter(seq); - writer.WriteMapHeader(2); - writer.Write("A"); - writer.Write(-1); - writer.Write("B"); - writer.Write("foobar"); - writer.Flush(); - - // Verify deserialization - dynamic result = MessagePackSerializer.Deserialize(mpoType, seq, options); - ((int)result.A).Should().Be(12345); // default value - ((string)result.B).Should().Be("foobar"); // from input - }); - } - - [Fact] - public async Task PropertiesGetterSetterWithParameterizedConstructor() - { - using var tempWorkarea = TemporaryProjectWorkarea.Create(); - var contents = @" -using System; -using System.Collections.Generic; -using MessagePack; - -namespace TempProject -{ - [MessagePackObject(true)] - public class MyMessagePackObject - { - public int A { get; set; } - public string B { get; set; } - - public MyMessagePackObject(int a, string b) - { - A = a; - B = b; - } - } -} - "; - tempWorkarea.AddFileToTargetProject("MyMessagePackObject.cs", contents); - - var compiler = new MessagePackCompiler.CodeGenerator(testOutputHelper.WriteLine, CancellationToken.None); - await compiler.GenerateFileAsync( - tempWorkarea.GetOutputCompilation().Compilation, - tempWorkarea.OutputDirectory, - "TempProjectResolver", - "TempProject.Generated", - false, - string.Empty, - Array.Empty()); - - var compilation = tempWorkarea.GetOutputCompilation(); - compilation.Compilation.GetDiagnostics().Should().NotContain(x => x.Severity == DiagnosticSeverity.Error); - - // Run tests with the generated resolver/formatter assembly. - compilation.ExecuteWithGeneratedAssembly((ctx, assembly) => - { - var mpoType = assembly.GetType("TempProject.MyMessagePackObject"); - var options = MessagePackSerializerOptions.Standard - .WithResolver(CompositeResolver.Create( - StandardResolver.Instance, - TestUtilities.GetResolverInstance(assembly, "TempProject.Generated.Resolvers.TempProjectResolver"))); - - // Build `{ "A": -1, "B": "foobar" }` - var seq = new Sequence(); - var writer = new MessagePackWriter(seq); - writer.WriteMapHeader(2); - writer.Write("A"); - writer.Write(-1); - writer.Write("B"); - writer.Write("foobar"); - writer.Flush(); - - // Verify deserialization - dynamic result = MessagePackSerializer.Deserialize(mpoType, seq, options); - ((int)result.A).Should().Be(-1); // from input - ((string)result.B).Should().Be("foobar"); // from input - - // Verify serialization - var serialized = MessagePackSerializer.Serialize(mpoType, (object)result, options); - serialized.Should().BeEquivalentTo(seq.AsReadOnlySequence.ToArray()); - }); - } - - [Fact] - public async Task PropertiesGetterSetterWithParameterizedConstructorPartially() - { - using var tempWorkarea = TemporaryProjectWorkarea.Create(); - var contents = @" -using System; -using System.Collections.Generic; -using MessagePack; - -namespace TempProject -{ - [MessagePackObject(true)] - public class MyMessagePackObject - { - public int A { get; set; } - public string B { get; set; } - - public MyMessagePackObject(int a) - { - A = a; - } - } -} - "; - tempWorkarea.AddFileToTargetProject("MyMessagePackObject.cs", contents); - - var compiler = new MessagePackCompiler.CodeGenerator(testOutputHelper.WriteLine, CancellationToken.None); - await compiler.GenerateFileAsync( - tempWorkarea.GetOutputCompilation().Compilation, - tempWorkarea.OutputDirectory, - "TempProjectResolver", - "TempProject.Generated", - false, - string.Empty, - Array.Empty()); - - var compilation = tempWorkarea.GetOutputCompilation(); - compilation.Compilation.GetDiagnostics().Should().NotContain(x => x.Severity == DiagnosticSeverity.Error); - - // Run tests with the generated resolver/formatter assembly. - compilation.ExecuteWithGeneratedAssembly((ctx, assembly) => - { - var mpoType = assembly.GetType("TempProject.MyMessagePackObject"); - var options = MessagePackSerializerOptions.Standard - .WithResolver(CompositeResolver.Create( - StandardResolver.Instance, - TestUtilities.GetResolverInstance(assembly, "TempProject.Generated.Resolvers.TempProjectResolver"))); - - // Build `{ "A": -1, "B": "foobar" }` - var seq = new Sequence(); - var writer = new MessagePackWriter(seq); - writer.WriteMapHeader(2); - writer.Write("A"); - writer.Write(-1); - writer.Write("B"); - writer.Write("foobar"); - writer.Flush(); - - // Verify deserialization - dynamic result = MessagePackSerializer.Deserialize(mpoType, seq, options); - ((int)result.A).Should().Be(-1); // from ctor - ((string)result.B).Should().Be("foobar"); // from setter - - // Verify serialization - var serialized = MessagePackSerializer.Serialize(mpoType, (object)result, options); - serialized.Should().BeEquivalentTo(seq.AsReadOnlySequence.ToArray()); - }); - } - - [Fact] - public async Task PropertiesGetterSetterWithParameterizedConstructorDoNotUseSetter() - { - using var tempWorkarea = TemporaryProjectWorkarea.Create(); - var contents = @" -using System; -using System.Collections.Generic; -using MessagePack; - -namespace TempProject -{ - [MessagePackObject(true)] - public class MyMessagePackObject - { - public int A { get; set; } - - public MyMessagePackObject(int a) - { - } - } -} - "; - tempWorkarea.AddFileToTargetProject("MyMessagePackObject.cs", contents); - - var compiler = new MessagePackCompiler.CodeGenerator(testOutputHelper.WriteLine, CancellationToken.None); - await compiler.GenerateFileAsync( - tempWorkarea.GetOutputCompilation().Compilation, - tempWorkarea.OutputDirectory, - "TempProjectResolver", - "TempProject.Generated", - false, - string.Empty, - Array.Empty()); - - var compilation = tempWorkarea.GetOutputCompilation(); - compilation.Compilation.GetDiagnostics().Should().NotContain(x => x.Severity == DiagnosticSeverity.Error); - - // Run tests with the generated resolver/formatter assembly. - compilation.ExecuteWithGeneratedAssembly((ctx, assembly) => - { - var mpoType = assembly.GetType("TempProject.MyMessagePackObject"); - var options = MessagePackSerializerOptions.Standard - .WithResolver(CompositeResolver.Create( - StandardResolver.Instance, - TestUtilities.GetResolverInstance(assembly, "TempProject.Generated.Resolvers.TempProjectResolver"))); - - // Build `{ "A": -1 }` - var seq = new Sequence(); - var writer = new MessagePackWriter(seq); - writer.WriteMapHeader(1); - writer.Write("A"); - writer.Write(-1); - writer.Flush(); - - // Verify deserialization - dynamic result = MessagePackSerializer.Deserialize(mpoType, seq, options); - ((int)result.A).Should().Be(0); - }); - } - - [Fact] - public async Task PropertiesGetterSetterWithParameterizedConstructorAndDefaultValue() - { - using var tempWorkarea = TemporaryProjectWorkarea.Create(); - var contents = @" -using System; -using System.Collections.Generic; -using MessagePack; - -namespace TempProject -{ - [MessagePackObject(true)] - public class MyMessagePackObject - { - public int A { get; set; } - public string B { get; set; } = ""foobar""; - - public MyMessagePackObject(int a) - { - A = a; - } - } -} - "; - tempWorkarea.AddFileToTargetProject("MyMessagePackObject.cs", contents); - - var compiler = new MessagePackCompiler.CodeGenerator(testOutputHelper.WriteLine, CancellationToken.None); - await compiler.GenerateFileAsync( - tempWorkarea.GetOutputCompilation().Compilation, - tempWorkarea.OutputDirectory, - "TempProjectResolver", - "TempProject.Generated", - false, - string.Empty, - Array.Empty()); - - var compilation = tempWorkarea.GetOutputCompilation(); - compilation.Compilation.GetDiagnostics().Should().NotContain(x => x.Severity == DiagnosticSeverity.Error); - - // Run tests with the generated resolver/formatter assembly. - compilation.ExecuteWithGeneratedAssembly((ctx, assembly) => - { - var mpoType = assembly.GetType("TempProject.MyMessagePackObject"); - var options = MessagePackSerializerOptions.Standard - .WithResolver(CompositeResolver.Create( - StandardResolver.Instance, - TestUtilities.GetResolverInstance(assembly, "TempProject.Generated.Resolvers.TempProjectResolver"))); - - // Build `{ "A": -1 }` - var seq = new Sequence(); - var writer = new MessagePackWriter(seq); - writer.WriteMapHeader(1); - writer.Write("A"); - writer.Write(-1); - writer.Flush(); - - // Verify deserialization - dynamic result = MessagePackSerializer.Deserialize(mpoType, seq, options); - ((int)result.A).Should().Be(-1); // from ctor - ((string)result.B).Should().Be("foobar"); // default value - }); - } - } -} diff --git a/tests/MessagePack.SourceGenerator.Tests/MessagePack.SourceGenerator.Tests.csproj b/tests/MessagePack.SourceGenerator.Tests/MessagePack.SourceGenerator.Tests.csproj index c9933f335..6b9471c53 100644 --- a/tests/MessagePack.SourceGenerator.Tests/MessagePack.SourceGenerator.Tests.csproj +++ b/tests/MessagePack.SourceGenerator.Tests/MessagePack.SourceGenerator.Tests.csproj @@ -7,10 +7,6 @@ 11 - - - - diff --git a/tests/MessagePack.SourceGenerator.Tests/Resources/PropertiesGetterOnlyDefaultValue/Formatters.TempProject.MyMessagePackObjectFormatter.g.cs b/tests/MessagePack.SourceGenerator.Tests/Resources/PropertiesGetterOnlyDefaultValue/Formatters.TempProject.MyMessagePackObjectFormatter.g.cs new file mode 100644 index 000000000..3ae90505b --- /dev/null +++ b/tests/MessagePack.SourceGenerator.Tests/Resources/PropertiesGetterOnlyDefaultValue/Formatters.TempProject.MyMessagePackObjectFormatter.g.cs @@ -0,0 +1,72 @@ +// + +#pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 + +namespace Formatters.TempProject +{ + using MsgPack = global::MessagePack; + + internal sealed class MyMessagePackObjectFormatter : global::MessagePack.Formatters.IMessagePackFormatter + { + // A + private static global::System.ReadOnlySpan GetSpan_A() => new byte[1 + 1] { 161, 65 }; + // B + private static global::System.ReadOnlySpan GetSpan_B() => new byte[1 + 1] { 161, 66 }; + + public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::TempProject.MyMessagePackObject value, global::MessagePack.MessagePackSerializerOptions options) + { + if (value is null) + { + writer.WriteNil(); + return; + } + + var formatterResolver = options.Resolver; + writer.WriteMapHeader(2); + writer.WriteRaw(GetSpan_A()); + writer.Write(value.A); + writer.WriteRaw(GetSpan_B()); + MsgPack::FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Serialize(ref writer, value.B, options); + } + + public global::TempProject.MyMessagePackObject Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) + { + if (reader.TryReadNil()) + { + return null; + } + + options.Security.DepthStep(ref reader); + var formatterResolver = options.Resolver; + var length = reader.ReadMapHeader(); + var ____result = new global::TempProject.MyMessagePackObject(); + + for (int i = 0; i < length; i++) + { + var stringKey = global::MessagePack.Internal.CodeGenHelpers.ReadStringSpan(ref reader); + switch (stringKey.Length) + { + default: + FAIL: + reader.Skip(); + continue; + case 1: + switch (global::MessagePack.Internal.AutomataKeyGen.GetKey(ref stringKey)) + { + default: goto FAIL; + case 65UL: + reader.Skip(); + continue; + case 66UL: + reader.Skip(); + continue; + } + + } + } + + reader.Depth--; + return ____result; + } + } +} diff --git a/tests/MessagePack.SourceGenerator.Tests/Resources/PropertiesGetterOnlyDefaultValue/MessagePack.GeneratedMessagePackResolver.g.cs b/tests/MessagePack.SourceGenerator.Tests/Resources/PropertiesGetterOnlyDefaultValue/MessagePack.GeneratedMessagePackResolver.g.cs new file mode 100644 index 000000000..69765f674 --- /dev/null +++ b/tests/MessagePack.SourceGenerator.Tests/Resources/PropertiesGetterOnlyDefaultValue/MessagePack.GeneratedMessagePackResolver.g.cs @@ -0,0 +1,70 @@ +// + +#pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 + +namespace MessagePack +{ + using MsgPack = global::MessagePack; + using Formatters = global::Formatters; + + /// A MessagePack resolver that uses generated formatters for types in this assembly. + internal class GeneratedMessagePackResolver : MsgPack::IFormatterResolver + { + /// An instance of this resolver that only returns formatters specifically generated for types in this assembly. + public static readonly MsgPack::IFormatterResolver Instance = new GeneratedMessagePackResolver(); + + /// An instance of this resolver that returns standard AOT-compatible formatters as well as formatters specifically generated for types in this assembly. + public static readonly MsgPack::IFormatterResolver InstanceWithStandardAotResolver = MsgPack::Resolvers.CompositeResolver.Create(Instance, MsgPack::Resolvers.StandardAotResolver.Instance); + + private GeneratedMessagePackResolver() + { + } + + public MsgPack::Formatters.IMessagePackFormatter GetFormatter() + { + return FormatterCache.Formatter; + } + + private static class FormatterCache + { + internal static readonly MsgPack::Formatters.IMessagePackFormatter Formatter; + + static FormatterCache() + { + var f = GeneratedMessagePackResolverGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + Formatter = (MsgPack::Formatters.IMessagePackFormatter)f; + } + } + } + } + + internal static class GeneratedMessagePackResolverGetFormatterHelper + { + private static readonly global::System.Collections.Generic.Dictionary lookup; + + static GeneratedMessagePackResolverGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(1) + { + { typeof(global::TempProject.MyMessagePackObject), 0 }, + }; + } + + internal static object GetFormatter(global::System.Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + case 0: return new Formatters::TempProject.MyMessagePackObjectFormatter(); + default: return null; + } + } + } +} diff --git a/tests/MessagePack.SourceGenerator.Tests/Resources/PropertiesGetterOnlyIgnore/Formatters.TempProject.MyMessagePackObjectFormatter.g.cs b/tests/MessagePack.SourceGenerator.Tests/Resources/PropertiesGetterOnlyIgnore/Formatters.TempProject.MyMessagePackObjectFormatter.g.cs new file mode 100644 index 000000000..3ae90505b --- /dev/null +++ b/tests/MessagePack.SourceGenerator.Tests/Resources/PropertiesGetterOnlyIgnore/Formatters.TempProject.MyMessagePackObjectFormatter.g.cs @@ -0,0 +1,72 @@ +// + +#pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 + +namespace Formatters.TempProject +{ + using MsgPack = global::MessagePack; + + internal sealed class MyMessagePackObjectFormatter : global::MessagePack.Formatters.IMessagePackFormatter + { + // A + private static global::System.ReadOnlySpan GetSpan_A() => new byte[1 + 1] { 161, 65 }; + // B + private static global::System.ReadOnlySpan GetSpan_B() => new byte[1 + 1] { 161, 66 }; + + public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::TempProject.MyMessagePackObject value, global::MessagePack.MessagePackSerializerOptions options) + { + if (value is null) + { + writer.WriteNil(); + return; + } + + var formatterResolver = options.Resolver; + writer.WriteMapHeader(2); + writer.WriteRaw(GetSpan_A()); + writer.Write(value.A); + writer.WriteRaw(GetSpan_B()); + MsgPack::FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Serialize(ref writer, value.B, options); + } + + public global::TempProject.MyMessagePackObject Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) + { + if (reader.TryReadNil()) + { + return null; + } + + options.Security.DepthStep(ref reader); + var formatterResolver = options.Resolver; + var length = reader.ReadMapHeader(); + var ____result = new global::TempProject.MyMessagePackObject(); + + for (int i = 0; i < length; i++) + { + var stringKey = global::MessagePack.Internal.CodeGenHelpers.ReadStringSpan(ref reader); + switch (stringKey.Length) + { + default: + FAIL: + reader.Skip(); + continue; + case 1: + switch (global::MessagePack.Internal.AutomataKeyGen.GetKey(ref stringKey)) + { + default: goto FAIL; + case 65UL: + reader.Skip(); + continue; + case 66UL: + reader.Skip(); + continue; + } + + } + } + + reader.Depth--; + return ____result; + } + } +} diff --git a/tests/MessagePack.SourceGenerator.Tests/Resources/PropertiesGetterOnlyIgnore/MessagePack.GeneratedMessagePackResolver.g.cs b/tests/MessagePack.SourceGenerator.Tests/Resources/PropertiesGetterOnlyIgnore/MessagePack.GeneratedMessagePackResolver.g.cs new file mode 100644 index 000000000..69765f674 --- /dev/null +++ b/tests/MessagePack.SourceGenerator.Tests/Resources/PropertiesGetterOnlyIgnore/MessagePack.GeneratedMessagePackResolver.g.cs @@ -0,0 +1,70 @@ +// + +#pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 + +namespace MessagePack +{ + using MsgPack = global::MessagePack; + using Formatters = global::Formatters; + + /// A MessagePack resolver that uses generated formatters for types in this assembly. + internal class GeneratedMessagePackResolver : MsgPack::IFormatterResolver + { + /// An instance of this resolver that only returns formatters specifically generated for types in this assembly. + public static readonly MsgPack::IFormatterResolver Instance = new GeneratedMessagePackResolver(); + + /// An instance of this resolver that returns standard AOT-compatible formatters as well as formatters specifically generated for types in this assembly. + public static readonly MsgPack::IFormatterResolver InstanceWithStandardAotResolver = MsgPack::Resolvers.CompositeResolver.Create(Instance, MsgPack::Resolvers.StandardAotResolver.Instance); + + private GeneratedMessagePackResolver() + { + } + + public MsgPack::Formatters.IMessagePackFormatter GetFormatter() + { + return FormatterCache.Formatter; + } + + private static class FormatterCache + { + internal static readonly MsgPack::Formatters.IMessagePackFormatter Formatter; + + static FormatterCache() + { + var f = GeneratedMessagePackResolverGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + Formatter = (MsgPack::Formatters.IMessagePackFormatter)f; + } + } + } + } + + internal static class GeneratedMessagePackResolverGetFormatterHelper + { + private static readonly global::System.Collections.Generic.Dictionary lookup; + + static GeneratedMessagePackResolverGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(1) + { + { typeof(global::TempProject.MyMessagePackObject), 0 }, + }; + } + + internal static object GetFormatter(global::System.Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + case 0: return new Formatters::TempProject.MyMessagePackObjectFormatter(); + default: return null; + } + } + } +} diff --git a/tests/MessagePack.SourceGenerator.Tests/Resources/PropertiesGetterOnlyMixed/Formatters.TempProject.MyMessagePackObjectFormatter.g.cs b/tests/MessagePack.SourceGenerator.Tests/Resources/PropertiesGetterOnlyMixed/Formatters.TempProject.MyMessagePackObjectFormatter.g.cs new file mode 100644 index 000000000..f25f329a6 --- /dev/null +++ b/tests/MessagePack.SourceGenerator.Tests/Resources/PropertiesGetterOnlyMixed/Formatters.TempProject.MyMessagePackObjectFormatter.g.cs @@ -0,0 +1,72 @@ +// + +#pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 + +namespace Formatters.TempProject +{ + using MsgPack = global::MessagePack; + + internal sealed class MyMessagePackObjectFormatter : global::MessagePack.Formatters.IMessagePackFormatter + { + // A + private static global::System.ReadOnlySpan GetSpan_A() => new byte[1 + 1] { 161, 65 }; + // B + private static global::System.ReadOnlySpan GetSpan_B() => new byte[1 + 1] { 161, 66 }; + + public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::TempProject.MyMessagePackObject value, global::MessagePack.MessagePackSerializerOptions options) + { + if (value is null) + { + writer.WriteNil(); + return; + } + + var formatterResolver = options.Resolver; + writer.WriteMapHeader(2); + writer.WriteRaw(GetSpan_A()); + writer.Write(value.A); + writer.WriteRaw(GetSpan_B()); + MsgPack::FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Serialize(ref writer, value.B, options); + } + + public global::TempProject.MyMessagePackObject Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) + { + if (reader.TryReadNil()) + { + return null; + } + + options.Security.DepthStep(ref reader); + var formatterResolver = options.Resolver; + var length = reader.ReadMapHeader(); + var ____result = new global::TempProject.MyMessagePackObject(); + + for (int i = 0; i < length; i++) + { + var stringKey = global::MessagePack.Internal.CodeGenHelpers.ReadStringSpan(ref reader); + switch (stringKey.Length) + { + default: + FAIL: + reader.Skip(); + continue; + case 1: + switch (global::MessagePack.Internal.AutomataKeyGen.GetKey(ref stringKey)) + { + default: goto FAIL; + case 65UL: + reader.Skip(); + continue; + case 66UL: + ____result.B = MsgPack::FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Deserialize(ref reader, options); + continue; + } + + } + } + + reader.Depth--; + return ____result; + } + } +} diff --git a/tests/MessagePack.SourceGenerator.Tests/Resources/PropertiesGetterOnlyMixed/MessagePack.GeneratedMessagePackResolver.g.cs b/tests/MessagePack.SourceGenerator.Tests/Resources/PropertiesGetterOnlyMixed/MessagePack.GeneratedMessagePackResolver.g.cs new file mode 100644 index 000000000..69765f674 --- /dev/null +++ b/tests/MessagePack.SourceGenerator.Tests/Resources/PropertiesGetterOnlyMixed/MessagePack.GeneratedMessagePackResolver.g.cs @@ -0,0 +1,70 @@ +// + +#pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 + +namespace MessagePack +{ + using MsgPack = global::MessagePack; + using Formatters = global::Formatters; + + /// A MessagePack resolver that uses generated formatters for types in this assembly. + internal class GeneratedMessagePackResolver : MsgPack::IFormatterResolver + { + /// An instance of this resolver that only returns formatters specifically generated for types in this assembly. + public static readonly MsgPack::IFormatterResolver Instance = new GeneratedMessagePackResolver(); + + /// An instance of this resolver that returns standard AOT-compatible formatters as well as formatters specifically generated for types in this assembly. + public static readonly MsgPack::IFormatterResolver InstanceWithStandardAotResolver = MsgPack::Resolvers.CompositeResolver.Create(Instance, MsgPack::Resolvers.StandardAotResolver.Instance); + + private GeneratedMessagePackResolver() + { + } + + public MsgPack::Formatters.IMessagePackFormatter GetFormatter() + { + return FormatterCache.Formatter; + } + + private static class FormatterCache + { + internal static readonly MsgPack::Formatters.IMessagePackFormatter Formatter; + + static FormatterCache() + { + var f = GeneratedMessagePackResolverGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + Formatter = (MsgPack::Formatters.IMessagePackFormatter)f; + } + } + } + } + + internal static class GeneratedMessagePackResolverGetFormatterHelper + { + private static readonly global::System.Collections.Generic.Dictionary lookup; + + static GeneratedMessagePackResolverGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(1) + { + { typeof(global::TempProject.MyMessagePackObject), 0 }, + }; + } + + internal static object GetFormatter(global::System.Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + case 0: return new Formatters::TempProject.MyMessagePackObjectFormatter(); + default: return null; + } + } + } +} diff --git a/tests/MessagePack.SourceGenerator.Tests/Resources/PropertiesGetterOnlyWithParameterizedConstructor/Formatters.TempProject.MyMessagePackObjectFormatter.g.cs b/tests/MessagePack.SourceGenerator.Tests/Resources/PropertiesGetterOnlyWithParameterizedConstructor/Formatters.TempProject.MyMessagePackObjectFormatter.g.cs new file mode 100644 index 000000000..a8ece7170 --- /dev/null +++ b/tests/MessagePack.SourceGenerator.Tests/Resources/PropertiesGetterOnlyWithParameterizedConstructor/Formatters.TempProject.MyMessagePackObjectFormatter.g.cs @@ -0,0 +1,74 @@ +// + +#pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 + +namespace Formatters.TempProject +{ + using MsgPack = global::MessagePack; + + internal sealed class MyMessagePackObjectFormatter : global::MessagePack.Formatters.IMessagePackFormatter + { + // A + private static global::System.ReadOnlySpan GetSpan_A() => new byte[1 + 1] { 161, 65 }; + // B + private static global::System.ReadOnlySpan GetSpan_B() => new byte[1 + 1] { 161, 66 }; + + public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::TempProject.MyMessagePackObject value, global::MessagePack.MessagePackSerializerOptions options) + { + if (value is null) + { + writer.WriteNil(); + return; + } + + var formatterResolver = options.Resolver; + writer.WriteMapHeader(2); + writer.WriteRaw(GetSpan_A()); + writer.Write(value.A); + writer.WriteRaw(GetSpan_B()); + MsgPack::FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Serialize(ref writer, value.B, options); + } + + public global::TempProject.MyMessagePackObject Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) + { + if (reader.TryReadNil()) + { + return null; + } + + options.Security.DepthStep(ref reader); + var formatterResolver = options.Resolver; + var length = reader.ReadMapHeader(); + var __A__ = default(int); + var __B__ = default(string); + + for (int i = 0; i < length; i++) + { + var stringKey = global::MessagePack.Internal.CodeGenHelpers.ReadStringSpan(ref reader); + switch (stringKey.Length) + { + default: + FAIL: + reader.Skip(); + continue; + case 1: + switch (global::MessagePack.Internal.AutomataKeyGen.GetKey(ref stringKey)) + { + default: goto FAIL; + case 65UL: + __A__ = reader.ReadInt32(); + continue; + case 66UL: + __B__ = MsgPack::FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Deserialize(ref reader, options); + continue; + } + + } + } + + var ____result = new global::TempProject.MyMessagePackObject(__A__, __B__); + reader.Depth--; + return ____result; + } + } +} diff --git a/tests/MessagePack.SourceGenerator.Tests/Resources/PropertiesGetterOnlyWithParameterizedConstructor/MessagePack.GeneratedMessagePackResolver.g.cs b/tests/MessagePack.SourceGenerator.Tests/Resources/PropertiesGetterOnlyWithParameterizedConstructor/MessagePack.GeneratedMessagePackResolver.g.cs new file mode 100644 index 000000000..69765f674 --- /dev/null +++ b/tests/MessagePack.SourceGenerator.Tests/Resources/PropertiesGetterOnlyWithParameterizedConstructor/MessagePack.GeneratedMessagePackResolver.g.cs @@ -0,0 +1,70 @@ +// + +#pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 + +namespace MessagePack +{ + using MsgPack = global::MessagePack; + using Formatters = global::Formatters; + + /// A MessagePack resolver that uses generated formatters for types in this assembly. + internal class GeneratedMessagePackResolver : MsgPack::IFormatterResolver + { + /// An instance of this resolver that only returns formatters specifically generated for types in this assembly. + public static readonly MsgPack::IFormatterResolver Instance = new GeneratedMessagePackResolver(); + + /// An instance of this resolver that returns standard AOT-compatible formatters as well as formatters specifically generated for types in this assembly. + public static readonly MsgPack::IFormatterResolver InstanceWithStandardAotResolver = MsgPack::Resolvers.CompositeResolver.Create(Instance, MsgPack::Resolvers.StandardAotResolver.Instance); + + private GeneratedMessagePackResolver() + { + } + + public MsgPack::Formatters.IMessagePackFormatter GetFormatter() + { + return FormatterCache.Formatter; + } + + private static class FormatterCache + { + internal static readonly MsgPack::Formatters.IMessagePackFormatter Formatter; + + static FormatterCache() + { + var f = GeneratedMessagePackResolverGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + Formatter = (MsgPack::Formatters.IMessagePackFormatter)f; + } + } + } + } + + internal static class GeneratedMessagePackResolverGetFormatterHelper + { + private static readonly global::System.Collections.Generic.Dictionary lookup; + + static GeneratedMessagePackResolverGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(1) + { + { typeof(global::TempProject.MyMessagePackObject), 0 }, + }; + } + + internal static object GetFormatter(global::System.Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + case 0: return new Formatters::TempProject.MyMessagePackObjectFormatter(); + default: return null; + } + } + } +} diff --git a/tests/MessagePack.SourceGenerator.Tests/Resources/PropertiesGetterOnlyWithParameterizedConstructorDefaultValue/Formatters.TempProject.MyMessagePackObjectFormatter.g.cs b/tests/MessagePack.SourceGenerator.Tests/Resources/PropertiesGetterOnlyWithParameterizedConstructorDefaultValue/Formatters.TempProject.MyMessagePackObjectFormatter.g.cs new file mode 100644 index 000000000..308595d4e --- /dev/null +++ b/tests/MessagePack.SourceGenerator.Tests/Resources/PropertiesGetterOnlyWithParameterizedConstructorDefaultValue/Formatters.TempProject.MyMessagePackObjectFormatter.g.cs @@ -0,0 +1,73 @@ +// + +#pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 + +namespace Formatters.TempProject +{ + using MsgPack = global::MessagePack; + + internal sealed class MyMessagePackObjectFormatter : global::MessagePack.Formatters.IMessagePackFormatter + { + // A + private static global::System.ReadOnlySpan GetSpan_A() => new byte[1 + 1] { 161, 65 }; + // B + private static global::System.ReadOnlySpan GetSpan_B() => new byte[1 + 1] { 161, 66 }; + + public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::TempProject.MyMessagePackObject value, global::MessagePack.MessagePackSerializerOptions options) + { + if (value is null) + { + writer.WriteNil(); + return; + } + + var formatterResolver = options.Resolver; + writer.WriteMapHeader(2); + writer.WriteRaw(GetSpan_A()); + writer.Write(value.A); + writer.WriteRaw(GetSpan_B()); + MsgPack::FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Serialize(ref writer, value.B, options); + } + + public global::TempProject.MyMessagePackObject Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) + { + if (reader.TryReadNil()) + { + return null; + } + + options.Security.DepthStep(ref reader); + var formatterResolver = options.Resolver; + var length = reader.ReadMapHeader(); + var __B__ = default(string); + + for (int i = 0; i < length; i++) + { + var stringKey = global::MessagePack.Internal.CodeGenHelpers.ReadStringSpan(ref reader); + switch (stringKey.Length) + { + default: + FAIL: + reader.Skip(); + continue; + case 1: + switch (global::MessagePack.Internal.AutomataKeyGen.GetKey(ref stringKey)) + { + default: goto FAIL; + case 65UL: + reader.Skip(); + continue; + case 66UL: + __B__ = MsgPack::FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Deserialize(ref reader, options); + continue; + } + + } + } + + var ____result = new global::TempProject.MyMessagePackObject(__B__); + reader.Depth--; + return ____result; + } + } +} diff --git a/tests/MessagePack.SourceGenerator.Tests/Resources/PropertiesGetterOnlyWithParameterizedConstructorDefaultValue/MessagePack.GeneratedMessagePackResolver.g.cs b/tests/MessagePack.SourceGenerator.Tests/Resources/PropertiesGetterOnlyWithParameterizedConstructorDefaultValue/MessagePack.GeneratedMessagePackResolver.g.cs new file mode 100644 index 000000000..69765f674 --- /dev/null +++ b/tests/MessagePack.SourceGenerator.Tests/Resources/PropertiesGetterOnlyWithParameterizedConstructorDefaultValue/MessagePack.GeneratedMessagePackResolver.g.cs @@ -0,0 +1,70 @@ +// + +#pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 + +namespace MessagePack +{ + using MsgPack = global::MessagePack; + using Formatters = global::Formatters; + + /// A MessagePack resolver that uses generated formatters for types in this assembly. + internal class GeneratedMessagePackResolver : MsgPack::IFormatterResolver + { + /// An instance of this resolver that only returns formatters specifically generated for types in this assembly. + public static readonly MsgPack::IFormatterResolver Instance = new GeneratedMessagePackResolver(); + + /// An instance of this resolver that returns standard AOT-compatible formatters as well as formatters specifically generated for types in this assembly. + public static readonly MsgPack::IFormatterResolver InstanceWithStandardAotResolver = MsgPack::Resolvers.CompositeResolver.Create(Instance, MsgPack::Resolvers.StandardAotResolver.Instance); + + private GeneratedMessagePackResolver() + { + } + + public MsgPack::Formatters.IMessagePackFormatter GetFormatter() + { + return FormatterCache.Formatter; + } + + private static class FormatterCache + { + internal static readonly MsgPack::Formatters.IMessagePackFormatter Formatter; + + static FormatterCache() + { + var f = GeneratedMessagePackResolverGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + Formatter = (MsgPack::Formatters.IMessagePackFormatter)f; + } + } + } + } + + internal static class GeneratedMessagePackResolverGetFormatterHelper + { + private static readonly global::System.Collections.Generic.Dictionary lookup; + + static GeneratedMessagePackResolverGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(1) + { + { typeof(global::TempProject.MyMessagePackObject), 0 }, + }; + } + + internal static object GetFormatter(global::System.Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + case 0: return new Formatters::TempProject.MyMessagePackObjectFormatter(); + default: return null; + } + } + } +} diff --git a/tests/MessagePack.SourceGenerator.Tests/Resources/PropertiesGetterOnlyWithParameterizedConstructorPartially/Formatters.TempProject.MyMessagePackObjectFormatter.g.cs b/tests/MessagePack.SourceGenerator.Tests/Resources/PropertiesGetterOnlyWithParameterizedConstructorPartially/Formatters.TempProject.MyMessagePackObjectFormatter.g.cs new file mode 100644 index 000000000..308595d4e --- /dev/null +++ b/tests/MessagePack.SourceGenerator.Tests/Resources/PropertiesGetterOnlyWithParameterizedConstructorPartially/Formatters.TempProject.MyMessagePackObjectFormatter.g.cs @@ -0,0 +1,73 @@ +// + +#pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 + +namespace Formatters.TempProject +{ + using MsgPack = global::MessagePack; + + internal sealed class MyMessagePackObjectFormatter : global::MessagePack.Formatters.IMessagePackFormatter + { + // A + private static global::System.ReadOnlySpan GetSpan_A() => new byte[1 + 1] { 161, 65 }; + // B + private static global::System.ReadOnlySpan GetSpan_B() => new byte[1 + 1] { 161, 66 }; + + public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::TempProject.MyMessagePackObject value, global::MessagePack.MessagePackSerializerOptions options) + { + if (value is null) + { + writer.WriteNil(); + return; + } + + var formatterResolver = options.Resolver; + writer.WriteMapHeader(2); + writer.WriteRaw(GetSpan_A()); + writer.Write(value.A); + writer.WriteRaw(GetSpan_B()); + MsgPack::FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Serialize(ref writer, value.B, options); + } + + public global::TempProject.MyMessagePackObject Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) + { + if (reader.TryReadNil()) + { + return null; + } + + options.Security.DepthStep(ref reader); + var formatterResolver = options.Resolver; + var length = reader.ReadMapHeader(); + var __B__ = default(string); + + for (int i = 0; i < length; i++) + { + var stringKey = global::MessagePack.Internal.CodeGenHelpers.ReadStringSpan(ref reader); + switch (stringKey.Length) + { + default: + FAIL: + reader.Skip(); + continue; + case 1: + switch (global::MessagePack.Internal.AutomataKeyGen.GetKey(ref stringKey)) + { + default: goto FAIL; + case 65UL: + reader.Skip(); + continue; + case 66UL: + __B__ = MsgPack::FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Deserialize(ref reader, options); + continue; + } + + } + } + + var ____result = new global::TempProject.MyMessagePackObject(__B__); + reader.Depth--; + return ____result; + } + } +} diff --git a/tests/MessagePack.SourceGenerator.Tests/Resources/PropertiesGetterOnlyWithParameterizedConstructorPartially/MessagePack.GeneratedMessagePackResolver.g.cs b/tests/MessagePack.SourceGenerator.Tests/Resources/PropertiesGetterOnlyWithParameterizedConstructorPartially/MessagePack.GeneratedMessagePackResolver.g.cs new file mode 100644 index 000000000..69765f674 --- /dev/null +++ b/tests/MessagePack.SourceGenerator.Tests/Resources/PropertiesGetterOnlyWithParameterizedConstructorPartially/MessagePack.GeneratedMessagePackResolver.g.cs @@ -0,0 +1,70 @@ +// + +#pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 + +namespace MessagePack +{ + using MsgPack = global::MessagePack; + using Formatters = global::Formatters; + + /// A MessagePack resolver that uses generated formatters for types in this assembly. + internal class GeneratedMessagePackResolver : MsgPack::IFormatterResolver + { + /// An instance of this resolver that only returns formatters specifically generated for types in this assembly. + public static readonly MsgPack::IFormatterResolver Instance = new GeneratedMessagePackResolver(); + + /// An instance of this resolver that returns standard AOT-compatible formatters as well as formatters specifically generated for types in this assembly. + public static readonly MsgPack::IFormatterResolver InstanceWithStandardAotResolver = MsgPack::Resolvers.CompositeResolver.Create(Instance, MsgPack::Resolvers.StandardAotResolver.Instance); + + private GeneratedMessagePackResolver() + { + } + + public MsgPack::Formatters.IMessagePackFormatter GetFormatter() + { + return FormatterCache.Formatter; + } + + private static class FormatterCache + { + internal static readonly MsgPack::Formatters.IMessagePackFormatter Formatter; + + static FormatterCache() + { + var f = GeneratedMessagePackResolverGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + Formatter = (MsgPack::Formatters.IMessagePackFormatter)f; + } + } + } + } + + internal static class GeneratedMessagePackResolverGetFormatterHelper + { + private static readonly global::System.Collections.Generic.Dictionary lookup; + + static GeneratedMessagePackResolverGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(1) + { + { typeof(global::TempProject.MyMessagePackObject), 0 }, + }; + } + + internal static object GetFormatter(global::System.Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + case 0: return new Formatters::TempProject.MyMessagePackObjectFormatter(); + default: return null; + } + } + } +} diff --git a/tests/MessagePack.SourceGenerator.Tests/Resources/PropertiesGetterSetter/Formatters.TempProject.MyMessagePackObjectFormatter.g.cs b/tests/MessagePack.SourceGenerator.Tests/Resources/PropertiesGetterSetter/Formatters.TempProject.MyMessagePackObjectFormatter.g.cs new file mode 100644 index 000000000..f992bc512 --- /dev/null +++ b/tests/MessagePack.SourceGenerator.Tests/Resources/PropertiesGetterSetter/Formatters.TempProject.MyMessagePackObjectFormatter.g.cs @@ -0,0 +1,72 @@ +// + +#pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 + +namespace Formatters.TempProject +{ + using MsgPack = global::MessagePack; + + internal sealed class MyMessagePackObjectFormatter : global::MessagePack.Formatters.IMessagePackFormatter + { + // A + private static global::System.ReadOnlySpan GetSpan_A() => new byte[1 + 1] { 161, 65 }; + // B + private static global::System.ReadOnlySpan GetSpan_B() => new byte[1 + 1] { 161, 66 }; + + public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::TempProject.MyMessagePackObject value, global::MessagePack.MessagePackSerializerOptions options) + { + if (value is null) + { + writer.WriteNil(); + return; + } + + var formatterResolver = options.Resolver; + writer.WriteMapHeader(2); + writer.WriteRaw(GetSpan_A()); + writer.Write(value.A); + writer.WriteRaw(GetSpan_B()); + MsgPack::FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Serialize(ref writer, value.B, options); + } + + public global::TempProject.MyMessagePackObject Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) + { + if (reader.TryReadNil()) + { + return null; + } + + options.Security.DepthStep(ref reader); + var formatterResolver = options.Resolver; + var length = reader.ReadMapHeader(); + var ____result = new global::TempProject.MyMessagePackObject(); + + for (int i = 0; i < length; i++) + { + var stringKey = global::MessagePack.Internal.CodeGenHelpers.ReadStringSpan(ref reader); + switch (stringKey.Length) + { + default: + FAIL: + reader.Skip(); + continue; + case 1: + switch (global::MessagePack.Internal.AutomataKeyGen.GetKey(ref stringKey)) + { + default: goto FAIL; + case 65UL: + ____result.A = reader.ReadInt32(); + continue; + case 66UL: + ____result.B = MsgPack::FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Deserialize(ref reader, options); + continue; + } + + } + } + + reader.Depth--; + return ____result; + } + } +} diff --git a/tests/MessagePack.SourceGenerator.Tests/Resources/PropertiesGetterSetter/MessagePack.GeneratedMessagePackResolver.g.cs b/tests/MessagePack.SourceGenerator.Tests/Resources/PropertiesGetterSetter/MessagePack.GeneratedMessagePackResolver.g.cs new file mode 100644 index 000000000..69765f674 --- /dev/null +++ b/tests/MessagePack.SourceGenerator.Tests/Resources/PropertiesGetterSetter/MessagePack.GeneratedMessagePackResolver.g.cs @@ -0,0 +1,70 @@ +// + +#pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 + +namespace MessagePack +{ + using MsgPack = global::MessagePack; + using Formatters = global::Formatters; + + /// A MessagePack resolver that uses generated formatters for types in this assembly. + internal class GeneratedMessagePackResolver : MsgPack::IFormatterResolver + { + /// An instance of this resolver that only returns formatters specifically generated for types in this assembly. + public static readonly MsgPack::IFormatterResolver Instance = new GeneratedMessagePackResolver(); + + /// An instance of this resolver that returns standard AOT-compatible formatters as well as formatters specifically generated for types in this assembly. + public static readonly MsgPack::IFormatterResolver InstanceWithStandardAotResolver = MsgPack::Resolvers.CompositeResolver.Create(Instance, MsgPack::Resolvers.StandardAotResolver.Instance); + + private GeneratedMessagePackResolver() + { + } + + public MsgPack::Formatters.IMessagePackFormatter GetFormatter() + { + return FormatterCache.Formatter; + } + + private static class FormatterCache + { + internal static readonly MsgPack::Formatters.IMessagePackFormatter Formatter; + + static FormatterCache() + { + var f = GeneratedMessagePackResolverGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + Formatter = (MsgPack::Formatters.IMessagePackFormatter)f; + } + } + } + } + + internal static class GeneratedMessagePackResolverGetFormatterHelper + { + private static readonly global::System.Collections.Generic.Dictionary lookup; + + static GeneratedMessagePackResolverGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(1) + { + { typeof(global::TempProject.MyMessagePackObject), 0 }, + }; + } + + internal static object GetFormatter(global::System.Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + case 0: return new Formatters::TempProject.MyMessagePackObjectFormatter(); + default: return null; + } + } + } +} diff --git a/tests/MessagePack.SourceGenerator.Tests/Resources/PropertiesGetterSetterWithDefaultValue/Formatters.TempProject.MyMessagePackObjectFormatter.g.cs b/tests/MessagePack.SourceGenerator.Tests/Resources/PropertiesGetterSetterWithDefaultValue/Formatters.TempProject.MyMessagePackObjectFormatter.g.cs new file mode 100644 index 000000000..f992bc512 --- /dev/null +++ b/tests/MessagePack.SourceGenerator.Tests/Resources/PropertiesGetterSetterWithDefaultValue/Formatters.TempProject.MyMessagePackObjectFormatter.g.cs @@ -0,0 +1,72 @@ +// + +#pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 + +namespace Formatters.TempProject +{ + using MsgPack = global::MessagePack; + + internal sealed class MyMessagePackObjectFormatter : global::MessagePack.Formatters.IMessagePackFormatter + { + // A + private static global::System.ReadOnlySpan GetSpan_A() => new byte[1 + 1] { 161, 65 }; + // B + private static global::System.ReadOnlySpan GetSpan_B() => new byte[1 + 1] { 161, 66 }; + + public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::TempProject.MyMessagePackObject value, global::MessagePack.MessagePackSerializerOptions options) + { + if (value is null) + { + writer.WriteNil(); + return; + } + + var formatterResolver = options.Resolver; + writer.WriteMapHeader(2); + writer.WriteRaw(GetSpan_A()); + writer.Write(value.A); + writer.WriteRaw(GetSpan_B()); + MsgPack::FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Serialize(ref writer, value.B, options); + } + + public global::TempProject.MyMessagePackObject Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) + { + if (reader.TryReadNil()) + { + return null; + } + + options.Security.DepthStep(ref reader); + var formatterResolver = options.Resolver; + var length = reader.ReadMapHeader(); + var ____result = new global::TempProject.MyMessagePackObject(); + + for (int i = 0; i < length; i++) + { + var stringKey = global::MessagePack.Internal.CodeGenHelpers.ReadStringSpan(ref reader); + switch (stringKey.Length) + { + default: + FAIL: + reader.Skip(); + continue; + case 1: + switch (global::MessagePack.Internal.AutomataKeyGen.GetKey(ref stringKey)) + { + default: goto FAIL; + case 65UL: + ____result.A = reader.ReadInt32(); + continue; + case 66UL: + ____result.B = MsgPack::FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Deserialize(ref reader, options); + continue; + } + + } + } + + reader.Depth--; + return ____result; + } + } +} diff --git a/tests/MessagePack.SourceGenerator.Tests/Resources/PropertiesGetterSetterWithDefaultValue/MessagePack.GeneratedMessagePackResolver.g.cs b/tests/MessagePack.SourceGenerator.Tests/Resources/PropertiesGetterSetterWithDefaultValue/MessagePack.GeneratedMessagePackResolver.g.cs new file mode 100644 index 000000000..69765f674 --- /dev/null +++ b/tests/MessagePack.SourceGenerator.Tests/Resources/PropertiesGetterSetterWithDefaultValue/MessagePack.GeneratedMessagePackResolver.g.cs @@ -0,0 +1,70 @@ +// + +#pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 + +namespace MessagePack +{ + using MsgPack = global::MessagePack; + using Formatters = global::Formatters; + + /// A MessagePack resolver that uses generated formatters for types in this assembly. + internal class GeneratedMessagePackResolver : MsgPack::IFormatterResolver + { + /// An instance of this resolver that only returns formatters specifically generated for types in this assembly. + public static readonly MsgPack::IFormatterResolver Instance = new GeneratedMessagePackResolver(); + + /// An instance of this resolver that returns standard AOT-compatible formatters as well as formatters specifically generated for types in this assembly. + public static readonly MsgPack::IFormatterResolver InstanceWithStandardAotResolver = MsgPack::Resolvers.CompositeResolver.Create(Instance, MsgPack::Resolvers.StandardAotResolver.Instance); + + private GeneratedMessagePackResolver() + { + } + + public MsgPack::Formatters.IMessagePackFormatter GetFormatter() + { + return FormatterCache.Formatter; + } + + private static class FormatterCache + { + internal static readonly MsgPack::Formatters.IMessagePackFormatter Formatter; + + static FormatterCache() + { + var f = GeneratedMessagePackResolverGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + Formatter = (MsgPack::Formatters.IMessagePackFormatter)f; + } + } + } + } + + internal static class GeneratedMessagePackResolverGetFormatterHelper + { + private static readonly global::System.Collections.Generic.Dictionary lookup; + + static GeneratedMessagePackResolverGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(1) + { + { typeof(global::TempProject.MyMessagePackObject), 0 }, + }; + } + + internal static object GetFormatter(global::System.Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + case 0: return new Formatters::TempProject.MyMessagePackObjectFormatter(); + default: return null; + } + } + } +} diff --git a/tests/MessagePack.SourceGenerator.Tests/Resources/PropertiesGetterSetterWithDefaultValueInputPartially/Formatters.TempProject.MyMessagePackObjectFormatter.g.cs b/tests/MessagePack.SourceGenerator.Tests/Resources/PropertiesGetterSetterWithDefaultValueInputPartially/Formatters.TempProject.MyMessagePackObjectFormatter.g.cs new file mode 100644 index 000000000..f992bc512 --- /dev/null +++ b/tests/MessagePack.SourceGenerator.Tests/Resources/PropertiesGetterSetterWithDefaultValueInputPartially/Formatters.TempProject.MyMessagePackObjectFormatter.g.cs @@ -0,0 +1,72 @@ +// + +#pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 + +namespace Formatters.TempProject +{ + using MsgPack = global::MessagePack; + + internal sealed class MyMessagePackObjectFormatter : global::MessagePack.Formatters.IMessagePackFormatter + { + // A + private static global::System.ReadOnlySpan GetSpan_A() => new byte[1 + 1] { 161, 65 }; + // B + private static global::System.ReadOnlySpan GetSpan_B() => new byte[1 + 1] { 161, 66 }; + + public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::TempProject.MyMessagePackObject value, global::MessagePack.MessagePackSerializerOptions options) + { + if (value is null) + { + writer.WriteNil(); + return; + } + + var formatterResolver = options.Resolver; + writer.WriteMapHeader(2); + writer.WriteRaw(GetSpan_A()); + writer.Write(value.A); + writer.WriteRaw(GetSpan_B()); + MsgPack::FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Serialize(ref writer, value.B, options); + } + + public global::TempProject.MyMessagePackObject Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) + { + if (reader.TryReadNil()) + { + return null; + } + + options.Security.DepthStep(ref reader); + var formatterResolver = options.Resolver; + var length = reader.ReadMapHeader(); + var ____result = new global::TempProject.MyMessagePackObject(); + + for (int i = 0; i < length; i++) + { + var stringKey = global::MessagePack.Internal.CodeGenHelpers.ReadStringSpan(ref reader); + switch (stringKey.Length) + { + default: + FAIL: + reader.Skip(); + continue; + case 1: + switch (global::MessagePack.Internal.AutomataKeyGen.GetKey(ref stringKey)) + { + default: goto FAIL; + case 65UL: + ____result.A = reader.ReadInt32(); + continue; + case 66UL: + ____result.B = MsgPack::FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Deserialize(ref reader, options); + continue; + } + + } + } + + reader.Depth--; + return ____result; + } + } +} diff --git a/tests/MessagePack.SourceGenerator.Tests/Resources/PropertiesGetterSetterWithDefaultValueInputPartially/MessagePack.GeneratedMessagePackResolver.g.cs b/tests/MessagePack.SourceGenerator.Tests/Resources/PropertiesGetterSetterWithDefaultValueInputPartially/MessagePack.GeneratedMessagePackResolver.g.cs new file mode 100644 index 000000000..69765f674 --- /dev/null +++ b/tests/MessagePack.SourceGenerator.Tests/Resources/PropertiesGetterSetterWithDefaultValueInputPartially/MessagePack.GeneratedMessagePackResolver.g.cs @@ -0,0 +1,70 @@ +// + +#pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 + +namespace MessagePack +{ + using MsgPack = global::MessagePack; + using Formatters = global::Formatters; + + /// A MessagePack resolver that uses generated formatters for types in this assembly. + internal class GeneratedMessagePackResolver : MsgPack::IFormatterResolver + { + /// An instance of this resolver that only returns formatters specifically generated for types in this assembly. + public static readonly MsgPack::IFormatterResolver Instance = new GeneratedMessagePackResolver(); + + /// An instance of this resolver that returns standard AOT-compatible formatters as well as formatters specifically generated for types in this assembly. + public static readonly MsgPack::IFormatterResolver InstanceWithStandardAotResolver = MsgPack::Resolvers.CompositeResolver.Create(Instance, MsgPack::Resolvers.StandardAotResolver.Instance); + + private GeneratedMessagePackResolver() + { + } + + public MsgPack::Formatters.IMessagePackFormatter GetFormatter() + { + return FormatterCache.Formatter; + } + + private static class FormatterCache + { + internal static readonly MsgPack::Formatters.IMessagePackFormatter Formatter; + + static FormatterCache() + { + var f = GeneratedMessagePackResolverGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + Formatter = (MsgPack::Formatters.IMessagePackFormatter)f; + } + } + } + } + + internal static class GeneratedMessagePackResolverGetFormatterHelper + { + private static readonly global::System.Collections.Generic.Dictionary lookup; + + static GeneratedMessagePackResolverGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(1) + { + { typeof(global::TempProject.MyMessagePackObject), 0 }, + }; + } + + internal static object GetFormatter(global::System.Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + case 0: return new Formatters::TempProject.MyMessagePackObjectFormatter(); + default: return null; + } + } + } +} diff --git a/tests/MessagePack.SourceGenerator.Tests/Resources/PropertiesGetterSetterWithParameterizedConstructor/Formatters.TempProject.MyMessagePackObjectFormatter.g.cs b/tests/MessagePack.SourceGenerator.Tests/Resources/PropertiesGetterSetterWithParameterizedConstructor/Formatters.TempProject.MyMessagePackObjectFormatter.g.cs new file mode 100644 index 000000000..a8ece7170 --- /dev/null +++ b/tests/MessagePack.SourceGenerator.Tests/Resources/PropertiesGetterSetterWithParameterizedConstructor/Formatters.TempProject.MyMessagePackObjectFormatter.g.cs @@ -0,0 +1,74 @@ +// + +#pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 + +namespace Formatters.TempProject +{ + using MsgPack = global::MessagePack; + + internal sealed class MyMessagePackObjectFormatter : global::MessagePack.Formatters.IMessagePackFormatter + { + // A + private static global::System.ReadOnlySpan GetSpan_A() => new byte[1 + 1] { 161, 65 }; + // B + private static global::System.ReadOnlySpan GetSpan_B() => new byte[1 + 1] { 161, 66 }; + + public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::TempProject.MyMessagePackObject value, global::MessagePack.MessagePackSerializerOptions options) + { + if (value is null) + { + writer.WriteNil(); + return; + } + + var formatterResolver = options.Resolver; + writer.WriteMapHeader(2); + writer.WriteRaw(GetSpan_A()); + writer.Write(value.A); + writer.WriteRaw(GetSpan_B()); + MsgPack::FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Serialize(ref writer, value.B, options); + } + + public global::TempProject.MyMessagePackObject Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) + { + if (reader.TryReadNil()) + { + return null; + } + + options.Security.DepthStep(ref reader); + var formatterResolver = options.Resolver; + var length = reader.ReadMapHeader(); + var __A__ = default(int); + var __B__ = default(string); + + for (int i = 0; i < length; i++) + { + var stringKey = global::MessagePack.Internal.CodeGenHelpers.ReadStringSpan(ref reader); + switch (stringKey.Length) + { + default: + FAIL: + reader.Skip(); + continue; + case 1: + switch (global::MessagePack.Internal.AutomataKeyGen.GetKey(ref stringKey)) + { + default: goto FAIL; + case 65UL: + __A__ = reader.ReadInt32(); + continue; + case 66UL: + __B__ = MsgPack::FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Deserialize(ref reader, options); + continue; + } + + } + } + + var ____result = new global::TempProject.MyMessagePackObject(__A__, __B__); + reader.Depth--; + return ____result; + } + } +} diff --git a/tests/MessagePack.SourceGenerator.Tests/Resources/PropertiesGetterSetterWithParameterizedConstructor/MessagePack.GeneratedMessagePackResolver.g.cs b/tests/MessagePack.SourceGenerator.Tests/Resources/PropertiesGetterSetterWithParameterizedConstructor/MessagePack.GeneratedMessagePackResolver.g.cs new file mode 100644 index 000000000..69765f674 --- /dev/null +++ b/tests/MessagePack.SourceGenerator.Tests/Resources/PropertiesGetterSetterWithParameterizedConstructor/MessagePack.GeneratedMessagePackResolver.g.cs @@ -0,0 +1,70 @@ +// + +#pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 + +namespace MessagePack +{ + using MsgPack = global::MessagePack; + using Formatters = global::Formatters; + + /// A MessagePack resolver that uses generated formatters for types in this assembly. + internal class GeneratedMessagePackResolver : MsgPack::IFormatterResolver + { + /// An instance of this resolver that only returns formatters specifically generated for types in this assembly. + public static readonly MsgPack::IFormatterResolver Instance = new GeneratedMessagePackResolver(); + + /// An instance of this resolver that returns standard AOT-compatible formatters as well as formatters specifically generated for types in this assembly. + public static readonly MsgPack::IFormatterResolver InstanceWithStandardAotResolver = MsgPack::Resolvers.CompositeResolver.Create(Instance, MsgPack::Resolvers.StandardAotResolver.Instance); + + private GeneratedMessagePackResolver() + { + } + + public MsgPack::Formatters.IMessagePackFormatter GetFormatter() + { + return FormatterCache.Formatter; + } + + private static class FormatterCache + { + internal static readonly MsgPack::Formatters.IMessagePackFormatter Formatter; + + static FormatterCache() + { + var f = GeneratedMessagePackResolverGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + Formatter = (MsgPack::Formatters.IMessagePackFormatter)f; + } + } + } + } + + internal static class GeneratedMessagePackResolverGetFormatterHelper + { + private static readonly global::System.Collections.Generic.Dictionary lookup; + + static GeneratedMessagePackResolverGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(1) + { + { typeof(global::TempProject.MyMessagePackObject), 0 }, + }; + } + + internal static object GetFormatter(global::System.Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + case 0: return new Formatters::TempProject.MyMessagePackObjectFormatter(); + default: return null; + } + } + } +} diff --git a/tests/MessagePack.SourceGenerator.Tests/Resources/PropertiesGetterSetterWithParameterizedConstructorAndDefaultValue/Formatters.TempProject.MyMessagePackObjectFormatter.g.cs b/tests/MessagePack.SourceGenerator.Tests/Resources/PropertiesGetterSetterWithParameterizedConstructorAndDefaultValue/Formatters.TempProject.MyMessagePackObjectFormatter.g.cs new file mode 100644 index 000000000..f448ea3a0 --- /dev/null +++ b/tests/MessagePack.SourceGenerator.Tests/Resources/PropertiesGetterSetterWithParameterizedConstructorAndDefaultValue/Formatters.TempProject.MyMessagePackObjectFormatter.g.cs @@ -0,0 +1,81 @@ +// + +#pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 + +namespace Formatters.TempProject +{ + using MsgPack = global::MessagePack; + + internal sealed class MyMessagePackObjectFormatter : global::MessagePack.Formatters.IMessagePackFormatter + { + // A + private static global::System.ReadOnlySpan GetSpan_A() => new byte[1 + 1] { 161, 65 }; + // B + private static global::System.ReadOnlySpan GetSpan_B() => new byte[1 + 1] { 161, 66 }; + + public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::TempProject.MyMessagePackObject value, global::MessagePack.MessagePackSerializerOptions options) + { + if (value is null) + { + writer.WriteNil(); + return; + } + + var formatterResolver = options.Resolver; + writer.WriteMapHeader(2); + writer.WriteRaw(GetSpan_A()); + writer.Write(value.A); + writer.WriteRaw(GetSpan_B()); + MsgPack::FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Serialize(ref writer, value.B, options); + } + + public global::TempProject.MyMessagePackObject Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) + { + if (reader.TryReadNil()) + { + return null; + } + + options.Security.DepthStep(ref reader); + var formatterResolver = options.Resolver; + var length = reader.ReadMapHeader(); + var __A__ = default(int); + var __B__IsInitialized = false; + var __B__ = default(string); + + for (int i = 0; i < length; i++) + { + var stringKey = global::MessagePack.Internal.CodeGenHelpers.ReadStringSpan(ref reader); + switch (stringKey.Length) + { + default: + FAIL: + reader.Skip(); + continue; + case 1: + switch (global::MessagePack.Internal.AutomataKeyGen.GetKey(ref stringKey)) + { + default: goto FAIL; + case 65UL: + __A__ = reader.ReadInt32(); + continue; + case 66UL: + __B__IsInitialized = true; + __B__ = MsgPack::FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Deserialize(ref reader, options); + continue; + } + + } + } + + var ____result = new global::TempProject.MyMessagePackObject(__A__); + if (__B__IsInitialized) + { + ____result.B = __B__; + } + + reader.Depth--; + return ____result; + } + } +} diff --git a/tests/MessagePack.SourceGenerator.Tests/Resources/PropertiesGetterSetterWithParameterizedConstructorAndDefaultValue/MessagePack.GeneratedMessagePackResolver.g.cs b/tests/MessagePack.SourceGenerator.Tests/Resources/PropertiesGetterSetterWithParameterizedConstructorAndDefaultValue/MessagePack.GeneratedMessagePackResolver.g.cs new file mode 100644 index 000000000..69765f674 --- /dev/null +++ b/tests/MessagePack.SourceGenerator.Tests/Resources/PropertiesGetterSetterWithParameterizedConstructorAndDefaultValue/MessagePack.GeneratedMessagePackResolver.g.cs @@ -0,0 +1,70 @@ +// + +#pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 + +namespace MessagePack +{ + using MsgPack = global::MessagePack; + using Formatters = global::Formatters; + + /// A MessagePack resolver that uses generated formatters for types in this assembly. + internal class GeneratedMessagePackResolver : MsgPack::IFormatterResolver + { + /// An instance of this resolver that only returns formatters specifically generated for types in this assembly. + public static readonly MsgPack::IFormatterResolver Instance = new GeneratedMessagePackResolver(); + + /// An instance of this resolver that returns standard AOT-compatible formatters as well as formatters specifically generated for types in this assembly. + public static readonly MsgPack::IFormatterResolver InstanceWithStandardAotResolver = MsgPack::Resolvers.CompositeResolver.Create(Instance, MsgPack::Resolvers.StandardAotResolver.Instance); + + private GeneratedMessagePackResolver() + { + } + + public MsgPack::Formatters.IMessagePackFormatter GetFormatter() + { + return FormatterCache.Formatter; + } + + private static class FormatterCache + { + internal static readonly MsgPack::Formatters.IMessagePackFormatter Formatter; + + static FormatterCache() + { + var f = GeneratedMessagePackResolverGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + Formatter = (MsgPack::Formatters.IMessagePackFormatter)f; + } + } + } + } + + internal static class GeneratedMessagePackResolverGetFormatterHelper + { + private static readonly global::System.Collections.Generic.Dictionary lookup; + + static GeneratedMessagePackResolverGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(1) + { + { typeof(global::TempProject.MyMessagePackObject), 0 }, + }; + } + + internal static object GetFormatter(global::System.Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + case 0: return new Formatters::TempProject.MyMessagePackObjectFormatter(); + default: return null; + } + } + } +} diff --git a/tests/MessagePack.SourceGenerator.Tests/Resources/PropertiesGetterSetterWithParameterizedConstructorDoNotUseSetter/Formatters.TempProject.MyMessagePackObjectFormatter.g.cs b/tests/MessagePack.SourceGenerator.Tests/Resources/PropertiesGetterSetterWithParameterizedConstructorDoNotUseSetter/Formatters.TempProject.MyMessagePackObjectFormatter.g.cs new file mode 100644 index 000000000..6b39e4610 --- /dev/null +++ b/tests/MessagePack.SourceGenerator.Tests/Resources/PropertiesGetterSetterWithParameterizedConstructorDoNotUseSetter/Formatters.TempProject.MyMessagePackObjectFormatter.g.cs @@ -0,0 +1,61 @@ +// + +#pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 + +namespace Formatters.TempProject +{ + using MsgPack = global::MessagePack; + + internal sealed class MyMessagePackObjectFormatter : global::MessagePack.Formatters.IMessagePackFormatter + { + // A + private static global::System.ReadOnlySpan GetSpan_A() => new byte[1 + 1] { 161, 65 }; + + public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::TempProject.MyMessagePackObject value, global::MessagePack.MessagePackSerializerOptions options) + { + if (value is null) + { + writer.WriteNil(); + return; + } + + writer.WriteMapHeader(1); + writer.WriteRaw(GetSpan_A()); + writer.Write(value.A); + } + + public global::TempProject.MyMessagePackObject Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) + { + if (reader.TryReadNil()) + { + return null; + } + + options.Security.DepthStep(ref reader); + var length = reader.ReadMapHeader(); + var __A__ = default(int); + + for (int i = 0; i < length; i++) + { + var stringKey = global::MessagePack.Internal.CodeGenHelpers.ReadStringSpan(ref reader); + switch (stringKey.Length) + { + default: + FAIL: + reader.Skip(); + continue; + case 1: + if (stringKey[0] != 65) { goto FAIL; } + + __A__ = reader.ReadInt32(); + continue; + + } + } + + var ____result = new global::TempProject.MyMessagePackObject(__A__); + reader.Depth--; + return ____result; + } + } +} diff --git a/tests/MessagePack.SourceGenerator.Tests/Resources/PropertiesGetterSetterWithParameterizedConstructorDoNotUseSetter/MessagePack.GeneratedMessagePackResolver.g.cs b/tests/MessagePack.SourceGenerator.Tests/Resources/PropertiesGetterSetterWithParameterizedConstructorDoNotUseSetter/MessagePack.GeneratedMessagePackResolver.g.cs new file mode 100644 index 000000000..69765f674 --- /dev/null +++ b/tests/MessagePack.SourceGenerator.Tests/Resources/PropertiesGetterSetterWithParameterizedConstructorDoNotUseSetter/MessagePack.GeneratedMessagePackResolver.g.cs @@ -0,0 +1,70 @@ +// + +#pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 + +namespace MessagePack +{ + using MsgPack = global::MessagePack; + using Formatters = global::Formatters; + + /// A MessagePack resolver that uses generated formatters for types in this assembly. + internal class GeneratedMessagePackResolver : MsgPack::IFormatterResolver + { + /// An instance of this resolver that only returns formatters specifically generated for types in this assembly. + public static readonly MsgPack::IFormatterResolver Instance = new GeneratedMessagePackResolver(); + + /// An instance of this resolver that returns standard AOT-compatible formatters as well as formatters specifically generated for types in this assembly. + public static readonly MsgPack::IFormatterResolver InstanceWithStandardAotResolver = MsgPack::Resolvers.CompositeResolver.Create(Instance, MsgPack::Resolvers.StandardAotResolver.Instance); + + private GeneratedMessagePackResolver() + { + } + + public MsgPack::Formatters.IMessagePackFormatter GetFormatter() + { + return FormatterCache.Formatter; + } + + private static class FormatterCache + { + internal static readonly MsgPack::Formatters.IMessagePackFormatter Formatter; + + static FormatterCache() + { + var f = GeneratedMessagePackResolverGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + Formatter = (MsgPack::Formatters.IMessagePackFormatter)f; + } + } + } + } + + internal static class GeneratedMessagePackResolverGetFormatterHelper + { + private static readonly global::System.Collections.Generic.Dictionary lookup; + + static GeneratedMessagePackResolverGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(1) + { + { typeof(global::TempProject.MyMessagePackObject), 0 }, + }; + } + + internal static object GetFormatter(global::System.Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + case 0: return new Formatters::TempProject.MyMessagePackObjectFormatter(); + default: return null; + } + } + } +} diff --git a/tests/MessagePack.SourceGenerator.Tests/Resources/PropertiesGetterSetterWithParameterizedConstructorPartially/Formatters.TempProject.MyMessagePackObjectFormatter.g.cs b/tests/MessagePack.SourceGenerator.Tests/Resources/PropertiesGetterSetterWithParameterizedConstructorPartially/Formatters.TempProject.MyMessagePackObjectFormatter.g.cs new file mode 100644 index 000000000..f448ea3a0 --- /dev/null +++ b/tests/MessagePack.SourceGenerator.Tests/Resources/PropertiesGetterSetterWithParameterizedConstructorPartially/Formatters.TempProject.MyMessagePackObjectFormatter.g.cs @@ -0,0 +1,81 @@ +// + +#pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 + +namespace Formatters.TempProject +{ + using MsgPack = global::MessagePack; + + internal sealed class MyMessagePackObjectFormatter : global::MessagePack.Formatters.IMessagePackFormatter + { + // A + private static global::System.ReadOnlySpan GetSpan_A() => new byte[1 + 1] { 161, 65 }; + // B + private static global::System.ReadOnlySpan GetSpan_B() => new byte[1 + 1] { 161, 66 }; + + public void Serialize(ref global::MessagePack.MessagePackWriter writer, global::TempProject.MyMessagePackObject value, global::MessagePack.MessagePackSerializerOptions options) + { + if (value is null) + { + writer.WriteNil(); + return; + } + + var formatterResolver = options.Resolver; + writer.WriteMapHeader(2); + writer.WriteRaw(GetSpan_A()); + writer.Write(value.A); + writer.WriteRaw(GetSpan_B()); + MsgPack::FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Serialize(ref writer, value.B, options); + } + + public global::TempProject.MyMessagePackObject Deserialize(ref global::MessagePack.MessagePackReader reader, global::MessagePack.MessagePackSerializerOptions options) + { + if (reader.TryReadNil()) + { + return null; + } + + options.Security.DepthStep(ref reader); + var formatterResolver = options.Resolver; + var length = reader.ReadMapHeader(); + var __A__ = default(int); + var __B__IsInitialized = false; + var __B__ = default(string); + + for (int i = 0; i < length; i++) + { + var stringKey = global::MessagePack.Internal.CodeGenHelpers.ReadStringSpan(ref reader); + switch (stringKey.Length) + { + default: + FAIL: + reader.Skip(); + continue; + case 1: + switch (global::MessagePack.Internal.AutomataKeyGen.GetKey(ref stringKey)) + { + default: goto FAIL; + case 65UL: + __A__ = reader.ReadInt32(); + continue; + case 66UL: + __B__IsInitialized = true; + __B__ = MsgPack::FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Deserialize(ref reader, options); + continue; + } + + } + } + + var ____result = new global::TempProject.MyMessagePackObject(__A__); + if (__B__IsInitialized) + { + ____result.B = __B__; + } + + reader.Depth--; + return ____result; + } + } +} diff --git a/tests/MessagePack.SourceGenerator.Tests/Resources/PropertiesGetterSetterWithParameterizedConstructorPartially/MessagePack.GeneratedMessagePackResolver.g.cs b/tests/MessagePack.SourceGenerator.Tests/Resources/PropertiesGetterSetterWithParameterizedConstructorPartially/MessagePack.GeneratedMessagePackResolver.g.cs new file mode 100644 index 000000000..69765f674 --- /dev/null +++ b/tests/MessagePack.SourceGenerator.Tests/Resources/PropertiesGetterSetterWithParameterizedConstructorPartially/MessagePack.GeneratedMessagePackResolver.g.cs @@ -0,0 +1,70 @@ +// + +#pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 + +namespace MessagePack +{ + using MsgPack = global::MessagePack; + using Formatters = global::Formatters; + + /// A MessagePack resolver that uses generated formatters for types in this assembly. + internal class GeneratedMessagePackResolver : MsgPack::IFormatterResolver + { + /// An instance of this resolver that only returns formatters specifically generated for types in this assembly. + public static readonly MsgPack::IFormatterResolver Instance = new GeneratedMessagePackResolver(); + + /// An instance of this resolver that returns standard AOT-compatible formatters as well as formatters specifically generated for types in this assembly. + public static readonly MsgPack::IFormatterResolver InstanceWithStandardAotResolver = MsgPack::Resolvers.CompositeResolver.Create(Instance, MsgPack::Resolvers.StandardAotResolver.Instance); + + private GeneratedMessagePackResolver() + { + } + + public MsgPack::Formatters.IMessagePackFormatter GetFormatter() + { + return FormatterCache.Formatter; + } + + private static class FormatterCache + { + internal static readonly MsgPack::Formatters.IMessagePackFormatter Formatter; + + static FormatterCache() + { + var f = GeneratedMessagePackResolverGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + Formatter = (MsgPack::Formatters.IMessagePackFormatter)f; + } + } + } + } + + internal static class GeneratedMessagePackResolverGetFormatterHelper + { + private static readonly global::System.Collections.Generic.Dictionary lookup; + + static GeneratedMessagePackResolverGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(1) + { + { typeof(global::TempProject.MyMessagePackObject), 0 }, + }; + } + + internal static object GetFormatter(global::System.Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + case 0: return new Formatters::TempProject.MyMessagePackObjectFormatter(); + default: return null; + } + } + } +} diff --git a/tests/MessagePack.SourceGenerator.Tests/StringKeyedFormatterTests.cs b/tests/MessagePack.SourceGenerator.Tests/StringKeyedFormatterTests.cs new file mode 100644 index 000000000..373e45abf --- /dev/null +++ b/tests/MessagePack.SourceGenerator.Tests/StringKeyedFormatterTests.cs @@ -0,0 +1,315 @@ +// Copyright (c) All contributors. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using MessagePack.SourceGenerator.Tests; + +public class StringKeyedFormatterTests +{ + [Fact] + public async Task PropertiesGetterSetter() + { + string testSource = """ +using System; +using System.Collections.Generic; +using MessagePack; + +namespace TempProject +{ + [MessagePackObject(true)] + public class MyMessagePackObject + { + public int A { get; set; } + public string B { get; set; } + } +} +"""; + await VerifyCS.Test.RunDefaultAsync(testSource); + } + + [Fact] + public async Task PropertiesGetterOnlyMixed() + { + string testSource = """ +using System; +using System.Collections.Generic; +using MessagePack; + +namespace TempProject +{ + [MessagePackObject(true)] + public class MyMessagePackObject + { + public int A { get; } + public string B { get; set; } + } +} +"""; + await VerifyCS.Test.RunDefaultAsync(testSource); + } + + [Fact] + public async Task PropertiesGetterOnlyIgnore() + { + string testSource = """ +using System; +using System.Collections.Generic; +using MessagePack; + +namespace TempProject +{ + [MessagePackObject(true)] + public class MyMessagePackObject + { + public int A { get; } + public string B { get; } + } +} +"""; + await VerifyCS.Test.RunDefaultAsync(testSource); + } + + [Fact] + public async Task PropertiesGetterOnlyDefaultValue() + { + string testSource = """ +using System; +using System.Collections.Generic; +using MessagePack; + +namespace TempProject +{ + [MessagePackObject(true)] + public class MyMessagePackObject + { + public int A { get; } = 123; + public string B { get; } = "foobar"; + } +} +"""; + await VerifyCS.Test.RunDefaultAsync(testSource); + } + + [Fact] + public async Task PropertiesGetterSetterWithDefaultValue() + { + string testSource = """ +using System; +using System.Collections.Generic; +using MessagePack; + +namespace TempProject +{ + [MessagePackObject(true)] + public class MyMessagePackObject + { + public int A { get; set; } = 123; + public string B { get; set; } = "foobar"; + } +} +"""; + await VerifyCS.Test.RunDefaultAsync(testSource); + } + + [Fact] + public async Task PropertiesGetterSetterWithDefaultValueInputPartially() + { + string testSource = """ +using System; +using System.Collections.Generic; +using MessagePack; + +namespace TempProject +{ + [MessagePackObject(true)] + public class MyMessagePackObject + { + public int A { get; set; } = 123; + public string B { get; set; } = "foobar"; + } +} +"""; + await VerifyCS.Test.RunDefaultAsync(testSource); + } + + [Fact] + public async Task PropertiesGetterOnlyWithParameterizedConstructor() + { + string testSource = """ +using System; +using System.Collections.Generic; +using MessagePack; + +namespace TempProject +{ + [MessagePackObject(true)] + public class MyMessagePackObject + { + public int A { get; } + public string B { get; } + + public MyMessagePackObject(int a, string b) + { + A = a; + B = b; + } + } +} +"""; + await VerifyCS.Test.RunDefaultAsync(testSource); + } + + [Fact] + public async Task PropertiesGetterOnlyWithParameterizedConstructorPartially() + { + string testSource = """ +using System; +using System.Collections.Generic; +using MessagePack; + +namespace TempProject +{ + [MessagePackObject(true)] + public class MyMessagePackObject + { + public int A { get; } + public string B { get; } + + public MyMessagePackObject(string b) + { + B = b; + } + } +} +"""; + await VerifyCS.Test.RunDefaultAsync(testSource); + } + + [Fact] + public async Task PropertiesGetterOnlyWithParameterizedConstructorDefaultValue() + { + string testSource = """ +using System; +using System.Collections.Generic; +using MessagePack; + +namespace TempProject +{ + [MessagePackObject(true)] + public class MyMessagePackObject + { + public int A { get; } = 12345; + public string B { get; } = "some"; + + public MyMessagePackObject(string b) + { + B = b; + } + } +} +"""; + await VerifyCS.Test.RunDefaultAsync(testSource); + } + + [Fact] + public async Task PropertiesGetterSetterWithParameterizedConstructor() + { + string testSource = """ +using System; +using System.Collections.Generic; +using MessagePack; + +namespace TempProject +{ + [MessagePackObject(true)] + public class MyMessagePackObject + { + public int A { get; set; } + public string B { get; set; } + + public MyMessagePackObject(int a, string b) + { + A = a; + B = b; + } + } +} +"""; + await VerifyCS.Test.RunDefaultAsync(testSource); + } + + [Fact] + public async Task PropertiesGetterSetterWithParameterizedConstructorPartially() + { + string testSource = """ +using System; +using System.Collections.Generic; +using MessagePack; + +namespace TempProject +{ + [MessagePackObject(true)] + public class MyMessagePackObject + { + public int A { get; set; } + public string B { get; set; } + + public MyMessagePackObject(int a) + { + A = a; + } + } +} +"""; + await VerifyCS.Test.RunDefaultAsync(testSource); + } + + [Fact] + public async Task PropertiesGetterSetterWithParameterizedConstructorDoNotUseSetter() + { + string testSource = """ +using System; +using System.Collections.Generic; +using MessagePack; + +namespace TempProject +{ + [MessagePackObject(true)] + public class MyMessagePackObject + { + public int A { get; set; } + + public MyMessagePackObject(int a) + { + } + } +} +"""; + await VerifyCS.Test.RunDefaultAsync(testSource); + } + + [Fact] + public async Task PropertiesGetterSetterWithParameterizedConstructorAndDefaultValue() + { + string testSource = """ +using System; +using System.Collections.Generic; +using MessagePack; + +namespace TempProject +{ + [MessagePackObject(true)] + public class MyMessagePackObject + { + public int A { get; set; } + public string B { get; set; } = "foobar"; + + public MyMessagePackObject(int a) + { + A = a; + } + } +} +"""; + await VerifyCS.Test.RunDefaultAsync(testSource); + } +} diff --git a/tests/MessagePack.SourceGenerator.Unity.Tests/MessagePack.SourceGenerator.Unity.Tests.csproj b/tests/MessagePack.SourceGenerator.Unity.Tests/MessagePack.SourceGenerator.Unity.Tests.csproj index f65134d53..ed44f5a46 100644 --- a/tests/MessagePack.SourceGenerator.Unity.Tests/MessagePack.SourceGenerator.Unity.Tests.csproj +++ b/tests/MessagePack.SourceGenerator.Unity.Tests/MessagePack.SourceGenerator.Unity.Tests.csproj @@ -10,7 +10,6 @@ - From 61487fc4e2ec227e3ec06f2d8db1f895d72a834e Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Wed, 12 Apr 2023 07:11:44 -0600 Subject: [PATCH 093/660] Get all tests passing or skipped --- .../MessagePackGenerator.cs | 10 +++- .../Transforms/FormatterTemplate.cs | 3 +- .../Transforms/FormatterTemplate.tt | 2 + .../GenericsFormatterTests.cs | 17 +++--- .../Formatters.ContainerObjectFormatter.g.cs | 2 + .../Formatters.SubObjectFormatter.g.cs | 2 + .../Formatters.TempProject.BarFormatter.g.cs | 2 + ...WithCustomFormatterAttributeFormatter.g.cs | 2 + ...amespace.MyMessagePackObjectFormatter.g.cs | 2 + ...ingClass_MyMessagePackObjectFormatter.g.cs | 2 + ...rmatters.MyMessagePackObjectFormatter.g.cs | 2 + .../Formatters.ContainerObjectFormatter.g.cs | 2 + .../Formatters.MyGenericTypeFormatter_T_.g.cs | 2 + ...matters.GenericClassFormatter_T1, T2_.g.cs | 2 + ...ject.MyGenericObjectFormatter_T1, T2_.g.cs | 2 + ...matters.TempProject.MyObjectFormatter.g.cs | 2 + ...s.TempProject.MyObjectNestedFormatter.g.cs | 2 + ...mpProject.MyGenericObjectFormatter_T_.g.cs | 2 + ...matters.TempProject.MyObjectFormatter.g.cs | 2 + ...s.TempProject.MyObjectNestedFormatter.g.cs | 2 + ...mpProject.MyGenericObjectFormatter_T_.g.cs | 2 + ...mpProject.MyGenericObjectFormatter_T_.g.cs | 2 + ...atters.TempProject.MyObject2Formatter.g.cs | 2 + ...matters.TempProject.MyObjectFormatter.g.cs | 2 + ...tters.TempProject.WrapperFormatter_T_.g.cs | 2 + ...mpProject.MyGenericObjectFormatter_T_.g.cs | 2 + ...ject.MyInnerGenericObjectFormatter_T_.g.cs | 2 + ...tters.TempProject.WrapperFormatter_T_.g.cs | 2 + ...enericObjectFormatter_T1, T2, T3, T4_.g.cs | 2 + ...enericObjectFormatter_T1, T2, T3, T4_.g.cs | 2 + ...ject.MyGenericObjectFormatter_T1, T2_.g.cs | 2 + ...mpProject.MyGenericObjectFormatter_T_.g.cs | 2 + ...mpProject.MyGenericObjectFormatter_T_.g.cs | 2 + ...mpProject.MyGenericObjectFormatter_T_.g.cs | 56 +++++++++++++++++++ ...matters.TempProject.MyObjectFormatter.g.cs | 2 + ...s.TempProject.MyObjectNestedFormatter.g.cs | 2 + ...sagePack.GeneratedMessagePackResolver.g.cs | 10 +--- ...mpProject.MyGenericObjectFormatter_T_.g.cs | 2 + ...ject.MyInnerGenericObjectFormatter_T_.g.cs | 2 + ...atters.TempProject.MyObject2Formatter.g.cs | 2 + ...matters.TempProject.MyObjectFormatter.g.cs | 2 + ...tters.TempProject.WrapperFormatter_T_.g.cs | 2 + ...matters.TempProject.MyObjectFormatter.g.cs | 2 + .../Formatters.Object1Formatter.g.cs | 2 + .../Formatters.Object2Formatter.g.cs | 2 + ...ers.MyTestNamespace.Derived1Formatter.g.cs | 2 + ...ers.MyTestNamespace.Derived2Formatter.g.cs | 2 + ...amespace.MyMessagePackObjectFormatter.g.cs | 2 + ...ers.ContainingClass_Derived1Formatter.g.cs | 2 + ...ers.ContainingClass_Derived2Formatter.g.cs | 2 + ...ingClass_MyMessagePackObjectFormatter.g.cs | 2 + .../Formatters.Derived1Formatter.g.cs | 2 + .../Formatters.Derived2Formatter.g.cs | 2 + ...rmatters.MyMessagePackObjectFormatter.g.cs | 2 + ...matters.TempProject.MyObjectFormatter.g.cs | 2 + 55 files changed, 176 insertions(+), 20 deletions(-) create mode 100644 tests/MessagePack.SourceGenerator.Tests/Resources/Generics_Defined_In_ReferencedProject/Formatters.TempProject.MyGenericObjectFormatter_T_.g.cs diff --git a/src/MessagePack.SourceGenerator/MessagePackGenerator.cs b/src/MessagePack.SourceGenerator/MessagePackGenerator.cs index bc01c19b2..895d9324a 100644 --- a/src/MessagePack.SourceGenerator/MessagePackGenerator.cs +++ b/src/MessagePack.SourceGenerator/MessagePackGenerator.cs @@ -68,12 +68,18 @@ void Collect(TypeDeclarationSyntax typeDecl) context.RegisterSourceOutput(source, static (context, source) => { - Generate(new GeneratorContext(context), source!); + if (source is not null) + { + Generate(new GeneratorContext(context), source); + } }); context.RegisterSourceOutput(source, static (context, source) => { - GenerateResolver(new GeneratorContext(context), source!); + if (source is not null) + { + GenerateResolver(new GeneratorContext(context), source); + } }); } diff --git a/src/MessagePack.SourceGenerator/Transforms/FormatterTemplate.cs b/src/MessagePack.SourceGenerator/Transforms/FormatterTemplate.cs index 659232f88..3f318a7c4 100644 --- a/src/MessagePack.SourceGenerator/Transforms/FormatterTemplate.cs +++ b/src/MessagePack.SourceGenerator/Transforms/FormatterTemplate.cs @@ -26,7 +26,8 @@ public partial class FormatterTemplate : FormatterTemplateBase /// public virtual string TransformText() { - this.Write("\r\nnamespace "); + this.Write("\r\n#pragma warning disable CS8669 // We may leak nullable annotations into generat" + + "ed code.\r\n\r\nnamespace "); this.Write(this.ToStringHelper.ToStringWithCulture(Namespace)); this.Write("\r\n{\r\n\tusing MsgPack = global::MessagePack;\r\n\r\n"); bool isFormatterResolverNecessary = ShouldUseFormatterResolverHelper.ShouldUseFormatterResolver(Info.Members); diff --git a/src/MessagePack.SourceGenerator/Transforms/FormatterTemplate.tt b/src/MessagePack.SourceGenerator/Transforms/FormatterTemplate.tt index e63dc69e7..5da3af86c 100644 --- a/src/MessagePack.SourceGenerator/Transforms/FormatterTemplate.tt +++ b/src/MessagePack.SourceGenerator/Transforms/FormatterTemplate.tt @@ -5,6 +5,8 @@ <#@ import namespace="System.Collections.Generic" #> <#@ import namespace="MessagePackAnalyzer.Transforms" #> +#pragma warning disable CS8669 // We may leak nullable annotations into generated code. + namespace <#= Namespace #> { using MsgPack = global::MessagePack; diff --git a/tests/MessagePack.SourceGenerator.Tests/GenericsFormatterTests.cs b/tests/MessagePack.SourceGenerator.Tests/GenericsFormatterTests.cs index 84ed2fe29..f3a33453e 100644 --- a/tests/MessagePack.SourceGenerator.Tests/GenericsFormatterTests.cs +++ b/tests/MessagePack.SourceGenerator.Tests/GenericsFormatterTests.cs @@ -428,7 +428,7 @@ public class MyGenericObject await VerifyCS.Test.RunDefaultAsync(testSource); } - [Fact] + [Fact(Skip = "Does not pass yet because the project reference isn't set up correctly.")] public async Task Generics_Defined_In_ReferencedProject() { string defineSource = """ @@ -469,6 +469,13 @@ public class MyObjectNested } } """; + var definingProject = new Microsoft.CodeAnalysis.Testing.ProjectState("DefiningProject", LanguageNames.CSharp, string.Empty, ".cs") + { + Sources = { defineSource }, + ReferenceAssemblies = new VerifyCS.Test().ReferenceAssemblies, + }; + definingProject.AdditionalReferences.AddRange(new VerifyCS.Test().TestState.AdditionalReferences); + await new VerifyCS.Test { TestState = @@ -476,13 +483,7 @@ public class MyObjectNested Sources = { usageSource }, AdditionalProjects = { - { - "DefiningProject", - new Microsoft.CodeAnalysis.Testing.ProjectState("DefiningProject", LanguageNames.CSharp, string.Empty, ".cs") - { - Sources = { defineSource }, - } - }, + { "DefiningProject", definingProject }, }, AdditionalProjectReferences = { "DefiningProject" }, }, diff --git a/tests/MessagePack.SourceGenerator.Tests/Resources/ArrayTypedProperty/Formatters.ContainerObjectFormatter.g.cs b/tests/MessagePack.SourceGenerator.Tests/Resources/ArrayTypedProperty/Formatters.ContainerObjectFormatter.g.cs index 00d014009..ef37df632 100644 --- a/tests/MessagePack.SourceGenerator.Tests/Resources/ArrayTypedProperty/Formatters.ContainerObjectFormatter.g.cs +++ b/tests/MessagePack.SourceGenerator.Tests/Resources/ArrayTypedProperty/Formatters.ContainerObjectFormatter.g.cs @@ -2,6 +2,8 @@ #pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 +#pragma warning disable CS8669 // We may leak nullable annotations into generated code. + namespace Formatters { using MsgPack = global::MessagePack; diff --git a/tests/MessagePack.SourceGenerator.Tests/Resources/ArrayTypedProperty/Formatters.SubObjectFormatter.g.cs b/tests/MessagePack.SourceGenerator.Tests/Resources/ArrayTypedProperty/Formatters.SubObjectFormatter.g.cs index f8fa45ce1..4b05c039f 100644 --- a/tests/MessagePack.SourceGenerator.Tests/Resources/ArrayTypedProperty/Formatters.SubObjectFormatter.g.cs +++ b/tests/MessagePack.SourceGenerator.Tests/Resources/ArrayTypedProperty/Formatters.SubObjectFormatter.g.cs @@ -2,6 +2,8 @@ #pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 +#pragma warning disable CS8669 // We may leak nullable annotations into generated code. + namespace Formatters { using MsgPack = global::MessagePack; diff --git a/tests/MessagePack.SourceGenerator.Tests/Resources/CanGenerateMessagePackFormatterAttr/Formatters.TempProject.BarFormatter.g.cs b/tests/MessagePack.SourceGenerator.Tests/Resources/CanGenerateMessagePackFormatterAttr/Formatters.TempProject.BarFormatter.g.cs index 240e394d0..82890b88f 100644 --- a/tests/MessagePack.SourceGenerator.Tests/Resources/CanGenerateMessagePackFormatterAttr/Formatters.TempProject.BarFormatter.g.cs +++ b/tests/MessagePack.SourceGenerator.Tests/Resources/CanGenerateMessagePackFormatterAttr/Formatters.TempProject.BarFormatter.g.cs @@ -2,6 +2,8 @@ #pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 +#pragma warning disable CS8669 // We may leak nullable annotations into generated code. + namespace Formatters.TempProject { using MsgPack = global::MessagePack; diff --git a/tests/MessagePack.SourceGenerator.Tests/Resources/CustomFormatterViaAttributeOnProperty(False)/Formatters.HasPropertyWithCustomFormatterAttributeFormatter.g.cs b/tests/MessagePack.SourceGenerator.Tests/Resources/CustomFormatterViaAttributeOnProperty(False)/Formatters.HasPropertyWithCustomFormatterAttributeFormatter.g.cs index 3f227685c..2a4393b68 100644 --- a/tests/MessagePack.SourceGenerator.Tests/Resources/CustomFormatterViaAttributeOnProperty(False)/Formatters.HasPropertyWithCustomFormatterAttributeFormatter.g.cs +++ b/tests/MessagePack.SourceGenerator.Tests/Resources/CustomFormatterViaAttributeOnProperty(False)/Formatters.HasPropertyWithCustomFormatterAttributeFormatter.g.cs @@ -2,6 +2,8 @@ #pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 +#pragma warning disable CS8669 // We may leak nullable annotations into generated code. + namespace Formatters { using MsgPack = global::MessagePack; diff --git a/tests/MessagePack.SourceGenerator.Tests/Resources/EnumFormatter(Namespace, False)/Formatters.MyTestNamespace.MyMessagePackObjectFormatter.g.cs b/tests/MessagePack.SourceGenerator.Tests/Resources/EnumFormatter(Namespace, False)/Formatters.MyTestNamespace.MyMessagePackObjectFormatter.g.cs index 1529eb9fd..0c97c1f31 100644 --- a/tests/MessagePack.SourceGenerator.Tests/Resources/EnumFormatter(Namespace, False)/Formatters.MyTestNamespace.MyMessagePackObjectFormatter.g.cs +++ b/tests/MessagePack.SourceGenerator.Tests/Resources/EnumFormatter(Namespace, False)/Formatters.MyTestNamespace.MyMessagePackObjectFormatter.g.cs @@ -2,6 +2,8 @@ #pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 +#pragma warning disable CS8669 // We may leak nullable annotations into generated code. + namespace Formatters.MyTestNamespace { using MsgPack = global::MessagePack; diff --git a/tests/MessagePack.SourceGenerator.Tests/Resources/EnumFormatter(NestingClass, False)/Formatters.ContainingClass_MyMessagePackObjectFormatter.g.cs b/tests/MessagePack.SourceGenerator.Tests/Resources/EnumFormatter(NestingClass, False)/Formatters.ContainingClass_MyMessagePackObjectFormatter.g.cs index 94af15ad3..260df53da 100644 --- a/tests/MessagePack.SourceGenerator.Tests/Resources/EnumFormatter(NestingClass, False)/Formatters.ContainingClass_MyMessagePackObjectFormatter.g.cs +++ b/tests/MessagePack.SourceGenerator.Tests/Resources/EnumFormatter(NestingClass, False)/Formatters.ContainingClass_MyMessagePackObjectFormatter.g.cs @@ -2,6 +2,8 @@ #pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 +#pragma warning disable CS8669 // We may leak nullable annotations into generated code. + namespace Formatters { using MsgPack = global::MessagePack; diff --git a/tests/MessagePack.SourceGenerator.Tests/Resources/EnumFormatter(None, False)/Formatters.MyMessagePackObjectFormatter.g.cs b/tests/MessagePack.SourceGenerator.Tests/Resources/EnumFormatter(None, False)/Formatters.MyMessagePackObjectFormatter.g.cs index 983bb67c4..9889be5eb 100644 --- a/tests/MessagePack.SourceGenerator.Tests/Resources/EnumFormatter(None, False)/Formatters.MyMessagePackObjectFormatter.g.cs +++ b/tests/MessagePack.SourceGenerator.Tests/Resources/EnumFormatter(None, False)/Formatters.MyMessagePackObjectFormatter.g.cs @@ -2,6 +2,8 @@ #pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 +#pragma warning disable CS8669 // We may leak nullable annotations into generated code. + namespace Formatters { using MsgPack = global::MessagePack; diff --git a/tests/MessagePack.SourceGenerator.Tests/Resources/GenericType/Formatters.ContainerObjectFormatter.g.cs b/tests/MessagePack.SourceGenerator.Tests/Resources/GenericType/Formatters.ContainerObjectFormatter.g.cs index 85ba4f7b2..f7fe1b240 100644 --- a/tests/MessagePack.SourceGenerator.Tests/Resources/GenericType/Formatters.ContainerObjectFormatter.g.cs +++ b/tests/MessagePack.SourceGenerator.Tests/Resources/GenericType/Formatters.ContainerObjectFormatter.g.cs @@ -2,6 +2,8 @@ #pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 +#pragma warning disable CS8669 // We may leak nullable annotations into generated code. + namespace Formatters { using MsgPack = global::MessagePack; diff --git a/tests/MessagePack.SourceGenerator.Tests/Resources/GenericType/Formatters.MyGenericTypeFormatter_T_.g.cs b/tests/MessagePack.SourceGenerator.Tests/Resources/GenericType/Formatters.MyGenericTypeFormatter_T_.g.cs index 4a7c9e968..23ba863b7 100644 --- a/tests/MessagePack.SourceGenerator.Tests/Resources/GenericType/Formatters.MyGenericTypeFormatter_T_.g.cs +++ b/tests/MessagePack.SourceGenerator.Tests/Resources/GenericType/Formatters.MyGenericTypeFormatter_T_.g.cs @@ -2,6 +2,8 @@ #pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 +#pragma warning disable CS8669 // We may leak nullable annotations into generated code. + namespace Formatters { using MsgPack = global::MessagePack; diff --git a/tests/MessagePack.SourceGenerator.Tests/Resources/GenericTypeArg/Formatters.GenericClassFormatter_T1, T2_.g.cs b/tests/MessagePack.SourceGenerator.Tests/Resources/GenericTypeArg/Formatters.GenericClassFormatter_T1, T2_.g.cs index aeedc3a32..83e3a2c5e 100644 --- a/tests/MessagePack.SourceGenerator.Tests/Resources/GenericTypeArg/Formatters.GenericClassFormatter_T1, T2_.g.cs +++ b/tests/MessagePack.SourceGenerator.Tests/Resources/GenericTypeArg/Formatters.GenericClassFormatter_T1, T2_.g.cs @@ -2,6 +2,8 @@ #pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 +#pragma warning disable CS8669 // We may leak nullable annotations into generated code. + namespace Formatters { using MsgPack = global::MessagePack; diff --git a/tests/MessagePack.SourceGenerator.Tests/Resources/GenericsOfT1T2Formatter/Formatters.TempProject.MyGenericObjectFormatter_T1, T2_.g.cs b/tests/MessagePack.SourceGenerator.Tests/Resources/GenericsOfT1T2Formatter/Formatters.TempProject.MyGenericObjectFormatter_T1, T2_.g.cs index b4ba2263f..d55c6565e 100644 --- a/tests/MessagePack.SourceGenerator.Tests/Resources/GenericsOfT1T2Formatter/Formatters.TempProject.MyGenericObjectFormatter_T1, T2_.g.cs +++ b/tests/MessagePack.SourceGenerator.Tests/Resources/GenericsOfT1T2Formatter/Formatters.TempProject.MyGenericObjectFormatter_T1, T2_.g.cs @@ -2,6 +2,8 @@ #pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 +#pragma warning disable CS8669 // We may leak nullable annotations into generated code. + namespace Formatters.TempProject { using MsgPack = global::MessagePack; diff --git a/tests/MessagePack.SourceGenerator.Tests/Resources/GenericsOfT1T2Formatter/Formatters.TempProject.MyObjectFormatter.g.cs b/tests/MessagePack.SourceGenerator.Tests/Resources/GenericsOfT1T2Formatter/Formatters.TempProject.MyObjectFormatter.g.cs index 6e23fac50..c6f15a532 100644 --- a/tests/MessagePack.SourceGenerator.Tests/Resources/GenericsOfT1T2Formatter/Formatters.TempProject.MyObjectFormatter.g.cs +++ b/tests/MessagePack.SourceGenerator.Tests/Resources/GenericsOfT1T2Formatter/Formatters.TempProject.MyObjectFormatter.g.cs @@ -2,6 +2,8 @@ #pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 +#pragma warning disable CS8669 // We may leak nullable annotations into generated code. + namespace Formatters.TempProject { using MsgPack = global::MessagePack; diff --git a/tests/MessagePack.SourceGenerator.Tests/Resources/GenericsOfT1T2Formatter/Formatters.TempProject.MyObjectNestedFormatter.g.cs b/tests/MessagePack.SourceGenerator.Tests/Resources/GenericsOfT1T2Formatter/Formatters.TempProject.MyObjectNestedFormatter.g.cs index b96019006..363ca129c 100644 --- a/tests/MessagePack.SourceGenerator.Tests/Resources/GenericsOfT1T2Formatter/Formatters.TempProject.MyObjectNestedFormatter.g.cs +++ b/tests/MessagePack.SourceGenerator.Tests/Resources/GenericsOfT1T2Formatter/Formatters.TempProject.MyObjectNestedFormatter.g.cs @@ -2,6 +2,8 @@ #pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 +#pragma warning disable CS8669 // We may leak nullable annotations into generated code. + namespace Formatters.TempProject { using MsgPack = global::MessagePack; diff --git a/tests/MessagePack.SourceGenerator.Tests/Resources/GenericsOfTFormatter/Formatters.TempProject.MyGenericObjectFormatter_T_.g.cs b/tests/MessagePack.SourceGenerator.Tests/Resources/GenericsOfTFormatter/Formatters.TempProject.MyGenericObjectFormatter_T_.g.cs index 0c6c03f50..44538b8ef 100644 --- a/tests/MessagePack.SourceGenerator.Tests/Resources/GenericsOfTFormatter/Formatters.TempProject.MyGenericObjectFormatter_T_.g.cs +++ b/tests/MessagePack.SourceGenerator.Tests/Resources/GenericsOfTFormatter/Formatters.TempProject.MyGenericObjectFormatter_T_.g.cs @@ -2,6 +2,8 @@ #pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 +#pragma warning disable CS8669 // We may leak nullable annotations into generated code. + namespace Formatters.TempProject { using MsgPack = global::MessagePack; diff --git a/tests/MessagePack.SourceGenerator.Tests/Resources/GenericsOfTFormatter/Formatters.TempProject.MyObjectFormatter.g.cs b/tests/MessagePack.SourceGenerator.Tests/Resources/GenericsOfTFormatter/Formatters.TempProject.MyObjectFormatter.g.cs index d1e3f850d..412999b1a 100644 --- a/tests/MessagePack.SourceGenerator.Tests/Resources/GenericsOfTFormatter/Formatters.TempProject.MyObjectFormatter.g.cs +++ b/tests/MessagePack.SourceGenerator.Tests/Resources/GenericsOfTFormatter/Formatters.TempProject.MyObjectFormatter.g.cs @@ -2,6 +2,8 @@ #pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 +#pragma warning disable CS8669 // We may leak nullable annotations into generated code. + namespace Formatters.TempProject { using MsgPack = global::MessagePack; diff --git a/tests/MessagePack.SourceGenerator.Tests/Resources/GenericsOfTFormatter/Formatters.TempProject.MyObjectNestedFormatter.g.cs b/tests/MessagePack.SourceGenerator.Tests/Resources/GenericsOfTFormatter/Formatters.TempProject.MyObjectNestedFormatter.g.cs index 2589b533c..04e86d4ad 100644 --- a/tests/MessagePack.SourceGenerator.Tests/Resources/GenericsOfTFormatter/Formatters.TempProject.MyObjectNestedFormatter.g.cs +++ b/tests/MessagePack.SourceGenerator.Tests/Resources/GenericsOfTFormatter/Formatters.TempProject.MyObjectNestedFormatter.g.cs @@ -2,6 +2,8 @@ #pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 +#pragma warning disable CS8669 // We may leak nullable annotations into generated code. + namespace Formatters.TempProject { using MsgPack = global::MessagePack; diff --git a/tests/MessagePack.SourceGenerator.Tests/Resources/GenericsOfTFormatter_FormatterOnly/Formatters.TempProject.MyGenericObjectFormatter_T_.g.cs b/tests/MessagePack.SourceGenerator.Tests/Resources/GenericsOfTFormatter_FormatterOnly/Formatters.TempProject.MyGenericObjectFormatter_T_.g.cs index 0c6c03f50..44538b8ef 100644 --- a/tests/MessagePack.SourceGenerator.Tests/Resources/GenericsOfTFormatter_FormatterOnly/Formatters.TempProject.MyGenericObjectFormatter_T_.g.cs +++ b/tests/MessagePack.SourceGenerator.Tests/Resources/GenericsOfTFormatter_FormatterOnly/Formatters.TempProject.MyGenericObjectFormatter_T_.g.cs @@ -2,6 +2,8 @@ #pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 +#pragma warning disable CS8669 // We may leak nullable annotations into generated code. + namespace Formatters.TempProject { using MsgPack = global::MessagePack; diff --git a/tests/MessagePack.SourceGenerator.Tests/Resources/GenericsOfTFormatter_WithKnownTypes/Formatters.TempProject.MyGenericObjectFormatter_T_.g.cs b/tests/MessagePack.SourceGenerator.Tests/Resources/GenericsOfTFormatter_WithKnownTypes/Formatters.TempProject.MyGenericObjectFormatter_T_.g.cs index db81f0058..66352ecc0 100644 --- a/tests/MessagePack.SourceGenerator.Tests/Resources/GenericsOfTFormatter_WithKnownTypes/Formatters.TempProject.MyGenericObjectFormatter_T_.g.cs +++ b/tests/MessagePack.SourceGenerator.Tests/Resources/GenericsOfTFormatter_WithKnownTypes/Formatters.TempProject.MyGenericObjectFormatter_T_.g.cs @@ -2,6 +2,8 @@ #pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 +#pragma warning disable CS8669 // We may leak nullable annotations into generated code. + namespace Formatters.TempProject { using MsgPack = global::MessagePack; diff --git a/tests/MessagePack.SourceGenerator.Tests/Resources/GenericsOfTFormatter_WithKnownTypes/Formatters.TempProject.MyObject2Formatter.g.cs b/tests/MessagePack.SourceGenerator.Tests/Resources/GenericsOfTFormatter_WithKnownTypes/Formatters.TempProject.MyObject2Formatter.g.cs index 1b380326a..dec176dee 100644 --- a/tests/MessagePack.SourceGenerator.Tests/Resources/GenericsOfTFormatter_WithKnownTypes/Formatters.TempProject.MyObject2Formatter.g.cs +++ b/tests/MessagePack.SourceGenerator.Tests/Resources/GenericsOfTFormatter_WithKnownTypes/Formatters.TempProject.MyObject2Formatter.g.cs @@ -2,6 +2,8 @@ #pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 +#pragma warning disable CS8669 // We may leak nullable annotations into generated code. + namespace Formatters.TempProject { using MsgPack = global::MessagePack; diff --git a/tests/MessagePack.SourceGenerator.Tests/Resources/GenericsOfTFormatter_WithKnownTypes/Formatters.TempProject.MyObjectFormatter.g.cs b/tests/MessagePack.SourceGenerator.Tests/Resources/GenericsOfTFormatter_WithKnownTypes/Formatters.TempProject.MyObjectFormatter.g.cs index 0199bf628..d45242836 100644 --- a/tests/MessagePack.SourceGenerator.Tests/Resources/GenericsOfTFormatter_WithKnownTypes/Formatters.TempProject.MyObjectFormatter.g.cs +++ b/tests/MessagePack.SourceGenerator.Tests/Resources/GenericsOfTFormatter_WithKnownTypes/Formatters.TempProject.MyObjectFormatter.g.cs @@ -2,6 +2,8 @@ #pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 +#pragma warning disable CS8669 // We may leak nullable annotations into generated code. + namespace Formatters.TempProject { using MsgPack = global::MessagePack; diff --git a/tests/MessagePack.SourceGenerator.Tests/Resources/GenericsUnionFormatter/Formatters.TempProject.WrapperFormatter_T_.g.cs b/tests/MessagePack.SourceGenerator.Tests/Resources/GenericsUnionFormatter/Formatters.TempProject.WrapperFormatter_T_.g.cs index af008ec5c..d384c2402 100644 --- a/tests/MessagePack.SourceGenerator.Tests/Resources/GenericsUnionFormatter/Formatters.TempProject.WrapperFormatter_T_.g.cs +++ b/tests/MessagePack.SourceGenerator.Tests/Resources/GenericsUnionFormatter/Formatters.TempProject.WrapperFormatter_T_.g.cs @@ -2,6 +2,8 @@ #pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 +#pragma warning disable CS8669 // We may leak nullable annotations into generated code. + namespace Formatters.TempProject { using MsgPack = global::MessagePack; diff --git a/tests/MessagePack.SourceGenerator.Tests/Resources/GenericsUnionFormatter_Nested/Formatters.TempProject.MyGenericObjectFormatter_T_.g.cs b/tests/MessagePack.SourceGenerator.Tests/Resources/GenericsUnionFormatter_Nested/Formatters.TempProject.MyGenericObjectFormatter_T_.g.cs index 7c6ce378f..7317ec98a 100644 --- a/tests/MessagePack.SourceGenerator.Tests/Resources/GenericsUnionFormatter_Nested/Formatters.TempProject.MyGenericObjectFormatter_T_.g.cs +++ b/tests/MessagePack.SourceGenerator.Tests/Resources/GenericsUnionFormatter_Nested/Formatters.TempProject.MyGenericObjectFormatter_T_.g.cs @@ -2,6 +2,8 @@ #pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 +#pragma warning disable CS8669 // We may leak nullable annotations into generated code. + namespace Formatters.TempProject { using MsgPack = global::MessagePack; diff --git a/tests/MessagePack.SourceGenerator.Tests/Resources/GenericsUnionFormatter_Nested/Formatters.TempProject.MyInnerGenericObjectFormatter_T_.g.cs b/tests/MessagePack.SourceGenerator.Tests/Resources/GenericsUnionFormatter_Nested/Formatters.TempProject.MyInnerGenericObjectFormatter_T_.g.cs index 0fc28a2b0..e6891d482 100644 --- a/tests/MessagePack.SourceGenerator.Tests/Resources/GenericsUnionFormatter_Nested/Formatters.TempProject.MyInnerGenericObjectFormatter_T_.g.cs +++ b/tests/MessagePack.SourceGenerator.Tests/Resources/GenericsUnionFormatter_Nested/Formatters.TempProject.MyInnerGenericObjectFormatter_T_.g.cs @@ -2,6 +2,8 @@ #pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 +#pragma warning disable CS8669 // We may leak nullable annotations into generated code. + namespace Formatters.TempProject { using MsgPack = global::MessagePack; diff --git a/tests/MessagePack.SourceGenerator.Tests/Resources/GenericsUnionFormatter_Nested/Formatters.TempProject.WrapperFormatter_T_.g.cs b/tests/MessagePack.SourceGenerator.Tests/Resources/GenericsUnionFormatter_Nested/Formatters.TempProject.WrapperFormatter_T_.g.cs index 900f7ec45..08b80f746 100644 --- a/tests/MessagePack.SourceGenerator.Tests/Resources/GenericsUnionFormatter_Nested/Formatters.TempProject.WrapperFormatter_T_.g.cs +++ b/tests/MessagePack.SourceGenerator.Tests/Resources/GenericsUnionFormatter_Nested/Formatters.TempProject.WrapperFormatter_T_.g.cs @@ -2,6 +2,8 @@ #pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 +#pragma warning disable CS8669 // We may leak nullable annotations into generated code. + namespace Formatters.TempProject { using MsgPack = global::MessagePack; diff --git a/tests/MessagePack.SourceGenerator.Tests/Resources/Generics_Constraints_Multiple/Formatters.TempProject.MyGenericObjectFormatter_T1, T2, T3, T4_.g.cs b/tests/MessagePack.SourceGenerator.Tests/Resources/Generics_Constraints_Multiple/Formatters.TempProject.MyGenericObjectFormatter_T1, T2, T3, T4_.g.cs index c5bedd308..c74f61513 100644 --- a/tests/MessagePack.SourceGenerator.Tests/Resources/Generics_Constraints_Multiple/Formatters.TempProject.MyGenericObjectFormatter_T1, T2, T3, T4_.g.cs +++ b/tests/MessagePack.SourceGenerator.Tests/Resources/Generics_Constraints_Multiple/Formatters.TempProject.MyGenericObjectFormatter_T1, T2, T3, T4_.g.cs @@ -2,6 +2,8 @@ #pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 +#pragma warning disable CS8669 // We may leak nullable annotations into generated code. + namespace Formatters.TempProject { using MsgPack = global::MessagePack; diff --git a/tests/MessagePack.SourceGenerator.Tests/Resources/Generics_Constraints_NullableReferenceType/Formatters.TempProject.MyGenericObjectFormatter_T1, T2, T3, T4_.g.cs b/tests/MessagePack.SourceGenerator.Tests/Resources/Generics_Constraints_NullableReferenceType/Formatters.TempProject.MyGenericObjectFormatter_T1, T2, T3, T4_.g.cs index a56f4d6e5..bd6c8fca9 100644 --- a/tests/MessagePack.SourceGenerator.Tests/Resources/Generics_Constraints_NullableReferenceType/Formatters.TempProject.MyGenericObjectFormatter_T1, T2, T3, T4_.g.cs +++ b/tests/MessagePack.SourceGenerator.Tests/Resources/Generics_Constraints_NullableReferenceType/Formatters.TempProject.MyGenericObjectFormatter_T1, T2, T3, T4_.g.cs @@ -2,6 +2,8 @@ #pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 +#pragma warning disable CS8669 // We may leak nullable annotations into generated code. + namespace Formatters.TempProject { using MsgPack = global::MessagePack; diff --git a/tests/MessagePack.SourceGenerator.Tests/Resources/Generics_Constraints_ReferenceType_Nullable/Formatters.TempProject.MyGenericObjectFormatter_T1, T2_.g.cs b/tests/MessagePack.SourceGenerator.Tests/Resources/Generics_Constraints_ReferenceType_Nullable/Formatters.TempProject.MyGenericObjectFormatter_T1, T2_.g.cs index e5ac4d4fc..b279b626c 100644 --- a/tests/MessagePack.SourceGenerator.Tests/Resources/Generics_Constraints_ReferenceType_Nullable/Formatters.TempProject.MyGenericObjectFormatter_T1, T2_.g.cs +++ b/tests/MessagePack.SourceGenerator.Tests/Resources/Generics_Constraints_ReferenceType_Nullable/Formatters.TempProject.MyGenericObjectFormatter_T1, T2_.g.cs @@ -2,6 +2,8 @@ #pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 +#pragma warning disable CS8669 // We may leak nullable annotations into generated code. + namespace Formatters.TempProject { using MsgPack = global::MessagePack; diff --git a/tests/MessagePack.SourceGenerator.Tests/Resources/Generics_Constraints_Struct/Formatters.TempProject.MyGenericObjectFormatter_T_.g.cs b/tests/MessagePack.SourceGenerator.Tests/Resources/Generics_Constraints_Struct/Formatters.TempProject.MyGenericObjectFormatter_T_.g.cs index 2766f17a6..cd388f235 100644 --- a/tests/MessagePack.SourceGenerator.Tests/Resources/Generics_Constraints_Struct/Formatters.TempProject.MyGenericObjectFormatter_T_.g.cs +++ b/tests/MessagePack.SourceGenerator.Tests/Resources/Generics_Constraints_Struct/Formatters.TempProject.MyGenericObjectFormatter_T_.g.cs @@ -2,6 +2,8 @@ #pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 +#pragma warning disable CS8669 // We may leak nullable annotations into generated code. + namespace Formatters.TempProject { using MsgPack = global::MessagePack; diff --git a/tests/MessagePack.SourceGenerator.Tests/Resources/Generics_Constraints_Type/Formatters.TempProject.MyGenericObjectFormatter_T_.g.cs b/tests/MessagePack.SourceGenerator.Tests/Resources/Generics_Constraints_Type/Formatters.TempProject.MyGenericObjectFormatter_T_.g.cs index 6372a561f..59d68da70 100644 --- a/tests/MessagePack.SourceGenerator.Tests/Resources/Generics_Constraints_Type/Formatters.TempProject.MyGenericObjectFormatter_T_.g.cs +++ b/tests/MessagePack.SourceGenerator.Tests/Resources/Generics_Constraints_Type/Formatters.TempProject.MyGenericObjectFormatter_T_.g.cs @@ -2,6 +2,8 @@ #pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 +#pragma warning disable CS8669 // We may leak nullable annotations into generated code. + namespace Formatters.TempProject { using MsgPack = global::MessagePack; diff --git a/tests/MessagePack.SourceGenerator.Tests/Resources/Generics_Defined_In_ReferencedProject/Formatters.TempProject.MyGenericObjectFormatter_T_.g.cs b/tests/MessagePack.SourceGenerator.Tests/Resources/Generics_Defined_In_ReferencedProject/Formatters.TempProject.MyGenericObjectFormatter_T_.g.cs new file mode 100644 index 000000000..44538b8ef --- /dev/null +++ b/tests/MessagePack.SourceGenerator.Tests/Resources/Generics_Defined_In_ReferencedProject/Formatters.TempProject.MyGenericObjectFormatter_T_.g.cs @@ -0,0 +1,56 @@ +// + +#pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 + +#pragma warning disable CS8669 // We may leak nullable annotations into generated code. + +namespace Formatters.TempProject +{ + using MsgPack = global::MessagePack; + + internal sealed class MyGenericObjectFormatter : MsgPack::Formatters.IMessagePackFormatter> + { + + public void Serialize(ref MsgPack::MessagePackWriter writer, global::TempProject.MyGenericObject value, MsgPack::MessagePackSerializerOptions options) + { + if (value == null) + { + writer.WriteNil(); + return; + } + + MsgPack::IFormatterResolver formatterResolver = options.Resolver; + writer.WriteArrayHeader(1); + MsgPack::FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Serialize(ref writer, value.Content, options); + } + + public global::TempProject.MyGenericObject Deserialize(ref MsgPack::MessagePackReader reader, MsgPack::MessagePackSerializerOptions options) + { + if (reader.TryReadNil()) + { + return null; + } + + options.Security.DepthStep(ref reader); + MsgPack::IFormatterResolver formatterResolver = options.Resolver; + var length = reader.ReadArrayHeader(); + var ____result = new global::TempProject.MyGenericObject(); + + for (int i = 0; i < length; i++) + { + switch (i) + { + case 0: + ____result.Content = MsgPack::FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Deserialize(ref reader, options); + break; + default: + reader.Skip(); + break; + } + } + + reader.Depth--; + return ____result; + } + } +} diff --git a/tests/MessagePack.SourceGenerator.Tests/Resources/Generics_Defined_In_ReferencedProject/Formatters.TempProject.MyObjectFormatter.g.cs b/tests/MessagePack.SourceGenerator.Tests/Resources/Generics_Defined_In_ReferencedProject/Formatters.TempProject.MyObjectFormatter.g.cs index d1e3f850d..412999b1a 100644 --- a/tests/MessagePack.SourceGenerator.Tests/Resources/Generics_Defined_In_ReferencedProject/Formatters.TempProject.MyObjectFormatter.g.cs +++ b/tests/MessagePack.SourceGenerator.Tests/Resources/Generics_Defined_In_ReferencedProject/Formatters.TempProject.MyObjectFormatter.g.cs @@ -2,6 +2,8 @@ #pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 +#pragma warning disable CS8669 // We may leak nullable annotations into generated code. + namespace Formatters.TempProject { using MsgPack = global::MessagePack; diff --git a/tests/MessagePack.SourceGenerator.Tests/Resources/Generics_Defined_In_ReferencedProject/Formatters.TempProject.MyObjectNestedFormatter.g.cs b/tests/MessagePack.SourceGenerator.Tests/Resources/Generics_Defined_In_ReferencedProject/Formatters.TempProject.MyObjectNestedFormatter.g.cs index 2589b533c..04e86d4ad 100644 --- a/tests/MessagePack.SourceGenerator.Tests/Resources/Generics_Defined_In_ReferencedProject/Formatters.TempProject.MyObjectNestedFormatter.g.cs +++ b/tests/MessagePack.SourceGenerator.Tests/Resources/Generics_Defined_In_ReferencedProject/Formatters.TempProject.MyObjectNestedFormatter.g.cs @@ -2,6 +2,8 @@ #pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 +#pragma warning disable CS8669 // We may leak nullable annotations into generated code. + namespace Formatters.TempProject { using MsgPack = global::MessagePack; diff --git a/tests/MessagePack.SourceGenerator.Tests/Resources/Generics_Defined_In_ReferencedProject/MessagePack.GeneratedMessagePackResolver.g.cs b/tests/MessagePack.SourceGenerator.Tests/Resources/Generics_Defined_In_ReferencedProject/MessagePack.GeneratedMessagePackResolver.g.cs index 059e46fd0..e5a757c0b 100644 --- a/tests/MessagePack.SourceGenerator.Tests/Resources/Generics_Defined_In_ReferencedProject/MessagePack.GeneratedMessagePackResolver.g.cs +++ b/tests/MessagePack.SourceGenerator.Tests/Resources/Generics_Defined_In_ReferencedProject/MessagePack.GeneratedMessagePackResolver.g.cs @@ -46,12 +46,8 @@ internal static class GeneratedMessagePackResolverGetFormatterHelper static GeneratedMessagePackResolverGetFormatterHelper() { - lookup = new global::System.Collections.Generic.Dictionary(4) + lookup = new global::System.Collections.Generic.Dictionary(0) { - { typeof(global::TempProject.MyGenericObject>), 0 }, - { typeof(global::TempProject.MyGenericObject), 1 }, - { typeof(global::TempProject.MyObject), 2 }, - { typeof(global::TempProject.MyObjectNested), 3 }, }; } @@ -65,10 +61,6 @@ internal static object GetFormatter(global::System.Type t) switch (key) { - case 0: return new Formatters::TempProject.MyGenericObjectFormatter>(); - case 1: return new Formatters::TempProject.MyGenericObjectFormatter(); - case 2: return new Formatters::TempProject.MyObjectFormatter(); - case 3: return new Formatters::TempProject.MyObjectNestedFormatter(); default: return null; } } diff --git a/tests/MessagePack.SourceGenerator.Tests/Resources/NestedGenericTypes/Formatters.TempProject.MyGenericObjectFormatter_T_.g.cs b/tests/MessagePack.SourceGenerator.Tests/Resources/NestedGenericTypes/Formatters.TempProject.MyGenericObjectFormatter_T_.g.cs index c1799f8d1..39de6210c 100644 --- a/tests/MessagePack.SourceGenerator.Tests/Resources/NestedGenericTypes/Formatters.TempProject.MyGenericObjectFormatter_T_.g.cs +++ b/tests/MessagePack.SourceGenerator.Tests/Resources/NestedGenericTypes/Formatters.TempProject.MyGenericObjectFormatter_T_.g.cs @@ -2,6 +2,8 @@ #pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 +#pragma warning disable CS8669 // We may leak nullable annotations into generated code. + namespace Formatters.TempProject { using MsgPack = global::MessagePack; diff --git a/tests/MessagePack.SourceGenerator.Tests/Resources/NestedGenericTypes/Formatters.TempProject.MyInnerGenericObjectFormatter_T_.g.cs b/tests/MessagePack.SourceGenerator.Tests/Resources/NestedGenericTypes/Formatters.TempProject.MyInnerGenericObjectFormatter_T_.g.cs index 0fc28a2b0..e6891d482 100644 --- a/tests/MessagePack.SourceGenerator.Tests/Resources/NestedGenericTypes/Formatters.TempProject.MyInnerGenericObjectFormatter_T_.g.cs +++ b/tests/MessagePack.SourceGenerator.Tests/Resources/NestedGenericTypes/Formatters.TempProject.MyInnerGenericObjectFormatter_T_.g.cs @@ -2,6 +2,8 @@ #pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 +#pragma warning disable CS8669 // We may leak nullable annotations into generated code. + namespace Formatters.TempProject { using MsgPack = global::MessagePack; diff --git a/tests/MessagePack.SourceGenerator.Tests/Resources/NestedGenericTypes/Formatters.TempProject.MyObject2Formatter.g.cs b/tests/MessagePack.SourceGenerator.Tests/Resources/NestedGenericTypes/Formatters.TempProject.MyObject2Formatter.g.cs index 1b380326a..dec176dee 100644 --- a/tests/MessagePack.SourceGenerator.Tests/Resources/NestedGenericTypes/Formatters.TempProject.MyObject2Formatter.g.cs +++ b/tests/MessagePack.SourceGenerator.Tests/Resources/NestedGenericTypes/Formatters.TempProject.MyObject2Formatter.g.cs @@ -2,6 +2,8 @@ #pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 +#pragma warning disable CS8669 // We may leak nullable annotations into generated code. + namespace Formatters.TempProject { using MsgPack = global::MessagePack; diff --git a/tests/MessagePack.SourceGenerator.Tests/Resources/NestedGenericTypes/Formatters.TempProject.MyObjectFormatter.g.cs b/tests/MessagePack.SourceGenerator.Tests/Resources/NestedGenericTypes/Formatters.TempProject.MyObjectFormatter.g.cs index 8ef0f2ea2..100b53da3 100644 --- a/tests/MessagePack.SourceGenerator.Tests/Resources/NestedGenericTypes/Formatters.TempProject.MyObjectFormatter.g.cs +++ b/tests/MessagePack.SourceGenerator.Tests/Resources/NestedGenericTypes/Formatters.TempProject.MyObjectFormatter.g.cs @@ -2,6 +2,8 @@ #pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 +#pragma warning disable CS8669 // We may leak nullable annotations into generated code. + namespace Formatters.TempProject { using MsgPack = global::MessagePack; diff --git a/tests/MessagePack.SourceGenerator.Tests/Resources/NestedGenericTypes/Formatters.TempProject.WrapperFormatter_T_.g.cs b/tests/MessagePack.SourceGenerator.Tests/Resources/NestedGenericTypes/Formatters.TempProject.WrapperFormatter_T_.g.cs index 900f7ec45..08b80f746 100644 --- a/tests/MessagePack.SourceGenerator.Tests/Resources/NestedGenericTypes/Formatters.TempProject.WrapperFormatter_T_.g.cs +++ b/tests/MessagePack.SourceGenerator.Tests/Resources/NestedGenericTypes/Formatters.TempProject.WrapperFormatter_T_.g.cs @@ -2,6 +2,8 @@ #pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 +#pragma warning disable CS8669 // We may leak nullable annotations into generated code. + namespace Formatters.TempProject { using MsgPack = global::MessagePack; diff --git a/tests/MessagePack.SourceGenerator.Tests/Resources/NullableFormatter/Formatters.TempProject.MyObjectFormatter.g.cs b/tests/MessagePack.SourceGenerator.Tests/Resources/NullableFormatter/Formatters.TempProject.MyObjectFormatter.g.cs index b3d337ecd..c1f2d3a05 100644 --- a/tests/MessagePack.SourceGenerator.Tests/Resources/NullableFormatter/Formatters.TempProject.MyObjectFormatter.g.cs +++ b/tests/MessagePack.SourceGenerator.Tests/Resources/NullableFormatter/Formatters.TempProject.MyObjectFormatter.g.cs @@ -2,6 +2,8 @@ #pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 +#pragma warning disable CS8669 // We may leak nullable annotations into generated code. + namespace Formatters.TempProject { using MsgPack = global::MessagePack; diff --git a/tests/MessagePack.SourceGenerator.Tests/Resources/TwoTypes(False)/Formatters.Object1Formatter.g.cs b/tests/MessagePack.SourceGenerator.Tests/Resources/TwoTypes(False)/Formatters.Object1Formatter.g.cs index 385db3fc4..65ab0b6df 100644 --- a/tests/MessagePack.SourceGenerator.Tests/Resources/TwoTypes(False)/Formatters.Object1Formatter.g.cs +++ b/tests/MessagePack.SourceGenerator.Tests/Resources/TwoTypes(False)/Formatters.Object1Formatter.g.cs @@ -2,6 +2,8 @@ #pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 +#pragma warning disable CS8669 // We may leak nullable annotations into generated code. + namespace Formatters { using MsgPack = global::MessagePack; diff --git a/tests/MessagePack.SourceGenerator.Tests/Resources/TwoTypes(False)/Formatters.Object2Formatter.g.cs b/tests/MessagePack.SourceGenerator.Tests/Resources/TwoTypes(False)/Formatters.Object2Formatter.g.cs index 86061d386..a5fa502a6 100644 --- a/tests/MessagePack.SourceGenerator.Tests/Resources/TwoTypes(False)/Formatters.Object2Formatter.g.cs +++ b/tests/MessagePack.SourceGenerator.Tests/Resources/TwoTypes(False)/Formatters.Object2Formatter.g.cs @@ -2,6 +2,8 @@ #pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 +#pragma warning disable CS8669 // We may leak nullable annotations into generated code. + namespace Formatters { using MsgPack = global::MessagePack; diff --git a/tests/MessagePack.SourceGenerator.Tests/Resources/UnionFormatter(Namespace)/Formatters.MyTestNamespace.Derived1Formatter.g.cs b/tests/MessagePack.SourceGenerator.Tests/Resources/UnionFormatter(Namespace)/Formatters.MyTestNamespace.Derived1Formatter.g.cs index 9f6ec3997..eca72171e 100644 --- a/tests/MessagePack.SourceGenerator.Tests/Resources/UnionFormatter(Namespace)/Formatters.MyTestNamespace.Derived1Formatter.g.cs +++ b/tests/MessagePack.SourceGenerator.Tests/Resources/UnionFormatter(Namespace)/Formatters.MyTestNamespace.Derived1Formatter.g.cs @@ -2,6 +2,8 @@ #pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 +#pragma warning disable CS8669 // We may leak nullable annotations into generated code. + namespace Formatters.MyTestNamespace { using MsgPack = global::MessagePack; diff --git a/tests/MessagePack.SourceGenerator.Tests/Resources/UnionFormatter(Namespace)/Formatters.MyTestNamespace.Derived2Formatter.g.cs b/tests/MessagePack.SourceGenerator.Tests/Resources/UnionFormatter(Namespace)/Formatters.MyTestNamespace.Derived2Formatter.g.cs index d352bddaa..1d603f664 100644 --- a/tests/MessagePack.SourceGenerator.Tests/Resources/UnionFormatter(Namespace)/Formatters.MyTestNamespace.Derived2Formatter.g.cs +++ b/tests/MessagePack.SourceGenerator.Tests/Resources/UnionFormatter(Namespace)/Formatters.MyTestNamespace.Derived2Formatter.g.cs @@ -2,6 +2,8 @@ #pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 +#pragma warning disable CS8669 // We may leak nullable annotations into generated code. + namespace Formatters.MyTestNamespace { using MsgPack = global::MessagePack; diff --git a/tests/MessagePack.SourceGenerator.Tests/Resources/UnionFormatter(Namespace)/Formatters.MyTestNamespace.MyMessagePackObjectFormatter.g.cs b/tests/MessagePack.SourceGenerator.Tests/Resources/UnionFormatter(Namespace)/Formatters.MyTestNamespace.MyMessagePackObjectFormatter.g.cs index 2599523bf..d7865ca98 100644 --- a/tests/MessagePack.SourceGenerator.Tests/Resources/UnionFormatter(Namespace)/Formatters.MyTestNamespace.MyMessagePackObjectFormatter.g.cs +++ b/tests/MessagePack.SourceGenerator.Tests/Resources/UnionFormatter(Namespace)/Formatters.MyTestNamespace.MyMessagePackObjectFormatter.g.cs @@ -2,6 +2,8 @@ #pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 +#pragma warning disable CS8669 // We may leak nullable annotations into generated code. + namespace Formatters.MyTestNamespace { using MsgPack = global::MessagePack; diff --git a/tests/MessagePack.SourceGenerator.Tests/Resources/UnionFormatter(NestingClass)/Formatters.ContainingClass_Derived1Formatter.g.cs b/tests/MessagePack.SourceGenerator.Tests/Resources/UnionFormatter(NestingClass)/Formatters.ContainingClass_Derived1Formatter.g.cs index ea3ee42d9..1c72ff2c3 100644 --- a/tests/MessagePack.SourceGenerator.Tests/Resources/UnionFormatter(NestingClass)/Formatters.ContainingClass_Derived1Formatter.g.cs +++ b/tests/MessagePack.SourceGenerator.Tests/Resources/UnionFormatter(NestingClass)/Formatters.ContainingClass_Derived1Formatter.g.cs @@ -2,6 +2,8 @@ #pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 +#pragma warning disable CS8669 // We may leak nullable annotations into generated code. + namespace Formatters { using MsgPack = global::MessagePack; diff --git a/tests/MessagePack.SourceGenerator.Tests/Resources/UnionFormatter(NestingClass)/Formatters.ContainingClass_Derived2Formatter.g.cs b/tests/MessagePack.SourceGenerator.Tests/Resources/UnionFormatter(NestingClass)/Formatters.ContainingClass_Derived2Formatter.g.cs index 155680fea..6b1597abf 100644 --- a/tests/MessagePack.SourceGenerator.Tests/Resources/UnionFormatter(NestingClass)/Formatters.ContainingClass_Derived2Formatter.g.cs +++ b/tests/MessagePack.SourceGenerator.Tests/Resources/UnionFormatter(NestingClass)/Formatters.ContainingClass_Derived2Formatter.g.cs @@ -2,6 +2,8 @@ #pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 +#pragma warning disable CS8669 // We may leak nullable annotations into generated code. + namespace Formatters { using MsgPack = global::MessagePack; diff --git a/tests/MessagePack.SourceGenerator.Tests/Resources/UnionFormatter(NestingClass)/Formatters.ContainingClass_MyMessagePackObjectFormatter.g.cs b/tests/MessagePack.SourceGenerator.Tests/Resources/UnionFormatter(NestingClass)/Formatters.ContainingClass_MyMessagePackObjectFormatter.g.cs index 86965a9cf..453e17868 100644 --- a/tests/MessagePack.SourceGenerator.Tests/Resources/UnionFormatter(NestingClass)/Formatters.ContainingClass_MyMessagePackObjectFormatter.g.cs +++ b/tests/MessagePack.SourceGenerator.Tests/Resources/UnionFormatter(NestingClass)/Formatters.ContainingClass_MyMessagePackObjectFormatter.g.cs @@ -2,6 +2,8 @@ #pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 +#pragma warning disable CS8669 // We may leak nullable annotations into generated code. + namespace Formatters { using MsgPack = global::MessagePack; diff --git a/tests/MessagePack.SourceGenerator.Tests/Resources/UnionFormatter(None)/Formatters.Derived1Formatter.g.cs b/tests/MessagePack.SourceGenerator.Tests/Resources/UnionFormatter(None)/Formatters.Derived1Formatter.g.cs index 081056c25..6643d2aa3 100644 --- a/tests/MessagePack.SourceGenerator.Tests/Resources/UnionFormatter(None)/Formatters.Derived1Formatter.g.cs +++ b/tests/MessagePack.SourceGenerator.Tests/Resources/UnionFormatter(None)/Formatters.Derived1Formatter.g.cs @@ -2,6 +2,8 @@ #pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 +#pragma warning disable CS8669 // We may leak nullable annotations into generated code. + namespace Formatters { using MsgPack = global::MessagePack; diff --git a/tests/MessagePack.SourceGenerator.Tests/Resources/UnionFormatter(None)/Formatters.Derived2Formatter.g.cs b/tests/MessagePack.SourceGenerator.Tests/Resources/UnionFormatter(None)/Formatters.Derived2Formatter.g.cs index d5e4cf09d..628b46f02 100644 --- a/tests/MessagePack.SourceGenerator.Tests/Resources/UnionFormatter(None)/Formatters.Derived2Formatter.g.cs +++ b/tests/MessagePack.SourceGenerator.Tests/Resources/UnionFormatter(None)/Formatters.Derived2Formatter.g.cs @@ -2,6 +2,8 @@ #pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 +#pragma warning disable CS8669 // We may leak nullable annotations into generated code. + namespace Formatters { using MsgPack = global::MessagePack; diff --git a/tests/MessagePack.SourceGenerator.Tests/Resources/UnionFormatter(None)/Formatters.MyMessagePackObjectFormatter.g.cs b/tests/MessagePack.SourceGenerator.Tests/Resources/UnionFormatter(None)/Formatters.MyMessagePackObjectFormatter.g.cs index e2e339afe..14f27b866 100644 --- a/tests/MessagePack.SourceGenerator.Tests/Resources/UnionFormatter(None)/Formatters.MyMessagePackObjectFormatter.g.cs +++ b/tests/MessagePack.SourceGenerator.Tests/Resources/UnionFormatter(None)/Formatters.MyMessagePackObjectFormatter.g.cs @@ -2,6 +2,8 @@ #pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 +#pragma warning disable CS8669 // We may leak nullable annotations into generated code. + namespace Formatters { using MsgPack = global::MessagePack; diff --git a/tests/MessagePack.SourceGenerator.Tests/Resources/WellKnownGenericsFormatter/Formatters.TempProject.MyObjectFormatter.g.cs b/tests/MessagePack.SourceGenerator.Tests/Resources/WellKnownGenericsFormatter/Formatters.TempProject.MyObjectFormatter.g.cs index a39e9ea47..629f69c03 100644 --- a/tests/MessagePack.SourceGenerator.Tests/Resources/WellKnownGenericsFormatter/Formatters.TempProject.MyObjectFormatter.g.cs +++ b/tests/MessagePack.SourceGenerator.Tests/Resources/WellKnownGenericsFormatter/Formatters.TempProject.MyObjectFormatter.g.cs @@ -2,6 +2,8 @@ #pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 +#pragma warning disable CS8669 // We may leak nullable annotations into generated code. + namespace Formatters.TempProject { using MsgPack = global::MessagePack; From 72d1aebbcb769625f283adbd030df10781179183 Mon Sep 17 00:00:00 2001 From: y-sasaki <11359025+Y-YoL@users.noreply.github.com> Date: Wed, 12 Apr 2023 22:25:56 +0900 Subject: [PATCH 094/660] Fix compile error in Unity --- .../Assets/Scripts/MessagePack/Resolvers/StandardResolver.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Resolvers/StandardResolver.cs b/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Resolvers/StandardResolver.cs index 6beb2271f..91d794d8f 100644 --- a/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Resolvers/StandardResolver.cs +++ b/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Resolvers/StandardResolver.cs @@ -107,8 +107,9 @@ public static class StandardAotResolver AttributeFormatterResolver.Instance, // Try use [MessagePackFormatter] #if UNITY_2018_3_OR_NEWER MessagePack.Unity.UnityResolver.Instance, -#endif +#else ImmutableCollection.ImmutableCollectionResolver.Instance, +#endif }); } From de00d6be73f63c230cff7b84a77b3aafdf5ee3ba Mon Sep 17 00:00:00 2001 From: y-sasaki <11359025+Y-YoL@users.noreply.github.com> Date: Wed, 12 Apr 2023 23:24:41 +0900 Subject: [PATCH 095/660] Set nullable in unity The only important part is "additionalCompilerArguments", but there are many differences because Unity automatically migrates --- .gitignore | 1 + .../ProjectSettings/ProjectSettings.asset | 205 ++++++++++++------ 2 files changed, 137 insertions(+), 69 deletions(-) diff --git a/.gitignore b/.gitignore index 692107f29..b5cae3bc9 100644 --- a/.gitignore +++ b/.gitignore @@ -358,6 +358,7 @@ src/MessagePack.UnityClient/bin/* src/MessagePack.UnityClient/Library/* src/MessagePack.UnityClient/obj/* src/MessagePack.UnityClient/Temp/* +src/MessagePack.UnityClient/UserSettings/* # BenchmarkDotNet results BenchmarkDotNet.Artifacts/ diff --git a/src/MessagePack.UnityClient/ProjectSettings/ProjectSettings.asset b/src/MessagePack.UnityClient/ProjectSettings/ProjectSettings.asset index 4405bc44d..e8da29ffa 100644 --- a/src/MessagePack.UnityClient/ProjectSettings/ProjectSettings.asset +++ b/src/MessagePack.UnityClient/ProjectSettings/ProjectSettings.asset @@ -3,7 +3,7 @@ --- !u!129 &1 PlayerSettings: m_ObjectHideFlags: 0 - serializedVersion: 16 + serializedVersion: 23 productGUID: bacd30c5dbbe47048b83bac719532e2a AndroidProfiler: 0 AndroidFilterTouchesWhenObscured: 0 @@ -49,11 +49,12 @@ PlayerSettings: m_StereoRenderingPath: 0 m_ActiveColorSpace: 0 m_MTRendering: 1 + mipStripping: 0 + numberOfMipsStripped: 0 m_StackTraceTypes: 010000000100000001000000010000000100000001000000 iosShowActivityIndicatorOnLoading: -1 androidShowActivityIndicatorOnLoading: -1 - iosAppInBackgroundBehavior: 0 - displayResolutionDialog: 1 + iosUseCustomAppBackgroundBehavior: 0 iosAllowHTTPDownload: 1 allowedAutorotateToPortrait: 1 allowedAutorotateToPortraitUpsideDown: 1 @@ -65,7 +66,14 @@ PlayerSettings: disableDepthAndStencilBuffers: 0 androidStartInFullscreen: 1 androidRenderOutsideSafeArea: 0 + androidUseSwappy: 0 androidBlitType: 0 + androidResizableWindow: 0 + androidDefaultWindowWidth: 1920 + androidDefaultWindowHeight: 1080 + androidMinimumWindowWidth: 400 + androidMinimumWindowHeight: 300 + androidFullscreenMode: 1 defaultIsNativeResolution: 1 macRetinaSupport: 1 runInBackground: 1 @@ -84,7 +92,6 @@ PlayerSettings: useMacAppStoreValidation: 0 macAppStoreCategory: public.app-category.games gpuSkinning: 1 - graphicsJobs: 0 xboxPIXTextureCapture: 0 xboxEnableAvatar: 0 xboxEnableKinect: 0 @@ -92,7 +99,6 @@ PlayerSettings: xboxEnableFitness: 0 visibleInBackground: 1 allowFullscreenSwitch: 1 - graphicsJobMode: 0 fullscreenMode: 1 xboxSpeechDB: 0 xboxEnableHeadOrientation: 0 @@ -105,6 +111,7 @@ PlayerSettings: xboxOneMonoLoggingLevel: 0 xboxOneLoggingLevel: 1 xboxOneDisableEsram: 0 + xboxOneEnableTypeOptimization: 0 xboxOnePresentImmediateThreshold: 0 switchQueueCommandMemory: 0 switchQueueControlMemory: 16384 @@ -112,7 +119,15 @@ PlayerSettings: switchNVNShaderPoolsGranularity: 33554432 switchNVNDefaultPoolsGranularity: 16777216 switchNVNOtherPoolsGranularity: 16777216 + switchNVNMaxPublicTextureIDCount: 0 + switchNVNMaxPublicSamplerIDCount: 0 + stadiaPresentMode: 0 + stadiaTargetFramerate: 0 + vulkanNumSwapchainBuffers: 3 vulkanEnableSetSRGBWrite: 0 + vulkanEnablePreTransform: 0 + vulkanEnableLateAcquireNextImage: 0 + vulkanEnableCommandBufferRecycling: 1 m_SupportedAspectRatios: 4:3: 1 5:4: 1 @@ -127,42 +142,27 @@ PlayerSettings: xboxOneDisableKinectGpuReservation: 1 xboxOneEnable7thCore: 1 vrSettings: - cardboard: - depthFormat: 0 - enableTransitionView: 0 - daydream: - depthFormat: 0 - useSustainedPerformanceMode: 0 - enableVideoLayer: 0 - useProtectedVideoMemory: 0 - minimumSupportedHeadTracking: 0 - maximumSupportedHeadTracking: 1 - hololens: - depthFormat: 1 - depthBufferSharingEnabled: 1 - lumin: - depthFormat: 0 - frameTiming: 2 - enableGLCache: 0 - glCacheMaxBlobSize: 524288 - glCacheMaxFileSize: 8388608 - oculus: - sharedDepthBuffer: 1 - dashSupport: 1 enable360StereoCapture: 0 isWsaHolographicRemotingEnabled: 0 - protectGraphicsMemory: 0 enableFrameTimingStats: 0 + enableOpenGLProfilerGPURecorders: 1 useHDRDisplay: 0 + D3DHDRBitDepth: 0 m_ColorGamuts: 00000000 targetPixelDensity: 30 resolutionScalingMode: 0 + resetResolutionOnWindowResize: 0 androidSupportedAspectRatio: 1 androidMaxAspectRatio: 2.1 - applicationIdentifier: {} - buildNumber: {} + applicationIdentifier: + Standalone: com.DefaultCompany.MessagePack.UnityClient + buildNumber: + Standalone: 0 + iPhone: 0 + tvOS: 0 + overrideDefaultApplicationIdentifier: 0 AndroidBundleVersionCode: 1 - AndroidMinSdkVersion: 16 + AndroidMinSdkVersion: 22 AndroidTargetSdkVersion: 0 AndroidPreferredInstallLocation: 1 aotOptions: @@ -177,32 +177,16 @@ PlayerSettings: StripUnusedMeshComponents: 1 VertexChannelCompressionMask: 4054 iPhoneSdkVersion: 988 - iOSTargetOSVersionString: 9.0 + iOSTargetOSVersionString: 11.0 tvOSSdkVersion: 0 tvOSRequireExtendedGameController: 0 - tvOSTargetOSVersionString: 9.0 + tvOSTargetOSVersionString: 11.0 uIPrerenderedIcon: 0 uIRequiresPersistentWiFi: 0 uIRequiresFullScreen: 1 uIStatusBarHidden: 1 uIExitOnSuspend: 0 uIStatusBarStyle: 0 - iPhoneSplashScreen: {fileID: 0} - iPhoneHighResSplashScreen: {fileID: 0} - iPhoneTallHighResSplashScreen: {fileID: 0} - iPhone47inSplashScreen: {fileID: 0} - iPhone55inPortraitSplashScreen: {fileID: 0} - iPhone55inLandscapeSplashScreen: {fileID: 0} - iPhone58inPortraitSplashScreen: {fileID: 0} - iPhone58inLandscapeSplashScreen: {fileID: 0} - iPadPortraitSplashScreen: {fileID: 0} - iPadHighResPortraitSplashScreen: {fileID: 0} - iPadLandscapeSplashScreen: {fileID: 0} - iPadHighResLandscapeSplashScreen: {fileID: 0} - iPhone65inPortraitSplashScreen: {fileID: 0} - iPhone65inLandscapeSplashScreen: {fileID: 0} - iPhone61inPortraitSplashScreen: {fileID: 0} - iPhone61inLandscapeSplashScreen: {fileID: 0} appleTVSplashScreen: {fileID: 0} appleTVSplashScreen2x: {fileID: 0} tvOSSmallIconLayers: [] @@ -230,15 +214,17 @@ PlayerSettings: iOSLaunchScreeniPadFillPct: 100 iOSLaunchScreeniPadSize: 100 iOSLaunchScreeniPadCustomXibPath: - iOSUseLaunchScreenStoryboard: 0 iOSLaunchScreenCustomStoryboardPath: + iOSLaunchScreeniPadCustomStoryboardPath: iOSDeviceRequirements: [] iOSURLSchemes: [] + macOSURLSchemes: [] iOSBackgroundModes: 0 iOSMetalForceHardShadows: 0 metalEditorSupport: 1 metalAPIValidation: 1 iOSRenderExtraFrameOnPause: 0 + iosCopyPluginsCodeInsteadOfSymlink: 0 appleDeveloperTeamID: iOSManualSigningProvisioningProfileID: tvOSManualSigningProvisioningProfileID: @@ -248,10 +234,19 @@ PlayerSettings: iOSRequireARKit: 0 iOSAutomaticallyDetectAndAddCapabilities: 1 appleEnableProMotion: 0 + shaderPrecisionModel: 0 clonedFromGUID: c0afd0d1d80e3634a9dac47e8a0426ea templatePackageId: com.unity.template.3d@1.3.0 templateDefaultScene: Assets/Scenes/SampleScene.unity + useCustomMainManifest: 0 + useCustomLauncherManifest: 0 + useCustomMainGradleTemplate: 0 + useCustomLauncherGradleManifest: 0 + useCustomBaseGradleTemplate: 0 + useCustomGradlePropertiesTemplate: 0 + useCustomProguardFile: 0 AndroidTargetArchitectures: 5 + AndroidTargetDevices: 0 AndroidSplashScreenScale: 0 androidSplashScreen: {fileID: 0} AndroidKeystoreName: '{inproject}: ' @@ -268,7 +263,12 @@ PlayerSettings: height: 180 banner: {fileID: 0} androidGamepadSupportLevel: 0 - resolutionDialogBanner: {fileID: 0} + chromeosInputEmulation: 1 + AndroidMinifyWithR8: 0 + AndroidMinifyRelease: 0 + AndroidMinifyDebug: 0 + AndroidValidateAppBundleSize: 1 + AndroidAppBundleSizeToValidate: 150 m_BuildTargetIcons: [] m_BuildTargetPlatformIcons: [] m_BuildTargetBatching: @@ -287,16 +287,58 @@ PlayerSettings: - m_BuildTarget: WebGL m_StaticBatching: 0 m_DynamicBatching: 0 + m_BuildTargetGraphicsJobs: + - m_BuildTarget: WindowsStandaloneSupport + m_GraphicsJobs: 0 + - m_BuildTarget: MacStandaloneSupport + m_GraphicsJobs: 0 + - m_BuildTarget: LinuxStandaloneSupport + m_GraphicsJobs: 0 + - m_BuildTarget: AndroidPlayer + m_GraphicsJobs: 0 + - m_BuildTarget: iOSSupport + m_GraphicsJobs: 0 + - m_BuildTarget: PS4Player + m_GraphicsJobs: 0 + - m_BuildTarget: PS5Player + m_GraphicsJobs: 0 + - m_BuildTarget: XboxOnePlayer + m_GraphicsJobs: 0 + - m_BuildTarget: GameCoreXboxOneSupport + m_GraphicsJobs: 0 + - m_BuildTarget: GameCoreScarlettSupport + m_GraphicsJobs: 0 + - m_BuildTarget: Switch + m_GraphicsJobs: 0 + - m_BuildTarget: WebGLSupport + m_GraphicsJobs: 0 + - m_BuildTarget: MetroSupport + m_GraphicsJobs: 0 + - m_BuildTarget: AppleTVSupport + m_GraphicsJobs: 0 + - m_BuildTarget: BJMSupport + m_GraphicsJobs: 0 + - m_BuildTarget: LuminSupport + m_GraphicsJobs: 0 + - m_BuildTarget: CloudRendering + m_GraphicsJobs: 0 + - m_BuildTarget: EmbeddedLinux + m_GraphicsJobs: 0 + m_BuildTargetGraphicsJobMode: + - m_BuildTarget: PS4Player + m_GraphicsJobMode: 0 + - m_BuildTarget: XboxOnePlayer + m_GraphicsJobMode: 0 m_BuildTargetGraphicsAPIs: - m_BuildTarget: AndroidPlayer m_APIs: 0b00000008000000 - m_Automatic: 1 + m_Automatic: 0 - m_BuildTarget: iOSSupport m_APIs: 10000000 m_Automatic: 1 - m_BuildTarget: AppleTVSupport m_APIs: 10000000 - m_Automatic: 0 + m_Automatic: 1 - m_BuildTarget: WebGLSupport m_APIs: 0b000000 m_Automatic: 1 @@ -306,7 +348,6 @@ PlayerSettings: m_Devices: - Oculus - OpenVR - m_BuildTargetEnableVuforiaSettings: [] openGLRequireES31: 0 openGLRequireES31AEP: 0 openGLRequireES32: 0 @@ -317,6 +358,8 @@ PlayerSettings: tvOS: 1 m_BuildTargetGroupLightmapEncodingQuality: [] m_BuildTargetGroupLightmapSettings: [] + m_BuildTargetNormalMapEncoding: [] + m_BuildTargetDefaultTextureCompressionFormat: [] playModeTestRunnerEnabled: 0 runPlayModeTestAsEditModeTest: 0 actionOnDotNetUnhandledException: 1 @@ -326,12 +369,16 @@ PlayerSettings: cameraUsageDescription: locationUsageDescription: microphoneUsageDescription: + bluetoothUsageDescription: + switchNMETAOverride: switchNetLibKey: switchSocketMemoryPoolSize: 6144 switchSocketAllocatorPoolSize: 128 switchSocketConcurrencyLimit: 14 switchScreenResolutionBehavior: 2 switchUseCPUProfiler: 0 + switchUseGOLDLinker: 0 + switchLTOSetting: 0 switchApplicationID: 0x01004b9000490000 switchNSODependencies: switchTitleNames_0: @@ -349,6 +396,7 @@ PlayerSettings: switchTitleNames_12: switchTitleNames_13: switchTitleNames_14: + switchTitleNames_15: switchPublisherNames_0: switchPublisherNames_1: switchPublisherNames_2: @@ -364,6 +412,7 @@ PlayerSettings: switchPublisherNames_12: switchPublisherNames_13: switchPublisherNames_14: + switchPublisherNames_15: switchIcons_0: {fileID: 0} switchIcons_1: {fileID: 0} switchIcons_2: {fileID: 0} @@ -379,6 +428,7 @@ PlayerSettings: switchIcons_12: {fileID: 0} switchIcons_13: {fileID: 0} switchIcons_14: {fileID: 0} + switchIcons_15: {fileID: 0} switchSmallIcons_0: {fileID: 0} switchSmallIcons_1: {fileID: 0} switchSmallIcons_2: {fileID: 0} @@ -394,6 +444,7 @@ PlayerSettings: switchSmallIcons_12: {fileID: 0} switchSmallIcons_13: {fileID: 0} switchSmallIcons_14: {fileID: 0} + switchSmallIcons_15: {fileID: 0} switchManualHTML: switchAccessibleURLs: switchLegalInformation: @@ -425,6 +476,7 @@ PlayerSettings: switchRatingsInt_9: 0 switchRatingsInt_10: 0 switchRatingsInt_11: 0 + switchRatingsInt_12: 0 switchLocalCommunicationIds_0: switchLocalCommunicationIds_1: switchLocalCommunicationIds_2: @@ -455,6 +507,11 @@ PlayerSettings: switchSocketInitializeEnabled: 1 switchNetworkInterfaceManagerInitializeEnabled: 1 switchPlayerConnectionEnabled: 1 + switchUseNewStyleFilepaths: 0 + switchUseMicroSleepForYield: 1 + switchEnableRamDiskSupport: 0 + switchMicroSleepForYieldTime: 25 + switchRamDiskSpaceSize: 12 ps4NPAgeRating: 12 ps4NPTitleSecret: ps4NPTrophyPackPath: @@ -481,6 +538,7 @@ PlayerSettings: ps4ShareFilePath: ps4ShareOverlayImagePath: ps4PrivacyGuardImagePath: + ps4ExtraSceSysFile: ps4NPtitleDatPath: ps4RemotePlayKeyAssignment: -1 ps4RemotePlayKeyMappingDir: @@ -506,6 +564,7 @@ PlayerSettings: ps4UseResolutionFallback: 0 ps4ReprojectionSupport: 0 ps4UseAudio3dBackend: 0 + ps4UseLowGarlicFragmentationMode: 1 ps4SocialScreenEnabled: 0 ps4ScriptOptimizationLevel: 0 ps4Audio3dVirtualSpeakerCount: 14 @@ -522,11 +581,16 @@ PlayerSettings: ps4disableAutoHideSplash: 0 ps4videoRecordingFeaturesUsed: 0 ps4contentSearchFeaturesUsed: 0 + ps4CompatibilityPS5: 0 + ps4AllowPS5Detection: 0 + ps4GPU800MHz: 1 ps4attribEyeToEyeDistanceSettingVR: 0 ps4IncludedModules: [] + ps4attribVROutputEnabled: 0 monoEnv: splashScreenBackgroundSourceLandscape: {fileID: 0} splashScreenBackgroundSourcePortrait: {fileID: 0} + blurSplashScreenBackground: 1 spritePackerPolicy: webGLMemorySize: 256 webGLExceptionSupport: 1 @@ -539,20 +603,28 @@ PlayerSettings: webGLAnalyzeBuildSize: 0 webGLUseEmbeddedResources: 0 webGLCompressionFormat: 1 + webGLWasmArithmeticExceptions: 0 webGLLinkerTarget: 1 webGLThreadsSupport: 0 - webGLWasmStreaming: 0 + webGLDecompressionFallback: 0 scriptingDefineSymbols: {} + additionalCompilerArguments: + Standalone: + - -nullable:enable platformArchitecture: {} scriptingBackend: Standalone: 1 il2cppCompilerConfiguration: {} managedStrippingLevel: {} incrementalIl2cppBuild: {} + suppressCommonWarnings: 1 allowUnsafeCode: 1 + useDeterministicCompilation: 1 + enableRoslynAnalyzers: 1 additionalIl2CppArgs: scriptingRuntimeVersion: 1 gcIncremental: 0 + assemblyVersionValidation: 1 gcWBarrierValidation: 0 apiCompatibilityLevelPerPlatform: Standalone: 3 @@ -585,6 +657,7 @@ PlayerSettings: metroFTAName: metroFTAFileTypes: [] metroProtocolName: + vcxProjDefaultLanguage: XboxOneProductId: XboxOneUpdateKey: XboxOneSandboxId: @@ -603,18 +676,16 @@ PlayerSettings: XboxOneCapability: [] XboxOneGameRating: {} XboxOneIsContentPackage: 0 + XboxOneEnhancedXboxCompatibilityMode: 0 XboxOneEnableGPUVariability: 1 XboxOneSockets: {} XboxOneSplashScreen: {fileID: 0} XboxOneAllowedProductIds: [] XboxOnePersistentLocalStorageSize: 0 XboxOneXTitleMemory: 8 - xboxOneScriptCompiler: 1 XboxOneOverrideIdentityName: - vrEditorSettings: - daydream: - daydreamIconForeground: {fileID: 0} - daydreamIconBackground: {fileID: 0} + XboxOneOverrideIdentityPublisher: + vrEditorSettings: {} cloudServicesEnabled: UNet: 1 luminIcon: @@ -628,19 +699,15 @@ PlayerSettings: luminVersion: m_VersionCode: 1 m_VersionName: - facebookSdkVersion: 7.9.4 - facebookAppId: - facebookCookies: 1 - facebookLogging: 1 - facebookStatus: 1 - facebookXfbml: 0 - facebookFrictionlessRequests: 1 apiCompatibilityLevel: 6 + activeInputHandler: 0 cloudProjectId: 2616b476-0990-4307-a328-9a2582cb2402 framebufferDepthMemorylessMode: 0 + qualitySettingsNames: [] projectName: MessagePack.UnityClient organizationId: andrewarnott cloudEnabled: 0 - enableNativePlatformBackendsForNewInputSystem: 0 - disableOldInputManagerSupport: 0 legacyClampBlendShapeWeights: 0 + playerDataPath: + forceSRGBBlit: 1 + virtualTexturingSupportEnabled: 0 From 0b5e5d916fe6e820a02608710da70f94ff15c5ae Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Wed, 12 Apr 2023 09:45:35 -0600 Subject: [PATCH 096/660] Split code fix out of analyzer assembly This is important for dependency reasons, since code fixes bring in more dependencies than analyzers, and `dotnet build` and unity don't contain the dependencies required for code fixes. --- Directory.Packages.props | 1 + MessagePack.sln | 9 +- .../MessagePack.Analyzers.CodeFixes.csproj} | 31 +-- .../MessagePackCodeFixProvider.cs | 183 +++++++++++++++++ .../tools/install.ps1 | 0 .../tools/uninstall.ps1 | 0 .../AnalyzerReleases.Shipped.md | 0 .../AnalyzerReleases.Unshipped.md | 0 .../CodeAnalysis/AnalyzerOptions.cs | 2 +- .../CodeAnalysis/CodeAnalysisUtilities.cs | 2 +- .../CodeAnalysis/EnumSerializationInfo.cs | 2 +- .../CodeAnalysis/FullModel.cs | 2 +- .../CodeAnalysis/GenericSerializationInfo.cs | 2 +- .../CodeAnalysis/GenericTypeParameterInfo.cs | 2 +- .../CodeAnalysis/IResolverRegisterInfo.cs | 2 +- .../CodeAnalysis/MemberSerializationInfo.cs | 4 +- .../CodeAnalysis/ObjectSerializationInfo.cs | 2 +- .../CodeAnalysis/ReferenceSymbols.cs | 2 +- .../ResolverRegisterInfoComparer.cs | 2 +- .../CodeAnalysis/TypeCollector.cs | 2 +- .../CodeAnalysis/UnionSerializationInfo.cs | 2 +- .../CodeAnalysis/UnionSubTypeInfo.cs | 2 +- .../MessagePack.Analyzers.csproj | 29 +++ .../MsgPack001SpecifyOptionsAnalyzer.cs | 63 ++++++ .../MsgPack002UseConstantOptionsAnalyzer.cs | 86 ++++++++ .../MsgPack00xMessagePackAnalyzer.cs | 2 +- .../Properties/AssemblyInfo.cs | 6 + .../Strings.Designer.cs | 4 +- .../Strings.resx | 0 .../ShouldUseFormatterResolverHelper.cs | 2 +- .../Usings.cs | 2 +- .../Utils/AnalyzerUtilities.cs | 2 +- .../Utils/RoslynAnalyzerExtensions.cs | 2 +- .../version.json | 0 .../MessagePackGenerator.cs | 2 +- .../MessagePackGenerator.Emit.cs | 2 +- .../MessagePackGenerator.cs | 4 +- .../Transforms/FormatterTemplate.cs | 2 +- .../Transforms/IFormatterTemplate.cs | 2 +- .../StringKeyFormatterDeserializeHelper.cs | 2 +- .../StringKey/StringKeyFormatterTemplate.cs | 4 +- .../Transforms/TemplatePartials.cs | 2 +- .../MessagePackCodeFixProvider.cs | 184 ------------------ .../MsgPack001SpecifyOptionsAnalyzer.cs | 64 ------ .../MsgPack002UseConstantOptionsAnalyzer.cs | 87 --------- src/SourceGenerator.props | 2 +- .../MessagePack.SourceGenerator.Tests.csproj | 2 +- .../Usings.cs | 2 +- ...agePack.SourceGenerator.Unity.Tests.csproj | 2 +- .../MessagePackAnalyzer.Tests.csproj | 3 +- .../MessagePackAnalyzerTests.cs | 2 +- .../MsgPack001SpecifyOptionsAnalyzerTests.cs | 6 +- ...gPack002UseConstantOptionsAnalyzerTests.cs | 6 +- tests/SourceGeneratorConsumer.props | 2 +- 54 files changed, 431 insertions(+), 403 deletions(-) rename src/{MessagePackAnalyzer/MessagePackAnalyzer.csproj => MessagePack.Analyzers.CodeFixes/MessagePack.Analyzers.CodeFixes.csproj} (57%) create mode 100644 src/MessagePack.Analyzers.CodeFixes/MessagePackCodeFixProvider.cs rename src/{MessagePackAnalyzer => MessagePack.Analyzers.CodeFixes}/tools/install.ps1 (100%) rename src/{MessagePackAnalyzer => MessagePack.Analyzers.CodeFixes}/tools/uninstall.ps1 (100%) rename src/{MessagePackAnalyzer => MessagePack.Analyzers}/AnalyzerReleases.Shipped.md (100%) rename src/{MessagePackAnalyzer => MessagePack.Analyzers}/AnalyzerReleases.Unshipped.md (100%) rename src/{MessagePackAnalyzer => MessagePack.Analyzers}/CodeAnalysis/AnalyzerOptions.cs (98%) rename src/{MessagePackAnalyzer => MessagePack.Analyzers}/CodeAnalysis/CodeAnalysisUtilities.cs (96%) rename src/{MessagePackAnalyzer => MessagePack.Analyzers}/CodeAnalysis/EnumSerializationInfo.cs (96%) rename src/{MessagePackAnalyzer => MessagePack.Analyzers}/CodeAnalysis/FullModel.cs (98%) rename src/{MessagePackAnalyzer => MessagePack.Analyzers}/CodeAnalysis/GenericSerializationInfo.cs (93%) rename src/{MessagePackAnalyzer => MessagePack.Analyzers}/CodeAnalysis/GenericTypeParameterInfo.cs (86%) rename src/{MessagePackAnalyzer => MessagePack.Analyzers}/CodeAnalysis/IResolverRegisterInfo.cs (88%) rename src/{MessagePackAnalyzer => MessagePack.Analyzers}/CodeAnalysis/MemberSerializationInfo.cs (95%) rename src/{MessagePackAnalyzer => MessagePack.Analyzers}/CodeAnalysis/ObjectSerializationInfo.cs (98%) rename src/{MessagePackAnalyzer => MessagePack.Analyzers}/CodeAnalysis/ReferenceSymbols.cs (98%) rename src/{MessagePackAnalyzer => MessagePack.Analyzers}/CodeAnalysis/ResolverRegisterInfoComparer.cs (91%) rename src/{MessagePackAnalyzer => MessagePack.Analyzers}/CodeAnalysis/TypeCollector.cs (99%) rename src/{MessagePackAnalyzer => MessagePack.Analyzers}/CodeAnalysis/UnionSerializationInfo.cs (96%) rename src/{MessagePackAnalyzer => MessagePack.Analyzers}/CodeAnalysis/UnionSubTypeInfo.cs (82%) create mode 100644 src/MessagePack.Analyzers/MessagePack.Analyzers.csproj create mode 100644 src/MessagePack.Analyzers/MsgPack001SpecifyOptionsAnalyzer.cs create mode 100644 src/MessagePack.Analyzers/MsgPack002UseConstantOptionsAnalyzer.cs rename src/{MessagePackAnalyzer => MessagePack.Analyzers}/MsgPack00xMessagePackAnalyzer.cs (99%) create mode 100644 src/MessagePack.Analyzers/Properties/AssemblyInfo.cs rename src/{MessagePackAnalyzer => MessagePack.Analyzers}/Strings.Designer.cs (97%) rename src/{MessagePackAnalyzer => MessagePack.Analyzers}/Strings.resx (100%) rename src/{MessagePackAnalyzer => MessagePack.Analyzers}/Transforms/ShouldUseFormatterResolverHelper.cs (96%) rename src/{MessagePackAnalyzer => MessagePack.Analyzers}/Usings.cs (76%) rename src/{MessagePackAnalyzer => MessagePack.Analyzers}/Utils/AnalyzerUtilities.cs (91%) rename src/{MessagePackAnalyzer => MessagePack.Analyzers}/Utils/RoslynAnalyzerExtensions.cs (99%) rename src/{MessagePackAnalyzer => MessagePack.Analyzers}/version.json (100%) delete mode 100644 src/MessagePackAnalyzer/MessagePackCodeFixProvider.cs delete mode 100644 src/MessagePackAnalyzer/MsgPack001SpecifyOptionsAnalyzer.cs delete mode 100644 src/MessagePackAnalyzer/MsgPack002UseConstantOptionsAnalyzer.cs diff --git a/Directory.Packages.props b/Directory.Packages.props index 912b501f4..7139cc3b5 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -32,6 +32,7 @@ + diff --git a/MessagePack.sln b/MessagePack.sln index 32d11a746..d7a831d72 100644 --- a/MessagePack.sln +++ b/MessagePack.sln @@ -41,7 +41,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MessagePack.ReactivePropert EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MessagePack.ImmutableCollection", "src\MessagePack.ImmutableCollection\MessagePack.ImmutableCollection.csproj", "{E066F547-7261-4561-AEFC-E64DBFD874F8}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MessagePackAnalyzer", "src\MessagePackAnalyzer\MessagePackAnalyzer.csproj", "{2F9A6E0C-DE95-4460-96B7-EB72BBEAEE9E}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MessagePack.Analyzers", "src\MessagePack.Analyzers\MessagePack.Analyzers.csproj", "{2F9A6E0C-DE95-4460-96B7-EB72BBEAEE9E}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PerfNetFramework", "sandbox\PerfNetFramework\PerfNetFramework.csproj", "{014A3DCE-50A6-4774-A4C1-C66EEAB67133}" EndProject @@ -103,6 +103,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MessagePack.SourceGenerator EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MessagePack.SourceGenerator.Unity.Tests", "tests\MessagePack.SourceGenerator.Unity.Tests\MessagePack.SourceGenerator.Unity.Tests.csproj", "{EAC1B79C-F77D-4DEF-BF53-75E700A301A4}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MessagePack.Analyzers.CodeFixes", "src\MessagePack.Analyzers.CodeFixes\MessagePack.Analyzers.CodeFixes.csproj", "{7A6CB600-2393-468F-9952-84EC624D57BD}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -225,6 +227,10 @@ Global {EAC1B79C-F77D-4DEF-BF53-75E700A301A4}.Debug|Any CPU.Build.0 = Debug|Any CPU {EAC1B79C-F77D-4DEF-BF53-75E700A301A4}.Release|Any CPU.ActiveCfg = Release|Any CPU {EAC1B79C-F77D-4DEF-BF53-75E700A301A4}.Release|Any CPU.Build.0 = Release|Any CPU + {7A6CB600-2393-468F-9952-84EC624D57BD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {7A6CB600-2393-468F-9952-84EC624D57BD}.Debug|Any CPU.Build.0 = Debug|Any CPU + {7A6CB600-2393-468F-9952-84EC624D57BD}.Release|Any CPU.ActiveCfg = Release|Any CPU + {7A6CB600-2393-468F-9952-84EC624D57BD}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -259,6 +265,7 @@ Global {7908D954-15D4-4D67-B49A-4484809DA2C4} = {19FE674A-AC94-4E7E-B24C-2285D1D04CDE} {EDBA7DDC-69AF-4D5B-A8F6-3B508F8CC0FC} = {19FE674A-AC94-4E7E-B24C-2285D1D04CDE} {EAC1B79C-F77D-4DEF-BF53-75E700A301A4} = {19FE674A-AC94-4E7E-B24C-2285D1D04CDE} + {7A6CB600-2393-468F-9952-84EC624D57BD} = {86309CF6-0054-4CE3-BFD3-CA0AA7DB17BC} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {B3911209-2DBF-47F8-98F6-BBC0EDFE63DE} diff --git a/src/MessagePackAnalyzer/MessagePackAnalyzer.csproj b/src/MessagePack.Analyzers.CodeFixes/MessagePack.Analyzers.CodeFixes.csproj similarity index 57% rename from src/MessagePackAnalyzer/MessagePackAnalyzer.csproj rename to src/MessagePack.Analyzers.CodeFixes/MessagePack.Analyzers.CodeFixes.csproj index 59e1e5ada..ece521244 100644 --- a/src/MessagePackAnalyzer/MessagePackAnalyzer.csproj +++ b/src/MessagePack.Analyzers.CodeFixes/MessagePack.Analyzers.CodeFixes.csproj @@ -1,7 +1,9 @@  netstandard2.0 + MessagePack.Analyzers enable + MessagePackAnalyzer Analyzer of MessagePack for C#, verify rule for [MessagePackObject] and code fix for [Key]. MsgPack;MessagePack;Serialization;Formatter;Analyzer @@ -15,35 +17,20 @@ + - - - all - - - - - - - True - True - Strings.resx - + - - - ResXFileCodeGenerator - Strings.Designer.cs - - - + - - + + + + diff --git a/src/MessagePack.Analyzers.CodeFixes/MessagePackCodeFixProvider.cs b/src/MessagePack.Analyzers.CodeFixes/MessagePackCodeFixProvider.cs new file mode 100644 index 000000000..7b1efc2c7 --- /dev/null +++ b/src/MessagePack.Analyzers.CodeFixes/MessagePackCodeFixProvider.cs @@ -0,0 +1,183 @@ +// Copyright (c) All contributors. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using System; +using System.Collections.Immutable; +using System.Composition; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.CodeActions; +using Microsoft.CodeAnalysis.CodeFixes; +using Microsoft.CodeAnalysis.CSharp; +using Microsoft.CodeAnalysis.CSharp.Syntax; +using Microsoft.CodeAnalysis.Editing; + +namespace MessagePack.Analyzers; + +[ExportCodeFixProvider(LanguageNames.CSharp, Name = nameof(MessagePackCodeFixProvider)), Shared] +public class MessagePackCodeFixProvider : CodeFixProvider +{ + public sealed override ImmutableArray FixableDiagnosticIds + { + get + { + return ImmutableArray.Create( + MsgPack00xMessagePackAnalyzer.PublicMemberNeedsKey.Id, + MsgPack00xMessagePackAnalyzer.TypeMustBeMessagePackObject.Id); + } + } + + public sealed override FixAllProvider GetFixAllProvider() + { + return WellKnownFixAllProviders.BatchFixer; + } + + public sealed override async Task RegisterCodeFixesAsync(CodeFixContext context) + { + var root = await context.Document.GetSyntaxRootAsync(context.CancellationToken).ConfigureAwait(false) as CompilationUnitSyntax; + if (root is null) + { + return; + } + + SemanticModel? model = await context.Document.GetSemanticModelAsync(context.CancellationToken).ConfigureAwait(false); + if (model is null) + { + return; + } + + SyntaxNode targetNode = root.FindNode(context.Span); + TypeInfo myTypeInfo = model.GetTypeInfo(targetNode, context.CancellationToken); + + string? typeName = context.Diagnostics[0]?.Properties.GetValueOrDefault("type", null); + INamedTypeSymbol? namedSymbol = + myTypeInfo.Type as INamedTypeSymbol ?? + (typeName is not null ? model.Compilation.GetTypeByMetadataName(typeName.Replace("global::", string.Empty)) : null); + + if (namedSymbol is null) + { + var property = targetNode as PropertyDeclarationSyntax; + var field = targetNode as FieldDeclarationSyntax; + var dec = targetNode as VariableDeclaratorSyntax; + IdentifierNameSyntax? identifierName = targetNode as IdentifierNameSyntax; + + ITypeSymbol? targetType = null; + if (property == null && field == null) + { + var typeDeclare = targetNode as TypeDeclarationSyntax; + if (typeDeclare != null) + { + targetType = model.GetDeclaredSymbol(typeDeclare); + } + else if (dec != null) + { + var fieldOrProperty = model.GetDeclaredSymbol(dec) as ISymbol; + if (context.Diagnostics[0].Id == MsgPack00xMessagePackAnalyzer.TypeMustBeMessagePackObject.Id) + { + targetType = (fieldOrProperty as IPropertySymbol)?.Type; + if (targetType == null) + { + targetType = (fieldOrProperty as IFieldSymbol)?.Type; + } + } + else + { + targetType = (fieldOrProperty as IPropertySymbol)?.ContainingType; + if (targetType == null) + { + targetType = (fieldOrProperty as IFieldSymbol)?.ContainingType; + } + } + } + } + else + { + if (context.Diagnostics[0].Id == MsgPack00xMessagePackAnalyzer.TypeMustBeMessagePackObject.Id) + { + targetType = (property != null) + ? (model.GetDeclaredSymbol(property) as IPropertySymbol)?.Type + : (model.GetDeclaredSymbol(field!) as IFieldSymbol)?.Type; + } + else + { + targetType = (property != null) + ? (model.GetDeclaredSymbol(property) as IPropertySymbol)?.ContainingType + : (model.GetDeclaredSymbol(field!) as IFieldSymbol)?.ContainingType; + } + } + + if (targetType == null) + { + return; + } + + if (targetType.TypeKind == TypeKind.Array) + { + targetType = ((IArrayTypeSymbol)targetType).ElementType; + } + + namedSymbol = targetType as INamedTypeSymbol; + if (namedSymbol == null) + { + return; + } + } + + var action = CodeAction.Create("Add MessagePack KeyAttribute", c => AddKeyAttributeAsync(context.Document, namedSymbol, c), "MessagePackAnalyzer.AddKeyAttribute"); + + context.RegisterCodeFix(action, context.Diagnostics.First()); // use single. + } + + private static async Task AddKeyAttributeAsync(Document document, INamedTypeSymbol type, CancellationToken cancellationToken) + { + var solutionEditor = new SolutionEditor(document.Project.Solution); + + ISymbol[] targets = type.GetAllMembers() + .Where(x => x.Kind == SymbolKind.Property || x.Kind == SymbolKind.Field) + .Where(x => x.GetAttributes().FindAttributeShortName(MsgPack00xMessagePackAnalyzer.IgnoreShortName) == null && x.GetAttributes().FindAttributeShortName(MsgPack00xMessagePackAnalyzer.IgnoreDataMemberShortName) == null) + .Where(x => !x.IsStatic) + .Where(x => + { + return x switch + { + IPropertySymbol p => p.ExplicitInterfaceImplementations.Length == 0, + IFieldSymbol f => !f.IsImplicitlyDeclared, + _ => throw new NotSupportedException("Unsupported member type."), + }; + }) + .ToArray(); + + var startOrder = targets + .Select(x => x.GetAttributes().FindAttributeShortName(MsgPack00xMessagePackAnalyzer.KeyAttributeShortName)) + .Where(x => x != null) + .Select(x => x.ConstructorArguments[0]) + .Where(x => !x.IsNull) + .Where(x => x.Value is int) + .Select(x => (int)x.Value!) + .DefaultIfEmpty(-1) // if empty, start from zero. + .Max() + 1; + + foreach (ISymbol member in targets) + { + if (member.GetAttributes().FindAttributeShortName(MsgPack00xMessagePackAnalyzer.KeyAttributeShortName) is null) + { + SyntaxNode node = await member.DeclaringSyntaxReferences[0].GetSyntaxAsync(cancellationToken).ConfigureAwait(false); + var documentEditor = await solutionEditor.GetDocumentEditorAsync(document.Project.Solution.GetDocumentId(node.SyntaxTree), cancellationToken).ConfigureAwait(false); + var syntaxGenerator = SyntaxGenerator.GetGenerator(documentEditor.OriginalDocument); + documentEditor.AddAttribute(node, syntaxGenerator.Attribute("MessagePack.KeyAttribute", syntaxGenerator.LiteralExpression(startOrder++))); + } + } + + if (type.GetAttributes().FindAttributeShortName(MsgPack00xMessagePackAnalyzer.MessagePackObjectAttributeShortName) == null) + { + SyntaxNode node = await type.DeclaringSyntaxReferences[0].GetSyntaxAsync(cancellationToken).ConfigureAwait(false); + var documentEditor = await solutionEditor.GetDocumentEditorAsync(document.Project.Solution.GetDocumentId(node.SyntaxTree), cancellationToken).ConfigureAwait(false); + var syntaxGenerator = SyntaxGenerator.GetGenerator(documentEditor.OriginalDocument); + documentEditor.AddAttribute(node, syntaxGenerator.Attribute("MessagePack.MessagePackObject")); + } + + return solutionEditor.GetChangedSolution(); + } +} diff --git a/src/MessagePackAnalyzer/tools/install.ps1 b/src/MessagePack.Analyzers.CodeFixes/tools/install.ps1 similarity index 100% rename from src/MessagePackAnalyzer/tools/install.ps1 rename to src/MessagePack.Analyzers.CodeFixes/tools/install.ps1 diff --git a/src/MessagePackAnalyzer/tools/uninstall.ps1 b/src/MessagePack.Analyzers.CodeFixes/tools/uninstall.ps1 similarity index 100% rename from src/MessagePackAnalyzer/tools/uninstall.ps1 rename to src/MessagePack.Analyzers.CodeFixes/tools/uninstall.ps1 diff --git a/src/MessagePackAnalyzer/AnalyzerReleases.Shipped.md b/src/MessagePack.Analyzers/AnalyzerReleases.Shipped.md similarity index 100% rename from src/MessagePackAnalyzer/AnalyzerReleases.Shipped.md rename to src/MessagePack.Analyzers/AnalyzerReleases.Shipped.md diff --git a/src/MessagePackAnalyzer/AnalyzerReleases.Unshipped.md b/src/MessagePack.Analyzers/AnalyzerReleases.Unshipped.md similarity index 100% rename from src/MessagePackAnalyzer/AnalyzerReleases.Unshipped.md rename to src/MessagePack.Analyzers/AnalyzerReleases.Unshipped.md diff --git a/src/MessagePackAnalyzer/CodeAnalysis/AnalyzerOptions.cs b/src/MessagePack.Analyzers/CodeAnalysis/AnalyzerOptions.cs similarity index 98% rename from src/MessagePackAnalyzer/CodeAnalysis/AnalyzerOptions.cs rename to src/MessagePack.Analyzers/CodeAnalysis/AnalyzerOptions.cs index d8affc15d..1fe586c53 100644 --- a/src/MessagePackAnalyzer/CodeAnalysis/AnalyzerOptions.cs +++ b/src/MessagePack.Analyzers/CodeAnalysis/AnalyzerOptions.cs @@ -6,7 +6,7 @@ using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.Diagnostics; -namespace MessagePackAnalyzer.CodeAnalysis; +namespace MessagePack.Analyzers.CodeAnalysis; public record AnalyzerOptions( string ResolverNamespace = "MessagePack", diff --git a/src/MessagePackAnalyzer/CodeAnalysis/CodeAnalysisUtilities.cs b/src/MessagePack.Analyzers/CodeAnalysis/CodeAnalysisUtilities.cs similarity index 96% rename from src/MessagePackAnalyzer/CodeAnalysis/CodeAnalysisUtilities.cs rename to src/MessagePack.Analyzers/CodeAnalysis/CodeAnalysisUtilities.cs index 05e8d9ab8..21794abea 100644 --- a/src/MessagePackAnalyzer/CodeAnalysis/CodeAnalysisUtilities.cs +++ b/src/MessagePack.Analyzers/CodeAnalysis/CodeAnalysisUtilities.cs @@ -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. -namespace MessagePackAnalyzer.CodeAnalysis; +namespace MessagePack.Analyzers.CodeAnalysis; public static class CodeAnalysisUtilities { diff --git a/src/MessagePackAnalyzer/CodeAnalysis/EnumSerializationInfo.cs b/src/MessagePack.Analyzers/CodeAnalysis/EnumSerializationInfo.cs similarity index 96% rename from src/MessagePackAnalyzer/CodeAnalysis/EnumSerializationInfo.cs rename to src/MessagePack.Analyzers/CodeAnalysis/EnumSerializationInfo.cs index 317cef3e9..564054539 100644 --- a/src/MessagePackAnalyzer/CodeAnalysis/EnumSerializationInfo.cs +++ b/src/MessagePack.Analyzers/CodeAnalysis/EnumSerializationInfo.cs @@ -3,7 +3,7 @@ using Microsoft.CodeAnalysis; -namespace MessagePackAnalyzer.CodeAnalysis; +namespace MessagePack.Analyzers.CodeAnalysis; public sealed record EnumSerializationInfo(string? Namespace, string Name, string FullName, string UnderlyingTypeName) : IResolverRegisterInfo { diff --git a/src/MessagePackAnalyzer/CodeAnalysis/FullModel.cs b/src/MessagePack.Analyzers/CodeAnalysis/FullModel.cs similarity index 98% rename from src/MessagePackAnalyzer/CodeAnalysis/FullModel.cs rename to src/MessagePack.Analyzers/CodeAnalysis/FullModel.cs index a70c1fc77..f04b56685 100644 --- a/src/MessagePackAnalyzer/CodeAnalysis/FullModel.cs +++ b/src/MessagePack.Analyzers/CodeAnalysis/FullModel.cs @@ -3,7 +3,7 @@ using System.Collections.Immutable; -namespace MessagePackAnalyzer.CodeAnalysis; +namespace MessagePack.Analyzers.CodeAnalysis; public record FullModel( ImmutableSortedSet ObjectInfos, diff --git a/src/MessagePackAnalyzer/CodeAnalysis/GenericSerializationInfo.cs b/src/MessagePack.Analyzers/CodeAnalysis/GenericSerializationInfo.cs similarity index 93% rename from src/MessagePackAnalyzer/CodeAnalysis/GenericSerializationInfo.cs rename to src/MessagePack.Analyzers/CodeAnalysis/GenericSerializationInfo.cs index cfa405848..b1f91bc47 100644 --- a/src/MessagePackAnalyzer/CodeAnalysis/GenericSerializationInfo.cs +++ b/src/MessagePack.Analyzers/CodeAnalysis/GenericSerializationInfo.cs @@ -3,7 +3,7 @@ using Microsoft.CodeAnalysis; -namespace MessagePackAnalyzer.CodeAnalysis; +namespace MessagePack.Analyzers.CodeAnalysis; public sealed record GenericSerializationInfo(string FullName, string FormatterName, bool IsOpenGenericType) : IResolverRegisterInfo { diff --git a/src/MessagePackAnalyzer/CodeAnalysis/GenericTypeParameterInfo.cs b/src/MessagePack.Analyzers/CodeAnalysis/GenericTypeParameterInfo.cs similarity index 86% rename from src/MessagePackAnalyzer/CodeAnalysis/GenericTypeParameterInfo.cs rename to src/MessagePack.Analyzers/CodeAnalysis/GenericTypeParameterInfo.cs index 30da7aad8..6784eb21a 100644 --- a/src/MessagePackAnalyzer/CodeAnalysis/GenericTypeParameterInfo.cs +++ b/src/MessagePack.Analyzers/CodeAnalysis/GenericTypeParameterInfo.cs @@ -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. -namespace MessagePackAnalyzer.CodeAnalysis; +namespace MessagePack.Analyzers.CodeAnalysis; public record GenericTypeParameterInfo(string Name, string Constraints) { diff --git a/src/MessagePackAnalyzer/CodeAnalysis/IResolverRegisterInfo.cs b/src/MessagePack.Analyzers/CodeAnalysis/IResolverRegisterInfo.cs similarity index 88% rename from src/MessagePackAnalyzer/CodeAnalysis/IResolverRegisterInfo.cs rename to src/MessagePack.Analyzers/CodeAnalysis/IResolverRegisterInfo.cs index f36faef3b..5a88ec2c7 100644 --- a/src/MessagePackAnalyzer/CodeAnalysis/IResolverRegisterInfo.cs +++ b/src/MessagePack.Analyzers/CodeAnalysis/IResolverRegisterInfo.cs @@ -3,7 +3,7 @@ using Microsoft.CodeAnalysis; -namespace MessagePackAnalyzer.CodeAnalysis; +namespace MessagePack.Analyzers.CodeAnalysis; public interface IResolverRegisterInfo { diff --git a/src/MessagePackAnalyzer/CodeAnalysis/MemberSerializationInfo.cs b/src/MessagePack.Analyzers/CodeAnalysis/MemberSerializationInfo.cs similarity index 95% rename from src/MessagePackAnalyzer/CodeAnalysis/MemberSerializationInfo.cs rename to src/MessagePack.Analyzers/CodeAnalysis/MemberSerializationInfo.cs index d441c66d0..4fa9045c9 100644 --- a/src/MessagePackAnalyzer/CodeAnalysis/MemberSerializationInfo.cs +++ b/src/MessagePack.Analyzers/CodeAnalysis/MemberSerializationInfo.cs @@ -1,9 +1,9 @@ // Copyright (c) All contributors. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -using MessagePackAnalyzer.Transforms; +using MessagePack.Analyzers.Transforms; -namespace MessagePackAnalyzer.CodeAnalysis; +namespace MessagePack.Analyzers.CodeAnalysis; public record MemberSerializationInfo( bool IsProperty, diff --git a/src/MessagePackAnalyzer/CodeAnalysis/ObjectSerializationInfo.cs b/src/MessagePack.Analyzers/CodeAnalysis/ObjectSerializationInfo.cs similarity index 98% rename from src/MessagePackAnalyzer/CodeAnalysis/ObjectSerializationInfo.cs rename to src/MessagePack.Analyzers/CodeAnalysis/ObjectSerializationInfo.cs index 675514e45..4eb40228c 100644 --- a/src/MessagePackAnalyzer/CodeAnalysis/ObjectSerializationInfo.cs +++ b/src/MessagePack.Analyzers/CodeAnalysis/ObjectSerializationInfo.cs @@ -3,7 +3,7 @@ using Microsoft.CodeAnalysis; -namespace MessagePackAnalyzer.CodeAnalysis; +namespace MessagePack.Analyzers.CodeAnalysis; public record ObjectSerializationInfo( bool IsClass, diff --git a/src/MessagePackAnalyzer/CodeAnalysis/ReferenceSymbols.cs b/src/MessagePack.Analyzers/CodeAnalysis/ReferenceSymbols.cs similarity index 98% rename from src/MessagePackAnalyzer/CodeAnalysis/ReferenceSymbols.cs rename to src/MessagePack.Analyzers/CodeAnalysis/ReferenceSymbols.cs index 5178bd6e9..c58dfbcad 100644 --- a/src/MessagePackAnalyzer/CodeAnalysis/ReferenceSymbols.cs +++ b/src/MessagePack.Analyzers/CodeAnalysis/ReferenceSymbols.cs @@ -4,7 +4,7 @@ using System.Diagnostics.CodeAnalysis; using Microsoft.CodeAnalysis; -namespace MessagePackAnalyzer.CodeAnalysis; +namespace MessagePack.Analyzers.CodeAnalysis; public record ReferenceSymbols( INamedTypeSymbol MessagePackObjectAttribute, diff --git a/src/MessagePackAnalyzer/CodeAnalysis/ResolverRegisterInfoComparer.cs b/src/MessagePack.Analyzers/CodeAnalysis/ResolverRegisterInfoComparer.cs similarity index 91% rename from src/MessagePackAnalyzer/CodeAnalysis/ResolverRegisterInfoComparer.cs rename to src/MessagePack.Analyzers/CodeAnalysis/ResolverRegisterInfoComparer.cs index 5ab54e75c..12c43b363 100644 --- a/src/MessagePackAnalyzer/CodeAnalysis/ResolverRegisterInfoComparer.cs +++ b/src/MessagePack.Analyzers/CodeAnalysis/ResolverRegisterInfoComparer.cs @@ -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. -namespace MessagePackAnalyzer.CodeAnalysis; +namespace MessagePack.Analyzers.CodeAnalysis; public class ResolverRegisterInfoComparer : IComparer { diff --git a/src/MessagePackAnalyzer/CodeAnalysis/TypeCollector.cs b/src/MessagePack.Analyzers/CodeAnalysis/TypeCollector.cs similarity index 99% rename from src/MessagePackAnalyzer/CodeAnalysis/TypeCollector.cs rename to src/MessagePack.Analyzers/CodeAnalysis/TypeCollector.cs index b6ae23211..ab8c3be3c 100644 --- a/src/MessagePackAnalyzer/CodeAnalysis/TypeCollector.cs +++ b/src/MessagePack.Analyzers/CodeAnalysis/TypeCollector.cs @@ -10,7 +10,7 @@ using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp.Syntax; -namespace MessagePackAnalyzer.CodeAnalysis; +namespace MessagePack.Analyzers.CodeAnalysis; public class MessagePackGeneratorResolveFailedException : Exception { diff --git a/src/MessagePackAnalyzer/CodeAnalysis/UnionSerializationInfo.cs b/src/MessagePack.Analyzers/CodeAnalysis/UnionSerializationInfo.cs similarity index 96% rename from src/MessagePackAnalyzer/CodeAnalysis/UnionSerializationInfo.cs rename to src/MessagePack.Analyzers/CodeAnalysis/UnionSerializationInfo.cs index a95b39d8f..c0d3e906a 100644 --- a/src/MessagePackAnalyzer/CodeAnalysis/UnionSerializationInfo.cs +++ b/src/MessagePack.Analyzers/CodeAnalysis/UnionSerializationInfo.cs @@ -3,7 +3,7 @@ using Microsoft.CodeAnalysis; -namespace MessagePackAnalyzer.CodeAnalysis; +namespace MessagePack.Analyzers.CodeAnalysis; public record UnionSerializationInfo( string? Namespace, diff --git a/src/MessagePackAnalyzer/CodeAnalysis/UnionSubTypeInfo.cs b/src/MessagePack.Analyzers/CodeAnalysis/UnionSubTypeInfo.cs similarity index 82% rename from src/MessagePackAnalyzer/CodeAnalysis/UnionSubTypeInfo.cs rename to src/MessagePack.Analyzers/CodeAnalysis/UnionSubTypeInfo.cs index 2be99b87c..a9e722776 100644 --- a/src/MessagePackAnalyzer/CodeAnalysis/UnionSubTypeInfo.cs +++ b/src/MessagePack.Analyzers/CodeAnalysis/UnionSubTypeInfo.cs @@ -1,6 +1,6 @@ // Copyright (c) All contributors. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -namespace MessagePackAnalyzer.CodeAnalysis; +namespace MessagePack.Analyzers.CodeAnalysis; public record UnionSubTypeInfo(int Key, string Type); diff --git a/src/MessagePack.Analyzers/MessagePack.Analyzers.csproj b/src/MessagePack.Analyzers/MessagePack.Analyzers.csproj new file mode 100644 index 000000000..9edf60b71 --- /dev/null +++ b/src/MessagePack.Analyzers/MessagePack.Analyzers.csproj @@ -0,0 +1,29 @@ + + + netstandard2.0 + enable + false + MessagePack.Analyzers.Only + + $(CodeAnalysisVersionForUnity) + + + + + + + + + + True + True + Strings.resx + + + + + ResXFileCodeGenerator + Strings.Designer.cs + + + diff --git a/src/MessagePack.Analyzers/MsgPack001SpecifyOptionsAnalyzer.cs b/src/MessagePack.Analyzers/MsgPack001SpecifyOptionsAnalyzer.cs new file mode 100644 index 000000000..ff294d865 --- /dev/null +++ b/src/MessagePack.Analyzers/MsgPack001SpecifyOptionsAnalyzer.cs @@ -0,0 +1,63 @@ +// Copyright (c) All contributors. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using System.Collections.Immutable; +using System.Linq; +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.Diagnostics; +using Microsoft.CodeAnalysis.Operations; + +namespace MessagePack.Analyzers; + +/// +/// An analyzer that guards against calling APIs that rely on static, mutable fields defining "default" options. +/// +[DiagnosticAnalyzer(LanguageNames.CSharp, LanguageNames.VisualBasic)] +public class MsgPack001SpecifyOptionsAnalyzer : DiagnosticAnalyzer +{ + public const string MissingOptionsId = "MsgPack001"; + + public static readonly DiagnosticDescriptor MissingOptionsDescriptor = new DiagnosticDescriptor( + id: MissingOptionsId, + title: new LocalizableResourceString(nameof(Strings.MsgPack001_Title), Strings.ResourceManager, typeof(Strings)), + messageFormat: new LocalizableResourceString(nameof(Strings.MsgPack001_MessageFormat), Strings.ResourceManager, typeof(Strings)), + category: "Reliability", + defaultSeverity: DiagnosticSeverity.Warning, + isEnabledByDefault: false, + description: new LocalizableResourceString(nameof(Strings.MsgPack001_Description), Strings.ResourceManager, typeof(Strings)), + helpLinkUri: AnalyzerUtilities.GetHelpLink(MissingOptionsId)); + + private static readonly ImmutableArray ReusableSupportedDiagnostics = ImmutableArray.Create(MissingOptionsDescriptor); + + public override ImmutableArray SupportedDiagnostics => ReusableSupportedDiagnostics; + + public override void Initialize(AnalysisContext context) + { + context.ConfigureGeneratedCodeAnalysis(GeneratedCodeAnalysisFlags.Analyze | GeneratedCodeAnalysisFlags.ReportDiagnostics); + context.EnableConcurrentExecution(); + context.RegisterCompilationStartAction(compilationStartContext => + { + ITypeSymbol? messagePackSerializationOptionsTypeSymbol = compilationStartContext.Compilation.GetTypeByMetadataName("MessagePack.MessagePackSerializerOptions"); + if (messagePackSerializationOptionsTypeSymbol is object) + { + compilationStartContext.RegisterOperationAction(c => this.AnalyzeInvocation(c, messagePackSerializationOptionsTypeSymbol), OperationKind.Invocation); + } + }); + } + + private void AnalyzeInvocation(OperationAnalysisContext ctxt, ITypeSymbol messagePackSerializationOptionsTypeSymbol) + { + var operation = (IInvocationOperation)ctxt.Operation; + + // Is this an invocation on a method defined in the MessagePack assembly? + if (SymbolEqualityComparer.Default.Equals(operation.TargetMethod.ContainingAssembly, messagePackSerializationOptionsTypeSymbol.ContainingAssembly)) + { + var optionsArg = operation.Arguments.FirstOrDefault(arg => SymbolEqualityComparer.Default.Equals(arg.Value?.Type, messagePackSerializationOptionsTypeSymbol)); + if (optionsArg is object && optionsArg.Value.IsImplicit) + { + // The caller is omitting a MessagePackSerializerOptions argument or setting it to null. + ctxt.ReportDiagnostic(Diagnostic.Create(MissingOptionsDescriptor, optionsArg.Value.Syntax.GetLocation())); + } + } + } +} diff --git a/src/MessagePack.Analyzers/MsgPack002UseConstantOptionsAnalyzer.cs b/src/MessagePack.Analyzers/MsgPack002UseConstantOptionsAnalyzer.cs new file mode 100644 index 000000000..b26e3dc64 --- /dev/null +++ b/src/MessagePack.Analyzers/MsgPack002UseConstantOptionsAnalyzer.cs @@ -0,0 +1,86 @@ +// Copyright (c) All contributors. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using System.Collections.Immutable; +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.Diagnostics; +using Microsoft.CodeAnalysis.Operations; + +namespace MessagePack.Analyzers; + +/// +/// An analyzer to guide callers to avoid use of mutable static fields for MessagePackSerializerOptions. +/// +[DiagnosticAnalyzer(LanguageNames.CSharp, LanguageNames.VisualBasic)] +public class MsgPack002UseConstantOptionsAnalyzer : DiagnosticAnalyzer +{ + public const string MutableSharedOptionsId = "MsgPack002"; + + public static readonly DiagnosticDescriptor MutableSharedOptionsDescriptor = new DiagnosticDescriptor( + id: MutableSharedOptionsId, + title: new LocalizableResourceString(nameof(Strings.MsgPack002_Title), Strings.ResourceManager, typeof(Strings)), + messageFormat: new LocalizableResourceString(nameof(Strings.MsgPack002_MessageFormat), Strings.ResourceManager, typeof(Strings)), + category: "Reliability", + defaultSeverity: DiagnosticSeverity.Warning, + isEnabledByDefault: false, + description: new LocalizableResourceString(nameof(Strings.MsgPack002_Description), Strings.ResourceManager, typeof(Strings)), + helpLinkUri: AnalyzerUtilities.GetHelpLink(MutableSharedOptionsId)); + + private static readonly ImmutableArray ReusableSupportedDiagnostics = ImmutableArray.Create(MutableSharedOptionsDescriptor); + + public override ImmutableArray SupportedDiagnostics => ReusableSupportedDiagnostics; + + public override void Initialize(AnalysisContext context) + { + context.ConfigureGeneratedCodeAnalysis(GeneratedCodeAnalysisFlags.Analyze | GeneratedCodeAnalysisFlags.ReportDiagnostics); + context.EnableConcurrentExecution(); + context.RegisterCompilationStartAction(compilationStartContext => + { + ITypeSymbol? messagePackSerializationOptionsTypeSymbol = compilationStartContext.Compilation.GetTypeByMetadataName("MessagePack.MessagePackSerializerOptions"); + if (messagePackSerializationOptionsTypeSymbol is object) + { + compilationStartContext.RegisterOperationAction(c => this.AnalyzeMemberReference(c, messagePackSerializationOptionsTypeSymbol), OperationKind.PropertyReference, OperationKind.FieldReference); + } + }); + } + + private static bool IsLessWritableThanReadable(ISymbol symbol) + { + if (symbol is IPropertySymbol property) + { + if (property.GetMethod is null) + { + // The property has no getter, so the calling code has other problems. + // Don't report a problem. + return true; + } + + if (property.SetMethod is null) + { + // If the property has no setter, we're totally good. + return true; + } + + return property.SetMethod.DeclaredAccessibility < property.GetMethod.DeclaredAccessibility; + } + + if (symbol is IFieldSymbol field) + { + return field.IsReadOnly; + } + + return true; + } + + private void AnalyzeMemberReference(OperationAnalysisContext ctxt, ITypeSymbol messagePackSerializationOptionsTypeSymbol) + { + var memberReferenceOperation = (IMemberReferenceOperation)ctxt.Operation; + var referencedMember = memberReferenceOperation.Member; + if (SymbolEqualityComparer.Default.Equals(memberReferenceOperation.Type, messagePackSerializationOptionsTypeSymbol) && referencedMember.IsStatic && referencedMember.DeclaredAccessibility > Accessibility.Private && !IsLessWritableThanReadable(referencedMember)) + { + // The caller is passing in a value from a mutable static that is as writable as it is readable (a dangerous habit). + // TODO: fix ID, message, etc. to describe the problem. + ctxt.ReportDiagnostic(Diagnostic.Create(MutableSharedOptionsDescriptor, memberReferenceOperation.Syntax.GetLocation())); + } + } +} diff --git a/src/MessagePackAnalyzer/MsgPack00xMessagePackAnalyzer.cs b/src/MessagePack.Analyzers/MsgPack00xMessagePackAnalyzer.cs similarity index 99% rename from src/MessagePackAnalyzer/MsgPack00xMessagePackAnalyzer.cs rename to src/MessagePack.Analyzers/MsgPack00xMessagePackAnalyzer.cs index 597fb3d7a..6b584705e 100644 --- a/src/MessagePackAnalyzer/MsgPack00xMessagePackAnalyzer.cs +++ b/src/MessagePack.Analyzers/MsgPack00xMessagePackAnalyzer.cs @@ -7,7 +7,7 @@ using Microsoft.CodeAnalysis.CSharp.Syntax; using Microsoft.CodeAnalysis.Diagnostics; -namespace MessagePackAnalyzer; +namespace MessagePack.Analyzers; [DiagnosticAnalyzer(LanguageNames.CSharp)] public class MsgPack00xMessagePackAnalyzer : DiagnosticAnalyzer diff --git a/src/MessagePack.Analyzers/Properties/AssemblyInfo.cs b/src/MessagePack.Analyzers/Properties/AssemblyInfo.cs new file mode 100644 index 000000000..0c458607b --- /dev/null +++ b/src/MessagePack.Analyzers/Properties/AssemblyInfo.cs @@ -0,0 +1,6 @@ +// Copyright (c) All contributors. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +using System.Runtime.CompilerServices; + +[assembly: InternalsVisibleTo("MessagePack.Analyzers.CodeFixes, PublicKey=" + ThisAssembly.PublicKey)] diff --git a/src/MessagePackAnalyzer/Strings.Designer.cs b/src/MessagePack.Analyzers/Strings.Designer.cs similarity index 97% rename from src/MessagePackAnalyzer/Strings.Designer.cs rename to src/MessagePack.Analyzers/Strings.Designer.cs index 61ac9b4a1..8a0503562 100644 --- a/src/MessagePackAnalyzer/Strings.Designer.cs +++ b/src/MessagePack.Analyzers/Strings.Designer.cs @@ -8,7 +8,7 @@ // //------------------------------------------------------------------------------ -namespace MessagePackAnalyzer { +namespace MessagePack.Analyzers { using System; @@ -39,7 +39,7 @@ internal Strings() { internal static global::System.Resources.ResourceManager ResourceManager { get { if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("MessagePackAnalyzer.Strings", typeof(Strings).Assembly); + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("MessagePack.Analyzers.Strings", typeof(Strings).Assembly); resourceMan = temp; } return resourceMan; diff --git a/src/MessagePackAnalyzer/Strings.resx b/src/MessagePack.Analyzers/Strings.resx similarity index 100% rename from src/MessagePackAnalyzer/Strings.resx rename to src/MessagePack.Analyzers/Strings.resx diff --git a/src/MessagePackAnalyzer/Transforms/ShouldUseFormatterResolverHelper.cs b/src/MessagePack.Analyzers/Transforms/ShouldUseFormatterResolverHelper.cs similarity index 96% rename from src/MessagePackAnalyzer/Transforms/ShouldUseFormatterResolverHelper.cs rename to src/MessagePack.Analyzers/Transforms/ShouldUseFormatterResolverHelper.cs index 7852e3533..892f46222 100644 --- a/src/MessagePackAnalyzer/Transforms/ShouldUseFormatterResolverHelper.cs +++ b/src/MessagePack.Analyzers/Transforms/ShouldUseFormatterResolverHelper.cs @@ -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. -namespace MessagePackAnalyzer.Transforms; +namespace MessagePack.Analyzers.Transforms; public static class ShouldUseFormatterResolverHelper { diff --git a/src/MessagePackAnalyzer/Usings.cs b/src/MessagePack.Analyzers/Usings.cs similarity index 76% rename from src/MessagePackAnalyzer/Usings.cs rename to src/MessagePack.Analyzers/Usings.cs index 303bcb34f..4341e1664 100644 --- a/src/MessagePackAnalyzer/Usings.cs +++ b/src/MessagePack.Analyzers/Usings.cs @@ -1,4 +1,4 @@ // Copyright (c) All contributors. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -global using MessagePackAnalyzer.CodeAnalysis; +global using MessagePack.Analyzers.CodeAnalysis; diff --git a/src/MessagePackAnalyzer/Utils/AnalyzerUtilities.cs b/src/MessagePack.Analyzers/Utils/AnalyzerUtilities.cs similarity index 91% rename from src/MessagePackAnalyzer/Utils/AnalyzerUtilities.cs rename to src/MessagePack.Analyzers/Utils/AnalyzerUtilities.cs index 9e423f2fd..1094f05c5 100644 --- a/src/MessagePackAnalyzer/Utils/AnalyzerUtilities.cs +++ b/src/MessagePack.Analyzers/Utils/AnalyzerUtilities.cs @@ -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. -namespace MessagePackAnalyzer; +namespace MessagePack.Analyzers; internal static class AnalyzerUtilities { diff --git a/src/MessagePackAnalyzer/Utils/RoslynAnalyzerExtensions.cs b/src/MessagePack.Analyzers/Utils/RoslynAnalyzerExtensions.cs similarity index 99% rename from src/MessagePackAnalyzer/Utils/RoslynAnalyzerExtensions.cs rename to src/MessagePack.Analyzers/Utils/RoslynAnalyzerExtensions.cs index 2583b5412..7ec0994c4 100644 --- a/src/MessagePackAnalyzer/Utils/RoslynAnalyzerExtensions.cs +++ b/src/MessagePack.Analyzers/Utils/RoslynAnalyzerExtensions.cs @@ -5,7 +5,7 @@ using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp.Syntax; -namespace MessagePackAnalyzer; +namespace MessagePack.Analyzers; public static class RoslynAnalyzerExtensions { diff --git a/src/MessagePackAnalyzer/version.json b/src/MessagePack.Analyzers/version.json similarity index 100% rename from src/MessagePackAnalyzer/version.json rename to src/MessagePack.Analyzers/version.json diff --git a/src/MessagePack.SourceGenerator.Unity/MessagePackGenerator.cs b/src/MessagePack.SourceGenerator.Unity/MessagePackGenerator.cs index 7a2ac60f8..e4dd3a029 100644 --- a/src/MessagePack.SourceGenerator.Unity/MessagePackGenerator.cs +++ b/src/MessagePack.SourceGenerator.Unity/MessagePackGenerator.cs @@ -2,7 +2,7 @@ // Licensed under the MIT license. See LICENSE file in the project root for full license information. using System.Collections.Immutable; -using MessagePackAnalyzer.CodeAnalysis; +using MessagePack.Analyzers.CodeAnalysis; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp.Syntax; diff --git a/src/MessagePack.SourceGenerator/MessagePackGenerator.Emit.cs b/src/MessagePack.SourceGenerator/MessagePackGenerator.Emit.cs index 29ad5236b..f991e9545 100644 --- a/src/MessagePack.SourceGenerator/MessagePackGenerator.Emit.cs +++ b/src/MessagePack.SourceGenerator/MessagePackGenerator.Emit.cs @@ -2,8 +2,8 @@ // Licensed under the MIT license. See LICENSE file in the project root for full license information. using System.Text; +using MessagePack.Analyzers.CodeAnalysis; using MessagePack.SourceGenerator.Transforms; -using MessagePackAnalyzer.CodeAnalysis; using Microsoft.CodeAnalysis; namespace MessagePack.SourceGenerator; diff --git a/src/MessagePack.SourceGenerator/MessagePackGenerator.cs b/src/MessagePack.SourceGenerator/MessagePackGenerator.cs index 895d9324a..8c8a71452 100644 --- a/src/MessagePack.SourceGenerator/MessagePackGenerator.cs +++ b/src/MessagePack.SourceGenerator/MessagePackGenerator.cs @@ -2,11 +2,11 @@ // Licensed under the MIT license. See LICENSE file in the project root for full license information. using System.Collections.Immutable; -using MessagePackAnalyzer.CodeAnalysis; +using MessagePack.Analyzers.CodeAnalysis; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp.Syntax; using Microsoft.CodeAnalysis.Diagnostics; -using AnalyzerOptions = MessagePackAnalyzer.CodeAnalysis.AnalyzerOptions; +using AnalyzerOptions = MessagePack.Analyzers.CodeAnalysis.AnalyzerOptions; namespace MessagePack.SourceGenerator; diff --git a/src/MessagePack.SourceGenerator/Transforms/FormatterTemplate.cs b/src/MessagePack.SourceGenerator/Transforms/FormatterTemplate.cs index 3f318a7c4..9de8f7bd3 100644 --- a/src/MessagePack.SourceGenerator/Transforms/FormatterTemplate.cs +++ b/src/MessagePack.SourceGenerator/Transforms/FormatterTemplate.cs @@ -12,7 +12,7 @@ namespace MessagePack.SourceGenerator.Transforms using System.Linq; using System.Text; using System.Collections.Generic; - using MessagePackAnalyzer.Transforms; + using MessagePack.Analyzers.Transforms; using System; /// diff --git a/src/MessagePack.SourceGenerator/Transforms/IFormatterTemplate.cs b/src/MessagePack.SourceGenerator/Transforms/IFormatterTemplate.cs index 45316bcde..77e417ad3 100644 --- a/src/MessagePack.SourceGenerator/Transforms/IFormatterTemplate.cs +++ b/src/MessagePack.SourceGenerator/Transforms/IFormatterTemplate.cs @@ -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. -using MessagePackAnalyzer.CodeAnalysis; +using MessagePack.Analyzers.CodeAnalysis; namespace MessagePack.SourceGenerator.Transforms; diff --git a/src/MessagePack.SourceGenerator/Transforms/StringKey/StringKeyFormatterDeserializeHelper.cs b/src/MessagePack.SourceGenerator/Transforms/StringKey/StringKeyFormatterDeserializeHelper.cs index ec51953fd..8d3fa512d 100644 --- a/src/MessagePack.SourceGenerator/Transforms/StringKey/StringKeyFormatterDeserializeHelper.cs +++ b/src/MessagePack.SourceGenerator/Transforms/StringKey/StringKeyFormatterDeserializeHelper.cs @@ -2,8 +2,8 @@ // Licensed under the MIT license. See LICENSE file in the project root for full license information. using System.Text; +using MessagePack.Analyzers.CodeAnalysis; using MessagePack.Internal; -using MessagePackAnalyzer.CodeAnalysis; namespace MessagePack.SourceGenerator.Transforms; diff --git a/src/MessagePack.SourceGenerator/Transforms/StringKey/StringKeyFormatterTemplate.cs b/src/MessagePack.SourceGenerator/Transforms/StringKey/StringKeyFormatterTemplate.cs index 905d37a48..565dd0aa3 100644 --- a/src/MessagePack.SourceGenerator/Transforms/StringKey/StringKeyFormatterTemplate.cs +++ b/src/MessagePack.SourceGenerator/Transforms/StringKey/StringKeyFormatterTemplate.cs @@ -12,8 +12,8 @@ namespace MessagePack.SourceGenerator.Transforms using System; using System.Linq; using System.Collections.Generic; - using MessagePackAnalyzer.CodeAnalysis; - using MessagePackAnalyzer.Transforms; + using MessagePack.Analyzers.CodeAnalysis; + using MessagePack.Analyzers.Transforms; /// /// Class to produce the template output diff --git a/src/MessagePack.SourceGenerator/Transforms/TemplatePartials.cs b/src/MessagePack.SourceGenerator/Transforms/TemplatePartials.cs index 0a16cf5de..8aa63313e 100644 --- a/src/MessagePack.SourceGenerator/Transforms/TemplatePartials.cs +++ b/src/MessagePack.SourceGenerator/Transforms/TemplatePartials.cs @@ -3,7 +3,7 @@ #pragma warning disable SA1402 // File may only contain a single type -using MessagePackAnalyzer.CodeAnalysis; +using MessagePack.Analyzers.CodeAnalysis; namespace MessagePack.SourceGenerator.Transforms; diff --git a/src/MessagePackAnalyzer/MessagePackCodeFixProvider.cs b/src/MessagePackAnalyzer/MessagePackCodeFixProvider.cs deleted file mode 100644 index f210acc06..000000000 --- a/src/MessagePackAnalyzer/MessagePackCodeFixProvider.cs +++ /dev/null @@ -1,184 +0,0 @@ -// Copyright (c) All contributors. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - -using System; -using System.Collections.Immutable; -using System.Composition; -using System.Linq; -using System.Threading; -using System.Threading.Tasks; -using Microsoft.CodeAnalysis; -using Microsoft.CodeAnalysis.CodeActions; -using Microsoft.CodeAnalysis.CodeFixes; -using Microsoft.CodeAnalysis.CSharp; -using Microsoft.CodeAnalysis.CSharp.Syntax; -using Microsoft.CodeAnalysis.Editing; - -namespace MessagePackAnalyzer -{ - [ExportCodeFixProvider(LanguageNames.CSharp, Name = nameof(MessagePackCodeFixProvider)), Shared] - public class MessagePackCodeFixProvider : CodeFixProvider - { - public sealed override ImmutableArray FixableDiagnosticIds - { - get - { - return ImmutableArray.Create( - MsgPack00xMessagePackAnalyzer.PublicMemberNeedsKey.Id, - MsgPack00xMessagePackAnalyzer.TypeMustBeMessagePackObject.Id); - } - } - - public sealed override FixAllProvider GetFixAllProvider() - { - return WellKnownFixAllProviders.BatchFixer; - } - - public sealed override async Task RegisterCodeFixesAsync(CodeFixContext context) - { - var root = await context.Document.GetSyntaxRootAsync(context.CancellationToken).ConfigureAwait(false) as CompilationUnitSyntax; - if (root is null) - { - return; - } - - SemanticModel? model = await context.Document.GetSemanticModelAsync(context.CancellationToken).ConfigureAwait(false); - if (model is null) - { - return; - } - - SyntaxNode targetNode = root.FindNode(context.Span); - TypeInfo myTypeInfo = model.GetTypeInfo(targetNode, context.CancellationToken); - - string? typeName = context.Diagnostics[0]?.Properties.GetValueOrDefault("type", null); - INamedTypeSymbol? namedSymbol = - myTypeInfo.Type as INamedTypeSymbol ?? - (typeName is not null ? model.Compilation.GetTypeByMetadataName(typeName.Replace("global::", string.Empty)) : null); - - if (namedSymbol is null) - { - var property = targetNode as PropertyDeclarationSyntax; - var field = targetNode as FieldDeclarationSyntax; - var dec = targetNode as VariableDeclaratorSyntax; - IdentifierNameSyntax? identifierName = targetNode as IdentifierNameSyntax; - - ITypeSymbol? targetType = null; - if (property == null && field == null) - { - var typeDeclare = targetNode as TypeDeclarationSyntax; - if (typeDeclare != null) - { - targetType = model.GetDeclaredSymbol(typeDeclare); - } - else if (dec != null) - { - var fieldOrProperty = model.GetDeclaredSymbol(dec) as ISymbol; - if (context.Diagnostics[0].Id == MsgPack00xMessagePackAnalyzer.TypeMustBeMessagePackObject.Id) - { - targetType = (fieldOrProperty as IPropertySymbol)?.Type; - if (targetType == null) - { - targetType = (fieldOrProperty as IFieldSymbol)?.Type; - } - } - else - { - targetType = (fieldOrProperty as IPropertySymbol)?.ContainingType; - if (targetType == null) - { - targetType = (fieldOrProperty as IFieldSymbol)?.ContainingType; - } - } - } - } - else - { - if (context.Diagnostics[0].Id == MsgPack00xMessagePackAnalyzer.TypeMustBeMessagePackObject.Id) - { - targetType = (property != null) - ? (model.GetDeclaredSymbol(property) as IPropertySymbol)?.Type - : (model.GetDeclaredSymbol(field!) as IFieldSymbol)?.Type; - } - else - { - targetType = (property != null) - ? (model.GetDeclaredSymbol(property) as IPropertySymbol)?.ContainingType - : (model.GetDeclaredSymbol(field!) as IFieldSymbol)?.ContainingType; - } - } - - if (targetType == null) - { - return; - } - - if (targetType.TypeKind == TypeKind.Array) - { - targetType = ((IArrayTypeSymbol)targetType).ElementType; - } - - namedSymbol = targetType as INamedTypeSymbol; - if (namedSymbol == null) - { - return; - } - } - - var action = CodeAction.Create("Add MessagePack KeyAttribute", c => AddKeyAttributeAsync(context.Document, namedSymbol, c), "MessagePackAnalyzer.AddKeyAttribute"); - - context.RegisterCodeFix(action, context.Diagnostics.First()); // use single. - } - - private static async Task AddKeyAttributeAsync(Document document, INamedTypeSymbol type, CancellationToken cancellationToken) - { - var solutionEditor = new SolutionEditor(document.Project.Solution); - - ISymbol[] targets = type.GetAllMembers() - .Where(x => x.Kind == SymbolKind.Property || x.Kind == SymbolKind.Field) - .Where(x => x.GetAttributes().FindAttributeShortName(MsgPack00xMessagePackAnalyzer.IgnoreShortName) == null && x.GetAttributes().FindAttributeShortName(MsgPack00xMessagePackAnalyzer.IgnoreDataMemberShortName) == null) - .Where(x => !x.IsStatic) - .Where(x => - { - return x switch - { - IPropertySymbol p => p.ExplicitInterfaceImplementations.Length == 0, - IFieldSymbol f => !f.IsImplicitlyDeclared, - _ => throw new NotSupportedException("Unsupported member type."), - }; - }) - .ToArray(); - - var startOrder = targets - .Select(x => x.GetAttributes().FindAttributeShortName(MsgPack00xMessagePackAnalyzer.KeyAttributeShortName)) - .Where(x => x != null) - .Select(x => x.ConstructorArguments[0]) - .Where(x => !x.IsNull) - .Where(x => x.Value is int) - .Select(x => (int)x.Value!) - .DefaultIfEmpty(-1) // if empty, start from zero. - .Max() + 1; - - foreach (ISymbol member in targets) - { - if (member.GetAttributes().FindAttributeShortName(MsgPack00xMessagePackAnalyzer.KeyAttributeShortName) is null) - { - SyntaxNode node = await member.DeclaringSyntaxReferences[0].GetSyntaxAsync(cancellationToken).ConfigureAwait(false); - var documentEditor = await solutionEditor.GetDocumentEditorAsync(document.Project.Solution.GetDocumentId(node.SyntaxTree), cancellationToken).ConfigureAwait(false); - var syntaxGenerator = SyntaxGenerator.GetGenerator(documentEditor.OriginalDocument); - documentEditor.AddAttribute(node, syntaxGenerator.Attribute("MessagePack.KeyAttribute", syntaxGenerator.LiteralExpression(startOrder++))); - } - } - - if (type.GetAttributes().FindAttributeShortName(MsgPack00xMessagePackAnalyzer.MessagePackObjectAttributeShortName) == null) - { - SyntaxNode node = await type.DeclaringSyntaxReferences[0].GetSyntaxAsync(cancellationToken).ConfigureAwait(false); - var documentEditor = await solutionEditor.GetDocumentEditorAsync(document.Project.Solution.GetDocumentId(node.SyntaxTree), cancellationToken).ConfigureAwait(false); - var syntaxGenerator = SyntaxGenerator.GetGenerator(documentEditor.OriginalDocument); - documentEditor.AddAttribute(node, syntaxGenerator.Attribute("MessagePack.MessagePackObject")); - } - - return solutionEditor.GetChangedSolution(); - } - } -} diff --git a/src/MessagePackAnalyzer/MsgPack001SpecifyOptionsAnalyzer.cs b/src/MessagePackAnalyzer/MsgPack001SpecifyOptionsAnalyzer.cs deleted file mode 100644 index 7d1539fef..000000000 --- a/src/MessagePackAnalyzer/MsgPack001SpecifyOptionsAnalyzer.cs +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright (c) All contributors. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - -using System.Collections.Immutable; -using System.Linq; -using Microsoft.CodeAnalysis; -using Microsoft.CodeAnalysis.Diagnostics; -using Microsoft.CodeAnalysis.Operations; - -namespace MessagePackAnalyzer -{ - /// - /// An analyzer that guards against calling APIs that rely on static, mutable fields defining "default" options. - /// - [DiagnosticAnalyzer(LanguageNames.CSharp, LanguageNames.VisualBasic)] - public class MsgPack001SpecifyOptionsAnalyzer : DiagnosticAnalyzer - { - public const string MissingOptionsId = "MsgPack001"; - - public static readonly DiagnosticDescriptor MissingOptionsDescriptor = new DiagnosticDescriptor( - id: MissingOptionsId, - title: new LocalizableResourceString(nameof(Strings.MsgPack001_Title), Strings.ResourceManager, typeof(Strings)), - messageFormat: new LocalizableResourceString(nameof(Strings.MsgPack001_MessageFormat), Strings.ResourceManager, typeof(Strings)), - category: "Reliability", - defaultSeverity: DiagnosticSeverity.Warning, - isEnabledByDefault: false, - description: new LocalizableResourceString(nameof(Strings.MsgPack001_Description), Strings.ResourceManager, typeof(Strings)), - helpLinkUri: AnalyzerUtilities.GetHelpLink(MissingOptionsId)); - - private static readonly ImmutableArray ReusableSupportedDiagnostics = ImmutableArray.Create(MissingOptionsDescriptor); - - public override ImmutableArray SupportedDiagnostics => ReusableSupportedDiagnostics; - - public override void Initialize(AnalysisContext context) - { - context.ConfigureGeneratedCodeAnalysis(GeneratedCodeAnalysisFlags.Analyze | GeneratedCodeAnalysisFlags.ReportDiagnostics); - context.EnableConcurrentExecution(); - context.RegisterCompilationStartAction(compilationStartContext => - { - ITypeSymbol? messagePackSerializationOptionsTypeSymbol = compilationStartContext.Compilation.GetTypeByMetadataName("MessagePack.MessagePackSerializerOptions"); - if (messagePackSerializationOptionsTypeSymbol is object) - { - compilationStartContext.RegisterOperationAction(c => this.AnalyzeInvocation(c, messagePackSerializationOptionsTypeSymbol), OperationKind.Invocation); - } - }); - } - - private void AnalyzeInvocation(OperationAnalysisContext ctxt, ITypeSymbol messagePackSerializationOptionsTypeSymbol) - { - var operation = (IInvocationOperation)ctxt.Operation; - - // Is this an invocation on a method defined in the MessagePack assembly? - if (SymbolEqualityComparer.Default.Equals(operation.TargetMethod.ContainingAssembly, messagePackSerializationOptionsTypeSymbol.ContainingAssembly)) - { - var optionsArg = operation.Arguments.FirstOrDefault(arg => SymbolEqualityComparer.Default.Equals(arg.Value?.Type, messagePackSerializationOptionsTypeSymbol)); - if (optionsArg is object && optionsArg.Value.IsImplicit) - { - // The caller is omitting a MessagePackSerializerOptions argument or setting it to null. - ctxt.ReportDiagnostic(Diagnostic.Create(MissingOptionsDescriptor, optionsArg.Value.Syntax.GetLocation())); - } - } - } - } -} diff --git a/src/MessagePackAnalyzer/MsgPack002UseConstantOptionsAnalyzer.cs b/src/MessagePackAnalyzer/MsgPack002UseConstantOptionsAnalyzer.cs deleted file mode 100644 index 6efdd00ff..000000000 --- a/src/MessagePackAnalyzer/MsgPack002UseConstantOptionsAnalyzer.cs +++ /dev/null @@ -1,87 +0,0 @@ -// Copyright (c) All contributors. All rights reserved. -// Licensed under the MIT license. See LICENSE file in the project root for full license information. - -using System.Collections.Immutable; -using Microsoft.CodeAnalysis; -using Microsoft.CodeAnalysis.Diagnostics; -using Microsoft.CodeAnalysis.Operations; - -namespace MessagePackAnalyzer -{ - /// - /// An analyzer to guide callers to avoid use of mutable static fields for MessagePackSerializerOptions. - /// - [DiagnosticAnalyzer(LanguageNames.CSharp, LanguageNames.VisualBasic)] - public class MsgPack002UseConstantOptionsAnalyzer : DiagnosticAnalyzer - { - public const string MutableSharedOptionsId = "MsgPack002"; - - public static readonly DiagnosticDescriptor MutableSharedOptionsDescriptor = new DiagnosticDescriptor( - id: MutableSharedOptionsId, - title: new LocalizableResourceString(nameof(Strings.MsgPack002_Title), Strings.ResourceManager, typeof(Strings)), - messageFormat: new LocalizableResourceString(nameof(Strings.MsgPack002_MessageFormat), Strings.ResourceManager, typeof(Strings)), - category: "Reliability", - defaultSeverity: DiagnosticSeverity.Warning, - isEnabledByDefault: false, - description: new LocalizableResourceString(nameof(Strings.MsgPack002_Description), Strings.ResourceManager, typeof(Strings)), - helpLinkUri: AnalyzerUtilities.GetHelpLink(MutableSharedOptionsId)); - - private static readonly ImmutableArray ReusableSupportedDiagnostics = ImmutableArray.Create(MutableSharedOptionsDescriptor); - - public override ImmutableArray SupportedDiagnostics => ReusableSupportedDiagnostics; - - public override void Initialize(AnalysisContext context) - { - context.ConfigureGeneratedCodeAnalysis(GeneratedCodeAnalysisFlags.Analyze | GeneratedCodeAnalysisFlags.ReportDiagnostics); - context.EnableConcurrentExecution(); - context.RegisterCompilationStartAction(compilationStartContext => - { - ITypeSymbol? messagePackSerializationOptionsTypeSymbol = compilationStartContext.Compilation.GetTypeByMetadataName("MessagePack.MessagePackSerializerOptions"); - if (messagePackSerializationOptionsTypeSymbol is object) - { - compilationStartContext.RegisterOperationAction(c => this.AnalyzeMemberReference(c, messagePackSerializationOptionsTypeSymbol), OperationKind.PropertyReference, OperationKind.FieldReference); - } - }); - } - - private static bool IsLessWritableThanReadable(ISymbol symbol) - { - if (symbol is IPropertySymbol property) - { - if (property.GetMethod is null) - { - // The property has no getter, so the calling code has other problems. - // Don't report a problem. - return true; - } - - if (property.SetMethod is null) - { - // If the property has no setter, we're totally good. - return true; - } - - return property.SetMethod.DeclaredAccessibility < property.GetMethod.DeclaredAccessibility; - } - - if (symbol is IFieldSymbol field) - { - return field.IsReadOnly; - } - - return true; - } - - private void AnalyzeMemberReference(OperationAnalysisContext ctxt, ITypeSymbol messagePackSerializationOptionsTypeSymbol) - { - var memberReferenceOperation = (IMemberReferenceOperation)ctxt.Operation; - var referencedMember = memberReferenceOperation.Member; - if (SymbolEqualityComparer.Default.Equals(memberReferenceOperation.Type, messagePackSerializationOptionsTypeSymbol) && referencedMember.IsStatic && referencedMember.DeclaredAccessibility > Accessibility.Private && !IsLessWritableThanReadable(referencedMember)) - { - // The caller is passing in a value from a mutable static that is as writable as it is readable (a dangerous habit). - // TODO: fix ID, message, etc. to describe the problem. - ctxt.ReportDiagnostic(Diagnostic.Create(MutableSharedOptionsDescriptor, memberReferenceOperation.Syntax.GetLocation())); - } - } - } -} diff --git a/src/SourceGenerator.props b/src/SourceGenerator.props index 6fd180d89..537bf4a95 100644 --- a/src/SourceGenerator.props +++ b/src/SourceGenerator.props @@ -16,6 +16,6 @@ - + diff --git a/tests/MessagePack.SourceGenerator.Tests/MessagePack.SourceGenerator.Tests.csproj b/tests/MessagePack.SourceGenerator.Tests/MessagePack.SourceGenerator.Tests.csproj index 6b9471c53..7493caf0e 100644 --- a/tests/MessagePack.SourceGenerator.Tests/MessagePack.SourceGenerator.Tests.csproj +++ b/tests/MessagePack.SourceGenerator.Tests/MessagePack.SourceGenerator.Tests.csproj @@ -25,7 +25,7 @@ - + diff --git a/tests/MessagePack.SourceGenerator.Tests/Usings.cs b/tests/MessagePack.SourceGenerator.Tests/Usings.cs index b02988250..88e92a2c8 100644 --- a/tests/MessagePack.SourceGenerator.Tests/Usings.cs +++ b/tests/MessagePack.SourceGenerator.Tests/Usings.cs @@ -2,7 +2,7 @@ // Licensed under the MIT license. See LICENSE file in the project root for full license information. global using System.Collections.Immutable; -global using MessagePackAnalyzer.CodeAnalysis; +global using MessagePack.Analyzers.CodeAnalysis; global using Xunit; global using Xunit.Abstractions; global using VerifyCS = CSharpSourceGeneratorVerifier; diff --git a/tests/MessagePack.SourceGenerator.Unity.Tests/MessagePack.SourceGenerator.Unity.Tests.csproj b/tests/MessagePack.SourceGenerator.Unity.Tests/MessagePack.SourceGenerator.Unity.Tests.csproj index ed44f5a46..6bbccfae3 100644 --- a/tests/MessagePack.SourceGenerator.Unity.Tests/MessagePack.SourceGenerator.Unity.Tests.csproj +++ b/tests/MessagePack.SourceGenerator.Unity.Tests/MessagePack.SourceGenerator.Unity.Tests.csproj @@ -30,7 +30,7 @@ - + diff --git a/tests/MessagePackAnalyzer.Tests/MessagePackAnalyzer.Tests.csproj b/tests/MessagePackAnalyzer.Tests/MessagePackAnalyzer.Tests.csproj index 60f472c0a..97a72dcbf 100644 --- a/tests/MessagePackAnalyzer.Tests/MessagePackAnalyzer.Tests.csproj +++ b/tests/MessagePackAnalyzer.Tests/MessagePackAnalyzer.Tests.csproj @@ -17,7 +17,8 @@ - + + diff --git a/tests/MessagePackAnalyzer.Tests/MessagePackAnalyzerTests.cs b/tests/MessagePackAnalyzer.Tests/MessagePackAnalyzerTests.cs index 9589b75b0..fc899b378 100644 --- a/tests/MessagePackAnalyzer.Tests/MessagePackAnalyzerTests.cs +++ b/tests/MessagePackAnalyzer.Tests/MessagePackAnalyzerTests.cs @@ -6,7 +6,7 @@ using Microsoft.CodeAnalysis.Testing; using Xunit; using VerifyCS = - CSharpCodeFixVerifier; + CSharpCodeFixVerifier; public class MessagePackAnalyzerTests { diff --git a/tests/MessagePackAnalyzer.Tests/MsgPack001SpecifyOptionsAnalyzerTests.cs b/tests/MessagePackAnalyzer.Tests/MsgPack001SpecifyOptionsAnalyzerTests.cs index 4cb406cec..a2a2a9ccd 100644 --- a/tests/MessagePackAnalyzer.Tests/MsgPack001SpecifyOptionsAnalyzerTests.cs +++ b/tests/MessagePackAnalyzer.Tests/MsgPack001SpecifyOptionsAnalyzerTests.cs @@ -3,11 +3,11 @@ using System; using System.Threading.Tasks; -using MessagePackAnalyzer; +using MessagePack.Analyzers; using Microsoft.CodeAnalysis; using Xunit; -using VerifyCS = CSharpCodeFixVerifier; -using VerifyVB = VisualBasicCodeFixVerifier; +using VerifyCS = CSharpCodeFixVerifier; +using VerifyVB = VisualBasicCodeFixVerifier; public class MsgPack001SpecifyOptionsAnalyzerTests { diff --git a/tests/MessagePackAnalyzer.Tests/MsgPack002UseConstantOptionsAnalyzerTests.cs b/tests/MessagePackAnalyzer.Tests/MsgPack002UseConstantOptionsAnalyzerTests.cs index 544e9a3a6..0ecab7b83 100644 --- a/tests/MessagePackAnalyzer.Tests/MsgPack002UseConstantOptionsAnalyzerTests.cs +++ b/tests/MessagePackAnalyzer.Tests/MsgPack002UseConstantOptionsAnalyzerTests.cs @@ -3,11 +3,11 @@ using System; using System.Threading.Tasks; -using MessagePackAnalyzer; +using MessagePack.Analyzers; using Microsoft.CodeAnalysis; using Xunit; -using VerifyCS = CSharpCodeFixVerifier; -using VerifyVB = VisualBasicCodeFixVerifier; +using VerifyCS = CSharpCodeFixVerifier; +using VerifyVB = VisualBasicCodeFixVerifier; public class MsgPack002UseConstantOptionsAnalyzerTests { diff --git a/tests/SourceGeneratorConsumer.props b/tests/SourceGeneratorConsumer.props index 354485d0c..5597e591c 100644 --- a/tests/SourceGeneratorConsumer.props +++ b/tests/SourceGeneratorConsumer.props @@ -6,7 +6,7 @@ Analyzer false - + Analyzer false From 40a53f23fbe56caa9b8ad89bb9fd66a409fe02a9 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Wed, 12 Apr 2023 10:10:38 -0600 Subject: [PATCH 097/660] Add incremental clean of zip staging directory --- .../MessagePack.SourceGenerator.Unity.csproj | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/MessagePack.SourceGenerator.Unity/MessagePack.SourceGenerator.Unity.csproj b/src/MessagePack.SourceGenerator.Unity/MessagePack.SourceGenerator.Unity.csproj index a5b6894d6..9748aea66 100644 --- a/src/MessagePack.SourceGenerator.Unity/MessagePack.SourceGenerator.Unity.csproj +++ b/src/MessagePack.SourceGenerator.Unity/MessagePack.SourceGenerator.Unity.csproj @@ -19,14 +19,19 @@ + + $(IntermediateOutputPath)zip\ + + + $(ZipStagingDirectory)%(FileName)%(Extension) + + - - $(IntermediateOutputPath)zip - - + + From 46ab8bf74210c0f6436a72ffa357e0bc501ad8d9 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Wed, 12 Apr 2023 10:12:18 -0600 Subject: [PATCH 098/660] Rename analyzer test project --- MessagePack.sln | 2 +- .../Helpers/CSharpCodeFixVerifier`2+Test.cs | 0 .../Helpers/CSharpCodeFixVerifier`2.cs | 0 .../Helpers/ReferencesHelper.cs | 0 .../Helpers/VisualBasicCodeFixVerifier`2+Test.cs | 0 .../Helpers/VisualBasicCodeFixVerifier`2.cs | 0 .../MessagePack.Analyzers.Tests.csproj} | 0 .../MessagePackAnalyzerTests.cs | 0 .../MsgPack001SpecifyOptionsAnalyzerTests.cs | 0 .../MsgPack002UseConstantOptionsAnalyzerTests.cs | 0 10 files changed, 1 insertion(+), 1 deletion(-) rename tests/{MessagePackAnalyzer.Tests => MessagePack.Analyzers.Tests}/Helpers/CSharpCodeFixVerifier`2+Test.cs (100%) rename tests/{MessagePackAnalyzer.Tests => MessagePack.Analyzers.Tests}/Helpers/CSharpCodeFixVerifier`2.cs (100%) rename tests/{MessagePackAnalyzer.Tests => MessagePack.Analyzers.Tests}/Helpers/ReferencesHelper.cs (100%) rename tests/{MessagePackAnalyzer.Tests => MessagePack.Analyzers.Tests}/Helpers/VisualBasicCodeFixVerifier`2+Test.cs (100%) rename tests/{MessagePackAnalyzer.Tests => MessagePack.Analyzers.Tests}/Helpers/VisualBasicCodeFixVerifier`2.cs (100%) rename tests/{MessagePackAnalyzer.Tests/MessagePackAnalyzer.Tests.csproj => MessagePack.Analyzers.Tests/MessagePack.Analyzers.Tests.csproj} (100%) rename tests/{MessagePackAnalyzer.Tests => MessagePack.Analyzers.Tests}/MessagePackAnalyzerTests.cs (100%) rename tests/{MessagePackAnalyzer.Tests => MessagePack.Analyzers.Tests}/MsgPack001SpecifyOptionsAnalyzerTests.cs (100%) rename tests/{MessagePackAnalyzer.Tests => MessagePack.Analyzers.Tests}/MsgPack002UseConstantOptionsAnalyzerTests.cs (100%) diff --git a/MessagePack.sln b/MessagePack.sln index d7a831d72..8327f23ad 100644 --- a/MessagePack.sln +++ b/MessagePack.sln @@ -83,7 +83,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MessagePack.Internal.Tests" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MessagePack.SourceGenerator", "src\MessagePack.SourceGenerator\MessagePack.SourceGenerator.csproj", "{32C91908-5CAD-4C95-B240-ACBBACAC9476}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MessagePackAnalyzer.Tests", "tests\MessagePackAnalyzer.Tests\MessagePackAnalyzer.Tests.csproj", "{7E5FB4B9-A0F5-4B10-A1F3-03AC0BC8265A}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MessagePack.Analyzers.Tests", "tests\MessagePack.Analyzers.Tests\MessagePack.Analyzers.Tests.csproj", "{7E5FB4B9-A0F5-4B10-A1F3-03AC0BC8265A}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MessagePack.SourceGenerator.Tests", "tests\MessagePack.SourceGenerator.Tests\MessagePack.SourceGenerator.Tests.csproj", "{6AC51E68-4681-463A-B4B6-BD53517244B2}" EndProject diff --git a/tests/MessagePackAnalyzer.Tests/Helpers/CSharpCodeFixVerifier`2+Test.cs b/tests/MessagePack.Analyzers.Tests/Helpers/CSharpCodeFixVerifier`2+Test.cs similarity index 100% rename from tests/MessagePackAnalyzer.Tests/Helpers/CSharpCodeFixVerifier`2+Test.cs rename to tests/MessagePack.Analyzers.Tests/Helpers/CSharpCodeFixVerifier`2+Test.cs diff --git a/tests/MessagePackAnalyzer.Tests/Helpers/CSharpCodeFixVerifier`2.cs b/tests/MessagePack.Analyzers.Tests/Helpers/CSharpCodeFixVerifier`2.cs similarity index 100% rename from tests/MessagePackAnalyzer.Tests/Helpers/CSharpCodeFixVerifier`2.cs rename to tests/MessagePack.Analyzers.Tests/Helpers/CSharpCodeFixVerifier`2.cs diff --git a/tests/MessagePackAnalyzer.Tests/Helpers/ReferencesHelper.cs b/tests/MessagePack.Analyzers.Tests/Helpers/ReferencesHelper.cs similarity index 100% rename from tests/MessagePackAnalyzer.Tests/Helpers/ReferencesHelper.cs rename to tests/MessagePack.Analyzers.Tests/Helpers/ReferencesHelper.cs diff --git a/tests/MessagePackAnalyzer.Tests/Helpers/VisualBasicCodeFixVerifier`2+Test.cs b/tests/MessagePack.Analyzers.Tests/Helpers/VisualBasicCodeFixVerifier`2+Test.cs similarity index 100% rename from tests/MessagePackAnalyzer.Tests/Helpers/VisualBasicCodeFixVerifier`2+Test.cs rename to tests/MessagePack.Analyzers.Tests/Helpers/VisualBasicCodeFixVerifier`2+Test.cs diff --git a/tests/MessagePackAnalyzer.Tests/Helpers/VisualBasicCodeFixVerifier`2.cs b/tests/MessagePack.Analyzers.Tests/Helpers/VisualBasicCodeFixVerifier`2.cs similarity index 100% rename from tests/MessagePackAnalyzer.Tests/Helpers/VisualBasicCodeFixVerifier`2.cs rename to tests/MessagePack.Analyzers.Tests/Helpers/VisualBasicCodeFixVerifier`2.cs diff --git a/tests/MessagePackAnalyzer.Tests/MessagePackAnalyzer.Tests.csproj b/tests/MessagePack.Analyzers.Tests/MessagePack.Analyzers.Tests.csproj similarity index 100% rename from tests/MessagePackAnalyzer.Tests/MessagePackAnalyzer.Tests.csproj rename to tests/MessagePack.Analyzers.Tests/MessagePack.Analyzers.Tests.csproj diff --git a/tests/MessagePackAnalyzer.Tests/MessagePackAnalyzerTests.cs b/tests/MessagePack.Analyzers.Tests/MessagePackAnalyzerTests.cs similarity index 100% rename from tests/MessagePackAnalyzer.Tests/MessagePackAnalyzerTests.cs rename to tests/MessagePack.Analyzers.Tests/MessagePackAnalyzerTests.cs diff --git a/tests/MessagePackAnalyzer.Tests/MsgPack001SpecifyOptionsAnalyzerTests.cs b/tests/MessagePack.Analyzers.Tests/MsgPack001SpecifyOptionsAnalyzerTests.cs similarity index 100% rename from tests/MessagePackAnalyzer.Tests/MsgPack001SpecifyOptionsAnalyzerTests.cs rename to tests/MessagePack.Analyzers.Tests/MsgPack001SpecifyOptionsAnalyzerTests.cs diff --git a/tests/MessagePackAnalyzer.Tests/MsgPack002UseConstantOptionsAnalyzerTests.cs b/tests/MessagePack.Analyzers.Tests/MsgPack002UseConstantOptionsAnalyzerTests.cs similarity index 100% rename from tests/MessagePackAnalyzer.Tests/MsgPack002UseConstantOptionsAnalyzerTests.cs rename to tests/MessagePack.Analyzers.Tests/MsgPack002UseConstantOptionsAnalyzerTests.cs From 69f78d1079947db97cf090e356854dcacdda139e Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Wed, 12 Apr 2023 10:50:35 -0600 Subject: [PATCH 099/660] Update documentation for using source generators --- README.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 00ed533c1..94e393481 100644 --- a/README.md +++ b/README.md @@ -1586,15 +1586,16 @@ For all other Unity targets, AOT is required. If you want to avoid the upfront dynamic generation cost or you need to run on Xamarin or Unity, you need AOT code generation. ```ps1 -dotnet add package MessagePack.Generator +dotnet add package MessagePack.SourceGenerator ``` Or for Unity, use the source generator that targets the older Roslyn compiler. [Setting up a source generator for unity](https://docs.unity3d.com/Manual/roslyn-analyzers.html) is a bit more involved. The unity instructions describe copying the analyzer .dll into your unity project. -You should get the analyzer .dll from the the unity source generator .zip file uploaded on our GitHub releases page. +You should get the analyzer/source generator .dll's from the the `MessagePack.SourceGenerator.Unity.zip` file uploaded on our GitHub releases page. +Be sure to add _all_ the .dlls in that .zip as analyzers. -This package adds a roslyn Source Generator that produces `IMessagePackFormatter` implementing classes for each of your `[MessagePackObject]` classes. +The package (or unity .zip file) adds a roslyn Source Generator that produces `IMessagePackFormatter` implementing classes for each of your `[MessagePackObject]` classes. These formatters are aggregated into a generated `IMessagePackResolver` class named `GeneratedMessagePackResolver`. This class will be generated into the `$(RootNamespace)` of your project, or the `MessagePack` namespace if `RootNamespace` is empty or undefined. From 8dc25455b973930538966dc687a20019fc28e70a Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Wed, 12 Apr 2023 10:58:00 -0600 Subject: [PATCH 100/660] Fix analyzer and source generator in unity --- Directory.Packages.props | 2 +- README.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Directory.Packages.props b/Directory.Packages.props index 7139cc3b5..ad6ca4034 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -77,7 +77,7 @@ - + diff --git a/README.md b/README.md index 94e393481..1af284700 100644 --- a/README.md +++ b/README.md @@ -1598,7 +1598,7 @@ Be sure to add _all_ the .dlls in that .zip as analyzers. The package (or unity .zip file) adds a roslyn Source Generator that produces `IMessagePackFormatter` implementing classes for each of your `[MessagePackObject]` classes. These formatters are aggregated into a generated `IMessagePackResolver` class named `GeneratedMessagePackResolver`. -This class will be generated into the `$(RootNamespace)` of your project, or the `MessagePack` namespace if `RootNamespace` is empty or undefined. +This class will be generated into the `$(RootNamespace)` of your project, or the `MessagePack` namespace if `RootNamespace` is empty or undefined (as in Unity). Leveraging these formatters at runtime requires that you opt-in, which typically looks like this: From 6bdaaf0a01849ad4eeb150005fb4f864b658ddbf Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Wed, 12 Apr 2023 12:08:18 -0600 Subject: [PATCH 101/660] Bring back support for the additional allow types The switch to source generation accidentally dropped support for this, but #1598 drew attention to its importance so I've fixed it and added a test. --- .../CodeAnalysis/AnalyzerOptions.cs | 17 +++-- .../CodeAnalysis/TypeCollector.cs | 4 +- .../GenerationTests.cs | 16 +++++ ...peWithAutoGeneratedFormatterFormatter.g.cs | 56 +++++++++++++++ ...sagePack.GeneratedMessagePackResolver.g.cs | 70 +++++++++++++++++++ .../Usings.cs | 2 +- .../CSharpSourceGeneratorVerifier`1+Test.cs | 28 ++++++-- 7 files changed, 173 insertions(+), 20 deletions(-) create mode 100644 tests/MessagePack.SourceGenerator.Tests/Resources/AdditionalAllowTypes/Formatters.TypeWithAutoGeneratedFormatterFormatter.g.cs create mode 100644 tests/MessagePack.SourceGenerator.Tests/Resources/AdditionalAllowTypes/MessagePack.GeneratedMessagePackResolver.g.cs diff --git a/src/MessagePack.Analyzers/CodeAnalysis/AnalyzerOptions.cs b/src/MessagePack.Analyzers/CodeAnalysis/AnalyzerOptions.cs index 1fe586c53..619dc94d8 100644 --- a/src/MessagePack.Analyzers/CodeAnalysis/AnalyzerOptions.cs +++ b/src/MessagePack.Analyzers/CodeAnalysis/AnalyzerOptions.cs @@ -14,21 +14,20 @@ public record AnalyzerOptions( string ProjectRootNamespace = "", bool PublicResolver = false, bool UsesMapMode = false, - IReadOnlyCollection? IgnoreTypeNames = null, - IReadOnlyCollection? AdditionalAllowTypes = null) + ImmutableHashSet? AdditionalAllowTypes = null) { public const string RootNamespace = "build_property.RootNamespace"; public const string PublicMessagePackGeneratedResolver = "build_property.PublicMessagePackGeneratedResolver"; public const string MessagePackGeneratedResolverNamespace = "build_property.MessagePackGeneratedResolverNamespace"; public const string MessagePackGeneratedResolverName = "build_property.MessagePackGeneratedResolverName"; public const string MessagePackGeneratedUsesMapMode = "build_property.MessagePackGeneratedUsesMapMode"; - private const string JsonOptionsFileName = "MessagePackAnalyzer.json"; + public const string JsonOptionsFileName = "MessagePackAnalyzer.json"; public static readonly AnalyzerOptions Default = new AnalyzerOptions(); public string FormatterNamespace => "Formatters"; - public static AnalyzerOptions Parse(Microsoft.CodeAnalysis.Diagnostics.AnalyzerConfigOptions options, ImmutableArray additionalTexts) + public static AnalyzerOptions Parse(AnalyzerConfigOptions options, ImmutableArray additionalTexts) { if (!options.TryGetValue(RootNamespace, out string? projectRootNamespace)) { @@ -64,18 +63,18 @@ public static AnalyzerOptions Parse(Microsoft.CodeAnalysis.Diagnostics.AnalyzerC AdditionalAllowTypes: GetAdditionalAllowTypes(additionalTexts)); } - private static IReadOnlyCollection GetAdditionalAllowTypes(ImmutableArray additionalTexts) + private static ImmutableHashSet GetAdditionalAllowTypes(ImmutableArray additionalTexts) { Microsoft.CodeAnalysis.AdditionalText? config = additionalTexts.FirstOrDefault(x => string.Equals(Path.GetFileName(x.Path), JsonOptionsFileName, StringComparison.OrdinalIgnoreCase)); if (config is null) { - return Array.Empty(); + return ImmutableHashSet.Empty; } try { JsonDocument json = JsonDocument.Parse(config.GetText()?.ToString() ?? string.Empty, new JsonDocumentOptions { AllowTrailingCommas = true, CommentHandling = JsonCommentHandling.Skip, MaxDepth = 5 }); - List allowTypes = new(); + var allowTypes = ImmutableHashSet.CreateBuilder(); if (json.RootElement.ValueKind == JsonValueKind.Array) { foreach (var element in json.RootElement.EnumerateArray()) @@ -87,12 +86,12 @@ private static IReadOnlyCollection GetAdditionalAllowTypes(ImmutableArra } } - return allowTypes; + return allowTypes.ToImmutable(); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine("Can't load MessagePackAnalyzer.json: " + ex); - return Array.Empty(); + return ImmutableHashSet.Empty; } } } diff --git a/src/MessagePack.Analyzers/CodeAnalysis/TypeCollector.cs b/src/MessagePack.Analyzers/CodeAnalysis/TypeCollector.cs index ab8c3be3c..fe1274aec 100644 --- a/src/MessagePack.Analyzers/CodeAnalysis/TypeCollector.cs +++ b/src/MessagePack.Analyzers/CodeAnalysis/TypeCollector.cs @@ -188,7 +188,6 @@ public class TypeCollector private readonly Action? reportDiagnostic; private readonly ITypeSymbol? targetType; private readonly bool excludeArrayElement; - private readonly HashSet externalIgnoreTypeNames; // visitor workspace: #pragma warning disable RS1024 // Compare symbols correctly (https://github.com/dotnet/roslyn-analyzers/issues/5246) @@ -207,7 +206,6 @@ private TypeCollector(Compilation compilation, AnalyzerOptions options, Referenc this.reportDiagnostic = reportDiagnostic; this.isForceUseMap = options.UsesMapMode; this.options = options; - this.externalIgnoreTypeNames = new HashSet(options.IgnoreTypeNames ?? Array.Empty()); this.compilation = compilation; this.excludeArrayElement = true; @@ -292,7 +290,7 @@ private bool CollectCore(ITypeSymbol typeSymbol) return result; } - if (this.externalIgnoreTypeNames.Contains(typeSymbolString)) + if (this.options.AdditionalAllowTypes?.Contains(typeSymbolString) is true) { result = true; this.alreadyCollected.Add(typeSymbol, result); diff --git a/tests/MessagePack.SourceGenerator.Tests/GenerationTests.cs b/tests/MessagePack.SourceGenerator.Tests/GenerationTests.cs index 41d84a339..155f51124 100644 --- a/tests/MessagePack.SourceGenerator.Tests/GenerationTests.cs +++ b/tests/MessagePack.SourceGenerator.Tests/GenerationTests.cs @@ -164,4 +164,20 @@ public class GenericClass """; await VerifyCS.Test.RunDefaultAsync(testSource); } + + [Fact] + public async Task AdditionalAllowTypes() + { + string testSource = Preamble + """ +class MyCustomType { } + +[MessagePackObject] +class TypeWithAutoGeneratedFormatter +{ + [Key(0)] + public MyCustomType Value { get; set; } +} +"""; + await VerifyCS.Test.RunDefaultAsync(testSource, options: AnalyzerOptions.Default with { AdditionalAllowTypes = ImmutableHashSet.Empty.Add("MyCustomType") }); + } } diff --git a/tests/MessagePack.SourceGenerator.Tests/Resources/AdditionalAllowTypes/Formatters.TypeWithAutoGeneratedFormatterFormatter.g.cs b/tests/MessagePack.SourceGenerator.Tests/Resources/AdditionalAllowTypes/Formatters.TypeWithAutoGeneratedFormatterFormatter.g.cs new file mode 100644 index 000000000..7e1403be6 --- /dev/null +++ b/tests/MessagePack.SourceGenerator.Tests/Resources/AdditionalAllowTypes/Formatters.TypeWithAutoGeneratedFormatterFormatter.g.cs @@ -0,0 +1,56 @@ +// + +#pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 + +#pragma warning disable CS8669 // We may leak nullable annotations into generated code. + +namespace Formatters +{ + using MsgPack = global::MessagePack; + + internal sealed class TypeWithAutoGeneratedFormatterFormatter : MsgPack::Formatters.IMessagePackFormatter + { + + public void Serialize(ref MsgPack::MessagePackWriter writer, global::TypeWithAutoGeneratedFormatter value, MsgPack::MessagePackSerializerOptions options) + { + if (value == null) + { + writer.WriteNil(); + return; + } + + MsgPack::IFormatterResolver formatterResolver = options.Resolver; + writer.WriteArrayHeader(1); + MsgPack::FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Serialize(ref writer, value.Value, options); + } + + public global::TypeWithAutoGeneratedFormatter Deserialize(ref MsgPack::MessagePackReader reader, MsgPack::MessagePackSerializerOptions options) + { + if (reader.TryReadNil()) + { + return null; + } + + options.Security.DepthStep(ref reader); + MsgPack::IFormatterResolver formatterResolver = options.Resolver; + var length = reader.ReadArrayHeader(); + var ____result = new global::TypeWithAutoGeneratedFormatter(); + + for (int i = 0; i < length; i++) + { + switch (i) + { + case 0: + ____result.Value = MsgPack::FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Deserialize(ref reader, options); + break; + default: + reader.Skip(); + break; + } + } + + reader.Depth--; + return ____result; + } + } +} diff --git a/tests/MessagePack.SourceGenerator.Tests/Resources/AdditionalAllowTypes/MessagePack.GeneratedMessagePackResolver.g.cs b/tests/MessagePack.SourceGenerator.Tests/Resources/AdditionalAllowTypes/MessagePack.GeneratedMessagePackResolver.g.cs new file mode 100644 index 000000000..b5ca1194c --- /dev/null +++ b/tests/MessagePack.SourceGenerator.Tests/Resources/AdditionalAllowTypes/MessagePack.GeneratedMessagePackResolver.g.cs @@ -0,0 +1,70 @@ +// + +#pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 + +namespace MessagePack +{ + using MsgPack = global::MessagePack; + using Formatters = global::Formatters; + + /// A MessagePack resolver that uses generated formatters for types in this assembly. + internal class GeneratedMessagePackResolver : MsgPack::IFormatterResolver + { + /// An instance of this resolver that only returns formatters specifically generated for types in this assembly. + public static readonly MsgPack::IFormatterResolver Instance = new GeneratedMessagePackResolver(); + + /// An instance of this resolver that returns standard AOT-compatible formatters as well as formatters specifically generated for types in this assembly. + public static readonly MsgPack::IFormatterResolver InstanceWithStandardAotResolver = MsgPack::Resolvers.CompositeResolver.Create(Instance, MsgPack::Resolvers.StandardAotResolver.Instance); + + private GeneratedMessagePackResolver() + { + } + + public MsgPack::Formatters.IMessagePackFormatter GetFormatter() + { + return FormatterCache.Formatter; + } + + private static class FormatterCache + { + internal static readonly MsgPack::Formatters.IMessagePackFormatter Formatter; + + static FormatterCache() + { + var f = GeneratedMessagePackResolverGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + Formatter = (MsgPack::Formatters.IMessagePackFormatter)f; + } + } + } + } + + internal static class GeneratedMessagePackResolverGetFormatterHelper + { + private static readonly global::System.Collections.Generic.Dictionary lookup; + + static GeneratedMessagePackResolverGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(1) + { + { typeof(global::TypeWithAutoGeneratedFormatter), 0 }, + }; + } + + internal static object GetFormatter(global::System.Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + case 0: return new Formatters::TypeWithAutoGeneratedFormatterFormatter(); + default: return null; + } + } + } +} diff --git a/tests/MessagePack.SourceGenerator.Tests/Usings.cs b/tests/MessagePack.SourceGenerator.Tests/Usings.cs index 88e92a2c8..09d83a5d3 100644 --- a/tests/MessagePack.SourceGenerator.Tests/Usings.cs +++ b/tests/MessagePack.SourceGenerator.Tests/Usings.cs @@ -5,4 +5,4 @@ global using MessagePack.Analyzers.CodeAnalysis; global using Xunit; global using Xunit.Abstractions; -global using VerifyCS = CSharpSourceGeneratorVerifier; +global using VerifyCS = CSharpSourceGeneratorVerifier; diff --git a/tests/MessagePack.SourceGenerator.Tests/Verifiers/CSharpSourceGeneratorVerifier`1+Test.cs b/tests/MessagePack.SourceGenerator.Tests/Verifiers/CSharpSourceGeneratorVerifier`1+Test.cs index 774a8fb2c..69432b00b 100644 --- a/tests/MessagePack.SourceGenerator.Tests/Verifiers/CSharpSourceGeneratorVerifier`1+Test.cs +++ b/tests/MessagePack.SourceGenerator.Tests/Verifiers/CSharpSourceGeneratorVerifier`1+Test.cs @@ -12,20 +12,19 @@ using System.Reflection; using System.Runtime.CompilerServices; using System.Text; +using System.Text.Json; using MessagePack; +using MessagePack.Analyzers; using MessagePack.SourceGenerator; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp.Testing; +using Microsoft.CodeAnalysis.Diagnostics; using Microsoft.CodeAnalysis.Testing; using Microsoft.CodeAnalysis.Testing.Verifiers; +using AnalyzerOptions = MessagePack.Analyzers.CodeAnalysis.AnalyzerOptions; -public static partial class CSharpSourceGeneratorVerifier -#if UNITY - where TSourceGenerator : ISourceGenerator, new() -#else - where TSourceGenerator : IIncrementalGenerator, new() -#endif +public static partial class CSharpSourceGeneratorVerifier { public class Test : CSharpSourceGeneratorTest { @@ -66,6 +65,7 @@ public AnalyzerOptions Options } this.TestState.AnalyzerConfigFiles.Add((filename, ConstructGlobalConfigString(value))); + this.TestState.AdditionalFiles.Add(($"./{AnalyzerOptions.JsonOptionsFileName}", ConstructConfigJsonString(value))); } } @@ -112,7 +112,15 @@ public Test AddGeneratedSources([CallerMemberName] string? testMethod = null) protected override IEnumerable GetSourceGenerators() { - yield return typeof(TSourceGenerator); + yield return typeof(MessagePackGenerator); + } + + protected override IEnumerable GetDiagnosticAnalyzers() + { + foreach (Type analyzer in typeof(MsgPack001SpecifyOptionsAnalyzer).Assembly.GetTypes().Where(t => typeof(DiagnosticAnalyzer).IsAssignableFrom(t))) + { + yield return (DiagnosticAnalyzer)Activator.CreateInstance(analyzer)!; + } } protected override CompilationOptions CreateCompilationOptions() @@ -172,6 +180,12 @@ private static void WriteTreeToDiskIfNecessary(SyntaxTree tree, string resourceD File.WriteAllText(filePath, tree.GetText().ToString(), tree.Encoding); } + private static string ConstructConfigJsonString(AnalyzerOptions options) + { + string json = JsonSerializer.Serialize(options.AdditionalAllowTypes, new JsonSerializerOptions { WriteIndented = true }); + return json; + } + private static string ConstructGlobalConfigString(AnalyzerOptions options) { StringBuilder globalConfigBuilder = new(); From d3208d90b90266627213fd4dfd47914faea4a3ea Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Thu, 13 Apr 2023 06:55:22 -0600 Subject: [PATCH 102/660] Report diagnostics instead of throw from TypeCollector --- .../AnalyzerReleases.Unshipped.md | 10 +- .../CodeAnalysis/AnalyzerOptions.cs | 5 + .../CodeAnalysis/TypeCollector.cs | 59 ++++++---- .../MsgPack00xMessagePackAnalyzer.cs | 102 ++++++++++++++++++ .../MessagePackGenerator.cs | 2 +- .../MessagePackGenerator.cs | 2 +- 6 files changed, 154 insertions(+), 26 deletions(-) diff --git a/src/MessagePack.Analyzers/AnalyzerReleases.Unshipped.md b/src/MessagePack.Analyzers/AnalyzerReleases.Unshipped.md index 20f9e3881..008db619f 100644 --- a/src/MessagePack.Analyzers/AnalyzerReleases.Unshipped.md +++ b/src/MessagePack.Analyzers/AnalyzerReleases.Unshipped.md @@ -7,7 +7,9 @@ Rule ID | Category | Severity | Notes --------|----------|----------|------- MsgPack001 | Reliability | Disabled | MsgPack001SpecifyOptionsAnalyzer MsgPack002 | Reliability | Disabled | MsgPack002UseConstantOptionsAnalyzer -MsgPack003 | Usage | Error | MessagePackAnalyzer -MsgPack004 | Usage | Error | MessagePackAnalyzer -MsgPack005 | Usage | Error | MessagePackAnalyzer -MsgPack006 | Usage | Error | MessagePackAnalyzer \ No newline at end of file +MsgPack003 | Usage | Error | MsgPack00xMessagePackAnalyzer +MsgPack004 | Usage | Error | MsgPack00xMessagePackAnalyzer +MsgPack005 | Usage | Error | MsgPack00xMessagePackAnalyzer +MsgPack006 | Usage | Error | MsgPack00xMessagePackAnalyzer +MsgPack007 | Usage | Error | MsgPack00xMessagePackAnalyzer +MsgPack008 | Usage | Error | MsgPack00xMessagePackAnalyzer \ No newline at end of file diff --git a/src/MessagePack.Analyzers/CodeAnalysis/AnalyzerOptions.cs b/src/MessagePack.Analyzers/CodeAnalysis/AnalyzerOptions.cs index 619dc94d8..de50e7350 100644 --- a/src/MessagePack.Analyzers/CodeAnalysis/AnalyzerOptions.cs +++ b/src/MessagePack.Analyzers/CodeAnalysis/AnalyzerOptions.cs @@ -27,6 +27,11 @@ public record AnalyzerOptions( public string FormatterNamespace => "Formatters"; + /// + /// Gets a value indicating whether the analyzer is generating source code. + /// + public bool IsGeneratingSource { get; init; } + public static AnalyzerOptions Parse(AnalyzerConfigOptions options, ImmutableArray additionalTexts) { if (!options.TryGetValue(RootNamespace, out string? projectRootNamespace)) diff --git a/src/MessagePack.Analyzers/CodeAnalysis/TypeCollector.cs b/src/MessagePack.Analyzers/CodeAnalysis/TypeCollector.cs index fe1274aec..d67d5a32b 100644 --- a/src/MessagePack.Analyzers/CodeAnalysis/TypeCollector.cs +++ b/src/MessagePack.Analyzers/CodeAnalysis/TypeCollector.cs @@ -9,6 +9,7 @@ using System.Text.RegularExpressions; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp.Syntax; +using Microsoft.CodeAnalysis.Operations; namespace MessagePack.Analyzers.CodeAnalysis; @@ -378,18 +379,25 @@ private bool CollectEnum(INamedTypeSymbol type, ISymbol enumUnderlyingType) private bool CollectUnion(INamedTypeSymbol type) { + if (!options.IsGeneratingSource) + { + // In analyzer-only mode, this method doesn't work. + return true; + } + ImmutableArray[] unionAttrs = type.GetAttributes().Where(x => x.AttributeClass.ApproximatelyEqual(this.typeReferences.UnionAttribute)).Select(x => x.ConstructorArguments).ToArray(); if (unionAttrs.Length == 0) { - throw new MessagePackGeneratorResolveFailedException("Serialization Type must mark UnionAttribute." + " type: " + type.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat)); + this.reportDiagnostic?.Invoke(Diagnostic.Create(MsgPack00xMessagePackAnalyzer.UnionAttributeRequired, type.DeclaringSyntaxReferences.FirstOrDefault()?.GetSyntax().GetLocation())); } // 0, Int 1, SubType - UnionSubTypeInfo UnionSubTypeInfoSelector(ImmutableArray x) + UnionSubTypeInfo? UnionSubTypeInfoSelector(ImmutableArray x) { if (!(x[0] is { Value: int key }) || !(x[1] is { Value: ITypeSymbol typeSymbol })) { - throw new NotSupportedException("AOT code generation only supports UnionAttribute that uses a Type parameter, but the " + type.ToDisplayString(SymbolDisplayFormat.CSharpErrorMessageFormat) + " type uses an unsupported parameter."); + this.reportDiagnostic?.Invoke(Diagnostic.Create(MsgPack00xMessagePackAnalyzer.AotUnionAttributeRequiresTypeArg, GetIdentifierLocation(type))); + return null; } var typeName = typeSymbol.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat); @@ -400,7 +408,7 @@ UnionSubTypeInfo UnionSubTypeInfoSelector(ImmutableArray x) type.ContainingNamespace.IsGlobalNamespace ? null : type.ContainingNamespace.ToDisplayString(), type.Name, type.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat), - unionAttrs.Select(UnionSubTypeInfoSelector).OrderBy(x => x.Key).ToArray()); + unionAttrs.Select(UnionSubTypeInfoSelector).Where(i => i is not null).OrderBy(x => x!.Key).ToArray()!); this.collectedUnionInfo.Add(info); return true; @@ -439,7 +447,7 @@ private bool CollectArray(IArrayTypeSymbol array) var fullName = array.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat); var elementTypeDisplayName = elemType.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat); - string formatterName; + string? formatterName; if (array.IsSZArray) { formatterName = "MsgPack::Formatters.ArrayFormatter<" + elementTypeDisplayName + ">"; @@ -451,8 +459,13 @@ private bool CollectArray(IArrayTypeSymbol array) 2 => "MsgPack::Formatters.TwoDimensionalArrayFormatter<" + elementTypeDisplayName + ">", 3 => "MsgPack::Formatters.ThreeDimensionalArrayFormatter<" + elementTypeDisplayName + ">", 4 => "MsgPack::Formatters.FourDimensionalArrayFormatter<" + elementTypeDisplayName + ">", - _ => throw new InvalidOperationException("does not supports array dimension, " + fullName), + _ => null, }; + if (formatterName is null) + { + ////this.reportDiagnostic?.Invoke(Diagnostic.Create(MsgPack00xMessagePackAnalyzer.AotArrayRankTooHigh)); + return false; + } } var info = new GenericSerializationInfo(fullName, formatterName, elemType is ITypeParameterSymbol); @@ -782,7 +795,7 @@ private bool CheckValidMessagePackFormatterAttribute(AttributeData formatterAttr { if ((isIntKey && intKey == null) || (!isIntKey && stringKey == null)) { - throw new MessagePackGeneratorResolveFailedException("all members key type must be same." + " type: " + type.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat) + " member:" + item.Name); + this.reportDiagnostic?.Invoke(Diagnostic.Create(MsgPack00xMessagePackAnalyzer.DoNotMixStringAndIntKeys, item.DeclaringSyntaxReferences.FirstOrDefault()?.GetSyntax().GetLocation())); } } @@ -790,7 +803,7 @@ private bool CheckValidMessagePackFormatterAttribute(AttributeData formatterAttr { if (intMembers.ContainsKey(intKey!.Value)) { - throw new MessagePackGeneratorResolveFailedException("key is duplicated, all members key must be unique." + " type: " + type.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat) + " member:" + item.Name); + this.reportDiagnostic?.Invoke(Diagnostic.Create(MsgPack00xMessagePackAnalyzer.KeysMustBeUnique, item.DeclaringSyntaxReferences.FirstOrDefault()?.GetSyntax().GetLocation())); } var member = new MemberSerializationInfo(true, isWritable, isReadable, intKey!.Value, item.Name, item.Name, item.Type.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat), item.Type.ToDisplayString(BinaryWriteFormat), customFormatterAttr?.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat)); @@ -800,7 +813,7 @@ private bool CheckValidMessagePackFormatterAttribute(AttributeData formatterAttr { if (stringMembers.ContainsKey(stringKey!)) { - throw new MessagePackGeneratorResolveFailedException("key is duplicated, all members key must be unique." + " type: " + type.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat) + " member:" + item.Name); + this.reportDiagnostic?.Invoke(Diagnostic.Create(MsgPack00xMessagePackAnalyzer.KeysMustBeUnique, item.DeclaringSyntaxReferences.FirstOrDefault()?.GetSyntax().GetLocation())); } var member = new MemberSerializationInfo(true, isWritable, isReadable, hiddenIntKey++, stringKey!, item.Name, item.Type.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat), item.Type.ToDisplayString(BinaryWriteFormat), customFormatterAttr?.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat)); @@ -855,7 +868,7 @@ private bool CheckValidMessagePackFormatterAttribute(AttributeData formatterAttr var stringKey = key is { Value: string stringKeyValue } ? stringKeyValue : default; if (intKey == null && stringKey == null) { - throw new MessagePackGeneratorResolveFailedException("both IntKey and StringKey are null." + " type: " + type.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat) + " member:" + item.Name); + this.reportDiagnostic?.Invoke(Diagnostic.Create(MsgPack00xMessagePackAnalyzer.BothStringAndIntKeyAreNull, item.DeclaringSyntaxReferences.FirstOrDefault()?.GetSyntax().GetLocation())); } if (searchFirst) @@ -867,7 +880,7 @@ private bool CheckValidMessagePackFormatterAttribute(AttributeData formatterAttr { if ((isIntKey && intKey == null) || (!isIntKey && stringKey == null)) { - throw new MessagePackGeneratorResolveFailedException("all members key type must be same." + " type: " + type.Name + " member:" + item.Name); + this.reportDiagnostic?.Invoke(Diagnostic.Create(MsgPack00xMessagePackAnalyzer.DoNotMixStringAndIntKeys, item.DeclaringSyntaxReferences.FirstOrDefault()?.GetSyntax().GetLocation())); } } @@ -875,7 +888,7 @@ private bool CheckValidMessagePackFormatterAttribute(AttributeData formatterAttr { if (intMembers.ContainsKey(intKey!.Value)) { - throw new MessagePackGeneratorResolveFailedException("key is duplicated, all members key must be unique." + " type: " + type.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat) + " member:" + item.Name); + this.reportDiagnostic?.Invoke(Diagnostic.Create(MsgPack00xMessagePackAnalyzer.KeysMustBeUnique, item.DeclaringSyntaxReferences.FirstOrDefault()?.GetSyntax().GetLocation())); } var member = new MemberSerializationInfo(true, isWritable, isReadable, intKey!.Value, item.Name, item.Name, item.Type.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat), item.Type.ToDisplayString(BinaryWriteFormat), customFormatterAttr?.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat)); @@ -885,7 +898,7 @@ private bool CheckValidMessagePackFormatterAttribute(AttributeData formatterAttr { if (stringMembers.ContainsKey(stringKey!)) { - throw new MessagePackGeneratorResolveFailedException("key is duplicated, all members key must be unique." + " type: " + type.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat) + " member:" + item.Name); + this.reportDiagnostic?.Invoke(Diagnostic.Create(MsgPack00xMessagePackAnalyzer.KeysMustBeUnique, item.DeclaringSyntaxReferences.FirstOrDefault()?.GetSyntax().GetLocation())); } var member = new MemberSerializationInfo(true, isWritable, isReadable, hiddenIntKey++, stringKey!, item.Name, item.Type.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat), item.Type.ToDisplayString(BinaryWriteFormat), customFormatterAttr?.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat)); @@ -913,7 +926,7 @@ private bool CheckValidMessagePackFormatterAttribute(AttributeData formatterAttr // struct allows null ctor if (ctor == null && isClass) { - throw new MessagePackGeneratorResolveFailedException("can't find public constructor. type:" + type.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat)); + this.reportDiagnostic?.Invoke(Diagnostic.Create(MsgPack00xMessagePackAnalyzer.NoDeserializingConstructor, GetIdentifierLocation(type))); } var constructorParameters = new List(); @@ -944,7 +957,7 @@ private bool CheckValidMessagePackFormatterAttribute(AttributeData formatterAttr } else { - throw new MessagePackGeneratorResolveFailedException("can't find matched constructor parameter, parameterType mismatch. type:" + type.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat) + " parameterIndex:" + ctorParamIndex + " parameterType:" + item.Type.Name); + this.reportDiagnostic?.Invoke(Diagnostic.Create(MsgPack00xMessagePackAnalyzer.DeserializingConstructorParameterTypeMismatch, GetLocation(item))); } } } @@ -957,7 +970,7 @@ private bool CheckValidMessagePackFormatterAttribute(AttributeData formatterAttr } else { - throw new MessagePackGeneratorResolveFailedException("can't find matched constructor parameter, index not found. type:" + type.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat) + " parameterIndex:" + ctorParamIndex); + this.reportDiagnostic?.Invoke(Diagnostic.Create(MsgPack00xMessagePackAnalyzer.DeserializingConstructorParameterIndexMissing, GetParameterListLocation(ctor))); } } } @@ -971,7 +984,7 @@ private bool CheckValidMessagePackFormatterAttribute(AttributeData formatterAttr { if (ctorEnumerator == null) { - throw new MessagePackGeneratorResolveFailedException("can't find matched constructor parameter, index not found. type:" + type.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat) + " parameterName:" + item.Name); + this.reportDiagnostic?.Invoke(Diagnostic.Create(MsgPack00xMessagePackAnalyzer.DeserializingConstructorParameterNameMissing, GetParameterListLocation(ctor))); } ctor = null; @@ -985,7 +998,7 @@ private bool CheckValidMessagePackFormatterAttribute(AttributeData formatterAttr { if (ctorEnumerator == null) { - throw new MessagePackGeneratorResolveFailedException("duplicate matched constructor parameter name:" + type.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat) + " parameterName:" + item.Name + " parameterType:" + item.Type.Name); + this.reportDiagnostic?.Invoke(Diagnostic.Create(MsgPack00xMessagePackAnalyzer.DeserializingConstructorParameterNameDuplicate, GetLocation(item))); } ctor = null; @@ -1001,7 +1014,7 @@ private bool CheckValidMessagePackFormatterAttribute(AttributeData formatterAttr { if (ctorEnumerator == null) { - throw new MessagePackGeneratorResolveFailedException("can't find matched constructor parameter, parameterType mismatch. type:" + type.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat) + " parameterName:" + item.Name + " parameterType:" + item.Type.Name); + this.reportDiagnostic?.Invoke(Diagnostic.Create(MsgPack00xMessagePackAnalyzer.DeserializingConstructorParameterTypeMismatch, GetLocation(item))); } ctor = null; @@ -1016,7 +1029,7 @@ private bool CheckValidMessagePackFormatterAttribute(AttributeData formatterAttr if (ctor == null) { - throw new MessagePackGeneratorResolveFailedException("can't find matched constructor. type:" + type.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat)); + this.reportDiagnostic?.Invoke(Diagnostic.Create(MsgPack00xMessagePackAnalyzer.NoDeserializingConstructor, GetIdentifierLocation(type))); } } @@ -1078,6 +1091,12 @@ private static GenericTypeParameterInfo ToGenericTypeParameterInfo(ITypeParamete return new GenericTypeParameterInfo(typeParameter.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat), string.Join(", ", constraints)); } + private static Location? GetIdentifierLocation(INamedTypeSymbol type) => ((BaseTypeDeclarationSyntax?)type.DeclaringSyntaxReferences.FirstOrDefault()?.GetSyntax())?.Identifier.GetLocation(); + + private static Location? GetLocation(IParameterSymbol parameter) => parameter.DeclaringSyntaxReferences.FirstOrDefault()?.GetSyntax().GetLocation(); + + private static Location? GetParameterListLocation(IMethodSymbol? method) => ((BaseMethodDeclarationSyntax?)method?.DeclaringSyntaxReferences.FirstOrDefault()?.GetSyntax())?.ParameterList.GetLocation(); + private static string GetGenericFormatterClassName(INamedTypeSymbol type) { return type.Name; diff --git a/src/MessagePack.Analyzers/MsgPack00xMessagePackAnalyzer.cs b/src/MessagePack.Analyzers/MsgPack00xMessagePackAnalyzer.cs index 6b584705e..c6fe72dd4 100644 --- a/src/MessagePack.Analyzers/MsgPack00xMessagePackAnalyzer.cs +++ b/src/MessagePack.Analyzers/MsgPack00xMessagePackAnalyzer.cs @@ -16,6 +16,8 @@ public class MsgPack00xMessagePackAnalyzer : DiagnosticAnalyzer public const string AttributeMessagePackObjectMembersId = "MsgPack004"; public const string InvalidMessagePackObjectId = "MsgPack005"; public const string MessagePackFormatterMustBeMessagePackFormatterId = "MsgPack006"; + public const string DeserializingConstructorId = "MsgPack007"; + public const string AOTLimitationsId = "MsgPack008"; internal const string Category = "Usage"; @@ -85,6 +87,106 @@ public class MsgPack00xMessagePackAnalyzer : DiagnosticAnalyzer isEnabledByDefault: true, helpLinkUri: AnalyzerUtilities.GetHelpLink(InvalidMessagePackObjectId)); + internal static readonly DiagnosticDescriptor DoNotMixStringAndIntKeys = new DiagnosticDescriptor( + id: InvalidMessagePackObjectId, + title: "Attribute public members of MessagePack objects", + category: Category, + messageFormat: "All KeyAttribute arguments must be of the same type (either string or int)", + description: "Use string or int keys consistently.", + defaultSeverity: DiagnosticSeverity.Error, + isEnabledByDefault: true, + helpLinkUri: AnalyzerUtilities.GetHelpLink(InvalidMessagePackObjectId)); + + internal static readonly DiagnosticDescriptor KeysMustBeUnique = new DiagnosticDescriptor( + id: InvalidMessagePackObjectId, + title: "Attribute public members of MessagePack objects", + category: Category, + messageFormat: "All KeyAttribute arguments must be unique", + description: "Each key must be unique.", + defaultSeverity: DiagnosticSeverity.Error, + isEnabledByDefault: true, + helpLinkUri: AnalyzerUtilities.GetHelpLink(InvalidMessagePackObjectId)); + + internal static readonly DiagnosticDescriptor UnionAttributeRequired = new DiagnosticDescriptor( + id: InvalidMessagePackObjectId, + title: "Attribute public members of MessagePack objects", + category: Category, + messageFormat: "This type must carry a UnionAttribute", + description: "A UnionAttribute is required on interfaces and abstract base classes used as serialized types.", + defaultSeverity: DiagnosticSeverity.Error, + isEnabledByDefault: true, + helpLinkUri: AnalyzerUtilities.GetHelpLink(InvalidMessagePackObjectId)); + + internal static readonly DiagnosticDescriptor NoDeserializingConstructor = new DiagnosticDescriptor( + id: DeserializingConstructorId, + title: "Deserializing constructors", + category: Category, + messageFormat: "Cannot find a public constructor", + description: "A deserializable type must carry a public constructor.", + defaultSeverity: DiagnosticSeverity.Error, + isEnabledByDefault: true, + helpLinkUri: AnalyzerUtilities.GetHelpLink(DeserializingConstructorId)); + + internal static readonly DiagnosticDescriptor DeserializingConstructorParameterTypeMismatch = new DiagnosticDescriptor( + id: DeserializingConstructorId, + title: "Deserializing constructors", + category: Category, + messageFormat: "Deserializing constructor parameter type mismatch", + description: "Constructor parameter types must match the serializable members.", + defaultSeverity: DiagnosticSeverity.Error, + isEnabledByDefault: true, + helpLinkUri: AnalyzerUtilities.GetHelpLink(DeserializingConstructorId)); + + internal static readonly DiagnosticDescriptor DeserializingConstructorParameterIndexMissing = new DiagnosticDescriptor( + id: DeserializingConstructorId, + title: "Deserializing constructors", + category: Category, + messageFormat: "Deserializing constructor parameter count mismatch", + description: "Constructor parameter count must meet or exceed the number of serialized members or the highest key index.", + defaultSeverity: DiagnosticSeverity.Error, + isEnabledByDefault: true, + helpLinkUri: AnalyzerUtilities.GetHelpLink(DeserializingConstructorId)); + + internal static readonly DiagnosticDescriptor DeserializingConstructorParameterNameMissing = new DiagnosticDescriptor( + id: DeserializingConstructorId, + title: "Deserializing constructors", + category: Category, + messageFormat: "Deserializing constructor parameter name mismatch", + description: "Parameter names must match the serialized members' named keys.", + defaultSeverity: DiagnosticSeverity.Error, + isEnabledByDefault: true, + helpLinkUri: AnalyzerUtilities.GetHelpLink(DeserializingConstructorId)); + + internal static readonly DiagnosticDescriptor DeserializingConstructorParameterNameDuplicate = new DiagnosticDescriptor( + id: DeserializingConstructorId, + title: "Deserializing constructors", + category: Category, + messageFormat: "Duplicate matched constructor parameter name", + description: "Parameter names must match the serialized members' named keys.", + defaultSeverity: DiagnosticSeverity.Error, + isEnabledByDefault: true, + helpLinkUri: AnalyzerUtilities.GetHelpLink(DeserializingConstructorId)); + + internal static readonly DiagnosticDescriptor AotUnionAttributeRequiresTypeArg = new DiagnosticDescriptor( + id: AOTLimitationsId, + title: "AOT limitations", + category: Category, + messageFormat: "The source generator only supports UnionAttribute with a Type argument", + description: "Use a type argument with UnionAttribute.", + defaultSeverity: DiagnosticSeverity.Error, + isEnabledByDefault: true, + helpLinkUri: AnalyzerUtilities.GetHelpLink(AOTLimitationsId)); + + internal static readonly DiagnosticDescriptor AotArrayRankTooHigh = new DiagnosticDescriptor( + id: AOTLimitationsId, + title: "AOT limitations", + category: Category, + messageFormat: "Array rank too high for built-in array formatters", + description: "Avoid excessively high array ranks, or write a custom formatter.", + defaultSeverity: DiagnosticSeverity.Error, + isEnabledByDefault: true, + helpLinkUri: AnalyzerUtilities.GetHelpLink(AOTLimitationsId)); + public override ImmutableArray SupportedDiagnostics { get; } = ImmutableArray.Create( TypeMustBeMessagePackObject, PublicMemberNeedsKey, diff --git a/src/MessagePack.SourceGenerator.Unity/MessagePackGenerator.cs b/src/MessagePack.SourceGenerator.Unity/MessagePackGenerator.cs index e4dd3a029..ced1c6e90 100644 --- a/src/MessagePack.SourceGenerator.Unity/MessagePackGenerator.cs +++ b/src/MessagePack.SourceGenerator.Unity/MessagePackGenerator.cs @@ -31,7 +31,7 @@ public void Execute(GeneratorExecutionContext context) return; } - AnalyzerOptions options = AnalyzerOptions.Parse(context.AnalyzerConfigOptions.GlobalOptions, context.AdditionalFiles); + AnalyzerOptions options = AnalyzerOptions.Parse(context.AnalyzerConfigOptions.GlobalOptions, context.AdditionalFiles) with { IsGeneratingSource = true }; List modelPerType = new(); foreach (var syntax in receiver.ClassDeclarations) diff --git a/src/MessagePack.SourceGenerator/MessagePackGenerator.cs b/src/MessagePack.SourceGenerator/MessagePackGenerator.cs index 8c8a71452..80cd74920 100644 --- a/src/MessagePack.SourceGenerator/MessagePackGenerator.cs +++ b/src/MessagePack.SourceGenerator/MessagePackGenerator.cs @@ -19,7 +19,7 @@ public partial class MessagePackGenerator : IIncrementalGenerator public void Initialize(IncrementalGeneratorInitializationContext context) { var options = context.AdditionalTextsProvider.Collect().Combine(context.AnalyzerConfigOptionsProvider).Select( - ((ImmutableArray AdditionalFiles, AnalyzerConfigOptionsProvider Options) t, CancellationToken ct) => AnalyzerOptions.Parse(t.Options.GlobalOptions, t.AdditionalFiles)); + ((ImmutableArray AdditionalFiles, AnalyzerConfigOptionsProvider Options) t, CancellationToken ct) => AnalyzerOptions.Parse(t.Options.GlobalOptions, t.AdditionalFiles) with { IsGeneratingSource = true }); var messagePackObjectTypes = context.SyntaxProvider.ForAttributeWithMetadataName( MessagePackObjectAttributeFullName, From 2c933490c4eb4013a84d8f631b319230c3dd5384 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Wed, 12 Apr 2023 20:10:08 -0600 Subject: [PATCH 103/660] Enable P2P generic test --- .../GenericsFormatterTests.cs | 12 +-- .../MessagePack.SourceGenerator.Tests.csproj | 4 + ...pProject.MyGenericObjectFormatter_T_.g.cs} | 0 ...agePack.GeneratedMessagePackResolver.g.cs} | 0 ...mpProject.MyGenericObjectFormatter_T_.g.cs | 56 +++++++++++++ ...atters.TempProject.MyObjectFormatter.g.cs} | 0 ....TempProject.MyObjectNestedFormatter.g.cs} | 0 ...sagePack.GeneratedMessagePackResolver.g.cs | 76 +++++++++++++++++ .../CSharpSourceGeneratorVerifier`1+Test.cs | 82 ++++++++++++------- 9 files changed, 191 insertions(+), 39 deletions(-) rename tests/MessagePack.SourceGenerator.Tests/Resources/Generics_Defined_In_ReferencedProject/{Formatters.TempProject.MyGenericObjectFormatter_T_.g.cs => DefiningProject.Formatters.TempProject.MyGenericObjectFormatter_T_.g.cs} (100%) rename tests/MessagePack.SourceGenerator.Tests/Resources/Generics_Defined_In_ReferencedProject/{MessagePack.GeneratedMessagePackResolver.g.cs => DefiningProject.MessagePack.GeneratedMessagePackResolver.g.cs} (100%) create mode 100644 tests/MessagePack.SourceGenerator.Tests/Resources/Generics_Defined_In_ReferencedProject/TestProject.Formatters.TempProject.MyGenericObjectFormatter_T_.g.cs rename tests/MessagePack.SourceGenerator.Tests/Resources/Generics_Defined_In_ReferencedProject/{Formatters.TempProject.MyObjectFormatter.g.cs => TestProject.Formatters.TempProject.MyObjectFormatter.g.cs} (100%) rename tests/MessagePack.SourceGenerator.Tests/Resources/Generics_Defined_In_ReferencedProject/{Formatters.TempProject.MyObjectNestedFormatter.g.cs => TestProject.Formatters.TempProject.MyObjectNestedFormatter.g.cs} (100%) create mode 100644 tests/MessagePack.SourceGenerator.Tests/Resources/Generics_Defined_In_ReferencedProject/TestProject.MessagePack.GeneratedMessagePackResolver.g.cs diff --git a/tests/MessagePack.SourceGenerator.Tests/GenericsFormatterTests.cs b/tests/MessagePack.SourceGenerator.Tests/GenericsFormatterTests.cs index f3a33453e..b77462779 100644 --- a/tests/MessagePack.SourceGenerator.Tests/GenericsFormatterTests.cs +++ b/tests/MessagePack.SourceGenerator.Tests/GenericsFormatterTests.cs @@ -1,6 +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. +using MessagePack; using Microsoft.CodeAnalysis; public class GenericsFormatterTests @@ -428,7 +429,7 @@ public class MyGenericObject await VerifyCS.Test.RunDefaultAsync(testSource); } - [Fact(Skip = "Does not pass yet because the project reference isn't set up correctly.")] + [Fact] public async Task Generics_Defined_In_ReferencedProject() { string defineSource = """ @@ -469,13 +470,6 @@ public class MyObjectNested } } """; - var definingProject = new Microsoft.CodeAnalysis.Testing.ProjectState("DefiningProject", LanguageNames.CSharp, string.Empty, ".cs") - { - Sources = { defineSource }, - ReferenceAssemblies = new VerifyCS.Test().ReferenceAssemblies, - }; - definingProject.AdditionalReferences.AddRange(new VerifyCS.Test().TestState.AdditionalReferences); - await new VerifyCS.Test { TestState = @@ -483,7 +477,7 @@ public class MyObjectNested Sources = { usageSource }, AdditionalProjects = { - { "DefiningProject", definingProject }, + ["DefiningProject"] = { Sources = { defineSource } }, }, AdditionalProjectReferences = { "DefiningProject" }, }, diff --git a/tests/MessagePack.SourceGenerator.Tests/MessagePack.SourceGenerator.Tests.csproj b/tests/MessagePack.SourceGenerator.Tests/MessagePack.SourceGenerator.Tests.csproj index 7493caf0e..20bb97d25 100644 --- a/tests/MessagePack.SourceGenerator.Tests/MessagePack.SourceGenerator.Tests.csproj +++ b/tests/MessagePack.SourceGenerator.Tests/MessagePack.SourceGenerator.Tests.csproj @@ -29,4 +29,8 @@ + + + + diff --git a/tests/MessagePack.SourceGenerator.Tests/Resources/Generics_Defined_In_ReferencedProject/Formatters.TempProject.MyGenericObjectFormatter_T_.g.cs b/tests/MessagePack.SourceGenerator.Tests/Resources/Generics_Defined_In_ReferencedProject/DefiningProject.Formatters.TempProject.MyGenericObjectFormatter_T_.g.cs similarity index 100% rename from tests/MessagePack.SourceGenerator.Tests/Resources/Generics_Defined_In_ReferencedProject/Formatters.TempProject.MyGenericObjectFormatter_T_.g.cs rename to tests/MessagePack.SourceGenerator.Tests/Resources/Generics_Defined_In_ReferencedProject/DefiningProject.Formatters.TempProject.MyGenericObjectFormatter_T_.g.cs diff --git a/tests/MessagePack.SourceGenerator.Tests/Resources/Generics_Defined_In_ReferencedProject/MessagePack.GeneratedMessagePackResolver.g.cs b/tests/MessagePack.SourceGenerator.Tests/Resources/Generics_Defined_In_ReferencedProject/DefiningProject.MessagePack.GeneratedMessagePackResolver.g.cs similarity index 100% rename from tests/MessagePack.SourceGenerator.Tests/Resources/Generics_Defined_In_ReferencedProject/MessagePack.GeneratedMessagePackResolver.g.cs rename to tests/MessagePack.SourceGenerator.Tests/Resources/Generics_Defined_In_ReferencedProject/DefiningProject.MessagePack.GeneratedMessagePackResolver.g.cs diff --git a/tests/MessagePack.SourceGenerator.Tests/Resources/Generics_Defined_In_ReferencedProject/TestProject.Formatters.TempProject.MyGenericObjectFormatter_T_.g.cs b/tests/MessagePack.SourceGenerator.Tests/Resources/Generics_Defined_In_ReferencedProject/TestProject.Formatters.TempProject.MyGenericObjectFormatter_T_.g.cs new file mode 100644 index 000000000..44538b8ef --- /dev/null +++ b/tests/MessagePack.SourceGenerator.Tests/Resources/Generics_Defined_In_ReferencedProject/TestProject.Formatters.TempProject.MyGenericObjectFormatter_T_.g.cs @@ -0,0 +1,56 @@ +// + +#pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 + +#pragma warning disable CS8669 // We may leak nullable annotations into generated code. + +namespace Formatters.TempProject +{ + using MsgPack = global::MessagePack; + + internal sealed class MyGenericObjectFormatter : MsgPack::Formatters.IMessagePackFormatter> + { + + public void Serialize(ref MsgPack::MessagePackWriter writer, global::TempProject.MyGenericObject value, MsgPack::MessagePackSerializerOptions options) + { + if (value == null) + { + writer.WriteNil(); + return; + } + + MsgPack::IFormatterResolver formatterResolver = options.Resolver; + writer.WriteArrayHeader(1); + MsgPack::FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Serialize(ref writer, value.Content, options); + } + + public global::TempProject.MyGenericObject Deserialize(ref MsgPack::MessagePackReader reader, MsgPack::MessagePackSerializerOptions options) + { + if (reader.TryReadNil()) + { + return null; + } + + options.Security.DepthStep(ref reader); + MsgPack::IFormatterResolver formatterResolver = options.Resolver; + var length = reader.ReadArrayHeader(); + var ____result = new global::TempProject.MyGenericObject(); + + for (int i = 0; i < length; i++) + { + switch (i) + { + case 0: + ____result.Content = MsgPack::FormatterResolverExtensions.GetFormatterWithVerify(formatterResolver).Deserialize(ref reader, options); + break; + default: + reader.Skip(); + break; + } + } + + reader.Depth--; + return ____result; + } + } +} diff --git a/tests/MessagePack.SourceGenerator.Tests/Resources/Generics_Defined_In_ReferencedProject/Formatters.TempProject.MyObjectFormatter.g.cs b/tests/MessagePack.SourceGenerator.Tests/Resources/Generics_Defined_In_ReferencedProject/TestProject.Formatters.TempProject.MyObjectFormatter.g.cs similarity index 100% rename from tests/MessagePack.SourceGenerator.Tests/Resources/Generics_Defined_In_ReferencedProject/Formatters.TempProject.MyObjectFormatter.g.cs rename to tests/MessagePack.SourceGenerator.Tests/Resources/Generics_Defined_In_ReferencedProject/TestProject.Formatters.TempProject.MyObjectFormatter.g.cs diff --git a/tests/MessagePack.SourceGenerator.Tests/Resources/Generics_Defined_In_ReferencedProject/Formatters.TempProject.MyObjectNestedFormatter.g.cs b/tests/MessagePack.SourceGenerator.Tests/Resources/Generics_Defined_In_ReferencedProject/TestProject.Formatters.TempProject.MyObjectNestedFormatter.g.cs similarity index 100% rename from tests/MessagePack.SourceGenerator.Tests/Resources/Generics_Defined_In_ReferencedProject/Formatters.TempProject.MyObjectNestedFormatter.g.cs rename to tests/MessagePack.SourceGenerator.Tests/Resources/Generics_Defined_In_ReferencedProject/TestProject.Formatters.TempProject.MyObjectNestedFormatter.g.cs diff --git a/tests/MessagePack.SourceGenerator.Tests/Resources/Generics_Defined_In_ReferencedProject/TestProject.MessagePack.GeneratedMessagePackResolver.g.cs b/tests/MessagePack.SourceGenerator.Tests/Resources/Generics_Defined_In_ReferencedProject/TestProject.MessagePack.GeneratedMessagePackResolver.g.cs new file mode 100644 index 000000000..059e46fd0 --- /dev/null +++ b/tests/MessagePack.SourceGenerator.Tests/Resources/Generics_Defined_In_ReferencedProject/TestProject.MessagePack.GeneratedMessagePackResolver.g.cs @@ -0,0 +1,76 @@ +// + +#pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 + +namespace MessagePack +{ + using MsgPack = global::MessagePack; + using Formatters = global::Formatters; + + /// A MessagePack resolver that uses generated formatters for types in this assembly. + internal class GeneratedMessagePackResolver : MsgPack::IFormatterResolver + { + /// An instance of this resolver that only returns formatters specifically generated for types in this assembly. + public static readonly MsgPack::IFormatterResolver Instance = new GeneratedMessagePackResolver(); + + /// An instance of this resolver that returns standard AOT-compatible formatters as well as formatters specifically generated for types in this assembly. + public static readonly MsgPack::IFormatterResolver InstanceWithStandardAotResolver = MsgPack::Resolvers.CompositeResolver.Create(Instance, MsgPack::Resolvers.StandardAotResolver.Instance); + + private GeneratedMessagePackResolver() + { + } + + public MsgPack::Formatters.IMessagePackFormatter GetFormatter() + { + return FormatterCache.Formatter; + } + + private static class FormatterCache + { + internal static readonly MsgPack::Formatters.IMessagePackFormatter Formatter; + + static FormatterCache() + { + var f = GeneratedMessagePackResolverGetFormatterHelper.GetFormatter(typeof(T)); + if (f != null) + { + Formatter = (MsgPack::Formatters.IMessagePackFormatter)f; + } + } + } + } + + internal static class GeneratedMessagePackResolverGetFormatterHelper + { + private static readonly global::System.Collections.Generic.Dictionary lookup; + + static GeneratedMessagePackResolverGetFormatterHelper() + { + lookup = new global::System.Collections.Generic.Dictionary(4) + { + { typeof(global::TempProject.MyGenericObject>), 0 }, + { typeof(global::TempProject.MyGenericObject), 1 }, + { typeof(global::TempProject.MyObject), 2 }, + { typeof(global::TempProject.MyObjectNested), 3 }, + }; + } + + internal static object GetFormatter(global::System.Type t) + { + int key; + if (!lookup.TryGetValue(t, out key)) + { + return null; + } + + switch (key) + { + case 0: return new Formatters::TempProject.MyGenericObjectFormatter>(); + case 1: return new Formatters::TempProject.MyGenericObjectFormatter(); + case 2: return new Formatters::TempProject.MyObjectFormatter(); + case 3: return new Formatters::TempProject.MyObjectNestedFormatter(); + default: return null; + } + } + } +} diff --git a/tests/MessagePack.SourceGenerator.Tests/Verifiers/CSharpSourceGeneratorVerifier`1+Test.cs b/tests/MessagePack.SourceGenerator.Tests/Verifiers/CSharpSourceGeneratorVerifier`1+Test.cs index 69432b00b..2d87d6788 100644 --- a/tests/MessagePack.SourceGenerator.Tests/Verifiers/CSharpSourceGeneratorVerifier`1+Test.cs +++ b/tests/MessagePack.SourceGenerator.Tests/Verifiers/CSharpSourceGeneratorVerifier`1+Test.cs @@ -29,10 +29,10 @@ public static partial class CSharpSourceGeneratorVerifier public class Test : CSharpSourceGeneratorTest { private readonly string? testFile; - private readonly string? testMethod; + private readonly string testMethod; private AnalyzerOptions options = AnalyzerOptions.Default; - public Test([CallerFilePath] string? testFile = null, [CallerMemberName] string? testMethod = null) + public Test([CallerFilePath] string? testFile = null, [CallerMemberName] string testMethod = null!) { this.CompilerDiagnostics = CompilerDiagnostics.Warnings; @@ -46,8 +46,6 @@ public Test([CallerFilePath] string? testFile = null, [CallerMemberName] string? #if WRITE_EXPECTED TestBehaviors |= TestBehaviors.SkipGeneratedSourcesCheck; #endif - - this.AddGeneratedSources(testMethod); } public LanguageVersion LanguageVersion { get; set; } = LanguageVersion.Latest; @@ -69,7 +67,7 @@ public AnalyzerOptions Options } } - public static async Task RunDefaultAsync(string testSource, AnalyzerOptions? options = null, [CallerFilePath] string? testFile = null, [CallerMemberName] string? testMethod = null) + public static async Task RunDefaultAsync(string testSource, AnalyzerOptions? options = null, [CallerFilePath] string? testFile = null, [CallerMemberName] string testMethod = null!) { await new Test(testFile, testMethod) { @@ -81,35 +79,58 @@ public static async Task RunDefaultAsync(string testSource, AnalyzerOptions? opt }.RunAsync(); } - public Test AddGeneratedSources([CallerMemberName] string? testMethod = null) + public Test AddGeneratedSources() { - string expectedPrefix = $"{ThisAssembly.AssemblyName}.Resources.{testMethod}." - .Replace(' ', '_') - .Replace(',', '_') - .Replace('(', '_') - .Replace(')', '_'); - - foreach (var resourceName in typeof(Test).Assembly.GetManifestResourceNames()) + static void AddGeneratedSources(ProjectState project, string testMethod, bool withPrefix) { - if (!resourceName.StartsWith(expectedPrefix)) - { - continue; - } - - using var resourceStream = Assembly.GetExecutingAssembly().GetManifestResourceStream(resourceName); - if (resourceStream is null) + string prefix = withPrefix ? $"{project.Name}." : string.Empty; + string expectedPrefix = $"{ThisAssembly.AssemblyName}.Resources.{testMethod}.{prefix}" + .Replace(' ', '_') + .Replace(',', '_') + .Replace('(', '_') + .Replace(')', '_'); + + foreach (var resourceName in typeof(Test).Assembly.GetManifestResourceNames()) { - throw new InvalidOperationException(); + if (!resourceName.StartsWith(expectedPrefix)) + { + continue; + } + + using var resourceStream = Assembly.GetExecutingAssembly().GetManifestResourceStream(resourceName); + if (resourceStream is null) + { + throw new InvalidOperationException(); + } + + using var reader = new StreamReader(resourceStream, Encoding.UTF8, detectEncodingFromByteOrderMarks: true, bufferSize: 4096, leaveOpen: true); + var name = resourceName.Substring(expectedPrefix.Length); + project.GeneratedSources.Add((typeof(MessagePackGenerator), name, reader.ReadToEnd())); } + } - using var reader = new StreamReader(resourceStream, Encoding.UTF8, detectEncodingFromByteOrderMarks: true, bufferSize: 4096, leaveOpen: true); - var name = resourceName.Substring(expectedPrefix.Length); - this.TestState.GeneratedSources.Add((typeof(MessagePackGenerator), name, reader.ReadToEnd())); + AddGeneratedSources(this.TestState, this.testMethod, this.TestState.AdditionalProjects.Count > 0); + foreach (ProjectState addlProject in this.TestState.AdditionalProjects.Values) + { + AddGeneratedSources(addlProject, this.testMethod, true); } return this; } + protected override Task RunImplAsync(CancellationToken cancellationToken) + { + this.AddGeneratedSources(); + + foreach (ProjectState addlProject in this.TestState.AdditionalProjects.Values) + { + addlProject.AdditionalReferences.AddRange(this.TestState.AdditionalReferences); + addlProject.DocumentationMode = DocumentationMode.Parse; + } + + return base.RunImplAsync(cancellationToken); + } + protected override IEnumerable GetSourceGenerators() { yield return typeof(MessagePackGenerator); @@ -139,17 +160,18 @@ protected override ParseOptions CreateParseOptions() protected override async Task<(Compilation, ImmutableArray)> GetProjectCompilationAsync(Project project, IVerifier verifier, CancellationToken cancellationToken) { - var resourceDirectory = Path.Combine(Path.GetDirectoryName(this.testFile)!, "Resources", this.testMethod!); + string fileNamePrefix = this.TestState.AdditionalProjects.Count > 0 ? $"{project.Name}." : string.Empty; + var resourceDirectory = Path.Combine(Path.GetDirectoryName(this.testFile)!, "Resources", this.testMethod); var (compilation, diagnostics) = await base.GetProjectCompilationAsync(project, verifier, cancellationToken); var expectedNames = new HashSet(); foreach (var tree in compilation.SyntaxTrees.Skip(project.DocumentIds.Count)) { - WriteTreeToDiskIfNecessary(tree, resourceDirectory); + WriteTreeToDiskIfNecessary(tree, resourceDirectory, fileNamePrefix); expectedNames.Add(Path.GetFileName(tree.FilePath)); } - var currentTestPrefix = $"{ThisAssembly.AssemblyName}.Resources.{this.testMethod}."; + var currentTestPrefix = $"{ThisAssembly.AssemblyName}.Resources.{this.testMethod}.{fileNamePrefix}"; foreach (var name in this.GetType().Assembly.GetManifestResourceNames()) { if (!name.StartsWith(currentTestPrefix)) @@ -167,15 +189,15 @@ protected override ParseOptions CreateParseOptions() } [Conditional("WRITE_EXPECTED")] - private static void WriteTreeToDiskIfNecessary(SyntaxTree tree, string resourceDirectory) + private static void WriteTreeToDiskIfNecessary(SyntaxTree tree, string resourceDirectory, string fileNamePrefix) { if (tree.Encoding is null) { throw new ArgumentException("Syntax tree encoding was not specified"); } - var name = Path.GetFileName(tree.FilePath); - var filePath = Path.Combine(resourceDirectory, name); + string name = fileNamePrefix + Path.GetFileName(tree.FilePath); + string filePath = Path.Combine(resourceDirectory, name); Directory.CreateDirectory(resourceDirectory); File.WriteAllText(filePath, tree.GetText().ToString(), tree.Encoding); } From 2381c7276720eb8084c1006baf16e6ac6aae2c9a Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Fri, 14 Apr 2023 20:54:34 -0600 Subject: [PATCH 104/660] Fix ARM64 detection on Windows Powershell --- tools/Install-DotNetSdk.ps1 | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/Install-DotNetSdk.ps1 b/tools/Install-DotNetSdk.ps1 index 10af50411..e190fcfbf 100644 --- a/tools/Install-DotNetSdk.ps1 +++ b/tools/Install-DotNetSdk.ps1 @@ -47,6 +47,7 @@ $arch = [System.Runtime.InteropServices.RuntimeInformation]::ProcessArchitecture if (!$arch) { # Windows Powershell leaves this blank $arch = 'x64' if ($env:PROCESSOR_ARCHITECTURE -eq 'ARM64') { $arch = 'ARM64' } + if (${env:ProgramFiles(Arm)}) { $arch = 'ARM64' } } # Search for all .NET runtime versions referenced from MSBuild projects and arrange to install them. From b3e9f4ee3722b395ea4e3cdae74e812b9884d8aa Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Sun, 16 Apr 2023 07:29:40 -0600 Subject: [PATCH 105/660] Bump up SDK and tools versions --- .config/dotnet-tools.json | 4 ++-- global.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json index 5d3dae876..151689b63 100644 --- a/.config/dotnet-tools.json +++ b/.config/dotnet-tools.json @@ -3,7 +3,7 @@ "isRoot": true, "tools": { "powershell": { - "version": "7.3.3", + "version": "7.3.4", "commands": [ "pwsh" ] @@ -15,7 +15,7 @@ ] }, "dotnet-coverage": { - "version": "17.6.11", + "version": "17.7.0", "commands": [ "dotnet-coverage" ] diff --git a/global.json b/global.json index cf9eefa6e..c7d7e468c 100644 --- a/global.json +++ b/global.json @@ -1,6 +1,6 @@ { "sdk": { - "version": "7.0.201", + "version": "7.0.203", "rollForward": "patch", "allowPrerelease": false } From 0c36c87330bb89a4b39d69703263dc14f10831ab Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Mon, 17 Apr 2023 12:13:59 -0600 Subject: [PATCH 106/660] Copy the .config file when applying the template --- Apply-Template.ps1 | 1 + 1 file changed, 1 insertion(+) diff --git a/Apply-Template.ps1 b/Apply-Template.ps1 index 12bfaa129..1c7733558 100644 --- a/Apply-Template.ps1 +++ b/Apply-Template.ps1 @@ -31,6 +31,7 @@ try { Write-Host "Updating $Path" robocopy /mir $PSScriptRoot/azure-pipelines $Path/azure-pipelines +robocopy /mir $PSScriptRoot/.config $Path/.config robocopy /mir $PSScriptRoot/.devcontainer $Path/.devcontainer robocopy /mir $PSScriptRoot/.github $Path/.github robocopy /mir $PSScriptRoot/.vscode $Path/.vscode From 591d64ee9e9fbe3311308d3c57cdb80f66353086 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Tue, 25 Apr 2023 09:50:33 -0600 Subject: [PATCH 107/660] Upgrade `actions/checkout` GitHub action to v3 This resolves a warning about old node.js version based github actions. --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 7718f84ad..3fc278de2 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -27,7 +27,7 @@ jobs: - windows-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 with: fetch-depth: 0 # avoid shallow clone so nbgv can do its work. - name: ⚙ Install prerequisites From e45848775d23805e530d9e0475307afc936a6d24 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Sat, 29 Apr 2023 12:04:57 -0600 Subject: [PATCH 108/660] Elevate CA1062 for shipping code --- .editorconfig | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.editorconfig b/.editorconfig index 078687778..fce73c076 100644 --- a/.editorconfig +++ b/.editorconfig @@ -176,5 +176,8 @@ dotnet_diagnostic.DOC108.severity = warning dotnet_diagnostic.DOC200.severity = warning dotnet_diagnostic.DOC202.severity = warning +# CA1062: Validate arguments of public methods +dotnet_diagnostic.CA1062.severity = warning + [*.sln] indent_style = tab From c3c23f7e91194f845d8df92755edb6803f6cea47 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Mon, 1 May 2023 08:10:45 -0600 Subject: [PATCH 109/660] Bump Nerdbank.GitVersioning to 3.6.128 --- .config/dotnet-tools.json | 2 +- Directory.Packages.props | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json index 151689b63..54fc58866 100644 --- a/.config/dotnet-tools.json +++ b/.config/dotnet-tools.json @@ -21,7 +21,7 @@ ] }, "nbgv": { - "version": "3.5.119", + "version": "3.6.128", "commands": [ "nbgv" ] diff --git a/Directory.Packages.props b/Directory.Packages.props index b523e5c63..5758824bf 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -12,7 +12,7 @@ - + From e90465acd44c421921f48cca04fc4c7e73dd7034 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Mon, 1 May 2023 22:48:46 -0600 Subject: [PATCH 110/660] Update Dockerfile --- .devcontainer/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 7ffd07efb..01c94a90e 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -1,5 +1,5 @@ # Refer to https://hub.docker.com/_/microsoft-dotnet-sdk for available versions -FROM mcr.microsoft.com/dotnet/sdk:7.0.101-jammy +FROM mcr.microsoft.com/dotnet/sdk:7.0.203-jammy # Installing mono makes `dotnet test` work without errors even for net472. # But installing it takes a long time, so it's excluded by default. From 46b4f565e380906d043528f2442c0cb1591f585c Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Tue, 2 May 2023 07:41:53 -0600 Subject: [PATCH 111/660] Fix placement of $RestoreArguments construction --- init.ps1 | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/init.ps1 b/init.ps1 index 6211304f8..00a9589ba 100755 --- a/init.ps1 +++ b/init.ps1 @@ -83,13 +83,13 @@ Push-Location $PSScriptRoot try { $HeaderColor = 'Green' - if (!$NoRestore -and $PSCmdlet.ShouldProcess("NuGet packages", "Restore")) { - $RestoreArguments = @() - if ($Interactive) - { - $RestoreArguments += '--interactive' - } + $RestoreArguments = @() + if ($Interactive) + { + $RestoreArguments += '--interactive' + } + if (!$NoRestore -and $PSCmdlet.ShouldProcess("NuGet packages", "Restore")) { Write-Host "Restoring NuGet packages" -ForegroundColor $HeaderColor dotnet restore @RestoreArguments if ($lastexitcode -ne 0) { From 4d4c330486ea2fe98d9ae70ed1c05fb5bba31c92 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Thu, 11 May 2023 08:51:17 -0600 Subject: [PATCH 112/660] Switch from `MSBuildTreatWarningsAsErrors` to `-warnaserror` This is per @rainersigwald's suggestion in https://github.com/dotnet/msbuild/issues/8735#issuecomment-1544076504 --- .github/workflows/build.yml | 3 +-- azure-pipelines.yml | 1 - azure-pipelines/dotnet.yml | 2 +- 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 3fc278de2..33502820a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -8,7 +8,6 @@ on: pull_request: env: - MSBuildTreatWarningsAsErrors: true DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true BUILDCONFIGURATION: Release # codecov_token: 4dc9e7e2-6b01-4932-a180-847b52b43d35 # Get a new one from https://codecov.io/ @@ -44,7 +43,7 @@ jobs: run: azure-pipelines/variables/_pipelines.ps1 shell: pwsh - name: 🛠 build - run: dotnet build -t:build,pack --no-restore -c ${{ env.BUILDCONFIGURATION }} /v:m /bl:"${{ runner.temp }}/_artifacts/build_logs/build.binlog" + run: dotnet build -t:build,pack --no-restore -c ${{ env.BUILDCONFIGURATION }} -warnaserror /bl:"${{ runner.temp }}/_artifacts/build_logs/build.binlog" - name: 🧪 test run: azure-pipelines/dotnet-test-cloud.ps1 -Configuration ${{ env.BUILDCONFIGURATION }} -Agent ${{ runner.os }} shell: pwsh diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 521d4ce6b..9867b3db8 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -23,7 +23,6 @@ parameters: default: true variables: - MSBuildTreatWarningsAsErrors: true DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true BuildConfiguration: Release codecov_token: 4dc9e7e2-6b01-4932-a180-847b52b43d35 # Get a new one from https://codecov.io/ diff --git a/azure-pipelines/dotnet.yml b/azure-pipelines/dotnet.yml index 79babd4d4..512415497 100644 --- a/azure-pipelines/dotnet.yml +++ b/azure-pipelines/dotnet.yml @@ -3,7 +3,7 @@ parameters: steps: -- script: dotnet build -t:build,pack --no-restore -c $(BuildConfiguration) /bl:"$(Build.ArtifactStagingDirectory)/build_logs/build.binlog" +- script: dotnet build -t:build,pack --no-restore -c $(BuildConfiguration) -warnaserror /bl:"$(Build.ArtifactStagingDirectory)/build_logs/build.binlog" displayName: 🛠 dotnet build - powershell: azure-pipelines/dotnet-test-cloud.ps1 -Configuration $(BuildConfiguration) -Agent $(Agent.JobName) -PublishResults From aefd199847243c1e0a6a8224db00ccb25a5bc9e0 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Wed, 17 May 2023 10:56:28 -0600 Subject: [PATCH 113/660] Bump .NET SDK to 7.0.302 --- .devcontainer/Dockerfile | 2 +- global.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 01c94a90e..6d2f30da6 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -1,5 +1,5 @@ # Refer to https://hub.docker.com/_/microsoft-dotnet-sdk for available versions -FROM mcr.microsoft.com/dotnet/sdk:7.0.203-jammy +FROM mcr.microsoft.com/dotnet/sdk:7.0.302-jammy # Installing mono makes `dotnet test` work without errors even for net472. # But installing it takes a long time, so it's excluded by default. diff --git a/global.json b/global.json index c7d7e468c..abde95a8b 100644 --- a/global.json +++ b/global.json @@ -1,6 +1,6 @@ { "sdk": { - "version": "7.0.203", + "version": "7.0.302", "rollForward": "patch", "allowPrerelease": false } From 390f2a46a2d92e9decc8fa9b192fe739d032bba2 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Sat, 20 May 2023 07:51:27 -0600 Subject: [PATCH 114/660] Fix the errant package dependency in source generator package The source generator package was depending on the non-existant MessagePack.Analyzers.Only package. --- .../MessagePack.Analyzers.CodeFixes.csproj | 8 ++++++++ src/SourceGenerator.props | 5 ++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/MessagePack.Analyzers.CodeFixes/MessagePack.Analyzers.CodeFixes.csproj b/src/MessagePack.Analyzers.CodeFixes/MessagePack.Analyzers.CodeFixes.csproj index ece521244..a82577255 100644 --- a/src/MessagePack.Analyzers.CodeFixes/MessagePack.Analyzers.CodeFixes.csproj +++ b/src/MessagePack.Analyzers.CodeFixes/MessagePack.Analyzers.CodeFixes.csproj @@ -19,6 +19,14 @@ + + + + all + + diff --git a/src/SourceGenerator.props b/src/SourceGenerator.props index 537bf4a95..9ba87f063 100644 --- a/src/SourceGenerator.props +++ b/src/SourceGenerator.props @@ -16,6 +16,9 @@ - + + + From 518af1455bbc5524beadfd4a5c044fa5e694c87c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 20 May 2023 08:04:46 -0600 Subject: [PATCH 115/660] Bump System.Collections.Immutable from 6.0.0 to 7.0.0 (#1611) Bumps [System.Collections.Immutable](https://github.com/dotnet/runtime) from 6.0.0 to 7.0.0. - [Release notes](https://github.com/dotnet/runtime/releases) - [Commits](https://github.com/dotnet/runtime/compare/v6.0.0...v7.0.0) --- updated-dependencies: - dependency-name: System.Collections.Immutable dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Directory.Packages.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Directory.Packages.props b/Directory.Packages.props index e8f94ddf1..bd44143ad 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -59,7 +59,7 @@ - + From 354b522a12ab85fd819356484a63e7cf38ae2579 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Sat, 20 May 2023 13:25:55 -0600 Subject: [PATCH 116/660] Bump NB.GV to 3.6.132 --- .config/dotnet-tools.json | 2 +- Directory.Packages.props | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json index 54fc58866..93547faf7 100644 --- a/.config/dotnet-tools.json +++ b/.config/dotnet-tools.json @@ -21,7 +21,7 @@ ] }, "nbgv": { - "version": "3.6.128", + "version": "3.6.132", "commands": [ "nbgv" ] diff --git a/Directory.Packages.props b/Directory.Packages.props index 5758824bf..7cf54cc17 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -12,7 +12,7 @@ - + From 4f2a6d8391ae5f2b9a577bd3c3bbb03a201a4ff8 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 20 May 2023 13:28:47 -0600 Subject: [PATCH 117/660] Bump CSharpIsNullAnalyzer from 0.1.329 to 0.1.495 (#204) * Crank up dependabot * Bump CSharpIsNullAnalyzer from 0.1.329 to 0.1.495 Bumps [CSharpIsNullAnalyzer](https://github.com/AArnott/CSharpIsNull) from 0.1.329 to 0.1.495. - [Release notes](https://github.com/AArnott/CSharpIsNull/releases) - [Commits](https://github.com/AArnott/CSharpIsNull/commits) --- updated-dependencies: - dependency-name: CSharpIsNullAnalyzer dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --------- Signed-off-by: dependabot[bot] Co-authored-by: Andrew Arnott Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/dependabot.yml | 4 ++-- Directory.Packages.props | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index b9b0f54a2..63e3e890b 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -1,9 +1,9 @@ # Please see the documentation for all configuration options: -# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates +# https://docs.github.com/en/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file version: 2 updates: - package-ecosystem: nuget directory: / schedule: - interval: monthly + interval: weekly diff --git a/Directory.Packages.props b/Directory.Packages.props index 7cf54cc17..74916ca21 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -10,7 +10,7 @@ - + From 119ce0770abc0ad1a3b8bdab3ca622470579ec92 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 20 May 2023 13:29:01 -0600 Subject: [PATCH 118/660] Bump Microsoft.NET.Test.Sdk from 17.5.0 to 17.6.0 (#202) * Crank up dependabot * Bump Microsoft.NET.Test.Sdk from 17.5.0 to 17.6.0 Bumps [Microsoft.NET.Test.Sdk](https://github.com/microsoft/vstest) from 17.5.0 to 17.6.0. - [Release notes](https://github.com/microsoft/vstest/releases) - [Changelog](https://github.com/microsoft/vstest/blob/main/docs/releases.md) - [Commits](https://github.com/microsoft/vstest/compare/v17.5.0...v17.6.0) --- updated-dependencies: - dependency-name: Microsoft.NET.Test.Sdk dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --------- Signed-off-by: dependabot[bot] Co-authored-by: Andrew Arnott Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Directory.Packages.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Directory.Packages.props b/Directory.Packages.props index 74916ca21..061f8ed44 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -5,7 +5,7 @@ true - + From 0991fe932a245d50f30ebab193a3cd50dc520939 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 20 May 2023 13:29:13 -0600 Subject: [PATCH 119/660] Bump dotnet-coverage from 17.7.0 to 17.7.1 (#205) * Crank up dependabot * Bump dotnet-coverage from 17.7.0 to 17.7.1 Bumps [dotnet-coverage](https://github.com/microsoft/codecoverage) from 17.7.0 to 17.7.1. - [Commits](https://github.com/microsoft/codecoverage/commits) --- updated-dependencies: - dependency-name: dotnet-coverage dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --------- Signed-off-by: dependabot[bot] Co-authored-by: Andrew Arnott Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .config/dotnet-tools.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json index 93547faf7..5ed46cc1c 100644 --- a/.config/dotnet-tools.json +++ b/.config/dotnet-tools.json @@ -15,7 +15,7 @@ ] }, "dotnet-coverage": { - "version": "17.7.0", + "version": "17.7.1", "commands": [ "dotnet-coverage" ] From e50278a744ac29ee6f066b9406d2933c898f3eea Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Sat, 27 May 2023 07:48:43 -0600 Subject: [PATCH 120/660] Bump Nerdbank.GitVersioning to 3.6.133 --- .config/dotnet-tools.json | 2 +- Directory.Packages.props | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json index 5ed46cc1c..fa4ceb59c 100644 --- a/.config/dotnet-tools.json +++ b/.config/dotnet-tools.json @@ -21,7 +21,7 @@ ] }, "nbgv": { - "version": "3.6.132", + "version": "3.6.133", "commands": [ "nbgv" ] diff --git a/Directory.Packages.props b/Directory.Packages.props index 061f8ed44..738a2f99d 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -12,7 +12,7 @@ - + From 0f018d451cefcd76ba924050c7a63581bcf7ed58 Mon Sep 17 00:00:00 2001 From: Sergey Andreev Date: Thu, 1 Jun 2023 16:51:23 +0200 Subject: [PATCH 121/660] Added CollectCore call during union collection --- src/MessagePack.Analyzers/CodeAnalysis/TypeCollector.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/MessagePack.Analyzers/CodeAnalysis/TypeCollector.cs b/src/MessagePack.Analyzers/CodeAnalysis/TypeCollector.cs index d67d5a32b..90cd64e18 100644 --- a/src/MessagePack.Analyzers/CodeAnalysis/TypeCollector.cs +++ b/src/MessagePack.Analyzers/CodeAnalysis/TypeCollector.cs @@ -400,6 +400,8 @@ private bool CollectUnion(INamedTypeSymbol type) return null; } + CollectCore(typeSymbol); + var typeName = typeSymbol.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat); return new UnionSubTypeInfo(key, typeName); } From 1579bbaf76e95e700c4aef5311fd5aefc0dd2e18 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Mon, 5 Jun 2023 07:21:57 -0600 Subject: [PATCH 122/660] Bump Microsoft.NET.Test.Sdk to 17.6.1 --- Directory.Packages.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Directory.Packages.props b/Directory.Packages.props index 738a2f99d..386c6eecb 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -5,7 +5,7 @@ true - + From e22efe97b08fa4795d834d7e16310143195345d6 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Wed, 7 Jun 2023 15:52:58 -0600 Subject: [PATCH 123/660] Bump Microsoft.NET.Test.Sdk to 17.6.2 --- Directory.Packages.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Directory.Packages.props b/Directory.Packages.props index 386c6eecb..1de332842 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -5,7 +5,7 @@ true - + From 6bda4998f46e6278de384b1d85bdf448e7a9989e Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Sun, 11 Jun 2023 18:05:02 -0600 Subject: [PATCH 124/660] Suppress warnings about input validation --- .editorconfig | 2 +- .vscode/settings.json | 5 +++-- sandbox/.editorconfig | 4 ++++ src/MessagePack.Analyzers/.editorconfig | 4 ++++ src/MessagePack.SourceGenerator/.editorconfig | 3 +++ 5 files changed, 15 insertions(+), 3 deletions(-) create mode 100644 sandbox/.editorconfig create mode 100644 src/MessagePack.Analyzers/.editorconfig diff --git a/.editorconfig b/.editorconfig index 0109aed89..0e4bbcde8 100644 --- a/.editorconfig +++ b/.editorconfig @@ -187,7 +187,7 @@ dotnet_diagnostic.DOC200.severity = warning dotnet_diagnostic.DOC202.severity = warning # CA1062: Validate arguments of public methods -dotnet_diagnostic.CA1062.severity = warning +dotnet_diagnostic.CA1062.severity = suggestion # CS1591: Missing XML comment for publicly visible type or member dotnet_diagnostic.CS1591.severity = suggestion diff --git a/.vscode/settings.json b/.vscode/settings.json index 3ae1371c6..668ec34df 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -3,6 +3,7 @@ "files.insertFinalNewline": true, "files.trimFinalNewlines": true, "omnisharp.enableEditorConfigSupport": true, - "omnisharp.enableImportCompletion": true, - "omnisharp.enableRoslynAnalyzers": true + "omnisharp.enableRoslynAnalyzers": true, + "dotnet.completion.showCompletionItemsFromUnimportedNamespaces": true, + "dotnet.defaultSolution": "MessagePack.sln" } diff --git a/sandbox/.editorconfig b/sandbox/.editorconfig new file mode 100644 index 000000000..c7bcd1010 --- /dev/null +++ b/sandbox/.editorconfig @@ -0,0 +1,4 @@ +[*.cs] + +# CA1062: Validate arguments of public methods +dotnet_diagnostic.CA1062.severity = silent diff --git a/src/MessagePack.Analyzers/.editorconfig b/src/MessagePack.Analyzers/.editorconfig new file mode 100644 index 000000000..c7bcd1010 --- /dev/null +++ b/src/MessagePack.Analyzers/.editorconfig @@ -0,0 +1,4 @@ +[*.cs] + +# CA1062: Validate arguments of public methods +dotnet_diagnostic.CA1062.severity = silent diff --git a/src/MessagePack.SourceGenerator/.editorconfig b/src/MessagePack.SourceGenerator/.editorconfig index 6b835fc65..f82bae653 100644 --- a/src/MessagePack.SourceGenerator/.editorconfig +++ b/src/MessagePack.SourceGenerator/.editorconfig @@ -2,3 +2,6 @@ # VSTHRD111: Use ConfigureAwait(bool) dotnet_diagnostic.VSTHRD111.severity = none + +# CA1062: Validate arguments of public methods +dotnet_diagnostic.CA1062.severity = silent From 1c68c8ce183acf3b06425ea263055c6284c50ca9 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Sun, 11 Jun 2023 19:15:38 -0600 Subject: [PATCH 125/660] Retarget net461 to net462 --- sandbox/PerfNetFramework/README.md | 2 +- sandbox/TestData.InvalidProject/TestData.InvalidProject.csproj | 2 +- sandbox/TestData.InvalidSyntax/TestData.InvalidSyntax.csproj | 2 +- sandbox/TestData2/TestData2.csproj | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/sandbox/PerfNetFramework/README.md b/sandbox/PerfNetFramework/README.md index 3c202c2be..f91fa842c 100644 --- a/sandbox/PerfNetFramework/README.md +++ b/sandbox/PerfNetFramework/README.md @@ -10,7 +10,7 @@ When collecting ETL traces, use these settings in the Collect->Run dialog: | Setting | Value | |-------------|-------| -| Command | `dotnet run -c release -p .\sandbox\PerfNetFramework\ -f net461 --no-build` +| Command | `dotnet run -c release -p .\sandbox\PerfNetFramework\ -f net472 --no-build` | Current Dir | `d:\git\messagepack-csharp` (or wherever your enlistment is) | Additional Providers | `*MessagePack-Benchmark` | No V3.X NGen | Checked diff --git a/sandbox/TestData.InvalidProject/TestData.InvalidProject.csproj b/sandbox/TestData.InvalidProject/TestData.InvalidProject.csproj index 8164cf6f1..3b149c7b3 100644 --- a/sandbox/TestData.InvalidProject/TestData.InvalidProject.csproj +++ b/sandbox/TestData.InvalidProject/TestData.InvalidProject.csproj @@ -1,6 +1,6 @@  - net461 + net462 diff --git a/sandbox/TestData.InvalidSyntax/TestData.InvalidSyntax.csproj b/sandbox/TestData.InvalidSyntax/TestData.InvalidSyntax.csproj index 0743ce6f8..26e2e25dc 100644 --- a/sandbox/TestData.InvalidSyntax/TestData.InvalidSyntax.csproj +++ b/sandbox/TestData.InvalidSyntax/TestData.InvalidSyntax.csproj @@ -1,6 +1,6 @@  - net461 + net462 diff --git a/sandbox/TestData2/TestData2.csproj b/sandbox/TestData2/TestData2.csproj index 67411bf1f..72afb639c 100644 --- a/sandbox/TestData2/TestData2.csproj +++ b/sandbox/TestData2/TestData2.csproj @@ -1,6 +1,6 @@  - net461 + net462 From d62699e7f573ef758fe72b33602d38d1b8515574 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Sun, 11 Jun 2023 19:17:56 -0600 Subject: [PATCH 126/660] Rollback package dependency versions for analyzers Fixes #1635 --- Directory.Packages.props | 13 +++++++++++-- src/Directory.Build.props | 1 + .../Directory.Build.props | 6 ++++++ src/MessagePack.Analyzers/Directory.Build.props | 6 ++++++ .../Directory.Build.props | 6 ++++++ .../Directory.Build.props | 6 ++++++ 6 files changed, 36 insertions(+), 2 deletions(-) create mode 100644 src/MessagePack.Analyzers.CodeFixes/Directory.Build.props create mode 100644 src/MessagePack.Analyzers/Directory.Build.props create mode 100644 src/MessagePack.SourceGenerator.Unity/Directory.Build.props create mode 100644 src/MessagePack.SourceGenerator/Directory.Build.props diff --git a/Directory.Packages.props b/Directory.Packages.props index 4a342eed2..3f07286bb 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -8,7 +8,7 @@ 4.3.0 - 4.3.0 + 4.3.0 1.1.2-beta1.23163.2 @@ -26,7 +26,7 @@ - + @@ -74,7 +74,16 @@ + + + + + + + + + diff --git a/src/Directory.Build.props b/src/Directory.Build.props index 199d8a013..ed2fba9e5 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -3,6 +3,7 @@ enable True $(MSBuildThisFileDirectory)..\opensource.snk + true diff --git a/src/MessagePack.Analyzers.CodeFixes/Directory.Build.props b/src/MessagePack.Analyzers.CodeFixes/Directory.Build.props new file mode 100644 index 000000000..ea193bb7a --- /dev/null +++ b/src/MessagePack.Analyzers.CodeFixes/Directory.Build.props @@ -0,0 +1,6 @@ + + + true + + + diff --git a/src/MessagePack.Analyzers/Directory.Build.props b/src/MessagePack.Analyzers/Directory.Build.props new file mode 100644 index 000000000..ea193bb7a --- /dev/null +++ b/src/MessagePack.Analyzers/Directory.Build.props @@ -0,0 +1,6 @@ + + + true + + + diff --git a/src/MessagePack.SourceGenerator.Unity/Directory.Build.props b/src/MessagePack.SourceGenerator.Unity/Directory.Build.props new file mode 100644 index 000000000..ea193bb7a --- /dev/null +++ b/src/MessagePack.SourceGenerator.Unity/Directory.Build.props @@ -0,0 +1,6 @@ + + + true + + + diff --git a/src/MessagePack.SourceGenerator/Directory.Build.props b/src/MessagePack.SourceGenerator/Directory.Build.props new file mode 100644 index 000000000..ea193bb7a --- /dev/null +++ b/src/MessagePack.SourceGenerator/Directory.Build.props @@ -0,0 +1,6 @@ + + + true + + + From 5a7ce31fa8a9a4aba53bc853529bc7bf308e9111 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Tue, 13 Jun 2023 14:17:25 -0600 Subject: [PATCH 127/660] Fix symbol file selection for R2R outputs --- azure-pipelines/Get-SymbolFiles.ps1 | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/azure-pipelines/Get-SymbolFiles.ps1 b/azure-pipelines/Get-SymbolFiles.ps1 index 0ce229fc2..b5063cec6 100644 --- a/azure-pipelines/Get-SymbolFiles.ps1 +++ b/azure-pipelines/Get-SymbolFiles.ps1 @@ -43,8 +43,13 @@ $PDBs |% { } } |% { # Collect the DLLs/EXEs as well. - $dllPath = "$($_.Directory)/$($_.BaseName).dll" - $exePath = "$($_.Directory)/$($_.BaseName).exe" + $rootName = "$($_.Directory)/$($_.BaseName)" + if ($rootName.EndsWith('.ni')) { + $rootName = $rootName.Substring(0, $rootName.Length - 3) + } + + $dllPath = "$rootName.dll" + $exePath = "$rootName.exe" if (Test-Path $dllPath) { $BinaryImagePath = $dllPath } elseif (Test-Path $exePath) { From 18710500489c2cac5d146411be32e3fc8bf79a9e Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Mon, 19 Jun 2023 15:41:52 -0600 Subject: [PATCH 128/660] Bump dotnet-coverage to 17.7.2 --- .config/dotnet-tools.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json index fa4ceb59c..a8478486c 100644 --- a/.config/dotnet-tools.json +++ b/.config/dotnet-tools.json @@ -15,7 +15,7 @@ ] }, "dotnet-coverage": { - "version": "17.7.1", + "version": "17.7.2", "commands": [ "dotnet-coverage" ] From 743fc78492c9929a6a379a4a2147868418123f74 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Fri, 23 Jun 2023 11:57:33 -0600 Subject: [PATCH 129/660] Add doc about removing the mark of the web Closes #1628 --- README.md | 5 ++++- doc/mark_of_the_web.png | Bin 0 -> 28261 bytes 2 files changed, 4 insertions(+), 1 deletion(-) create mode 100644 doc/mark_of_the_web.png diff --git a/README.md b/README.md index 1af284700..7d9f48fc7 100644 --- a/README.md +++ b/README.md @@ -1593,7 +1593,10 @@ Or for Unity, use the source generator that targets the older Roslyn compiler. [Setting up a source generator for unity](https://docs.unity3d.com/Manual/roslyn-analyzers.html) is a bit more involved. The unity instructions describe copying the analyzer .dll into your unity project. You should get the analyzer/source generator .dll's from the the `MessagePack.SourceGenerator.Unity.zip` file uploaded on our GitHub releases page. -Be sure to add _all_ the .dlls in that .zip as analyzers. +For each and every .dll in the .zip, be sure to: + +1. Windows only: Unblock each .dll for use by [removing the "Mark of the Web"](doc/mark_of_the_web.png). If the "Unblock" checkbox does not appear, the mark of the web is not present and you may proceed. +1. Add to the unity project as an analyzer. The package (or unity .zip file) adds a roslyn Source Generator that produces `IMessagePackFormatter` implementing classes for each of your `[MessagePackObject]` classes. diff --git a/doc/mark_of_the_web.png b/doc/mark_of_the_web.png new file mode 100644 index 0000000000000000000000000000000000000000..634ea6123d2061c7c242ad3920b2a0a434e5784d GIT binary patch literal 28261 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 GzyAV-Y@ Date: Mon, 26 Jun 2023 13:26:39 +0200 Subject: [PATCH 130/660] Added test case for union attribute and interface --- sandbox/TestData2/UnionInterface.cs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 sandbox/TestData2/UnionInterface.cs diff --git a/sandbox/TestData2/UnionInterface.cs b/sandbox/TestData2/UnionInterface.cs new file mode 100644 index 000000000..c4d6d54e1 --- /dev/null +++ b/sandbox/TestData2/UnionInterface.cs @@ -0,0 +1,22 @@ +// Copyright (c) All contributors. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +#pragma warning disable SA1307 // Accessible fields should begin with upper-case letter +#pragma warning disable SA1401 // Fields should be private +#pragma warning disable SA1402 // File may only contain a single type +#pragma warning disable SA1649 // File name should match first type name + +namespace TestData2 +{ + [Union(0, typeof(UnionInterfaceImplementation))] + public interface IUnionInterface + { + float Value { get; } + } + + [MessagePackObject(true)] + public class UnionInterfaceImplementation : IUnionInterface + { + public float Value { get; set; } + } +} From ba056964139aaa2ede6ce37019e1b9f2073c7484 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 26 Jun 2023 17:10:49 -0600 Subject: [PATCH 131/660] Bump StyleCop.Analyzers.Unstable from 1.2.0.435 to 1.2.0.507 (#207) Bumps [StyleCop.Analyzers.Unstable](https://github.com/DotNetAnalyzers/StyleCopAnalyzers) from 1.2.0.435 to 1.2.0.507. - [Release notes](https://github.com/DotNetAnalyzers/StyleCopAnalyzers/releases) - [Changelog](https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/KnownChanges.md) - [Commits](https://github.com/DotNetAnalyzers/StyleCopAnalyzers/commits) --- updated-dependencies: - dependency-name: StyleCop.Analyzers.Unstable dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Directory.Packages.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Directory.Packages.props b/Directory.Packages.props index 1de332842..6942b31ec 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -14,7 +14,7 @@ - + From 03de5e6821c5b280fcd006eb240486a0df519b49 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 26 Jun 2023 17:10:58 -0600 Subject: [PATCH 132/660] Bump dotnet-coverage from 17.7.2 to 17.7.3 (#208) Bumps [dotnet-coverage](https://github.com/microsoft/codecoverage) from 17.7.2 to 17.7.3. - [Commits](https://github.com/microsoft/codecoverage/commits) --- updated-dependencies: - dependency-name: dotnet-coverage dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .config/dotnet-tools.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json index a8478486c..970744649 100644 --- a/.config/dotnet-tools.json +++ b/.config/dotnet-tools.json @@ -15,7 +15,7 @@ ] }, "dotnet-coverage": { - "version": "17.7.2", + "version": "17.7.3", "commands": [ "dotnet-coverage" ] From 71f5f3617c3e64c99c0613c700bf227da2af37e6 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Wed, 28 Jun 2023 06:57:44 -0600 Subject: [PATCH 133/660] Bump Microsoft.NET.Test.Sdk to 17.6.3 --- Directory.Packages.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Directory.Packages.props b/Directory.Packages.props index 6942b31ec..c15928bee 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -5,7 +5,7 @@ true - + From 88e70184a887b05249cb829b8cefcca1b834b342 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Wed, 28 Jun 2023 07:01:02 -0600 Subject: [PATCH 134/660] Bump powershell to 7.3.5 --- .config/dotnet-tools.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json index 970744649..e344d8b0d 100644 --- a/.config/dotnet-tools.json +++ b/.config/dotnet-tools.json @@ -3,7 +3,7 @@ "isRoot": true, "tools": { "powershell": { - "version": "7.3.4", + "version": "7.3.5", "commands": [ "pwsh" ] From b0f343dba369555ef366435a8c7e9181fe98ea88 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Wed, 28 Jun 2023 09:06:47 -0600 Subject: [PATCH 135/660] Automatically include a README.md from the project directory --- src/Directory.Build.props | 8 ++++++++ src/Library/Library.csproj | 4 ---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/Directory.Build.props b/src/Directory.Build.props index 052fe3ef0..5be1dd441 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -1,3 +1,11 @@ + + + README.md + + + + + diff --git a/src/Library/Library.csproj b/src/Library/Library.csproj index b6b926ab7..50aff9973 100644 --- a/src/Library/Library.csproj +++ b/src/Library/Library.csproj @@ -1,9 +1,5 @@ net6.0;netstandard2.0 - README.md - - - From 799a2b70d24989888bb0de6468db2315c196d643 Mon Sep 17 00:00:00 2001 From: neuecc Date: Thu, 29 Jun 2023 02:23:40 +0900 Subject: [PATCH 136/660] remove MessagePackWindow in Unity --- .../MessagePack/Unity/MessagePackWindow.cs | 314 ------------------ .../Unity/MessagePackWindow.cs.meta | 11 - 2 files changed, 325 deletions(-) delete mode 100644 src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Unity/MessagePackWindow.cs delete mode 100644 src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Unity/MessagePackWindow.cs.meta diff --git a/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Unity/MessagePackWindow.cs b/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Unity/MessagePackWindow.cs deleted file mode 100644 index e1da84631..000000000 --- a/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Unity/MessagePackWindow.cs +++ /dev/null @@ -1,314 +0,0 @@ -#if UNITY_EDITOR - -using System; -using System.Diagnostics; -using System.Text; -using System.Threading.Tasks; -using UnityEditor; -using UnityEngine; - -namespace MessagePack.Unity.Editor -{ - internal class MessagePackWindow : EditorWindow - { - static MessagePackWindow window; - - bool processInitialized; - - bool isDotnetInstalled; - string dotnetVersion; - - bool isInstalledMpc; - bool installingMpc; - bool invokingMpc; - - MpcArgument mpcArgument; - - [MenuItem("Window/MessagePack/CodeGenerator")] - public static void OpenWindow() - { - if (window != null) - { - window.Close(); - } - - // will called OnEnable(singleton instance will be set). - GetWindow("MessagePack CodeGen").Show(); - } - - async void OnEnable() - { - window = this; // set singleton. - try - { - var dotnet = await ProcessHelper.FindDotnetAsync(); - isDotnetInstalled = dotnet.found; - dotnetVersion = dotnet.version; - - if (isDotnetInstalled) - { - isInstalledMpc = await ProcessHelper.IsInstalledMpc(); - } - } - finally - { - mpcArgument = MpcArgument.Restore(); - processInitialized = true; - } - } - - async void OnGUI() - { - if (!processInitialized) - { - GUILayout.Label("Check .NET Core SDK/CodeGen install status."); - return; - } - if (mpcArgument == null) - { - return; - } - - if (!isDotnetInstalled) - { - GUILayout.Label(".NET Core SDK not found."); - GUILayout.Label("MessagePack CodeGen requires .NET Core Runtime."); - if (GUILayout.Button("Open .NET Core install page.")) - { - Application.OpenURL("https://dotnet.microsoft.com/download"); - } - return; - } - - if (!isInstalledMpc) - { - GUILayout.Label("MessagePack CodeGen is not installed."); - EditorGUI.BeginDisabledGroup(installingMpc); - - if (GUILayout.Button("Install MessagePack CodeGen.")) - { - installingMpc = true; - try - { - var log = await ProcessHelper.InstallMpc(); - if (!string.IsNullOrWhiteSpace(log)) - { - UnityEngine.Debug.Log(log); - } - if (log != null && log.Contains("error")) - { - isInstalledMpc = false; - } - else - { - isInstalledMpc = true; - } - } - finally - { - installingMpc = false; - } - return; - } - - EditorGUI.EndDisabledGroup(); - return; - } - - EditorGUILayout.LabelField("-i input path(csproj or directory):"); - TextField(mpcArgument, x => x.Input, (x, y) => x.Input = y); - - EditorGUILayout.LabelField("-o output filepath(.cs) or directory(multiple):"); - TextField(mpcArgument, x => x.Output, (x, y) => x.Output = y); - - EditorGUILayout.LabelField("-m(optional) use map mode:"); - var newToggle = EditorGUILayout.Toggle(mpcArgument.UseMapMode); - if (mpcArgument.UseMapMode != newToggle) - { - mpcArgument.UseMapMode = newToggle; - mpcArgument.Save(); - } - - EditorGUILayout.LabelField("-c(optional) conditional compiler symbols(split with ','):"); - TextField(mpcArgument, x => x.ConditionalSymbol, (x, y) => x.ConditionalSymbol = y); - - EditorGUILayout.LabelField("-r(optional) generated resolver name:"); - TextField(mpcArgument, x => x.ResolverName, (x, y) => x.ResolverName = y); - - EditorGUILayout.LabelField("-n(optional) namespace root name:"); - TextField(mpcArgument, x => x.Namespace, (x, y) => x.Namespace = y); - - EditorGUILayout.LabelField("-ms(optional) Generate #if-- files by symbols, split with ','"); - TextField(mpcArgument, x => x.MultipleIfDirectiveOutputSymbols, (x, y) => x.MultipleIfDirectiveOutputSymbols = y); - - EditorGUI.BeginDisabledGroup(invokingMpc); - if (GUILayout.Button("Generate")) - { - var commnadLineArguments = mpcArgument.ToString(); - UnityEngine.Debug.Log("Generate MessagePack Files, command:" + commnadLineArguments); - - invokingMpc = true; - try - { - var log = await ProcessHelper.InvokeProcessStartAsync("mpc", commnadLineArguments); - UnityEngine.Debug.Log(log); - } - finally - { - invokingMpc = false; - } - } - EditorGUI.EndDisabledGroup(); - } - - void TextField(MpcArgument args, Func getter, Action setter) - { - var current = getter(args); - var newValue = EditorGUILayout.TextField(current); - if (newValue != current) - { - setter(args, newValue); - args.Save(); - } - } - } - - internal class MpcArgument - { - public string Input; - public string Output; - public string ConditionalSymbol; - public string ResolverName; - public string Namespace; - public bool UseMapMode; - public string MultipleIfDirectiveOutputSymbols; - - static string Key => "MessagePackCodeGen." + Application.productName; - - public static MpcArgument Restore() - { - if (EditorPrefs.HasKey(Key)) - { - var json = EditorPrefs.GetString(Key); - return JsonUtility.FromJson(json); - } - else - { - return new MpcArgument(); - } - } - - public void Save() - { - var json = JsonUtility.ToJson(this); - EditorPrefs.SetString(Key, json); - } - - public override string ToString() - { - var sb = new StringBuilder(); - sb.Append("-i "); sb.Append(Input); - sb.Append(" -o "); sb.Append(Output); - if (!string.IsNullOrWhiteSpace(ConditionalSymbol)) - { - sb.Append(" -c "); sb.Append(ConditionalSymbol); - } - if (!string.IsNullOrWhiteSpace(ResolverName)) - { - sb.Append(" -r "); sb.Append(ResolverName); - } - if (UseMapMode) - { - sb.Append(" -m"); - } - if (!string.IsNullOrWhiteSpace(Namespace)) - { - sb.Append(" -n "); sb.Append(Namespace); - } - if (!string.IsNullOrWhiteSpace(MultipleIfDirectiveOutputSymbols)) - { - sb.Append(" -ms "); sb.Append(MultipleIfDirectiveOutputSymbols); - } - - return sb.ToString(); - } - } - - internal static class ProcessHelper - { - const string InstallName = "messagepack.generator"; - - public static async Task IsInstalledMpc() - { - var list = await InvokeProcessStartAsync("dotnet", "tool list -g"); - if (list.Contains(InstallName)) - { - return true; - } - else - { - return false; - } - } - - public static async Task InstallMpc() - { - return await InvokeProcessStartAsync("dotnet", "tool install --global " + InstallName); - } - - public static async Task<(bool found, string version)> FindDotnetAsync() - { - try - { - var version = await InvokeProcessStartAsync("dotnet", "--version"); - return (true, version); - } - catch - { - return (false, null); - } - } - - public static Task InvokeProcessStartAsync(string fileName, string arguments) - { - var psi = new ProcessStartInfo() - { - CreateNoWindow = true, - WindowStyle = ProcessWindowStyle.Hidden, - StandardOutputEncoding = Encoding.UTF8, - StandardErrorEncoding = Encoding.UTF8, - RedirectStandardOutput = true, - RedirectStandardError = true, - UseShellExecute = false, - FileName = fileName, - Arguments = arguments, - WorkingDirectory = Application.dataPath - }; - - Process p; - try - { - p = Process.Start(psi); - } - catch (Exception ex) - { - return Task.FromException(ex); - } - - var tcs = new TaskCompletionSource(); - p.EnableRaisingEvents = true; - p.Exited += (object sender, System.EventArgs e) => - { - var data = p.StandardOutput.ReadToEnd(); - p.Dispose(); - p = null; - - tcs.TrySetResult(data); - }; - - return tcs.Task; - } - } -} - -#endif diff --git a/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Unity/MessagePackWindow.cs.meta b/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Unity/MessagePackWindow.cs.meta deleted file mode 100644 index 1b1eb68b8..000000000 --- a/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Unity/MessagePackWindow.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: c7b2124e98ab01345a59ac40b0979625 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: From 7d92b4ab86281d8f041d79c1b01018c98a211286 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 10 Jul 2023 15:02:28 -0600 Subject: [PATCH 137/660] Bump xunit.runner.visualstudio from 2.4.5 to 2.5.0 (#210) Bumps [xunit.runner.visualstudio](https://github.com/xunit/visualstudio.xunit) from 2.4.5 to 2.5.0. - [Release notes](https://github.com/xunit/visualstudio.xunit/releases) - [Commits](https://github.com/xunit/visualstudio.xunit/compare/v2.4.5...2.5.0) --- updated-dependencies: - dependency-name: xunit.runner.visualstudio dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Directory.Packages.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Directory.Packages.props b/Directory.Packages.props index c15928bee..3ac312f9d 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -6,7 +6,7 @@ - + From 2e19c89761d8d7f934250f4effca22136c48cf39 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 10 Jul 2023 21:08:52 +0000 Subject: [PATCH 138/660] Bump xunit from 2.4.2 to 2.5.0 (#209) --- Directory.Packages.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Directory.Packages.props b/Directory.Packages.props index 3ac312f9d..6af95c882 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -7,7 +7,7 @@ - + From 75b0953f6e91e66076030f20fa0bc4a2990ad906 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Mon, 10 Jul 2023 15:25:18 -0600 Subject: [PATCH 139/660] Remove `tool run` from `dotnet nbgv` invocation I have an Azure Pipeline where `InsertVersionsValues.ps1` (in the microbuild branch) works but this step fails, and the only difference is that one omits `tool run` from `dotnet nbgv`. I continue to believe this is a bug in the `dotnet tool` command. --- azure-pipelines/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines/build.yml b/azure-pipelines/build.yml index 2e2f426e0..9c445f727 100644 --- a/azure-pipelines/build.yml +++ b/azure-pipelines/build.yml @@ -17,7 +17,7 @@ jobs: clean: true - template: install-dependencies.yml - - script: dotnet tool run nbgv cloud -c + - script: dotnet nbgv cloud -c displayName: ⚙ Set build number - template: dotnet.yml From 442ca7c6e521a55a39351b9ef3a3b81207fa4ef5 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Mon, 10 Jul 2023 16:12:43 -0600 Subject: [PATCH 140/660] Dependabot to ignore dotnet-format --- .github/dependabot.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 63e3e890b..484f2bfcd 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -7,3 +7,7 @@ updates: directory: / schedule: interval: weekly + ignore: + # This package has unlisted versions on nuget.org that are not supported. Avoid them. + - dependency-name: dotnet-format + versions: ["6.x", "7.x", "8.x"] From b379933ef3581bd4904e883d92ebcd72a018a321 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Mon, 10 Jul 2023 19:46:17 -0600 Subject: [PATCH 141/660] Set tab settings for .ps1 files --- .editorconfig | 4 ++++ .vscode/settings.json | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/.editorconfig b/.editorconfig index fce73c076..959801c2e 100644 --- a/.editorconfig +++ b/.editorconfig @@ -32,6 +32,10 @@ indent_size = 2 indent_size = 2 indent_style = space +[*.ps1] +indent_style = space +indent_size = 4 + # Dotnet code style settings: [*.{cs,vb}] # Sort using and Import directives with System.* appearing first diff --git a/.vscode/settings.json b/.vscode/settings.json index 3ae1371c6..54c5c6896 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -3,6 +3,6 @@ "files.insertFinalNewline": true, "files.trimFinalNewlines": true, "omnisharp.enableEditorConfigSupport": true, - "omnisharp.enableImportCompletion": true, - "omnisharp.enableRoslynAnalyzers": true + "omnisharp.enableRoslynAnalyzers": true, + "dotnet.completion.showCompletionItemsFromUnimportedNamespaces": true } From 0f7accdd5ed39690633bba7a7f9f83f3caf0b970 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 17 Jul 2023 07:37:40 -0600 Subject: [PATCH 142/660] Bump powershell from 7.3.5 to 7.3.6 (#212) Bumps [powershell](https://github.com/PowerShell/PowerShell) from 7.3.5 to 7.3.6. - [Release notes](https://github.com/PowerShell/PowerShell/releases) - [Commits](https://github.com/PowerShell/PowerShell/compare/v7.3.5...v7.3.6) --- updated-dependencies: - dependency-name: powershell dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .config/dotnet-tools.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json index e344d8b0d..f8713e90a 100644 --- a/.config/dotnet-tools.json +++ b/.config/dotnet-tools.json @@ -3,7 +3,7 @@ "isRoot": true, "tools": { "powershell": { - "version": "7.3.5", + "version": "7.3.6", "commands": [ "pwsh" ] From 05a925a4be9598efcffce2fdd7fb3135d5f7f8be Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 17 Jul 2023 07:38:14 -0600 Subject: [PATCH 143/660] Bump dotnet-coverage from 17.7.3 to 17.8.0 (#211) Bumps [dotnet-coverage](https://github.com/microsoft/codecoverage) from 17.7.3 to 17.8.0. - [Commits](https://github.com/microsoft/codecoverage/commits) --- updated-dependencies: - dependency-name: dotnet-coverage dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .config/dotnet-tools.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json index f8713e90a..05b6b5bb1 100644 --- a/.config/dotnet-tools.json +++ b/.config/dotnet-tools.json @@ -15,7 +15,7 @@ ] }, "dotnet-coverage": { - "version": "17.7.3", + "version": "17.8.0", "commands": [ "dotnet-coverage" ] From 0cc89db1dda3f9c7a436bea77e903f17baf7a989 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Sat, 22 Jul 2023 11:14:58 -0600 Subject: [PATCH 144/660] Bump dotnet-coverage to 17.8.2 --- .config/dotnet-tools.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json index 05b6b5bb1..a20f90b96 100644 --- a/.config/dotnet-tools.json +++ b/.config/dotnet-tools.json @@ -15,7 +15,7 @@ ] }, "dotnet-coverage": { - "version": "17.8.0", + "version": "17.8.2", "commands": [ "dotnet-coverage" ] From 2651c692388aa2e27213c7b89959de56b81f1ecb Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 7 Aug 2023 10:09:53 -0600 Subject: [PATCH 145/660] Bump Microsoft.NET.Test.Sdk from 17.6.3 to 17.7.0 (#213) Bumps [Microsoft.NET.Test.Sdk](https://github.com/microsoft/vstest) from 17.6.3 to 17.7.0. - [Release notes](https://github.com/microsoft/vstest/releases) - [Changelog](https://github.com/microsoft/vstest/blob/main/docs/releases.md) - [Commits](https://github.com/microsoft/vstest/compare/v17.6.3...v17.7.0) --- updated-dependencies: - dependency-name: Microsoft.NET.Test.Sdk dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Directory.Packages.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Directory.Packages.props b/Directory.Packages.props index 6af95c882..58a5a2656 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -5,7 +5,7 @@ true - + From 390c9b4b021aa949d7848254e946b0cc45eccbeb Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Sat, 12 Aug 2023 11:06:06 -0600 Subject: [PATCH 146/660] Drop unused `ProjectRootNamespace` analyzer option --- .../CodeAnalysis/AnalyzerOptions.cs | 10 +--------- .../build/MessagePack.SourceGenerator.props | 1 - .../Verifiers/CSharpSourceGeneratorVerifier`1+Test.cs | 3 +-- 3 files changed, 2 insertions(+), 12 deletions(-) diff --git a/src/MessagePack.Analyzers/CodeAnalysis/AnalyzerOptions.cs b/src/MessagePack.Analyzers/CodeAnalysis/AnalyzerOptions.cs index de50e7350..c04c96840 100644 --- a/src/MessagePack.Analyzers/CodeAnalysis/AnalyzerOptions.cs +++ b/src/MessagePack.Analyzers/CodeAnalysis/AnalyzerOptions.cs @@ -11,12 +11,10 @@ namespace MessagePack.Analyzers.CodeAnalysis; public record AnalyzerOptions( string ResolverNamespace = "MessagePack", string ResolverName = "GeneratedMessagePackResolver", - string ProjectRootNamespace = "", bool PublicResolver = false, bool UsesMapMode = false, ImmutableHashSet? AdditionalAllowTypes = null) { - public const string RootNamespace = "build_property.RootNamespace"; public const string PublicMessagePackGeneratedResolver = "build_property.PublicMessagePackGeneratedResolver"; public const string MessagePackGeneratedResolverNamespace = "build_property.MessagePackGeneratedResolverNamespace"; public const string MessagePackGeneratedResolverName = "build_property.MessagePackGeneratedResolverName"; @@ -34,11 +32,6 @@ public record AnalyzerOptions( public static AnalyzerOptions Parse(AnalyzerConfigOptions options, ImmutableArray additionalTexts) { - if (!options.TryGetValue(RootNamespace, out string? projectRootNamespace)) - { - projectRootNamespace = Default.ProjectRootNamespace; - } - if (!options.TryGetValue(MessagePackGeneratedResolverNamespace, out string? resolverNamespace)) { resolverNamespace = Default.ResolverNamespace; @@ -62,7 +55,6 @@ public static AnalyzerOptions Parse(AnalyzerConfigOptions options, ImmutableArra return new AnalyzerOptions( ResolverNamespace: resolverNamespace, ResolverName: resolverName, - ProjectRootNamespace: projectRootNamespace, PublicResolver: string.Equals(publicResolver, "true", StringComparison.OrdinalIgnoreCase), UsesMapMode: string.Equals(usesMapMode, "true", StringComparison.OrdinalIgnoreCase), AdditionalAllowTypes: GetAdditionalAllowTypes(additionalTexts)); @@ -70,7 +62,7 @@ public static AnalyzerOptions Parse(AnalyzerConfigOptions options, ImmutableArra private static ImmutableHashSet GetAdditionalAllowTypes(ImmutableArray additionalTexts) { - Microsoft.CodeAnalysis.AdditionalText? config = additionalTexts.FirstOrDefault(x => string.Equals(Path.GetFileName(x.Path), JsonOptionsFileName, StringComparison.OrdinalIgnoreCase)); + AdditionalText? config = additionalTexts.FirstOrDefault(x => string.Equals(Path.GetFileName(x.Path), JsonOptionsFileName, StringComparison.OrdinalIgnoreCase)); if (config is null) { return ImmutableHashSet.Empty; diff --git a/src/MessagePack.SourceGenerator/build/MessagePack.SourceGenerator.props b/src/MessagePack.SourceGenerator/build/MessagePack.SourceGenerator.props index c16131410..48c81913f 100644 --- a/src/MessagePack.SourceGenerator/build/MessagePack.SourceGenerator.props +++ b/src/MessagePack.SourceGenerator/build/MessagePack.SourceGenerator.props @@ -7,7 +7,6 @@ - diff --git a/tests/MessagePack.SourceGenerator.Tests/Verifiers/CSharpSourceGeneratorVerifier`1+Test.cs b/tests/MessagePack.SourceGenerator.Tests/Verifiers/CSharpSourceGeneratorVerifier`1+Test.cs index 2d87d6788..3f6cc254f 100644 --- a/tests/MessagePack.SourceGenerator.Tests/Verifiers/CSharpSourceGeneratorVerifier`1+Test.cs +++ b/tests/MessagePack.SourceGenerator.Tests/Verifiers/CSharpSourceGeneratorVerifier`1+Test.cs @@ -75,7 +75,7 @@ public static async Task RunDefaultAsync(string testSource, AnalyzerOptions? opt { Sources = { testSource }, }, - Options = options ?? AnalyzerOptions.Default with { ProjectRootNamespace = "TestRootNamespace" }, + Options = options ?? AnalyzerOptions.Default, }.RunAsync(); } @@ -213,7 +213,6 @@ private static string ConstructGlobalConfigString(AnalyzerOptions options) StringBuilder globalConfigBuilder = new(); globalConfigBuilder.AppendLine("is_global = true"); globalConfigBuilder.AppendLine(); - globalConfigBuilder.AppendLine($"{AnalyzerOptions.RootNamespace} = {options.ProjectRootNamespace}"); globalConfigBuilder.AppendLine($"{AnalyzerOptions.PublicMessagePackGeneratedResolver} = {options.PublicResolver}"); globalConfigBuilder.AppendLine($"{AnalyzerOptions.MessagePackGeneratedResolverNamespace} = {options.ResolverNamespace}"); globalConfigBuilder.AppendLine($"{AnalyzerOptions.MessagePackGeneratedResolverName} = {options.ResolverName}"); From ce0c7cae051810a622922bc1d7fd064eb0ed2fe2 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Sat, 12 Aug 2023 14:16:42 -0600 Subject: [PATCH 147/660] Switch from MSBuild properties to an AdditionalFiles json file This allows unity (which has no msbuild properties) to configure the source generator. Closes #1650 --- MessagePack.sln | 3 +- MessagePackAnalyzer.schema.json | 61 +++++++ README.md | 56 +++--- doc/MessagePackAnalyzer.json | 18 ++ sandbox/Sandbox/MessagePackAnalyzer.json | 8 + sandbox/Sandbox/Sandbox.csproj | 1 - sandbox/SharedData/MessagePackAnalyzer.json | 8 + sandbox/SharedData/SharedData.csproj | 1 - .../CodeAnalysis/AnalyzerOptions.cs | 169 ++++++++++++------ .../CodeAnalysis/TypeCollector.cs | 6 +- .../MessagePack.Analyzers.csproj | 9 + .../MsgPack00xMessagePackAnalyzer.cs | 2 +- .../build/MessagePack.Analyzers.targets | 8 + .../MessagePackGenerator.cs | 2 +- .../MessagePack.SourceGenerator.csproj | 9 +- .../MessagePackGenerator.cs | 2 +- .../Transforms/TemplatePartials.cs | 8 +- .../build/MessagePack.SourceGenerator.props | 15 -- .../build/MessagePack.SourceGenerator.targets | 6 - .../GenerationTests.cs | 6 +- .../MultipleTypesTests.cs | 2 +- .../CSharpSourceGeneratorVerifier`1+Test.cs | 12 +- tests/SourceGeneratorConsumer.props | 2 +- tests/SourceGeneratorConsumer.targets | 2 +- 24 files changed, 283 insertions(+), 133 deletions(-) create mode 100644 MessagePackAnalyzer.schema.json create mode 100644 doc/MessagePackAnalyzer.json create mode 100644 sandbox/Sandbox/MessagePackAnalyzer.json create mode 100644 sandbox/SharedData/MessagePackAnalyzer.json create mode 100644 src/MessagePack.Analyzers/build/MessagePack.Analyzers.targets delete mode 100644 src/MessagePack.SourceGenerator/build/MessagePack.SourceGenerator.props delete mode 100644 src/MessagePack.SourceGenerator/build/MessagePack.SourceGenerator.targets diff --git a/MessagePack.sln b/MessagePack.sln index 8327f23ad..09e346ef3 100644 --- a/MessagePack.sln +++ b/MessagePack.sln @@ -24,6 +24,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "docs", "docs", "{344DC89D-8 ProjectSection(SolutionItems) = preProject .gitignore = .gitignore LICENSE = LICENSE + doc\MessagePackAnalyzer.json = doc\MessagePackAnalyzer.json README.md = README.md EndProjectSection EndProject @@ -103,7 +104,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MessagePack.SourceGenerator EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MessagePack.SourceGenerator.Unity.Tests", "tests\MessagePack.SourceGenerator.Unity.Tests\MessagePack.SourceGenerator.Unity.Tests.csproj", "{EAC1B79C-F77D-4DEF-BF53-75E700A301A4}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MessagePack.Analyzers.CodeFixes", "src\MessagePack.Analyzers.CodeFixes\MessagePack.Analyzers.CodeFixes.csproj", "{7A6CB600-2393-468F-9952-84EC624D57BD}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MessagePack.Analyzers.CodeFixes", "src\MessagePack.Analyzers.CodeFixes\MessagePack.Analyzers.CodeFixes.csproj", "{7A6CB600-2393-468F-9952-84EC624D57BD}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution diff --git a/MessagePackAnalyzer.schema.json b/MessagePackAnalyzer.schema.json new file mode 100644 index 000000000..945e490cc --- /dev/null +++ b/MessagePackAnalyzer.schema.json @@ -0,0 +1,61 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema", + "title": "MessagePackAnalyzer.json schema", + "type": "object", + "additionalProperties": false, + "properties": { + "generator": { + "type": "object", + "description": "Customizes AOT source generation of formatters for custom types.", + "additionalProperties": false, + "properties": { + "usesMapMode": { + "type": "boolean", + "description": "A value indicating whether types will be serialized with their property names as well as their values in a key=value dictionary, as opposed to an array of values.", + "default": false + }, + "resolver": { + "type": "object", + "description": "Describes the generated resolver.", + "additionalProperties": false, + "properties": { + "public": { + "type": "boolean", + "description": "A value indicating whether the generated resolver should be public (as opposed to internal). A public resolver is appropriate when developing a library that may be used by another assembly that needs to aggregate this generated resolver with others.", + "default": false + }, + "name": { + "type": "string", + "description": "The name to use for the resolver.", + "default": "GeneratedMessagePackResolver" + }, + "namespace": { + "type": "string", + "description": "The namespace the source generated resolver will be emitted into.", + "default": "MessagePack" + } + } + }, + "formatters": { + "type": "object", + "description": "Customizes aspects of source generated formatters.", + "additionalProperties": false, + "properties": { + "namespace": { + "type": "string", + "description": "The root namespace into which formatters are emitted.", + "default": "Formatters" + } + } + } + } + }, + "customFormattedTypes": { + "type": "array", + "description": "An array of fully-qualified names of types that are included in serialized object graphs but are assumed to have custom formatters registered already.", + "items": { + "type": "string" + } + } + } +} diff --git a/README.md b/README.md index 7d9f48fc7..80f3e3713 100644 --- a/README.md +++ b/README.md @@ -168,14 +168,19 @@ The MessagePackAnalyzer package aids with: ![analyzergif](https://cloud.githubusercontent.com/assets/46207/23837445/ce734eae-07cb-11e7-9758-d69f0f095bc1.gif) -If you want to allow a specific custom type (for example, when registering a custom type), put `MessagePackAnalyzer.json` at the project root and change the Build Action to `AdditionalFiles`. - -![image](https://cloud.githubusercontent.com/assets/46207/23837427/8a8d507c-07cb-11e7-9277-5a566eb0bfde.png) +If you want to allow a specific custom type (for example, when registering a custom type), put `MessagePackAnalyzer.json` at the project root. +If using Unity, you should configure Unity to treat this as an `AdditionalFiles` in the C# compiler. An example `MessagePackAnalyzer.json`: ```json -[ "MyNamespace.FooClass", "MyNameSpace.BarStruct" ] +{ + "$schema": "https://raw.githubusercontent.com/MessagePack-CSharp/MessagePack-CSharp/develop/MessagePackAnalyzer.schema.json", + "customFormattedTypes": [ + "MyNamespace.MyClass", + "MyNamespace.AnotherClass" + ] +} ``` ## Built-in supported types @@ -1626,26 +1631,35 @@ T after = MessagePackSerializer.Deserialize(serialized); ### Customizations -A few MSBuild properties can be set in your project to customize source generation: +You can customize the generated source through a `MessagePackAnalyzer.json` file added to the project root directory. +If using Unity, you should configure Unity to treat this as an `AdditionalFiles` in the C# compiler. -Property | Purpose | Default value ---|--|-- -`PublicMessagePackGeneratedResolver` | A boolean value indicating whether the generated resolver should be `public`. This is useful for shared libraries so their consumers can leverage the AOT formatters (which are always `internal`) in the library. | `false` -`MessagePackGeneratedResolverNamespace` | The namespace to use for the generated resolver class. | The `$(RootNamespace)` of the project, or `MessagePack` if the root namespace is empty. -`MessagePackGeneratedResolverName` | The name of the generated resolver type. | `GeneratedMessagePackResolver` -`MessagePackGeneratedUsesMapMode` | A boolean value that indicates whether all formatters should use property maps instead of more compact arrays. | `false` - -For example you could add this xml to your project file to set each of the above properties (in this example, to their default values): +An example `MessagePackAnalyzer.json`: -```xml - - false - $(RootNamespace) - GeneratedMessagePackResolver - false - +```json +{ + "$schema": "https://raw.githubusercontent.com/MessagePack-CSharp/MessagePack-CSharp/develop/MessagePackAnalyzer.schema.json", + "generator": { + "resolver": { + "public": false, + "name": "GeneratedMessagePackResolver", + "namespace": "" + }, + "formatters": { + "namespace": "Formatters" + }, + "usesMapMode": false + }, + "customFormattedTypes": [ + "MyNamespace.MyClass", + "MyNamespace.AnotherClass" + ] +} ``` +The above example mostly sets defaults. +You can discover all the available settings, their defaults and meanings in a JSON editor that supports JSON schema, or by reviewing [the JSON schema][AnalyzerJsonSchema] yourself. + When exposing the generated resolver publicly, consumers outside the library should aggregate the resolver using its `Instance` property, which contains *only* the generated formatters. The `InstanceWithStandardAotResolver` property is a convenience for callers that will not be aggregating the resolver with those from other libraries, since it aggregates built-in AOT friendly resolvers from the MessagePack library itself. @@ -1702,3 +1716,5 @@ The StreamJsonRpc library is based on [JSON-RPC](https://www.jsonrpc.org/) and i ## How to build See our [contributor's guide](CONTRIBUTING.md). + +[AnalyzerJsonSchema]: https://github.com/MessagePack-CSharp/MessagePack-CSharp/blob/develop/MessagePackAnalyzer.schema.json diff --git a/doc/MessagePackAnalyzer.json b/doc/MessagePackAnalyzer.json new file mode 100644 index 000000000..a8e9b33cb --- /dev/null +++ b/doc/MessagePackAnalyzer.json @@ -0,0 +1,18 @@ +{ + "$schema": "../MessagePackAnalyzer.schema.json", + "generator": { + "resolver": { + "public": false, + "name": "GeneratedMessagePackResolver", + "namespace": "MessagePack" + }, + "formatters": { + "namespace": "Formatters" + }, + "usesMapMode": false + }, + "customFormattedTypes": [ + "MyNamespace.MyClass", + "MyNamespace.AnotherClass" + ] +} \ No newline at end of file diff --git a/sandbox/Sandbox/MessagePackAnalyzer.json b/sandbox/Sandbox/MessagePackAnalyzer.json new file mode 100644 index 000000000..1fd8e9c3a --- /dev/null +++ b/sandbox/Sandbox/MessagePackAnalyzer.json @@ -0,0 +1,8 @@ +{ + "$schema": "../../MessagePackAnalyzer.schema.json", + "generator": { + "resolver": { + "public": true + } + } +} \ No newline at end of file diff --git a/sandbox/Sandbox/Sandbox.csproj b/sandbox/Sandbox/Sandbox.csproj index 7353010c0..4755bc638 100644 --- a/sandbox/Sandbox/Sandbox.csproj +++ b/sandbox/Sandbox/Sandbox.csproj @@ -5,7 +5,6 @@ Exe net6.0 True - true diff --git a/sandbox/SharedData/MessagePackAnalyzer.json b/sandbox/SharedData/MessagePackAnalyzer.json new file mode 100644 index 000000000..1fd8e9c3a --- /dev/null +++ b/sandbox/SharedData/MessagePackAnalyzer.json @@ -0,0 +1,8 @@ +{ + "$schema": "../../MessagePackAnalyzer.schema.json", + "generator": { + "resolver": { + "public": true + } + } +} \ No newline at end of file diff --git a/sandbox/SharedData/SharedData.csproj b/sandbox/SharedData/SharedData.csproj index 4cf40d8d1..dbd593788 100644 --- a/sandbox/SharedData/SharedData.csproj +++ b/sandbox/SharedData/SharedData.csproj @@ -3,7 +3,6 @@ netstandard2.0 - true diff --git a/src/MessagePack.Analyzers/CodeAnalysis/AnalyzerOptions.cs b/src/MessagePack.Analyzers/CodeAnalysis/AnalyzerOptions.cs index c04c96840..aa5d6436c 100644 --- a/src/MessagePack.Analyzers/CodeAnalysis/AnalyzerOptions.cs +++ b/src/MessagePack.Analyzers/CodeAnalysis/AnalyzerOptions.cs @@ -3,92 +3,143 @@ using System.Collections.Immutable; using System.Text.Json; +using System.Text.Json.Serialization; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.Diagnostics; namespace MessagePack.Analyzers.CodeAnalysis; -public record AnalyzerOptions( - string ResolverNamespace = "MessagePack", - string ResolverName = "GeneratedMessagePackResolver", - bool PublicResolver = false, - bool UsesMapMode = false, - ImmutableHashSet? AdditionalAllowTypes = null) +///

+/// Options for the analyzer and source generator, which may be deserialized from a MessagePackAnalyzer.json file. +/// +public record AnalyzerOptions { - public const string PublicMessagePackGeneratedResolver = "build_property.PublicMessagePackGeneratedResolver"; - public const string MessagePackGeneratedResolverNamespace = "build_property.MessagePackGeneratedResolverNamespace"; - public const string MessagePackGeneratedResolverName = "build_property.MessagePackGeneratedResolverName"; - public const string MessagePackGeneratedUsesMapMode = "build_property.MessagePackGeneratedUsesMapMode"; + public const string RootNamespace = "build_property.RootNamespace"; public const string JsonOptionsFileName = "MessagePackAnalyzer.json"; public static readonly AnalyzerOptions Default = new AnalyzerOptions(); - public string FormatterNamespace => "Formatters"; + /// + /// Gets an array of fully-qualified names of types that are included in serialized object graphs but are assumed to have custom formatters registered already. + /// + public ImmutableHashSet CustomFormattedTypes { get; init; } = ImmutableHashSet.Empty; + + public GeneratorOptions Generator { get; init; } = new(); + + public string FormatterNamespace => this.Generator.Formatters.Namespace; /// /// Gets a value indicating whether the analyzer is generating source code. /// public bool IsGeneratingSource { get; init; } - public static AnalyzerOptions Parse(AnalyzerConfigOptions options, ImmutableArray additionalTexts) + public static AnalyzerOptions Parse(AnalyzerConfigOptions options, ImmutableArray additionalTexts, CancellationToken cancellationToken) { - if (!options.TryGetValue(MessagePackGeneratedResolverNamespace, out string? resolverNamespace)) - { - resolverNamespace = Default.ResolverNamespace; - } + // The default namespace for the resolver comes from the project root namespace. + AnalyzerOptions result = Default; - if (!options.TryGetValue(MessagePackGeneratedResolverName, out string? resolverName)) + if (additionalTexts.FirstOrDefault(x => string.Equals(Path.GetFileName(x.Path), JsonOptionsFileName, StringComparison.OrdinalIgnoreCase))?.GetText(cancellationToken)?.ToString() is string configJson) { - resolverName = Default.ResolverName; + try + { + result = JsonSerializer.Deserialize( + configJson, + new JsonSerializerOptions + { + AllowTrailingCommas = true, + MaxDepth = 5, + PropertyNamingPolicy = JsonNamingPolicy.CamelCase, + ReadCommentHandling = JsonCommentHandling.Skip, + }) ?? Default; + } + catch (Exception ex) + { + System.Diagnostics.Debug.WriteLine("Can't load MessagePackAnalyzer.json: " + ex); + } } - if (!options.TryGetValue(MessagePackGeneratedUsesMapMode, out string? usesMapMode)) + if (result.Generator.Resolver.Namespace is null) { - usesMapMode = Default.UsesMapMode ? "true" : "false"; - } + if (!options.TryGetValue(RootNamespace, out string? resolverNamespace)) + { + resolverNamespace = "MessagePack"; + } - if (!options.TryGetValue(PublicMessagePackGeneratedResolver, out string? publicResolver)) - { - publicResolver = Default.PublicResolver ? "true" : "false"; + result = result with { Generator = result.Generator with { Resolver = result.Generator.Resolver with { Namespace = resolverNamespace } } }; } - return new AnalyzerOptions( - ResolverNamespace: resolverNamespace, - ResolverName: resolverName, - PublicResolver: string.Equals(publicResolver, "true", StringComparison.OrdinalIgnoreCase), - UsesMapMode: string.Equals(usesMapMode, "true", StringComparison.OrdinalIgnoreCase), - AdditionalAllowTypes: GetAdditionalAllowTypes(additionalTexts)); + return result; } +} - private static ImmutableHashSet GetAdditionalAllowTypes(ImmutableArray additionalTexts) - { - AdditionalText? config = additionalTexts.FirstOrDefault(x => string.Equals(Path.GetFileName(x.Path), JsonOptionsFileName, StringComparison.OrdinalIgnoreCase)); - if (config is null) - { - return ImmutableHashSet.Empty; - } +/// +/// Customizes aspects of source generated formatters. +/// +public record FormattersOptions +{ + /// + /// The default options. + /// + public static readonly FormattersOptions Default = new(); - try - { - JsonDocument json = JsonDocument.Parse(config.GetText()?.ToString() ?? string.Empty, new JsonDocumentOptions { AllowTrailingCommas = true, CommentHandling = JsonCommentHandling.Skip, MaxDepth = 5 }); - var allowTypes = ImmutableHashSet.CreateBuilder(); - if (json.RootElement.ValueKind == JsonValueKind.Array) - { - foreach (var element in json.RootElement.EnumerateArray()) - { - if (element.GetString() is string { Length: > 0 } allowType) - { - allowTypes.Add(allowType); - } - } - } + /// + /// Gets the root namespace into which formatters are emitted. + /// + public string Namespace { get; init; } = "Formatters"; +} - return allowTypes.ToImmutable(); - } - catch (Exception ex) - { - System.Diagnostics.Debug.WriteLine("Can't load MessagePackAnalyzer.json: " + ex); - return ImmutableHashSet.Empty; - } - } +/// +/// Describes the generated resolver. +/// +public record ResolverOptions +{ + /// + /// The default options. + /// + public static readonly ResolverOptions Default = new(); + + /// + /// Gets a value indicating whether the generated resolver should be public (as opposed to internal). + /// A public resolver is appropriate when developing a library that may be used by another assembly that needs to aggregate this generated resolver with others. + /// + [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)] + public bool Public { get; init; } + + /// + /// Gets the name to use for the resolver. + /// + public string Name { get; init; } = "GeneratedMessagePackResolver"; + + /// + /// Gets the namespace the source generated resolver will be emitted into. + /// + [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)] + public string? Namespace { get; init; } +} + +/// +/// Customizes AOT source generation of formatters for custom types. +/// +public record GeneratorOptions +{ + /// + /// The default options. + /// + public static readonly GeneratorOptions Default = new(); + + /// + /// Gets a value indicating whether types will be serialized with their property names as well as their values in a key=value dictionary, as opposed to an array of values. + /// + [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)] + public bool UsesMapMode { get; init; } + + /// + /// Gets options for the generated resolver. + /// + public ResolverOptions Resolver { get; init; } = new(); + + /// + /// Gets options for the generated formatter. + /// + public FormattersOptions Formatters { get; init; } = new(); } diff --git a/src/MessagePack.Analyzers/CodeAnalysis/TypeCollector.cs b/src/MessagePack.Analyzers/CodeAnalysis/TypeCollector.cs index d67d5a32b..247feff8f 100644 --- a/src/MessagePack.Analyzers/CodeAnalysis/TypeCollector.cs +++ b/src/MessagePack.Analyzers/CodeAnalysis/TypeCollector.cs @@ -183,7 +183,6 @@ public class TypeCollector #pragma warning restore SA1509 // Opening braces should not be preceded by blank line }; - private readonly bool isForceUseMap; private readonly AnalyzerOptions options; private readonly ReferenceSymbols typeReferences; private readonly Action? reportDiagnostic; @@ -205,7 +204,6 @@ private TypeCollector(Compilation compilation, AnalyzerOptions options, Referenc { this.typeReferences = referenceSymbols; this.reportDiagnostic = reportDiagnostic; - this.isForceUseMap = options.UsesMapMode; this.options = options; this.compilation = compilation; this.excludeArrayElement = true; @@ -291,7 +289,7 @@ private bool CollectCore(ITypeSymbol typeSymbol) return result; } - if (this.options.AdditionalAllowTypes?.Contains(typeSymbolString) is true) + if (this.options.CustomFormattedTypes.Contains(typeSymbolString) is true) { result = true; this.alreadyCollected.Add(typeSymbol, result); @@ -663,7 +661,7 @@ private bool CheckValidMessagePackFormatterAttribute(AttributeData formatterAttr var intMembers = new Dictionary(); var stringMembers = new Dictionary(); - if (this.isForceUseMap || (contractAttr?.ConstructorArguments[0] is { Value: bool firstConstructorArgument } && firstConstructorArgument)) + if (this.options.Generator.UsesMapMode || (contractAttr?.ConstructorArguments[0] is { Value: bool firstConstructorArgument } && firstConstructorArgument)) { // All public members are serialize target except [Ignore] member. isIntKey = false; diff --git a/src/MessagePack.Analyzers/MessagePack.Analyzers.csproj b/src/MessagePack.Analyzers/MessagePack.Analyzers.csproj index 9edf60b71..2eeb2e55f 100644 --- a/src/MessagePack.Analyzers/MessagePack.Analyzers.csproj +++ b/src/MessagePack.Analyzers/MessagePack.Analyzers.csproj @@ -7,6 +7,15 @@ $(CodeAnalysisVersionForUnity) + + + true + build\ + + + + + diff --git a/src/MessagePack.Analyzers/MsgPack00xMessagePackAnalyzer.cs b/src/MessagePack.Analyzers/MsgPack00xMessagePackAnalyzer.cs index c6fe72dd4..6076e4130 100644 --- a/src/MessagePack.Analyzers/MsgPack00xMessagePackAnalyzer.cs +++ b/src/MessagePack.Analyzers/MsgPack00xMessagePackAnalyzer.cs @@ -199,7 +199,7 @@ public override void Initialize(AnalysisContext context) context.ConfigureGeneratedCodeAnalysis(GeneratedCodeAnalysisFlags.Analyze | GeneratedCodeAnalysisFlags.ReportDiagnostics); context.RegisterCompilationStartAction(ctxt => { - CodeAnalysis.AnalyzerOptions options = CodeAnalysis.AnalyzerOptions.Parse(ctxt.Options.AnalyzerConfigOptionsProvider.GlobalOptions, ctxt.Options.AdditionalFiles); + CodeAnalysis.AnalyzerOptions options = CodeAnalysis.AnalyzerOptions.Parse(ctxt.Options.AnalyzerConfigOptionsProvider.GlobalOptions, ctxt.Options.AdditionalFiles, ctxt.CancellationToken); if (ReferenceSymbols.TryCreate(ctxt.Compilation, out ReferenceSymbols? typeReferences)) { ctxt.RegisterSyntaxNodeAction(c => Analyze(c, typeReferences, options), SyntaxKind.ClassDeclaration, SyntaxKind.StructDeclaration, SyntaxKind.InterfaceDeclaration); diff --git a/src/MessagePack.Analyzers/build/MessagePack.Analyzers.targets b/src/MessagePack.Analyzers/build/MessagePack.Analyzers.targets new file mode 100644 index 000000000..6ecb44bab --- /dev/null +++ b/src/MessagePack.Analyzers/build/MessagePack.Analyzers.targets @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/src/MessagePack.SourceGenerator.Unity/MessagePackGenerator.cs b/src/MessagePack.SourceGenerator.Unity/MessagePackGenerator.cs index ced1c6e90..26a9c6711 100644 --- a/src/MessagePack.SourceGenerator.Unity/MessagePackGenerator.cs +++ b/src/MessagePack.SourceGenerator.Unity/MessagePackGenerator.cs @@ -31,7 +31,7 @@ public void Execute(GeneratorExecutionContext context) return; } - AnalyzerOptions options = AnalyzerOptions.Parse(context.AnalyzerConfigOptions.GlobalOptions, context.AdditionalFiles) with { IsGeneratingSource = true }; + AnalyzerOptions options = AnalyzerOptions.Parse(context.AnalyzerConfigOptions.GlobalOptions, context.AdditionalFiles, context.CancellationToken) with { IsGeneratingSource = true }; List modelPerType = new(); foreach (var syntax in receiver.ClassDeclarations) diff --git a/src/MessagePack.SourceGenerator/MessagePack.SourceGenerator.csproj b/src/MessagePack.SourceGenerator/MessagePack.SourceGenerator.csproj index d22589512..04a0a95e4 100644 --- a/src/MessagePack.SourceGenerator/MessagePack.SourceGenerator.csproj +++ b/src/MessagePack.SourceGenerator/MessagePack.SourceGenerator.csproj @@ -17,13 +17,6 @@ MsgPack;MessagePack;Serialization;Formatter;Serializer - - - true - build\ - - - @@ -88,5 +81,5 @@ - +
diff --git a/src/MessagePack.SourceGenerator/MessagePackGenerator.cs b/src/MessagePack.SourceGenerator/MessagePackGenerator.cs index 80cd74920..83af54f3a 100644 --- a/src/MessagePack.SourceGenerator/MessagePackGenerator.cs +++ b/src/MessagePack.SourceGenerator/MessagePackGenerator.cs @@ -19,7 +19,7 @@ public partial class MessagePackGenerator : IIncrementalGenerator public void Initialize(IncrementalGeneratorInitializationContext context) { var options = context.AdditionalTextsProvider.Collect().Combine(context.AnalyzerConfigOptionsProvider).Select( - ((ImmutableArray AdditionalFiles, AnalyzerConfigOptionsProvider Options) t, CancellationToken ct) => AnalyzerOptions.Parse(t.Options.GlobalOptions, t.AdditionalFiles) with { IsGeneratingSource = true }); + ((ImmutableArray AdditionalFiles, AnalyzerConfigOptionsProvider Options) t, CancellationToken ct) => AnalyzerOptions.Parse(t.Options.GlobalOptions, t.AdditionalFiles, ct) with { IsGeneratingSource = true }); var messagePackObjectTypes = context.SyntaxProvider.ForAttributeWithMetadataName( MessagePackObjectAttributeFullName, diff --git a/src/MessagePack.SourceGenerator/Transforms/TemplatePartials.cs b/src/MessagePack.SourceGenerator/Transforms/TemplatePartials.cs index 8aa63313e..25a4df910 100644 --- a/src/MessagePack.SourceGenerator/Transforms/TemplatePartials.cs +++ b/src/MessagePack.SourceGenerator/Transforms/TemplatePartials.cs @@ -53,17 +53,17 @@ public ResolverTemplate(AnalyzerOptions options, IReadOnlyList this.Options.ResolverNamespace; + public string ResolverNamespace => this.Options.Generator.Resolver.Namespace ?? string.Empty; public string FormatterNamespace => this.Options.FormatterNamespace; - public string ResolverName => this.Options.ResolverName; + public string ResolverName => this.Options.Generator.Resolver.Name; - public bool PublicResolver => this.Options.PublicResolver; + public bool PublicResolver => this.Options.Generator.Resolver.Public; public IReadOnlyList RegisterInfos { get; } - public string FileName => $"{CodeAnalysisUtilities.QualifyWithOptionalNamespace(this.Options.ResolverName, this.Options.ResolverNamespace)}.g.cs"; + public string FileName => $"{CodeAnalysisUtilities.QualifyWithOptionalNamespace(this.ResolverName, this.ResolverNamespace)}.g.cs"; } public partial class EnumTemplate diff --git a/src/MessagePack.SourceGenerator/build/MessagePack.SourceGenerator.props b/src/MessagePack.SourceGenerator/build/MessagePack.SourceGenerator.props deleted file mode 100644 index 48c81913f..000000000 --- a/src/MessagePack.SourceGenerator/build/MessagePack.SourceGenerator.props +++ /dev/null @@ -1,15 +0,0 @@ - - - - false - GeneratedMessagePackResolver - false - - - - - - - - - \ No newline at end of file diff --git a/src/MessagePack.SourceGenerator/build/MessagePack.SourceGenerator.targets b/src/MessagePack.SourceGenerator/build/MessagePack.SourceGenerator.targets deleted file mode 100644 index cc1576181..000000000 --- a/src/MessagePack.SourceGenerator/build/MessagePack.SourceGenerator.targets +++ /dev/null @@ -1,6 +0,0 @@ - - - $(RootNamespace) - MessagePack - - \ No newline at end of file diff --git a/tests/MessagePack.SourceGenerator.Tests/GenerationTests.cs b/tests/MessagePack.SourceGenerator.Tests/GenerationTests.cs index 155f51124..3b720d896 100644 --- a/tests/MessagePack.SourceGenerator.Tests/GenerationTests.cs +++ b/tests/MessagePack.SourceGenerator.Tests/GenerationTests.cs @@ -34,7 +34,7 @@ internal enum MyEnum """; testSource = TestUtilities.WrapTestSource(testSource, container); - await VerifyCS.Test.RunDefaultAsync(testSource, options: AnalyzerOptions.Default with { UsesMapMode = usesMapMode }, testMethod: $"{nameof(EnumFormatter)}({container}, {usesMapMode})"); + await VerifyCS.Test.RunDefaultAsync(testSource, options: AnalyzerOptions.Default with { Generator = GeneratorOptions.Default with { UsesMapMode = usesMapMode } }, testMethod: $"{nameof(EnumFormatter)}({container}, {usesMapMode})"); } [Theory, PairwiseData] @@ -69,7 +69,7 @@ public UnserializableRecord Deserialize(ref MessagePackReader reader, MessagePac } } """; - await VerifyCS.Test.RunDefaultAsync(testSource, options: AnalyzerOptions.Default with { UsesMapMode = usesMapMode }, testMethod: $"{nameof(CustomFormatterViaAttributeOnProperty)}({usesMapMode})"); + await VerifyCS.Test.RunDefaultAsync(testSource, options: AnalyzerOptions.Default with { Generator = GeneratorOptions.Default with { UsesMapMode = usesMapMode } }, testMethod: $"{nameof(CustomFormatterViaAttributeOnProperty)}({usesMapMode})"); } [Theory, PairwiseData] @@ -178,6 +178,6 @@ class TypeWithAutoGeneratedFormatter public MyCustomType Value { get; set; } } """; - await VerifyCS.Test.RunDefaultAsync(testSource, options: AnalyzerOptions.Default with { AdditionalAllowTypes = ImmutableHashSet.Empty.Add("MyCustomType") }); + await VerifyCS.Test.RunDefaultAsync(testSource, options: AnalyzerOptions.Default with { CustomFormattedTypes = ImmutableHashSet.Empty.Add("MyCustomType") }); } } diff --git a/tests/MessagePack.SourceGenerator.Tests/MultipleTypesTests.cs b/tests/MessagePack.SourceGenerator.Tests/MultipleTypesTests.cs index 2d60fdf86..65de36f4d 100644 --- a/tests/MessagePack.SourceGenerator.Tests/MultipleTypesTests.cs +++ b/tests/MessagePack.SourceGenerator.Tests/MultipleTypesTests.cs @@ -26,7 +26,7 @@ class Object2 { } """; - await VerifyCS.Test.RunDefaultAsync(testSource, options: AnalyzerOptions.Default with { UsesMapMode = usesMapMode }, testMethod: $"{nameof(TwoTypes)}({usesMapMode})"); + await VerifyCS.Test.RunDefaultAsync(testSource, options: AnalyzerOptions.Default with { Generator = GeneratorOptions.Default with { UsesMapMode = usesMapMode } }, testMethod: $"{nameof(TwoTypes)}({usesMapMode})"); } [Fact] diff --git a/tests/MessagePack.SourceGenerator.Tests/Verifiers/CSharpSourceGeneratorVerifier`1+Test.cs b/tests/MessagePack.SourceGenerator.Tests/Verifiers/CSharpSourceGeneratorVerifier`1+Test.cs index 3f6cc254f..6509579ba 100644 --- a/tests/MessagePack.SourceGenerator.Tests/Verifiers/CSharpSourceGeneratorVerifier`1+Test.cs +++ b/tests/MessagePack.SourceGenerator.Tests/Verifiers/CSharpSourceGeneratorVerifier`1+Test.cs @@ -204,7 +204,13 @@ private static void WriteTreeToDiskIfNecessary(SyntaxTree tree, string resourceD private static string ConstructConfigJsonString(AnalyzerOptions options) { - string json = JsonSerializer.Serialize(options.AdditionalAllowTypes, new JsonSerializerOptions { WriteIndented = true }); + string json = JsonSerializer.Serialize( + options, + new JsonSerializerOptions + { + WriteIndented = true, + PropertyNamingPolicy = JsonNamingPolicy.CamelCase, + }); return json; } @@ -213,10 +219,6 @@ private static string ConstructGlobalConfigString(AnalyzerOptions options) StringBuilder globalConfigBuilder = new(); globalConfigBuilder.AppendLine("is_global = true"); globalConfigBuilder.AppendLine(); - globalConfigBuilder.AppendLine($"{AnalyzerOptions.PublicMessagePackGeneratedResolver} = {options.PublicResolver}"); - globalConfigBuilder.AppendLine($"{AnalyzerOptions.MessagePackGeneratedResolverNamespace} = {options.ResolverNamespace}"); - globalConfigBuilder.AppendLine($"{AnalyzerOptions.MessagePackGeneratedResolverName} = {options.ResolverName}"); - globalConfigBuilder.AppendLine($"{AnalyzerOptions.MessagePackGeneratedUsesMapMode} = {options.UsesMapMode}"); return globalConfigBuilder.ToString(); } diff --git a/tests/SourceGeneratorConsumer.props b/tests/SourceGeneratorConsumer.props index 5597e591c..4f43792e4 100644 --- a/tests/SourceGeneratorConsumer.props +++ b/tests/SourceGeneratorConsumer.props @@ -1,5 +1,5 @@ - + diff --git a/tests/SourceGeneratorConsumer.targets b/tests/SourceGeneratorConsumer.targets index 509b7ae23..526c700b7 100644 --- a/tests/SourceGeneratorConsumer.targets +++ b/tests/SourceGeneratorConsumer.targets @@ -1,3 +1,3 @@ - + From f764c84caec60eff9579c03ce16db43b142c2d74 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 21 Aug 2023 09:15:30 -0600 Subject: [PATCH 148/660] Bump Microsoft.NET.Test.Sdk from 17.7.0 to 17.7.1 (#214) Bumps [Microsoft.NET.Test.Sdk](https://github.com/microsoft/vstest) from 17.7.0 to 17.7.1. - [Release notes](https://github.com/microsoft/vstest/releases) - [Changelog](https://github.com/microsoft/vstest/blob/main/docs/releases.md) - [Commits](https://github.com/microsoft/vstest/compare/v17.7.0...v17.7.1) --- updated-dependencies: - dependency-name: Microsoft.NET.Test.Sdk dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Directory.Packages.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Directory.Packages.props b/Directory.Packages.props index 58a5a2656..8d5408940 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -5,7 +5,7 @@ true - + From 05f9dd77512332bdd8a312db97bd07d26084b935 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 21 Aug 2023 15:18:33 +0000 Subject: [PATCH 149/660] Bump dotnet-coverage from 17.8.2 to 17.8.4 (#215) Bumps [dotnet-coverage](https://github.com/microsoft/codecoverage) from 17.8.2 to 17.8.4. - [Commits](https://github.com/microsoft/codecoverage/commits) --- updated-dependencies: - dependency-name: dotnet-coverage dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .config/dotnet-tools.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json index a20f90b96..2b62ebce6 100644 --- a/.config/dotnet-tools.json +++ b/.config/dotnet-tools.json @@ -15,7 +15,7 @@ ] }, "dotnet-coverage": { - "version": "17.8.2", + "version": "17.8.4", "commands": [ "dotnet-coverage" ] From c8abc41f0afd07c570d13d6ac41134da00485d91 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Thu, 31 Aug 2023 10:41:26 -0600 Subject: [PATCH 150/660] Align YAML indentation more consistently --- .github/dependabot.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 484f2bfcd..a0e8933bb 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -8,6 +8,6 @@ updates: schedule: interval: weekly ignore: - # This package has unlisted versions on nuget.org that are not supported. Avoid them. - - dependency-name: dotnet-format - versions: ["6.x", "7.x", "8.x"] + # This package has unlisted versions on nuget.org that are not supported. Avoid them. + - dependency-name: dotnet-format + versions: ["6.x", "7.x", "8.x"] From 295313bfbc59d3c6fe8fa4c9e5f080d86d236f95 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 31 Aug 2023 11:27:21 -0600 Subject: [PATCH 151/660] Bump Microsoft.NET.Test.Sdk from 17.7.1 to 17.7.2 (#218) Bumps [Microsoft.NET.Test.Sdk](https://github.com/microsoft/vstest) from 17.7.1 to 17.7.2. - [Release notes](https://github.com/microsoft/vstest/releases) - [Changelog](https://github.com/microsoft/vstest/blob/main/docs/releases.md) - [Commits](https://github.com/microsoft/vstest/compare/v17.7.1...v17.7.2) --- updated-dependencies: - dependency-name: Microsoft.NET.Test.Sdk dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Directory.Packages.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Directory.Packages.props b/Directory.Packages.props index 8d5408940..76d18e0d8 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -5,7 +5,7 @@ true - + From 0a35e80ec55441fc0c10d2ea68cd03e6b4c64004 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Tue, 5 Sep 2023 15:31:49 -0600 Subject: [PATCH 152/660] Fix typo in comment --- src/Directory.Build.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Directory.Build.props b/src/Directory.Build.props index 5be1dd441..5e648d5ee 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -1,5 +1,5 @@ - + README.md From cf980d71f2dc30d777674b77a1afef6a1e8ddd72 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Fri, 8 Sep 2023 10:43:58 -0600 Subject: [PATCH 153/660] Bump dotnet-coverage to 17.8.6 --- .config/dotnet-tools.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json index 2b62ebce6..d93241f4c 100644 --- a/.config/dotnet-tools.json +++ b/.config/dotnet-tools.json @@ -15,7 +15,7 @@ ] }, "dotnet-coverage": { - "version": "17.8.4", + "version": "17.8.6", "commands": [ "dotnet-coverage" ] From 9c140f7ad43a49c31170807eba202c9164e2407e Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Mon, 11 Sep 2023 08:20:23 -0600 Subject: [PATCH 154/660] Fix analyzer when only MessagePack.Annotations is referenced Fixes #1672 --- src/MessagePack.Analyzers/CodeAnalysis/ReferenceSymbols.cs | 6 +----- .../MessagePack.Analyzers.Tests/Helpers/ReferencesHelper.cs | 4 ++++ .../MessagePack.Analyzers.Tests/MessagePackAnalyzerTests.cs | 1 + 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/MessagePack.Analyzers/CodeAnalysis/ReferenceSymbols.cs b/src/MessagePack.Analyzers/CodeAnalysis/ReferenceSymbols.cs index c58dfbcad..dd7ea1ab1 100644 --- a/src/MessagePack.Analyzers/CodeAnalysis/ReferenceSymbols.cs +++ b/src/MessagePack.Analyzers/CodeAnalysis/ReferenceSymbols.cs @@ -13,7 +13,7 @@ public record ReferenceSymbols( INamedTypeSymbol KeyAttribute, INamedTypeSymbol IgnoreAttribute, INamedTypeSymbol FormatterAttribute, - INamedTypeSymbol MessagePackFormatter, + INamedTypeSymbol? MessagePackFormatter, INamedTypeSymbol? IgnoreDataMemberAttribute, INamedTypeSymbol IMessagePackSerializationCallbackReceiver) { @@ -58,10 +58,6 @@ public static bool TryCreate(Compilation compilation, [NotNullWhen(true)] out Re } INamedTypeSymbol? messageFormatter = compilation.GetTypeByMetadataName("MessagePack.Formatters.IMessagePackFormatter"); - if (messageFormatter is null) - { - return false; - } INamedTypeSymbol? ignoreDataMemberAttribute = compilation.GetTypeByMetadataName("System.Runtime.Serialization.IgnoreDataMemberAttribute"); diff --git a/tests/MessagePack.Analyzers.Tests/Helpers/ReferencesHelper.cs b/tests/MessagePack.Analyzers.Tests/Helpers/ReferencesHelper.cs index 0b2885331..d2d5f1b01 100644 --- a/tests/MessagePack.Analyzers.Tests/Helpers/ReferencesHelper.cs +++ b/tests/MessagePack.Analyzers.Tests/Helpers/ReferencesHelper.cs @@ -9,4 +9,8 @@ internal static class ReferencesHelper internal static ReferenceAssemblies DefaultReferences = ReferenceAssemblies.NetFramework.Net472.Default .AddPackages(ImmutableArray.Create( new PackageIdentity("MessagePack", "2.0.335"))); + + internal static ReferenceAssemblies AnnotationsOnly = ReferenceAssemblies.NetFramework.Net472.Default + .AddPackages(ImmutableArray.Create( + new PackageIdentity("MessagePack.Annotations", "2.0.335"))); } diff --git a/tests/MessagePack.Analyzers.Tests/MessagePackAnalyzerTests.cs b/tests/MessagePack.Analyzers.Tests/MessagePackAnalyzerTests.cs index fc899b378..b39cbfb2e 100644 --- a/tests/MessagePack.Analyzers.Tests/MessagePackAnalyzerTests.cs +++ b/tests/MessagePack.Analyzers.Tests/MessagePackAnalyzerTests.cs @@ -190,6 +190,7 @@ public class Bar : Foo await new VerifyCS.Test { + ReferenceAssemblies = ReferencesHelper.AnnotationsOnly, CodeFixTestBehaviors = CodeFixTestBehaviors.SkipLocalDiagnosticCheck, // BUGBUG: move diagnostic to `Foo` reference in Bar's base type list. TestState = { From 39bdb37ead87044bad1ae12b4cb8ce8800a863dc Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 20 Sep 2023 08:50:51 -0600 Subject: [PATCH 155/660] Bump xunit from 2.5.0 to 2.5.1 (#219) Bumps [xunit](https://github.com/xunit/xunit) from 2.5.0 to 2.5.1. - [Commits](https://github.com/xunit/xunit/compare/2.5.0...2.5.1) --- updated-dependencies: - dependency-name: xunit dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Directory.Packages.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Directory.Packages.props b/Directory.Packages.props index 76d18e0d8..b3cdf478c 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -7,7 +7,7 @@ - + From a7f083d5fa0dd1107a04d6b724b117ac6e3c0eb4 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 20 Sep 2023 14:58:32 +0000 Subject: [PATCH 156/660] Bump xunit.runner.visualstudio from 2.5.0 to 2.5.1 (#220) --- Directory.Packages.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Directory.Packages.props b/Directory.Packages.props index b3cdf478c..2cc8fe04a 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -6,7 +6,7 @@ - + From 5d99f303c0357175a0d1932e9ee5255f2476b5a5 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Wed, 20 Sep 2023 16:13:36 -0600 Subject: [PATCH 157/660] Bump powershell to 7.3.7 --- .config/dotnet-tools.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json index d93241f4c..08f5c1eb2 100644 --- a/.config/dotnet-tools.json +++ b/.config/dotnet-tools.json @@ -3,7 +3,7 @@ "isRoot": true, "tools": { "powershell": { - "version": "7.3.6", + "version": "7.3.7", "commands": [ "pwsh" ] From 7726859b29c1290b01e5c6dc0fa1449664596429 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Thu, 21 Sep 2023 11:08:45 -0600 Subject: [PATCH 158/660] Fix LangVersion at 11 Using `latest` allows VS previews to encourage use of syntax that will later fail when built with the SDK prescribed in our global.json file. --- Directory.Build.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Directory.Build.props b/Directory.Build.props index 35fd4f69a..22986f2f3 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -5,7 +5,7 @@ $(RepoRootPath)obj\$([MSBuild]::MakeRelative($(RepoRootPath), $(MSBuildProjectDirectory)))\ $(RepoRootPath)bin\$(MSBuildProjectName)\ $(RepoRootPath)bin\Packages\$(Configuration)\ - latest + 11 enable enable latest From 9ed3b099a203939b40046d582a795d5a4becfb60 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Wed, 27 Sep 2023 05:49:40 -0600 Subject: [PATCH 159/660] Bump dotnet-coverage to 17.8.7 --- .config/dotnet-tools.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json index 08f5c1eb2..3e0ec525a 100644 --- a/.config/dotnet-tools.json +++ b/.config/dotnet-tools.json @@ -15,7 +15,7 @@ ] }, "dotnet-coverage": { - "version": "17.8.6", + "version": "17.8.7", "commands": [ "dotnet-coverage" ] From 75d85ec086b0c8592941927776f6032fec432148 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Sun, 1 Oct 2023 22:26:59 -0600 Subject: [PATCH 160/660] Revert "Bump dotnet-coverage to 17.8.7" This reverts commit 9ed3b099a203939b40046d582a795d5a4becfb60. --- .config/dotnet-tools.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json index 3e0ec525a..08f5c1eb2 100644 --- a/.config/dotnet-tools.json +++ b/.config/dotnet-tools.json @@ -15,7 +15,7 @@ ] }, "dotnet-coverage": { - "version": "17.8.7", + "version": "17.8.6", "commands": [ "dotnet-coverage" ] From b0d89f938752bb23c4019dd2f2180cababcfbc89 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Sun, 8 Oct 2023 08:19:50 -0600 Subject: [PATCH 161/660] Bump .NET SDK to 7.0.401 --- .devcontainer/Dockerfile | 2 +- global.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 6d2f30da6..cef7ac6f7 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -1,5 +1,5 @@ # Refer to https://hub.docker.com/_/microsoft-dotnet-sdk for available versions -FROM mcr.microsoft.com/dotnet/sdk:7.0.302-jammy +FROM mcr.microsoft.com/dotnet/sdk:7.0.401-jammy # Installing mono makes `dotnet test` work without errors even for net472. # But installing it takes a long time, so it's excluded by default. diff --git a/global.json b/global.json index abde95a8b..f153194c4 100644 --- a/global.json +++ b/global.json @@ -1,6 +1,6 @@ { "sdk": { - "version": "7.0.302", + "version": "7.0.401", "rollForward": "patch", "allowPrerelease": false } From 2214ca952dbc76efce9af5226a7320803acec85b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 16 Oct 2023 07:47:59 -0600 Subject: [PATCH 162/660] Bump xunit.runner.visualstudio from 2.5.1 to 2.5.3 (#224) Bumps [xunit.runner.visualstudio](https://github.com/xunit/visualstudio.xunit) from 2.5.1 to 2.5.3. - [Release notes](https://github.com/xunit/visualstudio.xunit/releases) - [Commits](https://github.com/xunit/visualstudio.xunit/compare/2.5.1...2.5.3) --- updated-dependencies: - dependency-name: xunit.runner.visualstudio dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Directory.Packages.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Directory.Packages.props b/Directory.Packages.props index 2cc8fe04a..536511dc2 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -6,7 +6,7 @@ - + From 7df665541e0d93f5e9c0e20e5e62a29337619e6f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 16 Oct 2023 07:48:29 -0600 Subject: [PATCH 163/660] Bump dotnet-coverage from 17.8.6 to 17.9.1 (#222) Bumps [dotnet-coverage](https://github.com/microsoft/codecoverage) from 17.8.6 to 17.9.1. - [Commits](https://github.com/microsoft/codecoverage/commits) --- updated-dependencies: - dependency-name: dotnet-coverage dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .config/dotnet-tools.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json index 08f5c1eb2..e7623fce4 100644 --- a/.config/dotnet-tools.json +++ b/.config/dotnet-tools.json @@ -15,7 +15,7 @@ ] }, "dotnet-coverage": { - "version": "17.8.6", + "version": "17.9.1", "commands": [ "dotnet-coverage" ] From 646c1791371e7ad5cdb923b8e054dc1b5b93f95d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 16 Oct 2023 07:48:35 -0600 Subject: [PATCH 164/660] Bump powershell from 7.3.7 to 7.3.8 (#221) Bumps [powershell](https://github.com/PowerShell/PowerShell) from 7.3.7 to 7.3.8. - [Release notes](https://github.com/PowerShell/PowerShell/releases) - [Commits](https://github.com/PowerShell/PowerShell/compare/v7.3.7...v7.3.8) --- updated-dependencies: - dependency-name: powershell dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .config/dotnet-tools.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json index e7623fce4..c13b4c68a 100644 --- a/.config/dotnet-tools.json +++ b/.config/dotnet-tools.json @@ -3,7 +3,7 @@ "isRoot": true, "tools": { "powershell": { - "version": "7.3.7", + "version": "7.3.8", "commands": [ "pwsh" ] From 125983c0dd2f8fae5171b321f5258b6ebbea4894 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 16 Oct 2023 13:55:23 +0000 Subject: [PATCH 165/660] Bump xunit from 2.5.1 to 2.5.2 (#223) --- Directory.Packages.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Directory.Packages.props b/Directory.Packages.props index 536511dc2..6f6fe2ef4 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -7,7 +7,7 @@ - + From ba76e6100b9d0586974eb10d15afed3e92d798b5 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 23 Oct 2023 20:54:18 -0600 Subject: [PATCH 166/660] Bump xunit from 2.5.2 to 2.5.3 (#226) Bumps [xunit](https://github.com/xunit/xunit) from 2.5.2 to 2.5.3. - [Commits](https://github.com/xunit/xunit/compare/2.5.2...2.5.3) --- updated-dependencies: - dependency-name: xunit dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Directory.Packages.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Directory.Packages.props b/Directory.Packages.props index 6f6fe2ef4..47b1fc9c7 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -7,7 +7,7 @@ - + From 7ef6ca07b8f5c03398958a4e3c7482f7129499cb Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 23 Oct 2023 20:54:29 -0600 Subject: [PATCH 167/660] Bump dotnet-coverage from 17.9.1 to 17.9.3 (#225) Bumps [dotnet-coverage](https://github.com/microsoft/codecoverage) from 17.9.1 to 17.9.3. - [Commits](https://github.com/microsoft/codecoverage/commits) --- updated-dependencies: - dependency-name: dotnet-coverage dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .config/dotnet-tools.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json index c13b4c68a..b935d933f 100644 --- a/.config/dotnet-tools.json +++ b/.config/dotnet-tools.json @@ -15,7 +15,7 @@ ] }, "dotnet-coverage": { - "version": "17.9.1", + "version": "17.9.3", "commands": [ "dotnet-coverage" ] From 62691614bbd61856e40986df43f8e9a43274b48f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 30 Oct 2023 12:50:05 -0600 Subject: [PATCH 168/660] Bump powershell from 7.3.8 to 7.3.9 (#227) Bumps [powershell](https://github.com/PowerShell/PowerShell) from 7.3.8 to 7.3.9. - [Release notes](https://github.com/PowerShell/PowerShell/releases) - [Commits](https://github.com/PowerShell/PowerShell/compare/v7.3.8...v7.3.9) --- updated-dependencies: - dependency-name: powershell dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .config/dotnet-tools.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json index b935d933f..de46e939b 100644 --- a/.config/dotnet-tools.json +++ b/.config/dotnet-tools.json @@ -3,7 +3,7 @@ "isRoot": true, "tools": { "powershell": { - "version": "7.3.8", + "version": "7.3.9", "commands": [ "pwsh" ] From 2e6c239bbcb193809c4379a7f7797e734d0c988c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 6 Nov 2023 11:09:57 -0700 Subject: [PATCH 169/660] Bump xunit from 2.5.3 to 2.6.1 (#228) Bumps [xunit](https://github.com/xunit/xunit) from 2.5.3 to 2.6.1. - [Commits](https://github.com/xunit/xunit/compare/2.5.3...2.6.1) --- updated-dependencies: - dependency-name: xunit dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Directory.Packages.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Directory.Packages.props b/Directory.Packages.props index 47b1fc9c7..c5b4d4835 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -7,7 +7,7 @@ - + From f7808587e502730b326bbc67dd939719ff8401d8 Mon Sep 17 00:00:00 2001 From: nenoNaninu Date: Tue, 7 Nov 2023 10:21:13 +0900 Subject: [PATCH 170/660] Support to analyze records (#1698) --- .../MessagePackCodeFixProvider.cs | 4 +- .../CodeAnalysis/TypeCollector.cs | 17 ++- .../MsgPack00xMessagePackAnalyzer.cs | 2 +- .../MessagePackAnalyzerTests.cs | 121 +++++++++++++++++- 4 files changed, 136 insertions(+), 8 deletions(-) diff --git a/src/MessagePack.Analyzers.CodeFixes/MessagePackCodeFixProvider.cs b/src/MessagePack.Analyzers.CodeFixes/MessagePackCodeFixProvider.cs index 7b1efc2c7..fcbe2ffe9 100644 --- a/src/MessagePack.Analyzers.CodeFixes/MessagePackCodeFixProvider.cs +++ b/src/MessagePack.Analyzers.CodeFixes/MessagePackCodeFixProvider.cs @@ -1,4 +1,4 @@ -// Copyright (c) All contributors. All rights reserved. +// Copyright (c) All contributors. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. using System; @@ -161,7 +161,7 @@ private static async Task AddKeyAttributeAsync(Document document, INam foreach (ISymbol member in targets) { - if (member.GetAttributes().FindAttributeShortName(MsgPack00xMessagePackAnalyzer.KeyAttributeShortName) is null) + if (!member.IsImplicitlyDeclared && member.GetAttributes().FindAttributeShortName(MsgPack00xMessagePackAnalyzer.KeyAttributeShortName) is null) { SyntaxNode node = await member.DeclaringSyntaxReferences[0].GetSyntaxAsync(cancellationToken).ConfigureAwait(false); var documentEditor = await solutionEditor.GetDocumentEditorAsync(document.Project.Solution.GetDocumentId(node.SyntaxTree), cancellationToken).ConfigureAwait(false); diff --git a/src/MessagePack.Analyzers/CodeAnalysis/TypeCollector.cs b/src/MessagePack.Analyzers/CodeAnalysis/TypeCollector.cs index f502e5d2a..3e95d93ce 100644 --- a/src/MessagePack.Analyzers/CodeAnalysis/TypeCollector.cs +++ b/src/MessagePack.Analyzers/CodeAnalysis/TypeCollector.cs @@ -1,4 +1,4 @@ -// Copyright (c) All contributors. All rights reserved. +// Copyright (c) All contributors. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. #pragma warning disable SA1402 // File may only contain a single type @@ -759,7 +759,10 @@ private bool CheckValidMessagePackFormatterAttribute(AttributeData formatterAttr { if (SymbolEqualityComparer.Default.Equals(item.ContainingType, type)) { - this.reportDiagnostic?.Invoke(Diagnostic.Create(MsgPack00xMessagePackAnalyzer.PublicMemberNeedsKey, ((PropertyDeclarationSyntax)item.DeclaringSyntaxReferences[0].GetSyntax()).Identifier.GetLocation(), type.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat), item.Name)); + var syntax = item.DeclaringSyntaxReferences[0].GetSyntax(); + var identifier = (syntax as PropertyDeclarationSyntax)?.Identifier ?? (syntax as ParameterSyntax)?.Identifier; + + this.reportDiagnostic?.Invoke(Diagnostic.Create(MsgPack00xMessagePackAnalyzer.PublicMemberNeedsKey, identifier?.GetLocation(), type.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat), item.Name)); } else if (type.BaseType is not null) { @@ -828,8 +831,16 @@ private bool CheckValidMessagePackFormatterAttribute(AttributeData formatterAttr // recursive collect if (!this.CollectCore(item.Type)) { + var syntax = item.DeclaringSyntaxReferences.FirstOrDefault()?.GetSyntax(); + + var typeSyntax = (syntax as PropertyDeclarationSyntax)?.Type + ?? (syntax as ParameterSyntax)?.Type; // for primary constructor + // TODO: add the declaration of the referenced type as an additional location. - this.reportDiagnostic?.Invoke(Diagnostic.Create(MsgPack00xMessagePackAnalyzer.TypeMustBeMessagePackObject, (item.DeclaringSyntaxReferences.FirstOrDefault()?.GetSyntax() as PropertyDeclarationSyntax)?.Type.GetLocation(), item.Type.ToDisplayString(ShortTypeNameFormat))); + this.reportDiagnostic?.Invoke(Diagnostic.Create( + MsgPack00xMessagePackAnalyzer.TypeMustBeMessagePackObject, + typeSyntax?.GetLocation(), + item.Type.ToDisplayString(ShortTypeNameFormat))); } } } diff --git a/src/MessagePack.Analyzers/MsgPack00xMessagePackAnalyzer.cs b/src/MessagePack.Analyzers/MsgPack00xMessagePackAnalyzer.cs index 6076e4130..e206387b4 100644 --- a/src/MessagePack.Analyzers/MsgPack00xMessagePackAnalyzer.cs +++ b/src/MessagePack.Analyzers/MsgPack00xMessagePackAnalyzer.cs @@ -202,7 +202,7 @@ public override void Initialize(AnalysisContext context) CodeAnalysis.AnalyzerOptions options = CodeAnalysis.AnalyzerOptions.Parse(ctxt.Options.AnalyzerConfigOptionsProvider.GlobalOptions, ctxt.Options.AdditionalFiles, ctxt.CancellationToken); if (ReferenceSymbols.TryCreate(ctxt.Compilation, out ReferenceSymbols? typeReferences)) { - ctxt.RegisterSyntaxNodeAction(c => Analyze(c, typeReferences, options), SyntaxKind.ClassDeclaration, SyntaxKind.StructDeclaration, SyntaxKind.InterfaceDeclaration); + ctxt.RegisterSyntaxNodeAction(c => Analyze(c, typeReferences, options), SyntaxKind.ClassDeclaration, SyntaxKind.StructDeclaration, SyntaxKind.InterfaceDeclaration, SyntaxKind.RecordDeclaration); } }); } diff --git a/tests/MessagePack.Analyzers.Tests/MessagePackAnalyzerTests.cs b/tests/MessagePack.Analyzers.Tests/MessagePackAnalyzerTests.cs index b39cbfb2e..29566dd72 100644 --- a/tests/MessagePack.Analyzers.Tests/MessagePackAnalyzerTests.cs +++ b/tests/MessagePack.Analyzers.Tests/MessagePackAnalyzerTests.cs @@ -32,8 +32,8 @@ public async Task MessageFormatterAttribute() string input = Preamble + @"using MessagePack.Formatters; public class FooFormatter : IMessagePackFormatter { - public void Serialize(ref MessagePackWriter writer, Foo value, MessagePackSerializerOptions options) {} - public Foo Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options) => default; + public void Serialize(ref MessagePackWriter writer, Foo value, MessagePackSerializerOptions options) {} + public Foo Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options) => default; } @@ -152,6 +152,123 @@ public class Bar await VerifyCS.VerifyCodeFixAsync(input, output); } + [Fact] + public async Task AddAttributeToTypeForRecord1() + { + // Don't use Preamble because we want to test that it works without a using statement at the top. + string input = @" +public class Foo +{ + public string Member { get; set; } +} + +[MessagePack.MessagePackObject] +public record Bar +{ + [MessagePack.Key(0)] + public {|MsgPack003:Foo|} Member { get; set; } +} +"; + + string output = @" +[MessagePack.MessagePackObject] +public class Foo +{ + [MessagePack.Key(0)] + public string Member { get; set; } +} + +[MessagePack.MessagePackObject] +public record Bar +{ + [MessagePack.Key(0)] + public Foo Member { get; set; } +} +"; + + await VerifyCS.VerifyCodeFixAsync(input, output); + } + + [Fact] + public async Task AddAttributeToTypeForRecord2() + { + // Don't use Preamble because we want to test that it works without a using statement at the top. + string input = @" +public record Foo +{ + public string Member { get; set; } +} + +[MessagePack.MessagePackObject] +public record Bar +{ + [MessagePack.Key(0)] + public {|MsgPack003:Foo|} Member { get; set; } +} +"; + + string output = @" +[MessagePack.MessagePackObject] +public record Foo +{ + [MessagePack.Key(0)] + public string Member { get; set; } +} + +[MessagePack.MessagePackObject] +public record Bar +{ + [MessagePack.Key(0)] + public Foo Member { get; set; } +} +"; + + await VerifyCS.VerifyCodeFixAsync(input, output); + } + + [Fact] + public async Task AddAttributeToTypeForRecordPrimaryConstructor() + { + // Don't use Preamble because we want to test that it works without a using statement at the top. + string input = @" +public class Foo +{ + public string Member { get; set; } +} + +[MessagePack.MessagePackObject] +public record Bar([property: MessagePack.Key(0)] {|MsgPack003:Foo|} Member); + +namespace System.Runtime.CompilerServices +{ + internal static class IsExternalInit + { + } +} +"; + + string output = @" +[MessagePack.MessagePackObject] +public class Foo +{ + [MessagePack.Key(0)] + public string Member { get; set; } +} + +[MessagePack.MessagePackObject] +public record Bar([property: MessagePack.Key(0)] Foo Member); + +namespace System.Runtime.CompilerServices +{ + internal static class IsExternalInit + { + } +} +"; + + await VerifyCS.VerifyCodeFixAsync(input, output); + } + [Fact] public async Task CodeFixAppliesAcrossFiles() { From 4337ca1c8ebf7bff355d024ab525e9428d8a0bb4 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Wed, 8 Nov 2023 06:41:30 -0700 Subject: [PATCH 171/660] Ignore `dotnet-format` v9 versions --- .github/dependabot.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index a0e8933bb..9053ac863 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -10,4 +10,4 @@ updates: ignore: # This package has unlisted versions on nuget.org that are not supported. Avoid them. - dependency-name: dotnet-format - versions: ["6.x", "7.x", "8.x"] + versions: ["6.x", "7.x", "8.x", "9.x"] From 5a0cd156d0da7a37b76ac60b8c5245494958f51f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 13 Nov 2023 06:49:02 -0700 Subject: [PATCH 172/660] Bump Microsoft.NET.Test.Sdk from 17.7.2 to 17.8.0 (#229) Bumps [Microsoft.NET.Test.Sdk](https://github.com/microsoft/vstest) from 17.7.2 to 17.8.0. - [Release notes](https://github.com/microsoft/vstest/releases) - [Changelog](https://github.com/microsoft/vstest/blob/main/docs/releases.md) - [Commits](https://github.com/microsoft/vstest/compare/v17.7.2...v17.8.0) --- updated-dependencies: - dependency-name: Microsoft.NET.Test.Sdk dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Directory.Packages.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Directory.Packages.props b/Directory.Packages.props index c5b4d4835..faa3fc68b 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -5,7 +5,7 @@ true - + From 0fcb1d81a073695876aca758d81881c182de864b Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Mon, 13 Nov 2023 15:26:34 -0700 Subject: [PATCH 173/660] Apply Directory.Packages.props in Apply-Template.ps1 --- Apply-Template.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Apply-Template.ps1 b/Apply-Template.ps1 index 1c7733558..42ed33623 100644 --- a/Apply-Template.ps1 +++ b/Apply-Template.ps1 @@ -36,7 +36,7 @@ robocopy /mir $PSScriptRoot/.devcontainer $Path/.devcontainer robocopy /mir $PSScriptRoot/.github $Path/.github robocopy /mir $PSScriptRoot/.vscode $Path/.vscode robocopy /mir $PSScriptRoot/tools $Path/tools -robocopy $PSScriptRoot $Path Directory.Build.* global.json init.* azure-pipelines.yml .gitignore .gitattributes .editorconfig +robocopy $PSScriptRoot $Path Directory.Build.* Directory.Packages.props global.json init.* azure-pipelines.yml .gitignore .gitattributes .editorconfig robocopy $PSScriptRoot/src $Path/src Directory.Build.* .editorconfig AssemblyInfo.cs robocopy $PSScriptRoot/test $Path/test Directory.Build.* .editorconfig Remove-Item $Path/azure-pipelines/expand-template.yml From e678b457c03adcff1f5459586095c27a3a88f15d Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Tue, 14 Nov 2023 21:38:21 -0700 Subject: [PATCH 174/660] Bump to the .NET 8.0.100 SDK --- .devcontainer/Dockerfile | 2 +- Directory.Build.props | 2 +- global.json | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index cef7ac6f7..b680b1dbc 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -1,5 +1,5 @@ # Refer to https://hub.docker.com/_/microsoft-dotnet-sdk for available versions -FROM mcr.microsoft.com/dotnet/sdk:7.0.401-jammy +FROM mcr.microsoft.com/dotnet/sdk:8.0.100-jammy # Installing mono makes `dotnet test` work without errors even for net472. # But installing it takes a long time, so it's excluded by default. diff --git a/Directory.Build.props b/Directory.Build.props index 22986f2f3..d3edacc82 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -5,7 +5,7 @@ $(RepoRootPath)obj\$([MSBuild]::MakeRelative($(RepoRootPath), $(MSBuildProjectDirectory)))\ $(RepoRootPath)bin\$(MSBuildProjectName)\ $(RepoRootPath)bin\Packages\$(Configuration)\ - 11 + 12 enable enable latest diff --git a/global.json b/global.json index f153194c4..d24a9b70b 100644 --- a/global.json +++ b/global.json @@ -1,6 +1,6 @@ { "sdk": { - "version": "7.0.401", + "version": "8.0.100", "rollForward": "patch", "allowPrerelease": false } From d1ffce8a4b3a570dc97532af7cb7d6cf47ccc82d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 20 Nov 2023 12:36:51 -0700 Subject: [PATCH 175/660] Bump xunit from 2.6.1 to 2.6.2 (#234) Bumps [xunit](https://github.com/xunit/xunit) from 2.6.1 to 2.6.2. - [Commits](https://github.com/xunit/xunit/compare/2.6.1...2.6.2) --- updated-dependencies: - dependency-name: xunit dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Directory.Packages.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Directory.Packages.props b/Directory.Packages.props index faa3fc68b..272353bff 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -7,7 +7,7 @@ - + From ccd2c89fa9aa2e2e991cd15f16827bcbe654fc10 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 20 Nov 2023 12:37:45 -0700 Subject: [PATCH 176/660] Bump Microsoft.SourceLink.GitHub from 1.1.1 to 8.0.0 (#232) Bumps [Microsoft.SourceLink.GitHub](https://github.com/dotnet/sourcelink) from 1.1.1 to 8.0.0. - [Release notes](https://github.com/dotnet/sourcelink/releases) - [Commits](https://github.com/dotnet/sourcelink/compare/1.1.1...8.0.0) --- updated-dependencies: - dependency-name: Microsoft.SourceLink.GitHub dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Directory.Packages.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Directory.Packages.props b/Directory.Packages.props index 272353bff..9ac2f3710 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -17,6 +17,6 @@ - + From 42894612a6492693491c9a91b3e314d8f10658e8 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 20 Nov 2023 12:37:58 -0700 Subject: [PATCH 177/660] Bump powershell from 7.3.9 to 7.4.0 (#231) Bumps [powershell](https://github.com/PowerShell/PowerShell) from 7.3.9 to 7.4.0. - [Release notes](https://github.com/PowerShell/PowerShell/releases) - [Commits](https://github.com/PowerShell/PowerShell/compare/v7.3.9...v7.4.0) --- updated-dependencies: - dependency-name: powershell dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .config/dotnet-tools.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json index de46e939b..7a4b9444e 100644 --- a/.config/dotnet-tools.json +++ b/.config/dotnet-tools.json @@ -3,7 +3,7 @@ "isRoot": true, "tools": { "powershell": { - "version": "7.3.9", + "version": "7.4.0", "commands": [ "pwsh" ] From 7e872d33dbd08fce619141103e8c8c7bcf7cd966 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 20 Nov 2023 19:43:19 +0000 Subject: [PATCH 178/660] Bump xunit.runner.visualstudio from 2.5.3 to 2.5.4 (#233) --- Directory.Packages.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Directory.Packages.props b/Directory.Packages.props index 9ac2f3710..3ad9b7937 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -6,7 +6,7 @@ - + From 5da8083e9f0a5f79f906d27e8d8dda3386f02bb1 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Wed, 22 Nov 2023 11:58:24 -0700 Subject: [PATCH 179/660] Validate formatted code in builds --- azure-pipelines/build.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/azure-pipelines/build.yml b/azure-pipelines/build.yml index 9c445f727..5d1835d56 100644 --- a/azure-pipelines/build.yml +++ b/azure-pipelines/build.yml @@ -36,6 +36,8 @@ jobs: - template: dotnet.yml parameters: RunTests: ${{ parameters.RunTests }} + - script: dotnet format --verify-no-changes --no-restore + displayName: 💅 Verify formatted code - template: expand-template.yml - job: macOS From c4890509d2ef60e24bbed0ec213882bcead28848 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Wed, 22 Nov 2023 13:42:32 -0700 Subject: [PATCH 180/660] Enable auto-format on save in VS and VS Code --- .vscode/settings.json | 3 ++- settings.VisualStudio.json | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 settings.VisualStudio.json diff --git a/.vscode/settings.json b/.vscode/settings.json index 54c5c6896..5101737c1 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -4,5 +4,6 @@ "files.trimFinalNewlines": true, "omnisharp.enableEditorConfigSupport": true, "omnisharp.enableRoslynAnalyzers": true, - "dotnet.completion.showCompletionItemsFromUnimportedNamespaces": true + "dotnet.completion.showCompletionItemsFromUnimportedNamespaces": true, + "editor.formatOnSave": true } diff --git a/settings.VisualStudio.json b/settings.VisualStudio.json new file mode 100644 index 000000000..7abb4a060 --- /dev/null +++ b/settings.VisualStudio.json @@ -0,0 +1,3 @@ +{ + "textEditor.codeCleanup.profile": "profile1" +} From 41f6d2704083294ec0338f68e2bc54f461177c58 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Wed, 22 Nov 2023 14:37:47 -0700 Subject: [PATCH 181/660] Remove `dotnet-format` as a tool It's part of the SDK now, and the version on nuget.org is no longer maintained. --- .config/dotnet-tools.json | 8 +------- .github/dependabot.yml | 4 ---- 2 files changed, 1 insertion(+), 11 deletions(-) diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json index 7a4b9444e..0e4a78462 100644 --- a/.config/dotnet-tools.json +++ b/.config/dotnet-tools.json @@ -8,12 +8,6 @@ "pwsh" ] }, - "dotnet-format": { - "version": "5.1.250801", - "commands": [ - "dotnet-format" - ] - }, "dotnet-coverage": { "version": "17.9.3", "commands": [ @@ -27,4 +21,4 @@ ] } } -} +} \ No newline at end of file diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 9053ac863..63e3e890b 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -7,7 +7,3 @@ updates: directory: / schedule: interval: weekly - ignore: - # This package has unlisted versions on nuget.org that are not supported. Avoid them. - - dependency-name: dotnet-format - versions: ["6.x", "7.x", "8.x", "9.x"] From ac3f1dff5d485d6e8c56998c87bb3665f0d4bbf9 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Wed, 29 Nov 2023 07:09:14 -0700 Subject: [PATCH 182/660] Make symbolic link failures more detectable --- azure-pipelines/artifacts/_stage_all.ps1 | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/azure-pipelines/artifacts/_stage_all.ps1 b/azure-pipelines/artifacts/_stage_all.ps1 index d81d16d46..b077931cc 100644 --- a/azure-pipelines/artifacts/_stage_all.ps1 +++ b/azure-pipelines/artifacts/_stage_all.ps1 @@ -30,6 +30,12 @@ function Create-SymbolicLink { } else { cmd /c "mklink `"$Link`" `"$Target`"" | Out-Null } + + if ($LASTEXITCODE -ne 0) { + # Windows requires admin privileges to create symbolic links + # unless Developer Mode has been enabled. + throw "Failed to create symbolic link at $Link that points to $Target" + } } # Stage all artifacts From 41771506014fc409c68858d14c2e061d4c2de665 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Thu, 30 Nov 2023 11:56:35 -0700 Subject: [PATCH 183/660] Add xml header to msbuild files MSBuild doesn't need them, but Azure Repos won't recognize .targets and .props files as xml files without it. And recognizing them means syntax coloring, which is worthwhile. --- Directory.Build.props | 1 + Directory.Build.targets | 1 + Directory.Packages.props | 1 + src/Directory.Build.props | 1 + src/Directory.Build.targets | 1 + test/Directory.Build.props | 1 + test/Directory.Build.targets | 1 + 7 files changed, 7 insertions(+) diff --git a/Directory.Build.props b/Directory.Build.props index d3edacc82..e42ac60a6 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -1,3 +1,4 @@ + Debug diff --git a/Directory.Build.targets b/Directory.Build.targets index ea7b6e6f8..cc8184aac 100644 --- a/Directory.Build.targets +++ b/Directory.Build.targets @@ -1,3 +1,4 @@ + diff --git a/Directory.Packages.props b/Directory.Packages.props index 3ad9b7937..6cf06aef4 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -1,3 +1,4 @@ + diff --git a/src/Directory.Build.props b/src/Directory.Build.props index 5e648d5ee..9ba7818d4 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -1,3 +1,4 @@ + diff --git a/src/Directory.Build.targets b/src/Directory.Build.targets index c1d929a5b..07f413461 100644 --- a/src/Directory.Build.targets +++ b/src/Directory.Build.targets @@ -1,3 +1,4 @@ + diff --git a/test/Directory.Build.props b/test/Directory.Build.props index ad4a4b6c5..6c7aa71dc 100644 --- a/test/Directory.Build.props +++ b/test/Directory.Build.props @@ -1,3 +1,4 @@ + diff --git a/test/Directory.Build.targets b/test/Directory.Build.targets index 052fe3ef0..a6e0f4ace 100644 --- a/test/Directory.Build.targets +++ b/test/Directory.Build.targets @@ -1,3 +1,4 @@ + From db4440205ad8c7adac61bea7aea42a63496599d7 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Fri, 1 Dec 2023 12:28:16 -0700 Subject: [PATCH 184/660] Stop VS Code from wrapping xml files --- .vscode/settings.json | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 5101737c1..ce72437ca 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -5,5 +5,8 @@ "omnisharp.enableEditorConfigSupport": true, "omnisharp.enableRoslynAnalyzers": true, "dotnet.completion.showCompletionItemsFromUnimportedNamespaces": true, - "editor.formatOnSave": true + "editor.formatOnSave": true, + "[xml]": { + "editor.wordWrap": "off" + } } From 3a5c8f0ee6540b10f7c58f6489bd0b3ca286c6b2 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Mon, 11 Dec 2023 13:19:20 -0700 Subject: [PATCH 185/660] Add dotnet_separate_import_directive_groups to .editorconfig This is the default setting in VS, but folks who have changed the setting can cause noise in PRs unless we pin the setting at the repo level. --- .editorconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/.editorconfig b/.editorconfig index 959801c2e..ffae180a8 100644 --- a/.editorconfig +++ b/.editorconfig @@ -40,6 +40,7 @@ indent_size = 4 [*.{cs,vb}] # Sort using and Import directives with System.* appearing first dotnet_sort_system_directives_first = true +dotnet_separate_import_directive_groups = false dotnet_style_qualification_for_field = true:warning dotnet_style_qualification_for_property = true:warning dotnet_style_qualification_for_method = true:warning From f8f3f9e2501d480a8d313c2e36bdd978c4191813 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 11 Dec 2023 17:12:47 -0700 Subject: [PATCH 186/660] Bump xunit from 2.6.2 to 2.6.3 (#239) Bumps [xunit](https://github.com/xunit/xunit) from 2.6.2 to 2.6.3. - [Commits](https://github.com/xunit/xunit/compare/2.6.2...2.6.3) --- updated-dependencies: - dependency-name: xunit dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Directory.Packages.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Directory.Packages.props b/Directory.Packages.props index 6cf06aef4..041ea3d1e 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -8,7 +8,7 @@ - + From 20c7541a3ca7b7cd4c7fa30335be69e31b1d41a8 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 11 Dec 2023 17:13:10 -0700 Subject: [PATCH 187/660] Bump dotnet-coverage from 17.9.3 to 17.9.5 (#238) Bumps [dotnet-coverage](https://github.com/microsoft/codecoverage) from 17.9.3 to 17.9.5. - [Commits](https://github.com/microsoft/codecoverage/commits) --- updated-dependencies: - dependency-name: dotnet-coverage dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .config/dotnet-tools.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json index 0e4a78462..c08307f6e 100644 --- a/.config/dotnet-tools.json +++ b/.config/dotnet-tools.json @@ -9,7 +9,7 @@ ] }, "dotnet-coverage": { - "version": "17.9.3", + "version": "17.9.5", "commands": [ "dotnet-coverage" ] From 37705a891a10e45737c3c8d4fb8708141738ec1b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 12 Dec 2023 00:20:18 +0000 Subject: [PATCH 188/660] Bump xunit.runner.visualstudio from 2.5.4 to 2.5.5 (#237) --- Directory.Packages.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Directory.Packages.props b/Directory.Packages.props index 041ea3d1e..4cf7998db 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -7,7 +7,7 @@ - + From c3e46493fe2de84ece6d1fb0ffd1749ef7ca3a3b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 18 Dec 2023 06:47:41 -0700 Subject: [PATCH 189/660] Bump dotnet-coverage from 17.9.5 to 17.9.6 (#240) Bumps [dotnet-coverage](https://github.com/microsoft/codecoverage) from 17.9.5 to 17.9.6. - [Commits](https://github.com/microsoft/codecoverage/commits) --- updated-dependencies: - dependency-name: dotnet-coverage dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .config/dotnet-tools.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json index c08307f6e..b46731160 100644 --- a/.config/dotnet-tools.json +++ b/.config/dotnet-tools.json @@ -9,7 +9,7 @@ ] }, "dotnet-coverage": { - "version": "17.9.5", + "version": "17.9.6", "commands": [ "dotnet-coverage" ] From 9198063d425cd079e19d2f0d2bf523de3cbb343d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 26 Dec 2023 08:01:46 -0700 Subject: [PATCH 190/660] Bump xunit.runner.visualstudio from 2.5.5 to 2.5.6 (#243) Bumps [xunit.runner.visualstudio](https://github.com/xunit/visualstudio.xunit) from 2.5.5 to 2.5.6. - [Release notes](https://github.com/xunit/visualstudio.xunit/releases) - [Commits](https://github.com/xunit/visualstudio.xunit/compare/2.5.5...2.5.6) --- updated-dependencies: - dependency-name: xunit.runner.visualstudio dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Directory.Packages.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Directory.Packages.props b/Directory.Packages.props index 4cf7998db..1d02ad280 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -7,7 +7,7 @@ - + From cd53181413c400fa42418b25329764d69ffc758c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 26 Dec 2023 15:08:21 +0000 Subject: [PATCH 191/660] Bump xunit from 2.6.3 to 2.6.4 (#242) --- Directory.Packages.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Directory.Packages.props b/Directory.Packages.props index 1d02ad280..50ea3701b 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -8,7 +8,7 @@ - + From b9d62f310b3bcc9d0397a39d64049bc046e63f6c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 26 Dec 2023 11:16:41 -0700 Subject: [PATCH 192/660] Bump StyleCop.Analyzers.Unstable from 1.2.0.507 to 1.2.0.556 (#241) Bumps [StyleCop.Analyzers.Unstable](https://github.com/DotNetAnalyzers/StyleCopAnalyzers) from 1.2.0.507 to 1.2.0.556. - [Release notes](https://github.com/DotNetAnalyzers/StyleCopAnalyzers/releases) - [Changelog](https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/KnownChanges.md) - [Commits](https://github.com/DotNetAnalyzers/StyleCopAnalyzers/commits) --- updated-dependencies: - dependency-name: StyleCop.Analyzers.Unstable dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Directory.Packages.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Directory.Packages.props b/Directory.Packages.props index 50ea3701b..41167d99a 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -15,7 +15,7 @@ - + From 8cca53a94ca482408ed6cd9d6a570f7eb8e5d199 Mon Sep 17 00:00:00 2001 From: pCYSl5EDgo Date: Wed, 10 Jan 2024 08:38:27 +0900 Subject: [PATCH 193/660] update global.json to 8.0.100 --- global.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/global.json b/global.json index abde95a8b..d24a9b70b 100644 --- a/global.json +++ b/global.json @@ -1,6 +1,6 @@ { "sdk": { - "version": "7.0.302", + "version": "8.0.100", "rollForward": "patch", "allowPrerelease": false } From 60ac95f07f478fddde65f8a2e6026aad8bed4cd6 Mon Sep 17 00:00:00 2001 From: pCYSl5EDgo Date: Wed, 10 Jan 2024 08:39:13 +0900 Subject: [PATCH 194/660] Fix: secutiry vulnerability in Nuget.Protocol 6.5.0 https://github.com/advisories/GHSA-6qmf-mmc7-6c2p --- Directory.Packages.props | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Directory.Packages.props b/Directory.Packages.props index 3f07286bb..98e2dd25a 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -48,8 +48,8 @@ - - + + From 787ed746043726ef08827974a2bab459c30a6449 Mon Sep 17 00:00:00 2001 From: pCYSl5EDgo Date: Wed, 10 Jan 2024 09:00:09 +0900 Subject: [PATCH 195/660] Update packages which does not need code fix --- Directory.Packages.props | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/Directory.Packages.props b/Directory.Packages.props index 98e2dd25a..847967eab 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -4,7 +4,7 @@ true true - 0.13.5 + 0.13.12 4.3.0 @@ -19,14 +19,14 @@ - + - + @@ -41,25 +41,25 @@ - - + + - + - + - - - + + + - + - - - + + + @@ -67,11 +67,11 @@ - - - + + + - + @@ -96,6 +96,6 @@ - + From f3e6307f4358f0badf48c6707f8d8d7d06c88f43 Mon Sep 17 00:00:00 2001 From: pCYSl5EDgo Date: Wed, 10 Jan 2024 09:16:12 +0900 Subject: [PATCH 196/660] Update docker file dependency --- .devcontainer/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 6d2f30da6..25f361c7a 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -1,5 +1,5 @@ # Refer to https://hub.docker.com/_/microsoft-dotnet-sdk for available versions -FROM mcr.microsoft.com/dotnet/sdk:7.0.302-jammy +FROM mcr.microsoft.com/dotnet/sdk:8.0.100-1-jammy # Installing mono makes `dotnet test` work without errors even for net472. # But installing it takes a long time, so it's excluded by default. From 11cf2f020a516574ae355dee41632f86206bc659 Mon Sep 17 00:00:00 2001 From: pCYSl5EDgo Date: Wed, 10 Jan 2024 16:09:08 +0900 Subject: [PATCH 197/660] update StleyCop.Analyzers.Unstable to 1.2.0.556 suppress SA1402 --- Directory.Packages.props | 2 +- src/MessagePack.Analyzers/CodeAnalysis/AnalyzerOptions.cs | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/Directory.Packages.props b/Directory.Packages.props index 847967eab..95e89f25b 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -93,7 +93,7 @@ - + diff --git a/src/MessagePack.Analyzers/CodeAnalysis/AnalyzerOptions.cs b/src/MessagePack.Analyzers/CodeAnalysis/AnalyzerOptions.cs index aa5d6436c..37ff4945d 100644 --- a/src/MessagePack.Analyzers/CodeAnalysis/AnalyzerOptions.cs +++ b/src/MessagePack.Analyzers/CodeAnalysis/AnalyzerOptions.cs @@ -9,6 +9,8 @@ namespace MessagePack.Analyzers.CodeAnalysis; +#pragma warning disable SA1402 // File may only contain a single type + /// /// Options for the analyzer and source generator, which may be deserialized from a MessagePackAnalyzer.json file. /// @@ -143,3 +145,4 @@ public record GeneratorOptions ///
public FormattersOptions Formatters { get; init; } = new(); } +#pragma warning restore SA1402 // File may only contain a single type From 663338efb10fb1cc3d05d814d9632362ee64b967 Mon Sep 17 00:00:00 2001 From: pCYSl5EDgo Date: Wed, 10 Jan 2024 17:19:31 +0900 Subject: [PATCH 198/660] Update TargetFrameworks --- .../ExperimentalBenchmark.csproj | 2 +- .../SerializerBenchmark.csproj | 2 +- .../MessagePack.Internal.csproj | 2 +- .../PerfBenchmarkDotNet.csproj | 2 +- .../PerfNetFramework/PerfNetFramework.csproj | 2 +- sandbox/Sandbox/Sandbox.csproj | 2 +- .../MessagePack.AspNetCoreMvcFormatter.csproj | 8 +- .../MessagePack.Experimental.csproj | 2 +- src/MessagePack/MessagePack.csproj | 2 +- src/MessagePack/net8.0/PublicAPI.Shipped.txt | 1181 +++++++++++++++++ .../net8.0/PublicAPI.Unshipped.txt | 44 + .../MessagePack.Analyzers.Tests.csproj | 2 +- ...gePack.AspNetCoreMvcFormatter.Tests.csproj | 2 +- .../MessagePack.Experimental.Tests.csproj | 2 +- .../MessagePack.GeneratedCode.Tests.csproj | 2 +- .../MessagePack.Internal.Tests.csproj | 2 +- ...Pack.SourceGenerator.ExecutionTests.csproj | 2 +- ...urceGenerator.MapModeExecutionTests.csproj | 2 +- .../MessagePack.SourceGenerator.Tests.csproj | 2 +- ...agePack.SourceGenerator.Unity.Tests.csproj | 2 +- .../MessagePack.Tests.csproj | 2 +- 21 files changed, 1247 insertions(+), 22 deletions(-) create mode 100644 src/MessagePack/net8.0/PublicAPI.Shipped.txt create mode 100644 src/MessagePack/net8.0/PublicAPI.Unshipped.txt diff --git a/benchmark/ExperimentalBenchmark/ExperimentalBenchmark.csproj b/benchmark/ExperimentalBenchmark/ExperimentalBenchmark.csproj index 08cce028b..a67ec549d 100644 --- a/benchmark/ExperimentalBenchmark/ExperimentalBenchmark.csproj +++ b/benchmark/ExperimentalBenchmark/ExperimentalBenchmark.csproj @@ -2,7 +2,7 @@ Exe - net6.0 + net6.0;net8.0 Benchmark true $(NoWarn);MSB3243 diff --git a/benchmark/SerializerBenchmark/SerializerBenchmark.csproj b/benchmark/SerializerBenchmark/SerializerBenchmark.csproj index f1fc6457d..f1ec5f460 100644 --- a/benchmark/SerializerBenchmark/SerializerBenchmark.csproj +++ b/benchmark/SerializerBenchmark/SerializerBenchmark.csproj @@ -2,7 +2,7 @@ Exe - net7.0 + net8.0 SerializerBenchmark Benchmark true diff --git a/sandbox/MessagePack.Internal/MessagePack.Internal.csproj b/sandbox/MessagePack.Internal/MessagePack.Internal.csproj index 7bf49a9af..86f6a7b4e 100644 --- a/sandbox/MessagePack.Internal/MessagePack.Internal.csproj +++ b/sandbox/MessagePack.Internal/MessagePack.Internal.csproj @@ -1,7 +1,7 @@  - net6.0 + net6.0;net8.0 enable $(DefineConstants);SPAN_BUILTIN;MESSAGEPACK_INTERNAL true diff --git a/sandbox/PerfBenchmarkDotNet/PerfBenchmarkDotNet.csproj b/sandbox/PerfBenchmarkDotNet/PerfBenchmarkDotNet.csproj index 4dbab7b25..425c61a90 100644 --- a/sandbox/PerfBenchmarkDotNet/PerfBenchmarkDotNet.csproj +++ b/sandbox/PerfBenchmarkDotNet/PerfBenchmarkDotNet.csproj @@ -1,7 +1,7 @@  Exe - net472;net7.0 + net472;net8.0 true true diff --git a/sandbox/PerfNetFramework/PerfNetFramework.csproj b/sandbox/PerfNetFramework/PerfNetFramework.csproj index e97936e7e..321dced72 100644 --- a/sandbox/PerfNetFramework/PerfNetFramework.csproj +++ b/sandbox/PerfNetFramework/PerfNetFramework.csproj @@ -1,7 +1,7 @@  Exe - net472;net7.0 + net472;net8.0 true diff --git a/sandbox/Sandbox/Sandbox.csproj b/sandbox/Sandbox/Sandbox.csproj index 4755bc638..20f022cd0 100644 --- a/sandbox/Sandbox/Sandbox.csproj +++ b/sandbox/Sandbox/Sandbox.csproj @@ -3,7 +3,7 @@ Exe - net6.0 + net6.0;net8.0 True diff --git a/src/MessagePack.AspNetCoreMvcFormatter/MessagePack.AspNetCoreMvcFormatter.csproj b/src/MessagePack.AspNetCoreMvcFormatter/MessagePack.AspNetCoreMvcFormatter.csproj index 6203d8a90..825074bdf 100644 --- a/src/MessagePack.AspNetCoreMvcFormatter/MessagePack.AspNetCoreMvcFormatter.csproj +++ b/src/MessagePack.AspNetCoreMvcFormatter/MessagePack.AspNetCoreMvcFormatter.csproj @@ -1,20 +1,20 @@  - netstandard2.0;net6.0 + netstandard2.0;net6.0;net8.0 ASP.NET Core MVC Input/Output MessagePack formatter ASP.NET Core MVC Input/Output MessagePack formatter. MsgPack;MessagePack;Serialization;Formatter;Serializer;aspnetcore;aspnetcoremvc - + - + - + diff --git a/src/MessagePack.Experimental/MessagePack.Experimental.csproj b/src/MessagePack.Experimental/MessagePack.Experimental.csproj index 58d6fb688..6c36e9be2 100644 --- a/src/MessagePack.Experimental/MessagePack.Experimental.csproj +++ b/src/MessagePack.Experimental/MessagePack.Experimental.csproj @@ -1,7 +1,7 @@ - net6.0 + net6.0;net8.0 true MessagePack for C#, Experimental Plugins diff --git a/src/MessagePack/MessagePack.csproj b/src/MessagePack/MessagePack.csproj index 390323add..08e27d31a 100644 --- a/src/MessagePack/MessagePack.csproj +++ b/src/MessagePack/MessagePack.csproj @@ -1,7 +1,7 @@  - netstandard2.0;net6.0 + netstandard2.0;net6.0;net8.0 $(NoWarn);CS0649 True $(DefineConstants);SPAN_BUILTIN diff --git a/src/MessagePack/net8.0/PublicAPI.Shipped.txt b/src/MessagePack/net8.0/PublicAPI.Shipped.txt new file mode 100644 index 000000000..159e4b86c --- /dev/null +++ b/src/MessagePack/net8.0/PublicAPI.Shipped.txt @@ -0,0 +1,1181 @@ +#nullable enable +MessagePack.ExtensionHeader +MessagePack.ExtensionHeader.ExtensionHeader(sbyte typeCode, int length) -> void +MessagePack.ExtensionHeader.ExtensionHeader(sbyte typeCode, uint length) -> void +MessagePack.ExtensionHeader.Length.get -> uint +MessagePack.ExtensionHeader.TypeCode.get -> sbyte +MessagePack.ExtensionResult +MessagePack.ExtensionResult.Data.get -> System.Buffers.ReadOnlySequence +MessagePack.ExtensionResult.ExtensionResult(sbyte typeCode, System.Buffers.ReadOnlySequence data) -> void +MessagePack.ExtensionResult.ExtensionResult(sbyte typeCode, System.Memory data) -> void +MessagePack.ExtensionResult.Header.get -> MessagePack.ExtensionHeader +MessagePack.ExtensionResult.TypeCode.get -> sbyte +MessagePack.FormatterNotRegisteredException +MessagePack.FormatterNotRegisteredException.FormatterNotRegisteredException(string? message) -> void +MessagePack.FormatterResolverExtensions +MessagePack.Formatters.ArrayFormatter +MessagePack.Formatters.ArrayFormatter.ArrayFormatter() -> void +MessagePack.Formatters.ArrayFormatter.Deserialize(ref MessagePack.MessagePackReader reader, MessagePack.MessagePackSerializerOptions! options) -> T[]? +MessagePack.Formatters.ArrayFormatter.Serialize(ref MessagePack.MessagePackWriter writer, T[]? value, MessagePack.MessagePackSerializerOptions! options) -> void +MessagePack.Formatters.ArraySegmentFormatter +MessagePack.Formatters.ArraySegmentFormatter.ArraySegmentFormatter() -> void +MessagePack.Formatters.ArraySegmentFormatter.Deserialize(ref MessagePack.MessagePackReader reader, MessagePack.MessagePackSerializerOptions! options) -> System.ArraySegment +MessagePack.Formatters.ArraySegmentFormatter.Serialize(ref MessagePack.MessagePackWriter writer, System.ArraySegment value, MessagePack.MessagePackSerializerOptions! options) -> void +MessagePack.Formatters.BigIntegerFormatter +MessagePack.Formatters.BigIntegerFormatter.Deserialize(ref MessagePack.MessagePackReader reader, MessagePack.MessagePackSerializerOptions! options) -> System.Numerics.BigInteger +MessagePack.Formatters.BigIntegerFormatter.Serialize(ref MessagePack.MessagePackWriter writer, System.Numerics.BigInteger value, MessagePack.MessagePackSerializerOptions! options) -> void +MessagePack.Formatters.BitArrayFormatter +MessagePack.Formatters.BitArrayFormatter.Deserialize(ref MessagePack.MessagePackReader reader, MessagePack.MessagePackSerializerOptions! options) -> System.Collections.BitArray? +MessagePack.Formatters.BitArrayFormatter.Serialize(ref MessagePack.MessagePackWriter writer, System.Collections.BitArray? value, MessagePack.MessagePackSerializerOptions! options) -> void +MessagePack.Formatters.BooleanArrayFormatter +MessagePack.Formatters.BooleanArrayFormatter.Deserialize(ref MessagePack.MessagePackReader reader, MessagePack.MessagePackSerializerOptions! options) -> bool[]? +MessagePack.Formatters.BooleanArrayFormatter.Serialize(ref MessagePack.MessagePackWriter writer, bool[]? value, MessagePack.MessagePackSerializerOptions! options) -> void +MessagePack.Formatters.BooleanFormatter +MessagePack.Formatters.BooleanFormatter.Deserialize(ref MessagePack.MessagePackReader reader, MessagePack.MessagePackSerializerOptions! options) -> bool +MessagePack.Formatters.BooleanFormatter.Serialize(ref MessagePack.MessagePackWriter writer, bool value, MessagePack.MessagePackSerializerOptions! options) -> void +MessagePack.Formatters.ByteArrayFormatter +MessagePack.Formatters.ByteArrayFormatter.Deserialize(ref MessagePack.MessagePackReader reader, MessagePack.MessagePackSerializerOptions! options) -> byte[]? +MessagePack.Formatters.ByteArrayFormatter.Serialize(ref MessagePack.MessagePackWriter writer, byte[]? value, MessagePack.MessagePackSerializerOptions! options) -> void +MessagePack.Formatters.ByteArraySegmentFormatter +MessagePack.Formatters.ByteArraySegmentFormatter.Deserialize(ref MessagePack.MessagePackReader reader, MessagePack.MessagePackSerializerOptions! options) -> System.ArraySegment +MessagePack.Formatters.ByteArraySegmentFormatter.Serialize(ref MessagePack.MessagePackWriter writer, System.ArraySegment value, MessagePack.MessagePackSerializerOptions! options) -> void +MessagePack.Formatters.ByteFormatter +MessagePack.Formatters.ByteFormatter.Deserialize(ref MessagePack.MessagePackReader reader, MessagePack.MessagePackSerializerOptions! options) -> byte +MessagePack.Formatters.ByteFormatter.Serialize(ref MessagePack.MessagePackWriter writer, byte value, MessagePack.MessagePackSerializerOptions! options) -> void +MessagePack.Formatters.CharArrayFormatter +MessagePack.Formatters.CharArrayFormatter.Deserialize(ref MessagePack.MessagePackReader reader, MessagePack.MessagePackSerializerOptions! options) -> char[]? +MessagePack.Formatters.CharArrayFormatter.Serialize(ref MessagePack.MessagePackWriter writer, char[]? value, MessagePack.MessagePackSerializerOptions! options) -> void +MessagePack.Formatters.CharFormatter +MessagePack.Formatters.CharFormatter.Deserialize(ref MessagePack.MessagePackReader reader, MessagePack.MessagePackSerializerOptions! options) -> char +MessagePack.Formatters.CharFormatter.Serialize(ref MessagePack.MessagePackWriter writer, char value, MessagePack.MessagePackSerializerOptions! options) -> void +MessagePack.Formatters.CollectionFormatterBase +MessagePack.Formatters.CollectionFormatterBase.CollectionFormatterBase() -> void +MessagePack.Formatters.CollectionFormatterBase +MessagePack.Formatters.CollectionFormatterBase.CollectionFormatterBase() -> void +MessagePack.Formatters.CollectionFormatterBase +MessagePack.Formatters.CollectionFormatterBase.CollectionFormatterBase() -> void +MessagePack.Formatters.CollectionFormatterBase.Deserialize(ref MessagePack.MessagePackReader reader, MessagePack.MessagePackSerializerOptions! options) -> TCollection? +MessagePack.Formatters.CollectionFormatterBase.Serialize(ref MessagePack.MessagePackWriter writer, TCollection? value, MessagePack.MessagePackSerializerOptions! options) -> void +MessagePack.Formatters.ComplexFormatter +MessagePack.Formatters.ComplexFormatter.Deserialize(ref MessagePack.MessagePackReader reader, MessagePack.MessagePackSerializerOptions! options) -> System.Numerics.Complex +MessagePack.Formatters.ComplexFormatter.Serialize(ref MessagePack.MessagePackWriter writer, System.Numerics.Complex value, MessagePack.MessagePackSerializerOptions! options) -> void +MessagePack.Formatters.ConcurrentBagFormatter +MessagePack.Formatters.ConcurrentBagFormatter.ConcurrentBagFormatter() -> void +MessagePack.Formatters.ConcurrentDictionaryFormatter +MessagePack.Formatters.ConcurrentDictionaryFormatter.ConcurrentDictionaryFormatter() -> void +MessagePack.Formatters.ConcurrentQueueFormatter +MessagePack.Formatters.ConcurrentQueueFormatter.ConcurrentQueueFormatter() -> void +MessagePack.Formatters.ConcurrentStackFormatter +MessagePack.Formatters.ConcurrentStackFormatter.ConcurrentStackFormatter() -> void +MessagePack.Formatters.DateTimeArrayFormatter +MessagePack.Formatters.DateTimeArrayFormatter.Deserialize(ref MessagePack.MessagePackReader reader, MessagePack.MessagePackSerializerOptions! options) -> System.DateTime[]? +MessagePack.Formatters.DateTimeArrayFormatter.Serialize(ref MessagePack.MessagePackWriter writer, System.DateTime[]? value, MessagePack.MessagePackSerializerOptions! options) -> void +MessagePack.Formatters.DateTimeFormatter +MessagePack.Formatters.DateTimeFormatter.Deserialize(ref MessagePack.MessagePackReader reader, MessagePack.MessagePackSerializerOptions! options) -> System.DateTime +MessagePack.Formatters.DateTimeFormatter.Serialize(ref MessagePack.MessagePackWriter writer, System.DateTime value, MessagePack.MessagePackSerializerOptions! options) -> void +MessagePack.Formatters.DateTimeOffsetFormatter +MessagePack.Formatters.DateTimeOffsetFormatter.Deserialize(ref MessagePack.MessagePackReader reader, MessagePack.MessagePackSerializerOptions! options) -> System.DateTimeOffset +MessagePack.Formatters.DateTimeOffsetFormatter.Serialize(ref MessagePack.MessagePackWriter writer, System.DateTimeOffset value, MessagePack.MessagePackSerializerOptions! options) -> void +MessagePack.Formatters.DecimalFormatter +MessagePack.Formatters.DecimalFormatter.Deserialize(ref MessagePack.MessagePackReader reader, MessagePack.MessagePackSerializerOptions! options) -> decimal +MessagePack.Formatters.DecimalFormatter.Serialize(ref MessagePack.MessagePackWriter writer, decimal value, MessagePack.MessagePackSerializerOptions! options) -> void +MessagePack.Formatters.DictionaryFormatter +MessagePack.Formatters.DictionaryFormatter.DictionaryFormatter() -> void +MessagePack.Formatters.DictionaryFormatterBase +MessagePack.Formatters.DictionaryFormatterBase.DictionaryFormatterBase() -> void +MessagePack.Formatters.DictionaryFormatterBase +MessagePack.Formatters.DictionaryFormatterBase.DictionaryFormatterBase() -> void +MessagePack.Formatters.DictionaryFormatterBase +MessagePack.Formatters.DictionaryFormatterBase.Deserialize(ref MessagePack.MessagePackReader reader, MessagePack.MessagePackSerializerOptions! options) -> TDictionary? +MessagePack.Formatters.DictionaryFormatterBase.DictionaryFormatterBase() -> void +MessagePack.Formatters.DictionaryFormatterBase.Serialize(ref MessagePack.MessagePackWriter writer, TDictionary? value, MessagePack.MessagePackSerializerOptions! options) -> void +MessagePack.Formatters.DoubleArrayFormatter +MessagePack.Formatters.DoubleArrayFormatter.Deserialize(ref MessagePack.MessagePackReader reader, MessagePack.MessagePackSerializerOptions! options) -> double[]? +MessagePack.Formatters.DoubleArrayFormatter.Serialize(ref MessagePack.MessagePackWriter writer, double[]? value, MessagePack.MessagePackSerializerOptions! options) -> void +MessagePack.Formatters.DoubleFormatter +MessagePack.Formatters.DoubleFormatter.Deserialize(ref MessagePack.MessagePackReader reader, MessagePack.MessagePackSerializerOptions! options) -> double +MessagePack.Formatters.DoubleFormatter.Serialize(ref MessagePack.MessagePackWriter writer, double value, MessagePack.MessagePackSerializerOptions! options) -> void +MessagePack.Formatters.DynamicObjectTypeFallbackFormatter +MessagePack.Formatters.DynamicObjectTypeFallbackFormatter.Deserialize(ref MessagePack.MessagePackReader reader, MessagePack.MessagePackSerializerOptions! options) -> object? +MessagePack.Formatters.DynamicObjectTypeFallbackFormatter.Serialize(ref MessagePack.MessagePackWriter writer, object? value, MessagePack.MessagePackSerializerOptions! options) -> void +MessagePack.Formatters.EnumAsStringFormatter +MessagePack.Formatters.EnumAsStringFormatter.Deserialize(ref MessagePack.MessagePackReader reader, MessagePack.MessagePackSerializerOptions! options) -> T +MessagePack.Formatters.EnumAsStringFormatter.EnumAsStringFormatter() -> void +MessagePack.Formatters.EnumAsStringFormatter.Serialize(ref MessagePack.MessagePackWriter writer, T value, MessagePack.MessagePackSerializerOptions! options) -> void +MessagePack.Formatters.ForceByteBlockFormatter +MessagePack.Formatters.ForceByteBlockFormatter.Deserialize(ref MessagePack.MessagePackReader reader, MessagePack.MessagePackSerializerOptions! options) -> byte +MessagePack.Formatters.ForceByteBlockFormatter.Serialize(ref MessagePack.MessagePackWriter writer, byte value, MessagePack.MessagePackSerializerOptions! options) -> void +MessagePack.Formatters.ForceInt16BlockArrayFormatter +MessagePack.Formatters.ForceInt16BlockArrayFormatter.Deserialize(ref MessagePack.MessagePackReader reader, MessagePack.MessagePackSerializerOptions! options) -> short[]? +MessagePack.Formatters.ForceInt16BlockArrayFormatter.Serialize(ref MessagePack.MessagePackWriter writer, short[]? value, MessagePack.MessagePackSerializerOptions! options) -> void +MessagePack.Formatters.ForceInt16BlockFormatter +MessagePack.Formatters.ForceInt16BlockFormatter.Deserialize(ref MessagePack.MessagePackReader reader, MessagePack.MessagePackSerializerOptions! options) -> short +MessagePack.Formatters.ForceInt16BlockFormatter.Serialize(ref MessagePack.MessagePackWriter writer, short value, MessagePack.MessagePackSerializerOptions! options) -> void +MessagePack.Formatters.ForceInt32BlockArrayFormatter +MessagePack.Formatters.ForceInt32BlockArrayFormatter.Deserialize(ref MessagePack.MessagePackReader reader, MessagePack.MessagePackSerializerOptions! options) -> int[]? +MessagePack.Formatters.ForceInt32BlockArrayFormatter.Serialize(ref MessagePack.MessagePackWriter writer, int[]? value, MessagePack.MessagePackSerializerOptions! options) -> void +MessagePack.Formatters.ForceInt32BlockFormatter +MessagePack.Formatters.ForceInt32BlockFormatter.Deserialize(ref MessagePack.MessagePackReader reader, MessagePack.MessagePackSerializerOptions! options) -> int +MessagePack.Formatters.ForceInt32BlockFormatter.Serialize(ref MessagePack.MessagePackWriter writer, int value, MessagePack.MessagePackSerializerOptions! options) -> void +MessagePack.Formatters.ForceInt64BlockArrayFormatter +MessagePack.Formatters.ForceInt64BlockArrayFormatter.Deserialize(ref MessagePack.MessagePackReader reader, MessagePack.MessagePackSerializerOptions! options) -> long[]? +MessagePack.Formatters.ForceInt64BlockArrayFormatter.Serialize(ref MessagePack.MessagePackWriter writer, long[]? value, MessagePack.MessagePackSerializerOptions! options) -> void +MessagePack.Formatters.ForceInt64BlockFormatter +MessagePack.Formatters.ForceInt64BlockFormatter.Deserialize(ref MessagePack.MessagePackReader reader, MessagePack.MessagePackSerializerOptions! options) -> long +MessagePack.Formatters.ForceInt64BlockFormatter.Serialize(ref MessagePack.MessagePackWriter writer, long value, MessagePack.MessagePackSerializerOptions! options) -> void +MessagePack.Formatters.ForceSByteBlockArrayFormatter +MessagePack.Formatters.ForceSByteBlockArrayFormatter.Deserialize(ref MessagePack.MessagePackReader reader, MessagePack.MessagePackSerializerOptions! options) -> sbyte[]? +MessagePack.Formatters.ForceSByteBlockArrayFormatter.Serialize(ref MessagePack.MessagePackWriter writer, sbyte[]? value, MessagePack.MessagePackSerializerOptions! options) -> void +MessagePack.Formatters.ForceSByteBlockFormatter +MessagePack.Formatters.ForceSByteBlockFormatter.Deserialize(ref MessagePack.MessagePackReader reader, MessagePack.MessagePackSerializerOptions! options) -> sbyte +MessagePack.Formatters.ForceSByteBlockFormatter.Serialize(ref MessagePack.MessagePackWriter writer, sbyte value, MessagePack.MessagePackSerializerOptions! options) -> void +MessagePack.Formatters.ForceUInt16BlockArrayFormatter +MessagePack.Formatters.ForceUInt16BlockArrayFormatter.Deserialize(ref MessagePack.MessagePackReader reader, MessagePack.MessagePackSerializerOptions! options) -> ushort[]? +MessagePack.Formatters.ForceUInt16BlockArrayFormatter.Serialize(ref MessagePack.MessagePackWriter writer, ushort[]? value, MessagePack.MessagePackSerializerOptions! options) -> void +MessagePack.Formatters.ForceUInt16BlockFormatter +MessagePack.Formatters.ForceUInt16BlockFormatter.Deserialize(ref MessagePack.MessagePackReader reader, MessagePack.MessagePackSerializerOptions! options) -> ushort +MessagePack.Formatters.ForceUInt16BlockFormatter.Serialize(ref MessagePack.MessagePackWriter writer, ushort value, MessagePack.MessagePackSerializerOptions! options) -> void +MessagePack.Formatters.ForceUInt32BlockArrayFormatter +MessagePack.Formatters.ForceUInt32BlockArrayFormatter.Deserialize(ref MessagePack.MessagePackReader reader, MessagePack.MessagePackSerializerOptions! options) -> uint[]? +MessagePack.Formatters.ForceUInt32BlockArrayFormatter.Serialize(ref MessagePack.MessagePackWriter writer, uint[]? value, MessagePack.MessagePackSerializerOptions! options) -> void +MessagePack.Formatters.ForceUInt32BlockFormatter +MessagePack.Formatters.ForceUInt32BlockFormatter.Deserialize(ref MessagePack.MessagePackReader reader, MessagePack.MessagePackSerializerOptions! options) -> uint +MessagePack.Formatters.ForceUInt32BlockFormatter.Serialize(ref MessagePack.MessagePackWriter writer, uint value, MessagePack.MessagePackSerializerOptions! options) -> void +MessagePack.Formatters.ForceUInt64BlockArrayFormatter +MessagePack.Formatters.ForceUInt64BlockArrayFormatter.Deserialize(ref MessagePack.MessagePackReader reader, MessagePack.MessagePackSerializerOptions! options) -> ulong[]? +MessagePack.Formatters.ForceUInt64BlockArrayFormatter.Serialize(ref MessagePack.MessagePackWriter writer, ulong[]? value, MessagePack.MessagePackSerializerOptions! options) -> void +MessagePack.Formatters.ForceUInt64BlockFormatter +MessagePack.Formatters.ForceUInt64BlockFormatter.Deserialize(ref MessagePack.MessagePackReader reader, MessagePack.MessagePackSerializerOptions! options) -> ulong +MessagePack.Formatters.ForceUInt64BlockFormatter.Serialize(ref MessagePack.MessagePackWriter writer, ulong value, MessagePack.MessagePackSerializerOptions! options) -> void +MessagePack.Formatters.FourDimensionalArrayFormatter +MessagePack.Formatters.FourDimensionalArrayFormatter.Deserialize(ref MessagePack.MessagePackReader reader, MessagePack.MessagePackSerializerOptions! options) -> T[,,,]? +MessagePack.Formatters.FourDimensionalArrayFormatter.FourDimensionalArrayFormatter() -> void +MessagePack.Formatters.FourDimensionalArrayFormatter.Serialize(ref MessagePack.MessagePackWriter writer, T[,,,]? value, MessagePack.MessagePackSerializerOptions! options) -> void +MessagePack.Formatters.GenericCollectionFormatter +MessagePack.Formatters.GenericCollectionFormatter.GenericCollectionFormatter() -> void +MessagePack.Formatters.GenericDictionaryFormatter +MessagePack.Formatters.GenericDictionaryFormatter.GenericDictionaryFormatter() -> void +MessagePack.Formatters.GenericEnumFormatter +MessagePack.Formatters.GenericEnumFormatter.Deserialize(ref MessagePack.MessagePackReader reader, MessagePack.MessagePackSerializerOptions! options) -> T +MessagePack.Formatters.GenericEnumFormatter.GenericEnumFormatter() -> void +MessagePack.Formatters.GenericEnumFormatter.Serialize(ref MessagePack.MessagePackWriter writer, T value, MessagePack.MessagePackSerializerOptions! options) -> void +MessagePack.Formatters.GuidFormatter +MessagePack.Formatters.GuidFormatter.Deserialize(ref MessagePack.MessagePackReader reader, MessagePack.MessagePackSerializerOptions! options) -> System.Guid +MessagePack.Formatters.GuidFormatter.Serialize(ref MessagePack.MessagePackWriter writer, System.Guid value, MessagePack.MessagePackSerializerOptions! options) -> void +MessagePack.Formatters.HashSetFormatter +MessagePack.Formatters.HashSetFormatter.HashSetFormatter() -> void +MessagePack.Formatters.IMessagePackFormatter +MessagePack.Formatters.IMessagePackFormatter +MessagePack.Formatters.IMessagePackFormatter.Deserialize(ref MessagePack.MessagePackReader reader, MessagePack.MessagePackSerializerOptions! options) -> T +MessagePack.Formatters.IMessagePackFormatter.Serialize(ref MessagePack.MessagePackWriter writer, T value, MessagePack.MessagePackSerializerOptions! options) -> void +MessagePack.Formatters.IgnoreFormatter +MessagePack.Formatters.IgnoreFormatter.Deserialize(ref MessagePack.MessagePackReader reader, MessagePack.MessagePackSerializerOptions! options) -> T? +MessagePack.Formatters.IgnoreFormatter.IgnoreFormatter() -> void +MessagePack.Formatters.IgnoreFormatter.Serialize(ref MessagePack.MessagePackWriter writer, T? value, MessagePack.MessagePackSerializerOptions! options) -> void +MessagePack.Formatters.Int16ArrayFormatter +MessagePack.Formatters.Int16ArrayFormatter.Deserialize(ref MessagePack.MessagePackReader reader, MessagePack.MessagePackSerializerOptions! options) -> short[]? +MessagePack.Formatters.Int16ArrayFormatter.Serialize(ref MessagePack.MessagePackWriter writer, short[]? value, MessagePack.MessagePackSerializerOptions! options) -> void +MessagePack.Formatters.Int16Formatter +MessagePack.Formatters.Int16Formatter.Deserialize(ref MessagePack.MessagePackReader reader, MessagePack.MessagePackSerializerOptions! options) -> short +MessagePack.Formatters.Int16Formatter.Serialize(ref MessagePack.MessagePackWriter writer, short value, MessagePack.MessagePackSerializerOptions! options) -> void +MessagePack.Formatters.Int32ArrayFormatter +MessagePack.Formatters.Int32ArrayFormatter.Deserialize(ref MessagePack.MessagePackReader reader, MessagePack.MessagePackSerializerOptions! options) -> int[]? +MessagePack.Formatters.Int32ArrayFormatter.Serialize(ref MessagePack.MessagePackWriter writer, int[]? value, MessagePack.MessagePackSerializerOptions! options) -> void +MessagePack.Formatters.Int32Formatter +MessagePack.Formatters.Int32Formatter.Deserialize(ref MessagePack.MessagePackReader reader, MessagePack.MessagePackSerializerOptions! options) -> int +MessagePack.Formatters.Int32Formatter.Serialize(ref MessagePack.MessagePackWriter writer, int value, MessagePack.MessagePackSerializerOptions! options) -> void +MessagePack.Formatters.Int64ArrayFormatter +MessagePack.Formatters.Int64ArrayFormatter.Deserialize(ref MessagePack.MessagePackReader reader, MessagePack.MessagePackSerializerOptions! options) -> long[]? +MessagePack.Formatters.Int64ArrayFormatter.Serialize(ref MessagePack.MessagePackWriter writer, long[]? value, MessagePack.MessagePackSerializerOptions! options) -> void +MessagePack.Formatters.Int64Formatter +MessagePack.Formatters.Int64Formatter.Deserialize(ref MessagePack.MessagePackReader reader, MessagePack.MessagePackSerializerOptions! options) -> long +MessagePack.Formatters.Int64Formatter.Serialize(ref MessagePack.MessagePackWriter writer, long value, MessagePack.MessagePackSerializerOptions! options) -> void +MessagePack.Formatters.InterfaceCollectionFormatter +MessagePack.Formatters.InterfaceCollectionFormatter.InterfaceCollectionFormatter() -> void +MessagePack.Formatters.InterfaceDictionaryFormatter +MessagePack.Formatters.InterfaceDictionaryFormatter.InterfaceDictionaryFormatter() -> void +MessagePack.Formatters.InterfaceEnumerableFormatter +MessagePack.Formatters.InterfaceEnumerableFormatter.InterfaceEnumerableFormatter() -> void +MessagePack.Formatters.InterfaceGroupingFormatter +MessagePack.Formatters.InterfaceGroupingFormatter.Deserialize(ref MessagePack.MessagePackReader reader, MessagePack.MessagePackSerializerOptions! options) -> System.Linq.IGrouping? +MessagePack.Formatters.InterfaceGroupingFormatter.InterfaceGroupingFormatter() -> void +MessagePack.Formatters.InterfaceGroupingFormatter.Serialize(ref MessagePack.MessagePackWriter writer, System.Linq.IGrouping? value, MessagePack.MessagePackSerializerOptions! options) -> void +MessagePack.Formatters.InterfaceListFormatter +MessagePack.Formatters.InterfaceListFormatter.InterfaceListFormatter() -> void +MessagePack.Formatters.InterfaceLookupFormatter +MessagePack.Formatters.InterfaceLookupFormatter.InterfaceLookupFormatter() -> void +MessagePack.Formatters.InterfaceReadOnlyCollectionFormatter +MessagePack.Formatters.InterfaceReadOnlyCollectionFormatter.InterfaceReadOnlyCollectionFormatter() -> void +MessagePack.Formatters.InterfaceReadOnlyDictionaryFormatter +MessagePack.Formatters.InterfaceReadOnlyDictionaryFormatter.InterfaceReadOnlyDictionaryFormatter() -> void +MessagePack.Formatters.InterfaceReadOnlyListFormatter +MessagePack.Formatters.InterfaceReadOnlyListFormatter.InterfaceReadOnlyListFormatter() -> void +MessagePack.Formatters.InterfaceSetFormatter +MessagePack.Formatters.InterfaceSetFormatter.InterfaceSetFormatter() -> void +MessagePack.Formatters.KeyValuePairFormatter +MessagePack.Formatters.KeyValuePairFormatter.Deserialize(ref MessagePack.MessagePackReader reader, MessagePack.MessagePackSerializerOptions! options) -> System.Collections.Generic.KeyValuePair +MessagePack.Formatters.KeyValuePairFormatter.KeyValuePairFormatter() -> void +MessagePack.Formatters.KeyValuePairFormatter.Serialize(ref MessagePack.MessagePackWriter writer, System.Collections.Generic.KeyValuePair value, MessagePack.MessagePackSerializerOptions! options) -> void +MessagePack.Formatters.LazyFormatter +MessagePack.Formatters.LazyFormatter.Deserialize(ref MessagePack.MessagePackReader reader, MessagePack.MessagePackSerializerOptions! options) -> System.Lazy? +MessagePack.Formatters.LazyFormatter.LazyFormatter() -> void +MessagePack.Formatters.LazyFormatter.Serialize(ref MessagePack.MessagePackWriter writer, System.Lazy? value, MessagePack.MessagePackSerializerOptions! options) -> void +MessagePack.Formatters.LinkedListFormatter +MessagePack.Formatters.LinkedListFormatter.LinkedListFormatter() -> void +MessagePack.Formatters.ListFormatter +MessagePack.Formatters.ListFormatter.Deserialize(ref MessagePack.MessagePackReader reader, MessagePack.MessagePackSerializerOptions! options) -> System.Collections.Generic.List? +MessagePack.Formatters.ListFormatter.ListFormatter() -> void +MessagePack.Formatters.ListFormatter.Serialize(ref MessagePack.MessagePackWriter writer, System.Collections.Generic.List? value, MessagePack.MessagePackSerializerOptions! options) -> void +MessagePack.Formatters.NativeDateTimeArrayFormatter +MessagePack.Formatters.NativeDateTimeArrayFormatter.Deserialize(ref MessagePack.MessagePackReader reader, MessagePack.MessagePackSerializerOptions! options) -> System.DateTime[]? +MessagePack.Formatters.NativeDateTimeArrayFormatter.NativeDateTimeArrayFormatter() -> void +MessagePack.Formatters.NativeDateTimeArrayFormatter.Serialize(ref MessagePack.MessagePackWriter writer, System.DateTime[]? value, MessagePack.MessagePackSerializerOptions! options) -> void +MessagePack.Formatters.NativeDateTimeFormatter +MessagePack.Formatters.NativeDateTimeFormatter.Deserialize(ref MessagePack.MessagePackReader reader, MessagePack.MessagePackSerializerOptions! options) -> System.DateTime +MessagePack.Formatters.NativeDateTimeFormatter.NativeDateTimeFormatter() -> void +MessagePack.Formatters.NativeDateTimeFormatter.Serialize(ref MessagePack.MessagePackWriter writer, System.DateTime value, MessagePack.MessagePackSerializerOptions! options) -> void +MessagePack.Formatters.NativeDecimalFormatter +MessagePack.Formatters.NativeDecimalFormatter.Deserialize(ref MessagePack.MessagePackReader reader, MessagePack.MessagePackSerializerOptions! options) -> decimal +MessagePack.Formatters.NativeDecimalFormatter.Serialize(ref MessagePack.MessagePackWriter writer, decimal value, MessagePack.MessagePackSerializerOptions! options) -> void +MessagePack.Formatters.NativeGuidFormatter +MessagePack.Formatters.NativeGuidFormatter.Deserialize(ref MessagePack.MessagePackReader reader, MessagePack.MessagePackSerializerOptions! options) -> System.Guid +MessagePack.Formatters.NativeGuidFormatter.Serialize(ref MessagePack.MessagePackWriter writer, System.Guid value, MessagePack.MessagePackSerializerOptions! options) -> void +MessagePack.Formatters.NilFormatter +MessagePack.Formatters.NilFormatter.Deserialize(ref MessagePack.MessagePackReader reader, MessagePack.MessagePackSerializerOptions! options) -> MessagePack.Nil +MessagePack.Formatters.NilFormatter.Serialize(ref MessagePack.MessagePackWriter writer, MessagePack.Nil value, MessagePack.MessagePackSerializerOptions! options) -> void +MessagePack.Formatters.NonGenericDictionaryFormatter +MessagePack.Formatters.NonGenericDictionaryFormatter.Deserialize(ref MessagePack.MessagePackReader reader, MessagePack.MessagePackSerializerOptions! options) -> T? +MessagePack.Formatters.NonGenericDictionaryFormatter.NonGenericDictionaryFormatter() -> void +MessagePack.Formatters.NonGenericDictionaryFormatter.Serialize(ref MessagePack.MessagePackWriter writer, T? value, MessagePack.MessagePackSerializerOptions! options) -> void +MessagePack.Formatters.NonGenericInterfaceDictionaryFormatter +MessagePack.Formatters.NonGenericInterfaceDictionaryFormatter.Deserialize(ref MessagePack.MessagePackReader reader, MessagePack.MessagePackSerializerOptions! options) -> System.Collections.IDictionary? +MessagePack.Formatters.NonGenericInterfaceDictionaryFormatter.Serialize(ref MessagePack.MessagePackWriter writer, System.Collections.IDictionary? value, MessagePack.MessagePackSerializerOptions! options) -> void +MessagePack.Formatters.NonGenericInterfaceListFormatter +MessagePack.Formatters.NonGenericInterfaceListFormatter.Deserialize(ref MessagePack.MessagePackReader reader, MessagePack.MessagePackSerializerOptions! options) -> System.Collections.IList? +MessagePack.Formatters.NonGenericInterfaceListFormatter.Serialize(ref MessagePack.MessagePackWriter writer, System.Collections.IList? value, MessagePack.MessagePackSerializerOptions! options) -> void +MessagePack.Formatters.NonGenericListFormatter +MessagePack.Formatters.NonGenericListFormatter.Deserialize(ref MessagePack.MessagePackReader reader, MessagePack.MessagePackSerializerOptions! options) -> T? +MessagePack.Formatters.NonGenericListFormatter.NonGenericListFormatter() -> void +MessagePack.Formatters.NonGenericListFormatter.Serialize(ref MessagePack.MessagePackWriter writer, T? value, MessagePack.MessagePackSerializerOptions! options) -> void +MessagePack.Formatters.NullableBooleanFormatter +MessagePack.Formatters.NullableBooleanFormatter.Deserialize(ref MessagePack.MessagePackReader reader, MessagePack.MessagePackSerializerOptions! options) -> bool? +MessagePack.Formatters.NullableBooleanFormatter.Serialize(ref MessagePack.MessagePackWriter writer, bool? value, MessagePack.MessagePackSerializerOptions! options) -> void +MessagePack.Formatters.NullableByteFormatter +MessagePack.Formatters.NullableByteFormatter.Deserialize(ref MessagePack.MessagePackReader reader, MessagePack.MessagePackSerializerOptions! options) -> byte? +MessagePack.Formatters.NullableByteFormatter.Serialize(ref MessagePack.MessagePackWriter writer, byte? value, MessagePack.MessagePackSerializerOptions! options) -> void +MessagePack.Formatters.NullableCharFormatter +MessagePack.Formatters.NullableCharFormatter.Deserialize(ref MessagePack.MessagePackReader reader, MessagePack.MessagePackSerializerOptions! options) -> char? +MessagePack.Formatters.NullableCharFormatter.Serialize(ref MessagePack.MessagePackWriter writer, char? value, MessagePack.MessagePackSerializerOptions! options) -> void +MessagePack.Formatters.NullableDateTimeFormatter +MessagePack.Formatters.NullableDateTimeFormatter.Deserialize(ref MessagePack.MessagePackReader reader, MessagePack.MessagePackSerializerOptions! options) -> System.DateTime? +MessagePack.Formatters.NullableDateTimeFormatter.Serialize(ref MessagePack.MessagePackWriter writer, System.DateTime? value, MessagePack.MessagePackSerializerOptions! options) -> void +MessagePack.Formatters.NullableDoubleFormatter +MessagePack.Formatters.NullableDoubleFormatter.Deserialize(ref MessagePack.MessagePackReader reader, MessagePack.MessagePackSerializerOptions! options) -> double? +MessagePack.Formatters.NullableDoubleFormatter.Serialize(ref MessagePack.MessagePackWriter writer, double? value, MessagePack.MessagePackSerializerOptions! options) -> void +MessagePack.Formatters.NullableForceByteBlockFormatter +MessagePack.Formatters.NullableForceByteBlockFormatter.Deserialize(ref MessagePack.MessagePackReader reader, MessagePack.MessagePackSerializerOptions! options) -> byte? +MessagePack.Formatters.NullableForceByteBlockFormatter.Serialize(ref MessagePack.MessagePackWriter writer, byte? value, MessagePack.MessagePackSerializerOptions! options) -> void +MessagePack.Formatters.NullableForceInt16BlockFormatter +MessagePack.Formatters.NullableForceInt16BlockFormatter.Deserialize(ref MessagePack.MessagePackReader reader, MessagePack.MessagePackSerializerOptions! options) -> short? +MessagePack.Formatters.NullableForceInt16BlockFormatter.Serialize(ref MessagePack.MessagePackWriter writer, short? value, MessagePack.MessagePackSerializerOptions! options) -> void +MessagePack.Formatters.NullableForceInt32BlockFormatter +MessagePack.Formatters.NullableForceInt32BlockFormatter.Deserialize(ref MessagePack.MessagePackReader reader, MessagePack.MessagePackSerializerOptions! options) -> int? +MessagePack.Formatters.NullableForceInt32BlockFormatter.Serialize(ref MessagePack.MessagePackWriter writer, int? value, MessagePack.MessagePackSerializerOptions! options) -> void +MessagePack.Formatters.NullableForceInt64BlockFormatter +MessagePack.Formatters.NullableForceInt64BlockFormatter.Deserialize(ref MessagePack.MessagePackReader reader, MessagePack.MessagePackSerializerOptions! options) -> long? +MessagePack.Formatters.NullableForceInt64BlockFormatter.Serialize(ref MessagePack.MessagePackWriter writer, long? value, MessagePack.MessagePackSerializerOptions! options) -> void +MessagePack.Formatters.NullableForceSByteBlockFormatter +MessagePack.Formatters.NullableForceSByteBlockFormatter.Deserialize(ref MessagePack.MessagePackReader reader, MessagePack.MessagePackSerializerOptions! options) -> sbyte? +MessagePack.Formatters.NullableForceSByteBlockFormatter.Serialize(ref MessagePack.MessagePackWriter writer, sbyte? value, MessagePack.MessagePackSerializerOptions! options) -> void +MessagePack.Formatters.NullableForceUInt16BlockFormatter +MessagePack.Formatters.NullableForceUInt16BlockFormatter.Deserialize(ref MessagePack.MessagePackReader reader, MessagePack.MessagePackSerializerOptions! options) -> ushort? +MessagePack.Formatters.NullableForceUInt16BlockFormatter.Serialize(ref MessagePack.MessagePackWriter writer, ushort? value, MessagePack.MessagePackSerializerOptions! options) -> void +MessagePack.Formatters.NullableForceUInt32BlockFormatter +MessagePack.Formatters.NullableForceUInt32BlockFormatter.Deserialize(ref MessagePack.MessagePackReader reader, MessagePack.MessagePackSerializerOptions! options) -> uint? +MessagePack.Formatters.NullableForceUInt32BlockFormatter.Serialize(ref MessagePack.MessagePackWriter writer, uint? value, MessagePack.MessagePackSerializerOptions! options) -> void +MessagePack.Formatters.NullableForceUInt64BlockFormatter +MessagePack.Formatters.NullableForceUInt64BlockFormatter.Deserialize(ref MessagePack.MessagePackReader reader, MessagePack.MessagePackSerializerOptions! options) -> ulong? +MessagePack.Formatters.NullableForceUInt64BlockFormatter.Serialize(ref MessagePack.MessagePackWriter writer, ulong? value, MessagePack.MessagePackSerializerOptions! options) -> void +MessagePack.Formatters.NullableFormatter +MessagePack.Formatters.NullableFormatter.Deserialize(ref MessagePack.MessagePackReader reader, MessagePack.MessagePackSerializerOptions! options) -> T? +MessagePack.Formatters.NullableFormatter.NullableFormatter() -> void +MessagePack.Formatters.NullableFormatter.Serialize(ref MessagePack.MessagePackWriter writer, T? value, MessagePack.MessagePackSerializerOptions! options) -> void +MessagePack.Formatters.NullableInt16Formatter +MessagePack.Formatters.NullableInt16Formatter.Deserialize(ref MessagePack.MessagePackReader reader, MessagePack.MessagePackSerializerOptions! options) -> short? +MessagePack.Formatters.NullableInt16Formatter.Serialize(ref MessagePack.MessagePackWriter writer, short? value, MessagePack.MessagePackSerializerOptions! options) -> void +MessagePack.Formatters.NullableInt32Formatter +MessagePack.Formatters.NullableInt32Formatter.Deserialize(ref MessagePack.MessagePackReader reader, MessagePack.MessagePackSerializerOptions! options) -> int? +MessagePack.Formatters.NullableInt32Formatter.Serialize(ref MessagePack.MessagePackWriter writer, int? value, MessagePack.MessagePackSerializerOptions! options) -> void +MessagePack.Formatters.NullableInt64Formatter +MessagePack.Formatters.NullableInt64Formatter.Deserialize(ref MessagePack.MessagePackReader reader, MessagePack.MessagePackSerializerOptions! options) -> long? +MessagePack.Formatters.NullableInt64Formatter.Serialize(ref MessagePack.MessagePackWriter writer, long? value, MessagePack.MessagePackSerializerOptions! options) -> void +MessagePack.Formatters.NullableNilFormatter +MessagePack.Formatters.NullableNilFormatter.Deserialize(ref MessagePack.MessagePackReader reader, MessagePack.MessagePackSerializerOptions! options) -> MessagePack.Nil? +MessagePack.Formatters.NullableNilFormatter.Serialize(ref MessagePack.MessagePackWriter writer, MessagePack.Nil? value, MessagePack.MessagePackSerializerOptions! options) -> void +MessagePack.Formatters.NullableSByteFormatter +MessagePack.Formatters.NullableSByteFormatter.Deserialize(ref MessagePack.MessagePackReader reader, MessagePack.MessagePackSerializerOptions! options) -> sbyte? +MessagePack.Formatters.NullableSByteFormatter.Serialize(ref MessagePack.MessagePackWriter writer, sbyte? value, MessagePack.MessagePackSerializerOptions! options) -> void +MessagePack.Formatters.NullableSingleFormatter +MessagePack.Formatters.NullableSingleFormatter.Deserialize(ref MessagePack.MessagePackReader reader, MessagePack.MessagePackSerializerOptions! options) -> float? +MessagePack.Formatters.NullableSingleFormatter.Serialize(ref MessagePack.MessagePackWriter writer, float? value, MessagePack.MessagePackSerializerOptions! options) -> void +MessagePack.Formatters.NullableStringArrayFormatter +MessagePack.Formatters.NullableStringArrayFormatter.Deserialize(ref MessagePack.MessagePackReader reader, MessagePack.MessagePackSerializerOptions! options) -> string?[]? +MessagePack.Formatters.NullableStringArrayFormatter.Serialize(ref MessagePack.MessagePackWriter writer, string?[]? value, MessagePack.MessagePackSerializerOptions! options) -> void +MessagePack.Formatters.NullableStringFormatter +MessagePack.Formatters.NullableStringFormatter.Deserialize(ref MessagePack.MessagePackReader reader, MessagePack.MessagePackSerializerOptions! options) -> string? +MessagePack.Formatters.NullableStringFormatter.Serialize(ref MessagePack.MessagePackWriter writer, string? value, MessagePack.MessagePackSerializerOptions! options) -> void +MessagePack.Formatters.NullableUInt16Formatter +MessagePack.Formatters.NullableUInt16Formatter.Deserialize(ref MessagePack.MessagePackReader reader, MessagePack.MessagePackSerializerOptions! options) -> ushort? +MessagePack.Formatters.NullableUInt16Formatter.Serialize(ref MessagePack.MessagePackWriter writer, ushort? value, MessagePack.MessagePackSerializerOptions! options) -> void +MessagePack.Formatters.NullableUInt32Formatter +MessagePack.Formatters.NullableUInt32Formatter.Deserialize(ref MessagePack.MessagePackReader reader, MessagePack.MessagePackSerializerOptions! options) -> uint? +MessagePack.Formatters.NullableUInt32Formatter.Serialize(ref MessagePack.MessagePackWriter writer, uint? value, MessagePack.MessagePackSerializerOptions! options) -> void +MessagePack.Formatters.NullableUInt64Formatter +MessagePack.Formatters.NullableUInt64Formatter.Deserialize(ref MessagePack.MessagePackReader reader, MessagePack.MessagePackSerializerOptions! options) -> ulong? +MessagePack.Formatters.NullableUInt64Formatter.Serialize(ref MessagePack.MessagePackWriter writer, ulong? value, MessagePack.MessagePackSerializerOptions! options) -> void +MessagePack.Formatters.ObservableCollectionFormatter +MessagePack.Formatters.ObservableCollectionFormatter.ObservableCollectionFormatter() -> void +MessagePack.Formatters.PrimitiveObjectFormatter +MessagePack.Formatters.PrimitiveObjectFormatter.Deserialize(ref MessagePack.MessagePackReader reader, MessagePack.MessagePackSerializerOptions! options) -> object? +MessagePack.Formatters.PrimitiveObjectFormatter.Serialize(ref MessagePack.MessagePackWriter writer, object? value, MessagePack.MessagePackSerializerOptions! options) -> void +MessagePack.Formatters.QueueFormatter +MessagePack.Formatters.QueueFormatter.QueueFormatter() -> void +MessagePack.Formatters.ReadOnlyCollectionFormatter +MessagePack.Formatters.ReadOnlyCollectionFormatter.ReadOnlyCollectionFormatter() -> void +MessagePack.Formatters.ReadOnlyDictionaryFormatter +MessagePack.Formatters.ReadOnlyDictionaryFormatter.ReadOnlyDictionaryFormatter() -> void +MessagePack.Formatters.ReadOnlyObservableCollectionFormatter +MessagePack.Formatters.ReadOnlyObservableCollectionFormatter.ReadOnlyObservableCollectionFormatter() -> void +MessagePack.Formatters.SByteArrayFormatter +MessagePack.Formatters.SByteArrayFormatter.Deserialize(ref MessagePack.MessagePackReader reader, MessagePack.MessagePackSerializerOptions! options) -> sbyte[]? +MessagePack.Formatters.SByteArrayFormatter.Serialize(ref MessagePack.MessagePackWriter writer, sbyte[]? value, MessagePack.MessagePackSerializerOptions! options) -> void +MessagePack.Formatters.SByteFormatter +MessagePack.Formatters.SByteFormatter.Deserialize(ref MessagePack.MessagePackReader reader, MessagePack.MessagePackSerializerOptions! options) -> sbyte +MessagePack.Formatters.SByteFormatter.Serialize(ref MessagePack.MessagePackWriter writer, sbyte value, MessagePack.MessagePackSerializerOptions! options) -> void +MessagePack.Formatters.SingleArrayFormatter +MessagePack.Formatters.SingleArrayFormatter.Deserialize(ref MessagePack.MessagePackReader reader, MessagePack.MessagePackSerializerOptions! options) -> float[]? +MessagePack.Formatters.SingleArrayFormatter.Serialize(ref MessagePack.MessagePackWriter writer, float[]? value, MessagePack.MessagePackSerializerOptions! options) -> void +MessagePack.Formatters.SingleFormatter +MessagePack.Formatters.SingleFormatter.Deserialize(ref MessagePack.MessagePackReader reader, MessagePack.MessagePackSerializerOptions! options) -> float +MessagePack.Formatters.SingleFormatter.Serialize(ref MessagePack.MessagePackWriter writer, float value, MessagePack.MessagePackSerializerOptions! options) -> void +MessagePack.Formatters.SortedDictionaryFormatter +MessagePack.Formatters.SortedDictionaryFormatter.SortedDictionaryFormatter() -> void +MessagePack.Formatters.SortedListFormatter +MessagePack.Formatters.SortedListFormatter.SortedListFormatter() -> void +MessagePack.Formatters.StackFormatter +MessagePack.Formatters.StackFormatter.StackFormatter() -> void +MessagePack.Formatters.StaticNullableFormatter +MessagePack.Formatters.StaticNullableFormatter.Deserialize(ref MessagePack.MessagePackReader reader, MessagePack.MessagePackSerializerOptions! options) -> T? +MessagePack.Formatters.StaticNullableFormatter.Serialize(ref MessagePack.MessagePackWriter writer, T? value, MessagePack.MessagePackSerializerOptions! options) -> void +MessagePack.Formatters.StaticNullableFormatter.StaticNullableFormatter(MessagePack.Formatters.IMessagePackFormatter! underlyingFormatter) -> void +MessagePack.Formatters.StringBuilderFormatter +MessagePack.Formatters.StringBuilderFormatter.Deserialize(ref MessagePack.MessagePackReader reader, MessagePack.MessagePackSerializerOptions! options) -> System.Text.StringBuilder? +MessagePack.Formatters.StringBuilderFormatter.Serialize(ref MessagePack.MessagePackWriter writer, System.Text.StringBuilder? value, MessagePack.MessagePackSerializerOptions! options) -> void +MessagePack.Formatters.ThreeDimensionalArrayFormatter +MessagePack.Formatters.ThreeDimensionalArrayFormatter.Deserialize(ref MessagePack.MessagePackReader reader, MessagePack.MessagePackSerializerOptions! options) -> T[,,]? +MessagePack.Formatters.ThreeDimensionalArrayFormatter.Serialize(ref MessagePack.MessagePackWriter writer, T[,,]? value, MessagePack.MessagePackSerializerOptions! options) -> void +MessagePack.Formatters.ThreeDimensionalArrayFormatter.ThreeDimensionalArrayFormatter() -> void +MessagePack.Formatters.TimeSpanFormatter +MessagePack.Formatters.TimeSpanFormatter.Deserialize(ref MessagePack.MessagePackReader reader, MessagePack.MessagePackSerializerOptions! options) -> System.TimeSpan +MessagePack.Formatters.TimeSpanFormatter.Serialize(ref MessagePack.MessagePackWriter writer, System.TimeSpan value, MessagePack.MessagePackSerializerOptions! options) -> void +MessagePack.Formatters.TupleFormatter +MessagePack.Formatters.TupleFormatter.Deserialize(ref MessagePack.MessagePackReader reader, MessagePack.MessagePackSerializerOptions! options) -> System.Tuple? +MessagePack.Formatters.TupleFormatter.Serialize(ref MessagePack.MessagePackWriter writer, System.Tuple? value, MessagePack.MessagePackSerializerOptions! options) -> void +MessagePack.Formatters.TupleFormatter.TupleFormatter() -> void +MessagePack.Formatters.TupleFormatter +MessagePack.Formatters.TupleFormatter.Deserialize(ref MessagePack.MessagePackReader reader, MessagePack.MessagePackSerializerOptions! options) -> System.Tuple? +MessagePack.Formatters.TupleFormatter.Serialize(ref MessagePack.MessagePackWriter writer, System.Tuple? value, MessagePack.MessagePackSerializerOptions! options) -> void +MessagePack.Formatters.TupleFormatter.TupleFormatter() -> void +MessagePack.Formatters.TupleFormatter +MessagePack.Formatters.TupleFormatter.Deserialize(ref MessagePack.MessagePackReader reader, MessagePack.MessagePackSerializerOptions! options) -> System.Tuple? +MessagePack.Formatters.TupleFormatter.Serialize(ref MessagePack.MessagePackWriter writer, System.Tuple? value, MessagePack.MessagePackSerializerOptions! options) -> void +MessagePack.Formatters.TupleFormatter.TupleFormatter() -> void +MessagePack.Formatters.TupleFormatter +MessagePack.Formatters.TupleFormatter.Deserialize(ref MessagePack.MessagePackReader reader, MessagePack.MessagePackSerializerOptions! options) -> System.Tuple? +MessagePack.Formatters.TupleFormatter.Serialize(ref MessagePack.MessagePackWriter writer, System.Tuple? value, MessagePack.MessagePackSerializerOptions! options) -> void +MessagePack.Formatters.TupleFormatter.TupleFormatter() -> void +MessagePack.Formatters.TupleFormatter +MessagePack.Formatters.TupleFormatter.Deserialize(ref MessagePack.MessagePackReader reader, MessagePack.MessagePackSerializerOptions! options) -> System.Tuple? +MessagePack.Formatters.TupleFormatter.Serialize(ref MessagePack.MessagePackWriter writer, System.Tuple? value, MessagePack.MessagePackSerializerOptions! options) -> void +MessagePack.Formatters.TupleFormatter.TupleFormatter() -> void +MessagePack.Formatters.TupleFormatter +MessagePack.Formatters.TupleFormatter.Deserialize(ref MessagePack.MessagePackReader reader, MessagePack.MessagePackSerializerOptions! options) -> System.Tuple? +MessagePack.Formatters.TupleFormatter.Serialize(ref MessagePack.MessagePackWriter writer, System.Tuple? value, MessagePack.MessagePackSerializerOptions! options) -> void +MessagePack.Formatters.TupleFormatter.TupleFormatter() -> void +MessagePack.Formatters.TupleFormatter +MessagePack.Formatters.TupleFormatter.Deserialize(ref MessagePack.MessagePackReader reader, MessagePack.MessagePackSerializerOptions! options) -> System.Tuple? +MessagePack.Formatters.TupleFormatter.Serialize(ref MessagePack.MessagePackWriter writer, System.Tuple? value, MessagePack.MessagePackSerializerOptions! options) -> void +MessagePack.Formatters.TupleFormatter.TupleFormatter() -> void +MessagePack.Formatters.TupleFormatter +MessagePack.Formatters.TupleFormatter.Deserialize(ref MessagePack.MessagePackReader reader, MessagePack.MessagePackSerializerOptions! options) -> System.Tuple? +MessagePack.Formatters.TupleFormatter.Serialize(ref MessagePack.MessagePackWriter writer, System.Tuple? value, MessagePack.MessagePackSerializerOptions! options) -> void +MessagePack.Formatters.TupleFormatter.TupleFormatter() -> void +MessagePack.Formatters.TwoDimensionalArrayFormatter +MessagePack.Formatters.TwoDimensionalArrayFormatter.Deserialize(ref MessagePack.MessagePackReader reader, MessagePack.MessagePackSerializerOptions! options) -> T[,]? +MessagePack.Formatters.TwoDimensionalArrayFormatter.Serialize(ref MessagePack.MessagePackWriter writer, T[,]? value, MessagePack.MessagePackSerializerOptions! options) -> void +MessagePack.Formatters.TwoDimensionalArrayFormatter.TwoDimensionalArrayFormatter() -> void +MessagePack.Formatters.TypelessFormatter +MessagePack.Formatters.TypelessFormatter.Deserialize(ref MessagePack.MessagePackReader reader, MessagePack.MessagePackSerializerOptions! options) -> object? +MessagePack.Formatters.TypelessFormatter.Serialize(ref MessagePack.MessagePackWriter writer, object? value, MessagePack.MessagePackSerializerOptions! options) -> void +MessagePack.Formatters.UInt16ArrayFormatter +MessagePack.Formatters.UInt16ArrayFormatter.Deserialize(ref MessagePack.MessagePackReader reader, MessagePack.MessagePackSerializerOptions! options) -> ushort[]? +MessagePack.Formatters.UInt16ArrayFormatter.Serialize(ref MessagePack.MessagePackWriter writer, ushort[]? value, MessagePack.MessagePackSerializerOptions! options) -> void +MessagePack.Formatters.UInt16Formatter +MessagePack.Formatters.UInt16Formatter.Deserialize(ref MessagePack.MessagePackReader reader, MessagePack.MessagePackSerializerOptions! options) -> ushort +MessagePack.Formatters.UInt16Formatter.Serialize(ref MessagePack.MessagePackWriter writer, ushort value, MessagePack.MessagePackSerializerOptions! options) -> void +MessagePack.Formatters.UInt32ArrayFormatter +MessagePack.Formatters.UInt32ArrayFormatter.Deserialize(ref MessagePack.MessagePackReader reader, MessagePack.MessagePackSerializerOptions! options) -> uint[]? +MessagePack.Formatters.UInt32ArrayFormatter.Serialize(ref MessagePack.MessagePackWriter writer, uint[]? value, MessagePack.MessagePackSerializerOptions! options) -> void +MessagePack.Formatters.UInt32Formatter +MessagePack.Formatters.UInt32Formatter.Deserialize(ref MessagePack.MessagePackReader reader, MessagePack.MessagePackSerializerOptions! options) -> uint +MessagePack.Formatters.UInt32Formatter.Serialize(ref MessagePack.MessagePackWriter writer, uint value, MessagePack.MessagePackSerializerOptions! options) -> void +MessagePack.Formatters.UInt64ArrayFormatter +MessagePack.Formatters.UInt64ArrayFormatter.Deserialize(ref MessagePack.MessagePackReader reader, MessagePack.MessagePackSerializerOptions! options) -> ulong[]? +MessagePack.Formatters.UInt64ArrayFormatter.Serialize(ref MessagePack.MessagePackWriter writer, ulong[]? value, MessagePack.MessagePackSerializerOptions! options) -> void +MessagePack.Formatters.UInt64Formatter +MessagePack.Formatters.UInt64Formatter.Deserialize(ref MessagePack.MessagePackReader reader, MessagePack.MessagePackSerializerOptions! options) -> ulong +MessagePack.Formatters.UInt64Formatter.Serialize(ref MessagePack.MessagePackWriter writer, ulong value, MessagePack.MessagePackSerializerOptions! options) -> void +MessagePack.Formatters.UriFormatter +MessagePack.Formatters.UriFormatter.Deserialize(ref MessagePack.MessagePackReader reader, MessagePack.MessagePackSerializerOptions! options) -> System.Uri? +MessagePack.Formatters.UriFormatter.Serialize(ref MessagePack.MessagePackWriter writer, System.Uri? value, MessagePack.MessagePackSerializerOptions! options) -> void +MessagePack.Formatters.ValueTupleFormatter +MessagePack.Formatters.ValueTupleFormatter.Deserialize(ref MessagePack.MessagePackReader reader, MessagePack.MessagePackSerializerOptions! options) -> System.ValueTuple +MessagePack.Formatters.ValueTupleFormatter.Serialize(ref MessagePack.MessagePackWriter writer, System.ValueTuple value, MessagePack.MessagePackSerializerOptions! options) -> void +MessagePack.Formatters.ValueTupleFormatter.ValueTupleFormatter() -> void +MessagePack.Formatters.ValueTupleFormatter +MessagePack.Formatters.ValueTupleFormatter.Deserialize(ref MessagePack.MessagePackReader reader, MessagePack.MessagePackSerializerOptions! options) -> (T1, T2, T3, T4, T5, T6, T7) +MessagePack.Formatters.ValueTupleFormatter.Serialize(ref MessagePack.MessagePackWriter writer, (T1, T2, T3, T4, T5, T6, T7) value, MessagePack.MessagePackSerializerOptions! options) -> void +MessagePack.Formatters.ValueTupleFormatter.ValueTupleFormatter() -> void +MessagePack.Formatters.ValueTupleFormatter +MessagePack.Formatters.ValueTupleFormatter.Deserialize(ref MessagePack.MessagePackReader reader, MessagePack.MessagePackSerializerOptions! options) -> (T1, T2, T3, T4, T5, T6) +MessagePack.Formatters.ValueTupleFormatter.Serialize(ref MessagePack.MessagePackWriter writer, (T1, T2, T3, T4, T5, T6) value, MessagePack.MessagePackSerializerOptions! options) -> void +MessagePack.Formatters.ValueTupleFormatter.ValueTupleFormatter() -> void +MessagePack.Formatters.ValueTupleFormatter +MessagePack.Formatters.ValueTupleFormatter.Deserialize(ref MessagePack.MessagePackReader reader, MessagePack.MessagePackSerializerOptions! options) -> (T1, T2, T3, T4, T5) +MessagePack.Formatters.ValueTupleFormatter.Serialize(ref MessagePack.MessagePackWriter writer, (T1, T2, T3, T4, T5) value, MessagePack.MessagePackSerializerOptions! options) -> void +MessagePack.Formatters.ValueTupleFormatter.ValueTupleFormatter() -> void +MessagePack.Formatters.ValueTupleFormatter +MessagePack.Formatters.ValueTupleFormatter.Deserialize(ref MessagePack.MessagePackReader reader, MessagePack.MessagePackSerializerOptions! options) -> (T1, T2, T3, T4) +MessagePack.Formatters.ValueTupleFormatter.Serialize(ref MessagePack.MessagePackWriter writer, (T1, T2, T3, T4) value, MessagePack.MessagePackSerializerOptions! options) -> void +MessagePack.Formatters.ValueTupleFormatter.ValueTupleFormatter() -> void +MessagePack.Formatters.ValueTupleFormatter +MessagePack.Formatters.ValueTupleFormatter.Deserialize(ref MessagePack.MessagePackReader reader, MessagePack.MessagePackSerializerOptions! options) -> (T1, T2, T3) +MessagePack.Formatters.ValueTupleFormatter.Serialize(ref MessagePack.MessagePackWriter writer, (T1, T2, T3) value, MessagePack.MessagePackSerializerOptions! options) -> void +MessagePack.Formatters.ValueTupleFormatter.ValueTupleFormatter() -> void +MessagePack.Formatters.ValueTupleFormatter +MessagePack.Formatters.ValueTupleFormatter.Deserialize(ref MessagePack.MessagePackReader reader, MessagePack.MessagePackSerializerOptions! options) -> (T1, T2) +MessagePack.Formatters.ValueTupleFormatter.Serialize(ref MessagePack.MessagePackWriter writer, (T1, T2) value, MessagePack.MessagePackSerializerOptions! options) -> void +MessagePack.Formatters.ValueTupleFormatter.ValueTupleFormatter() -> void +MessagePack.Formatters.ValueTupleFormatter +MessagePack.Formatters.ValueTupleFormatter.Deserialize(ref MessagePack.MessagePackReader reader, MessagePack.MessagePackSerializerOptions! options) -> System.ValueTuple +MessagePack.Formatters.ValueTupleFormatter.Serialize(ref MessagePack.MessagePackWriter writer, System.ValueTuple value, MessagePack.MessagePackSerializerOptions! options) -> void +MessagePack.Formatters.ValueTupleFormatter.ValueTupleFormatter() -> void +MessagePack.Formatters.VersionFormatter +MessagePack.Formatters.VersionFormatter.Deserialize(ref MessagePack.MessagePackReader reader, MessagePack.MessagePackSerializerOptions! options) -> System.Version? +MessagePack.Formatters.VersionFormatter.Serialize(ref MessagePack.MessagePackWriter writer, System.Version? value, MessagePack.MessagePackSerializerOptions! options) -> void +MessagePack.IFormatterResolver +MessagePack.IFormatterResolver.GetFormatter() -> MessagePack.Formatters.IMessagePackFormatter? +MessagePack.Internal.AutomataDictionary +MessagePack.Internal.AutomataDictionary.Add(string! str, int value) -> void +MessagePack.Internal.AutomataDictionary.AutomataDictionary() -> void +MessagePack.Internal.AutomataDictionary.EmitMatch(System.Reflection.Emit.ILGenerator! il, System.Reflection.Emit.LocalBuilder! bytesSpan, System.Reflection.Emit.LocalBuilder! key, System.Action>! onFound, System.Action! onNotFound) -> void +MessagePack.Internal.AutomataDictionary.GetEnumerator() -> System.Collections.Generic.IEnumerator>! +MessagePack.Internal.AutomataDictionary.TryGetValue(System.ReadOnlySpan bytes, out int value) -> bool +MessagePack.Internal.AutomataDictionary.TryGetValue(in System.Buffers.ReadOnlySequence bytes, out int value) -> bool +MessagePack.Internal.AutomataKeyGen +MessagePack.Internal.ByteArrayStringHashTable +MessagePack.Internal.ByteArrayStringHashTable.Add(byte[]! key, int value) -> void +MessagePack.Internal.ByteArrayStringHashTable.Add(string! key, int value) -> void +MessagePack.Internal.ByteArrayStringHashTable.ByteArrayStringHashTable(int capacity) -> void +MessagePack.Internal.ByteArrayStringHashTable.ByteArrayStringHashTable(int capacity, float loadFactor) -> void +MessagePack.Internal.ByteArrayStringHashTable.GetEnumerator() -> System.Collections.Generic.IEnumerator>! +MessagePack.Internal.ByteArrayStringHashTable.TryGetValue(System.ReadOnlySpan key, out int value) -> bool +MessagePack.Internal.ByteArrayStringHashTable.TryGetValue(in System.Buffers.ReadOnlySequence key, out int value) -> bool +MessagePack.Internal.CodeGenHelpers +MessagePack.Internal.RuntimeTypeHandleEqualityComparer +MessagePack.Internal.RuntimeTypeHandleEqualityComparer.Equals(System.RuntimeTypeHandle x, System.RuntimeTypeHandle y) -> bool +MessagePack.Internal.RuntimeTypeHandleEqualityComparer.GetHashCode(System.RuntimeTypeHandle obj) -> int +MessagePack.Internal.UnsafeMemory +MessagePack.Internal.UnsafeMemory32 +MessagePack.Internal.UnsafeMemory64 +MessagePack.MessagePackCode +MessagePack.MessagePackCompression +MessagePack.MessagePackCompression.Lz4Block = 1 -> MessagePack.MessagePackCompression +MessagePack.MessagePackCompression.Lz4BlockArray = 2 -> MessagePack.MessagePackCompression +MessagePack.MessagePackCompression.None = 0 -> MessagePack.MessagePackCompression +MessagePack.MessagePackRange +MessagePack.MessagePackReader +MessagePack.MessagePackReader.CancellationToken.get -> System.Threading.CancellationToken +MessagePack.MessagePackReader.CancellationToken.set -> void +MessagePack.MessagePackReader.Clone(in System.Buffers.ReadOnlySequence readOnlySequence) -> MessagePack.MessagePackReader +MessagePack.MessagePackReader.Consumed.get -> long +MessagePack.MessagePackReader.CreatePeekReader() -> MessagePack.MessagePackReader +MessagePack.MessagePackReader.End.get -> bool +MessagePack.MessagePackReader.IsNil.get -> bool +MessagePack.MessagePackReader.MessagePackReader(System.ReadOnlyMemory memory) -> void +MessagePack.MessagePackReader.MessagePackReader(in System.Buffers.ReadOnlySequence readOnlySequence) -> void +MessagePack.MessagePackReader.NextCode.get -> byte +MessagePack.MessagePackReader.NextMessagePackType.get -> MessagePack.MessagePackType +MessagePack.MessagePackReader.Position.get -> System.SequencePosition +MessagePack.MessagePackReader.ReadArrayHeader() -> int +MessagePack.MessagePackReader.ReadBoolean() -> bool +MessagePack.MessagePackReader.ReadByte() -> byte +MessagePack.MessagePackReader.ReadBytes() -> System.Buffers.ReadOnlySequence? +MessagePack.MessagePackReader.ReadChar() -> char +MessagePack.MessagePackReader.ReadDateTime() -> System.DateTime +MessagePack.MessagePackReader.ReadDouble() -> double +MessagePack.MessagePackReader.ReadExtensionFormat() -> MessagePack.ExtensionResult +MessagePack.MessagePackReader.ReadExtensionFormatHeader() -> MessagePack.ExtensionHeader +MessagePack.MessagePackReader.ReadInt16() -> short +MessagePack.MessagePackReader.ReadInt32() -> int +MessagePack.MessagePackReader.ReadInt64() -> long +MessagePack.MessagePackReader.ReadMapHeader() -> int +MessagePack.MessagePackReader.ReadNil() -> MessagePack.Nil +MessagePack.MessagePackReader.ReadRaw() -> System.Buffers.ReadOnlySequence +MessagePack.MessagePackReader.ReadRaw(long length) -> System.Buffers.ReadOnlySequence +MessagePack.MessagePackReader.ReadSByte() -> sbyte +MessagePack.MessagePackReader.ReadSingle() -> float +MessagePack.MessagePackReader.ReadString() -> string? +MessagePack.MessagePackReader.ReadStringSequence() -> System.Buffers.ReadOnlySequence? +MessagePack.MessagePackReader.ReadUInt16() -> ushort +MessagePack.MessagePackReader.ReadUInt32() -> uint +MessagePack.MessagePackReader.ReadUInt64() -> ulong +MessagePack.MessagePackReader.Sequence.get -> System.Buffers.ReadOnlySequence +MessagePack.MessagePackReader.Skip() -> void +MessagePack.MessagePackReader.TryReadNil() -> bool +MessagePack.MessagePackReader.TryReadStringSpan(out System.ReadOnlySpan span) -> bool +MessagePack.MessagePackSerializationException +MessagePack.MessagePackSerializationException.MessagePackSerializationException() -> void +MessagePack.MessagePackSerializationException.MessagePackSerializationException(System.Runtime.Serialization.SerializationInfo! info, System.Runtime.Serialization.StreamingContext context) -> void +MessagePack.MessagePackSerializationException.MessagePackSerializationException(string? message) -> void +MessagePack.MessagePackSerializationException.MessagePackSerializationException(string? message, System.Exception? inner) -> void +MessagePack.MessagePackSerializer +MessagePack.MessagePackSerializer.Typeless +MessagePack.MessagePackSerializerOptions +MessagePack.MessagePackSerializerOptions.AllowAssemblyVersionMismatch.get -> bool +MessagePack.MessagePackSerializerOptions.Compression.get -> MessagePack.MessagePackCompression +MessagePack.MessagePackSerializerOptions.MessagePackSerializerOptions(MessagePack.IFormatterResolver! resolver) -> void +MessagePack.MessagePackSerializerOptions.MessagePackSerializerOptions(MessagePack.MessagePackSerializerOptions! copyFrom) -> void +MessagePack.MessagePackSerializerOptions.OldSpec.get -> bool? +MessagePack.MessagePackSerializerOptions.OmitAssemblyVersion.get -> bool +MessagePack.MessagePackSerializerOptions.Resolver.get -> MessagePack.IFormatterResolver! +MessagePack.MessagePackSerializerOptions.WithAllowAssemblyVersionMismatch(bool allowAssemblyVersionMismatch) -> MessagePack.MessagePackSerializerOptions! +MessagePack.MessagePackSerializerOptions.WithCompression(MessagePack.MessagePackCompression compression) -> MessagePack.MessagePackSerializerOptions! +MessagePack.MessagePackSerializerOptions.WithOldSpec(bool? oldSpec = true) -> MessagePack.MessagePackSerializerOptions! +MessagePack.MessagePackSerializerOptions.WithOmitAssemblyVersion(bool omitAssemblyVersion) -> MessagePack.MessagePackSerializerOptions! +MessagePack.MessagePackSerializerOptions.WithResolver(MessagePack.IFormatterResolver! resolver) -> MessagePack.MessagePackSerializerOptions! +MessagePack.MessagePackStreamReader +MessagePack.MessagePackStreamReader.Dispose() -> void +MessagePack.MessagePackStreamReader.MessagePackStreamReader(System.IO.Stream! stream) -> void +MessagePack.MessagePackStreamReader.ReadAsync(System.Threading.CancellationToken cancellationToken) -> System.Threading.Tasks.ValueTask?> +MessagePack.MessagePackStreamReader.RemainingBytes.get -> System.Buffers.ReadOnlySequence +MessagePack.MessagePackType +MessagePack.MessagePackType.Array = 7 -> MessagePack.MessagePackType +MessagePack.MessagePackType.Binary = 6 -> MessagePack.MessagePackType +MessagePack.MessagePackType.Boolean = 3 -> MessagePack.MessagePackType +MessagePack.MessagePackType.Extension = 9 -> MessagePack.MessagePackType +MessagePack.MessagePackType.Float = 4 -> MessagePack.MessagePackType +MessagePack.MessagePackType.Integer = 1 -> MessagePack.MessagePackType +MessagePack.MessagePackType.Map = 8 -> MessagePack.MessagePackType +MessagePack.MessagePackType.Nil = 2 -> MessagePack.MessagePackType +MessagePack.MessagePackType.String = 5 -> MessagePack.MessagePackType +MessagePack.MessagePackType.Unknown = 0 -> MessagePack.MessagePackType +MessagePack.MessagePackWriter +MessagePack.MessagePackWriter.Advance(int length) -> void +MessagePack.MessagePackWriter.CancellationToken.get -> System.Threading.CancellationToken +MessagePack.MessagePackWriter.CancellationToken.set -> void +MessagePack.MessagePackWriter.Clone(System.Buffers.IBufferWriter! writer) -> MessagePack.MessagePackWriter +MessagePack.MessagePackWriter.Flush() -> void +MessagePack.MessagePackWriter.GetSpan(int length) -> System.Span +MessagePack.MessagePackWriter.MessagePackWriter(System.Buffers.IBufferWriter! writer) -> void +MessagePack.MessagePackWriter.OldSpec.get -> bool +MessagePack.MessagePackWriter.OldSpec.set -> void +MessagePack.MessagePackWriter.Write(System.DateTime dateTime) -> void +MessagePack.MessagePackWriter.Write(System.ReadOnlySpan src) -> void +MessagePack.MessagePackWriter.Write(System.ReadOnlySpan value) -> void +MessagePack.MessagePackWriter.Write(bool value) -> void +MessagePack.MessagePackWriter.Write(byte value) -> void +MessagePack.MessagePackWriter.Write(byte[]? src) -> void +MessagePack.MessagePackWriter.Write(char value) -> void +MessagePack.MessagePackWriter.Write(double value) -> void +MessagePack.MessagePackWriter.Write(float value) -> void +MessagePack.MessagePackWriter.Write(in System.Buffers.ReadOnlySequence src) -> void +MessagePack.MessagePackWriter.Write(int value) -> void +MessagePack.MessagePackWriter.Write(long value) -> void +MessagePack.MessagePackWriter.Write(sbyte value) -> void +MessagePack.MessagePackWriter.Write(short value) -> void +MessagePack.MessagePackWriter.Write(string? value) -> void +MessagePack.MessagePackWriter.Write(uint value) -> void +MessagePack.MessagePackWriter.Write(ulong value) -> void +MessagePack.MessagePackWriter.Write(ushort value) -> void +MessagePack.MessagePackWriter.WriteArrayHeader(int count) -> void +MessagePack.MessagePackWriter.WriteArrayHeader(uint count) -> void +MessagePack.MessagePackWriter.WriteExtensionFormat(MessagePack.ExtensionResult extensionData) -> void +MessagePack.MessagePackWriter.WriteExtensionFormatHeader(MessagePack.ExtensionHeader extensionHeader) -> void +MessagePack.MessagePackWriter.WriteInt16(short value) -> void +MessagePack.MessagePackWriter.WriteInt32(int value) -> void +MessagePack.MessagePackWriter.WriteInt64(long value) -> void +MessagePack.MessagePackWriter.WriteInt8(sbyte value) -> void +MessagePack.MessagePackWriter.WriteMapHeader(int count) -> void +MessagePack.MessagePackWriter.WriteMapHeader(uint count) -> void +MessagePack.MessagePackWriter.WriteNil() -> void +MessagePack.MessagePackWriter.WriteRaw(System.ReadOnlySpan rawMessagePackBlock) -> void +MessagePack.MessagePackWriter.WriteRaw(in System.Buffers.ReadOnlySequence rawMessagePackBlock) -> void +MessagePack.MessagePackWriter.WriteString(System.ReadOnlySpan utf8stringBytes) -> void +MessagePack.MessagePackWriter.WriteString(in System.Buffers.ReadOnlySequence utf8stringBytes) -> void +MessagePack.MessagePackWriter.WriteUInt16(ushort value) -> void +MessagePack.MessagePackWriter.WriteUInt32(uint value) -> void +MessagePack.MessagePackWriter.WriteUInt64(ulong value) -> void +MessagePack.MessagePackWriter.WriteUInt8(byte value) -> void +MessagePack.Nil +MessagePack.Nil.Equals(MessagePack.Nil other) -> bool +MessagePack.Nil.Nil() -> void +MessagePack.ReservedMessagePackExtensionTypeCode +MessagePack.Resolvers.AttributeFormatterResolver +MessagePack.Resolvers.AttributeFormatterResolver.GetFormatter() -> MessagePack.Formatters.IMessagePackFormatter? +MessagePack.Resolvers.BuiltinResolver +MessagePack.Resolvers.BuiltinResolver.GetFormatter() -> MessagePack.Formatters.IMessagePackFormatter? +MessagePack.Resolvers.CompositeResolver +MessagePack.Resolvers.ContractlessStandardResolver +MessagePack.Resolvers.ContractlessStandardResolver.GetFormatter() -> MessagePack.Formatters.IMessagePackFormatter? +MessagePack.Resolvers.ContractlessStandardResolverAllowPrivate +MessagePack.Resolvers.ContractlessStandardResolverAllowPrivate.GetFormatter() -> MessagePack.Formatters.IMessagePackFormatter? +MessagePack.Resolvers.DynamicContractlessObjectResolver +MessagePack.Resolvers.DynamicContractlessObjectResolver.GetFormatter() -> MessagePack.Formatters.IMessagePackFormatter? +MessagePack.Resolvers.DynamicContractlessObjectResolverAllowPrivate +MessagePack.Resolvers.DynamicContractlessObjectResolverAllowPrivate.DynamicContractlessObjectResolverAllowPrivate() -> void +MessagePack.Resolvers.DynamicContractlessObjectResolverAllowPrivate.GetFormatter() -> MessagePack.Formatters.IMessagePackFormatter? +MessagePack.Resolvers.DynamicEnumAsStringResolver +MessagePack.Resolvers.DynamicEnumAsStringResolver.GetFormatter() -> MessagePack.Formatters.IMessagePackFormatter? +MessagePack.Resolvers.DynamicEnumResolver +MessagePack.Resolvers.DynamicEnumResolver.GetFormatter() -> MessagePack.Formatters.IMessagePackFormatter? +MessagePack.Resolvers.DynamicGenericResolver +MessagePack.Resolvers.DynamicGenericResolver.GetFormatter() -> MessagePack.Formatters.IMessagePackFormatter? +MessagePack.Resolvers.DynamicObjectResolver +MessagePack.Resolvers.DynamicObjectResolver.GetFormatter() -> MessagePack.Formatters.IMessagePackFormatter? +MessagePack.Resolvers.DynamicObjectResolverAllowPrivate +MessagePack.Resolvers.DynamicObjectResolverAllowPrivate.GetFormatter() -> MessagePack.Formatters.IMessagePackFormatter? +MessagePack.Resolvers.DynamicUnionResolver +MessagePack.Resolvers.DynamicUnionResolver.GetFormatter() -> MessagePack.Formatters.IMessagePackFormatter? +MessagePack.Resolvers.NativeDateTimeResolver +MessagePack.Resolvers.NativeDateTimeResolver.GetFormatter() -> MessagePack.Formatters.IMessagePackFormatter? +MessagePack.Resolvers.NativeDecimalResolver +MessagePack.Resolvers.NativeDecimalResolver.GetFormatter() -> MessagePack.Formatters.IMessagePackFormatter? +MessagePack.Resolvers.NativeGuidResolver +MessagePack.Resolvers.NativeGuidResolver.GetFormatter() -> MessagePack.Formatters.IMessagePackFormatter? +MessagePack.Resolvers.PrimitiveObjectResolver +MessagePack.Resolvers.PrimitiveObjectResolver.GetFormatter() -> MessagePack.Formatters.IMessagePackFormatter? +MessagePack.Resolvers.StandardResolver +MessagePack.Resolvers.StandardResolver.GetFormatter() -> MessagePack.Formatters.IMessagePackFormatter? +MessagePack.Resolvers.StandardResolverAllowPrivate +MessagePack.Resolvers.StandardResolverAllowPrivate.GetFormatter() -> MessagePack.Formatters.IMessagePackFormatter? +MessagePack.Resolvers.StaticCompositeResolver +MessagePack.Resolvers.StaticCompositeResolver.GetFormatter() -> MessagePack.Formatters.IMessagePackFormatter? +MessagePack.Resolvers.StaticCompositeResolver.Register(System.Collections.Generic.IReadOnlyList! formatters, System.Collections.Generic.IReadOnlyList! resolvers) -> void +MessagePack.Resolvers.StaticCompositeResolver.Register(params MessagePack.Formatters.IMessagePackFormatter![]! formatters) -> void +MessagePack.Resolvers.StaticCompositeResolver.Register(params MessagePack.IFormatterResolver![]! resolvers) -> void +MessagePack.Resolvers.TypelessContractlessStandardResolver +MessagePack.Resolvers.TypelessContractlessStandardResolver.GetFormatter() -> MessagePack.Formatters.IMessagePackFormatter? +MessagePack.Resolvers.TypelessContractlessStandardResolver.TypelessContractlessStandardResolver() -> void +MessagePack.Resolvers.TypelessObjectResolver +MessagePack.Resolvers.TypelessObjectResolver.GetFormatter() -> MessagePack.Formatters.IMessagePackFormatter? +MessagePack.TinyJsonException +MessagePack.TinyJsonException.TinyJsonException(string! message) -> void +abstract MessagePack.Formatters.CollectionFormatterBase.Add(TIntermediate collection, int index, TElement value, MessagePack.MessagePackSerializerOptions! options) -> void +abstract MessagePack.Formatters.CollectionFormatterBase.Complete(TIntermediate intermediateCollection) -> TCollection +abstract MessagePack.Formatters.CollectionFormatterBase.Create(int count, MessagePack.MessagePackSerializerOptions! options) -> TIntermediate +abstract MessagePack.Formatters.CollectionFormatterBase.GetSourceEnumerator(TCollection source) -> TEnumerator +abstract MessagePack.Formatters.DictionaryFormatterBase.Add(TIntermediate collection, int index, TKey key, TValue value, MessagePack.MessagePackSerializerOptions! options) -> void +abstract MessagePack.Formatters.DictionaryFormatterBase.Complete(TIntermediate intermediateCollection) -> TDictionary! +abstract MessagePack.Formatters.DictionaryFormatterBase.Create(int count, MessagePack.MessagePackSerializerOptions! options) -> TIntermediate +abstract MessagePack.Formatters.DictionaryFormatterBase.GetSourceEnumerator(TDictionary! source) -> TEnumerator +const MessagePack.MessagePackCode.Array16 = 220 -> byte +const MessagePack.MessagePackCode.Array32 = 221 -> byte +const MessagePack.MessagePackCode.Bin16 = 197 -> byte +const MessagePack.MessagePackCode.Bin32 = 198 -> byte +const MessagePack.MessagePackCode.Bin8 = 196 -> byte +const MessagePack.MessagePackCode.Ext16 = 200 -> byte +const MessagePack.MessagePackCode.Ext32 = 201 -> byte +const MessagePack.MessagePackCode.Ext8 = 199 -> byte +const MessagePack.MessagePackCode.False = 194 -> byte +const MessagePack.MessagePackCode.FixExt1 = 212 -> byte +const MessagePack.MessagePackCode.FixExt16 = 216 -> byte +const MessagePack.MessagePackCode.FixExt2 = 213 -> byte +const MessagePack.MessagePackCode.FixExt4 = 214 -> byte +const MessagePack.MessagePackCode.FixExt8 = 215 -> byte +const MessagePack.MessagePackCode.Float32 = 202 -> byte +const MessagePack.MessagePackCode.Float64 = 203 -> byte +const MessagePack.MessagePackCode.Int16 = 209 -> byte +const MessagePack.MessagePackCode.Int32 = 210 -> byte +const MessagePack.MessagePackCode.Int64 = 211 -> byte +const MessagePack.MessagePackCode.Int8 = 208 -> byte +const MessagePack.MessagePackCode.Map16 = 222 -> byte +const MessagePack.MessagePackCode.Map32 = 223 -> byte +const MessagePack.MessagePackCode.MaxFixArray = 159 -> byte +const MessagePack.MessagePackCode.MaxFixInt = 127 -> byte +const MessagePack.MessagePackCode.MaxFixMap = 143 -> byte +const MessagePack.MessagePackCode.MaxFixStr = 191 -> byte +const MessagePack.MessagePackCode.MaxNegativeFixInt = 255 -> byte +const MessagePack.MessagePackCode.MinFixArray = 144 -> byte +const MessagePack.MessagePackCode.MinFixInt = 0 -> byte +const MessagePack.MessagePackCode.MinFixMap = 128 -> byte +const MessagePack.MessagePackCode.MinFixStr = 160 -> byte +const MessagePack.MessagePackCode.MinNegativeFixInt = 224 -> byte +const MessagePack.MessagePackCode.NeverUsed = 193 -> byte +const MessagePack.MessagePackCode.Nil = 192 -> byte +const MessagePack.MessagePackCode.Str16 = 218 -> byte +const MessagePack.MessagePackCode.Str32 = 219 -> byte +const MessagePack.MessagePackCode.Str8 = 217 -> byte +const MessagePack.MessagePackCode.True = 195 -> byte +const MessagePack.MessagePackCode.UInt16 = 205 -> byte +const MessagePack.MessagePackCode.UInt32 = 206 -> byte +const MessagePack.MessagePackCode.UInt64 = 207 -> byte +const MessagePack.MessagePackCode.UInt8 = 204 -> byte +const MessagePack.MessagePackRange.MaxFixArrayCount = 15 -> int +const MessagePack.MessagePackRange.MaxFixMapCount = 15 -> int +const MessagePack.MessagePackRange.MaxFixNegativeInt = -1 -> int +const MessagePack.MessagePackRange.MaxFixPositiveInt = 127 -> int +const MessagePack.MessagePackRange.MaxFixStringLength = 31 -> int +const MessagePack.MessagePackRange.MinFixNegativeInt = -32 -> int +const MessagePack.MessagePackRange.MinFixStringLength = 0 -> int +const MessagePack.ReservedMessagePackExtensionTypeCode.DateTime = -1 -> sbyte +override MessagePack.Formatters.CollectionFormatterBase.GetSourceEnumerator(TCollection source) -> System.Collections.Generic.IEnumerator! +override MessagePack.Formatters.DictionaryFormatterBase.Complete(TDictionary! intermediateCollection) -> TDictionary! +override MessagePack.Formatters.DictionaryFormatterBase.GetSourceEnumerator(TDictionary! source) -> System.Collections.Generic.IEnumerator>! +override MessagePack.Internal.AutomataDictionary.ToString() -> string! +override MessagePack.Nil.Equals(object? obj) -> bool +override MessagePack.Nil.GetHashCode() -> int +override MessagePack.Nil.ToString() -> string! +override sealed MessagePack.Formatters.CollectionFormatterBase.Complete(TCollection intermediateCollection) -> TCollection +static MessagePack.FormatterResolverExtensions.GetFormatterDynamic(this MessagePack.IFormatterResolver! resolver, System.Type! type) -> object? +static MessagePack.FormatterResolverExtensions.GetFormatterWithVerify(this MessagePack.IFormatterResolver! resolver) -> MessagePack.Formatters.IMessagePackFormatter! +static MessagePack.Formatters.PrimitiveObjectFormatter.IsSupportedType(System.Type! type, System.Reflection.TypeInfo! typeInfo, object! value) -> bool +static MessagePack.Internal.AutomataKeyGen.GetKey(ref System.ReadOnlySpan span) -> ulong +static MessagePack.Internal.CodeGenHelpers.GetArrayFromNullableSequence(in System.Buffers.ReadOnlySequence? sequence) -> byte[]? +static MessagePack.Internal.CodeGenHelpers.GetEncodedStringBytes(string! value) -> byte[]! +static MessagePack.Internal.CodeGenHelpers.GetSpanFromSequence(in System.Buffers.ReadOnlySequence sequence) -> System.ReadOnlySpan +static MessagePack.Internal.CodeGenHelpers.ReadStringSpan(ref MessagePack.MessagePackReader reader) -> System.ReadOnlySpan +static MessagePack.Internal.UnsafeMemory32.WriteRaw1(ref MessagePack.MessagePackWriter writer, System.ReadOnlySpan src) -> void +static MessagePack.Internal.UnsafeMemory32.WriteRaw10(ref MessagePack.MessagePackWriter writer, System.ReadOnlySpan src) -> void +static MessagePack.Internal.UnsafeMemory32.WriteRaw11(ref MessagePack.MessagePackWriter writer, System.ReadOnlySpan src) -> void +static MessagePack.Internal.UnsafeMemory32.WriteRaw12(ref MessagePack.MessagePackWriter writer, System.ReadOnlySpan src) -> void +static MessagePack.Internal.UnsafeMemory32.WriteRaw13(ref MessagePack.MessagePackWriter writer, System.ReadOnlySpan src) -> void +static MessagePack.Internal.UnsafeMemory32.WriteRaw14(ref MessagePack.MessagePackWriter writer, System.ReadOnlySpan src) -> void +static MessagePack.Internal.UnsafeMemory32.WriteRaw15(ref MessagePack.MessagePackWriter writer, System.ReadOnlySpan src) -> void +static MessagePack.Internal.UnsafeMemory32.WriteRaw16(ref MessagePack.MessagePackWriter writer, System.ReadOnlySpan src) -> void +static MessagePack.Internal.UnsafeMemory32.WriteRaw17(ref MessagePack.MessagePackWriter writer, System.ReadOnlySpan src) -> void +static MessagePack.Internal.UnsafeMemory32.WriteRaw18(ref MessagePack.MessagePackWriter writer, System.ReadOnlySpan src) -> void +static MessagePack.Internal.UnsafeMemory32.WriteRaw19(ref MessagePack.MessagePackWriter writer, System.ReadOnlySpan src) -> void +static MessagePack.Internal.UnsafeMemory32.WriteRaw2(ref MessagePack.MessagePackWriter writer, System.ReadOnlySpan src) -> void +static MessagePack.Internal.UnsafeMemory32.WriteRaw20(ref MessagePack.MessagePackWriter writer, System.ReadOnlySpan src) -> void +static MessagePack.Internal.UnsafeMemory32.WriteRaw21(ref MessagePack.MessagePackWriter writer, System.ReadOnlySpan src) -> void +static MessagePack.Internal.UnsafeMemory32.WriteRaw22(ref MessagePack.MessagePackWriter writer, System.ReadOnlySpan src) -> void +static MessagePack.Internal.UnsafeMemory32.WriteRaw23(ref MessagePack.MessagePackWriter writer, System.ReadOnlySpan src) -> void +static MessagePack.Internal.UnsafeMemory32.WriteRaw24(ref MessagePack.MessagePackWriter writer, System.ReadOnlySpan src) -> void +static MessagePack.Internal.UnsafeMemory32.WriteRaw25(ref MessagePack.MessagePackWriter writer, System.ReadOnlySpan src) -> void +static MessagePack.Internal.UnsafeMemory32.WriteRaw26(ref MessagePack.MessagePackWriter writer, System.ReadOnlySpan src) -> void +static MessagePack.Internal.UnsafeMemory32.WriteRaw27(ref MessagePack.MessagePackWriter writer, System.ReadOnlySpan src) -> void +static MessagePack.Internal.UnsafeMemory32.WriteRaw28(ref MessagePack.MessagePackWriter writer, System.ReadOnlySpan src) -> void +static MessagePack.Internal.UnsafeMemory32.WriteRaw29(ref MessagePack.MessagePackWriter writer, System.ReadOnlySpan src) -> void +static MessagePack.Internal.UnsafeMemory32.WriteRaw3(ref MessagePack.MessagePackWriter writer, System.ReadOnlySpan src) -> void +static MessagePack.Internal.UnsafeMemory32.WriteRaw30(ref MessagePack.MessagePackWriter writer, System.ReadOnlySpan src) -> void +static MessagePack.Internal.UnsafeMemory32.WriteRaw31(ref MessagePack.MessagePackWriter writer, System.ReadOnlySpan src) -> void +static MessagePack.Internal.UnsafeMemory32.WriteRaw4(ref MessagePack.MessagePackWriter writer, System.ReadOnlySpan src) -> void +static MessagePack.Internal.UnsafeMemory32.WriteRaw5(ref MessagePack.MessagePackWriter writer, System.ReadOnlySpan src) -> void +static MessagePack.Internal.UnsafeMemory32.WriteRaw6(ref MessagePack.MessagePackWriter writer, System.ReadOnlySpan src) -> void +static MessagePack.Internal.UnsafeMemory32.WriteRaw7(ref MessagePack.MessagePackWriter writer, System.ReadOnlySpan src) -> void +static MessagePack.Internal.UnsafeMemory32.WriteRaw8(ref MessagePack.MessagePackWriter writer, System.ReadOnlySpan src) -> void +static MessagePack.Internal.UnsafeMemory32.WriteRaw9(ref MessagePack.MessagePackWriter writer, System.ReadOnlySpan src) -> void +static MessagePack.Internal.UnsafeMemory64.WriteRaw1(ref MessagePack.MessagePackWriter writer, System.ReadOnlySpan src) -> void +static MessagePack.Internal.UnsafeMemory64.WriteRaw10(ref MessagePack.MessagePackWriter writer, System.ReadOnlySpan src) -> void +static MessagePack.Internal.UnsafeMemory64.WriteRaw11(ref MessagePack.MessagePackWriter writer, System.ReadOnlySpan src) -> void +static MessagePack.Internal.UnsafeMemory64.WriteRaw12(ref MessagePack.MessagePackWriter writer, System.ReadOnlySpan src) -> void +static MessagePack.Internal.UnsafeMemory64.WriteRaw13(ref MessagePack.MessagePackWriter writer, System.ReadOnlySpan src) -> void +static MessagePack.Internal.UnsafeMemory64.WriteRaw14(ref MessagePack.MessagePackWriter writer, System.ReadOnlySpan src) -> void +static MessagePack.Internal.UnsafeMemory64.WriteRaw15(ref MessagePack.MessagePackWriter writer, System.ReadOnlySpan src) -> void +static MessagePack.Internal.UnsafeMemory64.WriteRaw16(ref MessagePack.MessagePackWriter writer, System.ReadOnlySpan src) -> void +static MessagePack.Internal.UnsafeMemory64.WriteRaw17(ref MessagePack.MessagePackWriter writer, System.ReadOnlySpan src) -> void +static MessagePack.Internal.UnsafeMemory64.WriteRaw18(ref MessagePack.MessagePackWriter writer, System.ReadOnlySpan src) -> void +static MessagePack.Internal.UnsafeMemory64.WriteRaw19(ref MessagePack.MessagePackWriter writer, System.ReadOnlySpan src) -> void +static MessagePack.Internal.UnsafeMemory64.WriteRaw2(ref MessagePack.MessagePackWriter writer, System.ReadOnlySpan src) -> void +static MessagePack.Internal.UnsafeMemory64.WriteRaw20(ref MessagePack.MessagePackWriter writer, System.ReadOnlySpan src) -> void +static MessagePack.Internal.UnsafeMemory64.WriteRaw21(ref MessagePack.MessagePackWriter writer, System.ReadOnlySpan src) -> void +static MessagePack.Internal.UnsafeMemory64.WriteRaw22(ref MessagePack.MessagePackWriter writer, System.ReadOnlySpan src) -> void +static MessagePack.Internal.UnsafeMemory64.WriteRaw23(ref MessagePack.MessagePackWriter writer, System.ReadOnlySpan src) -> void +static MessagePack.Internal.UnsafeMemory64.WriteRaw24(ref MessagePack.MessagePackWriter writer, System.ReadOnlySpan src) -> void +static MessagePack.Internal.UnsafeMemory64.WriteRaw25(ref MessagePack.MessagePackWriter writer, System.ReadOnlySpan src) -> void +static MessagePack.Internal.UnsafeMemory64.WriteRaw26(ref MessagePack.MessagePackWriter writer, System.ReadOnlySpan src) -> void +static MessagePack.Internal.UnsafeMemory64.WriteRaw27(ref MessagePack.MessagePackWriter writer, System.ReadOnlySpan src) -> void +static MessagePack.Internal.UnsafeMemory64.WriteRaw28(ref MessagePack.MessagePackWriter writer, System.ReadOnlySpan src) -> void +static MessagePack.Internal.UnsafeMemory64.WriteRaw29(ref MessagePack.MessagePackWriter writer, System.ReadOnlySpan src) -> void +static MessagePack.Internal.UnsafeMemory64.WriteRaw3(ref MessagePack.MessagePackWriter writer, System.ReadOnlySpan src) -> void +static MessagePack.Internal.UnsafeMemory64.WriteRaw30(ref MessagePack.MessagePackWriter writer, System.ReadOnlySpan src) -> void +static MessagePack.Internal.UnsafeMemory64.WriteRaw31(ref MessagePack.MessagePackWriter writer, System.ReadOnlySpan src) -> void +static MessagePack.Internal.UnsafeMemory64.WriteRaw4(ref MessagePack.MessagePackWriter writer, System.ReadOnlySpan src) -> void +static MessagePack.Internal.UnsafeMemory64.WriteRaw5(ref MessagePack.MessagePackWriter writer, System.ReadOnlySpan src) -> void +static MessagePack.Internal.UnsafeMemory64.WriteRaw6(ref MessagePack.MessagePackWriter writer, System.ReadOnlySpan src) -> void +static MessagePack.Internal.UnsafeMemory64.WriteRaw7(ref MessagePack.MessagePackWriter writer, System.ReadOnlySpan src) -> void +static MessagePack.Internal.UnsafeMemory64.WriteRaw8(ref MessagePack.MessagePackWriter writer, System.ReadOnlySpan src) -> void +static MessagePack.Internal.UnsafeMemory64.WriteRaw9(ref MessagePack.MessagePackWriter writer, System.ReadOnlySpan src) -> void +static MessagePack.MessagePackCode.ToFormatName(byte code) -> string! +static MessagePack.MessagePackCode.ToMessagePackType(byte code) -> MessagePack.MessagePackType +static MessagePack.MessagePackSerializer.ConvertFromJson(System.IO.TextReader! reader, ref MessagePack.MessagePackWriter writer, MessagePack.MessagePackSerializerOptions? options = null) -> void +static MessagePack.MessagePackSerializer.ConvertFromJson(string! str, MessagePack.MessagePackSerializerOptions? options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> byte[]! +static MessagePack.MessagePackSerializer.ConvertFromJson(string! str, ref MessagePack.MessagePackWriter writer, MessagePack.MessagePackSerializerOptions? options = null) -> void +static MessagePack.MessagePackSerializer.ConvertToJson(System.ReadOnlyMemory bytes, MessagePack.MessagePackSerializerOptions? options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> string! +static MessagePack.MessagePackSerializer.ConvertToJson(in System.Buffers.ReadOnlySequence bytes, MessagePack.MessagePackSerializerOptions? options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> string! +static MessagePack.MessagePackSerializer.ConvertToJson(ref MessagePack.MessagePackReader reader, System.IO.TextWriter! jsonWriter, MessagePack.MessagePackSerializerOptions? options = null) -> void +static MessagePack.MessagePackSerializer.DefaultOptions.get -> MessagePack.MessagePackSerializerOptions! +static MessagePack.MessagePackSerializer.DefaultOptions.set -> void +static MessagePack.MessagePackSerializer.Deserialize(System.Type! type, System.Buffers.ReadOnlySequence bytes, MessagePack.MessagePackSerializerOptions? options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> object? +static MessagePack.MessagePackSerializer.Deserialize(System.Type! type, System.IO.Stream! stream, MessagePack.MessagePackSerializerOptions? options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> object? +static MessagePack.MessagePackSerializer.Deserialize(System.Type! type, System.ReadOnlyMemory bytes, MessagePack.MessagePackSerializerOptions? options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> object? +static MessagePack.MessagePackSerializer.Deserialize(System.Type! type, ref MessagePack.MessagePackReader reader, MessagePack.MessagePackSerializerOptions? options = null) -> object? +static MessagePack.MessagePackSerializer.Deserialize(System.IO.Stream! stream, MessagePack.MessagePackSerializerOptions? options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> T +static MessagePack.MessagePackSerializer.Deserialize(System.ReadOnlyMemory buffer, MessagePack.MessagePackSerializerOptions? options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> T +static MessagePack.MessagePackSerializer.Deserialize(System.ReadOnlyMemory buffer, MessagePack.MessagePackSerializerOptions? options, out int bytesRead, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> T +static MessagePack.MessagePackSerializer.Deserialize(System.ReadOnlyMemory buffer, out int bytesRead, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> T +static MessagePack.MessagePackSerializer.Deserialize(in System.Buffers.ReadOnlySequence byteSequence, MessagePack.MessagePackSerializerOptions? options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> T +static MessagePack.MessagePackSerializer.Deserialize(ref MessagePack.MessagePackReader reader, MessagePack.MessagePackSerializerOptions? options = null) -> T +static MessagePack.MessagePackSerializer.DeserializeAsync(System.Type! type, System.IO.Stream! stream, MessagePack.MessagePackSerializerOptions? options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.ValueTask +static MessagePack.MessagePackSerializer.DeserializeAsync(System.IO.Stream! stream, MessagePack.MessagePackSerializerOptions? options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.ValueTask +static MessagePack.MessagePackSerializer.Serialize(System.Type! type, System.Buffers.IBufferWriter! writer, object? obj, MessagePack.MessagePackSerializerOptions? options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> void +static MessagePack.MessagePackSerializer.Serialize(System.Type! type, System.IO.Stream! stream, object? obj, MessagePack.MessagePackSerializerOptions? options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> void +static MessagePack.MessagePackSerializer.Serialize(System.Type! type, object? obj, MessagePack.MessagePackSerializerOptions? options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> byte[]! +static MessagePack.MessagePackSerializer.Serialize(System.Type! type, ref MessagePack.MessagePackWriter writer, object? obj, MessagePack.MessagePackSerializerOptions? options = null) -> void +static MessagePack.MessagePackSerializer.Serialize(System.Buffers.IBufferWriter! writer, T value, MessagePack.MessagePackSerializerOptions? options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> void +static MessagePack.MessagePackSerializer.Serialize(System.IO.Stream! stream, T value, MessagePack.MessagePackSerializerOptions? options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> void +static MessagePack.MessagePackSerializer.Serialize(T value, MessagePack.MessagePackSerializerOptions? options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> byte[]! +static MessagePack.MessagePackSerializer.Serialize(ref MessagePack.MessagePackWriter writer, T value, MessagePack.MessagePackSerializerOptions? options = null) -> void +static MessagePack.MessagePackSerializer.SerializeAsync(System.Type! type, System.IO.Stream! stream, object? obj, MessagePack.MessagePackSerializerOptions? options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.Task! +static MessagePack.MessagePackSerializer.SerializeAsync(System.IO.Stream! stream, T value, MessagePack.MessagePackSerializerOptions? options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.Task! +static MessagePack.MessagePackSerializer.SerializeToJson(System.IO.TextWriter! textWriter, T obj, MessagePack.MessagePackSerializerOptions? options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> void +static MessagePack.MessagePackSerializer.SerializeToJson(T obj, MessagePack.MessagePackSerializerOptions? options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> string! +static MessagePack.MessagePackSerializer.Typeless.DefaultOptions.get -> MessagePack.MessagePackSerializerOptions! +static MessagePack.MessagePackSerializer.Typeless.DefaultOptions.set -> void +static MessagePack.MessagePackSerializer.Typeless.Deserialize(System.IO.Stream! stream, MessagePack.MessagePackSerializerOptions? options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> object? +static MessagePack.MessagePackSerializer.Typeless.Deserialize(System.Memory bytes, MessagePack.MessagePackSerializerOptions? options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> object? +static MessagePack.MessagePackSerializer.Typeless.Deserialize(in System.Buffers.ReadOnlySequence byteSequence, MessagePack.MessagePackSerializerOptions? options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> object? +static MessagePack.MessagePackSerializer.Typeless.Deserialize(ref MessagePack.MessagePackReader reader, MessagePack.MessagePackSerializerOptions? options = null) -> object? +static MessagePack.MessagePackSerializer.Typeless.DeserializeAsync(System.IO.Stream! stream, MessagePack.MessagePackSerializerOptions? options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.ValueTask +static MessagePack.MessagePackSerializer.Typeless.Serialize(System.Buffers.IBufferWriter! writer, object? obj, MessagePack.MessagePackSerializerOptions? options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> void +static MessagePack.MessagePackSerializer.Typeless.Serialize(System.IO.Stream! stream, object? obj, MessagePack.MessagePackSerializerOptions? options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> void +static MessagePack.MessagePackSerializer.Typeless.Serialize(object? obj, MessagePack.MessagePackSerializerOptions? options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> byte[]! +static MessagePack.MessagePackSerializer.Typeless.Serialize(ref MessagePack.MessagePackWriter writer, object? obj, MessagePack.MessagePackSerializerOptions? options = null) -> void +static MessagePack.MessagePackSerializer.Typeless.SerializeAsync(System.IO.Stream! stream, object? obj, MessagePack.MessagePackSerializerOptions? options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> System.Threading.Tasks.Task! +static MessagePack.MessagePackSerializerOptions.Standard.get -> MessagePack.MessagePackSerializerOptions! +static MessagePack.Resolvers.CompositeResolver.Create(System.Collections.Generic.IReadOnlyList! formatters, System.Collections.Generic.IReadOnlyList! resolvers) -> MessagePack.IFormatterResolver! +static MessagePack.Resolvers.CompositeResolver.Create(params MessagePack.Formatters.IMessagePackFormatter![]! formatters) -> MessagePack.IFormatterResolver! +static MessagePack.Resolvers.CompositeResolver.Create(params MessagePack.IFormatterResolver![]! resolvers) -> MessagePack.IFormatterResolver! +static readonly MessagePack.Formatters.BigIntegerFormatter.Instance -> MessagePack.Formatters.IMessagePackFormatter! +static readonly MessagePack.Formatters.BitArrayFormatter.Instance -> MessagePack.Formatters.IMessagePackFormatter! +static readonly MessagePack.Formatters.BooleanArrayFormatter.Instance -> MessagePack.Formatters.BooleanArrayFormatter! +static readonly MessagePack.Formatters.BooleanFormatter.Instance -> MessagePack.Formatters.BooleanFormatter! +static readonly MessagePack.Formatters.ByteArrayFormatter.Instance -> MessagePack.Formatters.ByteArrayFormatter! +static readonly MessagePack.Formatters.ByteArraySegmentFormatter.Instance -> MessagePack.Formatters.ByteArraySegmentFormatter! +static readonly MessagePack.Formatters.ByteFormatter.Instance -> MessagePack.Formatters.ByteFormatter! +static readonly MessagePack.Formatters.CharArrayFormatter.Instance -> MessagePack.Formatters.CharArrayFormatter! +static readonly MessagePack.Formatters.CharFormatter.Instance -> MessagePack.Formatters.CharFormatter! +static readonly MessagePack.Formatters.ComplexFormatter.Instance -> MessagePack.Formatters.IMessagePackFormatter! +static readonly MessagePack.Formatters.DateTimeArrayFormatter.Instance -> MessagePack.Formatters.DateTimeArrayFormatter! +static readonly MessagePack.Formatters.DateTimeFormatter.Instance -> MessagePack.Formatters.DateTimeFormatter! +static readonly MessagePack.Formatters.DateTimeOffsetFormatter.Instance -> MessagePack.Formatters.IMessagePackFormatter! +static readonly MessagePack.Formatters.DecimalFormatter.Instance -> MessagePack.Formatters.DecimalFormatter! +static readonly MessagePack.Formatters.DoubleArrayFormatter.Instance -> MessagePack.Formatters.DoubleArrayFormatter! +static readonly MessagePack.Formatters.DoubleFormatter.Instance -> MessagePack.Formatters.DoubleFormatter! +static readonly MessagePack.Formatters.DynamicObjectTypeFallbackFormatter.Instance -> MessagePack.Formatters.IMessagePackFormatter! +static readonly MessagePack.Formatters.ForceByteBlockFormatter.Instance -> MessagePack.Formatters.ForceByteBlockFormatter! +static readonly MessagePack.Formatters.ForceInt16BlockArrayFormatter.Instance -> MessagePack.Formatters.ForceInt16BlockArrayFormatter! +static readonly MessagePack.Formatters.ForceInt16BlockFormatter.Instance -> MessagePack.Formatters.ForceInt16BlockFormatter! +static readonly MessagePack.Formatters.ForceInt32BlockArrayFormatter.Instance -> MessagePack.Formatters.ForceInt32BlockArrayFormatter! +static readonly MessagePack.Formatters.ForceInt32BlockFormatter.Instance -> MessagePack.Formatters.ForceInt32BlockFormatter! +static readonly MessagePack.Formatters.ForceInt64BlockArrayFormatter.Instance -> MessagePack.Formatters.ForceInt64BlockArrayFormatter! +static readonly MessagePack.Formatters.ForceInt64BlockFormatter.Instance -> MessagePack.Formatters.ForceInt64BlockFormatter! +static readonly MessagePack.Formatters.ForceSByteBlockArrayFormatter.Instance -> MessagePack.Formatters.ForceSByteBlockArrayFormatter! +static readonly MessagePack.Formatters.ForceSByteBlockFormatter.Instance -> MessagePack.Formatters.ForceSByteBlockFormatter! +static readonly MessagePack.Formatters.ForceUInt16BlockArrayFormatter.Instance -> MessagePack.Formatters.ForceUInt16BlockArrayFormatter! +static readonly MessagePack.Formatters.ForceUInt16BlockFormatter.Instance -> MessagePack.Formatters.ForceUInt16BlockFormatter! +static readonly MessagePack.Formatters.ForceUInt32BlockArrayFormatter.Instance -> MessagePack.Formatters.ForceUInt32BlockArrayFormatter! +static readonly MessagePack.Formatters.ForceUInt32BlockFormatter.Instance -> MessagePack.Formatters.ForceUInt32BlockFormatter! +static readonly MessagePack.Formatters.ForceUInt64BlockArrayFormatter.Instance -> MessagePack.Formatters.ForceUInt64BlockArrayFormatter! +static readonly MessagePack.Formatters.ForceUInt64BlockFormatter.Instance -> MessagePack.Formatters.ForceUInt64BlockFormatter! +static readonly MessagePack.Formatters.GuidFormatter.Instance -> MessagePack.Formatters.IMessagePackFormatter! +static readonly MessagePack.Formatters.Int16ArrayFormatter.Instance -> MessagePack.Formatters.Int16ArrayFormatter! +static readonly MessagePack.Formatters.Int16Formatter.Instance -> MessagePack.Formatters.Int16Formatter! +static readonly MessagePack.Formatters.Int32ArrayFormatter.Instance -> MessagePack.Formatters.Int32ArrayFormatter! +static readonly MessagePack.Formatters.Int32Formatter.Instance -> MessagePack.Formatters.Int32Formatter! +static readonly MessagePack.Formatters.Int64ArrayFormatter.Instance -> MessagePack.Formatters.Int64ArrayFormatter! +static readonly MessagePack.Formatters.Int64Formatter.Instance -> MessagePack.Formatters.Int64Formatter! +static readonly MessagePack.Formatters.NativeDateTimeArrayFormatter.Instance -> MessagePack.Formatters.NativeDateTimeArrayFormatter! +static readonly MessagePack.Formatters.NativeDateTimeFormatter.Instance -> MessagePack.Formatters.NativeDateTimeFormatter! +static readonly MessagePack.Formatters.NativeDecimalFormatter.Instance -> MessagePack.Formatters.IMessagePackFormatter! +static readonly MessagePack.Formatters.NativeGuidFormatter.Instance -> MessagePack.Formatters.IMessagePackFormatter! +static readonly MessagePack.Formatters.NilFormatter.Instance -> MessagePack.Formatters.IMessagePackFormatter! +static readonly MessagePack.Formatters.NonGenericInterfaceDictionaryFormatter.Instance -> MessagePack.Formatters.IMessagePackFormatter! +static readonly MessagePack.Formatters.NonGenericInterfaceListFormatter.Instance -> MessagePack.Formatters.IMessagePackFormatter! +static readonly MessagePack.Formatters.NullableBooleanFormatter.Instance -> MessagePack.Formatters.NullableBooleanFormatter! +static readonly MessagePack.Formatters.NullableByteFormatter.Instance -> MessagePack.Formatters.NullableByteFormatter! +static readonly MessagePack.Formatters.NullableCharFormatter.Instance -> MessagePack.Formatters.NullableCharFormatter! +static readonly MessagePack.Formatters.NullableDateTimeFormatter.Instance -> MessagePack.Formatters.NullableDateTimeFormatter! +static readonly MessagePack.Formatters.NullableDoubleFormatter.Instance -> MessagePack.Formatters.NullableDoubleFormatter! +static readonly MessagePack.Formatters.NullableForceByteBlockFormatter.Instance -> MessagePack.Formatters.NullableForceByteBlockFormatter! +static readonly MessagePack.Formatters.NullableForceInt16BlockFormatter.Instance -> MessagePack.Formatters.NullableForceInt16BlockFormatter! +static readonly MessagePack.Formatters.NullableForceInt32BlockFormatter.Instance -> MessagePack.Formatters.NullableForceInt32BlockFormatter! +static readonly MessagePack.Formatters.NullableForceInt64BlockFormatter.Instance -> MessagePack.Formatters.NullableForceInt64BlockFormatter! +static readonly MessagePack.Formatters.NullableForceSByteBlockFormatter.Instance -> MessagePack.Formatters.NullableForceSByteBlockFormatter! +static readonly MessagePack.Formatters.NullableForceUInt16BlockFormatter.Instance -> MessagePack.Formatters.NullableForceUInt16BlockFormatter! +static readonly MessagePack.Formatters.NullableForceUInt32BlockFormatter.Instance -> MessagePack.Formatters.NullableForceUInt32BlockFormatter! +static readonly MessagePack.Formatters.NullableForceUInt64BlockFormatter.Instance -> MessagePack.Formatters.NullableForceUInt64BlockFormatter! +static readonly MessagePack.Formatters.NullableInt16Formatter.Instance -> MessagePack.Formatters.NullableInt16Formatter! +static readonly MessagePack.Formatters.NullableInt32Formatter.Instance -> MessagePack.Formatters.NullableInt32Formatter! +static readonly MessagePack.Formatters.NullableInt64Formatter.Instance -> MessagePack.Formatters.NullableInt64Formatter! +static readonly MessagePack.Formatters.NullableNilFormatter.Instance -> MessagePack.Formatters.IMessagePackFormatter! +static readonly MessagePack.Formatters.NullableSByteFormatter.Instance -> MessagePack.Formatters.NullableSByteFormatter! +static readonly MessagePack.Formatters.NullableSingleFormatter.Instance -> MessagePack.Formatters.NullableSingleFormatter! +static readonly MessagePack.Formatters.NullableStringArrayFormatter.Instance -> MessagePack.Formatters.NullableStringArrayFormatter! +static readonly MessagePack.Formatters.NullableStringFormatter.Instance -> MessagePack.Formatters.NullableStringFormatter! +static readonly MessagePack.Formatters.NullableUInt16Formatter.Instance -> MessagePack.Formatters.NullableUInt16Formatter! +static readonly MessagePack.Formatters.NullableUInt32Formatter.Instance -> MessagePack.Formatters.NullableUInt32Formatter! +static readonly MessagePack.Formatters.NullableUInt64Formatter.Instance -> MessagePack.Formatters.NullableUInt64Formatter! +static readonly MessagePack.Formatters.PrimitiveObjectFormatter.Instance -> MessagePack.Formatters.IMessagePackFormatter! +static readonly MessagePack.Formatters.SByteArrayFormatter.Instance -> MessagePack.Formatters.SByteArrayFormatter! +static readonly MessagePack.Formatters.SByteFormatter.Instance -> MessagePack.Formatters.SByteFormatter! +static readonly MessagePack.Formatters.SingleArrayFormatter.Instance -> MessagePack.Formatters.SingleArrayFormatter! +static readonly MessagePack.Formatters.SingleFormatter.Instance -> MessagePack.Formatters.SingleFormatter! +static readonly MessagePack.Formatters.StringBuilderFormatter.Instance -> MessagePack.Formatters.IMessagePackFormatter! +static readonly MessagePack.Formatters.TimeSpanFormatter.Instance -> MessagePack.Formatters.IMessagePackFormatter! +static readonly MessagePack.Formatters.TypelessFormatter.Instance -> MessagePack.Formatters.IMessagePackFormatter! +static readonly MessagePack.Formatters.UInt16ArrayFormatter.Instance -> MessagePack.Formatters.UInt16ArrayFormatter! +static readonly MessagePack.Formatters.UInt16Formatter.Instance -> MessagePack.Formatters.UInt16Formatter! +static readonly MessagePack.Formatters.UInt32ArrayFormatter.Instance -> MessagePack.Formatters.UInt32ArrayFormatter! +static readonly MessagePack.Formatters.UInt32Formatter.Instance -> MessagePack.Formatters.UInt32Formatter! +static readonly MessagePack.Formatters.UInt64ArrayFormatter.Instance -> MessagePack.Formatters.UInt64ArrayFormatter! +static readonly MessagePack.Formatters.UInt64Formatter.Instance -> MessagePack.Formatters.UInt64Formatter! +static readonly MessagePack.Formatters.UriFormatter.Instance -> MessagePack.Formatters.IMessagePackFormatter! +static readonly MessagePack.Formatters.VersionFormatter.Instance -> MessagePack.Formatters.IMessagePackFormatter! +static readonly MessagePack.Internal.AutomataKeyGen.GetKeyMethod -> System.Reflection.MethodInfo! +static readonly MessagePack.Internal.RuntimeTypeHandleEqualityComparer.Default -> System.Collections.Generic.IEqualityComparer! +static readonly MessagePack.Internal.UnsafeMemory.Is32Bit -> bool +static readonly MessagePack.Nil.Default -> MessagePack.Nil +static readonly MessagePack.Resolvers.AttributeFormatterResolver.Instance -> MessagePack.Resolvers.AttributeFormatterResolver! +static readonly MessagePack.Resolvers.BuiltinResolver.Instance -> MessagePack.Resolvers.BuiltinResolver! +static readonly MessagePack.Resolvers.ContractlessStandardResolver.Instance -> MessagePack.Resolvers.ContractlessStandardResolver! +static readonly MessagePack.Resolvers.ContractlessStandardResolver.Options -> MessagePack.MessagePackSerializerOptions! +static readonly MessagePack.Resolvers.ContractlessStandardResolverAllowPrivate.Instance -> MessagePack.Resolvers.ContractlessStandardResolverAllowPrivate! +static readonly MessagePack.Resolvers.ContractlessStandardResolverAllowPrivate.Options -> MessagePack.MessagePackSerializerOptions! +static readonly MessagePack.Resolvers.DynamicContractlessObjectResolver.Instance -> MessagePack.Resolvers.DynamicContractlessObjectResolver! +static readonly MessagePack.Resolvers.DynamicContractlessObjectResolverAllowPrivate.Instance -> MessagePack.Resolvers.DynamicContractlessObjectResolverAllowPrivate! +static readonly MessagePack.Resolvers.DynamicEnumAsStringResolver.Instance -> MessagePack.Resolvers.DynamicEnumAsStringResolver! +static readonly MessagePack.Resolvers.DynamicEnumAsStringResolver.Options -> MessagePack.MessagePackSerializerOptions! +static readonly MessagePack.Resolvers.DynamicEnumResolver.Instance -> MessagePack.Resolvers.DynamicEnumResolver! +static readonly MessagePack.Resolvers.DynamicGenericResolver.Instance -> MessagePack.Resolvers.DynamicGenericResolver! +static readonly MessagePack.Resolvers.DynamicObjectResolver.Instance -> MessagePack.Resolvers.DynamicObjectResolver! +static readonly MessagePack.Resolvers.DynamicObjectResolver.Options -> MessagePack.MessagePackSerializerOptions! +static readonly MessagePack.Resolvers.DynamicObjectResolverAllowPrivate.Instance -> MessagePack.Resolvers.DynamicObjectResolverAllowPrivate! +static readonly MessagePack.Resolvers.DynamicUnionResolver.Instance -> MessagePack.Resolvers.DynamicUnionResolver! +static readonly MessagePack.Resolvers.DynamicUnionResolver.Options -> MessagePack.MessagePackSerializerOptions! +static readonly MessagePack.Resolvers.NativeDateTimeResolver.Instance -> MessagePack.Resolvers.NativeDateTimeResolver! +static readonly MessagePack.Resolvers.NativeDateTimeResolver.Options -> MessagePack.MessagePackSerializerOptions! +static readonly MessagePack.Resolvers.NativeDecimalResolver.Instance -> MessagePack.Resolvers.NativeDecimalResolver! +static readonly MessagePack.Resolvers.NativeGuidResolver.Instance -> MessagePack.Resolvers.NativeGuidResolver! +static readonly MessagePack.Resolvers.PrimitiveObjectResolver.Instance -> MessagePack.Resolvers.PrimitiveObjectResolver! +static readonly MessagePack.Resolvers.PrimitiveObjectResolver.Options -> MessagePack.MessagePackSerializerOptions! +static readonly MessagePack.Resolvers.StandardResolver.Instance -> MessagePack.Resolvers.StandardResolver! +static readonly MessagePack.Resolvers.StandardResolver.Options -> MessagePack.MessagePackSerializerOptions! +static readonly MessagePack.Resolvers.StandardResolverAllowPrivate.Instance -> MessagePack.Resolvers.StandardResolverAllowPrivate! +static readonly MessagePack.Resolvers.StandardResolverAllowPrivate.Options -> MessagePack.MessagePackSerializerOptions! +static readonly MessagePack.Resolvers.StaticCompositeResolver.Instance -> MessagePack.Resolvers.StaticCompositeResolver! +static readonly MessagePack.Resolvers.TypelessContractlessStandardResolver.Instance -> MessagePack.Resolvers.TypelessContractlessStandardResolver! +static readonly MessagePack.Resolvers.TypelessContractlessStandardResolver.Options -> MessagePack.MessagePackSerializerOptions! +static readonly MessagePack.Resolvers.TypelessObjectResolver.Instance -> MessagePack.IFormatterResolver! +virtual MessagePack.Formatters.CollectionFormatterBase.GetCount(TCollection sequence) -> int? +virtual MessagePack.MessagePackSerializerOptions.Clone() -> MessagePack.MessagePackSerializerOptions! +virtual MessagePack.MessagePackSerializerOptions.LoadType(string! typeName) -> System.Type? +virtual MessagePack.MessagePackSerializerOptions.ThrowIfDeserializingTypeIsDisallowed(System.Type! type) -> void +MessagePack.ExtensionHeader.Equals(MessagePack.ExtensionHeader other) -> bool +MessagePack.Formatters.InterfaceCollectionFormatter2 +MessagePack.Formatters.InterfaceCollectionFormatter2.InterfaceCollectionFormatter2() -> void +MessagePack.Formatters.InterfaceListFormatter2 +MessagePack.Formatters.InterfaceListFormatter2.InterfaceListFormatter2() -> void +MessagePack.MessagePackReader.Depth.get -> int +MessagePack.MessagePackReader.Depth.set -> void +MessagePack.MessagePackReader.ReadDateTime(MessagePack.ExtensionHeader header) -> System.DateTime +MessagePack.MessagePackReader.TryReadArrayHeader(out int count) -> bool +MessagePack.MessagePackReader.TryReadExtensionFormatHeader(out MessagePack.ExtensionHeader extensionHeader) -> bool +MessagePack.MessagePackReader.TryReadMapHeader(out int count) -> bool +MessagePack.MessagePackSecurity +MessagePack.MessagePackSecurity.DepthStep(ref MessagePack.MessagePackReader reader) -> void +MessagePack.MessagePackSecurity.GetEqualityComparer() -> System.Collections.IEqualityComparer! +MessagePack.MessagePackSecurity.GetEqualityComparer() -> System.Collections.Generic.IEqualityComparer! +MessagePack.MessagePackSecurity.HashCollisionResistant.get -> bool +MessagePack.MessagePackSecurity.MaximumObjectGraphDepth.get -> int +MessagePack.MessagePackSecurity.MessagePackSecurity(MessagePack.MessagePackSecurity! copyFrom) -> void +MessagePack.MessagePackSecurity.WithHashCollisionResistant(bool hashCollisionResistant) -> MessagePack.MessagePackSecurity! +MessagePack.MessagePackSecurity.WithMaximumObjectGraphDepth(int maximumObjectGraphDepth) -> MessagePack.MessagePackSecurity! +MessagePack.MessagePackSerializerOptions.Security.get -> MessagePack.MessagePackSecurity! +MessagePack.MessagePackSerializerOptions.WithSecurity(MessagePack.MessagePackSecurity! security) -> MessagePack.MessagePackSerializerOptions! +MessagePack.MessagePackStreamReader.DiscardBufferedData() -> void +MessagePack.MessagePackStreamReader.MessagePackStreamReader(System.IO.Stream! stream, bool leaveOpen) -> void +MessagePack.MessagePackStreamReader.ReadArrayAsync(System.Threading.CancellationToken cancellationToken) -> System.Collections.Generic.IAsyncEnumerable>! +MessagePack.MessagePackWriter.WriteBinHeader(int length) -> void +MessagePack.MessagePackWriter.WriteStringHeader(int byteCount) -> void +static readonly MessagePack.MessagePackSecurity.TrustedData -> MessagePack.MessagePackSecurity! +static readonly MessagePack.MessagePackSecurity.UntrustedData -> MessagePack.MessagePackSecurity! +virtual MessagePack.MessagePackSecurity.Clone() -> MessagePack.MessagePackSecurity! +virtual MessagePack.MessagePackSecurity.GetHashCollisionResistantEqualityComparer() -> System.Collections.IEqualityComparer! +virtual MessagePack.MessagePackSecurity.GetHashCollisionResistantEqualityComparer() -> System.Collections.Generic.IEqualityComparer! +MessagePack.Formatters.ByteMemoryFormatter +MessagePack.Formatters.ByteMemoryFormatter.Deserialize(ref MessagePack.MessagePackReader reader, MessagePack.MessagePackSerializerOptions! options) -> System.Memory +MessagePack.Formatters.ByteMemoryFormatter.Serialize(ref MessagePack.MessagePackWriter writer, System.Memory value, MessagePack.MessagePackSerializerOptions! options) -> void +MessagePack.Formatters.ByteReadOnlyMemoryFormatter +MessagePack.Formatters.ByteReadOnlyMemoryFormatter.Deserialize(ref MessagePack.MessagePackReader reader, MessagePack.MessagePackSerializerOptions! options) -> System.ReadOnlyMemory +MessagePack.Formatters.ByteReadOnlyMemoryFormatter.Serialize(ref MessagePack.MessagePackWriter writer, System.ReadOnlyMemory value, MessagePack.MessagePackSerializerOptions! options) -> void +MessagePack.Formatters.ByteReadOnlySequenceFormatter +MessagePack.Formatters.ByteReadOnlySequenceFormatter.Deserialize(ref MessagePack.MessagePackReader reader, MessagePack.MessagePackSerializerOptions! options) -> System.Buffers.ReadOnlySequence +MessagePack.Formatters.ByteReadOnlySequenceFormatter.Serialize(ref MessagePack.MessagePackWriter writer, System.Buffers.ReadOnlySequence value, MessagePack.MessagePackSerializerOptions! options) -> void +MessagePack.Formatters.ExpandoObjectFormatter +MessagePack.Formatters.ExpandoObjectFormatter.Deserialize(ref MessagePack.MessagePackReader reader, MessagePack.MessagePackSerializerOptions! options) -> System.Dynamic.ExpandoObject? +MessagePack.Formatters.ExpandoObjectFormatter.Serialize(ref MessagePack.MessagePackWriter writer, System.Dynamic.ExpandoObject? value, MessagePack.MessagePackSerializerOptions! options) -> void +MessagePack.Formatters.ForceTypelessFormatter +MessagePack.Formatters.ForceTypelessFormatter.Deserialize(ref MessagePack.MessagePackReader reader, MessagePack.MessagePackSerializerOptions! options) -> T? +MessagePack.Formatters.ForceTypelessFormatter.ForceTypelessFormatter() -> void +MessagePack.Formatters.ForceTypelessFormatter.Serialize(ref MessagePack.MessagePackWriter writer, T? value, MessagePack.MessagePackSerializerOptions! options) -> void +MessagePack.Formatters.MemoryFormatter +MessagePack.Formatters.MemoryFormatter.Deserialize(ref MessagePack.MessagePackReader reader, MessagePack.MessagePackSerializerOptions! options) -> System.Memory +MessagePack.Formatters.MemoryFormatter.MemoryFormatter() -> void +MessagePack.Formatters.MemoryFormatter.Serialize(ref MessagePack.MessagePackWriter writer, System.Memory value, MessagePack.MessagePackSerializerOptions! options) -> void +MessagePack.Formatters.NonGenericInterfaceCollectionFormatter +MessagePack.Formatters.NonGenericInterfaceCollectionFormatter.Deserialize(ref MessagePack.MessagePackReader reader, MessagePack.MessagePackSerializerOptions! options) -> System.Collections.ICollection? +MessagePack.Formatters.NonGenericInterfaceCollectionFormatter.Serialize(ref MessagePack.MessagePackWriter writer, System.Collections.ICollection? value, MessagePack.MessagePackSerializerOptions! options) -> void +MessagePack.Formatters.NonGenericInterfaceEnumerableFormatter +MessagePack.Formatters.NonGenericInterfaceEnumerableFormatter.Deserialize(ref MessagePack.MessagePackReader reader, MessagePack.MessagePackSerializerOptions! options) -> System.Collections.IEnumerable? +MessagePack.Formatters.NonGenericInterfaceEnumerableFormatter.Serialize(ref MessagePack.MessagePackWriter writer, System.Collections.IEnumerable? value, MessagePack.MessagePackSerializerOptions! options) -> void +MessagePack.Formatters.PrimitiveObjectFormatter.PrimitiveObjectFormatter() -> void +MessagePack.Formatters.ReadOnlyMemoryFormatter +MessagePack.Formatters.ReadOnlyMemoryFormatter.Deserialize(ref MessagePack.MessagePackReader reader, MessagePack.MessagePackSerializerOptions! options) -> System.ReadOnlyMemory +MessagePack.Formatters.ReadOnlyMemoryFormatter.ReadOnlyMemoryFormatter() -> void +MessagePack.Formatters.ReadOnlyMemoryFormatter.Serialize(ref MessagePack.MessagePackWriter writer, System.ReadOnlyMemory value, MessagePack.MessagePackSerializerOptions! options) -> void +MessagePack.Formatters.ReadOnlySequenceFormatter +MessagePack.Formatters.ReadOnlySequenceFormatter.Deserialize(ref MessagePack.MessagePackReader reader, MessagePack.MessagePackSerializerOptions! options) -> System.Buffers.ReadOnlySequence +MessagePack.Formatters.ReadOnlySequenceFormatter.ReadOnlySequenceFormatter() -> void +MessagePack.Formatters.ReadOnlySequenceFormatter.Serialize(ref MessagePack.MessagePackWriter writer, System.Buffers.ReadOnlySequence value, MessagePack.MessagePackSerializerOptions! options) -> void +MessagePack.Formatters.TypeFormatter +MessagePack.Formatters.TypeFormatter.Deserialize(ref MessagePack.MessagePackReader reader, MessagePack.MessagePackSerializerOptions! options) -> T? +MessagePack.Formatters.TypeFormatter.Serialize(ref MessagePack.MessagePackWriter writer, T? value, MessagePack.MessagePackSerializerOptions! options) -> void +MessagePack.Formatters.TypelessFormatter.TypelessFormatter() -> void +MessagePack.ImmutableCollection.ImmutableArrayFormatter +~MessagePack.ImmutableCollection.ImmutableArrayFormatter.Deserialize(ref MessagePack.MessagePackReader reader, MessagePack.MessagePackSerializerOptions options) -> System.Collections.Immutable.ImmutableArray +MessagePack.ImmutableCollection.ImmutableArrayFormatter.ImmutableArrayFormatter() -> void +~MessagePack.ImmutableCollection.ImmutableArrayFormatter.Serialize(ref MessagePack.MessagePackWriter writer, System.Collections.Immutable.ImmutableArray value, MessagePack.MessagePackSerializerOptions options) -> void +MessagePack.ImmutableCollection.ImmutableCollectionResolver +MessagePack.ImmutableCollection.ImmutableCollectionResolver.GetFormatter() -> MessagePack.Formatters.IMessagePackFormatter? +MessagePack.ImmutableCollection.ImmutableDictionaryFormatter +MessagePack.ImmutableCollection.ImmutableDictionaryFormatter.ImmutableDictionaryFormatter() -> void +MessagePack.ImmutableCollection.ImmutableHashSetFormatter +MessagePack.ImmutableCollection.ImmutableHashSetFormatter.ImmutableHashSetFormatter() -> void +MessagePack.ImmutableCollection.ImmutableListFormatter +MessagePack.ImmutableCollection.ImmutableListFormatter.ImmutableListFormatter() -> void +MessagePack.ImmutableCollection.ImmutableQueueBuilder +MessagePack.ImmutableCollection.ImmutableQueueBuilder.Add(T value) -> void +MessagePack.ImmutableCollection.ImmutableQueueBuilder.ImmutableQueueBuilder() -> void +~MessagePack.ImmutableCollection.ImmutableQueueBuilder.Q.get -> System.Collections.Immutable.ImmutableQueue +~MessagePack.ImmutableCollection.ImmutableQueueBuilder.Q.set -> void +MessagePack.ImmutableCollection.ImmutableQueueFormatter +MessagePack.ImmutableCollection.ImmutableQueueFormatter.ImmutableQueueFormatter() -> void +MessagePack.ImmutableCollection.ImmutableSortedDictionaryFormatter +MessagePack.ImmutableCollection.ImmutableSortedDictionaryFormatter.ImmutableSortedDictionaryFormatter() -> void +MessagePack.ImmutableCollection.ImmutableSortedSetFormatter +MessagePack.ImmutableCollection.ImmutableSortedSetFormatter.ImmutableSortedSetFormatter() -> void +MessagePack.ImmutableCollection.ImmutableStackFormatter +MessagePack.ImmutableCollection.ImmutableStackFormatter.ImmutableStackFormatter() -> void +MessagePack.ImmutableCollection.InterfaceImmutableDictionaryFormatter +MessagePack.ImmutableCollection.InterfaceImmutableDictionaryFormatter.InterfaceImmutableDictionaryFormatter() -> void +MessagePack.ImmutableCollection.InterfaceImmutableListFormatter +MessagePack.ImmutableCollection.InterfaceImmutableListFormatter.InterfaceImmutableListFormatter() -> void +MessagePack.ImmutableCollection.InterfaceImmutableQueueFormatter +MessagePack.ImmutableCollection.InterfaceImmutableQueueFormatter.InterfaceImmutableQueueFormatter() -> void +MessagePack.ImmutableCollection.InterfaceImmutableSetFormatter +MessagePack.ImmutableCollection.InterfaceImmutableSetFormatter.InterfaceImmutableSetFormatter() -> void +MessagePack.ImmutableCollection.InterfaceImmutableStackFormatter +MessagePack.ImmutableCollection.InterfaceImmutableStackFormatter.InterfaceImmutableStackFormatter() -> void +MessagePack.Resolvers.ExpandoObjectResolver +~override MessagePack.ImmutableCollection.ImmutableDictionaryFormatter.Add(System.Collections.Immutable.ImmutableDictionary.Builder collection, int index, TKey key, TValue value, MessagePack.MessagePackSerializerOptions options) -> void +~override MessagePack.ImmutableCollection.ImmutableDictionaryFormatter.Complete(System.Collections.Immutable.ImmutableDictionary.Builder intermediateCollection) -> System.Collections.Immutable.ImmutableDictionary +~override MessagePack.ImmutableCollection.ImmutableDictionaryFormatter.Create(int count, MessagePack.MessagePackSerializerOptions options) -> System.Collections.Immutable.ImmutableDictionary.Builder +~override MessagePack.ImmutableCollection.ImmutableDictionaryFormatter.GetSourceEnumerator(System.Collections.Immutable.ImmutableDictionary source) -> System.Collections.Immutable.ImmutableDictionary.Enumerator +~override MessagePack.ImmutableCollection.ImmutableHashSetFormatter.Add(System.Collections.Immutable.ImmutableHashSet.Builder collection, int index, T value, MessagePack.MessagePackSerializerOptions options) -> void +~override MessagePack.ImmutableCollection.ImmutableHashSetFormatter.Complete(System.Collections.Immutable.ImmutableHashSet.Builder intermediateCollection) -> System.Collections.Immutable.ImmutableHashSet +~override MessagePack.ImmutableCollection.ImmutableHashSetFormatter.Create(int count, MessagePack.MessagePackSerializerOptions options) -> System.Collections.Immutable.ImmutableHashSet.Builder +~override MessagePack.ImmutableCollection.ImmutableHashSetFormatter.GetSourceEnumerator(System.Collections.Immutable.ImmutableHashSet source) -> System.Collections.Immutable.ImmutableHashSet.Enumerator +~override MessagePack.ImmutableCollection.ImmutableListFormatter.Add(System.Collections.Immutable.ImmutableList.Builder collection, int index, T value, MessagePack.MessagePackSerializerOptions options) -> void +~override MessagePack.ImmutableCollection.ImmutableListFormatter.Complete(System.Collections.Immutable.ImmutableList.Builder intermediateCollection) -> System.Collections.Immutable.ImmutableList +~override MessagePack.ImmutableCollection.ImmutableListFormatter.Create(int count, MessagePack.MessagePackSerializerOptions options) -> System.Collections.Immutable.ImmutableList.Builder +~override MessagePack.ImmutableCollection.ImmutableListFormatter.GetSourceEnumerator(System.Collections.Immutable.ImmutableList source) -> System.Collections.Immutable.ImmutableList.Enumerator +~override MessagePack.ImmutableCollection.ImmutableQueueFormatter.Add(MessagePack.ImmutableCollection.ImmutableQueueBuilder collection, int index, T value, MessagePack.MessagePackSerializerOptions options) -> void +~override MessagePack.ImmutableCollection.ImmutableQueueFormatter.Complete(MessagePack.ImmutableCollection.ImmutableQueueBuilder intermediateCollection) -> System.Collections.Immutable.ImmutableQueue +~override MessagePack.ImmutableCollection.ImmutableQueueFormatter.Create(int count, MessagePack.MessagePackSerializerOptions options) -> MessagePack.ImmutableCollection.ImmutableQueueBuilder +~override MessagePack.ImmutableCollection.ImmutableSortedDictionaryFormatter.Add(System.Collections.Immutable.ImmutableSortedDictionary.Builder collection, int index, TKey key, TValue value, MessagePack.MessagePackSerializerOptions options) -> void +~override MessagePack.ImmutableCollection.ImmutableSortedDictionaryFormatter.Complete(System.Collections.Immutable.ImmutableSortedDictionary.Builder intermediateCollection) -> System.Collections.Immutable.ImmutableSortedDictionary +~override MessagePack.ImmutableCollection.ImmutableSortedDictionaryFormatter.Create(int count, MessagePack.MessagePackSerializerOptions options) -> System.Collections.Immutable.ImmutableSortedDictionary.Builder +~override MessagePack.ImmutableCollection.ImmutableSortedDictionaryFormatter.GetSourceEnumerator(System.Collections.Immutable.ImmutableSortedDictionary source) -> System.Collections.Immutable.ImmutableSortedDictionary.Enumerator +~override MessagePack.ImmutableCollection.ImmutableSortedSetFormatter.Add(System.Collections.Immutable.ImmutableSortedSet.Builder collection, int index, T value, MessagePack.MessagePackSerializerOptions options) -> void +~override MessagePack.ImmutableCollection.ImmutableSortedSetFormatter.Complete(System.Collections.Immutable.ImmutableSortedSet.Builder intermediateCollection) -> System.Collections.Immutable.ImmutableSortedSet +~override MessagePack.ImmutableCollection.ImmutableSortedSetFormatter.Create(int count, MessagePack.MessagePackSerializerOptions options) -> System.Collections.Immutable.ImmutableSortedSet.Builder +~override MessagePack.ImmutableCollection.ImmutableSortedSetFormatter.GetSourceEnumerator(System.Collections.Immutable.ImmutableSortedSet source) -> System.Collections.Immutable.ImmutableSortedSet.Enumerator +~override MessagePack.ImmutableCollection.ImmutableStackFormatter.Add(T[] collection, int index, T value, MessagePack.MessagePackSerializerOptions options) -> void +~override MessagePack.ImmutableCollection.ImmutableStackFormatter.Complete(T[] intermediateCollection) -> System.Collections.Immutable.ImmutableStack +~override MessagePack.ImmutableCollection.ImmutableStackFormatter.Create(int count, MessagePack.MessagePackSerializerOptions options) -> T[] +~override MessagePack.ImmutableCollection.InterfaceImmutableDictionaryFormatter.Add(System.Collections.Immutable.ImmutableDictionary.Builder collection, int index, TKey key, TValue value, MessagePack.MessagePackSerializerOptions options) -> void +~override MessagePack.ImmutableCollection.InterfaceImmutableDictionaryFormatter.Complete(System.Collections.Immutable.ImmutableDictionary.Builder intermediateCollection) -> System.Collections.Immutable.IImmutableDictionary +~override MessagePack.ImmutableCollection.InterfaceImmutableDictionaryFormatter.Create(int count, MessagePack.MessagePackSerializerOptions options) -> System.Collections.Immutable.ImmutableDictionary.Builder +~override MessagePack.ImmutableCollection.InterfaceImmutableListFormatter.Add(System.Collections.Immutable.ImmutableList.Builder collection, int index, T value, MessagePack.MessagePackSerializerOptions options) -> void +~override MessagePack.ImmutableCollection.InterfaceImmutableListFormatter.Complete(System.Collections.Immutable.ImmutableList.Builder intermediateCollection) -> System.Collections.Immutable.IImmutableList +~override MessagePack.ImmutableCollection.InterfaceImmutableListFormatter.Create(int count, MessagePack.MessagePackSerializerOptions options) -> System.Collections.Immutable.ImmutableList.Builder +~override MessagePack.ImmutableCollection.InterfaceImmutableQueueFormatter.Add(MessagePack.ImmutableCollection.ImmutableQueueBuilder collection, int index, T value, MessagePack.MessagePackSerializerOptions options) -> void +~override MessagePack.ImmutableCollection.InterfaceImmutableQueueFormatter.Complete(MessagePack.ImmutableCollection.ImmutableQueueBuilder intermediateCollection) -> System.Collections.Immutable.IImmutableQueue +~override MessagePack.ImmutableCollection.InterfaceImmutableQueueFormatter.Create(int count, MessagePack.MessagePackSerializerOptions options) -> MessagePack.ImmutableCollection.ImmutableQueueBuilder +~override MessagePack.ImmutableCollection.InterfaceImmutableSetFormatter.Add(System.Collections.Immutable.ImmutableHashSet.Builder collection, int index, T value, MessagePack.MessagePackSerializerOptions options) -> void +~override MessagePack.ImmutableCollection.InterfaceImmutableSetFormatter.Complete(System.Collections.Immutable.ImmutableHashSet.Builder intermediateCollection) -> System.Collections.Immutable.IImmutableSet +~override MessagePack.ImmutableCollection.InterfaceImmutableSetFormatter.Create(int count, MessagePack.MessagePackSerializerOptions options) -> System.Collections.Immutable.ImmutableHashSet.Builder +~override MessagePack.ImmutableCollection.InterfaceImmutableStackFormatter.Add(T[] collection, int index, T value, MessagePack.MessagePackSerializerOptions options) -> void +~override MessagePack.ImmutableCollection.InterfaceImmutableStackFormatter.Complete(T[] intermediateCollection) -> System.Collections.Immutable.IImmutableStack +~override MessagePack.ImmutableCollection.InterfaceImmutableStackFormatter.Create(int count, MessagePack.MessagePackSerializerOptions options) -> T[] +static readonly MessagePack.Formatters.ByteMemoryFormatter.Instance -> MessagePack.Formatters.ByteMemoryFormatter! +static readonly MessagePack.Formatters.ByteReadOnlyMemoryFormatter.Instance -> MessagePack.Formatters.ByteReadOnlyMemoryFormatter! +static readonly MessagePack.Formatters.ByteReadOnlySequenceFormatter.Instance -> MessagePack.Formatters.ByteReadOnlySequenceFormatter! +static readonly MessagePack.Formatters.ExpandoObjectFormatter.Instance -> MessagePack.Formatters.IMessagePackFormatter! +static readonly MessagePack.Formatters.NonGenericInterfaceCollectionFormatter.Instance -> MessagePack.Formatters.IMessagePackFormatter! +static readonly MessagePack.Formatters.NonGenericInterfaceEnumerableFormatter.Instance -> MessagePack.Formatters.IMessagePackFormatter! +static readonly MessagePack.Formatters.TypeFormatter.Instance -> MessagePack.Formatters.IMessagePackFormatter! +static readonly MessagePack.ImmutableCollection.ImmutableCollectionResolver.Instance -> MessagePack.ImmutableCollection.ImmutableCollectionResolver! +static readonly MessagePack.Resolvers.ExpandoObjectResolver.Instance -> MessagePack.IFormatterResolver! +static readonly MessagePack.Resolvers.ExpandoObjectResolver.Options -> MessagePack.MessagePackSerializerOptions! +virtual MessagePack.Formatters.PrimitiveObjectFormatter.DeserializeMap(ref MessagePack.MessagePackReader reader, int length, MessagePack.MessagePackSerializerOptions! options) -> object! +MessagePack.ExtensionHeader.ExtensionHeader() -> void +MessagePack.ExtensionResult.ExtensionResult() -> void +MessagePack.FormatterNotRegisteredException.FormatterNotRegisteredException(System.Runtime.Serialization.SerializationInfo! info, System.Runtime.Serialization.StreamingContext context) -> void +MessagePack.Formatters.HalfFormatter +MessagePack.Formatters.HalfFormatter.Deserialize(ref MessagePack.MessagePackReader reader, MessagePack.MessagePackSerializerOptions! options) -> System.Half +MessagePack.Formatters.HalfFormatter.Serialize(ref MessagePack.MessagePackWriter writer, System.Half value, MessagePack.MessagePackSerializerOptions! options) -> void +MessagePack.Formatters.InterfaceReadOnlySetFormatter +MessagePack.Formatters.InterfaceReadOnlySetFormatter.InterfaceReadOnlySetFormatter() -> void +MessagePack.MessagePackReader.MessagePackReader() -> void +MessagePack.MessagePackSerializerOptions.SequencePool.get -> MessagePack.SequencePool! +MessagePack.MessagePackSerializerOptions.WithPool(MessagePack.SequencePool! pool) -> MessagePack.MessagePackSerializerOptions! +MessagePack.MessagePackStreamReader.MessagePackStreamReader(System.IO.Stream! stream, bool leaveOpen, MessagePack.SequencePool! sequencePool) -> void +MessagePack.MessagePackStreamReader.ReadArrayHeaderAsync(System.Threading.CancellationToken cancellationToken) -> System.Threading.Tasks.ValueTask +MessagePack.MessagePackStreamReader.ReadMapHeaderAsync(System.Threading.CancellationToken cancellationToken) -> System.Threading.Tasks.ValueTask +MessagePack.MessagePackWriter.MessagePackWriter() -> void +MessagePack.SequencePool +MessagePack.SequencePool.SequencePool() -> void +MessagePack.SequencePool.SequencePool(int maxSize) -> void +MessagePack.SequencePool.SequencePool(int maxSize, System.Buffers.ArrayPool! arrayPool) -> void +MessagePack.TinyJsonException.TinyJsonException(System.Runtime.Serialization.SerializationInfo! info, System.Runtime.Serialization.StreamingContext context) -> void +static MessagePack.Nil.operator !=(MessagePack.Nil left, MessagePack.Nil right) -> bool +static MessagePack.Nil.operator ==(MessagePack.Nil left, MessagePack.Nil right) -> bool +static readonly MessagePack.Formatters.HalfFormatter.Instance -> MessagePack.Formatters.IMessagePackFormatter! +virtual MessagePack.MessagePackStreamReader.Dispose(bool disposing) -> void +MessagePack.Formatters.GenericEnumerableFormatter +MessagePack.Formatters.GenericEnumerableFormatter.GenericEnumerableFormatter() -> void +MessagePack.Formatters.GenericReadOnlyDictionaryFormatter +MessagePack.Formatters.GenericReadOnlyDictionaryFormatter.GenericReadOnlyDictionaryFormatter() -> void diff --git a/src/MessagePack/net8.0/PublicAPI.Unshipped.txt b/src/MessagePack/net8.0/PublicAPI.Unshipped.txt new file mode 100644 index 000000000..d7903ded6 --- /dev/null +++ b/src/MessagePack/net8.0/PublicAPI.Unshipped.txt @@ -0,0 +1,44 @@ +MessagePack.Formatters.DateOnlyFormatter +MessagePack.Formatters.DateOnlyFormatter.Deserialize(ref MessagePack.MessagePackReader reader, MessagePack.MessagePackSerializerOptions! options) -> System.DateOnly +MessagePack.Formatters.DateOnlyFormatter.Serialize(ref MessagePack.MessagePackWriter writer, System.DateOnly value, MessagePack.MessagePackSerializerOptions! options) -> void +MessagePack.Formatters.Matrix3x2Formatter +MessagePack.Formatters.Matrix3x2Formatter.Deserialize(ref MessagePack.MessagePackReader reader, MessagePack.MessagePackSerializerOptions! options) -> System.Numerics.Matrix3x2 +MessagePack.Formatters.Matrix3x2Formatter.Serialize(ref MessagePack.MessagePackWriter writer, System.Numerics.Matrix3x2 value, MessagePack.MessagePackSerializerOptions! options) -> void +MessagePack.Formatters.Matrix4x4Formatter +MessagePack.Formatters.Matrix4x4Formatter.Deserialize(ref MessagePack.MessagePackReader reader, MessagePack.MessagePackSerializerOptions! options) -> System.Numerics.Matrix4x4 +MessagePack.Formatters.Matrix4x4Formatter.Serialize(ref MessagePack.MessagePackWriter writer, System.Numerics.Matrix4x4 value, MessagePack.MessagePackSerializerOptions! options) -> void +MessagePack.Formatters.QuaternionFormatter +MessagePack.Formatters.QuaternionFormatter.Deserialize(ref MessagePack.MessagePackReader reader, MessagePack.MessagePackSerializerOptions! options) -> System.Numerics.Quaternion +MessagePack.Formatters.QuaternionFormatter.Serialize(ref MessagePack.MessagePackWriter writer, System.Numerics.Quaternion value, MessagePack.MessagePackSerializerOptions! options) -> void +MessagePack.Formatters.StringInterningFormatter +MessagePack.Formatters.StringInterningFormatter.Deserialize(ref MessagePack.MessagePackReader reader, MessagePack.MessagePackSerializerOptions! options) -> string? +MessagePack.Formatters.StringInterningFormatter.Serialize(ref MessagePack.MessagePackWriter writer, string? value, MessagePack.MessagePackSerializerOptions! options) -> void +MessagePack.Formatters.StringInterningFormatter.StringInterningFormatter() -> void +MessagePack.Formatters.TimeOnlyFormatter +MessagePack.Formatters.TimeOnlyFormatter.Deserialize(ref MessagePack.MessagePackReader reader, MessagePack.MessagePackSerializerOptions! options) -> System.TimeOnly +MessagePack.Formatters.TimeOnlyFormatter.Serialize(ref MessagePack.MessagePackWriter writer, System.TimeOnly value, MessagePack.MessagePackSerializerOptions! options) -> void +MessagePack.Formatters.Vector2Formatter +MessagePack.Formatters.Vector2Formatter.Deserialize(ref MessagePack.MessagePackReader reader, MessagePack.MessagePackSerializerOptions! options) -> System.Numerics.Vector2 +MessagePack.Formatters.Vector2Formatter.Serialize(ref MessagePack.MessagePackWriter writer, System.Numerics.Vector2 value, MessagePack.MessagePackSerializerOptions! options) -> void +MessagePack.Formatters.Vector3Formatter +MessagePack.Formatters.Vector3Formatter.Deserialize(ref MessagePack.MessagePackReader reader, MessagePack.MessagePackSerializerOptions! options) -> System.Numerics.Vector3 +MessagePack.Formatters.Vector3Formatter.Serialize(ref MessagePack.MessagePackWriter writer, System.Numerics.Vector3 value, MessagePack.MessagePackSerializerOptions! options) -> void +MessagePack.Formatters.Vector4Formatter +MessagePack.Formatters.Vector4Formatter.Deserialize(ref MessagePack.MessagePackReader reader, MessagePack.MessagePackSerializerOptions! options) -> System.Numerics.Vector4 +MessagePack.Formatters.Vector4Formatter.Serialize(ref MessagePack.MessagePackWriter writer, System.Numerics.Vector4 value, MessagePack.MessagePackSerializerOptions! options) -> void +MessagePack.MessagePackSerializerOptions.CompressionMinLength.get -> int +MessagePack.MessagePackSerializerOptions.SuggestedContiguousMemorySize.get -> int +MessagePack.MessagePackSerializerOptions.WithCompressionMinLength(int compressionMinLength) -> MessagePack.MessagePackSerializerOptions! +MessagePack.MessagePackSerializerOptions.WithSuggestedContiguousMemorySize(int suggestedContiguousMemorySize) -> MessagePack.MessagePackSerializerOptions! +MessagePack.Resolvers.StandardAotResolver +static MessagePack.MessagePackWriter.GetEncodedLength(long value) -> int +static MessagePack.MessagePackWriter.GetEncodedLength(ulong value) -> int +static readonly MessagePack.Formatters.DateOnlyFormatter.Instance -> MessagePack.Formatters.DateOnlyFormatter! +static readonly MessagePack.Formatters.Matrix3x2Formatter.Instance -> MessagePack.Formatters.IMessagePackFormatter! +static readonly MessagePack.Formatters.Matrix4x4Formatter.Instance -> MessagePack.Formatters.IMessagePackFormatter! +static readonly MessagePack.Formatters.QuaternionFormatter.Instance -> MessagePack.Formatters.IMessagePackFormatter! +static readonly MessagePack.Formatters.TimeOnlyFormatter.Instance -> MessagePack.Formatters.TimeOnlyFormatter! +static readonly MessagePack.Formatters.Vector2Formatter.Instance -> MessagePack.Formatters.IMessagePackFormatter! +static readonly MessagePack.Formatters.Vector3Formatter.Instance -> MessagePack.Formatters.IMessagePackFormatter! +static readonly MessagePack.Formatters.Vector4Formatter.Instance -> MessagePack.Formatters.IMessagePackFormatter! +static readonly MessagePack.Resolvers.StandardAotResolver.Instance -> MessagePack.IFormatterResolver! diff --git a/tests/MessagePack.Analyzers.Tests/MessagePack.Analyzers.Tests.csproj b/tests/MessagePack.Analyzers.Tests/MessagePack.Analyzers.Tests.csproj index 97a72dcbf..787472b3d 100644 --- a/tests/MessagePack.Analyzers.Tests/MessagePack.Analyzers.Tests.csproj +++ b/tests/MessagePack.Analyzers.Tests/MessagePack.Analyzers.Tests.csproj @@ -1,7 +1,7 @@  - net7.0 + net8.0 enable diff --git a/tests/MessagePack.AspNetCoreMvcFormatter.Tests/MessagePack.AspNetCoreMvcFormatter.Tests.csproj b/tests/MessagePack.AspNetCoreMvcFormatter.Tests/MessagePack.AspNetCoreMvcFormatter.Tests.csproj index 90fb9d667..02c44ce1c 100644 --- a/tests/MessagePack.AspNetCoreMvcFormatter.Tests/MessagePack.AspNetCoreMvcFormatter.Tests.csproj +++ b/tests/MessagePack.AspNetCoreMvcFormatter.Tests/MessagePack.AspNetCoreMvcFormatter.Tests.csproj @@ -1,7 +1,7 @@  - net6.0 + net6.0;net8.0 diff --git a/tests/MessagePack.Experimental.Tests/MessagePack.Experimental.Tests.csproj b/tests/MessagePack.Experimental.Tests/MessagePack.Experimental.Tests.csproj index 2247537ba..5a5b9fd2c 100644 --- a/tests/MessagePack.Experimental.Tests/MessagePack.Experimental.Tests.csproj +++ b/tests/MessagePack.Experimental.Tests/MessagePack.Experimental.Tests.csproj @@ -1,7 +1,7 @@ - net6.0 + net6.0;net8.0 diff --git a/tests/MessagePack.GeneratedCode.Tests/MessagePack.GeneratedCode.Tests.csproj b/tests/MessagePack.GeneratedCode.Tests/MessagePack.GeneratedCode.Tests.csproj index 4f6ce1eae..77a81045b 100644 --- a/tests/MessagePack.GeneratedCode.Tests/MessagePack.GeneratedCode.Tests.csproj +++ b/tests/MessagePack.GeneratedCode.Tests/MessagePack.GeneratedCode.Tests.csproj @@ -1,7 +1,7 @@ - net6.0 + net6.0;net8.0 diff --git a/tests/MessagePack.Internal.Tests/MessagePack.Internal.Tests.csproj b/tests/MessagePack.Internal.Tests/MessagePack.Internal.Tests.csproj index 7a148d207..c089103cf 100644 --- a/tests/MessagePack.Internal.Tests/MessagePack.Internal.Tests.csproj +++ b/tests/MessagePack.Internal.Tests/MessagePack.Internal.Tests.csproj @@ -1,6 +1,6 @@  - net6.0 + net6.0;net8.0 diff --git a/tests/MessagePack.SourceGenerator.ExecutionTests/MessagePack.SourceGenerator.ExecutionTests.csproj b/tests/MessagePack.SourceGenerator.ExecutionTests/MessagePack.SourceGenerator.ExecutionTests.csproj index 3fbe1cbb1..3d033631b 100644 --- a/tests/MessagePack.SourceGenerator.ExecutionTests/MessagePack.SourceGenerator.ExecutionTests.csproj +++ b/tests/MessagePack.SourceGenerator.ExecutionTests/MessagePack.SourceGenerator.ExecutionTests.csproj @@ -2,7 +2,7 @@ - net7.0 + net8.0 enable enable true diff --git a/tests/MessagePack.SourceGenerator.MapModeExecutionTests/MessagePack.SourceGenerator.MapModeExecutionTests.csproj b/tests/MessagePack.SourceGenerator.MapModeExecutionTests/MessagePack.SourceGenerator.MapModeExecutionTests.csproj index d9a3c0c40..77a4955a3 100644 --- a/tests/MessagePack.SourceGenerator.MapModeExecutionTests/MessagePack.SourceGenerator.MapModeExecutionTests.csproj +++ b/tests/MessagePack.SourceGenerator.MapModeExecutionTests/MessagePack.SourceGenerator.MapModeExecutionTests.csproj @@ -2,7 +2,7 @@ - net7.0 + net8.0 enable enable true diff --git a/tests/MessagePack.SourceGenerator.Tests/MessagePack.SourceGenerator.Tests.csproj b/tests/MessagePack.SourceGenerator.Tests/MessagePack.SourceGenerator.Tests.csproj index 20bb97d25..8ea134c1a 100644 --- a/tests/MessagePack.SourceGenerator.Tests/MessagePack.SourceGenerator.Tests.csproj +++ b/tests/MessagePack.SourceGenerator.Tests/MessagePack.SourceGenerator.Tests.csproj @@ -1,7 +1,7 @@  - net7.0 + net8.0 enable enable 11 diff --git a/tests/MessagePack.SourceGenerator.Unity.Tests/MessagePack.SourceGenerator.Unity.Tests.csproj b/tests/MessagePack.SourceGenerator.Unity.Tests/MessagePack.SourceGenerator.Unity.Tests.csproj index 6bbccfae3..d74a7f2e7 100644 --- a/tests/MessagePack.SourceGenerator.Unity.Tests/MessagePack.SourceGenerator.Unity.Tests.csproj +++ b/tests/MessagePack.SourceGenerator.Unity.Tests/MessagePack.SourceGenerator.Unity.Tests.csproj @@ -1,7 +1,7 @@  - net7.0 + net8.0 enable enable 11 diff --git a/tests/MessagePack.Tests/MessagePack.Tests.csproj b/tests/MessagePack.Tests/MessagePack.Tests.csproj index f66b0f2fe..9603c758a 100644 --- a/tests/MessagePack.Tests/MessagePack.Tests.csproj +++ b/tests/MessagePack.Tests/MessagePack.Tests.csproj @@ -1,6 +1,6 @@  - net6.0 + net6.0;net8.0 $(TargetFrameworks);net472 true 10 From 7fc36c9fbd7dca7f03b787f315e866451ade5638 Mon Sep 17 00:00:00 2001 From: pCYSl5EDgo Date: Wed, 10 Jan 2024 17:20:41 +0900 Subject: [PATCH 199/660] SystemException(SerializationInfo, StreamingContext) is now oboslete --- .../Assets/Scripts/MessagePack/IFormatterResolver.cs | 3 +++ .../Assets/Scripts/MessagePack/Internal/TinyJsonReader.cs | 3 +++ .../Scripts/MessagePack/MessagePackSerializationException.cs | 3 +++ .../Scripts/MessagePack/Resolvers/DynamicObjectResolver.cs | 3 +++ 4 files changed, 12 insertions(+) diff --git a/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/IFormatterResolver.cs b/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/IFormatterResolver.cs index acdd9776f..edac79905 100644 --- a/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/IFormatterResolver.cs +++ b/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/IFormatterResolver.cs @@ -122,6 +122,9 @@ public FormatterNotRegisteredException(string? message) { } +#if NET8_0_OR_GREATER + [Obsolete] +#endif protected FormatterNotRegisteredException(SerializationInfo info, StreamingContext context) : base(info, context) { diff --git a/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Internal/TinyJsonReader.cs b/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Internal/TinyJsonReader.cs index 2d082f9f7..e4ceaabfe 100644 --- a/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Internal/TinyJsonReader.cs +++ b/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Internal/TinyJsonReader.cs @@ -49,6 +49,9 @@ public TinyJsonException(string message) { } +#if NET8_0_OR_GREATER + [Obsolete] +#endif protected TinyJsonException(SerializationInfo info, StreamingContext context) : base(info, context) { diff --git a/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/MessagePackSerializationException.cs b/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/MessagePackSerializationException.cs index 730668d8a..b038d3383 100644 --- a/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/MessagePackSerializationException.cs +++ b/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/MessagePackSerializationException.cs @@ -48,6 +48,9 @@ public MessagePackSerializationException(string? message, Exception? inner) ///
/// Serialization info. /// Serialization context. +#if NET8_0_OR_GREATER + [Obsolete] +#endif protected MessagePackSerializationException( System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) diff --git a/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Resolvers/DynamicObjectResolver.cs b/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Resolvers/DynamicObjectResolver.cs index 125d0069b..e52316506 100644 --- a/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Resolvers/DynamicObjectResolver.cs +++ b/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Resolvers/DynamicObjectResolver.cs @@ -2438,6 +2438,9 @@ public InitAccessorInGenericClassNotSupportedException(string message, Exception { } +#if NET8_0_OR_GREATER + [Obsolete] +#endif protected InitAccessorInGenericClassNotSupportedException( SerializationInfo info, StreamingContext context) From 6d409ba0781cd89d2dd4269f1a17867efd09ae58 Mon Sep 17 00:00:00 2001 From: pCYSl5EDgo Date: Wed, 10 Jan 2024 17:21:05 +0900 Subject: [PATCH 200/660] fix warning: in paramter --- .../UnsafeUnmanagedStructFormatter.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/MessagePack.Experimental/UnsafeUnmanagedStructFormatter/UnsafeUnmanagedStructFormatter.cs b/src/MessagePack.Experimental/UnsafeUnmanagedStructFormatter/UnsafeUnmanagedStructFormatter.cs index 0388f5026..37a230c46 100644 --- a/src/MessagePack.Experimental/UnsafeUnmanagedStructFormatter/UnsafeUnmanagedStructFormatter.cs +++ b/src/MessagePack.Experimental/UnsafeUnmanagedStructFormatter/UnsafeUnmanagedStructFormatter.cs @@ -45,7 +45,7 @@ public T Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions var sequence = reader.ReadRaw(sizeof(T)); if (sequence.IsSingleSegment) { - return Unsafe.As(ref Unsafe.AsRef(sequence.FirstSpan[0])); + return Unsafe.As(ref Unsafe.AsRef(in sequence.FirstSpan[0])); } T answer; From 517751379fd9901aeef27a84bf589853b87b4922 Mon Sep 17 00:00:00 2001 From: pCYSl5EDgo Date: Wed, 10 Jan 2024 17:21:28 +0900 Subject: [PATCH 201/660] fix error: ref scope problem --- .../MessagePack/Internal/CodeGenHelpers.cs | 18 ++++++++++++------ .../Tests/ShareTests/MessagePackBinaryTest.cs | 12 ++++++------ 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Internal/CodeGenHelpers.cs b/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Internal/CodeGenHelpers.cs index e1f4bca81..b1b9625b3 100644 --- a/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Internal/CodeGenHelpers.cs +++ b/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Internal/CodeGenHelpers.cs @@ -88,7 +88,18 @@ public static ReadOnlySpan ReadStringSpan(ref MessagePackReader reader) { if (!reader.TryReadStringSpan(out ReadOnlySpan result)) { - return GetSpanFromSequence(reader.ReadStringSequence()); + ReadOnlySequence? sequence = reader.ReadStringSequence(); + if (sequence.HasValue) + { + if (sequence.Value.IsSingleSegment) + { + return sequence.Value.First.Span; + } + + return sequence.Value.ToArray(); + } + + return default; } return result; @@ -100,10 +111,5 @@ public static ReadOnlySpan ReadStringSpan(ref MessagePackReader reader) /// The sequence. /// The byte array or . public static byte[]? GetArrayFromNullableSequence(in ReadOnlySequence? sequence) => sequence?.ToArray(); - - private static ReadOnlySpan GetSpanFromSequence(in ReadOnlySequence? sequence) - { - return sequence.HasValue ? GetSpanFromSequence(sequence.Value) : default; - } } } diff --git a/src/MessagePack.UnityClient/Assets/Scripts/Tests/ShareTests/MessagePackBinaryTest.cs b/src/MessagePack.UnityClient/Assets/Scripts/Tests/ShareTests/MessagePackBinaryTest.cs index 78923366c..2e7a6a0ea 100644 --- a/src/MessagePack.UnityClient/Assets/Scripts/Tests/ShareTests/MessagePackBinaryTest.cs +++ b/src/MessagePack.UnityClient/Assets/Scripts/Tests/ShareTests/MessagePackBinaryTest.cs @@ -828,8 +828,8 @@ public void IntegerRangeTest() smallWriter = new MessagePackWriter(small); smallWriter.Write(ushort.MaxValue); smallWriter.Flush(); - smallReader = new MessagePackReader(small.AsReadOnlySequence); - smallReader.ReadInt32().Is(ushort.MaxValue); + var smallReader2 = new MessagePackReader(small.AsReadOnlySequence); + smallReader2.ReadInt32().Is(ushort.MaxValue); target.Reset(); targetWriter = new MessagePackWriter(target); @@ -856,8 +856,8 @@ public void IntegerRangeTest() smallWriter = new MessagePackWriter(small); smallWriter.Write(ushort.MaxValue); smallWriter.Flush(); - smallReader = new MessagePackReader(small.AsReadOnlySequence); - smallReader.ReadInt64().Is(ushort.MaxValue); + var smallReader2 = new MessagePackReader(small.AsReadOnlySequence); + smallReader2.ReadInt64().Is(ushort.MaxValue); target.Reset(); targetWriter = new MessagePackWriter(target); @@ -869,8 +869,8 @@ public void IntegerRangeTest() smallWriter = new MessagePackWriter(small); smallWriter.Write(uint.MaxValue); smallWriter.Flush(); - smallReader = new MessagePackReader(small.AsReadOnlySequence); - smallReader.ReadInt64().Is(uint.MaxValue); + var smallReader3 = new MessagePackReader(small.AsReadOnlySequence); + smallReader3.ReadInt64().Is(uint.MaxValue); target.Reset(); targetWriter = new MessagePackWriter(target); From d11f14a60b5e2397abcef18b5d319e293c561925 Mon Sep 17 00:00:00 2001 From: pCYSl5EDgo Date: Wed, 10 Jan 2024 17:45:31 +0900 Subject: [PATCH 202/660] ref readonly parameter requires C#12 --- Directory.Build.props | 1 + 1 file changed, 1 insertion(+) diff --git a/Directory.Build.props b/Directory.Build.props index 54fddd00e..56716b0ea 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -6,6 +6,7 @@ $(RepoRootPath)bin\$(MSBuildProjectName)\ $(RepoRootPath)bin\Packages\$(Configuration)\ 10 + 12 latest true true From 62619bd777ceb305b3916909ae563e599346ebb0 Mon Sep 17 00:00:00 2001 From: pCYSl5EDgo Date: Wed, 10 Jan 2024 20:49:19 +0900 Subject: [PATCH 203/660] support net80 reference assembly in roslyn testing --- Directory.Packages.props | 2 +- .../Verifiers/CSharpSourceGeneratorVerifier`1+Test.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Directory.Packages.props b/Directory.Packages.props index 95e89f25b..6ffdbfd88 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -9,7 +9,7 @@ 4.3.0 4.3.0 - 1.1.2-beta1.23163.2 + 1.1.2-beta1.23509.1 3.8.0 diff --git a/tests/MessagePack.SourceGenerator.Tests/Verifiers/CSharpSourceGeneratorVerifier`1+Test.cs b/tests/MessagePack.SourceGenerator.Tests/Verifiers/CSharpSourceGeneratorVerifier`1+Test.cs index 6509579ba..998539880 100644 --- a/tests/MessagePack.SourceGenerator.Tests/Verifiers/CSharpSourceGeneratorVerifier`1+Test.cs +++ b/tests/MessagePack.SourceGenerator.Tests/Verifiers/CSharpSourceGeneratorVerifier`1+Test.cs @@ -36,7 +36,7 @@ public Test([CallerFilePath] string? testFile = null, [CallerMemberName] string { this.CompilerDiagnostics = CompilerDiagnostics.Warnings; - this.ReferenceAssemblies = ReferenceAssemblies.Net.Net60; + this.ReferenceAssemblies = ReferenceAssemblies.Net.Net80; this.TestState.AdditionalReferences.Add(typeof(MessagePackObjectAttribute).Assembly); this.TestState.AdditionalReferences.Add(typeof(MessagePackSerializer).Assembly); From 9a5da8be0f8f9d2c2b2002f2fde064f2dc8c2644 Mon Sep 17 00:00:00 2001 From: pCYSl5EDgo Date: Wed, 10 Jan 2024 22:04:31 +0900 Subject: [PATCH 204/660] downgrade --- Directory.Packages.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Directory.Packages.props b/Directory.Packages.props index 6ffdbfd88..9df3f756d 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -71,7 +71,7 @@ - +
From 17adbee16d07501320d36615e218003668683a91 Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Wed, 10 Jan 2024 06:44:12 -0700 Subject: [PATCH 205/660] Remove unnecessary warning restore --- src/MessagePack.Analyzers/CodeAnalysis/AnalyzerOptions.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/MessagePack.Analyzers/CodeAnalysis/AnalyzerOptions.cs b/src/MessagePack.Analyzers/CodeAnalysis/AnalyzerOptions.cs index 37ff4945d..8c137d2aa 100644 --- a/src/MessagePack.Analyzers/CodeAnalysis/AnalyzerOptions.cs +++ b/src/MessagePack.Analyzers/CodeAnalysis/AnalyzerOptions.cs @@ -145,4 +145,3 @@ public record GeneratorOptions ///
public FormattersOptions Formatters { get; init; } = new(); } -#pragma warning restore SA1402 // File may only contain a single type From d05e763b73d31ad72fb8b0e0f2bfb895a1a1338e Mon Sep 17 00:00:00 2001 From: Andrew Arnott Date: Wed, 10 Jan 2024 08:46:03 -0700 Subject: [PATCH 206/660] Fix source generator within this solution --- Directory.Packages.props | 3 ++- .../CodeAnalysis/AnalyzerOptions.cs | 25 +++++++------------ tests/SourceGeneratorConsumer.props | 5 ++++ 3 files changed, 16 insertions(+), 17 deletions(-) diff --git a/Directory.Packages.props b/Directory.Packages.props index 9df3f756d..aba93fd5a 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -26,7 +26,7 @@ - + @@ -64,6 +64,7 @@ + diff --git a/src/MessagePack.Analyzers/CodeAnalysis/AnalyzerOptions.cs b/src/MessagePack.Analyzers/CodeAnalysis/AnalyzerOptions.cs index 8c137d2aa..b6a0859bb 100644 --- a/src/MessagePack.Analyzers/CodeAnalysis/AnalyzerOptions.cs +++ b/src/MessagePack.Analyzers/CodeAnalysis/AnalyzerOptions.cs @@ -42,22 +42,15 @@ public static AnalyzerOptions Parse(AnalyzerConfigOptions options, ImmutableArra if (additionalTexts.FirstOrDefault(x => string.Equals(Path.GetFileName(x.Path), JsonOptionsFileName, StringComparison.OrdinalIgnoreCase))?.GetText(cancellationToken)?.ToString() is string configJson) { - try - { - result = JsonSerializer.Deserialize( - configJson, - new JsonSerializerOptions - { - AllowTrailingCommas = true, - MaxDepth = 5, - PropertyNamingPolicy = JsonNamingPolicy.CamelCase, - ReadCommentHandling = JsonCommentHandling.Skip, - }) ?? Default; - } - catch (Exception ex) - { - System.Diagnostics.Debug.WriteLine("Can't load MessagePackAnalyzer.json: " + ex); - } + result = JsonSerializer.Deserialize( + configJson, + new JsonSerializerOptions + { + AllowTrailingCommas = true, + MaxDepth = 5, + PropertyNamingPolicy = JsonNamingPolicy.CamelCase, + ReadCommentHandling = JsonCommentHandling.Skip, + }) ?? Default; } if (result.Generator.Resolver.Namespace is null) diff --git a/tests/SourceGeneratorConsumer.props b/tests/SourceGeneratorConsumer.props index 4f43792e4..cc0af6a1b 100644 --- a/tests/SourceGeneratorConsumer.props +++ b/tests/SourceGeneratorConsumer.props @@ -15,10 +15,15 @@ + + + + + From b960fb1a501c777b8d817f3fd19003ec44de49ff Mon Sep 17 00:00:00 2001 From: pCYSl5EDgo Date: Thu, 11 Jan 2024 01:14:56 +0900 Subject: [PATCH 207/660] suppress RS1035 by .editorconfig --- .editorconfig | 3 +++ Directory.Packages.props | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/.editorconfig b/.editorconfig index 0e4bbcde8..b0b397261 100644 --- a/.editorconfig +++ b/.editorconfig @@ -171,6 +171,9 @@ csharp_prefer_braces = true:silent dotnet_diagnostic.RS0041.severity = suggestion +# RS1035: Do not use APIs banned for analyzers(such as Environment.NewLine) +dotnet_diagnostic.RS1035.severity = suggestion + # SA1130: Use lambda syntax dotnet_diagnostic.SA1130.severity = silent diff --git a/Directory.Packages.props b/Directory.Packages.props index aba93fd5a..bc598ec73 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -31,7 +31,7 @@ - + From 9754d5df937f2996c834fef357b22cd96ae8d484 Mon Sep 17 00:00:00 2001 From: pCYSl5EDgo Date: Thu, 11 Jan 2024 07:50:34 +0900 Subject: [PATCH 208/660] Update RS1035 suppression affection more scoped --- .editorconfig | 3 --- src/MessagePack.SourceGenerator/MessagePackGenerator.Emit.cs | 2 ++ src/MessagePack.SourceGenerator/Transforms/.editorconfig | 4 ++++ 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/.editorconfig b/.editorconfig index b0b397261..0e4bbcde8 100644 --- a/.editorconfig +++ b/.editorconfig @@ -171,9 +171,6 @@ csharp_prefer_braces = true:silent dotnet_diagnostic.RS0041.severity = suggestion -# RS1035: Do not use APIs banned for analyzers(such as Environment.NewLine) -dotnet_diagnostic.RS1035.severity = suggestion - # SA1130: Use lambda syntax dotnet_diagnostic.SA1130.severity = silent diff --git a/src/MessagePack.SourceGenerator/MessagePackGenerator.Emit.cs b/src/MessagePack.SourceGenerator/MessagePackGenerator.Emit.cs index f991e9545..4418028bc 100644 --- a/src/MessagePack.SourceGenerator/MessagePackGenerator.Emit.cs +++ b/src/MessagePack.SourceGenerator/MessagePackGenerator.Emit.cs @@ -10,12 +10,14 @@ namespace MessagePack.SourceGenerator; public partial class MessagePackGenerator { +#pragma warning disable RS1035 // Do not use APIs banned for analyzers private static readonly string FileHeader = """ // #pragma warning disable 618, 612, 414, 168, CS1591, SA1129, SA1309, SA1312, SA1403, SA1649 """.Replace(Environment.NewLine, "\r\n"); +#pragma warning restore RS1035 // Do not use APIs banned for analyzers /// /// Generates the specialized resolver and formatters for the types that require serialization in a given compilation. diff --git a/src/MessagePack.SourceGenerator/Transforms/.editorconfig b/src/MessagePack.SourceGenerator/Transforms/.editorconfig index e27bead64..1976b20e5 100644 --- a/src/MessagePack.SourceGenerator/Transforms/.editorconfig +++ b/src/MessagePack.SourceGenerator/Transforms/.editorconfig @@ -1,3 +1,7 @@ [*.tt] indent_size = 4 indent_style = tab + +[*.cs] +# RS1035: Do not use APIs banned for analyzers(such as Environment.NewLine) +dotnet_diagnostic.RS1035.severity = suggestion From 75a2a506b3344db049791ff58699e6fdd6d68823 Mon Sep 17 00:00:00 2001 From: pCYSl5EDgo Date: Thu, 11 Jan 2024 21:51:24 +0900 Subject: [PATCH 209/660] FrozenCollection --- .../Formatters/FrozenCollectionFormatters.cs | 157 ++++++++++++++++++ .../Resolvers/ImmutableCollectionResolver.cs | 7 + .../net8.0/PublicAPI.Unshipped.txt | 10 ++ .../ExtensionTests/FrozenCollectionTest.cs | 116 +++++++++++++ 4 files changed, 290 insertions(+) create mode 100644 src/MessagePack/Formatters/FrozenCollectionFormatters.cs create mode 100644 tests/MessagePack.Tests/ExtensionTests/FrozenCollectionTest.cs diff --git a/src/MessagePack/Formatters/FrozenCollectionFormatters.cs b/src/MessagePack/Formatters/FrozenCollectionFormatters.cs new file mode 100644 index 000000000..435f37a0e --- /dev/null +++ b/src/MessagePack/Formatters/FrozenCollectionFormatters.cs @@ -0,0 +1,157 @@ +// Copyright (c) All contributors. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +#if NET8_0_OR_GREATER + +using System.Collections.Frozen; +using System.Collections.Generic; +using MessagePack.Formatters; + +#pragma warning disable SA1402 // File may only contain a single type +#pragma warning disable SA1649 // File name should match first type name + +namespace MessagePack.ImmutableCollection +{ + public sealed class FrozenDictionaryFormatter : IMessagePackFormatter?> + where TKey : notnull + { + private readonly IEqualityComparer? comparer; + + public FrozenDictionaryFormatter() + { + comparer = default; + } + + public FrozenDictionaryFormatter(IEqualityComparer comparer) + { + this.comparer = comparer; + } + + public void Serialize(ref MessagePackWriter writer, FrozenDictionary? value, MessagePackSerializerOptions options) + { + if (value is null) + { + writer.WriteNil(); + return; + } + + IFormatterResolver resolver = options.Resolver; + IMessagePackFormatter keyFormatter = resolver.GetFormatterWithVerify(); + IMessagePackFormatter valueFormatter = resolver.GetFormatterWithVerify(); + + // https://github.com/dotnet/runtime/blob/4c500699b938d53993b928b93543b8dbe68f69aa/src/libraries/System.Collections.Immutable/src/System/Collections/Frozen/FrozenHashTable.cs#L134C2-L134C2 + // FrozenDictionary.Count uses FrozenHashTable's Count property which is O(1). + var count = value.Count; + writer.WriteMapHeader(count); + if (count == 0) + { + return; + } + + FrozenDictionary.Enumerator e = value.GetEnumerator(); + while (e.MoveNext()) + { + writer.CancellationToken.ThrowIfCancellationRequested(); + KeyValuePair item = e.Current; + keyFormatter.Serialize(ref writer, item.Key, options); + valueFormatter.Serialize(ref writer, item.Value, options); + } + } + + public FrozenDictionary? Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options) + { + if (reader.TryReadNil()) + { + return default; + } + + var count = reader.ReadMapHeader(); + if (count == 0) + { + return FrozenDictionary.Empty; + } + + IFormatterResolver resolver = options.Resolver; + IMessagePackFormatter keyFormatter = resolver.GetFormatterWithVerify(); + IMessagePackFormatter valueFormatter = resolver.GetFormatterWithVerify(); + IEqualityComparer comparer = this.comparer ?? options.Security.GetEqualityComparer(); + + // https://github.com/dotnet/runtime/blob/4c500699b938d53993b928b93543b8dbe68f69aa/src/libraries/System.Collections.Immutable/src/System/Collections/Frozen/FrozenDictionary.cs#L87 + // FrozenDictionary.ToFrozenDictionary internally allocates Dictionary object. + var dictionary = new Dictionary(count, comparer); + for (var i = 0; i < count; i++) + { + dictionary.Add(keyFormatter.Deserialize(ref reader, options), valueFormatter.Deserialize(ref reader, options)); + } + + return dictionary.ToFrozenDictionary(comparer); + } + } + + public sealed class FrozenSetFormatter : IMessagePackFormatter?> + { + private readonly IEqualityComparer? comparer; + + public FrozenSetFormatter() + { + comparer = default; + } + + public FrozenSetFormatter(IEqualityComparer comparer) + { + this.comparer = comparer; + } + + public void Serialize(ref MessagePackWriter writer, FrozenSet? value, MessagePackSerializerOptions options) + { + if (value is null) + { + writer.WriteNil(); + return; + } + + var count = value.Count; + writer.WriteArrayHeader(count); + if (count == 0) + { + return; + } + + IMessagePackFormatter formatter = options.Resolver.GetFormatterWithVerify(); + FrozenSet.Enumerator e = value.GetEnumerator(); + while (e.MoveNext()) + { + formatter.Serialize(ref writer, e.Current, options); + } + } + + public FrozenSet? Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options) + { + if (reader.TryReadNil()) + { + return default; + } + + var count = reader.ReadArrayHeader(); + if (count == 0) + { + return FrozenSet.Empty; + } + + IMessagePackFormatter formatter = options.Resolver.GetFormatterWithVerify(); + IEqualityComparer comparer = this.comparer ?? options.Security.GetEqualityComparer(); + + // https://github.com/dotnet/runtime/blob/4c500699b938d53993b928b93543b8dbe68f69aa/src/libraries/System.Collections.Immutable/src/System/Collections/Frozen/FrozenSet.cs#L41 + // FrozenSet.ToFrozenSet internally allocates HashSet object. + var set = new HashSet(count, comparer); + for (var i = 0; i < count; i++) + { + set.Add(formatter.Deserialize(ref reader, options)); + } + + return set.ToFrozenSet(comparer); + } + } +} + +#endif diff --git a/src/MessagePack/Resolvers/ImmutableCollectionResolver.cs b/src/MessagePack/Resolvers/ImmutableCollectionResolver.cs index 0f3faf285..de645990e 100644 --- a/src/MessagePack/Resolvers/ImmutableCollectionResolver.cs +++ b/src/MessagePack/Resolvers/ImmutableCollectionResolver.cs @@ -2,6 +2,9 @@ // Licensed under the MIT license. See LICENSE file in the project root for full license information. using System; +#if NET8_0_OR_GREATER +using System.Collections.Frozen; +#endif using System.Collections.Generic; using System.Collections.Immutable; using System.Reflection; @@ -52,6 +55,10 @@ internal static class ImmutableCollectionGetFormatterHelper { typeof(IImmutableQueue<>), typeof(InterfaceImmutableQueueFormatter<>) }, { typeof(IImmutableSet<>), typeof(InterfaceImmutableSetFormatter<>) }, { typeof(IImmutableStack<>), typeof(InterfaceImmutableStackFormatter<>) }, +#if NET8_0_OR_GREATER + { typeof(FrozenDictionary<,>), typeof(FrozenDictionaryFormatter<,>) }, + { typeof(FrozenSet<>), typeof(FrozenSetFormatter<>) }, +#endif }; internal static object? GetFormatter(Type t) diff --git a/src/MessagePack/net8.0/PublicAPI.Unshipped.txt b/src/MessagePack/net8.0/PublicAPI.Unshipped.txt index d7903ded6..0b60f4329 100644 --- a/src/MessagePack/net8.0/PublicAPI.Unshipped.txt +++ b/src/MessagePack/net8.0/PublicAPI.Unshipped.txt @@ -26,6 +26,16 @@ MessagePack.Formatters.Vector3Formatter.Serialize(ref MessagePack.MessagePackWri MessagePack.Formatters.Vector4Formatter MessagePack.Formatters.Vector4Formatter.Deserialize(ref MessagePack.MessagePackReader reader, MessagePack.MessagePackSerializerOptions! options) -> System.Numerics.Vector4 MessagePack.Formatters.Vector4Formatter.Serialize(ref MessagePack.MessagePackWriter writer, System.Numerics.Vector4 value, MessagePack.MessagePackSerializerOptions! options) -> void +MessagePack.ImmutableCollection.FrozenDictionaryFormatter +MessagePack.ImmutableCollection.FrozenDictionaryFormatter.FrozenDictionaryFormatter() -> void +MessagePack.ImmutableCollection.FrozenDictionaryFormatter.FrozenDictionaryFormatter(System.Collections.Generic.IEqualityComparer! comparer) -> void +MessagePack.ImmutableCollection.FrozenDictionaryFormatter.Serialize(ref MessagePack.MessagePackWriter writer, System.Collections.Frozen.FrozenDictionary? value, MessagePack.MessagePackSerializerOptions! options) -> void +MessagePack.ImmutableCollection.FrozenDictionaryFormatter.Deserialize(ref MessagePack.MessagePackReader reader, MessagePack.MessagePackSerializerOptions! options) -> System.Collections.Frozen.FrozenDictionary? +MessagePack.ImmutableCollection.FrozenSetFormatter +MessagePack.ImmutableCollection.FrozenSetFormatter.FrozenSetFormatter() -> void +MessagePack.ImmutableCollection.FrozenSetFormatter.FrozenSetFormatter(System.Collections.Generic.IEqualityComparer! comparer) -> void +MessagePack.ImmutableCollection.FrozenSetFormatter.Serialize(ref MessagePack.MessagePackWriter writer, System.Collections.Frozen.FrozenSet? value, MessagePack.MessagePackSerializerOptions! options) -> void +MessagePack.ImmutableCollection.FrozenSetFormatter.Deserialize(ref MessagePack.MessagePackReader reader, MessagePack.MessagePackSerializerOptions! options) -> System.Collections.Frozen.FrozenSet? MessagePack.MessagePackSerializerOptions.CompressionMinLength.get -> int MessagePack.MessagePackSerializerOptions.SuggestedContiguousMemorySize.get -> int MessagePack.MessagePackSerializerOptions.WithCompressionMinLength(int compressionMinLength) -> MessagePack.MessagePackSerializerOptions! diff --git a/tests/MessagePack.Tests/ExtensionTests/FrozenCollectionTest.cs b/tests/MessagePack.Tests/ExtensionTests/FrozenCollectionTest.cs new file mode 100644 index 000000000..b8a950a7e --- /dev/null +++ b/tests/MessagePack.Tests/ExtensionTests/FrozenCollectionTest.cs @@ -0,0 +1,116 @@ +// Copyright (c) All contributors. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +#if NET8_0_OR_GREATER +#nullable enable + +using System; +using System.Collections.Frozen; +using System.Collections.Generic; +using System.Runtime.InteropServices; +using Xunit; + +namespace MessagePack.Tests.ExtensionTests +{ + public class FrozenCollectionTest + { + private T Convert(T value) + { + MessagePackSerializerOptions options = MessagePackSerializerOptions.Standard; + return MessagePackSerializer.Deserialize(MessagePackSerializer.Serialize(value, options), options); + } + + [Fact] + public void EmptySet() + { + { + var empty = FrozenSet.Empty; + Convert(empty).IsStructuralEqual(empty); + } + + { + var empty = FrozenSet.Empty; + Convert(empty).IsStructuralEqual(empty); + } + + { + var empty = FrozenSet.Empty; + Convert(empty).IsStructuralEqual(empty); + } + + { + var empty = FrozenSet.Empty; + Convert(empty).IsStructuralEqual(empty); + } + } + + [Fact] + public void EmptyDictionary() + { + { + var empty = FrozenDictionary.Empty; + Convert(empty).IsStructuralEqual(empty); + } + + { + var empty = FrozenDictionary.Empty; + Convert(empty).IsStructuralEqual(empty); + } + + { + var empty = FrozenDictionary.Empty; + Convert(empty).IsStructuralEqual(empty); + } + + { + var empty = FrozenDictionary.Empty; + Convert(empty).IsStructuralEqual(empty); + } + + { + var empty = FrozenDictionary.Empty; + Convert(empty).IsStructuralEqual(empty); + } + + { + var empty = FrozenDictionary.Empty; + Convert(empty).IsStructuralEqual(empty); + } + + { + var empty = FrozenDictionary.Empty; + Convert(empty).IsStructuralEqual(empty); + } + + { + var empty = FrozenDictionary.Empty; + Convert(empty).IsStructuralEqual(empty); + } + } + + [Fact] + public void IntSet() + { + for (var i = 1; i < 11; i++) + { + var array = new int[1 << i]; + Random.Shared.NextBytes(MemoryMarshal.AsBytes(array)); + var set = array.ToFrozenSet(); + Convert(set).IsStructuralEqualIgnoreCollectionOrder(set); + } + } + + [Fact] + public void IntDictionary() + { + for (var i = 1; i < 11; i++) + { + var array = new KeyValuePair[1 << i]; + Random.Shared.NextBytes(MemoryMarshal.AsBytes>(array)); + var dictionary = array.ToFrozenDictionary(); + Convert(dictionary).IsStructuralEqualIgnoreCollectionOrder(dictionary); + } + } + } +} +#endif From 7dba99e2da7d9dcef3779c7df94fcb46046352ad Mon Sep 17 00:00:00 2001 From: pCYSl5EDgo Date: Thu, 11 Jan 2024 23:42:25 +0900 Subject: [PATCH 210/660] Add PriorityQueue --- .../Formatters/CollectionFormatter.cs | 98 +++++++++++++++++++ .../Resolvers/DynamicGenericResolver.cs | 3 + .../Tests/ShareTests/CollectionTest.cs | 3 + .../net6.0/PublicAPI.Unshipped.txt | 5 + .../net8.0/PublicAPI.Unshipped.txt | 5 + 5 files changed, 114 insertions(+) diff --git a/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Formatters/CollectionFormatter.cs b/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Formatters/CollectionFormatter.cs index 29d8ca7d7..e585e730a 100644 --- a/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Formatters/CollectionFormatter.cs +++ b/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Formatters/CollectionFormatter.cs @@ -535,6 +535,104 @@ protected override Queue Complete(Queue intermediateCollection) } } +#if NET6_0_OR_GREATER + public sealed class PriorityQueueFormatter : IMessagePackFormatter?> + { + private readonly IComparer? comparer; + + public PriorityQueueFormatter() + { + comparer = default; + } + + public PriorityQueueFormatter(IComparer? comparer) + { + this.comparer = comparer; + } + + public void Serialize(ref MessagePackWriter writer, PriorityQueue? value, MessagePackSerializerOptions options) + { + if (value is null) + { + writer.WriteNil(); + return; + } + + // https://github.com/dotnet/runtime/blob/a6bf4e4b94db9c1e28f50393e0a1943892e34bed/src/libraries/System.Collections/src/System/Collections/Generic/PriorityQueue.cs#L172 + // Count property is reading just private field _size; + var count = value.Count; + writer.WriteMapHeader(count); + if (count == 0) + { + return; + } + + IFormatterResolver resolver = options.Resolver; + IMessagePackFormatter elementFormatter = resolver.GetFormatterWithVerify(); + IMessagePackFormatter priorityFormatter = resolver.GetFormatterWithVerify(); + PriorityQueue.UnorderedItemsCollection items = value.UnorderedItems; + using PriorityQueue.UnorderedItemsCollection.Enumerator e = items.GetEnumerator(); + while (e.MoveNext()) + { + var pair = e.Current; + elementFormatter.Serialize(ref writer, pair.Element, options); + priorityFormatter.Serialize(ref writer, pair.Priority, options); + } + } + + public PriorityQueue? Deserialize(ref MessagePackReader reader, MessagePackSerializerOptions options) + { + if (reader.TryReadNil()) + { + return default; + } + + var count = reader.ReadMapHeader(); + if (count == 0) + { + return new PriorityQueue(comparer); + } + + IFormatterResolver resolver = options.Resolver; + IMessagePackFormatter elementFormatter = resolver.GetFormatterWithVerify(); + IMessagePackFormatter priorityFormatter = resolver.GetFormatterWithVerify(); + + // https://github.com/dotnet/runtime/blob/a6bf4e4b94db9c1e28f50393e0a1943892e34bed/src/libraries/System.Collections/src/System/Collections/Generic/PriorityQueue.cs#L160C22-L160C47 + // EnumerableHelpers.ToArray is called for IEnumerable>. + var sharedBuffer = ArrayPool>.Shared.Rent(count); + try + { + if (sharedBuffer.Length == count) + { + for (var i = 0; i < sharedBuffer.Length; i++) + { + sharedBuffer[i].Item1 = elementFormatter.Deserialize(ref reader, options); + sharedBuffer[i].Item2 = priorityFormatter.Deserialize(ref reader, options); + } + + return new PriorityQueue(sharedBuffer, comparer); + } + else + { + var segment = new ArraySegment>(sharedBuffer, 0, count); + var span = segment.AsSpan(); + for (var i = 0; i < span.Length; i++) + { + span[i].Item1 = elementFormatter.Deserialize(ref reader, options); + span[i].Item2 = priorityFormatter.Deserialize(ref reader, options); + } + + return new PriorityQueue(segment, comparer); + } + } + finally + { + ArrayPool>.Shared.Return(sharedBuffer); + } + } + } +#endif + // should deserialize reverse order. public sealed class StackFormatter : CollectionFormatterBase.Enumerator, Stack> { diff --git a/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Resolvers/DynamicGenericResolver.cs b/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Resolvers/DynamicGenericResolver.cs index d3b9d0b02..7a2fa59b2 100644 --- a/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Resolvers/DynamicGenericResolver.cs +++ b/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Resolvers/DynamicGenericResolver.cs @@ -54,6 +54,9 @@ internal static class DynamicGenericResolverGetFormatterHelper { typeof(List<>), typeof(ListFormatter<>) }, { typeof(LinkedList<>), typeof(LinkedListFormatter<>) }, { typeof(Queue<>), typeof(QueueFormatter<>) }, +#if NET6_0_OR_GREATER + { typeof(PriorityQueue<,>), typeof(PriorityQueueFormatter<,>) }, +#endif { typeof(Stack<>), typeof(StackFormatter<>) }, { typeof(HashSet<>), typeof(HashSetFormatter<>) }, { typeof(ReadOnlyCollection<>), typeof(ReadOnlyCollectionFormatter<>) }, diff --git a/src/MessagePack.UnityClient/Assets/Scripts/Tests/ShareTests/CollectionTest.cs b/src/MessagePack.UnityClient/Assets/Scripts/Tests/ShareTests/CollectionTest.cs index dd880ca39..ade9561ad 100644 --- a/src/MessagePack.UnityClient/Assets/Scripts/Tests/ShareTests/CollectionTest.cs +++ b/src/MessagePack.UnityClient/Assets/Scripts/Tests/ShareTests/CollectionTest.cs @@ -31,6 +31,9 @@ private T Convert(T value) new object[] { new ReadOnlyCollection(new[] { 1, 10, 100 }), null }, new object[] { new ObservableCollection(new[] { 1, 10, 100 }), null }, new object[] { new ReadOnlyObservableCollection(new ObservableCollection(new[] { 1, 10, 100 })), null }, +#if NET6_0_OR_GREATER + new object[] { new PriorityQueue(new[] { ("1", 1), ("10", 10), ("100", 100) }), null }, +#endif }; [Theory] diff --git a/src/MessagePack/net6.0/PublicAPI.Unshipped.txt b/src/MessagePack/net6.0/PublicAPI.Unshipped.txt index d7903ded6..526d348e7 100644 --- a/src/MessagePack/net6.0/PublicAPI.Unshipped.txt +++ b/src/MessagePack/net6.0/PublicAPI.Unshipped.txt @@ -7,6 +7,11 @@ MessagePack.Formatters.Matrix3x2Formatter.Serialize(ref MessagePack.MessagePackW MessagePack.Formatters.Matrix4x4Formatter MessagePack.Formatters.Matrix4x4Formatter.Deserialize(ref MessagePack.MessagePackReader reader, MessagePack.MessagePackSerializerOptions! options) -> System.Numerics.Matrix4x4 MessagePack.Formatters.Matrix4x4Formatter.Serialize(ref MessagePack.MessagePackWriter writer, System.Numerics.Matrix4x4 value, MessagePack.MessagePackSerializerOptions! options) -> void +MessagePack.Formatters.PriorityQueueFormatter +MessagePack.Formatters.PriorityQueueFormatter.PriorityQueueFormatter() -> void +MessagePack.Formatters.PriorityQueueFormatter.PriorityQueueFormatter(System.Collections.Generic.IComparer? comparer) -> void +MessagePack.Formatters.PriorityQueueFormatter.Serialize(ref MessagePack.MessagePackWriter writer, System.Collections.Generic.PriorityQueue? value, MessagePack.MessagePackSerializerOptions! options) -> void +MessagePack.Formatters.PriorityQueueFormatter.Deserialize(ref MessagePack.MessagePackReader reader, MessagePack.MessagePackSerializerOptions! options) -> System.Collections.Generic.PriorityQueue? MessagePack.Formatters.QuaternionFormatter MessagePack.Formatters.QuaternionFormatter.Deserialize(ref MessagePack.MessagePackReader reader, MessagePack.MessagePackSerializerOptions! options) -> System.Numerics.Quaternion MessagePack.Formatters.QuaternionFormatter.Serialize(ref MessagePack.MessagePackWriter writer, System.Numerics.Quaternion value, MessagePack.MessagePackSerializerOptions! options) -> void diff --git a/src/MessagePack/net8.0/PublicAPI.Unshipped.txt b/src/MessagePack/net8.0/PublicAPI.Unshipped.txt index d7903ded6..526d348e7 100644 --- a/src/MessagePack/net8.0/PublicAPI.Unshipped.txt +++ b/src/MessagePack/net8.0/PublicAPI.Unshipped.txt @@ -7,6 +7,11 @@ MessagePack.Formatters.Matrix3x2Formatter.Serialize(ref MessagePack.MessagePackW MessagePack.Formatters.Matrix4x4Formatter MessagePack.Formatters.Matrix4x4Formatter.Deserialize(ref MessagePack.MessagePackReader reader, MessagePack.MessagePackSerializerOptions! options) -> System.Numerics.Matrix4x4 MessagePack.Formatters.Matrix4x4Formatter.Serialize(ref MessagePack.MessagePackWriter writer, System.Numerics.Matrix4x4 value, MessagePack.MessagePackSerializerOptions! options) -> void +MessagePack.Formatters.PriorityQueueFormatter +MessagePack.Formatters.PriorityQueueFormatter.PriorityQueueFormatter() -> void +MessagePack.Formatters.PriorityQueueFormatter.PriorityQueueFormatter(System.Collections.Generic.IComparer? comparer) -> void +MessagePack.Formatters.PriorityQueueFormatter.Serialize(ref MessagePack.MessagePackWriter writer, System.Collections.Generic.PriorityQueue? value, MessagePack.MessagePackSerializerOptions! options) -> void +MessagePack.Formatters.PriorityQueueFormatter.Deserialize(ref MessagePack.MessagePackReader reader, MessagePack.MessagePackSerializerOptions! options) -> System.Collections.Generic.PriorityQueue? MessagePack.Formatters.QuaternionFormatter MessagePack.Formatters.QuaternionFormatter.Deserialize(ref MessagePack.MessagePackReader reader, MessagePack.MessagePackSerializerOptions! options) -> System.Numerics.Quaternion MessagePack.Formatters.QuaternionFormatter.Serialize(ref MessagePack.MessagePackWriter writer, System.Numerics.Quaternion value, MessagePack.MessagePackSerializerOptions! options) -> void From 5c706ebf39e24bd5f43f3c3a3f49fee840af8651 Mon Sep 17 00:00:00 2001 From: pCYSl5EDgo Date: Fri, 12 Jan 2024 00:09:22 +0900 Subject: [PATCH 211/660] Fix: add secutiry DepthStep --- src/MessagePack/Formatters/FrozenCollectionFormatters.cs | 4 +++- src/MessagePack/net8.0/PublicAPI.Unshipped.txt | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/MessagePack/Formatters/FrozenCollectionFormatters.cs b/src/MessagePack/Formatters/FrozenCollectionFormatters.cs index 435f37a0e..ba7f9602c 100644 --- a/src/MessagePack/Formatters/FrozenCollectionFormatters.cs +++ b/src/MessagePack/Formatters/FrozenCollectionFormatters.cs @@ -22,7 +22,7 @@ public FrozenDictionaryFormatter() comparer = default; } - public FrozenDictionaryFormatter(IEqualityComparer comparer) + public FrozenDictionaryFormatter(IEqualityComparer? comparer) { this.comparer = comparer; } @@ -71,6 +71,7 @@ public void Serialize(ref MessagePackWriter writer, FrozenDictionary.Empty; } + options.Security.DepthStep(ref reader); IFormatterResolver resolver = options.Resolver; IMessagePackFormatter keyFormatter = resolver.GetFormatterWithVerify(); IMessagePackFormatter valueFormatter = resolver.GetFormatterWithVerify(); @@ -81,6 +82,7 @@ public void Serialize(ref MessagePackWriter writer, FrozenDictionary(count, comparer); for (var i = 0; i < count; i++) { + reader.CancellationToken.ThrowIfCancellationRequested(); dictionary.Add(keyFormatter.Deserialize(ref reader, options), valueFormatter.Deserialize(ref reader, options)); } diff --git a/src/MessagePack/net8.0/PublicAPI.Unshipped.txt b/src/MessagePack/net8.0/PublicAPI.Unshipped.txt index 0b60f4329..c3c792ffc 100644 --- a/src/MessagePack/net8.0/PublicAPI.Unshipped.txt +++ b/src/MessagePack/net8.0/PublicAPI.Unshipped.txt @@ -28,7 +28,7 @@ MessagePack.Formatters.Vector4Formatter.Deserialize(ref MessagePack.MessagePackR MessagePack.Formatters.Vector4Formatter.Serialize(ref MessagePack.MessagePackWriter writer, System.Numerics.Vector4 value, MessagePack.MessagePackSerializerOptions! options) -> void MessagePack.ImmutableCollection.FrozenDictionaryFormatter MessagePack.ImmutableCollection.FrozenDictionaryFormatter.FrozenDictionaryFormatter() -> void -MessagePack.ImmutableCollection.FrozenDictionaryFormatter.FrozenDictionaryFormatter(System.Collections.Generic.IEqualityComparer! comparer) -> void +MessagePack.ImmutableCollection.FrozenDictionaryFormatter.FrozenDictionaryFormatter(System.Collections.Generic.IEqualityComparer? comparer) -> void MessagePack.ImmutableCollection.FrozenDictionaryFormatter.Serialize(ref MessagePack.MessagePackWriter writer, System.Collections.Frozen.FrozenDictionary? value, MessagePack.MessagePackSerializerOptions! options) -> void MessagePack.ImmutableCollection.FrozenDictionaryFormatter.Deserialize(ref MessagePack.MessagePackReader reader, MessagePack.MessagePackSerializerOptions! options) -> System.Collections.Frozen.FrozenDictionary? MessagePack.ImmutableCollection.FrozenSetFormatter From faa0435677fa42a5d60f4e171a37fb4aff9fdd15 Mon Sep 17 00:00:00 2001 From: pCYSl5EDgo Date: Fri, 12 Jan 2024 00:11:14 +0900 Subject: [PATCH 212/660] Fix: security DepthStep --- .../Scripts/MessagePack/Formatters/CollectionFormatter.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Formatters/CollectionFormatter.cs b/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Formatters/CollectionFormatter.cs index e585e730a..0f06e853c 100644 --- a/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Formatters/CollectionFormatter.cs +++ b/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Formatters/CollectionFormatter.cs @@ -574,6 +574,7 @@ public void Serialize(ref MessagePackWriter writer, PriorityQueue.UnorderedItemsCollection.Enumerator e = items.GetEnumerator(); while (e.MoveNext()) { + writer.CancellationToken.ThrowIfCancellationRequested(); var pair = e.Current; elementFormatter.Serialize(ref writer, pair.Element, options); priorityFormatter.Serialize(ref writer, pair.Priority, options); @@ -593,6 +594,7 @@ public void Serialize(ref MessagePackWriter writer, PriorityQueue(comparer); } + options.Security.DepthStep(ref reader); IFormatterResolver resolver = options.Resolver; IMessagePackFormatter elementFormatter = resolver.GetFormatterWithVerify(); IMessagePackFormatter priorityFormatter = resolver.GetFormatterWithVerify(); @@ -606,6 +608,7 @@ public void Serialize(ref MessagePackWriter writer, PriorityQueue Date: Fri, 12 Jan 2024 00:19:58 +0900 Subject: [PATCH 213/660] Update: List with CollectionsMarshal --- .../Formatters/CollectionFormatter.cs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Formatters/CollectionFormatter.cs b/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Formatters/CollectionFormatter.cs index 29d8ca7d7..a76fe02e8 100644 --- a/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Formatters/CollectionFormatter.cs +++ b/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Formatters/CollectionFormatter.cs @@ -263,11 +263,20 @@ public void Serialize(ref MessagePackWriter writer, List? value, MessagePackS var c = value.Count; writer.WriteArrayHeader(c); +#if NET6_0_OR_GREATER + var span = CollectionsMarshal.AsSpan(value); + for (int i = 0; i < span.Length; i++) + { + writer.CancellationToken.ThrowIfCancellationRequested(); + formatter.Serialize(ref writer, span[i], options); + } +#else for (int i = 0; i < c; i++) { writer.CancellationToken.ThrowIfCancellationRequested(); formatter.Serialize(ref writer, value[i], options); } +#endif } } @@ -286,11 +295,21 @@ public void Serialize(ref MessagePackWriter writer, List? value, MessagePackS options.Security.DepthStep(ref reader); try { +#if NET8_0_OR_GREATER + CollectionsMarshal.SetCount(list, len); + var span = CollectionsMarshal.AsSpan(list); + for (int i = 0; i < span.Length; i++) + { + reader.CancellationToken.ThrowIfCancellationRequested(); + span[i] = formatter.Deserialize(ref reader, options); + } +#else for (int i = 0; i < len; i++) { reader.CancellationToken.ThrowIfCancellationRequested(); list.Add(formatter.Deserialize(ref reader, options)); } +#endif } finally { From 21e76ebc09af7efed63fb5c2fa67afccadea2dbc Mon Sep 17 00:00:00 2001 From: pCYSl5EDgo Date: Fri, 12 Jan 2024 00:22:06 +0900 Subject: [PATCH 214/660] Fix DepthStep and recovery --- .../Formatters/FrozenCollectionFormatters.cs | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/MessagePack/Formatters/FrozenCollectionFormatters.cs b/src/MessagePack/Formatters/FrozenCollectionFormatters.cs index ba7f9602c..96b046462 100644 --- a/src/MessagePack/Formatters/FrozenCollectionFormatters.cs +++ b/src/MessagePack/Formatters/FrozenCollectionFormatters.cs @@ -71,7 +71,6 @@ public void Serialize(ref MessagePackWriter writer, FrozenDictionary.Empty; } - options.Security.DepthStep(ref reader); IFormatterResolver resolver = options.Resolver; IMessagePackFormatter keyFormatter = resolver.GetFormatterWithVerify(); IMessagePackFormatter valueFormatter = resolver.GetFormatterWithVerify(); @@ -80,10 +79,18 @@ public void Serialize(ref MessagePackWriter writer, FrozenDictionary object. var dictionary = new Dictionary(count, comparer); - for (var i = 0; i < count; i++) + options.Security.DepthStep(ref reader); + try + { + for (var i = 0; i < count; i++) + { + reader.CancellationToken.ThrowIfCancellationRequested(); + dictionary.Add(keyFormatter.Deserialize(ref reader, options), valueFormatter.Deserialize(ref reader, options)); + } + } + finally { - reader.CancellationToken.ThrowIfCancellationRequested(); - dictionary.Add(keyFormatter.Deserialize(ref reader, options), valueFormatter.Deserialize(ref reader, options)); + reader.Depth--; } return dictionary.ToFrozenDictionary(comparer); From fd5e5740f811540d7e3a2f87610872bc53fcb878 Mon Sep 17 00:00:00 2001 From: pCYSl5EDgo Date: Fri, 12 Jan 2024 00:26:45 +0900 Subject: [PATCH 215/660] Fix DepthStep --- .../Formatters/CollectionFormatter.cs | 44 +++++++++++-------- 1 file changed, 26 insertions(+), 18 deletions(-) diff --git a/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Formatters/CollectionFormatter.cs b/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Formatters/CollectionFormatter.cs index 0f06e853c..9483c8480 100644 --- a/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Formatters/CollectionFormatter.cs +++ b/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Formatters/CollectionFormatter.cs @@ -594,7 +594,6 @@ public void Serialize(ref MessagePackWriter writer, PriorityQueue(comparer); } - options.Security.DepthStep(ref reader); IFormatterResolver resolver = options.Resolver; IMessagePackFormatter elementFormatter = resolver.GetFormatterWithVerify(); IMessagePackFormatter priorityFormatter = resolver.GetFormatterWithVerify(); @@ -604,29 +603,38 @@ public void Serialize(ref MessagePackWriter writer, PriorityQueue>.Shared.Rent(count); try { - if (sharedBuffer.Length == count) + options.Security.DepthStep(ref reader); + try { - for (var i = 0; i < sharedBuffer.Length; i++) + if (sharedBuffer.Length == count) { - reader.CancellationToken.ThrowIfCancellationRequested(); - sharedBuffer[i].Item1 = elementFormatter.Deserialize(ref reader, options); - sharedBuffer[i].Item2 = priorityFormatter.Deserialize(ref reader, options); + for (var i = 0; i < sharedBuffer.Length; i++) + { + reader.CancellationToken.ThrowIfCancellationRequested(); + sharedBuffer[i].Item1 = elementFormatter.Deserialize(ref reader, options); + sharedBuffer[i].Item2 = priorityFormatter.Deserialize(ref reader, options); + } + + return new PriorityQueue(sharedBuffer, comparer); } + else + { + var segment = new ArraySegment>(sharedBuffer, 0, count); + var span = segment.AsSpan(); + for (var i = 0; i < span.Length; i++) + { + reader.CancellationToken.ThrowIfCancellationRequested(); + span[i].Item1 = elementFormatter.Deserialize(ref reader, options); + span[i].Item2 = priorityFormatter.Deserialize(ref reader, options); + } - return new PriorityQueue(sharedBuffer, comparer); + // This constructor box segment. List> instead? + return new PriorityQueue(segment, comparer); + } } - else + finally { - var segment = new ArraySegment>(sharedBuffer, 0, count); - var span = segment.AsSpan(); - for (var i = 0; i < span.Length; i++) - { - reader.CancellationToken.ThrowIfCancellationRequested(); - span[i].Item1 = elementFormatter.Deserialize(ref reader, options); - span[i].Item2 = priorityFormatter.Deserialize(ref reader, options); - } - - return new PriorityQueue(segment, comparer); + reader.Depth--; } } finally From 104130e9a9285bffa255c8df121986b7f36ac107 Mon Sep 17 00:00:00 2001 From: neuecc Date: Fri, 12 Jan 2024 18:43:27 +0900 Subject: [PATCH 216/660] cleanup structure --- .../Debug/netstandard2.0/package.json | 12 + .../Debug/netstandard2.0/package.json.meta | 4 +- src/AssemblyInfo.cs | 1 + .../Attributes.cs | 2 +- ...essagePackSerializationCallbackReceiver.cs | 0 .../MessagePack.Annotations.csproj | 4 - .../MessagePack.SourceGenerator.Unity.csproj | 6 +- .../MessagePack.SourceGenerator.csproj | 6 +- .../Assets/NuGet.config | 16 + .../Assets/NuGet.config.meta | 23 + .../Assets/{Plugins.meta => Packages.meta} | 2 +- .../Microsoft.Bcl.AsyncInterfaces.6.0.0.meta} | 2 +- .../.signature.p7s | Bin 0 -> 18702 bytes .../Icon.png | Bin 0 -> 7006 bytes .../Icon.png.meta | 123 + .../LICENSE.TXT | 23 + .../LICENSE.TXT.meta} | 2 +- .../Microsoft.Bcl.AsyncInterfaces.nuspec | 31 + .../Microsoft.Bcl.AsyncInterfaces.nuspec.meta | 7 + .../THIRD-PARTY-NOTICES.TXT | 939 +++ .../THIRD-PARTY-NOTICES.TXT.meta} | 4 +- .../lib.meta} | 2 +- .../lib/net461.meta} | 2 +- .../net461/Microsoft.Bcl.AsyncInterfaces.dll | Bin 0 -> 22144 bytes .../Microsoft.Bcl.AsyncInterfaces.dll.meta | 23 + .../net461/Microsoft.Bcl.AsyncInterfaces.xml | 223 + .../Microsoft.Bcl.AsyncInterfaces.xml.meta | 7 + .../useSharedDesignerContext.txt | 0 .../useSharedDesignerContext.txt.meta | 7 + .../Microsoft.NET.StringTools.17.6.3.meta | 8 + .../.signature.p7s | Bin 0 -> 22799 bytes .../MSBuild-NuGet-Icon.png | Bin 0 -> 7006 bytes .../MSBuild-NuGet-Icon.png.meta | 123 + .../Microsoft.NET.StringTools.nuspec | 32 + .../Microsoft.NET.StringTools.nuspec.meta | 7 + .../README.md | 5 + .../README.md.meta | 7 + .../Microsoft.NET.StringTools.17.6.3/lib.meta | 8 + .../lib/net472.meta | 8 + .../lib/net472/Microsoft.NET.StringTools.dll | Bin 0 -> 30336 bytes .../net472/Microsoft.NET.StringTools.dll.meta | 23 + .../lib/net472/Microsoft.NET.StringTools.xml | 492 ++ .../net472/Microsoft.NET.StringTools.xml.meta | 7 + .../notices.meta | 8 + .../notices/THIRDPARTYNOTICES.txt | 46 + .../notices/THIRDPARTYNOTICES.txt.meta | 7 + .../System.Collections.Immutable.6.0.0.meta | 8 + .../.signature.p7s | Bin 0 -> 18702 bytes .../Icon.png | Bin 0 -> 7006 bytes .../Icon.png.meta | 123 + .../LICENSE.TXT | 23 + .../LICENSE.TXT.meta | 7 + .../System.Collections.Immutable.nuspec | 48 + .../System.Collections.Immutable.nuspec.meta | 7 + .../THIRD-PARTY-NOTICES.TXT | 939 +++ .../THIRD-PARTY-NOTICES.TXT.meta | 7 + .../buildTransitive.meta | 8 + .../buildTransitive/netcoreapp2.0.meta | 8 + .../System.Collections.Immutable.targets | 6 + .../System.Collections.Immutable.targets.meta | 7 + .../buildTransitive/netcoreapp3.1.meta | 8 + .../buildTransitive/netcoreapp3.1/_._ | 0 .../buildTransitive/netcoreapp3.1/_._.meta | 7 + .../lib.meta | 8 + .../lib/net461.meta | 8 + .../net461/System.Collections.Immutable.dll | Bin 0 -> 193664 bytes .../System.Collections.Immutable.dll.meta | 23 + .../net461/System.Collections.Immutable.xml | 5380 +++++++++++++++++ .../System.Collections.Immutable.xml.meta | 7 + .../useSharedDesignerContext.txt | 0 .../useSharedDesignerContext.txt.meta | 7 + ...Runtime.CompilerServices.Unsafe.6.0.0.meta | 8 + .../.signature.p7s | Bin 0 -> 18703 bytes .../Icon.png | Bin 0 -> 7006 bytes .../Icon.png.meta | 123 + .../LICENSE.TXT | 23 + .../LICENSE.TXT.meta | 7 + ...tem.Runtime.CompilerServices.Unsafe.nuspec | 29 + ...untime.CompilerServices.Unsafe.nuspec.meta | 7 + .../THIRD-PARTY-NOTICES.TXT | 939 +++ .../THIRD-PARTY-NOTICES.TXT.meta | 7 + .../buildTransitive.meta | 8 + .../buildTransitive/netcoreapp2.0.meta | 8 + ...em.Runtime.CompilerServices.Unsafe.targets | 6 + ...ntime.CompilerServices.Unsafe.targets.meta | 7 + .../buildTransitive/netcoreapp3.1.meta | 8 + .../buildTransitive/netcoreapp3.1/_._ | 0 .../buildTransitive/netcoreapp3.1/_._.meta | 7 + .../lib.meta | 8 + .../lib/net461.meta | 8 + ...System.Runtime.CompilerServices.Unsafe.dll | Bin 0 -> 18024 bytes ...m.Runtime.CompilerServices.Unsafe.dll.meta | 23 + ...System.Runtime.CompilerServices.Unsafe.xml | 291 + ...m.Runtime.CompilerServices.Unsafe.xml.meta | 7 + .../useSharedDesignerContext.txt | 0 .../useSharedDesignerContext.txt.meta | 7 + .../Editor/HierarchyTreeBuilder.cs | 133 - .../Editor/HierarchyTreeBuilder.cs.meta | 11 - .../Editor/UnitTestBuilder.MenuItems.cs | 345 -- .../Editor/UnitTestBuilder.MenuItems.cs.meta | 11 - .../Editor/UnitTestBuilder.cs | 552 -- .../Editor/UnitTestBuilder.cs.meta | 12 - .../RuntimeUnitTestToolkit.asmdef | 16 - .../RuntimeUnitTestToolkit/UnitTestData.cs | 391 -- .../UnitTestData.cs.meta | 11 - .../RuntimeUnitTestToolkit/UnitTestRunner.cs | 450 -- .../UnitTestRunner.cs.meta | 12 - .../RuntimeUnitTestToolkit/package.json | 11 - .../Assets/Scenes/Sandbox.unity | 29 +- .../Assets/Scenes/SandboxSettings.lighting | 64 + .../Scenes/SandboxSettings.lighting.meta | 8 + .../Assets/Scripts/Editor/PackageExporter.cs | 41 - .../Scripts/Editor/PackageExporter.cs.meta | 11 - .../Scripts/MessagePack/Annotations.meta | 8 - .../Annotations/Attributes.cs.meta | 11 - ...ePackSerializationCallbackReceiver.cs.meta | 11 - .../MessagePack.Annotations.asmdef | 3 - .../Scripts/MessagePack/BitOperations.cs.meta | 11 - .../Scripts/MessagePack/BufferWriter.cs.meta | 11 - .../MessagePack/ExtensionHeader.cs.meta | 11 - .../MessagePack/ExtensionResult.cs.meta | 11 - .../Scripts/MessagePack/Formatters.meta | 8 - .../Formatters/CollectionFormatter.cs.meta | 11 - .../Formatters/CollectionHelpers`2.cs.meta | 11 - .../Formatters/DateTimeFormatters.cs.meta | 11 - .../Formatters/DictionaryFormatter.cs.meta | 11 - ...DynamicObjectTypeFallbackFormatter.cs.meta | 11 - .../EnumAsStringFormatter`1.cs.meta | 11 - .../Formatters/ExpandoObjectFormatter.cs.meta | 11 - .../Formatters/GenericEnumFormatter`1.cs.meta | 11 - .../IMessagePackFormatter`1.cs.meta | 11 - .../Formatters/IgnoreFormatter`1.cs.meta | 11 - .../MultiDimensionalArrayFormatter.cs.meta | 11 - .../Formatters/NilFormatter.cs.meta | 11 - .../Formatters/NullableFormatter.cs.meta | 11 - .../PrimitiveObjectFormatter.cs.meta | 11 - .../StandardClassLibraryFormatter.cs.meta | 11 - .../StringInterningFormatter.cs.meta | 11 - .../Formatters/TypelessFormatter.cs.meta | 11 - .../Formatters/UnsafeBinaryFormatters.cs.meta | 11 - .../Scripts/MessagePack/HashCode.cs.meta | 11 - .../MessagePack/IFormatterResolver.cs.meta | 11 - .../Assets/Scripts/MessagePack/Internal.meta | 8 - .../Internal/AsymmetricKeyHashTable.cs.meta | 11 - .../Internal/AutomataDictionary.cs.meta | 11 - .../Internal/AutomataKeyGen.cs.meta | 11 - .../Internal/ByteArrayStringHashTable.cs.meta | 11 - .../Internal/CodeGenHelpers.cs.meta | 11 - .../Internal/DateTimeConstants.cs.meta | 11 - .../Internal/DynamicAssembly.cs.meta | 11 - .../Internal/ExpressionUtility.cs.meta | 11 - .../MessagePack/Internal/FarmHash.cs.meta | 11 - .../MessagePack/Internal/GuidBits.cs.meta | 11 - .../Internal/ILGeneratorExtensions.cs.meta | 11 - .../Internal/ReflectionExtensions.cs.meta | 11 - .../RuntimeTypeHandleEqualityComparer.cs.meta | 11 - .../ThreadsafeTypeKeyHashTable.cs.meta | 11 - .../Internal/TinyJsonReader.cs.meta | 11 - .../Internal/UnsafeMemory.Low.cs.meta | 11 - .../Assets/Scripts/MessagePack/LZ4.meta | 8 - .../MessagePack/LZ4/LZ4Codec.Helper.cs.meta | 11 - .../MessagePack/LZ4/LZ4Codec.Safe.cs.meta | 11 - .../LZ4/LZ4Codec.Safe32.Dirty.cs.meta | 11 - .../LZ4/LZ4Codec.Safe64.Dirty.cs.meta | 11 - .../MessagePack/LZ4/LZ4Codec.Unsafe.cs.meta | 11 - .../LZ4/LZ4Codec.Unsafe32.Dirty.cs.meta | 11 - .../LZ4/LZ4Codec.Unsafe64.Dirty.cs.meta | 11 - .../Scripts/MessagePack/LZ4/LZ4Codec.cs.meta | 11 - .../MessagePack/MessagePack.Unity.asmdef | 18 + ...def.meta => MessagePack.Unity.asmdef.meta} | 2 +- .../Scripts/MessagePack/MessagePack.asmdef | 22 - .../MessagePack/MessagePackCode.cs.meta | 11 - .../MessagePackCompression.cs.meta | 11 - .../MessagePack/MessagePackReader.cs.meta | 11 - .../MessagePack/MessagePackSecurity.cs.meta | 11 - .../MessagePackSerializationException.cs.meta | 11 - .../MessagePackSerializer.Json.cs.meta | 11 - .../MessagePackSerializer.NonGeneric.cs.meta | 11 - .../MessagePack/MessagePackSerializer.cs.meta | 11 - .../MessagePackSerializerOptions.cs.meta | 11 - .../MessagePackStreamReader.cs.meta | 11 - .../MessagePack/MessagePackWriter.cs.meta | 11 - .../MessagePack/MonoProtection.cs.meta | 10 - .../Assets/Scripts/MessagePack/Nil.cs.meta | 11 - .../Assets/Scripts/MessagePack/Resolvers.meta | 8 - .../AttributeFormatterResolver.cs.meta | 11 - .../Resolvers/BuiltinResolver.cs.meta | 11 - .../CachingFormatterResolver.cs.meta | 11 - .../Resolvers/CompositeResolver.cs.meta | 11 - ...ntractlessReflectionObjectResolver.cs.meta | 11 - .../DynamicEnumAsStringResolver.cs.meta | 11 - .../Resolvers/DynamicEnumResolver.cs.meta | 11 - .../Resolvers/DynamicGenericResolver.cs.meta | 11 - .../Resolvers/DynamicObjectResolver.cs.meta | 11 - .../Resolvers/DynamicUnionResolver.cs.meta | 11 - .../Resolvers/ExpandoObjectResolver.cs.meta | 11 - .../Resolvers/NativeDateTimeResolver.cs.meta | 11 - .../Resolvers/NativeDecimalResolver.cs.meta | 11 - .../Resolvers/NativeGuidResolver.cs.meta | 11 - .../Resolvers/PrimitiveObjectResolver.cs.meta | 11 - .../Resolvers/ResolverUtilities.cs.meta | 11 - .../Resolvers/StandardResolver.cs.meta | 11 - .../Resolvers/StaticCompositeResolver.cs.meta | 11 - ...pelessContractlessStandardResolver.cs.meta | 11 - .../Resolvers/TypelessObjectResolver.cs.meta | 11 - .../MessagePack/SafeBitConverter.cs.meta | 11 - .../Scripts/MessagePack/SequencePool.cs.meta | 11 - .../MessagePack/SequenceReader.cs.meta | 11 - .../SequenceReaderExtensions.cs.meta | 11 - .../StreamPolyfillExtensions.cs.meta | 11 - .../MessagePack/StringEncoding.cs.meta | 11 - .../Assets/Scripts/MessagePack/T4.meta | 8 - .../T4/ForceSizePrimitiveFormatter.cs | 817 --- .../T4/ForceSizePrimitiveFormatter.cs.meta | 11 - .../T4/MessagePackReader.Integers.cs | 440 -- .../T4/MessagePackReader.Integers.cs.meta | 11 - .../MessagePack/T4/PrimitiveFormatter.cs | 1254 ---- .../MessagePack/T4/PrimitiveFormatter.cs.meta | 11 - .../Scripts/MessagePack/T4/TupleFormatter.cs | 447 -- .../MessagePack/T4/TupleFormatter.cs.meta | 11 - .../Scripts/MessagePack/T4/UnsafeMemory.cs | 903 --- .../MessagePack/T4/UnsafeMemory.cs.meta | 11 - .../MessagePack/T4/ValueTupleFormatter.cs | 391 -- .../T4/ValueTupleFormatter.cs.meta | 11 - .../Assets/Scripts/MessagePack/Unity.meta | 2 +- .../Unity/Extension/UnityBlitResolver.cs | 1 + .../Unity/Extension/UnsafeBlitFormatter.cs | 1 + .../Scripts/MessagePack/Unity/Formatters.cs | 1 + .../ThisLibraryExtensionTypeCodes.cs | 0 .../ThisLibraryExtensionTypeCodes.cs.meta | 2 +- .../MessagePack/Unity/UnityResolver.cs | 3 +- .../Scripts/MessagePack/Utilities.cs.meta | 11 - .../Scripts/MessagePack/_InternalVisibleTo.cs | 10 - .../MessagePack/_InternalVisibleTo.cs.meta | 11 - .../Scripts/MessagePack/package.json.meta | 2 +- .../Internal => Tests}/Sequence`1.cs | 0 .../Internal => Tests}/Sequence`1.cs.meta | 2 +- .../Assets/Scripts/Tests/Tests.asmdef | 14 +- .../Assets/Scripts/Tests/csc.rsp.meta | 7 + .../Assets/packages.config | 7 + .../Assets/packages.config.meta | 23 + .../Packages/manifest.json | 11 + .../Packages/packages-lock.json | 72 + .../ProjectSettings/ProjectSettings.asset | 2 +- .../SceneTemplateSettings.json | 167 + .../UserSettings/EditorUserSettings.asset | Bin 4156 -> 745 bytes .../MessagePack.UnityShims.csproj | 4 - .../Scripts => }/MessagePack/BitOperations.cs | 0 .../Scripts => }/MessagePack/BufferWriter.cs | 0 .../MessagePack/ExtensionHeader.cs | 0 .../MessagePack/ExtensionResult.cs | 0 .../Formatters/CollectionFormatter.cs | 0 .../Formatters/CollectionHelpers`2.cs | 0 .../Formatters/DateTimeFormatters.cs | 0 .../Formatters/DictionaryFormatter.cs | 0 .../DynamicObjectTypeFallbackFormatter.cs | 0 .../Formatters/EnumAsStringFormatter`1.cs | 0 .../Formatters/ExpandoObjectFormatter.cs | 0 .../Formatters/GenericEnumFormatter`1.cs | 0 .../Formatters/IMessagePackFormatter`1.cs | 0 .../Formatters/IgnoreFormatter`1.cs | 0 .../MultiDimensionalArrayFormatter.cs | 0 .../MessagePack/Formatters/NilFormatter.cs | 0 .../Formatters/NullableFormatter.cs | 0 .../Formatters/PrimitiveObjectFormatter.cs | 0 .../StandardClassLibraryFormatter.cs | 0 .../Formatters/StringInterningFormatter.cs | 0 .../Formatters/TypelessFormatter.cs | 0 .../Formatters/UnsafeBinaryFormatters.cs | 0 .../Scripts => }/MessagePack/HashCode.cs | 0 .../MessagePack/IFormatterResolver.cs | 0 .../Internal/AsymmetricKeyHashTable.cs | 0 .../Internal/AutomataDictionary.cs | 0 .../MessagePack/Internal/AutomataKeyGen.cs | 0 .../Internal/ByteArrayStringHashTable.cs | 0 .../MessagePack/Internal/CodeGenHelpers.cs | 0 .../MessagePack/Internal/DateTimeConstants.cs | 0 .../MessagePack/Internal/DynamicAssembly.cs | 0 .../MessagePack/Internal/ExpressionUtility.cs | 0 .../MessagePack/Internal/FarmHash.cs | 0 .../MessagePack/Internal/GuidBits.cs | 0 .../Internal/ILGeneratorExtensions.cs | 0 .../Internal/ReflectionExtensions.cs | 0 .../RuntimeTypeHandleEqualityComparer.cs | 0 src/MessagePack/Internal/Sequence`1.cs | 652 ++ .../Internal/ThreadsafeTypeKeyHashTable.cs | 0 .../MessagePack/Internal/TinyJsonReader.cs | 0 .../MessagePack/Internal/UnsafeMemory.Low.cs | 0 .../MessagePack/LZ4/LZ4Codec.Helper.cs | 0 .../MessagePack/LZ4/LZ4Codec.Safe.cs | 0 .../MessagePack/LZ4/LZ4Codec.Safe32.Dirty.cs | 0 .../MessagePack/LZ4/LZ4Codec.Safe64.Dirty.cs | 0 .../MessagePack/LZ4/LZ4Codec.Unsafe.cs | 0 .../LZ4/LZ4Codec.Unsafe32.Dirty.cs | 0 .../LZ4/LZ4Codec.Unsafe64.Dirty.cs | 0 .../Scripts => }/MessagePack/LZ4/LZ4Codec.cs | 0 src/MessagePack/MessagePack.csproj | 21 - .../MessagePack/MessagePackCode.cs | 0 .../MessagePack/MessagePackCompression.cs | 0 .../MessagePack/MessagePackReader.cs | 0 .../MessagePack/MessagePackSecurity.cs | 0 .../MessagePackSerializationException.cs | 0 .../MessagePack/MessagePackSerializer.Json.cs | 0 .../MessagePackSerializer.NonGeneric.cs | 0 .../MessagePack/MessagePackSerializer.cs | 0 .../MessagePackSerializerOptions.cs | 0 .../MessagePack/MessagePackStreamReader.cs | 0 .../MessagePack/MessagePackWriter.cs | 0 .../MessagePack/MonoProtection.cs | 0 .../Assets/Scripts => }/MessagePack/Nil.cs | 0 .../Resolvers/AttributeFormatterResolver.cs | 0 .../MessagePack/Resolvers/BuiltinResolver.cs | 0 .../Resolvers/CachingFormatterResolver.cs | 0 .../Resolvers/CompositeResolver.cs | 0 .../ContractlessReflectionObjectResolver.cs | 0 .../Resolvers/DynamicEnumAsStringResolver.cs | 0 .../Resolvers/DynamicEnumResolver.cs | 0 .../Resolvers/DynamicGenericResolver.cs | 0 .../Resolvers/DynamicObjectResolver.cs | 0 .../Resolvers/DynamicUnionResolver.cs | 0 .../Resolvers/ExpandoObjectResolver.cs | 0 .../Resolvers/NativeDateTimeResolver.cs | 0 .../Resolvers/NativeDecimalResolver.cs | 0 .../Resolvers/NativeGuidResolver.cs | 0 .../Resolvers/PrimitiveObjectResolver.cs | 0 .../Resolvers/ResolverUtilities.cs | 0 .../MessagePack/Resolvers/StandardResolver.cs | 0 .../Resolvers/StaticCompositeResolver.cs | 0 .../TypelessContractlessStandardResolver.cs | 0 .../Resolvers/TypelessObjectResolver.cs | 0 .../MessagePack/SafeBitConverter.cs | 0 .../Scripts => }/MessagePack/SequencePool.cs | 0 .../MessagePack/SequenceReader.cs | 0 .../MessagePack/SequenceReaderExtensions.cs | 0 .../MessagePack/StreamPolyfillExtensions.cs | 0 .../MessagePack/StringEncoding.cs | 0 .../ThisLibraryExtensionTypeCodes.cs | 76 + .../Scripts => }/MessagePack/Utilities.cs | 0 .../MessagePack.Tests.csproj | 23 +- .../ThisLibraryExtensionTypeCodes.cs | 76 + 340 files changed, 11618 insertions(+), 7502 deletions(-) create mode 100644 bin/MessagePack/Debug/netstandard2.0/package.json rename src/MessagePack.UnityClient/Assets/Scripts/MessagePack/MessagePack.asmdef.meta => bin/MessagePack/Debug/netstandard2.0/package.json.meta (59%) rename src/{MessagePack.UnityClient/Assets/Scripts/MessagePack/Annotations => MessagePack.Annotations}/Attributes.cs (96%) rename src/{MessagePack.UnityClient/Assets/Scripts/MessagePack/Annotations => MessagePack.Annotations}/IMessagePackSerializationCallbackReceiver.cs (100%) create mode 100644 src/MessagePack.UnityClient/Assets/NuGet.config create mode 100644 src/MessagePack.UnityClient/Assets/NuGet.config.meta rename src/MessagePack.UnityClient/Assets/{Plugins.meta => Packages.meta} (77%) rename src/MessagePack.UnityClient/Assets/{RuntimeUnitTestToolkit.meta => Packages/Microsoft.Bcl.AsyncInterfaces.6.0.0.meta} (77%) create mode 100644 src/MessagePack.UnityClient/Assets/Packages/Microsoft.Bcl.AsyncInterfaces.6.0.0/.signature.p7s create mode 100644 src/MessagePack.UnityClient/Assets/Packages/Microsoft.Bcl.AsyncInterfaces.6.0.0/Icon.png create mode 100644 src/MessagePack.UnityClient/Assets/Packages/Microsoft.Bcl.AsyncInterfaces.6.0.0/Icon.png.meta create mode 100644 src/MessagePack.UnityClient/Assets/Packages/Microsoft.Bcl.AsyncInterfaces.6.0.0/LICENSE.TXT rename src/MessagePack.UnityClient/Assets/{RuntimeUnitTestToolkit/package.json.meta => Packages/Microsoft.Bcl.AsyncInterfaces.6.0.0/LICENSE.TXT.meta} (75%) create mode 100644 src/MessagePack.UnityClient/Assets/Packages/Microsoft.Bcl.AsyncInterfaces.6.0.0/Microsoft.Bcl.AsyncInterfaces.nuspec create mode 100644 src/MessagePack.UnityClient/Assets/Packages/Microsoft.Bcl.AsyncInterfaces.6.0.0/Microsoft.Bcl.AsyncInterfaces.nuspec.meta create mode 100644 src/MessagePack.UnityClient/Assets/Packages/Microsoft.Bcl.AsyncInterfaces.6.0.0/THIRD-PARTY-NOTICES.TXT rename src/MessagePack.UnityClient/Assets/{RuntimeUnitTestToolkit/RuntimeUnitTestToolkit.asmdef.meta => Packages/Microsoft.Bcl.AsyncInterfaces.6.0.0/THIRD-PARTY-NOTICES.TXT.meta} (59%) rename src/MessagePack.UnityClient/Assets/{RuntimeUnitTestToolkit/Editor.meta => Packages/Microsoft.Bcl.AsyncInterfaces.6.0.0/lib.meta} (77%) rename src/MessagePack.UnityClient/Assets/{Scripts/Editor.meta => Packages/Microsoft.Bcl.AsyncInterfaces.6.0.0/lib/net461.meta} (77%) create mode 100644 src/MessagePack.UnityClient/Assets/Packages/Microsoft.Bcl.AsyncInterfaces.6.0.0/lib/net461/Microsoft.Bcl.AsyncInterfaces.dll create mode 100644 src/MessagePack.UnityClient/Assets/Packages/Microsoft.Bcl.AsyncInterfaces.6.0.0/lib/net461/Microsoft.Bcl.AsyncInterfaces.dll.meta create mode 100644 src/MessagePack.UnityClient/Assets/Packages/Microsoft.Bcl.AsyncInterfaces.6.0.0/lib/net461/Microsoft.Bcl.AsyncInterfaces.xml create mode 100644 src/MessagePack.UnityClient/Assets/Packages/Microsoft.Bcl.AsyncInterfaces.6.0.0/lib/net461/Microsoft.Bcl.AsyncInterfaces.xml.meta create mode 100644 src/MessagePack.UnityClient/Assets/Packages/Microsoft.Bcl.AsyncInterfaces.6.0.0/useSharedDesignerContext.txt create mode 100644 src/MessagePack.UnityClient/Assets/Packages/Microsoft.Bcl.AsyncInterfaces.6.0.0/useSharedDesignerContext.txt.meta create mode 100644 src/MessagePack.UnityClient/Assets/Packages/Microsoft.NET.StringTools.17.6.3.meta create mode 100644 src/MessagePack.UnityClient/Assets/Packages/Microsoft.NET.StringTools.17.6.3/.signature.p7s create mode 100644 src/MessagePack.UnityClient/Assets/Packages/Microsoft.NET.StringTools.17.6.3/MSBuild-NuGet-Icon.png create mode 100644 src/MessagePack.UnityClient/Assets/Packages/Microsoft.NET.StringTools.17.6.3/MSBuild-NuGet-Icon.png.meta create mode 100644 src/MessagePack.UnityClient/Assets/Packages/Microsoft.NET.StringTools.17.6.3/Microsoft.NET.StringTools.nuspec create mode 100644 src/MessagePack.UnityClient/Assets/Packages/Microsoft.NET.StringTools.17.6.3/Microsoft.NET.StringTools.nuspec.meta create mode 100644 src/MessagePack.UnityClient/Assets/Packages/Microsoft.NET.StringTools.17.6.3/README.md create mode 100644 src/MessagePack.UnityClient/Assets/Packages/Microsoft.NET.StringTools.17.6.3/README.md.meta create mode 100644 src/MessagePack.UnityClient/Assets/Packages/Microsoft.NET.StringTools.17.6.3/lib.meta create mode 100644 src/MessagePack.UnityClient/Assets/Packages/Microsoft.NET.StringTools.17.6.3/lib/net472.meta create mode 100644 src/MessagePack.UnityClient/Assets/Packages/Microsoft.NET.StringTools.17.6.3/lib/net472/Microsoft.NET.StringTools.dll create mode 100644 src/MessagePack.UnityClient/Assets/Packages/Microsoft.NET.StringTools.17.6.3/lib/net472/Microsoft.NET.StringTools.dll.meta create mode 100644 src/MessagePack.UnityClient/Assets/Packages/Microsoft.NET.StringTools.17.6.3/lib/net472/Microsoft.NET.StringTools.xml create mode 100644 src/MessagePack.UnityClient/Assets/Packages/Microsoft.NET.StringTools.17.6.3/lib/net472/Microsoft.NET.StringTools.xml.meta create mode 100644 src/MessagePack.UnityClient/Assets/Packages/Microsoft.NET.StringTools.17.6.3/notices.meta create mode 100644 src/MessagePack.UnityClient/Assets/Packages/Microsoft.NET.StringTools.17.6.3/notices/THIRDPARTYNOTICES.txt create mode 100644 src/MessagePack.UnityClient/Assets/Packages/Microsoft.NET.StringTools.17.6.3/notices/THIRDPARTYNOTICES.txt.meta create mode 100644 src/MessagePack.UnityClient/Assets/Packages/System.Collections.Immutable.6.0.0.meta create mode 100644 src/MessagePack.UnityClient/Assets/Packages/System.Collections.Immutable.6.0.0/.signature.p7s create mode 100644 src/MessagePack.UnityClient/Assets/Packages/System.Collections.Immutable.6.0.0/Icon.png create mode 100644 src/MessagePack.UnityClient/Assets/Packages/System.Collections.Immutable.6.0.0/Icon.png.meta create mode 100644 src/MessagePack.UnityClient/Assets/Packages/System.Collections.Immutable.6.0.0/LICENSE.TXT create mode 100644 src/MessagePack.UnityClient/Assets/Packages/System.Collections.Immutable.6.0.0/LICENSE.TXT.meta create mode 100644 src/MessagePack.UnityClient/Assets/Packages/System.Collections.Immutable.6.0.0/System.Collections.Immutable.nuspec create mode 100644 src/MessagePack.UnityClient/Assets/Packages/System.Collections.Immutable.6.0.0/System.Collections.Immutable.nuspec.meta create mode 100644 src/MessagePack.UnityClient/Assets/Packages/System.Collections.Immutable.6.0.0/THIRD-PARTY-NOTICES.TXT create mode 100644 src/MessagePack.UnityClient/Assets/Packages/System.Collections.Immutable.6.0.0/THIRD-PARTY-NOTICES.TXT.meta create mode 100644 src/MessagePack.UnityClient/Assets/Packages/System.Collections.Immutable.6.0.0/buildTransitive.meta create mode 100644 src/MessagePack.UnityClient/Assets/Packages/System.Collections.Immutable.6.0.0/buildTransitive/netcoreapp2.0.meta create mode 100644 src/MessagePack.UnityClient/Assets/Packages/System.Collections.Immutable.6.0.0/buildTransitive/netcoreapp2.0/System.Collections.Immutable.targets create mode 100644 src/MessagePack.UnityClient/Assets/Packages/System.Collections.Immutable.6.0.0/buildTransitive/netcoreapp2.0/System.Collections.Immutable.targets.meta create mode 100644 src/MessagePack.UnityClient/Assets/Packages/System.Collections.Immutable.6.0.0/buildTransitive/netcoreapp3.1.meta create mode 100644 src/MessagePack.UnityClient/Assets/Packages/System.Collections.Immutable.6.0.0/buildTransitive/netcoreapp3.1/_._ create mode 100644 src/MessagePack.UnityClient/Assets/Packages/System.Collections.Immutable.6.0.0/buildTransitive/netcoreapp3.1/_._.meta create mode 100644 src/MessagePack.UnityClient/Assets/Packages/System.Collections.Immutable.6.0.0/lib.meta create mode 100644 src/MessagePack.UnityClient/Assets/Packages/System.Collections.Immutable.6.0.0/lib/net461.meta create mode 100644 src/MessagePack.UnityClient/Assets/Packages/System.Collections.Immutable.6.0.0/lib/net461/System.Collections.Immutable.dll create mode 100644 src/MessagePack.UnityClient/Assets/Packages/System.Collections.Immutable.6.0.0/lib/net461/System.Collections.Immutable.dll.meta create mode 100644 src/MessagePack.UnityClient/Assets/Packages/System.Collections.Immutable.6.0.0/lib/net461/System.Collections.Immutable.xml create mode 100644 src/MessagePack.UnityClient/Assets/Packages/System.Collections.Immutable.6.0.0/lib/net461/System.Collections.Immutable.xml.meta create mode 100644 src/MessagePack.UnityClient/Assets/Packages/System.Collections.Immutable.6.0.0/useSharedDesignerContext.txt create mode 100644 src/MessagePack.UnityClient/Assets/Packages/System.Collections.Immutable.6.0.0/useSharedDesignerContext.txt.meta create mode 100644 src/MessagePack.UnityClient/Assets/Packages/System.Runtime.CompilerServices.Unsafe.6.0.0.meta create mode 100644 src/MessagePack.UnityClient/Assets/Packages/System.Runtime.CompilerServices.Unsafe.6.0.0/.signature.p7s create mode 100644 src/MessagePack.UnityClient/Assets/Packages/System.Runtime.CompilerServices.Unsafe.6.0.0/Icon.png create mode 100644 src/MessagePack.UnityClient/Assets/Packages/System.Runtime.CompilerServices.Unsafe.6.0.0/Icon.png.meta create mode 100644 src/MessagePack.UnityClient/Assets/Packages/System.Runtime.CompilerServices.Unsafe.6.0.0/LICENSE.TXT create mode 100644 src/MessagePack.UnityClient/Assets/Packages/System.Runtime.CompilerServices.Unsafe.6.0.0/LICENSE.TXT.meta create mode 100644 src/MessagePack.UnityClient/Assets/Packages/System.Runtime.CompilerServices.Unsafe.6.0.0/System.Runtime.CompilerServices.Unsafe.nuspec create mode 100644 src/MessagePack.UnityClient/Assets/Packages/System.Runtime.CompilerServices.Unsafe.6.0.0/System.Runtime.CompilerServices.Unsafe.nuspec.meta create mode 100644 src/MessagePack.UnityClient/Assets/Packages/System.Runtime.CompilerServices.Unsafe.6.0.0/THIRD-PARTY-NOTICES.TXT create mode 100644 src/MessagePack.UnityClient/Assets/Packages/System.Runtime.CompilerServices.Unsafe.6.0.0/THIRD-PARTY-NOTICES.TXT.meta create mode 100644 src/MessagePack.UnityClient/Assets/Packages/System.Runtime.CompilerServices.Unsafe.6.0.0/buildTransitive.meta create mode 100644 src/MessagePack.UnityClient/Assets/Packages/System.Runtime.CompilerServices.Unsafe.6.0.0/buildTransitive/netcoreapp2.0.meta create mode 100644 src/MessagePack.UnityClient/Assets/Packages/System.Runtime.CompilerServices.Unsafe.6.0.0/buildTransitive/netcoreapp2.0/System.Runtime.CompilerServices.Unsafe.targets create mode 100644 src/MessagePack.UnityClient/Assets/Packages/System.Runtime.CompilerServices.Unsafe.6.0.0/buildTransitive/netcoreapp2.0/System.Runtime.CompilerServices.Unsafe.targets.meta create mode 100644 src/MessagePack.UnityClient/Assets/Packages/System.Runtime.CompilerServices.Unsafe.6.0.0/buildTransitive/netcoreapp3.1.meta create mode 100644 src/MessagePack.UnityClient/Assets/Packages/System.Runtime.CompilerServices.Unsafe.6.0.0/buildTransitive/netcoreapp3.1/_._ create mode 100644 src/MessagePack.UnityClient/Assets/Packages/System.Runtime.CompilerServices.Unsafe.6.0.0/buildTransitive/netcoreapp3.1/_._.meta create mode 100644 src/MessagePack.UnityClient/Assets/Packages/System.Runtime.CompilerServices.Unsafe.6.0.0/lib.meta create mode 100644 src/MessagePack.UnityClient/Assets/Packages/System.Runtime.CompilerServices.Unsafe.6.0.0/lib/net461.meta create mode 100644 src/MessagePack.UnityClient/Assets/Packages/System.Runtime.CompilerServices.Unsafe.6.0.0/lib/net461/System.Runtime.CompilerServices.Unsafe.dll create mode 100644 src/MessagePack.UnityClient/Assets/Packages/System.Runtime.CompilerServices.Unsafe.6.0.0/lib/net461/System.Runtime.CompilerServices.Unsafe.dll.meta create mode 100644 src/MessagePack.UnityClient/Assets/Packages/System.Runtime.CompilerServices.Unsafe.6.0.0/lib/net461/System.Runtime.CompilerServices.Unsafe.xml create mode 100644 src/MessagePack.UnityClient/Assets/Packages/System.Runtime.CompilerServices.Unsafe.6.0.0/lib/net461/System.Runtime.CompilerServices.Unsafe.xml.meta create mode 100644 src/MessagePack.UnityClient/Assets/Packages/System.Runtime.CompilerServices.Unsafe.6.0.0/useSharedDesignerContext.txt create mode 100644 src/MessagePack.UnityClient/Assets/Packages/System.Runtime.CompilerServices.Unsafe.6.0.0/useSharedDesignerContext.txt.meta delete mode 100644 src/MessagePack.UnityClient/Assets/RuntimeUnitTestToolkit/Editor/HierarchyTreeBuilder.cs delete mode 100644 src/MessagePack.UnityClient/Assets/RuntimeUnitTestToolkit/Editor/HierarchyTreeBuilder.cs.meta delete mode 100644 src/MessagePack.UnityClient/Assets/RuntimeUnitTestToolkit/Editor/UnitTestBuilder.MenuItems.cs delete mode 100644 src/MessagePack.UnityClient/Assets/RuntimeUnitTestToolkit/Editor/UnitTestBuilder.MenuItems.cs.meta delete mode 100644 src/MessagePack.UnityClient/Assets/RuntimeUnitTestToolkit/Editor/UnitTestBuilder.cs delete mode 100644 src/MessagePack.UnityClient/Assets/RuntimeUnitTestToolkit/Editor/UnitTestBuilder.cs.meta delete mode 100644 src/MessagePack.UnityClient/Assets/RuntimeUnitTestToolkit/RuntimeUnitTestToolkit.asmdef delete mode 100644 src/MessagePack.UnityClient/Assets/RuntimeUnitTestToolkit/UnitTestData.cs delete mode 100644 src/MessagePack.UnityClient/Assets/RuntimeUnitTestToolkit/UnitTestData.cs.meta delete mode 100644 src/MessagePack.UnityClient/Assets/RuntimeUnitTestToolkit/UnitTestRunner.cs delete mode 100644 src/MessagePack.UnityClient/Assets/RuntimeUnitTestToolkit/UnitTestRunner.cs.meta delete mode 100644 src/MessagePack.UnityClient/Assets/RuntimeUnitTestToolkit/package.json create mode 100644 src/MessagePack.UnityClient/Assets/Scenes/SandboxSettings.lighting create mode 100644 src/MessagePack.UnityClient/Assets/Scenes/SandboxSettings.lighting.meta delete mode 100644 src/MessagePack.UnityClient/Assets/Scripts/Editor/PackageExporter.cs delete mode 100644 src/MessagePack.UnityClient/Assets/Scripts/Editor/PackageExporter.cs.meta delete mode 100644 src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Annotations.meta delete mode 100644 src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Annotations/Attributes.cs.meta delete mode 100644 src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Annotations/IMessagePackSerializationCallbackReceiver.cs.meta delete mode 100644 src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Annotations/MessagePack.Annotations.asmdef delete mode 100644 src/MessagePack.UnityClient/Assets/Scripts/MessagePack/BitOperations.cs.meta delete mode 100644 src/MessagePack.UnityClient/Assets/Scripts/MessagePack/BufferWriter.cs.meta delete mode 100644 src/MessagePack.UnityClient/Assets/Scripts/MessagePack/ExtensionHeader.cs.meta delete mode 100644 src/MessagePack.UnityClient/Assets/Scripts/MessagePack/ExtensionResult.cs.meta delete mode 100644 src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Formatters.meta delete mode 100644 src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Formatters/CollectionFormatter.cs.meta delete mode 100644 src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Formatters/CollectionHelpers`2.cs.meta delete mode 100644 src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Formatters/DateTimeFormatters.cs.meta delete mode 100644 src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Formatters/DictionaryFormatter.cs.meta delete mode 100644 src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Formatters/DynamicObjectTypeFallbackFormatter.cs.meta delete mode 100644 src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Formatters/EnumAsStringFormatter`1.cs.meta delete mode 100644 src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Formatters/ExpandoObjectFormatter.cs.meta delete mode 100644 src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Formatters/GenericEnumFormatter`1.cs.meta delete mode 100644 src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Formatters/IMessagePackFormatter`1.cs.meta delete mode 100644 src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Formatters/IgnoreFormatter`1.cs.meta delete mode 100644 src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Formatters/MultiDimensionalArrayFormatter.cs.meta delete mode 100644 src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Formatters/NilFormatter.cs.meta delete mode 100644 src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Formatters/NullableFormatter.cs.meta delete mode 100644 src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Formatters/PrimitiveObjectFormatter.cs.meta delete mode 100644 src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Formatters/StandardClassLibraryFormatter.cs.meta delete mode 100644 src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Formatters/StringInterningFormatter.cs.meta delete mode 100644 src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Formatters/TypelessFormatter.cs.meta delete mode 100644 src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Formatters/UnsafeBinaryFormatters.cs.meta delete mode 100644 src/MessagePack.UnityClient/Assets/Scripts/MessagePack/HashCode.cs.meta delete mode 100644 src/MessagePack.UnityClient/Assets/Scripts/MessagePack/IFormatterResolver.cs.meta delete mode 100644 src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Internal.meta delete mode 100644 src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Internal/AsymmetricKeyHashTable.cs.meta delete mode 100644 src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Internal/AutomataDictionary.cs.meta delete mode 100644 src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Internal/AutomataKeyGen.cs.meta delete mode 100644 src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Internal/ByteArrayStringHashTable.cs.meta delete mode 100644 src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Internal/CodeGenHelpers.cs.meta delete mode 100644 src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Internal/DateTimeConstants.cs.meta delete mode 100644 src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Internal/DynamicAssembly.cs.meta delete mode 100644 src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Internal/ExpressionUtility.cs.meta delete mode 100644 src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Internal/FarmHash.cs.meta delete mode 100644 src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Internal/GuidBits.cs.meta delete mode 100644 src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Internal/ILGeneratorExtensions.cs.meta delete mode 100644 src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Internal/ReflectionExtensions.cs.meta delete mode 100644 src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Internal/RuntimeTypeHandleEqualityComparer.cs.meta delete mode 100644 src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Internal/ThreadsafeTypeKeyHashTable.cs.meta delete mode 100644 src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Internal/TinyJsonReader.cs.meta delete mode 100644 src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Internal/UnsafeMemory.Low.cs.meta delete mode 100644 src/MessagePack.UnityClient/Assets/Scripts/MessagePack/LZ4.meta delete mode 100644 src/MessagePack.UnityClient/Assets/Scripts/MessagePack/LZ4/LZ4Codec.Helper.cs.meta delete mode 100644 src/MessagePack.UnityClient/Assets/Scripts/MessagePack/LZ4/LZ4Codec.Safe.cs.meta delete mode 100644 src/MessagePack.UnityClient/Assets/Scripts/MessagePack/LZ4/LZ4Codec.Safe32.Dirty.cs.meta delete mode 100644 src/MessagePack.UnityClient/Assets/Scripts/MessagePack/LZ4/LZ4Codec.Safe64.Dirty.cs.meta delete mode 100644 src/MessagePack.UnityClient/Assets/Scripts/MessagePack/LZ4/LZ4Codec.Unsafe.cs.meta delete mode 100644 src/MessagePack.UnityClient/Assets/Scripts/MessagePack/LZ4/LZ4Codec.Unsafe32.Dirty.cs.meta delete mode 100644 src/MessagePack.UnityClient/Assets/Scripts/MessagePack/LZ4/LZ4Codec.Unsafe64.Dirty.cs.meta delete mode 100644 src/MessagePack.UnityClient/Assets/Scripts/MessagePack/LZ4/LZ4Codec.cs.meta create mode 100644 src/MessagePack.UnityClient/Assets/Scripts/MessagePack/MessagePack.Unity.asmdef rename src/MessagePack.UnityClient/Assets/Scripts/MessagePack/{Annotations/MessagePack.Annotations.asmdef.meta => MessagePack.Unity.asmdef.meta} (76%) delete mode 100644 src/MessagePack.UnityClient/Assets/Scripts/MessagePack/MessagePack.asmdef delete mode 100644 src/MessagePack.UnityClient/Assets/Scripts/MessagePack/MessagePackCode.cs.meta delete mode 100644 src/MessagePack.UnityClient/Assets/Scripts/MessagePack/MessagePackCompression.cs.meta delete mode 100644 src/MessagePack.UnityClient/Assets/Scripts/MessagePack/MessagePackReader.cs.meta delete mode 100644 src/MessagePack.UnityClient/Assets/Scripts/MessagePack/MessagePackSecurity.cs.meta delete mode 100644 src/MessagePack.UnityClient/Assets/Scripts/MessagePack/MessagePackSerializationException.cs.meta delete mode 100644 src/MessagePack.UnityClient/Assets/Scripts/MessagePack/MessagePackSerializer.Json.cs.meta delete mode 100644 src/MessagePack.UnityClient/Assets/Scripts/MessagePack/MessagePackSerializer.NonGeneric.cs.meta delete mode 100644 src/MessagePack.UnityClient/Assets/Scripts/MessagePack/MessagePackSerializer.cs.meta delete mode 100644 src/MessagePack.UnityClient/Assets/Scripts/MessagePack/MessagePackSerializerOptions.cs.meta delete mode 100644 src/MessagePack.UnityClient/Assets/Scripts/MessagePack/MessagePackStreamReader.cs.meta delete mode 100644 src/MessagePack.UnityClient/Assets/Scripts/MessagePack/MessagePackWriter.cs.meta delete mode 100644 src/MessagePack.UnityClient/Assets/Scripts/MessagePack/MonoProtection.cs.meta delete mode 100644 src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Nil.cs.meta delete mode 100644 src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Resolvers.meta delete mode 100644 src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Resolvers/AttributeFormatterResolver.cs.meta delete mode 100644 src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Resolvers/BuiltinResolver.cs.meta delete mode 100644 src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Resolvers/CachingFormatterResolver.cs.meta delete mode 100644 src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Resolvers/CompositeResolver.cs.meta delete mode 100644 src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Resolvers/ContractlessReflectionObjectResolver.cs.meta delete mode 100644 src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Resolvers/DynamicEnumAsStringResolver.cs.meta delete mode 100644 src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Resolvers/DynamicEnumResolver.cs.meta delete mode 100644 src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Resolvers/DynamicGenericResolver.cs.meta delete mode 100644 src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Resolvers/DynamicObjectResolver.cs.meta delete mode 100644 src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Resolvers/DynamicUnionResolver.cs.meta delete mode 100644 src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Resolvers/ExpandoObjectResolver.cs.meta delete mode 100644 src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Resolvers/NativeDateTimeResolver.cs.meta delete mode 100644 src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Resolvers/NativeDecimalResolver.cs.meta delete mode 100644 src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Resolvers/NativeGuidResolver.cs.meta delete mode 100644 src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Resolvers/PrimitiveObjectResolver.cs.meta delete mode 100644 src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Resolvers/ResolverUtilities.cs.meta delete mode 100644 src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Resolvers/StandardResolver.cs.meta delete mode 100644 src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Resolvers/StaticCompositeResolver.cs.meta delete mode 100644 src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Resolvers/TypelessContractlessStandardResolver.cs.meta delete mode 100644 src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Resolvers/TypelessObjectResolver.cs.meta delete mode 100644 src/MessagePack.UnityClient/Assets/Scripts/MessagePack/SafeBitConverter.cs.meta delete mode 100644 src/MessagePack.UnityClient/Assets/Scripts/MessagePack/SequencePool.cs.meta delete mode 100644 src/MessagePack.UnityClient/Assets/Scripts/MessagePack/SequenceReader.cs.meta delete mode 100644 src/MessagePack.UnityClient/Assets/Scripts/MessagePack/SequenceReaderExtensions.cs.meta delete mode 100644 src/MessagePack.UnityClient/Assets/Scripts/MessagePack/StreamPolyfillExtensions.cs.meta delete mode 100644 src/MessagePack.UnityClient/Assets/Scripts/MessagePack/StringEncoding.cs.meta delete mode 100644 src/MessagePack.UnityClient/Assets/Scripts/MessagePack/T4.meta delete mode 100644 src/MessagePack.UnityClient/Assets/Scripts/MessagePack/T4/ForceSizePrimitiveFormatter.cs delete mode 100644 src/MessagePack.UnityClient/Assets/Scripts/MessagePack/T4/ForceSizePrimitiveFormatter.cs.meta delete mode 100644 src/MessagePack.UnityClient/Assets/Scripts/MessagePack/T4/MessagePackReader.Integers.cs delete mode 100644 src/MessagePack.UnityClient/Assets/Scripts/MessagePack/T4/MessagePackReader.Integers.cs.meta delete mode 100644 src/MessagePack.UnityClient/Assets/Scripts/MessagePack/T4/PrimitiveFormatter.cs delete mode 100644 src/MessagePack.UnityClient/Assets/Scripts/MessagePack/T4/PrimitiveFormatter.cs.meta delete mode 100644 src/MessagePack.UnityClient/Assets/Scripts/MessagePack/T4/TupleFormatter.cs delete mode 100644 src/MessagePack.UnityClient/Assets/Scripts/MessagePack/T4/TupleFormatter.cs.meta delete mode 100644 src/MessagePack.UnityClient/Assets/Scripts/MessagePack/T4/UnsafeMemory.cs delete mode 100644 src/MessagePack.UnityClient/Assets/Scripts/MessagePack/T4/UnsafeMemory.cs.meta delete mode 100644 src/MessagePack.UnityClient/Assets/Scripts/MessagePack/T4/ValueTupleFormatter.cs delete mode 100644 src/MessagePack.UnityClient/Assets/Scripts/MessagePack/T4/ValueTupleFormatter.cs.meta rename src/MessagePack.UnityClient/Assets/Scripts/MessagePack/{ => Unity}/ThisLibraryExtensionTypeCodes.cs (100%) rename src/MessagePack.UnityClient/Assets/Scripts/MessagePack/{ => Unity}/ThisLibraryExtensionTypeCodes.cs.meta (83%) delete mode 100644 src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Utilities.cs.meta delete mode 100644 src/MessagePack.UnityClient/Assets/Scripts/MessagePack/_InternalVisibleTo.cs delete mode 100644 src/MessagePack.UnityClient/Assets/Scripts/MessagePack/_InternalVisibleTo.cs.meta rename src/MessagePack.UnityClient/Assets/Scripts/{MessagePack/Internal => Tests}/Sequence`1.cs (100%) rename src/MessagePack.UnityClient/Assets/Scripts/{MessagePack/Internal => Tests}/Sequence`1.cs.meta (83%) create mode 100644 src/MessagePack.UnityClient/Assets/Scripts/Tests/csc.rsp.meta create mode 100644 src/MessagePack.UnityClient/Assets/packages.config create mode 100644 src/MessagePack.UnityClient/Assets/packages.config.meta create mode 100644 src/MessagePack.UnityClient/Packages/manifest.json create mode 100644 src/MessagePack.UnityClient/Packages/packages-lock.json create mode 100644 src/MessagePack.UnityClient/ProjectSettings/SceneTemplateSettings.json rename src/{MessagePack.UnityClient/Assets/Scripts => }/MessagePack/BitOperations.cs (100%) rename src/{MessagePack.UnityClient/Assets/Scripts => }/MessagePack/BufferWriter.cs (100%) rename src/{MessagePack.UnityClient/Assets/Scripts => }/MessagePack/ExtensionHeader.cs (100%) rename src/{MessagePack.UnityClient/Assets/Scripts => }/MessagePack/ExtensionResult.cs (100%) rename src/{MessagePack.UnityClient/Assets/Scripts => }/MessagePack/Formatters/CollectionFormatter.cs (100%) rename src/{MessagePack.UnityClient/Assets/Scripts => }/MessagePack/Formatters/CollectionHelpers`2.cs (100%) rename src/{MessagePack.UnityClient/Assets/Scripts => }/MessagePack/Formatters/DateTimeFormatters.cs (100%) rename src/{MessagePack.UnityClient/Assets/Scripts => }/MessagePack/Formatters/DictionaryFormatter.cs (100%) rename src/{MessagePack.UnityClient/Assets/Scripts => }/MessagePack/Formatters/DynamicObjectTypeFallbackFormatter.cs (100%) rename src/{MessagePack.UnityClient/Assets/Scripts => }/MessagePack/Formatters/EnumAsStringFormatter`1.cs (100%) rename src/{MessagePack.UnityClient/Assets/Scripts => }/MessagePack/Formatters/ExpandoObjectFormatter.cs (100%) rename src/{MessagePack.UnityClient/Assets/Scripts => }/MessagePack/Formatters/GenericEnumFormatter`1.cs (100%) rename src/{MessagePack.UnityClient/Assets/Scripts => }/MessagePack/Formatters/IMessagePackFormatter`1.cs (100%) rename src/{MessagePack.UnityClient/Assets/Scripts => }/MessagePack/Formatters/IgnoreFormatter`1.cs (100%) rename src/{MessagePack.UnityClient/Assets/Scripts => }/MessagePack/Formatters/MultiDimensionalArrayFormatter.cs (100%) rename src/{MessagePack.UnityClient/Assets/Scripts => }/MessagePack/Formatters/NilFormatter.cs (100%) rename src/{MessagePack.UnityClient/Assets/Scripts => }/MessagePack/Formatters/NullableFormatter.cs (100%) rename src/{MessagePack.UnityClient/Assets/Scripts => }/MessagePack/Formatters/PrimitiveObjectFormatter.cs (100%) rename src/{MessagePack.UnityClient/Assets/Scripts => }/MessagePack/Formatters/StandardClassLibraryFormatter.cs (100%) rename src/{MessagePack.UnityClient/Assets/Scripts => }/MessagePack/Formatters/StringInterningFormatter.cs (100%) rename src/{MessagePack.UnityClient/Assets/Scripts => }/MessagePack/Formatters/TypelessFormatter.cs (100%) rename src/{MessagePack.UnityClient/Assets/Scripts => }/MessagePack/Formatters/UnsafeBinaryFormatters.cs (100%) rename src/{MessagePack.UnityClient/Assets/Scripts => }/MessagePack/HashCode.cs (100%) rename src/{MessagePack.UnityClient/Assets/Scripts => }/MessagePack/IFormatterResolver.cs (100%) rename src/{MessagePack.UnityClient/Assets/Scripts => }/MessagePack/Internal/AsymmetricKeyHashTable.cs (100%) rename src/{MessagePack.UnityClient/Assets/Scripts => }/MessagePack/Internal/AutomataDictionary.cs (100%) rename src/{MessagePack.UnityClient/Assets/Scripts => }/MessagePack/Internal/AutomataKeyGen.cs (100%) rename src/{MessagePack.UnityClient/Assets/Scripts => }/MessagePack/Internal/ByteArrayStringHashTable.cs (100%) rename src/{MessagePack.UnityClient/Assets/Scripts => }/MessagePack/Internal/CodeGenHelpers.cs (100%) rename src/{MessagePack.UnityClient/Assets/Scripts => }/MessagePack/Internal/DateTimeConstants.cs (100%) rename src/{MessagePack.UnityClient/Assets/Scripts => }/MessagePack/Internal/DynamicAssembly.cs (100%) rename src/{MessagePack.UnityClient/Assets/Scripts => }/MessagePack/Internal/ExpressionUtility.cs (100%) rename src/{MessagePack.UnityClient/Assets/Scripts => }/MessagePack/Internal/FarmHash.cs (100%) rename src/{MessagePack.UnityClient/Assets/Scripts => }/MessagePack/Internal/GuidBits.cs (100%) rename src/{MessagePack.UnityClient/Assets/Scripts => }/MessagePack/Internal/ILGeneratorExtensions.cs (100%) rename src/{MessagePack.UnityClient/Assets/Scripts => }/MessagePack/Internal/ReflectionExtensions.cs (100%) rename src/{MessagePack.UnityClient/Assets/Scripts => }/MessagePack/Internal/RuntimeTypeHandleEqualityComparer.cs (100%) create mode 100644 src/MessagePack/Internal/Sequence`1.cs rename src/{MessagePack.UnityClient/Assets/Scripts => }/MessagePack/Internal/ThreadsafeTypeKeyHashTable.cs (100%) rename src/{MessagePack.UnityClient/Assets/Scripts => }/MessagePack/Internal/TinyJsonReader.cs (100%) rename src/{MessagePack.UnityClient/Assets/Scripts => }/MessagePack/Internal/UnsafeMemory.Low.cs (100%) rename src/{MessagePack.UnityClient/Assets/Scripts => }/MessagePack/LZ4/LZ4Codec.Helper.cs (100%) rename src/{MessagePack.UnityClient/Assets/Scripts => }/MessagePack/LZ4/LZ4Codec.Safe.cs (100%) rename src/{MessagePack.UnityClient/Assets/Scripts => }/MessagePack/LZ4/LZ4Codec.Safe32.Dirty.cs (100%) rename src/{MessagePack.UnityClient/Assets/Scripts => }/MessagePack/LZ4/LZ4Codec.Safe64.Dirty.cs (100%) rename src/{MessagePack.UnityClient/Assets/Scripts => }/MessagePack/LZ4/LZ4Codec.Unsafe.cs (100%) rename src/{MessagePack.UnityClient/Assets/Scripts => }/MessagePack/LZ4/LZ4Codec.Unsafe32.Dirty.cs (100%) rename src/{MessagePack.UnityClient/Assets/Scripts => }/MessagePack/LZ4/LZ4Codec.Unsafe64.Dirty.cs (100%) rename src/{MessagePack.UnityClient/Assets/Scripts => }/MessagePack/LZ4/LZ4Codec.cs (100%) rename src/{MessagePack.UnityClient/Assets/Scripts => }/MessagePack/MessagePackCode.cs (100%) rename src/{MessagePack.UnityClient/Assets/Scripts => }/MessagePack/MessagePackCompression.cs (100%) rename src/{MessagePack.UnityClient/Assets/Scripts => }/MessagePack/MessagePackReader.cs (100%) rename src/{MessagePack.UnityClient/Assets/Scripts => }/MessagePack/MessagePackSecurity.cs (100%) rename src/{MessagePack.UnityClient/Assets/Scripts => }/MessagePack/MessagePackSerializationException.cs (100%) rename src/{MessagePack.UnityClient/Assets/Scripts => }/MessagePack/MessagePackSerializer.Json.cs (100%) rename src/{MessagePack.UnityClient/Assets/Scripts => }/MessagePack/MessagePackSerializer.NonGeneric.cs (100%) rename src/{MessagePack.UnityClient/Assets/Scripts => }/MessagePack/MessagePackSerializer.cs (100%) rename src/{MessagePack.UnityClient/Assets/Scripts => }/MessagePack/MessagePackSerializerOptions.cs (100%) rename src/{MessagePack.UnityClient/Assets/Scripts => }/MessagePack/MessagePackStreamReader.cs (100%) rename src/{MessagePack.UnityClient/Assets/Scripts => }/MessagePack/MessagePackWriter.cs (100%) rename src/{MessagePack.UnityClient/Assets/Scripts => }/MessagePack/MonoProtection.cs (100%) rename src/{MessagePack.UnityClient/Assets/Scripts => }/MessagePack/Nil.cs (100%) rename src/{MessagePack.UnityClient/Assets/Scripts => }/MessagePack/Resolvers/AttributeFormatterResolver.cs (100%) rename src/{MessagePack.UnityClient/Assets/Scripts => }/MessagePack/Resolvers/BuiltinResolver.cs (100%) rename src/{MessagePack.UnityClient/Assets/Scripts => }/MessagePack/Resolvers/CachingFormatterResolver.cs (100%) rename src/{MessagePack.UnityClient/Assets/Scripts => }/MessagePack/Resolvers/CompositeResolver.cs (100%) rename src/{MessagePack.UnityClient/Assets/Scripts => }/MessagePack/Resolvers/ContractlessReflectionObjectResolver.cs (100%) rename src/{MessagePack.UnityClient/Assets/Scripts => }/MessagePack/Resolvers/DynamicEnumAsStringResolver.cs (100%) rename src/{MessagePack.UnityClient/Assets/Scripts => }/MessagePack/Resolvers/DynamicEnumResolver.cs (100%) rename src/{MessagePack.UnityClient/Assets/Scripts => }/MessagePack/Resolvers/DynamicGenericResolver.cs (100%) rename src/{MessagePack.UnityClient/Assets/Scripts => }/MessagePack/Resolvers/DynamicObjectResolver.cs (100%) rename src/{MessagePack.UnityClient/Assets/Scripts => }/MessagePack/Resolvers/DynamicUnionResolver.cs (100%) rename src/{MessagePack.UnityClient/Assets/Scripts => }/MessagePack/Resolvers/ExpandoObjectResolver.cs (100%) rename src/{MessagePack.UnityClient/Assets/Scripts => }/MessagePack/Resolvers/NativeDateTimeResolver.cs (100%) rename src/{MessagePack.UnityClient/Assets/Scripts => }/MessagePack/Resolvers/NativeDecimalResolver.cs (100%) rename src/{MessagePack.UnityClient/Assets/Scripts => }/MessagePack/Resolvers/NativeGuidResolver.cs (100%) rename src/{MessagePack.UnityClient/Assets/Scripts => }/MessagePack/Resolvers/PrimitiveObjectResolver.cs (100%) rename src/{MessagePack.UnityClient/Assets/Scripts => }/MessagePack/Resolvers/ResolverUtilities.cs (100%) rename src/{MessagePack.UnityClient/Assets/Scripts => }/MessagePack/Resolvers/StandardResolver.cs (100%) rename src/{MessagePack.UnityClient/Assets/Scripts => }/MessagePack/Resolvers/StaticCompositeResolver.cs (100%) rename src/{MessagePack.UnityClient/Assets/Scripts => }/MessagePack/Resolvers/TypelessContractlessStandardResolver.cs (100%) rename src/{MessagePack.UnityClient/Assets/Scripts => }/MessagePack/Resolvers/TypelessObjectResolver.cs (100%) rename src/{MessagePack.UnityClient/Assets/Scripts => }/MessagePack/SafeBitConverter.cs (100%) rename src/{MessagePack.UnityClient/Assets/Scripts => }/MessagePack/SequencePool.cs (100%) rename src/{MessagePack.UnityClient/Assets/Scripts => }/MessagePack/SequenceReader.cs (100%) rename src/{MessagePack.UnityClient/Assets/Scripts => }/MessagePack/SequenceReaderExtensions.cs (100%) rename src/{MessagePack.UnityClient/Assets/Scripts => }/MessagePack/StreamPolyfillExtensions.cs (100%) rename src/{MessagePack.UnityClient/Assets/Scripts => }/MessagePack/StringEncoding.cs (100%) create mode 100644 src/MessagePack/ThisLibraryExtensionTypeCodes.cs rename src/{MessagePack.UnityClient/Assets/Scripts => }/MessagePack/Utilities.cs (100%) create mode 100644 tests/MessagePack.Tests/ThisLibraryExtensionTypeCodes.cs diff --git a/bin/MessagePack/Debug/netstandard2.0/package.json b/bin/MessagePack/Debug/netstandard2.0/package.json new file mode 100644 index 000000000..98e6a4380 --- /dev/null +++ b/bin/MessagePack/Debug/netstandard2.0/package.json @@ -0,0 +1,12 @@ +{ + "name": "com.github.messagepack.internal", + "displayName": "MessagePack Internal", + "author": { "name": "MessagePack-CSharp", "url": "https://github.com/MessagePack-CSharp/MessagePack-CSharp" }, + "version": "1.0.0", + "unity": "2021.3", + "description": "Internal Package of MessagePack for development time.", + "keywords": [ "Serialization" ], + "license": "MIT", + "category": "Scripting", + "dependencies": {} +} diff --git a/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/MessagePack.asmdef.meta b/bin/MessagePack/Debug/netstandard2.0/package.json.meta similarity index 59% rename from src/MessagePack.UnityClient/Assets/Scripts/MessagePack/MessagePack.asmdef.meta rename to bin/MessagePack/Debug/netstandard2.0/package.json.meta index c40ca3e5d..8878a36ef 100644 --- a/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/MessagePack.asmdef.meta +++ b/bin/MessagePack/Debug/netstandard2.0/package.json.meta @@ -1,6 +1,6 @@ fileFormatVersion: 2 -guid: bbde805d927e795439d7a746d1749cab -AssemblyDefinitionImporter: +guid: b958014f8e837e34aa1a78db9cd582de +PackageManifestImporter: externalObjects: {} userData: assetBundleName: diff --git a/src/AssemblyInfo.cs b/src/AssemblyInfo.cs index e083c6a92..3e3050aef 100644 --- a/src/AssemblyInfo.cs +++ b/src/AssemblyInfo.cs @@ -1,6 +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. +using System.Runtime.CompilerServices; using System.Runtime.InteropServices; [assembly: DefaultDllImportSearchPaths(DllImportSearchPath.SafeDirectories)] diff --git a/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Annotations/Attributes.cs b/src/MessagePack.Annotations/Attributes.cs similarity index 96% rename from src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Annotations/Attributes.cs rename to src/MessagePack.Annotations/Attributes.cs index a90a17b69..227872199 100644 --- a/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Annotations/Attributes.cs +++ b/src/MessagePack.Annotations/Attributes.cs @@ -83,7 +83,7 @@ public class SerializationConstructorAttribute : Attribute { } - [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Interface | AttributeTargets.Enum | AttributeTargets.Field | AttributeTargets.Property | AttributeTargets.Parameter | AttributeTargets.ReturnValue, AllowMultiple = false, Inherited = true)] + [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Interface | AttributeTargets.Enum | AttributeTargets.Field | AttributeTargets.Property, AllowMultiple = false, Inherited = true)] public class MessagePackFormatterAttribute : Attribute { public Type FormatterType { get; private set; } diff --git a/src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Annotations/IMessagePackSerializationCallbackReceiver.cs b/src/MessagePack.Annotations/IMessagePackSerializationCallbackReceiver.cs similarity index 100% rename from src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Annotations/IMessagePackSerializationCallbackReceiver.cs rename to src/MessagePack.Annotations/IMessagePackSerializationCallbackReceiver.cs diff --git a/src/MessagePack.Annotations/MessagePack.Annotations.csproj b/src/MessagePack.Annotations/MessagePack.Annotations.csproj index 48e95271a..dba6f8d6a 100644 --- a/src/MessagePack.Annotations/MessagePack.Annotations.csproj +++ b/src/MessagePack.Annotations/MessagePack.Annotations.csproj @@ -10,8 +10,4 @@ MsgPack;MessagePack;Serialization;Formatter;Serializer;Unity;Xamarin - - - - diff --git a/src/MessagePack.SourceGenerator.Unity/MessagePack.SourceGenerator.Unity.csproj b/src/MessagePack.SourceGenerator.Unity/MessagePack.SourceGenerator.Unity.csproj index 9748aea66..22ce3a008 100644 --- a/src/MessagePack.SourceGenerator.Unity/MessagePack.SourceGenerator.Unity.csproj +++ b/src/MessagePack.SourceGenerator.Unity/MessagePack.SourceGenerator.Unity.csproj @@ -13,9 +13,9 @@ - - - + + + diff --git a/src/MessagePack.SourceGenerator/MessagePack.SourceGenerator.csproj b/src/MessagePack.SourceGenerator/MessagePack.SourceGenerator.csproj index 04a0a95e4..f7c18e5f7 100644 --- a/src/MessagePack.SourceGenerator/MessagePack.SourceGenerator.csproj +++ b/src/MessagePack.SourceGenerator/MessagePack.SourceGenerator.csproj @@ -18,9 +18,9 @@ - - - + + + True True diff --git a/src/MessagePack.UnityClient/Assets/NuGet.config b/src/MessagePack.UnityClient/Assets/NuGet.config new file mode 100644 index 000000000..82fb1c875 --- /dev/null +++ b/src/MessagePack.UnityClient/Assets/NuGet.config @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/MessagePack.UnityClient/Assets/NuGet.config.meta b/src/MessagePack.UnityClient/Assets/NuGet.config.meta new file mode 100644 index 000000000..f47e51479 --- /dev/null +++ b/src/MessagePack.UnityClient/Assets/NuGet.config.meta @@ -0,0 +1,23 @@ +fileFormatVersion: 2 +guid: fe2fcfbf53515974890c7219634c8357 +labels: +- NuGetForUnity +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + defineConstraints: [] + isPreloaded: 0 + isOverridable: 0 + isExplicitlyReferenced: 0 + validateReferences: 1 + platformData: + - first: + Any: + second: + enabled: 1 + settings: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/src/MessagePack.UnityClient/Assets/Plugins.meta b/src/MessagePack.UnityClient/Assets/Packages.meta similarity index 77% rename from src/MessagePack.UnityClient/Assets/Plugins.meta rename to src/MessagePack.UnityClient/Assets/Packages.meta index 7b05e62c2..6c6265d77 100644 --- a/src/MessagePack.UnityClient/Assets/Plugins.meta +++ b/src/MessagePack.UnityClient/Assets/Packages.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 5fb5bfc38043b7444b650388190ea48f +guid: f55a9c6bfe6b5ba41a8def05325b42f5 folderAsset: yes DefaultImporter: externalObjects: {} diff --git a/src/MessagePack.UnityClient/Assets/RuntimeUnitTestToolkit.meta b/src/MessagePack.UnityClient/Assets/Packages/Microsoft.Bcl.AsyncInterfaces.6.0.0.meta similarity index 77% rename from src/MessagePack.UnityClient/Assets/RuntimeUnitTestToolkit.meta rename to src/MessagePack.UnityClient/Assets/Packages/Microsoft.Bcl.AsyncInterfaces.6.0.0.meta index 85e74e6a0..fe732a03a 100644 --- a/src/MessagePack.UnityClient/Assets/RuntimeUnitTestToolkit.meta +++ b/src/MessagePack.UnityClient/Assets/Packages/Microsoft.Bcl.AsyncInterfaces.6.0.0.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: abcb1a88f6868eb4da993d61d6aeef51 +guid: 734bf39dff30ef34ca07f62c82bd8ac8 folderAsset: yes DefaultImporter: externalObjects: {} diff --git a/src/MessagePack.UnityClient/Assets/Packages/Microsoft.Bcl.AsyncInterfaces.6.0.0/.signature.p7s b/src/MessagePack.UnityClient/Assets/Packages/Microsoft.Bcl.AsyncInterfaces.6.0.0/.signature.p7s new file mode 100644 index 0000000000000000000000000000000000000000..c7137b00d1abafbf7afc5bdc1fb4e6aa11ac5662 GIT binary patch literal 18702 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 QG(A4*zT1OQR8+nH0m0)eL;wH) literal 0 HcmV?d00001 diff --git a/src/MessagePack.UnityClient/Assets/Packages/Microsoft.Bcl.AsyncInterfaces.6.0.0/Icon.png b/src/MessagePack.UnityClient/Assets/Packages/Microsoft.Bcl.AsyncInterfaces.6.0.0/Icon.png new file mode 100644 index 0000000000000000000000000000000000000000..a0f1fdbf4d5eae0e561018cccee74f6a454cdb9c GIT binary patch literal 7006 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 literal 0 HcmV?d00001 diff --git a/src/MessagePack.UnityClient/Assets/Packages/Microsoft.Bcl.AsyncInterfaces.6.0.0/Icon.png.meta b/src/MessagePack.UnityClient/Assets/Packages/Microsoft.Bcl.AsyncInterfaces.6.0.0/Icon.png.meta new file mode 100644 index 000000000..6e7154ef5 --- /dev/null +++ b/src/MessagePack.UnityClient/Assets/Packages/Microsoft.Bcl.AsyncInterfaces.6.0.0/Icon.png.meta @@ -0,0 +1,123 @@ +fileFormatVersion: 2 +guid: da58a9dbba7faa7409c013e84be33ded +TextureImporter: + internalIDToNameTable: [] + externalObjects: {} + serializedVersion: 12 + mipmaps: + mipMapMode: 0 + enableMipMap: 1 + sRGBTexture: 1 + linearTexture: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapsPreserveCoverage: 0 + alphaTestReferenceValue: 0.5 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 0 + streamingMipmaps: 0 + streamingMipmapsPriority: 0 + vTOnly: 0 + ignoreMasterTextureLimit: 0 + grayScaleToAlpha: 0 + generateCubemap: 6 + cubemapConvolution: 0 + seamlessCubemap: 0 + textureFormat: 1 + maxTextureSize: 2048 + textureSettings: + serializedVersion: 2 + filterMode: 1 + aniso: 1 + mipBias: 0 + wrapU: 0 + wrapV: 0 + wrapW: 0 + nPOTScale: 1 + lightmap: 0 + compressionQuality: 50 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spritePixelsToUnits: 100 + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spriteGenerateFallbackPhysicsShape: 1 + alphaUsage: 1 + alphaIsTransparency: 0 + spriteTessellationDetail: -1 + textureType: 0 + textureShape: 1 + singleChannelComponent: 0 + flipbookRows: 1 + flipbookColumns: 1 + maxTextureSizeSet: 0 + compressionQualitySet: 0 + textureFormatSet: 0 + ignorePngGamma: 0 + applyGammaDecoding: 0 + cookieLightType: 0 + platformSettings: + - serializedVersion: 3 + buildTarget: DefaultTexturePlatform + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + - serializedVersion: 3 + buildTarget: Standalone + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + - serializedVersion: 3 + buildTarget: Server + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + spriteSheet: + serializedVersion: 2 + sprites: [] + outline: [] + physicsShape: [] + bones: [] + spriteID: + internalID: 0 + vertices: [] + indices: + edges: [] + weights: [] + secondaryTextures: [] + nameFileIdTable: {} + spritePackingTag: + pSDRemoveMatte: 0 + pSDShowRemoveMatteOption: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/src/MessagePack.UnityClient/Assets/Packages/Microsoft.Bcl.AsyncInterfaces.6.0.0/LICENSE.TXT b/src/MessagePack.UnityClient/Assets/Packages/Microsoft.Bcl.AsyncInterfaces.6.0.0/LICENSE.TXT new file mode 100644 index 000000000..984713a49 --- /dev/null +++ b/src/MessagePack.UnityClient/Assets/Packages/Microsoft.Bcl.AsyncInterfaces.6.0.0/LICENSE.TXT @@ -0,0 +1,23 @@ +The MIT License (MIT) + +Copyright (c) .NET Foundation and Contributors + +All rights reserved. + +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. diff --git a/src/MessagePack.UnityClient/Assets/RuntimeUnitTestToolkit/package.json.meta b/src/MessagePack.UnityClient/Assets/Packages/Microsoft.Bcl.AsyncInterfaces.6.0.0/LICENSE.TXT.meta similarity index 75% rename from src/MessagePack.UnityClient/Assets/RuntimeUnitTestToolkit/package.json.meta rename to src/MessagePack.UnityClient/Assets/Packages/Microsoft.Bcl.AsyncInterfaces.6.0.0/LICENSE.TXT.meta index 61eb2c1b2..40069a11d 100644 --- a/src/MessagePack.UnityClient/Assets/RuntimeUnitTestToolkit/package.json.meta +++ b/src/MessagePack.UnityClient/Assets/Packages/Microsoft.Bcl.AsyncInterfaces.6.0.0/LICENSE.TXT.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: b7883c7ac5d6ea4409a229aeab14e796 +guid: 694de7cb60ee844439afae26d3415940 TextScriptImporter: externalObjects: {} userData: diff --git a/src/MessagePack.UnityClient/Assets/Packages/Microsoft.Bcl.AsyncInterfaces.6.0.0/Microsoft.Bcl.AsyncInterfaces.nuspec b/src/MessagePack.UnityClient/Assets/Packages/Microsoft.Bcl.AsyncInterfaces.6.0.0/Microsoft.Bcl.AsyncInterfaces.nuspec new file mode 100644 index 000000000..b132d7e80 --- /dev/null +++ b/src/MessagePack.UnityClient/Assets/Packages/Microsoft.Bcl.AsyncInterfaces.6.0.0/Microsoft.Bcl.AsyncInterfaces.nuspec @@ -0,0 +1,31 @@ + + + + Microsoft.Bcl.AsyncInterfaces + 6.0.0 + Microsoft + MIT + https://licenses.nuget.org/MIT + Icon.png + https://dot.net/ + Provides the IAsyncEnumerable<T> and IAsyncDisposable interfaces and helper types for .NET Standard 2.0. This package is not required starting with .NET Standard 2.1 and .NET Core 3.0. + +Commonly Used Types: +System.IAsyncDisposable +System.Collections.Generic.IAsyncEnumerable +System.Collections.Generic.IAsyncEnumerator + https://go.microsoft.com/fwlink/?LinkID=799421 + © Microsoft Corporation. All rights reserved. + true + + + + + + + + + + + + \ No newline at end of file diff --git a/src/MessagePack.UnityClient/Assets/Packages/Microsoft.Bcl.AsyncInterfaces.6.0.0/Microsoft.Bcl.AsyncInterfaces.nuspec.meta b/src/MessagePack.UnityClient/Assets/Packages/Microsoft.Bcl.AsyncInterfaces.6.0.0/Microsoft.Bcl.AsyncInterfaces.nuspec.meta new file mode 100644 index 000000000..dd4605b28 --- /dev/null +++ b/src/MessagePack.UnityClient/Assets/Packages/Microsoft.Bcl.AsyncInterfaces.6.0.0/Microsoft.Bcl.AsyncInterfaces.nuspec.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 6720cf744577f4e43b5f23cba7b3c693 +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/src/MessagePack.UnityClient/Assets/Packages/Microsoft.Bcl.AsyncInterfaces.6.0.0/THIRD-PARTY-NOTICES.TXT b/src/MessagePack.UnityClient/Assets/Packages/Microsoft.Bcl.AsyncInterfaces.6.0.0/THIRD-PARTY-NOTICES.TXT new file mode 100644 index 000000000..89c59b21d --- /dev/null +++ b/src/MessagePack.UnityClient/Assets/Packages/Microsoft.Bcl.AsyncInterfaces.6.0.0/THIRD-PARTY-NOTICES.TXT @@ -0,0 +1,939 @@ +.NET Runtime uses third-party libraries or other resources that may be +distributed under licenses different than the .NET Runtime software. + +In the event that we accidentally failed to list a required notice, please +bring it to our attention. Post an issue or email us: + + dotnet@microsoft.com + +The attached notices are provided for information only. + +License notice for ASP.NET +------------------------------- + +Copyright (c) .NET Foundation. All rights reserved. +Licensed under the Apache License, Version 2.0. + +Available at +https://github.com/dotnet/aspnetcore/blob/main/LICENSE.txt + +License notice for Slicing-by-8 +------------------------------- + +http://sourceforge.net/projects/slicing-by-8/ + +Copyright (c) 2004-2006 Intel Corporation - All Rights Reserved + + +This software program is licensed subject to the BSD License, available at +http://www.opensource.org/licenses/bsd-license.html. + + +License notice for Unicode data +------------------------------- + +https://www.unicode.org/license.html + +Copyright © 1991-2020 Unicode, Inc. All rights reserved. +Distributed under the Terms of Use in https://www.unicode.org/copyright.html. + +Permission is hereby granted, free of charge, to any person obtaining +a copy of the Unicode data files and any associated documentation +(the "Data Files") or Unicode software and any associated documentation +(the "Software") to deal in the Data Files or Software +without restriction, including without limitation the rights to use, +copy, modify, merge, publish, distribute, and/or sell copies of +the Data Files or Software, and to permit persons to whom the Data Files +or Software are furnished to do so, provided that either +(a) this copyright and permission notice appear with all copies +of the Data Files or Software, or +(b) this copyright and permission notice appear in associated +Documentation. + +THE DATA FILES AND SOFTWARE ARE 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 OF THIRD PARTY RIGHTS. +IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN THIS +NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL +DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, +DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER +TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +PERFORMANCE OF THE DATA FILES OR SOFTWARE. + +Except as contained in this notice, the name of a copyright holder +shall not be used in advertising or otherwise to promote the sale, +use or other dealings in these Data Files or Software without prior +written authorization of the copyright holder. + +License notice for Zlib +----------------------- + +https://github.com/madler/zlib +http://zlib.net/zlib_license.html + +/* zlib.h -- interface of the 'zlib' general purpose compression library + version 1.2.11, January 15th, 2017 + + Copyright (C) 1995-2017 Jean-loup Gailly and Mark Adler + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + + Jean-loup Gailly Mark Adler + jloup@gzip.org madler@alumni.caltech.edu + +*/ + +License notice for Mono +------------------------------- + +http://www.mono-project.com/docs/about-mono/ + +Copyright (c) .NET Foundation Contributors + +MIT License + +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. + +License notice for International Organization for Standardization +----------------------------------------------------------------- + +Portions (C) International Organization for Standardization 1986: + Permission to copy in any form is granted for use with + conforming SGML systems and applications as defined in + ISO 8879, provided this notice is included in all copies. + +License notice for Intel +------------------------ + +"Copyright (c) 2004-2006 Intel Corporation - All Rights Reserved + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +License notice for Xamarin and Novell +------------------------------------- + +Copyright (c) 2015 Xamarin, Inc (http://www.xamarin.com) + +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. + +Copyright (c) 2011 Novell, Inc (http://www.novell.com) + +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. + +Third party notice for W3C +-------------------------- + +"W3C SOFTWARE AND DOCUMENT NOTICE AND LICENSE +Status: This license takes effect 13 May, 2015. +This work is being provided by the copyright holders under the following license. +License +By obtaining and/or copying this work, you (the licensee) agree that you have read, understood, and will comply with the following terms and conditions. +Permission to copy, modify, and distribute this work, with or without modification, for any purpose and without fee or royalty is hereby granted, provided that you include the following on ALL copies of the work or portions thereof, including modifications: +The full text of this NOTICE in a location viewable to users of the redistributed or derivative work. +Any pre-existing intellectual property disclaimers, notices, or terms and conditions. If none exist, the W3C Software and Document Short Notice should be included. +Notice of any changes or modifications, through a copyright statement on the new code or document such as "This software or document includes material copied from or derived from [title and URI of the W3C document]. Copyright © [YEAR] W3C® (MIT, ERCIM, Keio, Beihang)." +Disclaimers +THIS WORK IS PROVIDED "AS IS," AND COPYRIGHT HOLDERS MAKE NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF THE SOFTWARE OR DOCUMENT WILL NOT INFRINGE ANY THIRD PARTY PATENTS, COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS. +COPYRIGHT HOLDERS WILL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF ANY USE OF THE SOFTWARE OR DOCUMENT. +The name and trademarks of copyright holders may NOT be used in advertising or publicity pertaining to the work without specific, written prior permission. Title to copyright in this work will at all times remain with copyright holders." + +License notice for Bit Twiddling Hacks +-------------------------------------- + +Bit Twiddling Hacks + +By Sean Eron Anderson +seander@cs.stanford.edu + +Individually, the code snippets here are in the public domain (unless otherwise +noted) — feel free to use them however you please. The aggregate collection and +descriptions are © 1997-2005 Sean Eron Anderson. The code and descriptions are +distributed in the hope that they will be useful, but WITHOUT ANY WARRANTY and +without even the implied warranty of merchantability or fitness for a particular +purpose. + +License notice for Brotli +-------------------------------------- + +Copyright (c) 2009, 2010, 2013-2016 by the Brotli Authors. + +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. + +compress_fragment.c: +Copyright (c) 2011, Google Inc. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above +copyright notice, this list of conditions and the following disclaimer +in the documentation and/or other materials provided with the +distribution. + * Neither the name of Google Inc. nor the names of its +contributors may be used to endorse or promote products derived from +this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +""AS IS"" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +decode_fuzzer.c: +Copyright (c) 2015 The Chromium Authors. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above +copyright notice, this list of conditions and the following disclaimer +in the documentation and/or other materials provided with the +distribution. + * Neither the name of Google Inc. nor the names of its +contributors may be used to endorse or promote products derived from +this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +""AS IS"" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." + +License notice for Json.NET +------------------------------- + +https://github.com/JamesNK/Newtonsoft.Json/blob/master/LICENSE.md + +The MIT License (MIT) + +Copyright (c) 2007 James Newton-King + +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. + +License notice for vectorized base64 encoding / decoding +-------------------------------------------------------- + +Copyright (c) 2005-2007, Nick Galbreath +Copyright (c) 2013-2017, Alfred Klomp +Copyright (c) 2015-2017, Wojciech Mula +Copyright (c) 2016-2017, Matthieu Darbois +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + +- Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + +- Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS +IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A +PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED +TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +License notice for RFC 3492 +--------------------------- + +The punycode implementation is based on the sample code in RFC 3492 + +Copyright (C) The Internet Society (2003). All Rights Reserved. + +This document and translations of it may be copied and furnished to +others, and derivative works that comment on or otherwise explain it +or assist in its implementation may be prepared, copied, published +and distributed, in whole or in part, without restriction of any +kind, provided that the above copyright notice and this paragraph are +included on all such copies and derivative works. However, this +document itself may not be modified in any way, such as by removing +the copyright notice or references to the Internet Society or other +Internet organizations, except as needed for the purpose of +developing Internet standards in which case the procedures for +copyrights defined in the Internet Standards process must be +followed, or as required to translate it into languages other than +English. + +The limited permissions granted above are perpetual and will not be +revoked by the Internet Society or its successors or assigns. + +This document and the information contained herein is provided on an +"AS IS" basis and THE INTERNET SOCIETY AND THE INTERNET ENGINEERING +TASK FORCE DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING +BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION +HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF +MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + +License notice for Algorithm from Internet Draft document "UUIDs and GUIDs" +--------------------------------------------------------------------------- + +Copyright (c) 1990- 1993, 1996 Open Software Foundation, Inc. +Copyright (c) 1989 by Hewlett-Packard Company, Palo Alto, Ca. & +Digital Equipment Corporation, Maynard, Mass. +To anyone who acknowledges that this file is provided "AS IS" +without any express or implied warranty: permission to use, copy, +modify, and distribute this file for any purpose is hereby +granted without fee, provided that the above copyright notices and +this notice appears in all source code copies, and that none of +the names of Open Software Foundation, Inc., Hewlett-Packard +Company, or Digital Equipment Corporation be used in advertising +or publicity pertaining to distribution of the software without +specific, written prior permission. Neither Open Software +Foundation, Inc., Hewlett-Packard Company, Microsoft, nor Digital Equipment +Corporation makes any representations about the suitability of +this software for any purpose. + +Copyright(C) The Internet Society 1997. All Rights Reserved. + +This document and translations of it may be copied and furnished to others, +and derivative works that comment on or otherwise explain it or assist in +its implementation may be prepared, copied, published and distributed, in +whole or in part, without restriction of any kind, provided that the above +copyright notice and this paragraph are included on all such copies and +derivative works.However, this document itself may not be modified in any +way, such as by removing the copyright notice or references to the Internet +Society or other Internet organizations, except as needed for the purpose of +developing Internet standards in which case the procedures for copyrights +defined in the Internet Standards process must be followed, or as required +to translate it into languages other than English. + +The limited permissions granted above are perpetual and will not be revoked +by the Internet Society or its successors or assigns. + +This document and the information contained herein is provided on an "AS IS" +basis and THE INTERNET SOCIETY AND THE INTERNET ENGINEERING TASK FORCE +DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO +ANY WARRANTY THAT THE USE OF THE INFORMATION HEREIN WILL NOT INFRINGE ANY +RIGHTS OR ANY IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A +PARTICULAR PURPOSE. + +License notice for Algorithm from RFC 4122 - +A Universally Unique IDentifier (UUID) URN Namespace +---------------------------------------------------- + +Copyright (c) 1990- 1993, 1996 Open Software Foundation, Inc. +Copyright (c) 1989 by Hewlett-Packard Company, Palo Alto, Ca. & +Digital Equipment Corporation, Maynard, Mass. +Copyright (c) 1998 Microsoft. +To anyone who acknowledges that this file is provided "AS IS" +without any express or implied warranty: permission to use, copy, +modify, and distribute this file for any purpose is hereby +granted without fee, provided that the above copyright notices and +this notice appears in all source code copies, and that none of +the names of Open Software Foundation, Inc., Hewlett-Packard +Company, Microsoft, or Digital Equipment Corporation be used in +advertising or publicity pertaining to distribution of the software +without specific, written prior permission. Neither Open Software +Foundation, Inc., Hewlett-Packard Company, Microsoft, nor Digital +Equipment Corporation makes any representations about the +suitability of this software for any purpose." + +License notice for The LLVM Compiler Infrastructure +--------------------------------------------------- + +Developed by: + + LLVM Team + + University of Illinois at Urbana-Champaign + + http://llvm.org + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal with +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: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimers. + + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimers in the + documentation and/or other materials provided with the distribution. + + * Neither the names of the LLVM Team, University of Illinois at + Urbana-Champaign, nor the names of its contributors may be used to + endorse or promote products derived from this Software without specific + prior written permission. + +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 +CONTRIBUTORS 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 WITH THE +SOFTWARE. + +License notice for Bob Jenkins +------------------------------ + +By Bob Jenkins, 1996. bob_jenkins@burtleburtle.net. You may use this +code any way you wish, private, educational, or commercial. It's free. + +License notice for Greg Parker +------------------------------ + +Greg Parker gparker@cs.stanford.edu December 2000 +This code is in the public domain and may be copied or modified without +permission. + +License notice for libunwind based code +---------------------------------------- + +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. + +License notice for Printing Floating-Point Numbers (Dragon4) +------------------------------------------------------------ + +/****************************************************************************** + Copyright (c) 2014 Ryan Juckett + http://www.ryanjuckett.com/ + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + + 3. This notice may not be removed or altered from any source + distribution. +******************************************************************************/ + +License notice for Printing Floating-point Numbers (Grisu3) +----------------------------------------------------------- + +Copyright 2012 the V8 project authors. All rights reserved. +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the following + disclaimer in the documentation and/or other materials provided + with the distribution. + * Neither the name of Google Inc. nor the names of its + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +License notice for xxHash +------------------------- + +xxHash Library +Copyright (c) 2012-2014, Yann Collet +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright notice, this + list of conditions and the following disclaimer in the documentation and/or + other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +License notice for Berkeley SoftFloat Release 3e +------------------------------------------------ + +https://github.com/ucb-bar/berkeley-softfloat-3 +https://github.com/ucb-bar/berkeley-softfloat-3/blob/master/COPYING.txt + +License for Berkeley SoftFloat Release 3e + +John R. Hauser +2018 January 20 + +The following applies to the whole of SoftFloat Release 3e as well as to +each source file individually. + +Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018 The Regents of the +University of California. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions, and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions, and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + 3. Neither the name of the University nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY +EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE +DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +License notice for xoshiro RNGs +-------------------------------- + +Written in 2018 by David Blackman and Sebastiano Vigna (vigna@acm.org) + +To the extent possible under law, the author has dedicated all copyright +and related and neighboring rights to this software to the public domain +worldwide. This software is distributed without any warranty. + +See . + +License for fastmod (https://github.com/lemire/fastmod) and ibm-fpgen (https://github.com/nigeltao/parse-number-fxx-test-data) +-------------------------------------- + + Copyright 2018 Daniel Lemire + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +License notice for The C++ REST SDK +----------------------------------- + +C++ REST SDK + +The MIT License (MIT) + +Copyright (c) Microsoft Corporation + +All rights reserved. + +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. + +License notice for MessagePack-CSharp +------------------------------------- + +MessagePack for C# + +MIT License + +Copyright (c) 2017 Yoshifumi Kawai + +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. + +License notice for lz4net +------------------------------------- + +lz4net + +Copyright (c) 2013-2017, Milosz Krajewski + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. + +Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +License notice for Nerdbank.Streams +----------------------------------- + +The MIT License (MIT) + +Copyright (c) Andrew Arnott + +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. + +License notice for RapidJSON +---------------------------- + +Tencent is pleased to support the open source community by making RapidJSON available. + +Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved. + +Licensed under the MIT License (the "License"); you may not use this file except +in compliance with the License. You may obtain a copy of the License at + +http://opensource.org/licenses/MIT + +Unless required by applicable law or agreed to in writing, software distributed +under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR +CONDITIONS OF ANY KIND, either express or implied. See the License for the +specific language governing permissions and limitations under the License. + +License notice for DirectX Math Library +--------------------------------------- + +https://github.com/microsoft/DirectXMath/blob/master/LICENSE + + The MIT License (MIT) + +Copyright (c) 2011-2020 Microsoft Corp + +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. + +License notice for ldap4net +--------------------------- + +The MIT License (MIT) + +Copyright (c) 2018 Alexander Chermyanin + +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. + +License notice for vectorized sorting code +------------------------------------------ + +MIT License + +Copyright (c) 2020 Dan Shechter + +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. + +License notice for musl +----------------------- + +musl as a whole is licensed under the following standard MIT license: + +Copyright © 2005-2020 Rich Felker, et al. + +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. + + +License notice for "Faster Unsigned Division by Constants" +------------------------------ + +Reference implementations of computing and using the "magic number" approach to dividing +by constants, including codegen instructions. The unsigned division incorporates the +"round down" optimization per ridiculous_fish. + +This is free and unencumbered software. Any copyright is dedicated to the Public Domain. + + +License notice for mimalloc +----------------------------------- + +MIT License + +Copyright (c) 2019 Microsoft Corporation, Daan Leijen + +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. diff --git a/src/MessagePack.UnityClient/Assets/RuntimeUnitTestToolkit/RuntimeUnitTestToolkit.asmdef.meta b/src/MessagePack.UnityClient/Assets/Packages/Microsoft.Bcl.AsyncInterfaces.6.0.0/THIRD-PARTY-NOTICES.TXT.meta similarity index 59% rename from src/MessagePack.UnityClient/Assets/RuntimeUnitTestToolkit/RuntimeUnitTestToolkit.asmdef.meta rename to src/MessagePack.UnityClient/Assets/Packages/Microsoft.Bcl.AsyncInterfaces.6.0.0/THIRD-PARTY-NOTICES.TXT.meta index 5ad198be0..927e936c2 100644 --- a/src/MessagePack.UnityClient/Assets/RuntimeUnitTestToolkit/RuntimeUnitTestToolkit.asmdef.meta +++ b/src/MessagePack.UnityClient/Assets/Packages/Microsoft.Bcl.AsyncInterfaces.6.0.0/THIRD-PARTY-NOTICES.TXT.meta @@ -1,6 +1,6 @@ fileFormatVersion: 2 -guid: 14c4fea4b238088479114ba2ffe195f9 -AssemblyDefinitionImporter: +guid: 316f4d68a6f62264a8a9146c70f4d1de +TextScriptImporter: externalObjects: {} userData: assetBundleName: diff --git a/src/MessagePack.UnityClient/Assets/RuntimeUnitTestToolkit/Editor.meta b/src/MessagePack.UnityClient/Assets/Packages/Microsoft.Bcl.AsyncInterfaces.6.0.0/lib.meta similarity index 77% rename from src/MessagePack.UnityClient/Assets/RuntimeUnitTestToolkit/Editor.meta rename to src/MessagePack.UnityClient/Assets/Packages/Microsoft.Bcl.AsyncInterfaces.6.0.0/lib.meta index 2e4c0c54e..d32be317b 100644 --- a/src/MessagePack.UnityClient/Assets/RuntimeUnitTestToolkit/Editor.meta +++ b/src/MessagePack.UnityClient/Assets/Packages/Microsoft.Bcl.AsyncInterfaces.6.0.0/lib.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: bc6ad6aaa548c204f9866a24b01d4507 +guid: 7017700133a222145abd477815665c75 folderAsset: yes DefaultImporter: externalObjects: {} diff --git a/src/MessagePack.UnityClient/Assets/Scripts/Editor.meta b/src/MessagePack.UnityClient/Assets/Packages/Microsoft.Bcl.AsyncInterfaces.6.0.0/lib/net461.meta similarity index 77% rename from src/MessagePack.UnityClient/Assets/Scripts/Editor.meta rename to src/MessagePack.UnityClient/Assets/Packages/Microsoft.Bcl.AsyncInterfaces.6.0.0/lib/net461.meta index 0b7cbaf5d..ad3fa53a3 100644 --- a/src/MessagePack.UnityClient/Assets/Scripts/Editor.meta +++ b/src/MessagePack.UnityClient/Assets/Packages/Microsoft.Bcl.AsyncInterfaces.6.0.0/lib/net461.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: af4eefe66f709854aaa6f1ce1f77dc41 +guid: 90461a7f2d2d2954790dbcb9b3220998 folderAsset: yes DefaultImporter: externalObjects: {} diff --git a/src/MessagePack.UnityClient/Assets/Packages/Microsoft.Bcl.AsyncInterfaces.6.0.0/lib/net461/Microsoft.Bcl.AsyncInterfaces.dll b/src/MessagePack.UnityClient/Assets/Packages/Microsoft.Bcl.AsyncInterfaces.6.0.0/lib/net461/Microsoft.Bcl.AsyncInterfaces.dll new file mode 100644 index 0000000000000000000000000000000000000000..476f1b160787e8793399a1f6256da26610ff60d3 GIT binary patch literal 22144 zcmeHv2Ut@{*YMn%0)*ZK5g{OILtA;BbwfCW%lyV$@k_AX-Y zu66Bo?Q8F@uC8S*Yx&PiLWpJe-T(Q%_j$kP`~RysGw00AnKNhRoS8ZIYHY6x#6k$M z;rID7LR%rlPY8j34@#ie%6+>P+GuvdV=LA5ghz6=T*J>(tFqLRT)tGIRI0T6bQxcr zujI>>{D}A@ey%D*CbYEVdFfdvL?YCcVxg+*-Hz4ub`yE>%_#<KVpPRu#hDP zSwNB6|t;XW~>7QDl~pV5DGKKaefkvA3s<&8gWnn=zL>igv|xTp>r#7$Mh&1Ug^;Zs`s4^IrtOfx0qP6|8k_6giXMV9ECIll-fi?4 zTL1$vMp+mY>q-UAxQkhIG1Or<^>uAV55YN2Lm)c{TmUxpHEE_R_V%P%f=0N02bwh$ zxUgyVP&Opq2+IbQv8rt8VqByGz~$K?x)|3GxZ-BLpcyEH2hH4Y!Wrt0$#HZsrn2Z_ zjB5BsG`bj9Wa(&wboF%AR31>EE7o}87IkU@AvIRex3@jRLbf0i2x3dKu*N`p6j##( z*KS5Tv2-~%y4VX-pxscC!R?};9e!xK7*-X}sb}_3oYD=3!ld%(AzU8C^pi4Wz&wc;AOIKU}pKGw>16#kfNs zK3$A^@oAt-Rj?d+`2Z+i+S$9Ix081R@6CpmxP>oQBZ8zzSHGz*t658q01OcrV@W_r zm@_VN!|Mg~!}2v(LpD$2Pa1KE3|4ICG#_(X5CAkXIxDtQnokEoAmHXEK712ZE6AM& zUX-9U0# z!4p9=?l71*w$LyJ%+H=<%kgPw%gM+6S(^Dahb*+D?Af+#-%j3wc9;uW&>j*u(xs{c zWSe=L4eJPLQ(vcM!$KhQi5m(~6NYIexCGj8pl4MCL_OvvzWLCo3l#e_AxhHC09}lg z|E;==OI0zrEAFtakQj*=3#eX!xWu@{*Q)%Yj7*J*UZ*a)_1VSY6Bn$GtBC_nC3x0} zbAf#Xdx-={z>amk1*{FmiAz-701)4TD+m&CEwR2R2_s+mBhtp;k4PKhkAxc7hj=9+ zxCyuq?DIg4xIf4u6Koe+bI?4Gt4e_~uBtmgol=PYDP#?)DXzB!&k%^DpPhfoBP^*) z7==ALJQna96d+`T{*1o}Ob5@b0^ngDLQRGt6ab?5z^_S?RxMX%X>g7H;L>0ys7Xo^ z8UlG6obQwp4T~9#2V4MyXcDGSr2~#18Vsg~`$97_aI5G&<&QTM+&h>rY3l?jxF!Ts zLg?M~DYz7}U9usCk&-h4h(hWBPqIZ?>dSCBNX6BSii;@rW>YS@NT8B~^RrlyruOJH zD2|IBvKDc;s3oTZmy33Bs-Sc|8^dYrgFtD^!Z3w{p$&lrgzi9~h`=`lt|c|ISeSnq zaO0s@oKQ0^O5#r8@X#HE^KWU~%PbRI=b9PL@1}A7As55<1g<9ZG8Qg9OSo|$&qH#k z$wP|}uK5h%(($}0Ao)m>K|mQ~g6r%uy8w0A0J$iil)f~<{hs0Ans*6wq;T6}3R4`Q z6&Ixv7*1e0k?rXD}k@a*jqiuK@_yB1${`M%!FVEVa%n_%93F5Flq^4Rs!d{7c9 zcMdYey6yP|hD#7S#OY6c09kd&igRzEJk7 zt_(09%M^Xkx9d;YvUteT1Hm%_%F5vy5KORg^w`XaWr$O3&|?~t{wycdUWb_u<7Tm(QKY`?oLLTF!}XXYPt9tG*6Fds)L@ni zx&lW$gi28)_XTo8PxRPD@JQ|`54$!fTTC!vQ;bbUpEy6T+)6Ft{s z=72Rp7TC$65y%fPFJxmwp-ixO3Z0=b|hok29qg)*aN(0qWd<}IjHp!)-S zXXa1gQ3O*9D7JY#Rg13EDbxz8hS!T~N4#7+;_=#%^(O(&qp59_9cvyA&X%({M&& zL2V1DNyB~$yENDgZr>Q}h=u@$Im$y*(Gs*1?T3}DqE1mys6Qz_%`VZM)1U)rgHSBp z6RZ-S;Od^XbPz588n_Hn2cZbMC)g_j$#`I?_)G`B2L%wTwje1SchNfB0A`JXS;eUi zchHx^8Gz6o^>h~mM=*HY^yPd#?yJZBAZ>{{AYT**D=H2ZpeX7GG#_GFxggs>7dQZiB=9$<;cQSO08U( zFEP|2Ww@3o7}ttd>bb}=FcU(I4%HMYrIE_~T$x&uu8{Q?Az+g!&&pTJGQuTFsZ4>% ze^;x!M3FB`mS}Q93nX%_o=L0(1W_c)G%~HBJV}+WmV%UO+>3z<`A{hq88Tl;qgAPa zlqJ)qMQdfbB9xpD8t5-JP{deEs9mfoBVQrw0P(gol&g`d)Czezlt@uhp$6Is!&M4} zjC7z8c9JP&YPl3e$TfK?jc!yZRy9Z#2k|vBMii~o%G3}X%aLWEzaKL*M?y3batl&XAD7j1l zZ8SuCFgv+<&~M~mX|_a}B?Ec!)T1<+VG8wH)Qu5OhtZ6ZPQF`Wm=D7&B9Krk&y^(? z=E*uslo`ONlT3@TD77kAPa%_nl9RL&tt?g|&6X=cB+|uWzYixCDyBq^q^xx)B^S)L!latEH_G@C+ znVT-l$dF~!Q?M@O3YnTL3t(?lWT=#)kz~mX7>bak=VxURlQ1x@>oQrc1xqm^gJr?e zRZCzc8*8J!O0q-^%7}vax2!;=&Z#em9ITZoHDDC=q`F?BK;rH)_4f;-m6kTa8+KRTAr0{R21Gd39|)hlt$EO zO`=Sa5wBDfevb)QkkY6?zs`weY31p1gBd^ROj> zQgl+tGQb7O$QmU(f^KuEr-iDsU{6zOwjP05MFtGJONmyR zjcp6u3m7%t?7+Wdt1`m!<%$fMT1T$4^)HLka=)mFl^dTv0CuG4j3|{_=TCqG=9whT zmf_6|Fye(FBf)zrq-ip>TBXKrkw{Q)$p+64R*i&G9VCf<$wtT}SxQ)Va;XOW?bknX)x9>Y@c71lAQ>aVLVxT z8f0)VI%ock;Mnu$Yw*nJbGq3_CNQtx%V^hKjT0(M|0`YC1u=R6`Mn=|j{QV;3KA;z3@gY{rrzlen09!|#wZecV zxCe(%Q&v_aU&uD0Y+d0hVJkCXCtfjKb|wAa7eThUPlj3MhMI!gaKBfRyIaEUs;;1)oLf3AU;FA|4+|&QJ$aY}-MG z2eRl$G-ip(0_Y!-0K$sP;sQr|cqwXEG82R8G}jgPR5F=zHANuGOuLe~cyL?}A3@f} zgzIWovcj%pjSjlPy$o6rxPnv}MVgJWEja<#E*i!He@XEg3mb}s#|-xyH)P5K!Ei66 z>^#;{sso>6S8_&2cC}5lEx8Q+fG{B-D;BO6OGXe7$QA3^)!D{|rlG|)qD8DpGakl) zv8xGGfJUyk=_Vdx0WuwOu4X1Iz3?!TpkAFAz*47VtUwbJ%F(tjg$oJFM+D^%h}CRc zG65@)&4){!6;#F&=)1KrMsNkn6m!E0H{DXyr+dSIn`2Cm7u$b6;d`xHNi}|lz%D^( z8Z0#~zAgfum=r3)H&7f_jVV8HY;f}IfbE-I+B&1#Z9i?=@FW;%*^aH2-8pu7cpCeZ z^{9a<%co3S+2Yrawx@QiX}iqo)3RNQJQV{bwB~g^$9m(?IY+tEGj-I`piXYe*8`7F zSuAOXw!W8La6NhR*u9rh=18@B=!lg0jh=ZOZ{c+4vi+SUq5f?eb1v^b+cM}Fhyf8S zuC0v4wX=cY*rou*))iC-ixm`X1Ir%4IyJ*u!3&ip`oTHdR0v1u79w24ZM~o_gzISC z8pMm&4X9rcV2u(Jm zHwf7-xdR_=etLTSy%E08fkO#7agy?EnF3B{d@bDEG<>*$@QFHMTTo_5)ERs+yz%4f zzV?BWFWjg2at$AU?V|=iE{97rUxW89*!uYeaLoLswTN^=c;e^*-yir{@+^69!pK#@ z8K0k`0Ur1UscB=$)1P~EW2u+fQ1G3Afbi>q|MSZDz=donWYG$Q5{ra^VzG$PO$eqi zEdzqYVwu0xUm|JUT9zIpP8VmU`}<3S{l%ipV6ne6QzXiOYiTR87HkYNxNj{{1H2QZ zkY%C_!WDA76{e^a9@$!Lo~DhTUl!;pKV2wQ<@#l)v`U%QPpvz;!S_KF3V}68gVC5p zE3+Z!0k>N~EMY0A3S!|{A%|cJUVYfYux%MtLukI+v>BVN-gEfb+taLK9S&SuOLf(D zxpKC2Yv`nI6P~}6Omg4Ta*+Mquv^b3JkxH7m#@lq46yCta_@7*)y$9Ou-T6!>_S(hNUcy+Eir8IWAc2mUfS6-zwzb!ZX9I`^9{a znuV2Cn4MXKUrnRo`TaH`DmDRI_F(w!jDTM=T%vn)Q8|R*TMrZv2|t`MdhmN<<0mmG zBI&r#mOcVjl33 z3whW8bvuEc00}G`Xwer{^48hcWyKKbmub=S>M?j)N4hIsC*D8Sz@x zz%LWV!6!OYlU0USC7w0ieJcZQ2b94!B7lPi#)n6lXH@HZJcTF>YAQe%^=ltn>DQ|k zAv`nneRL;U)EFc{s1@+Q>rsqE00SY#Ic$jt=GYV3*7H?@^a`WVemmBGDwhy=S+JtDP-g|`@Y}xrO0U?qLJ49viW7UkB9V8{Bdc<V>5&K%`+JbH69dqJ!6XzQ+r+yi3Z+aW@%MQkqu*oi6-_YiLwm1WoC%n7*|Z;*?<2ME)p=!a5>A~ z-Ef0|OL~Tkk6(M>yKO>vC|}HoM2wr0C0r84B9WM3f&)dp02Kqu=ut-cZ;{WEG1tk* z#y4rEj9O@{7nmwm88r!}mKsZ!QKe{hYF^m2)slOz9!2vzG;%+7p=xUDhOZ9~U*Ge| zW4}(OOktbcrqt|XQ6^ar%hsf`pT7F#ASYk%*$&u>I)BiKb59UAJ0DBmiP1HgYFyss>fEE znpbrjd^u>v!3EB7;`|ie9DlUs?t*6tuKRkckK4aVTf0kR z269=CPL7#1b)01LMstx(gQ|5_8z-LLeejAy*NVkv;XT?9imqudm^zOA&WB_3{0`4H zV_T=WU7j9DmWyV${PUvw)z+8WDLr$tM|8GL>-V&@u;})%h_{;8j(5jzSsuFYWMipN zT70hO&uwh;L$1Zxy!+I(rR4IiEpI-)ee1e3uf)~jV??ibvjtZjEFW|kS+j(CaKbNo zL*jZHP4(}pD({)A_k_}57u2FMY8cE&5#tV1*SIO$nQ34!p01`8*Az^P!!cp8n8vt* z6}ti3;aRMlzvY+lKH=eGmq;F{d;1oz31$*-u`N5A>9jbK2^Y0sn&Y)#Zf_JaGQ1Si z@DuW7YORW&D3_{44HySpm1A!i&?-PI_HT)kV1J!NO|V2I4xN=5_Yyeg%2qnHZtb}# zclptLdODMgyL4yAGBHeab*Jjc@^BoufVf3LL4h#W@D>w?FY?ENK|{GOc}?AR&}9lDaWd6g!1UV!GAg3|$`iFFSx?Y5qkQTE+qkZckC4*)&|| zzVsceG8#UY9r5mfw&k)KQKxCE?a|_G(jIH0ECOCm>(FH7?(sX4k_u5ymlZjD>hqT}4o%kLF+_dK3plRfLu@!xuB z=1qB9b3$AY@3&#@_0adRloBaH-$(dif4KSIs%;#5tGt{GgDbX;8T$0(RPTcJRM3&430rQwzftNdJijS!3`!V3EKc$#Z*=?Y zhx3c&akp}L;Z`wX!TJe5Kkn4y%-fcwg(n2FTW|{91u7Zya#GN0|7~jqOf*%E@IOB6 z((5C$MpcS4)y%*RzaM4o8?ydd*A|C8+5Im*2zFgJh`ZIyRF!ox?0$n|p*x<>dD-Qo z^7J~+q*JH2xObYZaM$E^*l#_)e?7TkY+qVX}42v1}qG9LjMLpB4$0ld=ja06!oSu50o^a3X z_@P$wb5fYpqNQesW>&Y#iCNfa$Saqr*7+MZb$ZWc%1nxwGETZ~$Kgq=D$bI#0Lyr> zn8QX>I{M$@$zh+sCdsmIQNPn9svw>k4(nT<39rw!GJa@2yr71-U!h^oft{x{6C`E= zgPCBw=d>cIh{5Q8d`~Q+J&mlNWOvE@dC41=xzbgCXvD}w!`YdShDr)=9pp4bZjKIN5tEJYy=R&5wy>s2f@_e7dCDAP&SnjU2 zFW5b;{j)#swCrW$9@|~8utuct(~jsvb3u|I&Rq2=;xG} z2f+)hA2o^I>AW>!NaWqU`_)A^)epRG?1`Fr@Yz1s9#=<9coG}UEL%14#*^OjYd&0C zmw9_{RcZ0l3r}MnM7LOGFIc*4XjaMnvFU@;*87dT*kewgJp}^6?@x303nuwY3TYj` z_tvP0F$c`L9{hPpxSw|V8|B-<{GLAcefv+J)gj)0Of#@U+} zMvphI+YX~;hO0Wm5vk}&V9&e|NHJ{)X>ntfo5B{;XqA3T=l|HC^;21wq|2C z<&3q#_j4E)Yyn?vb86o{G1=_;)opID*(EXwOk5ofn_bx7ZFYXr zx}ENC_-mQc`B->9yR?caoyL?-HYiERVoFCa9qYQIsRsUk*B#!xGgMNIUmm=&lBf%% zc^YB1HkS!8Frb+LH!;7lQCuXA#E%pZ&yYfNBn{#iI0mSTwdtayLVjaomjDix?7mqq z%9qTznOx{1Ja&tdw;}TD=`>0N=(lug&(t7-o9^tG2(H8TZOGh(gUo4+s}bHRPT z*!lMJgT5zw&)XOs%sa%}cWBMpd+RS>bsXI-vS*NZU~`w@wXd4Lz3$V7FQ2hKbxgKW zwQP%ae+Y-Wl=2pIDC=k+n`!>zhS=A)CJlF0IS!3nHt1f6w`|e=zKQAO`x{GJRh8ek z^78GA1`B32zjb0s)#=~*N<;7THktE72W|oP47WDl-C?&xvg!FRhZ?bW-w6H5O7Pot znctJDKNj?u`GZ}aJZ?R+&^hMwg$+%z^Y7QZ|1j=X^ODE%wlyD^r|hm1 zZ`{bwl}>JdW^VVm_&p^(JQobM6?+st3+2^z{B!y7#eMfK7(Khk!0vIKBYzA#GJ8;O zUP|NQ!juhTMhEE8tb+(Hzit7O+4FP&*?z1ZsLl|RNN7g;VH?U}Lehgl)_TrO?CwR}*Fvz${Lej#(# zQdV)dCLhCB-8_B)tqkxn(t3J=%UFrCHvfJ(?^}_A$PR)+&-#PKcwJaz9 zpMOo5o8K{@-4EQ0%VXb+5nNllJ$qZ$+^LhbHovaf6zVkOkG02Z`0KV7#eKT^Xj0C~ zk|S?&cJ~}!B}E~xd|Nur+mUo?^F+%#f#S6H?mJsm%xJbxR23@<^i483c5zVfgZY~a z&Ux27e4Qug-{-N{q0<)IGG`4K9UR$ZUAN>{n=CjplOIU)S+9R;^eQo9{;6rp;*(m= zexiE0s?m__3V&6AMQv^Ti8HrHKkK}4(PxK9htrkQ(l-X!-hY{~MmV8Im>`h9>ioEw zM+e#@oVQ3l|Ni>$V<*bihaYGCbo2x3X4L7M&x+c34Q(KZTTo{Ai7B&tZx{(`~ia@$p&i{FNe znlWCw>W!1LB?|a(Avr0DADI-_CIY1P4G4>h@QsWN3l%kGn&5gYd)Iol$?#pgFMQvS zo5$CG(@|Y!6$??QcT5@UR(&Lj3auHQSk>pnFXXK)6>4l)_<}Ix-=YZp$XNFE->dMA zB-Y2F7!rqqi53NlT8o3kt#xrIh)U_v|CRFuYyI1c28Ayg6kIgmP3;TsW6O8#%wI9A z-SlP&Q`hYp^LgFPktZxJAMH4}Z*BZ0=kSqluay0Hw9Ut;lA~7JitjEy@tgnTHotwC zX!>EmD8_%)INk6C8THGG)ZWD#ZdSG0 zBS|@3U0$*M*@_pFeowo7#Zle*R=byt*z}reB#c1WqZGSaid4=q14b9doq ztl=sX|Ma!$F%CK3nK(X(eh@e?`@_mzn?KxM#toDl$of>+HT?d^OAp5hCFjMy>!|R_ zqZg>MO)m8cN+@``(shH+psBJQsCVjb2c0UYb!`F~+mG+fuReJ8^!4|ve(|?+AJpAj zu&Tka3(c}ThE6>casTCEA=Kp5&A1-{m%)C5CyM?!PD5H)u+}i`+vSxlC_- z(#(G15DAl7%S2fJ-hcGSCvogQKaSR$FDn;p4j8nU)-~Q z)Qg^-%Ecqyw34jJX{E`vr>1tDviHE!zGo!%O2HwQcjYBJZb&{v?QP!JE6Yyp;xV=+ zCSy!OdTrm21@7&i_sCzpYiw9-NVhZAbGRL{hQH4IkyRNn?Ahs6#D|?f9*OANufZIO6Ym*Y z=c(?4r@H;OA%X9@rvH|Z!1+JAADi@WVW0HuGwr8U^uBmNPw>->SF;(|1=h0a({F;%iD);&gfV=kkx+fq6HqR4Zkiu{#vyA6zBGePw#u= zHe@#JJD7Q7z>U`ro)6yj)AD&u@4VajG$*--Y0GY95q5uWOB#RtRe!s&gN}!UgwFn@ zkJINq@A^3f&hY9UqkR@;bGT;D@I%92v>w{4qw9;AgEs_ri;yaYiSY7lcj_r?N#&%}7CSe8WZ%l0FYeO(V@i$Rr_J{!`tL|jn{~BE$fMs+ z&djVB|9L?A@M{OVm``qYJNQY%E(4`=i#>Ap&snsv-TUD~D+g2zUYdLM)|_{ZKLlNx z_Uh0QUS;{>UGrSlvcpDf-BdE$Gl;*b>Aj36Z(i*gCQWT>T_gylNcStSQgpICPK+0YTsZ?zq0cB8L$hNr3I%DMzM)vn)fp&JiGCX1)Gc_ZsI z_~F~-omaiNt{x`IQ5CExJ+{njb?}ZShmKt;+o(R#_|?`?lv~N4jmCH<2e0pa<*;SS z%%UGOZB6gb@O?btroYgx#p@salAC+HIlMaViePK)imR3DmxV1na;jly?9K9b-m@0j zW-{k?XvHx%q{Xjij`eHwlSfVJrnSFBw5v)OcyYnmgDH39*L&|8_uelSHsQe-O}LzvRxH|u<%m|^+tXqbZ`J4pCM{1EnC}jG-D^6l8iIDEC5wms zhc_;xS7sdeC;c3B&r7tA@pQJ`3ayNq)A*IVA)11(wRAO)F~!YTCJXor>he^1 zwecARL}rziqGk8(JKeo-PO)*yiL6CV79*F>o=_HSvnkC6>}Srq|v)k=550FL@bc|{b@hL=FS@vPc4kbfAKTdl6TLUxy8B(vf*<0PFD7n|R$Bh_yFV~uuRo;Kd6I=6Ss$u`gN?h zR(PMPzT&!Cwt3EdJNkU@A#JKBzBcLYcjxdk(+s(-N5s>~>HU*ZH_YYLzI)Tr+O6Bw gGVzd5lhXA8$?m@{PL7qI{do6nltqEyD%>Xi4>-*U&;S4c literal 0 HcmV?d00001 diff --git a/src/MessagePack.UnityClient/Assets/Packages/Microsoft.Bcl.AsyncInterfaces.6.0.0/lib/net461/Microsoft.Bcl.AsyncInterfaces.dll.meta b/src/MessagePack.UnityClient/Assets/Packages/Microsoft.Bcl.AsyncInterfaces.6.0.0/lib/net461/Microsoft.Bcl.AsyncInterfaces.dll.meta new file mode 100644 index 000000000..4ce9ce2b2 --- /dev/null +++ b/src/MessagePack.UnityClient/Assets/Packages/Microsoft.Bcl.AsyncInterfaces.6.0.0/lib/net461/Microsoft.Bcl.AsyncInterfaces.dll.meta @@ -0,0 +1,23 @@ +fileFormatVersion: 2 +guid: d38694dd2ad1dd94190676c0e5a2154e +labels: +- NuGetForUnity +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + defineConstraints: [] + isPreloaded: 0 + isOverridable: 0 + isExplicitlyReferenced: 0 + validateReferences: 1 + platformData: + - first: + Any: + second: + enabled: 1 + settings: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/src/MessagePack.UnityClient/Assets/Packages/Microsoft.Bcl.AsyncInterfaces.6.0.0/lib/net461/Microsoft.Bcl.AsyncInterfaces.xml b/src/MessagePack.UnityClient/Assets/Packages/Microsoft.Bcl.AsyncInterfaces.6.0.0/lib/net461/Microsoft.Bcl.AsyncInterfaces.xml new file mode 100644 index 000000000..cb1744f60 --- /dev/null +++ b/src/MessagePack.UnityClient/Assets/Packages/Microsoft.Bcl.AsyncInterfaces.6.0.0/lib/net461/Microsoft.Bcl.AsyncInterfaces.xml @@ -0,0 +1,223 @@ + + + + Microsoft.Bcl.AsyncInterfaces + + + + Provides the core logic for implementing a manual-reset or . + + + + + The callback to invoke when the operation completes if was called before the operation completed, + or if the operation completed before a callback was supplied, + or null if a callback hasn't yet been provided and the operation hasn't yet completed. + + + + State to pass to . + + + to flow to the callback, or null if no flowing is required. + + + + A "captured" or with which to invoke the callback, + or null if no special context is required. + + + + Whether the current operation has completed. + + + The result with which the operation succeeded, or the default value if it hasn't yet completed or failed. + + + The exception with which the operation failed, or null if it hasn't yet completed or completed successfully. + + + The current version of this value, used to help prevent misuse. + + + Gets or sets whether to force continuations to run asynchronously. + Continuations may run asynchronously if this is false, but they'll never run synchronously if this is true. + + + Resets to prepare for the next operation. + + + Completes with a successful result. + The result. + + + Complets with an error. + + + + Gets the operation version. + + + Gets the status of the operation. + Opaque value that was provided to the 's constructor. + + + Gets the result of the operation. + Opaque value that was provided to the 's constructor. + + + Schedules the continuation action for this operation. + The continuation to invoke when the operation has completed. + The state object to pass to when it's invoked. + Opaque value that was provided to the 's constructor. + The flags describing the behavior of the continuation. + + + Ensures that the specified token matches the current version. + The token supplied by . + + + Signals that the operation has completed. Invoked after the result or error has been set. + + + + Invokes the continuation with the appropriate captured context / scheduler. + This assumes that if is not null we're already + running within that . + + + + Provides a set of static methods for configuring -related behaviors on asynchronous enumerables and disposables. + + + Configures how awaits on the tasks returned from an async disposable will be performed. + The source async disposable. + Whether to capture and marshal back to the current context. + The configured async disposable. + + + Configures how awaits on the tasks returned from an async iteration will be performed. + The type of the objects being iterated. + The source enumerable being iterated. + Whether to capture and marshal back to the current context. + The configured enumerable. + + + Sets the to be passed to when iterating. + The type of the objects being iterated. + The source enumerable being iterated. + The to use. + The configured enumerable. + + + Represents a builder for asynchronous iterators. + + + Creates an instance of the struct. + The initialized instance. + + + Invokes on the state machine while guarding the . + The type of the state machine. + The state machine instance, passed by reference. + + + Schedules the state machine to proceed to the next action when the specified awaiter completes. + The type of the awaiter. + The type of the state machine. + The awaiter. + The state machine. + + + Schedules the state machine to proceed to the next action when the specified awaiter completes. + The type of the awaiter. + The type of the state machine. + The awaiter. + The state machine. + + + Marks iteration as being completed, whether successfully or otherwise. + + + Gets an object that may be used to uniquely identify this builder to the debugger. + + + Indicates whether a method is an asynchronous iterator. + + + Initializes a new instance of the class. + The type object for the underlying state machine type that's used to implement a state machine method. + + + Provides a type that can be used to configure how awaits on an are performed. + + + Provides an awaitable async enumerable that enables cancelable iteration and configured awaits. + + + Configures how awaits on the tasks returned from an async iteration will be performed. + Whether to capture and marshal back to the current context. + The configured enumerable. + This will replace any previous value set by for this iteration. + + + Sets the to be passed to when iterating. + The to use. + The configured enumerable. + This will replace any previous set by for this iteration. + + + Provides an awaitable async enumerator that enables cancelable iteration and configured awaits. + + + Advances the enumerator asynchronously to the next element of the collection. + + A that will complete with a result of true + if the enumerator was successfully advanced to the next element, or false if the enumerator has + passed the end of the collection. + + + + Gets the element in the collection at the current position of the enumerator. + + + + Performs application-defined tasks associated with freeing, releasing, or + resetting unmanaged resources asynchronously. + + + + Exposes an enumerator that provides asynchronous iteration over values of a specified type. + The type of values to enumerate. + + + Returns an enumerator that iterates asynchronously through the collection. + A that may be used to cancel the asynchronous iteration. + An enumerator that can be used to iterate asynchronously through the collection. + + + Supports a simple asynchronous iteration over a generic collection. + The type of objects to enumerate. + + + Advances the enumerator asynchronously to the next element of the collection. + + A that will complete with a result of true if the enumerator + was successfully advanced to the next element, or false if the enumerator has passed the end + of the collection. + + + + Gets the element in the collection at the current position of the enumerator. + + + Provides a mechanism for releasing unmanaged resources asynchronously. + + + + Performs application-defined tasks associated with freeing, releasing, or + resetting unmanaged resources asynchronously. + + + + diff --git a/src/MessagePack.UnityClient/Assets/Packages/Microsoft.Bcl.AsyncInterfaces.6.0.0/lib/net461/Microsoft.Bcl.AsyncInterfaces.xml.meta b/src/MessagePack.UnityClient/Assets/Packages/Microsoft.Bcl.AsyncInterfaces.6.0.0/lib/net461/Microsoft.Bcl.AsyncInterfaces.xml.meta new file mode 100644 index 000000000..2074e8e4a --- /dev/null +++ b/src/MessagePack.UnityClient/Assets/Packages/Microsoft.Bcl.AsyncInterfaces.6.0.0/lib/net461/Microsoft.Bcl.AsyncInterfaces.xml.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: dbea2514bff46e24e8d1b77ac6958102 +TextScriptImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/src/MessagePack.UnityClient/Assets/Packages/Microsoft.Bcl.AsyncInterfaces.6.0.0/useSharedDesignerContext.txt b/src/MessagePack.UnityClient/Assets/Packages/Microsoft.Bcl.AsyncInterfaces.6.0.0/useSharedDesignerContext.txt new file mode 100644 index 000000000..e69de29bb diff --git a/src/MessagePack.UnityClient/Assets/Packages/Microsoft.Bcl.AsyncInterfaces.6.0.0/useSharedDesignerContext.txt.meta b/src/MessagePack.UnityClient/Assets/Packages/Microsoft.Bcl.AsyncInterfaces.6.0.0/useSharedDesignerContext.txt.meta new file mode 100644 index 000000000..847dbaf04 --- /dev/null +++ b/src/MessagePack.UnityClient/Assets/Packages/Microsoft.Bcl.AsyncInterfaces.6.0.0/useSharedDesignerContext.txt.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: a874ba50dfab254488475e4448c73ff0 +TextScriptImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/src/MessagePack.UnityClient/Assets/Packages/Microsoft.NET.StringTools.17.6.3.meta b/src/MessagePack.UnityClient/Assets/Packages/Microsoft.NET.StringTools.17.6.3.meta new file mode 100644 index 000000000..ff955d346 --- /dev/null +++ b/src/MessagePack.UnityClient/Assets/Packages/Microsoft.NET.StringTools.17.6.3.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 0b0874f4ec69dae45bb529391abc2a51 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/src/MessagePack.UnityClient/Assets/Packages/Microsoft.NET.StringTools.17.6.3/.signature.p7s b/src/MessagePack.UnityClient/Assets/Packages/Microsoft.NET.StringTools.17.6.3/.signature.p7s new file mode 100644 index 0000000000000000000000000000000000000000..9a0f0439f1443d53a0554687b696cb64843eb24f GIT binary patch literal 22799 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

S<&4y{bW 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 SX1L>Kyv_PplP);F@P7ad76fbn literal 0 HcmV?d00001 diff --git a/src/MessagePack.UnityClient/Assets/Packages/Microsoft.NET.StringTools.17.6.3/MSBuild-NuGet-Icon.png b/src/MessagePack.UnityClient/Assets/Packages/Microsoft.NET.StringTools.17.6.3/MSBuild-NuGet-Icon.png new file mode 100644 index 0000000000000000000000000000000000000000..a0f1fdbf4d5eae0e561018cccee74f6a454cdb9c GIT binary patch literal 7006 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 literal 0 HcmV?d00001 diff --git a/src/MessagePack.UnityClient/Assets/Packages/Microsoft.NET.StringTools.17.6.3/MSBuild-NuGet-Icon.png.meta b/src/MessagePack.UnityClient/Assets/Packages/Microsoft.NET.StringTools.17.6.3/MSBuild-NuGet-Icon.png.meta new file mode 100644 index 000000000..020ea2ca1 --- /dev/null +++ b/src/MessagePack.UnityClient/Assets/Packages/Microsoft.NET.StringTools.17.6.3/MSBuild-NuGet-Icon.png.meta @@ -0,0 +1,123 @@ +fileFormatVersion: 2 +guid: 2b34f3c8627a6d747b26b4b4841e8f6c +TextureImporter: + internalIDToNameTable: [] + externalObjects: {} + serializedVersion: 12 + mipmaps: + mipMapMode: 0 + enableMipMap: 1 + sRGBTexture: 1 + linearTexture: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapsPreserveCoverage: 0 + alphaTestReferenceValue: 0.5 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 0 + streamingMipmaps: 0 + streamingMipmapsPriority: 0 + vTOnly: 0 + ignoreMasterTextureLimit: 0 + grayScaleToAlpha: 0 + generateCubemap: 6 + cubemapConvolution: 0 + seamlessCubemap: 0 + textureFormat: 1 + maxTextureSize: 2048 + textureSettings: + serializedVersion: 2 + filterMode: 1 + aniso: 1 + mipBias: 0 + wrapU: 0 + wrapV: 0 + wrapW: 0 + nPOTScale: 1 + lightmap: 0 + compressionQuality: 50 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spritePixelsToUnits: 100 + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spriteGenerateFallbackPhysicsShape: 1 + alphaUsage: 1 + alphaIsTransparency: 0 + spriteTessellationDetail: -1 + textureType: 0 + textureShape: 1 + singleChannelComponent: 0 + flipbookRows: 1 + flipbookColumns: 1 + maxTextureSizeSet: 0 + compressionQualitySet: 0 + textureFormatSet: 0 + ignorePngGamma: 0 + applyGammaDecoding: 0 + cookieLightType: 0 + platformSettings: + - serializedVersion: 3 + buildTarget: DefaultTexturePlatform + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + - serializedVersion: 3 + buildTarget: Standalone + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + - serializedVersion: 3 + buildTarget: Server + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + spriteSheet: + serializedVersion: 2 + sprites: [] + outline: [] + physicsShape: [] + bones: [] + spriteID: + internalID: 0 + vertices: [] + indices: + edges: [] + weights: [] + secondaryTextures: [] + nameFileIdTable: {} + spritePackingTag: + pSDRemoveMatte: 0 + pSDShowRemoveMatteOption: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/src/MessagePack.UnityClient/Assets/Packages/Microsoft.NET.StringTools.17.6.3/Microsoft.NET.StringTools.nuspec b/src/MessagePack.UnityClient/Assets/Packages/Microsoft.NET.StringTools.17.6.3/Microsoft.NET.StringTools.nuspec new file mode 100644 index 000000000..32db47d34 --- /dev/null +++ b/src/MessagePack.UnityClient/Assets/Packages/Microsoft.NET.StringTools.17.6.3/Microsoft.NET.StringTools.nuspec @@ -0,0 +1,32 @@ + + + + Microsoft.NET.StringTools + 17.6.3 + Microsoft + true + MIT + https://licenses.nuget.org/MIT + MSBuild-NuGet-Icon.png + README.md + http://go.microsoft.com/fwlink/?LinkId=624683 + https://go.microsoft.com/fwlink/?linkid=825694 + This package contains the Microsoft.NET.StringTools assembly which implements common string-related functionality such as weak interning. + © Microsoft Corporation. All rights reserved. + MSBuild + true + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/MessagePack.UnityClient/Assets/Packages/Microsoft.NET.StringTools.17.6.3/Microsoft.NET.StringTools.nuspec.meta b/src/MessagePack.UnityClient/Assets/Packages/Microsoft.NET.StringTools.17.6.3/Microsoft.NET.StringTools.nuspec.meta new file mode 100644 index 000000000..ae4d3a4f3 --- /dev/null +++ b/src/MessagePack.UnityClient/Assets/Packages/Microsoft.NET.StringTools.17.6.3/Microsoft.NET.StringTools.nuspec.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 3b93f3278451aa24abd38577df5f36f8 +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/src/MessagePack.UnityClient/Assets/Packages/Microsoft.NET.StringTools.17.6.3/README.md b/src/MessagePack.UnityClient/Assets/Packages/Microsoft.NET.StringTools.17.6.3/README.md new file mode 100644 index 000000000..76545b3e5 --- /dev/null +++ b/src/MessagePack.UnityClient/Assets/Packages/Microsoft.NET.StringTools.17.6.3/README.md @@ -0,0 +1,5 @@ +# Microsoft.NET.StringTools + +This package contains the Microsoft.NET.StringTools assembly which implements common string-related functionality such as weak interning. + +At this time, this is primarily an internal implementation detail of MSBuild and Visual Studio and we do not expect other consumers of the package. If you think you might like to use it, please start a discussion at https://github.com/dotnet/msbuild/discussions to let us know your use cases. diff --git a/src/MessagePack.UnityClient/Assets/Packages/Microsoft.NET.StringTools.17.6.3/README.md.meta b/src/MessagePack.UnityClient/Assets/Packages/Microsoft.NET.StringTools.17.6.3/README.md.meta new file mode 100644 index 000000000..b9e40b785 --- /dev/null +++ b/src/MessagePack.UnityClient/Assets/Packages/Microsoft.NET.StringTools.17.6.3/README.md.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: ffefda41aa9c9634eac066109de0cd9a +TextScriptImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/src/MessagePack.UnityClient/Assets/Packages/Microsoft.NET.StringTools.17.6.3/lib.meta b/src/MessagePack.UnityClient/Assets/Packages/Microsoft.NET.StringTools.17.6.3/lib.meta new file mode 100644 index 000000000..32f6c8478 --- /dev/null +++ b/src/MessagePack.UnityClient/Assets/Packages/Microsoft.NET.StringTools.17.6.3/lib.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 84de30caec705834499cb73207984f22 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/src/MessagePack.UnityClient/Assets/Packages/Microsoft.NET.StringTools.17.6.3/lib/net472.meta b/src/MessagePack.UnityClient/Assets/Packages/Microsoft.NET.StringTools.17.6.3/lib/net472.meta new file mode 100644 index 000000000..4f6cb8fdc --- /dev/null +++ b/src/MessagePack.UnityClient/Assets/Packages/Microsoft.NET.StringTools.17.6.3/lib/net472.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: b206445ffa07ce543966d89006307945 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/src/MessagePack.UnityClient/Assets/Packages/Microsoft.NET.StringTools.17.6.3/lib/net472/Microsoft.NET.StringTools.dll b/src/MessagePack.UnityClient/Assets/Packages/Microsoft.NET.StringTools.17.6.3/lib/net472/Microsoft.NET.StringTools.dll new file mode 100644 index 0000000000000000000000000000000000000000..4c4d3ffda4dd1cba308fd5f32f1a05088abbb383 GIT binary patch literal 30336 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 literal 0 HcmV?d00001 diff --git a/src/MessagePack.UnityClient/Assets/Packages/Microsoft.NET.StringTools.17.6.3/lib/net472/Microsoft.NET.StringTools.dll.meta b/src/MessagePack.UnityClient/Assets/Packages/Microsoft.NET.StringTools.17.6.3/lib/net472/Microsoft.NET.StringTools.dll.meta new file mode 100644 index 000000000..6ece78d0b --- /dev/null +++ b/src/MessagePack.UnityClient/Assets/Packages/Microsoft.NET.StringTools.17.6.3/lib/net472/Microsoft.NET.StringTools.dll.meta @@ -0,0 +1,23 @@ +fileFormatVersion: 2 +guid: 8e445e13368969245be57a5c68243fb0 +labels: +- NuGetForUnity +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + defineConstraints: [] + isPreloaded: 0 + isOverridable: 0 + isExplicitlyReferenced: 0 + validateReferences: 1 + platformData: + - first: + Any: + second: + enabled: 1 + settings: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/src/MessagePack.UnityClient/Assets/Packages/Microsoft.NET.StringTools.17.6.3/lib/net472/Microsoft.NET.StringTools.xml b/src/MessagePack.UnityClient/Assets/Packages/Microsoft.NET.StringTools.17.6.3/lib/net472/Microsoft.NET.StringTools.xml new file mode 100644 index 000000000..6cc400d51 --- /dev/null +++ b/src/MessagePack.UnityClient/Assets/Packages/Microsoft.NET.StringTools.17.6.3/lib/net472/Microsoft.NET.StringTools.xml @@ -0,0 +1,492 @@ + + + + Microsoft.NET.StringTools + + + +

+ Represents a string that can be converted to System.String with interning, i.e. by returning an existing string if it has been seen before + and is still tracked in the intern table. + + + + + Enumerator for the top-level struct. Enumerates characters of the string. + + + + + The InternableString being enumerated. + + + + + Index of the current span, -1 represents the inline span. + + + + + Index of the current character in the current span, -1 if MoveNext has not been called yet. + + + + + Returns the current character. + + + + + Moves to the next character. + + True if there is another character, false if the enumerator reached the end. + + + + The span held by this struct, inline to be able to represent . May be empty. + + + + + Additional spans held by this struct. May be null. + + + + + Constructs a new InternableString wrapping the given . + + The span to wrap. + + When wrapping a span representing an entire System.String, use Internable(string) for optimum performance. + + + + + Constructs a new InternableString wrapping the given string. + + The string to wrap, must be non-null. + + + + Constructs a new InternableString wrapping the given SpanBasedStringBuilder. + + + + + Gets the length of the string. + + + + + Creates a new enumerator for enumerating characters in this string. Does not allocate. + + The enumerator. + + + + Returns true if the string is equal to another string by ordinal comparison. + + Another string. + True if this string is equal to . + + + + Returns a System.String representing this string. Allocates memory unless this InternableString was created by wrapping a + System.String in which case the original string is returned. + + The string. + + + + Returns true if this InternableString wraps a System.String and the same System.String is passed as the argument. + + The string to compare to. + True is this instance wraps the given string. + + + + Converts this instance to a System.String while first searching for a match in the intern table. + + + May allocate depending on whether the string has already been interned. + + + + + Implements the simple yet very decently performing djb2-like hash function (xor version) as inspired by + https://github.com/dotnet/runtime/blob/6262ae8e6a33abac569ab6086cdccc470c810ea4/src/libraries/System.Private.CoreLib/src/System/String.Comparison.cs#L810-L840 + + A stable hashcode of the string represented by this instance. + + Unlike the BCL method, this implementation works only on two characters at a time to cut on the complexity with + characters that feed into the same operation but straddle multiple spans. Note that it must return the same value for + a given string regardless of how it's split into spans (e.g. { "AB" } and { "A", "B" } have the same hash code). + + + + + Hashes a memory block specified by a pointer and length. + + Pointer to the first character. + Number of characters at . + The running hash code. + True if the incoming was calculated from an odd number of characters. + The updated running hash code (not passed as a ref parameter to play nicely with JIT optimizations). + + + + Rotates an integer by the specified number of bits. + + The value to rotate. + The number of bits. + The rotated value. + + + + A StringBuilder replacement that keeps a list of spans making up the intermediate string rather + than a copy of its characters. This has positive impact on both memory (no need to allocate space for the intermediate string) + and time (no need to copy characters to the intermediate string). + + + The method tries to intern the resulting string without even allocating it if it's already interned. + Use to take advantage of pooling to eliminate allocation overhead of this class. + + + + + Enumerator for the top-level class. Enumerates characters of the string. + + + + + The spans being enumerated. + + + + + Index of the current span. + + + + + Index of the current character in the current span, -1 if MoveNext has not been called yet. + + + + + Returns the current character. + + + + + Moves to the next character. + + True if there is another character, false if the enumerator reached the end. + + + + Spans making up the rope. + + + + + Internal getter to get the list of spans out of the SpanBasedStringBuilder. + + + + + Constructs a new SpanBasedStringBuilder containing the given string. + + The string to wrap, must be non-null. + + + + Constructs a new empty SpanBasedStringBuilder with the given expected number of spans. + + + + + Gets the length of the string. + + + + + Gets the capacity of the SpanBasedStringBuilder in terms of number of spans it can hold without allocating. + + + + + Creates a new enumerator for enumerating characters in this string. Does not allocate. + + The enumerator. + + + + Converts this instance to a System.String while first searching for a match in the intern table. + + + May allocate depending on whether the string has already been interned. + + + + + Releases this instance. + + + + + Appends a string. + + The string to append. + + + + Appends a substring. + + The string to append. + The start index of the substring within to append. + The length of the substring to append. + + + + Appends a character span represented by . + + The character span to append. + + + + Removes leading white-space characters from the string. + + + + + Removes trailing white-space characters from the string. + + + + + Removes leading and trailing white-space characters from the string. + + + + + Clears this instance making it represent an empty string. + + + + + Per-thread instance of the SpanBasedStringBuilder, created lazily. + + + This field serves as a per-thread one-item object pool, which is adequate for most use + cases as the builder is not expected to be held for extended periods of time. + + + + + Interns the given string, keeping only a weak reference to the returned value. + + The string to intern. + A string equal to , could be the same object as . + + The intern pool does not retain strong references to the strings it's holding so strings are automatically evicted + after they become unrooted. This is in contrast to System.String.Intern which holds strings forever. + + + + + Interns the given readonly span of characters, keeping only a weak reference to the returned value. + + The character span to intern. + A string equal to , could be the result of calling ToString() on . + + The intern pool does not retain strong references to the strings it's holding so strings are automatically evicted + after they become unrooted. This is in contrast to System.String.Intern which holds strings forever. + + + + + Returns a new or recycled . + + The SpanBasedStringBuilder. + + Call on the returned instance to recycle it. + + + + + Enables diagnostics in the interner. Call to retrieve the diagnostic data. + + + + + Retrieves the diagnostic data describing the current state of the interner. Make sure to call beforehand. + + + + + Returns a instance back to the pool if possible. + + The instance to return. + + + + Implements the WeakStringCache functionality on modern .NET versions where ConcurrentDictionary is available. + + + A cache of weak GC handles pointing to strings. Weak GC handles are functionally equivalent to WeakReference's but have less overhead + (they're a struct as opposed to WR which is a finalizable class) at the expense of requiring manual lifetime management. As long as + a string has an ordinary strong GC root elsewhere in the process and another string with the same hashcode hasn't reused the entry, + the cache has a reference to it and can match it to an internable. When the string is collected, it is also automatically "removed" + from the cache by becoming unrecoverable from the GC handle. GC handles that do not reference a live string anymore are freed lazily. + + + + + Main entrypoint of this cache. Tries to look up a string that matches the given internable. If it succeeds, returns + the string and sets cacheHit to true. If the string is not found, calls ExpensiveConvertToString on the internable, + adds the resulting string to the cache, and returns it, setting cacheHit to false. + + The internable describing the string we're looking for. + true if match found in cache, false otherwise. + A string matching the given internable. + + + + Iterates over the cache and removes unused GC handles, i.e. handles that don't reference live strings. + This is expensive so try to call such that the cost is amortized to O(1) per GetOrCreateEntry() invocation. + + + + + Returns internal debug counters calculated based on the current state of the cache. + + + + + Debug stats returned by GetDebugInfo(). + + + + + Holds a weak GC handle to a string. Shared by all strings with the same hash code and referencing the last such string we've seen. + + + + + Weak GC handle to the last string of the given hashcode we've seen. + + + + + Returns true if the string referenced by the handle is still alive. + + + + + Returns the string referenced by this handle if it is equal to the given internable. + + The internable describing the string we're looking for. + The string matching the internable or null if the handle is referencing a collected string or the string is different. + + + + Sets the handle to the given string. If the handle is still referencing another live string, that string is effectively forgotten. + + The string to set. + + + + Frees the GC handle. + + + + + Initial capacity of the underlying dictionary. + + + + + The maximum size we let the collection grow before scavenging unused entries. + + + + + Frees all GC handles and clears the cache. + + + + + Returns internal debug counters calculated based on the current state of the cache. + + + + + Implements interning based on a WeakStringCache. + + + + + Enumerates the possible interning results. + + + + + The cache to keep strings in. + + + + + Number of times the regular interning path found the string in the cache. + + + + + Number of times the regular interning path added the string to the cache. + + + + + Total number of strings eliminated by interning. + + + + + Total number of chars eliminated across all strings. + + + + + Maps strings that went though the interning path to the number of times they have been + seen. The higher the number the better the payoff of interning. Null if statistics + gathering has not been enabled. + + + + + Try to intern the string. + The return value indicates the how the string was interned. + + + + + WeakIntern the given InternableString. + + + + + + + + + + Returns a string with human-readable statistics. + + + + + Releases all strings from the underlying intern table. + + + + diff --git a/src/MessagePack.UnityClient/Assets/Packages/Microsoft.NET.StringTools.17.6.3/lib/net472/Microsoft.NET.StringTools.xml.meta b/src/MessagePack.UnityClient/Assets/Packages/Microsoft.NET.StringTools.17.6.3/lib/net472/Microsoft.NET.StringTools.xml.meta new file mode 100644 index 000000000..58b0a72d4 --- /dev/null +++ b/src/MessagePack.UnityClient/Assets/Packages/Microsoft.NET.StringTools.17.6.3/lib/net472/Microsoft.NET.StringTools.xml.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 1d16a4a1cd98e6e479034a859ff9736e +TextScriptImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/src/MessagePack.UnityClient/Assets/Packages/Microsoft.NET.StringTools.17.6.3/notices.meta b/src/MessagePack.UnityClient/Assets/Packages/Microsoft.NET.StringTools.17.6.3/notices.meta new file mode 100644 index 000000000..4a11b6f36 --- /dev/null +++ b/src/MessagePack.UnityClient/Assets/Packages/Microsoft.NET.StringTools.17.6.3/notices.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 654d05d440241d34db6c950ce1b86549 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/src/MessagePack.UnityClient/Assets/Packages/Microsoft.NET.StringTools.17.6.3/notices/THIRDPARTYNOTICES.txt b/src/MessagePack.UnityClient/Assets/Packages/Microsoft.NET.StringTools.17.6.3/notices/THIRDPARTYNOTICES.txt new file mode 100644 index 000000000..28661c086 --- /dev/null +++ b/src/MessagePack.UnityClient/Assets/Packages/Microsoft.NET.StringTools.17.6.3/notices/THIRDPARTYNOTICES.txt @@ -0,0 +1,46 @@ +MSBuild uses third-party material as listed below. The attached notices are +provided for informational purposes only. + +Notice for LockCheck +------------------------------- +The MIT License (MIT) + +Copyright (c) 2015 Christian Klutz + +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. + +------------------------------- + +Notice for Samples for xUnit.net +------------------------------- + +Copyright (c) .NET Foundation and Contributors + +All Rights Reserved + +Licensed under the Apache License, Version 2.0 (the "License"); you may not use +this file except in compliance with the License. + +You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software distributed +under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR +CONDITIONS OF ANY KIND, either express or implied. See the License for the specific +language governing permissions and limitations under the License. +------------------------------- diff --git a/src/MessagePack.UnityClient/Assets/Packages/Microsoft.NET.StringTools.17.6.3/notices/THIRDPARTYNOTICES.txt.meta b/src/MessagePack.UnityClient/Assets/Packages/Microsoft.NET.StringTools.17.6.3/notices/THIRDPARTYNOTICES.txt.meta new file mode 100644 index 000000000..cfcbd0093 --- /dev/null +++ b/src/MessagePack.UnityClient/Assets/Packages/Microsoft.NET.StringTools.17.6.3/notices/THIRDPARTYNOTICES.txt.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 8ac550355cb71274d8fa90d40116e51e +TextScriptImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/src/MessagePack.UnityClient/Assets/Packages/System.Collections.Immutable.6.0.0.meta b/src/MessagePack.UnityClient/Assets/Packages/System.Collections.Immutable.6.0.0.meta new file mode 100644 index 000000000..4b2b6af56 --- /dev/null +++ b/src/MessagePack.UnityClient/Assets/Packages/System.Collections.Immutable.6.0.0.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: d5ebbf01cf857f7498ad1ad99fa1b48a +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/src/MessagePack.UnityClient/Assets/Packages/System.Collections.Immutable.6.0.0/.signature.p7s b/src/MessagePack.UnityClient/Assets/Packages/System.Collections.Immutable.6.0.0/.signature.p7s new file mode 100644 index 0000000000000000000000000000000000000000..317c98c84fbcbd93032db71e3741cd2b4886e205 GIT binary patch literal 18702 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 NnJ_eiWi}3;|1Y7aLz@5q literal 0 HcmV?d00001 diff --git a/src/MessagePack.UnityClient/Assets/Packages/System.Collections.Immutable.6.0.0/Icon.png b/src/MessagePack.UnityClient/Assets/Packages/System.Collections.Immutable.6.0.0/Icon.png new file mode 100644 index 0000000000000000000000000000000000000000..a0f1fdbf4d5eae0e561018cccee74f6a454cdb9c GIT binary patch literal 7006 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 literal 0 HcmV?d00001 diff --git a/src/MessagePack.UnityClient/Assets/Packages/System.Collections.Immutable.6.0.0/Icon.png.meta b/src/MessagePack.UnityClient/Assets/Packages/System.Collections.Immutable.6.0.0/Icon.png.meta new file mode 100644 index 000000000..a64c6fcea --- /dev/null +++ b/src/MessagePack.UnityClient/Assets/Packages/System.Collections.Immutable.6.0.0/Icon.png.meta @@ -0,0 +1,123 @@ +fileFormatVersion: 2 +guid: 0f353ac9e363a2e45b90885c93196de5 +TextureImporter: + internalIDToNameTable: [] + externalObjects: {} + serializedVersion: 12 + mipmaps: + mipMapMode: 0 + enableMipMap: 1 + sRGBTexture: 1 + linearTexture: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapsPreserveCoverage: 0 + alphaTestReferenceValue: 0.5 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 0 + streamingMipmaps: 0 + streamingMipmapsPriority: 0 + vTOnly: 0 + ignoreMasterTextureLimit: 0 + grayScaleToAlpha: 0 + generateCubemap: 6 + cubemapConvolution: 0 + seamlessCubemap: 0 + textureFormat: 1 + maxTextureSize: 2048 + textureSettings: + serializedVersion: 2 + filterMode: 1 + aniso: 1 + mipBias: 0 + wrapU: 0 + wrapV: 0 + wrapW: 0 + nPOTScale: 1 + lightmap: 0 + compressionQuality: 50 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spritePixelsToUnits: 100 + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spriteGenerateFallbackPhysicsShape: 1 + alphaUsage: 1 + alphaIsTransparency: 0 + spriteTessellationDetail: -1 + textureType: 0 + textureShape: 1 + singleChannelComponent: 0 + flipbookRows: 1 + flipbookColumns: 1 + maxTextureSizeSet: 0 + compressionQualitySet: 0 + textureFormatSet: 0 + ignorePngGamma: 0 + applyGammaDecoding: 0 + cookieLightType: 0 + platformSettings: + - serializedVersion: 3 + buildTarget: DefaultTexturePlatform + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + - serializedVersion: 3 + buildTarget: Standalone + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + - serializedVersion: 3 + buildTarget: Server + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + spriteSheet: + serializedVersion: 2 + sprites: [] + outline: [] + physicsShape: [] + bones: [] + spriteID: + internalID: 0 + vertices: [] + indices: + edges: [] + weights: [] + secondaryTextures: [] + nameFileIdTable: {} + spritePackingTag: + pSDRemoveMatte: 0 + pSDShowRemoveMatteOption: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/src/MessagePack.UnityClient/Assets/Packages/System.Collections.Immutable.6.0.0/LICENSE.TXT b/src/MessagePack.UnityClient/Assets/Packages/System.Collections.Immutable.6.0.0/LICENSE.TXT new file mode 100644 index 000000000..984713a49 --- /dev/null +++ b/src/MessagePack.UnityClient/Assets/Packages/System.Collections.Immutable.6.0.0/LICENSE.TXT @@ -0,0 +1,23 @@ +The MIT License (MIT) + +Copyright (c) .NET Foundation and Contributors + +All rights reserved. + +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. diff --git a/src/MessagePack.UnityClient/Assets/Packages/System.Collections.Immutable.6.0.0/LICENSE.TXT.meta b/src/MessagePack.UnityClient/Assets/Packages/System.Collections.Immutable.6.0.0/LICENSE.TXT.meta new file mode 100644 index 000000000..80eee41df --- /dev/null +++ b/src/MessagePack.UnityClient/Assets/Packages/System.Collections.Immutable.6.0.0/LICENSE.TXT.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 07b47edb731840e4296d8f17a2fbf6c1 +TextScriptImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/src/MessagePack.UnityClient/Assets/Packages/System.Collections.Immutable.6.0.0/System.Collections.Immutable.nuspec b/src/MessagePack.UnityClient/Assets/Packages/System.Collections.Immutable.6.0.0/System.Collections.Immutable.nuspec new file mode 100644 index 000000000..be9151ee6 --- /dev/null +++ b/src/MessagePack.UnityClient/Assets/Packages/System.Collections.Immutable.6.0.0/System.Collections.Immutable.nuspec @@ -0,0 +1,48 @@ + + + + System.Collections.Immutable + 6.0.0 + Microsoft + MIT + https://licenses.nuget.org/MIT + Icon.png + https://dot.net/ + This package provides collections that are thread safe and guaranteed to never change their contents, also known as immutable collections. Like strings, any methods that perform modifications will not change the existing instance but instead return a new instance. For efficiency reasons, the implementation uses a sharing mechanism to ensure that newly created instances share as much data as possible with the previous instance while ensuring that operations have a predictable time complexity. + +Commonly Used Types: +System.Collections.Immutable.ImmutableArray +System.Collections.Immutable.ImmutableArray<T> +System.Collections.Immutable.ImmutableDictionary +System.Collections.Immutable.ImmutableDictionary<TKey,TValue> +System.Collections.Immutable.ImmutableHashSet +System.Collections.Immutable.ImmutableHashSet<T> +System.Collections.Immutable.ImmutableList +System.Collections.Immutable.ImmutableList<T> +System.Collections.Immutable.ImmutableQueue +System.Collections.Immutable.ImmutableQueue<T> +System.Collections.Immutable.ImmutableSortedDictionary +System.Collections.Immutable.ImmutableSortedDictionary<TKey,TValue> +System.Collections.Immutable.ImmutableSortedSet +System.Collections.Immutable.ImmutableSortedSet<T> +System.Collections.Immutable.ImmutableStack +System.Collections.Immutable.ImmutableStack<T> + https://go.microsoft.com/fwlink/?LinkID=799421 + © Microsoft Corporation. All rights reserved. + true + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/MessagePack.UnityClient/Assets/Packages/System.Collections.Immutable.6.0.0/System.Collections.Immutable.nuspec.meta b/src/MessagePack.UnityClient/Assets/Packages/System.Collections.Immutable.6.0.0/System.Collections.Immutable.nuspec.meta new file mode 100644 index 000000000..2b51723f6 --- /dev/null +++ b/src/MessagePack.UnityClient/Assets/Packages/System.Collections.Immutable.6.0.0/System.Collections.Immutable.nuspec.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 08614a2aa165b2c4bac2566ca44a954a +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/src/MessagePack.UnityClient/Assets/Packages/System.Collections.Immutable.6.0.0/THIRD-PARTY-NOTICES.TXT b/src/MessagePack.UnityClient/Assets/Packages/System.Collections.Immutable.6.0.0/THIRD-PARTY-NOTICES.TXT new file mode 100644 index 000000000..89c59b21d --- /dev/null +++ b/src/MessagePack.UnityClient/Assets/Packages/System.Collections.Immutable.6.0.0/THIRD-PARTY-NOTICES.TXT @@ -0,0 +1,939 @@ +.NET Runtime uses third-party libraries or other resources that may be +distributed under licenses different than the .NET Runtime software. + +In the event that we accidentally failed to list a required notice, please +bring it to our attention. Post an issue or email us: + + dotnet@microsoft.com + +The attached notices are provided for information only. + +License notice for ASP.NET +------------------------------- + +Copyright (c) .NET Foundation. All rights reserved. +Licensed under the Apache License, Version 2.0. + +Available at +https://github.com/dotnet/aspnetcore/blob/main/LICENSE.txt + +License notice for Slicing-by-8 +------------------------------- + +http://sourceforge.net/projects/slicing-by-8/ + +Copyright (c) 2004-2006 Intel Corporation - All Rights Reserved + + +This software program is licensed subject to the BSD License, available at +http://www.opensource.org/licenses/bsd-license.html. + + +License notice for Unicode data +------------------------------- + +https://www.unicode.org/license.html + +Copyright © 1991-2020 Unicode, Inc. All rights reserved. +Distributed under the Terms of Use in https://www.unicode.org/copyright.html. + +Permission is hereby granted, free of charge, to any person obtaining +a copy of the Unicode data files and any associated documentation +(the "Data Files") or Unicode software and any associated documentation +(the "Software") to deal in the Data Files or Software +without restriction, including without limitation the rights to use, +copy, modify, merge, publish, distribute, and/or sell copies of +the Data Files or Software, and to permit persons to whom the Data Files +or Software are furnished to do so, provided that either +(a) this copyright and permission notice appear with all copies +of the Data Files or Software, or +(b) this copyright and permission notice appear in associated +Documentation. + +THE DATA FILES AND SOFTWARE ARE 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 OF THIRD PARTY RIGHTS. +IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN THIS +NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL +DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, +DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER +TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +PERFORMANCE OF THE DATA FILES OR SOFTWARE. + +Except as contained in this notice, the name of a copyright holder +shall not be used in advertising or otherwise to promote the sale, +use or other dealings in these Data Files or Software without prior +written authorization of the copyright holder. + +License notice for Zlib +----------------------- + +https://github.com/madler/zlib +http://zlib.net/zlib_license.html + +/* zlib.h -- interface of the 'zlib' general purpose compression library + version 1.2.11, January 15th, 2017 + + Copyright (C) 1995-2017 Jean-loup Gailly and Mark Adler + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + + Jean-loup Gailly Mark Adler + jloup@gzip.org madler@alumni.caltech.edu + +*/ + +License notice for Mono +------------------------------- + +http://www.mono-project.com/docs/about-mono/ + +Copyright (c) .NET Foundation Contributors + +MIT License + +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. + +License notice for International Organization for Standardization +----------------------------------------------------------------- + +Portions (C) International Organization for Standardization 1986: + Permission to copy in any form is granted for use with + conforming SGML systems and applications as defined in + ISO 8879, provided this notice is included in all copies. + +License notice for Intel +------------------------ + +"Copyright (c) 2004-2006 Intel Corporation - All Rights Reserved + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +License notice for Xamarin and Novell +------------------------------------- + +Copyright (c) 2015 Xamarin, Inc (http://www.xamarin.com) + +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. + +Copyright (c) 2011 Novell, Inc (http://www.novell.com) + +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. + +Third party notice for W3C +-------------------------- + +"W3C SOFTWARE AND DOCUMENT NOTICE AND LICENSE +Status: This license takes effect 13 May, 2015. +This work is being provided by the copyright holders under the following license. +License +By obtaining and/or copying this work, you (the licensee) agree that you have read, understood, and will comply with the following terms and conditions. +Permission to copy, modify, and distribute this work, with or without modification, for any purpose and without fee or royalty is hereby granted, provided that you include the following on ALL copies of the work or portions thereof, including modifications: +The full text of this NOTICE in a location viewable to users of the redistributed or derivative work. +Any pre-existing intellectual property disclaimers, notices, or terms and conditions. If none exist, the W3C Software and Document Short Notice should be included. +Notice of any changes or modifications, through a copyright statement on the new code or document such as "This software or document includes material copied from or derived from [title and URI of the W3C document]. Copyright © [YEAR] W3C® (MIT, ERCIM, Keio, Beihang)." +Disclaimers +THIS WORK IS PROVIDED "AS IS," AND COPYRIGHT HOLDERS MAKE NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF THE SOFTWARE OR DOCUMENT WILL NOT INFRINGE ANY THIRD PARTY PATENTS, COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS. +COPYRIGHT HOLDERS WILL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF ANY USE OF THE SOFTWARE OR DOCUMENT. +The name and trademarks of copyright holders may NOT be used in advertising or publicity pertaining to the work without specific, written prior permission. Title to copyright in this work will at all times remain with copyright holders." + +License notice for Bit Twiddling Hacks +-------------------------------------- + +Bit Twiddling Hacks + +By Sean Eron Anderson +seander@cs.stanford.edu + +Individually, the code snippets here are in the public domain (unless otherwise +noted) — feel free to use them however you please. The aggregate collection and +descriptions are © 1997-2005 Sean Eron Anderson. The code and descriptions are +distributed in the hope that they will be useful, but WITHOUT ANY WARRANTY and +without even the implied warranty of merchantability or fitness for a particular +purpose. + +License notice for Brotli +-------------------------------------- + +Copyright (c) 2009, 2010, 2013-2016 by the Brotli Authors. + +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. + +compress_fragment.c: +Copyright (c) 2011, Google Inc. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above +copyright notice, this list of conditions and the following disclaimer +in the documentation and/or other materials provided with the +distribution. + * Neither the name of Google Inc. nor the names of its +contributors may be used to endorse or promote products derived from +this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +""AS IS"" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +decode_fuzzer.c: +Copyright (c) 2015 The Chromium Authors. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above +copyright notice, this list of conditions and the following disclaimer +in the documentation and/or other materials provided with the +distribution. + * Neither the name of Google Inc. nor the names of its +contributors may be used to endorse or promote products derived from +this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +""AS IS"" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." + +License notice for Json.NET +------------------------------- + +https://github.com/JamesNK/Newtonsoft.Json/blob/master/LICENSE.md + +The MIT License (MIT) + +Copyright (c) 2007 James Newton-King + +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. + +License notice for vectorized base64 encoding / decoding +-------------------------------------------------------- + +Copyright (c) 2005-2007, Nick Galbreath +Copyright (c) 2013-2017, Alfred Klomp +Copyright (c) 2015-2017, Wojciech Mula +Copyright (c) 2016-2017, Matthieu Darbois +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + +- Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + +- Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS +IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A +PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED +TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +License notice for RFC 3492 +--------------------------- + +The punycode implementation is based on the sample code in RFC 3492 + +Copyright (C) The Internet Society (2003). All Rights Reserved. + +This document and translations of it may be copied and furnished to +others, and derivative works that comment on or otherwise explain it +or assist in its implementation may be prepared, copied, published +and distributed, in whole or in part, without restriction of any +kind, provided that the above copyright notice and this paragraph are +included on all such copies and derivative works. However, this +document itself may not be modified in any way, such as by removing +the copyright notice or references to the Internet Society or other +Internet organizations, except as needed for the purpose of +developing Internet standards in which case the procedures for +copyrights defined in the Internet Standards process must be +followed, or as required to translate it into languages other than +English. + +The limited permissions granted above are perpetual and will not be +revoked by the Internet Society or its successors or assigns. + +This document and the information contained herein is provided on an +"AS IS" basis and THE INTERNET SOCIETY AND THE INTERNET ENGINEERING +TASK FORCE DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING +BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION +HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF +MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + +License notice for Algorithm from Internet Draft document "UUIDs and GUIDs" +--------------------------------------------------------------------------- + +Copyright (c) 1990- 1993, 1996 Open Software Foundation, Inc. +Copyright (c) 1989 by Hewlett-Packard Company, Palo Alto, Ca. & +Digital Equipment Corporation, Maynard, Mass. +To anyone who acknowledges that this file is provided "AS IS" +without any express or implied warranty: permission to use, copy, +modify, and distribute this file for any purpose is hereby +granted without fee, provided that the above copyright notices and +this notice appears in all source code copies, and that none of +the names of Open Software Foundation, Inc., Hewlett-Packard +Company, or Digital Equipment Corporation be used in advertising +or publicity pertaining to distribution of the software without +specific, written prior permission. Neither Open Software +Foundation, Inc., Hewlett-Packard Company, Microsoft, nor Digital Equipment +Corporation makes any representations about the suitability of +this software for any purpose. + +Copyright(C) The Internet Society 1997. All Rights Reserved. + +This document and translations of it may be copied and furnished to others, +and derivative works that comment on or otherwise explain it or assist in +its implementation may be prepared, copied, published and distributed, in +whole or in part, without restriction of any kind, provided that the above +copyright notice and this paragraph are included on all such copies and +derivative works.However, this document itself may not be modified in any +way, such as by removing the copyright notice or references to the Internet +Society or other Internet organizations, except as needed for the purpose of +developing Internet standards in which case the procedures for copyrights +defined in the Internet Standards process must be followed, or as required +to translate it into languages other than English. + +The limited permissions granted above are perpetual and will not be revoked +by the Internet Society or its successors or assigns. + +This document and the information contained herein is provided on an "AS IS" +basis and THE INTERNET SOCIETY AND THE INTERNET ENGINEERING TASK FORCE +DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO +ANY WARRANTY THAT THE USE OF THE INFORMATION HEREIN WILL NOT INFRINGE ANY +RIGHTS OR ANY IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A +PARTICULAR PURPOSE. + +License notice for Algorithm from RFC 4122 - +A Universally Unique IDentifier (UUID) URN Namespace +---------------------------------------------------- + +Copyright (c) 1990- 1993, 1996 Open Software Foundation, Inc. +Copyright (c) 1989 by Hewlett-Packard Company, Palo Alto, Ca. & +Digital Equipment Corporation, Maynard, Mass. +Copyright (c) 1998 Microsoft. +To anyone who acknowledges that this file is provided "AS IS" +without any express or implied warranty: permission to use, copy, +modify, and distribute this file for any purpose is hereby +granted without fee, provided that the above copyright notices and +this notice appears in all source code copies, and that none of +the names of Open Software Foundation, Inc., Hewlett-Packard +Company, Microsoft, or Digital Equipment Corporation be used in +advertising or publicity pertaining to distribution of the software +without specific, written prior permission. Neither Open Software +Foundation, Inc., Hewlett-Packard Company, Microsoft, nor Digital +Equipment Corporation makes any representations about the +suitability of this software for any purpose." + +License notice for The LLVM Compiler Infrastructure +--------------------------------------------------- + +Developed by: + + LLVM Team + + University of Illinois at Urbana-Champaign + + http://llvm.org + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal with +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: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimers. + + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimers in the + documentation and/or other materials provided with the distribution. + + * Neither the names of the LLVM Team, University of Illinois at + Urbana-Champaign, nor the names of its contributors may be used to + endorse or promote products derived from this Software without specific + prior written permission. + +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 +CONTRIBUTORS 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 WITH THE +SOFTWARE. + +License notice for Bob Jenkins +------------------------------ + +By Bob Jenkins, 1996. bob_jenkins@burtleburtle.net. You may use this +code any way you wish, private, educational, or commercial. It's free. + +License notice for Greg Parker +------------------------------ + +Greg Parker gparker@cs.stanford.edu December 2000 +This code is in the public domain and may be copied or modified without +permission. + +License notice for libunwind based code +---------------------------------------- + +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. + +License notice for Printing Floating-Point Numbers (Dragon4) +------------------------------------------------------------ + +/****************************************************************************** + Copyright (c) 2014 Ryan Juckett + http://www.ryanjuckett.com/ + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + + 3. This notice may not be removed or altered from any source + distribution. +******************************************************************************/ + +License notice for Printing Floating-point Numbers (Grisu3) +----------------------------------------------------------- + +Copyright 2012 the V8 project authors. All rights reserved. +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the following + disclaimer in the documentation and/or other materials provided + with the distribution. + * Neither the name of Google Inc. nor the names of its + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +License notice for xxHash +------------------------- + +xxHash Library +Copyright (c) 2012-2014, Yann Collet +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright notice, this + list of conditions and the following disclaimer in the documentation and/or + other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +License notice for Berkeley SoftFloat Release 3e +------------------------------------------------ + +https://github.com/ucb-bar/berkeley-softfloat-3 +https://github.com/ucb-bar/berkeley-softfloat-3/blob/master/COPYING.txt + +License for Berkeley SoftFloat Release 3e + +John R. Hauser +2018 January 20 + +The following applies to the whole of SoftFloat Release 3e as well as to +each source file individually. + +Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018 The Regents of the +University of California. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions, and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions, and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + 3. Neither the name of the University nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY +EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE +DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +License notice for xoshiro RNGs +-------------------------------- + +Written in 2018 by David Blackman and Sebastiano Vigna (vigna@acm.org) + +To the extent possible under law, the author has dedicated all copyright +and related and neighboring rights to this software to the public domain +worldwide. This software is distributed without any warranty. + +See . + +License for fastmod (https://github.com/lemire/fastmod) and ibm-fpgen (https://github.com/nigeltao/parse-number-fxx-test-data) +-------------------------------------- + + Copyright 2018 Daniel Lemire + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +License notice for The C++ REST SDK +----------------------------------- + +C++ REST SDK + +The MIT License (MIT) + +Copyright (c) Microsoft Corporation + +All rights reserved. + +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. + +License notice for MessagePack-CSharp +------------------------------------- + +MessagePack for C# + +MIT License + +Copyright (c) 2017 Yoshifumi Kawai + +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. + +License notice for lz4net +------------------------------------- + +lz4net + +Copyright (c) 2013-2017, Milosz Krajewski + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. + +Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +License notice for Nerdbank.Streams +----------------------------------- + +The MIT License (MIT) + +Copyright (c) Andrew Arnott + +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. + +License notice for RapidJSON +---------------------------- + +Tencent is pleased to support the open source community by making RapidJSON available. + +Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved. + +Licensed under the MIT License (the "License"); you may not use this file except +in compliance with the License. You may obtain a copy of the License at + +http://opensource.org/licenses/MIT + +Unless required by applicable law or agreed to in writing, software distributed +under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR +CONDITIONS OF ANY KIND, either express or implied. See the License for the +specific language governing permissions and limitations under the License. + +License notice for DirectX Math Library +--------------------------------------- + +https://github.com/microsoft/DirectXMath/blob/master/LICENSE + + The MIT License (MIT) + +Copyright (c) 2011-2020 Microsoft Corp + +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. + +License notice for ldap4net +--------------------------- + +The MIT License (MIT) + +Copyright (c) 2018 Alexander Chermyanin + +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. + +License notice for vectorized sorting code +------------------------------------------ + +MIT License + +Copyright (c) 2020 Dan Shechter + +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. + +License notice for musl +----------------------- + +musl as a whole is licensed under the following standard MIT license: + +Copyright © 2005-2020 Rich Felker, et al. + +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. + + +License notice for "Faster Unsigned Division by Constants" +------------------------------ + +Reference implementations of computing and using the "magic number" approach to dividing +by constants, including codegen instructions. The unsigned division incorporates the +"round down" optimization per ridiculous_fish. + +This is free and unencumbered software. Any copyright is dedicated to the Public Domain. + + +License notice for mimalloc +----------------------------------- + +MIT License + +Copyright (c) 2019 Microsoft Corporation, Daan Leijen + +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. diff --git a/src/MessagePack.UnityClient/Assets/Packages/System.Collections.Immutable.6.0.0/THIRD-PARTY-NOTICES.TXT.meta b/src/MessagePack.UnityClient/Assets/Packages/System.Collections.Immutable.6.0.0/THIRD-PARTY-NOTICES.TXT.meta new file mode 100644 index 000000000..c1614dda5 --- /dev/null +++ b/src/MessagePack.UnityClient/Assets/Packages/System.Collections.Immutable.6.0.0/THIRD-PARTY-NOTICES.TXT.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 8e5a8fe6ee20d844498326f369445c80 +TextScriptImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/src/MessagePack.UnityClient/Assets/Packages/System.Collections.Immutable.6.0.0/buildTransitive.meta b/src/MessagePack.UnityClient/Assets/Packages/System.Collections.Immutable.6.0.0/buildTransitive.meta new file mode 100644 index 000000000..e67d9243e --- /dev/null +++ b/src/MessagePack.UnityClient/Assets/Packages/System.Collections.Immutable.6.0.0/buildTransitive.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: c8bca4057dcdd8448a8625c1163fbf9a +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/src/MessagePack.UnityClient/Assets/Packages/System.Collections.Immutable.6.0.0/buildTransitive/netcoreapp2.0.meta b/src/MessagePack.UnityClient/Assets/Packages/System.Collections.Immutable.6.0.0/buildTransitive/netcoreapp2.0.meta new file mode 100644 index 000000000..747a3ff31 --- /dev/null +++ b/src/MessagePack.UnityClient/Assets/Packages/System.Collections.Immutable.6.0.0/buildTransitive/netcoreapp2.0.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 29592120a2a1fac4797b00c4acc4707a +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/src/MessagePack.UnityClient/Assets/Packages/System.Collections.Immutable.6.0.0/buildTransitive/netcoreapp2.0/System.Collections.Immutable.targets b/src/MessagePack.UnityClient/Assets/Packages/System.Collections.Immutable.6.0.0/buildTransitive/netcoreapp2.0/System.Collections.Immutable.targets new file mode 100644 index 000000000..ef88db2a8 --- /dev/null +++ b/src/MessagePack.UnityClient/Assets/Packages/System.Collections.Immutable.6.0.0/buildTransitive/netcoreapp2.0/System.Collections.Immutable.targets @@ -0,0 +1,6 @@ + + + + + diff --git a/src/MessagePack.UnityClient/Assets/Packages/System.Collections.Immutable.6.0.0/buildTransitive/netcoreapp2.0/System.Collections.Immutable.targets.meta b/src/MessagePack.UnityClient/Assets/Packages/System.Collections.Immutable.6.0.0/buildTransitive/netcoreapp2.0/System.Collections.Immutable.targets.meta new file mode 100644 index 000000000..7892ca8cc --- /dev/null +++ b/src/MessagePack.UnityClient/Assets/Packages/System.Collections.Immutable.6.0.0/buildTransitive/netcoreapp2.0/System.Collections.Immutable.targets.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 3abbc16be940f6d469b6485c7ed42774 +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/src/MessagePack.UnityClient/Assets/Packages/System.Collections.Immutable.6.0.0/buildTransitive/netcoreapp3.1.meta b/src/MessagePack.UnityClient/Assets/Packages/System.Collections.Immutable.6.0.0/buildTransitive/netcoreapp3.1.meta new file mode 100644 index 000000000..435fa963f --- /dev/null +++ b/src/MessagePack.UnityClient/Assets/Packages/System.Collections.Immutable.6.0.0/buildTransitive/netcoreapp3.1.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 88680b640bf5d2f4da62030031ee1903 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/src/MessagePack.UnityClient/Assets/Packages/System.Collections.Immutable.6.0.0/buildTransitive/netcoreapp3.1/_._ b/src/MessagePack.UnityClient/Assets/Packages/System.Collections.Immutable.6.0.0/buildTransitive/netcoreapp3.1/_._ new file mode 100644 index 000000000..e69de29bb diff --git a/src/MessagePack.UnityClient/Assets/Packages/System.Collections.Immutable.6.0.0/buildTransitive/netcoreapp3.1/_._.meta b/src/MessagePack.UnityClient/Assets/Packages/System.Collections.Immutable.6.0.0/buildTransitive/netcoreapp3.1/_._.meta new file mode 100644 index 000000000..4da68a2bb --- /dev/null +++ b/src/MessagePack.UnityClient/Assets/Packages/System.Collections.Immutable.6.0.0/buildTransitive/netcoreapp3.1/_._.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 5bb291d713b969d47a5cc4c5e75a8b6b +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/src/MessagePack.UnityClient/Assets/Packages/System.Collections.Immutable.6.0.0/lib.meta b/src/MessagePack.UnityClient/Assets/Packages/System.Collections.Immutable.6.0.0/lib.meta new file mode 100644 index 000000000..f1eba9dcc --- /dev/null +++ b/src/MessagePack.UnityClient/Assets/Packages/System.Collections.Immutable.6.0.0/lib.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: a7fccc4727653f841a3ac846c667de73 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/src/MessagePack.UnityClient/Assets/Packages/System.Collections.Immutable.6.0.0/lib/net461.meta b/src/MessagePack.UnityClient/Assets/Packages/System.Collections.Immutable.6.0.0/lib/net461.meta new file mode 100644 index 000000000..b70b34488 --- /dev/null +++ b/src/MessagePack.UnityClient/Assets/Packages/System.Collections.Immutable.6.0.0/lib/net461.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: de2dd5a09b308e6458223984f4ede8fd +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/src/MessagePack.UnityClient/Assets/Packages/System.Collections.Immutable.6.0.0/lib/net461/System.Collections.Immutable.dll b/src/MessagePack.UnityClient/Assets/Packages/System.Collections.Immutable.6.0.0/lib/net461/System.Collections.Immutable.dll new file mode 100644 index 0000000000000000000000000000000000000000..0167fd9892f914c210ff728679457cc1bfa75cb9 GIT binary patch literal 193664 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 JJb~53{{aM`zuW)- literal 0 HcmV?d00001 diff --git a/src/MessagePack.UnityClient/Assets/Packages/System.Collections.Immutable.6.0.0/lib/net461/System.Collections.Immutable.dll.meta b/src/MessagePack.UnityClient/Assets/Packages/System.Collections.Immutable.6.0.0/lib/net461/System.Collections.Immutable.dll.meta new file mode 100644 index 000000000..4a0f1ec78 --- /dev/null +++ b/src/MessagePack.UnityClient/Assets/Packages/System.Collections.Immutable.6.0.0/lib/net461/System.Collections.Immutable.dll.meta @@ -0,0 +1,23 @@ +fileFormatVersion: 2 +guid: b737b55a546ea5a4d9affbf9236fe9fa +labels: +- NuGetForUnity +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + defineConstraints: [] + isPreloaded: 0 + isOverridable: 0 + isExplicitlyReferenced: 0 + validateReferences: 1 + platformData: + - first: + Any: + second: + enabled: 1 + settings: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/src/MessagePack.UnityClient/Assets/Packages/System.Collections.Immutable.6.0.0/lib/net461/System.Collections.Immutable.xml b/src/MessagePack.UnityClient/Assets/Packages/System.Collections.Immutable.6.0.0/lib/net461/System.Collections.Immutable.xml new file mode 100644 index 000000000..fb6b8088f --- /dev/null +++ b/src/MessagePack.UnityClient/Assets/Packages/System.Collections.Immutable.6.0.0/lib/net461/System.Collections.Immutable.xml @@ -0,0 +1,5380 @@ + + + + System.Collections.Immutable + + + + Represents an immutable collection of key/value pairs. + + NuGet package: System.Collections.Immutable (about immutable collections and how to install) + The type of keys in the dictionary. + The type of values in the dictionary. + + + Adds an element with the specified key and value to the dictionary. + The key of the element to add. + The value of the element to add. + The given key already exists in the dictionary but has a different value. + A new immutable dictionary that contains the additional key/value pair. + + + Adds the specified key/value pairs to the dictionary. + The key/value pairs to add. + One of the given keys already exists in the dictionary but has a different value. + A new immutable dictionary that contains the additional key/value pairs. + + + Retrieves an empty dictionary that has the same ordering and key/value comparison rules as this dictionary instance. + An empty dictionary with equivalent ordering and key/value comparison rules. + + + Determines whether the immutable dictionary contains the specified key/value pair. + The key/value pair to locate. + + if the specified key/value pair is found in the dictionary; otherwise, . + + + Removes the element with the specified key from the immutable dictionary. + The key of the element to remove. + A new immutable dictionary with the specified element removed; or this instance if the specified key cannot be found in the dictionary. + + + Removes the elements with the specified keys from the immutable dictionary. + The keys of the elements to remove. + A new immutable dictionary with the specified keys removed; or this instance if the specified keys cannot be found in the dictionary. + + + Sets the specified key and value in the immutable dictionary, possibly overwriting an existing value for the key. + The key of the entry to add. + The key value to set. + A new immutable dictionary that contains the specified key/value pair. + + + Sets the specified key/value pairs in the immutable dictionary, possibly overwriting existing values for the keys. + The key/value pairs to set in the dictionary. If any of the keys already exist in the dictionary, this method will overwrite their previous values. + A new immutable dictionary that contains the specified key/value pairs. + + + Determines whether this dictionary contains a specified key. + The key to search for. + The matching key located in the dictionary if found, or equalkey if no match is found. + + if a match for is found; otherwise, . + + + Represents a list of elements that cannot be modified. + + NuGet package: System.Collections.Immutable (about immutable collections and how to install) + The type of elements in the list. + + + Makes a copy of the list, and adds the specified object to the end of the copied list. + The object to add to the list. + A new list with the object added. + + + Makes a copy of the list and adds the specified objects to the end of the copied list. + The objects to add to the list. + A new list with the elements added. + + + Creates a list with all the items removed, but with the same sorting and ordering semantics as this list. + An empty list that has the same sorting and ordering semantics as this instance. + + + Searches for the specified object and returns the zero-based index of the first occurrence within the range of elements in the that starts at the specified index and contains the specified number of elements. + The object to locate in the . This value can be null for reference types. + The zero-based starting indexes of the search. 0 (zero) is valid in an empty list. + The number of elements in the section to search. + The equality comparer to use to locate . + The zero-based index of the first occurrence of within the range of elements in the that starts at and contains number of elements if found; otherwise -1. + + + Inserts the specified element at the specified index in the immutable list. + The zero-based index at which to insert the value. + The object to insert. + A new immutable list that includes the specified element. + + + Inserts the specified elements at the specified index in the immutable list. + The zero-based index at which the new elements should be inserted. + The elements to insert. + A new immutable list that includes the specified elements. + + + Searches for the specified object and returns the zero-based index of the last occurrence within the range of elements in the that contains the specified number of elements and ends at the specified index. + The object to locate in the list. The value can be for reference types. + The zero-based starting index of the search. 0 (zero) is valid in an empty list. + The number of elements in the section to search. + The equality comparer to match . + Returns . + + + Removes the first occurrence of a specified object from this immutable list. + The object to remove from the list. + The equality comparer to use to locate . + A new list with the specified object removed. + + + Removes all the elements that match the conditions defined by the specified predicate. + The delegate that defines the conditions of the elements to remove. + A new immutable list with the elements removed. + + + Removes the element at the specified index of the immutable list. + The index of the element to remove. + A new list with the element removed. + + + Removes the specified object from the list. + The objects to remove from the list. + The equality comparer to use to determine if match any objects in the list. + A new immutable list with the specified objects removed, if matched objects in the list. + + + Removes a range of elements from the . + The zero-based starting index of the range of elements to remove. + The number of elements to remove. + A new immutable list with the elements removed. + + + Returns a new list with the first matching element in the list replaced with the specified element. + The element to be replaced. + The element to replace the first occurrence of with. + The equality comparer to use for matching . + + does not exist in the list. + A new list that contains , even if is the same as . + + + Replaces an element in the list at a given position with the specified element. + The position in the list of the element to replace. + The element to replace the old element with. + A new list that contains the new element, even if the element at the specified location is the same as the new element. + + + Represents an immutable first-in, first-out collection of objects. + + NuGet package: System.Collections.Immutable (about immutable collections and how to install) + The type of elements in the queue. + + + Returns a new queue with all the elements removed. + An empty immutable queue. + + + Removes the first element in the immutable queue, and returns the new queue. + The queue is empty. + The new immutable queue with the first element removed. This value is never . + + + Adds an element to the end of the immutable queue, and returns the new queue. + The element to add. + The new immutable queue with the specified element added. + + + Returns the element at the beginning of the immutable queue without removing it. + The queue is empty. + The element at the beginning of the queue. + + + Gets a value that indicates whether this immutable queue is empty. + + if this queue is empty; otherwise, . + + + Represents a set of elements that can only be modified by creating a new instance of the set. + + NuGet package: System.Collections.Immutable (about immutable collections and how to install) + The type of element stored in the set. + + + Adds the specified element to this immutable set. + The element to add. + A new set with the element added, or this set if the element is already in the set. + + + Retrieves an empty immutable set that has the same sorting and ordering semantics as this instance. + An empty set that has the same sorting and ordering semantics as this instance. + + + Determines whether this immutable set contains a specified element. + The element to locate in the set. + + if the set contains the specified value; otherwise, . + + + Removes the elements in the specified collection from the current immutable set. + The collection of items to remove from this set. + A new set with the items removed; or the original set if none of the items were in the set. + + + Creates an immutable set that contains only elements that exist in this set and the specified set. + The collection to compare to the current . + A new immutable set that contains elements that exist in both sets. + + + Determines whether the current immutable set is a proper (strict) subset of the specified collection. + The collection to compare to the current set. + + if the current set is a proper subset of the specified collection; otherwise, . + + + Determines whether the current immutable set is a proper (strict) superset of the specified collection. + The collection to compare to the current set. + + if the current set is a proper superset of the specified collection; otherwise, . + + + Determines whether the current immutable set is a subset of a specified collection. + The collection to compare to the current set. + + if the current set is a subset of the specified collection; otherwise, . + + + Determines whether the current immutable set is a superset of a specified collection. + The collection to compare to the current set. + + if the current set is a superset of the specified collection; otherwise, . + + + Determines whether the current immutable set overlaps with the specified collection. + The collection to compare to the current set. + + if the current set and the specified collection share at least one common element; otherwise, . + + + Removes the specified element from this immutable set. + The element to remove. + A new set with the specified element removed, or the current set if the element cannot be found in the set. + + + Determines whether the current immutable set and the specified collection contain the same elements. + The collection to compare to the current set. + + if the sets are equal; otherwise, . + + + Creates an immutable set that contains only elements that are present either in the current set or in the specified collection, but not both. + The collection to compare to the current set. + A new set that contains the elements that are present only in the current set or in the specified collection, but not both. + + + Determines whether the set contains a specified value. + The value to search for. + The matching value from the set, if found, or equalvalue if there are no matches. + + if a matching value was found; otherwise, . + + + Creates a new immutable set that contains all elements that are present in either the current set or in the specified collection. + The collection to add elements from. + A new immutable set with the items added; or the original set if all the items were already in the set. + + + Represents an immutable last-in-first-out (LIFO) collection. + + NuGet package: System.Collections.Immutable (about immutable collections and how to install) + The type of elements in the stack. + + + Removes all objects from the immutable stack. + An empty immutable stack. + + + Returns the element at the top of the immutable stack without removing it. + The stack is empty. + The element at the top of the stack. + + + Removes the element at the top of the immutable stack and returns the new stack. + The stack is empty. + The new stack; never . + + + Inserts an element at the top of the immutable stack and returns the new stack. + The element to push onto the stack. + The new stack. + + + Gets a value that indicates whether this immutable stack is empty. + + if this stack is empty; otherwise,. + + + Provides methods for creating an array that is immutable; meaning it cannot be changed once it is created. + + NuGet package: System.Collections.Immutable (about immutable collections and how to install) + + + Searches the sorted immutable array for a specified element using the default comparer and returns the zero-based index of the element, if it's found. + The sorted array to search. + The object to search for. + The type of element stored in the array. + + does not implement or the search encounters an element that does not implement . + The zero-based index of the item in the array, if item is found; otherwise, a negative number that is the bitwise complement of the index of the next element that is larger than or, if there is no larger element, the bitwise complement of . + + + Searches a sorted immutable array for a specified element and returns the zero-based index of the element, if it's found. + The sorted array to search. + The object to search for. + The comparer implementation to use when comparing elements, or null to use the default comparer. + The type of element stored in the array. + + is null and does not implement or the search encounters an element that does not implement . + The zero-based index of the item in the array, if item is found; otherwise, a negative number that is the bitwise complement of the index of the next element that is larger than or, if there is no larger element, the bitwise complement of . + + + Searches a sorted immutable array for a specified element and returns the zero-based index of the element, if it's found. + The sorted array to search. + The starting index of the range to search. + The length of the range to search. + The object to search for. + The type of element stored in the array. + + does not implement or the search encounters an element that does not implement . + + and do not specify a valid range in . + + is less than the lower bound of . + +-or- + + is less than zero. + The zero-based index of the item in the array, if item is found; otherwise, a negative number that is the bitwise complement of the index of the next element that is larger than or, if there is no larger element, the bitwise complement of . + + + Searches a sorted immutable array for a specified element and returns the zero-based index of the element. + The sorted array to search. + The starting index of the range to search. + The length of the range to search. + The object to search for. + The comparer to use when comparing elements for equality or to use the default comparer. + The type of element stored in the array. + + is null and does not implement or the search encounters an element that does not implement . + + and do not specify a valid range in . + +-or- + + is , and is of a type that is not compatible with the elements of . + + is less than the lower bound of . + +-or- + + is less than zero. + The zero-based index of the item in the array, if item is found; otherwise, a negative number that is the bitwise complement of the index of the next element that is larger than or, if there is no larger element, the bitwise complement of . + + + Creates an empty immutable array. + The type of elements stored in the array. + An empty immutable array. + + + Creates an immutable array that contains the specified object. + The object to store in the array. + The type of elements stored in the array. + An immutable array that contains the specified object. + + + Creates an immutable array that contains the specified objects. + The first object to store in the array. + The second object to store in the array. + The type of elements stored in the array. + An immutable array that contains the specified objects. + + + Creates an immutable array that contains the specified objects. + The first object to store in the array. + The second object to store in the array. + The third object to store in the array. + The type of elements stored in the array. + An immutable array that contains the specified objects. + + + Creates an immutable array that contains the specified objects. + The first object to store in the array. + The second object to store in the array. + The third object to store in the array. + The fourth object to store in the array. + The type of elements stored in the array. + An immutable array that contains the specified objects. + + + Creates an immutable array from the specified array of objects. + The array of objects to populate the array with. + The type of elements stored in the array. + An immutable array that contains the array of items. + + + Creates an immutable array with specified objects from another array. + The source array of objects. + The index of the first element to copy from . + The number of elements from to include in this immutable array. + The type of elements stored in the array. + An immutable array that contains the specified objects from the source array. + + + Creates an immutable array with the specified objects from another immutable array. + The source array of objects. + The index of the first element to copy from . + The number of elements from to include in this immutable array. + The type of elements stored in the array. + An immutable array that contains the specified objects from the source array. + + + Creates a mutable array that can be converted to an without allocating new memory. + The type of elements stored in the builder. + A mutable array of the specified type that can be efficiently converted to an immutable array. + + + Creates a mutable array that can be converted to an without allocating new memory. + The initial capacity of the builder. + The type of elements stored in the builder. + A mutable array of the specified type that can be efficiently converted to an immutable array. + + + Creates a new populated with the specified items. + The elements to add to the array. + The type of element stored in the array. + An immutable array that contains the specified items. + + + Initializes a new instance of the struct. + The source array to initialize the resulting array with. + The function to apply to each element from the source array. + The type of element stored in the source array. + The type of element to store in the target array. + An immutable array that contains the specified items. + + + Initializes a new instance of the struct. + The source array to initialize the resulting array with. + The index of the first element in the source array to include in the resulting array. + The number of elements from the source array to include in the resulting array. + The function to apply to each element from the source array included in the resulting array. + The type of element stored in the source array. + The type of element to store in the target array. + An immutable array that contains the specified items. + + + Initializes a new instance of the struct. + The source array to initialize the resulting array with. + The function to apply to each element from the source array. + An argument to be passed to the selector mapping function. + The type of element stored in the source array. + The type of argument to pass to the selector mapping function. + The type of element to store in the target array. + An immutable array that contains the specified items. + + + Initializes a new instance of the struct. + The source array to initialize the resulting array with. + The index of the first element in the source array to include in the resulting array. + The number of elements from the source array to include in the resulting array. + The function to apply to each element from the source array included in the resulting array. + An argument to be passed to the selector mapping function. + The type of element stored in the source array. + The type of argument to be passed to the selector mapping function. + The type of element to be stored in the target array. + An immutable array that contains the specified items. + + + Creates an immutable array from the specified collection. + The collection of objects to copy to the immutable array. + The type of elements contained in . + An immutable array that contains the specified collection of objects. + + + Creates an immutable array from the current contents of the builder's array. + The builder to create the immutable array from. + The type of elements contained in the immutable array. + An immutable array that contains the current contents of the builder's array. + + + Represents an array that is immutable; meaning it cannot be changed once it is created. + + NuGet package: System.Collections.Immutable (about immutable collections and how to install) + The type of element stored by the array. + + + Gets an empty immutable array. + + + Returns a copy of the original array with the specified item added to the end. + The item to be added to the end of the array. + A new array with the specified item added to the end. + + + Returns a copy of the original array with the specified elements added to the end of the array. + The elements to add to the array. + A new array with the elements added. + + + Returns a copy of the original array with the specified elements added to the end of the array. + The elements to add to the array. + A new array with the elements added. + + + Returns a new immutable array that contains the elements of this array cast to a different type. + The type of array element to return. + An immutable array that contains the elements of this array, cast to a different type. If the cast fails, returns an array whose property returns . + + + Creates a new read-only memory region over this immutable array. + The read-only memory representation of this immutable array. + + + Creates a new read-only span over this immutable array. + The read-only span representation of this immutable array. + + + Initializes a new instance of the struct by casting the underlying array to an array of type . + The type of array element to return. + Thrown if the cast is illegal. + An immutable array instance with elements cast to the new type. + + + Initializes a new instance of the struct based on the contents of an existing instance, allowing a covariant static cast to efficiently reuse the existing array. + The array to initialize the array with. No copy is made. + The type of array element to return. + An immutable array instance with elements cast to the new type. + + + Returns an array with all the elements removed. + An array with all of the elements removed. + + + Determines whether the specified item exists in the array. + The item to search for. + + if the specified item was found in the array; otherwise . + + + Copies the contents of this array to the specified array. + The array to copy to. + + + Copies the contents of this array to the specified array starting at the specified destination index. + The array to copy to. + The index in where copying begins. + + + Copies the specified items in this array to the specified array at the specified starting index. + The index of this array where copying begins. + The array to copy to. + The index in where copying begins. + The number of elements to copy from this array. + + + Indicates whether specified array is equal to this array. + An object to compare with this object. + + if is equal to this array; otherwise, . + + + Determines if this array is equal to the specified object. + The to compare with this array. + + if this array is equal to ; otherwise, . + + + Returns an enumerator that iterates through the contents of the array. + An enumerator. + + + Returns a hash code for this instance. + A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table. + + + Searches the array for the specified item. + The item to search for. + The zero-based index position of the item if it is found, or -1 if it is not. + + + Searches the array for the specified item. + The item to search for. + The index at which to begin the search. + The zero-based index position of the item if it is found, or -1 if it is not. + + + Searches the array for the specified item. + The item to search for. + The index at which to begin the search. + The equality comparer to use in the search. + The zero-based index position of the item if it is found, or -1 if it is not. + + + Searches the array for the specified item. + The item to search for. + The index at which to begin the search. + The number of elements to search. + The zero-based index position of the item if it is found, or -1 if it is not. + + + Searches the array for the specified item. + The item to search for. + The index at which to begin the search. + The number of elements to search. + The equality comparer to use in the search. + The zero-based index position of the item if it is found, or -1 if it is not. + + + Returns a new array with the specified value inserted at the specified position. + The 0-based index into the array at which the new item should be added. + The item to insert at the start of the array. + A new array with the item inserted at the specified index. + + + Inserts the specified values at the specified index. + The index at which to insert the value. + The elements to insert. + A new immutable array with the items inserted at the specified index. + + + Inserts the specified values at the specified index. + The index at which to insert the value. + The elements to insert. + A new immutable array with the items inserted at the specified index. + + + Gets a read-only reference to the element at the specified in the read-only list. + The zero-based index of the element to get a reference to. + A read-only reference to the element at the specified in the read-only list. + + + Searches the array for the specified item; starting at the end of the array. + The item to search for. + The 0-based index into the array where the item was found; or -1 if it could not be found. + + + Searches the array for the specified item; starting at the end of the array. + The item to search for. + The index at which to begin the search. + The 0-based index into the array where the item was found; or -1 if it could not be found. + + + Searches the array for the specified item; starting at the end of the array. + The item to search for. + The index at which to begin the search. + The number of elements to search. + The 0-based index into the array where the item was found; or -1 if it could not be found. + + + Searches the array for the specified item; starting at the end of the array. + The item to search for. + The index at which to begin the search. + The number of elements to search. + The equality comparer to use in the search. + The 0-based index into the array where the item was found; or -1 if it could not be found. + + + Filters the elements of this array to those assignable to the specified type. + The type to filter the elements of the sequence on. + An that contains elements from the input sequence of type of . + + + Returns a value that indicates if two arrays are equal. + The array to the left of the operator. + The array to the right of the operator. + + if the arrays are equal; otherwise, . + + + Returns a value that indicates if two arrays are equal. + The array to the left of the operator. + The array to the right of the operator. + + if the arrays are equal; otherwise, . + + + Returns a value that indicates whether two arrays are not equal. + The array to the left of the operator. + The array to the right of the operator. + + if the arrays are not equal; otherwise, . + + + Checks for inequality between two array. + The object to the left of the operator. + The object to the right of the operator. + + if the two arrays are not equal; otherwise, . + + + Returns an array with the first occurrence of the specified element removed from the array. If no match is found, the current array is returned. + The item to remove. + A new array with the item removed. + + + Returns an array with the first occurrence of the specified element removed from the array. + + If no match is found, the current array is returned. + The item to remove. + The equality comparer to use in the search. + A new array with the specified item removed. + + + Removes all the items from the array that meet the specified condition. + The delegate that defines the conditions of the elements to remove. + A new array with items that meet the specified condition removed. + + + Returns an array with the element at the specified position removed. + The 0-based index of the element to remove from the returned array. + A new array with the item at the specified index removed. + + + Removes the specified items from this array. + The items to remove if matches are found in this list. + A new array with the elements removed. + + + Removes the specified items from this array. + The items to remove if matches are found in this list. + The equality comparer to use in the search. + A new array with the elements removed. + + + Removes the specified values from this list. + The items to remove if matches are found in this list. + A new list with the elements removed. + + + Removes the specified items from this list. + The items to remove if matches are found in this list. + The equality comparer to use in the search. + A new array with the elements removed. + + + Returns an array with the elements at the specified position removed. + The 0-based index of the starting element to remove from the array. + The number of elements to remove from the array. + The new array with the specified elements removed. + + + Finds the first element in the array equal to the specified value and replaces the value with the specified new value. + The value to find and replace in the array. + The value to replace the oldvalue with. + + is not found in the array. + A new array that contains even if the new and old values are the same. + + + Finds the first element in the array equal to the specified value and replaces the value with the specified new value. + The value to find and replace in the array. + The value to replace the oldvalue with. + The equality comparer to use to compare values. + + is not found in the array. + A new array that contains even if the new and old values are the same. + + + Replaces the item at the specified index with the specified item. + The index of the item to replace. + The item to add to the list. + The new array that contains at the specified index. + + + Sorts the elements in the immutable array using the default comparer. + A new immutable array that contains the items in this array, in sorted order. + + + Sorts the elements in the immutable array using the specified comparer. + The implementation to use when comparing elements, or to use the default comparer. + A new immutable array that contains the items in this array, in sorted order. + + + Sorts the elements in the entire using the specified . + The to use when comparing elements. + + is null. + The sorted list. + + + Sorts the specified elements in the immutable array using the specified comparer. + The index of the first element to sort. + The number of elements to include in the sort. + The implementation to use when comparing elements, or to use the default comparer. + A new immutable array that contains the items in this array, in sorted order. + + + Throws in all cases. + The item to add to the end of the array. + + + Throws in all cases. + + + Throws in all cases. + The object to remove from the array. + Throws in all cases. + + + Returns an enumerator that iterates through the array. + The property returns . + An enumerator that can be used to iterate through the array. + + + Throws in all cases. + The index of the location to insert the item. + The item to insert. + + + Throws in all cases. + The index. + + + Copies this array to another array starting at the specified index. + The array to copy this array to. + The index in the destination array to start the copy operation. + + + Returns an enumerator that iterates through the immutable array. + The property returns . + An enumerator that iterates through the immutable array. + + + Throws in all cases. + The value to add to the array. + Thrown in all cases. + Throws in all cases. + + + Throws in all cases. + Thrown in all cases. + + + Throws in all cases. + The value to check for. + Throws in all cases. + + + Gets the value at the specified index. + The value to return the index of. + The value of the element at the specified index. + + + Throws in all cases. + Index that indicates where to insert the item. + The value to insert. + Thrown in all cases. + + + Throws in all cases. + The value to remove from the array. + Thrown in all cases. + + + Throws in all cases. + The index of the item to remove. + Thrown in all cases. + + + Returns a copy of the original array with the specified item added to the end. + The value to add to the end of the array. + A new array with the specified item added to the end. + + + Returns a copy of the original array with the specified elements added to the end of the array. + The elements to add to the end of the array. + A new array with the elements added to the end. + + + Returns an array with all the elements removed. + An array with all the elements removed. + + + Returns a new array with the specified value inserted at the specified position. + The 0-based index into the array at which the new item should be added. + The item to insert at the start of the array. + A new array with the specified value inserted. + + + Inserts the specified values at the specified index. + The index at which to insert the value. + The elements to insert. + A new array with the specified values inserted. + + + Returns an array with the first occurrence of the specified element removed from the array; if no match is found, the current array is returned. + The value to remove from the array. + The equality comparer to use in the search. + A new array with the value removed. + + + Removes all the items from the array that meet the specified condition. + The delegate that defines the conditions of the elements to remove. + A new array with items that meet the specified condition removed. + + + Returns an array with the element at the specified position removed. + The 0-based index of the element to remove from the returned array. + A new array with the specified item removed. + + + Removes the specified items from this array. + The items to remove if matches are found in this list. + The equality comparer to use in the search. + A new array with the elements removed. + + + Returns an array with the elements at the specified position removed. + The 0-based index of the starting element to remove from the array. + The number of elements to remove from the array. + The new array with the specified elements removed. + + + Finds the first element in the array equal to the specified value and replaces the value with the specified new value. + The value to find and replace in the array. + The value to replace the oldvalue with. + The equality comparer to use to compare values. + + is not found in the array. + A new array that contains even if the new and old values are the same. + + + Replaces the item at the specified index with the specified item. + The index of the item to replace. + The value to add to the list. + The new array that contains at the specified index. + + + Determines whether the current collection element precedes, occurs in the same position as, or follows another element in the sort order. + The element to compare with the current instance. + The object used to compare members of the current array with the corresponding members of other array. + The arrays are not the same length. + An integer that indicates whether the current element precedes, is in the same position or follows the other element. + + + Determines whether this array is structurally equal to the specified array. + The array to compare with the current instance. + An object that determines whether the current instance and other are structurally equal. + + if the two arrays are structurally equal; otherwise, . + + + Returns a hash code for the current instance. + An object that computes the hash code of the current object. + The hash code for the current instance. + + + Creates a mutable array that has the same contents as this array and can be efficiently mutated across multiple operations using standard mutable interfaces. + The new builder with the same contents as this array. + + + Gets a value indicating whether this array was declared but not initialized. + + if the is ; otherwise, . + + + Gets a value indicating whether this is empty or is not initialized. + + if the is or ; otherwise, . + + + Gets a value indicating whether this is empty. + + if the is empty; otherwise, . + + + Gets the element at the specified index in the immutable array. + The zero-based index of the element to get. + The element at the specified index in the immutable array. + + + Gets the number of elements in the array. + The number of elements in the array. + + + Gets the number of items in the collection. + Thrown if the property returns true. + Number of items in the collection. + + + Gets a value indicating whether this instance is read only. + + if this instance is read only; otherwise, . + + + Gets or sets the element at the specified index in the read-only list. + The zero-based index of the element to get. + Always thrown from the setter. + Thrown if the property returns true. + The element at the specified index in the read-only list. + + + Gets the number of items in the collection. + Thrown if the property returns true. + The number of items in the collection. + + + Gets the element at the specified index. + The index. + Thrown if the property returns true. + The element. + + + Gets the size of the array. + Thrown if the property returns true. + The number of items in the collection. + + + See the interface. Always returns since since immutable collections are thread-safe. + Boolean value determining whether the collection is thread-safe. + + + Gets the sync root. + An object for synchronizing access to the collection. + + + Gets a value indicating whether this instance is fixed size. + + if this instance is fixed size; otherwise, . + + + Gets a value indicating whether this instance is read only. + + if this instance is read only; otherwise, . + + + Gets or sets the at the specified index. + The index. + Always thrown from the setter. + Thrown if the property returns true. + The object at the specified index. + + + A writable array accessor that can be converted into an instance without allocating extra memory. + + NuGet package: System.Collections.Immutable (about immutable collections and how to install) + + + + Adds the specified item to the array. + The object to add to the array. + + + Adds the specified items to the end of the array. + The items to add to the array. + + + Adds the specified items to the end of the array. + The items to add to the array. + The number of elements from the source array to add. + + + Adds the specified items to the end of the array. + The items to add to the array. + + + Adds the specified items to the end of the array. + The items to add to the array. + + + Adds the specified items to the end of the array. + The items to add to the array. + + + Adds the specified items to the end of the array. + The items to add to the array. + The number of elements from the source array to add. + + + Adds the specified items that derive from the type currently in the array, to the end of the array. + The items to add to end of the array. + The type that derives from the type of item already in the array. + + + Adds the specified items that derive from the type currently in the array, to the end of the array. + The items to add to the end of the array. + The type that derives from the type of item already in the array. + + + Adds the specified items that derive from the type currently in the array, to the end of the array. + The items to add to the end of the array. + The type that derives from the type of item already in the array. + + + Removes all items from the array. + + + Determines whether the array contains a specific value. + The object to locate in the array. + + if the object is found; otherwise, . + + + Copies the current contents to the specified array. + The array to copy to. + The index to start the copy operation. + + + Gets an object that can be used to iterate through the collection. + An object that can be used to iterate through the collection. + + + Determines the index of a specific item in the array. + The item to locate in the array. + The index of if it's found in the list; otherwise, -1. + + + Determines the index of the specified item. + The item to locate in the array. + The starting position of the search. + The index of if it's found in the list; otherwise, -1. + + + Determines the index of the specified item. + The item to locate in the array. + The starting position of the search. + The number of elements to search. + The index of if it's found in the list; otherwise, -1. + + + Determines the index for the specified item. + The item to locate in the array. + The index at which to begin the search. + The starting position of the search. + The equality comparer to use in the search. + The index of if it's found in the list; otherwise, -1. + + + Inserts an item in the array at the specified index. + The zero-based index at which to insert the item. + The object to insert into the array. + + + Gets a read-only reference to the element at the specified index. + The item index. + + is greater or equal to the array count. + The read-only reference to the element at the specified index. + + + Determines the 0-based index of the last occurrence of the specified item in this array. + The item to search for. + The 0-based index where the item was found; or -1 if it could not be found. + + + Determines the 0-based index of the last occurrence of the specified item in this array. + The item to search for. + The starting position of the search. + The 0-based index into the array where the item was found; or -1 if it could not be found. + + + Determines the 0-based index of the last occurrence of the specified item in this array. + The item to search for. + The starting position of the search. + The number of elements to search. + The 0-based index into the array where the item was found; or -1 if it could not be found. + + + Determines the 0-based index of the last occurrence of the specified item in this array. + The item to search for. + The starting position of the search. + The number of elements to search. + The equality comparer to use in the search. + The 0-based index into the array where the item was found; or -1 if it could not be found. + + + Extracts the internal array as an and replaces it with a zero length array. + When doesn't equal . + An immutable array containing the elements of the builder. + + + Removes the specified element. + The item to remove. + + if was found and removed; otherwise, . + + + Removes the item at the specified index from the array. + The zero-based index of the item to remove. + + + Reverses the order of elements in the collection. + + + Sorts the contents of the array. + + + Sorts the contents of the array. + The comparer to use for sorting. If comparer is , the default comparer for the elements type in the array is used. + + + Sorts the elements in the entire array using the specified . + The to use when comparing elements. + + is null. + + + Sorts the contents of the array. + The starting index for the sort. + The number of elements to include in the sort. + The comparer to use for sorting. If comparer is , the default comparer for the elements type in the array is used. + + + Returns an enumerator that iterates through the array. + An enumerator that iterates through the array. + + + Returns an enumerator that iterates through the array. + An enumerator that iterates through the array. + + + Creates a new array with the current contents of this . + A new array with the contents of this . + + + Returns an immutable array that contains the current contents of this . + An immutable array that contains the current contents of this . + + + Gets or sets the length of the internal array. When set, the internal array is reallocated to the given capacity if it is not already the specified length. + The length of the internal array. + + + Gets or sets the number of items in the array. + The number of items in the array. + + + Gets or sets the item at the specified index. + The index of the item to get or set. + The specified index is not in the array. + The item at the specified index. + + + Gets a value that indicates whether the is read-only. + + if the is read-only; otherwise, . + + + An array enumerator. + + NuGet package: System.Collections.Immutable (about immutable collections and how to install) + + + + Advances to the next value in the array. + + if another item exists in the array; otherwise, . + + + Gets the current item. + The current item. + + + Provides a set of initialization methods for instances of the class. + + NuGet package: System.Collections.Immutable (about immutable collections and how to install) + + + Determines whether the specified immutable dictionary contains the specified key/value pair. + The immutable dictionary to search. + The key to locate in the immutable dictionary. + The value to locate on the specified key, if the key is found. + The type of the keys in the immutable dictionary. + The type of the values in the immutable dictionary. + + if this map contains the specified key/value pair; otherwise, . + + + Creates an empty immutable dictionary. + The type of keys stored by the dictionary. + The type of values stored by the dictionary. + An empty immutable dictionary. + + + Creates an empty immutable dictionary that uses the specified key comparer. + The implementation to use to determine the equality of keys in the dictionary. + The type of keys stored by the dictionary. + The type of values stored by the dictionary. + An empty immutable dictionary. + + + Creates an empty immutable dictionary that uses the specified key and value comparers. + The implementation to use to determine the equality of keys in the dictionary. + The implementation to use to determine the equality of values in the dictionary. + The type of keys stored by the dictionary. + The type of values stored by the dictionary. + An empty immutable dictionary. + + + Creates a new immutable dictionary builder. + The type of keys stored by the dictionary. + The type of values stored by the dictionary. + The new builder. + + + Creates a new immutable dictionary builder. + The key comparer. + The type of keys stored by the dictionary. + The type of values stored by the dictionary. + The new builder. + + + Creates a new immutable dictionary builder. + The key comparer. + The value comparer. + The type of keys stored by the dictionary. + The type of values stored by the dictionary. + The new builder. + + + Creates a new immutable dictionary that contains the specified items. + The items used to populate the dictionary before it's immutable. + The type of keys in the dictionary. + The type of values in the dictionary. + A new immutable dictionary that contains the specified items. + + + Creates a new immutable dictionary that contains the specified items and uses the specified key comparer. + The comparer implementation to use to compare keys for equality. + The items to add to the dictionary before it's immutable. + The type of keys in the dictionary. + The type of values in the dictionary. + A new immutable dictionary that contains the specified items and uses the specified comparer. + + + Creates a new immutable dictionary that contains the specified items and uses the specified key comparer. + The comparer implementation to use to compare keys for equality. + The comparer implementation to use to compare values for equality. + The items to add to the dictionary before it's immutable. + The type of keys in the dictionary. + The type of values in the dictionary. + A new immutable dictionary that contains the specified items and uses the specified comparer. + + + Gets the value for a given key if a matching key exists in the dictionary. + The dictionary to retrieve the value from. + The key to search for. + The type of the key. + The type of the value. + The value for the key, or default(TValue) if no matching key was found. + + + Gets the value for a given key if a matching key exists in the dictionary. + The dictionary to retrieve the value from. + The key to search for. + The default value to return if no matching key is found in the dictionary. + The type of the key. + The type of the value. + The value for the key, or if no matching key was found. + + + Constructs an immutable dictionary from an existing collection of elements, applying a transformation function to the source keys. + The source collection used to generate the immutable dictionary. + The function used to transform keys for the immutable dictionary. + The type of element in the source collection. + The type of key in the resulting immutable dictionary. + The immutable dictionary that contains elements from , with keys transformed by applying . + + + Constructs an immutable dictionary based on some transformation of a sequence. + The source collection used to generate the immutable dictionary. + The function used to transform keys for the immutable dictionary. + The key comparer to use for the dictionary. + The type of element in the source collection. + The type of key in the resulting immutable dictionary. + The immutable dictionary that contains elements from , with keys transformed by applying . + + + Enumerates a sequence of key/value pairs and produces an immutable dictionary of its contents. + The sequence of key/value pairs to enumerate. + The type of the keys in the dictionary. + The type of the values in the dictionary. + An immutable dictionary that contains the key/value pairs in the specified sequence. + + + Enumerates a sequence of key/value pairs and produces an immutable dictionary of its contents by using the specified key comparer. + The sequence of key/value pairs to enumerate. + The key comparer to use when building the immutable dictionary. + The type of the keys in the dictionary. + The type of the values in the dictionary. + An immutable dictionary that contains the key/value pairs in the specified sequence. + + + Enumerates a sequence of key/value pairs and produces an immutable dictionary of its contents by using the specified key and value comparers. + The sequence of key/value pairs to enumerate. + The key comparer to use when building the immutable dictionary. + The value comparer to use for the immutable dictionary. + The type of the keys in the dictionary. + The type of the values in the dictionary. + An immutable dictionary that contains the key/value pairs in the specified sequence. + + + Creates an immutable dictionary from the current contents of the builder's dictionary. + The builder to create the immutable dictionary from. + The type of the keys in the dictionary. + The type of the values in the dictionary. + An immutable dictionary that contains the current contents in the builder's dictionary. + + + Enumerates and transforms a sequence, and produces an immutable dictionary of its contents. + The sequence to enumerate to generate the dictionary. + The function that will produce the key for the dictionary from each sequence element. + The function that will produce the value for the dictionary from each sequence element. + The type of the elements in the sequence. + The type of the keys in the resulting dictionary. + The type of the values in the resulting dictionary. + An immutable dictionary that contains the items in the specified sequence. + + + Enumerates and transforms a sequence, and produces an immutable dictionary of its contents by using the specified key comparer. + The sequence to enumerate to generate the dictionary. + The function that will produce the key for the dictionary from each sequence element. + The function that will produce the value for the dictionary from each sequence element. + The key comparer to use for the dictionary. + The type of the elements in the sequence. + The type of the keys in the resulting dictionary. + The type of the values in the resulting dictionary. + An immutable dictionary that contains the items in the specified sequence. + + + Enumerates and transforms a sequence, and produces an immutable dictionary of its contents by using the specified key and value comparers. + The sequence to enumerate to generate the dictionary. + The function that will produce the key for the dictionary from each sequence element. + The function that will produce the value for the dictionary from each sequence element. + The key comparer to use for the dictionary. + The value comparer to use for the dictionary. + The type of the elements in the sequence. + The type of the keys in the resulting dictionary. + The type of the values in the resulting dictionary. + An immutable dictionary that contains the items in the specified sequence. + + + Represents an immutable, unordered collection of keys and values. + + NuGet package: System.Collections.Immutable (about immutable collections and how to install) + The type of the keys in the dictionary. + The type of the values in the dictionary. + + + Gets an empty immutable dictionary. + + + Adds an element with the specified key and value to the immutable dictionary. + The key of the element to add. + The value of the element to add. + The given key already exists in the dictionary but has a different value. + A new immutable dictionary that contains the additional key/value pair. + + + Adds the specified key/value pairs to the immutable dictionary. + The key/value pairs to add. + One of the given keys already exists in the dictionary but has a different value. + A new immutable dictionary that contains the additional key/value pairs. + + + Retrieves an empty immutable dictionary that has the same ordering and key/value comparison rules as this dictionary instance. + An empty dictionary with equivalent ordering and key/value comparison rules. + + + Determines whether this immutable dictionary contains the specified key/value pair. + The key/value pair to locate. + + if the specified key/value pair is found in the dictionary; otherwise, . + + + Determines whether the immutable dictionary contains an element with the specified key. + The key to locate. + + if the immutable dictionary contains an element with the specified key; otherwise, . + + + Determines whether the immutable dictionary contains an element with the specified value. + The value to locate. The value can be for reference types. + + if the dictionary contains an element with the specified value; otherwise, . + + + Returns an enumerator that iterates through the immutable dictionary. + An enumerator that can be used to iterate through the dictionary. + + + Removes the element with the specified key from the immutable dictionary. + The key of the element to remove. + A new immutable dictionary with the specified element removed; or this instance if the specified key cannot be found in the dictionary. + + + Removes the elements with the specified keys from the immutable dictionary. + The keys of the elements to remove. + A new immutable dictionary with the specified keys removed; or this instance if the specified keys cannot be found in the dictionary. + + + Sets the specified key and value in the immutable dictionary, possibly overwriting an existing value for the key. + The key of the entry to add. + The key value to set. + A new immutable dictionary that contains the specified key/value pair. + + + Sets the specified key/value pairs in the immutable dictionary, possibly overwriting existing values for the keys. + The key/value pairs to set in the dictionary. If any of the keys already exist in the dictionary, this method will overwrite their previous values. + A new immutable dictionary that contains the specified key/value pairs. + + + Adds an item to the . + The object to add to the . + + + Removes all items from the . + + + Copies the elements of the to an , starting at a particular index. + The one-dimensional that is the destination of the elements copied from . The must have zero-based indexing. + The zero-based index in at which copying begins. + + + Removes the first occurrence of a specific object from the . + The object to remove from the . + + if was successfully removed from the ; otherwise, . This method also returns if is not found in the original . + + + Adds an element with the provided key and value to the immutable dictionary. + The object to use as the key of the element to add. + The object to use as the value of the element to add. + + is . + An element with the same key already exists in the . + The is read-only. + + + Removes the element with the specified key from the generic dictionary. + The key of the element to remove. + + is . + The is read-only. + + if the element is successfully removed; otherwise, . This method also returns if was not found in the original generic dictionary. + + + Returns an enumerator that iterates through the collection. + An enumerator that can be used to iterate through the collection. + + + Copies the elements of the dictionary to an array, starting at a particular array index. + The one-dimensional array that is the destination of the elements copied from the dictionary. The array must have zero-based indexing. + The zero-based index in at which copying begins. + + + Adds an element with the provided key and value to the immutable dictionary object. + The object to use as the key of the element to add. + The object to use as the value of the element to add. + + + Clears this instance. + The dictionary object is read-only. + + + Determines whether the immutable dictionary object contains an element with the specified key. + The key to locate in the dictionary object. + + if the dictionary contains an element with the key; otherwise, . + + + Returns an object for the immutable dictionary object. + An enumerator object for the dictionary object. + + + Removes the element with the specified key from the immutable dictionary object. + The key of the element to remove. + + + Returns an enumerator that iterates through a collection. + An enumerator object that can be used to iterate through the collection. + + + See the interface. + Key of the entry to be added. + Value of the entry to be added. + A new immutable dictionary that contains the additional key/value pair. + + + See the interface. + Sequence of key/value pairs to be added to the dictionary. + A new immutable dictionary that contains the additional key/value pairs. + + + Retrieves an empty dictionary that has the same ordering and key-value comparison rules as this dictionary instance. + The immutable dictionary instance. + + + See the interface. + Key of the entry to be removed. + A new immutable dictionary with the specified element removed; or this instance if the specified key cannot be found in the dictionary. + + + See the interface. + Sequence of keys to be removed. + A new immutable dictionary with the specified keys removed; or this instance if the specified keys cannot be found in the dictionary. + + + See the interface. + Key of entry to be added. + Value of the entry to be added. + A new immutable dictionary that contains the specified key/value pair. + + + Applies a given set of key-value pairs to an immutable dictionary, replacing any conflicting keys in the resulting dictionary. + The key-value pairs to set on the map. Any keys that conflict with existing keys will replace the previous values. + A copy of the immutable dictionary with updated key-value pairs. + + + Creates an immutable dictionary with the same contents as this dictionary that can be efficiently mutated across multiple operations by using standard mutable interfaces. + A collection with the same contents as this dictionary that can be efficiently mutated across multiple operations by using standard mutable interfaces. + + + Determines whether this dictionary contains a specified key. + The key to search for. + The matching key located in the dictionary if found, or equalkey if no match is found. + + if a match for is found; otherwise, . + + + Gets the value associated with the specified key. + The key whose value will be retrieved. + When this method returns, contains the value associated with the specified key, if the key is found; otherwise, contains the default value for the type of the parameter. This parameter is passed uninitialized. + + is null. + + if the object that implements the dictionary contains an element with the specified key; otherwise, . + + + Gets an instance of the immutable dictionary that uses the specified key comparer. + The key comparer to use. + An instance of the immutable dictionary that uses the given comparer. + + + Gets an instance of the immutable dictionary that uses the specified key and value comparers. + The key comparer to use. + The value comparer to use. + An instance of the immutable dictionary that uses the given comparers. + + + Gets the number of key/value pairs in the immutable dictionary. + The number of key/value pairs in the dictionary. + + + Gets a value that indicates whether this instance of the immutable dictionary is empty. + + if this instance is empty; otherwise, . + + + Gets the associated with the specified key. + The type of the key. + The value associated with the specified key. If no results are found, the operation throws an exception. + + + Gets the key comparer for the immutable dictionary. + The key comparer. + + + Gets the keys in the immutable dictionary. + The keys in the immutable dictionary. + + + Gets a value indicating whether the is read-only. + + if the is read-only; otherwise, . + + + Gets or sets the with the specified key. + The type of the key. + An object of type associated with the . + + + Gets the keys. + A collection containing the keys. + + + Gets the values. + A collection containing the values. + + + Gets a value indicating whether access to the is synchronized (thread safe). + + if access to the is synchronized (thread safe); otherwise, . + + + Gets an object that can be used to synchronize access to the . + An object that can be used to synchronize access to the . + + + Gets a value indicating whether the object has a fixed size. + + if the object has a fixed size; otherwise, . + + + Gets a value indicating whether the is read-only. + + if the is read-only; otherwise, . + + + Gets or sets the element with the specified key. + The key. + The value stored under the specified key. + + + Gets an containing the keys of the . + An containing the keys of the object that implements . + + + Gets an containing the values in the . + An containing the values in the object that implements . + + + Gets the value comparer used to determine whether values are equal. + The value comparer used to determine whether values are equal. + + + Gets the values in the immutable dictionary. + The values in the immutable dictionary. + + + Represents a hash map that mutates with little or no memory allocations and that can produce or build on immutable hash map instances very efficiently. + + NuGet package: System.Collections.Immutable (about immutable collections and how to install) + + + + + Adds an element that has the specified key and value to the immutable dictionary. + The key of the element to add. + The value of the element to add. + + is null. + An element with the same key already exists in the dictionary. + The dictionary is read-only. + + + Adds the specified item to the immutable dictionary. + The object to add to the dictionary. + The dictionary is read-only. + + + Adds a sequence of values to this collection. + The items to add to this collection. + + + Removes all items from the immutable dictionary. + The dictionary is read-only. + + + Determines whether the immutable dictionary contains a specific value. + The object to locate in the dictionary. + + if is found in the dictionary; otherwise, . + + + Determines whether the immutable dictionary contains an element that has the specified key. + The key to locate in the dictionary. + + is null. + + if the dictionary contains an element with the key; otherwise, . + + + Determines whether the immutable dictionary contains an element that has the specified value. + The value to locate in the immutable dictionary. The value can be for reference types. + + if the dictionary contains an element with the specified value; otherwise, . + + + Returns an enumerator that iterates through the immutable dictionary. + An enumerator that can be used to iterate through the collection. + + + Gets the value for a given key if a matching key exists in the dictionary. + The key to search for. + The value for the key, or default(TValue) if no matching key was found. + + + Gets the value for a given key if a matching key exists in the dictionary. + The key to search for. + The default value to return if no matching key is found in the dictionary. + The value for the key, or if no matching key was found. + + + Removes the element with the specified key from the immutable dictionary. + The key of the element to remove. + + is null. + The dictionary is read-only. + + if the element is successfully removed; otherwise, . This method also returns if was not found in the dictionary. + + + Removes the first occurrence of a specific object from the immutable dictionary. + The object to remove from the dictionary. + The dictionary is read-only. + + if was successfully removed from the dictionary; otherwise, . This method also returns false if is not found in the dictionary. + + + Removes any entries with keys that match those found in the specified sequence from the immutable dictionary. + The keys for entries to remove from the dictionary. + + + Copies the elements of the dictionary to an array of type , starting at the specified array index. + The one-dimensional array that is the destination of the elements copied from the dictionary. The array must have zero-based indexing. + The zero-based index in at which copying begins. + + + Returns an enumerator that iterates through the collection. + An enumerator that can be used to iterate through the collection. + + + Copies the elements of the dictionary to an array of type , starting at the specified array index. + The one-dimensional array of type that is the destination of the elements copied from the dictionary. The array must have zero-based indexing. + The zero-based index in at which copying begins. + + + Adds an element with the provided key and value to the dictionary object. + The key of the element to add. + The value of the element to add. + + + Determines whether the dictionary object contains an element with the specified key. + The key to locate. + + if the dictionary contains an element with the key; otherwise, . + + + Returns an object for the dictionary. + + An object for the dictionary. + + + Removes the element with the specified key from the dictionary. + The key of the element to remove. + + + Returns an enumerator that iterates through a collection. + An enumerator object that can be used to iterate through the collection. + + + Creates an immutable dictionary based on the contents of this instance. + An immutable dictionary. + + + Determines whether this dictionary contains a specified key. + The key to search for. + The matching key located in the dictionary if found, or equalkey if no match is found. + + if a match for is found; otherwise, . + + + Returns the value associated with the specified key. + The key whose value will be retrieved. + When this method returns, contains the value associated with the specified key, if the key is found; otherwise, returns the default value for the type of the parameter. This parameter is passed uninitialized. + + is null. + + if the object that implements the immutable dictionary contains an element with the specified key; otherwise, . + + + Gets the number of elements contained in the immutable dictionary. + The number of elements contained in the immutable dictionary. + + + Gets or sets the element with the specified key. + The element to get or set. + + is . + The property is being retrieved, and is not found. + The property is being set, and the is read-only. + The element that has the specified key. + + + Gets or sets the key comparer. + The key comparer. + + + Gets a collection that contains the keys of the immutable dictionary. + A collection that contains the keys of the object that implements the immutable dictionary. + + + Gets a value that indicates whether the collection is read-only. + + if the collection is read-only; otherwise, . + + + Gets a collection containing the keys of the generic dictionary. + A collection containing the keys of the object that implements the generic dictionary. + + + Gets a collection containing the values in the generic dictionary. + A collection containing the values in the object that implements the generic dictionary. + + + Gets a value that indicates whether access to the is synchronized (thread safe). + + if access to the is synchronized (thread safe); otherwise, . + + + Gets an object that can be used to synchronize access to the . + An object that can be used to synchronize access to the . + + + Gets a value that indicates whether the object has a fixed size. + + if the object has a fixed size; otherwise, . + + + Gets a value that indicates whether the is read-only. + + if the is read-only; otherwise, . + + + Gets or sets the element with the specified key. + The key. + Value stored under specified key. + + + Gets an containing the keys of the . + An containing the keys of the object that implements . + + + Gets an containing the values in the . + An containing the values in the object that implements . + + + Gets or sets the value comparer. + The value comparer. + + + Gets a collection that contains the values of the immutable dictionary. + A collection that contains the values of the object that implements the dictionary. + + + Enumerates the contents of the immutable dictionary without allocating any memory. + + NuGet package: System.Collections.Immutable (about immutable collections and how to install) + + + + + Releases the resources used by the current instance of the class. + + + Advances the enumerator to the next element of the immutable dictionary. + The dictionary was modified after the enumerator was created. + + if the enumerator was successfully advanced to the next element; if the enumerator has passed the end of the dictionary. + + + Sets the enumerator to its initial position, which is before the first element in the dictionary. + The dictionary was modified after the enumerator was created. + + + Gets the element at the current position of the enumerator. + The element in the dictionary at the current position of the enumerator. + + + Gets the current element. + Current element in enumeration. + + + Provides a set of initialization methods for instances of the class. + + NuGet package: System.Collections.Immutable (about immutable collections and how to install) + + + Creates an empty immutable hash set. + The type of items to be stored in the immutable hash set. + An empty immutable hash set. + + + Creates a new immutable hash set that contains the specified item. + The item to prepopulate the hash set with. + The type of items in the immutable hash set. + A new immutable hash set that contains the specified item. + + + Creates a new immutable hash set that contains the specified array of items. + An array that contains the items to prepopulate the hash set with. + The type of items in the immutable hash set. + A new immutable hash set that contains the specified items. + + + Creates an empty immutable hash set that uses the specified equality comparer. + The object to use for comparing objects in the set for equality. + The type of items in the immutable hash set. + An empty immutable hash set. + + + Creates a new immutable hash set that contains the specified item and uses the specified equality comparer for the set type. + The object to use for comparing objects in the set for equality. + The item to prepopulate the hash set with. + The type of items in the immutable hash set. + A new immutable hash set that contains the specified item. + + + Creates a new immutable hash set that contains the items in the specified collection and uses the specified equality comparer for the set type. + The object to use for comparing objects in the set for equality. + An array that contains the items to prepopulate the hash set with. + The type of items stored in the immutable hash set. + A new immutable hash set that contains the specified items. + + + Creates a new immutable hash set builder. + The type of items stored by the collection. + The immutable hash set builder. + + + Creates a new immutable hash set builder. + The object to use for comparing objects in the set for equality. + The type of items stored by the collection. + The new immutable hash set builder. + + + Creates a new immutable hash set prefilled with the specified items. + The items to add to the hash set. + The type of items stored by the collection. + The new immutable hash set that contains the specified items. + + + Creates a new immutable hash set that contains the specified items and uses the specified equality comparer for the set type. + The object to use for comparing objects in the set for equality. + The items add to the collection before immutability is applied. + The type of items stored in the collection. + The new immutable hash set. + + + Enumerates a sequence and produces an immutable hash set of its contents. + The sequence to enumerate. + The type of the elements in the sequence. + An immutable hash set that contains the items in the specified sequence. + + + Enumerates a sequence, produces an immutable hash set of its contents, and uses the specified equality comparer for the set type. + The sequence to enumerate. + The object to use for comparing objects in the set for equality. + The type of the elements in the sequence. + An immutable hash set that contains the items in the specified sequence and uses the specified equality comparer. + + + Creates an immutable hash set from the current contents of the builder's set. + The builder to create the immutable hash set from. + The type of the elements in the hash set. + An immutable hash set that contains the current contents in the builder's set. + + + Represents an immutable, unordered hash set. + + NuGet package: System.Collections.Immutable (about immutable collections and how to install) + The type of elements in the hash set. + + + Gets an immutable hash set for this type that uses the default . + + + Adds the specified element to the hash set. + The element to add to the set. + A hash set that contains the added value and any values previously held by the object. + + + Retrieves an empty immutable hash set that has the same sorting and ordering semantics as this instance. + An empty hash set that has the same sorting and ordering semantics as this instance. + + + Determines whether this immutable hash set contains the specified element. + The object to locate in the immutable hash set. + + if is found in the ; otherwise, . + + + Removes the elements in the specified collection from the current immutable hash set. + The collection of items to remove from this set. + A new set with the items removed; or the original set if none of the items were in the set. + + + Returns an enumerator that iterates through the collection. + An enumerator that can be used to iterate through the collection. + + + Creates an immutable hash set that contains elements that exist in both this set and the specified set. + The collection to compare to the current set. + A new immutable set that contains any elements that exist in both sets. + + + Determines whether the current immutable hash set is a proper (strict) subset of a specified collection. + The collection to compare to the current set. + + if the current set is a proper subset of the specified collection; otherwise, . + + + Determines whether the current immutable hash set is a proper (strict) superset of a specified collection. + The collection to compare to the current set. + + if the current set is a proper superset of the specified collection; otherwise, . + + + Determines whether the current immutable hash set is a subset of a specified collection. + The collection to compare to the current set. + + if the current set is a subset of the specified collection; otherwise, . + + + Determines whether the current immutable hash set is a superset of a specified collection. + The collection to compare to the current set. + + if the current set is a superset of the specified collection; otherwise, . + + + Determines whether the current immutable hash set overlaps with the specified collection. + The collection to compare to the current set. + + if the current set and the specified collection share at least one common element; otherwise, . + + + Removes the specified element from this immutable hash set. + The element to remove. + A new set with the specified element removed, or the current set if the element cannot be found in the set. + + + Determines whether the current immutable hash set and the specified collection contain the same elements. + The collection to compare to the current set. + + if the sets are equal; otherwise, . + + + Creates an immutable hash set that contains only elements that are present either in the current set or in the specified collection, but not both. + The collection to compare to the current set. + A new set that contains the elements that are present only in the current set or in the specified collection, but not both. + + + Adds an item to the set. + The object to add to the set. + The set is read-only. + + + Removes all items from this set. + The set is read-only. + + + Copies the elements of the set to an array, starting at a particular index. + The one-dimensional array that is the destination of the elements copied from the set. The array must have zero-based indexing. + The zero-based index in at which copying begins. + + + Removes the first occurrence of a specific object from the set. + The object to remove from the set. + + if the element is successfully removed; otherwise, . + + + Returns an enumerator that iterates through the collection. + An enumerator that iterates through the collection. + + + Adds an element to the current set and returns a value that indicates whether the element was successfully added. + The element to add to the collection. + + if the element is added to the set; if the element is already in the set. + + + Removes all elements in the specified collection from the current set. + The collection of items to remove. + + + Modifies the current set so that it contains only elements that are also in a specified collection. + The collection to compare to the current collection. + + + Modifies the current set so that it contains only elements that are present either in the current set or in the specified collection, but not both. + The collection to compare to the current set. + + + Modifies the current set so that it contains all elements that are present in either the current set or in the specified collection. + The collection to compare to the current set. + + + Copies the elements of the set to an array, starting at a particular index. + The one-dimensional array that is the destination of the elements copied from the set. The array must have zero-based indexing. + The zero-based index in at which copying begins. + + + Returns an enumerator that iterates through a set. + An enumerator that can be used to iterate through the set. + + + Adds the specified element to this immutable set. + The element to add. + A new set with the element added, or this set if the element is already in the set. + + + Retrieves an empty set that has the same sorting and ordering semantics as this instance. + An empty set that has the same sorting or ordering semantics as this instance. + + + Removes the elements in the specified collection from the current set. + The collection of items to remove from this set. + A new set with the items removed; or the original set if none of the items were in the set. + + + Creates an immutable set that contains elements that exist in both this set and the specified set. + The collection to compare to the current set. + A new immutable set that contains any elements that exist in both sets. + + + Removes the specified element from this immutable set. + The element to remove. + A new set with the specified element removed, or the current set if the element cannot be found in the set. + + + Creates an immutable set that contains only elements that are present either in the current set or in the specified collection, but not both. + The collection to compare to the current set. + A new set that contains the elements that are present only in the current set or in the specified collection, but not both. + + + Creates a new immutable set that contains all elements that are present in either the current set or in the specified collection. + The collection to add elements from. + A new immutable set with the items added; or the original set if all the items were already in the set. + + + Creates an immutable hash set that has the same contents as this set and can be efficiently mutated across multiple operations by using standard mutable interfaces. + A set with the same contents as this set that can be efficiently mutated across multiple operations by using standard mutable interfaces. + + + Searches the set for a given value and returns the equal value it finds, if any. + The value to search for. + The value from the set that the search found, or the original value if the search yielded no match. + A value indicating whether the search was successful. + + + Creates a new immutable hash set that contains all elements that are present in either the current set or in the specified collection. + The collection to add elements from. + A new immutable hash set with the items added; or the original set if all the items were already in the set. + + + Gets an instance of the immutable hash set that uses the specified equality comparer for its search methods. + The equality comparer to use. + An instance of this immutable hash set that uses the given comparer. + + + Gets the number of elements in the immutable hash set. + The number of elements in the hash set. + + + Gets a value that indicates whether the current immutable hash set is empty. + + if this instance is empty; otherwise, . + + + Gets the object that is used to obtain hash codes for the keys and to check the equality of values in the immutable hash set. + The comparer used to obtain hash codes for the keys and check equality. + + + See the interface. + + + See the interface. + + + See . + + + Represents a hash set that mutates with little or no memory allocations and that can produce or build on immutable hash set instances very efficiently. + + NuGet package: System.Collections.Immutable (about immutable collections and how to install) + + + + Adds the specified item to the immutable hash set. + The item to add. + + if the item did not already belong to the collection; otherwise, . + + + Removes all items from the immutable hash set. + The hash set is read-only. + + + Determines whether the immutable hash set contains a specific value. + The object to locate in the hash set. + + if is found in the hash set ; otherwise, . + + + Removes all elements in the specified collection from the current hash set. + The collection of items to remove from the set. + + + Returns an enumerator that iterates through the immutable hash set. + An enumerator that can be used to iterate through the set. + + + Modifies the current set so that it contains only elements that are also in a specified collection. + The collection to compare to the current set. + + + Determines whether the current set is a proper (strict) subset of a specified collection. + The collection to compare to the current set. + + if the current set is a proper subset of ; otherwise, . + + + Determines whether the current set is a proper (strict) superset of a specified collection. + The collection to compare to the current set. + + if the current set is a proper superset of ; otherwise, . + + + Determines whether the current set is a subset of a specified collection. + The collection to compare to the current set. + + if the current set is a subset of ; otherwise, . + + + Determines whether the current set is a superset of a specified collection. + The collection to compare to the current set. + + if the current set is a superset of ; otherwise, . + + + Determines whether the current set overlaps with the specified collection. + The collection to compare to the current set. + + if the current set and share at least one common element; otherwise, . + + + Removes the first occurrence of a specific object from the immutable hash set. + The object to remove from the set. + The set is read-only. + + if was successfully removed from the set ; otherwise, . This method also returns if is not found in the original set. + + + Determines whether the current set and the specified collection contain the same elements. + The collection to compare to the current set. + + if the current set is equal to ; otherwise, . + + + Modifies the current set so that it contains only elements that are present either in the current set or in the specified collection, but not both. + The collection to compare to the current set. + + + Adds an item to the hash set. + The object to add to the set. + The set is read-only. + + + Copies the elements of the hash set to an array, starting at a particular array index. + The one-dimensional array that is the destination of the elements copied from the hash set. The array must have zero-based indexing. + The zero-based index in at which copying begins. + + + Returns an enumerator that iterates through the collection. + An enumerator that can be used to iterate through the collection. + + + Returns an enumerator that iterates through a collection. + An enumerator that can be used to iterate through the collection. + + + Creates an immutable hash set based on the contents of this instance. + An immutable set. + + + Searches the set for a given value and returns the equal value it finds, if any. + The value for which to search. + The value from the set that the search found, or the original value if the search yielded no match. + A value indicating whether the search was successful. + + + Modifies the current set so that it contains all elements that are present in both the current set and in the specified collection. + The collection to compare to the current set. + + + Gets the number of elements contained in the immutable hash set. + The number of elements contained in the immutable hash set. + + + Gets or sets the key comparer. + The key comparer. + + + Gets a value indicating whether the is read-only. + + if the is read-only; otherwise, . + + + Enumerates the contents of the immutable hash set without allocating any memory. + + NuGet package: System.Collections.Immutable (about immutable collections and how to install) + + + + Releases the resources used by the current instance of the class. + + + Advances the enumerator to the next element of the immutable hash set. + The hash set was modified after the enumerator was created. + + if the enumerator was successfully advanced to the next element; if the enumerator has passed the end of the hash set. + + + Sets the enumerator to its initial position, which is before the first element in the hash set. + The hash set was modified after the enumerator was created. + + + Gets the element at the current position of the enumerator. + The element at the current position of the enumerator. + + + Gets the current element. + + + Contains interlocked exchange mechanisms for immutable collections. + + NuGet package: System.Collections.Immutable (about immutable collections and how to install) + + + Obtains the value from a dictionary after having added it or updated an existing entry. + The variable or field to atomically update if the specified is not in the dictionary. + The key for the value to add or update. + The value to use if no previous value exists. + The function that receives the key and prior value and returns the new value with which to update the dictionary. + The type of key stored by the dictionary. + The type of value stored by the dictionary. + The added or updated value. + + + Obtains the value from a dictionary after having added it or updated an existing entry. + The variable or field to atomically update if the specified is not in the dictionary. + The key for the value to add or update. + The function that receives the key and returns a new value to add to the dictionary when no value previously exists. + The function that receives the key and prior value and returns the new value with which to update the dictionary. + The type of key stored by the dictionary. + The type of value stored by the dictionary. + The added or updated value. + + + Atomically enqueues an element to the end of a queue. + The variable or field to atomically update. + The value to enqueue. + The type of items contained in the collection. + + + Gets the value for the specified key from the dictionary, or if the key was not found, adds a new value to the dictionary. + The variable or field to atomically update if the specified key is not in the dictionary. + The key for the value to get or add. + The value to add to the dictionary the key is not found. + The type of the keys contained in the collection. + The type of the values contained in the collection. + The value at the specified key or if the key was not present. + + + Gets the value for the specified key from the dictionary, or if the key was not found, adds a new value to the dictionary. + The variable or field to atomically update if the specified is not in the dictionary. + The key for the value to retrieve or add. + The function to execute to obtain the value to insert into the dictionary if the key is not found. This delegate will not be invoked more than once. + The type of the keys contained in the collection. + The type of the values contained in the collection. + The value at the specified key or if the key was not present. + + + Gets the value for the specified key from the dictionary, or if the key was not found, adds a new value to the dictionary. + The variable or field to update if the specified is not in the dictionary. + The key for the value to retrieve or add. + The function to execute to obtain the value to insert into the dictionary if the key is not found. + The argument to pass to the value factory. + The type of the keys contained in the collection. + The type of the values contained in the collection. + The type of the argument supplied to the value factory. + The value at the specified key or if the key was not present. + + + Compares two immutable arrays for equality and, if they are equal, replaces one of the arrays. + The destination, whose value is compared with and possibly replaced. + The value that replaces the destination value if the comparison results in equality. + The value that is compared to the value at . + The type of element stored by the array. + The original value in . + + + Sets an array to the specified array and returns a reference to the original array, as an atomic operation. + The array to set to the specified value. + The value to which the parameter is set. + The type of element stored by the array. + The original value of . + + + Sets an array to the specified array if the array has not been initialized. + The array to set to the specified value. + The value to which the parameter is set, if it's not initialized. + The type of element stored by the array. + + if the array was assigned the specified value; otherwise, . + + + Pushes a new element onto the stack. + The stack to update. + The value to push on the stack. + The type of items in the stack. + + + Adds the specified key and value to the dictionary if the key is not in the dictionary. + The dictionary to update with the specified key and value. + The key to add, if is not already defined in the dictionary. + The value to add. + The type of the keys contained in the collection. + The type of the values contained in the collection. + + if the key is not in the dictionary; otherwise, . + + + Atomically removes and returns the specified element at the head of the queue, if the queue is not empty. + The variable or field to atomically update. + Set to the value from the head of the queue, if the queue not empty. + The type of items in the queue. + + if the queue is not empty and the head element is removed; otherwise, . + + + Removes an element from the top of the stack, if there is an element to remove. + The stack to update. + Receives the value removed from the stack, if the stack is not empty. + The type of items in the stack. + + if an element is removed from the stack; otherwise, . + + + Removes the element with the specified key, if the key exists. + The dictionary to update. + The key to remove. + Receives the value of the removed item, if the dictionary is not empty. + The type of the keys contained in the collection. + The type of the values contained in the collection. + + if the key was found and removed; otherwise, . + + + Sets the specified key to the specified value if the specified key already is set to a specific value. + The dictionary to update. + The key to update. + The new value to set. + The current value for in order for the update to succeed. + The type of the keys contained in the collection. + The type of the values contained in the collection. + + if and are present in the dictionary and comparison was updated to ; otherwise, . + + + Mutates a value in-place with optimistic locking transaction semantics via a specified transformation function. The transformation is retried as many times as necessary to win the optimistic locking race. + The variable or field to be changed, which may be accessed by multiple threads. + A function that mutates the value. This function should be side-effect free, as it may run multiple times when races occur with other threads. + The type of data. + + if the location's value is changed by applying the result of the function; if the location's value remained the same because the last invocation of returned the existing value. + + + Mutates an immutable array in-place with optimistic locking transaction semantics via a specified transformation function. + The transformation is retried as many times as necessary to win the optimistic locking race. + The immutable array to be changed. + A function that produces the new array from the old. This function should be side-effect free, as it may run multiple times when races occur with other threads. + The type of data in the immutable array. + + if the location's value is changed by applying the result of the function; if the location's value remained the same because the last invocation of returned the existing value. + + + Mutates a value in-place with optimistic locking transaction semantics via a specified transformation function. The transformation is retried as many times as necessary to win the optimistic locking race. + The variable or field to be changed, which may be accessed by multiple threads. + A function that mutates the value. This function should be side-effect free, as it may run multiple times when races occur with other threads. + The argument to pass to . + The type of data. + The type of argument passed to the . + + if the location's value is changed by applying the result of the function; if the location's value remained the same because the last invocation of returned the existing value. + + + Mutates an immutable array in-place with optimistic locking transaction semantics via a specified transformation function. + The transformation is retried as many times as necessary to win the optimistic locking race. + The immutable array to be changed. + A function that produces the new array from the old. This function should be side-effect free, as it may run multiple times when races occur with other threads. + The argument to pass to . + The type of data in the immutable array. + The type of argument passed to the . + + if the location's value is changed by applying the result of the function; if the location's value remained the same because the last invocation of returned the existing value. + + + Provides a set of initialization methods for instances of the class. + + NuGet package: System.Collections.Immutable (about immutable collections and how to install) + + + Creates an empty immutable list. + The type of items to be stored in the . + An empty immutable list. + + + Creates a new immutable list that contains the specified item. + The item to prepopulate the list with. + The type of items in the . + A new that contains the specified item. + + + Creates a new immutable list that contains the specified array of items. + An array that contains the items to prepopulate the list with. + The type of items in the . + A new immutable list that contains the specified items. + + + Creates a new immutable list builder. + The type of items stored by the collection. + The immutable collection builder. + + + Creates a new immutable list that contains the specified items. + The items to add to the list. + The type of items in the . + An immutable list that contains the specified items. + + + Searches for the specified object and returns the zero-based index of the first occurrence within the list. + The list to search. + The object to locate in the list. The value can be null for reference types. + The type of items in the list. + The zero-based index of the first occurrence of item within the range of elements in the list that extends from index to the last element, if found; otherwise, -1. + + + Searches for the specified object and returns the zero-based index of the first occurrence within the list. + The list to search. + The object to locate in the Immutable list. The value can be null for reference types. + The equality comparer to use in the search. + The type of items in the list. + The zero-based index of the first occurrence of item within the range of elements in the immutable list that extends from index to the last element, if found; otherwise, -1. + + + Searches for the specified object and returns the zero-based index of the first occurrence within the range of elements in the immutable list that extends from the specified index to the last element. + The list to search. + The object to locate in the Immutable list. The value can be null for reference types. + The zero-based starting index of the search. 0 (zero) is valid in an empty list. + The type of items in the list. + The zero-based index of the first occurrence of item within the range of elements in the Immutable list that extends from index to the last element, if found; otherwise, -1. + + + Searches for the specified object and returns the zero-based index of the first occurrence within the range of elements in the immutable list that extends from the specified index to the last element. + The list to search. + The object to locate in the Immutable list. The value can be null for reference types. + The zero-based starting index of the search. 0 (zero) is valid in an empty list. + The number of elements in the section to search. + The type of items in the list. + The zero-based index of the first occurrence of item within the range of elements in the Immutable list that extends from index to the last element, if found; otherwise, -1. + + + Searches for the specified object and returns the zero-based index of the last occurrence within the entire immutable list. + The list to search. + The object to locate in the Immutable list. The value can be null for reference types. + The type of items in the list. + The zero-based index of the last occurrence of item within the entire the Immutable list, if found; otherwise, -1. + + + Searches for the specified object and returns the zero-based index of the last occurrence within the entire immutable list. + The list to search. + The object to locate in the Immutable list. The value can be null for reference types. + The equality comparer to use in the search. + The type of items in the list. + The zero-based index of the last occurrence of item within the entire the Immutable list, if found; otherwise, -1. + + + Searches for the specified object and returns the zero-based index of the last occurrence within the range of elements in the immutable list that extends from the first element to the specified index. + The list to search. + The object to locate in the Immutable list. The value can be null for reference types. + The zero-based starting index of the backward search. + The type of items in the list. + The zero-based index of the last occurrence of item within the range of elements in the Immutable list that extends from the first element to index, if found; otherwise, -1. + + + Searches for the specified object and returns the zero-based index of the last occurrence within the range of elements in the immutable list that extends from the first element to the specified index. + The list to search. + The object to locate in the Immutable list. The value can be null for reference types. + The zero-based starting index of the backward search. + The number of elements in the section to search. + The type of items in the list. + The zero-based index of the last occurrence of item within the range of elements in the Immutable list that extends from the first element to index, if found; otherwise, -1. + + + Removes the specified value from this list. + The list to search. + The value to remove. + The type of items in the list. + A new immutable list with the element removed, or this list if the element is not in this list. + + + Removes the specified values from this list. + The list to search. + The items to remove if matches are found in this list. + The type of items in the list. + A new immutable list with the elements removed. + + + Replaces the first equal element in the list with the specified element. + The list to search. + The element to replace. + The element to replace the old element with. + The type of items in the list. + Thrown when the old value does not exist in the list. + The new list -- even if the value being replaced is equal to the new value for that position. + + + Enumerates a sequence and produces an immutable list of its contents. + The sequence to enumerate. + The type of the elements in the sequence. + An immutable list that contains the items in the specified sequence. + + + Creates an immutable list from the current contents of the builder's collection. + The builder to create the immutable list from. + The type of the elements in the list. + An immutable list that contains the current contents in the builder's collection. + + + Represents an immutable list, which is a strongly typed list of objects that can be accessed by index. + + NuGet package: System.Collections.Immutable (about immutable collections and how to install) + The type of elements in the list. + + + Gets an empty set with the default sort comparer. + + + Adds the specified object to the end of the immutable list. + The object to add. + A new immutable list with the object added. + + + Adds the elements of the specified collection to the end of the immutable list. + The collection whose elements will be added to the end of the list. + A new immutable list with the elements added. + + + Searches the entire sorted list for an element using the default comparer and returns the zero-based index of the element. + The object to locate. The value can be for reference types. + The default comparer cannot find a comparer implementation of the for type T. + The zero-based index of item in the sorted List, if item is found; otherwise, a negative number that is the bitwise complement of the index of the next element that is larger than item or, if there is no larger element, the bitwise complement of . + + + Searches the entire sorted list for an element using the specified comparer and returns the zero-based index of the element. + The object to locate. The value can be null for reference types. + The comparer implementation to use when comparing elements or null to use the default comparer. + comparer is , and the default comparer cannot find an comparer implementation for type T. + The zero-based index of item in the sorted List, if item is found; otherwise, a negative number that is the bitwise complement of the index of the next element that is larger than item or, if there is no larger element, the bitwise complement of . + + + Searches a range of elements in the sorted list for an element using the specified comparer and returns the zero-based index of the element. + The zero-based starting index of the range to search. + The length of the range to search. + The object to locate. The value can be null for reference types. + The comparer implementation to use when comparing elements, or to use the default comparer. + index is less than 0 or is less than 0. + index and do not denote a valid range in the list. + + is , and the default comparer cannot find an comparer implementation for type T. + The zero-based index of item in the sorted list, if item is found; otherwise, a negative number that is the bitwise complement of the index of the next element that is larger than item or, if there is no larger element, the bitwise complement of . + + + Removes all elements from the immutable list. + An empty list that retains the same sort or unordered semantics that this instance has. + + + Determines whether this immutable list contains the specified value. + The value to locate. + + if the list contains the specified value; otherwise, . + + + Converts the elements in the current immutable list to another type, and returns a list containing the converted elements. + A delegate that converts each element from one type to another type. + The type of the elements of the target array. + A list of the target type containing the converted elements from the current . + + + Copies the entire immutable list to a compatible one-dimensional array, starting at the beginning of the target array. + The one-dimensional array that is the destination of the elements copied from the immutable list. The array must have zero-based indexing. + + + Copies the entire immutable list to a compatible one-dimensional array, starting at the specified index of the target array. + The one-dimensional array that is the destination of the elements copied from the immutable list. The array must have zero-based indexing. + The zero-based index in at which copying begins. + + + Copies a range of elements from the immutable list to a compatible one-dimensional array, starting at the specified index of the target array. + The zero-based index in the source immutable list at which copying begins. + The one-dimensional array that is the destination of the elements copied from the immutable list. The array must have zero-based indexing. + The zero-based index in array at which copying begins. + The number of elements to copy. + + + Determines whether the immutable list contains elements that match the conditions defined by the specified predicate. + The delegate that defines the conditions of the elements to search for. + + if the immutable list contains one or more elements that match the conditions defined by the specified predicate; otherwise, . + + + Searches for an element that matches the conditions defined by the specified predicate, and returns the first occurrence within the entire immutable list. + The delegate that defines the conditions of the element to search for. + The first element that matches the conditions defined by the specified predicate, if found; otherwise, the default value for type . + + + Retrieves all the elements that match the conditions defined by the specified predicate. + The delegate that defines the conditions of the elements to search for. + An immutable list that contains all the elements that match the conditions defined by the specified predicate, if found; otherwise, an empty immutable list. + + + Searches for an element that matches the conditions defined by the specified predicate, and returns the zero-based index of the first occurrence within the range of elements in the immutable list that starts at the specified index and contains the specified number of elements. + The zero-based starting index of the search. + The number of elements in the section to search. + The delegate that defines the conditions of the element to search for. + The zero-based index of the first occurrence of an element that matches the conditions defined by match, if found; otherwise, ?1. + + + Searches for an element that matches the conditions defined by the specified predicate, and returns the zero-based index of the first occurrence within the range of elements in the immutable list that extends from the specified index to the last element. + The zero-based starting index of the search. + The delegate that defines the conditions of the element to search for. + The zero-based index of the first occurrence of an element that matches the conditions defined by match, if found; otherwise, ?1. + + + Searches for an element that matches the conditions defined by the specified predicate, and returns the zero-based index of the first occurrence within the entire immutable list. + The delegate that defines the conditions of the element to search for. + The zero-based index of the first occurrence of an element that matches the conditions defined by match, if found; otherwise, ?1. + + + Searches for an element that matches the conditions defined by the specified predicate, and returns the last occurrence within the entire immutable list. + The delegate that defines the conditions of the element to search for. + The last element that matches the conditions defined by the specified predicate, if found; otherwise, the default value for type . + + + Searches for an element that matches the conditions defined by the specified predicate, and returns the zero-based index of the last occurrence within the range of elements in the immutable list that contains the specified number of elements and ends at the specified index. + The zero-based starting index of the backward search. + The number of elements in the section to search. + The delegate that defines the conditions of the element to search for. + The zero-based index of the last occurrence of an element that matches the conditions defined by , if found; otherwise, ?1. + + + Searches for an element that matches the conditions defined by the specified predicate, and returns the zero-based index of the last occurrence within the range of elements in the immutable list that extends from the first element to the specified index. + The zero-based starting index of the backward search. + The delegate that defines the conditions of the element to search for. + The zero-based index of the last occurrence of an element that matches the conditions defined by , if found; otherwise, ?1. + + + Searches for an element that matches the conditions defined by the specified predicate, and returns the zero-based index of the last occurrence within the entire immutable list. + The delegate that defines the conditions of the element to search for. + The zero-based index of the last occurrence of an element that matches the conditions defined by , if found; otherwise, ?1. + + + Performs the specified action on each element of the immutable list. + The delegate to perform on each element of the immutable list. + + + Returns an enumerator that iterates through the immutable list. + An enumerator that can be used to iterate through the immutable list. + + + Creates a shallow copy of a range of elements in the source immutable list. + The zero-based index at which the range starts. + The number of elements in the range. + A shallow copy of a range of elements in the source immutable list. + + + Searches for the specified object and returns the zero-based index of the first occurrence within the entire immutable list. + The object to locate in the immutable list. The value can be for reference types. + The zero-based index of the first occurrence of within the entire immutable list, if found; otherwise, ?1. + + + Searches for the specified object and returns the zero-based index of the first occurrence within the range of elements in the list that starts at the specified index and contains the specified number of elements. + The object to locate in the list The value can be null for reference types. + The zero-based starting index of the search. 0 (zero) is valid in an empty list. + The number of elements in the section to search. + The equality comparer to use in the search. + The zero-based index of the first occurrence of item within the range of elements in the list that starts at index and contains count number of elements, if found; otherwise, -1. + + + Inserts the specified object into the immutable list at the specified index. + The zero-based index at which to insert the object. + The object to insert. + The new immutable list after the object is inserted. + + + Inserts the elements of a collection into the immutable list at the specified index. + The zero-based index at which to insert the elements. + The collection whose elements should be inserted. + The new immutable list after the elements are inserted. + + + Gets a read-only reference to the element of the set at the given . + The 0-based index of the element in the set to return. + + is negative or not less than . + A read-only reference to the element at the given position. + + + Searches for the specified object and returns the zero-based index of the last occurrence within the range of elements in the list that contains the specified number of elements and ends at the specified index. + The object to locate in the list. The value can be null for reference types. + The zero-based starting index of the backward search. + The number of elements in the section to search. + The equality comparer to use in the search. + The zero-based index of the last occurrence of item within the range of elements in the list that contains count number of elements and ends at index, if found; otherwise, -1. + + + Removes the first occurrence of the specified object from this immutable list. + The object to remove. + A new list with the object removed, or this list if the specified object is not in this list. + + + Removes the first occurrence of the object that matches the specified value from this immutable list. + The value of the element to remove from the list. + The equality comparer to use in the search. + A new list with the object removed, or this list if the specified object is not in this list. + + + Removes all the elements that match the conditions defined by the specified predicate. + The delegate that defines the conditions of the elements to remove. + The new list with the elements removed. + + + Removes the element at the specified index. + The zero-based index of the element to remove. + A new list with the element removed. + + + Removes a range of elements from this immutable list. + The collection whose elements should be removed if matches are found in this list. + A new list with the elements removed. + + + Removes the specified values from this list. + The items to remove if matches are found in this list. + The equality comparer to use in the search. + A new list with the elements removed. + + + Removes a range of elements, starting from the specified index and containing the specified number of elements, from this immutable list. + The starting index to begin removal. + The number of elements to remove. + A new list with the elements removed. + + + Replaces the specified element in the immutable list with a new element. + The element to replace. + The element to replace with. + + does not exist in the immutable list. + The new list with the replaced element, even if it is equal to the old element. + + + Replaces the specified element in the immutable list with a new element. + The element to replace in the list. + The element to replace with. + The comparer to use to check for equality. + A new list with the object replaced, or this list if the specified object is not in this list. + + + Reverses the order of the elements in the entire immutable list. + The reversed list. + + + Reverses the order of the elements in the specified range of the immutable list. + The zero-based starting index of the range to reverse. + The number of elements in the range to reverse. + The reversed list. + + + Replaces an element at a given position in the immutable list with the specified element. + The position in the list of the element to replace. + The element to replace the old element with. + The new list with the replaced element, even if it is equal to the old element at that position. + + + Sorts the elements in the entire immutable list using the default comparer. + The sorted list. + + + Sorts the elements in the entire immutable list using the specified comparer. + The implementation to use when comparing elements, or to use the default comparer (). + The sorted list. + + + Sorts the elements in the entire immutable list using the specified comparer. + The delegate to use when comparing elements. + + is . + The sorted list. + + + Sorts a range of elements in the immutable list using the specified comparer. + The zero-based starting index of the range to sort. + The length of the range to sort. + The implementation to use when comparing elements, or to use the default comparer (). + The sorted list. + + + Adds the specified item to the immutable list. + The item to add. + Always thrown. + + + Removes all items from the immutable list. + + + + Removes the first occurrence of a specific object from the immutable list. + The object to remove. + Always thrown. + + if was successfully removed from the list; otherwise, . This method also returns if is not found in the original list. + + + Returns an enumerator that iterates through the immutable list. + An enumerator that can be used to iterate through the list. + + + Inserts an object in the immutable list at the specified index. + The zero-based index at which should be inserted. + The object to insert. + + + + Removes the value at the specified index. + The zero-based index of the item to remove. + + + + Copies the entire immutable list to a compatible one-dimensional array, starting at the specified array index. + The one-dimensional array that is the destination of the elements copied from immutable list. + The zero-based index in at which copying begins. + + + Returns an enumerator that iterates through the immutable list. + An enumerator that can be used to iterate through the list. + + + Adds an item to the immutable list. + The object to add to the list. + Always thrown. + The position into which the new element was inserted, or -1 to indicate that the item was not inserted into the list. + + + Removes all items from the immutable list. + Always thrown. + + + Determines whether the immutable list contains a specific value. + The object to locate in the list. + + + if the object is found in the list; otherwise, . + + + Determines the index of a specific item in the immutable list. + The object to locate in the list. + + The index of if found in the list; otherwise, -1. + + + Inserts an item into the immutable list at the specified index. + The zero-based index at which should be inserted. + The object to insert into the list. + Always thrown. + + + Removes the first occurrence of a specific object from the immutable list. + The object to remove from the list. + Always thrown. + + + Removes the item at the specified index of the immutable list. + The zero-based index of the item to remove. + Always thrown. + + + Adds the specified value to this immutable list. + The value to add. + A new list with the element added. + + + Adds the specified values to this immutable list. + The values to add. + A new list with the elements added. + + + Retrieves an empty list that has the same sorting and ordering semantics as this instance. + An empty list that has the same sorting and ordering semantics as this instance. + + + Inserts the specified element at the specified index in the immutable list. + The index at which to insert the value. + The element to insert. + A new immutable list that includes the specified element. + + + Inserts the specified elements at the specified index in the immutable list. + The index at which to insert the elements. + The elements to insert. + A new immutable list that includes the specified elements. + + + Removes the element with the specified value from the list. + The value of the element to remove from the list. + The comparer to use to compare elements for equality. + A new with the specified element removed. + + + Removes all the elements that match the conditions defined by the specified predicate. + The delegate that defines the conditions of the elements to remove. + A new immutable list with the elements removed. + + + Removes the element at the specified index of the immutable list. + The index of the element to remove. + A new list with the element removed. + + + Removes a range of elements from this immutable list that match the items specified. + The range of items to remove from the list, if found. + The equality comparer to use to compare elements. + + or is . + An immutable list with the items removed. + + + Removes the specified number of elements at the specified location from this list. + The starting index of the range of elements to remove. + The number of elements to remove. + A new list with the elements removed. + + + Replaces an element in the list with the specified element. + The element to replace. + The element to replace the old element with. + The equality comparer to use in the search. + Thrown when the old value does not exist in the list. + The new list. + + + Replaces an element in the list at a given position with the specified element. + The position in the list of the element to replace. + The element to replace the old element with. + The new list. + + + Creates a list that has the same contents as this list and can be efficiently mutated across multiple operations using standard mutable interfaces. + The created list with the same contents as this list. + + + Determines whether every element in the immutable list matches the conditions defined by the specified predicate. + The delegate that defines the conditions to check against the elements. + + if every element in the immutable list matches the conditions defined by the specified predicate; otherwise, . If the list has no elements, the return value is . + + + Gets the number of elements contained in the list. + The number of elements in the list. + + + Gets a value that indicates whether this list is empty. + + if the list is empty; otherwise, . + + + Gets the element at the specified index of the list. + The index of the element to retrieve. + In a get operation, is negative or not less than . + The element at the specified index. + + + Gets a value indicating whether the is read-only. + + if the is read-only; otherwise, . + + + Gets or sets the value at the specified index. + The zero-based index of the item to access. + Thrown from getter when is negative or not less than . + Always thrown from the setter. + Value stored in the specified index. + + + This type is immutable, so it is always thread-safe. See the interface. + Boolean value determining whether the collection is thread-safe. + + + See . + Object used for synchronizing access to the collection. + + + Gets a value indicating whether the has a fixed size. + + if the has a fixed size; otherwise, . + + + Gets a value indicating whether the is read-only. + + if the is read-only; otherwise, . + + + Gets or sets the at the specified index. + The index. + Thrown from getter when is negative or not less than . + Always thrown from the setter. + The value at the specified index. + + + Represents a list that mutates with little or no memory allocations and that can produce or build on immutable list instances very efficiently. + + NuGet package: System.Collections.Immutable (about immutable collections and how to install) + + + + Adds an item to the immutable list. + The item to add to the list. + + + Adds a series of elements to the end of this list. + The elements to add to the end of the list. + + + Searches the entire for an element using the default comparer and returns the zero-based index of the element. + The object to locate. The value can be null for reference types. + The default comparer cannot find an implementation of the generic interface or the interface for type T. + The zero-based index of item in the , if item is found; otherwise, a negative number that is the bitwise complement of the index of the next element that is larger than . + + + Searches the entire for an element using the specified comparer and returns the zero-based index of the element. + The object to locate. This value can be null for reference types. + The implementation to use when comparing elements, or for the default comparer. + + is , and the default comparer cannot find an implementation of the generic interface or the interface for type T. + The zero-based index of item in the , if item is found; otherwise, a negative number that is the bitwise complement of the index of the next element that is larger than . + + + Searches the specified range of the for an element using the specified comparer and returns the zero-based index of the element. + The zero-based starting index of the range to search. + The length of the range to search. + The object to locate. This value can be null for reference types. + The implementation to use when comparing elements, or for the default comparer. + + is less than 0. +-or- + + is less than 0. + + and do not denote a valid range in the . + + is , and the default comparer cannot find an implementation of the generic interface or the interface for type T. + The zero-based index of item in the , if item is found; otherwise, a negative number that is the bitwise complement of the index of the next element that is larger than . + + + Removes all items from the immutable list. + + + Determines whether the immutable list contains a specific value. + The object to locate in the list. + + if item is found in the list; otherwise, . + + + Creates a new immutable list from the list represented by this builder by using the converter function. + The converter function. + The type of the output of the delegate converter function. + A new immutable list from the list represented by this builder. + + + Copies the entire immutable list to a compatible one-dimensional array, starting at the beginning of the target array. + The one-dimensional array that is the destination of the elements copied from the immutable list. The array must have zero-based indexing. + + + Copies the entire immutable list to a compatible one-dimensional array, starting at the specified index of the target array. + The one-dimensional array that is the destination of the elements copied from the immutable list. The array must have zero-based indexing. + The zero-based index in array at which copying begins. + + + Copies the entire immutable list to a compatible one-dimensional array, starting at the specified index of the target array. + The zero-based index in the source immutable list at which copying begins. + The one-dimensional array that is the destination of the elements copied from the immutable list. The array must have zero-based indexing. + The zero-based index in at which copying begins. + The number of elements to copy. + + + Determines whether the immutable list contains elements that match the conditions defined by the specified predicate. + The delegate that defines the conditions of the elements to search for. + + if the immutable list contains one or more elements that match the conditions defined by the specified predicate; otherwise, . + + + Searches for an element that matches the conditions defined by the specified predicate, and returns the first occurrence within the entire immutable list. + The delegate that defines the conditions of the element to search for. + The first element that matches the conditions defined by the specified predicate, if found; otherwise, the default value for type . + + + Retrieves all the elements that match the conditions defined by the specified predicate. + The delegate that defines the conditions of the elements to search for. + An immutable list containing all the elements that match the conditions defined by the specified predicate, if found; otherwise, an empty immutable list. + + + Searches for an element that matches the conditions defined by the specified predicate, and returns the zero-based index of the first occurrence within the range of elements in the immutable list that starts at the specified index and contains the specified number of elements. + The zero-based starting index of the search. + The number of elements in the section to search. + The delegate that defines the conditions of the element to search for. + The zero-based index of the first occurrence of an element that matches the conditions defined by , if found; otherwise, -1. + + + Searches for an element that matches the conditions defined by the specified predicate, and returns the zero-based index of the first occurrence within the range of elements in the immutable list that extends from the specified index to the last element. + The zero-based starting index of the search. + The delegate that defines the conditions of the element to search for. + The zero-based index of the first occurrence of an element that matches the conditions defined by , if found; otherwise, -1. + + + Searches for an element that matches the conditions defined by the specified predicate, and returns the zero-based index of the first occurrence within the entire immutable list. + The delegate that defines the conditions of the element to search for. + The zero-based index of the first occurrence of an element that matches the conditions defined by , if found; otherwise, -1. + + + Searches for an element that matches the conditions defined by the specified predicate, and returns the last occurrence within the entire immutable list. + The delegate that defines the conditions of the element to search for. + The last element that matches the conditions defined by the specified predicate, found; otherwise, the default value for type . + + + Searches for an element that matches the conditions defined by the specified predicate, and returns the zero-based index of the last occurrence within the range of elements in the immutable list that contains the specified number of elements and ends at the specified index. + The zero-based starting index of the backward search. + The number of elements in the section to search. + The delegate that defines the conditions of the element to search for. + The zero-based index of the last occurrence of an element that matches the conditions defined by , if found; otherwise, -1. + + + Searches for an element that matches the conditions defined by the specified predicate, and returns the zero-based index of the last occurrence within the range of elements in the immutable list that extends from the first element to the specified index. + The zero-based starting index of the backward search. + The delegate that defines the conditions of the element to search for. + The zero-based index of the last occurrence of an element that matches the conditions defined by , if found; otherwise, -1. + + + Searches for an element that matches the conditions defined by the specified predicate, and returns the zero-based index of the last occurrence within the entire immutable list. + The delegate that defines the conditions of the element to search for. + The zero-based index of the last occurrence of an element that matches the conditions defined by , if found; otherwise, -1. + + + Performs the specified action on each element of the list. + The delegate to perform on each element of the list. + + + Returns an enumerator that iterates through the collection. + An enumerator that can be used to iterate through the list. + + + Creates a shallow copy of a range of elements in the source immutable list. + The zero-based index at which the range starts. + The number of elements in the range. + A shallow copy of a range of elements in the source immutable list. + + + Searches for the specified object and returns the zero-based index of the first occurrence within the range of elements in the immutable list. + The object to locate in the immutable list. The value can be for reference types. + The zero-based index of the first occurrence of within the range of elements in the immutable list, if found; otherwise, -1. + + + Searches for the specified object and returns the zero-based index of the first occurrence within the range of elements in the immutable list that extends from the specified index to the last element. + The object to locate in the immutable list. The value can be for reference types. + The zero-based starting index of the search. 0 (zero) is valid in an empty list. + The zero-based index of the first occurrence of item within the range of elements in the immutable list that extends from to the last element, if found; otherwise, -1. + + + Searches for the specified object and returns the zero-based index of the first occurrence within the range of elements in the immutable list that starts at the specified index and contains the specified number of elements. + The object to locate in the immutable list. The value can be for reference types. + The zero-based starting index of the search. 0 (zero) is valid in an empty list. + The number of elements in the section to search. + The zero-based index of the first occurrence of item within the range of elements in the immutable list that starts at and contains number of elements, if found; otherwise, -1. + + + Searches for the specified object and returns the zero-based index of the first occurrence within the range of elements in the that starts at the specified index and contains the specified number of elements. + The object to locate in the immutable list. The value can be for reference types. + The zero-based starting index of the search. 0 (zero) is valid in an empty list. + The number of elements to search. + The value comparer to use for comparing elements for equality. + The zero-based index of the first occurrence of item within the range of elements in the immutable list that starts at and contains number of elements, if found; otherwise, -1 + + + Inserts an item to the immutable list at the specified index. + The zero-based index at which should be inserted. + The object to insert into the immutable list. + + + Inserts the elements of a collection into the immutable list at the specified index. + The zero-based index at which the new elements should be inserted. + The collection whose elements should be inserted into the immutable list. The collection itself cannot be , but it can contain elements that are null, if type T is a reference type. + + + Gets a read-only reference to the value for a given into the list. + The index of the desired element. + A read-only reference to the value at the specified . + + + Searches for the specified object and returns the zero-based index of the last occurrence within the entire immutable list. + The object to locate in the immutable list. The value can be for reference types. + The zero-based index of the last occurrence of within the entire immutable list, if found; otherwise, -1. + + + Searches for the specified object and returns the zero-based index of the last occurrence within the range of elements in the immutable list that extends from the first element to the specified index. + The object to locate in the immutable list. The value can be for reference types. + The zero-based starting index of the backward search. + The zero-based index of the last occurrence of within the range of elements in the immutable list that extends from the first element to , if found; otherwise, -1. + + + Searches for the specified object and returns the zero-based index of the last occurrence within the range of elements in the immutable list that contains the specified number of elements and ends at the specified index. + The object to locate in the immutable list. The value can be for reference types. + The zero-based starting index of the backward search. + The number of elements in the section to search. + The zero-based index of the last occurrence of within the range of elements in the immutable list that contains number of elements and ends at , if found; otherwise, -1. + + + Searches for the specified object and returns the zero-based index of the last occurrence within the range of elements in the immutable list that contains the specified number of elements and ends at the specified index. + The object to locate in the immutable list. The value can be for reference types. + The zero-based starting index of the search. 0 (zero) is valid in an empty list. + The number of elements to search. + The value comparer to use for comparing elements for equality. + The zero-based index of the first occurrence of item within the range of elements in the immutable list that starts at and contains number of elements, if found; otherwise, -1 + + + Removes the first occurrence of a specific object from the immutable list. + The object to remove from the list. + + if item was successfully removed from the list; otherwise, . This method also returns if item is not found in the list. + + + Removes all the elements that match the conditions defined by the specified predicate. + The delegate that defines the conditions of the elements to remove. + The number of elements removed from the immutable list. + + + Removes the item at the specified index of the immutable list. + The zero-based index of the item to remove from the list. + + + Reverses the order of the elements in the entire immutable list. + + + Reverses the order of the elements in the specified range of the immutable list. + The zero-based starting index of the range to reverse. + The number of elements in the range to reverse. + + + Sorts the elements in the entire immutable list by using the default comparer. + + + Sorts the elements in the entire immutable list by using the specified comparer. + The implementation to use when comparing elements, or to use the default comparer (). + + + Sorts the elements in the entire immutable list by using the specified comparison object. + The object to use when comparing elements. + + is . + + + Sorts the elements in a range of elements in the immutable list by using the specified comparer. + The zero-based starting index of the range to sort. + The length of the range to sort. + The implementation to use when comparing elements, or to use the default comparer (). + + + Returns an enumerator that iterates through the collection. + An enumerator that can be used to iterate through the collection. + + + Copies the elements of the list to an array, starting at a particular array index. + The one-dimensional array that is the destination of the elements copied from the list. The array must have zero-based indexing. + The zero-based index in at which copying begins. + + + + Returns an enumerator that iterates through the collection. + An enumerator that can be used to iterate through the collection. + + + Adds an item to the list. + The object to add to the list. + + The position into which the new element was inserted, or -1 to indicate that the item was not inserted into the collection. + + + Removes all items from the list. + + + + Determines whether the list contains a specific value. + The object to locate in the list. + + + if the is found in the list; otherwise, . + + + Determines the index of a specific item in the list. + The object to locate in the list. + + The index of if found in the list; otherwise, -1. + + + Inserts an item to the list at the specified index. + The zero-based index at which should be inserted. + The object to insert into the list. + + + + Removes the first occurrence of a specific object from the list. + The object to remove from the list. + + + + Creates an immutable list based on the contents of this instance. + An immutable list. + + + Determines whether every element in the immutable list matches the conditions defined by the specified predicate. + The delegate that defines the conditions to check against the elements. + + if every element in the immutable list matches the conditions defined by the specified predicate; otherwise, . If the list has no elements, the return value is . + + + Gets the number of elements in this immutable list. + The number of elements in this list. + + + Gets or sets the value for a given index in the list. + The index of the item to get or set. + The value at the specified index. + + + Gets a value that indicates whether this instance is read-only. + Always . + + + Gets a value that indicates whether access to the is synchronized (thread safe). + + if access to the is synchronized (thread safe); otherwise, . + + + Gets an object that can be used to synchronize access to the . + An object that can be used to synchronize access to the . + + + Gets a value that indicates whether the has a fixed size. + + if the has a fixed size; otherwise, . + + + Gets a value that indicates whether the is read-only. + + if the is read-only; otherwise, . + + + Gets or sets the at the specified index. + The index. + The object at the specified index. + + + Enumerates the contents of a binary tree. + + NuGet package: System.Collections.Immutable (about immutable collections and how to install) + + + + Releases the resources used by the current instance of the class. + + + Advances enumeration to the next element of the immutable list. + + if the enumerator was successfully advanced to the next element; if the enumerator has passed the end of the list. + + + Sets the enumerator to its initial position, which is before the first element in the immutable list. + + + Gets the element at the current position of the enumerator. + The element at the current position of the enumerator. + + + The current element. + + + Provides a set of initialization methods for instances of the class. + + NuGet package: System.Collections.Immutable (about immutable collections and how to install) + + + Creates an empty immutable queue. + The type of items to be stored in the immutable queue. + An empty immutable queue. + + + Creates a new immutable queue that contains the specified item. + The item to prepopulate the queue with. + The type of items in the immutable queue. + A new immutable queue that contains the specified item. + + + Creates a new immutable queue that contains the specified array of items. + An array that contains the items to prepopulate the queue with. + The type of items in the immutable queue. + A new immutable queue that contains the specified items. + + + Creates a new immutable queue that contains the specified items. + The items to add to the queue before immutability is applied. + The type of elements in the queue. + An immutable queue that contains the specified items. + + + Removes the item at the beginning of the immutable queue, and returns the new queue. + The queue to remove the item from. + When this method returns, contains the item from the beginning of the queue. + The type of elements in the immutable queue. + The stack is empty. + The new queue with the item removed. + + + Represents an immutable queue. + + NuGet package: System.Collections.Immutable (about immutable collections and how to install) + The type of elements in the queue. + + + Removes all objects from the immutable queue. + The empty immutable queue. + + + Removes the element at the beginning of the immutable queue, and returns the new queue. + The queue is empty. + The new immutable queue; never . + + + Removes the item at the beginning of the immutable queue, and returns the new queue. + When this method returns, contains the element from the beginning of the queue. + The queue is empty. + The new immutable queue with the beginning element removed. + + + Adds an element to the end of the immutable queue, and returns the new queue. + The element to add. + The new immutable queue. + + + Returns an enumerator that iterates through the immutable queue. + An enumerator that can be used to iterate through the queue. + + + Returns the element at the beginning of the immutable queue without removing it. + The queue is empty. + The element at the beginning of the queue. + + + Gets a read-only reference to the element at the front of the queue. + The queue is empty. + Read-only reference to the element at the front of the queue. + + + Returns an enumerator that iterates through the collection. + An enumerator that can be used to iterate through the collection. + + + Returns an enumerator that iterates through a collection. + An object that can be used to iterate through the collection. + + + Removes all elements from the immutable queue. + The empty immutable queue. + + + Removes the element at the beginning of the immutable queue, and returns the new queue. + Thrown when the queue is empty. + The new immutable queue; never . + + + Adds an element to the end of the immutable queue, and returns the new queue. + The element to add. + The new immutable queue. + + + Gets an empty immutable queue. + An empty immutable queue. + + + Gets a value that indicates whether this immutable queue is empty. + + NuGet package: System.Collections.Immutable (about immutable collections and how to install) + + if this queue is empty; otherwise, . + + + Enumerates the contents of an immutable queue without allocating any memory. + + NuGet package: System.Collections.Immutable (about immutable collections and how to install) + + + + Advances the enumerator to the next element of the immutable queue. + + if the enumerator was successfully advanced to the next element; if the enumerator has passed the end of the queue. + + + Gets the element at the current position of the enumerator. + The element at the current position of the enumerator. + + + Provides a set of initialization methods for instances of the class. + + NuGet package: System.Collections.Immutable (about immutable collections and how to install) + + + Creates an empty immutable sorted dictionary. + The type of keys stored by the dictionary. + The type of values stored by the dictionary. + An empty immutable sorted dictionary. + + + Creates an empty immutable sorted dictionary that uses the specified key comparer. + The implementation to use to determine the equality of keys in the dictionary. + The type of keys stored by the dictionary. + The type of values stored by the dictionary. + An empty immutable sorted dictionary. + + + Creates an empty immutable sorted dictionary that uses the specified key and value comparers. + The implementation to use to determine the equality of keys in the dictionary. + The implementation to use to determine the equality of values in the dictionary. + The type of keys stored by the dictionary. + The type of values stored by the dictionary. + An empty immutable sorted dictionary. + + + Creates a new immutable sorted dictionary builder. + The type of keys stored by the dictionary. + The type of values stored by the dictionary. + The immutable collection builder. + + + Creates a new immutable sorted dictionary builder. + The key comparer. + The type of keys stored by the dictionary. + The type of values stored by the dictionary. + The immutable collection builder. + + + Creates a new immutable sorted dictionary builder. + The key comparer. + The value comparer. + The type of keys stored by the dictionary. + The type of values stored by the dictionary. + The immutable collection builder. + + + Creates a new immutable sorted dictionary from the specified range of items with the specified key comparer. + The comparer implementation to use to evaluate keys for equality and sorting. + The items to add to the sorted dictionary. + The type of keys stored in the dictionary. + The type of values stored in the dictionary. + The new immutable sorted dictionary that contains the specified items and uses the specified key comparer. + + + Creates a new immutable sorted dictionary from the specified range of items with the specified key and value comparers. + The comparer implementation to use to compare keys for equality and sorting. + The comparer implementation to use to compare values for equality. + The items to add to the sorted dictionary before it's immutable. + The type of keys stored in the dictionary. + The type of values stored in the dictionary. + An immutable sorted dictionary that contains the specified items and uses the specified comparers. + + + Creates an immutable sorted dictionary that contains the specified items and uses the default comparer. + The items to add to the sorted dictionary before it's immutable. + The type of keys stored in the dictionary. + The type of values stored in the dictionary. + An immutable sorted dictionary that contains the specified items. + + + Enumerates a sequence of key/value pairs and produces an immutable sorted dictionary of its contents. + The sequence of key/value pairs to enumerate. + The type of the keys in the dictionary. + The type of the values in the dictionary. + An immutable sorted dictionary that contains the key/value pairs in the specified sequence. + + + Enumerates a sequence of key/value pairs and produces an immutable dictionary of its contents by using the specified key comparer. + The sequence of key/value pairs to enumerate. + The key comparer to use when building the immutable dictionary. + The type of the keys in the dictionary. + The type of the values in the dictionary. + An immutable sorted dictionary that contains the key/value pairs in the specified sequence. + + + Enumerates a sequence of key/value pairs and produces an immutable sorted dictionary of its contents by using the specified key and value comparers. + The sequence of key/value pairs to enumerate. + The key comparer to use when building the immutable dictionary. + The value comparer to use for the immutable dictionary. + The type of the keys in the dictionary. + The type of the values in the dictionary. + An immutable sorted dictionary that contains the key/value pairs in the specified sequence. + + + Creates an immutable sorted dictionary from the current contents of the builder's dictionary. + The builder to create the immutable sorted dictionary from. + The type of the keys in the dictionary. + The type of the values in the dictionary. + An immutable sorted dictionary that contains the current contents in the builder's dictionary. + + + Enumerates and transforms a sequence, and produces an immutable sorted dictionary of its contents. + The sequence to enumerate to generate the dictionary. + The function that will produce the key for the dictionary from each sequence element. + The function that will produce the value for the dictionary from each sequence element. + The type of the elements in the sequence. + The type of the keys in the resulting dictionary. + The type of the values in the resulting dictionary. + An immutable sorted dictionary that contains the items in the specified sequence. + + + Enumerates and transforms a sequence, and produces an immutable sorted dictionary of its contents by using the specified key comparer. + The sequence to enumerate to generate the dictionary. + The function that will produce the key for the dictionary from each sequence element. + The function that will produce the value for the dictionary from each sequence element. + The key comparer to use for the dictionary. + The type of the elements in the sequence. + The type of the keys in the resulting dictionary. + The type of the values in the resulting dictionary. + An immutable dictionary that contains the items in the specified sequence. + + + Enumerates and transforms a sequence, and produces an immutable sorted dictionary of its contents by using the specified key and value comparers. + The sequence to enumerate to generate the dictionary. + The function that will produce the key for the dictionary from each sequence element. + The function that will produce the value for the dictionary from each sequence element. + The key comparer to use for the dictionary. + The value comparer to use for the dictionary. + The type of the elements in the sequence. + The type of the keys in the resulting dictionary. + The type of the values in the resulting dictionary. + An immutable sorted dictionary that contains the items in the specified sequence. + + + Represents an immutable sorted dictionary. + + NuGet package: System.Collections.Immutable (about immutable collections and how to install) + The type of the key contained in the dictionary. + The type of the value contained in the dictionary. + + + Gets an empty immutable sorted dictionary. + + + Adds an element with the specified key and value to the immutable sorted dictionary. + The key of the entry to add. + The value of entry to add. + The given key already exists in the dictionary but has a different value. + A new immutable sorted dictionary that contains the additional key/value pair. + + + Adds the specific key/value pairs to the immutable sorted dictionary. + The key/value pairs to add. + One of the given keys already exists in the dictionary but has a different value. + A new immutable dictionary that contains the additional key/value pairs. + + + Retrieves an empty immutable sorted dictionary that has the same ordering and key/value comparison rules as this dictionary instance. + An empty dictionary with equivalent ordering and key/value comparison rules. + + + Determines whether this immutable sorted dictionary contains the specified key/value pair. + The key/value pair to locate. + + if the specified key/value pair is found in the dictionary; otherwise, . + + + Determines whether this immutable sorted map contains the specified key. + The key to locate. + + if the immutable dictionary contains the specified key; otherwise, . + + + Determines whether the immutable sorted dictionary contains an element with the specified value. + The value to locate. The value can be for reference types. + + if the dictionary contains an element with the specified value; otherwise, . + + + Returns an enumerator that iterates through the immutable sorted dictionary. + An enumerator that can be used to iterate through the dictionary. + + + Removes the element with the specified value from the immutable sorted dictionary. + The value of the element to remove. + A new immutable dictionary with the specified element removed; or this instance if the specified value cannot be found in the dictionary. + + + Removes the elements with the specified keys from the immutable sorted dictionary. + The keys of the elements to remove. + A new immutable dictionary with the specified keys removed; or this instance if the specified keys cannot be found in the dictionary. + + + Sets the specified key and value in the immutable sorted dictionary, possibly overwriting an existing value for the given key. + The key of the entry to add. + The key value to set. + A new immutable sorted dictionary that contains the specified key/value pair. + + + Sets the specified key/value pairs in the immutable sorted dictionary, possibly overwriting existing values for the keys. + The key/value pairs to set in the dictionary. If any of the keys already exist in the dictionary, this method will overwrite their previous values. + An immutable dictionary that contains the specified key/value pairs. + + + Adds an item to the . + The object to add to the . + + + Removes all items from the . + + + Copies the elements of the to an , starting at a particular index. + The one-dimensional that is the destination of the elements copied from . The must have zero-based indexing. + The zero-based index in at which copying begins. + + + Removes the first occurrence of a specific object from the . + The object to remove from the . + + if was successfully removed from the ; otherwise, . This method also returns if is not found in the original . + + + Adds an element with the provided key and value to the generic dictionary. + The object to use as the key of the element to add. + The object to use as the value of the element to add. + + is . + An element with the same key already exists in the . + The is read-only. + + + Removes the element with the specified key from the generic dictionary. + The key of the element to remove. + + is . + The is read-only. + + if the element is successfully removed; otherwise, . This method also returns if was not found in the original generic dictionary. + + + Returns an enumerator that iterates through the collection. + An enumerator that can be used to iterate through the collection. + + + Copies the elements of the dictionary to an array, starting at a particular array index. + The one-dimensional array that is the destination of the elements copied from the dictionary. The array must have zero-based indexing. + The zero-based index in at which copying begins. + + + Adds an element with the provided key and value to the dictionary object. + The object to use as the key of the element to add. + The object to use as the value of the element to add. + + + Clears this instance. + The dictionary object is read-only. + + + Determines whether the immutable dictionary object contains an element with the specified key. + The key to locate in the dictionary object. + + if the dictionary contains an element with the key; otherwise, . + + + Returns an object for the immutable dictionary object. + An enumerator object for the dictionary object. + + + Removes the element with the specified key from the immutable dictionary object. + The key of the element to remove. + + + Returns an enumerator that iterates through a collection. + An enumerator object that can be used to iterate through the collection. + + + See the interface. + Key of the entry to be added. + Value of the entry to be added. + The instance. + + + See the interface. + Sequence of key/value pairs to be added. + The instance. + + + See the interface. + The instance. + + + See the interface. + Key of entry to be removed. + The instance. + + + See the interface. + Sequence of keys to be removed. + The instance. + + + See the interface. + Key of entry to be updated. + Value of entry to be updated. + The instance. + + + Applies a given set of key-value pairs to an immutable dictionary, replacing any conflicting keys in the resulting dictionary. + A set of key-value pairs to set on the map. + The instance. + + + Creates an immutable sorted dictionary with the same contents as this dictionary that can be efficiently mutated across multiple operations by using standard mutable interfaces. + A collection with the same contents as this dictionary. + + + Determines whether this dictionary contains a specified key. + The key to search for. + The matching key located in the dictionary if found, or equalkey if no match is found. + + if a match for is found; otherwise, . + + + Gets the value associated with the specified key. + The key whose value will be retrieved. + When this method returns, contains the value associated with the specified key, if the key is found; otherwise, contains the default value for the type of the parameter. + + if the dictionary contains an element with the specified key; otherwise, . + + + Returns a read-only reference to the value associated with the provided . + Key of the entry to be looked up. + The is not present. + A read-only reference to the value associated with the provided . + + + Gets an instance of the immutable sorted dictionary that uses the specified key comparer. + The key comparer to use. + An instance of the immutable dictionary that uses the given comparer. + + + Gets an instance of the immutable sorted dictionary that uses the specified key and value comparers. + The key comparer to use. + The value comparer to use. + An instance of the immutable dictionary that uses the given comparers. + + + Gets the number of key/value pairs in the immutable sorted dictionary. + The number of key/value pairs in the dictionary. + + + Gets a value that indicates whether this instance of the immutable sorted dictionary is empty. + + if this instance is empty; otherwise, . + + + Gets the associated with the specified key. + The key to retrieve the value for. + The value associated with the specified key. If no results are found, the operation throws an exception. + + + Gets the key comparer for the immutable sorted dictionary. + The key comparer for the dictionary. + + + Gets the keys in the immutable sorted dictionary. + The keys in the immutable dictionary. + + + Gets a value indicating whether the is read-only. + + if the is read-only; otherwise, . + + + Gets or sets the with the specified key. + The object to use as the key of the element to access. + An object of type associated with the . + + + Gets the keys. + A collection containing the keys. + + + Gets the values. + A collection containing the values. + + + Gets a value indicating whether access to the is synchronized (thread safe). + + if access to the is synchronized (thread-safe); otherwise, . + + + Gets an object that can be used to synchronize access to the . + An object that can be used to synchronize access to the . + + + Gets a value indicating whether the object has a fixed size. + + if the object has a fixed size; otherwise, . + + + Gets a value indicating whether the is read-only. + + if the is read-only; otherwise, . + + + Gets or sets the element with the specified key. + The key of the element to be accessed. + Value stored under the specified key. + + + Gets an containing the keys of the . + An containing the keys of the object that implements . + + + Gets an containing the values in the . + An containing the values in the object that implements . + + + Gets the value comparer used to determine whether values are equal. + The value comparer used to determine whether values are equal. + + + Gets the values in the immutable sorted dictionary. + The values in the dictionary. + + + Represents a sorted dictionary that mutates with little or no memory allocations and that can produce or build on immutable sorted dictionary instances very efficiently. + + NuGet package: System.Collections.Immutable (about immutable collections and how to install) + + + + + Adds an element that has the specified key and value to the immutable sorted dictionary. + The key of the element to add. + The value of the element to add. + + + Adds the specified item to the immutable sorted dictionary. + The object to add to the dictionary. + + + Adds a sequence of values to the immutable sorted dictionary. + The items to add to the dictionary. + + + Removes all items from the immutable sorted dictionary. + + + Determines whether the immutable sorted dictionary contains a specific value. + The object to locate in the dictionary. + + if is found in the dictionary; otherwise, . + + + Determines whether the immutable sorted dictionary contains an element with the specified key. + The key to locate in the dictionary. + + if the dictionary contains an element with the key; otherwise, . + + + Determines whether the immutable sorted dictionary contains an element with the specified value. + The value to locate in the dictionary. The value can be for reference types. + + if the immutable sorted dictionary contains an element with the specified value; otherwise, . + + + Returns an enumerator that iterates through the immutable sorted dictionary. + An enumerator that can be used to iterate through the dictionary. + + + Gets the value for a given key if a matching key exists in the dictionary; otherwise the default value. + The key to search for. + The value for the key, or default(TValue) if no matching key was found. + + + Gets the value for a given key if a matching key exists in the dictionary; otherwise the default value. + The key to search for. + The default value to return if no matching key is found in the dictionary. + The value for the key, or if no matching key was found. + + + Removes the element with the specified key from the immutable sorted dictionary. + The key of the element to remove. + + if the element is successfully removed; otherwise, . This method also returns if was not found in the original dictionary. + + + Removes the first occurrence of a specific object from the immutable sorted dictionary. + The object to remove from the dictionary. + + if was successfully removed from the dictionary; otherwise, . This method also returns if is not found in the dictionary. + + + Removes any entries with keys that match those found in the specified sequence from the immutable sorted dictionary. + The keys for entries to remove from the dictionary. + + + See . + The one-dimensional array that is the destination of the elements copied from the dictionary. The array must have zero-based indexing. + The zero-based index in at which copying begins. + + + See . + An enumerator that can be used to iterate through the collection. + + + Copies the elements of the dictionary to an array, starting at a particular array index. + + NuGet package: System.Collections.Immutable (about immutable collections and how to install) + The one-dimensional array that is the destination of the elements copied from the dictionary. The array must have zero-based indexing. + The zero-based index in at which copying begins. + + + Adds an element with the provided key and value to the dictionary object. + The key of the element to add. + The value of the element to add. + + + Determines whether the dictionary object contains an element with the specified key. + The key to locate. + + if the dictionary contains an element with the key; otherwise, . + + + Returns an object for the dictionary. + An object for the dictionary. + + + Removes the element with the specified key from the dictionary. + The key of the element to remove. + + + Returns an enumerator that iterates through a collection. + An enumerator object that can be used to iterate through the collection. + + + Creates an immutable sorted dictionary based on the contents of this instance. + An immutable sorted dictionary. + + + Determines whether this dictionary contains a specified key. + The key to search for. + The matching key located in the dictionary if found, or equalkey if no match is found. + + if a match for is found; otherwise, . + + + Gets the value associated with the specified key. + The key whose value will be retrieved. + When this method returns, contains the value associated with the specified key, if the key is found; otherwise, contains the default value for the type of the parameter. This parameter is passed uninitialized. + + if the object that implements the dictionary contains an element with the specified key; otherwise, . + + + Returns a read-only reference to the value associated with the provided . + Key of the entry to be looked up. + The is not present. + A read-only reference to the value associated with the provided . + + + Gets the number of elements in this immutable sorted dictionary. + The number of elements in this dictionary. + + + Gets or sets the value for a specified key in the immutable sorted dictionary. + The key to retrieve the value for. + The value associated with the given key. + + + Gets or sets the key comparer. + The key comparer. + + + Gets a strongly typed, read-only collection of elements. + A strongly typed, read-only collection of elements. + + + Gets a value that indicates whether this instance is read-only. + Always . + + + Returns a collection containing all keys stored in the dictionary. See . + A collection containing all keys stored in the dictionary. + + + Returns a collection containing all values stored in the dictionary. See . + A collection containing all values stored in the dictionary. + + + Gets a value that indicates whether access to the is synchronized (thread safe). + + if access to the is synchronized (thread safe); otherwise, . + + + Gets an object that can be used to synchronize access to the . + An object that can be used to synchronize access to the . + + + Gets a value that indicates whether the object has a fixed size. + + if the object has a fixed size; otherwise, . + + + Gets a value that indicates whether the is read-only. + + if the is read-only; otherwise, . + + + Gets or sets the element with the specified key. + The key. + The value associated with the specified key. + + + Gets an containing the keys of the . + An containing the keys of the object that implements . + + + Gets an containing the values in the . + An containing the values in the object that implements . + + + Gets or sets the value comparer. + The value comparer. + + + Gets a collection that contains the values of the immutable sorted dictionary. + A collection that contains the values of the object that implements the dictionary. + + + Enumerates the contents of a binary tree. + + NuGet package: System.Collections.Immutable (about immutable collections and how to install) + + + + + Releases the resources used by the current instance of the class. + + + Advances the enumerator to the next element of the immutable sorted dictionary. + + if the enumerator was successfully advanced to the next element; if the enumerator has passed the end of the sorted dictionary. + + + Sets the enumerator to its initial position, which is before the first element in the immutable sorted dictionary. + + + Gets the element at the current position of the enumerator. + The element at the current position of the enumerator. + + + The current element. + + + Provides a set of initialization methods for instances of the class. + + NuGet package: System.Collections.Immutable (about immutable collections and how to install) + + + Creates an empty immutable sorted set. + The type of items to be stored in the immutable set. + An empty immutable sorted set. + + + Creates a new immutable sorted set that contains the specified item. + The item to prepopulate the set with. + The type of items in the immutable set. + A new immutable set that contains the specified item. + + + Creates a new immutable sorted set that contains the specified array of items. + An array that contains the items to prepopulate the set with. + The type of items in the immutable set. + A new immutable set that contains the specified items. + + + Creates an empty immutable sorted set that uses the specified comparer. + The implementation to use when comparing items in the set. + The type of items in the immutable set. + An empty immutable set. + + + Creates a new immutable sorted set that contains the specified item and uses the specified comparer. + The implementation to use when comparing items in the set. + The item to prepopulate the set with. + The type of items stored in the immutable set. + A new immutable set that contains the specified item. + + + Creates a new immutable sorted set that contains the specified array of items and uses the specified comparer. + The implementation to use when comparing items in the set. + An array that contains the items to prepopulate the set with. + The type of items in the immutable set. + A new immutable set that contains the specified items. + + + Returns a collection that can be used to build an immutable sorted set. + The type of items stored by the collection. + The immutable collection builder. + + + Returns a collection that can be used to build an immutable sorted set. + The comparer used to compare items in the set for equality. + The type of items stored by the collection. + The immutable collection. + + + Creates a new immutable collection that contains the specified items. + The comparer to use to compare elements in this set. + The items to add to the set before it's immutable. + The type of items stored by the collection. + The new immutable set that contains the specified items. + + + Creates a new immutable collection that contains the specified items. + The items to add to the set with before it's immutable. + The type of items stored by the collection. + The new immutable set that contains the specified items. + + + Enumerates a sequence and produces an immutable sorted set of its contents. + The sequence to enumerate. + The type of the elements in the sequence. + An immutable sorted set that contains the items in the specified sequence. + + + Enumerates a sequence, produces an immutable sorted set of its contents, and uses the specified comparer. + The sequence to enumerate. + The comparer to use for initializing and adding members to the sorted set. + The type of the elements in the sequence. + An immutable sorted set that contains the items in the specified sequence. + + + Creates an immutable sorted set from the current contents of the builder's set. + The builder to create the immutable sorted set from. + The type of the elements in the immutable sorted set. + An immutable sorted set that contains the current contents in the builder's set. + + + Represents an immutable sorted set implementation. + +NuGet package: System.Collections.Immutable (about immutable collections and how to install) + The type of elements in the set. + + + Gets an empty immutable sorted set. + + + Adds the specified value to this immutable sorted set. + The value to add. + A new set with the element added, or this set if the element is already in this set. + + + Removes all elements from the immutable sorted set. + An empty set with the elements removed. + + + Determines whether this immutable sorted set contains the specified value. + The value to check for. + + if the set contains the specified value; otherwise, . + + + Removes a specified set of items from this immutable sorted set. + The items to remove from this set. + A new set with the items removed; or the original set if none of the items were in the set. + + + Returns an enumerator that iterates through the immutable sorted set. + An enumerator that can be used to iterate through the set. + + + Gets the position within this immutable sorted set that the specified value appears in. + The value whose position is being sought. + The index of the specified in the sorted set, if is found. If is not found and is less than one or more elements in this set, this method returns a negative number that is the bitwise complement of the index of the first element that is larger than value. If is not found and is greater than any of the elements in the set, this method returns a negative number that is the bitwise complement of the index of the last element plus 1. + + + Creates an immutable sorted set that contains elements that exist both in this set and in the specified set. + The set to intersect with this one. + A new immutable sorted set that contains any elements that exist in both sets. + + + Determines whether the current immutable sorted set is a proper (strict) subset of the specified collection. + The collection to compare to the current set. + + if the current set is a proper subset of ; otherwise, . + + + Determines whether the current immutable sorted set is a proper superset of a specified collection. + The collection to compare to the current set. + + if the current set is a proper superset of ; otherwise, . + + + Determines whether the current immutable sorted set is a subset of a specified collection. + The collection to compare to the current set. + + if the current set is a subset of ; otherwise, . + + + Determines whether the current immutable sorted set is a superset of a specified collection. + The collection to compare to the current set. + + if the current set is a superset of ; otherwise, . + + + Gets a read-only reference of the element of the set at the given . + The 0-based index of the element in the set to return. + A read-only reference of the element at the given position. + + + Determines whether the current immutable sorted set and a specified collection share common elements. + The collection to compare to the current set. + + if the current set and share at least one common element; otherwise, . + + + Removes the specified value from this immutable sorted set. + The element to remove. + A new immutable sorted set with the element removed, or this set if the element was not found in the set. + + + Returns an that iterates over this immutable sorted set in reverse order. + An enumerator that iterates over the immutable sorted set in reverse order. + + + Determines whether the current immutable sorted set and the specified collection contain the same elements. + The collection to compare to the current set. + + if the sets are equal; otherwise, . + + + Creates an immutable sorted set that contains elements that exist either in this set or in a given sequence, but not both. + The other sequence of items. + The new immutable sorted set. + + + Adds the specified value to the collection. + The value to add. + + + Removes all the items from the collection. + + + Copies the elements of the collection to an array, starting at a particular array index. + The one-dimensional array that is the destination of the elements copied from collection. The array must have zero-based indexing. + The zero-based index in at which copying begins. + + + Removes the first occurrence of a specific object from the collection. + The object to remove from the collection. + + if was successfully removed from the collection; otherwise, . + + + Returns an enumerator that iterates through the collection. + An enumerator that can be used to iterate through the collection. + + + Inserts an item in the set at the specified index. + The zero-based index at which should be inserted. + The object to insert into the set. + + + Removes the item at the specified index. + The zero-based index of the item to remove. + + + Adds an element to the current set and returns a value to indicate if the element was successfully added. + The element to add to the set. + + if the element is added to the set; if the element is already in the set. + + + Removes all elements in the specified collection from the current set. + The collection of items to remove from the set. + + + Modifies the current set so that it contains only elements that are also in a specified collection. + The collection to compare to the current set. + + + Modifies the current set so that it contains only elements that are present either in the current set or in the specified collection, but not both. + The collection to compare to the current set. + + + Modifies the current set so that it contains all elements that are present in either the current set or the specified collection. + The collection to compare to the current set. + + + Copies the elements of the set to an array, starting at a particular array index. + The one-dimensional array that is the destination of the elements copied from the set. The array must have zero-based indexing. + The zero-based index in at which copying begins. + + + Returns an enumerator that iterates through a collection. + An enumerator object that can be used to iterate through the collection. + + + Adds an item to the set. + The object to add to the set. + The set is read-only or has a fixed size. + The position into which the new element was inserted, or -1 to indicate that the item was not inserted into the collection. + + + Removes all items from the set. + Thrown in all cases. + + + Determines whether the set contains a specific value. + The object to locate in the set. + + if the object is found in the set; otherwise, . + + + Determines the index of a specific item in the set. + The object to locate in the set. + The index of if found in the list; otherwise, -1. + + + Inserts an item into the set at the specified index. + The zero-based index at which should be inserted. + The object to insert into the set. + The set is read-only or has a fixed size. + + + Removes the first occurrence of a specific object from the set. + The object to remove from the set. + The set is read-only or has a fixed size. + + + Removes the item at the specified index of the set. + The zero-based index of the item to remove. + The set is read-only or has a fixed size. + + + Adds the specified element to this immutable set. + The element to add. + A new set with the element added, or this set if the element is already in the set. + + + Retrieves an empty immutable set that has the same sorting and ordering semantics as this instance. + An empty set that has the same sorting and ordering semantics as this instance. + + + Removes the elements in the specified collection from the current immutable set. + The items to remove from this set. + The new set with the items removed; or the original set if none of the items were in the set. + + + Creates an immutable set that contains elements that exist in both this set and the specified set. + The collection to compare to the current set. + A new immutable set that contains any elements that exist in both sets. + + + Removes the specified element from this immutable set. + The element to remove. + A new set with the specified element removed, or the current set if the element cannot be found in the set. + + + Creates an immutable set that contains only elements that are present either in the current set or in the specified collection, but not both. + The collection to compare to the current set. + A new set that contains the elements that are present only in the current set or in the specified collection, but not both. + + + Creates a new immutable set that contains all elements that are present in either the current set or in the specified collection. + The collection to add elements from. + A new immutable set with the items added; or the original set if all the items were already in the set. + + + Creates a collection that has the same contents as this immutable sorted set that can be efficiently manipulated by using standard mutable interfaces. + The sorted set builder. + + + Searches the set for a given value and returns the equal value it finds, if any. + The value to search for. + The value from the set that the search found, or the original value if the search yielded no match. + A value indicating whether the search was successful. + + + Adds a given set of items to this immutable sorted set. + The items to add. + The new set with the items added; or the original set if all the items were already in the set. + + + Returns the immutable sorted set that has the specified key comparer. + The comparer to check for. + The immutable sorted set that has the specified key comparer. + + + Gets the number of elements in the immutable sorted set. + The number of elements in the immutable sorted set. + + + Gets a value that indicates whether this immutable sorted set is empty. + + if this set is empty; otherwise, . + + + Gets the element of the immutable sorted set at the given index. + The index of the element to retrieve from the sorted set. + The element at the given index. + + + Gets the comparer used to sort keys in the immutable sorted set. + The comparer used to sort keys. + + + Gets the maximum value in the immutable sorted set, as defined by the comparer. + The maximum value in the set. + + + Gets the minimum value in the immutable sorted set, as defined by the comparer. + The minimum value in the set. + + + Returns true, since immutable collections are always read-only. See the interface. + A boolean value indicating whether the collection is read-only. + + + See the interface. + The zero-based index of the item to access. + The element stored at the specified index. + + + Returns true, since immutable collections are always thread-safe. See the interface. + A boolean value indicating whether the collection is thread-safe. + + + See . + Object used for synchronizing access to the collection. + + + Gets a value that indicates whether the has a fixed size. + + if the has a fixed size; otherwise, . + + + Gets a value that indicates whether the is read-only. + + if the is read-only; otherwise, . + + + Gets or sets the at the specified index. + The index. + + The . + + + Represents a sorted set that enables changes with little or no memory allocations, and efficiently manipulates or builds immutable sorted sets. + + NuGet package: System.Collections.Immutable (about immutable collections and how to install) + + + + Adds an element to the current set and returns a value to indicate whether the element was successfully added. + The element to add to the set. + + if the element is added to the set; if the element is already in the set. + + + Removes all elements from this set. + + + Determines whether the set contains the specified object. + The object to locate in the set. + + if is found in the set; otherwise, . + + + Removes the specified set of items from the current set. + The collection of items to remove from the set. + + + Returns an enumerator that iterates through the set. + A enumerator that can be used to iterate through the set. + + + Modifies the current set so that it contains only elements that are also in a specified collection. + The collection to compare to the current set. + + + Determines whether the current set is a proper (strict) subset of a specified collection. + The collection to compare to the current set. + + if the current set is a proper subset of ; otherwise, . + + + Determines whether the current set is a proper (strict) superset of a specified collection. + The collection to compare to the current set. + + if the current set is a proper superset of ; otherwise, . + + + Determines whether the current set is a subset of a specified collection. + The collection is compare to the current set. + + if the current set is a subset of ; otherwise, . + + + Determines whether the current set is a superset of a specified collection. + The collection to compare to the current set. + + if the current set is a superset of ; otherwise, . + + + Gets a read-only reference to the element of the set at the given . + The 0-based index of the element in the set to return. + A read-only reference to the element at the given position. + + + Determines whether the current set overlaps with the specified collection. + The collection to compare to the current set. + + if the current set and share at least one common element; otherwise, . + + + Removes the first occurrence of the specified object from the set. + The object to remove from the set. + + if was removed from the set; if was not found in the set. + + + Returns an enumerator that iterates over the immutable sorted set in reverse order. + An enumerator that iterates over the set in reverse order. + + + Determines whether the current set and the specified collection contain the same elements. + The collection to compare to the current set. + + if the current set is equal to ; otherwise, . + + + Modifies the current set so that it contains only elements that are present either in the current set or in the specified collection, but not both. + The collection to compare to the current set. + + + Adds an element to the current set and returns a value to indicate whether the element was successfully added. + The element to add to the set. + + + Copies the elements of the collection to an array, starting at a particular array index. + The one-dimensional array that is the destination of the elements copied from collection. The array must have zero-based indexing. + The zero-based index in at which copying begins. + + + Returns an enumerator that iterates through the collection. + A enumerator that can be used to iterate through the collection. + + + Copies the elements of the set to an array, starting at a particular array index. + The one-dimensional array that is the destination of the elements copied from the set. The array must have zero-based indexing. + The zero-based index in at which copying begins. + + + Returns an enumerator that iterates through the collection. + A enumerator that can be used to iterate through the collection. + + + Creates an immutable sorted set based on the contents of this instance. + An immutable set. + + + Searches the set for a given value and returns the equal value it finds, if any. + The value for which to search. + The value from the set that the search found, or the original value if the search yielded no match. + A value indicating whether the search was successful. + + + Modifies the current set so that it contains all elements that are present in both the current set and in the specified collection. + The collection to compare to the current state. + + + Gets the number of elements in the immutable sorted set. + The number of elements in this set. + + + Gets the element of the set at the given index. + The 0-based index of the element in the set to return. + The element at the given position. + + + Gets or sets the object that is used to determine equality for the values in the immutable sorted set. + The comparer that is used to determine equality for the values in the set. + + + Gets the maximum value in the immutable sorted set, as defined by the comparer. + The maximum value in the set. + + + Gets the minimum value in the immutable sorted set, as defined by the comparer. + The minimum value in the set. + + + Gets a value that indicates whether this instance is read-only. + Always . + + + Gets a value that indicates whether access to the is synchronized (thread-safe). + + if access to the is synchronized (thread-safe); otherwise, . + + + Gets an object that can be used to synchronize access to the . + An object that can be used to synchronize access to the . + + + Enumerates the contents of a binary tree. + + NuGet package: System.Collections.Immutable (about immutable collections and how to install) + + + + Releases the resources used by the current instance of the class. + + NuGet package: System.Collections.Immutable (about immutable collections and how to install) + + + Advances the enumerator to the next element of the immutable sorted set. + + NuGet package: System.Collections.Immutable (about immutable collections and how to install) + + if the enumerator was successfully advanced to the next element; if the enumerator has passed the end of the sorted set. + + + Sets the enumerator to its initial position, which is before the first element in the immutable sorted set. + + NuGet package: System.Collections.Immutable (about immutable collections and how to install) + + + Gets the element at the current position of the enumerator. + + NuGet package: System.Collections.Immutable (about immutable collections and how to install) + The element at the current position of the enumerator. + + + The current element. + + + Provides a set of initialization methods for instances of the class. + + NuGet package: System.Collections.Immutable (about immutable collections and how to install) + + + Creates an empty immutable stack. + The type of items to be stored in the immutable stack. + An empty immutable stack. + + + Creates a new immutable stack that contains the specified item. + The item to prepopulate the stack with. + The type of items in the immutable stack. + A new immutable collection that contains the specified item. + + + Creates a new immutable stack that contains the specified array of items. + An array that contains the items to prepopulate the stack with. + The type of items in the immutable stack. + A new immutable stack that contains the specified items. + + + Creates a new immutable stack that contains the specified items. + The items to add to the stack before it's immutable. + The type of items in the stack. + An immutable stack that contains the specified items. + + + Removes the specified item from an immutable stack. + The stack to modify. + The item to remove from the stack. + The type of items contained in the stack. + The stack is empty. + A stack; never . + + + Represents an immutable stack. + + NuGet package: System.Collections.Immutable (about immutable collections and how to install) + The type of element on the stack. + + + Removes all objects from the immutable stack. + An empty immutable stack. + + + Returns an enumerator that iterates through the immutable stack. + An enumerator that can be used to iterate through the stack. + + + Returns the object at the top of the stack without removing it. + The stack is empty. + The object at the top of the stack. + + + Gets a read-only reference to the element on the top of the stack. + Thrown when the stack is empty. + A read-only reference to the element on the top of the stack. + + + Removes the element at the top of the immutable stack and returns the stack after the removal. + The stack is empty. + A stack; never . + + + Removes the specified element from the immutable stack and returns the stack after the removal. + The value to remove from the stack. + A stack; never . + + + Inserts an object at the top of the immutable stack and returns the new stack. + The object to push onto the stack. + The new stack. + + + Returns an enumerator that iterates through the collection. + An enumerator that can be used to iterate through the collection. + + + Returns an enumerator that iterates through a collection. + An object that can be used to iterate through the collection. + + + Removes all elements from the immutable stack. + The empty immutable stack. + + + Removes the element at the top of the immutable stack and returns the new stack. + The stack is empty. + The new stack; never . + + + Inserts an element at the top of the immutable stack and returns the new stack. + The element to push onto the stack. + The new stack. + + + Gets an empty immutable stack. + An empty immutable stack. + + + Gets a value that indicates whether this instance of the immutable stack is empty. + + if this instance is empty; otherwise, . + + + Enumerates the contents of an immutable stack without allocating any memory. + + NuGet package: System.Collections.Immutable (about immutable collections and how to install) + + + + Advances the enumerator to the next element of the immutable stack. + + if the enumerator was successfully advanced to the next element; if the enumerator has passed the end of the stack. + + + Gets the element at the current position of the enumerator. + The element at the current position of the enumerator. + + + LINQ extension method overrides that offer greater efficiency for than the standard LINQ methods + + NuGet package: System.Collections.Immutable (about immutable collections and how to install) + + + Applies a function to a sequence of elements in a cumulative way. + The collection to apply the function to. + A function to be invoked on each element, in a cumulative way. + The type of element contained by the collection. + The final value after the cumulative function has been applied to all elements. + + + Applies a function to a sequence of elements in a cumulative way. + The collection to apply the function to. + The initial accumulator value. + A function to be invoked on each element, in a cumulative way. + The type of the accumulated value. + The type of element contained by the collection. + The final accumulator value. + + + Applies a function to a sequence of elements in a cumulative way. + The collection to apply the function to. + The initial accumulator value. + A function to be invoked on each element, in a cumulative way. + A function to transform the final accumulator value into the result type. + The type of the accumulated value. + The type of result returned by the result selector. + The type of element contained by the collection. + The final accumulator value. + + + Gets a value indicating whether all elements in this array match a given condition. + The array to check for matches. + The predicate. + The type of element contained by the collection. + + if every element of the source sequence passes the test in the specified predicate; otherwise, . + + + Returns a value indicating whether this collection contains any elements. + The builder to check for matches. + The type of elements in the array. + + if the array builder contains any elements; otherwise, . + + + Gets a value indicating whether the array contains any elements. + The array to check for elements. + The type of element contained by the collection. + + if the array contains an elements; otherwise, . + + + Gets a value indicating whether the array contains any elements that match a specified condition. + The array to check for elements. + The delegate that defines the condition to match to an element. + The type of element contained by the collection. + + if an element matches the specified condition; otherwise, . + + + Returns the element at a specified index in the array. + The array to find an element in. + The index for the element to retrieve. + The type of element contained by the collection. + The item at the specified index. + + + Returns the element at a specified index in a sequence or a default value if the index is out of range. + The array to find an element in. + The index for the element to retrieve. + The type of element contained by the collection. + The item at the specified index, or the default value if the index is not found. + + + Returns the first element in the collection. + The builder to retrieve an item from. + The type of items in the array. + If the array is empty. + The first item in the list. + + + Returns the first element in an array. + The array to get an item from. + The type of element contained by the collection. + If the array is empty. + The first item in the array. + + + Returns the first element in a sequence that satisfies a specified condition. + The array to get an item from. + The delegate that defines the conditions of the element to search for. + The type of element contained by the collection. + If the array is empty. + The first item in the list if it meets the condition specified by . + + + Returns the first element in the collection, or the default value if the collection is empty. + The builder to retrieve an element from. + The type of item in the builder. + The first item in the list, if found; otherwise the default value for the item type. + + + Returns the first element of a sequence, or a default value if the sequence contains no elements. + The array to retrieve items from. + The type of element contained by the collection. + The first item in the list, if found; otherwise the default value for the item type. + + + Returns the first element of the sequence that satisfies a condition or a default value if no such element is found. + The array to retrieve elements from. + The delegate that defines the conditions of the element to search for. + The type of element contained by the collection. + The first item in the list, if found; otherwise the default value for the item type. + + + Returns the last element in the collection. + The builder to retrieve elements from. + The type of item in the builder. + Thrown if the collection is empty. + The last element in the builder. + + + Returns the last element of the array. + The array to retrieve items from. + The type of element contained by the array. + Thrown if the collection is empty. + The last element in the array. + + + Returns the last element of a sequence that satisfies a specified condition. + The array to retrieve elements from. + The delegate that defines the conditions of the element to retrieve. + The type of element contained by the collection. + Thrown if the collection is empty. + The last element of the array that satisfies the condition. + + + Returns the last element in the collection, or the default value if the collection is empty. + The builder to retrieve an element from. + The type of item in the builder. + The last element of a sequence, or a default value if the sequence contains no elements. + + + Returns the last element of a sequence, or a default value if the sequence contains no elements. + The array to retrieve items from. + The type of element contained by the collection. + The last element of a sequence, or a default value if the sequence contains no elements. + + + Returns the last element of a sequence that satisfies a condition or a default value if no such element is found. + The array to retrieve an element from. + The delegate that defines the conditions of the element to search for. + The type of element contained by the collection. + The last element of a sequence, or a default value if the sequence contains no elements. + + + Projects each element of a sequence into a new form. + The immutable array to select items from. + A transform function to apply to each element. + The type of element contained by the collection. + The type of the result element. + An whose elements are the result of invoking the transform function on each element of source. + + + Projects each element of a sequence to an , flattens the resulting sequences into one sequence, and invokes a result selector function on each element therein. + The immutable array. + A transform function to apply to each element of the input sequence. + A transform function to apply to each element of the intermediate sequence. + The type of the elements of . + The type of the intermediate elements collected by . + The type of the elements of the resulting sequence. + An whose elements are the result of invoking the one-to-many transform function on each element of and then mapping each of those sequence elements and their corresponding source element to a result element. + + + Determines whether two sequences are equal according to an equality comparer. + The array to use for comparison. + The items to use for comparison. + The comparer to use to check for equality. + The type of element in the compared array. + The type of element contained by the collection. + + to indicate the sequences are equal; otherwise, . + + + Determines whether two sequences are equal according to an equality comparer. + The array to use for comparison. + The items to use for comparison. + The comparer to use to check for equality. + The type of element in the compared array. + The type of element contained by the collection. + + to indicate the sequences are equal; otherwise, . + + + Determines whether two sequences are equal according to an equality comparer. + The array to use for comparison. + The items to use for comparison. + The comparer to use to check for equality. + The type of element in the compared array. + The type of element contained by the collection. + + to indicate the sequences are equal; otherwise, . + + + Returns the only element of a sequence, and throws an exception if there is not exactly one element in the sequence. + The array to retrieve the element from. + The type of element contained by the collection. + The element in the sequence. + + + Returns the only element of a sequence that satisfies a specified condition, and throws an exception if more than one such element exists. + The immutable array to return a single element from. + The function to test whether an element should be returned. + The type of element contained by the collection. + Returns . + + + Returns the only element of the array, or a default value if the sequence is empty; this method throws an exception if there is more than one element in the sequence. + The array. + The type of element contained by the collection. + + contains more than one element. + The element in the array, or the default value if the array is empty. + + + Returns the only element of a sequence that satisfies a specified condition or a default value if no such element exists; this method throws an exception if more than one element satisfies the condition. + The array to get the element from. + The condition the element must satisfy. + The type of element contained by the collection. + More than one element satisfies the condition in . + The element if it satisfies the specified condition; otherwise the default element. + + + Copies the contents of this array to a mutable array. + The immutable array to copy into a mutable one. + The type of element contained by the collection. + The newly instantiated array. + + + Creates a dictionary based on the contents of this array. + The array to create a dictionary from. + The key selector. + The type of the key. + The type of element contained by the collection. + The newly initialized dictionary. + + + Creates a dictionary based on the contents of this array. + The array to create a dictionary from. + The key selector. + The comparer to initialize the dictionary with. + The type of the key. + The type of element contained by the collection. + The newly initialized dictionary. + + + Creates a dictionary based on the contents of this array. + The array to create a dictionary from. + The key selector. + The element selector. + The type of the key. + The type of the element. + The type of element contained by the collection. + The newly initialized dictionary. + + + Creates a dictionary based on the contents of this array. + The array to create a dictionary from. + The key selector. + The element selector. + The comparer to initialize the dictionary with. + The type of the key. + The type of the element. + The type of element contained by the collection. + The newly initialized dictionary. + + + Filters a sequence of values based on a predicate. + The array to filter. + The condition to use for filtering the array content. + The type of element contained by the collection. + Returns that contains elements that meet the condition. + + + \ No newline at end of file diff --git a/src/MessagePack.UnityClient/Assets/Packages/System.Collections.Immutable.6.0.0/lib/net461/System.Collections.Immutable.xml.meta b/src/MessagePack.UnityClient/Assets/Packages/System.Collections.Immutable.6.0.0/lib/net461/System.Collections.Immutable.xml.meta new file mode 100644 index 000000000..3e71c3848 --- /dev/null +++ b/src/MessagePack.UnityClient/Assets/Packages/System.Collections.Immutable.6.0.0/lib/net461/System.Collections.Immutable.xml.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: fbbd87e7ec046fc478a5f4602116dc8f +TextScriptImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/src/MessagePack.UnityClient/Assets/Packages/System.Collections.Immutable.6.0.0/useSharedDesignerContext.txt b/src/MessagePack.UnityClient/Assets/Packages/System.Collections.Immutable.6.0.0/useSharedDesignerContext.txt new file mode 100644 index 000000000..e69de29bb diff --git a/src/MessagePack.UnityClient/Assets/Packages/System.Collections.Immutable.6.0.0/useSharedDesignerContext.txt.meta b/src/MessagePack.UnityClient/Assets/Packages/System.Collections.Immutable.6.0.0/useSharedDesignerContext.txt.meta new file mode 100644 index 000000000..b6f29b239 --- /dev/null +++ b/src/MessagePack.UnityClient/Assets/Packages/System.Collections.Immutable.6.0.0/useSharedDesignerContext.txt.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 73c1ead61257b0e4994a94b013bd5965 +TextScriptImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/src/MessagePack.UnityClient/Assets/Packages/System.Runtime.CompilerServices.Unsafe.6.0.0.meta b/src/MessagePack.UnityClient/Assets/Packages/System.Runtime.CompilerServices.Unsafe.6.0.0.meta new file mode 100644 index 000000000..2dba03f82 --- /dev/null +++ b/src/MessagePack.UnityClient/Assets/Packages/System.Runtime.CompilerServices.Unsafe.6.0.0.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 943403a2fd514c7489071566278211c6 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/src/MessagePack.UnityClient/Assets/Packages/System.Runtime.CompilerServices.Unsafe.6.0.0/.signature.p7s b/src/MessagePack.UnityClient/Assets/Packages/System.Runtime.CompilerServices.Unsafe.6.0.0/.signature.p7s new file mode 100644 index 0000000000000000000000000000000000000000..2a015f966a69f29ae7ad9536a621550dd06064cf GIT binary patch literal 18703 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 c+-y&+VR+#gf0N|~9UfH*JD5Jjm{4}uUR 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 literal 0 HcmV?d00001 diff --git a/src/MessagePack.UnityClient/Assets/Packages/System.Runtime.CompilerServices.Unsafe.6.0.0/Icon.png.meta b/src/MessagePack.UnityClient/Assets/Packages/System.Runtime.CompilerServices.Unsafe.6.0.0/Icon.png.meta new file mode 100644 index 000000000..9d8841019 --- /dev/null +++ b/src/MessagePack.UnityClient/Assets/Packages/System.Runtime.CompilerServices.Unsafe.6.0.0/Icon.png.meta @@ -0,0 +1,123 @@ +fileFormatVersion: 2 +guid: 205c2dd3af89e214f808d564e4852311 +TextureImporter: + internalIDToNameTable: [] + externalObjects: {} + serializedVersion: 12 + mipmaps: + mipMapMode: 0 + enableMipMap: 1 + sRGBTexture: 1 + linearTexture: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapsPreserveCoverage: 0 + alphaTestReferenceValue: 0.5 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 0 + streamingMipmaps: 0 + streamingMipmapsPriority: 0 + vTOnly: 0 + ignoreMasterTextureLimit: 0 + grayScaleToAlpha: 0 + generateCubemap: 6 + cubemapConvolution: 0 + seamlessCubemap: 0 + textureFormat: 1 + maxTextureSize: 2048 + textureSettings: + serializedVersion: 2 + filterMode: 1 + aniso: 1 + mipBias: 0 + wrapU: 0 + wrapV: 0 + wrapW: 0 + nPOTScale: 1 + lightmap: 0 + compressionQuality: 50 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spritePixelsToUnits: 100 + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spriteGenerateFallbackPhysicsShape: 1 + alphaUsage: 1 + alphaIsTransparency: 0 + spriteTessellationDetail: -1 + textureType: 0 + textureShape: 1 + singleChannelComponent: 0 + flipbookRows: 1 + flipbookColumns: 1 + maxTextureSizeSet: 0 + compressionQualitySet: 0 + textureFormatSet: 0 + ignorePngGamma: 0 + applyGammaDecoding: 0 + cookieLightType: 0 + platformSettings: + - serializedVersion: 3 + buildTarget: DefaultTexturePlatform + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + - serializedVersion: 3 + buildTarget: Standalone + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + - serializedVersion: 3 + buildTarget: Server + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + spriteSheet: + serializedVersion: 2 + sprites: [] + outline: [] + physicsShape: [] + bones: [] + spriteID: + internalID: 0 + vertices: [] + indices: + edges: [] + weights: [] + secondaryTextures: [] + nameFileIdTable: {} + spritePackingTag: + pSDRemoveMatte: 0 + pSDShowRemoveMatteOption: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/src/MessagePack.UnityClient/Assets/Packages/System.Runtime.CompilerServices.Unsafe.6.0.0/LICENSE.TXT b/src/MessagePack.UnityClient/Assets/Packages/System.Runtime.CompilerServices.Unsafe.6.0.0/LICENSE.TXT new file mode 100644 index 000000000..984713a49 --- /dev/null +++ b/src/MessagePack.UnityClient/Assets/Packages/System.Runtime.CompilerServices.Unsafe.6.0.0/LICENSE.TXT @@ -0,0 +1,23 @@ +The MIT License (MIT) + +Copyright (c) .NET Foundation and Contributors + +All rights reserved. + +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. diff --git a/src/MessagePack.UnityClient/Assets/Packages/System.Runtime.CompilerServices.Unsafe.6.0.0/LICENSE.TXT.meta b/src/MessagePack.UnityClient/Assets/Packages/System.Runtime.CompilerServices.Unsafe.6.0.0/LICENSE.TXT.meta new file mode 100644 index 000000000..46ddf545a --- /dev/null +++ b/src/MessagePack.UnityClient/Assets/Packages/System.Runtime.CompilerServices.Unsafe.6.0.0/LICENSE.TXT.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 086c54c94c5ac8945aff4943bf0b8f87 +TextScriptImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/src/MessagePack.UnityClient/Assets/Packages/System.Runtime.CompilerServices.Unsafe.6.0.0/System.Runtime.CompilerServices.Unsafe.nuspec b/src/MessagePack.UnityClient/Assets/Packages/System.Runtime.CompilerServices.Unsafe.6.0.0/System.Runtime.CompilerServices.Unsafe.nuspec new file mode 100644 index 000000000..d6590a917 --- /dev/null +++ b/src/MessagePack.UnityClient/Assets/Packages/System.Runtime.CompilerServices.Unsafe.6.0.0/System.Runtime.CompilerServices.Unsafe.nuspec @@ -0,0 +1,29 @@ + + + + System.Runtime.CompilerServices.Unsafe + 6.0.0 + Microsoft + MIT + https://licenses.nuget.org/MIT + Icon.png + https://dot.net/ + Provides the System.Runtime.CompilerServices.Unsafe class, which provides generic, low-level functionality for manipulating pointers. + +Commonly Used Types: +System.Runtime.CompilerServices.Unsafe + https://go.microsoft.com/fwlink/?LinkID=799421 + © Microsoft Corporation. All rights reserved. + true + + + + + + + + + + + + \ No newline at end of file diff --git a/src/MessagePack.UnityClient/Assets/Packages/System.Runtime.CompilerServices.Unsafe.6.0.0/System.Runtime.CompilerServices.Unsafe.nuspec.meta b/src/MessagePack.UnityClient/Assets/Packages/System.Runtime.CompilerServices.Unsafe.6.0.0/System.Runtime.CompilerServices.Unsafe.nuspec.meta new file mode 100644 index 000000000..6faecbac3 --- /dev/null +++ b/src/MessagePack.UnityClient/Assets/Packages/System.Runtime.CompilerServices.Unsafe.6.0.0/System.Runtime.CompilerServices.Unsafe.nuspec.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 55129857346dcd14ba7ea157f60341f7 +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/src/MessagePack.UnityClient/Assets/Packages/System.Runtime.CompilerServices.Unsafe.6.0.0/THIRD-PARTY-NOTICES.TXT b/src/MessagePack.UnityClient/Assets/Packages/System.Runtime.CompilerServices.Unsafe.6.0.0/THIRD-PARTY-NOTICES.TXT new file mode 100644 index 000000000..89c59b21d --- /dev/null +++ b/src/MessagePack.UnityClient/Assets/Packages/System.Runtime.CompilerServices.Unsafe.6.0.0/THIRD-PARTY-NOTICES.TXT @@ -0,0 +1,939 @@ +.NET Runtime uses third-party libraries or other resources that may be +distributed under licenses different than the .NET Runtime software. + +In the event that we accidentally failed to list a required notice, please +bring it to our attention. Post an issue or email us: + + dotnet@microsoft.com + +The attached notices are provided for information only. + +License notice for ASP.NET +------------------------------- + +Copyright (c) .NET Foundation. All rights reserved. +Licensed under the Apache License, Version 2.0. + +Available at +https://github.com/dotnet/aspnetcore/blob/main/LICENSE.txt + +License notice for Slicing-by-8 +------------------------------- + +http://sourceforge.net/projects/slicing-by-8/ + +Copyright (c) 2004-2006 Intel Corporation - All Rights Reserved + + +This software program is licensed subject to the BSD License, available at +http://www.opensource.org/licenses/bsd-license.html. + + +License notice for Unicode data +------------------------------- + +https://www.unicode.org/license.html + +Copyright © 1991-2020 Unicode, Inc. All rights reserved. +Distributed under the Terms of Use in https://www.unicode.org/copyright.html. + +Permission is hereby granted, free of charge, to any person obtaining +a copy of the Unicode data files and any associated documentation +(the "Data Files") or Unicode software and any associated documentation +(the "Software") to deal in the Data Files or Software +without restriction, including without limitation the rights to use, +copy, modify, merge, publish, distribute, and/or sell copies of +the Data Files or Software, and to permit persons to whom the Data Files +or Software are furnished to do so, provided that either +(a) this copyright and permission notice appear with all copies +of the Data Files or Software, or +(b) this copyright and permission notice appear in associated +Documentation. + +THE DATA FILES AND SOFTWARE ARE 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 OF THIRD PARTY RIGHTS. +IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS INCLUDED IN THIS +NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL +DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, +DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER +TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +PERFORMANCE OF THE DATA FILES OR SOFTWARE. + +Except as contained in this notice, the name of a copyright holder +shall not be used in advertising or otherwise to promote the sale, +use or other dealings in these Data Files or Software without prior +written authorization of the copyright holder. + +License notice for Zlib +----------------------- + +https://github.com/madler/zlib +http://zlib.net/zlib_license.html + +/* zlib.h -- interface of the 'zlib' general purpose compression library + version 1.2.11, January 15th, 2017 + + Copyright (C) 1995-2017 Jean-loup Gailly and Mark Adler + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + + Jean-loup Gailly Mark Adler + jloup@gzip.org madler@alumni.caltech.edu + +*/ + +License notice for Mono +------------------------------- + +http://www.mono-project.com/docs/about-mono/ + +Copyright (c) .NET Foundation Contributors + +MIT License + +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. + +License notice for International Organization for Standardization +----------------------------------------------------------------- + +Portions (C) International Organization for Standardization 1986: + Permission to copy in any form is granted for use with + conforming SGML systems and applications as defined in + ISO 8879, provided this notice is included in all copies. + +License notice for Intel +------------------------ + +"Copyright (c) 2004-2006 Intel Corporation - All Rights Reserved + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +License notice for Xamarin and Novell +------------------------------------- + +Copyright (c) 2015 Xamarin, Inc (http://www.xamarin.com) + +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. + +Copyright (c) 2011 Novell, Inc (http://www.novell.com) + +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. + +Third party notice for W3C +-------------------------- + +"W3C SOFTWARE AND DOCUMENT NOTICE AND LICENSE +Status: This license takes effect 13 May, 2015. +This work is being provided by the copyright holders under the following license. +License +By obtaining and/or copying this work, you (the licensee) agree that you have read, understood, and will comply with the following terms and conditions. +Permission to copy, modify, and distribute this work, with or without modification, for any purpose and without fee or royalty is hereby granted, provided that you include the following on ALL copies of the work or portions thereof, including modifications: +The full text of this NOTICE in a location viewable to users of the redistributed or derivative work. +Any pre-existing intellectual property disclaimers, notices, or terms and conditions. If none exist, the W3C Software and Document Short Notice should be included. +Notice of any changes or modifications, through a copyright statement on the new code or document such as "This software or document includes material copied from or derived from [title and URI of the W3C document]. Copyright © [YEAR] W3C® (MIT, ERCIM, Keio, Beihang)." +Disclaimers +THIS WORK IS PROVIDED "AS IS," AND COPYRIGHT HOLDERS MAKE NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF THE SOFTWARE OR DOCUMENT WILL NOT INFRINGE ANY THIRD PARTY PATENTS, COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS. +COPYRIGHT HOLDERS WILL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF ANY USE OF THE SOFTWARE OR DOCUMENT. +The name and trademarks of copyright holders may NOT be used in advertising or publicity pertaining to the work without specific, written prior permission. Title to copyright in this work will at all times remain with copyright holders." + +License notice for Bit Twiddling Hacks +-------------------------------------- + +Bit Twiddling Hacks + +By Sean Eron Anderson +seander@cs.stanford.edu + +Individually, the code snippets here are in the public domain (unless otherwise +noted) — feel free to use them however you please. The aggregate collection and +descriptions are © 1997-2005 Sean Eron Anderson. The code and descriptions are +distributed in the hope that they will be useful, but WITHOUT ANY WARRANTY and +without even the implied warranty of merchantability or fitness for a particular +purpose. + +License notice for Brotli +-------------------------------------- + +Copyright (c) 2009, 2010, 2013-2016 by the Brotli Authors. + +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. + +compress_fragment.c: +Copyright (c) 2011, Google Inc. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above +copyright notice, this list of conditions and the following disclaimer +in the documentation and/or other materials provided with the +distribution. + * Neither the name of Google Inc. nor the names of its +contributors may be used to endorse or promote products derived from +this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +""AS IS"" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +decode_fuzzer.c: +Copyright (c) 2015 The Chromium Authors. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above +copyright notice, this list of conditions and the following disclaimer +in the documentation and/or other materials provided with the +distribution. + * Neither the name of Google Inc. nor the names of its +contributors may be used to endorse or promote products derived from +this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +""AS IS"" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." + +License notice for Json.NET +------------------------------- + +https://github.com/JamesNK/Newtonsoft.Json/blob/master/LICENSE.md + +The MIT License (MIT) + +Copyright (c) 2007 James Newton-King + +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. + +License notice for vectorized base64 encoding / decoding +-------------------------------------------------------- + +Copyright (c) 2005-2007, Nick Galbreath +Copyright (c) 2013-2017, Alfred Klomp +Copyright (c) 2015-2017, Wojciech Mula +Copyright (c) 2016-2017, Matthieu Darbois +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + +- Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + +- Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS +IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A +PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED +TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +License notice for RFC 3492 +--------------------------- + +The punycode implementation is based on the sample code in RFC 3492 + +Copyright (C) The Internet Society (2003). All Rights Reserved. + +This document and translations of it may be copied and furnished to +others, and derivative works that comment on or otherwise explain it +or assist in its implementation may be prepared, copied, published +and distributed, in whole or in part, without restriction of any +kind, provided that the above copyright notice and this paragraph are +included on all such copies and derivative works. However, this +document itself may not be modified in any way, such as by removing +the copyright notice or references to the Internet Society or other +Internet organizations, except as needed for the purpose of +developing Internet standards in which case the procedures for +copyrights defined in the Internet Standards process must be +followed, or as required to translate it into languages other than +English. + +The limited permissions granted above are perpetual and will not be +revoked by the Internet Society or its successors or assigns. + +This document and the information contained herein is provided on an +"AS IS" basis and THE INTERNET SOCIETY AND THE INTERNET ENGINEERING +TASK FORCE DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING +BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION +HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF +MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + +License notice for Algorithm from Internet Draft document "UUIDs and GUIDs" +--------------------------------------------------------------------------- + +Copyright (c) 1990- 1993, 1996 Open Software Foundation, Inc. +Copyright (c) 1989 by Hewlett-Packard Company, Palo Alto, Ca. & +Digital Equipment Corporation, Maynard, Mass. +To anyone who acknowledges that this file is provided "AS IS" +without any express or implied warranty: permission to use, copy, +modify, and distribute this file for any purpose is hereby +granted without fee, provided that the above copyright notices and +this notice appears in all source code copies, and that none of +the names of Open Software Foundation, Inc., Hewlett-Packard +Company, or Digital Equipment Corporation be used in advertising +or publicity pertaining to distribution of the software without +specific, written prior permission. Neither Open Software +Foundation, Inc., Hewlett-Packard Company, Microsoft, nor Digital Equipment +Corporation makes any representations about the suitability of +this software for any purpose. + +Copyright(C) The Internet Society 1997. All Rights Reserved. + +This document and translations of it may be copied and furnished to others, +and derivative works that comment on or otherwise explain it or assist in +its implementation may be prepared, copied, published and distributed, in +whole or in part, without restriction of any kind, provided that the above +copyright notice and this paragraph are included on all such copies and +derivative works.However, this document itself may not be modified in any +way, such as by removing the copyright notice or references to the Internet +Society or other Internet organizations, except as needed for the purpose of +developing Internet standards in which case the procedures for copyrights +defined in the Internet Standards process must be followed, or as required +to translate it into languages other than English. + +The limited permissions granted above are perpetual and will not be revoked +by the Internet Society or its successors or assigns. + +This document and the information contained herein is provided on an "AS IS" +basis and THE INTERNET SOCIETY AND THE INTERNET ENGINEERING TASK FORCE +DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO +ANY WARRANTY THAT THE USE OF THE INFORMATION HEREIN WILL NOT INFRINGE ANY +RIGHTS OR ANY IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A +PARTICULAR PURPOSE. + +License notice for Algorithm from RFC 4122 - +A Universally Unique IDentifier (UUID) URN Namespace +---------------------------------------------------- + +Copyright (c) 1990- 1993, 1996 Open Software Foundation, Inc. +Copyright (c) 1989 by Hewlett-Packard Company, Palo Alto, Ca. & +Digital Equipment Corporation, Maynard, Mass. +Copyright (c) 1998 Microsoft. +To anyone who acknowledges that this file is provided "AS IS" +without any express or implied warranty: permission to use, copy, +modify, and distribute this file for any purpose is hereby +granted without fee, provided that the above copyright notices and +this notice appears in all source code copies, and that none of +the names of Open Software Foundation, Inc., Hewlett-Packard +Company, Microsoft, or Digital Equipment Corporation be used in +advertising or publicity pertaining to distribution of the software +without specific, written prior permission. Neither Open Software +Foundation, Inc., Hewlett-Packard Company, Microsoft, nor Digital +Equipment Corporation makes any representations about the +suitability of this software for any purpose." + +License notice for The LLVM Compiler Infrastructure +--------------------------------------------------- + +Developed by: + + LLVM Team + + University of Illinois at Urbana-Champaign + + http://llvm.org + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal with +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: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimers. + + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimers in the + documentation and/or other materials provided with the distribution. + + * Neither the names of the LLVM Team, University of Illinois at + Urbana-Champaign, nor the names of its contributors may be used to + endorse or promote products derived from this Software without specific + prior written permission. + +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 +CONTRIBUTORS 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 WITH THE +SOFTWARE. + +License notice for Bob Jenkins +------------------------------ + +By Bob Jenkins, 1996. bob_jenkins@burtleburtle.net. You may use this +code any way you wish, private, educational, or commercial. It's free. + +License notice for Greg Parker +------------------------------ + +Greg Parker gparker@cs.stanford.edu December 2000 +This code is in the public domain and may be copied or modified without +permission. + +License notice for libunwind based code +---------------------------------------- + +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. + +License notice for Printing Floating-Point Numbers (Dragon4) +------------------------------------------------------------ + +/****************************************************************************** + Copyright (c) 2014 Ryan Juckett + http://www.ryanjuckett.com/ + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + + 3. This notice may not be removed or altered from any source + distribution. +******************************************************************************/ + +License notice for Printing Floating-point Numbers (Grisu3) +----------------------------------------------------------- + +Copyright 2012 the V8 project authors. All rights reserved. +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the following + disclaimer in the documentation and/or other materials provided + with the distribution. + * Neither the name of Google Inc. nor the names of its + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +License notice for xxHash +------------------------- + +xxHash Library +Copyright (c) 2012-2014, Yann Collet +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright notice, this + list of conditions and the following disclaimer in the documentation and/or + other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +License notice for Berkeley SoftFloat Release 3e +------------------------------------------------ + +https://github.com/ucb-bar/berkeley-softfloat-3 +https://github.com/ucb-bar/berkeley-softfloat-3/blob/master/COPYING.txt + +License for Berkeley SoftFloat Release 3e + +John R. Hauser +2018 January 20 + +The following applies to the whole of SoftFloat Release 3e as well as to +each source file individually. + +Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018 The Regents of the +University of California. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions, and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions, and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + 3. Neither the name of the University nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY +EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE +DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +License notice for xoshiro RNGs +-------------------------------- + +Written in 2018 by David Blackman and Sebastiano Vigna (vigna@acm.org) + +To the extent possible under law, the author has dedicated all copyright +and related and neighboring rights to this software to the public domain +worldwide. This software is distributed without any warranty. + +See . + +License for fastmod (https://github.com/lemire/fastmod) and ibm-fpgen (https://github.com/nigeltao/parse-number-fxx-test-data) +-------------------------------------- + + Copyright 2018 Daniel Lemire + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +License notice for The C++ REST SDK +----------------------------------- + +C++ REST SDK + +The MIT License (MIT) + +Copyright (c) Microsoft Corporation + +All rights reserved. + +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. + +License notice for MessagePack-CSharp +------------------------------------- + +MessagePack for C# + +MIT License + +Copyright (c) 2017 Yoshifumi Kawai + +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. + +License notice for lz4net +------------------------------------- + +lz4net + +Copyright (c) 2013-2017, Milosz Krajewski + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. + +Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +License notice for Nerdbank.Streams +----------------------------------- + +The MIT License (MIT) + +Copyright (c) Andrew Arnott + +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. + +License notice for RapidJSON +---------------------------- + +Tencent is pleased to support the open source community by making RapidJSON available. + +Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved. + +Licensed under the MIT License (the "License"); you may not use this file except +in compliance with the License. You may obtain a copy of the License at + +http://opensource.org/licenses/MIT + +Unless required by applicable law or agreed to in writing, software distributed +under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR +CONDITIONS OF ANY KIND, either express or implied. See the License for the +specific language governing permissions and limitations under the License. + +License notice for DirectX Math Library +--------------------------------------- + +https://github.com/microsoft/DirectXMath/blob/master/LICENSE + + The MIT License (MIT) + +Copyright (c) 2011-2020 Microsoft Corp + +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. + +License notice for ldap4net +--------------------------- + +The MIT License (MIT) + +Copyright (c) 2018 Alexander Chermyanin + +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. + +License notice for vectorized sorting code +------------------------------------------ + +MIT License + +Copyright (c) 2020 Dan Shechter + +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. + +License notice for musl +----------------------- + +musl as a whole is licensed under the following standard MIT license: + +Copyright © 2005-2020 Rich Felker, et al. + +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. + + +License notice for "Faster Unsigned Division by Constants" +------------------------------ + +Reference implementations of computing and using the "magic number" approach to dividing +by constants, including codegen instructions. The unsigned division incorporates the +"round down" optimization per ridiculous_fish. + +This is free and unencumbered software. Any copyright is dedicated to the Public Domain. + + +License notice for mimalloc +----------------------------------- + +MIT License + +Copyright (c) 2019 Microsoft Corporation, Daan Leijen + +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. diff --git a/src/MessagePack.UnityClient/Assets/Packages/System.Runtime.CompilerServices.Unsafe.6.0.0/THIRD-PARTY-NOTICES.TXT.meta b/src/MessagePack.UnityClient/Assets/Packages/System.Runtime.CompilerServices.Unsafe.6.0.0/THIRD-PARTY-NOTICES.TXT.meta new file mode 100644 index 000000000..210dd5d34 --- /dev/null +++ b/src/MessagePack.UnityClient/Assets/Packages/System.Runtime.CompilerServices.Unsafe.6.0.0/THIRD-PARTY-NOTICES.TXT.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 81c0b488fcb971c4185000065204cac2 +TextScriptImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/src/MessagePack.UnityClient/Assets/Packages/System.Runtime.CompilerServices.Unsafe.6.0.0/buildTransitive.meta b/src/MessagePack.UnityClient/Assets/Packages/System.Runtime.CompilerServices.Unsafe.6.0.0/buildTransitive.meta new file mode 100644 index 000000000..999c649fa --- /dev/null +++ b/src/MessagePack.UnityClient/Assets/Packages/System.Runtime.CompilerServices.Unsafe.6.0.0/buildTransitive.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: a5e637219365a4b4995ef33ee5522cdb +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/src/MessagePack.UnityClient/Assets/Packages/System.Runtime.CompilerServices.Unsafe.6.0.0/buildTransitive/netcoreapp2.0.meta b/src/MessagePack.UnityClient/Assets/Packages/System.Runtime.CompilerServices.Unsafe.6.0.0/buildTransitive/netcoreapp2.0.meta new file mode 100644 index 000000000..1ada9ef40 --- /dev/null +++ b/src/MessagePack.UnityClient/Assets/Packages/System.Runtime.CompilerServices.Unsafe.6.0.0/buildTransitive/netcoreapp2.0.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 3de0c472abd895549973413e9fb03fd4 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/src/MessagePack.UnityClient/Assets/Packages/System.Runtime.CompilerServices.Unsafe.6.0.0/buildTransitive/netcoreapp2.0/System.Runtime.CompilerServices.Unsafe.targets b/src/MessagePack.UnityClient/Assets/Packages/System.Runtime.CompilerServices.Unsafe.6.0.0/buildTransitive/netcoreapp2.0/System.Runtime.CompilerServices.Unsafe.targets new file mode 100644 index 000000000..98eb1d3b6 --- /dev/null +++ b/src/MessagePack.UnityClient/Assets/Packages/System.Runtime.CompilerServices.Unsafe.6.0.0/buildTransitive/netcoreapp2.0/System.Runtime.CompilerServices.Unsafe.targets @@ -0,0 +1,6 @@ + + + + + diff --git a/src/MessagePack.UnityClient/Assets/Packages/System.Runtime.CompilerServices.Unsafe.6.0.0/buildTransitive/netcoreapp2.0/System.Runtime.CompilerServices.Unsafe.targets.meta b/src/MessagePack.UnityClient/Assets/Packages/System.Runtime.CompilerServices.Unsafe.6.0.0/buildTransitive/netcoreapp2.0/System.Runtime.CompilerServices.Unsafe.targets.meta new file mode 100644 index 000000000..3e3acb28e --- /dev/null +++ b/src/MessagePack.UnityClient/Assets/Packages/System.Runtime.CompilerServices.Unsafe.6.0.0/buildTransitive/netcoreapp2.0/System.Runtime.CompilerServices.Unsafe.targets.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: d35deef4e8de4f044989c1bb296bccb1 +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/src/MessagePack.UnityClient/Assets/Packages/System.Runtime.CompilerServices.Unsafe.6.0.0/buildTransitive/netcoreapp3.1.meta b/src/MessagePack.UnityClient/Assets/Packages/System.Runtime.CompilerServices.Unsafe.6.0.0/buildTransitive/netcoreapp3.1.meta new file mode 100644 index 000000000..315bee467 --- /dev/null +++ b/src/MessagePack.UnityClient/Assets/Packages/System.Runtime.CompilerServices.Unsafe.6.0.0/buildTransitive/netcoreapp3.1.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 11c134d66e4edc546b99201b3983f8dc +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/src/MessagePack.UnityClient/Assets/Packages/System.Runtime.CompilerServices.Unsafe.6.0.0/buildTransitive/netcoreapp3.1/_._ b/src/MessagePack.UnityClient/Assets/Packages/System.Runtime.CompilerServices.Unsafe.6.0.0/buildTransitive/netcoreapp3.1/_._ new file mode 100644 index 000000000..e69de29bb diff --git a/src/MessagePack.UnityClient/Assets/Packages/System.Runtime.CompilerServices.Unsafe.6.0.0/buildTransitive/netcoreapp3.1/_._.meta b/src/MessagePack.UnityClient/Assets/Packages/System.Runtime.CompilerServices.Unsafe.6.0.0/buildTransitive/netcoreapp3.1/_._.meta new file mode 100644 index 000000000..b08d29ff3 --- /dev/null +++ b/src/MessagePack.UnityClient/Assets/Packages/System.Runtime.CompilerServices.Unsafe.6.0.0/buildTransitive/netcoreapp3.1/_._.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: ff911ff4af9ebb649992334c3457924a +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/src/MessagePack.UnityClient/Assets/Packages/System.Runtime.CompilerServices.Unsafe.6.0.0/lib.meta b/src/MessagePack.UnityClient/Assets/Packages/System.Runtime.CompilerServices.Unsafe.6.0.0/lib.meta new file mode 100644 index 000000000..4bbf2dbd4 --- /dev/null +++ b/src/MessagePack.UnityClient/Assets/Packages/System.Runtime.CompilerServices.Unsafe.6.0.0/lib.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 5f9480aad99cb974bbb318c121e7399f +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/src/MessagePack.UnityClient/Assets/Packages/System.Runtime.CompilerServices.Unsafe.6.0.0/lib/net461.meta b/src/MessagePack.UnityClient/Assets/Packages/System.Runtime.CompilerServices.Unsafe.6.0.0/lib/net461.meta new file mode 100644 index 000000000..93b5fd44c --- /dev/null +++ b/src/MessagePack.UnityClient/Assets/Packages/System.Runtime.CompilerServices.Unsafe.6.0.0/lib/net461.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: dffc15fc29d3559409bda41b7ccf99de +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/src/MessagePack.UnityClient/Assets/Packages/System.Runtime.CompilerServices.Unsafe.6.0.0/lib/net461/System.Runtime.CompilerServices.Unsafe.dll b/src/MessagePack.UnityClient/Assets/Packages/System.Runtime.CompilerServices.Unsafe.6.0.0/lib/net461/System.Runtime.CompilerServices.Unsafe.dll new file mode 100644 index 0000000000000000000000000000000000000000..c5ba4e4047a15b3adc61340c781307d9c6e89413 GIT binary patch literal 18024 zcmeHu2V7Ij()gYv^bRUTN+>EKgcA?}6{QMDm5zcKLVyS)m;@;*Lgb=Yu_1~|v7lb; zT~S2E-g_4-7Pz9qwd*(MB!S$k-gm$M_ulV)zwiAIp4pw*-PzgQ*`1v^F=%utq9TN7 z@P7M-&>l#M$DM?K4GN%G(`=t6+M#mRd=D0Q);uDWE2L)%_$dNb2A$2~@%SQoB8M)> z;?cQ0x_3x8J%gXbVQ6TmT1i=l`XCgDQPINyAxqX8N(ea) zA$3SfA#W@#`dbOTOLVfjGT?r44H+U%jtKB8y#PQNIaZKc{-Hzf41rL<1|lh&J7g5$ zHG)^}aR=!c0!}&~DiX31G81z^@`Xh9xFh5#%gfR&#Js{o$VNd5$h!|hLv;{RA*tOU zlrEXtZpx2y2@e^!2i)nG@^zo-qMNH%UdnN3(w{PA!Quw8Hi_^Dp~hubVA*Thp2Dx z1HLlapV|}TAMusaF;YEAzEF`0>q7$sMx#SfRkR_-DBB7Yvd{1Ft~Ji>o&!?%Nm(T` zb9rq*WeR3~NrF`YunNXkql`2HFHQ9rRi>0d(suAkVS^iR^|`y<-_ z9H&ww<+9@p^c9n=2eHE?574MTpee{`UF+VfnQTm~iA*nhk$Ne&´RVDkZYh5I? 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 literal 0 HcmV?d00001 diff --git a/src/MessagePack.UnityClient/Assets/Packages/System.Runtime.CompilerServices.Unsafe.6.0.0/lib/net461/System.Runtime.CompilerServices.Unsafe.dll.meta b/src/MessagePack.UnityClient/Assets/Packages/System.Runtime.CompilerServices.Unsafe.6.0.0/lib/net461/System.Runtime.CompilerServices.Unsafe.dll.meta new file mode 100644 index 000000000..83c1d46fa --- /dev/null +++ b/src/MessagePack.UnityClient/Assets/Packages/System.Runtime.CompilerServices.Unsafe.6.0.0/lib/net461/System.Runtime.CompilerServices.Unsafe.dll.meta @@ -0,0 +1,23 @@ +fileFormatVersion: 2 +guid: 2d19ddaf8caa62e4b9504848333097ff +labels: +- NuGetForUnity +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + defineConstraints: [] + isPreloaded: 0 + isOverridable: 0 + isExplicitlyReferenced: 0 + validateReferences: 1 + platformData: + - first: + Any: + second: + enabled: 1 + settings: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/src/MessagePack.UnityClient/Assets/Packages/System.Runtime.CompilerServices.Unsafe.6.0.0/lib/net461/System.Runtime.CompilerServices.Unsafe.xml b/src/MessagePack.UnityClient/Assets/Packages/System.Runtime.CompilerServices.Unsafe.6.0.0/lib/net461/System.Runtime.CompilerServices.Unsafe.xml new file mode 100644 index 000000000..9d794922c --- /dev/null +++ b/src/MessagePack.UnityClient/Assets/Packages/System.Runtime.CompilerServices.Unsafe.6.0.0/lib/net461/System.Runtime.CompilerServices.Unsafe.xml @@ -0,0 +1,291 @@ + + + + System.Runtime.CompilerServices.Unsafe + + + + Contains generic, low-level functionality for manipulating pointers. + + + Adds an element offset to the given reference. + The reference to add the offset to. + The offset to add. + The type of reference. + A new reference that reflects the addition of offset to pointer. + + + Adds an element offset to the given reference. + The reference to add the offset to. + The offset to add. + The type of reference. + A new reference that reflects the addition of offset to pointer. + + + Adds an element offset to the given reference. + The reference to add the offset to. + The offset to add. + The type of reference. + A new reference that reflects the addition of offset to pointer. + + + Adds an element offset to the given void pointer. + The void pointer to add the offset to. + The offset to add. + The type of void pointer. + A new void pointer that reflects the addition of offset to the specified pointer. + + + Adds a byte offset to the given reference. + The reference to add the offset to. + The offset to add. + The type of reference. + A new reference that reflects the addition of byte offset to pointer. + + + Adds a byte offset to the given reference. + The reference to add the offset to. + The offset to add. + The type of reference. + A new reference that reflects the addition of byte offset to pointer. + + + Determines whether the specified references point to the same location. + The first reference to compare. + The second reference to compare. + The type of reference. + + if and point to the same location; otherwise, . + + + Casts the given object to the specified type. + The object to cast. + The type which the object will be cast to. + The original object, casted to the given type. + + + Reinterprets the given reference as a reference to a value of type . + The reference to reinterpret. + The type of reference to reinterpret. + The desired type of the reference. + A reference to a value of type . + + + Returns a pointer to the given by-ref parameter. + The object whose pointer is obtained. + The type of object. + A pointer to the given value. + + + Reinterprets the given read-only reference as a reference. + The read-only reference to reinterpret. + The type of reference. + A reference to a value of type . + + + Reinterprets the given location as a reference to a value of type . + The location of the value to reference. + The type of the interpreted location. + A reference to a value of type . + + + Determines the byte offset from origin to target from the given references. + The reference to origin. + The reference to target. + The type of reference. + Byte offset from origin to target i.e. - . + + + Copies a value of type to the given location. + The location to copy to. + A pointer to the value to copy. + The type of value to copy. + + + Copies a value of type to the given location. + The location to copy to. + A reference to the value to copy. + The type of value to copy. + + + Copies bytes from the source address to the destination address. + The destination address to copy to. + The source address to copy from. + The number of bytes to copy. + + + Copies bytes from the source address to the destination address. + The destination address to copy to. + The source address to copy from. + The number of bytes to copy. + + + Copies bytes from the source address to the destination address without assuming architecture dependent alignment of the addresses. + The destination address to copy to. + The source address to copy from. + The number of bytes to copy. + + + Copies bytes from the source address to the destination address without assuming architecture dependent alignment of the addresses. + The destination address to copy to. + The source address to copy from. + The number of bytes to copy. + + + Initializes a block of memory at the given location with a given initial value. + The address of the start of the memory block to initialize. + The value to initialize the block to. + The number of bytes to initialize. + + + Initializes a block of memory at the given location with a given initial value. + The address of the start of the memory block to initialize. + The value to initialize the block to. + The number of bytes to initialize. + + + Initializes a block of memory at the given location with a given initial value without assuming architecture dependent alignment of the address. + The address of the start of the memory block to initialize. + The value to initialize the block to. + The number of bytes to initialize. + + + Initializes a block of memory at the given location with a given initial value without assuming architecture dependent alignment of the address. + The address of the start of the memory block to initialize. + The value to initialize the block to. + The number of bytes to initialize. + + + Returns a value that indicates whether a specified reference is greater than another specified reference. + The first value to compare. + The second value to compare. + The type of the reference. + + if is greater than ; otherwise, . + + + Returns a value that indicates whether a specified reference is less than another specified reference. + The first value to compare. + The second value to compare. + The type of the reference. + + if is less than ; otherwise, . + + + Determines if a given reference to a value of type is a null reference. + The reference to check. + The type of the reference. + + if is a null reference; otherwise, . + + + Returns a reference to a value of type that is a null reference. + The type of the reference. + A reference to a value of type that is a null reference. + + + Reads a value of type from the given location. + The location to read from. + The type to read. + An object of type read from the given location. + + + Reads a value of type from the given location without assuming architecture dependent alignment of the addresses. + The location to read from. + The type to read. + An object of type read from the given location. + + + Reads a value of type from the given location without assuming architecture dependent alignment of the addresses. + The location to read from. + The type to read. + An object of type read from the given location. + + + Returns the size of an object of the given type parameter. + The type of object whose size is retrieved. + The size of an object of type . + + + Bypasses definite assignment rules for a given value. + The uninitialized object. + The type of the uninitialized object. + + + Subtracts an element offset from the given reference. + The reference to subtract the offset from. + The offset to subtract. + The type of reference. + A new reference that reflects the subtraction of offset from pointer. + + + Subtracts an element offset from the given reference. + The reference to subtract the offset from. + The offset to subtract. + The type of reference. + A new reference that reflects the subtraction of offset from pointer. + + + Subtracts an element offset from the given reference. + The reference to subtract the offset from. + The offset to subtract. + The type of reference. + A new reference that reflects the subraction of offset from pointer. + + + Subtracts an element offset from the given void pointer. + The void pointer to subtract the offset from. + The offset to subtract. + The type of the void pointer. + A new void pointer that reflects the subtraction of offset from the specified pointer. + + + Subtracts a byte offset from the given reference. + The reference to subtract the offset from. + The offset to subtract. + The type of reference. + A new reference that reflects the subtraction of byte offset from pointer. + + + Subtracts a byte offset from the given reference. + The reference to subtract the offset from. + The offset to subtract. + The type of reference. + A new reference that reflects the subraction of byte offset from pointer. + + + Returns a to a boxed value. + The value to unbox. + The type to be unboxed. + + is , and is a non-nullable value type. + + is not a boxed value type. + +-or- + + is not a boxed . + + cannot be found. + A to the boxed value . + + + Writes a value of type to the given location. + The location to write to. + The value to write. + The type of value to write. + + + Writes a value of type to the given location without assuming architecture dependent alignment of the addresses. + The location to write to. + The value to write. + The type of value to write. + + + Writes a value of type to the given location without assuming architecture dependent alignment of the addresses. + The location to write to. + The value to write. + The type of value to write. + + + \ No newline at end of file diff --git a/src/MessagePack.UnityClient/Assets/Packages/System.Runtime.CompilerServices.Unsafe.6.0.0/lib/net461/System.Runtime.CompilerServices.Unsafe.xml.meta b/src/MessagePack.UnityClient/Assets/Packages/System.Runtime.CompilerServices.Unsafe.6.0.0/lib/net461/System.Runtime.CompilerServices.Unsafe.xml.meta new file mode 100644 index 000000000..db82cb1e5 --- /dev/null +++ b/src/MessagePack.UnityClient/Assets/Packages/System.Runtime.CompilerServices.Unsafe.6.0.0/lib/net461/System.Runtime.CompilerServices.Unsafe.xml.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 0f8802d96c8a46145b65761bc0cadd54 +TextScriptImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/src/MessagePack.UnityClient/Assets/Packages/System.Runtime.CompilerServices.Unsafe.6.0.0/useSharedDesignerContext.txt b/src/MessagePack.UnityClient/Assets/Packages/System.Runtime.CompilerServices.Unsafe.6.0.0/useSharedDesignerContext.txt new file mode 100644 index 000000000..e69de29bb diff --git a/src/MessagePack.UnityClient/Assets/Packages/System.Runtime.CompilerServices.Unsafe.6.0.0/useSharedDesignerContext.txt.meta b/src/MessagePack.UnityClient/Assets/Packages/System.Runtime.CompilerServices.Unsafe.6.0.0/useSharedDesignerContext.txt.meta new file mode 100644 index 000000000..566c5685e --- /dev/null +++ b/src/MessagePack.UnityClient/Assets/Packages/System.Runtime.CompilerServices.Unsafe.6.0.0/useSharedDesignerContext.txt.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 997b487a7b4d16d4199975d621acba66 +TextScriptImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/src/MessagePack.UnityClient/Assets/RuntimeUnitTestToolkit/Editor/HierarchyTreeBuilder.cs b/src/MessagePack.UnityClient/Assets/RuntimeUnitTestToolkit/Editor/HierarchyTreeBuilder.cs deleted file mode 100644 index 9a2adc2b5..000000000 --- a/src/MessagePack.UnityClient/Assets/RuntimeUnitTestToolkit/Editor/HierarchyTreeBuilder.cs +++ /dev/null @@ -1,133 +0,0 @@ -#if UNITY_EDITOR - -using System; -using UnityEngine; - -namespace RuntimeUnitTestToolkit.Editor -{ - // functional declarative construction like flutter. - - internal interface IBuilder - { - GameObject GameObject { get; } - T GetComponent(); - } - - internal class Builder : IBuilder - where T : Component - { - public T Component1 { get; private set; } - public GameObject GameObject { get; private set; } - - public Transform Transform { get { return GameObject.transform; } } - public RectTransform RectTransform { get { return GameObject.GetComponent(); } } - - public Action SetTarget - { - set - { - value(this.GameObject); - } - } - - - public IBuilder Child - { - set - { - value.GameObject.transform.SetParent(GameObject.transform); - } - } - - public IBuilder[] Children - { - set - { - foreach (var item in value) - { - item.GameObject.transform.SetParent(GameObject.transform); - } - } - } - - public Builder(string name) - { - this.GameObject = new GameObject(name); - this.Component1 = GameObject.AddComponent(); - } - - public Builder(string name, out T referenceSelf) // out primary reference. - { - this.GameObject = new GameObject(name); - this.Component1 = GameObject.AddComponent(); - referenceSelf = this.Component1; - } - - public TComponent GetComponent() - { - return this.GameObject.GetComponent(); - } - } - - internal class Builder : Builder - where T1 : Component - where T2 : Component - { - public T2 Component2 { get; private set; } - - public Builder(string name) - : base(name) - { - this.Component2 = GameObject.AddComponent(); - } - - public Builder(string name, out T1 referenceSelf) - : base(name, out referenceSelf) - { - this.Component2 = GameObject.AddComponent(); - } - } - - internal class Builder : Builder - where T1 : Component - where T2 : Component - where T3 : Component - { - public T3 Component3 { get; private set; } - - public Builder(string name) - : base(name) - { - this.Component3 = GameObject.AddComponent(); - } - - public Builder(string name, out T1 referenceSelf) - : base(name, out referenceSelf) - { - this.Component3 = GameObject.AddComponent(); - } - } - - internal class Builder : Builder - where T1 : Component - where T2 : Component - where T3 : Component - where T4 : Component - { - public T4 Component4 { get; private set; } - - public Builder(string name) - : base(name) - { - this.Component4 = GameObject.AddComponent(); - } - - public Builder(string name, out T1 referenceSelf) - : base(name, out referenceSelf) - { - this.Component4 = GameObject.AddComponent(); - } - } -} - -#endif \ No newline at end of file diff --git a/src/MessagePack.UnityClient/Assets/RuntimeUnitTestToolkit/Editor/HierarchyTreeBuilder.cs.meta b/src/MessagePack.UnityClient/Assets/RuntimeUnitTestToolkit/Editor/HierarchyTreeBuilder.cs.meta deleted file mode 100644 index 82c8e9bb4..000000000 --- a/src/MessagePack.UnityClient/Assets/RuntimeUnitTestToolkit/Editor/HierarchyTreeBuilder.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 8760bbbab905a534eb6fb7b61b736926 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/src/MessagePack.UnityClient/Assets/RuntimeUnitTestToolkit/Editor/UnitTestBuilder.MenuItems.cs b/src/MessagePack.UnityClient/Assets/RuntimeUnitTestToolkit/Editor/UnitTestBuilder.MenuItems.cs deleted file mode 100644 index 94508b51c..000000000 --- a/src/MessagePack.UnityClient/Assets/RuntimeUnitTestToolkit/Editor/UnitTestBuilder.MenuItems.cs +++ /dev/null @@ -1,345 +0,0 @@ -#if UNITY_EDITOR -using UnityEditor; - -// Settings MenuItems. - -public static partial class UnitTestBuilder -{ - [MenuItem("Test/Settings/ScriptBackend/Mono", validate = true, priority = 1)] - static bool ValidateScriptBackendMono() - { - Menu.SetChecked("Test/Settings/ScriptBackend/Mono", LoadOrGetDefaultSettings().ScriptBackend == ScriptingImplementation.Mono2x); - return true; - } - - [MenuItem("Test/Settings/ScriptBackend/Mono", validate = false, priority = 1)] - static void ScriptBackendMono() - { - var settings = LoadOrGetDefaultSettings(); - settings.UseCurrentScriptBackend = false; - settings.ScriptBackend = ScriptingImplementation.Mono2x; - SaveSettings(settings); - } - - [MenuItem("Test/Settings/ScriptBackend/IL2CPP", validate = true, priority = 2)] - static bool ValidateScriptBackendIL2CPP() - { - Menu.SetChecked("Test/Settings/ScriptBackend/IL2CPP", LoadOrGetDefaultSettings().ScriptBackend == ScriptingImplementation.IL2CPP); - return true; - } - - [MenuItem("Test/Settings/ScriptBackend/IL2CPP", validate = false, priority = 2)] - static void ScriptBackendIL2CPP() - { - var settings = LoadOrGetDefaultSettings(); - settings.UseCurrentScriptBackend = false; - settings.ScriptBackend = ScriptingImplementation.IL2CPP; - SaveSettings(settings); - } - - [MenuItem("Test/Settings/AutoRunPlayer", validate = true, priority = 3)] - static bool ValidateAutoRun() - { - Menu.SetChecked("Test/Settings/AutoRunPlayer", LoadOrGetDefaultSettings().AutoRunPlayer); - return true; - } - - [MenuItem("Test/Settings/AutoRunPlayer", validate = false, priority = 3)] - static void AutoRun() - { - var settings = LoadOrGetDefaultSettings(); - settings.AutoRunPlayer = !settings.AutoRunPlayer; - SaveSettings(settings); - } - - [MenuItem("Test/Settings/Headless", validate = true, priority = 4)] - static bool ValidateHeadless() - { - Menu.SetChecked("Test/Settings/Headless", LoadOrGetDefaultSettings().Headless); - return true; - } - - [MenuItem("Test/Settings/Headless", validate = false, priority = 4)] - static void Headless() - { - var settings = LoadOrGetDefaultSettings(); - settings.Headless = !settings.Headless; - SaveSettings(settings); - } - - [MenuItem("Test/Settings/DisableAutoClose", validate = true, priority = 5)] - static bool ValidateDisableAutoClose() - { - Menu.SetChecked("Test/Settings/DisableAutoClose", LoadOrGetDefaultSettings().DisableAutoClose); - return true; - } - - [MenuItem("Test/Settings/DisableAutoClose", validate = false, priority = 5)] - static void DisableAutoClose() - { - var settings = LoadOrGetDefaultSettings(); - settings.DisableAutoClose = !settings.DisableAutoClose; - SaveSettings(settings); - } - - // generated - - /* - * - void Main() -{ -var sb = new StringBuilder(); - -var p = 1; -foreach (var target in Enum.GetNames(typeof(BuildTarget))) -{ - var path = $"Test/Settings/BuildTarget/{target}"; - var priority = p++; - - var template = $@" -[MenuItem(""{path}"", validate = true, priority = {priority})] -static bool ValidateBuildTarget{target}() -{{ -Menu.SetChecked(""{path}"", LoadOrGetDefaultSettings().BuildTarget == BuildTarget.{target}); -return true; -}} - -[MenuItem(""{path}"", validate = false, priority = {priority})] -static void BuildTarget{target}() -{{ -var settings = LoadOrGetDefaultSettings(); -settings.UseCurrentBuildTarget = false; -settings.BuildTarget = BuildTarget.{target}; -SaveSettings(settings); -}}"; - - sb.AppendLine(template); -} - -sb.ToString().Dump(); -} - -public enum BuildTarget -{ -StandaloneWindows, -StandaloneWindows64, -StandaloneLinux, -StandaloneLinux64, -StandaloneOSX, -WebGL, -iOS, -Android, -WSAPlayer, -PS4, -XboxOne, -Switch, -} - */ - - - [MenuItem("Test/Settings/BuildTarget/StandaloneWindows", validate = true, priority = 1)] - static bool ValidateBuildTargetStandaloneWindows() - { - Menu.SetChecked("Test/Settings/BuildTarget/StandaloneWindows", LoadOrGetDefaultSettings().BuildTarget == BuildTarget.StandaloneWindows); - return true; - } - - [MenuItem("Test/Settings/BuildTarget/StandaloneWindows", validate = false, priority = 1)] - static void BuildTargetStandaloneWindows() - { - var settings = LoadOrGetDefaultSettings(); - settings.UseCurrentBuildTarget = false; - settings.BuildTarget = BuildTarget.StandaloneWindows; - SaveSettings(settings); - } - - [MenuItem("Test/Settings/BuildTarget/StandaloneWindows64", validate = true, priority = 2)] - static bool ValidateBuildTargetStandaloneWindows64() - { - Menu.SetChecked("Test/Settings/BuildTarget/StandaloneWindows64", LoadOrGetDefaultSettings().BuildTarget == BuildTarget.StandaloneWindows64); - return true; - } - - [MenuItem("Test/Settings/BuildTarget/StandaloneWindows64", validate = false, priority = 2)] - static void BuildTargetStandaloneWindows64() - { - var settings = LoadOrGetDefaultSettings(); - settings.UseCurrentBuildTarget = false; - settings.BuildTarget = BuildTarget.StandaloneWindows64; - SaveSettings(settings); - } - -#if !UNITY_2019_2_OR_NEWER - - [MenuItem("Test/Settings/BuildTarget/StandaloneLinux", validate = true, priority = 3)] - static bool ValidateBuildTargetStandaloneLinux() - { - Menu.SetChecked("Test/Settings/BuildTarget/StandaloneLinux", LoadOrGetDefaultSettings().BuildTarget == BuildTarget.StandaloneLinux); - return true; - } - - [MenuItem("Test/Settings/BuildTarget/StandaloneLinux", validate = false, priority = 3)] - static void BuildTargetStandaloneLinux() - { - var settings = LoadOrGetDefaultSettings(); - settings.UseCurrentBuildTarget = false; - settings.BuildTarget = BuildTarget.StandaloneLinux; - SaveSettings(settings); - } - -#endif - - [MenuItem("Test/Settings/BuildTarget/StandaloneLinux64", validate = true, priority = 4)] - static bool ValidateBuildTargetStandaloneLinux64() - { - Menu.SetChecked("Test/Settings/BuildTarget/StandaloneLinux64", LoadOrGetDefaultSettings().BuildTarget == BuildTarget.StandaloneLinux64); - return true; - } - - [MenuItem("Test/Settings/BuildTarget/StandaloneLinux64", validate = false, priority = 4)] - static void BuildTargetStandaloneLinux64() - { - var settings = LoadOrGetDefaultSettings(); - settings.UseCurrentBuildTarget = false; - settings.BuildTarget = BuildTarget.StandaloneLinux64; - SaveSettings(settings); - } - - [MenuItem("Test/Settings/BuildTarget/StandaloneOSX", validate = true, priority = 5)] - static bool ValidateBuildTargetStandaloneOSX() - { - Menu.SetChecked("Test/Settings/BuildTarget/StandaloneOSX", LoadOrGetDefaultSettings().BuildTarget == BuildTarget.StandaloneOSX); - return true; - } - - [MenuItem("Test/Settings/BuildTarget/StandaloneOSX", validate = false, priority = 5)] - static void BuildTargetStandaloneOSX() - { - var settings = LoadOrGetDefaultSettings(); - settings.UseCurrentBuildTarget = false; - settings.BuildTarget = BuildTarget.StandaloneOSX; - SaveSettings(settings); - } - - [MenuItem("Test/Settings/BuildTarget/WebGL", validate = true, priority = 6)] - static bool ValidateBuildTargetWebGL() - { - Menu.SetChecked("Test/Settings/BuildTarget/WebGL", LoadOrGetDefaultSettings().BuildTarget == BuildTarget.WebGL); - return true; - } - - [MenuItem("Test/Settings/BuildTarget/WebGL", validate = false, priority = 6)] - static void BuildTargetWebGL() - { - var settings = LoadOrGetDefaultSettings(); - settings.UseCurrentBuildTarget = false; - settings.BuildTarget = BuildTarget.WebGL; - SaveSettings(settings); - } - - [MenuItem("Test/Settings/BuildTarget/iOS", validate = true, priority = 7)] - static bool ValidateBuildTargetiOS() - { - Menu.SetChecked("Test/Settings/BuildTarget/iOS", LoadOrGetDefaultSettings().BuildTarget == BuildTarget.iOS); - return true; - } - - [MenuItem("Test/Settings/BuildTarget/iOS", validate = false, priority = 7)] - static void BuildTargetiOS() - { - var settings = LoadOrGetDefaultSettings(); - settings.UseCurrentBuildTarget = false; - settings.BuildTarget = BuildTarget.iOS; - SaveSettings(settings); - } - - [MenuItem("Test/Settings/BuildTarget/Android", validate = true, priority = 8)] - static bool ValidateBuildTargetAndroid() - { - Menu.SetChecked("Test/Settings/BuildTarget/Android", LoadOrGetDefaultSettings().BuildTarget == BuildTarget.Android); - return true; - } - - [MenuItem("Test/Settings/BuildTarget/Android", validate = false, priority = 8)] - static void BuildTargetAndroid() - { - var settings = LoadOrGetDefaultSettings(); - settings.UseCurrentBuildTarget = false; - settings.BuildTarget = BuildTarget.Android; - SaveSettings(settings); - } - - [MenuItem("Test/Settings/BuildTarget/WSAPlayer", validate = true, priority = 9)] - static bool ValidateBuildTargetWSAPlayer() - { - Menu.SetChecked("Test/Settings/BuildTarget/WSAPlayer", LoadOrGetDefaultSettings().BuildTarget == BuildTarget.WSAPlayer); - return true; - } - - [MenuItem("Test/Settings/BuildTarget/WSAPlayer", validate = false, priority = 9)] - static void BuildTargetWSAPlayer() - { - var settings = LoadOrGetDefaultSettings(); - settings.UseCurrentBuildTarget = false; - settings.BuildTarget = BuildTarget.WSAPlayer; - SaveSettings(settings); - } - - [MenuItem("Test/Settings/BuildTarget/PS4", validate = true, priority = 10)] - static bool ValidateBuildTargetPS4() - { - Menu.SetChecked("Test/Settings/BuildTarget/PS4", LoadOrGetDefaultSettings().BuildTarget == BuildTarget.PS4); - return true; - } - - [MenuItem("Test/Settings/BuildTarget/PS4", validate = false, priority = 10)] - static void BuildTargetPS4() - { - var settings = LoadOrGetDefaultSettings(); - settings.UseCurrentBuildTarget = false; - settings.BuildTarget = BuildTarget.PS4; - SaveSettings(settings); - } - - [MenuItem("Test/Settings/BuildTarget/XboxOne", validate = true, priority = 11)] - static bool ValidateBuildTargetXboxOne() - { - Menu.SetChecked("Test/Settings/BuildTarget/XboxOne", LoadOrGetDefaultSettings().BuildTarget == BuildTarget.XboxOne); - return true; - } - - [MenuItem("Test/Settings/BuildTarget/XboxOne", validate = false, priority = 11)] - static void BuildTargetXboxOne() - { - var settings = LoadOrGetDefaultSettings(); - settings.UseCurrentBuildTarget = false; - settings.BuildTarget = BuildTarget.XboxOne; - SaveSettings(settings); - } - - [MenuItem("Test/Settings/BuildTarget/Switch", validate = true, priority = 12)] - static bool ValidateBuildTargetSwitch() - { - Menu.SetChecked("Test/Settings/BuildTarget/Switch", LoadOrGetDefaultSettings().BuildTarget == BuildTarget.Switch); - return true; - } - - [MenuItem("Test/Settings/BuildTarget/Switch", validate = false, priority = 12)] - static void BuildTargetSwitch() - { - var settings = LoadOrGetDefaultSettings(); - settings.UseCurrentBuildTarget = false; - settings.BuildTarget = BuildTarget.Switch; - SaveSettings(settings); - } - - - - - - - - -} - -#endif diff --git a/src/MessagePack.UnityClient/Assets/RuntimeUnitTestToolkit/Editor/UnitTestBuilder.MenuItems.cs.meta b/src/MessagePack.UnityClient/Assets/RuntimeUnitTestToolkit/Editor/UnitTestBuilder.MenuItems.cs.meta deleted file mode 100644 index 7c9917290..000000000 --- a/src/MessagePack.UnityClient/Assets/RuntimeUnitTestToolkit/Editor/UnitTestBuilder.MenuItems.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 12bdad0556e999f4aa82da29415d361f -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/src/MessagePack.UnityClient/Assets/RuntimeUnitTestToolkit/Editor/UnitTestBuilder.cs b/src/MessagePack.UnityClient/Assets/RuntimeUnitTestToolkit/Editor/UnitTestBuilder.cs deleted file mode 100644 index 9d7ddeb16..000000000 --- a/src/MessagePack.UnityClient/Assets/RuntimeUnitTestToolkit/Editor/UnitTestBuilder.cs +++ /dev/null @@ -1,552 +0,0 @@ -#if UNITY_EDITOR - -using RuntimeUnitTestToolkit; -using RuntimeUnitTestToolkit.Editor; -using System; -using UnityEditor; -using UnityEditor.Build; -using UnityEditor.Build.Reporting; -using UnityEditor.SceneManagement; -using UnityEngine; -using UnityEngine.EventSystems; -using UnityEngine.SceneManagement; -using UnityEngine.UI; - -internal class RuntimeUnitTestSettings -{ - public ScriptingImplementation ScriptBackend; - public bool UseCurrentScriptBackend; - public BuildTarget BuildTarget; - public bool UseCurrentBuildTarget; - - public bool Headless; - public bool AutoRunPlayer; - public bool DisableAutoClose; - - public RuntimeUnitTestSettings() - { - UseCurrentBuildTarget = true; - UseCurrentScriptBackend = true; - Headless = false; - AutoRunPlayer = true; - DisableAutoClose = false; - } - - public override string ToString() - { - return $"{ScriptBackend} {BuildTarget} Headless:{Headless} AutoRunPlayer:{AutoRunPlayer} DisableAutoClose:{DisableAutoClose}"; - } -} - -// no namespace(because invoke from commandline) -public static partial class UnitTestBuilder -{ - const string SettingsKeyBase = "RuntimeUnitTest.Settings."; - - [MenuItem("Test/BuildUnitTest")] - public static void BuildUnitTest() - { - var settings = new RuntimeUnitTestSettings(); // default - - string buildPath = null; - - if (Application.isBatchMode) // from commandline - { - settings.AutoRunPlayer = false; - settings.DisableAutoClose = false; - - var cmdArgs = Environment.GetCommandLineArgs(); - for (int i = 0; i < cmdArgs.Length; i++) - { - if (string.Equals(cmdArgs[i].Trim('-', '/'), "ScriptBackend", StringComparison.OrdinalIgnoreCase)) - { - settings.UseCurrentScriptBackend = false; - var str = cmdArgs[++i]; - if (str.StartsWith("mono", StringComparison.OrdinalIgnoreCase)) - { - settings.ScriptBackend = ScriptingImplementation.Mono2x; - } - else if (str.StartsWith("IL2CPP", StringComparison.OrdinalIgnoreCase)) - { - settings.ScriptBackend = ScriptingImplementation.IL2CPP; - } - else - { - settings.ScriptBackend = (ScriptingImplementation)Enum.Parse(typeof(ScriptingImplementation), str, true); - } - } - else if (string.Equals(cmdArgs[i].Trim('-', '/'), "BuildTarget", StringComparison.OrdinalIgnoreCase)) - { - settings.UseCurrentBuildTarget = false; - settings.BuildTarget = (BuildTarget)Enum.Parse(typeof(BuildTarget), cmdArgs[++i], true); - } - else if (string.Equals(cmdArgs[i].Trim('-', '/'), "Headless", StringComparison.OrdinalIgnoreCase)) - { - settings.Headless = true; - } - else if (string.Equals(cmdArgs[i].Trim('-', '/'), "buildPath", StringComparison.OrdinalIgnoreCase)) - { - buildPath = cmdArgs[++i]; - } - } - } - else - { - var key = SettingsKeyBase + Application.productName; - var settingsValue = EditorPrefs.GetString(key, null); - try - { - if (!string.IsNullOrWhiteSpace(settingsValue)) - { - settings = JsonUtility.FromJson(settingsValue); - } - } - catch - { - UnityEngine.Debug.LogError("Fail to load RuntimeUnitTest settings"); - EditorPrefs.SetString(key, null); - } - } - - if (settings.UseCurrentBuildTarget) - { - settings.BuildTarget = EditorUserBuildSettings.activeBuildTarget; - } - if (settings.UseCurrentScriptBackend) - { - settings.ScriptBackend = PlayerSettings.GetScriptingBackend(ToBuildTargetGroup(settings.BuildTarget)); - } - - if (buildPath == null) - { - buildPath = $"bin/UnitTest/{settings.BuildTarget}_{settings.ScriptBackend}/test" + GetExtensionForBuildTarget(settings.BuildTarget); - } - - var originalScene = SceneManager.GetActiveScene().path; - - BuildUnitTest(buildPath, settings.ScriptBackend, settings.BuildTarget, settings.Headless, settings.AutoRunPlayer, settings.DisableAutoClose); - - // reopen original scene - if (!string.IsNullOrWhiteSpace(originalScene)) - { - EditorSceneManager.OpenScene(originalScene, OpenSceneMode.Single); - } - else - { - EditorSceneManager.NewScene(NewSceneSetup.DefaultGameObjects); - } - } - - - [MenuItem("Test/LoadUnitTestScene")] - public static void LoadUnitTestScene() - { - var scene = EditorSceneManager.NewScene(NewSceneSetup.EmptyScene, NewSceneMode.Single); - BuildUnitTestRunnerScene(); - EditorSceneManager.MarkSceneDirty(scene); - } - - static RuntimeUnitTestSettings LoadOrGetDefaultSettings() - { - var key = SettingsKeyBase + Application.productName; - - var settingsValue = EditorPrefs.GetString(key, null); - RuntimeUnitTestSettings settings = null; - try - { - if (!string.IsNullOrWhiteSpace(settingsValue)) - { - settings = JsonUtility.FromJson(settingsValue); - } - } - catch - { - UnityEngine.Debug.LogError("Fail to load RuntimeUnitTest settings"); - EditorPrefs.SetString(key, null); - settings = null; - } - - if (settings == null) - { - // default - settings = new RuntimeUnitTestSettings - { - UseCurrentBuildTarget = true, - UseCurrentScriptBackend = true, - Headless = false, - AutoRunPlayer = true, - }; - } - - return settings; - } - - static void SaveSettings(RuntimeUnitTestSettings settings) - { - var key = SettingsKeyBase + Application.productName; - EditorPrefs.SetString(key, JsonUtility.ToJson(settings)); - } - - public static void BuildUnitTest(string buildPath, ScriptingImplementation scriptBackend, BuildTarget buildTarget, bool headless, bool autoRunPlayer, bool disableAutoClose) - { - var sceneName = "Assets/TempRuntimeUnitTestScene_" + DateTimeOffset.UtcNow.ToUnixTimeSeconds(); - if (disableAutoClose) - { - sceneName += "_DisableAutoClose"; - } - sceneName += ".unity"; - - var scene = EditorSceneManager.NewScene(NewSceneSetup.EmptyScene, NewSceneMode.Single); - - BuildUnitTestRunnerScene(); - - EditorSceneManager.MarkSceneDirty(scene); - AssetDatabase.SaveAssets(); - EditorSceneManager.SaveScene(scene, sceneName, false); - try - { - Build(sceneName, buildPath, new RuntimeUnitTestSettings { ScriptBackend = scriptBackend, BuildTarget = buildTarget, Headless = headless, AutoRunPlayer = autoRunPlayer, DisableAutoClose = disableAutoClose }); - } - finally - { - AssetDatabase.DeleteAsset(sceneName); - } - } - - public static UnitTestRunner BuildUnitTestRunnerScene() - { - const string kStandardSpritePath = "UI/Skin/UISprite.psd"; - const string kBackgroundSpritePath = "UI/Skin/Background.psd"; - var uisprite = AssetDatabase.GetBuiltinExtraResource(kStandardSpritePath); - var background = AssetDatabase.GetBuiltinExtraResource(kBackgroundSpritePath); - - ScrollRect buttonList; - VerticalLayoutGroup listLayout; - Scrollbar refListScrollbar; - ScrollRect logList; - Scrollbar refLogScrollbar; - Button clearButton; - Text logText; - - // Flutter like coded build utility - - var rootObject = new Builder("SceneRoot") - { - Children = new IBuilder[] { - new Builder("EventSystem"), - new Builder("Canvas") { - Component1 = { renderMode = RenderMode.ScreenSpaceOverlay }, - Children = new IBuilder[] { - new Builder("HorizontalSplitter") { - RectTransform = { anchorMin = new Vector2(0, 0), anchorMax = new Vector2(1, 1) }, - Component1 = { childControlWidth = true, childControlHeight = true, spacing = 10 }, - Children = new IBuilder[] { - new Builder("ButtonList", out buttonList) { - RectTransform = { pivot = new Vector2(0.5f, 0.5f) }, - Component1 = { horizontal =false, vertical = true, movementType = ScrollRect.MovementType.Clamped }, - Children = new IBuilder[] { - new Builder("ListLayoutToAttach", out listLayout) { - RectTransform = { anchorMin = new Vector2(0, 0), anchorMax = new Vector2(1, 1), pivot = new Vector2(0, 1) }, - Component1 = { childControlWidth = true, childControlHeight = true, childForceExpandWidth = true, childForceExpandHeight = false, spacing = 10, padding = new RectOffset(10,20,10,10) }, - Component2 = { horizontalFit = ContentSizeFitter.FitMode.Unconstrained, verticalFit = ContentSizeFitter.FitMode.PreferredSize }, - SetTarget = self => { buttonList.content = self.GetComponent(); }, - Child = new Builder("ClearButton", out clearButton) { - Component2 = { sprite = uisprite, type = Image.Type.Sliced }, - Component3 = { minHeight = 50 }, - SetTarget = self => { self.GetComponent