Skip to content

Commit c5b2dcd

Browse files
authored
Report a diagnostic when a type inherits from a GeneratedComClass-attributed type and does not have the GeneratedComClass attribute (#105277)
1 parent f68d8e1 commit c5b2dcd

17 files changed

+264
-214
lines changed

src/libraries/System.Runtime.InteropServices/System.Runtime.InteropServices.sln

+196-187
Large diffs are not rendered by default.

src/libraries/System.Runtime.InteropServices/gen/ComInterfaceGenerator/Analyzers/AddGeneratedComClassAnalyzer.cs

+6
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,12 @@ public override void Initialize(AnalysisContext context)
5252
return;
5353
}
5454
}
55+
56+
if (type.BaseType is not null
57+
&& type.BaseType.GetAttributes().Any(attr => generatedComClassAttributeType.Equals(attr.AttributeClass, SymbolEqualityComparer.Default)))
58+
{
59+
context.ReportDiagnostic(type.CreateDiagnostic(AddGeneratedComClassAttribute, type.Name));
60+
}
5561
}, SymbolKind.NamedType);
5662
});
5763
}

src/libraries/System.Runtime.InteropServices/gen/Common/Resources/Strings.resx

+1-1
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@
196196
<value>Add 'GeneratedComClassAttribute' to enable passing objects of this type to COM and allow unsafe code</value>
197197
</data>
198198
<data name="AddGeneratedComClassAttributeDescription" xml:space="preserve">
199-
<value>This type implements at least one type with the 'GeneratedComInterfaceAttribute' attribute. Add the 'GeneratedComClassAttribute' to enable passing this type to COM and exposing the COM interfaces for the types with the 'GeneratedComInterfaceAttribute' from objects of this type.</value>
199+
<value>This type implements at least one type with the 'GeneratedComInterfaceAttribute' attribute or its base type has the 'GeneratedComClassAttribute' attribute. Add the 'GeneratedComClassAttribute' to enable passing this type to COM and exposing the COM interfaces for the types with the 'GeneratedComInterfaceAttribute' from objects of this type.</value>
200200
</data>
201201
<data name="AddGeneratedComClassAttributeMessage" xml:space="preserve">
202202
<value>Add the 'GeneratedComClassAttribute' to '{0}' to enable passing objects of type '{0}' to COM</value>

src/libraries/System.Runtime.InteropServices/gen/Common/Resources/xlf/Strings.cs.xlf

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
<note />
99
</trans-unit>
1010
<trans-unit id="AddGeneratedComClassAttributeDescription">
11-
<source>This type implements at least one type with the 'GeneratedComInterfaceAttribute' attribute. Add the 'GeneratedComClassAttribute' to enable passing this type to COM and exposing the COM interfaces for the types with the 'GeneratedComInterfaceAttribute' from objects of this type.</source>
12-
<target state="translated">Tento typ implementuje alespoň jeden typ s atributem GeneratedComInterfaceAttribute. Přidejte generatedComClassAttribute, aby bylo možné předat tento typ modelu COM a zpřístupnit rozhraní COM pro typy s generatedComInterfaceAttribute z objektů tohoto typu.</target>
11+
<source>This type implements at least one type with the 'GeneratedComInterfaceAttribute' attribute or its base type has the 'GeneratedComClassAttribute' attribute. Add the 'GeneratedComClassAttribute' to enable passing this type to COM and exposing the COM interfaces for the types with the 'GeneratedComInterfaceAttribute' from objects of this type.</source>
12+
<target state="needs-review-translation">Tento typ implementuje alespoň jeden typ s atributem GeneratedComInterfaceAttribute. Přidejte generatedComClassAttribute, aby bylo možné předat tento typ modelu COM a zpřístupnit rozhraní COM pro typy s generatedComInterfaceAttribute z objektů tohoto typu.</target>
1313
<note />
1414
</trans-unit>
1515
<trans-unit id="AddGeneratedComClassAttributeMessage">

