Skip to content
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,20 @@ private static IncrementalMethodStubGenerationContext CalculateStubInformation(M
})
};
}
var direction = GetDirectionFromOptions(generatedComInterfaceAttributeData.Options);

// Ensure the size of collections are known at marshal / unmarshal in time.
// A collection that is marshalled in cannot have a size that is an 'out' parameter.
foreach (TypePositionInfo parameter in signatureContext.ManagedParameters)
{
MarshallerHelpers.ValidateCountInfoAvailableAtCall(
direction,
parameter,
generatorDiagnostics,
symbol,
GeneratorDiagnostics.SizeOfInCollectionMustBeDefinedAtCallOutParam,
GeneratorDiagnostics.SizeOfInCollectionMustBeDefinedAtCallReturnValue);
}

var containingSyntaxContext = new ContainingSyntaxContext(syntax);

Expand All @@ -322,7 +336,7 @@ private static IncrementalMethodStubGenerationContext CalculateStubInformation(M

var declaringType = ManagedTypeInfo.CreateTypeInfoForTypeSymbol(symbol.ContainingType);

var virtualMethodIndexData = new VirtualMethodIndexData(index, ImplicitThisParameter: true, GetDirectionFromOptions(generatedComInterfaceAttributeData.Options), true, ExceptionMarshalling.Com);
var virtualMethodIndexData = new VirtualMethodIndexData(index, ImplicitThisParameter: true, direction, true, ExceptionMarshalling.Com);

return new IncrementalMethodStubGenerationContext(
signatureContext,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,26 @@ public class Ids
WellKnownDiagnosticTags.Unnecessary
});

/// <inheritdoc cref="SR.SizeOfCollectionMustBeKnownAtMarshalTimeMessageOutParam"/>
public static readonly DiagnosticDescriptor SizeOfInCollectionMustBeDefinedAtCallOutParam =
new DiagnosticDescriptor(
Ids.InvalidGeneratedComInterfaceAttributeUsage,
GetResourceString(nameof(SR.SizeOfCollectionMustBeKnownAtMarshalTimeTitle)),
GetResourceString(nameof(SR.SizeOfCollectionMustBeKnownAtMarshalTimeMessageOutParam)),
Category,
DiagnosticSeverity.Warning,
isEnabledByDefault: true);

/// <inheritdoc cref="SR.SizeOfCollectionMustBeKnownAtMarshalTimeMessageReturnValue"/>
public static readonly DiagnosticDescriptor SizeOfInCollectionMustBeDefinedAtCallReturnValue =
new DiagnosticDescriptor(
Ids.InvalidGeneratedComInterfaceAttributeUsage,
GetResourceString(nameof(SR.SizeOfCollectionMustBeKnownAtMarshalTimeTitle)),
GetResourceString(nameof(SR.SizeOfCollectionMustBeKnownAtMarshalTimeMessageReturnValue)),
Category,
DiagnosticSeverity.Warning,
isEnabledByDefault: true);

