diff --git a/src/main/Yardarm.Client.UnitTests/Serialization/HeaderSerializerTests.cs b/src/main/Yardarm.Client.UnitTests/Serialization/HeaderSerializerTests.cs index d874903e..e2488574 100644 --- a/src/main/Yardarm.Client.UnitTests/Serialization/HeaderSerializerTests.cs +++ b/src/main/Yardarm.Client.UnitTests/Serialization/HeaderSerializerTests.cs @@ -15,7 +15,7 @@ public void SerializePrimitive_String_ReturnsString() { // Act - string result = HeaderSerializer.Instance.SerializePrimitive("test"); + string result = HeaderSerializer.SerializePrimitive("test"); // Assert @@ -27,7 +27,7 @@ public void SerializePrimitive_Integer_ReturnsString() { // Act - string result = HeaderSerializer.Instance.SerializePrimitive(105); + string result = HeaderSerializer.SerializePrimitive(105); // Assert @@ -39,7 +39,7 @@ public void SerializePrimitive_Long_ReturnsString() { // Act - string result = HeaderSerializer.Instance.SerializePrimitive(105L); + string result = HeaderSerializer.SerializePrimitive(105L); // Assert @@ -51,7 +51,7 @@ public void SerializePrimitive_Float_ReturnsString() { // Act - string result = HeaderSerializer.Instance.SerializePrimitive(1.05f); + string result = HeaderSerializer.SerializePrimitive(1.05f); // Assert @@ -63,7 +63,7 @@ public void SerializePrimitive_Double_ReturnsString() { // Act - string result = HeaderSerializer.Instance.SerializePrimitive(1.05); + string result = HeaderSerializer.SerializePrimitive(1.05); // Assert @@ -75,7 +75,7 @@ public void SerializePrimitive_True_ReturnsString() { // Act - string result = HeaderSerializer.Instance.SerializePrimitive(true); + string result = HeaderSerializer.SerializePrimitive(true); // Assert @@ -87,7 +87,7 @@ public void SerializePrimitive_False_ReturnsString() { // Act - string result = HeaderSerializer.Instance.SerializePrimitive(false); + string result = HeaderSerializer.SerializePrimitive(false); // Assert @@ -99,7 +99,7 @@ public void SerializePrimitive_DateTime_ReturnsString() { // Act - string result = HeaderSerializer.Instance.SerializePrimitive(new DateTime(2020, 1, 2, 3, 4, 5)); + string result = HeaderSerializer.SerializePrimitive(new DateTime(2020, 1, 2, 3, 4, 5)); // Assert @@ -111,7 +111,7 @@ public void SerializePrimitive_Date_ReturnsString() { // Act - string result = HeaderSerializer.Instance.SerializePrimitive(new DateTime(2020, 1, 2, 3, 4, 5), "date"); + string result = HeaderSerializer.SerializePrimitive(new DateTime(2020, 1, 2, 3, 4, 5), "date"); // Assert @@ -127,7 +127,7 @@ public void SerializeList_List_ReturnsCommaDelimitedString() { // Act - string result = HeaderSerializer.Instance.SerializeList( + string result = HeaderSerializer.SerializeList( new List { "abc", "def", "ghi" }); // Assert @@ -140,7 +140,7 @@ public void SerializeList_DateList_ReturnsCommaDelimitedString() { // Act - string result = HeaderSerializer.Instance.SerializeList( + string result = HeaderSerializer.SerializeList( new List { new(2020, 01, 02, 3, 4, 5), new(2021, 01, 02, 3, 4, 5) @@ -160,7 +160,7 @@ public void DeserializePrimitive_String_ReturnsString() { // Act - string result = HeaderSerializer.Instance.DeserializePrimitive( + string result = HeaderSerializer.DeserializePrimitive( ["test"]); // Assert @@ -173,7 +173,7 @@ public void DeserializePrimitive_MultipleStrings_ReturnsJoined() { // Act - string result = HeaderSerializer.Instance.DeserializePrimitive( + string result = HeaderSerializer.DeserializePrimitive( ["test", "value"]); // Assert @@ -186,7 +186,7 @@ public void DeserializePrimitive_Integer_ReturnsString() { // Act - int result = HeaderSerializer.Instance.DeserializePrimitive( + int result = HeaderSerializer.DeserializePrimitive( ["105"]); // Assert @@ -199,7 +199,7 @@ public void DeserializePrimitive_Long_ReturnsString() { // Act - long result = HeaderSerializer.Instance.DeserializePrimitive( + long result = HeaderSerializer.DeserializePrimitive( ["105"]); // Assert @@ -212,7 +212,7 @@ public void DeserializePrimitive_Float_ReturnsString() { // Act - float result = HeaderSerializer.Instance.DeserializePrimitive( + float result = HeaderSerializer.DeserializePrimitive( ["1.05"]); // Assert @@ -225,7 +225,7 @@ public void DeserializePrimitive_Double_ReturnsString() { // Act - double result = HeaderSerializer.Instance.DeserializePrimitive( + double result = HeaderSerializer.DeserializePrimitive( ["1.05"]); // Assert @@ -238,7 +238,7 @@ public void DeserializePrimitive_True_ReturnsString() { // Act - bool result = HeaderSerializer.Instance.DeserializePrimitive( + bool result = HeaderSerializer.DeserializePrimitive( ["true"]); // Assert @@ -251,7 +251,7 @@ public void DeserializePrimitive_False_ReturnsString() { // Act - bool result = HeaderSerializer.Instance.DeserializePrimitive( + bool result = HeaderSerializer.DeserializePrimitive( ["false"]); // Assert @@ -264,7 +264,7 @@ public void DeserializePrimitive_Date_ReturnsString() { // Act - var result = HeaderSerializer.Instance.DeserializePrimitive( + var result = HeaderSerializer.DeserializePrimitive( ["2020-01-02"], "date"); // Assert @@ -277,7 +277,7 @@ public void DeserializePrimitive_DateWithUnexpectedTime_FormatException() { // Act/Assert - var action = () => HeaderSerializer.Instance.DeserializePrimitive( + var action = () => HeaderSerializer.DeserializePrimitive( ["2020-01-02T03:04:05-04:00"], "date"); action.Should().Throw(); } @@ -289,7 +289,7 @@ public void DeserializePrimitive_DateTimeOffset_ReturnsString(string format) { // Act - var result = HeaderSerializer.Instance.DeserializePrimitive( + var result = HeaderSerializer.DeserializePrimitive( ["2020-01-02T03:04:05-04:00"], format); // Assert @@ -306,7 +306,7 @@ public void DeserializeList_ListOfStrings_ReturnsStrings() { // Act - List result = HeaderSerializer.Instance.DeserializeList( + List result = HeaderSerializer.DeserializeList( ["abc", "def", "ghi"]); // Assert @@ -319,7 +319,7 @@ public void DeserializeList_ListOfIntegers_ReturnsIntegers() { // Act - List result = HeaderSerializer.Instance.DeserializeList( + List result = HeaderSerializer.DeserializeList( ["1", "3", "5"]); // Assert diff --git a/src/main/Yardarm.Client.UnitTests/Serialization/LiteralSerializerTests.cs b/src/main/Yardarm.Client.UnitTests/Serialization/LiteralSerializerTests.cs index f3b51318..7135b41a 100644 --- a/src/main/Yardarm.Client.UnitTests/Serialization/LiteralSerializerTests.cs +++ b/src/main/Yardarm.Client.UnitTests/Serialization/LiteralSerializerTests.cs @@ -14,7 +14,7 @@ public void Serialize_String_ReturnsString() { // Act - string result = LiteralSerializer.Instance.Serialize("test"); + string result = LiteralSerializer.Serialize("test"); // Assert @@ -26,7 +26,7 @@ public void Serialize_Integer_ReturnsString() { // Act - string result = LiteralSerializer.Instance.Serialize(105); + string result = LiteralSerializer.Serialize(105); // Assert @@ -38,7 +38,7 @@ public void Serialize_Long_ReturnsString() { // Act - string result = LiteralSerializer.Instance.Serialize(105L); + string result = LiteralSerializer.Serialize(105L); // Assert @@ -50,7 +50,7 @@ public void Serialize_Float_ReturnsString() { // Act - string result = LiteralSerializer.Instance.Serialize(1.05f); + string result = LiteralSerializer.Serialize(1.05f); // Assert @@ -62,7 +62,7 @@ public void Serialize_Double_ReturnsString() { // Act - string result = LiteralSerializer.Instance.Serialize(1.05); + string result = LiteralSerializer.Serialize(1.05); // Assert @@ -74,7 +74,7 @@ public void Serialize_True_ReturnsString() { // Act - string result = LiteralSerializer.Instance.Serialize(true); + string result = LiteralSerializer.Serialize(true); // Assert @@ -86,7 +86,7 @@ public void Serialize_False_ReturnsString() { // Act - string result = LiteralSerializer.Instance.Serialize(false); + string result = LiteralSerializer.Serialize(false); // Assert @@ -98,7 +98,7 @@ public void Serialize_DateTime_ReturnsString() { // Act - string result = LiteralSerializer.Instance.Serialize(new DateTime(2020, 1, 2, 3, 4, 5)); + string result = LiteralSerializer.Serialize(new DateTime(2020, 1, 2, 3, 4, 5)); // Assert @@ -112,7 +112,7 @@ public void Serialize_Date_ReturnsString(string format) { // Act - string result = LiteralSerializer.Instance.Serialize(new DateTime(2020, 1, 2, 3, 4, 5), format); + string result = LiteralSerializer.Serialize(new DateTime(2020, 1, 2, 3, 4, 5), format); // Assert @@ -124,7 +124,7 @@ public void Serialize_DateTimeOffset_ReturnsString() { // Act - string result = LiteralSerializer.Instance.Serialize( + string result = LiteralSerializer.Serialize( new DateTimeOffset(2020, 1, 2, 3, 4, 5, TimeSpan.FromHours(-4))); // Assert @@ -139,7 +139,7 @@ public void Serialize_TimeSpan_ReturnsString(string format) { // Act - string result = LiteralSerializer.Instance.Serialize( + string result = LiteralSerializer.Serialize( new TimeSpan(0, 3, 4, 5), format); // Assert @@ -154,7 +154,7 @@ public void Serialize_TimeSpanMillis_ReturnsString(string format) { // Act - string result = LiteralSerializer.Instance.Serialize( + string result = LiteralSerializer.Serialize( new TimeSpan(0, 3, 4, 5, 123), format); // Assert @@ -171,7 +171,7 @@ public void Serialize_Guid_ReturnsString() // Act - string result = LiteralSerializer.Instance.Serialize(guid); + string result = LiteralSerializer.Serialize(guid); // Assert @@ -183,7 +183,7 @@ public void Serialize_Enum_ReturnsString() { // Act - string result = LiteralSerializer.Instance.Serialize(StringComparison.Ordinal); + string result = LiteralSerializer.Serialize(StringComparison.Ordinal); // Assert @@ -199,7 +199,7 @@ public void Deserialize_String_ReturnsString() { // Act - string result = LiteralSerializer.Instance.Deserialize("test"); + string result = LiteralSerializer.Deserialize("test"); // Assert @@ -211,7 +211,7 @@ public void Deserialize_Integer_ReturnsString() { // Act - int result = LiteralSerializer.Instance.Deserialize("105"); + int result = LiteralSerializer.Deserialize("105"); // Assert @@ -223,7 +223,7 @@ public void Deserialize_Long_ReturnsString() { // Act - long result = LiteralSerializer.Instance.Deserialize("105"); + long result = LiteralSerializer.Deserialize("105"); // Assert @@ -235,7 +235,7 @@ public void Deserialize_Float_ReturnsString() { // Act - float result = LiteralSerializer.Instance.Deserialize("1.05"); + float result = LiteralSerializer.Deserialize("1.05"); // Assert @@ -247,7 +247,7 @@ public void Deserialize_Double_ReturnsString() { // Act - double result = LiteralSerializer.Instance.Deserialize("1.05"); + double result = LiteralSerializer.Deserialize("1.05"); // Assert @@ -259,7 +259,7 @@ public void Deserialize_True_ReturnsString() { // Act - bool result = LiteralSerializer.Instance.Deserialize("true"); + bool result = LiteralSerializer.Deserialize("true"); // Assert @@ -271,7 +271,7 @@ public void Deserialize_False_ReturnsString() { // Act - bool result = LiteralSerializer.Instance.Deserialize("false"); + bool result = LiteralSerializer.Deserialize("false"); // Assert @@ -285,7 +285,7 @@ public void Deserialize_Date_ReturnsString(string format) { // Act - var result = LiteralSerializer.Instance.Deserialize("2020-01-02", format); + var result = LiteralSerializer.Deserialize("2020-01-02", format); // Assert @@ -299,7 +299,7 @@ public void Deserialize_TimeSpan_ReturnsString(string format) { // Act - var result = LiteralSerializer.Instance.Deserialize("13:01:02", format); + var result = LiteralSerializer.Deserialize("13:01:02", format); // Assert @@ -313,7 +313,7 @@ public void Deserialize_TimeSpanWithMillis_ReturnsString(string format) { // Act - var result = LiteralSerializer.Instance.Deserialize("13:01:02.234000", format); + var result = LiteralSerializer.Deserialize("13:01:02.234000", format); // Assert @@ -325,7 +325,7 @@ public void Deserialize_DateWithUnexpectedTime_FormatException() { // Act/Assert - var action = () => LiteralSerializer.Instance.Deserialize( + var action = () => LiteralSerializer.Deserialize( "2020-01-02T03:04:05-04:00", "date"); action.Should().Throw(); } @@ -337,7 +337,7 @@ public void Deserialize_DateTimeOffset_ReturnsString(string format) { // Act - var result = LiteralSerializer.Instance.Deserialize( + var result = LiteralSerializer.Deserialize( "2020-01-02T03:04:05-04:00", format); // Assert @@ -353,7 +353,7 @@ public void Deserialize_Guid_ReturnsValue() const string guid = "00000001-0002-0003-0004-000000000005"; // Act - Guid result = LiteralSerializer.Instance.Deserialize(guid); + Guid result = LiteralSerializer.Deserialize(guid); // Assert @@ -365,7 +365,7 @@ public void Deserialize_Enum_ReturnsValue() { // Act - StringComparison result = LiteralSerializer.Instance.Deserialize("Ordinal"); + StringComparison result = LiteralSerializer.Deserialize("Ordinal"); // Assert @@ -381,7 +381,7 @@ public void JoinListT_Date_Serializes() { // Act - var result = LiteralSerializer.Instance.JoinList(",", + var result = LiteralSerializer.JoinList(",", new[] {new DateTime(2020, 1, 2), new DateTime(2021, 2, 3)}, "date"); diff --git a/src/main/Yardarm.Client.UnitTests/Serialization/PathSegmentSerializerTests.cs b/src/main/Yardarm.Client.UnitTests/Serialization/PathSegmentSerializerTests.cs index bf9a5999..be5f7685 100644 --- a/src/main/Yardarm.Client.UnitTests/Serialization/PathSegmentSerializerTests.cs +++ b/src/main/Yardarm.Client.UnitTests/Serialization/PathSegmentSerializerTests.cs @@ -278,7 +278,7 @@ public void Serialize_LabelListExplodeFalse_ReturnsCommaDelimitedString() // Assert - result.Should().Be(".abc,def,ghi"); + result.Should().Be(".abc.def.ghi"); } [Fact] diff --git a/src/main/Yardarm.Client/Serialization/HeaderSerializer.cs b/src/main/Yardarm.Client/Serialization/HeaderSerializer.cs index 3eef807c..6245dba7 100644 --- a/src/main/Yardarm.Client/Serialization/HeaderSerializer.cs +++ b/src/main/Yardarm.Client/Serialization/HeaderSerializer.cs @@ -1,24 +1,12 @@ using System.Collections.Generic; -using System.Linq; using Yardarm.Client.Internal; // ReSharper disable once CheckNamespace namespace RootNamespace.Serialization { - public class HeaderSerializer + public static class HeaderSerializer { - public static HeaderSerializer Instance { get; } = new(LiteralSerializer.Instance); - - private readonly LiteralSerializer _literalSerializer; - - public HeaderSerializer(LiteralSerializer literalSerializer) - { - ThrowHelper.ThrowIfNull(literalSerializer); - - _literalSerializer = literalSerializer; - } - - public string SerializePrimitive(T value, string? format = null) + public static string SerializePrimitive(T value, string? format = null) { if (value == null) { @@ -31,20 +19,20 @@ public string SerializePrimitive(T value, string? format = null) return str; } - return _literalSerializer.Serialize(value, format); + return LiteralSerializer.Serialize(value, format); } - public string SerializeList(IEnumerable? list, string? format = null) + public static string SerializeList(IEnumerable? list, string? format = null) { if (list == null) { return ""; } - return _literalSerializer.JoinList(",", list, format); + return LiteralSerializer.JoinList(",", list, format); } - public T DeserializePrimitive(IEnumerable values, string? format = null) + public static T DeserializePrimitive(IEnumerable values, string? format = null) { // Rejoin the values from the header into a simple string #if NET6_0_OR_GREATER @@ -60,14 +48,14 @@ public T DeserializePrimitive(IEnumerable values, string? format = nu } // We're not dealing with a list, so join the values back together - return _literalSerializer.Deserialize(value, format); + return LiteralSerializer.Deserialize(value, format); } - public List DeserializeList(IEnumerable values, string? format = null) + public static List DeserializeList(IEnumerable values, string? format = null) { ThrowHelper.ThrowIfNull(values); - return _literalSerializer.DeserializeList(values, format); + return LiteralSerializer.DeserializeList(values, format); } } } diff --git a/src/main/Yardarm.Client/Serialization/LiteralSerializer.cs b/src/main/Yardarm.Client/Serialization/LiteralSerializer.cs index 02dc6859..9aefe217 100644 --- a/src/main/Yardarm.Client/Serialization/LiteralSerializer.cs +++ b/src/main/Yardarm.Client/Serialization/LiteralSerializer.cs @@ -1,20 +1,16 @@ using System; using System.Collections.Generic; -using System.ComponentModel; using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Linq; -using System.Reflection; using Yardarm.Client.Internal; // ReSharper disable once CheckNamespace namespace RootNamespace.Serialization { - public class LiteralSerializer + public static class LiteralSerializer { - public static LiteralSerializer Instance { get; } = new(); - - public string Serialize(T value, string? format = null) + public static string Serialize(T value, string? format = null) { if (value is null) { @@ -51,17 +47,23 @@ public string Serialize(T value, string? format = null) var timeSpan = (TimeSpan)(object)value; return timeSpan.ToString("c"); } + if (typeof(T) == typeof(Guid) || typeof(T) == typeof(Guid?)) + { + // Optimization for GUIDs, avoids loading CultureInfo.InvariantCulture which has no effect on GUID formatting + var guid = (Guid)(object)value; + return guid.ToString(); + } - if (value is IFormattable formattable) + if (value is IFormattable) { - return formattable.ToString(null, CultureInfo.InvariantCulture); + return ((IFormattable)value).ToString(null, CultureInfo.InvariantCulture); // constrained call avoiding boxing for value types } return value.ToString() ?? ""; } [return: NotNullIfNotNull(nameof(value))] - public T Deserialize(string? value, string? format = null) + public static T Deserialize(string? value, string? format = null) { if (value is null) { @@ -169,11 +171,11 @@ public T Deserialize(string? value, string? format = null) return default!; // unreachable } - public string JoinList(string separator, IEnumerable list, string? format = null) => + public static string JoinList(string separator, IEnumerable list, string? format = null) => string.Join(separator, list .Select(p => Serialize(p, format))); - public List DeserializeList(IEnumerable values, string? format = null) => + public static List DeserializeList(IEnumerable values, string? format = null) => new List(values.Select(p => Deserialize(p, format))); } } diff --git a/src/main/Yardarm.Client/Serialization/PathSegmentSerializer.cs b/src/main/Yardarm.Client/Serialization/PathSegmentSerializer.cs index f8069ed7..d632113f 100644 --- a/src/main/Yardarm.Client/Serialization/PathSegmentSerializer.cs +++ b/src/main/Yardarm.Client/Serialization/PathSegmentSerializer.cs @@ -1,12 +1,10 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; using System.ComponentModel; -using System.Diagnostics.CodeAnalysis; // ReSharper disable once CheckNamespace namespace RootNamespace.Serialization { - internal class PathSegmentSerializer + internal static class PathSegmentSerializer { public static string Serialize(string name, T value, PathSegmentStyle style = PathSegmentStyle.Simple, string? format = null) => style switch @@ -20,10 +18,10 @@ public static string Serialize(string name, T value, PathSegmentStyle style = public static string SerializeList(string name, IEnumerable values, PathSegmentStyle style = PathSegmentStyle.Simple, bool explode = false, string? format = null) => style switch { - PathSegmentStyle.Simple => LiteralSerializer.Instance.JoinList(",", values, format), - PathSegmentStyle.Label => "." + LiteralSerializer.Instance.JoinList(explode ? "." : ",", values, format), + PathSegmentStyle.Simple => LiteralSerializer.JoinList(",", values, format), + PathSegmentStyle.Label => "." + LiteralSerializer.JoinList(".", values, format), PathSegmentStyle.Matrix => - $";{name}={LiteralSerializer.Instance.JoinList(explode ? $";{name}=" : ",", values, format)}", + $";{name}={LiteralSerializer.JoinList(explode ? $";{name}=" : ",", values, format)}", _ => throw new InvalidEnumArgumentException(nameof(style), (int)style, typeof(PathSegmentStyle)) }; @@ -40,7 +38,7 @@ private static string SerializeSimple(T value, string? format = null) return str; } - return LiteralSerializer.Instance.Serialize(value, format); + return LiteralSerializer.Serialize(value, format); } private static string SerializeLabel(T value, string? format) @@ -56,7 +54,7 @@ private static string SerializeLabel(T value, string? format) return "." + str; } - return "." + LiteralSerializer.Instance.Serialize(value, format); + return "." + LiteralSerializer.Serialize(value, format); } private static string SerializeMatrix(string name, T value, string? format) @@ -72,7 +70,7 @@ private static string SerializeMatrix(string name, T value, string? format) return $";{name}={str}"; } - return $";{name}={LiteralSerializer.Instance.Serialize(value, format)}"; + return $";{name}={LiteralSerializer.Serialize(value, format)}"; } } } diff --git a/src/main/Yardarm.Client/Serialization/QueryStringBuilder.cs b/src/main/Yardarm.Client/Serialization/QueryStringBuilder.cs index a502616d..e302a5ff 100644 --- a/src/main/Yardarm.Client/Serialization/QueryStringBuilder.cs +++ b/src/main/Yardarm.Client/Serialization/QueryStringBuilder.cs @@ -114,8 +114,8 @@ private void Append(string name, string value) private static string EscapeValue(T value, bool allowReserved, string? format) => allowReserved - ? LiteralSerializer.Instance.Serialize(value, format) - : Uri.EscapeDataString(LiteralSerializer.Instance.Serialize(value, format)); + ? LiteralSerializer.Serialize(value, format) + : Uri.EscapeDataString(LiteralSerializer.Serialize(value, format)); [return: NotNullIfNotNull(nameof(uri))] public static Uri? AppendQueryParameter(Uri? uri, string name, string value) diff --git a/src/main/Yardarm.sln b/src/main/Yardarm.sln index a1e62983..a2f13394 100644 --- a/src/main/Yardarm.sln +++ b/src/main/Yardarm.sln @@ -27,6 +27,11 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Yardarm.MicrosoftExtensions EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Yardarm.MicrosoftExtensionsHttp.Client", "Yardarm.MicrosoftExtensionsHttp.Client\Yardarm.MicrosoftExtensionsHttp.Client.csproj", "{AB9CA15B-AE6E-421B-9662-E6264B4EA1CA}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{0F27CDEF-318E-4305-AE2B-AA44C670E7C2}" + ProjectSection(SolutionItems) = preProject + Directory.Packages.props = Directory.Packages.props + EndProjectSection +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU diff --git a/src/main/Yardarm/Enrichment/Responses/HeaderParsingEnricher.cs b/src/main/Yardarm/Enrichment/Responses/HeaderParsingEnricher.cs index c3c5a20a..6ad49ff0 100644 --- a/src/main/Yardarm/Enrichment/Responses/HeaderParsingEnricher.cs +++ b/src/main/Yardarm/Enrichment/Responses/HeaderParsingEnricher.cs @@ -84,7 +84,7 @@ protected virtual IEnumerable GenerateStatements( if (schemaElement is {Element.Type: "array"}) { deserializeExpression = InvocationExpression(MemberAccessExpression(SyntaxKind.SimpleMemberAccessExpression, - _serializationNamespace.HeaderSerializerInstance, + _serializationNamespace.HeaderSerializer, GenericName("DeserializeList") .AddTypeArgumentListArguments(typeName)), ArgumentList(SeparatedList(new [] @@ -96,7 +96,7 @@ protected virtual IEnumerable GenerateStatements( else { deserializeExpression = InvocationExpression(MemberAccessExpression(SyntaxKind.SimpleMemberAccessExpression, - _serializationNamespace.HeaderSerializerInstance, + _serializationNamespace.HeaderSerializer, GenericName("DeserializePrimitive") .AddTypeArgumentListArguments(typeName)), ArgumentList(SeparatedList(new [] { diff --git a/src/main/Yardarm/Generation/Request/AddHeadersMethodGenerator.cs b/src/main/Yardarm/Generation/Request/AddHeadersMethodGenerator.cs index b87ed9a0..99080942 100644 --- a/src/main/Yardarm/Generation/Request/AddHeadersMethodGenerator.cs +++ b/src/main/Yardarm/Generation/Request/AddHeadersMethodGenerator.cs @@ -89,7 +89,7 @@ protected virtual IEnumerable GenerateStatements( valueExpression = InvocationExpression( MemberAccessExpression( SyntaxKind.SimpleMemberAccessExpression, - SerializationNamespace.HeaderSerializerInstance, + SerializationNamespace.HeaderSerializer, IdentifierName("SerializeList")), ArgumentList(SeparatedList(new[] { @@ -102,7 +102,7 @@ protected virtual IEnumerable GenerateStatements( valueExpression = InvocationExpression( MemberAccessExpression( SyntaxKind.SimpleMemberAccessExpression, - SerializationNamespace.HeaderSerializerInstance, + SerializationNamespace.HeaderSerializer, IdentifierName("SerializePrimitive")), ArgumentList(SeparatedList(new [] { diff --git a/src/main/Yardarm/Names/ISerializationNamespace.cs b/src/main/Yardarm/Names/ISerializationNamespace.cs index b35f1438..d3444f38 100644 --- a/src/main/Yardarm/Names/ISerializationNamespace.cs +++ b/src/main/Yardarm/Names/ISerializationNamespace.cs @@ -6,7 +6,6 @@ namespace Yardarm.Names public interface ISerializationNamespace : IKnownNamespace { NameSyntax HeaderSerializer { get; } - ExpressionSyntax HeaderSerializerInstance { get; } NameSyntax ISerializationData { get; } NameSyntax ITypeSerializer { get; } NameSyntax ITypeSerializerRegistry { get; } diff --git a/src/main/Yardarm/Names/Internal/SerializationNamespace.cs b/src/main/Yardarm/Names/Internal/SerializationNamespace.cs index 4b31a475..8aceda5a 100644 --- a/src/main/Yardarm/Names/Internal/SerializationNamespace.cs +++ b/src/main/Yardarm/Names/Internal/SerializationNamespace.cs @@ -9,7 +9,6 @@ namespace Yardarm.Names.Internal internal class SerializationNamespace : ISerializationNamespace { public NameSyntax HeaderSerializer { get; } - public ExpressionSyntax HeaderSerializerInstance { get; } public NameSyntax Name { get; } public NameSyntax ISerializationData { get; } public NameSyntax ITypeSerializer { get; } @@ -32,10 +31,6 @@ public SerializationNamespace(IRootNamespace rootNamespace) Name, IdentifierName("HeaderSerializer")); - HeaderSerializerInstance = MemberAccessExpression(SyntaxKind.SimpleMemberAccessExpression, - HeaderSerializer, - IdentifierName("Instance")); - ISerializationData = QualifiedName( Name, IdentifierName("ISerializationData"));