I am using version 2.3.85 of msgpack c#, here is my class:
[MessagePackObject]
sealed public class FastCacheEntries<T>
{
[Key(0)]
public T CacheObject { get; set; }
[Key(1)]
public FastCacheEntryOptions? CacheEntryOptions { get; set; }
}
[MessagePackObject]
public class FastCacheEntryOptions
{
[IgnoreMember]
private TimeSpan? _absoluteExpirationFromNow;
[IgnoreMember]
private TimeSpan? _slidingExpiration;
[Key(0)]
public DateTimeOffset? AbsoluteExpiration { get; set; }
[Key(1)]
public TimeSpan? AbsoluteExpirationFromNow
{
get => _absoluteExpirationFromNow; set
{
// this method does not set AbsoluteExpiration as it would require calling Clock.UtcNow twice:
// once here and once in MemoryCache.SetEntry
if (value <= TimeSpan.Zero)
{
throw new ArgumentOutOfRangeException(
nameof(AbsoluteExpirationFromNow),
value,
"The relative expiration value must be positive.");
}
_absoluteExpirationFromNow = value;
}
}
[Key(2)]
public TimeSpan? SlidingExpiration
{
get => _slidingExpiration; set
{
if (value <= TimeSpan.Zero)
{
throw new ArgumentOutOfRangeException(
nameof(SlidingExpiration),
value,
"The sliding expiration value must be positive.");
}
_slidingExpiration = value;
}
}
[Key(3)]
public double SlidingExpirationInMinutes { get; set; }
[Key(4)]
public ExpirationPolicy? ExpirationPolicy { get; internal set; }
[Key(5)]
public DateTimeOffset? LastAccessTime { get; set; }
//[SerializationConstructor]
//public FastCacheEntryOptions(DateTimeOffset? absoluteExpiration = null, TimeSpan? slidingExpiration = null,TimeSpan? absoluteExpirationFromNow=null)
//{
// this.AbsoluteExpiration = absoluteExpiration;
// this._slidingExpiration = slidingExpiration;
// this._absoluteExpirationFromNow = absoluteExpirationFromNow;
//}
}
public enum ExpirationPolicy : int
{
Sliding,
Absolute,
AbsoluteByTimeSpan,
NeverExpire
}
I get no error on serialization, on deserialization all other values come fine but enum value is never grabbed. It's either default (in case of non null enum) or null in case of nullable.
i am using MessagePackSerializerOptions.Standard.WithCompression(MessagePackCompression.Lz4BlockArray) in MessagePack Settings.
I am using version 2.3.85 of msgpack c#, here is my class:
I get no error on serialization, on deserialization all other values come fine but enum value is never grabbed. It's either default (in case of non null enum) or null in case of nullable.
i am using
MessagePackSerializerOptions.Standard.WithCompression(MessagePackCompression.Lz4BlockArray)
in MessagePack Settings.