I am using SourceGenerator and analysing a class to create a string that needs to have the relative path of the class file to the csproj file.
I am able to find the absolute path of the class file using code below, but not the relative path
public class XamlControlAndPageFinder : ISyntaxContextReceiver
{
public void OnVisitSyntaxNode(GeneratorSyntaxContext context)
{
if (context.Node is ClassDeclarationSyntax userControl)
{
// This gives us the complete path and not relative path
var filePath = userControl.SyntaxTree.FilePath;
}
}
}