-
Notifications
You must be signed in to change notification settings - Fork 519
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Rgen] Complete the BindingTypeAttribute analyzer. (#21946)
The analyzer now checks the following: * All usages of `bindingTypeAttribute<T>` have to happen on partial classes. * `BindingType<Class>` can only be used on classes. * `BindingType<Category>` can only be used on static classes. * `BindingType<Protocol>` can only be used on interfaces. * `BindingType<StrongDictionary>` can only be used on classes. * `BindingType` can only be used on enums. Because we have not yet released any of the errors, we have sorted them to be the first ones from 0001-0006. --------- Co-authored-by: GitHub Actions Autoformatter <github-actions-autoformatter@xamarin.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: Rolf Bjarne Kvinge <rolf@xamarin.com>
- Loading branch information
1 parent
d0c520e
commit 2c7759a
Showing
13 changed files
with
743 additions
and
109 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
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
28 changes: 28 additions & 0 deletions
28
...rgen/Microsoft.Macios.Bindings.Analyzer/Extensions/BaseTypeDeclarationSyntaxExtensions.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,28 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
using System.Linq; | ||
using Microsoft.CodeAnalysis; | ||
using Microsoft.CodeAnalysis.CSharp; | ||
using Microsoft.CodeAnalysis.CSharp.Syntax; | ||
|
||
namespace Microsoft.Macios.Bindings.Analyzer.Extensions; | ||
|
||
public static class BaseTypeDeclarationSyntaxExtensions { | ||
|
||
/// <summary> | ||
/// Returns if the base type declaration was declared as a partial one. | ||
/// </summary> | ||
/// <param name="baseTypeDeclarationSyntax">The declaration under test.</param> | ||
/// <returns>True if the declaration is partial.</returns> | ||
public static bool IsPartial (this BaseTypeDeclarationSyntax baseTypeDeclarationSyntax) | ||
=> baseTypeDeclarationSyntax.Modifiers.Any (x => x.IsKind (SyntaxKind.PartialKeyword)); | ||
|
||
/// <summary> | ||
/// Returns if the based type declaration was declared as a static one. | ||
/// </summary> | ||
/// <param name="baseTypeDeclarationSyntax">The declaration under test.</param> | ||
/// <returns>True if the declaration is static.</returns> | ||
public static bool IsStatic (this BaseTypeDeclarationSyntax baseTypeDeclarationSyntax) | ||
=> baseTypeDeclarationSyntax.Modifiers.Any (x => x.IsKind (SyntaxKind.StaticKeyword)); | ||
|
||
} |
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
Oops, something went wrong.