Skip to content

Commit 1d0589b

Browse files
authored
[LibraryImportGenerator] Update diagnostic titles to use localized strings (#68533)
1 parent 1ae1451 commit 1d0589b

18 files changed

+557
-85
lines changed

src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/NativeMarshallingAttribute.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ namespace System.Runtime.InteropServices
1616
public sealed class NativeMarshallingAttribute : Attribute
1717
{
1818
/// <summary>
19-
/// Create a <see cref="MarshalUsingAttribute" /> that provides a native marshalling type.
19+
/// Create a <see cref="NativeMarshallingAttribute" /> that provides a native marshalling type.
2020
/// </summary>
2121
/// <param name="nativeType">The marshaller type used to convert the attributed type from managed to native code. This type must be attributed with <see cref="CustomTypeMarshallerAttribute" /></param>
2222
public NativeMarshallingAttribute(Type nativeType)

src/libraries/System.Runtime.InteropServices/gen/LibraryImportGenerator/Analyzers/AnalyzerDiagnostics.cs

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,14 @@ public static class Ids
1818
// Migration from DllImport to LibraryImport
1919
public const string ConvertToLibraryImport = Prefix + "001";
2020

21-
// ManualTypeMarshalling
22-
public const string MarshallerTypeMustSpecifyManagedType = Prefix + "002";
23-
public const string CustomTypeMarshallerAttributeMustBeValid = Prefix + "003";
24-
public const string InvalidNativeType = Prefix + "004";
25-
public const string GetPinnableReferenceReturnTypeBlittable = Prefix + "005";
26-
public const string CustomMarshallerTypeMustHaveRequiredShape = Prefix + "006";
27-
public const string CustomMarshallerTypeMustSupportDirection = Prefix + "007";
28-
public const string ProvidedMethodsNotSpecifiedInShape = Prefix + "008";
29-
public const string MissingAllocatingMarshallingFallback = Prefix + "009";
30-
public const string CallerAllocConstructorMustHaveBufferSize = Prefix + "010";
31-
public const string InvalidSignaturesInMarshallerShape = Prefix + "011";
32-
public const string MarshallerGetPinnableReferenceRequiresTwoStageMarshalling = Prefix + "012";
21+
// CustomTypeMarshaller
22+
public const string InvalidCustomTypeMarshallerAttributeUsage = Prefix + "002";
23+
public const string InvalidNativeType = Prefix + "003";
24+
public const string CustomMarshallerTypeMustHaveRequiredShape = Prefix + "004";
25+
public const string ProvidedMethodsNotSpecifiedInFeatures = Prefix + "005";
26+
public const string MissingAllocatingMarshallingFallback = Prefix + "006";
27+
public const string CallerAllocConstructorMustHaveBufferSize = Prefix + "007";
28+
public const string InvalidSignaturesInMarshallerShape = Prefix + "008";
3329
}
3430

3531
internal static LocalizableResourceString GetResourceString(string resourceName)

src/libraries/System.Runtime.InteropServices/gen/LibraryImportGenerator/Analyzers/CustomTypeMarshallerAnalyzer.cs

Lines changed: 43 additions & 43 deletions
Large diffs are not rendered by default.

src/libraries/System.Runtime.InteropServices/gen/LibraryImportGenerator/Analyzers/CustomTypeMarshallerFixer.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ private static async Task AddMissingFeatures(FixAllContext fixAllContext, Docume
9999
ImmutableArray.Create(
100100
AnalyzerDiagnostics.Ids.CustomMarshallerTypeMustHaveRequiredShape,
101101
AnalyzerDiagnostics.Ids.MissingAllocatingMarshallingFallback,
102-
AnalyzerDiagnostics.Ids.ProvidedMethodsNotSpecifiedInShape);
102+
AnalyzerDiagnostics.Ids.ProvidedMethodsNotSpecifiedInFeatures);
103103

104104
public override async Task RegisterCodeFixesAsync(CodeFixContext context)
105105
{
@@ -158,7 +158,7 @@ private static (CustomTypeMarshallerFeatures featuresToAdd, List<Diagnostic> fix
158158
CustomTypeMarshallerFeatures featuresToAdd = CustomTypeMarshallerFeatures.None;
159159
foreach (var diagnostic in diagnostics)
160160
{
161-
if (diagnostic.Id == AnalyzerDiagnostics.Ids.ProvidedMethodsNotSpecifiedInShape)
161+
if (diagnostic.Id == AnalyzerDiagnostics.Ids.ProvidedMethodsNotSpecifiedInFeatures)
162162
{
163163
featuresToAddDiagnostics.Add(diagnostic);
164164
if (diagnostic.Properties.TryGetValue(CustomTypeMarshallerAnalyzer.MissingFeaturesKey, out string missingFeatures)

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

Lines changed: 48 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<root>
3-
<!--
4-
Microsoft ResX Schema
5-
3+
<!--
4+
Microsoft ResX Schema
5+
66
Version 2.0
7-
8-
The primary goals of this format is to allow a simple XML format
9-
that is mostly human readable. The generation and parsing of the
10-
various data types are done through the TypeConverter classes
7+
8+
The primary goals of this format is to allow a simple XML format
9+
that is mostly human readable. The generation and parsing of the
10+
various data types are done through the TypeConverter classes
1111
associated with the data types.
12-
12+
1313
Example:
14-
14+
1515
... ado.net/XML headers & schema ...
1616
<resheader name="resmimetype">text/microsoft-resx</resheader>
1717
<resheader name="version">2.0</resheader>
@@ -26,36 +26,36 @@
2626
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
2727
<comment>This is a comment</comment>
2828
</data>
29-
30-
There are any number of "resheader" rows that contain simple
29+
30+
There are any number of "resheader" rows that contain simple
3131
name/value pairs.
32-
33-
Each data row contains a name, and value. The row also contains a
34-
type or mimetype. Type corresponds to a .NET class that support
35-
text/value conversion through the TypeConverter architecture.
36-
Classes that don't support this are serialized and stored with the
32+
33+
Each data row contains a name, and value. The row also contains a
34+
type or mimetype. Type corresponds to a .NET class that support
35+
text/value conversion through the TypeConverter architecture.
36+
Classes that don't support this are serialized and stored with the
3737
mimetype set.
38-
39-
The mimetype is used for serialized objects, and tells the
40-
ResXResourceReader how to depersist the object. This is currently not
38+
39+
The mimetype is used for serialized objects, and tells the
40+
ResXResourceReader how to depersist the object. This is currently not
4141
extensible. For a given mimetype the value must be set accordingly:
42-
43-
Note - application/x-microsoft.net.object.binary.base64 is the format
44-
that the ResXResourceWriter will generate, however the reader can
42+
43+
Note - application/x-microsoft.net.object.binary.base64 is the format
44+
that the ResXResourceWriter will generate, however the reader can
4545
read any of the formats listed below.
46-
46+
4747
mimetype: application/x-microsoft.net.object.binary.base64
48-
value : The object must be serialized with
48+
value : The object must be serialized with
4949
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
5050
: and then encoded with base64 encoding.
51-
51+
5252
mimetype: application/x-microsoft.net.object.soap.base64
53-
value : The object must be serialized with
53+
value : The object must be serialized with
5454
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
5555
: and then encoded with base64 encoding.
5656
5757
mimetype: application/x-microsoft.net.object.bytearray.base64
58-
value : The object must be serialized into a byte array
58+
value : The object must be serialized into a byte array
5959
: using a System.ComponentModel.TypeConverter
6060
: and then encoded with base64 encoding.
6161
-->
@@ -437,4 +437,25 @@
437437
<data name="TwoStageMarshallingNativeTypesMustMatchMessage" xml:space="preserve">
438438
<value>The return type of 'ToNativeValue' and the parameter type of 'FromNativeValue' must be the same</value>
439439
</data>
440+
<data name="CallerAllocConstructorMustHaveBufferSizeTitle" xml:space="preserve">
441+
<value>'BufferSize' should be set on 'CustomTypeMarshallerAttribute'</value>
442+
</data>
443+
<data name="CustomMarshallerTypeMustHaveRequiredShapeTitle" xml:space="preserve">
444+
<value>Marshaller type does not have the required shape</value>
445+
</data>
446+
<data name="InvalidCustomTypeMarshallerAttributeUsageTitle" xml:space="preserve">
447+
<value>Invalid `CustomTypeMarshallerAttribute` usage</value>
448+
</data>
449+
<data name="InvalidNativeTypeTitle" xml:space="preserve">
450+
<value>Specified native type is invalid</value>
451+
</data>
452+
<data name="InvalidSignaturesInMarshallerShapeTitle" xml:space="preserve">
453+
<value>Marshaller type has incompatible method signatures</value>
454+
</data>
455+
<data name="MissingAllocatingMarshallingFallbackTitle" xml:space="preserve">
456+
<value>Marshaller type does not support allocating constructor</value>
457+
</data>
458+
<data name="ProvidedMethodsNotSpecifiedInFeaturesTitle" xml:space="preserve">
459+
<value>Marshaller type defines a well-known method without specifying support for the corresponding feature</value>
460+
</data>
440461
</root>

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

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@
2222
<target state="translated">Nativní typ {0} musí nastavit pole BufferSize u použitého atributu System.Runtime.InteropServices.CustomTypeMarshallerAttribute, aby se určila velikost vyrovnávací paměť přidělené volajícímu, protože má konstruktor přebírající „Span&lt;byte&gt;“ přidělený volajícímu.</target>
2323
<note />
2424
</trans-unit>
25+
<trans-unit id="CallerAllocConstructorMustHaveBufferSizeTitle">
26+
<source>'BufferSize' should be set on 'CustomTypeMarshallerAttribute'</source>
27+
<target state="new">'BufferSize' should be set on 'CustomTypeMarshallerAttribute'</target>
28+
<note />
29+
</trans-unit>
2530
<trans-unit id="CallerAllocMarshallingShouldSupportAllocatingMarshallingFallbackDescription">
2631
<source>A type that supports marshalling from managed to native using a caller-allocated buffer should also support marshalling from managed to native where using a caller-allocated buffer is impossible.</source>
2732
<target state="translated">Typ, který podporuje zařazování ze spravovaného na nativní prostřednictvím vyrovnávací paměť přidělené volajícím, by měl zároveň podporovat zařazování ze spravovaného na nativní v případech, kdy není vyrovnávací paměť přidělená volajícím možná.</target>
@@ -132,6 +137,11 @@
132137
<target state="translated">Převést na LibraryImport s příponou {0}</target>
133138
<note />
134139
</trans-unit>
140+
<trans-unit id="CustomMarshallerTypeMustHaveRequiredShapeTitle">
141+
<source>Marshaller type does not have the required shape</source>
142+
<target state="new">Marshaller type does not have the required shape</target>
143+
<note />
144+
</trans-unit>
135145
<trans-unit id="CustomMarshallerTypeMustSupportDirectionDescription">
136146
<source>A native must set the 'Direction' property on the 'CustomTypeMarshallerAttribute' to a value that sets at least one known flag value on the 'CustomTypeMarshallerDirection' enum</source>
137147
<target state="translated">Nativní musí nastavit vlastnost „Direction“ u atributu CustomTypeMarshallerAttribute na hodnotu, která nastavuje alespoň jednu hodnotu příznaku na výčtu CustomTypeMarshallerDirection</target>
@@ -227,11 +237,26 @@
227237
<target state="translated">Metoda {0} by měla mít vlastnost „static“, „partial“ a non-generic, když je označena atributem LibraryImportAttribute. Generování zdroje voláním P/Invoke bude metodu {0} ignorovat.</target>
228238
<note />
229239
</trans-unit>
240+
<trans-unit id="InvalidCustomTypeMarshallerAttributeUsageTitle">
241+
<source>Invalid `CustomTypeMarshallerAttribute` usage</source>
242+
<target state="new">Invalid `CustomTypeMarshallerAttribute` usage</target>
243+
<note />
244+
</trans-unit>
230245
<trans-unit id="InvalidLibraryImportAttributeUsageTitle">
231246
<source>Invalid 'LibraryImportAttribute' usage</source>
232247
<target state="translated">Neplatné použití LibraryImportAttribute</target>
233248
<note />
234249
</trans-unit>
250+
<trans-unit id="InvalidNativeTypeTitle">
251+
<source>Specified native type is invalid</source>
252+
<target state="new">Specified native type is invalid</target>
253+
<note />
254+
</trans-unit>
255+
<trans-unit id="InvalidSignaturesInMarshallerShapeTitle">
256+
<source>Marshaller type has incompatible method signatures</source>
257+
<target state="new">Marshaller type has incompatible method signatures</target>
258+
<note />
259+
</trans-unit>
235260
<trans-unit id="InvalidStringMarshallingConfigurationDescription">
236261
<source>The configuration of 'StringMarshalling' and 'StringMarshallingCustomType' is invalid.</source>
237262
<target state="translated">Konfigurace StringMarshalling a StringMarshallingCustomType je neplatná.</target>
@@ -352,6 +377,11 @@
352377
<target state="translated">Typ {0} neurčuje spravovaný typ v atributu System.Runtime.InteropServices.CustomTypeMarshallerAttribute použitém na typ</target>
353378
<note />
354379
</trans-unit>
380+
<trans-unit id="MissingAllocatingMarshallingFallbackTitle">
381+
<source>Marshaller type does not support allocating constructor</source>
382+
<target state="new">Marshaller type does not support allocating constructor</target>
383+
<note />
384+
</trans-unit>
355385
<trans-unit id="NativeGenericTypeMustBeClosedOrMatchArityDescription">
356386
<source>The native type '{0}' 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>
357387
<target state="translated">Nativní typ {0} musí být uzavřený obecný typ nebo musí mít stejný počet obecných parametrů jako spravovaný typ, aby mohl vygenerovaný kód použít konkrétní vytvoření instance.</target>
@@ -412,6 +442,11 @@
412442
<target state="translated">Typ zařazování {0} podporuje zařazování ve směru „Out“ s funkcí TwoStageMarshalling, ale neposkytuje instanční metodu FromNativeValue, která vrací „void“ a přebírá jeden parametr.</target>
413443
<note />
414444
</trans-unit>
445+
<trans-unit id="ProvidedMethodsNotSpecifiedInFeaturesTitle">
446+
<source>Marshaller type defines a well-known method without specifying support for the corresponding feature</source>
447+
<target state="new">Marshaller type defines a well-known method without specifying support for the corresponding feature</target>
448+
<note />
449+
</trans-unit>
415450
<trans-unit id="RefNativeValueUnsupportedDescription">
416451
<source>The 'Value' property must not be a 'ref' or 'readonly ref' property.</source>
417452
<target state="translated">Vlastnost Value nesmí být vlastnost typu „ref“ ani „readonly“.</target>

0 commit comments

Comments
 (0)