Created
December 13, 2015 21:41
-
-
Save attilah/42a8f62ce28fe83bd770 to your computer and use it in GitHub Desktop.
Roslyn Orleans Codegen
This file contains 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
using Microsoft.CodeAnalysis; | |
using Microsoft.CodeAnalysis.CSharp; | |
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Threading.Tasks; | |
namespace MetaOrleans | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
var assemblies = new[] | |
{ | |
@"Chirper.GrainInterfaces.dll", | |
@"Chirper.Grains.dll" | |
}; | |
var metadataReferences = new List<MetadataReference>(); | |
foreach (var assembly in assemblies) | |
{ | |
metadataReferences.Add(MetadataReference.CreateFromFile(assembly)); | |
} | |
var compilation = CSharpCompilation.Create("dummy", references: metadataReferences); | |
var visitor = new GrainVisitor(); | |
visitor.Visit(compilation.GlobalNamespace); | |
} | |
private class GrainVisitor : SymbolVisitor | |
{ | |
public override void VisitNamespace(INamespaceSymbol symbol) | |
{ | |
Console.WriteLine(symbol.ToDisplayString()); | |
Parallel.ForEach(symbol.GetMembers(), s => Visit(s)); | |
} | |
public override void VisitNamedType(INamedTypeSymbol symbol) | |
{ | |
if (symbol.TypeKind == TypeKind.Class) | |
return; | |
if (symbol.TypeKind==TypeKind.Interface && (symbol.Name == "IGrainObserver" || symbol.Name == "IAddressable" || symbol.Name == "IGrainExtension")) | |
return; | |
if (symbol.TypeKind == TypeKind.Interface && (symbol.Name == "IGrain" || symbol.Name == "IGrainWithGuidKey" || symbol.Name == "IGrainWithIntegerKey" | |
|| symbol.Name == "IGrainWithGuidCompoundKey" || symbol.Name == "IGrainWithIntegerCompoundKey")) | |
return; | |
if (symbol.TypeKind == TypeKind.Interface && symbol.Name=="ISystemTarget") | |
return; | |
if (symbol.AllInterfaces.Any(i => i.Name=="IAddressable")) | |
Console.WriteLine($" {symbol.ToDisplayString()}"); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment