Roslyn syntax tree service
Vladimir Shkolka edited this page Jul 23, 2017
·
2 revisions
Gets syntax tree where current adaptation attribute was defined.
Type definition page.
- Microsoft.CodeAnalysis nuget package reference
typeof(Microsoft.CodeAnalysis.SyntaxTree)
Prints syntax tree file source path
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
[Designer("PS.Build.Adaptation")]
public class AdaptationAttribute : Attribute
{
#region Members
private void PreBuild(IServiceProvider provider)
{
var tree = (SyntaxTree)provider.GetService(typeof(SyntaxTree));
if (Debugger.IsAttached)
{
Debug.WriteLine(tree.FilePath);
}
}
#endregion
}