Skip to content
Merged
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
4 changes: 2 additions & 2 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
<PropertyGroup>
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
<CentralPackageTransitivePinningEnabled>true</CentralPackageTransitivePinningEnabled>
<MetadataVersion>54.0.44-preview</MetadataVersion>
<WDKMetadataVersion>0.7.3-experimental</WDKMetadataVersion>
<MetadataVersion>55.0.45-preview</MetadataVersion>
<WDKMetadataVersion>0.9.9-experimental</WDKMetadataVersion>
<!-- <DiaMetadataVersion>0.2.185-preview-g7e1e6a442c</DiaMetadataVersion> -->
<ApiDocsVersion>0.1.42-alpha</ApiDocsVersion>
<CodeAnalysisVersion>4.6.0</CodeAnalysisVersion>
Expand Down
2 changes: 1 addition & 1 deletion src/Microsoft.Windows.CsWin32/Generator.Struct.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ private StructDeclarationSyntax DeclareStruct(TypeDefinitionHandle typeDefHandle
// get => (EnumType)this._fieldName;
// set => this._fieldName = (UnderlyingType)value;
// }
this.RequestInteropType(this.Reader.GetString(typeDef.Namespace), propertyType.Identifier.ValueText, context);
this.RequestInteropType(this.GetNamespaceForPossiblyNestedType(typeDef), propertyType.Identifier.ValueText, context);
ExpressionSyntax fieldAccess = MemberAccessExpression(SyntaxKind.SimpleMemberAccessExpression, ThisExpression(), IdentifierName(fieldDeclarator.Identifier));
property = PropertyDeclaration(propertyType.WithTrailingTrivia(Space), Identifier(fieldName).WithTrailingTrivia(LineFeed))
.AddModifiers(TokenWithSpace(this.Visibility))
Expand Down
12 changes: 12 additions & 0 deletions src/Microsoft.Windows.CsWin32/Generator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1329,6 +1329,18 @@ private string GetNormalizedModuleName(MethodImport import)
return moduleName;
}

private string GetNamespaceForPossiblyNestedType(TypeDefinition nestedTypeDef)
{
if (nestedTypeDef.IsNested)
{
return this.GetNamespaceForPossiblyNestedType(this.Reader.GetTypeDefinition(nestedTypeDef.GetDeclaringType()));
}
else
{
return this.Reader.GetString(nestedTypeDef.Namespace);
}
}

private ParameterListSyntax CreateParameterList(MethodDefinition methodDefinition, MethodSignature<TypeHandleInfo> signature, TypeSyntaxSettings typeSettings)
=> FixTrivia(ParameterList().AddParameters(methodDefinition.GetParameters().Select(this.Reader.GetParameter).Where(p => !p.Name.IsNil).Select(p => this.CreateParameter(signature.ParameterTypes[p.SequenceNumber - 1], p, typeSettings)).ToArray()));

Expand Down
1 change: 1 addition & 0 deletions test/Microsoft.Windows.CsWin32.Tests/StructTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ public void InterestingStructs(
"DRIVER_OBJECT", // has an inline array of delegates
"DEVICE_RELATIONS", // ends with an inline "flexible" array
"D3DHAL_CONTEXTCREATEDATA", // contains a field that is a pointer to a struct that is normally managed
"MIB_TCPTABLE", // a struct that references another struct with a nested anonymous type, that loosely references an enum in the same namespace (by way of an attribute).
"WSD_EVENT")] // has a pointer field to a managed struct
string name,
bool allowMarshaling)
Expand Down