public static IEnumerable <INamedTypeSymbol> FindEntryPoints(INamespaceSymbol symbol) { var visitor = new EntryPointFinder(); visitor.Visit(symbol); return(visitor.EntryPoints); }
public static IEnumerable <INamedTypeSymbol> FindEntryPoints(INamespaceSymbol symbol) { var visitor = new EntryPointFinder(); // Only search source symbols visitor.Visit(symbol.ContainingCompilation.SourceModule.GlobalNamespace); return(visitor.EntryPoints); }
public int GetValidStartupClasses(IntPtr[] classNames, ref int count) { // If classNames is NULL, then we need to populate the number of valid startup // classes only var project = Workspace.CurrentSolution.GetProject(VisualStudioProject.Id); var compilation = project .GetCompilationAsync(CancellationToken.None) .WaitAndGetResult(CancellationToken.None); var entryPoints = EntryPointFinder.FindEntryPoints( compilation.Assembly.GlobalNamespace ); if (classNames == null) { count = entryPoints.Count(); return(VSConstants.S_OK); } else { // We return S_FALSE if we have more entrypoints than places in the array. var entryPointNames = entryPoints .Select( e => e.ToDisplayString( SymbolDisplayFormat.FullyQualifiedFormat.WithGlobalNamespaceStyle( SymbolDisplayGlobalNamespaceStyle.Omitted ) ) ) .ToArray(); if (entryPointNames.Length > classNames.Length) { return(VSConstants.S_FALSE); } // The old language service stored startup class names in its string table, // so the property page never freed them. To avoid leaking memory, we're // going to allocate our strings on the native heap and keep the pointers to them. // Subsequent calls to this function will free the old strings and allocate the // new ones. The last set of marshalled strings is freed in the destructor. if (_startupClasses != null) { foreach (var @class in _startupClasses) { Marshal.FreeHGlobal(@class); } } _startupClasses = entryPointNames.Select(Marshal.StringToHGlobalUni).ToArray(); Array.Copy(_startupClasses, classNames, _startupClasses.Length); count = entryPointNames.Length; return(VSConstants.S_OK); } }
public static IEnumerable <INamedTypeSymbol> FindEntryPoints(INamespaceSymbol symbol) { // This differs from the VB implementation (Microsoft.VisualStudio.LanguageServices.VisualBasic.ProjectSystemShim.EntryPointFinder) // because we don't ever consider forms entry points. // Techinically, this is wrong but it just doesn't matter since the // ref assemblies are unlikely to have a random Main() method that matches var visitor = new EntryPointFinder(); visitor.Visit(symbol); return(visitor.EntryPoints); }
private IEnumerable <INamedTypeSymbol> GetEntryPoints(Project project, Compilation compilation) { return(EntryPointFinder.FindEntryPoints(compilation.Assembly.GlobalNamespace)); }
public static IEnumerable<INamedTypeSymbol> FindEntryPoints(INamespaceSymbol symbol) { var visitor = new EntryPointFinder(); visitor.Visit(symbol); return visitor.EntryPoints; }
public IEnumerable <INamedTypeSymbol> FindEntryPoints(INamespaceSymbol symbol, bool findFormsOnly) { return(EntryPointFinder.FindEntryPoints(symbol)); }