From e055217292e034e46ebadd2e839b301b996d7064 Mon Sep 17 00:00:00 2001 From: TSRBerry <20988865+TSRBerry@users.noreply.github.com> Date: Wed, 28 Jun 2023 01:27:48 +0200 Subject: [Ryujinx.Horizon.Kernel.Generators] Address dotnet-format issues (#5376) * 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 --- .../SyscallSyntaxReceiver.cs | 53 ++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 src/Ryujinx.Horizon.Kernel.Generators/SyscallSyntaxReceiver.cs (limited to 'src/Ryujinx.Horizon.Kernel.Generators/SyscallSyntaxReceiver.cs') 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 SvcImplementations { get; } + + public SyscallSyntaxReceiver() + { + SvcImplementations = new List(); + } + + 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); + } + } + } +} -- cgit v1.2.3