Re-emable CA1507 (use nameof) (dotnet/corefx#39731)
authorStephen Toub <stoub@microsoft.com>
Wed, 24 Jul 2019 17:14:01 +0000 (13:14 -0400)
committerGitHub <noreply@github.com>
Wed, 24 Jul 2019 17:14:01 +0000 (13:14 -0400)
Commit migrated from https://github.com/dotnet/corefx/commit/c265373119bc0449d347862862b43de35a95b186

src/libraries/CodeAnalysis.ruleset
src/libraries/System.ComponentModel.TypeConverter/src/MS/Internal/Xml/Linq/ComponentModel/XComponentModel.cs
src/libraries/System.Data.OleDb/src/OleDbException.cs
src/libraries/System.Private.Xml/src/System/Xml/Core/XmlReaderSettings.cs
src/libraries/System.Private.Xml/src/System/Xml/Core/XmlWriterSettings.cs
src/libraries/System.Private.Xml/src/System/Xml/Serialization/CodeIdentifier.cs
src/libraries/System.Text.Json/src/System/Text/Json/Serialization/JsonSerializerOptions.Converters.cs

index 01ddb68..7f7db82 100644 (file)
@@ -32,7 +32,6 @@
     <Rule Id="CA1305" Action="None" /> <!-- Specify IFormatProvider -->
     <Rule Id="CA1307" Action="None" /> <!-- Specify StringComparison -->
     <Rule Id="CA1308" Action="None" /> <!-- Normalize strings to upper case -->
-    <Rule Id="CA1507" Action="None" /> <!-- Use nameof to express symbol names -->
     <Rule Id="CA1707" Action="None" /> <!-- Identifers should not contain underscores -->
     <Rule Id="CA1710" Action="None" /> <!-- Identifers should have correct suffix -->
     <Rule Id="CA1712" Action="None" /> <!-- Do not prefix enum values with type name -->
index 118a432..c55d181 100644 (file)
@@ -501,9 +501,9 @@ namespace MS.Internal.Xml.Linq.ComponentModel
         public XDeferredAxis(Func<XElement, XName, IEnumerable<T>> func, XElement element, XName name)
         {
             if (func == null)
-                throw new ArgumentNullException("func");
+                throw new ArgumentNullException(nameof(func));
             if (element == null)
-                throw new ArgumentNullException("element");
+                throw new ArgumentNullException(nameof(element));
             _func = func;
             this.element = element;
             this.name = name;
@@ -524,7 +524,7 @@ namespace MS.Internal.Xml.Linq.ComponentModel
             get
             {
                 if (expandedName == null)
-                    throw new ArgumentNullException("expandedName");
+                    throw new ArgumentNullException(nameof(expandedName));
                 if (name == null)
                 {
                     name = expandedName;
@@ -547,9 +547,9 @@ namespace MS.Internal.Xml.Linq.ComponentModel
         public XDeferredSingleton(Func<XElement, XName, T> func, XElement element, XName name)
         {
             if (func == null)
-                throw new ArgumentNullException("func");
+                throw new ArgumentNullException(nameof(func));
             if (element == null)
-                throw new ArgumentNullException("element");
+                throw new ArgumentNullException(nameof(element));
             _func = func;
             this.element = element;
             this.name = name;
@@ -560,7 +560,7 @@ namespace MS.Internal.Xml.Linq.ComponentModel
             get
             {
                 if (expandedName == null)
-                    throw new ArgumentNullException("expandedName");
+                    throw new ArgumentNullException(nameof(expandedName));
                 if (name == null)
                 {
                     name = expandedName;
index a7e094f..0611715 100644 (file)
@@ -40,7 +40,7 @@ namespace System.Data.OleDb
         {
             if (null == si)
             {
-                throw new ArgumentNullException("si");
+                throw new ArgumentNullException(nameof(si));
             }
             si.AddValue("oledbErrors", oledbErrors, typeof(OleDbErrorCollection));
             base.GetObjectData(si, context);
index c7e1fb4..f15dc20 100644 (file)
@@ -83,7 +83,7 @@ namespace System.Xml
             }
             set
             {
-                CheckReadOnly("Async");
+                CheckReadOnly(nameof(Async));
                 _useAsync = value;
             }
         }
@@ -97,7 +97,7 @@ namespace System.Xml
             }
             set
             {
-                CheckReadOnly("NameTable");
+                CheckReadOnly(nameof(NameTable));
                 _nameTable = value;
             }
         }
@@ -113,7 +113,7 @@ namespace System.Xml
         {
             set
             {
-                CheckReadOnly("XmlResolver");
+                CheckReadOnly(nameof(XmlResolver));
                 _xmlResolver = value;
                 IsXmlResolverSet = true;
             }
@@ -144,7 +144,7 @@ namespace System.Xml
             }
             set
             {
-                CheckReadOnly("LineNumberOffset");
+                CheckReadOnly(nameof(LineNumberOffset));
                 _lineNumberOffset = value;
             }
         }
@@ -157,7 +157,7 @@ namespace System.Xml
             }
             set
             {
-                CheckReadOnly("LinePositionOffset");
+                CheckReadOnly(nameof(LinePositionOffset));
                 _linePositionOffset = value;
             }
         }
@@ -171,7 +171,7 @@ namespace System.Xml
             }
             set
             {
-                CheckReadOnly("ConformanceLevel");
+                CheckReadOnly(nameof(ConformanceLevel));
 
                 if ((uint)value > (uint)ConformanceLevel.Document)
                 {
@@ -189,7 +189,7 @@ namespace System.Xml
             }
             set
             {
-                CheckReadOnly("CheckCharacters");
+                CheckReadOnly(nameof(CheckCharacters));
                 _checkCharacters = value;
             }
         }
