diff --git a/docs/fundamentals/code-analysis/quality-rules/ca1060.md b/docs/fundamentals/code-analysis/quality-rules/ca1060.md
index c45bfa68ddce8..8ea00981d3e64 100644
--- a/docs/fundamentals/code-analysis/quality-rules/ca1060.md
+++ b/docs/fundamentals/code-analysis/quality-rules/ca1060.md
@@ -73,7 +73,7 @@ The following example shows an **Interaction.Beep** method that wraps the **Mess
## SafeNativeMethods example
-P/Invoke methods that can be safely exposed to any application and that do not have any side effects should be put in a class that is named **SafeNativeMethods**. You do not have to demand permissions and you do not have to pay much attention to where they are called from.
+P/Invoke methods that can be safely exposed to any application and that do not have any side effects should be put in a class that is named **SafeNativeMethods**. You do not have to pay much attention to where they are called from.
The following example shows an **Environment.TickCount** property that wraps the **GetTickCount** function from kernel32.dll.
@@ -83,7 +83,7 @@ The following example shows an **Environment.TickCount** property that wraps the
## UnsafeNativeMethods example
-P/Invoke methods that cannot be safely called and that could cause side effects should be put in a class that is named **UnsafeNativeMethods**. These methods should be rigorously checked to make sure that they are not exposed to the user unintentionally. Alternatively, the methods should have another permission that is demanded instead of **UnmanagedCode** when they use them.
+P/Invoke methods that cannot be safely called and that could cause side effects should be put in a class that is named **UnsafeNativeMethods**. These methods should be rigorously checked to make sure that they are not exposed to the user unintentionally.
The following example shows a **Cursor.Hide** method that wraps the **ShowCursor** function from user32.dll.
diff --git a/docs/fundamentals/code-analysis/quality-rules/snippets/csharp/all-rules/.editorconfig b/docs/fundamentals/code-analysis/quality-rules/snippets/csharp/all-rules/.editorconfig
new file mode 100644
index 0000000000000..8b9bc7fe4a78a
--- /dev/null
+++ b/docs/fundamentals/code-analysis/quality-rules/snippets/csharp/all-rules/.editorconfig
@@ -0,0 +1,11 @@
+# All files
+[*]
+
+# CS0659: Type overrides Object.Equals(object o) but does not override Object.GetHashCode()
+dotnet_diagnostic.CS0659.severity = suggestion
+
+# CS0108: Member hides inherited member; missing new keyword
+dotnet_diagnostic.CS0108.severity = suggestion
+
+# CA1822: Mark members as static
+dotnet_diagnostic.CA1822.severity = none
diff --git a/docs/fundamentals/code-analysis/quality-rules/snippets/csharp/all-rules/all-rules.csproj b/docs/fundamentals/code-analysis/quality-rules/snippets/csharp/all-rules/all-rules.csproj
index e0e3dce6a5497..981d7b32c5b18 100644
--- a/docs/fundamentals/code-analysis/quality-rules/snippets/csharp/all-rules/all-rules.csproj
+++ b/docs/fundamentals/code-analysis/quality-rules/snippets/csharp/all-rules/all-rules.csproj
@@ -11,4 +11,8 @@
+
+
+
+
diff --git a/docs/fundamentals/code-analysis/quality-rules/snippets/csharp/all-rules/ca1060.cs b/docs/fundamentals/code-analysis/quality-rules/snippets/csharp/all-rules/ca1060.cs
index bb0e340b29b58..d4018a7e60e34 100644
--- a/docs/fundamentals/code-analysis/quality-rules/snippets/csharp/all-rules/ca1060.cs
+++ b/docs/fundamentals/code-analysis/quality-rules/snippets/csharp/all-rules/ca1060.cs
@@ -62,14 +62,8 @@ internal static class SafeNativeMethods
//
public static class Cursor
{
- // Callers do not require UnmanagedCode permission, however,
- // they do require UIPermissionWindow.AllWindows.
public static void Hide()
{
- // Need to demand an appropriate permission
- // in place of UnmanagedCode permission as
- // ShowCursor is not considered a safe method.
- new UIPermission(UIPermissionWindow.AllWindows).Demand();
UnsafeNativeMethods.ShowCursor(false);
}
}
diff --git a/docs/fundamentals/code-analysis/quality-rules/snippets/csharp/all-rules/ca1802.cs b/docs/fundamentals/code-analysis/quality-rules/snippets/csharp/all-rules/ca1802.cs
index ca6ee7f279f6c..ec498926ac995 100644
--- a/docs/fundamentals/code-analysis/quality-rules/snippets/csharp/all-rules/ca1802.cs
+++ b/docs/fundamentals/code-analysis/quality-rules/snippets/csharp/all-rules/ca1802.cs
@@ -1,4 +1,6 @@
-namespace ca1802
+using System;
+
+namespace ca1802
{
//
// This class violates the rule.
@@ -7,6 +9,11 @@ public class UseReadOnly
static readonly int x = 3;
static readonly double y = x + 2.1;
static readonly string s = "readonly";
+
+ public void Print()
+ {
+ Console.WriteLine(s);
+ }
}
// This class satisfies the rule.
diff --git a/docs/fundamentals/code-analysis/quality-rules/snippets/csharp/all-rules/ca1810.cs b/docs/fundamentals/code-analysis/quality-rules/snippets/csharp/all-rules/ca1810.cs
index d61e6935daf47..13b7b0c9abd94 100644
--- a/docs/fundamentals/code-analysis/quality-rules/snippets/csharp/all-rules/ca1810.cs
+++ b/docs/fundamentals/code-analysis/quality-rules/snippets/csharp/all-rules/ca1810.cs
@@ -1,4 +1,5 @@
-using System.Reflection;
+using System;
+using System.Reflection;
using System.Resources;
namespace ca1810
@@ -16,6 +17,11 @@ static StaticConstructor()
new ResourceManager("strings", Assembly.GetExecutingAssembly());
resourceString = stringManager.GetString("string");
}
+
+ public void Print()
+ {
+ Console.WriteLine(someInteger);
+ }
}
public class NoStaticConstructor
@@ -29,6 +35,11 @@ static string InitializeResourceString()
new ResourceManager("strings", Assembly.GetExecutingAssembly());
return stringManager.GetString("string");
}
+
+ public void Print()
+ {
+ Console.WriteLine(someInteger);
+ }
}
//
}
diff --git a/docs/fundamentals/code-analysis/quality-rules/snippets/csharp/all-rules/ca2109.cs b/docs/fundamentals/code-analysis/quality-rules/snippets/csharp/all-rules/ca2109.cs
index dee2689166e87..8d174b21a76f4 100644
--- a/docs/fundamentals/code-analysis/quality-rules/snippets/csharp/all-rules/ca2109.cs
+++ b/docs/fundamentals/code-analysis/quality-rules/snippets/csharp/all-rules/ca2109.cs
@@ -3,6 +3,7 @@
namespace ca2109
{
+#pragma warning disable SYSLIB0003
//
public class HandleEvents
{
@@ -21,4 +22,5 @@ public static void SomeActionHappened(Object sender, EventArgs e)
}
}
//
+#pragma warning restore SYSLIB0003
}
diff --git a/docs/fundamentals/code-analysis/quality-rules/snippets/csharp/all-rules/ca2229.cs b/docs/fundamentals/code-analysis/quality-rules/snippets/csharp/all-rules/ca2229.cs
index 5a6fe593f20f5..e954566dfba7c 100644
--- a/docs/fundamentals/code-analysis/quality-rules/snippets/csharp/all-rules/ca2229.cs
+++ b/docs/fundamentals/code-analysis/quality-rules/snippets/csharp/all-rules/ca2229.cs
@@ -26,8 +26,6 @@ protected SerializationConstructorsRequired(
}
// The following method serializes the instance.
- [SecurityPermission(SecurityAction.LinkDemand,
- Flags = SecurityPermissionFlag.SerializationFormatter)]
void ISerializable.GetObjectData(SerializationInfo info,
StreamingContext context)
{
diff --git a/docs/fundamentals/code-analysis/quality-rules/snippets/csharp/all-rules/ca2237.cs b/docs/fundamentals/code-analysis/quality-rules/snippets/csharp/all-rules/ca2237.cs
index c8c1db5854b18..4d22fa85f34f0 100644
--- a/docs/fundamentals/code-analysis/quality-rules/snippets/csharp/all-rules/ca2237.cs
+++ b/docs/fundamentals/code-analysis/quality-rules/snippets/csharp/all-rules/ca2237.cs
@@ -20,8 +20,6 @@ protected BaseType(
baseValue = info.GetInt32("baseValue");
}
- [SecurityPermissionAttribute(SecurityAction.Demand,
- SerializationFormatter = true)]
public virtual void GetObjectData(
SerializationInfo info, StreamingContext context)
{
diff --git a/docs/fundamentals/code-analysis/quality-rules/snippets/csharp/all-rules/ca2242.cs b/docs/fundamentals/code-analysis/quality-rules/snippets/csharp/all-rules/ca2242.cs
index 20d549ac6295f..70480e0727350 100644
--- a/docs/fundamentals/code-analysis/quality-rules/snippets/csharp/all-rules/ca2242.cs
+++ b/docs/fundamentals/code-analysis/quality-rules/snippets/csharp/all-rules/ca2242.cs
@@ -5,7 +5,7 @@ namespace ca2242
//
class NaNTests
{
- static double zero;
+ static double zero = 0;
static void Main()
{