This commit is contained in:
Copilot 2025-07-30 06:56:43 -07:00 committed by GitHub
commit f1ef83c810
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 8 additions and 5 deletions

View File

@ -38,7 +38,7 @@ namespace Microsoft.Interop
{
return DiagnosticInfo.Create(descriptor, location, DiagnosticProperties, NotSupportedDetails, elementName);
}
return DiagnosticInfo.Create(descriptor, location, DiagnosticProperties, TypePositionInfo.ManagedType.DiagnosticFormattedName, elementName);
return DiagnosticInfo.Create(descriptor, location, DiagnosticProperties, TypePositionInfo.ManagedType?.DiagnosticFormattedName ?? "<unknown>", elementName);
}
}

View File

@ -142,11 +142,14 @@ namespace Microsoft.Interop
foreach (KeyValuePair<MarshalMode, CustomTypeMarshallerData> mode in Marshallers.Modes)
{
foreach (TypePositionInfo nestedElement in mode.Value.CollectionElementMarshallingInfo.ElementDependencies)
if (mode.Value.CollectionElementMarshallingInfo is not null)
{
if (nestedElement.ManagedIndex != TypePositionInfo.UnsetIndex || nestedElement.NativeIndex != TypePositionInfo.UnsetIndex)
foreach (TypePositionInfo nestedElement in mode.Value.CollectionElementMarshallingInfo.ElementDependencies)
{
yield return nestedElement;
if (nestedElement.ManagedIndex != TypePositionInfo.UnsetIndex || nestedElement.NativeIndex != TypePositionInfo.UnsetIndex)
{
yield return nestedElement;
}
}
}
}

View File

@ -58,7 +58,7 @@ namespace LibraryImportGenerator.UnitTests
yield return new object[] { ID(), CodeSnippets.UserDefinedPrefixedAttributes, Array.Empty<DiagnosticResult>() };
// Bug: https://github.com/dotnet/runtime/issues/117448
// yield return new[] { ID(), CodeSnippets.ImproperCollectionWithMarshalUsingOnElements };
yield return new[] { ID(), CodeSnippets.ImproperCollectionWithMarshalUsingOnElements };
// No explicit marshalling for char or string
yield return new object[] { ID(), CodeSnippets.BasicParametersAndModifiers<char>(), new[]