Skip to content
This repository was archived by the owner on Oct 16, 2020. It is now read-only.

Commit fe56625

Browse files
committed
Update to NRefactory commit 9d875d3
9d875d3 Bump NRefactory version number to 5.4. ebe00cc ConsistencyCheck: Ensure mscorlib is added to the compilation (MSBuild doesn't return it for .NET 2.0 projects like IKVM) d68853d Fix missing FreezeList() call to DefaultUnresolvedTypeParameter.Freeze(). a71bf19 Merge several bugfixes from SharpDevelop repository to NRefactory. 6856bd1 Remove System.Runtime hack -- type forwarding should handle this case. 17aefe2 Handle blob decoding errors in the type system instead of placing catch-all handlers in random spots. 877394a Mark DefaultAssemblyReference.Corlib as obsolete f70e546 Updated mcs. 7a2614d Fixed null check 48bdfd7 Merge pull request #405 from DavidKarlas/paramBug e6ce1e6 Fixing parameter code completion after using '>' e.g. if(a>b)Method( 6da0a7b Ignored failing unit test. 4d0b4a4 Fixed 'Bug 20110 - [Forms] Autocomplete doesn't work for the Placeholder property'. e5958a8 Fixed another completion bug case. 37368af Fixed completion bug. 67a1d11 Disabled uncategorized/notworking code issues. cf4fc70 Disabled notworking code issue. That's fixed in .NET 4.5 anyways and this code issue was very, very slow. 39bb34a Remap failing system.runtime references to mscorlib. Use case: Reference portable.NET assemblies from non portable .NET code. 44e1ff1 Fixed Bug 20125 - Fails to show abstract method when writing "override" c47e3d1 Fixed little bug in resolver. It incorrectly resolved internal types sometimes. 6c4c6d3 Fixed wrong end location of RedundantAttributeParenthesesIssue. Due to a drawing error in monodevelop that wasn't visible before. 2b69be0 Fixed bug in inconsistent naming tests. 3c9256f Merge pull request #404 from mono-soc-2013/MateY-IndentEngine 4733874 Fixed issue 389. c0aebb7 Fixed issue in ResolveAtLocation. On indexer 'this' the indexer should be resolved. 1c48cd2 Merge pull request #400 from DavidKarlas/parseExpression 242c141 Fixed parser bug when using ParseExpression 9d1cc09 Fixed parser bug. 13b0928 Catches exception for the IsBrowsable extension method. Fixed monodevelop bug https://bugzilla.xamarin.com/show_bug.cgi?id=18706. 3f78bdb Merge pull request #397 from khellang/patch-1 f6e7c08 Update README 0b743ac Merge pull request #396 from Therzok/master 36d6246 Optimize some Linq. 75640bf Merge pull request #395 from Therzok/master 5789870 [CodeIssues] Add simplified versions Math functions. 28d04ae Fixed potential blob reader exception. 22d8bc2 Fixed failing unit tests. e2dced7 Merge branch 'master' of github.com:icsharpcode/NRefactory 705590d Merge pull request #392 from DavidKarlas/paramInfoAnywhere 800296d Merge pull request #393 from DavidKarlas/failRevert 63a63f2 Correcting bad revert. Sometimes it was returing 0 instead of -1. 27590b5 Improved resolving of target method for ParameterInfo so it can be triggered in middle of parameter and not only after '(',',','[' or '<'. 7aef513 Merge pull request #391 from DavidKarlas/revertPull390 a8141ef Reverting Pull #390 2132edc Merge pull request #390 from DavidKarlas/firstParameter b6ccdb9 Always displaying first parameter discription in ParameterInfo tooltip
1 parent 6b01d6f commit fe56625

87 files changed

Lines changed: 8124 additions & 5601 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/Libraries/NRefactory/ICSharpCode.NRefactory.CSharp.Refactoring/CodeIssues/NotWorking/AccessToClosureIssues/AccessToDisposedClosureIssue.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,12 @@
3232

3333
namespace ICSharpCode.NRefactory.CSharp.Refactoring
3434
{
35-
[IssueDescription ("Access to disposed closure variable",
36-
Description = "Access to closure variable from anonymous method when the variable is" +
37-
" disposed externally",
38-
Category = IssueCategories.CodeQualityIssues,
39-
Severity = Severity.Warning,
40-
AnalysisDisableKeyword = "AccessToDisposedClosure")]
35+
// [IssueDescription ("Access to disposed closure variable",
36+
// Description = "Access to closure variable from anonymous method when the variable is" +
37+
// " disposed externally",
38+
// Category = IssueCategories.CodeQualityIssues,
39+
// Severity = Severity.Warning,
40+
// AnalysisDisableKeyword = "AccessToDisposedClosure")]
4141
public class AccessToDisposedClosureIssue : AccessToClosureIssue
4242
{
4343
public AccessToDisposedClosureIssue ()

src/Libraries/NRefactory/ICSharpCode.NRefactory.CSharp.Refactoring/CodeIssues/NotWorking/AccessToClosureIssues/AccessToModifiedClosureIssue.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,12 @@
3131

3232
namespace ICSharpCode.NRefactory.CSharp.Refactoring
3333
{
34-
[IssueDescription("Access to modified closure variable",
35-
Description = "Access to closure variable from anonymous method when the variable is modified " +
36-
"externally",
37-
Category = IssueCategories.CodeQualityIssues,
38-
Severity = Severity.Warning,
39-
AnalysisDisableKeyword = "AccessToModifiedClosure")]
34+
// [IssueDescription("Access to modified closure variable",
35+
// Description = "Access to closure variable from anonymous method when the variable is modified " +
36+
// "externally",
37+
// Category = IssueCategories.CodeQualityIssues,
38+
// Severity = Severity.Warning,
39+
// AnalysisDisableKeyword = "AccessToModifiedClosure")]
4040
public class AccessToModifiedClosureIssue : AccessToClosureIssue
4141
{
4242
public AccessToModifiedClosureIssue ()

src/Libraries/NRefactory/ICSharpCode.NRefactory.CSharp.Refactoring/CodeIssues/NotWorking/VariableDeclaredInWideScopeIssue.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ public override void VisitVariableDeclarationStatement(VariableDeclarationStatem
134134
}
135135

136136
// Restrict to locations outside of blacklisted node types
137-
var firstBlackListedNode = path.Where(node => moveTargetBlacklist.Contains(node.GetType())).FirstOrDefault();
137+
var firstBlackListedNode = path.FirstOrDefault(node => moveTargetBlacklist.Contains(node.GetType()));
138138
if (firstBlackListedNode != null) {
139139
path = GetPath(rootNode, firstBlackListedNode.Parent);
140140
anchorNode = firstBlackListedNode;

src/Libraries/NRefactory/ICSharpCode.NRefactory.CSharp.Refactoring/CodeIssues/Synced/ConstraintViolations/InconsistentNamingIssue/NamingRule.cs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ public string GetErrorMessage(BaseRefactoringContext ctx, string name, out IList
376376
break;
377377

378378
case NamingStyle.CamelCase:
379-
if (id.Length > 0 && char.IsUpper(id [0])) {
379+
if (id.Length > 0 && !char.IsLower(id [0])) {
380380
errorMessage = string.Format(ctx.TranslateString("'{0}' should start with a lower case letter. (Rule '{1}')"), name, Name);
381381
} else if (!CheckUnderscore(id, UnderscoreHandling.Forbid)) {
382382
errorMessage = string.Format(ctx.TranslateString("'{0}' should not separate words with an underscore. (Rule '{1}')"), name, Name);
@@ -387,7 +387,7 @@ public string GetErrorMessage(BaseRefactoringContext ctx, string name, out IList
387387
suggestedNames.Add(CamelCaseIdentifier(id));
388388
break;
389389
case NamingStyle.CamelCaseWithLowerLetterUnderscore:
390-
if (id.Length > 0 && char.IsUpper(id [0])) {
390+
if (id.Length > 0 && !char.IsLower(id [0])) {
391391
errorMessage = string.Format(ctx.TranslateString("'{0}' should start with a lower case letter. (Rule '{1}')"), name, Name);
392392
} else if (!CheckUnderscore(id, UnderscoreHandling.AllowWithLowerStartingLetter)) {
393393
errorMessage = string.Format(ctx.TranslateString("after '_' a lower letter should follow. (Rule '{0}')"), Name);
@@ -398,7 +398,7 @@ public string GetErrorMessage(BaseRefactoringContext ctx, string name, out IList
398398
suggestedNames.Add(CamelCaseWithLowerLetterUnderscore(id));
399399
break;
400400
case NamingStyle.CamelCaseWithUpperLetterUnderscore:
401-
if (id.Length > 0 && char.IsUpper(id [0])) {
401+
if (id.Length > 0 && !char.IsLower(id [0])) {
402402
errorMessage = string.Format(ctx.TranslateString("'{0}' should start with a lower case letter. (Rule '{1}')"), name, Name);
403403
} else if (!CheckUnderscore(id, UnderscoreHandling.AllowWithUpperStartingLetter)) {
404404
errorMessage = string.Format(ctx.TranslateString("after '_' an upper letter should follow. (Rule '{0}')"), Name);
@@ -410,7 +410,7 @@ public string GetErrorMessage(BaseRefactoringContext ctx, string name, out IList
410410
break;
411411

412412
case NamingStyle.PascalCase:
413-
if (id.Length > 0 && char.IsLower(id [0])) {
413+
if (id.Length > 0 && !char.IsUpper(id [0])) {
414414
errorMessage = string.Format(ctx.TranslateString("'{0}' should start with an upper case letter. (Rule '{1}')"), name, Name);
415415
} else if (!CheckUnderscore(id, UnderscoreHandling.Forbid)) {
416416
errorMessage = string.Format(ctx.TranslateString("'{0}' should not separate words with an underscore. (Rule '{1}')"), name, Name);
@@ -421,7 +421,7 @@ public string GetErrorMessage(BaseRefactoringContext ctx, string name, out IList
421421
suggestedNames.Add(PascalCaseIdentifier(id));
422422
break;
423423
case NamingStyle.PascalCaseWithLowerLetterUnderscore:
424-
if (id.Length > 0 && char.IsLower(id [0])) {
424+
if (id.Length > 0 && !char.IsUpper(id [0])) {
425425
errorMessage = string.Format(ctx.TranslateString("'{0}' should start with an upper case letter. (Rule '{1}')"), name, Name);
426426
} else if (!CheckUnderscore(id, UnderscoreHandling.AllowWithLowerStartingLetter)) {
427427
errorMessage = string.Format(ctx.TranslateString("after '_' a lower letter should follow. (Rule '{0}')"), Name);
@@ -432,7 +432,7 @@ public string GetErrorMessage(BaseRefactoringContext ctx, string name, out IList
432432
suggestedNames.Add(PascalCaseWithLowerLetterUnderscore(id));
433433
break;
434434
case NamingStyle.PascalCaseWithUpperLetterUnderscore:
435-
if (id.Length > 0 && char.IsLower(id [0])) {
435+
if (id.Length > 0 && !char.IsUpper(id [0])) {
436436
errorMessage = string.Format(ctx.TranslateString("'{0}' should start with an upper case letter. (Rule '{1}')"), name, Name);
437437
} else if (!CheckUnderscore(id, UnderscoreHandling.AllowWithUpperStartingLetter)) {
438438
errorMessage = string.Format(ctx.TranslateString("after '_' an upper letter should follow. (Rule '{0}')"), Name);
@@ -443,7 +443,7 @@ public string GetErrorMessage(BaseRefactoringContext ctx, string name, out IList
443443
suggestedNames.Add(PascalCaseWithUpperLetterUnderscore(id));
444444
break;
445445
case NamingStyle.FirstUpper:
446-
if (id.Length > 0 && char.IsLower(id [0])) {
446+
if (id.Length > 0 && !char.IsUpper(id [0])) {
447447
errorMessage = string.Format(ctx.TranslateString("'{0}' should start with an upper case letter. (Rule '{1}')"), name, Name);
448448
} else if (id.Take(1).Any(ch => char.IsLetter(ch) && char.IsUpper(ch))) {
449449
errorMessage = string.Format(ctx.TranslateString("'{0}' contains an upper case letter after the first. (Rule '{1}')"), name, Name);
@@ -525,6 +525,8 @@ static string ConvertToValidName(string id, Func<char, char> firstCharFunc, Func
525525
bool first = true;
526526
for (int i = 0; i < id.Length; i++) {
527527
char ch = id[i];
528+
if (i == 0 && ch == '_')
529+
continue;
528530
if (first && char.IsLetter(ch)) {
529531
sb.Append(firstCharFunc(ch));
530532
firstCharFunc = followingCharFunc;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
//
2+
// ReplaceWithSingleCallToAverageIssue.cs
3+
//
4+
// Author:
5+
// Marius Ungureanu <marius.ungureanu@xamarin.com>
6+
//
7+
// Copyright (c) 2014 Xamarin <http://xamarin.com>
8+
//
9+
// Permission is hereby granted, free of charge, to any person obtaining a copy
10+
// of this software and associated documentation files (the "Software"), to deal
11+
// in the Software without restriction, including without limitation the rights
12+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13+
// copies of the Software, and to permit persons to whom the Software is
14+
// furnished to do so, subject to the following conditions:
15+
//
16+
// The above copyright notice and this permission notice shall be included in
17+
// all copies or substantial portions of the Software.
18+
//
19+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25+
// THE SOFTWARE.
26+
using System.Linq;
27+
using ICSharpCode.NRefactory.Semantics;
28+
using ICSharpCode.NRefactory.TypeSystem;
29+
using ICSharpCode.NRefactory.PatternMatching;
30+
using ICSharpCode.NRefactory.Refactoring;
31+
32+
namespace ICSharpCode.NRefactory.CSharp.Refactoring
33+
{
34+
[IssueDescription("Replace with single call to Average(...)",
35+
Description = "Replace with single call to Average(...)",
36+
Category = IssueCategories.PracticesAndImprovements,
37+
Severity = Severity.Suggestion,
38+
AnalysisDisableKeyword = "ReplaceWithSingleCallToAverage")]
39+
public class ReplaceWithSingleCallToAverageIssue : GatherVisitorCodeIssueProvider
40+
{
41+
static readonly AstNode pattern =
42+
new InvocationExpression (
43+
new MemberReferenceExpression (
44+
new NamedNode ("selectInvoke",
45+
new InvocationExpression (
46+
new MemberReferenceExpression (new AnyNode ("target"), "Select"),
47+
new AnyNode ())),
48+
Pattern.AnyString));
49+
50+
protected override IGatherVisitor CreateVisitor(BaseRefactoringContext context)
51+
{
52+
return new GatherVisitor<ReplaceWithSingleCallToAverageIssue>(context, "Average");
53+
}
54+
55+
internal class GatherVisitor<T> : GatherVisitorBase<T> where T : GatherVisitorCodeIssueProvider
56+
{
57+
readonly string member;
58+
59+
public GatherVisitor (BaseRefactoringContext ctx, string member) : base (ctx)
60+
{
61+
this.member = member;
62+
}
63+
64+
public override void VisitInvocationExpression (InvocationExpression invocationExpression)
65+
{
66+
base.VisitInvocationExpression (invocationExpression);
67+
68+
var match = pattern.Match (invocationExpression);
69+
if (!match.Success)
70+
return;
71+
72+
var averageResolve = ctx.Resolve (invocationExpression) as InvocationResolveResult;
73+
if (averageResolve == null || !HasPredicateVersion(averageResolve.Member))
74+
return;
75+
var selectInvoke = match.Get<InvocationExpression> ("selectInvoke").Single ();
76+
var selectResolve = ctx.Resolve (selectInvoke) as InvocationResolveResult;
77+
if (selectResolve == null || selectResolve.Member.Name != "Select" || !IsQueryExtensionClass(selectResolve.Member.DeclaringTypeDefinition))
78+
return;
79+
if (selectResolve.Member.Parameters.Count != 2)
80+
return;
81+
var predResolve = selectResolve.Member.Parameters [1];
82+
if (predResolve.Type.TypeParameterCount != 2)
83+
return;
84+
85+
AddIssue(new CodeIssue(
86+
invocationExpression, string.Format(ctx.TranslateString("Redundant Select() call with predicate followed by {0}()"), averageResolve.Member.Name),
87+
new CodeAction (
88+
string.Format(ctx.TranslateString("Replace with single call to '{0}'"), averageResolve.Member.Name),
89+
script => {
90+
var arg = selectInvoke.Arguments.Single ().Clone ();
91+
var target = match.Get<Expression> ("target").Single ().Clone ();
92+
script.Replace (invocationExpression, new InvocationExpression (new MemberReferenceExpression (target, averageResolve.Member.Name), arg));
93+
},
94+
invocationExpression
95+
)
96+
));
97+
}
98+
99+
static bool IsQueryExtensionClass(ITypeDefinition typeDef)
100+
{
101+
if (typeDef == null || typeDef.Namespace != "System.Linq")
102+
return false;
103+
switch (typeDef.Name) {
104+
case "Enumerable":
105+
case "ParallelEnumerable":
106+
case "Queryable":
107+
return true;
108+
default:
109+
return false;
110+
}
111+
}
112+
113+
bool HasPredicateVersion(IParameterizedMember member)
114+
{
115+
if (!IsQueryExtensionClass(member.DeclaringTypeDefinition))
116+
return false;
117+
return member.Name == this.member;
118+
}
119+
}
120+
}
121+
}
122+
123+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
//
2+
// ReplaceWithSingleCallToMaxIssue.cs
3+
//
4+
// Author:
5+
// Marius Ungureanu <marius.ungureanu@xamarin.com>
6+
//
7+
// Copyright (c) 2014 Xamarin <http://xamarin.com>
8+
//
9+
// Permission is hereby granted, free of charge, to any person obtaining a copy
10+
// of this software and associated documentation files (the "Software"), to deal
11+
// in the Software without restriction, including without limitation the rights
12+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13+
// copies of the Software, and to permit persons to whom the Software is
14+
// furnished to do so, subject to the following conditions:
15+
//
16+
// The above copyright notice and this permission notice shall be included in
17+
// all copies or substantial portions of the Software.
18+
//
19+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25+
// THE SOFTWARE.
26+
using ICSharpCode.NRefactory.Refactoring;
27+
28+
namespace ICSharpCode.NRefactory.CSharp.Refactoring
29+
{
30+
[IssueDescription("Replace with single call to Max(...)",
31+
Description = "Replace with single call to Max(...)",
32+
Category = IssueCategories.PracticesAndImprovements,
33+
Severity = Severity.Suggestion,
34+
AnalysisDisableKeyword = "ReplaceWithSingleCallToMax")]
35+
public class ReplaceWithSingleCallToMaxIssue : GatherVisitorCodeIssueProvider
36+
{
37+
protected override IGatherVisitor CreateVisitor(BaseRefactoringContext context)
38+
{
39+
return new ReplaceWithSingleCallToAverageIssue.GatherVisitor<ReplaceWithSingleCallToMaxIssue>(context, "Max");
40+
}
41+
}
42+
}
43+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
//
2+
// ReplaceWithSingleCallToMinIssue.cs
3+
//
4+
// Author:
5+
// Marius Ungureanu <marius.ungureanu@xamarin.com>
6+
//
7+
// Copyright (c) 2014 Xamarin <http://xamarin.com>
8+
//
9+
// Permission is hereby granted, free of charge, to any person obtaining a copy
10+
// of this software and associated documentation files (the "Software"), to deal
11+
// in the Software without restriction, including without limitation the rights
12+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13+
// copies of the Software, and to permit persons to whom the Software is
14+
// furnished to do so, subject to the following conditions:
15+
//
16+
// The above copyright notice and this permission notice shall be included in
17+
// all copies or substantial portions of the Software.
18+
//
19+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25+
// THE SOFTWARE.
26+
using ICSharpCode.NRefactory.Refactoring;
27+
28+
namespace ICSharpCode.NRefactory.CSharp.Refactoring
29+
{
30+
[IssueDescription("Replace with single call to Min(...)",
31+
Description = "Replace with single call to Min(...)",
32+
Category = IssueCategories.PracticesAndImprovements,
33+
Severity = Severity.Suggestion,
34+
AnalysisDisableKeyword = "ReplaceWithSingleCallToMin")]
35+
public class ReplaceWithSingleCallToMinIssue : GatherVisitorCodeIssueProvider
36+
{
37+
protected override IGatherVisitor CreateVisitor(BaseRefactoringContext context)
38+
{
39+
return new ReplaceWithSingleCallToAverageIssue.GatherVisitor<ReplaceWithSingleCallToMinIssue>(context, "Min");
40+
}
41+
}
42+
}
43+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
//
2+
// ReplaceWithSingleCallToSumIssue.cs
3+
//
4+
// Author:
5+
// Marius Ungureanu <marius.ungureanu@xamarin.com>
6+
//
7+
// Copyright (c) 2014 Xamarin <http://xamarin.com>
8+
//
9+
// Permission is hereby granted, free of charge, to any person obtaining a copy
10+
// of this software and associated documentation files (the "Software"), to deal
11+
// in the Software without restriction, including without limitation the rights
12+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13+
// copies of the Software, and to permit persons to whom the Software is
14+
// furnished to do so, subject to the following conditions:
15+
//
16+
// The above copyright notice and this permission notice shall be included in
17+
// all copies or substantial portions of the Software.
18+
//
19+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25+
// THE SOFTWARE.
26+
using ICSharpCode.NRefactory.Refactoring;
27+
28+
namespace ICSharpCode.NRefactory.CSharp.Refactoring
29+
{
30+
[IssueDescription("Replace with single call to Sum(...)",
31+
Description = "Replace with single call to Sum(...)",
32+
Category = IssueCategories.PracticesAndImprovements,
33+
Severity = Severity.Suggestion,
34+
AnalysisDisableKeyword = "ReplaceWithSingleCallToSum")]
35+
public class ReplaceWithSingleCallToSumIssue : GatherVisitorCodeIssueProvider
36+
{
37+
protected override IGatherVisitor CreateVisitor(BaseRefactoringContext context)
38+
{
39+
return new ReplaceWithSingleCallToAverageIssue.GatherVisitor<ReplaceWithSingleCallToSumIssue>(context, "Sum");
40+
}
41+
}
42+
}
43+

src/Libraries/NRefactory/ICSharpCode.NRefactory.CSharp.Refactoring/CodeIssues/Synced/RedundanciesInCode/RedundantAttributeParenthesesIssue.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public override void VisitAttribute(Attribute attribute)
5555
if (attribute.Arguments.Count > 0 || !attribute.HasArgumentList)
5656
return;
5757

58-
AddIssue(new CodeIssue(attribute.LParToken.StartLocation, attribute.RParToken.StartLocation, ctx.TranslateString("Parentheses are redundant if attribute has no arguments"), ctx.TranslateString("Remove '()'"), script =>
58+
AddIssue(new CodeIssue(attribute.LParToken.StartLocation, attribute.RParToken.EndLocation, ctx.TranslateString("Parentheses are redundant if attribute has no arguments"), ctx.TranslateString("Remove '()'"), script =>
5959
script.Replace(attribute, new Attribute { Type = attribute.Type.Clone() })) { IssueMarker = IssueMarker.GrayOut });
6060
}
6161
}

src/Libraries/NRefactory/ICSharpCode.NRefactory.CSharp.Refactoring/CodeIssues/Uncategorized/AutoAsyncIssue.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,10 @@
3939

4040
namespace ICSharpCode.NRefactory.CSharp.Refactoring
4141
{
42-
[IssueDescription("Old-style asynchronous function can be converted to C# 5 async",
43-
Description = "Detects usage of old-style TaskCompletionSource/ContinueWith and suggests using async/await instead",
44-
Category = IssueCategories.Opportunities,
45-
Severity = Severity.Hint)]
42+
// [IssueDescription("Old-style asynchronous function can be converted to C# 5 async",
43+
// Description = "Detects usage of old-style TaskCompletionSource/ContinueWith and suggests using async/await instead",
44+
// Category = IssueCategories.Opportunities,
45+
// Severity = Severity.Hint)]
4646
public class AutoAsyncIssue : GatherVisitorCodeIssueProvider
4747
{
4848
static readonly ReturnStatement ReturnTaskCompletionSourcePattern = new ReturnStatement {

0 commit comments

Comments
 (0)