Browse Source

Fixed some FxCop warnings.

newNRvisualizers
Daniel Grunwald 14 years ago
parent
commit
fe8e098a27
  1. 4
      ICSharpCode.NRefactory.CSharp/Ast/AstNode.cs
  2. 2
      ICSharpCode.NRefactory.CSharp/Formatter/AstFormattingVisitor.cs
  3. 2
      ICSharpCode.NRefactory.CSharp/OutputVisitor/CSharpAmbience.cs
  4. 4
      ICSharpCode.NRefactory.CSharp/Resolver/ResolveVisitor.cs
  5. 6
      ICSharpCode.NRefactory.CSharp/TypeSystem/ConstantValues.cs
  6. 2
      ICSharpCode.NRefactory.Tests/TypeSystem/TypeSystemTests.cs
  7. 4
      ICSharpCode.NRefactory.VB/Ast/AstNode.cs
  8. 6
      ICSharpCode.NRefactory/Completion/CompletionCategory.cs
  9. 6
      ICSharpCode.NRefactory/Documentation/DocumentationComment.cs
  10. 2
      ICSharpCode.NRefactory/Documentation/IdStringProvider.cs
  11. 2
      ICSharpCode.NRefactory/Documentation/XmlDocumentationProvider.cs
  12. 1
      ICSharpCode.NRefactory/Editor/ITextSource.cs
  13. 19
      ICSharpCode.NRefactory/IAnnotatable.cs
  14. 3
      ICSharpCode.NRefactory/ICSharpCode.NRefactory.csproj
  15. 12
      ICSharpCode.NRefactory/Semantics/ArrayAccessResolveResult.cs
  16. 6
      ICSharpCode.NRefactory/Semantics/ArrayCreateResolveResult.cs
  17. 3
      ICSharpCode.NRefactory/Semantics/ByReferenceResolveResult.cs
  18. 3
      ICSharpCode.NRefactory/Semantics/ConstantResolveResult.cs
  19. 4
      ICSharpCode.NRefactory/Semantics/InvocationResolveResult.cs
  20. 3
      ICSharpCode.NRefactory/Semantics/LocalResolveResult.cs
  21. 4
      ICSharpCode.NRefactory/Semantics/MemberResolveResult.cs
  22. 3
      ICSharpCode.NRefactory/Semantics/NamespaceResolveResult.cs
  23. 2
      ICSharpCode.NRefactory/Semantics/ResolveResult.cs
  24. 5
      ICSharpCode.NRefactory/Semantics/UnknownMemberResolveResult.cs
  25. 22
      ICSharpCode.NRefactory/TypeSystem/CecilLoader.cs
  26. 4
      ICSharpCode.NRefactory/TypeSystem/ComHelper.cs
  27. 8
      ICSharpCode.NRefactory/TypeSystem/IAmbience.cs
  28. 10
      ICSharpCode.NRefactory/TypeSystem/Implementation/AbstractResolvedTypeParameter.cs
  29. 2
      ICSharpCode.NRefactory/TypeSystem/Implementation/AbstractUnresolvedEntity.cs
  30. 2
      ICSharpCode.NRefactory/TypeSystem/Implementation/AbstractUnresolvedMember.cs
  31. 4
      ICSharpCode.NRefactory/TypeSystem/Implementation/DefaultAssemblyReference.cs
  32. 18
      ICSharpCode.NRefactory/TypeSystem/Implementation/DefaultParameter.cs
  33. 2
      ICSharpCode.NRefactory/TypeSystem/Implementation/DefaultUnresolvedAssembly.cs
  34. 6
      ICSharpCode.NRefactory/TypeSystem/Implementation/DefaultUnresolvedParameter.cs
  35. 11
      ICSharpCode.NRefactory/TypeSystem/Implementation/DefaultUnresolvedTypeDefinition.cs
  36. 10
      ICSharpCode.NRefactory/TypeSystem/Implementation/DefaultUnresolvedTypeParameter.cs
  37. 27
      ICSharpCode.NRefactory/TypeSystem/Implementation/FullNameAndTypeParameterCount.cs
  38. 2
      ICSharpCode.NRefactory/TypeSystem/Implementation/GetClassTypeReference.cs
  39. 4
      ICSharpCode.NRefactory/TypeSystem/Implementation/MergedNamespace.cs
  40. 2
      ICSharpCode.NRefactory/TypeSystem/Implementation/SimpleConstantValue.cs
  41. 5
      ICSharpCode.NRefactory/TypeSystem/Implementation/TypeParameterReference.cs
  42. 2
      ICSharpCode.NRefactory/TypeSystem/InheritanceHelper.cs
  43. 3
      ICSharpCode.NRefactory/Utils/BitVector16.cs
  44. 5
      ICSharpCode.NRefactory/Utils/BusyManager.cs
  45. 14
      ICSharpCode.NRefactory/Utils/CacheManager.cs
  46. 4
      ICSharpCode.NRefactory/Utils/EmptyList.cs
  47. 8
      ICSharpCode.NRefactory/Utils/FastSerializer.cs
  48. 2
      ICSharpCode.NRefactory/Utils/LazyInit.cs
  49. 4
      ICSharpCode.NRefactory/Utils/ReferenceComparer.cs

4
ICSharpCode.NRefactory.CSharp/Ast/AstNode.cs

@ -471,9 +471,7 @@ namespace ICSharpCode.NRefactory.CSharp
} }
// Finally, clone the annotation, if necessary // Finally, clone the annotation, if necessary
ICloneable copiedAnnotations = copy.annotations as ICloneable; // read from copy (for thread-safety) copy.CloneAnnotations();
if (copiedAnnotations != null)
copy.annotations = copiedAnnotations.Clone();
return copy; return copy;
} }

