Skip to content

Commit

Permalink
Diagnostic to cover the gap left by AttributeTargets.Method
Browse files Browse the repository at this point in the history
  • Loading branch information
jnm2 committed Apr 29, 2020
1 parent fb425a8 commit 3153060
Show file tree
Hide file tree
Showing 18 changed files with 90 additions and 21 deletions.
3 changes: 3 additions & 0 deletions src/Compilers/CSharp/Portable/CSharpResources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -6091,4 +6091,7 @@ To remove the warning, you can use /reference instead (set the Embed Interop Typ
<data name="ERR_ModuleInitializerMethodMustReturnVoid" xml:space="preserve">
<value>Module initializer method '{0}' must return void</value>
</data>
<data name="ERR_ModuleInitializerMethodMustBeOrdinary" xml:space="preserve">
<value>A module initializer must be an ordinary method</value>
</data>
</root>
13 changes: 7 additions & 6 deletions src/Compilers/CSharp/Portable/Errors/ErrorCode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1777,12 +1777,13 @@ internal enum ErrorCode
ERR_ExpressionTreeContainsFromEndIndexExpression = 8791,
ERR_ExpressionTreeContainsRangeExpression = 8792,

ERR_ModuleInitializerMethodMustBeAccessibleOutsideTopLevelType = 8793,
ERR_ModuleInitializerMethodMustBeStatic = 8794,
ERR_ModuleInitializerMethodMustNotHaveParameters = 8795,
ERR_ModuleInitializerMethodMustReturnVoid = 8796,
ERR_ModuleInitializerMethodMustNotBeGeneric = 8797,
ERR_ModuleInitializerMethodMustNotBeContainedInGenericType = 8798,
ERR_ModuleInitializerMethodMustBeOrdinary = 8793,
ERR_ModuleInitializerMethodMustBeAccessibleOutsideTopLevelType = 8794,
ERR_ModuleInitializerMethodMustBeStatic = 8795,
ERR_ModuleInitializerMethodMustNotHaveParameters = 8796,
ERR_ModuleInitializerMethodMustReturnVoid = 8797,
ERR_ModuleInitializerMethodMustNotBeGeneric = 8798,
ERR_ModuleInitializerMethodMustNotBeContainedInGenericType = 8799,

// Note: you will need to re-generate compiler code after adding warnings (eng\generate-compiler-code.cmd)
}
Expand Down
5 changes: 5 additions & 0 deletions src/Compilers/CSharp/Portable/xlf/CSharpResources.cs.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,11 @@
<target state="new">Module initializer method '{0}' must be accessible outside top-level type '{1}'</target>
<note />
</trans-unit>
<trans-unit id="ERR_ModuleInitializerMethodMustBeOrdinary">
<source>A module initializer must be an ordinary method</source>
<target state="new">A module initializer must be an ordinary method</target>
<note />
</trans-unit>
<trans-unit id="ERR_ModuleInitializerMethodMustBeStatic">
<source>Module initializer method '{0}' must be static</source>
<target state="new">Module initializer method '{0}' must be static</target>
Expand Down
5 changes: 5 additions & 0 deletions src/Compilers/CSharp/Portable/xlf/CSharpResources.de.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,11 @@
<target state="new">Module initializer method '{0}' must be accessible outside top-level type '{1}'</target>
<note />
</trans-unit>
<trans-unit id="ERR_ModuleInitializerMethodMustBeOrdinary">
<source>A module initializer must be an ordinary method</source>
<target state="new">A module initializer must be an ordinary method</target>
<note />
</trans-unit>
<trans-unit id="ERR_ModuleInitializerMethodMustBeStatic">
<source>Module initializer method '{0}' must be static</source>
<target state="new">Module initializer method '{0}' must be static</target>
Expand Down
5 changes: 5 additions & 0 deletions src/Compilers/CSharp/Portable/xlf/CSharpResources.es.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,11 @@
<target state="new">Module initializer method '{0}' must be accessible outside top-level type '{1}'</target>
<note />
</trans-unit>
<trans-unit id="ERR_ModuleInitializerMethodMustBeOrdinary">
<source>A module initializer must be an ordinary method</source>
<target state="new">A module initializer must be an ordinary method</target>
<note />
</trans-unit>
<trans-unit id="ERR_ModuleInitializerMethodMustBeStatic">
<source>Module initializer method '{0}' must be static</source>
<target state="new">Module initializer method '{0}' must be static</target>
Expand Down
5 changes: 5 additions & 0 deletions src/Compilers/CSharp/Portable/xlf/CSharpResources.fr.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,11 @@
<target state="new">Module initializer method '{0}' must be accessible outside top-level type '{1}'</target>
<note />
</trans-unit>
<trans-unit id="ERR_ModuleInitializerMethodMustBeOrdinary">
<source>A module initializer must be an ordinary method</source>
<target state="new">A module initializer must be an ordinary method</target>
<note />
</trans-unit>
<trans-unit id="ERR_ModuleInitializerMethodMustBeStatic">
<source>Module initializer method '{0}' must be static</source>
<target state="new">Module initializer method '{0}' must be static</target>
Expand Down
5 changes: 5 additions & 0 deletions src/Compilers/CSharp/Portable/xlf/CSharpResources.it.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,11 @@
<target state="new">Module initializer method '{0}' must be accessible outside top-level type '{1}'</target>
<note />
</trans-unit>
<trans-unit id="ERR_ModuleInitializerMethodMustBeOrdinary">
<source>A module initializer must be an ordinary method</source>
<target state="new">A module initializer must be an ordinary method</target>
<note />
</trans-unit>
<trans-unit id="ERR_ModuleInitializerMethodMustBeStatic">
<source>Module initializer method '{0}' must be static</source>
<target state="new">Module initializer method '{0}' must be static</target>
Expand Down
5 changes: 5 additions & 0 deletions src/Compilers/CSharp/Portable/xlf/CSharpResources.ja.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,11 @@
<target state="new">Module initializer method '{0}' must be accessible outside top-level type '{1}'</target>
<note />
</trans-unit>
<trans-unit id="ERR_ModuleInitializerMethodMustBeOrdinary">
<source>A module initializer must be an ordinary method</source>
<target state="new">A module initializer must be an ordinary method</target>
<note />
</trans-unit>
<trans-unit id="ERR_ModuleInitializerMethodMustBeStatic">
<source>Module initializer method '{0}' must be static</source>
<target state="new">Module initializer method '{0}' must be static</target>
Expand Down
5 changes: 5 additions & 0 deletions src/Compilers/CSharp/Portable/xlf/CSharpResources.ko.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,11 @@
<target state="new">Module initializer method '{0}' must be accessible outside top-level type '{1}'</target>
<note />
</trans-unit>
<trans-unit id="ERR_ModuleInitializerMethodMustBeOrdinary">
<source>A module initializer must be an ordinary method</source>
<target state="new">A module initializer must be an ordinary method</target>
<note />
</trans-unit>
<trans-unit id="ERR_ModuleInitializerMethodMustBeStatic">
<source>Module initializer method '{0}' must be static</source>
<target state="new">Module initializer method '{0}' must be static</target>
Expand Down
5 changes: 5 additions & 0 deletions src/Compilers/CSharp/Portable/xlf/CSharpResources.pl.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,11 @@
<target state="new">Module initializer method '{0}' must be accessible outside top-level type '{1}'</target>
<note />
</trans-unit>
<trans-unit id="ERR_ModuleInitializerMethodMustBeOrdinary">
<source>A module initializer must be an ordinary method</source>
<target state="new">A module initializer must be an ordinary method</target>
<note />
</trans-unit>
<trans-unit id="ERR_ModuleInitializerMethodMustBeStatic">
<source>Module initializer method '{0}' must be static</source>
<target state="new">Module initializer method '{0}' must be static</target>
Expand Down
5 changes: 5 additions & 0 deletions src/Compilers/CSharp/Portable/xlf/CSharpResources.pt-BR.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,11 @@
<target state="new">Module initializer method '{0}' must be accessible outside top-level type '{1}'</target>
<note />
</trans-unit>
<trans-unit id="ERR_ModuleInitializerMethodMustBeOrdinary">
<source>A module initializer must be an ordinary method</source>
<target state="new">A module initializer must be an ordinary method</target>
<note />
</trans-unit>
<trans-unit id="ERR_ModuleInitializerMethodMustBeStatic">
<source>Module initializer method '{0}' must be static</source>
<target state="new">Module initializer method '{0}' must be static</target>
Expand Down
5 changes: 5 additions & 0 deletions src/Compilers/CSharp/Portable/xlf/CSharpResources.ru.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,11 @@
<target state="new">Module initializer method '{0}' must be accessible outside top-level type '{1}'</target>
<note />
</trans-unit>
<trans-unit id="ERR_ModuleInitializerMethodMustBeOrdinary">
<source>A module initializer must be an ordinary method</source>
<target state="new">A module initializer must be an ordinary method</target>
<note />
</trans-unit>
<trans-unit id="ERR_ModuleInitializerMethodMustBeStatic">
<source>Module initializer method '{0}' must be static</source>
<target state="new">Module initializer method '{0}' must be static</target>
Expand Down
5 changes: 5 additions & 0 deletions src/Compilers/CSharp/Portable/xlf/CSharpResources.tr.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,11 @@
<target state="new">Module initializer method '{0}' must be accessible outside top-level type '{1}'</target>
<note />
</trans-unit>
<trans-unit id="ERR_ModuleInitializerMethodMustBeOrdinary">
<source>A module initializer must be an ordinary method</source>
<target state="new">A module initializer must be an ordinary method</target>
<note />
</trans-unit>
<trans-unit id="ERR_ModuleInitializerMethodMustBeStatic">
<source>Module initializer method '{0}' must be static</source>
<target state="new">Module initializer method '{0}' must be static</target>
Expand Down
5 changes: 5 additions & 0 deletions src/Compilers/CSharp/Portable/xlf/CSharpResources.zh-Hans.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,11 @@
<target state="new">Module initializer method '{0}' must be accessible outside top-level type '{1}'</target>
<note />
</trans-unit>
<trans-unit id="ERR_ModuleInitializerMethodMustBeOrdinary">
<source>A module initializer must be an ordinary method</source>
<target state="new">A module initializer must be an ordinary method</target>
<note />
</trans-unit>
<trans-unit id="ERR_ModuleInitializerMethodMustBeStatic">
<source>Module initializer method '{0}' must be static</source>
<target state="new">Module initializer method '{0}' must be static</target>
Expand Down
5 changes: 5 additions & 0 deletions src/Compilers/CSharp/Portable/xlf/CSharpResources.zh-Hant.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,11 @@
<target state="new">Module initializer method '{0}' must be accessible outside top-level type '{1}'</target>
<note />
</trans-unit>
<trans-unit id="ERR_ModuleInitializerMethodMustBeOrdinary">
<source>A module initializer must be an ordinary method</source>
<target state="new">A module initializer must be an ordinary method</target>
<note />
</trans-unit>
<trans-unit id="ERR_ModuleInitializerMethodMustBeStatic">
<source>Module initializer method '{0}' must be static</source>
<target state="new">Module initializer method '{0}' must be static</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ namespace System.Runtime.CompilerServices { class ModuleInitializerAttribute : S
";
var compilation = CreateCompilation(source, parseOptions: s_parseOptions);
compilation.VerifyDiagnostics(
// (6,6): error CS8793: Module initializer method 'M' must be accessible outside top-level type 'C'
// (6,6): error CS8794: Module initializer method 'M' must be accessible outside top-level type 'C'
// [ModuleInitializer]
Diagnostic(ErrorCode.ERR_ModuleInitializerMethodMustBeAccessibleOutsideTopLevelType, "ModuleInitializer").WithArguments("M", "C").WithLocation(6, 6)
);
Expand All @@ -46,7 +46,7 @@ namespace System.Runtime.CompilerServices { class ModuleInitializerAttribute : S
";
var compilation = CreateCompilation(source, parseOptions: s_parseOptions);
compilation.VerifyDiagnostics(
// (6,6): error CS8793: Module initializer method 'M' must be accessible outside top-level type 'C'
// (6,6): error CS8794: Module initializer method 'M' must be accessible outside top-level type 'C'
// [ModuleInitializer]
Diagnostic(ErrorCode.ERR_ModuleInitializerMethodMustBeAccessibleOutsideTopLevelType, "ModuleInitializer").WithArguments("M", "C").WithLocation(6, 6)
);
Expand All @@ -68,7 +68,7 @@ namespace System.Runtime.CompilerServices { class ModuleInitializerAttribute : S
";
var compilation = CreateCompilation(source, parseOptions: s_parseOptions);
compilation.VerifyDiagnostics(
// (6,6): error CS8793: Module initializer method 'M' must be accessible outside top-level type 'C'
// (6,6): error CS8794: Module initializer method 'M' must be accessible outside top-level type 'C'
// [ModuleInitializer]
Diagnostic(ErrorCode.ERR_ModuleInitializerMethodMustBeAccessibleOutsideTopLevelType, "ModuleInitializer").WithArguments("M", "C").WithLocation(6, 6)
);
Expand Down Expand Up @@ -183,7 +183,7 @@ namespace System.Runtime.CompilerServices { class ModuleInitializerAttribute : S
";
var compilation = CreateCompilation(source, parseOptions: s_parseOptions);
compilation.VerifyDiagnostics(
// (8,10): error CS8793: Module initializer method 'M' must be accessible outside top-level type 'C'
// (8,10): error CS8794: Module initializer method 'M' must be accessible outside top-level type 'C'
// [ModuleInitializer]
Diagnostic(ErrorCode.ERR_ModuleInitializerMethodMustBeAccessibleOutsideTopLevelType, "ModuleInitializer").WithArguments("M", "C").WithLocation(8, 10)
);
Expand All @@ -208,7 +208,7 @@ namespace System.Runtime.CompilerServices { class ModuleInitializerAttribute : S
";
var compilation = CreateCompilation(source, parseOptions: s_parseOptions);
compilation.VerifyDiagnostics(
// (8,10): error CS8793: Module initializer method 'M' must be accessible outside top-level type 'C'
// (8,10): error CS8794: Module initializer method 'M' must be accessible outside top-level type 'C'
// [ModuleInitializer]
Diagnostic(ErrorCode.ERR_ModuleInitializerMethodMustBeAccessibleOutsideTopLevelType, "ModuleInitializer").WithArguments("M", "C").WithLocation(8, 10)
);
Expand All @@ -233,7 +233,7 @@ namespace System.Runtime.CompilerServices { class ModuleInitializerAttribute : S
";
var compilation = CreateCompilation(source, parseOptions: s_parseOptions);
compilation.VerifyDiagnostics(
// (8,10): error CS8793: Module initializer method 'M' must be accessible outside top-level type 'C'
// (8,10): error CS8794: Module initializer method 'M' must be accessible outside top-level type 'C'
// [ModuleInitializer]
Diagnostic(ErrorCode.ERR_ModuleInitializerMethodMustBeAccessibleOutsideTopLevelType, "ModuleInitializer").WithArguments("M", "C").WithLocation(8, 10)
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ namespace System.Runtime.CompilerServices { class ModuleInitializerAttribute : S
";
var compilation = CreateCompilation(source, parseOptions: s_parseOptions);
compilation.VerifyDiagnostics(
// (6,6): error CS8797: Module initializer method 'M' must not have generic parameters
// (6,6): error CS8798: Module initializer method 'M' must not have generic parameters
// [ModuleInitializer]
Diagnostic(ErrorCode.ERR_ModuleInitializerMethodMustNotBeGeneric, "ModuleInitializer").WithArguments("M").WithLocation(6, 6)
);
Expand All @@ -46,7 +46,7 @@ namespace System.Runtime.CompilerServices { class ModuleInitializerAttribute : S
";
var compilation = CreateCompilation(source, parseOptions: s_parseOptions);
compilation.VerifyDiagnostics(
// (6,6): error CS8797: Module initializer method 'M' must not be contained in a generic type
// (6,6): error CS8798: Module initializer method 'M' must not be contained in a generic type
// [ModuleInitializer]
Diagnostic(ErrorCode.ERR_ModuleInitializerMethodMustNotBeContainedInGenericType, "ModuleInitializer").WithArguments("M").WithLocation(6, 6)
);
Expand All @@ -71,7 +71,7 @@ namespace System.Runtime.CompilerServices { class ModuleInitializerAttribute : S
";
var compilation = CreateCompilation(source, parseOptions: s_parseOptions);
compilation.VerifyDiagnostics(
// (8,10): error CS8798: Module initializer method 'M' must not be contained in a generic type
// (8,10): error CS8799: Module initializer method 'M' must not be contained in a generic type
// [ModuleInitializer]
Diagnostic(ErrorCode.ERR_ModuleInitializerMethodMustNotBeContainedInGenericType, "ModuleInitializer").WithArguments("M").WithLocation(8, 10)
);
Expand Down
Loading

0 comments on commit 3153060

Please sign in to comment.