-
Notifications
You must be signed in to change notification settings - Fork 510
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update syntax for async foreach and async using
- Loading branch information
Showing
5 changed files
with
140 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
StyleCop.Analyzers/StyleCop.Analyzers/Lightup/ForEachStatementSyntaxExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. | ||
// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. | ||
|
||
namespace StyleCop.Analyzers.Lightup | ||
{ | ||
using System; | ||
using Microsoft.CodeAnalysis; | ||
using Microsoft.CodeAnalysis.CSharp.Syntax; | ||
|
||
internal static class ForEachStatementSyntaxExtensions | ||
{ | ||
private static readonly Func<ForEachStatementSyntax, SyntaxToken> AwaitKeywordAccessor; | ||
private static readonly Func<ForEachStatementSyntax, SyntaxToken, ForEachStatementSyntax> WithAwaitKeywordAccessor; | ||
|
||
static ForEachStatementSyntaxExtensions() | ||
{ | ||
AwaitKeywordAccessor = LightupHelpers.CreateSyntaxPropertyAccessor<ForEachStatementSyntax, SyntaxToken>(typeof(ForEachStatementSyntax), nameof(AwaitKeyword)); | ||
WithAwaitKeywordAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor<ForEachStatementSyntax, SyntaxToken>(typeof(ForEachStatementSyntax), nameof(AwaitKeyword)); | ||
} | ||
|
||
public static SyntaxToken AwaitKeyword(this ForEachStatementSyntax syntax) | ||
{ | ||
return AwaitKeywordAccessor(syntax); | ||
} | ||
|
||
public static ForEachStatementSyntax WithAwaitKeyword(this ForEachStatementSyntax syntax, SyntaxToken awaitKeyword) | ||
{ | ||
return WithAwaitKeywordAccessor(syntax, awaitKeyword); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
StyleCop.Analyzers/StyleCop.Analyzers/Lightup/LocalDeclarationStatementSyntaxExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. | ||
// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. | ||
|
||
namespace StyleCop.Analyzers.Lightup | ||
{ | ||
using System; | ||
using Microsoft.CodeAnalysis; | ||
using Microsoft.CodeAnalysis.CSharp.Syntax; | ||
|
||
internal static class LocalDeclarationStatementSyntaxExtensions | ||
{ | ||
private static readonly Func<LocalDeclarationStatementSyntax, SyntaxToken> AwaitKeywordAccessor; | ||
private static readonly Func<LocalDeclarationStatementSyntax, SyntaxToken> UsingKeywordAccessor; | ||
|
||
private static readonly Func<LocalDeclarationStatementSyntax, SyntaxToken, LocalDeclarationStatementSyntax> WithAwaitKeywordAccessor; | ||
private static readonly Func<LocalDeclarationStatementSyntax, SyntaxToken, LocalDeclarationStatementSyntax> WithUsingKeywordAccessor; | ||
|
||
static LocalDeclarationStatementSyntaxExtensions() | ||
{ | ||
AwaitKeywordAccessor = LightupHelpers.CreateSyntaxPropertyAccessor<LocalDeclarationStatementSyntax, SyntaxToken>(typeof(LocalDeclarationStatementSyntax), nameof(AwaitKeyword)); | ||
UsingKeywordAccessor = LightupHelpers.CreateSyntaxPropertyAccessor<LocalDeclarationStatementSyntax, SyntaxToken>(typeof(LocalDeclarationStatementSyntax), nameof(UsingKeyword)); | ||
|
||
WithAwaitKeywordAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor<LocalDeclarationStatementSyntax, SyntaxToken>(typeof(LocalDeclarationStatementSyntax), nameof(AwaitKeyword)); | ||
WithUsingKeywordAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor<LocalDeclarationStatementSyntax, SyntaxToken>(typeof(LocalDeclarationStatementSyntax), nameof(UsingKeyword)); | ||
} | ||
|
||
public static SyntaxToken AwaitKeyword(this LocalDeclarationStatementSyntax syntax) | ||
{ | ||
return AwaitKeywordAccessor(syntax); | ||
} | ||
|
||
public static SyntaxToken UsingKeyword(this LocalDeclarationStatementSyntax syntax) | ||
{ | ||
return UsingKeywordAccessor(syntax); | ||
} | ||
|
||
public static LocalDeclarationStatementSyntax WithAwaitKeyword(this LocalDeclarationStatementSyntax syntax, SyntaxToken awaitKeyword) | ||
{ | ||
return WithAwaitKeywordAccessor(syntax, awaitKeyword); | ||
} | ||
|
||
public static LocalDeclarationStatementSyntax WithUsingKeyword(this LocalDeclarationStatementSyntax syntax, SyntaxToken usingKeyword) | ||
{ | ||
return WithUsingKeywordAccessor(syntax, usingKeyword); | ||
} | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
StyleCop.Analyzers/StyleCop.Analyzers/Lightup/UsingStatementSyntaxExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved. | ||
// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. | ||
|
||
namespace StyleCop.Analyzers.Lightup | ||
{ | ||
using System; | ||
using Microsoft.CodeAnalysis; | ||
using Microsoft.CodeAnalysis.CSharp.Syntax; | ||
|
||
internal static class UsingStatementSyntaxExtensions | ||
{ | ||
private static readonly Func<UsingStatementSyntax, SyntaxToken> AwaitKeywordAccessor; | ||
private static readonly Func<UsingStatementSyntax, SyntaxToken, UsingStatementSyntax> WithAwaitKeywordAccessor; | ||
|
||
static UsingStatementSyntaxExtensions() | ||
{ | ||
AwaitKeywordAccessor = LightupHelpers.CreateSyntaxPropertyAccessor<UsingStatementSyntax, SyntaxToken>(typeof(UsingStatementSyntax), nameof(AwaitKeyword)); | ||
WithAwaitKeywordAccessor = LightupHelpers.CreateSyntaxWithPropertyAccessor<UsingStatementSyntax, SyntaxToken>(typeof(UsingStatementSyntax), nameof(AwaitKeyword)); | ||
} | ||
|
||
public static SyntaxToken AwaitKeyword(this UsingStatementSyntax syntax) | ||
{ | ||
return AwaitKeywordAccessor(syntax); | ||
} | ||
|
||
public static UsingStatementSyntax WithAwaitKeyword(this UsingStatementSyntax syntax, SyntaxToken awaitKeyword) | ||
{ | ||
return WithAwaitKeywordAccessor(syntax, awaitKeyword); | ||
} | ||
} | ||
} |