2
ICSharpCode.NRefactory.CSharp/Formatter/AstFormattingVisitor.cs

@ -704,7 +704,6 @@ namespace ICSharpCode.NRefactory.CSharp
} }
FormatCommas (constructorDeclaration, policy.SpaceBeforeConstructorDeclarationParameterComma, policy.SpaceAfterConstructorDeclarationParameterComma); FormatCommas (constructorDeclaration, policy.SpaceBeforeConstructorDeclarationParameterComma, policy.SpaceAfterConstructorDeclarationParameterComma);
object result = null;
if (!constructorDeclaration.Body.IsNull) { if (!constructorDeclaration.Body.IsNull) {
EnforceBraceStyle (policy.ConstructorBraceStyle, constructorDeclaration.Body.LBraceToken, constructorDeclaration.Body.RBraceToken); EnforceBraceStyle (policy.ConstructorBraceStyle, constructorDeclaration.Body.LBraceToken, constructorDeclaration.Body.RBraceToken);
if (policy.IndentMethodBody) if (policy.IndentMethodBody)
@ -725,7 +724,6 @@ namespace ICSharpCode.NRefactory.CSharp
int offset = this.document.GetOffset (lParen.StartLocation); int offset = this.document.GetOffset (lParen.StartLocation);
ForceSpaceBefore (offset, policy.SpaceBeforeConstructorDeclarationParentheses); ForceSpaceBefore (offset, policy.SpaceBeforeConstructorDeclarationParentheses);
object result = null;
if (!destructorDeclaration.Body.IsNull) { if (!destructorDeclaration.Body.IsNull) {
EnforceBraceStyle (policy.DestructorBraceStyle, destructorDeclaration.Body.LBraceToken, destructorDeclaration.Body.RBraceToken); EnforceBraceStyle (policy.DestructorBraceStyle, destructorDeclaration.Body.LBraceToken, destructorDeclaration.Body.RBraceToken);
if (policy.IndentMethodBody) if (policy.IndentMethodBody)

2
ICSharpCode.NRefactory.CSharp/OutputVisitor/CSharpAmbience.cs

@ -55,7 +55,7 @@ namespace ICSharpCode.NRefactory.CSharp
EntityDeclaration node = astBuilder.ConvertEntity(entity); EntityDeclaration node = astBuilder.ConvertEntity(entity);
PrintModifiers(node.Modifiers, formatter); PrintModifiers(node.Modifiers, formatter);
if ((ConversionFlags & ConversionFlags.ShowDefinitionKeyWord) == ConversionFlags.ShowDefinitionKeyWord) { if ((ConversionFlags & ConversionFlags.ShowDefinitionKeyword) == ConversionFlags.ShowDefinitionKeyword) {
if (node is TypeDeclaration) { if (node is TypeDeclaration) {
switch (((TypeDeclaration)node).ClassType) { switch (((TypeDeclaration)node).ClassType) {
case ClassType.Class: case ClassType.Class:

4
ICSharpCode.NRefactory.CSharp/Resolver/ResolveVisitor.cs

@ -473,7 +473,7 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver
while (!resolverBeforeDict.TryGetValue(parent, out storedResolver)) { while (!resolverBeforeDict.TryGetValue(parent, out storedResolver)) {
parent = parent.Parent; parent = parent.Parent;
if (parent == null) 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; return storedResolver;
} }
@ -1255,7 +1255,7 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver
ResolveResult rr = resolver.ResolveIndexer(targetResult, arguments, argumentNames); ResolveResult rr = resolver.ResolveIndexer(targetResult, arguments, argumentNames);
ArrayAccessResolveResult aarr = rr as ArrayAccessResolveResult; ArrayAccessResolveResult aarr = rr as ArrayAccessResolveResult;
if (aarr != null) { if (aarr != null) {
ProcessConversionResults(indexerExpression.Arguments, aarr.Indices); ProcessConversionResults(indexerExpression.Arguments, aarr.Indexes);
} else { } else {
ProcessConversionsInInvocation(target, indexerExpression.Arguments, rr as CSharpInvocationResolveResult); ProcessConversionsInInvocation(target, indexerExpression.Arguments, rr as CSharpInvocationResolveResult);
} }

6
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<ResolveResult> input, ITypeResolveContext newContext)
{ {
if (input == null) if (input == null)
return null; return null;
ResolveResult[] output = new ResolveResult[input.Length]; ResolveResult[] output = new ResolveResult[input.Count];
for (int i = 0; i < input.Length; i++) { for (int i = 0; i < output.Length; i++) {
output[i] = MapToNewContext(input[i], newContext); output[i] = MapToNewContext(input[i], newContext);
} }
return output; return output;

2
ICSharpCode.NRefactory.Tests/TypeSystem/TypeSystemTests.cs

@ -613,7 +613,7 @@ namespace ICSharpCode.NRefactory.TypeSystem
{ {
ITypeDefinition type = GetTypeDefinition(typeof(ParamsAttribute)); ITypeDefinition type = GetTypeDefinition(typeof(ParamsAttribute));
var arr = (ArrayCreateResolveResult)type.Attributes.Single().PositionalArguments.Single(); var arr = (ArrayCreateResolveResult)type.Attributes.Single().PositionalArguments.Single();
Assert.AreEqual(5, arr.InitializerElements.Length); Assert.AreEqual(5, arr.InitializerElements.Count);
return arr.InitializerElements[index]; return arr.InitializerElements[index];
} }

4
ICSharpCode.NRefactory.VB/Ast/AstNode.cs

@ -413,9 +413,7 @@ namespace ICSharpCode.NRefactory.VB
} }
// Finally, clone the annotation, if necessary // Finally, clone the annotation, if necessary
ICloneable annotations = copy.annotations as ICloneable; // read from copy (for thread-safety) copy.CloneAnnotations();
if (annotations != null)
copy.annotations = annotations.Clone();
return copy; return copy;
} }

6
ICSharpCode.NRefactory/Completion/CompletionCategory.cs

@ -1,4 +1,4 @@
// //
// CompletionCategory.cs // CompletionCategory.cs
// //
// Author: // Author:
@ -33,11 +33,11 @@ namespace ICSharpCode.NRefactory.Completion
public string Icon { get; set; } 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.DisplayText = displayText;
this.Icon = icon; this.Icon = icon;

6
ICSharpCode.NRefactory/Documentation/DocumentationComment.cs

@ -85,10 +85,10 @@ namespace ICSharpCode.NRefactory.Documentation
return Xml.Text; return Xml.Text;
} }
public static implicit operator string (DocumentationComment cmt) public static implicit operator string (DocumentationComment documentationComment)
{ {
if (cmt != null) if (documentationComment != null)
return cmt.ToString (); return documentationComment.ToString ();
return null; return null;
} }
} }

2
ICSharpCode.NRefactory/Documentation/IdStringProvider.cs

@ -187,7 +187,7 @@ namespace ICSharpCode.NRefactory.Documentation
public static IMemberReference ParseMemberIdString(string memberIdString) public static IMemberReference ParseMemberIdString(string memberIdString)
{ {
if (memberIdString == null) if (memberIdString == null)
throw new ArgumentNullException("memberIDString"); throw new ArgumentNullException("memberIdString");
if (memberIdString.Length < 2 || memberIdString[1] != ':') if (memberIdString.Length < 2 || memberIdString[1] != ':')
throw new ReflectionNameParseException(0, "Missing type tag"); throw new ReflectionNameParseException(0, "Missing type tag");
char typeChar = memberIdString[0]; char typeChar = memberIdString[0];

2
ICSharpCode.NRefactory/Documentation/XmlDocumentationProvider.cs

@ -242,7 +242,7 @@ namespace ICSharpCode.NRefactory.Documentation
} }
} }
void ReadMembersSection(XmlTextReader reader, LinePositionMapper linePosMapper, List<IndexEntry> indexList) static void ReadMembersSection(XmlTextReader reader, LinePositionMapper linePosMapper, List<IndexEntry> indexList)
{ {
while (reader.Read()) { while (reader.Read()) {
switch (reader.NodeType) { switch (reader.NodeType) {

1
ICSharpCode.NRefactory/Editor/ITextSource.cs

@ -67,6 +67,7 @@ namespace ICSharpCode.NRefactory.Editor
/// <summary> /// <summary>
/// Gets the whole text as string. /// Gets the whole text as string.
/// </summary> /// </summary>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1721:PropertyNamesShouldNotMatchGetMethods")]
string Text { get; } string Text { get; }
/// <summary> /// <summary>

19
ICSharpCode.NRefactory/IAnnotatable.cs

@ -85,9 +85,22 @@ namespace ICSharpCode.NRefactory
// or to an AnnotationList. // or to an AnnotationList.
// Once it is pointed at an AnnotationList, it will never change (this allows thread-safety support by locking the list) // Once it is pointed at an AnnotationList, it will never change (this allows thread-safety support by locking the list)
[CLSCompliant(false)] object annotations;
[NonSerialized]
protected object annotations; /// <summary>
/// Clones all annotations.
/// This method is intended to be called by Clone() implementations in derived classes.
/// <code>
/// AstNode copy = (AstNode)MemberwiseClone();
/// copy.CloneAnnotations();
/// </code>
/// </summary>
protected void CloneAnnotations()
{
ICloneable cloneable = annotations as ICloneable;
if (cloneable != null)
annotations = cloneable.Clone();
}
sealed class AnnotationList : List<object>, ICloneable sealed class AnnotationList : List<object>, ICloneable
{ {

3
ICSharpCode.NRefactory/ICSharpCode.NRefactory.csproj

@ -14,7 +14,7 @@
<NoStdLib>False</NoStdLib> <NoStdLib>False</NoStdLib>
<TreatWarningsAsErrors>false</TreatWarningsAsErrors> <TreatWarningsAsErrors>false</TreatWarningsAsErrors>
<RunCodeAnalysis>False</RunCodeAnalysis> <RunCodeAnalysis>False</RunCodeAnalysis>
<CodeAnalysisRules>-Microsoft.Design#CA1026;-Microsoft.Security#CA2104</CodeAnalysisRules> <CodeAnalysisRules>-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</CodeAnalysisRules>
<SignAssembly>true</SignAssembly> <SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>..\ICSharpCode.NRefactory.snk</AssemblyOriginatorKeyFile> <AssemblyOriginatorKeyFile>..\ICSharpCode.NRefactory.snk</AssemblyOriginatorKeyFile>
<DelaySign>False</DelaySign> <DelaySign>False</DelaySign>
@ -35,6 +35,7 @@
<Optimize>False</Optimize> <Optimize>False</Optimize>
<DefineConstants>DEBUG;TRACE</DefineConstants> <DefineConstants>DEBUG;TRACE</DefineConstants>
<CheckForOverflowUnderflow>True</CheckForOverflowUnderflow> <CheckForOverflowUnderflow>True</CheckForOverflowUnderflow>
<StartAction>Project</StartAction>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Release' "> <PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<OutputPath>bin\Release\</OutputPath> <OutputPath>bin\Release\</OutputPath>

12
ICSharpCode.NRefactory/Semantics/ArrayAccessResolveResult.cs

@ -30,21 +30,21 @@ namespace ICSharpCode.NRefactory.Semantics
public class ArrayAccessResolveResult : ResolveResult public class ArrayAccessResolveResult : ResolveResult
{ {
public readonly ResolveResult Array; public readonly ResolveResult Array;
public readonly ResolveResult[] Indices; public readonly IList<ResolveResult> Indexes;
public ArrayAccessResolveResult(IType elementType, ResolveResult array, ResolveResult[] indices) : base(elementType) public ArrayAccessResolveResult(IType elementType, ResolveResult array, IList<ResolveResult> indexes) : base(elementType)
{ {
if (array == null) if (array == null)
throw new ArgumentNullException("array"); throw new ArgumentNullException("array");
if (indices == null) if (indexes == null)
throw new ArgumentNullException("indices"); throw new ArgumentNullException("indexes");
this.Array = array; this.Array = array;
this.Indices = indices; this.Indexes = indexes;
} }
public override IEnumerable<ResolveResult> GetChildResults() public override IEnumerable<ResolveResult> GetChildResults()
{ {
return new [] { Array }.Concat(Indices); return new [] { Array }.Concat(Indexes);
} }
} }
} }

6
ICSharpCode.NRefactory/Semantics/ArrayCreateResolveResult.cs

@ -32,15 +32,15 @@ namespace ICSharpCode.NRefactory.Semantics
/// <summary> /// <summary>
/// Gets the size arguments. /// Gets the size arguments.
/// </summary> /// </summary>
public readonly ResolveResult[] SizeArguments; public readonly IList<ResolveResult> SizeArguments;
/// <summary> /// <summary>
/// Gets the initializer elements. /// Gets the initializer elements.
/// This field may be null if no initializer was specified. /// This field may be null if no initializer was specified.
/// </summary> /// </summary>
public readonly ResolveResult[] InitializerElements; public readonly IList<ResolveResult> InitializerElements;
public ArrayCreateResolveResult(IType arrayType, ResolveResult[] sizeArguments, ResolveResult[] initializerElements) public ArrayCreateResolveResult(IType arrayType, IList<ResolveResult> sizeArguments, IList<ResolveResult> initializerElements)
: base(arrayType) : base(arrayType)
{ {
this.SizeArguments = sizeArguments; this.SizeArguments = sizeArguments;

3
ICSharpCode.NRefactory/Semantics/ByReferenceResolveResult.cs

@ -18,6 +18,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Globalization;
using System.Linq; using System.Linq;
using ICSharpCode.NRefactory.TypeSystem; using ICSharpCode.NRefactory.TypeSystem;
@ -59,7 +60,7 @@ namespace ICSharpCode.NRefactory.Semantics
public override string ToString() 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);
} }
} }
} }

3
ICSharpCode.NRefactory/Semantics/ConstantResolveResult.cs

@ -17,6 +17,7 @@
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
using System; using System;
using System.Globalization;
using ICSharpCode.NRefactory.TypeSystem; using ICSharpCode.NRefactory.TypeSystem;
namespace ICSharpCode.NRefactory.Semantics namespace ICSharpCode.NRefactory.Semantics
@ -43,7 +44,7 @@ namespace ICSharpCode.NRefactory.Semantics
public override string ToString() 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);
} }
} }
} }

