public static ISymUnmanagedNamespace[] GetNamespaces(this ISymUnmanagedScope symScope) { uint count; symScope.GetNamespaces(0, out count, new ISymUnmanagedNamespace[0]); ISymUnmanagedNamespace[] namespaces = new ISymUnmanagedNamespace[count]; symScope.GetNamespaces(count, out count, namespaces); return(namespaces); }
/// <summary> /// Gets the namespaces that are used within the current scope /// </summary> /// <returns>The namespaces that are used within the current scope</returns> public ISymbolNamespace[] GetNamespaces() { int nmNum; private_scope.GetNamespaces(0, out nmNum, null); ISymUnmanagedNamespace[] unNams = new ISymUnmanagedNamespace[nmNum]; ISymbolNamespace[] manNams = new ISymbolNamespace[nmNum]; private_scope.GetNamespaces(nmNum, out nmNum, unNams); for (int i = 0; i < nmNum; i++) { manNams[i] = new SymbolNamespace(unNams[i]); } return(manNams); }
public ISymbolNamespace[] GetNamespaces() { m_target.GetNamespaces(0, out var count, null); ISymUnmanagedNamespace[] uNamespaces = new ISymUnmanagedNamespace[count]; m_target.GetNamespaces(count, out count, uNamespaces); int i; ISymbolNamespace[] namespaces = new ISymbolNamespace[count]; for (i = 0; i < count; i++) { namespaces[i] = new SymNamespace(uNamespaces[i]); } return(namespaces); }
public ISymbolNamespace[] GetNamespaces() { uint numNss; scope.GetNamespaces(0, out numNss, null); var unNss = new ISymUnmanagedNamespace[numNss]; scope.GetNamespaces((uint)unNss.Length, out numNss, unNss); var nss = new ISymbolNamespace[numNss]; for (uint i = 0; i < numNss; i++) { nss[i] = new SymbolNamespace(unNss[i]); } return(nss); }
public ISymbolNamespace[] GetNamespaces() { int size; HRESULT.ThrowOnFailure(_unmanaged.GetNamespaces(0, out size, null)); var unmanagedNamespaces = new ISymUnmanagedNamespace[size]; HRESULT.ThrowOnFailure(_unmanaged.GetNamespaces(unmanagedNamespaces.Length, out size, unmanagedNamespaces)); var namespaces = new ISymbolNamespace[size]; for (int i = 0; i < size; i++) { namespaces[i] = new SymbolNamespace(unmanagedNamespaces[i]); } return(namespaces); }
public static ImmutableArray <ISymUnmanagedNamespace> GetNamespaces(this ISymUnmanagedScope scope) { int numNamespacesAvailable; scope.GetNamespaces(0, out numNamespacesAvailable, null); if (numNamespacesAvailable == 0) { return(ImmutableArray <ISymUnmanagedNamespace> .Empty); } int numNamespacesRead; ISymUnmanagedNamespace[] namespaces = new ISymUnmanagedNamespace[numNamespacesAvailable]; scope.GetNamespaces(numNamespacesAvailable, out numNamespacesRead, namespaces); if (numNamespacesRead != numNamespacesAvailable) { throw new InvalidOperationException(string.Format("Read only {0} of {1} namespaces.", numNamespacesRead, numNamespacesAvailable)); } return(ImmutableArray.Create(namespaces)); }
/// <summary> /// Get the (unprocessed) import strings for a given method. /// </summary> /// <remarks> /// Doesn't consider forwarding. /// /// CONSIDER: Dev12 doesn't just check the root scope - it digs around to find the best /// match based on the IL offset and then walks up to the root scope (see PdbUtil::GetScopeFromOffset). /// However, it's not clear that this matters, since imports can't be scoped in VB. This is probably /// just based on the way they were extracting locals and constants based on a specific scope. /// /// Returns empty array if there are no import strings for the specified method. /// </remarks> private static ImmutableArray <string> GetImportStrings(ISymUnmanagedReader reader, int methodToken, int methodVersion) { var method = reader.GetMethodByVersion(methodToken, methodVersion); if (method == null) { // In rare circumstances (only bad PDBs?) GetMethodByVersion can return null. // If there's no debug info for the method, then no import strings are available. return(ImmutableArray <string> .Empty); } ISymUnmanagedScope rootScope = method.GetRootScope(); if (rootScope == null) { Debug.Assert(false, "Expected a root scope."); return(ImmutableArray <string> .Empty); } var childScopes = rootScope.GetChildren(); if (childScopes.Length == 0) { // It seems like there should always be at least one child scope, but we've // seen PDBs where that is not the case. return(ImmutableArray <string> .Empty); } // As in NamespaceListWrapper::Init, we only consider namespaces in the first // child of the root scope. ISymUnmanagedScope firstChildScope = childScopes[0]; var namespaces = firstChildScope.GetNamespaces(); if (namespaces.Length == 0) { // It seems like there should always be at least one namespace (i.e. the global // namespace), but we've seen PDBs where that is not the case. return(ImmutableArray <string> .Empty); } return(ImmutableArray.CreateRange(namespaces.Select(n => n.GetName()))); }
private void WriteScopes(ISymUnmanagedScope scope) { writer.WriteStartElement("scope"); { writer.WriteAttributeString("startOffset", AsILOffset(scope.GetStartOffset())); writer.WriteAttributeString("endOffset", AsILOffset(scope.GetEndOffset())); { foreach (ISymUnmanagedNamespace @namespace in scope.GetNamespaces()) { WriteNamespace(@namespace); } WriteLocalsHelper(scope, slotNames: null, includeChildScopes: false); } foreach (ISymUnmanagedScope child in scope.GetScopes()) { WriteScopes(child); } } writer.WriteEndElement(); // </scope> }
/// <summary> /// Get the (unprocessed) import strings for a given method. /// </summary> /// <remarks> /// Doesn't consider forwarding. /// </remarks> private static ImmutableArray <string> GetImportStrings(this ISymUnmanagedMethod method) { ISymUnmanagedScope rootScope = method.GetRootScope(); if (rootScope == null) { Debug.Assert(false, "Expected a root scope."); return(ImmutableArray <string> .Empty); } ImmutableArray <ISymUnmanagedScope> childScopes = rootScope.GetScopes(); if (childScopes.Length == 0) { //Debug.Assert(false, "Expected at least one child scope."); // TODO (acasey): Why can't we assume this? return(ImmutableArray <string> .Empty); } // As in NamespaceListWrapper::Init, we only consider namespaces in the first // child of the root scope. ISymUnmanagedScope firstChildScope = childScopes[0]; ImmutableArray <ISymUnmanagedNamespace> namespaces = firstChildScope.GetNamespaces(); if (namespaces.Length == 0) { //Debug.Assert(false, "Expected at least one namespace (i.e. the global namespace)."); // TODO (acasey): Why can't we assume this? return(ImmutableArray <string> .Empty); } ArrayBuilder <string> importsBuilder = ArrayBuilder <string> .GetInstance(namespaces.Length); foreach (ISymUnmanagedNamespace @namespace in namespaces) { importsBuilder.Add(@namespace.GetName()); } return(importsBuilder.ToImmutableAndFree()); }
public int GetNamespaces(int cNameSpaces, out int pcNameSpaces, ISymUnmanagedNamespace[] namespaces) { return(_scope.GetNamespaces(cNameSpaces, out pcNameSpaces, namespaces)); }
private void WriteScope(ISymUnmanagedScope scope, bool isRoot) { _writer.WriteStartElement(isRoot ? "rootScope" : "scope"); _writer.WriteAttributeString("startOffset", AsILOffset(scope.GetStartOffset())); _writer.WriteAttributeString("endOffset", AsILOffset(scope.GetEndOffset())); foreach (ISymUnmanagedNamespace @namespace in scope.GetNamespaces()) { WriteNamespace(@namespace); } WriteLocals(scope); foreach (ISymUnmanagedScope child in scope.GetScopes()) { WriteScope(child, isRoot: false); } _writer.WriteEndElement(); }
private void WriteScopes(ISymUnmanagedScope rootScope) { // The root scope is always empty. The first scope opened by SymWriter is the child of the root scope. if (rootScope.GetNamespaces().IsEmpty && rootScope.GetLocals().IsEmpty && rootScope.GetConstants().IsEmpty) { foreach (ISymUnmanagedScope child in rootScope.GetScopes()) { WriteScope(child, isRoot: false); } } else { // This shouldn't be executed for PDBs generated via SymWriter. WriteScope(rootScope, isRoot: true); } }