Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include nested types when identifying namespace dependencies #1815

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion generation/WinSDK/autoTypes.json
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@
"NativeTypedef": true
},
{
"Namespace": "Windows.Win32.Media",
"Namespace": "Windows.Win32.Foundation",
"Name": "HTASK",
"ValueType": "DECLARE_HANDLE",
"InvalidHandleValues": [ -1, 0 ],
Expand Down
2 changes: 1 addition & 1 deletion generation/WinSDK/requiredNamespacesForNames.rsp
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,7 @@ DEPRECATED_CLR_API_MESG=Windows.Win32.System.ClrHosting
# endregion mscoree.h
# region mssip.h
MS_ADDINFO_CATALOGMEMBER=Windows.Win32.Security.Cryptography.Catalog
SIP_INDIRECT_DATA=Windows.Win32.Security.Cryptography
# endregion mssip.h
# region ntifs.h
RtlConvertSidToUnicodeString=Windows.Win32.Security
Expand Down Expand Up @@ -433,7 +434,6 @@ ILayoutStorage=Windows.Win32.System.Com.StructuredStorage
ILockBytes=Windows.Win32.System.Com.StructuredStorage
IRootStorage=Windows.Win32.System.Com.StructuredStorage
#ISequentialStream=Windows.Win32.System.Com.StructuredStorage
IStorage=Windows.Win32.System.Com.StructuredStorage
#IStream=Windows.Win32.System.Com.StructuredStorage
#IPersistStream=Windows.Win32.System.Com.StructuredStorage
IPersistStorage=Windows.Win32.System.Com.StructuredStorage
Expand Down
13 changes: 12 additions & 1 deletion sources/MetadataUtils/NamespaceDependencyUtil.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,11 @@ public IEnumerable<DependenciesInNamespace> GetNamespaceDependencies(string winm
{
DecompilerTypeSystem winmd1 = DecompilerTypeSystemUtils.CreateTypeSystemFromFile(winmdFileName);

foreach (var type1 in winmd1.GetTopLevelTypeDefinitions())
var types = new Queue<ITypeDefinition>(winmd1.GetTopLevelTypeDefinitions());
while (types.Any())
{
var type1 = types.Dequeue();

if (type1.FullName == "<Module>")
{
continue;
Expand All @@ -71,6 +74,14 @@ public IEnumerable<DependenciesInNamespace> GetNamespaceDependencies(string winm
string broughtInBy = $"{type1.Name}.{field.Name}";
this.AddTypeDependency(type1, depends, broughtInBy, field.Type);
}

foreach (var nested in type1.GetNestedTypes())
{
var def = nested.GetDefinition();
if (def != null) {
types.Enqueue(def);
}
}
}
else if (type1.Kind == TypeKind.Class && type1.Name == "Apis")
{
Expand Down