Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
5fd212d
rebase hc-tags work from dev (easier to re-branch due to drift)
mgravell Jan 9, 2025
9abc346
detect malformed unicode in tags/keys
mgravell Jan 10, 2025
886a413
avoid try/finally in unicode validation step
mgravell Jan 10, 2025
d8cc8e2
make build happy
mgravell Jan 10, 2025
c3cfd2f
happier
mgravell Jan 10, 2025
1b99172
Merge branch 'main' into marc/hc-tags3
mgravell Jan 28, 2025
0478a5d
Merge branch 'main' into marc/hc-tags3
mgravell Jan 28, 2025
9a5e4dc
normalize and test how per-entry vs global options are inherited
mgravell Jan 28, 2025
5d72360
Merge branch 'marc/hc-tags3' of https://github.com/mgravell/extension…
mgravell Jan 28, 2025
6a278fa
add loggine of rejected data
mgravell Jan 29, 2025
654173b
event log for tag invalidations
mgravell Jan 29, 2025
47a4123
make the CI overlord happy
mgravell Jan 29, 2025
c60048e
rebase hc-tags work from dev (easier to re-branch due to drift)
mgravell Jan 9, 2025
6664698
detect malformed unicode in tags/keys
mgravell Jan 10, 2025
75defc2
avoid try/finally in unicode validation step
mgravell Jan 10, 2025
ba433e5
make build happy
mgravell Jan 10, 2025
138946a
happier
mgravell Jan 10, 2025
f78e41d
normalize and test how per-entry vs global options are inherited
mgravell Jan 28, 2025
466b369
add loggine of rejected data
mgravell Jan 29, 2025
803003f
event log for tag invalidations
mgravell Jan 29, 2025
1b89029
make the CI overlord happy
mgravell Jan 29, 2025
33279db
Merge branch 'marc/hc-tags3' of https://github.com/mgravell/extension…
mgravell Jan 29, 2025
b761e50
add event-source into more tests (proves logging-related code branche…
mgravell Jan 30, 2025
11c7efd
add inbuilt type serializer test
mgravell Jan 30, 2025
16eff9e
add license header
mgravell Jan 30, 2025
437e2fa
improving code coverage
mgravell Jan 30, 2025
a5b816e
incorporate PR feedback re thread-static array
mgravell Jan 30, 2025
e470ef7
make the robots happy
mgravell Jan 30, 2025
a20dc13
Update src/Libraries/Microsoft.Extensions.Caching.Hybrid/Internal/Tag…
mgravell Jan 30, 2025
98dfbd6
tag-based invalidate: pass multiple tags, to ensure code paths
mgravell Jan 30, 2025
8b5155e
Merge branch 'marc/hc-tags3' of https://github.com/mgravell/extension…
mgravell Jan 30, 2025
6c7870b
Merge branch 'main' into marc/hc-tags3
mgravell Feb 3, 2025
07e7a39
more coverage
mgravell Feb 3, 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
Prev Previous commit
Next Next commit
add inbuilt type serializer test
  • Loading branch information
mgravell committed Jan 30, 2025
commit 11c7efde13205893a1310b596bf6ff6c9c060128
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,6 @@ public async Task StampedeJoin()
listener.AssertRemainingCountersZero();
}


[SkippableFact]
public async Task TagInvalidated()
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
using System.Buffers;

Check failure on line 1 in test/Libraries/Microsoft.Extensions.Caching.Hybrid.Tests/SerializerTests.cs

View check run for this annotation

Azure Pipelines / extensions-ci (Correctness WarningsCheck)

test/Libraries/Microsoft.Extensions.Caching.Hybrid.Tests/SerializerTests.cs#L1

test/Libraries/Microsoft.Extensions.Caching.Hybrid.Tests/SerializerTests.cs(1,1): error IDE0073: (NETCORE_ENGINEERING_TELEMETRY=Build) A source file is missing a required header. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0073)

Check failure on line 1 in test/Libraries/Microsoft.Extensions.Caching.Hybrid.Tests/SerializerTests.cs

View check run for this annotation

Azure Pipelines / extensions-ci (Correctness WarningsCheck)

test/Libraries/Microsoft.Extensions.Caching.Hybrid.Tests/SerializerTests.cs#L1

test/Libraries/Microsoft.Extensions.Caching.Hybrid.Tests/SerializerTests.cs(1,1): error IDE0073: (NETCORE_ENGINEERING_TELEMETRY=Build) A source file is missing a required header. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0073)

Check failure on line 1 in test/Libraries/Microsoft.Extensions.Caching.Hybrid.Tests/SerializerTests.cs

View check run for this annotation

Azure Pipelines / extensions-ci (Correctness WarningsCheck)

test/Libraries/Microsoft.Extensions.Caching.Hybrid.Tests/SerializerTests.cs#L1

test/Libraries/Microsoft.Extensions.Caching.Hybrid.Tests/SerializerTests.cs(1,1): error IDE0073: (NETCORE_ENGINEERING_TELEMETRY=Build) A source file is missing a required header. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0073)
using Microsoft.Extensions.Caching.Hybrid.Internal;

namespace Microsoft.Extensions.Caching.Hybrid.Tests;

public class SerializerTests
{
[Fact]
public void RoundTripString()
{
IHybridCacheSerializer<string> serializer = InbuiltTypeSerializer.Instance;

using var target = RecyclableArrayBufferWriter<byte>.Create(int.MaxValue);
serializer.Serialize("test value", target);
Assert.True("test value"u8.SequenceEqual(target.GetCommittedMemory().Span));
Assert.Equal("test value", serializer.Deserialize(target.AsSequence()));

// and deserialize with multi-chunk
Assert.Equal("test value", serializer.Deserialize(Split(target.AsSequence())));
}

[Fact]
public void RoundTripByteArray()
{
IHybridCacheSerializer<byte[]> serializer = InbuiltTypeSerializer.Instance;
var value = "test value"u8.ToArray();
using var target = RecyclableArrayBufferWriter<byte>.Create(int.MaxValue);
serializer.Serialize(value, target);
Assert.True("test value"u8.SequenceEqual(target.GetCommittedMemory().Span));
Assert.Equal(value, serializer.Deserialize(target.AsSequence()));

// and deserialize with multi-chunk
Assert.Equal(value, serializer.Deserialize(Split(target.AsSequence())));
}

private static ReadOnlySequence<byte> Split(ReadOnlySequence<byte> value)
{
// ensure the value is a multi-chunk segment
if (!value.IsSingleSegment || value.Length <= 1)
{
// already multiple chunks, or cannot be split
return value;
}

var chunk = value.First; // actually, single

Segment first = new(chunk.Slice(0, 1), null);
Segment second = new(chunk.Slice(1), first);
var result = new ReadOnlySequence<byte>(first, 0, second, chunk.Length - 1);
Assert.False(result.IsSingleSegment, "should be multi-segment");
return result;
}

private sealed class Segment : ReadOnlySequenceSegment<byte>
{
public Segment(ReadOnlyMemory<byte> memory, Segment? previous)
{
if (previous is not null)
{
RunningIndex = previous.RunningIndex + previous.Memory.Length;
previous.Next = this;
}

Memory = memory;
}
}

}
Loading