src/libraries/System.Runtime.InteropServices/gen/Common/Resources/xlf/Strings.de.xlf

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
<note />
99
</trans-unit>
1010
<trans-unit id="AddGeneratedComClassAttributeDescription">
11-
<source>This type implements at least one type with the 'GeneratedComInterfaceAttribute' attribute. Add the 'GeneratedComClassAttribute' to enable passing this type to COM and exposing the COM interfaces for the types with the 'GeneratedComInterfaceAttribute' from objects of this type.</source>
12-
<target state="translated">Dieser Typ implementiert mindestens einen Typ mit dem GeneratedComInterfaceAttribute-Attribut. Fügen Sie "GeneratedComClassAttribute" hinzu, um die Übergabe dieses Typs an COM zu ermöglichen und die COM-Schnittstellen für die Typen mit dem GeneratedComInterfaceAttribute aus Objekten dieses Typs verfügbar zu machen.</target>
11+
<source>This type implements at least one type with the 'GeneratedComInterfaceAttribute' attribute or its base type has the 'GeneratedComClassAttribute' attribute. Add the 'GeneratedComClassAttribute' to enable passing this type to COM and exposing the COM interfaces for the types with the 'GeneratedComInterfaceAttribute' from objects of this type.</source>
12+
<target state="needs-review-translation">Dieser Typ implementiert mindestens einen Typ mit dem GeneratedComInterfaceAttribute-Attribut. Fügen Sie "GeneratedComClassAttribute" hinzu, um die Übergabe dieses Typs an COM zu ermöglichen und die COM-Schnittstellen für die Typen mit dem GeneratedComInterfaceAttribute aus Objekten dieses Typs verfügbar zu machen.</target>
1313
<note />
1414
</trans-unit>
1515
<trans-unit id="AddGeneratedComClassAttributeMessage">

src/libraries/System.Runtime.InteropServices/gen/Common/Resources/xlf/Strings.es.xlf

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
<note />
99
</trans-unit>
1010
<trans-unit id="AddGeneratedComClassAttributeDescription">
11-
<source>This type implements at least one type with the 'GeneratedComInterfaceAttribute' attribute. Add the 'GeneratedComClassAttribute' to enable passing this type to COM and exposing the COM interfaces for the types with the 'GeneratedComInterfaceAttribute' from objects of this type.</source>
12-
<target state="translated">Este tipo implementa al menos un tipo con el atributo “GeneratedComInterfaceAttribute”. Agregue “GeneratedComClassAttribute” para habilitar el paso de este tipo a COM y exponer las interfaces COM para los tipos con “GeneratedComInterfaceAttribute” a partir de objetos de este tipo.</target>
11+
<source>This type implements at least one type with the 'GeneratedComInterfaceAttribute' attribute or its base type has the 'GeneratedComClassAttribute' attribute. Add the 'GeneratedComClassAttribute' to enable passing this type to COM and exposing the COM interfaces for the types with the 'GeneratedComInterfaceAttribute' from objects of this type.</source>
12+
<target state="needs-review-translation">Este tipo implementa al menos un tipo con el atributo “GeneratedComInterfaceAttribute”. Agregue “GeneratedComClassAttribute” para habilitar el paso de este tipo a COM y exponer las interfaces COM para los tipos con “GeneratedComInterfaceAttribute” a partir de objetos de este tipo.</target>
1313
<note />
1414
</trans-unit>
1515
<trans-unit id="AddGeneratedComClassAttributeMessage">

src/libraries/System.Runtime.InteropServices/gen/Common/Resources/xlf/Strings.fr.xlf

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
<note />
99
</trans-unit>
1010
<trans-unit id="AddGeneratedComClassAttributeDescription">
11-
<source>This type implements at least one type with the 'GeneratedComInterfaceAttribute' attribute. Add the 'GeneratedComClassAttribute' to enable passing this type to COM and exposing the COM interfaces for the types with the 'GeneratedComInterfaceAttribute' from objects of this type.</source>
12-
<target state="translated">Ce type implémente au moins un type avec l'attribut 'GeneratedComInterfaceAttribute'. Ajoutez le 'GeneratedComClassAttribute' pour activer le passage de ce type à COM et exposer les interfaces COM pour les types avec le 'GeneratedComInterfaceAttribute' des objets de ce type.</target>
11+
<source>This type implements at least one type with the 'GeneratedComInterfaceAttribute' attribute or its base type has the 'GeneratedComClassAttribute' attribute. Add the 'GeneratedComClassAttribute' to enable passing this type to COM and exposing the COM interfaces for the types with the 'GeneratedComInterfaceAttribute' from objects of this type.</source>
12+
<target state="needs-review-translation">Ce type implémente au moins un type avec l'attribut 'GeneratedComInterfaceAttribute'. Ajoutez le 'GeneratedComClassAttribute' pour activer le passage de ce type à COM et exposer les interfaces COM pour les types avec le 'GeneratedComInterfaceAttribute' des objets de ce type.</target>
1313
<note />
1414
</trans-unit>
1515
<trans-unit id="AddGeneratedComClassAttributeMessage">

