From c733aa880478ba45029a4686b62d174bade3ab23 Mon Sep 17 00:00:00 2001 From: Chris Ross Date: Fri, 25 Jul 2014 15:43:38 -0700 Subject: [PATCH] #28 - Use a GZipStream constructor that's supported on Mono. --- .../DataHandler/Serializer/TicketSerializer.cs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/Microsoft.AspNet.Security/DataHandler/Serializer/TicketSerializer.cs b/src/Microsoft.AspNet.Security/DataHandler/Serializer/TicketSerializer.cs index c6dbfc1324..7bfa9a1e6e 100644 --- a/src/Microsoft.AspNet.Security/DataHandler/Serializer/TicketSerializer.cs +++ b/src/Microsoft.AspNet.Security/DataHandler/Serializer/TicketSerializer.cs @@ -13,6 +13,7 @@ namespace Microsoft.AspNet.Security.DataHandler.Serializer { public class TicketSerializer : IDataSerializer { + private static readonly bool IsMono = Type.GetType("Mono.Runtime") != null; private const int FormatVersion = 2; [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2202:Do not dispose objects multiple times", Justification = "Dispose is idempotent")] @@ -20,7 +21,17 @@ namespace Microsoft.AspNet.Security.DataHandler.Serializer { using (var memory = new MemoryStream()) { - using (var compression = new GZipStream(memory, CompressionLevel.Optimal)) + GZipStream compression; + if (IsMono) + { + // The other constructor is not currently supported on Mono. + compression = new GZipStream(memory, CompressionMode.Compress); + } + else + { + compression = new GZipStream(memory, CompressionLevel.Optimal); + } + using (compression) { using (var writer = new BinaryWriter(compression)) {