From adf92394a46f765768c7f01cb811df5ad8a64f23 Mon Sep 17 00:00:00 2001 From: Jens Schulze Date: Wed, 10 Nov 2021 13:19:28 +0100 Subject: [PATCH] wip --- .../SrcInfoExportTest.cs | 34 +++++++++++++++++++ .../commercetools.Api.IntegrationTests.csproj | 1 + 2 files changed, 35 insertions(+) create mode 100644 commercetools.Sdk/IntegrationTests/commercetools.Api.IntegrationTests/SrcInfoExportTest.cs diff --git a/commercetools.Sdk/IntegrationTests/commercetools.Api.IntegrationTests/SrcInfoExportTest.cs b/commercetools.Sdk/IntegrationTests/commercetools.Api.IntegrationTests/SrcInfoExportTest.cs new file mode 100644 index 00000000000..c311b30fdb3 --- /dev/null +++ b/commercetools.Sdk/IntegrationTests/commercetools.Api.IntegrationTests/SrcInfoExportTest.cs @@ -0,0 +1,34 @@ +using System; +using System.IO; +using System.Linq; +using Microsoft.CodeAnalysis; +using Microsoft.CodeAnalysis.CSharp; +using Microsoft.CodeAnalysis.CSharp.Syntax; +using Xunit; + +namespace commercetools.Api.IntegrationTests +{ + public class SrcInfoExportTest + { + [Fact] + public void test() + { + String programPath = @"/Users/jensschulze/workspace/commercetools-dotnet-sdk-v2/commercetools.Sdk/IntegrationTests/commercetools.Api.IntegrationTests/Categories/CategoriesIntegrationTests.cs"; + String programText = File.ReadAllText(programPath); + SyntaxTree programTree = CSharpSyntaxTree.ParseText(programText); + CompilationUnitSyntax root = programTree.GetCompilationUnitRoot(); + + + var methods = from methodDeclaration in root.DescendantNodes().OfType() + select ( + ((methodDeclaration.Parent as ClassDeclarationSyntax).Parent as NamespaceDeclarationSyntax).Name.ToFullString(), + (methodDeclaration.Parent as ClassDeclarationSyntax).Identifier.ToFullString(), + methodDeclaration.Identifier.ToFullString(), methodDeclaration.Body.Statements.ToFullString(), + methodDeclaration.GetLocation().GetMappedLineSpan().StartLinePosition.Line.ToString(), + methodDeclaration.GetLocation().GetMappedLineSpan().EndLinePosition.Line.ToString() + ); + + Console.WriteLine(string.Join("\n", methods)); + } + } +} \ No newline at end of file diff --git a/commercetools.Sdk/IntegrationTests/commercetools.Api.IntegrationTests/commercetools.Api.IntegrationTests.csproj b/commercetools.Sdk/IntegrationTests/commercetools.Api.IntegrationTests/commercetools.Api.IntegrationTests.csproj index dca1af856ef..d4c9505cddb 100644 --- a/commercetools.Sdk/IntegrationTests/commercetools.Api.IntegrationTests/commercetools.Api.IntegrationTests.csproj +++ b/commercetools.Sdk/IntegrationTests/commercetools.Api.IntegrationTests/commercetools.Api.IntegrationTests.csproj @@ -14,6 +14,7 @@ + runtime; build; native; contentfiles; analyzers; buildtransitive all