Skip to content
Draft

wip #280

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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<MethodDeclarationSyntax>()
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));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="4.8.0" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="6.0.1" />
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="6.0.1" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="6.0.0" />
Expand Down