@@ -202,7 +202,7 @@ namespace System.Xml
             }
             set
             {
-                CheckReadOnly("MaxCharactersInDocument");
+                CheckReadOnly(nameof(MaxCharactersInDocument));
                 if (value < 0)
                 {
                     throw new ArgumentOutOfRangeException(nameof(value));
@@ -219,7 +219,7 @@ namespace System.Xml
             }
             set
             {
-                CheckReadOnly("MaxCharactersFromEntities");
+                CheckReadOnly(nameof(MaxCharactersFromEntities));
                 if (value < 0)
                 {
                     throw new ArgumentOutOfRangeException(nameof(value));
@@ -237,7 +237,7 @@ namespace System.Xml
             }
             set
             {
-                CheckReadOnly("IgnoreWhitespace");
+                CheckReadOnly(nameof(IgnoreWhitespace));
                 _ignoreWhitespace = value;
             }
         }
@@ -250,7 +250,7 @@ namespace System.Xml
             }
             set
             {
-                CheckReadOnly("IgnoreProcessingInstructions");
+                CheckReadOnly(nameof(IgnoreProcessingInstructions));
                 _ignorePIs = value;
             }
         }
@@ -263,7 +263,7 @@ namespace System.Xml
             }
             set
             {
-                CheckReadOnly("IgnoreComments");
+                CheckReadOnly(nameof(IgnoreComments));
                 _ignoreComments = value;
             }
         }
@@ -277,7 +277,7 @@ namespace System.Xml
             }
             set
             {
-                CheckReadOnly("ProhibitDtd");
+                CheckReadOnly(nameof(ProhibitDtd));
                 _dtdProcessing = value ? DtdProcessing.Prohibit : DtdProcessing.Parse;
             }
         }
@@ -290,7 +290,7 @@ namespace System.Xml
             }
             set
             {
-                CheckReadOnly("DtdProcessing");
+                CheckReadOnly(nameof(DtdProcessing));
 
                 if ((uint)value > (uint)DtdProcessing.Parse)
                 {
@@ -308,7 +308,7 @@ namespace System.Xml
             }
             set
             {
-                CheckReadOnly("CloseInput");
+                CheckReadOnly(nameof(CloseInput));
                 _closeInput = value;
             }
         }