src/libraries/System.Runtime.InteropServices/gen/Common/Resources/xlf/Strings.it.xlf

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
<note />
99
</trans-unit>
1010
<trans-unit id="AddGeneratedComClassAttributeDescription">
11-
<source>This type implements at least one type with the 'GeneratedComInterfaceAttribute' attribute. Add the 'GeneratedComClassAttribute' to enable passing this type to COM and exposing the COM interfaces for the types with the 'GeneratedComInterfaceAttribute' from objects of this type.</source>
12-
<target state="translated">Questo tipo implementa almeno un tipo con l'attributo 'GeneratedComInterfaceAttribute'. Aggiungere l'attributo 'GeneratedComClassAttribute' per consentire il passaggio di questo tipo a COM e l'esposizione delle interfacce COM per i tipi con l'attributo 'GeneratedComInterfaceAttribute' dagli oggetti di questo tipo.</target>
11+
<source>This type implements at least one type with the 'GeneratedComInterfaceAttribute' attribute or its base type has the 'GeneratedComClassAttribute' attribute. Add the 'GeneratedComClassAttribute' to enable passing this type to COM and exposing the COM interfaces for the types with the 'GeneratedComInterfaceAttribute' from objects of this type.</source>
12+
<target state="needs-review-translation">Questo tipo implementa almeno un tipo con l'attributo 'GeneratedComInterfaceAttribute'. Aggiungere l'attributo 'GeneratedComClassAttribute' per consentire il passaggio di questo tipo a COM e l'esposizione delle interfacce COM per i tipi con l'attributo 'GeneratedComInterfaceAttribute' dagli oggetti di questo tipo.</target>
1313
<note />
1414
</trans-unit>
1515
<trans-unit id="AddGeneratedComClassAttributeMessage">

src/libraries/System.Runtime.InteropServices/gen/Common/Resources/xlf/Strings.ja.xlf

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
<note />
99
</trans-unit>
1010
<trans-unit id="AddGeneratedComClassAttributeDescription">
11-
<source>This type implements at least one type with the 'GeneratedComInterfaceAttribute' attribute. Add the 'GeneratedComClassAttribute' to enable passing this type to COM and exposing the COM interfaces for the types with the 'GeneratedComInterfaceAttribute' from objects of this type.</source>
12-
<target state="translated">この型は、'GeneratedComInterfaceAttribute' 属性を持つ少なくとも 1 つの型を実装します。'GeneratedComClassAttribute' を追加して、この型を COM に渡し、この型のオブジェクトから 'GeneratedComInterfaceAttribute' を持つ型の COM インターフェイスを公開できるようにします。</target>
11+
<source>This type implements at least one type with the 'GeneratedComInterfaceAttribute' attribute or its base type has the 'GeneratedComClassAttribute' attribute. Add the 'GeneratedComClassAttribute' to enable passing this type to COM and exposing the COM interfaces for the types with the 'GeneratedComInterfaceAttribute' from objects of this type.</source>
12+
<target state="needs-review-translation">この型は、'GeneratedComInterfaceAttribute' 属性を持つ少なくとも 1 つの型を実装します。'GeneratedComClassAttribute' を追加して、この型を COM に渡し、この型のオブジェクトから 'GeneratedComInterfaceAttribute' を持つ型の COM インターフェイスを公開できるようにします。</target>
1313
<note />
1414
</trans-unit>
1515
<trans-unit id="AddGeneratedComClassAttributeMessage">

