diff --git a/tests/Microsoft.Identity.Web.Test/CacheEncryptionTests.cs b/tests/Microsoft.Identity.Web.Test/CacheEncryptionTests.cs index a92592f15..b54b61bb8 100644 --- a/tests/Microsoft.Identity.Web.Test/CacheEncryptionTests.cs +++ b/tests/Microsoft.Identity.Web.Test/CacheEncryptionTests.cs @@ -79,9 +79,12 @@ private byte[] GetFirstCacheValue(MemoryCache memoryCache) .GetType() .GetField("_coherentState", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic)! .GetValue(memoryCache)!; - memoryCacheContent = (content1? - .GetType() - .GetProperty("EntriesCollection", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic) + Type? content1Type = content1?.GetType(); + // The internals of CoherentState seem to change between .NET 9 RCs + memoryCacheContent = (( + content1Type?.GetProperty("_entries", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic) ?? + content1Type?.GetProperty("_stringEntries", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic) + ) .GetValue(content1) as IDictionary)!; #else memoryCacheContent = (memoryCache