@@ -321,7 +321,7 @@ namespace System.Xml
             }
             set
             {
-                CheckReadOnly("ValidationType");
+                CheckReadOnly(nameof(ValidationType));
 
                 // This introduces a dependency on the validation readers and along with that
                 // on XmlSchema and so on. For AOT builds this brings in a LOT of code
@@ -345,7 +345,7 @@ namespace System.Xml
             }
             set
             {
-                CheckReadOnly("ValidationFlags");
+                CheckReadOnly(nameof(ValidationFlags));
 
                 if ((uint)value > (uint)(XmlSchemaValidationFlags.ProcessInlineSchema | XmlSchemaValidationFlags.ProcessSchemaLocation |
                                            XmlSchemaValidationFlags.ReportValidationWarnings | XmlSchemaValidationFlags.ProcessIdentityConstraints |
@@ -369,7 +369,7 @@ namespace System.Xml
             }
             set
             {
-                CheckReadOnly("Schemas");
+                CheckReadOnly(nameof(Schemas));
                 _schemas = value;
             }
         }
@@ -378,12 +378,12 @@ namespace System.Xml
         {
             add
             {
-                CheckReadOnly("ValidationEventHandler");
+                CheckReadOnly(nameof(ValidationEventHandler));
                 _valEventHandler += value;
             }
             remove
             {
-                CheckReadOnly("ValidationEventHandler");
+                CheckReadOnly(nameof(ValidationEventHandler));
                 _valEventHandler -= value;
             }
         }
@@ -393,7 +393,7 @@ namespace System.Xml
         //
         public void Reset()
         {
-            CheckReadOnly("Reset");
+            CheckReadOnly(nameof(Reset));
             Initialize();
         }
 
index 7ca70cf..f24fd0f 100644 (file)
@@ -375,7 +375,7 @@ namespace System.Xml
             }
             set
             {
-                CheckReadOnly("DoNotEscapeUriAttributes");
+                CheckReadOnly(nameof(DoNotEscapeUriAttributes));
                 _doNotEscapeUriAttributes = value;
             }
         }
@@ -388,7 +388,7 @@ namespace System.Xml
             }
             set
             {
-                CheckReadOnly("MergeCDataSections");
+                CheckReadOnly(nameof(MergeCDataSections));
                 _mergeCDataSections = value;
             }
         }
@@ -402,7 +402,7 @@ namespace System.Xml
             }
             set
             {
-                CheckReadOnly("MediaType");
+                CheckReadOnly(nameof(MediaType));
                 _mediaType = value;
             }
         }
@@ -416,7 +416,7 @@ namespace System.Xml
             }
             set
             {
-                CheckReadOnly("DocTypeSystem");
+                CheckReadOnly(nameof(DocTypeSystem));
                 _docTypeSystem = value;
             }
         }
@@ -430,7 +430,7 @@ namespace System.Xml
             }
             set
             {
-                CheckReadOnly("DocTypePublic");
+                CheckReadOnly(nameof(DocTypePublic));
                 _docTypePublic = value;
             }
         }
@@ -444,7 +444,7 @@ namespace System.Xml
             }
             set
             {
-                CheckReadOnly("Standalone");
+                CheckReadOnly(nameof(Standalone));
                 _standalone = value;
             }
         }
@@ -458,7 +458,7 @@ namespace System.Xml
             }
             set
             {
-                CheckReadOnly("AutoXmlDeclaration");
+                CheckReadOnly(nameof(AutoXmlDeclaration));
                 _autoXmlDecl = value;
             }
         }
index 81354ba..4b106c3 100644 (file)
@@ -104,7 +104,7 @@ namespace System.Xml.Serialization
             // the given char is already a valid name character
 #if DEBUG
             // use exception in the place of Debug.Assert to avoid throwing asserts from a server process such as aspnet_ewp.exe
-            if (!IsValid(c)) throw new ArgumentException(SR.Format(SR.XmlInternalErrorDetails, "Invalid identifier character " + ((Int16)c).ToString(CultureInfo.InvariantCulture)), "c");
+            if (!IsValid(c)) throw new ArgumentException(SR.Format(SR.XmlInternalErrorDetails, "Invalid identifier character " + ((Int16)c).ToString(CultureInfo.InvariantCulture)), nameof(c));
 #endif
 
             // First char cannot be a number
@@ -155,7 +155,7 @@ namespace System.Xml.Serialization
                 default:
 #if DEBUG
                     // use exception in the place of Debug.Assert to avoid throwing asserts from a server process such as aspnet_ewp.exe
-                    throw new ArgumentException(SR.Format(SR.XmlInternalErrorDetails, "Unhandled category " + uc), "c");
+                    throw new ArgumentException(SR.Format(SR.XmlInternalErrorDetails, "Unhandled category " + uc), nameof(c));
 #else
                 return false;
 #endif
index 12980ec..d059708 100644 (file)
@@ -157,7 +157,7 @@ namespace System.Text.Json
                 converter = factory.GetConverterInternal(typeToConvert, this);
                 if (converter == null || converter.TypeToConvert == null)
                 {
-                    throw new ArgumentNullException("typeToConvert");
+                    throw new ArgumentNullException(nameof(typeToConvert));
                 }
             }