-
-
Save hoangitk/b6d53ae39fd1779f207b03609a4d4298 to your computer and use it in GitHub Desktop.
Reflection using Roslyn (without loading assemblies into the app domain)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var compilation = CSharpCompilation.Create("C") | |
.AddReferences(MetadataReference.CreateFromFile(pathToAssembly)); | |
foreach (var type in | |
from assemblySymbol in compilation.SourceModule.ReferencedAssemblySymbols | |
from module in assemblySymbol.Modules | |
from n in module.GlobalNamespace.GetMembers() | |
where n.IsNamespace | |
from type in n.GetTypeMembers() | |
select type) | |
{ | |
Console.WriteLine(type); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment