-
Notifications
You must be signed in to change notification settings - Fork 226
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Decompose SymbolHelper into dedicated extension classes (#9229)
- Loading branch information
1 parent
c755a17
commit ca0f118
Showing
32 changed files
with
3,199 additions
and
3,179 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
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
595 changes: 0 additions & 595 deletions
595
analyzers/src/SonarAnalyzer.CSharp/Extensions/SyntaxNodeExtensions.cs
This file was deleted.
Oops, something went wrong.
583 changes: 583 additions & 0 deletions
583
analyzers/src/SonarAnalyzer.CSharp/Extensions/SyntaxNodeExtensionsCSharp.cs
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
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
45 changes: 45 additions & 0 deletions
45
analyzers/src/SonarAnalyzer.Common/Extensions/IMethodSymbolExtensions.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,45 @@ | ||
/* | ||
* SonarAnalyzer for .NET | ||
* Copyright (C) 2015-2024 SonarSource SA | ||
* mailto: contact AT sonarsource DOT com | ||
* | ||
* This program is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU Lesser General Public | ||
* License as published by the Free Software Foundation; either | ||
* version 3 of the License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with this program; if not, write to the Free Software Foundation, | ||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
*/ | ||
|
||
namespace SonarAnalyzer.Extensions; | ||
|
||
internal static class IMethodSymbolExtensions | ||
{ | ||
public static bool IsExtensionOn(this IMethodSymbol methodSymbol, KnownType type) | ||
{ | ||
if (methodSymbol is { IsExtensionMethod: true }) | ||
{ | ||
var receiverType = methodSymbol.MethodKind == MethodKind.Ordinary | ||
? methodSymbol.Parameters.First().Type as INamedTypeSymbol | ||
: methodSymbol.ReceiverType as INamedTypeSymbol; | ||
return receiverType?.ConstructedFrom.Is(type) ?? false; | ||
} | ||
else | ||
{ | ||
return false; | ||
} | ||
} | ||
|
||
public static bool IsDestructor(this IMethodSymbol method) => | ||
method.MethodKind == MethodKind.Destructor; | ||
|
||
public static bool IsAnyAttributeInOverridingChain(this IMethodSymbol method) => | ||
method.IsAnyAttributeInOverridingChain(x => x.OverriddenMethod); | ||
} |
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
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
27 changes: 27 additions & 0 deletions
27
analyzers/src/SonarAnalyzer.Common/Extensions/IPropertySymbolExtensions.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,27 @@ | ||
/* | ||
* SonarAnalyzer for .NET | ||
* Copyright (C) 2015-2024 SonarSource SA | ||
* mailto: contact AT sonarsource DOT com | ||
* | ||
* This program is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU Lesser General Public | ||
* License as published by the Free Software Foundation; either | ||
* version 3 of the License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with this program; if not, write to the Free Software Foundation, | ||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
*/ | ||
|
||
namespace SonarAnalyzer.Extensions; | ||
|
||
internal static class IPropertySymbolExtensions | ||
{ | ||
public static bool IsAnyAttributeInOverridingChain(this IPropertySymbol property) => | ||
property.IsAnyAttributeInOverridingChain(x => x.OverriddenProperty); | ||
} |
Oops, something went wrong.