diff options
author | TSRBerry <20988865+TSRBerry@users.noreply.github.com> | 2023-06-28 01:27:48 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-06-27 23:27:48 +0000 |
commit | e055217292e034e46ebadd2e839b301b996d7064 (patch) | |
tree | 14510fcda8e0de97ca57442ad89bc07f19ad8573 /src/Ryujinx.Horizon.Kernel.Generators/SyscallSyntaxReceiver.cs | |
parent | fbaf62c2309f2987fa73a2022167ee3e81e31ea9 (diff) |
[Ryujinx.Horizon.Kernel.Generators] Address dotnet-format issues (#5376)1.1.928
* Address most dotnet format whitespace warnings
* Apply dotnet format whitespace formatting
A few of them have been manually reverted and the corresponding warning was silenced
* Simplify properties and array initialization, Use const when possible, Remove trailing commas
* Revert "Simplify properties and array initialization, Use const when possible, Remove trailing commas"
This reverts commit 9462e4136c0a2100dc28b20cf9542e06790aa67e.
* dotnet format whitespace after rebase
* Run dotnet format pass
* Remove left-over files and adjust namespaces
* Fix alignment
Diffstat (limited to 'src/Ryujinx.Horizon.Kernel.Generators/SyscallSyntaxReceiver.cs')
-rw-r--r-- | src/Ryujinx.Horizon.Kernel.Generators/SyscallSyntaxReceiver.cs | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/src/Ryujinx.Horizon.Kernel.Generators/SyscallSyntaxReceiver.cs b/src/Ryujinx.Horizon.Kernel.Generators/SyscallSyntaxReceiver.cs new file mode 100644 index 00000000..f586ee68 --- /dev/null +++ b/src/Ryujinx.Horizon.Kernel.Generators/SyscallSyntaxReceiver.cs @@ -0,0 +1,53 @@ +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.CSharp.Syntax; +using System.Collections.Generic; +using System.Linq; + +namespace Ryujinx.Horizon.Kernel.Generators +{ + class SyscallSyntaxReceiver : ISyntaxReceiver + { + public List<MethodDeclarationSyntax> SvcImplementations { get; } + + public SyscallSyntaxReceiver() + { + SvcImplementations = new List<MethodDeclarationSyntax>(); + } + + public void OnVisitSyntaxNode(SyntaxNode syntaxNode) + { + if (!(syntaxNode is ClassDeclarationSyntax classDeclaration) || classDeclaration.AttributeLists.Count == 0) + { + return; + } + + if (!classDeclaration.AttributeLists.Any(attributeList => + attributeList.Attributes.Any(x => x.Name.GetText().ToString() == "SvcImpl"))) + { + return; + } + + foreach (var memberDeclaration in classDeclaration.Members) + { + if (memberDeclaration is MethodDeclarationSyntax methodDeclaration) + { + VisitMethod(methodDeclaration); + } + } + } + + private void VisitMethod(MethodDeclarationSyntax methodDeclaration) + { + if (methodDeclaration.AttributeLists.Count == 0) + { + return; + } + + if (methodDeclaration.AttributeLists.Any(attributeList => + attributeList.Attributes.Any(x => x.Name.GetText().ToString() == "Svc"))) + { + SvcImplementations.Add(methodDeclaration); + } + } + } +} |