Skip to content

Commit

Permalink
Add stateful marshaller support to the CustomMarshallerAttributeAnaly…
Browse files Browse the repository at this point in the history
…zer (#72888)
  • Loading branch information
jkoritzinsky authored Jul 29, 2022
1 parent 32f3646 commit a01aea9
Show file tree
Hide file tree
Showing 23 changed files with 2,024 additions and 111 deletions.
2 changes: 2 additions & 0 deletions src/libraries/Common/src/Interop/Interop.Ldap.cs
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,8 @@ public LdapReferralCallback ToManaged()
}

public void OnInvoked() => GC.KeepAlive(_managed);

public void Free() {}
}
}
#else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,8 @@ public void OnInvoked()
{
GC.KeepAlive(_managed);
}

public void Free() {}
}
}
#endif
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -117,16 +117,16 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="CallerAllocConstructorMustHaveBufferSizeDescription" xml:space="preserve">
<data name="CallerAllocFromManagedMustHaveBufferSizeDescription" xml:space="preserve">
<value>When the 'Managed to Unmanaged with Caller-Allocated Buffer' shape is used by providing a 'FromManaged' method that takes a 'Span&lt;T&gt;' on the marshaller type, the type must provide a static 'BufferSize' property to provide the number of elements in the caller-allocated buffer.</value>
</data>
<data name="CallerAllocConstructorMustHaveBufferSizeMessage" xml:space="preserve">
<data name="CallerAllocFromManagedMustHaveBufferSizeMessage" xml:space="preserve">
<value>The marshaller type '{0}' must have a static read-only 'int' 'BufferSize' property to specify the size of the caller-allocated buffer because it has a FromManaged method that takes a caller-allocated 'Span&lt;{1}&gt;'</value>
</data>
<data name="StatelessLinearCollectionCallerAllocConstructorMustHaveBufferSizeDescription" xml:space="preserve">
<data name="StatelessLinearCollectionCallerAllocFromManagedMustHaveBufferSizeDescription" xml:space="preserve">
<value>When the 'Managed to Unmanaged with Caller-Allocated Buffer' shape is used by providing an 'AllocateContainerForUnmanagedElements' method that takes a 'Span&lt;T&gt;' on the marshaller type, the type must provide a static 'BufferSize' property to provide the number of elements in the caller-allocated buffer.</value>
</data>
<data name="StatelessLinearCollectionCallerAllocConstructorMustHaveBufferSizeMessage" xml:space="preserve">
<data name="StatelessLinearCollectionCallerAllocFromManagedMustHaveBufferSizeMessage" xml:space="preserve">
<value>The marshaller type '{0}' must have a static read-only 'int' 'BufferSize' property to specify the size of the caller-allocated buffer because it has an 'AllocateContainerForUnmanagedElements' method that takes a caller-allocated 'Span&lt;{1}&gt;'</value>
</data>
<data name="CannotForwardToDllImportDescription" xml:space="preserve">
Expand Down Expand Up @@ -375,7 +375,7 @@
<value>Overloading the 'FromUnmanaged' method is unuspported as some shapes are unable to distinguish between overloads.</value>
</data>
<data name="FromUnmanagedOverloadsNotSupportedMessage" xml:space="preserve">
<value>Overloading the 'FromUnmanaged' method is not supported in custom marshallers</value>
<value>The type '{0}' overloads the 'FromUnmanaged' method, which is not supported in custom marshallers</value>
</data>
<data name="ToUnmanagedFromManagedTypesMustMatchDescription" xml:space="preserve">
<value>The return type of 'ConvertToUnmanaged' and the parameter type of 'ConvertToManaged' must be the same.</value>
Expand Down Expand Up @@ -443,6 +443,12 @@
<data name="ElementTypesOfReturnTypesMustMatchMessage" xml:space="preserve">
<value>The element type of the span returned by '{0}' must be the same type as the element type of the span returned by '{1}'.</value>
</data>
<data name="ElementMarshallerCannotBeStatefulDescription" xml:space="preserve">
<value>A marshaller for an element scenario cannot be stateful.</value>
</data>
<data name="ElementMarshallerCannotBeStatefulMessage" xml:space="preserve">
<value>The specified marshaller type '{0}' is a stateful marshaller, but stateful marshallers are not allowed in the provided marshal mode '{1}'</value>
</data>
<data name="RequiresAllowUnsafeBlocksDescription" xml:space="preserve">
<value>LibraryImportAttribute requires unsafe code. Project must be updated with '&lt;AllowUnsafeBlocks&gt;true&lt;/AllowUnsafeBlocks&gt;'.</value>
</data>
Expand All @@ -452,6 +458,36 @@
<data name="RequiresAllowUnsafeBlocksTitle" xml:space="preserve">
<value>LibraryImportAttribute requires unsafe code.</value>
</data>
<data name="StatefulMarshallerRequiresFromManagedDescription" xml:space="preserve">
<value>A stateful marshaller that supports marshalling from managed to unmanaged must provide a 'FromManaged' instance method that takes the managed value as a parameter and returns 'void'.</value>
</data>
<data name="StatefulMarshallerRequiresFromManagedMessage" xml:space="preserve">
<value>The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a one-parameter instance method named 'FromManaged' that takes a '{2}' as a parameter and returns 'void'</value>
</data>
<data name="StatefulMarshallerRequiresToUnmanagedDescription" xml:space="preserve">
<value>A stateful marshaller that supports marshalling from managed to unmanaged must provide a 'ToUnmanaged' instance method that takes no parameters and returns the 'unmanaged' type.</value>
</data>
<data name="StatefulMarshallerRequiresToUnmanagedMessage" xml:space="preserve">
<value>The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a zero-parameter instance method named 'ToUnmanaged' that returns the 'unmanaged' type for the marshaller</value>
</data>
<data name="StatefulMarshallerRequiresFromUnmanagedDescription" xml:space="preserve">
<value>A stateful marshaller that supports marshalling from unmanaged to managed must provide a 'FromUnmanaged' instance method that takes the unmanaged value as a parameter and returns 'void'.</value>
</data>
<data name="StatefulMarshallerRequiresFromUnmanagedMessage" xml:space="preserve">
<value>The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a one-parameter instance method named 'FromUnmanaged' that takes the 'unmanaged' value as a parameter and returns 'void'</value>
</data>
<data name="StatefulMarshallerRequiresToManagedDescription" xml:space="preserve">
<value>A stateful marshaller that supports marshalling from unmanaged to managed must provide a 'ToManaged' instance method that takes no parameters and returns the managed type.</value>
</data>
<data name="StatefulMarshallerRequiresToManagedMessage" xml:space="preserve">
<value>The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a zero-parameter instance method named 'ToManaged' that returns '{2}'</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>
<data name="StatefulMarshallerRequiresFreeMessage" xml:space="preserve">
<value>The type '{0}' is a stateful marshaller and does not have a zero-parameter void-returning instance method named 'Free'</value>
</data>
<data name="ConvertToLibraryImportAddUnsafe" xml:space="preserve">
<value>Convert to 'LibraryImport' and enable unsafe code</value>
</data>
Expand All @@ -461,4 +497,4 @@
<data name="ConvertToLibraryImportWithSuffixAddUnsafe" xml:space="preserve">
<value>Convert to 'LibraryImport' with '{0}' suffix and enable unsafe code</value>
</data>
</root>
</root>
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
<target state="translated">Přidat chybějící vlastní typu zařazovacích členů</target>
<note />
</trans-unit>
<trans-unit id="CallerAllocConstructorMustHaveBufferSizeDescription">
<trans-unit id="CallerAllocFromManagedMustHaveBufferSizeDescription">
<source>When the 'Managed to Unmanaged with Caller-Allocated Buffer' shape is used by providing a 'FromManaged' method that takes a 'Span&lt;T&gt;' on the marshaller type, the type must provide a static 'BufferSize' property to provide the number of elements in the caller-allocated buffer.</source>
<target state="translated">Pokud se obrazec „Ze spravovaných na nespravované s vyrovnávací pamětí přidělenou volajícímu“ používá metodou FromManaged, která přebírá Span&lt;T&gt; u zařazovacího typu, musí typ poskytovat statickou vlastnost BufferSize, která určuje počet elementů ve vyrovnávací paměti přidělené volajícímu.</target>
<note />
</trans-unit>
<trans-unit id="CallerAllocConstructorMustHaveBufferSizeMessage">
<trans-unit id="CallerAllocFromManagedMustHaveBufferSizeMessage">
<source>The marshaller type '{0}' must have a static read-only 'int' 'BufferSize' property to specify the size of the caller-allocated buffer because it has a FromManaged method that takes a caller-allocated 'Span&lt;{1}&gt;'</source>
<target state="translated">Zařazovací typ {0} musí obsahovat statickou celočíselnou vlastnost BufferSize určenou jen pro čtení, která určuje velikost vyrovnávací paměti přidělené volajícímu, protože obsahuje metodu FromManaged, která přebírá Span&lt;{1}&gt; přidělený volajícímu.</target>
<note />
Expand Down Expand Up @@ -117,6 +117,16 @@
<target state="translated">Zařazovací typ nemá požadovaný tvar</target>
<note />
</trans-unit>
<trans-unit id="ElementMarshallerCannotBeStatefulDescription">
<source>A marshaller for an element scenario cannot be stateful.</source>
<target state="new">A marshaller for an element scenario cannot be stateful.</target>
<note />
</trans-unit>
<trans-unit id="ElementMarshallerCannotBeStatefulMessage">
<source>The specified marshaller type '{0}' is a stateful marshaller, but stateful marshallers are not allowed in the provided marshal mode '{1}'</source>
<target state="new">The specified marshaller type '{0}' is a stateful marshaller, but stateful marshallers are not allowed in the provided marshal mode '{1}'</target>
<note />
</trans-unit>
<trans-unit id="ElementTypesOfReturnTypesMustMatchDescription">
<source>The element type of the span returned by the first method must be the same type as the element type of the span returned by the second method.</source>
<target state="new">The element type of the span returned by the first method must be the same type as the element type of the span returned by the second method.</target>
Expand Down Expand Up @@ -163,8 +173,8 @@
<note />
</trans-unit>
<trans-unit id="FromUnmanagedOverloadsNotSupportedMessage">
<source>Overloading the 'FromUnmanaged' method is not supported in custom marshallers</source>
<target state="translated">Přetížení metody FromUnmanaged není u vlastního zařazování podporováno.</target>
<source>The type '{0}' overloads the 'FromUnmanaged' method, which is not supported in custom marshallers</source>
<target state="new">The type '{0}' overloads the 'FromUnmanaged' method, which is not supported in custom marshallers</target>
<note />
</trans-unit>
<trans-unit id="GetPinnableReferenceReturnTypeBlittableDescription">
Expand Down Expand Up @@ -387,12 +397,62 @@
<target state="new">The return type of '{0}' must be the same type as the return type of '{1}'</target>
<note />
</trans-unit>
<trans-unit id="StatelessLinearCollectionCallerAllocConstructorMustHaveBufferSizeDescription">
<trans-unit id="StatefulMarshallerRequiresFreeDescription">
<source>A stateful marshaller must have a zero-parameter void-returning instance method named 'Free'.</source>
<target state="new">A stateful marshaller must have a zero-parameter void-returning instance method named 'Free'.</target>
<note />
</trans-unit>
<trans-unit id="StatefulMarshallerRequiresFreeMessage">
<source>The type '{0}' is a stateful marshaller and does not have a zero-parameter void-returning instance method named 'Free'</source>
<target state="new">The type '{0}' is a stateful marshaller and does not have a zero-parameter void-returning instance method named 'Free'</target>
<note />
</trans-unit>
<trans-unit id="StatefulMarshallerRequiresFromManagedDescription">
<source>A stateful marshaller that supports marshalling from managed to unmanaged must provide a 'FromManaged' instance method that takes the managed value as a parameter and returns 'void'.</source>
<target state="new">A stateful marshaller that supports marshalling from managed to unmanaged must provide a 'FromManaged' instance method that takes the managed value as a parameter and returns 'void'.</target>
<note />
</trans-unit>
<trans-unit id="StatefulMarshallerRequiresFromManagedMessage">
<source>The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a one-parameter instance method named 'FromManaged' that takes a '{2}' as a parameter and returns 'void'</source>
<target state="new">The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a one-parameter instance method named 'FromManaged' that takes a '{2}' as a parameter and returns 'void'</target>
<note />
</trans-unit>
<trans-unit id="StatefulMarshallerRequiresFromUnmanagedDescription">
<source>A stateful marshaller that supports marshalling from unmanaged to managed must provide a 'FromUnmanaged' instance method that takes the unmanaged value as a parameter and returns 'void'.</source>
<target state="new">A stateful marshaller that supports marshalling from unmanaged to managed must provide a 'FromUnmanaged' instance method that takes the unmanaged value as a parameter and returns 'void'.</target>
<note />
</trans-unit>
<trans-unit id="StatefulMarshallerRequiresFromUnmanagedMessage">
<source>The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a one-parameter instance method named 'FromUnmanaged' that takes the 'unmanaged' value as a parameter and returns 'void'</source>
<target state="new">The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a one-parameter instance method named 'FromUnmanaged' that takes the 'unmanaged' value as a parameter and returns 'void'</target>
<note />
</trans-unit>
<trans-unit id="StatefulMarshallerRequiresToManagedDescription">
<source>A stateful marshaller that supports marshalling from unmanaged to managed must provide a 'ToManaged' instance method that takes no parameters and returns the managed type.</source>
<target state="new">A stateful marshaller that supports marshalling from unmanaged to managed must provide a 'ToManaged' instance method that takes no parameters and returns the managed type.</target>
<note />
</trans-unit>
<trans-unit id="StatefulMarshallerRequiresToManagedMessage">
<source>The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a zero-parameter instance method named 'ToManaged' that returns '{2}'</source>
<target state="new">The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a zero-parameter instance method named 'ToManaged' that returns '{2}'</target>
<note />
</trans-unit>
<trans-unit id="StatefulMarshallerRequiresToUnmanagedDescription">
<source>A stateful marshaller that supports marshalling from managed to unmanaged must provide a 'ToUnmanaged' instance method that takes no parameters and returns the 'unmanaged' type.</source>
<target state="new">A stateful marshaller that supports marshalling from managed to unmanaged must provide a 'ToUnmanaged' instance method that takes no parameters and returns the 'unmanaged' type.</target>
<note />
</trans-unit>
<trans-unit id="StatefulMarshallerRequiresToUnmanagedMessage">
<source>The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a zero-parameter instance method named 'ToUnmanaged' that returns the 'unmanaged' type for the marshaller</source>
<target state="new">The type '{0}' specifies that it supports the '{1}' marshal mode for '{2}' but it does not provide a zero-parameter instance method named 'ToUnmanaged' that returns the 'unmanaged' type for the marshaller</target>
<note />
</trans-unit>
<trans-unit id="StatelessLinearCollectionCallerAllocFromManagedMustHaveBufferSizeDescription">
<source>When the 'Managed to Unmanaged with Caller-Allocated Buffer' shape is used by providing an 'AllocateContainerForUnmanagedElements' method that takes a 'Span&lt;T&gt;' on the marshaller type, the type must provide a static 'BufferSize' property to provide the number of elements in the caller-allocated buffer.</source>
<target state="new">When the 'Managed to Unmanaged with Caller-Allocated Buffer' shape is used by providing an 'AllocateContainerForUnmanagedElements' method that takes a 'Span&lt;T&gt;' on the marshaller type, the type must provide a static 'BufferSize' property to provide the number of elements in the caller-allocated buffer.</target>
<note />
</trans-unit>
<trans-unit id="StatelessLinearCollectionCallerAllocConstructorMustHaveBufferSizeMessage">
<trans-unit id="StatelessLinearCollectionCallerAllocFromManagedMustHaveBufferSizeMessage">
<source>The marshaller type '{0}' must have a static read-only 'int' 'BufferSize' property to specify the size of the caller-allocated buffer because it has an 'AllocateContainerForUnmanagedElements' method that takes a caller-allocated 'Span&lt;{1}&gt;'</source>
<target state="new">The marshaller type '{0}' must have a static read-only 'int' 'BufferSize' property to specify the size of the caller-allocated buffer because it has an 'AllocateContainerForUnmanagedElements' method that takes a caller-allocated 'Span&lt;{1}&gt;'</target>
<note />
Expand Down
Loading

0 comments on commit a01aea9

Please sign in to comment.