Skip to content
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

Do not say the wrong default behavior for blittable arrays in ComInterfaceGenerator warning #88212

Merged
merged 33 commits into from
Jul 13, 2023
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
dc6356f
Fully qualify return type on UnreachableException methods
jtschuster Jun 15, 2023
0cc937e
Merge branch 'main' of https://github.com/dotnet/runtime
jtschuster Jun 16, 2023
a16a7d6
Merge branch 'main' of https://github.com/dotnet/runtime
jtschuster Jun 19, 2023
cca57d3
Merge branch 'main' of https://github.com/dotnet/runtime
jtschuster Jun 28, 2023
d56e81c
Merge branch 'main' of https://github.com/dotnet/runtime into InWarni…
jtschuster Jun 29, 2023
3ac3f6f
Say correct default for blittable arrays in warning
jtschuster Jun 29, 2023
e901baa
wip - SupportsByValueKind returns diag now
jtschuster Jul 6, 2023
2fd1d44
Use one resources file for all generators and tests, change byvalue attr
jtschuster Jul 6, 2023
e95fd73
Fix changes to SR names
jtschuster Jul 6, 2023
b7f4d21
[In] is allowed but not necessary
jtschuster Jul 6, 2023
2f135c2
wip
jtschuster Jul 7, 2023
5839779
wip about to merge main
jtschuster Jul 10, 2023
5b194d9
Merge branch 'main' of https://github.com/dotnet/runtime into InWarni…
jtschuster Jul 10, 2023
7d2ac74
Test cases done, filed / prepped issues for problems I hit
jtschuster Jul 10, 2023
797617a
Merge branch 'main' of https://github.com/dotnet/runtime into InWarni…
jtschuster Jul 10, 2023
a698ae2
undo unnecessary changes
jtschuster Jul 10, 2023
0a84827
Update src/libraries/System.Runtime.InteropServices/gen/Microsoft.Int…
jtschuster Jul 11, 2023
c48213e
Don't generate invalid UnmanagedCallersOnly wrappers. Instead, just s…
jkoritzinsky Jul 11, 2023
d324406
Only filter on the unmanaged to managed stub diagnostics.
jkoritzinsky Jul 11, 2023
d3f00a8
Only skip on error diagnostics (we don't want to skip generation beca…
jkoritzinsky Jul 11, 2023
b4659f1
PR Feedback
jtschuster Jul 11, 2023
53f5249
Merge remote-tracking branch 'jkoritzinsky/no-invalid-uco' into InWar…
jtschuster Jul 11, 2023
91c5b0d
PR Feedback
jtschuster Jul 11, 2023
8262e7d
Update src/libraries/System.Runtime.InteropServices/gen/Microsoft.Int…
jtschuster Jul 11, 2023
64725ae
Update src/libraries/System.Runtime.InteropServices/gen/Microsoft.Int…
jtschuster Jul 11, 2023
789a023
Update src/libraries/System.Runtime.InteropServices/gen/Microsoft.Int…
jtschuster Jul 11, 2023
acd847e
Update src/libraries/System.Runtime.InteropServices/gen/ComInterfaceG…
jtschuster Jul 11, 2023
2877315
Update src/libraries/System.Runtime.InteropServices/gen/Microsoft.Int…
jtschuster Jul 11, 2023
6536dcb
Update src/libraries/System.Runtime.InteropServices/gen/Microsoft.Int…
jtschuster Jul 11, 2023
7dfed5e
Update src/libraries/System.Runtime.InteropServices/gen/Microsoft.Int…
jtschuster Jul 11, 2023
41c11ea
Merge ref and value type default by value
jtschuster Jul 11, 2023
3ca63bc
Add issue for commented test cases
jtschuster Jul 11, 2023
f1f510c
Fix JS generator build
jtschuster Jul 12, 2023
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
Expand Up @@ -44,6 +44,13 @@ private static ResolvedGenerator ValidateByValueMarshalKind(TypePositionInfo inf
}
else if (info.ByValueContentsMarshalKind == ByValueContentsMarshalKind.In)
{
if (info.ManagedType is SzArrayType && generator.Generator is StaticPinnableManagedValueMarshaller)
{
return ResolvedGenerator.ResolvedWithDiagnostics(s_forwarder, generator.Diagnostics.Add(new GeneratorDiagnostic.NotSupported(info, context)
{
NotSupportedDetails = SR.InAttributeNotSupportedWithoutOutBlittableArray
}));
}
jtschuster marked this conversation as resolved.
Show resolved Hide resolved
return ResolvedGenerator.ResolvedWithDiagnostics(s_forwarder, generator.Diagnostics.Add(new GeneratorDiagnostic.NotSupported(info, context)
{
NotSupportedDetails = SR.InAttributeNotSupportedWithoutOut
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,4 +195,7 @@
<data name="InOutAttributes" xml:space="preserve">
<value>[In] and [Out] attributes</value>
</data>
<data name="InAttributeNotSupportedWithoutOutBlittableArray" xml:space="preserve">
<value>The '[In]' attribute is not supported unless the '[Out]' attribute is also used. Blittable arrays cannot be marshalled as '[In]' only.</value>
</data>
</root>
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@
<target state="translated">Atribut „[In]“ se nepodporuje, pokud není zároveň použit i atribut „[Out]“. Chování atributu „[In]“ bez atributu „[Out]“ je stejné, jako výchozí chování.</target>
<note />
</trans-unit>
<trans-unit id="InAttributeNotSupportedWithoutOutBlittableArray">
<source>The '[In]' attribute is not supported unless the '[Out]' attribute is also used. Blittable arrays cannot be marshalled as '[In]' only.</source>
<target state="new">The '[In]' attribute is not supported unless the '[Out]' attribute is also used. Blittable arrays cannot be marshalled as '[In]' only.</target>
<note />
</trans-unit>
<trans-unit id="InOutAttributeByRefNotSupported">
<source>The '[In]' and '[Out]' attributes are unsupported on parameters passed by reference. Use the 'in', 'ref', or 'out' keywords instead.</source>
<target state="translated">Atributy „[In]“ a „[Out]“ se nepodporují u parametrů předaných odkazem. Použijte místo nich klíčová slova „in“, „ref“ nebo „out“.</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@
<target state="translated">Das [In]-Attribut wird nur unterstützt, wenn auch das [Out]-Attribut verwendet wird. Das Verhalten des [In]-Attributs ohne das [Out]-Attribut entspricht dem Standardverhalten.</target>
<note />
</trans-unit>
<trans-unit id="InAttributeNotSupportedWithoutOutBlittableArray">
<source>The '[In]' attribute is not supported unless the '[Out]' attribute is also used. Blittable arrays cannot be marshalled as '[In]' only.</source>
<target state="new">The '[In]' attribute is not supported unless the '[Out]' attribute is also used. Blittable arrays cannot be marshalled as '[In]' only.</target>
<note />
</trans-unit>
<trans-unit id="InOutAttributeByRefNotSupported">
<source>The '[In]' and '[Out]' attributes are unsupported on parameters passed by reference. Use the 'in', 'ref', or 'out' keywords instead.</source>
<target state="translated">Die Attribute \"[In]\" und \"[Out]\" werden für Parameter, die als Verweis übergeben werden, nicht unterstützt. Verwenden Sie stattdessen die Schlüsselwörter \"in\", \"ref\" oder \"out\".</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@
<target state="translated">No se admite el atributo “[In]” a menos que también se use el atributo “[Out]”. El comportamiento del atributo “[In]” sin el atributo “[Out]” es el mismo que el predeterminado.</target>
<note />
</trans-unit>
<trans-unit id="InAttributeNotSupportedWithoutOutBlittableArray">
<source>The '[In]' attribute is not supported unless the '[Out]' attribute is also used. Blittable arrays cannot be marshalled as '[In]' only.</source>
<target state="new">The '[In]' attribute is not supported unless the '[Out]' attribute is also used. Blittable arrays cannot be marshalled as '[In]' only.</target>
<note />
</trans-unit>
<trans-unit id="InOutAttributeByRefNotSupported">
<source>The '[In]' and '[Out]' attributes are unsupported on parameters passed by reference. Use the 'in', 'ref', or 'out' keywords instead.</source>
<target state="translated">Los atributos “[In]” y “[Out]” no se admiten en los parámetros pasados por referencia. Use las palabras clave “in”, “ref” o “out” en su lugar.</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@
<target state="translated">L’attribut « [In] » n’est pas pris en charge, sauf si l’attribut « [Out] » est également utilisé. Le comportement de l’attribut « [In] »sans l’attribut « [Out] » est identique au comportement par défaut.</target>
<note />
</trans-unit>
<trans-unit id="InAttributeNotSupportedWithoutOutBlittableArray">
<source>The '[In]' attribute is not supported unless the '[Out]' attribute is also used. Blittable arrays cannot be marshalled as '[In]' only.</source>
<target state="new">The '[In]' attribute is not supported unless the '[Out]' attribute is also used. Blittable arrays cannot be marshalled as '[In]' only.</target>
<note />
</trans-unit>
<trans-unit id="InOutAttributeByRefNotSupported">
<source>The '[In]' and '[Out]' attributes are unsupported on parameters passed by reference. Use the 'in', 'ref', or 'out' keywords instead.</source>
<target state="translated">Les attributs « [In] » et « [Out] » ne sont pas pris en charge sur les paramètres passés par référence. Utilisez les mots clés « in », « ref » ou 'out' à la place.</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@
<target state="translated">L'attributo '[In]' non è supportato a meno che non venga usato anche l'attributo '[Out]'. Il comportamento dell'attributo '[In]' senza l'attributo '[Out]' è uguale a quello predefinito.</target>
<note />
</trans-unit>
<trans-unit id="InAttributeNotSupportedWithoutOutBlittableArray">
<source>The '[In]' attribute is not supported unless the '[Out]' attribute is also used. Blittable arrays cannot be marshalled as '[In]' only.</source>
<target state="new">The '[In]' attribute is not supported unless the '[Out]' attribute is also used. Blittable arrays cannot be marshalled as '[In]' only.</target>
<note />
</trans-unit>
<trans-unit id="InOutAttributeByRefNotSupported">
<source>The '[In]' and '[Out]' attributes are unsupported on parameters passed by reference. Use the 'in', 'ref', or 'out' keywords instead.</source>
<target state="translated">Gli attributi '[In]' e '[Out]' non sono supportati nei parametri passati per riferimento. Usare le parole chiave 'in', 'ref' o 'out'.</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@
<target state="translated">'[In]' 属性は、'[Out]' 属性も使用しない限りサポートされません。'[Out]' 属性なしでの '[In]' 属性の動作は、既定の動作と同じです。</target>
<note />
</trans-unit>
<trans-unit id="InAttributeNotSupportedWithoutOutBlittableArray">
<source>The '[In]' attribute is not supported unless the '[Out]' attribute is also used. Blittable arrays cannot be marshalled as '[In]' only.</source>
<target state="new">The '[In]' attribute is not supported unless the '[Out]' attribute is also used. Blittable arrays cannot be marshalled as '[In]' only.</target>
<note />
</trans-unit>
<trans-unit id="InOutAttributeByRefNotSupported">
<source>The '[In]' and '[Out]' attributes are unsupported on parameters passed by reference. Use the 'in', 'ref', or 'out' keywords instead.</source>
<target state="translated">'[In]' 属性と '[Out]' 属性は、参照渡しされたパラメーターではサポートされていません。代わりに 'in'、'ref'、または 'out' キーワードを使用します。</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@
<target state="translated">'[In]' 특성은 '[Out]' 특성도 함께 사용되지 않는 한 지원되지 않습니다. '[Out]' 특성이 없는 '[In]' 특성의 동작은 기본 동작과 동일합니다.</target>
<note />
</trans-unit>
<trans-unit id="InAttributeNotSupportedWithoutOutBlittableArray">
<source>The '[In]' attribute is not supported unless the '[Out]' attribute is also used. Blittable arrays cannot be marshalled as '[In]' only.</source>
<target state="new">The '[In]' attribute is not supported unless the '[Out]' attribute is also used. Blittable arrays cannot be marshalled as '[In]' only.</target>
<note />
</trans-unit>
<trans-unit id="InOutAttributeByRefNotSupported">
<source>The '[In]' and '[Out]' attributes are unsupported on parameters passed by reference. Use the 'in', 'ref', or 'out' keywords instead.</source>
<target state="translated">'[In]' 및 '[Out]' 특성은 참조로 전달된 매개 변수에서 지원되지 않습니다. 대신 'in', 'ref' 또는 'out' 키워드를 사용하세요.</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@
<target state="translated">Atrybut „[In]” nie jest obsługiwany, chyba że używany jest również atrybut „[Out]”. Zachowanie atrybutu „[In]” bez atrybutu „[Out]” jest takie samo jak zachowanie domyślne.</target>
<note />
</trans-unit>
<trans-unit id="InAttributeNotSupportedWithoutOutBlittableArray">
<source>The '[In]' attribute is not supported unless the '[Out]' attribute is also used. Blittable arrays cannot be marshalled as '[In]' only.</source>
<target state="new">The '[In]' attribute is not supported unless the '[Out]' attribute is also used. Blittable arrays cannot be marshalled as '[In]' only.</target>
<note />
</trans-unit>
<trans-unit id="InOutAttributeByRefNotSupported">
<source>The '[In]' and '[Out]' attributes are unsupported on parameters passed by reference. Use the 'in', 'ref', or 'out' keywords instead.</source>
<target state="translated">Atrybuty „[In]” i „[Out]” nie są obsługiwane w parametrach przekazywanych przez odwołanie. Zamiast tego użyj słów kluczowych „in”, „ref” lub „out”.</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@
<target state="translated">O atributo '[In]' não tem suporte, a menos que o '[Out]' também seja usado. O comportamento do atributo '[In]' sem o atributo '[Out]' é o mesmo que o comportamento padrão.</target>
<note />
</trans-unit>
<trans-unit id="InAttributeNotSupportedWithoutOutBlittableArray">
<source>The '[In]' attribute is not supported unless the '[Out]' attribute is also used. Blittable arrays cannot be marshalled as '[In]' only.</source>
<target state="new">The '[In]' attribute is not supported unless the '[Out]' attribute is also used. Blittable arrays cannot be marshalled as '[In]' only.</target>
<note />
</trans-unit>
<trans-unit id="InOutAttributeByRefNotSupported">
<source>The '[In]' and '[Out]' attributes are unsupported on parameters passed by reference. Use the 'in', 'ref', or 'out' keywords instead.</source>
<target state="translated">Os atributos '[In]' e '[Out]' não têm suporte em parâmetros passados por referência. Use as palavras-chave 'in', 'ref' ou 'out'.</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@
<target state="translated">Атрибут \"[In]\" не поддерживается, если атрибут \"[Out]' не используется. Поведение атрибута \"[In]\" без \"[Out]\" совпадает с поведением по умолчанию.</target>
<note />
</trans-unit>
<trans-unit id="InAttributeNotSupportedWithoutOutBlittableArray">
<source>The '[In]' attribute is not supported unless the '[Out]' attribute is also used. Blittable arrays cannot be marshalled as '[In]' only.</source>
<target state="new">The '[In]' attribute is not supported unless the '[Out]' attribute is also used. Blittable arrays cannot be marshalled as '[In]' only.</target>
<note />
</trans-unit>
<trans-unit id="InOutAttributeByRefNotSupported">
<source>The '[In]' and '[Out]' attributes are unsupported on parameters passed by reference. Use the 'in', 'ref', or 'out' keywords instead.</source>
<target state="translated">Атрибуты \"[In]\" и \"[Out]\" не поддерживаются для параметров, передаваемых по ссылке. Используйте вместо них ключевые слова \"in\", \"ref\" или \"out\".</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@
<target state="translated">'[Out]' özniteliği de kullanılmadığı sürece '[In]' özniteliği desteklenmiyor. '[Out]' özniteliği kullanılmadığında '[In]' özniteliğinin davranışı varsayılan davranışla aynı olacaktır.</target>
<note />
</trans-unit>
<trans-unit id="InAttributeNotSupportedWithoutOutBlittableArray">
<source>The '[In]' attribute is not supported unless the '[Out]' attribute is also used. Blittable arrays cannot be marshalled as '[In]' only.</source>
<target state="new">The '[In]' attribute is not supported unless the '[Out]' attribute is also used. Blittable arrays cannot be marshalled as '[In]' only.</target>
<note />
</trans-unit>
<trans-unit id="InOutAttributeByRefNotSupported">
<source>The '[In]' and '[Out]' attributes are unsupported on parameters passed by reference. Use the 'in', 'ref', or 'out' keywords instead.</source>
<target state="translated">'[In]' ve '[Out]' öznitelikleri başvuruya göre aktarılan parametrelerde desteklenmiyor. Bunun yerine 'in', 'ref' veya 'out' anahtar sözcüklerini kullanın.</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@
<target state="translated">不支持 “[In]” 属性,除非同时使用 “[Out]” 属性。没有 “[Out]” 属性的情况下,“[In]” 属性的行为与默认行为相同。</target>
<note />
</trans-unit>
<trans-unit id="InAttributeNotSupportedWithoutOutBlittableArray">
<source>The '[In]' attribute is not supported unless the '[Out]' attribute is also used. Blittable arrays cannot be marshalled as '[In]' only.</source>
<target state="new">The '[In]' attribute is not supported unless the '[Out]' attribute is also used. Blittable arrays cannot be marshalled as '[In]' only.</target>
<note />
</trans-unit>
<trans-unit id="InOutAttributeByRefNotSupported">
<source>The '[In]' and '[Out]' attributes are unsupported on parameters passed by reference. Use the 'in', 'ref', or 'out' keywords instead.</source>
<target state="translated">引用传递的参数不支持 “[In]” 和 “[Out]” 属性。请改用 “in”、“ref” 或 “out” 关键字。</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@
<target state="translated">除非一併使用'[Out]'屬性,否則不支援'[In]'屬性。沒有'[Out]'屬性的'[In]'屬性行為與默認行為相同。</target>
<note />
</trans-unit>
<trans-unit id="InAttributeNotSupportedWithoutOutBlittableArray">
<source>The '[In]' attribute is not supported unless the '[Out]' attribute is also used. Blittable arrays cannot be marshalled as '[In]' only.</source>
<target state="new">The '[In]' attribute is not supported unless the '[Out]' attribute is also used. Blittable arrays cannot be marshalled as '[In]' only.</target>
<note />
</trans-unit>
<trans-unit id="InOutAttributeByRefNotSupported">
<source>The '[In]' and '[Out]' attributes are unsupported on parameters passed by reference. Use the 'in', 'ref', or 'out' keywords instead.</source>
<target state="translated">參考所傳遞的參數不支援'[In]'和'[Out]'屬性。請改用 'in'、'ref' 或 'out' 關鍵詞。</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,17 @@ private string UnmanagedCallConv(Type[]? CallConvs = null)

public static readonly string DisableRuntimeMarshalling = "[assembly:System.Runtime.CompilerServices.DisableRuntimeMarshalling]";
public static readonly string UsingSystemRuntimeInteropServicesMarshalling = "using System.Runtime.InteropServices.Marshalling;";
public string InAttributedBlittableArray => $$"""
using System.Runtime.InteropServices;
using System.Runtime.InteropServices.Marshalling;

{{GeneratedComInterface()}}
partial interface INativeAPI
{
{{VirtualMethodIndex(0)}}
void Method([InAttribute] int[] parameter);
}
""";

public string SpecifiedMethodIndexNoExplicitParameters => $$"""
using System.Runtime.InteropServices;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@

using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Threading.Tasks;
Expand Down Expand Up @@ -834,6 +831,21 @@ public static IEnumerable<object[]> CodeSnippetsToCompile()
.WithLocation(1)
.WithArguments("ref return", "Basic.RefReadonlyReturn()"),
} };
yield return new object[] { ID(), CodeSnippets.ByValueParameterWithModifier<int[]>("In"), new[]
{
VerifyCS.Diagnostic(GeneratorDiagnostics.ParameterTypeNotSupportedWithDetails)
.WithLocation(0)
.WithArguments("The '[In]' attribute is not supported unless the '[Out]' attribute is also used. Blittable arrays cannot be marshalled as '[In]' only.", "p")
} };
}
public static IEnumerable<object[]> MyCodeSnippetsToCompile()
{
yield return new object[] { ID(), CodeSnippets.ByValueParameterWithModifier<int[]>("In"), new[]
{
VerifyCS.Diagnostic(GeneratorDiagnostics.ParameterTypeNotSupportedWithDetails)
.WithLocation(0)
.WithArguments("The '[In]' attribute is not supported unless the '[Out]' attribute is also used. Blittable arrays cannot be marshalled as '[In]' only.", "p")
} };
}

[Theory]
Expand Down Expand Up @@ -945,7 +957,7 @@ public async Task ValidateRequireAllowUnsafeBlocksDiagnostic()
class AllowUnsafeBlocksTest : VerifyCS.Test
{
public AllowUnsafeBlocksTest()
:base(referenceAncillaryInterop: false)
: base(referenceAncillaryInterop: false)
{
}

Expand Down