diff --git a/src/Compilers/CSharp/Portable/CSharpResources.resx b/src/Compilers/CSharp/Portable/CSharpResources.resx
index 84910f20b927e..4bae85a6ae515 100644
--- a/src/Compilers/CSharp/Portable/CSharpResources.resx
+++ b/src/Compilers/CSharp/Portable/CSharpResources.resx
@@ -7574,6 +7574,12 @@ To remove the warning, you can use /reference instead (set the Embed Interop Typ
The '&' operator should not be used on parameters or local variables in async methods.
+
+ Attribute parameter 'SizeConst' must be specified.
+
+
+ Attribute parameter 'SizeConst' must be specified.
+
'static' modifier must precede 'unsafe' modifier.
diff --git a/src/Compilers/CSharp/Portable/Errors/ErrorCode.cs b/src/Compilers/CSharp/Portable/Errors/ErrorCode.cs
index 762cd342bd694..37426545a5fac 100644
--- a/src/Compilers/CSharp/Portable/Errors/ErrorCode.cs
+++ b/src/Compilers/CSharp/Portable/Errors/ErrorCode.cs
@@ -2183,6 +2183,7 @@ internal enum ErrorCode
ERR_UnexpectedParameterList = 9122,
WRN_AddressOfInAsync = 9123,
WRN_CapturedPrimaryConstructorParameterInFieldInitializer = 9124,
+ WRN_ByValArraySizeConstRequired = 9125,
ERR_BadRefInUsingAlias = 9130,
ERR_BadUnsafeInUsingDirective = 9131,
diff --git a/src/Compilers/CSharp/Portable/Errors/ErrorFacts.cs b/src/Compilers/CSharp/Portable/Errors/ErrorFacts.cs
index 2faf048702d08..0b30dfc759144 100644
--- a/src/Compilers/CSharp/Portable/Errors/ErrorFacts.cs
+++ b/src/Compilers/CSharp/Portable/Errors/ErrorFacts.cs
@@ -209,6 +209,7 @@ internal static int GetWarningLevel(ErrorCode code)
switch (code)
{
case ErrorCode.WRN_AddressOfInAsync:
+ case ErrorCode.WRN_ByValArraySizeConstRequired:
// Warning level 8 is exclusively for warnings introduced in the compiler
// shipped with dotnet 8 (C# 12) and that can be reported for pre-existing code.
return 8;
@@ -2394,6 +2395,7 @@ internal static bool IsBuildOnlyDiagnostic(ErrorCode code)
case ErrorCode.WRN_TargetDifferentRefness:
case ErrorCode.ERR_OutAttrOnRefReadonlyParam:
case ErrorCode.WRN_RefReadonlyParameterDefaultValue:
+ case ErrorCode.WRN_ByValArraySizeConstRequired:
return false;
default:
// NOTE: All error codes must be explicitly handled in this switch statement
diff --git a/src/Compilers/CSharp/Portable/Errors/MessageProvider.cs b/src/Compilers/CSharp/Portable/Errors/MessageProvider.cs
index 887eb2aa5e307..51b5bf8f104cd 100644
--- a/src/Compilers/CSharp/Portable/Errors/MessageProvider.cs
+++ b/src/Compilers/CSharp/Portable/Errors/MessageProvider.cs
@@ -309,5 +309,7 @@ protected override void ReportAttributeParameterRequired(DiagnosticBag diagnosti
}
public override int ERR_BadAssemblyName => (int)ErrorCode.ERR_BadAssemblyName;
+
+ public override int? WRN_ByValArraySizeConstRequired => (int)ErrorCode.WRN_ByValArraySizeConstRequired;
}
}
diff --git a/src/Compilers/CSharp/Portable/Generated/ErrorFacts.Generated.cs b/src/Compilers/CSharp/Portable/Generated/ErrorFacts.Generated.cs
index a04c7696425a2..6da3c3d7f200b 100644
--- a/src/Compilers/CSharp/Portable/Generated/ErrorFacts.Generated.cs
+++ b/src/Compilers/CSharp/Portable/Generated/ErrorFacts.Generated.cs
@@ -316,6 +316,7 @@ public static bool IsWarning(ErrorCode code)
case ErrorCode.WRN_UnreadPrimaryConstructorParameter:
case ErrorCode.WRN_AddressOfInAsync:
case ErrorCode.WRN_CapturedPrimaryConstructorParameterInFieldInitializer:
+ case ErrorCode.WRN_ByValArraySizeConstRequired:
case ErrorCode.WRN_InterceptorSignatureMismatch:
case ErrorCode.WRN_NullabilityMismatchInReturnTypeOnInterceptor:
case ErrorCode.WRN_NullabilityMismatchInParameterTypeOnInterceptor:
diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.cs.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.cs.xlf
index 026eb46d6338c..42fa2552ea8a8 100644
--- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.cs.xlf
+++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.cs.xlf
@@ -2377,6 +2377,16 @@
The 'ref' modifier for an argument corresponding to 'in' parameter is equivalent to 'in'. Consider using 'in' instead.
+
+
+ Attribute parameter 'SizeConst' must be specified.
+
+
+
+
+ Attribute parameter 'SizeConst' must be specified.
+
+ Tato kombinace argumentů parametru {0} může vystavit proměnné, na které odkazuje parametr {1}, mimo obor jejich deklarace
diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.de.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.de.xlf
index a67617ea3a23e..c5a86b0a96fc6 100644
--- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.de.xlf
+++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.de.xlf
@@ -2377,6 +2377,16 @@
The 'ref' modifier for an argument corresponding to 'in' parameter is equivalent to 'in'. Consider using 'in' instead.
+
+
+ Attribute parameter 'SizeConst' must be specified.
+
+
+
+
+ Attribute parameter 'SizeConst' must be specified.
+
+ Diese Kombination aus Argumenten für "{0}" führt möglicherweise dazu, dass vom Parameter "{1}" referenzierte Variablen außerhalb ihres Deklarationsbereichs verfügbar gemacht werden.
diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.es.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.es.xlf
index 2054c6ecfd02c..fafb7050a28bd 100644
--- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.es.xlf
+++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.es.xlf
@@ -2377,6 +2377,16 @@
The 'ref' modifier for an argument corresponding to 'in' parameter is equivalent to 'in'. Consider using 'in' instead.
+
+
+ Attribute parameter 'SizeConst' must be specified.
+
+
+
+
+ Attribute parameter 'SizeConst' must be specified.
+
+ Esta combinación de argumentos para "{0}" puede exponer variables a las que el parámetro "{1}" hace referencia fuera de su ámbito de declaración
diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.fr.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.fr.xlf
index 43894215bec20..a895ffb4d017c 100644
--- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.fr.xlf
+++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.fr.xlf
@@ -2377,6 +2377,16 @@
The 'ref' modifier for an argument corresponding to 'in' parameter is equivalent to 'in'. Consider using 'in' instead.
+
+
+ Attribute parameter 'SizeConst' must be specified.
+
+
+
+
+ Attribute parameter 'SizeConst' must be specified.
+
+ Cette combinaison d'arguments pour '{0}' peut exposer les variables référencées par le paramètre '{1}' en dehors de la portée de leur déclaration
diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.it.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.it.xlf
index 2d471b652d7ce..be35af0d7e250 100644
--- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.it.xlf
+++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.it.xlf
@@ -2377,6 +2377,16 @@
The 'ref' modifier for an argument corresponding to 'in' parameter is equivalent to 'in'. Consider using 'in' instead.
+
+
+ Attribute parameter 'SizeConst' must be specified.
+
+
+
+
+ Attribute parameter 'SizeConst' must be specified.
+
+ Questa combinazione di argomenti per '{0}' può esporre variabili a cui fa riferimento il parametro '{1}' all'esterno del relativo ambito di dichiarazione
diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.ja.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.ja.xlf
index f3194b7843ce2..b4bf8c17f3851 100644
--- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.ja.xlf
+++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.ja.xlf
@@ -2377,6 +2377,16 @@
The 'ref' modifier for an argument corresponding to 'in' parameter is equivalent to 'in'. Consider using 'in' instead.
+
+
+ Attribute parameter 'SizeConst' must be specified.
+
+
+
+
+ Attribute parameter 'SizeConst' must be specified.
+
+ '{0}' に対するこの引数の組み合わせは、パラメーター '{1}' によって参照される変数が宣言のスコープ外に公開される可能性があります
diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.ko.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.ko.xlf
index de1ef080488f6..02384f72832f0 100644
--- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.ko.xlf
+++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.ko.xlf
@@ -2377,6 +2377,16 @@
The 'ref' modifier for an argument corresponding to 'in' parameter is equivalent to 'in'. Consider using 'in' instead.
+
+
+ Attribute parameter 'SizeConst' must be specified.
+
+
+
+
+ Attribute parameter 'SizeConst' must be specified.
+
+ '{0}'에 대한 이 인수 조합은 선언 범위 외부에 있는 '{1}' 매개 변수에서 참조하는 변수를 노출할 수 있습니다.
diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.pl.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.pl.xlf
index c5ce771ac6ffd..2d55a30b7a453 100644
--- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.pl.xlf
+++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.pl.xlf
@@ -2377,6 +2377,16 @@
The 'ref' modifier for an argument corresponding to 'in' parameter is equivalent to 'in'. Consider using 'in' instead.
+
+
+ Attribute parameter 'SizeConst' must be specified.
+
+
+
+
+ Attribute parameter 'SizeConst' must be specified.
+
+ Ta kombinacja argumentów „{0}” może uwidaczniać zmienne przywoływane przez parametr „{1}” poza zakresem deklaracji
diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.pt-BR.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.pt-BR.xlf
index 0c660e3afabf5..2e5a4495fbdbd 100644
--- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.pt-BR.xlf
+++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.pt-BR.xlf
@@ -2377,6 +2377,16 @@
The 'ref' modifier for an argument corresponding to 'in' parameter is equivalent to 'in'. Consider using 'in' instead.
+
+
+ Attribute parameter 'SizeConst' must be specified.
+
+
+
+
+ Attribute parameter 'SizeConst' must be specified.
+
+ Essa combinação de argumentos para '{0}' pode expor variáveis referenciadas pelo parâmetro '{1}' fora de seu escopo de declaração
diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.ru.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.ru.xlf
index c0892467d07eb..27a6cf7fcf82d 100644
--- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.ru.xlf
+++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.ru.xlf
@@ -2377,6 +2377,16 @@
The 'ref' modifier for an argument corresponding to 'in' parameter is equivalent to 'in'. Consider using 'in' instead.
+
+
+ Attribute parameter 'SizeConst' must be specified.
+
+
+
+
+ Attribute parameter 'SizeConst' must be specified.
+
+ Это сочетание аргументов для "{0}" может представить переменные, на которые ссылается параметр "{1}", за пределами их области объявления
diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.tr.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.tr.xlf
index 64dba5c612765..f2345e3073b2e 100644
--- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.tr.xlf
+++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.tr.xlf
@@ -2377,6 +2377,16 @@
The 'ref' modifier for an argument corresponding to 'in' parameter is equivalent to 'in'. Consider using 'in' instead.
+
+
+ Attribute parameter 'SizeConst' must be specified.
+
+
+
+
+ Attribute parameter 'SizeConst' must be specified.
+
+ '{0}' argümanlarının bu kombinasyonu, '{1}' parametresi tarafından başvurulan değişkenleri bildirim kapsamının dışında gösterebilir.
diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.zh-Hans.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.zh-Hans.xlf
index d7cb93e15b189..61f09e8fa8f14 100644
--- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.zh-Hans.xlf
+++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.zh-Hans.xlf
@@ -2377,6 +2377,16 @@
The 'ref' modifier for an argument corresponding to 'in' parameter is equivalent to 'in'. Consider using 'in' instead.
+
+
+ Attribute parameter 'SizeConst' must be specified.
+
+
+
+
+ Attribute parameter 'SizeConst' must be specified.
+
+ “{0}”的这种参数组合可能会在变量声明范围之外公开由参数“{1}”引用的变量
diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.zh-Hant.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.zh-Hant.xlf
index d592580b92122..06f71c5efc4e3 100644
--- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.zh-Hant.xlf
+++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.zh-Hant.xlf
@@ -2377,6 +2377,16 @@
The 'ref' modifier for an argument corresponding to 'in' parameter is equivalent to 'in'. Consider using 'in' instead.
+
+
+ Attribute parameter 'SizeConst' must be specified.
+
+
+
+
+ Attribute parameter 'SizeConst' must be specified.
+
+ 對 '{0}' 使用此引數組合,會在其宣告範圍外公開參數 '{1}' 所參考的變數
diff --git a/src/Compilers/CSharp/Test/Emit2/Attributes/AttributeTests_MarshalAs.cs b/src/Compilers/CSharp/Test/Emit2/Attributes/AttributeTests_MarshalAs.cs
index 376cdcb700292..ff16016296591 100644
--- a/src/Compilers/CSharp/Test/Emit2/Attributes/AttributeTests_MarshalAs.cs
+++ b/src/Compilers/CSharp/Test/Emit2/Attributes/AttributeTests_MarshalAs.cs
@@ -565,7 +565,6 @@ class X
public void NativeTypeFixedArray()
{
var source = @"
-using System;
using System.Runtime.InteropServices;
public class X
@@ -603,6 +602,20 @@ public class X
};
var verifier = CompileAndVerifyFieldMarshal(source, blobs);
+ verifier.VerifyDiagnostics(
+ // (6,6): warning CS9125: Attribute parameter 'SizeConst' must be specified.
+ // [MarshalAs(UnmanagedType.ByValArray)]
+ Diagnostic(ErrorCode.WRN_ByValArraySizeConstRequired, "MarshalAs(UnmanagedType.ByValArray)").WithLocation(6, 6),
+ // (9,6): warning CS9125: Attribute parameter 'SizeConst' must be specified.
+ // [MarshalAs(UnmanagedType.ByValArray, ArraySubType = UnmanagedType.ByValTStr, IidParameterIndex = -1, MarshalCookie = null, MarshalType = null, MarshalTypeRef = null,
+ Diagnostic(ErrorCode.WRN_ByValArraySizeConstRequired, @"MarshalAs(UnmanagedType.ByValArray, ArraySubType = UnmanagedType.ByValTStr, IidParameterIndex = -1, MarshalCookie = null, MarshalType = null, MarshalTypeRef = null,
+ SafeArrayUserDefinedSubType = null)").WithLocation(9, 6),
+ // (21,6): warning CS9125: Attribute parameter 'SizeConst' must be specified.
+ // [MarshalAs(UnmanagedType.ByValArray, ArraySubType = UnmanagedType.AsAny)]
+ Diagnostic(ErrorCode.WRN_ByValArraySizeConstRequired, "MarshalAs(UnmanagedType.ByValArray, ArraySubType = UnmanagedType.AsAny)").WithLocation(21, 6),
+ // (24,6): warning CS9125: Attribute parameter 'SizeConst' must be specified.
+ // [MarshalAs(UnmanagedType.ByValArray, ArraySubType = UnmanagedType.CustomMarshaler)]
+ Diagnostic(ErrorCode.WRN_ByValArraySizeConstRequired, "MarshalAs(UnmanagedType.ByValArray, ArraySubType = UnmanagedType.CustomMarshaler)").WithLocation(24, 6));
VerifyFieldMetadataDecoding(verifier, blobs);
}
@@ -656,9 +669,15 @@ public class X
// (8,170): error CS7045: Parameter not valid for the specified unmanaged type.
// [MarshalAs(UnmanagedType.ByValArray, ArraySubType = UnmanagedType.ByValTStr, SafeArraySubType = VarEnum.VT_BSTR, SafeArrayUserDefinedSubType = null, SizeConst = -1, SizeParamIndex = -1)]int ByValArray_e1;
Diagnostic(ErrorCode.ERR_ParameterNotValidForType, "SizeParamIndex = -1"),
+ // (9,6): warning CS9124: Attribute parameter 'SizeConst' must be specified.
+ // [MarshalAs(UnmanagedType.ByValArray, SizeParamIndex = short.MaxValue)] int ByValArray_e2;
+ Diagnostic(ErrorCode.WRN_ByValArraySizeConstRequired, "MarshalAs(UnmanagedType.ByValArray, SizeParamIndex = short.MaxValue)"),
// (9,42): error CS7045: Parameter not valid for the specified unmanaged type.
// [MarshalAs(UnmanagedType.ByValArray, SizeParamIndex = short.MaxValue)] int ByValArray_e2;
Diagnostic(ErrorCode.ERR_ParameterNotValidForType, "SizeParamIndex = short.MaxValue"),
+ // (10,6): warning CS9124: Attribute parameter 'SizeConst' must be specified.
+ // [MarshalAs(UnmanagedType.ByValArray, SafeArraySubType = VarEnum.VT_I2)] int ByValArray_e3;
+ Diagnostic(ErrorCode.WRN_ByValArraySizeConstRequired, "MarshalAs(UnmanagedType.ByValArray, SafeArraySubType = VarEnum.VT_I2)"),
// (10,42): error CS7045: Parameter not valid for the specified unmanaged type.
// [MarshalAs(UnmanagedType.ByValArray, SafeArraySubType = VarEnum.VT_I2)] int ByValArray_e3;
Diagnostic(ErrorCode.ERR_ParameterNotValidForType, "SafeArraySubType = VarEnum.VT_I2"),
@@ -667,6 +686,33 @@ public class X
Diagnostic(ErrorCode.ERR_InvalidNamedArgument, "SizeConst = 0x20000000").WithArguments("SizeConst"));
}
+ [Fact]
+ [WorkItem(68988, "https://github.com/dotnet/roslyn/issues/68988")]
+ public void NativeTypeFixedArray_SizeConstWarning_RespectsWarningLevel()
+ {
+ var source = @"
+using System.Runtime.InteropServices;
+
+public class X
+{
+ [MarshalAs(UnmanagedType.ByValArray)]
+ public int ByValArray0;
+}
+";
+ CreateCompilation(
+ source,
+ options: TestOptions.ReleaseDll.WithWarningLevel(7))
+ .VerifyDiagnostics();
+
+ CreateCompilation(
+ source,
+ options: TestOptions.ReleaseDll.WithWarningLevel(8))
+ .VerifyDiagnostics(
+ // (6,6): warning CS9125: Attribute parameter 'SizeConst' must be specified.
+ // [MarshalAs(UnmanagedType.ByValArray)]
+ Diagnostic(ErrorCode.WRN_ByValArraySizeConstRequired, "MarshalAs(UnmanagedType.ByValArray)").WithLocation(6, 6));
+ }
+
///
/// (SafeArraySubType, SafeArrayUserDefinedSubType), (ArraySubType, SizeConst, SizeParamIndex) not allowed,
/// (SafeArraySubType, SafeArrayUserDefinedSubType) not allowed together unless VT_DISPATCH, VT_UNKNOWN, VT_RECORD; others ignored.
diff --git a/src/Compilers/CSharp/Test/Syntax/Diagnostics/DiagnosticTest.cs b/src/Compilers/CSharp/Test/Syntax/Diagnostics/DiagnosticTest.cs
index 42c028ee87337..f27c9e061b6d2 100644
--- a/src/Compilers/CSharp/Test/Syntax/Diagnostics/DiagnosticTest.cs
+++ b/src/Compilers/CSharp/Test/Syntax/Diagnostics/DiagnosticTest.cs
@@ -458,6 +458,7 @@ public void WarningLevel_2()
Assert.Equal(7, ErrorFacts.GetWarningLevel(errorCode));
break;
case ErrorCode.WRN_AddressOfInAsync:
+ case ErrorCode.WRN_ByValArraySizeConstRequired:
// These are the warnings introduced with the warning "wave" shipped with dotnet 8 and C# 12.
Assert.Equal(8, ErrorFacts.GetWarningLevel(errorCode));
break;
diff --git a/src/Compilers/Core/Portable/Diagnostic/CommonMessageProvider.cs b/src/Compilers/Core/Portable/Diagnostic/CommonMessageProvider.cs
index 3b52ae4be55ac..afca96c5e1e44 100644
--- a/src/Compilers/Core/Portable/Diagnostic/CommonMessageProvider.cs
+++ b/src/Compilers/Core/Portable/Diagnostic/CommonMessageProvider.cs
@@ -328,5 +328,7 @@ public void ReportAttributeParameterRequired(BindingDiagnosticBag diagnostics, S
}
public abstract int ERR_BadAssemblyName { get; }
+
+ public abstract int? WRN_ByValArraySizeConstRequired { get; }
}
}
diff --git a/src/Compilers/Core/Portable/Symbols/Attributes/MarshalAsAttributeDecoder.cs b/src/Compilers/Core/Portable/Symbols/Attributes/MarshalAsAttributeDecoder.cs
index a688950774c1d..8613c4a0ddbdc 100644
--- a/src/Compilers/Core/Portable/Symbols/Attributes/MarshalAsAttributeDecoder.cs
+++ b/src/Compilers/Core/Portable/Symbols/Attributes/MarshalAsAttributeDecoder.cs
@@ -209,7 +209,7 @@ private static void DecodeMarshalAsArray(ref DecodeWellKnownAttributeArguments().GetOrCreateData();
diff --git a/src/Compilers/Test/Core/Mocks/TestMessageProvider.cs b/src/Compilers/Test/Core/Mocks/TestMessageProvider.cs
index 0cfc4e48dd9c2..68c2c5c6b9937 100644
--- a/src/Compilers/Test/Core/Mocks/TestMessageProvider.cs
+++ b/src/Compilers/Test/Core/Mocks/TestMessageProvider.cs
@@ -469,5 +469,7 @@ public override int ERR_InvalidDebugInfo
public override int WRN_DuplicateAnalyzerReference => throw new NotImplementedException();
public override int ERR_FunctionPointerTypesInAttributeNotSupported => throw new NotImplementedException();
+
+ public override int? WRN_ByValArraySizeConstRequired => throw new NotImplementedException();
}
}
diff --git a/src/Compilers/VisualBasic/Portable/Errors/MessageProvider.vb b/src/Compilers/VisualBasic/Portable/Errors/MessageProvider.vb
index 7919e4a630573..56e89b59d525e 100644
--- a/src/Compilers/VisualBasic/Portable/Errors/MessageProvider.vb
+++ b/src/Compilers/VisualBasic/Portable/Errors/MessageProvider.vb
@@ -622,6 +622,12 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
End Get
End Property
+ Public Overrides ReadOnly Property WRN_ByValArraySizeConstRequired As Integer?
+ Get
+ Return Nothing
+ End Get
+ End Property
+
End Class
End Namespace
diff --git a/src/Compilers/VisualBasic/Test/Emit/Attributes/AttributeTests_MarshalAs.vb b/src/Compilers/VisualBasic/Test/Emit/Attributes/AttributeTests_MarshalAs.vb
index 098701467ec61..a8ea1152b1a6e 100644
--- a/src/Compilers/VisualBasic/Test/Emit/Attributes/AttributeTests_MarshalAs.vb
+++ b/src/Compilers/VisualBasic/Test/Emit/Attributes/AttributeTests_MarshalAs.vb
@@ -498,6 +498,7 @@ End Class
}
Dim verifier = CompileAndVerifyFieldMarshal(source, blobs)
+ verifier.VerifyDiagnostics()
VerifyFieldMetadataDecoding(verifier, blobs)
End Sub