From 817149b959db05e09fe9892615b3f23e6dc31750 Mon Sep 17 00:00:00 2001 From: WhiteBlackGoose Date: Mon, 26 Jul 2021 12:36:36 +0300 Subject: [PATCH 1/3] Names -> Keywords Replacing full type names with keywords when appropriate Files affected: Anon.cs, Delegate.cs, Lambda.cs, createinstance2.cs, CreateInstance5.cs, Example4.cs, Example6.cs, Example8.cs, ForConsumers1.cs, GetSwitches3.cs. See #6920 --- .../System.AppContext.Class/cs/Example4.cs | 8 ++++---- .../System.AppContext.Class/cs/Example6.cs | 8 ++++---- .../System.AppContext.Class/cs/Example8.cs | 8 ++++---- .../System.AppContext.Class/cs/ForConsumers1.cs | 8 ++++---- .../System.AppContext.Class/cs/GetSwitches3.cs | 10 +++++----- .../VS_Snippets_CLR_System/system.Action~4/cs/Anon.cs | 6 +++--- .../system.Action~4/cs/Delegate.cs | 6 +++--- .../system.Action~4/cs/Lambda.cs | 6 +++--- .../cs/CreateInstance5.cs | 4 ++-- .../cs/createinstance2.cs | 10 +++++----- 10 files changed, 37 insertions(+), 37 deletions(-) diff --git a/samples/snippets/csharp/VS_Snippets_CLR_System/System.AppContext.Class/cs/Example4.cs b/samples/snippets/csharp/VS_Snippets_CLR_System/System.AppContext.Class/cs/Example4.cs index e16fba3b54a..d255cb4f46a 100644 --- a/samples/snippets/csharp/VS_Snippets_CLR_System/System.AppContext.Class/cs/Example4.cs +++ b/samples/snippets/csharp/VS_Snippets_CLR_System/System.AppContext.Class/cs/Example4.cs @@ -1,4 +1,4 @@ -// +// using System; using System.Reflection; @@ -6,7 +6,7 @@ public static class StringLibrary { - public static int SubstringStartsAt(String fullString, String substr) + public static int SubstringStartsAt(string fullString, string substr) { return fullString.IndexOf(substr, StringComparison.Ordinal); } @@ -22,8 +22,8 @@ public class Example { public static void Main() { - String value = "The archaeologist"; - String substring = "archæ"; + string value = "The archaeologist"; + string substring = "archæ"; int position = StringLibrary.SubstringStartsAt(value, substring); if (position >= 0) Console.WriteLine("'{0}' found in '{1}' starting at position {2}", diff --git a/samples/snippets/csharp/VS_Snippets_CLR_System/System.AppContext.Class/cs/Example6.cs b/samples/snippets/csharp/VS_Snippets_CLR_System/System.AppContext.Class/cs/Example6.cs index f0c64705475..a700387b555 100644 --- a/samples/snippets/csharp/VS_Snippets_CLR_System/System.AppContext.Class/cs/Example6.cs +++ b/samples/snippets/csharp/VS_Snippets_CLR_System/System.AppContext.Class/cs/Example6.cs @@ -1,4 +1,4 @@ -// +// using System; using System.Reflection; @@ -6,7 +6,7 @@ public static class StringLibrary { - public static int SubstringStartsAt(String fullString, String substr) + public static int SubstringStartsAt(string fullString, string substr) { return fullString.IndexOf(substr, StringComparison.CurrentCulture); } @@ -22,8 +22,8 @@ public class Example { public static void Main() { - String value = "The archaeologist"; - String substring = "archæ"; + string value = "The archaeologist"; + string substring = "archæ"; int position = StringLibrary.SubstringStartsAt(value, substring); if (position >= 0) Console.WriteLine("'{0}' found in '{1}' starting at position {2}", diff --git a/samples/snippets/csharp/VS_Snippets_CLR_System/System.AppContext.Class/cs/Example8.cs b/samples/snippets/csharp/VS_Snippets_CLR_System/System.AppContext.Class/cs/Example8.cs index ef5baf9cbf8..6957d93be49 100644 --- a/samples/snippets/csharp/VS_Snippets_CLR_System/System.AppContext.Class/cs/Example8.cs +++ b/samples/snippets/csharp/VS_Snippets_CLR_System/System.AppContext.Class/cs/Example8.cs @@ -1,4 +1,4 @@ -// +// using System; using System.Reflection; @@ -6,7 +6,7 @@ public static class StringLibrary { - public static int SubstringStartsAt(String fullString, String substr) + public static int SubstringStartsAt(string fullString, string substr) { bool flag; if (AppContext.TryGetSwitch("StringLibrary.DoNotUseCultureSensitiveComparison", out flag) && flag == true) @@ -26,8 +26,8 @@ public class Example { public static void Main() { - String value = "The archaeologist"; - String substring = "archæ"; + string value = "The archaeologist"; + string substring = "archæ"; int position = StringLibrary.SubstringStartsAt(value, substring); if (position >= 0) Console.WriteLine("'{0}' found in '{1}' starting at position {2}", diff --git a/samples/snippets/csharp/VS_Snippets_CLR_System/System.AppContext.Class/cs/ForConsumers1.cs b/samples/snippets/csharp/VS_Snippets_CLR_System/System.AppContext.Class/cs/ForConsumers1.cs index 81080c51812..97b2fcaee75 100644 --- a/samples/snippets/csharp/VS_Snippets_CLR_System/System.AppContext.Class/cs/ForConsumers1.cs +++ b/samples/snippets/csharp/VS_Snippets_CLR_System/System.AppContext.Class/cs/ForConsumers1.cs @@ -1,4 +1,4 @@ -// +// using System; using System.IO; using System.Runtime.Versioning; @@ -14,8 +14,8 @@ public static void Main() } // The example displays the following output: // Unhandled Exception: System.ArgumentException: The path is not of a legal form. -// at System.IO.Path.NewNormalizePathLimitedChecks(String path, Int32 maxPathLength, Boolean expandShortPaths) -// at System.IO.Path.NormalizePath(String path, Boolean fullCheck, Int32 maxPathLength, Boolean expandShortPaths) -// at System.IO.Path.InternalGetDirectoryName(String path) +// at System.IO.Path.NewNormalizePathLimitedChecks(string path, int maxPathLength, Boolean expandShortPaths) +// at System.IO.Path.NormalizePath(string path, Boolean fullCheck, int maxPathLength, Boolean expandShortPaths) +// at System.IO.Path.InternalGetDirectoryName(string path) // at Example.Main() // diff --git a/samples/snippets/csharp/VS_Snippets_CLR_System/System.AppContext.Class/cs/GetSwitches3.cs b/samples/snippets/csharp/VS_Snippets_CLR_System/System.AppContext.Class/cs/GetSwitches3.cs index d73939bed61..078dc0f3c70 100644 --- a/samples/snippets/csharp/VS_Snippets_CLR_System/System.AppContext.Class/cs/GetSwitches3.cs +++ b/samples/snippets/csharp/VS_Snippets_CLR_System/System.AppContext.Class/cs/GetSwitches3.cs @@ -1,4 +1,4 @@ -// +// using System; using System.Configuration; using System.Globalization; @@ -6,8 +6,8 @@ public class Example { - private const String SettingName = "AppContextSwitchOverrides"; - private const String SwitchName = "Switch.Application.Utilities.SwitchName"; + private const string SettingName = "AppContextSwitchOverrides"; + private const string SwitchName = "Switch.Application.Utilities.SwitchName"; public static void Main() { @@ -22,8 +22,8 @@ public static void Main() ConfigurationSection sec = config.GetSection("runtime"); if (sec != null) { - String rawXml = sec.SectionInformation.GetRawXml(); - if (String.IsNullOrEmpty(rawXml)) return; + string rawXml = sec.SectionInformation.GetRawXml(); + if (string.IsNullOrEmpty(rawXml)) return; var doc = new XmlDocument(); doc.LoadXml(rawXml); diff --git a/samples/snippets/csharp/VS_Snippets_CLR_System/system.Action~4/cs/Anon.cs b/samples/snippets/csharp/VS_Snippets_CLR_System/system.Action~4/cs/Anon.cs index ceb409cae27..7510d86ac08 100644 --- a/samples/snippets/csharp/VS_Snippets_CLR_System/system.Action~4/cs/Anon.cs +++ b/samples/snippets/csharp/VS_Snippets_CLR_System/system.Action~4/cs/Anon.cs @@ -1,4 +1,4 @@ -// +// using System; public class TestAnonymousMethod @@ -14,7 +14,7 @@ public static void Main() { CopyStrings(s1, s2, pos, num); }; copyOperation(ordinals, copiedOrdinals, 3, 5); foreach (string ordinal in copiedOrdinals) - Console.WriteLine(String.IsNullOrEmpty(ordinal) ? "" : ordinal); + Console.WriteLine(string.IsNullOrEmpty(ordinal) ? "" : ordinal); } private static void CopyStrings(string[] source, string[] target, @@ -24,7 +24,7 @@ private static void CopyStrings(string[] source, string[] target, throw new IndexOutOfRangeException("The source and target arrays must have the same number of elements."); for (int ctr = startPos; ctr <= startPos + number - 1; ctr++) - target[ctr] = String.Copy(source[ctr]); + target[ctr] = string.Copy(source[ctr]); } } // diff --git a/samples/snippets/csharp/VS_Snippets_CLR_System/system.Action~4/cs/Delegate.cs b/samples/snippets/csharp/VS_Snippets_CLR_System/system.Action~4/cs/Delegate.cs index 363816a88b3..9b4457654a3 100644 --- a/samples/snippets/csharp/VS_Snippets_CLR_System/system.Action~4/cs/Delegate.cs +++ b/samples/snippets/csharp/VS_Snippets_CLR_System/system.Action~4/cs/Delegate.cs @@ -1,4 +1,4 @@ -// +// using System; delegate void StringCopy(string[] stringArray1, @@ -16,7 +16,7 @@ public static void Main() StringCopy copyOperation = CopyStrings; copyOperation(ordinals, copiedOrdinals, 3, 5); foreach (string ordinal in copiedOrdinals) - Console.WriteLine(String.IsNullOrEmpty(ordinal) ? "" : ordinal); + Console.WriteLine(string.IsNullOrEmpty(ordinal) ? "" : ordinal); } private static void CopyStrings(string[] source, string[] target, @@ -26,7 +26,7 @@ private static void CopyStrings(string[] source, string[] target, throw new IndexOutOfRangeException("The source and target arrays must have the same number of elements."); for (int ctr = startPos; ctr <= startPos + number - 1; ctr++) - target[ctr] = String.Copy(source[ctr]); + target[ctr] = string.Copy(source[ctr]); } } // diff --git a/samples/snippets/csharp/VS_Snippets_CLR_System/system.Action~4/cs/Lambda.cs b/samples/snippets/csharp/VS_Snippets_CLR_System/system.Action~4/cs/Lambda.cs index 5d6f4acb72c..be73186c1b7 100644 --- a/samples/snippets/csharp/VS_Snippets_CLR_System/system.Action~4/cs/Lambda.cs +++ b/samples/snippets/csharp/VS_Snippets_CLR_System/system.Action~4/cs/Lambda.cs @@ -1,4 +1,4 @@ -// +// using System; public class TestLambdaExpression @@ -12,7 +12,7 @@ public static void Main() => CopyStrings(s1, s2, pos, num); copyOperation(ordinals, copiedOrdinals, 3, 5); foreach (string ordinal in copiedOrdinals) - Console.WriteLine(String.IsNullOrEmpty(ordinal) ? "" : ordinal); + Console.WriteLine(string.IsNullOrEmpty(ordinal) ? "" : ordinal); } private static void CopyStrings(string[] source, string[] target, @@ -22,7 +22,7 @@ private static void CopyStrings(string[] source, string[] target, throw new IndexOutOfRangeException("The source and target arrays must have the same number of elements."); for (int ctr = startPos; ctr <= startPos + number - 1; ctr++) - target[ctr] = String.Copy(source[ctr]); + target[ctr] = string.Copy(source[ctr]); } } // diff --git a/samples/snippets/csharp/VS_Snippets_CLR_System/system.activator.createinstance/cs/CreateInstance5.cs b/samples/snippets/csharp/VS_Snippets_CLR_System/system.activator.createinstance/cs/CreateInstance5.cs index 2b55ed2e9f1..40adf798e8a 100644 --- a/samples/snippets/csharp/VS_Snippets_CLR_System/system.activator.createinstance/cs/CreateInstance5.cs +++ b/samples/snippets/csharp/VS_Snippets_CLR_System/system.activator.createinstance/cs/CreateInstance5.cs @@ -1,4 +1,4 @@ -// +// using System; public class Example @@ -10,7 +10,7 @@ public static void Main() for (int ctr = 0; ctr < 26; ctr++) chars[ctr] = (char) (ctr + 0x0061); - Object obj = Activator.CreateInstance(typeof(String), + Object obj = Activator.CreateInstance(typeof(string), new Object[] { chars, 13, 10 } ); Console.WriteLine(obj); } diff --git a/samples/snippets/csharp/VS_Snippets_CLR_System/system.activator.createinstance/cs/createinstance2.cs b/samples/snippets/csharp/VS_Snippets_CLR_System/system.activator.createinstance/cs/createinstance2.cs index 58e2224a889..61c3000a4fe 100644 --- a/samples/snippets/csharp/VS_Snippets_CLR_System/system.activator.createinstance/cs/createinstance2.cs +++ b/samples/snippets/csharp/VS_Snippets_CLR_System/system.activator.createinstance/cs/createinstance2.cs @@ -1,4 +1,4 @@ -// +// using System; public class Example @@ -12,13 +12,13 @@ public static void Main() for (int ctr = 0; ctr <= arguments.GetUpperBound(0); ctr++) { object[] args = arguments[ctr]; - object result = Activator.CreateInstance(typeof(String), args); + object result = Activator.CreateInstance(typeof(string), args); Console.WriteLine("{0}: {1}", result.GetType().Name, result); } } } // The example displays the following output: -// String: abcdef -// String: bcde -// String: bbbbbbbbbbbbbbbbbbbb +// string: abcdef +// string: bcde +// string: bbbbbbbbbbbbbbbbbbbb // \ No newline at end of file From 0cdf485066627f1362ac754e8abb50bee1e304ea Mon Sep 17 00:00:00 2001 From: WhiteBlackGoose Date: Mon, 26 Jul 2021 13:08:10 +0300 Subject: [PATCH 2/3] An example reverted --- .../System.AppContext.Class/cs/ForConsumers1.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/samples/snippets/csharp/VS_Snippets_CLR_System/System.AppContext.Class/cs/ForConsumers1.cs b/samples/snippets/csharp/VS_Snippets_CLR_System/System.AppContext.Class/cs/ForConsumers1.cs index 97b2fcaee75..674ea0d4438 100644 --- a/samples/snippets/csharp/VS_Snippets_CLR_System/System.AppContext.Class/cs/ForConsumers1.cs +++ b/samples/snippets/csharp/VS_Snippets_CLR_System/System.AppContext.Class/cs/ForConsumers1.cs @@ -14,8 +14,8 @@ public static void Main() } // The example displays the following output: // Unhandled Exception: System.ArgumentException: The path is not of a legal form. -// at System.IO.Path.NewNormalizePathLimitedChecks(string path, int maxPathLength, Boolean expandShortPaths) -// at System.IO.Path.NormalizePath(string path, Boolean fullCheck, int maxPathLength, Boolean expandShortPaths) -// at System.IO.Path.InternalGetDirectoryName(string path) +// at System.IO.Path.NewNormalizePathLimitedChecks(String path, Int32 maxPathLength, Boolean expandShortPaths) +// at System.IO.Path.NormalizePath(String path, Boolean fullCheck, Int32 maxPathLength, Boolean expandShortPaths) +// at System.IO.Path.InternalGetDirectoryName(String path) // at Example.Main() // From 2da65d3c58efa5bc274782c7ccc78f5d478af126 Mon Sep 17 00:00:00 2001 From: WhiteBlackGoose Date: Mon, 26 Jul 2021 13:08:34 +0300 Subject: [PATCH 3/3] An example reverted --- .../system.activator.createinstance/cs/createinstance2.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/samples/snippets/csharp/VS_Snippets_CLR_System/system.activator.createinstance/cs/createinstance2.cs b/samples/snippets/csharp/VS_Snippets_CLR_System/system.activator.createinstance/cs/createinstance2.cs index 61c3000a4fe..dae5e35ea63 100644 --- a/samples/snippets/csharp/VS_Snippets_CLR_System/system.activator.createinstance/cs/createinstance2.cs +++ b/samples/snippets/csharp/VS_Snippets_CLR_System/system.activator.createinstance/cs/createinstance2.cs @@ -18,7 +18,7 @@ public static void Main() } } // The example displays the following output: -// string: abcdef -// string: bcde -// string: bbbbbbbbbbbbbbbbbbbb -// \ No newline at end of file +// String: abcdef +// String: bcde +// String: bbbbbbbbbbbbbbbbbbbb +//