mercredi 21 février 2018

Roslyn - how can I look up custom attributes for a class

I am trying to use Roslyn API (Microsoft.CodeAnalysis) for loading an assembly and looking up the custom attributes. Code I have so far is:

var assembly =  MetadataReference.CreateFromFile(tempFileName);
var compilation = CSharpCompilation.Create(null).AddReferences(assembly);
var assemblySymbol = (IAssemblySymbol)compilation.GetAssemblyOrModuleSymbol(assembly);

var globalNamespace = assemblySymbol.GlobalNamespace.GetAttributes();

But GetAttributes() is empty.

Can Roslyn even do this? Am I going about it the right way?

Thanks, VK





Aucun commentaire:

Enregistrer un commentaire