diff --git a/ICSharpCode.NRefactory.CSharp/Ast/AstNode.cs b/ICSharpCode.NRefactory.CSharp/Ast/AstNode.cs index cca4d85391..6009843d36 100644 --- a/ICSharpCode.NRefactory.CSharp/Ast/AstNode.cs +++ b/ICSharpCode.NRefactory.CSharp/Ast/AstNode.cs @@ -471,9 +471,7 @@ namespace ICSharpCode.NRefactory.CSharp } // Finally, clone the annotation, if necessary - ICloneable copiedAnnotations = copy.annotations as ICloneable; // read from copy (for thread-safety) - if (copiedAnnotations != null) - copy.annotations = copiedAnnotations.Clone(); + copy.CloneAnnotations(); return copy; } diff --git a/ICSharpCode.NRefactory.CSharp/Formatter/AstFormattingVisitor.cs b/ICSharpCode.NRefactory.CSharp/Formatter/AstFormattingVisitor.cs index 973e3e1c52..b5d5bd9413 100644 --- a/ICSharpCode.NRefactory.CSharp/Formatter/AstFormattingVisitor.cs +++ b/ICSharpCode.NRefactory.CSharp/Formatter/AstFormattingVisitor.cs @@ -704,7 +704,6 @@ namespace ICSharpCode.NRefactory.CSharp } FormatCommas (constructorDeclaration, policy.SpaceBeforeConstructorDeclarationParameterComma, policy.SpaceAfterConstructorDeclarationParameterComma); - object result = null; if (!constructorDeclaration.Body.IsNull) { EnforceBraceStyle (policy.ConstructorBraceStyle, constructorDeclaration.Body.LBraceToken, constructorDeclaration.Body.RBraceToken); if (policy.IndentMethodBody) @@ -725,7 +724,6 @@ namespace ICSharpCode.NRefactory.CSharp int offset = this.document.GetOffset (lParen.StartLocation); ForceSpaceBefore (offset, policy.SpaceBeforeConstructorDeclarationParentheses); - object result = null; if (!destructorDeclaration.Body.IsNull) { EnforceBraceStyle (policy.DestructorBraceStyle, destructorDeclaration.Body.LBraceToken, destructorDeclaration.Body.RBraceToken); if (policy.IndentMethodBody) diff --git a/ICSharpCode.NRefactory.CSharp/OutputVisitor/CSharpAmbience.cs b/ICSharpCode.NRefactory.CSharp/OutputVisitor/CSharpAmbience.cs index 4aa7287be3..1ba221d934 100644 --- a/ICSharpCode.NRefactory.CSharp/OutputVisitor/CSharpAmbience.cs +++ b/ICSharpCode.NRefactory.CSharp/OutputVisitor/CSharpAmbience.cs @@ -55,7 +55,7 @@ namespace ICSharpCode.NRefactory.CSharp EntityDeclaration node = astBuilder.ConvertEntity(entity); PrintModifiers(node.Modifiers, formatter); - if ((ConversionFlags & ConversionFlags.ShowDefinitionKeyWord) == ConversionFlags.ShowDefinitionKeyWord) { + if ((ConversionFlags & ConversionFlags.ShowDefinitionKeyword) == ConversionFlags.ShowDefinitionKeyword) { if (node is TypeDeclaration) { switch (((TypeDeclaration)node).ClassType) { case ClassType.Class: diff --git a/ICSharpCode.NRefactory.CSharp/Resolver/ResolveVisitor.cs b/ICSharpCode.NRefactory.CSharp/Resolver/ResolveVisitor.cs index a76f5c9688..4eccdc321d 100644 --- a/ICSharpCode.NRefactory.CSharp/Resolver/ResolveVisitor.cs +++ b/ICSharpCode.NRefactory.CSharp/Resolver/ResolveVisitor.cs @@ -473,7 +473,7 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver while (!resolverBeforeDict.TryGetValue(parent, out storedResolver)) { parent = parent.Parent; if (parent == null) - throw new InvalidOperationException("Could not find a resolver state for any parent of the specified node. Did you forget to call 'Scan(compilationUnit);'?"); + throw new InvalidOperationException("Could not find a resolver state for any parent of the specified node. Are you trying to resolve a node that is not a descendant of the CSharpAstResolver's root node?"); } return storedResolver; } @@ -1255,7 +1255,7 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver ResolveResult rr = resolver.ResolveIndexer(targetResult, arguments, argumentNames); ArrayAccessResolveResult aarr = rr as ArrayAccessResolveResult; if (aarr != null) { - ProcessConversionResults(indexerExpression.Arguments, aarr.Indices); + ProcessConversionResults(indexerExpression.Arguments, aarr.Indexes); } else { ProcessConversionsInInvocation(target, indexerExpression.Arguments, rr as CSharpInvocationResolveResult); } diff --git a/ICSharpCode.NRefactory.CSharp/TypeSystem/ConstantValues.cs b/ICSharpCode.NRefactory.CSharp/TypeSystem/ConstantValues.cs index cf203adca8..66cff254ab 100644 --- a/ICSharpCode.NRefactory.CSharp/TypeSystem/ConstantValues.cs +++ b/ICSharpCode.NRefactory.CSharp/TypeSystem/ConstantValues.cs @@ -89,12 +89,12 @@ namespace ICSharpCode.NRefactory.CSharp.TypeSystem.ConstantValues } } - static ResolveResult[] MapToNewContext(ResolveResult[] input, ITypeResolveContext newContext) + static ResolveResult[] MapToNewContext(IList input, ITypeResolveContext newContext) { if (input == null) return null; - ResolveResult[] output = new ResolveResult[input.Length]; - for (int i = 0; i < input.Length; i++) { + ResolveResult[] output = new ResolveResult[input.Count]; + for (int i = 0; i < output.Length; i++) { output[i] = MapToNewContext(input[i], newContext); } return output; diff --git a/ICSharpCode.NRefactory.Tests/TypeSystem/TypeSystemTests.cs b/ICSharpCode.NRefactory.Tests/TypeSystem/TypeSystemTests.cs index 44b0d1336f..146b0ea2f4 100644 --- a/ICSharpCode.NRefactory.Tests/TypeSystem/TypeSystemTests.cs +++ b/ICSharpCode.NRefactory.Tests/TypeSystem/TypeSystemTests.cs @@ -613,7 +613,7 @@ namespace ICSharpCode.NRefactory.TypeSystem { ITypeDefinition type = GetTypeDefinition(typeof(ParamsAttribute)); var arr = (ArrayCreateResolveResult)type.Attributes.Single().PositionalArguments.Single(); - Assert.AreEqual(5, arr.InitializerElements.Length); + Assert.AreEqual(5, arr.InitializerElements.Count); return arr.InitializerElements[index]; } diff --git a/ICSharpCode.NRefactory.VB/Ast/AstNode.cs b/ICSharpCode.NRefactory.VB/Ast/AstNode.cs index 448ae471b8..39b439d74c 100644 --- a/ICSharpCode.NRefactory.VB/Ast/AstNode.cs +++ b/ICSharpCode.NRefactory.VB/Ast/AstNode.cs @@ -413,9 +413,7 @@ namespace ICSharpCode.NRefactory.VB } // Finally, clone the annotation, if necessary - ICloneable annotations = copy.annotations as ICloneable; // read from copy (for thread-safety) - if (annotations != null) - copy.annotations = annotations.Clone(); + copy.CloneAnnotations(); return copy; } diff --git a/ICSharpCode.NRefactory/Completion/CompletionCategory.cs b/ICSharpCode.NRefactory/Completion/CompletionCategory.cs index a1ac3c7a6e..2f7fce1bfa 100644 --- a/ICSharpCode.NRefactory/Completion/CompletionCategory.cs +++ b/ICSharpCode.NRefactory/Completion/CompletionCategory.cs @@ -1,4 +1,4 @@ -// +// // CompletionCategory.cs // // Author: @@ -33,11 +33,11 @@ namespace ICSharpCode.NRefactory.Completion public string Icon { get; set; } - public CompletionCategory () + protected CompletionCategory () { } - public CompletionCategory (string displayText, string icon) + protected CompletionCategory (string displayText, string icon) { this.DisplayText = displayText; this.Icon = icon; diff --git a/ICSharpCode.NRefactory/Documentation/DocumentationComment.cs b/ICSharpCode.NRefactory/Documentation/DocumentationComment.cs index cb3d3b1a86..54b8e50a23 100644 --- a/ICSharpCode.NRefactory/Documentation/DocumentationComment.cs +++ b/ICSharpCode.NRefactory/Documentation/DocumentationComment.cs @@ -85,10 +85,10 @@ namespace ICSharpCode.NRefactory.Documentation return Xml.Text; } - public static implicit operator string (DocumentationComment cmt) + public static implicit operator string (DocumentationComment documentationComment) { - if (cmt != null) - return cmt.ToString (); + if (documentationComment != null) + return documentationComment.ToString (); return null; } } diff --git a/ICSharpCode.NRefactory/Documentation/IdStringProvider.cs b/ICSharpCode.NRefactory/Documentation/IdStringProvider.cs index 8576e4dd2c..9be979de08 100644 --- a/ICSharpCode.NRefactory/Documentation/IdStringProvider.cs +++ b/ICSharpCode.NRefactory/Documentation/IdStringProvider.cs @@ -187,7 +187,7 @@ namespace ICSharpCode.NRefactory.Documentation public static IMemberReference ParseMemberIdString(string memberIdString) { if (memberIdString == null) - throw new ArgumentNullException("memberIDString"); + throw new ArgumentNullException("memberIdString"); if (memberIdString.Length < 2 || memberIdString[1] != ':') throw new ReflectionNameParseException(0, "Missing type tag"); char typeChar = memberIdString[0]; diff --git a/ICSharpCode.NRefactory/Documentation/XmlDocumentationProvider.cs b/ICSharpCode.NRefactory/Documentation/XmlDocumentationProvider.cs index 1752c633f2..de2105211e 100644 --- a/ICSharpCode.NRefactory/Documentation/XmlDocumentationProvider.cs +++ b/ICSharpCode.NRefactory/Documentation/XmlDocumentationProvider.cs @@ -242,7 +242,7 @@ namespace ICSharpCode.NRefactory.Documentation } } - void ReadMembersSection(XmlTextReader reader, LinePositionMapper linePosMapper, List indexList) + static void ReadMembersSection(XmlTextReader reader, LinePositionMapper linePosMapper, List indexList) { while (reader.Read()) { switch (reader.NodeType) { diff --git a/ICSharpCode.NRefactory/Editor/ITextSource.cs b/ICSharpCode.NRefactory/Editor/ITextSource.cs index 31a48df7d1..8bb028a5f4 100644 --- a/ICSharpCode.NRefactory/Editor/ITextSource.cs +++ b/ICSharpCode.NRefactory/Editor/ITextSource.cs @@ -67,6 +67,7 @@ namespace ICSharpCode.NRefactory.Editor /// /// Gets the whole text as string. /// + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1721:PropertyNamesShouldNotMatchGetMethods")] string Text { get; } /// diff --git a/ICSharpCode.NRefactory/IAnnotatable.cs b/ICSharpCode.NRefactory/IAnnotatable.cs index 2c5f7cd802..07c82b734e 100644 --- a/ICSharpCode.NRefactory/IAnnotatable.cs +++ b/ICSharpCode.NRefactory/IAnnotatable.cs @@ -85,9 +85,22 @@ namespace ICSharpCode.NRefactory // or to an AnnotationList. // Once it is pointed at an AnnotationList, it will never change (this allows thread-safety support by locking the list) - [CLSCompliant(false)] - [NonSerialized] - protected object annotations; + object annotations; + + /// + /// Clones all annotations. + /// This method is intended to be called by Clone() implementations in derived classes. + /// + /// AstNode copy = (AstNode)MemberwiseClone(); + /// copy.CloneAnnotations(); + /// + /// + protected void CloneAnnotations() + { + ICloneable cloneable = annotations as ICloneable; + if (cloneable != null) + annotations = cloneable.Clone(); + } sealed class AnnotationList : List, ICloneable { diff --git a/ICSharpCode.NRefactory/ICSharpCode.NRefactory.csproj b/ICSharpCode.NRefactory/ICSharpCode.NRefactory.csproj index 11b3d515b5..1d7ea4834a 100644 --- a/ICSharpCode.NRefactory/ICSharpCode.NRefactory.csproj +++ b/ICSharpCode.NRefactory/ICSharpCode.NRefactory.csproj @@ -14,7 +14,7 @@ False false False - -Microsoft.Design#CA1026;-Microsoft.Security#CA2104 + -Microsoft.Design#CA1000;-Microsoft.Design#CA1004;-Microsoft.Design#CA1005;-Microsoft.Design#CA1006;-Microsoft.Design#CA1026;-Microsoft.Design#CA1033;-Microsoft.Design#CA1051;-Microsoft.Design#CA1063;-Microsoft.Naming#CA1702;-Microsoft.Naming#CA1704;-Microsoft.Naming#CA1710;-Microsoft.Naming#CA1716;-Microsoft.Naming#CA1720;-Microsoft.Performance#CA1800;-Microsoft.Security#CA2104 true ..\ICSharpCode.NRefactory.snk False @@ -35,6 +35,7 @@ False DEBUG;TRACE True + Project bin\Release\ diff --git a/ICSharpCode.NRefactory/Semantics/ArrayAccessResolveResult.cs b/ICSharpCode.NRefactory/Semantics/ArrayAccessResolveResult.cs index 286681eb31..535098f2b7 100644 --- a/ICSharpCode.NRefactory/Semantics/ArrayAccessResolveResult.cs +++ b/ICSharpCode.NRefactory/Semantics/ArrayAccessResolveResult.cs @@ -30,21 +30,21 @@ namespace ICSharpCode.NRefactory.Semantics public class ArrayAccessResolveResult : ResolveResult { public readonly ResolveResult Array; - public readonly ResolveResult[] Indices; + public readonly IList Indexes; - public ArrayAccessResolveResult(IType elementType, ResolveResult array, ResolveResult[] indices) : base(elementType) + public ArrayAccessResolveResult(IType elementType, ResolveResult array, IList indexes) : base(elementType) { if (array == null) throw new ArgumentNullException("array"); - if (indices == null) - throw new ArgumentNullException("indices"); + if (indexes == null) + throw new ArgumentNullException("indexes"); this.Array = array; - this.Indices = indices; + this.Indexes = indexes; } public override IEnumerable GetChildResults() { - return new [] { Array }.Concat(Indices); + return new [] { Array }.Concat(Indexes); } } } diff --git a/ICSharpCode.NRefactory/Semantics/ArrayCreateResolveResult.cs b/ICSharpCode.NRefactory/Semantics/ArrayCreateResolveResult.cs index 7b4a978ea1..9eb24e834b 100644 --- a/ICSharpCode.NRefactory/Semantics/ArrayCreateResolveResult.cs +++ b/ICSharpCode.NRefactory/Semantics/ArrayCreateResolveResult.cs @@ -32,15 +32,15 @@ namespace ICSharpCode.NRefactory.Semantics /// /// Gets the size arguments. /// - public readonly ResolveResult[] SizeArguments; + public readonly IList SizeArguments; /// /// Gets the initializer elements. /// This field may be null if no initializer was specified. /// - public readonly ResolveResult[] InitializerElements; + public readonly IList InitializerElements; - public ArrayCreateResolveResult(IType arrayType, ResolveResult[] sizeArguments, ResolveResult[] initializerElements) + public ArrayCreateResolveResult(IType arrayType, IList sizeArguments, IList initializerElements) : base(arrayType) { this.SizeArguments = sizeArguments; diff --git a/ICSharpCode.NRefactory/Semantics/ByReferenceResolveResult.cs b/ICSharpCode.NRefactory/Semantics/ByReferenceResolveResult.cs index 5522a0faf7..a2e8907c48 100644 --- a/ICSharpCode.NRefactory/Semantics/ByReferenceResolveResult.cs +++ b/ICSharpCode.NRefactory/Semantics/ByReferenceResolveResult.cs @@ -18,6 +18,7 @@ using System; using System.Collections.Generic; +using System.Globalization; using System.Linq; using ICSharpCode.NRefactory.TypeSystem; @@ -59,7 +60,7 @@ namespace ICSharpCode.NRefactory.Semantics public override string ToString() { - return string.Format("[{0} {1} {2}]", GetType().Name, IsOut ? "out" : "ref", ElementType); + return string.Format(CultureInfo.InvariantCulture, "[{0} {1} {2}]", GetType().Name, IsOut ? "out" : "ref", ElementType); } } } diff --git a/ICSharpCode.NRefactory/Semantics/ConstantResolveResult.cs b/ICSharpCode.NRefactory/Semantics/ConstantResolveResult.cs index e4dcd1e091..866c003089 100644 --- a/ICSharpCode.NRefactory/Semantics/ConstantResolveResult.cs +++ b/ICSharpCode.NRefactory/Semantics/ConstantResolveResult.cs @@ -17,6 +17,7 @@ // DEALINGS IN THE SOFTWARE. using System; +using System.Globalization; using ICSharpCode.NRefactory.TypeSystem; namespace ICSharpCode.NRefactory.Semantics @@ -43,7 +44,7 @@ namespace ICSharpCode.NRefactory.Semantics public override string ToString() { - return string.Format("[{0} {1} = {2}]", GetType().Name, this.Type, constantValue); + return string.Format(CultureInfo.InvariantCulture, "[{0} {1} = {2}]", GetType().Name, this.Type, constantValue); } } } diff --git a/ICSharpCode.NRefactory/Semantics/InvocationResolveResult.cs b/ICSharpCode.NRefactory/Semantics/InvocationResolveResult.cs index 2dfb8d7102..61c96bf735 100644 --- a/ICSharpCode.NRefactory/Semantics/InvocationResolveResult.cs +++ b/ICSharpCode.NRefactory/Semantics/InvocationResolveResult.cs @@ -35,7 +35,7 @@ namespace ICSharpCode.NRefactory.Semantics /// public readonly IList Arguments; - public InvocationResolveResult(ResolveResult targetResult, IParameterizedMember member, IList arguments) + protected InvocationResolveResult(ResolveResult targetResult, IParameterizedMember member, IList arguments) : base(targetResult, member) { this.Arguments = arguments ?? EmptyList.Instance; @@ -49,6 +49,8 @@ namespace ICSharpCode.NRefactory.Semantics /// Gets the arguments in the order they are being passed to the method. /// For parameter arrays (params), this will return an ArrayCreateResolveResult. /// + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate", + Justification = "Derived methods may be expensive and create new lists")] public virtual IList GetArgumentsForCall() { return Arguments; diff --git a/ICSharpCode.NRefactory/Semantics/LocalResolveResult.cs b/ICSharpCode.NRefactory/Semantics/LocalResolveResult.cs index 1bfaa3b376..fc8253c863 100644 --- a/ICSharpCode.NRefactory/Semantics/LocalResolveResult.cs +++ b/ICSharpCode.NRefactory/Semantics/LocalResolveResult.cs @@ -17,6 +17,7 @@ // DEALINGS IN THE SOFTWARE. using System; +using System.Globalization; using ICSharpCode.NRefactory.TypeSystem; namespace ICSharpCode.NRefactory.Semantics @@ -65,7 +66,7 @@ namespace ICSharpCode.NRefactory.Semantics public override string ToString() { - return string.Format("[LocalResolveResult {0}]", variable); + return string.Format(CultureInfo.InvariantCulture, "[LocalResolveResult {0}]", variable); } public override DomRegion GetDefinitionRegion() diff --git a/ICSharpCode.NRefactory/Semantics/MemberResolveResult.cs b/ICSharpCode.NRefactory/Semantics/MemberResolveResult.cs index ca742b2cb4..ed03205c31 100644 --- a/ICSharpCode.NRefactory/Semantics/MemberResolveResult.cs +++ b/ICSharpCode.NRefactory/Semantics/MemberResolveResult.cs @@ -18,7 +18,9 @@ using System; using System.Collections.Generic; +using System.Globalization; using System.Linq; + using ICSharpCode.NRefactory.TypeSystem; namespace ICSharpCode.NRefactory.Semantics @@ -85,7 +87,7 @@ namespace ICSharpCode.NRefactory.Semantics public override string ToString() { - return string.Format("[{0} {1}]", GetType().Name, member); + return string.Format(CultureInfo.InvariantCulture, "[{0} {1}]", GetType().Name, member); } public override DomRegion GetDefinitionRegion() diff --git a/ICSharpCode.NRefactory/Semantics/NamespaceResolveResult.cs b/ICSharpCode.NRefactory/Semantics/NamespaceResolveResult.cs index 425690329a..947a940c73 100644 --- a/ICSharpCode.NRefactory/Semantics/NamespaceResolveResult.cs +++ b/ICSharpCode.NRefactory/Semantics/NamespaceResolveResult.cs @@ -17,6 +17,7 @@ // DEALINGS IN THE SOFTWARE. using System; +using System.Globalization; using ICSharpCode.NRefactory.TypeSystem; namespace ICSharpCode.NRefactory.Semantics @@ -43,7 +44,7 @@ namespace ICSharpCode.NRefactory.Semantics public override string ToString() { - return string.Format("[{0} {1}]", GetType().Name, ns); + return string.Format(CultureInfo.InvariantCulture, "[{0} {1}]", GetType().Name, ns); } } } diff --git a/ICSharpCode.NRefactory/Semantics/ResolveResult.cs b/ICSharpCode.NRefactory/Semantics/ResolveResult.cs index 40b3bc055c..d73ecf6e41 100644 --- a/ICSharpCode.NRefactory/Semantics/ResolveResult.cs +++ b/ICSharpCode.NRefactory/Semantics/ResolveResult.cs @@ -38,6 +38,8 @@ namespace ICSharpCode.NRefactory.Semantics this.type = type; } + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1721:PropertyNamesShouldNotMatchGetMethods", + Justification = "Unrelated to object.GetType()")] public IType Type { get { return type; } } diff --git a/ICSharpCode.NRefactory/Semantics/UnknownMemberResolveResult.cs b/ICSharpCode.NRefactory/Semantics/UnknownMemberResolveResult.cs index 907c1a3ce4..bcb1c6025d 100644 --- a/ICSharpCode.NRefactory/Semantics/UnknownMemberResolveResult.cs +++ b/ICSharpCode.NRefactory/Semantics/UnknownMemberResolveResult.cs @@ -19,6 +19,7 @@ using System; using System.Collections.Generic; using System.Collections.ObjectModel; +using System.Globalization; using System.Linq; using ICSharpCode.NRefactory.TypeSystem; @@ -64,7 +65,7 @@ namespace ICSharpCode.NRefactory.Semantics public override string ToString() { - return string.Format("[{0} {1}.{2}]", GetType().Name, targetType, memberName); + return string.Format(CultureInfo.InvariantCulture, "[{0} {1}.{2}]", GetType().Name, targetType, memberName); } } @@ -115,7 +116,7 @@ namespace ICSharpCode.NRefactory.Semantics public override string ToString() { - return string.Format("[{0} {1}]", GetType().Name, identifier); + return string.Format(CultureInfo.InvariantCulture, "[{0} {1}]", GetType().Name, identifier); } } } diff --git a/ICSharpCode.NRefactory/TypeSystem/CecilLoader.cs b/ICSharpCode.NRefactory/TypeSystem/CecilLoader.cs index ffd9ed55fe..e37e971133 100644 --- a/ICSharpCode.NRefactory/TypeSystem/CecilLoader.cs +++ b/ICSharpCode.NRefactory/TypeSystem/CecilLoader.cs @@ -424,7 +424,7 @@ namespace ICSharpCode.NRefactory.TypeSystem static readonly ITypeReference methodImplAttributeTypeRef = typeof(MethodImplAttribute).ToTypeReference(); static readonly ITypeReference methodImplOptionsTypeRef = typeof(MethodImplOptions).ToTypeReference(); - bool HasAnyAttributes(MethodDefinition methodDefinition) + static bool HasAnyAttributes(MethodDefinition methodDefinition) { if (methodDefinition.HasPInvokeInfo) return true; @@ -891,10 +891,6 @@ namespace ICSharpCode.NRefactory.TypeSystem } } - public ICompilation Compilation { - get { return context.Compilation; } - } - public override string ToString() { return "[" + attributeType.ToString() + "(...)]"; @@ -1037,22 +1033,6 @@ namespace ICSharpCode.NRefactory.TypeSystem } } - public int ReadCompressedInt32() - { - unchecked { - var value =(int)(ReadCompressedUInt32() >> 1); - if((value & 1) == 0) - return value; - if(value < 0x40) - return value - 0x40; - if(value < 0x2000) - return value - 0x2000; - if(value < 0x10000000) - return value - 0x10000000; - return value - 0x20000000; - } - } - public float ReadSingle() { unchecked { diff --git a/ICSharpCode.NRefactory/TypeSystem/ComHelper.cs b/ICSharpCode.NRefactory/TypeSystem/ComHelper.cs index c8527b0d51..87f6f83f45 100644 --- a/ICSharpCode.NRefactory/TypeSystem/ComHelper.cs +++ b/ICSharpCode.NRefactory/TypeSystem/ComHelper.cs @@ -25,7 +25,7 @@ namespace ICSharpCode.NRefactory.TypeSystem /// /// Helper methods for COM. /// - public class ComHelper + public static class ComHelper { static bool IsComAttribute(IAttribute attribute, string name) { @@ -45,6 +45,8 @@ namespace ICSharpCode.NRefactory.TypeSystem /// /// Gets the CoClass of the specified COM interface. /// + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Co", + Justification = "Consistent with CoClassAttribute")] public static IType GetCoClass(ITypeDefinition typeDefinition) { if (typeDefinition == null) diff --git a/ICSharpCode.NRefactory/TypeSystem/IAmbience.cs b/ICSharpCode.NRefactory/TypeSystem/IAmbience.cs index 02fb4bcf0d..925db72c0f 100644 --- a/ICSharpCode.NRefactory/TypeSystem/IAmbience.cs +++ b/ICSharpCode.NRefactory/TypeSystem/IAmbience.cs @@ -42,7 +42,7 @@ namespace ICSharpCode.NRefactory.TypeSystem /// /// Show the definition key word (class, struct, Sub, Function, etc.) /// - ShowDefinitionKeyWord = 8, + ShowDefinitionKeyword = 8, /// /// Show the declaring type for the member /// @@ -76,17 +76,17 @@ namespace ICSharpCode.NRefactory.TypeSystem ShowReturnType | ShowModifiers | ShowTypeParameterList | - ShowDefinitionKeyWord | + ShowDefinitionKeyword | ShowBody, - All = 0xfff, + All = 0x3ff, } public interface IAmbience { ConversionFlags ConversionFlags { get; set; } - string ConvertEntity(IEntity e); + string ConvertEntity(IEntity entity); string ConvertType(IType type); string ConvertVariable(IVariable variable); diff --git a/ICSharpCode.NRefactory/TypeSystem/Implementation/AbstractResolvedTypeParameter.cs b/ICSharpCode.NRefactory/TypeSystem/Implementation/AbstractResolvedTypeParameter.cs index 5f548ad4c5..924987b33b 100644 --- a/ICSharpCode.NRefactory/TypeSystem/Implementation/AbstractResolvedTypeParameter.cs +++ b/ICSharpCode.NRefactory/TypeSystem/Implementation/AbstractResolvedTypeParameter.cs @@ -18,8 +18,8 @@ using System; using System.Collections.Generic; -using System.Linq; -using System.Threading; +using System.Globalization; + using ICSharpCode.NRefactory.Utils; namespace ICSharpCode.NRefactory.TypeSystem.Implementation @@ -43,7 +43,7 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation this.compilation = owner.Compilation; this.ownerType = owner.EntityType; this.index = index; - this.name = name ?? ((this.OwnerType == EntityType.Method ? "!!" : "!") + index.ToString()); + this.name = name ?? ((this.OwnerType == EntityType.Method ? "!!" : "!") + index.ToString(CultureInfo.InvariantCulture)); this.attributes = attributes ?? EmptyList.Instance; this.region = region; this.variance = variance; @@ -56,7 +56,7 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation this.compilation = compilation; this.ownerType = ownerType; this.index = index; - this.name = name ?? ((this.OwnerType == EntityType.Method ? "!!" : "!") + index.ToString()); + this.name = name ?? ((this.OwnerType == EntityType.Method ? "!!" : "!") + index.ToString(CultureInfo.InvariantCulture)); this.attributes = attributes ?? EmptyList.Instance; this.region = region; this.variance = variance; @@ -198,7 +198,7 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation public string ReflectionName { get { - return (this.OwnerType == EntityType.Method ? "``" : "`") + index.ToString(); + return (this.OwnerType == EntityType.Method ? "``" : "`") + index.ToString(CultureInfo.InvariantCulture); } } diff --git a/ICSharpCode.NRefactory/TypeSystem/Implementation/AbstractUnresolvedEntity.cs b/ICSharpCode.NRefactory/TypeSystem/Implementation/AbstractUnresolvedEntity.cs index 8397a80232..3906f24878 100644 --- a/ICSharpCode.NRefactory/TypeSystem/Implementation/AbstractUnresolvedEntity.cs +++ b/ICSharpCode.NRefactory/TypeSystem/Implementation/AbstractUnresolvedEntity.cs @@ -174,7 +174,7 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation get { return name; } set { if (value == null) - throw new ArgumentNullException(); + throw new ArgumentNullException("value"); ThrowIfFrozen(); name = value; } diff --git a/ICSharpCode.NRefactory/TypeSystem/Implementation/AbstractUnresolvedMember.cs b/ICSharpCode.NRefactory/TypeSystem/Implementation/AbstractUnresolvedMember.cs index 156da37c28..7caba61b28 100644 --- a/ICSharpCode.NRefactory/TypeSystem/Implementation/AbstractUnresolvedMember.cs +++ b/ICSharpCode.NRefactory/TypeSystem/Implementation/AbstractUnresolvedMember.cs @@ -68,7 +68,7 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation get { return returnType; } set { if (value == null) - throw new ArgumentNullException(); + throw new ArgumentNullException("value"); ThrowIfFrozen(); returnType = value; } diff --git a/ICSharpCode.NRefactory/TypeSystem/Implementation/DefaultAssemblyReference.cs b/ICSharpCode.NRefactory/TypeSystem/Implementation/DefaultAssemblyReference.cs index 76b0c14084..8987e65bf2 100644 --- a/ICSharpCode.NRefactory/TypeSystem/Implementation/DefaultAssemblyReference.cs +++ b/ICSharpCode.NRefactory/TypeSystem/Implementation/DefaultAssemblyReference.cs @@ -26,8 +26,8 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation [Serializable] public sealed class DefaultAssemblyReference : IAssemblyReference, ISupportsInterning { - public static IAssemblyReference CurrentAssembly = new CurrentAssemblyReference(); - public static IAssemblyReference Corlib = new DefaultAssemblyReference("mscorlib"); + public static readonly IAssemblyReference CurrentAssembly = new CurrentAssemblyReference(); + public static readonly IAssemblyReference Corlib = new DefaultAssemblyReference("mscorlib"); string shortName; diff --git a/ICSharpCode.NRefactory/TypeSystem/Implementation/DefaultParameter.cs b/ICSharpCode.NRefactory/TypeSystem/Implementation/DefaultParameter.cs index 02f5bfc091..5c03765229 100644 --- a/ICSharpCode.NRefactory/TypeSystem/Implementation/DefaultParameter.cs +++ b/ICSharpCode.NRefactory/TypeSystem/Implementation/DefaultParameter.cs @@ -107,22 +107,22 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation return ToString(this); } - public static string ToString(IParameter p) + public static string ToString(IParameter parameter) { StringBuilder b = new StringBuilder(); - if (p.IsRef) + if (parameter.IsRef) b.Append("ref "); - if (p.IsOut) + if (parameter.IsOut) b.Append("out "); - if (p.IsParams) + if (parameter.IsParams) b.Append("params "); - b.Append(p.Name); + b.Append(parameter.Name); b.Append(':'); - b.Append(p.Type.ToString()); - if (p.IsOptional) { + b.Append(parameter.Type.ToString()); + if (parameter.IsOptional) { b.Append(" = "); - if (p.ConstantValue != null) - b.Append(p.ConstantValue.ToString()); + if (parameter.ConstantValue != null) + b.Append(parameter.ConstantValue.ToString()); else b.Append("null"); } diff --git a/ICSharpCode.NRefactory/TypeSystem/Implementation/DefaultUnresolvedAssembly.cs b/ICSharpCode.NRefactory/TypeSystem/Implementation/DefaultUnresolvedAssembly.cs index 9db8f7936b..6f19f11360 100644 --- a/ICSharpCode.NRefactory/TypeSystem/Implementation/DefaultUnresolvedAssembly.cs +++ b/ICSharpCode.NRefactory/TypeSystem/Implementation/DefaultUnresolvedAssembly.cs @@ -61,7 +61,7 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation get { return assemblyName; } set { if (value == null) - throw new ArgumentNullException(); + throw new ArgumentNullException("value"); FreezableHelper.ThrowIfFrozen(this); assemblyName = value; } diff --git a/ICSharpCode.NRefactory/TypeSystem/Implementation/DefaultUnresolvedParameter.cs b/ICSharpCode.NRefactory/TypeSystem/Implementation/DefaultUnresolvedParameter.cs index a32a49fabb..0167cf6bab 100644 --- a/ICSharpCode.NRefactory/TypeSystem/Implementation/DefaultUnresolvedParameter.cs +++ b/ICSharpCode.NRefactory/TypeSystem/Implementation/DefaultUnresolvedParameter.cs @@ -18,8 +18,8 @@ using System; using System.Collections.Generic; -using System.Diagnostics.Contracts; using System.Text; + using ICSharpCode.NRefactory.Semantics; using ICSharpCode.NRefactory.Utils; @@ -62,7 +62,7 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation get { return name; } set { if (value == null) - throw new ArgumentNullException(); + throw new ArgumentNullException("value"); FreezableHelper.ThrowIfFrozen(this); name = value; } @@ -72,7 +72,7 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation get { return type; } set { if (value == null) - throw new ArgumentNullException(); + throw new ArgumentNullException("value"); FreezableHelper.ThrowIfFrozen(this); type = value; } diff --git a/ICSharpCode.NRefactory/TypeSystem/Implementation/DefaultUnresolvedTypeDefinition.cs b/ICSharpCode.NRefactory/TypeSystem/Implementation/DefaultUnresolvedTypeDefinition.cs index fbd154591e..d719372f6c 100644 --- a/ICSharpCode.NRefactory/TypeSystem/Implementation/DefaultUnresolvedTypeDefinition.cs +++ b/ICSharpCode.NRefactory/TypeSystem/Implementation/DefaultUnresolvedTypeDefinition.cs @@ -17,8 +17,9 @@ // DEALINGS IN THE SOFTWARE. using System; -using System.Linq; using System.Collections.Generic; +using System.Globalization; +using System.Linq; namespace ICSharpCode.NRefactory.TypeSystem.Implementation { @@ -110,7 +111,7 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation get { return namespaceName; } set { if (value == null) - throw new ArgumentNullException(); + throw new ArgumentNullException("value"); ThrowIfFrozen(); namespaceName = value; } @@ -121,18 +122,18 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation IUnresolvedTypeDefinition declaringTypeDef = this.DeclaringTypeDefinition; if (declaringTypeDef != null) { if (this.TypeParameters.Count > declaringTypeDef.TypeParameters.Count) { - return declaringTypeDef.ReflectionName + "+" + this.Name + "`" + (this.TypeParameters.Count - declaringTypeDef.TypeParameters.Count).ToString(); + return declaringTypeDef.ReflectionName + "+" + this.Name + "`" + (this.TypeParameters.Count - declaringTypeDef.TypeParameters.Count).ToString(CultureInfo.InvariantCulture); } else { return declaringTypeDef.ReflectionName + "+" + this.Name; } } else if (string.IsNullOrEmpty(namespaceName)) { if (this.TypeParameters.Count > 0) - return this.Name + "`" + this.TypeParameters.Count.ToString(); + return this.Name + "`" + this.TypeParameters.Count.ToString(CultureInfo.InvariantCulture); else return this.Name; } else { if (this.TypeParameters.Count > 0) - return namespaceName + "." + this.Name + "`" + this.TypeParameters.Count.ToString(); + return namespaceName + "." + this.Name + "`" + this.TypeParameters.Count.ToString(CultureInfo.InvariantCulture); else return namespaceName + "." + this.Name; } diff --git a/ICSharpCode.NRefactory/TypeSystem/Implementation/DefaultUnresolvedTypeParameter.cs b/ICSharpCode.NRefactory/TypeSystem/Implementation/DefaultUnresolvedTypeParameter.cs index 08db806338..ecc830e22c 100644 --- a/ICSharpCode.NRefactory/TypeSystem/Implementation/DefaultUnresolvedTypeParameter.cs +++ b/ICSharpCode.NRefactory/TypeSystem/Implementation/DefaultUnresolvedTypeParameter.cs @@ -18,8 +18,8 @@ using System; using System.Collections.Generic; -using System.Linq; -using System.Threading; +using System.Globalization; + using ICSharpCode.NRefactory.Utils; namespace ICSharpCode.NRefactory.TypeSystem.Implementation @@ -61,7 +61,7 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation { this.ownerType = ownerType; this.index = index; - this.name = name ?? ((ownerType == EntityType.Method ? "!!" : "!") + index.ToString()); + this.name = name ?? ((ownerType == EntityType.Method ? "!!" : "!") + index.ToString(CultureInfo.InvariantCulture)); } public EntityType OwnerType { @@ -95,9 +95,9 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation string INamedElement.ReflectionName { get { if (ownerType == EntityType.Method) - return "``" + index.ToString(); + return "``" + index.ToString(CultureInfo.InvariantCulture); else - return "`" + index.ToString(); + return "`" + index.ToString(CultureInfo.InvariantCulture); } } diff --git a/ICSharpCode.NRefactory/TypeSystem/Implementation/FullNameAndTypeParameterCount.cs b/ICSharpCode.NRefactory/TypeSystem/Implementation/FullNameAndTypeParameterCount.cs index 526c779b02..1057d9403f 100644 --- a/ICSharpCode.NRefactory/TypeSystem/Implementation/FullNameAndTypeParameterCount.cs +++ b/ICSharpCode.NRefactory/TypeSystem/Implementation/FullNameAndTypeParameterCount.cs @@ -22,7 +22,7 @@ using System.Collections.Generic; namespace ICSharpCode.NRefactory.TypeSystem.Implementation { [Serializable] - public struct FullNameAndTypeParameterCount + public struct FullNameAndTypeParameterCount : IEquatable { public readonly string Namespace; public readonly string Name; @@ -38,6 +38,31 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation this.Name = name; this.TypeParameterCount = typeParameterCount; } + + public override bool Equals(object obj) + { + return (obj is FullNameAndTypeParameterCount) && Equals((FullNameAndTypeParameterCount)obj); + } + + public bool Equals(FullNameAndTypeParameterCount other) + { + return this.Namespace == other.Namespace && this.Name == other.Name && this.TypeParameterCount == other.TypeParameterCount; + } + + public override int GetHashCode() + { + return Name.GetHashCode() ^ Namespace.GetHashCode() ^ TypeParameterCount; + } + + public static bool operator ==(FullNameAndTypeParameterCount lhs, FullNameAndTypeParameterCount rhs) + { + return lhs.Equals(rhs); + } + + public static bool operator !=(FullNameAndTypeParameterCount lhs, FullNameAndTypeParameterCount rhs) + { + return !lhs.Equals(rhs); + } } [Serializable] diff --git a/ICSharpCode.NRefactory/TypeSystem/Implementation/GetClassTypeReference.cs b/ICSharpCode.NRefactory/TypeSystem/Implementation/GetClassTypeReference.cs index 7c447df5f6..b5b6da763b 100644 --- a/ICSharpCode.NRefactory/TypeSystem/Implementation/GetClassTypeReference.cs +++ b/ICSharpCode.NRefactory/TypeSystem/Implementation/GetClassTypeReference.cs @@ -18,8 +18,6 @@ using System; using System.Linq; -using System.Linq.Expressions; -using ICSharpCode.NRefactory.Utils; namespace ICSharpCode.NRefactory.TypeSystem.Implementation { diff --git a/ICSharpCode.NRefactory/TypeSystem/Implementation/MergedNamespace.cs b/ICSharpCode.NRefactory/TypeSystem/Implementation/MergedNamespace.cs index 6c88297117..d63dfc84c0 100644 --- a/ICSharpCode.NRefactory/TypeSystem/Implementation/MergedNamespace.cs +++ b/ICSharpCode.NRefactory/TypeSystem/Implementation/MergedNamespace.cs @@ -18,6 +18,7 @@ using System; using System.Collections.Generic; +using System.Globalization; using System.Linq; using System.Text; using ICSharpCode.NRefactory.Utils; @@ -145,7 +146,8 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation public override string ToString() { - return string.Format("[MergedNamespace {0}{1} (from {2} assemblies)]", externAlias != null ? externAlias + "::" : null, this.FullName, this.namespaces.Length); + return string.Format(CultureInfo.InvariantCulture, "[MergedNamespace {0}{1} (from {2} assemblies)]", + externAlias != null ? externAlias + "::" : null, this.FullName, this.namespaces.Length); } } } diff --git a/ICSharpCode.NRefactory/TypeSystem/Implementation/SimpleConstantValue.cs b/ICSharpCode.NRefactory/TypeSystem/Implementation/SimpleConstantValue.cs index 91e0e29731..928624c0de 100644 --- a/ICSharpCode.NRefactory/TypeSystem/Implementation/SimpleConstantValue.cs +++ b/ICSharpCode.NRefactory/TypeSystem/Implementation/SimpleConstantValue.cs @@ -43,6 +43,8 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation return new ConstantResolveResult(type.Resolve(context), value); } + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Globalization", "CA1308:NormalizeStringsToUppercase", + Justification = "The C# keyword is lower case")] public override string ToString() { if (value == null) diff --git a/ICSharpCode.NRefactory/TypeSystem/Implementation/TypeParameterReference.cs b/ICSharpCode.NRefactory/TypeSystem/Implementation/TypeParameterReference.cs index 57c1222262..595fe2e90b 100644 --- a/ICSharpCode.NRefactory/TypeSystem/Implementation/TypeParameterReference.cs +++ b/ICSharpCode.NRefactory/TypeSystem/Implementation/TypeParameterReference.cs @@ -17,6 +17,7 @@ // DEALINGS IN THE SOFTWARE. using System; +using System.Globalization; namespace ICSharpCode.NRefactory.TypeSystem.Implementation { @@ -69,9 +70,9 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation public override string ToString() { if (ownerType == EntityType.Method) - return "!!" + index.ToString(); + return "!!" + index.ToString(CultureInfo.InvariantCulture); else - return "!" + index.ToString(); + return "!" + index.ToString(CultureInfo.InvariantCulture); } } } diff --git a/ICSharpCode.NRefactory/TypeSystem/InheritanceHelper.cs b/ICSharpCode.NRefactory/TypeSystem/InheritanceHelper.cs index c79556a9b7..fccebe5443 100644 --- a/ICSharpCode.NRefactory/TypeSystem/InheritanceHelper.cs +++ b/ICSharpCode.NRefactory/TypeSystem/InheritanceHelper.cs @@ -25,7 +25,7 @@ namespace ICSharpCode.NRefactory.TypeSystem /// /// Provides helper methods for inheritance. /// - public class InheritanceHelper + public static class InheritanceHelper { // TODO: maybe these should be extension methods? // or even part of the interface itself? (would allow for easy caching) diff --git a/ICSharpCode.NRefactory/Utils/BitVector16.cs b/ICSharpCode.NRefactory/Utils/BitVector16.cs index 62fa602c72..10a188daae 100644 --- a/ICSharpCode.NRefactory/Utils/BitVector16.cs +++ b/ICSharpCode.NRefactory/Utils/BitVector16.cs @@ -17,6 +17,7 @@ // DEALINGS IN THE SOFTWARE. using System; +using System.Globalization; namespace ICSharpCode.NRefactory.Utils { @@ -76,7 +77,7 @@ namespace ICSharpCode.NRefactory.Utils public override string ToString() { - return data.ToString("x4"); + return data.ToString("x4", CultureInfo.InvariantCulture); } } } diff --git a/ICSharpCode.NRefactory/Utils/BusyManager.cs b/ICSharpCode.NRefactory/Utils/BusyManager.cs index 51704eceeb..8ab38c4312 100644 --- a/ICSharpCode.NRefactory/Utils/BusyManager.cs +++ b/ICSharpCode.NRefactory/Utils/BusyManager.cs @@ -29,13 +29,16 @@ namespace ICSharpCode.NRefactory.Utils /// public static class BusyManager { + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1815:OverrideEqualsAndOperatorEqualsOnValueTypes")] + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1034:NestedTypesShouldNotBeVisible", + Justification = "Should always be used with 'var'")] public struct BusyLock : IDisposable { public static readonly BusyLock Failed = new BusyLock(null); readonly List objectList; - public BusyLock(List objectList) + internal BusyLock(List objectList) { this.objectList = objectList; } diff --git a/ICSharpCode.NRefactory/Utils/CacheManager.cs b/ICSharpCode.NRefactory/Utils/CacheManager.cs index 9bcb46503c..4d0bcd63bb 100644 --- a/ICSharpCode.NRefactory/Utils/CacheManager.cs +++ b/ICSharpCode.NRefactory/Utils/CacheManager.cs @@ -36,9 +36,9 @@ namespace ICSharpCode.NRefactory.Utils public object GetShared(object key) { - object val; - sharedDict.TryGetValue(key, out val); - return val; + object value; + sharedDict.TryGetValue(key, out value); + return value; } public object GetOrAddShared(object key, Func valueFactory) @@ -46,14 +46,14 @@ namespace ICSharpCode.NRefactory.Utils return sharedDict.GetOrAdd(key, valueFactory); } - public object GetOrAddShared(object key, object val) + public object GetOrAddShared(object key, object value) { - return sharedDict.GetOrAdd(key, val); + return sharedDict.GetOrAdd(key, value); } - public void SetShared(object key, object val) + public void SetShared(object key, object value) { - sharedDict[key] = val; + sharedDict[key] = value; } } } diff --git a/ICSharpCode.NRefactory/Utils/EmptyList.cs b/ICSharpCode.NRefactory/Utils/EmptyList.cs index ed566005b9..5accc1e852 100644 --- a/ICSharpCode.NRefactory/Utils/EmptyList.cs +++ b/ICSharpCode.NRefactory/Utils/EmptyList.cs @@ -31,8 +31,8 @@ namespace ICSharpCode.NRefactory private EmptyList() {} T IList.this[int index] { - get { throw new IndexOutOfRangeException(); } - set { throw new IndexOutOfRangeException(); } + get { throw new ArgumentOutOfRangeException("index"); } + set { throw new ArgumentOutOfRangeException("index"); } } int ICollection.Count { diff --git a/ICSharpCode.NRefactory/Utils/FastSerializer.cs b/ICSharpCode.NRefactory/Utils/FastSerializer.cs index 69346d6556..61f522c7f8 100644 --- a/ICSharpCode.NRefactory/Utils/FastSerializer.cs +++ b/ICSharpCode.NRefactory/Utils/FastSerializer.cs @@ -472,7 +472,7 @@ namespace ICSharpCode.NRefactory.Utils List fields = new List(); for (Type baseType = type; baseType != null; baseType = baseType.BaseType) { FieldInfo[] declFields = baseType.GetFields(BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.DeclaredOnly); - Array.Sort(declFields, (a,b) => a.Name.CompareTo(b.Name)); + Array.Sort(declFields, (a,b) => string.Compare(a.Name, b.Name, StringComparison.Ordinal)); fields.AddRange(declFields); } fields.RemoveAll(f => f.IsNotSerialized); @@ -806,7 +806,7 @@ namespace ICSharpCode.NRefactory.Utils return Reader.ReadInt32(); } - internal void DeserializeTypeDescriptions(FastSerializer fastSerializer) + internal void DeserializeTypeDescriptions() { for (int i = 0; i < this.Types.Length; i++) { Type type = this.Types[i]; @@ -918,7 +918,7 @@ namespace ICSharpCode.NRefactory.Utils throw new SerializationException("Unknown type kind"); } } - context.DeserializeTypeDescriptions(this); + context.DeserializeTypeDescriptions(); int[] typeIDByObjectID = new int[context.Objects.Length]; for (int i = 1 + fixedInstanceCount; i < context.Objects.Length; i++) { int typeID = context.ReadTypeID(); @@ -1296,7 +1296,7 @@ namespace ICSharpCode.NRefactory.Utils return action; } - CustomDeserializationAction CreateCustomDeserializationAction(Type type) + static CustomDeserializationAction CreateCustomDeserializationAction(Type type) { ConstructorInfo ctor = type.GetConstructor( BindingFlags.DeclaredOnly | BindingFlags.ExactBinding | BindingFlags.Instance diff --git a/ICSharpCode.NRefactory/Utils/LazyInit.cs b/ICSharpCode.NRefactory/Utils/LazyInit.cs index 08978503c8..dcb148ac80 100644 --- a/ICSharpCode.NRefactory/Utils/LazyInit.cs +++ b/ICSharpCode.NRefactory/Utils/LazyInit.cs @@ -28,6 +28,8 @@ namespace ICSharpCode.NRefactory.Utils { static volatile object barrier = null; + [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1804:RemoveUnusedLocals", MessageId = "tmp", + Justification = "The volatile read is important to cause a read barrier.")] public static void ReadBarrier() { object tmp = barrier; diff --git a/ICSharpCode.NRefactory/Utils/ReferenceComparer.cs b/ICSharpCode.NRefactory/Utils/ReferenceComparer.cs index 0cc64ba467..eaa96b2da9 100644 --- a/ICSharpCode.NRefactory/Utils/ReferenceComparer.cs +++ b/ICSharpCode.NRefactory/Utils/ReferenceComparer.cs @@ -26,9 +26,9 @@ namespace ICSharpCode.NRefactory.Utils { public readonly static ReferenceComparer Instance = new ReferenceComparer(); - public new bool Equals(object a, object b) + public new bool Equals(object x, object y) { - return a == b; + return x == y; } public int GetHashCode(object obj)