Browse Source

Use StringComparison.Ordinal

newNRvisualizers
Daniel Grunwald 13 years ago
parent
commit
60fc3694b7
  1. 2
      ICSharpCode.NRefactory.CSharp/Completion/CSharpCompletionEngine.cs
  2. 4
      ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/CreateClassDeclarationAction.cs
  3. 4
      ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/IntroduceFormatItemAction.cs
  4. 4
      ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/JoinStringAction.cs
  5. 4
      ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/SplitStringAction.cs
  6. 22
      ICSharpCode.NRefactory.CSharp/Refactoring/CodeIssues/InconsistentNamingIssue/NamingRule.cs

2
ICSharpCode.NRefactory.CSharp/Completion/CSharpCompletionEngine.cs

@ -2997,7 +2997,7 @@ namespace ICSharpCode.NRefactory.CSharp.Completion @@ -2997,7 +2997,7 @@ namespace ICSharpCode.NRefactory.CSharp.Completion
restart:
string lineText = document.GetText(line);
if (!lineText.Trim().StartsWith("///"))
if (!lineText.Trim().StartsWith("///", StringComparison.Ordinal))
return null;
int startIndex = Math.Min(location.Column - 1, lineText.Length - 1) - 1;
while (startIndex > 0 && lineText [startIndex] != '<') {

4
ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/CreateClassDeclarationAction.cs

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
//
//
// CreateClassDeclarationAction.cs
//
// Author:
@ -86,7 +86,7 @@ namespace ICSharpCode.NRefactory.CSharp.Refactoring @@ -86,7 +86,7 @@ namespace ICSharpCode.NRefactory.CSharp.Refactoring
string className = simpleType.Identifier;
if (simpleType.Parent is Attribute) {
if (!className.EndsWith("Attribute"))
if (!className.EndsWith("Attribute", System.StringComparison.Ordinal))
className += "Attribute";
}

4
ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/IntroduceFormatItemAction.cs

@ -50,8 +50,8 @@ namespace ICSharpCode.NRefactory.CSharp.Refactoring @@ -50,8 +50,8 @@ namespace ICSharpCode.NRefactory.CSharp.Refactoring
if (pexpr == null || !(pexpr.Value is string)) {
yield break;
}
if (pexpr.LiteralValue.StartsWith("@")) {
if (!(pexpr.StartLocation < new TextLocation (context.Location.Line, context.Location.Column - 1) && new TextLocation (context.Location.Line, context.Location.Column + 1) < pexpr.EndLocation)) {
if (pexpr.LiteralValue.StartsWith("@", StringComparison.Ordinal)) {
if (!(pexpr.StartLocation < new TextLocation(context.Location.Line, context.Location.Column - 1) && new TextLocation(context.Location.Line, context.Location.Column + 1) < pexpr.EndLocation)) {
yield break;
}
} else {

4
ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/JoinStringAction.cs

@ -47,8 +47,8 @@ namespace ICSharpCode.NRefactory.CSharp.Refactoring @@ -47,8 +47,8 @@ namespace ICSharpCode.NRefactory.CSharp.Refactoring
!(left.Value is string) || !(right.Value is string) || !node.OperatorToken.Contains(context.Location))
return null;
var isLeftVerbatim = left.LiteralValue.StartsWith ("@");
var isRightVerbatime = right.LiteralValue.StartsWith ("@");
var isLeftVerbatim = left.LiteralValue.StartsWith("@", System.StringComparison.Ordinal);
var isRightVerbatime = right.LiteralValue.StartsWith("@", System.StringComparison.Ordinal);
if (isLeftVerbatim != isRightVerbatime)
return null;

4
ICSharpCode.NRefactory.CSharp/Refactoring/CodeActions/SplitStringAction.cs

@ -41,7 +41,7 @@ namespace ICSharpCode.NRefactory.CSharp.Refactoring @@ -41,7 +41,7 @@ namespace ICSharpCode.NRefactory.CSharp.Refactoring
if (pexpr == null || !(pexpr.Value is string)) {
yield break;
}
if (pexpr.LiteralValue.StartsWith("@")) {
if (pexpr.LiteralValue.StartsWith("@", StringComparison.Ordinal)) {
if (!(pexpr.StartLocation < new TextLocation(context.Location.Line, context.Location.Column - 2) &&
new TextLocation(context.Location.Line, context.Location.Column + 2) < pexpr.EndLocation)) {
yield break;
@ -54,7 +54,7 @@ namespace ICSharpCode.NRefactory.CSharp.Refactoring @@ -54,7 +54,7 @@ namespace ICSharpCode.NRefactory.CSharp.Refactoring
yield return new CodeAction(context.TranslateString("Split string literal"), script => {
int offset = context.GetOffset (context.Location);
script.InsertText (offset, pexpr.LiteralValue.StartsWith ("@") ? "\" + @\"" : "\" + \"");
script.InsertText (offset, pexpr.LiteralValue.StartsWith("@", StringComparison.Ordinal) ? "\" + @\"" : "\" + \"");
});
}
}

22
ICSharpCode.NRefactory.CSharp/Refactoring/CodeIssues/InconsistentNamingIssue/NamingRule.cs

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
//
//
// NamingRule.cs
//
// Author:
@ -82,7 +82,7 @@ namespace ICSharpCode.NRefactory.CSharp.Refactoring @@ -82,7 +82,7 @@ namespace ICSharpCode.NRefactory.CSharp.Refactoring
string id = name;
bool foundPrefix = false;
if (RequiredPrefixes != null && RequiredPrefixes.Length > 0) {
var prefix = RequiredPrefixes.FirstOrDefault(p => id.StartsWith(p));
var prefix = RequiredPrefixes.FirstOrDefault(p => id.StartsWith(p, StringComparison.Ordinal));
if (prefix == null) {
return false;
}
@ -91,7 +91,7 @@ namespace ICSharpCode.NRefactory.CSharp.Refactoring @@ -91,7 +91,7 @@ namespace ICSharpCode.NRefactory.CSharp.Refactoring
}
if (!foundPrefix && AllowedPrefixes != null && AllowedPrefixes.Length > 0) {
var prefix = AllowedPrefixes.FirstOrDefault(p => id.StartsWith(p));
var prefix = AllowedPrefixes.FirstOrDefault(p => id.StartsWith(p, StringComparison.Ordinal));
if (prefix != null) {
id = id.Substring(prefix.Length);
foundPrefix = true;
@ -99,19 +99,19 @@ namespace ICSharpCode.NRefactory.CSharp.Refactoring @@ -99,19 +99,19 @@ namespace ICSharpCode.NRefactory.CSharp.Refactoring
}
if (!foundPrefix && ForbiddenPrefixes != null && ForbiddenPrefixes.Length > 0) {
if (ForbiddenPrefixes.Any(p => id.StartsWith(p))) {
if (ForbiddenPrefixes.Any(p => id.StartsWith(p, StringComparison.Ordinal))) {
return false;
}
}
if (RequiredSuffixes != null && RequiredSuffixes.Length > 0) {
var suffix = RequiredSuffixes.FirstOrDefault(s => id.EndsWith(s));
var suffix = RequiredSuffixes.FirstOrDefault(s => id.EndsWith(s, StringComparison.Ordinal));
if (suffix == null) {
return false;
}
id = id.Substring(0, id.Length - suffix.Length);
} else if (ForbiddenSuffixes != null && ForbiddenSuffixes.Length > 0) {
if (ForbiddenSuffixes.Any(p => id.EndsWith(p))) {
if (ForbiddenSuffixes.Any(p => id.EndsWith(p, StringComparison.Ordinal))) {
return false;
}
}
@ -166,14 +166,14 @@ namespace ICSharpCode.NRefactory.CSharp.Refactoring @@ -166,14 +166,14 @@ namespace ICSharpCode.NRefactory.CSharp.Refactoring
string suffix = null;
if (AllowedPrefixes != null && AllowedPrefixes.Length > 0) {
allowedPrefix = AllowedPrefixes.FirstOrDefault(p => id.StartsWith(p));
allowedPrefix = AllowedPrefixes.FirstOrDefault(p => id.StartsWith(p, StringComparison.Ordinal));
if (allowedPrefix != null)
id = id.Substring(allowedPrefix.Length);
}
if (RequiredPrefixes != null && RequiredPrefixes.Length > 0) {
requiredPrefix = RequiredPrefixes.FirstOrDefault(p => id.StartsWith(p));
requiredPrefix = RequiredPrefixes.FirstOrDefault(p => id.StartsWith(p, StringComparison.Ordinal));
if (requiredPrefix == null) {
errorMessage = string.Format(ctx.TranslateString("Name should have prefix '{0}'."), RequiredPrefixes [0]);
missingRequiredPrefix = true;
@ -181,7 +181,7 @@ namespace ICSharpCode.NRefactory.CSharp.Refactoring @@ -181,7 +181,7 @@ namespace ICSharpCode.NRefactory.CSharp.Refactoring
id = id.Substring(requiredPrefix.Length);
}
} else if (ForbiddenPrefixes != null && ForbiddenPrefixes.Length > 0) {
requiredPrefix = ForbiddenPrefixes.FirstOrDefault(p => id.StartsWith(p));
requiredPrefix = ForbiddenPrefixes.FirstOrDefault(p => id.StartsWith(p, StringComparison.Ordinal));
if (requiredPrefix != null) {
errorMessage = string.Format(ctx.TranslateString("Name has forbidden prefix '{0}'."), requiredPrefix);
id = id.Substring(requiredPrefix.Length);
@ -189,7 +189,7 @@ namespace ICSharpCode.NRefactory.CSharp.Refactoring @@ -189,7 +189,7 @@ namespace ICSharpCode.NRefactory.CSharp.Refactoring
}
if (RequiredSuffixes != null && RequiredSuffixes.Length > 0) {
suffix = RequiredSuffixes.FirstOrDefault(s => id.EndsWith(s));
suffix = RequiredSuffixes.FirstOrDefault(s => id.EndsWith(s, StringComparison.Ordinal));
if (suffix == null) {
errorMessage = string.Format(ctx.TranslateString("Name should have suffix '{0}'."), RequiredSuffixes [0]);
missingRequiredSuffix = true;
@ -197,7 +197,7 @@ namespace ICSharpCode.NRefactory.CSharp.Refactoring @@ -197,7 +197,7 @@ namespace ICSharpCode.NRefactory.CSharp.Refactoring
id = id.Substring(0, id.Length - suffix.Length);
}
} else if (ForbiddenSuffixes != null && ForbiddenSuffixes.Length > 0) {
suffix = ForbiddenSuffixes.FirstOrDefault(p => id.EndsWith(p));
suffix = ForbiddenSuffixes.FirstOrDefault(p => id.EndsWith(p, StringComparison.Ordinal));
if (suffix != null) {
errorMessage = string.Format(ctx.TranslateString("Name has forbidden suffix '{0}'."), suffix);
id = id.Substring(0, id.Length - suffix.Length);

Loading…
Cancel
Save