Skip to content

Advice on how best to introduce types to project via fabric #352

Closed Answered by svick
WhitWaldo asked this question in Q&A
Discussion options

You must be logged in to vote

As for the namespace, you could use the RootNamespace MSBuild property. It's probably already exposed to the compiler/Metalama in your project (if not, add <CompilerVisibleProperty Include="RootNamespace"/> inside an <ItemGroup>in your project file).

Then you can do e.g.:

class Fabric : ProjectFabric
{
    public override void AmendProject(IProjectAmender amender)
    {
        amender.AddAspect(c => new YourCompilationAspect(c.Project.TryGetProperty("RootNamespace", out var ns) ? ns : null));
    }
}

Replies: 3 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by WhitWaldo
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants