Skip to content
This repository has been archived by the owner on Jul 9, 2024. It is now read-only.

Fix IsTrimmable property #140

Merged
merged 4 commits into from
Feb 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -348,3 +348,6 @@ MigrationBackup/

# Ionide (cross platform F# VS Code tools) working folder
.ionide/

# JetBrains Rider
.idea/
4 changes: 2 additions & 2 deletions src/Microsoft.Kiota.Serialization.Text.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@
<PackageReadmeFile>README.md</PackageReadmeFile>
<NoWarn>$(NoWarn);NU5048;NETSDK1138</NoWarn>
</PropertyGroup>
<PropertyGroup Condition="'$(TargetFrameworkVersion)' == 'net5.0'">
<PropertyGroup Condition="'$(TargetFramework)' == 'net5.0'">
<IsTrimmable>true</IsTrimmable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0" PrivateAssets="All" />
<PackageReference Include="Microsoft.Kiota.Abstractions" Version="1.7.8" />
<PackageReference Include="Microsoft.Kiota.Abstractions" Version="1.7.9" />
</ItemGroup>

<PropertyGroup Condition="'$(TF_BUILD)' == 'true'">
Expand Down
8 changes: 4 additions & 4 deletions src/TextParseNode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,15 @@ public TextParseNode(string? text)
/// <inheritdoc />
public Time? GetTimeValue() => DateTime.TryParse(Text, out var result) ? new Time(result) : null;
/// <inheritdoc />
#if NET5_0_OR_GREATER
public IEnumerable<T?> GetCollectionOfEnumValues<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicFields)] T>() where T : struct, Enum
#if NET5_0_OR_GREATER
public IEnumerable<T?> GetCollectionOfEnumValues<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] T>() where T : struct, Enum
baywet marked this conversation as resolved.
Show resolved Hide resolved
#else
public IEnumerable<T?> GetCollectionOfEnumValues<T>() where T : struct, Enum
#endif
=> throw new InvalidOperationException(NoStructuredDataMessage);
/// <inheritdoc />
#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<T>() where T : struct, Enum
#endif
Expand Down
13 changes: 8 additions & 5 deletions src/TextSerializationWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ namespace Microsoft.Kiota.Serialization.Text;
/// <summary>
/// The <see cref="ISerializationWriter"/> implementation for text content types.
/// </summary>
public class TextSerializationWriter : ISerializationWriter, IDisposable {
public class TextSerializationWriter : ISerializationWriter, IDisposable
{
private readonly MemoryStream _stream = new MemoryStream();
private readonly StreamWriter _writer;
/// <summary>
Expand Down Expand Up @@ -45,7 +46,8 @@ public void Dispose()
GC.SuppressFinalize(this);
}
/// <inheritdoc />
public Stream GetSerializedContent() {
public Stream GetSerializedContent()
{
_writer.Flush();
_stream.Position = 0;
return _stream;
Expand Down Expand Up @@ -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;
}
Expand All @@ -102,14 +105,14 @@ public void WriteStringValue(string? key, string? value)
/// <inheritdoc />
public void WriteTimeValue(string? key, Time? value) => WriteStringValue(key, value?.ToString());
/// <inheritdoc />
#if NET5_0_OR_GREATER
#if NET5_0_OR_GREATER
public void WriteCollectionOfEnumValues<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicFields)] T>(string? key, IEnumerable<T?>? values) where T : struct, Enum
#else
public void WriteCollectionOfEnumValues<T>(string? key, IEnumerable<T?>? values) where T : struct, Enum
#endif
=> throw new InvalidOperationException(TextParseNode.NoStructuredDataMessage);
/// <inheritdoc />
#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<T>(string? key, T? value) where T : struct, Enum
Expand Down
Loading