/// <inheritdoc cref="SR.ComMethodReturningIntWillBeOutParameterMessage"/>
public static readonly DiagnosticDescriptor ComMethodManagedReturnWillBeOutVariable =
new DiagnosticDescriptor(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -700,6 +700,15 @@
<data name="RuntimeComApisDoNotSupportSourceGeneratedComTitle" xml:space="preserve">
<value>COM Interop APIs on 'System.Runtime.InteropServices.Marshal' do not support source-generated COM</value>
</data>
<data name="SizeOfCollectionMustBeKnownAtMarshalTimeTitle" xml:space="preserve">
<value>The size of a collection that is marshalled to the callee must be defined when the method is called.</value>
</data>
<data name="SizeOfCollectionMustBeKnownAtMarshalTimeMessageOutParam" xml:space="preserve">
<value>The size of parameter '{0}' that is marshalled to the callee must be defined when the method is called, but count parameter '{1}' is an 'out' parameter.</value>
</data>
<data name="SizeOfCollectionMustBeKnownAtMarshalTimeMessageReturnValue" xml:space="preserve">
<value>The size of parameter '{0}' that is marshalled to the callee must be defined when the method is called, but the return value is used as the size of the collection.</value>
</data>
<data name="StatefulMarshallerRequiresFreeDescription" xml:space="preserve">
<value>A stateful marshaller must have a zero-parameter void-returning instance method named 'Free'.</value>
</data>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -997,6 +997,21 @@
<target state="translated">Abstraktní typ odvozený ze SafeHandle nelze zařadit pomocí odkazu. Poskytnutý typ musí být konkrétní.</target>
<note />
</trans-unit>
<trans-unit id="SizeOfCollectionMustBeKnownAtMarshalTimeMessageOutParam">
<source>The size of parameter '{0}' that is marshalled to the callee must be defined when the method is called, but count parameter '{1}' is an 'out' parameter.</source>
<target state="new">The size of parameter '{0}' that is marshalled to the callee must be defined when the method is called, but count parameter '{1}' is an 'out' parameter.</target>
<note />
</trans-unit>
<trans-unit id="SizeOfCollectionMustBeKnownAtMarshalTimeMessageReturnValue">
<source>The size of parameter '{0}' that is marshalled to the callee must be defined when the method is called, but the return value is used as the size of the collection.</source>
<target state="new">The size of parameter '{0}' that is marshalled to the callee must be defined when the method is called, but the return value is used as the size of the collection.</target>
<note />
</trans-unit>
<trans-unit id="SizeOfCollectionMustBeKnownAtMarshalTimeTitle">
<source>The size of a collection that is marshalled to the callee must be defined when the method is called.</source>
<target state="new">The size of a collection that is marshalled to the callee must be defined when the method is called.</target>
<note />
</trans-unit>
<trans-unit id="StatefulMarshallerRequiresFreeDescription">
<source>A stateful marshaller must have a zero-parameter void-returning instance method named 'Free'.</source>
<target state="translated">Stavový zařazovač musí mít instanční metodu s názvem Free, která nemá žádné parametry a vrací void.</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -997,6 +997,21 @@
<target state="translated">Ein abstrakter Typ, der von \"SafeHandle\" abgeleitet wird, kann nicht als Verweis gemarshallt werden. Der angegebene Typ muss ein konkretes Element sein.</target>
<note />
</trans-unit>
<trans-unit id="SizeOfCollectionMustBeKnownAtMarshalTimeMessageOutParam">
<source>The size of parameter '{0}' that is marshalled to the callee must be defined when the method is called, but count parameter '{1}' is an 'out' parameter.</source>
<target state="new">The size of parameter '{0}' that is marshalled to the callee must be defined when the method is called, but count parameter '{1}' is an 'out' parameter.</target>
<note />
</trans-unit>
<trans-unit id="SizeOfCollectionMustBeKnownAtMarshalTimeMessageReturnValue">
<source>The size of parameter '{0}' that is marshalled to the callee must be defined when the method is called, but the return value is used as the size of the collection.</source>
<target state="new">The size of parameter '{0}' that is marshalled to the callee must be defined when the method is called, but the return value is used as the size of the collection.</target>
<note />
</trans-unit>
<trans-unit id="SizeOfCollectionMustBeKnownAtMarshalTimeTitle">
<source>The size of a collection that is marshalled to the callee must be defined when the method is called.</source>
<target state="new">The size of a collection that is marshalled to the callee must be defined when the method is called.</target>
<note />
</trans-unit>
<trans-unit id="StatefulMarshallerRequiresFreeDescription">
<source>A stateful marshaller must have a zero-parameter void-returning instance method named 'Free'.</source>
<target state="translated">Ein statusbehafteter Marshaller muss eine Instanzmethode mit dem Namen „Free“ mit null Parametern haben, die „nichtig“ zurückgibt.</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -997,6 +997,21 @@
<target state="translated">Un tipo abstracto derivado de “SafeHandle” no se puede serializar por referencia. El tipo proporcionado debe ser concreto.</target>
<note />
</trans-unit>
<trans-unit id="SizeOfCollectionMustBeKnownAtMarshalTimeMessageOutParam">
<source>The size of parameter '{0}' that is marshalled to the callee must be defined when the method is called, but count parameter '{1}' is an 'out' parameter.</source>
<target state="new">The size of parameter '{0}' that is marshalled to the callee must be defined when the method is called, but count parameter '{1}' is an 'out' parameter.</target>
<note />
</trans-unit>
<trans-unit id="SizeOfCollectionMustBeKnownAtMarshalTimeMessageReturnValue">
<source>The size of parameter '{0}' that is marshalled to the callee must be defined when the method is called, but the return value is used as the size of the collection.</source>
<target state="new">The size of parameter '{0}' that is marshalled to the callee must be defined when the method is called, but the return value is used as the size of the collection.</target>
<note />
</trans-unit>
<trans-unit id="SizeOfCollectionMustBeKnownAtMarshalTimeTitle">
<source>The size of a collection that is marshalled to the callee must be defined when the method is called.</source>
<target state="new">The size of a collection that is marshalled to the callee must be defined when the method is called.</target>
<note />
</trans-unit>
<trans-unit id="StatefulMarshallerRequiresFreeDescription">
<source>A stateful marshaller must have a zero-parameter void-returning instance method named 'Free'.</source>
<target state="translated">Un serializador con estado debe tener un método de instancia de devolución void de parámetro cero denominado 'Free'.</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -997,6 +997,21 @@
<target state="translated">Un type abstrait dérivé de « SafeHandle » ne peut pas être marshalé par référence. Le type fourni doit être concret.</target>
<note />
</trans-unit>
<trans-unit id="SizeOfCollectionMustBeKnownAtMarshalTimeMessageOutParam">
<source>The size of parameter '{0}' that is marshalled to the callee must be defined when the method is called, but count parameter '{1}' is an 'out' parameter.</source>
<target state="new">The size of parameter '{0}' that is marshalled to the callee must be defined when the method is called, but count parameter '{1}' is an 'out' parameter.</target>
<note />
</trans-unit>
<trans-unit id="SizeOfCollectionMustBeKnownAtMarshalTimeMessageReturnValue">
<source>The size of parameter '{0}' that is marshalled to the callee must be defined when the method is called, but the return value is used as the size of the collection.</source>
<target state="new">The size of parameter '{0}' that is marshalled to the callee must be defined when the method is called, but the return value is used as the size of the collection.</target>
<note />
</trans-unit>
<trans-unit id="SizeOfCollectionMustBeKnownAtMarshalTimeTitle">
<source>The size of a collection that is marshalled to the callee must be defined when the method is called.</source>
<target state="new">The size of a collection that is marshalled to the callee must be defined when the method is called.</target>
<note />
</trans-unit>
<trans-unit id="StatefulMarshallerRequiresFreeDescription">
<source>A stateful marshaller must have a zero-parameter void-returning instance method named 'Free'.</source>
<target state="translated">Un marshaleur avec état doit avoir une méthode d’instance de retour void de paramètre zéro nommée 'Free'.</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -997,6 +997,21 @@
<target state="translated">Non è possibile effettuare il marshalling per riferimento di un tipo astratto derivato da 'SafeHandle'. Il tipo specificato deve essere concreto.</target>
<note />
</trans-unit>
<trans-unit id="SizeOfCollectionMustBeKnownAtMarshalTimeMessageOutParam">
<source>The size of parameter '{0}' that is marshalled to the callee must be defined when the method is called, but count parameter '{1}' is an 'out' parameter.</source>
<target state="new">The size of parameter '{0}' that is marshalled to the callee must be defined when the method is called, but count parameter '{1}' is an 'out' parameter.</target>
<note />
</trans-unit>
<trans-unit id="SizeOfCollectionMustBeKnownAtMarshalTimeMessageReturnValue">
<source>The size of parameter '{0}' that is marshalled to the callee must be defined when the method is called, but the return value is used as the size of the collection.</source>
<target state="new">The size of parameter '{0}' that is marshalled to the callee must be defined when the method is called, but the return value is used as the size of the collection.</target>
<note />
</trans-unit>
<trans-unit id="SizeOfCollectionMustBeKnownAtMarshalTimeTitle">
<source>The size of a collection that is marshalled to the callee must be defined when the method is called.</source>
<target state="new">The size of a collection that is marshalled to the callee must be defined when the method is called.</target>
<note />
</trans-unit>
<trans-unit id="StatefulMarshallerRequiresFreeDescription">
<source>A stateful marshaller must have a zero-parameter void-returning instance method named 'Free'.</source>
<target state="translated">Un gestore di marshalling con stato deve avere un metodo di istanza con restituzione void con parametro zero denominato 'Free'.</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -997,6 +997,21 @@
<target state="translated">'SafeHandle' から派生した抽象型は、参照でマーシャリングできません。指定される型は具象型である必要があります。</target>
<note />
</trans-unit>
<trans-unit id="SizeOfCollectionMustBeKnownAtMarshalTimeMessageOutParam">
<source>The size of parameter '{0}' that is marshalled to the callee must be defined when the method is called, but count parameter '{1}' is an 'out' parameter.</source>
<target state="new">The size of parameter '{0}' that is marshalled to the callee must be defined when the method is called, but count parameter '{1}' is an 'out' parameter.</target>
<note />
</trans-unit>
<trans-unit id="SizeOfCollectionMustBeKnownAtMarshalTimeMessageReturnValue">
<source>The size of parameter '{0}' that is marshalled to the callee must be defined when the method is called, but the return value is used as the size of the collection.</source>
<target state="new">The size of parameter '{0}' that is marshalled to the callee must be defined when the method is called, but the return value is used as the size of the collection.</target>
<note />
</trans-unit>
<trans-unit id="SizeOfCollectionMustBeKnownAtMarshalTimeTitle">
<source>The size of a collection that is marshalled to the callee must be defined when the method is called.</source>
<target state="new">The size of a collection that is marshalled to the callee must be defined when the method is called.</target>
<note />
</trans-unit>
<trans-unit id="StatefulMarshallerRequiresFreeDescription">
<source>A stateful marshaller must have a zero-parameter void-returning instance method named 'Free'.</source>
<target state="translated">ステートフル マーシャラーには、'Free' という名前で、パラメーターがなく、‘void’ を返すインスタンス メソッドが必要です。</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -997,6 +997,21 @@
<target state="translated">'SafeHandle'에서 파생된 추상 형식은 참조로 마샬링할 수 없습니다. 제공된 형식은 구체적이어야 합니다.</target>
<note />
</trans-unit>
<trans-unit id="SizeOfCollectionMustBeKnownAtMarshalTimeMessageOutParam">
<source>The size of parameter '{0}' that is marshalled to the callee must be defined when the method is called, but count parameter '{1}' is an 'out' parameter.</source>
<target state="new">The size of parameter '{0}' that is marshalled to the callee must be defined when the method is called, but count parameter '{1}' is an 'out' parameter.</target>
<note />
</trans-unit>
<trans-unit id="SizeOfCollectionMustBeKnownAtMarshalTimeMessageReturnValue">
<source>The size of parameter '{0}' that is marshalled to the callee must be defined when the method is called, but the return value is used as the size of the collection.</source>
<target state="new">The size of parameter '{0}' that is marshalled to the callee must be defined when the method is called, but the return value is used as the size of the collection.</target>
<note />
</trans-unit>
<trans-unit id="SizeOfCollectionMustBeKnownAtMarshalTimeTitle">
<source>The size of a collection that is marshalled to the callee must be defined when the method is called.</source>
<target state="new">The size of a collection that is marshalled to the callee must be defined when the method is called.</target>
<note />
</trans-unit>
<trans-unit id="StatefulMarshallerRequiresFreeDescription">
<source>A stateful marshaller must have a zero-parameter void-returning instance method named 'Free'.</source>
<target state="translated">상태 저장 마샬러에는 'Free'라는 0 매개 변수 반환 인스턴스 메서드가 있어야 합니다.</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -997,6 +997,21 @@
<target state="translated">Typ abstrakcyjny pochodzący od elementu „SafeHandle” nie może być skierowany przez odwołanie. Podany typ musi być konkretny.</target>
<note />
</trans-unit>
<trans-unit id="SizeOfCollectionMustBeKnownAtMarshalTimeMessageOutParam">
<source>The size of parameter '{0}' that is marshalled to the callee must be defined when the method is called, but count parameter '{1}' is an 'out' parameter.</source>
<target state="new">The size of parameter '{0}' that is marshalled to the callee must be defined when the method is called, but count parameter '{1}' is an 'out' parameter.</target>
<note />
</trans-unit>
<trans-unit id="SizeOfCollectionMustBeKnownAtMarshalTimeMessageReturnValue">
<source>The size of parameter '{0}' that is marshalled to the callee must be defined when the method is called, but the return value is used as the size of the collection.</source>
<target state="new">The size of parameter '{0}' that is marshalled to the callee must be defined when the method is called, but the return value is used as the size of the collection.</target>
<note />
</trans-unit>
<trans-unit id="SizeOfCollectionMustBeKnownAtMarshalTimeTitle">
<source>The size of a collection that is marshalled to the callee must be defined when the method is called.</source>
<target state="new">The size of a collection that is marshalled to the callee must be defined when the method is called.</target>
<note />
</trans-unit>
<trans-unit id="StatefulMarshallerRequiresFreeDescription">
<source>A stateful marshaller must have a zero-parameter void-returning instance method named 'Free'.</source>
<target state="translated">Stanowy marshaller musi mieć metodę wystąpienia zwracającą wartość nieważną o parametrze 0 o nazwie „Free”.</target>
Expand Down
Loading