src/libraries/System.Runtime.InteropServices/gen/Common/Resources/xlf/Strings.ko.xlf

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
<note />
99
</trans-unit>
1010
<trans-unit id="AddGeneratedComClassAttributeDescription">
11-
<source>This type implements at least one type with the 'GeneratedComInterfaceAttribute' attribute. Add the 'GeneratedComClassAttribute' to enable passing this type to COM and exposing the COM interfaces for the types with the 'GeneratedComInterfaceAttribute' from objects of this type.</source>
12-
<target state="translated">이 유형은 'GeneratedComInterfaceAttribute' 특성이 있는 하나 이상의 유형을 구현합니다. 이 형식을 COM에 전달하고 이 형식의 개체에서 'GeneratedComInterfaceAttribute'가 있는 형식에 대한 COM 인터페이스를 노출하려면 'GeneratedComClassAttribute'를 추가합니다.</target>
11+
<source>This type implements at least one type with the 'GeneratedComInterfaceAttribute' attribute or its base type has the 'GeneratedComClassAttribute' attribute. Add the 'GeneratedComClassAttribute' to enable passing this type to COM and exposing the COM interfaces for the types with the 'GeneratedComInterfaceAttribute' from objects of this type.</source>
12+
<target state="needs-review-translation">이 유형은 'GeneratedComInterfaceAttribute' 특성이 있는 하나 이상의 유형을 구현합니다. 이 형식을 COM에 전달하고 이 형식의 개체에서 'GeneratedComInterfaceAttribute'가 있는 형식에 대한 COM 인터페이스를 노출하려면 'GeneratedComClassAttribute'를 추가합니다.</target>
1313
<note />
1414
</trans-unit>
1515
<trans-unit id="AddGeneratedComClassAttributeMessage">

src/libraries/System.Runtime.InteropServices/gen/Common/Resources/xlf/Strings.pl.xlf

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
<note />
99
</trans-unit>
1010
<trans-unit id="AddGeneratedComClassAttributeDescription">
11-
<source>This type implements at least one type with the 'GeneratedComInterfaceAttribute' attribute. Add the 'GeneratedComClassAttribute' to enable passing this type to COM and exposing the COM interfaces for the types with the 'GeneratedComInterfaceAttribute' from objects of this type.</source>
12-
<target state="translated">Ten typ implementuje co najmniej jeden typ z atrybutem „GeneratedComInterfaceAttribute”. Dodaj atrybut „GeneratedComClassAttribute”, aby umożliwić przekazywanie tego typu do modelu COM i uwidacznianie interfejsów COM dla typów z atrybutem „GeneratedComInterfaceAttribute” z obiektów tego typu.</target>
11+
<source>This type implements at least one type with the 'GeneratedComInterfaceAttribute' attribute or its base type has the 'GeneratedComClassAttribute' attribute. Add the 'GeneratedComClassAttribute' to enable passing this type to COM and exposing the COM interfaces for the types with the 'GeneratedComInterfaceAttribute' from objects of this type.</source>
12+
<target state="needs-review-translation">Ten typ implementuje co najmniej jeden typ z atrybutem „GeneratedComInterfaceAttribute”. Dodaj atrybut „GeneratedComClassAttribute”, aby umożliwić przekazywanie tego typu do modelu COM i uwidacznianie interfejsów COM dla typów z atrybutem „GeneratedComInterfaceAttribute” z obiektów tego typu.</target>
1313
<note />
1414
</trans-unit>
1515
<trans-unit id="AddGeneratedComClassAttributeMessage">

src/libraries/System.Runtime.InteropServices/gen/Common/Resources/xlf/Strings.pt-BR.xlf

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
<note />
99
</trans-unit>
1010
<trans-unit id="AddGeneratedComClassAttributeDescription">
11-
<source>This type implements at least one type with the 'GeneratedComInterfaceAttribute' attribute. Add the 'GeneratedComClassAttribute' to enable passing this type to COM and exposing the COM interfaces for the types with the 'GeneratedComInterfaceAttribute' from objects of this type.</source>
12-
<target state="translated">Esse tipo implementa pelo menos um tipo com o atributo 'GeneratedComInterfaceAttribute'. Adicione o 'GeneratedComClassAttribute' para habilitar a passagem desse tipo para COM e expor as interfaces COM para os tipos com o 'GeneratedComInterfaceAttribute' de objetos desse tipo.</target>
11+
<source>This type implements at least one type with the 'GeneratedComInterfaceAttribute' attribute or its base type has the 'GeneratedComClassAttribute' attribute. Add the 'GeneratedComClassAttribute' to enable passing this type to COM and exposing the COM interfaces for the types with the 'GeneratedComInterfaceAttribute' from objects of this type.</source>
12+
<target state="needs-review-translation">Esse tipo implementa pelo menos um tipo com o atributo 'GeneratedComInterfaceAttribute'. Adicione o 'GeneratedComClassAttribute' para habilitar a passagem desse tipo para COM e expor as interfaces COM para os tipos com o 'GeneratedComInterfaceAttribute' de objetos desse tipo.</target>
1313
<note />
1414
</trans-unit>
1515
<trans-unit id="AddGeneratedComClassAttributeMessage">

