瀏覽代碼

Fix net45 tests

James Newton-King 5 年之前
父節點
當前提交
18bfd9e2e5

+ 1 - 0
csharp/src/Google.Protobuf/CodedInputStream.cs

@@ -54,6 +54,7 @@ namespace Google.Protobuf
     /// and <see cref="MapField{TKey, TValue}"/> to serialize such fields.
     /// </para>
     /// </remarks>
+    [SecuritySafeCritical]
     public sealed class CodedInputStream : IDisposable
     {
         /// <summary>

+ 3 - 0
csharp/src/Google.Protobuf/Collections/MapField.cs

@@ -38,6 +38,7 @@ using System.Collections;
 using System.Collections.Generic;
 using System.IO;
 using System.Linq;
+using System.Security;
 
 namespace Google.Protobuf.Collections
 {
@@ -442,6 +443,7 @@ namespace Google.Protobuf.Collections
         /// </remarks>
         /// <param name="ctx">Input to read from</param>
         /// <param name="codec">Codec describing how the key/value pairs are encoded</param>
+        [SecuritySafeCritical]
         public void AddEntriesFrom(ref ParseContext ctx, Codec codec)
         {
             // TODO: deduplicate code?
@@ -689,6 +691,7 @@ namespace Google.Protobuf.Collections
                     }
                 }
 
+                [SecuritySafeCritical]
                 public void MergeFrom_Internal(ref ParseContext ctx)
                 {
                     // TODO(jtattermusch): deduplicate code

+ 2 - 0
csharp/src/Google.Protobuf/Collections/RepeatedField.cs

@@ -34,6 +34,7 @@ using System;
 using System.Collections;
 using System.Collections.Generic;
 using System.IO;
+using System.Security;
 
 namespace Google.Protobuf.Collections
 {
@@ -111,6 +112,7 @@ namespace Google.Protobuf.Collections
         /// </summary>
         /// <param name="ctx">The input to read from.</param>
         /// <param name="codec">The codec to use in order to read each entry.</param>
+        [SecuritySafeCritical]
         public void AddEntriesFrom(ref ParseContext ctx, FieldCodec<T> codec)
         {
             // TODO: Inline some of the Add code, so we can avoid checking the size on every

+ 2 - 0
csharp/src/Google.Protobuf/FieldCodec.cs

@@ -35,6 +35,7 @@ using Google.Protobuf.Compatibility;
 using Google.Protobuf.WellKnownTypes;
 using System;
 using System.Collections.Generic;
+using System.Security;
 
 namespace Google.Protobuf
 {
@@ -614,6 +615,7 @@ namespace Google.Protobuf
                 return value;
             }
 
+            [SecuritySafeCritical]
             internal static T Read<T>(ref ParseContext ctx, FieldCodec<T> codec)
             {
                 int length = ctx.ReadLength();

+ 4 - 1
csharp/src/Google.Protobuf/ParsingPrimitives.cs

@@ -46,6 +46,7 @@ namespace Google.Protobuf
     /// <summary>
     /// Primitives for parsing protobuf wire format.
     /// </summary>
+    [SecuritySafeCritical]
     internal static class ParsingPrimitives
     {
 
@@ -595,6 +596,7 @@ namespace Google.Protobuf
         /// <exception cref="InvalidProtocolBufferException">
         /// the end of the stream or the current limit was reached
         /// </exception>
+        [SecuritySafeCritical]
         public static string ReadRawString(ref ReadOnlySpan<byte> buffer, ref ParserInternalState state, int length)
         {
             // No need to read any data for an empty string.
@@ -643,7 +645,8 @@ namespace Google.Protobuf
             // Slow path: Build a byte array first then copy it.
             return CodedOutputStream.Utf8Encoding.GetString(ReadRawBytes(ref buffer, ref state, length), 0, length);
         }
-        
+
+        [SecuritySafeCritical]
         private static byte ReadRawByte(ref ReadOnlySpan<byte> buffer, ref ParserInternalState state)
         {
             if (state.bufferPos == state.bufferSize)

+ 2 - 0
csharp/src/Google.Protobuf/ParsingPrimitivesMessages.cs

@@ -34,12 +34,14 @@ using System;
 using System.Buffers;
 using System.IO;
 using System.Runtime.CompilerServices;
+using System.Security;
 
 namespace Google.Protobuf
 {
     /// <summary>
     /// Reading and skipping messages / groups
     /// </summary>
+    [SecuritySafeCritical]
     internal static class ParsingPrimitivesMessages
     {
         public static void SkipLastField(ref ReadOnlySpan<byte> buffer, ref ParserInternalState state)

+ 1 - 0
csharp/src/Google.Protobuf/ParsingPrimitivesWrappers.cs

@@ -46,6 +46,7 @@ namespace Google.Protobuf
     /// <summary>
     /// Fast parsing primitives for wrapper types
     /// </summary>
+    [SecuritySafeCritical]
     internal static class ParsingPrimitivesWrappers
     {
         internal static float? ReadFloatWrapperLittleEndian(ref ReadOnlySpan<byte> buffer, ref ParserInternalState state)

+ 2 - 0
csharp/src/Google.Protobuf/SegmentedBufferHelper.cs

@@ -34,6 +34,7 @@ using System;
 using System.Buffers;
 using System.IO;
 using System.Runtime.CompilerServices;
+using System.Security;
 
 namespace Google.Protobuf
 {
@@ -41,6 +42,7 @@ namespace Google.Protobuf
     /// Abstraction for reading from a stream / read only sequence.
     /// Parsing from the buffer is a loop of reading from current buffer / refreshing the buffer once done.
     /// </summary>
+    [SecuritySafeCritical]
     internal struct SegmentedBufferHelper
     {
         private int? totalLength;

+ 2 - 0
csharp/src/Google.Protobuf/UnknownFieldSet.cs

@@ -33,6 +33,7 @@
 using System;
 using System.Collections.Generic;
 using System.IO;
+using System.Security;
 using Google.Protobuf.Reflection;
 
 namespace Google.Protobuf
@@ -278,6 +279,7 @@ namespace Google.Protobuf
         /// <param name="unknownFields">The UnknownFieldSet which need to be merged</param>
         /// <param name="ctx">The parse context from which to read the field</param>
         /// <returns>The merged UnknownFieldSet</returns>
+        [SecuritySafeCritical]
         public static UnknownFieldSet MergeFieldFrom(UnknownFieldSet unknownFields,
                                                      ref ParseContext ctx)
         {