Skip to content

Commit

Permalink
Fix warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
Pilchie committed May 18, 2024
1 parent 38fd7d6 commit d246bf4
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,9 @@ protected virtual void Dispose(bool disposing)
/// <param name="key"></param>
/// <param name="timestamp"></param>
[DebuggerDisplay("{GetDebuggerDisplay()}")]
internal class MemoryRecordWithSimilarityScore(
#pragma warning disable CA1812 // 'MemoryRecordWithSimilarityScore' is an internal class that is apparently never instantiated. If so, remove the code from the assembly. If this class is intended to contain only static members, make it 'static' (Module in Visual Basic). (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1812)
internal sealed class MemoryRecordWithSimilarityScore(
#pragma warning restore CA1812
MemoryRecordMetadata metadata,
ReadOnlyMemory<float> embedding,
string? key,
Expand All @@ -421,7 +423,7 @@ private string GetDebuggerDisplay()
/// Creates a new record that also serializes an "id" property.
/// </summary>
[DebuggerDisplay("{GetDebuggerDisplay()}")]
internal class MemoryRecordWithId : MemoryRecord
internal sealed class MemoryRecordWithId : MemoryRecord
{
/// <summary>
/// Creates a new record that also serializes an "id" property.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// Taken from https://github.com/Azure/azure-cosmos-dotnet-v3/pull/4332

using System;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Reflection;
using System.Text.Json;
Expand All @@ -13,7 +14,7 @@ namespace Microsoft.Azure.Cosmos;
/// <summary>
/// This class provides a default implementation of System.Text.Json Cosmos Linq Serializer.
/// </summary>
internal class CosmosSystemTextJsonSerializer : CosmosLinqSerializer
internal sealed class CosmosSystemTextJsonSerializer : CosmosLinqSerializer
{
/// <summary>
/// A read-only instance of <see cref="JsonSerializerOptions"/>.
Expand All @@ -32,6 +33,7 @@ internal class CosmosSystemTextJsonSerializer : CosmosLinqSerializer
}

/// <inheritdoc/>
[return: MaybeNull]
public override T FromStream<T>(Stream stream)
{
if (stream == null)
Expand Down Expand Up @@ -107,22 +109,22 @@ public override Stream ToStream<T>(T input)
/// To handle such scenarios, please create a custom serializer which inherits from the <see cref="CosmosSystemTextJsonSerializer"/> and overrides the
/// SerializeMemberName to add any special handling.
/// </remarks>
public override string SerializeMemberName(MemberInfo memberInfo)
public override string? SerializeMemberName(MemberInfo memberInfo)
{
JsonExtensionDataAttribute jsonExtensionDataAttribute =
JsonExtensionDataAttribute? jsonExtensionDataAttribute =
memberInfo.GetCustomAttribute<JsonExtensionDataAttribute>(true);

if (jsonExtensionDataAttribute != null)
{
return null;
}

JsonPropertyNameAttribute jsonPropertyNameAttribute = memberInfo.GetCustomAttribute<JsonPropertyNameAttribute>(true);

string memberName = !string.IsNullOrEmpty(jsonPropertyNameAttribute?.Name)
? jsonPropertyNameAttribute.Name
: memberInfo.Name;
JsonPropertyNameAttribute? jsonPropertyNameAttribute = memberInfo.GetCustomAttribute<JsonPropertyNameAttribute>(true);
if (jsonPropertyNameAttribute is { } && !string.IsNullOrEmpty(jsonPropertyNameAttribute.Name))
{
return jsonPropertyNameAttribute.Name;
}

return memberName;
return memberInfo.Name;
}
}

0 comments on commit d246bf4

Please sign in to comment.