Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
19946d7
sample
anuchandy Jul 26, 2025
f8638ad
enable aot bin generatrion
anuchandy Jul 26, 2025
ca0e1ce
sample and sln in one proj
anuchandy Jul 26, 2025
3eaa768
set1 - net9
anuchandy Jul 26, 2025
3a35ae5
nullable ref type net9
anuchandy Jul 26, 2025
34bbd59
nullable ref 2 net9
anuchandy Jul 26, 2025
5e879bb
nullable ref 3 net9
anuchandy Jul 26, 2025
077727b
more fixes
anuchandy Jul 26, 2025
4c3c629
supress all net9 stylecop warns
anuchandy Jul 26, 2025
95bff0f
pref cntr only on win
anuchandy Jul 26, 2025
834dc82
supress obsolote warns (future work as it's nonblocking)
anuchandy Jul 27, 2025
b1421fa
fix supress VSTHRD002, use equal for value type, disable CS8601
anuchandy Jul 27, 2025
26caf0b
use fq UInt128
anuchandy Jul 27, 2025
6e17769
adapt to MemoryMarshal.Write ref breaking change in net9
anuchandy Jul 27, 2025
2b881ac
more: stick to just net9.0
anuchandy Jul 27, 2025
ea1a23d
rm perf cntr
anuchandy Jul 27, 2025
283a5a1
removes back compact stick to net9
anuchandy Jul 27, 2025
d069ef9
remove more back compact
anuchandy Jul 27, 2025
884e92d
read containers
anuchandy Jul 27, 2025
5529104
add more info to sample
anuchandy Jul 27, 2025
79b1d10
improve sample
anuchandy Jul 27, 2025
753e30a
cleanup
anuchandy Jul 28, 2025
70981a4
rm temp sample
anuchandy Jul 28, 2025
c64cb23
fix build
anuchandy Jul 28, 2025
7549538
use correct case for type names (c#9 rule)
anuchandy Jul 28, 2025
7d4efee
tests: use fq for unit128
anuchandy Jul 29, 2025
40ed1b7
use readExact
anuchandy Jul 29, 2025
bdfefe5
update the tests to pin net9
anuchandy Jul 29, 2025
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
16 changes: 14 additions & 2 deletions Microsoft.Azure.Cosmos.sln
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.29123.88
# Visual Studio Version 17
VisualStudioVersion = 17.14.36301.6 d17.14
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Azure.Cosmos", "Microsoft.Azure.Cosmos\src\Microsoft.Azure.Cosmos.csproj", "{36F6F6A8-CEC8-4261-9948-903495BC3C25}"
EndProject
Expand Down Expand Up @@ -180,6 +180,18 @@ Global
{021DDC27-02EF-42C4-9A9E-AA600833C2EE}.Release|Any CPU.Build.0 = Release|Any CPU
{021DDC27-02EF-42C4-9A9E-AA600833C2EE}.Release|x64.ActiveCfg = Release|Any CPU
{021DDC27-02EF-42C4-9A9E-AA600833C2EE}.Release|x64.Build.0 = Release|Any CPU
{D744906A-1091-403F-B0B6-794DE045169A}.Cover|Any CPU.ActiveCfg = Debug|Any CPU
{D744906A-1091-403F-B0B6-794DE045169A}.Cover|Any CPU.Build.0 = Debug|Any CPU
{D744906A-1091-403F-B0B6-794DE045169A}.Cover|x64.ActiveCfg = Debug|Any CPU
{D744906A-1091-403F-B0B6-794DE045169A}.Cover|x64.Build.0 = Debug|Any CPU
{D744906A-1091-403F-B0B6-794DE045169A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D744906A-1091-403F-B0B6-794DE045169A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D744906A-1091-403F-B0B6-794DE045169A}.Debug|x64.ActiveCfg = Debug|Any CPU
{D744906A-1091-403F-B0B6-794DE045169A}.Debug|x64.Build.0 = Debug|Any CPU
{D744906A-1091-403F-B0B6-794DE045169A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D744906A-1091-403F-B0B6-794DE045169A}.Release|Any CPU.Build.0 = Release|Any CPU
{D744906A-1091-403F-B0B6-794DE045169A}.Release|x64.ActiveCfg = Release|Any CPU
{D744906A-1091-403F-B0B6-794DE045169A}.Release|x64.Build.0 = Release|Any CPU
{CE4D6DA8-148D-4A98-943B-D8C2D532E1DC}.Cover|Any CPU.ActiveCfg = Debug|Any CPU
{CE4D6DA8-148D-4A98-943B-D8C2D532E1DC}.Cover|Any CPU.Build.0 = Debug|Any CPU
{CE4D6DA8-148D-4A98-943B-D8C2D532E1DC}.Cover|x64.ActiveCfg = Debug|Any CPU
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<NeutralLanguage>en-US</NeutralLanguage>
<CurrentDate>$([System.DateTime]::Now.ToString(yyyyMMdd))</CurrentDate>
<OutputType>Exe</OutputType>
<TargetFramework>net6</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<TargetType>library</TargetType>
<Authors>Microsoft</Authors>
<RootNamespace>Microsoft.Azure.Cosmos.FaultInjection</RootNamespace>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<IsTestProject>true</IsTestProject>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<Platform>AnyCPU</Platform>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<IsPackable>false</IsPackable>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<RootNamespace>Microsoft.Azure.Cosmos.FaultInjection.Tests</RootNamespace>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ protected ChangeFeedProcessorUserException(SerializationInfo info, StreamingCont
/// </summary>
/// <param name="info">The SerializationInfo object that holds serialized object data for the exception being thrown.</param>
/// <param name="context">The StreamingContext that contains contextual information about the source or destination.</param>
[Obsolete("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")]
public override void GetObjectData(SerializationInfo info, StreamingContext context)
{
base.GetObjectData(info, context);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ protected FeedException(SerializationInfo info, StreamingContext context)
/// </summary>
/// <param name="info">The SerializationInfo object that holds serialized object data for the exception being thrown.</param>
/// <param name="context">The StreamingContext that contains contextual information about the source or destination.</param>
[Obsolete("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")]
public override void GetObjectData(SerializationInfo info, StreamingContext context)
{
base.GetObjectData(info, context);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ protected LeaseLostException(SerializationInfo info, StreamingContext context)
/// </summary>
/// <param name="info">The SerializationInfo object that holds serialized object data for the exception being thrown.</param>
/// <param name="context">The StreamingContext that contains contextual information about the source or destination.</param>
[Obsolete("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId = "SYSLIB0051", UrlFormat = "https://aka.ms/dotnet-warnings/{0}")]
public override void GetObjectData(SerializationInfo info, StreamingContext context)
{
base.GetObjectData(info, context);
Expand Down
20 changes: 15 additions & 5 deletions Microsoft.Azure.Cosmos/src/CosmosElements/CosmosArray.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,15 @@ protected CosmosArray()

public override TResult Accept<TArg, TResult>(ICosmosElementVisitor<TArg, TResult> cosmosElementVisitor, TArg input) => cosmosElementVisitor.Visit(this, input);

public override bool Equals(CosmosElement cosmosElement) => cosmosElement is CosmosArray cosmosArray && this.Equals(cosmosArray);
public override bool Equals(CosmosElement? cosmosElement) => cosmosElement is CosmosArray cosmosArray && this.Equals(cosmosArray);

public bool Equals(CosmosArray cosmosArray)
public bool Equals(CosmosArray? cosmosArray)
{
if (cosmosArray is null)
{
return false;
}

if (this.Count != cosmosArray.Count)
{
return false;
Expand Down Expand Up @@ -77,10 +82,15 @@ public override int GetHashCode()
return (int)hash;
}

public int CompareTo(CosmosArray cosmosArray)
public int CompareTo(CosmosArray? cosmosArray)
{
UInt128 hash1 = DistinctHash.GetHash(this);
UInt128 hash2 = DistinctHash.GetHash(cosmosArray);
if (cosmosArray is null)
{
return 1;
}

Microsoft.Azure.Cosmos.UInt128 hash1 = DistinctHash.GetHash(this);
Microsoft.Azure.Cosmos.UInt128 hash2 = DistinctHash.GetHash(cosmosArray);
return UInt128BinaryComparer.Singleton.Compare(hash1, hash2);
}

Expand Down
19 changes: 16 additions & 3 deletions Microsoft.Azure.Cosmos/src/CosmosElements/CosmosBinary.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,15 @@ protected CosmosBinary()

public override TResult Accept<TArg, TResult>(ICosmosElementVisitor<TArg, TResult> cosmosElementVisitor, TArg input) => cosmosElementVisitor.Visit(this, input);

public override bool Equals(CosmosElement cosmosElement) => cosmosElement is CosmosBinary cosmosBinary && this.Equals(cosmosBinary);
public override bool Equals(CosmosElement? cosmosElement)
{
return cosmosElement is CosmosBinary cosmosBinary && this.Equals(cosmosBinary);
}

public bool Equals(CosmosBinary cosmosBinary) => this.Value.Span.SequenceEqual(cosmosBinary.Value.Span);
public bool Equals(CosmosBinary? cosmosBinary)
{
return cosmosBinary is not null && this.Value.Span.SequenceEqual(cosmosBinary.Value.Span);
}

public override int GetHashCode()
{
Expand All @@ -45,7 +51,14 @@ public override int GetHashCode()
return (int)hash;
}

public int CompareTo(CosmosBinary cosmosBinary) => this.Value.Span.SequenceCompareTo(cosmosBinary.Value.Span);
public int CompareTo(CosmosBinary? cosmosBinary)
{
if (cosmosBinary is null)
{
return 1;
}
return this.Value.Span.SequenceCompareTo(cosmosBinary.Value.Span);
}

public static CosmosBinary Create(
IJsonNavigator jsonNavigator,
Expand Down
14 changes: 9 additions & 5 deletions Microsoft.Azure.Cosmos/src/CosmosElements/CosmosBoolean.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,23 +47,27 @@ public override TResult Accept<TArg, TResult>(ICosmosElementVisitor<TArg, TResul
return cosmosElementVisitor.Visit(this, input);
}

public override bool Equals(CosmosElement cosmosElement)
public override bool Equals(CosmosElement? cosmosElement)
{
return cosmosElement is CosmosBoolean cosmosBoolean && this.Equals(cosmosBoolean);
}
}

public bool Equals(CosmosBoolean cosmosBoolean)
public bool Equals(CosmosBoolean? cosmosBoolean)
{
return this.Value == cosmosBoolean.Value;
return cosmosBoolean is not null && this.Value == cosmosBoolean.Value;
}

public override int GetHashCode()
{
return this.Value ? TrueHash : FalseHash;
}

public int CompareTo(CosmosBoolean cosmosBoolean)
public int CompareTo(CosmosBoolean? cosmosBoolean)
{
if (cosmosBoolean is null)
{
return 1;
}
return this.Value.CompareTo(cosmosBoolean.Value);
}

Expand Down
11 changes: 8 additions & 3 deletions Microsoft.Azure.Cosmos/src/CosmosElements/CosmosElement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,22 @@ public override string ToString()
return Utf8StringHelpers.ToString(jsonWriter.GetResult());
}

public override bool Equals(object obj)
public override bool Equals(object? obj)
{
return obj is CosmosElement cosmosElement && this.Equals(cosmosElement);
}

public abstract bool Equals(CosmosElement cosmosElement);
public abstract bool Equals(CosmosElement? cosmosElement);

public abstract override int GetHashCode();

public int CompareTo(CosmosElement other)
public int CompareTo(CosmosElement? other)
{
if (other is null)
{
return 1;
}

int thisTypeOrder = this.Accept(CosmosElementToTypeOrder.Singleton);
int otherTypeOrder = other.Accept(CosmosElementToTypeOrder.Singleton);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@ namespace Microsoft.Azure.Cosmos.CosmosElements
using System;
using System.Collections.Generic;
using System.Linq;
#if NETSTANDARD15 || NETSTANDARD16
using System.Reflection;
#endif
using System.Text;
using Microsoft.Azure.Cosmos.Json.Interop;
using Newtonsoft.Json;
Expand Down Expand Up @@ -77,11 +74,7 @@ sealed class CosmosElementJsonConverter : JsonConverter

public override bool CanConvert(Type objectType)
{
#if NETSTANDARD15 || NETSTANDARD16
return ConvertableTypes.Contains(objectType) || ConvertableTypes.Contains(objectType.GetTypeInfo().BaseType) || objectType == typeof(CosmosElement);
#else
return ConvertableTypes.Contains(objectType) || ConvertableTypes.Contains(objectType.BaseType) || objectType == typeof(CosmosElement);
#endif
}

public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
Expand Down
15 changes: 8 additions & 7 deletions Microsoft.Azure.Cosmos/src/CosmosElements/CosmosGuid.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,11 @@ public override TResult Accept<TArg, TResult>(ICosmosElementVisitor<TArg, TResul
return cosmosElementVisitor.Visit(this, input);
}

public override bool Equals(CosmosElement cosmosElement)
{
return cosmosElement is CosmosGuid cosmosGuid && this.Equals(cosmosGuid);
}
public override bool Equals(CosmosElement? cosmosElement) => cosmosElement is CosmosGuid cosmosGuid && this.Equals(cosmosGuid);

public bool Equals(CosmosGuid cosmosGuid)
public bool Equals(CosmosGuid? cosmosGuid)
{
return this.Value == cosmosGuid.Value;
return cosmosGuid is not null && this.Value == cosmosGuid.Value;
}

public override int GetHashCode()
Expand All @@ -60,8 +57,12 @@ public override int GetHashCode()
return (int)hash;
}

public int CompareTo(CosmosGuid cosmosGuid)
public int CompareTo(CosmosGuid? cosmosGuid)
{
if (cosmosGuid is null)
{
return 1;
}
return this.Value.CompareTo(cosmosGuid.Value);
}

Expand Down
10 changes: 5 additions & 5 deletions Microsoft.Azure.Cosmos/src/CosmosElements/CosmosNull.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,14 @@ public override TResult Accept<TArg, TResult>(ICosmosElementVisitor<TArg, TResul
return cosmosElementVisitor.Visit(this, input);
}

public override bool Equals(CosmosElement cosmosElement)
public override bool Equals(CosmosElement? cosmosElement)
{
return cosmosElement is CosmosNull cosmosNull && this.Equals(cosmosNull);
}

public bool Equals(CosmosNull cosmosNull)
public bool Equals(CosmosNull? cosmosNull)
{
return true;
return cosmosNull is not null;
}

public static CosmosNull Create()
Expand Down Expand Up @@ -91,9 +91,9 @@ public static bool TryParse(
return CosmosElement.TryParse<CosmosNull>(json, out cosmosNull);
}

public int CompareTo(CosmosNull other)
public int CompareTo(CosmosNull? other)
{
return 0;
return other is null ? 1 : 0;
}

public static new class Monadic
Expand Down
11 changes: 8 additions & 3 deletions Microsoft.Azure.Cosmos/src/CosmosElements/CosmosNumber.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,20 @@ public override TResult Accept<TArg, TResult>(ICosmosElementVisitor<TArg, TResul
return cosmosElementVisitor.Visit(this, input);
}

public override bool Equals(CosmosElement cosmosElement)
public override bool Equals(CosmosElement? cosmosElement)
{
return cosmosElement is CosmosNumber cosmosNumber && this.Equals(cosmosNumber);
}

public abstract bool Equals(CosmosNumber cosmosNumber);
public abstract bool Equals(CosmosNumber? cosmosNumber);

public int CompareTo(CosmosNumber other)
public int CompareTo(CosmosNumber? other)
{
if (other is null)
{
return 1;
}

int thisTypeOrder = this.Accept(CosmosNumberToTypeOrder.Singleton);
int otherTypeOrder = other.Accept(CosmosNumberToTypeOrder.Singleton);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ public EagerCosmosObject(IReadOnlyDictionary<string, CosmosElement> dictionary)
{
this.dictionary = new Dictionary<string, CosmosElement>(dictionary.ToDictionary(kvp => kvp.Key, kvp => kvp.Value));
}

public override CosmosElement this[string key] => this.dictionary[key];

public override int Count => this.dictionary.Count;
Expand All @@ -41,7 +40,12 @@ public EagerCosmosObject(IReadOnlyDictionary<string, CosmosElement> dictionary)

public override Enumerator GetEnumerator() => new Enumerator(this.dictionary.GetEnumerator());

public override bool TryGetValue(string key, out CosmosElement value) => this.dictionary.TryGetValue(key, out value);
public override bool TryGetValue(string key, out CosmosElement value)
{
#pragma warning disable CS8601 // Possible null reference assignment - intentional out parameter assignment
return this.dictionary.TryGetValue(key, out value);
#pragma warning restore CS8601 // Possible null reference assignment
}

public override void WriteTo(IJsonWriter jsonWriter)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,12 @@ public LazyCosmosObject(IJsonNavigator jsonNavigator, IJsonNavigatorNode jsonNav

public override Enumerator GetEnumerator() => new Enumerator(this.lazyCache.Value.GetEnumerator());

public override bool TryGetValue(string key, out CosmosElement value) => this.lazyCache.Value.TryGetValue(key, out value);
public override bool TryGetValue(string key, out CosmosElement value)
{
#pragma warning disable CS8601 // Possible null reference assignment - intentional out parameter assignment
return this.lazyCache.Value.TryGetValue(key, out value);
#pragma warning restore CS8601 // Possible null reference assignment
}

public override void WriteTo(IJsonWriter jsonWriter)
{
Expand Down
22 changes: 16 additions & 6 deletions Microsoft.Azure.Cosmos/src/CosmosElements/CosmosObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,19 +90,24 @@ public bool TryGetValue<TCosmosElement>(string key, out TCosmosElement typedCosm

IEnumerator<KeyValuePair<string, CosmosElement>> IEnumerable<KeyValuePair<string, CosmosElement>>.GetEnumerator() => this.GetEnumerator();

public override bool Equals(CosmosElement cosmosElement)
public override bool Equals(CosmosElement? cosmosElement)
{
return cosmosElement is CosmosObject cosmosObject && this.Equals(cosmosObject);
}

public bool Equals(CosmosObject cosmosObject)
public bool Equals(CosmosObject? cosmosObject)
{
if (cosmosObject is null)
{
return false;
}

if (this.Count != cosmosObject.Count)
{
return false;
}

// Order of properties does not mattter
// Order of properties does not matter
foreach (KeyValuePair<string, CosmosElement> kvp in this)
{
string propertyName = kvp.Key;
Expand Down Expand Up @@ -143,10 +148,15 @@ public override int GetHashCode()
return (int)hash;
}

public int CompareTo(CosmosObject cosmosObject)
public int CompareTo(CosmosObject? cosmosObject)
{
UInt128 hash1 = DistinctHash.GetHash(this);
UInt128 hash2 = DistinctHash.GetHash(cosmosObject);
if (cosmosObject is null)
{
return 1;
}

Microsoft.Azure.Cosmos.UInt128 hash1 = DistinctHash.GetHash(this);
Microsoft.Azure.Cosmos.UInt128 hash2 = DistinctHash.GetHash(cosmosObject);
return UInt128BinaryComparer.Singleton.Compare(hash1, hash2);
}

Expand Down
Loading