未验证 提交 cea383ed 编写于 作者: S Sam Harwell 提交者: GitHub

Merge pull request #35482 from sharwell/mark-serializable

Fix violations of CA2237 (Mark ISerializable types with serializable)
...@@ -14,6 +14,7 @@ namespace Microsoft.VisualStudio.Debugger ...@@ -14,6 +14,7 @@ namespace Microsoft.VisualStudio.Debugger
// Summary: // Summary:
// Base exception class for all exceptions within this API. // Base exception class for all exceptions within this API.
[DebuggerDisplay("\\{DkmException Code={Code,h}\\}")] [DebuggerDisplay("\\{DkmException Code={Code,h}\\}")]
[Serializable]
public class DkmException : ApplicationException public class DkmException : ApplicationException
{ {
private readonly DkmExceptionCode _code; private readonly DkmExceptionCode _code;
......
...@@ -2,13 +2,16 @@ ...@@ -2,13 +2,16 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Runtime.Serialization;
using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis;
using static Roslyn.Test.Utilities.ExceptionHelper; using static Roslyn.Test.Utilities.ExceptionHelper;
namespace Roslyn.Test.Utilities namespace Roslyn.Test.Utilities
{ {
[Serializable]
public class EmitException : Exception public class EmitException : Exception
{ {
[field: NonSerialized]
public IEnumerable<Diagnostic> Diagnostics { get; } public IEnumerable<Diagnostic> Diagnostics { get; }
public EmitException(IEnumerable<Diagnostic> diagnostics, string directory) public EmitException(IEnumerable<Diagnostic> diagnostics, string directory)
...@@ -16,8 +19,14 @@ public EmitException(IEnumerable<Diagnostic> diagnostics, string directory) ...@@ -16,8 +19,14 @@ public EmitException(IEnumerable<Diagnostic> diagnostics, string directory)
{ {
this.Diagnostics = diagnostics; this.Diagnostics = diagnostics;
} }
protected EmitException(SerializationInfo serializationInfo, StreamingContext streamingContext)
{
throw new NotImplementedException();
}
} }
[Serializable]
public class ExecutionException : Exception public class ExecutionException : Exception
{ {
public ExecutionException(string expectedOutput, string actualOutput, string exePath) public ExecutionException(string expectedOutput, string actualOutput, string exePath)
...@@ -25,5 +34,10 @@ public ExecutionException(string expectedOutput, string actualOutput, string exe ...@@ -25,5 +34,10 @@ public ExecutionException(string expectedOutput, string actualOutput, string exe
public ExecutionException(Exception innerException, string exePath) public ExecutionException(Exception innerException, string exePath)
: base(GetMessageFromException(innerException, exePath), innerException) { } : base(GetMessageFromException(innerException, exePath), innerException) { }
protected ExecutionException(SerializationInfo serializationInfo, StreamingContext streamingContext)
{
throw new NotImplementedException();
}
} }
} }
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
using System.Linq; using System.Linq;
using System.Reflection; using System.Reflection;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
using System.Runtime.Serialization;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.CodeAnalysis.Diagnostics; using Microsoft.CodeAnalysis.Diagnostics;
...@@ -17,8 +18,18 @@ namespace Microsoft.CodeAnalysis.Test.Utilities ...@@ -17,8 +18,18 @@ namespace Microsoft.CodeAnalysis.Test.Utilities
{ {
public class ThrowingDiagnosticAnalyzer<TLanguageKindEnum> : TestDiagnosticAnalyzer<TLanguageKindEnum> where TLanguageKindEnum : struct public class ThrowingDiagnosticAnalyzer<TLanguageKindEnum> : TestDiagnosticAnalyzer<TLanguageKindEnum> where TLanguageKindEnum : struct
{ {
[Serializable]
public class DeliberateException : Exception public class DeliberateException : Exception
{ {
public DeliberateException()
{
}
protected DeliberateException(SerializationInfo serializationInfo, StreamingContext streamingContext)
{
throw new NotImplementedException();
}
public override string Message public override string Message
{ {
get { return "If this goes unhandled, our diagnostics engine is susceptible to malicious analyzers"; } get { return "If this goes unhandled, our diagnostics engine is susceptible to malicious analyzers"; }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册