Skip to content

Create error on LibraryImport of generic delegate #114827

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

Open
wants to merge 2 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
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
<!--
Microsoft ResX Schema

Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes

The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.

Example:

... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
Expand All @@ -26,36 +26,36 @@
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple

There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the

Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not

The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can

Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.

mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.

mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.

mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
Expand Down Expand Up @@ -916,4 +916,7 @@
<data name="BaseInterfaceDefinedInOtherAssemblyTitle" xml:space="preserve">
<value>Specifying 'GeneratedComInterfaceAttribute' on an interface that has a base interface defined in another assembly is not supported</value>
</data>
<data name="GenericDelegatesNotSupported" xml:space="preserve">
<value>Marshalling a generic delegate is not supported. Consider using a function pointer instead.</value>
</data>
</root>
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,11 @@
<target state="translated">Konfigurace „StringMarshalling“ a „StringMarshallingCustomType“ se musí shodovat se základním rozhraním COM.</target>
<note />
</trans-unit>
<trans-unit id="GenericDelegatesNotSupported">
<source>Marshalling a generic delegate is not supported. Consider using a function pointer instead.</source>
<target state="new">Marshalling a generic delegate is not supported. Consider using a function pointer instead.</target>
<note />
</trans-unit>
<trans-unit id="GenericEntryPointMarshallerTypeMustBeClosedOrMatchArityDescription">
<source>The marshaller type must be a closed generic or have the same number of generic parameters as the managed type so the emitted code can use a specific instantiation.</source>
<target state="translated">Zařazovací typ musí být uzavřený obecný typ nebo mít stejný počet obecných parametrů jako spravovaný typ, aby mohl vygenerovaný kód použít konkrétní vytvoření instance.</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,11 @@
<target state="translated">Die Konfiguration von "StringMarshalling" und "StringMarshallingCustomType" muss mit der COM-Basisschnittstelle übereinstimmen.</target>
<note />
</trans-unit>
<trans-unit id="GenericDelegatesNotSupported">
<source>Marshalling a generic delegate is not supported. Consider using a function pointer instead.</source>
<target state="new">Marshalling a generic delegate is not supported. Consider using a function pointer instead.</target>
<note />
</trans-unit>
<trans-unit id="GenericEntryPointMarshallerTypeMustBeClosedOrMatchArityDescription">
<source>The marshaller type must be a closed generic or have the same number of generic parameters as the managed type so the emitted code can use a specific instantiation.</source>
<target state="translated">Der Marshaller-Typ muss ein geschlossener generischer Typ sein oder dieselbe Anzahl generischer Parameter wie der verwaltete Typ aufweisen, damit der ausgegebene Code eine bestimmte Instanziierung verwenden kann.</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,11 @@
<target state="translated">La configuración de "StringMarshalling" y "StringMarshallingCustomType" debe coincidir con la interfaz COM base.</target>
<note />
</trans-unit>
<trans-unit id="GenericDelegatesNotSupported">
<source>Marshalling a generic delegate is not supported. Consider using a function pointer instead.</source>
<target state="new">Marshalling a generic delegate is not supported. Consider using a function pointer instead.</target>
<note />
</trans-unit>
<trans-unit id="GenericEntryPointMarshallerTypeMustBeClosedOrMatchArityDescription">
<source>The marshaller type must be a closed generic or have the same number of generic parameters as the managed type so the emitted code can use a specific instantiation.</source>
<target state="translated">El tipo serializador debe ser un genérico cerrado o tener el mismo número de parámetros genéricos que el tipo administrado para que el código emitido pueda usar una creación de instancia específica.</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,11 @@
<target state="translated">La configuration de « StringMarshalling » et de « StringMarshallingCustomType » doit correspondre à l’interface COM de base.</target>
<note />
</trans-unit>
<trans-unit id="GenericDelegatesNotSupported">
<source>Marshalling a generic delegate is not supported. Consider using a function pointer instead.</source>
<target state="new">Marshalling a generic delegate is not supported. Consider using a function pointer instead.</target>
<note />
</trans-unit>
<trans-unit id="GenericEntryPointMarshallerTypeMustBeClosedOrMatchArityDescription">
<source>The marshaller type must be a closed generic or have the same number of generic parameters as the managed type so the emitted code can use a specific instantiation.</source>
<target state="translated">Le type marshaler doit être un générique fermé ou avoir le même nombre de paramètres génériques que le type managé pour que le code émis puisse utiliser une instanciation spécifique.</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,11 @@
<target state="translated">La configurazione di 'StringMarshalling' e 'StringMarshallingCustomType' deve corrispondere all'interfaccia COM di base.</target>
<note />
</trans-unit>
<trans-unit id="GenericDelegatesNotSupported">
<source>Marshalling a generic delegate is not supported. Consider using a function pointer instead.</source>
<target state="new">Marshalling a generic delegate is not supported. Consider using a function pointer instead.</target>
<note />
</trans-unit>
<trans-unit id="GenericEntryPointMarshallerTypeMustBeClosedOrMatchArityDescription">
<source>The marshaller type must be a closed generic or have the same number of generic parameters as the managed type so the emitted code can use a specific instantiation.</source>
<target state="translated">Il tipo di marshaller deve essere un generico chiuso o avere lo stesso numero di parametri generici del tipo gestito, in modo che il codice generato possa usare una creazione di istanza specifica.</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,11 @@
<target state="translated">'StringMarshalling' および 'StringMarshallingCustomType' の構成は、ベース COM インターフェイスと一致する必要があります。</target>
<note />
</trans-unit>
<trans-unit id="GenericDelegatesNotSupported">
<source>Marshalling a generic delegate is not supported. Consider using a function pointer instead.</source>
<target state="new">Marshalling a generic delegate is not supported. Consider using a function pointer instead.</target>
<note />
</trans-unit>
<trans-unit id="GenericEntryPointMarshallerTypeMustBeClosedOrMatchArityDescription">
<source>The marshaller type must be a closed generic or have the same number of generic parameters as the managed type so the emitted code can use a specific instantiation.</source>
<target state="translated">マーシャラー型は、クローズ ジェネリックであるか、マネージド型と同じ数のジェネリック パラメーターを持つ必要があります。これにより、生成されたコードが特定のインスタンス化を使用できるようになります。</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,11 @@
<target state="translated">'StringMarshalling' 및 'StringMarshallingCustomType'의 구성은 기본 COM 인터페이스와 일치해야 합니다.</target>
<note />
</trans-unit>
<trans-unit id="GenericDelegatesNotSupported">
<source>Marshalling a generic delegate is not supported. Consider using a function pointer instead.</source>
<target state="new">Marshalling a generic delegate is not supported. Consider using a function pointer instead.</target>
<note />
</trans-unit>
<trans-unit id="GenericEntryPointMarshallerTypeMustBeClosedOrMatchArityDescription">
<source>The marshaller type must be a closed generic or have the same number of generic parameters as the managed type so the emitted code can use a specific instantiation.</source>
<target state="translated">마샬러 형식은 닫힌 제네릭이거나 관리되는 형식과 동일한 수의 제네릭 매개 변수가 있어야 내보낸 코드에서 특정 인스턴스화를 사용할 수 있습니다.</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,11 @@
<target state="translated">Konfiguracja elementów „StringMarssourceing” i „StringMarsxtingCustomType” musi być zgodna z podstawowym interfejsem COM.</target>
<note />
</trans-unit>
<trans-unit id="GenericDelegatesNotSupported">
<source>Marshalling a generic delegate is not supported. Consider using a function pointer instead.</source>
<target state="new">Marshalling a generic delegate is not supported. Consider using a function pointer instead.</target>
<note />
</trans-unit>
<trans-unit id="GenericEntryPointMarshallerTypeMustBeClosedOrMatchArityDescription">
<source>The marshaller type must be a closed generic or have the same number of generic parameters as the managed type so the emitted code can use a specific instantiation.</source>
<target state="translated">Typ marshallera musi być zamkniętym typem ogólnym lub mieć taką samą liczbę parametrów ogólnych jak typ zarządzany, aby emitowany kod mógł używać określonego wystąpienia.</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,11 @@
<target state="translated">A configuração de 'StringMarshalling' e 'StringMarshallingCustomType' deve corresponder à interface COM base.</target>
<note />
</trans-unit>
<trans-unit id="GenericDelegatesNotSupported">
<source>Marshalling a generic delegate is not supported. Consider using a function pointer instead.</source>
<target state="new">Marshalling a generic delegate is not supported. Consider using a function pointer instead.</target>
<note />
</trans-unit>
<trans-unit id="GenericEntryPointMarshallerTypeMustBeClosedOrMatchArityDescription">
<source>The marshaller type must be a closed generic or have the same number of generic parameters as the managed type so the emitted code can use a specific instantiation.</source>
<target state="translated">O tipo de empacotador deve ser um genérico fechado ou ter o mesmo número de parâmetros genéricos que o tipo gerenciado para que o código emitido possa usar uma instanciação específica.</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,11 @@
<target state="translated">Конфигурация "StringMarshalling" и "StringMarshallingCustomType" должна соответствовать базовому COM-интерфейсу.</target>
<note />
</trans-unit>
<trans-unit id="GenericDelegatesNotSupported">
<source>Marshalling a generic delegate is not supported. Consider using a function pointer instead.</source>
<target state="new">Marshalling a generic delegate is not supported. Consider using a function pointer instead.</target>
<note />
</trans-unit>
<trans-unit id="GenericEntryPointMarshallerTypeMustBeClosedOrMatchArityDescription">
<source>The marshaller type must be a closed generic or have the same number of generic parameters as the managed type so the emitted code can use a specific instantiation.</source>
<target state="translated">Тип маршалера должен быть закрытым универсальным или иметь то же количество универсальных параметров, что и управляемый тип, чтобы создаваемый код мог использовать конкретный экземпляр.</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,11 @@
<target state="translated">'StringMarshalling' ve 'StringMarshallingCustomType' yapılandırması temel COM arabirimiyle eşleşmelidir.</target>
<note />
</trans-unit>
<trans-unit id="GenericDelegatesNotSupported">
<source>Marshalling a generic delegate is not supported. Consider using a function pointer instead.</source>
<target state="new">Marshalling a generic delegate is not supported. Consider using a function pointer instead.</target>
<note />
</trans-unit>
<trans-unit id="GenericEntryPointMarshallerTypeMustBeClosedOrMatchArityDescription">
<source>The marshaller type must be a closed generic or have the same number of generic parameters as the managed type so the emitted code can use a specific instantiation.</source>
<target state="translated">Hazırlayıcı türü kapalı bir genel tür olmalıdır veya gösterilen kodun belirli bir örnek oluşturma kullanabilmesi için yönetilen türle aynı sayıda genel parametreye sahip olmalıdır.</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,11 @@
<target state="translated">"StringMarshalling" 和 "StringMarshallingCustomType" 的配置必须与基本 COM 接口匹配。</target>
<note />
</trans-unit>
<trans-unit id="GenericDelegatesNotSupported">
<source>Marshalling a generic delegate is not supported. Consider using a function pointer instead.</source>
<target state="new">Marshalling a generic delegate is not supported. Consider using a function pointer instead.</target>
<note />
</trans-unit>
<trans-unit id="GenericEntryPointMarshallerTypeMustBeClosedOrMatchArityDescription">
<source>The marshaller type must be a closed generic or have the same number of generic parameters as the managed type so the emitted code can use a specific instantiation.</source>
<target state="translated">封送处理程序类型必须是封闭泛型或具有与托管类型相同数目的泛型参数,以便发出的代码可以使用特定实例化。</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,11 @@
<target state="translated">'StringMarshalling' 和 'StringMarshallingCustomType' 的設定必須和基底 COM 介面相符。</target>
<note />
</trans-unit>
<trans-unit id="GenericDelegatesNotSupported">
<source>Marshalling a generic delegate is not supported. Consider using a function pointer instead.</source>
<target state="new">Marshalling a generic delegate is not supported. Consider using a function pointer instead.</target>
<note />
</trans-unit>
<trans-unit id="GenericEntryPointMarshallerTypeMustBeClosedOrMatchArityDescription">
<source>The marshaller type must be a closed generic or have the same number of generic parameters as the managed type so the emitted code can use a specific instantiation.</source>
<target state="translated">封送處理器類型必須是封閉式泛型或具有與受控類型相同的泛型參數數目,因此發出的程式碼可以使用特定的具現化。</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public static ManagedTypeInfo CreateTypeInfoForTypeSymbol(ITypeSymbol type)
}
if (type.TypeKind == TypeKind.Delegate)
{
return new DelegateTypeInfo(typeName, diagnosticFormattedName);
return new DelegateTypeInfo(typeName, diagnosticFormattedName, type is INamedTypeSymbol { IsGenericType: true });
}
if (type.TypeKind == TypeKind.TypeParameter)
{
Expand Down Expand Up @@ -107,7 +107,7 @@ public sealed record PointerTypeInfo(string FullTypeName, string DiagnosticForma

public sealed record SzArrayType(ManagedTypeInfo ElementTypeInfo) : ManagedTypeInfo($"{ElementTypeInfo.FullTypeName}[]", $"{ElementTypeInfo.DiagnosticFormattedName}[]");

public sealed record DelegateTypeInfo(string FullTypeName, string DiagnosticFormattedName) : ManagedTypeInfo(FullTypeName, DiagnosticFormattedName);
public sealed record DelegateTypeInfo(string FullTypeName, string DiagnosticFormattedName, bool IsGeneric) : ManagedTypeInfo(FullTypeName, DiagnosticFormattedName);

public sealed record TypeParameterTypeInfo(string FullTypeName, string DiagnosticFormattedName) : ManagedTypeInfo(FullTypeName, DiagnosticFormattedName);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,11 @@ public ResolvedGenerator Create(
return ResolvedGenerator.Resolved(s_variantBool.Bind(info, context));

// Delegate types
case { ManagedType: DelegateTypeInfo, MarshallingAttributeInfo: NoMarshallingInfo or MarshalAsInfo(UnmanagedType.FunctionPtr, _) }:
case { ManagedType: DelegateTypeInfo delegateTypeInfo, MarshallingAttributeInfo: NoMarshallingInfo or MarshalAsInfo(UnmanagedType.FunctionPtr, _) }:
if (delegateTypeInfo.IsGeneric)
{
return ResolvedGenerator.NotSupported(info, context, new(info) { NotSupportedDetails = SR.GenericDelegatesNotSupported });
}
return ResolvedGenerator.Resolved(s_delegate.Bind(info, context));

// void
Expand Down
Loading
Loading