4
ICSharpCode.NRefactory/Semantics/InvocationResolveResult.cs

@ -35,7 +35,7 @@ namespace ICSharpCode.NRefactory.Semantics
/// </summary> /// </summary>
public readonly IList<ResolveResult> Arguments; public readonly IList<ResolveResult> Arguments;
public InvocationResolveResult(ResolveResult targetResult, IParameterizedMember member, IList<ResolveResult> arguments) protected InvocationResolveResult(ResolveResult targetResult, IParameterizedMember member, IList<ResolveResult> arguments)
: base(targetResult, member) : base(targetResult, member)
{ {
this.Arguments = arguments ?? EmptyList<ResolveResult>.Instance; this.Arguments = arguments ?? EmptyList<ResolveResult>.Instance;
@ -49,6 +49,8 @@ namespace ICSharpCode.NRefactory.Semantics
/// Gets the arguments in the order they are being passed to the method. /// Gets the arguments in the order they are being passed to the method.
/// For parameter arrays (params), this will return an ArrayCreateResolveResult. /// For parameter arrays (params), this will return an ArrayCreateResolveResult.
/// </summary> /// </summary>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate",
Justification = "Derived methods may be expensive and create new lists")]
public virtual IList<ResolveResult> GetArgumentsForCall() public virtual IList<ResolveResult> GetArgumentsForCall()
{ {
return Arguments; return Arguments;

3
ICSharpCode.NRefactory/Semantics/LocalResolveResult.cs

@ -17,6 +17,7 @@
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
using System; using System;
using System.Globalization;
using ICSharpCode.NRefactory.TypeSystem; using ICSharpCode.NRefactory.TypeSystem;
namespace ICSharpCode.NRefactory.Semantics namespace ICSharpCode.NRefactory.Semantics
@ -65,7 +66,7 @@ namespace ICSharpCode.NRefactory.Semantics
public override string ToString() public override string ToString()
{ {
return string.Format("[LocalResolveResult {0}]", variable); return string.Format(CultureInfo.InvariantCulture, "[LocalResolveResult {0}]", variable);
} }
public override DomRegion GetDefinitionRegion() public override DomRegion GetDefinitionRegion()

4
ICSharpCode.NRefactory/Semantics/MemberResolveResult.cs

@ -18,7 +18,9 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Globalization;
using System.Linq; using System.Linq;
using ICSharpCode.NRefactory.TypeSystem; using ICSharpCode.NRefactory.TypeSystem;
namespace ICSharpCode.NRefactory.Semantics namespace ICSharpCode.NRefactory.Semantics
@ -85,7 +87,7 @@ namespace ICSharpCode.NRefactory.Semantics
public override string ToString() 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() public override DomRegion GetDefinitionRegion()

3
ICSharpCode.NRefactory/Semantics/NamespaceResolveResult.cs

@ -17,6 +17,7 @@
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
using System; using System;
using System.Globalization;
using ICSharpCode.NRefactory.TypeSystem; using ICSharpCode.NRefactory.TypeSystem;
namespace ICSharpCode.NRefactory.Semantics namespace ICSharpCode.NRefactory.Semantics
@ -43,7 +44,7 @@ namespace ICSharpCode.NRefactory.Semantics
public override string ToString() public override string ToString()
{ {
return string.Format("[{0} {1}]", GetType().Name, ns); return string.Format(CultureInfo.InvariantCulture, "[{0} {1}]", GetType().Name, ns);
} }
} }
} }

