未验证 提交 ad2c2211 编写于 作者: A Ashish Kumar Singh 提交者: GitHub

Merge pull request #4800 from ThomasGoulet73/analyzers-update

Update FxCop analyzers
...@@ -6,8 +6,7 @@ ...@@ -6,8 +6,7 @@
<ItemGroup Condition="'$(IsTestProject)'!='true' AND '$(EnableAnalyzers)'=='true'"> <ItemGroup Condition="'$(IsTestProject)'!='true' AND '$(EnableAnalyzers)'=='true'">
<!-- Managed Code Reference analyzers --> <!-- Managed Code Reference analyzers -->
<PackageReference Include="Microsoft.DotNet.CodeAnalysis" Version="$(MicrosoftDotNetCodeAnalysisPackageVersion)" /> <PackageReference Include="Microsoft.DotNet.CodeAnalysis" Version="$(MicrosoftDotNetCodeAnalysisPackageVersion)" />
<PackageReference Include="Microsoft.CodeAnalysis.Common" Version="2.9.0" /> <PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="3.3.1" />
<PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="2.6.3" />
<PackageReference Include="System.Runtime.Analyzers" Version="1.1.0" /> <PackageReference Include="System.Runtime.Analyzers" Version="1.1.0" />
<PackageReference Include="System.Runtime.InteropServices.Analyzers" Version="1.1.0" /> <PackageReference Include="System.Runtime.InteropServices.Analyzers" Version="1.1.0" />
</ItemGroup> </ItemGroup>
......
...@@ -106,7 +106,7 @@ internal bool EndsEscapeSequence(char ch) ...@@ -106,7 +106,7 @@ internal bool EndsEscapeSequence(char ch)
internal bool Match(char start, char end) internal bool Match(char start, char end)
{ {
return _endChars.IndexOf(end.ToString()) == _startChars.IndexOf(start.ToString()); return _endChars.IndexOf(end.ToString(), StringComparison.Ordinal) == _startChars.IndexOf(start.ToString(), StringComparison.Ordinal);
} }
internal string StartBracketCharacters internal string StartBracketCharacters
......
...@@ -48,7 +48,7 @@ public string Name ...@@ -48,7 +48,7 @@ public string Name
} }
} }
private string _name = null; private string _name;
} }
#endif #endif
......
...@@ -54,6 +54,6 @@ public string Name ...@@ -54,6 +54,6 @@ public string Name
} }
// The name of the property that is designated to accept the x:Uid value // The name of the property that is designated to accept the x:Uid value
private string _name = null; private string _name;
} }
} }
...@@ -244,6 +244,9 @@ public static ValueSerializer GetSerializerFor(PropertyDescriptor descriptor, IV ...@@ -244,6 +244,9 @@ public static ValueSerializer GetSerializerFor(PropertyDescriptor descriptor, IV
/// </summary> /// </summary>
protected Exception GetConvertToException(object value, Type destinationType) protected Exception GetConvertToException(object value, Type destinationType)
{ {
if (destinationType == null)
throw new ArgumentNullException(nameof(destinationType));
string text; string text;
if (value == null) if (value == null)
{ {
......
...@@ -17,7 +17,7 @@ internal class ObjectWriterContext : XamlContext ...@@ -17,7 +17,7 @@ internal class ObjectWriterContext : XamlContext
{ {
private XamlContextStack<ObjectWriterFrame> _stack; private XamlContextStack<ObjectWriterFrame> _stack;
private object _rootInstance = null; private object _rootInstance;
ServiceProviderContext _serviceProviderContext; ServiceProviderContext _serviceProviderContext;
XamlRuntime _runtime; XamlRuntime _runtime;
......
...@@ -38,7 +38,7 @@ internal IList<XmlNsDefinition> NsDefs ...@@ -38,7 +38,7 @@ internal IList<XmlNsDefinition> NsDefs
} }
// Note this, is the only dictionary that we synchronize, because XamlSchemaContext adds to it // Note this, is the only dictionary that we synchronize, because XamlSchemaContext adds to it
private ConcurrentDictionary<string, IList<string>> _clrToXmlNs = null; private ConcurrentDictionary<string, IList<string>> _clrToXmlNs;
internal ConcurrentDictionary<string, IList<string>> ClrToXmlNs internal ConcurrentDictionary<string, IList<string>> ClrToXmlNs
{ {
get get
...@@ -64,7 +64,7 @@ internal ICollection<AssemblyName> InternalsVisibleTo ...@@ -64,7 +64,7 @@ internal ICollection<AssemblyName> InternalsVisibleTo
} }
} }
private Dictionary<string, string> _oldToNewNs = null; private Dictionary<string, string> _oldToNewNs;
internal Dictionary<string, string> OldToNewNs internal Dictionary<string, string> OldToNewNs
{ {
get get
...@@ -77,7 +77,7 @@ internal ICollection<AssemblyName> InternalsVisibleTo ...@@ -77,7 +77,7 @@ internal ICollection<AssemblyName> InternalsVisibleTo
} }
} }
private Dictionary<string, string> _prefixes = null; private Dictionary<string, string> _prefixes;
internal Dictionary<string, string> Prefixes internal Dictionary<string, string> Prefixes
{ {
get get
...@@ -90,7 +90,7 @@ internal ICollection<AssemblyName> InternalsVisibleTo ...@@ -90,7 +90,7 @@ internal ICollection<AssemblyName> InternalsVisibleTo
} }
} }
private string _rootNamespace = null; private string _rootNamespace;
internal string RootNamespace internal string RootNamespace
{ {
get get
......
...@@ -20,7 +20,7 @@ public NamespacePrefixLookup(out IEnumerable<NamespaceDeclaration> newNamespaces ...@@ -20,7 +20,7 @@ public NamespacePrefixLookup(out IEnumerable<NamespaceDeclaration> newNamespaces
#region INamespacePrefixLookup Members #region INamespacePrefixLookup Members
private int n = 0; private int n;
public string LookupPrefix(string ns) public string LookupPrefix(string ns)
{ {
// we really shouldn't generate extraneous new namespaces // we really shouldn't generate extraneous new namespaces
......
...@@ -33,7 +33,7 @@ class SeenCtorDirectiveFlags ...@@ -33,7 +33,7 @@ class SeenCtorDirectiveFlags
} }
List<SeenCtorDirectiveFlags> _seenStack = new List<SeenCtorDirectiveFlags>(); List<SeenCtorDirectiveFlags> _seenStack = new List<SeenCtorDirectiveFlags>();
int _startObjectDepth = 0; int _startObjectDepth;
List<int> _moveList; List<int> _moveList;
......
...@@ -30,7 +30,7 @@ public XamlName(string prefix, string name) ...@@ -30,7 +30,7 @@ public XamlName(string prefix, string name)
public abstract string ScopedName { get; } public abstract string ScopedName { get; }
protected string _prefix; protected string _prefix;
protected string _namespace = null; protected string _namespace;
public string Prefix { get { return _prefix; } } public string Prefix { get { return _prefix; } }
public string Namespace { get { return _namespace; } } public string Namespace { get { return _namespace; } }
......
...@@ -931,7 +931,7 @@ private XamlNode Logic_StartItemsProperty(XamlType collectionType) ...@@ -931,7 +931,7 @@ private XamlNode Logic_StartItemsProperty(XamlType collectionType)
#region Optimizations #region Optimizations
private readonly XamlTypeName arrayType = new XamlTypeName(@"http://schemas.microsoft.com/winfx/2006/xaml", "Array"); private readonly XamlTypeName arrayType = new XamlTypeName(@"http://schemas.microsoft.com/winfx/2006/xaml", "Array");
private XamlType _arrayExtensionType = null; private XamlType _arrayExtensionType;
private XamlType ArrayExtensionType private XamlType ArrayExtensionType
{ {
get get
...@@ -944,7 +944,7 @@ private XamlType ArrayExtensionType ...@@ -944,7 +944,7 @@ private XamlType ArrayExtensionType
} }
} }
private XamlMember _arrayTypeMember = null; private XamlMember _arrayTypeMember;
private XamlMember ArrayTypeMember private XamlMember ArrayTypeMember
{ {
get get
...@@ -957,7 +957,7 @@ private XamlMember ArrayTypeMember ...@@ -957,7 +957,7 @@ private XamlMember ArrayTypeMember
} }
} }
private XamlMember _itemsTypeMember = null; private XamlMember _itemsTypeMember;
private XamlMember ItemsTypeMember private XamlMember ItemsTypeMember
{ {
get get
......
...@@ -29,14 +29,14 @@ class XamlScanner ...@@ -29,14 +29,14 @@ class XamlScanner
XamlScannerStack _scannerStack; XamlScannerStack _scannerStack;
XamlParserContext _parserContext; XamlParserContext _parserContext;
XamlText _accumulatedText = null; XamlText _accumulatedText;
List<XamlAttribute> _attributes; List<XamlAttribute> _attributes;
int _nextAttribute; int _nextAttribute;
XamlScannerNode _currentNode; XamlScannerNode _currentNode;
Queue<XamlScannerNode> _readNodesQueue; Queue<XamlScannerNode> _readNodesQueue;
XamlXmlReaderSettings _settings; XamlXmlReaderSettings _settings;
XamlAttribute _typeArgumentAttribute; XamlAttribute _typeArgumentAttribute;
bool _hasKeyAttribute = false; bool _hasKeyAttribute;
internal XamlScanner(XamlParserContext context, XmlReader xmlReader, XamlXmlReaderSettings settings) internal XamlScanner(XamlParserContext context, XmlReader xmlReader, XamlXmlReaderSettings settings)
{ {
......
...@@ -29,8 +29,8 @@ public class XamlBackgroundReader : XamlReader, IXamlLineInfo ...@@ -29,8 +29,8 @@ public class XamlBackgroundReader : XamlReader, IXamlLineInfo
XamlWriter _writer; XamlWriter _writer;
bool _wrappedReaderHasLineInfo; bool _wrappedReaderHasLineInfo;
int _lineNumber=0; int _lineNumber;
int _linePosition=0; int _linePosition;
Thread _thread; Thread _thread;
Exception _caughtException; Exception _caughtException;
......
...@@ -16,7 +16,7 @@ namespace System.Xaml ...@@ -16,7 +16,7 @@ namespace System.Xaml
public class XamlNodeList public class XamlNodeList
{ {
List<XamlNode> _nodeList; List<XamlNode> _nodeList;
bool _readMode = false; bool _readMode;
XamlWriter _writer; XamlWriter _writer;
bool _hasLineInfo; bool _hasLineInfo;
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
namespace System.Xaml.Schema namespace System.Xaml.Schema
{ {
[Diagnostics.CodeAnalysis.SuppressMessage("Reliability", "CA2002:Do not lock on objects with weak identity", Justification = "This type is internal.")]
class TypeReflector : Reflector class TypeReflector : Reflector
{ {
private const XamlCollectionKind XamlCollectionKindInvalid = (XamlCollectionKind)byte.MaxValue; private const XamlCollectionKind XamlCollectionKindInvalid = (XamlCollectionKind)byte.MaxValue;
......
...@@ -994,7 +994,7 @@ abstract class ObjectOrValueMarkupInfo : MarkupInfo ...@@ -994,7 +994,7 @@ abstract class ObjectOrValueMarkupInfo : MarkupInfo
class ObjectMarkupInfo : ObjectOrValueMarkupInfo class ObjectMarkupInfo : ObjectOrValueMarkupInfo
{ {
List<MarkupInfo> properties = new List<MarkupInfo>(); List<MarkupInfo> properties = new List<MarkupInfo>();
bool? isAttributableMarkupExtension = null; bool? isAttributableMarkupExtension;
public List<MarkupInfo> Properties { get { return properties; } } public List<MarkupInfo> Properties { get { return properties; } }
public string Name { get; set; } public string Name { get; set; }
......
...@@ -542,6 +542,9 @@ private string GetCompatibleNamespace(string oldNs) ...@@ -542,6 +542,9 @@ private string GetCompatibleNamespace(string oldNs)
public virtual XamlType GetXamlType(Type type) public virtual XamlType GetXamlType(Type type)
{ {
if (type == null)
throw new ArgumentNullException(nameof(type));
return GetXamlType(type, XamlLanguage.TypeAlias(type)); return GetXamlType(type, XamlLanguage.TypeAlias(type));
} }
...@@ -683,7 +686,7 @@ internal virtual XamlMember GetAttachableEvent(string name, MethodInfo adder) ...@@ -683,7 +686,7 @@ internal virtual XamlMember GetAttachableEvent(string name, MethodInfo adder)
#region Settings #region Settings
// Unchanging, initialized in ctor // Unchanging, initialized in ctor
private readonly XamlSchemaContextSettings _settings = null; private readonly XamlSchemaContextSettings _settings;
public bool SupportMarkupExtensionsWithDuplicateArity public bool SupportMarkupExtensionsWithDuplicateArity
{ {
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
namespace System.Xaml namespace System.Xaml
{ {
[Diagnostics.CodeAnalysis.SuppressMessage("Reliability", "CA2000:Dispose objects before losing scope", Justification = "The IDisposable types in this class don't require dispose.")]
public static class XamlServices public static class XamlServices
{ {
// The main function is Load(XamlReader) // The main function is Load(XamlReader)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册