src/libraries/System.Runtime.InteropServices/gen/Common/Resources/xlf/Strings.ru.xlf

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
<note />
99
</trans-unit>
1010
<trans-unit id="AddGeneratedComClassAttributeDescription">
11-
<source>This type implements at least one type with the 'GeneratedComInterfaceAttribute' attribute. Add the 'GeneratedComClassAttribute' to enable passing this type to COM and exposing the COM interfaces for the types with the 'GeneratedComInterfaceAttribute' from objects of this type.</source>
12-
<target state="translated">Этот тип реализует по крайней мере один тип с атрибутом "GeneratedComInterfaceAttribute". Добавьте "GeneratedComClassAttribute", чтобы разрешить передачу этого типа в COM и предоставление COM-интерфейсов для типов с "GeneratedComInterfaceAttribute" из объектов этого типа.</target>
11+
<source>This type implements at least one type with the 'GeneratedComInterfaceAttribute' attribute or its base type has the 'GeneratedComClassAttribute' attribute. Add the 'GeneratedComClassAttribute' to enable passing this type to COM and exposing the COM interfaces for the types with the 'GeneratedComInterfaceAttribute' from objects of this type.</source>
12+
<target state="needs-review-translation">Этот тип реализует по крайней мере один тип с атрибутом "GeneratedComInterfaceAttribute". Добавьте "GeneratedComClassAttribute", чтобы разрешить передачу этого типа в COM и предоставление COM-интерфейсов для типов с "GeneratedComInterfaceAttribute" из объектов этого типа.</target>
1313
<note />
1414
</trans-unit>
1515
<trans-unit id="AddGeneratedComClassAttributeMessage">

src/libraries/System.Runtime.InteropServices/gen/Common/Resources/xlf/Strings.tr.xlf

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
<note />
99
</trans-unit>
1010
<trans-unit id="AddGeneratedComClassAttributeDescription">
11-
<source>This type implements at least one type with the 'GeneratedComInterfaceAttribute' attribute. Add the 'GeneratedComClassAttribute' to enable passing this type to COM and exposing the COM interfaces for the types with the 'GeneratedComInterfaceAttribute' from objects of this type.</source>
12-
<target state="translated">Bu tür, 'GeneratedComInterfaceAttribute' özniteliğine sahip en az bir tür uygular. Bu türü COM'a geçirmeyi ve bu türdeki nesnelerden 'GeneratedComInterfaceAttribute' içeren türler için COM arabirimlerini açığa çıkarmayı etkinleştirmek için 'GeneratedComClassAttribute' ekleyin.</target>
11+
<source>This type implements at least one type with the 'GeneratedComInterfaceAttribute' attribute or its base type has the 'GeneratedComClassAttribute' attribute. Add the 'GeneratedComClassAttribute' to enable passing this type to COM and exposing the COM interfaces for the types with the 'GeneratedComInterfaceAttribute' from objects of this type.</source>
12+
<target state="needs-review-translation">Bu tür, 'GeneratedComInterfaceAttribute' özniteliğine sahip en az bir tür uygular. Bu türü COM'a geçirmeyi ve bu türdeki nesnelerden 'GeneratedComInterfaceAttribute' içeren türler için COM arabirimlerini açığa çıkarmayı etkinleştirmek için 'GeneratedComClassAttribute' ekleyin.</target>
1313
<note />
1414
</trans-unit>
1515
<trans-unit id="AddGeneratedComClassAttributeMessage">

0 commit comments

Comments
 (0)