2
ICSharpCode.NRefactory/Semantics/ResolveResult.cs

@ -38,6 +38,8 @@ namespace ICSharpCode.NRefactory.Semantics
this.type = type; this.type = type;
} }
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1721:PropertyNamesShouldNotMatchGetMethods",
Justification = "Unrelated to object.GetType()")]
public IType Type { public IType Type {
get { return type; } get { return type; }
} }

5
ICSharpCode.NRefactory/Semantics/UnknownMemberResolveResult.cs

@ -19,6 +19,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.Globalization;
using System.Linq; using System.Linq;
using ICSharpCode.NRefactory.TypeSystem; using ICSharpCode.NRefactory.TypeSystem;
@ -64,7 +65,7 @@ namespace ICSharpCode.NRefactory.Semantics
public override string ToString() 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() public override string ToString()
{ {
return string.Format("[{0} {1}]", GetType().Name, identifier); return string.Format(CultureInfo.InvariantCulture, "[{0} {1}]", GetType().Name, identifier);
} }
} }
} }

22
ICSharpCode.NRefactory/TypeSystem/CecilLoader.cs

@ -424,7 +424,7 @@ namespace ICSharpCode.NRefactory.TypeSystem
static readonly ITypeReference methodImplAttributeTypeRef = typeof(MethodImplAttribute).ToTypeReference(); static readonly ITypeReference methodImplAttributeTypeRef = typeof(MethodImplAttribute).ToTypeReference();
static readonly ITypeReference methodImplOptionsTypeRef = typeof(MethodImplOptions).ToTypeReference(); static readonly ITypeReference methodImplOptionsTypeRef = typeof(MethodImplOptions).ToTypeReference();
bool HasAnyAttributes(MethodDefinition methodDefinition) static bool HasAnyAttributes(MethodDefinition methodDefinition)
{ {
if (methodDefinition.HasPInvokeInfo) if (methodDefinition.HasPInvokeInfo)
return true; return true;
@ -891,10 +891,6 @@ namespace ICSharpCode.NRefactory.TypeSystem
} }
} }
public ICompilation Compilation {
get { return context.Compilation; }
}
public override string ToString() public override string ToString()
{ {
return "[" + attributeType.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() public float ReadSingle()
{ {
unchecked { unchecked {

4
ICSharpCode.NRefactory/TypeSystem/ComHelper.cs

@ -25,7 +25,7 @@ namespace ICSharpCode.NRefactory.TypeSystem
/// <summary> /// <summary>
/// Helper methods for COM. /// Helper methods for COM.
/// </summary> /// </summary>
public class ComHelper public static class ComHelper
{ {
static bool IsComAttribute(IAttribute attribute, string name) static bool IsComAttribute(IAttribute attribute, string name)
{ {
@ -45,6 +45,8 @@ namespace ICSharpCode.NRefactory.TypeSystem
/// <summary> /// <summary>
/// Gets the CoClass of the specified COM interface. /// Gets the CoClass of the specified COM interface.
/// </summary> /// </summary>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Co",
Justification = "Consistent with CoClassAttribute")]
public static IType GetCoClass(ITypeDefinition typeDefinition) public static IType GetCoClass(ITypeDefinition typeDefinition)
{ {
if (typeDefinition == null) if (typeDefinition == null)

8
ICSharpCode.NRefactory/TypeSystem/IAmbience.cs

@ -42,7 +42,7 @@ namespace ICSharpCode.NRefactory.TypeSystem
/// <summary> /// <summary>
/// Show the definition key word (class, struct, Sub, Function, etc.) /// Show the definition key word (class, struct, Sub, Function, etc.)
/// </summary> /// </summary>
ShowDefinitionKeyWord = 8, ShowDefinitionKeyword = 8,
/// <summary> /// <summary>
/// Show the declaring type for the member /// Show the declaring type for the member
/// </summary> /// </summary>
@ -76,17 +76,17 @@ namespace ICSharpCode.NRefactory.TypeSystem
ShowReturnType | ShowReturnType |
ShowModifiers | ShowModifiers |
ShowTypeParameterList | ShowTypeParameterList |
ShowDefinitionKeyWord | ShowDefinitionKeyword |
ShowBody, ShowBody,
All = 0xfff, All = 0x3ff,
} }
public interface IAmbience public interface IAmbience
{ {
ConversionFlags ConversionFlags { get; set; } ConversionFlags ConversionFlags { get; set; }
string ConvertEntity(IEntity e); string ConvertEntity(IEntity entity);
string ConvertType(IType type); string ConvertType(IType type);
string ConvertVariable(IVariable variable); string ConvertVariable(IVariable variable);

10
ICSharpCode.NRefactory/TypeSystem/Implementation/AbstractResolvedTypeParameter.cs

@ -18,8 +18,8 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Globalization;
using System.Threading;
using ICSharpCode.NRefactory.Utils; using ICSharpCode.NRefactory.Utils;
namespace ICSharpCode.NRefactory.TypeSystem.Implementation namespace ICSharpCode.NRefactory.TypeSystem.Implementation
@ -43,7 +43,7 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation
this.compilation = owner.Compilation; this.compilation = owner.Compilation;
this.ownerType = owner.EntityType; this.ownerType = owner.EntityType;
this.index = index; 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<IAttribute>.Instance; this.attributes = attributes ?? EmptyList<IAttribute>.Instance;
this.region = region; this.region = region;
this.variance = variance; this.variance = variance;
@ -56,7 +56,7 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation
this.compilation = compilation; this.compilation = compilation;
this.ownerType = ownerType; this.ownerType = ownerType;
this.index = index; 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<IAttribute>.Instance; this.attributes = attributes ?? EmptyList<IAttribute>.Instance;
this.region = region; this.region = region;
this.variance = variance; this.variance = variance;
@ -198,7 +198,7 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation
public string ReflectionName { public string ReflectionName {
get { get {
return (this.OwnerType == EntityType.Method ? "``" : "`") + index.ToString(); return (this.OwnerType == EntityType.Method ? "``" : "`") + index.ToString(CultureInfo.InvariantCulture);
} }
} }

2
ICSharpCode.NRefactory/TypeSystem/Implementation/AbstractUnresolvedEntity.cs

@ -174,7 +174,7 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation
get { return name; } get { return name; }
set { set {
if (value == null) if (value == null)
throw new ArgumentNullException(); throw new ArgumentNullException("value");
ThrowIfFrozen(); ThrowIfFrozen();
name = value; name = value;
} }

2
ICSharpCode.NRefactory/TypeSystem/Implementation/AbstractUnresolvedMember.cs

@ -68,7 +68,7 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation
get { return returnType; } get { return returnType; }
set { set {
if (value == null) if (value == null)
throw new ArgumentNullException(); throw new ArgumentNullException("value");
ThrowIfFrozen(); ThrowIfFrozen();
returnType = value; returnType = value;
} }

4
ICSharpCode.NRefactory/TypeSystem/Implementation/DefaultAssemblyReference.cs

@ -26,8 +26,8 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation
[Serializable] [Serializable]
public sealed class DefaultAssemblyReference : IAssemblyReference, ISupportsInterning public sealed class DefaultAssemblyReference : IAssemblyReference, ISupportsInterning
{ {
public static IAssemblyReference CurrentAssembly = new CurrentAssemblyReference(); public static readonly IAssemblyReference CurrentAssembly = new CurrentAssemblyReference();
public static IAssemblyReference Corlib = new DefaultAssemblyReference("mscorlib"); public static readonly IAssemblyReference Corlib = new DefaultAssemblyReference("mscorlib");
string shortName; string shortName;

18
ICSharpCode.NRefactory/TypeSystem/Implementation/DefaultParameter.cs

@ -107,22 +107,22 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation
return ToString(this); return ToString(this);
} }
public static string ToString(IParameter p) public static string ToString(IParameter parameter)
{ {
StringBuilder b = new StringBuilder(); StringBuilder b = new StringBuilder();
if (p.IsRef) if (parameter.IsRef)
b.Append("ref "); b.Append("ref ");
if (p.IsOut) if (parameter.IsOut)
b.Append("out "); b.Append("out ");
if (p.IsParams) if (parameter.IsParams)
b.Append("params "); b.Append("params ");
b.Append(p.Name); b.Append(parameter.Name);
b.Append(':'); b.Append(':');
b.Append(p.Type.ToString()); b.Append(parameter.Type.ToString());
if (p.IsOptional) { if (parameter.IsOptional) {
b.Append(" = "); b.Append(" = ");
if (p.ConstantValue != null) if (parameter.ConstantValue != null)
b.Append(p.ConstantValue.ToString()); b.Append(parameter.ConstantValue.ToString());
else else
b.Append("null"); b.Append("null");
} }

2
ICSharpCode.NRefactory/TypeSystem/Implementation/DefaultUnresolvedAssembly.cs

@ -61,7 +61,7 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation
get { return assemblyName; } get { return assemblyName; }
set { set {
if (value == null) if (value == null)
throw new ArgumentNullException(); throw new ArgumentNullException("value");
FreezableHelper.ThrowIfFrozen(this); FreezableHelper.ThrowIfFrozen(this);
assemblyName = value; assemblyName = value;
} }

6
ICSharpCode.NRefactory/TypeSystem/Implementation/DefaultUnresolvedParameter.cs

@ -18,8 +18,8 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics.Contracts;
using System.Text; using System.Text;
using ICSharpCode.NRefactory.Semantics; using ICSharpCode.NRefactory.Semantics;
using ICSharpCode.NRefactory.Utils; using ICSharpCode.NRefactory.Utils;
@ -62,7 +62,7 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation
get { return name; } get { return name; }
set { set {
if (value == null) if (value == null)
throw new ArgumentNullException(); throw new ArgumentNullException("value");
FreezableHelper.ThrowIfFrozen(this); FreezableHelper.ThrowIfFrozen(this);
name = value; name = value;
} }
@ -72,7 +72,7 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation
get { return type; } get { return type; }
set { set {
if (value == null) if (value == null)
throw new ArgumentNullException(); throw new ArgumentNullException("value");
FreezableHelper.ThrowIfFrozen(this); FreezableHelper.ThrowIfFrozen(this);
type = value; type = value;
} }

11
ICSharpCode.NRefactory/TypeSystem/Implementation/DefaultUnresolvedTypeDefinition.cs

@ -17,8 +17,9 @@
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
using System; using System;
using System.Linq;
using System.Collections.Generic; using System.Collections.Generic;
using System.Globalization;
using System.Linq;
namespace ICSharpCode.NRefactory.TypeSystem.Implementation namespace ICSharpCode.NRefactory.TypeSystem.Implementation
{ {
@ -110,7 +111,7 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation
get { return namespaceName; } get { return namespaceName; }
set { set {
if (value == null) if (value == null)
throw new ArgumentNullException(); throw new ArgumentNullException("value");
ThrowIfFrozen(); ThrowIfFrozen();
namespaceName = value; namespaceName = value;
} }
@ -121,18 +122,18 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation
IUnresolvedTypeDefinition declaringTypeDef = this.DeclaringTypeDefinition; IUnresolvedTypeDefinition declaringTypeDef = this.DeclaringTypeDefinition;
if (declaringTypeDef != null) { if (declaringTypeDef != null) {
if (this.TypeParameters.Count > declaringTypeDef.TypeParameters.Count) { 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 { } else {
return declaringTypeDef.ReflectionName + "+" + this.Name; return declaringTypeDef.ReflectionName + "+" + this.Name;
} }
} else if (string.IsNullOrEmpty(namespaceName)) { } else if (string.IsNullOrEmpty(namespaceName)) {
if (this.TypeParameters.Count > 0) if (this.TypeParameters.Count > 0)
return this.Name + "`" + this.TypeParameters.Count.ToString(); return this.Name + "`" + this.TypeParameters.Count.ToString(CultureInfo.InvariantCulture);
else else
return this.Name; return this.Name;
} else { } else {
if (this.TypeParameters.Count > 0) if (this.TypeParameters.Count > 0)
return namespaceName + "." + this.Name + "`" + this.TypeParameters.Count.ToString(); return namespaceName + "." + this.Name + "`" + this.TypeParameters.Count.ToString(CultureInfo.InvariantCulture);
else else
return namespaceName + "." + this.Name; return namespaceName + "." + this.Name;
} }

10
ICSharpCode.NRefactory/TypeSystem/Implementation/DefaultUnresolvedTypeParameter.cs

@ -18,8 +18,8 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Globalization;
using System.Threading;
using ICSharpCode.NRefactory.Utils; using ICSharpCode.NRefactory.Utils;
namespace ICSharpCode.NRefactory.TypeSystem.Implementation namespace ICSharpCode.NRefactory.TypeSystem.Implementation
@ -61,7 +61,7 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation
{ {
this.ownerType = ownerType; this.ownerType = ownerType;
this.index = index; this.index = index;
this.name = name ?? ((ownerType == EntityType.Method ? "!!" : "!") + index.ToString()); this.name = name ?? ((ownerType == EntityType.Method ? "!!" : "!") + index.ToString(CultureInfo.InvariantCulture));
} }
public EntityType OwnerType { public EntityType OwnerType {
@ -95,9 +95,9 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation
string INamedElement.ReflectionName { string INamedElement.ReflectionName {
get { get {
if (ownerType == EntityType.Method) if (ownerType == EntityType.Method)
return "``" + index.ToString(); return "``" + index.ToString(CultureInfo.InvariantCulture);
else else
return "`" + index.ToString(); return "`" + index.ToString(CultureInfo.InvariantCulture);
} }
} }

27
ICSharpCode.NRefactory/TypeSystem/Implementation/FullNameAndTypeParameterCount.cs

@ -22,7 +22,7 @@ using System.Collections.Generic;
namespace ICSharpCode.NRefactory.TypeSystem.Implementation namespace ICSharpCode.NRefactory.TypeSystem.Implementation
{ {
[Serializable] [Serializable]
public struct FullNameAndTypeParameterCount public struct FullNameAndTypeParameterCount : IEquatable<FullNameAndTypeParameterCount>
{ {
public readonly string Namespace; public readonly string Namespace;
public readonly string Name; public readonly string Name;
@ -38,6 +38,31 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation
this.Name = name; this.Name = name;
this.TypeParameterCount = typeParameterCount; 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] [Serializable]

2
ICSharpCode.NRefactory/TypeSystem/Implementation/GetClassTypeReference.cs

@ -18,8 +18,6 @@
using System; using System;
using System.Linq; using System.Linq;
using System.Linq.Expressions;
using ICSharpCode.NRefactory.Utils;
namespace ICSharpCode.NRefactory.TypeSystem.Implementation namespace ICSharpCode.NRefactory.TypeSystem.Implementation
{ {

4
ICSharpCode.NRefactory/TypeSystem/Implementation/MergedNamespace.cs

@ -18,6 +18,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Globalization;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using ICSharpCode.NRefactory.Utils; using ICSharpCode.NRefactory.Utils;
@ -145,7 +146,8 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation
public override string ToString() 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);
} }
} }
} }

2
ICSharpCode.NRefactory/TypeSystem/Implementation/SimpleConstantValue.cs

@ -43,6 +43,8 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation
return new ConstantResolveResult(type.Resolve(context), value); 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() public override string ToString()
{ {
if (value == null) if (value == null)

5
ICSharpCode.NRefactory/TypeSystem/Implementation/TypeParameterReference.cs

@ -17,6 +17,7 @@
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
using System; using System;
using System.Globalization;
namespace ICSharpCode.NRefactory.TypeSystem.Implementation namespace ICSharpCode.NRefactory.TypeSystem.Implementation
{ {
@ -69,9 +70,9 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation
public override string ToString() public override string ToString()
{ {
if (ownerType == EntityType.Method) if (ownerType == EntityType.Method)
return "!!" + index.ToString(); return "!!" + index.ToString(CultureInfo.InvariantCulture);
else else
return "!" + index.ToString(); return "!" + index.ToString(CultureInfo.InvariantCulture);
} }
} }
} }

2
ICSharpCode.NRefactory/TypeSystem/InheritanceHelper.cs

@ -25,7 +25,7 @@ namespace ICSharpCode.NRefactory.TypeSystem
/// <summary> /// <summary>
/// Provides helper methods for inheritance. /// Provides helper methods for inheritance.
/// </summary> /// </summary>
public class InheritanceHelper public static class InheritanceHelper
{ {
// TODO: maybe these should be extension methods? // TODO: maybe these should be extension methods?
// or even part of the interface itself? (would allow for easy caching) // or even part of the interface itself? (would allow for easy caching)

3
ICSharpCode.NRefactory/Utils/BitVector16.cs

@ -17,6 +17,7 @@
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
using System; using System;
using System.Globalization;
namespace ICSharpCode.NRefactory.Utils namespace ICSharpCode.NRefactory.Utils
{ {
@ -76,7 +77,7 @@ namespace ICSharpCode.NRefactory.Utils
public override string ToString() public override string ToString()
{ {
return data.ToString("x4"); return data.ToString("x4", CultureInfo.InvariantCulture);
} }
} }
} }

5
ICSharpCode.NRefactory/Utils/BusyManager.cs

@ -29,13 +29,16 @@ namespace ICSharpCode.NRefactory.Utils
/// </summary> /// </summary>
public static class BusyManager 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 struct BusyLock : IDisposable
{ {
public static readonly BusyLock Failed = new BusyLock(null); public static readonly BusyLock Failed = new BusyLock(null);
readonly List<object> objectList; readonly List<object> objectList;
public BusyLock(List<object> objectList) internal BusyLock(List<object> objectList)
{ {
this.objectList = objectList; this.objectList = objectList;
} }

14
ICSharpCode.NRefactory/Utils/CacheManager.cs

@ -36,9 +36,9 @@ namespace ICSharpCode.NRefactory.Utils
public object GetShared(object key) public object GetShared(object key)
{ {
object val; object value;
sharedDict.TryGetValue(key, out val); sharedDict.TryGetValue(key, out value);
return val; return value;
} }
public object GetOrAddShared(object key, Func<object, object> valueFactory) public object GetOrAddShared(object key, Func<object, object> valueFactory)
@ -46,14 +46,14 @@ namespace ICSharpCode.NRefactory.Utils
return sharedDict.GetOrAdd(key, valueFactory); 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;
} }
} }
} }

4
ICSharpCode.NRefactory/Utils/EmptyList.cs

@ -31,8 +31,8 @@ namespace ICSharpCode.NRefactory
private EmptyList() {} private EmptyList() {}
T IList<T>.this[int index] { T IList<T>.this[int index] {
get { throw new IndexOutOfRangeException(); } get { throw new ArgumentOutOfRangeException("index"); }
set { throw new IndexOutOfRangeException(); } set { throw new ArgumentOutOfRangeException("index"); }
} }
int ICollection<T>.Count { int ICollection<T>.Count {

8
ICSharpCode.NRefactory/Utils/FastSerializer.cs

@ -472,7 +472,7 @@ namespace ICSharpCode.NRefactory.Utils
List<FieldInfo> fields = new List<FieldInfo>(); List<FieldInfo> fields = new List<FieldInfo>();
for (Type baseType = type; baseType != null; baseType = baseType.BaseType) { for (Type baseType = type; baseType != null; baseType = baseType.BaseType) {
FieldInfo[] declFields = baseType.GetFields(BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.DeclaredOnly); 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.AddRange(declFields);
} }
fields.RemoveAll(f => f.IsNotSerialized); fields.RemoveAll(f => f.IsNotSerialized);
@ -806,7 +806,7 @@ namespace ICSharpCode.NRefactory.Utils
return Reader.ReadInt32(); return Reader.ReadInt32();
} }
internal void DeserializeTypeDescriptions(FastSerializer fastSerializer) internal void DeserializeTypeDescriptions()
{ {
for (int i = 0; i < this.Types.Length; i++) { for (int i = 0; i < this.Types.Length; i++) {
Type type = this.Types[i]; Type type = this.Types[i];
@ -918,7 +918,7 @@ namespace ICSharpCode.NRefactory.Utils
throw new SerializationException("Unknown type kind"); throw new SerializationException("Unknown type kind");
} }
} }
context.DeserializeTypeDescriptions(this); context.DeserializeTypeDescriptions();
int[] typeIDByObjectID = new int[context.Objects.Length]; int[] typeIDByObjectID = new int[context.Objects.Length];
for (int i = 1 + fixedInstanceCount; i < context.Objects.Length; i++) { for (int i = 1 + fixedInstanceCount; i < context.Objects.Length; i++) {
int typeID = context.ReadTypeID(); int typeID = context.ReadTypeID();
@ -1296,7 +1296,7 @@ namespace ICSharpCode.NRefactory.Utils
return action; return action;
} }
CustomDeserializationAction CreateCustomDeserializationAction(Type type) static CustomDeserializationAction CreateCustomDeserializationAction(Type type)
{ {
ConstructorInfo ctor = type.GetConstructor( ConstructorInfo ctor = type.GetConstructor(
BindingFlags.DeclaredOnly | BindingFlags.ExactBinding | BindingFlags.Instance BindingFlags.DeclaredOnly | BindingFlags.ExactBinding | BindingFlags.Instance

2
ICSharpCode.NRefactory/Utils/LazyInit.cs

@ -28,6 +28,8 @@ namespace ICSharpCode.NRefactory.Utils
{ {
static volatile object barrier = null; 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() public static void ReadBarrier()
{ {
object tmp = barrier; object tmp = barrier;

4
ICSharpCode.NRefactory/Utils/ReferenceComparer.cs

@ -26,9 +26,9 @@ namespace ICSharpCode.NRefactory.Utils
{ {
public readonly static ReferenceComparer Instance = new ReferenceComparer(); 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) public int GetHashCode(object obj)

Loading…
Cancel
Save