diff --git a/.gitignore b/.gitignore index dfcfd56..aea9645 100644 --- a/.gitignore +++ b/.gitignore @@ -348,3 +348,6 @@ MigrationBackup/ # Ionide (cross platform F# VS Code tools) working folder .ionide/ + +# JetBrains Rider +.idea/ \ No newline at end of file diff --git a/src/Microsoft.Kiota.Serialization.Text.csproj b/src/Microsoft.Kiota.Serialization.Text.csproj index 360537d..590bfd1 100644 --- a/src/Microsoft.Kiota.Serialization.Text.csproj +++ b/src/Microsoft.Kiota.Serialization.Text.csproj @@ -33,13 +33,13 @@ README.md $(NoWarn);NU5048;NETSDK1138 - + true - + diff --git a/src/TextParseNode.cs b/src/TextParseNode.cs index 7dd0f17..63353de 100644 --- a/src/TextParseNode.cs +++ b/src/TextParseNode.cs @@ -66,15 +66,15 @@ public TextParseNode(string? text) /// public Time? GetTimeValue() => DateTime.TryParse(Text, out var result) ? new Time(result) : null; /// - #if NET5_0_OR_GREATER - public IEnumerable GetCollectionOfEnumValues<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicFields)] T>() where T : struct, Enum +#if NET5_0_OR_GREATER + public IEnumerable GetCollectionOfEnumValues<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] T>() where T : struct, Enum #else public IEnumerable GetCollectionOfEnumValues() where T : struct, Enum #endif => throw new InvalidOperationException(NoStructuredDataMessage); /// - #if NET5_0_OR_GREATER - public T? GetEnumValue<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicFields)] T>() where T : struct, Enum +#if NET5_0_OR_GREATER + public T? GetEnumValue<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] T>() where T : struct, Enum #else public T? GetEnumValue() where T : struct, Enum #endif diff --git a/src/TextSerializationWriter.cs b/src/TextSerializationWriter.cs index 57ae6b7..ba9f2c4 100644 --- a/src/TextSerializationWriter.cs +++ b/src/TextSerializationWriter.cs @@ -15,7 +15,8 @@ namespace Microsoft.Kiota.Serialization.Text; /// /// The implementation for text content types. /// -public class TextSerializationWriter : ISerializationWriter, IDisposable { +public class TextSerializationWriter : ISerializationWriter, IDisposable +{ private readonly MemoryStream _stream = new MemoryStream(); private readonly StreamWriter _writer; /// @@ -45,7 +46,8 @@ public void Dispose() GC.SuppressFinalize(this); } /// - public Stream GetSerializedContent() { + public Stream GetSerializedContent() + { _writer.Flush(); _stream.Position = 0; return _stream; @@ -92,7 +94,8 @@ public void WriteStringValue(string? key, string? value) if(!string.IsNullOrEmpty(value)) if(_written) throw new InvalidOperationException("a value was already written for this serialization writer, text content only supports a single value"); - else { + else + { _writer.Write(value); _written = true; } @@ -102,14 +105,14 @@ public void WriteStringValue(string? key, string? value) /// public void WriteTimeValue(string? key, Time? value) => WriteStringValue(key, value?.ToString()); /// - #if NET5_0_OR_GREATER +#if NET5_0_OR_GREATER public void WriteCollectionOfEnumValues<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicFields)] T>(string? key, IEnumerable? values) where T : struct, Enum #else public void WriteCollectionOfEnumValues(string? key, IEnumerable? values) where T : struct, Enum #endif => throw new InvalidOperationException(TextParseNode.NoStructuredDataMessage); /// - #if NET5_0_OR_GREATER +#if NET5_0_OR_GREATER public void WriteEnumValue<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicFields)] T>(string? key, T? value) where T : struct, Enum #else public void WriteEnumValue(string? key, T? value) where T : struct, Enum