Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
b55510b4
R
roslyn
项目概览
lwm1986
/
roslyn
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
roslyn
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
b55510b4
编写于
7月 17, 2020
作者:
N
Neal Gafter
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'master' of
https://github.com/dotnet/roslyn
into target-typing-merge2020-07-17
上级
a88765ed
824f464f
变更
38
展开全部
隐藏空白更改
内联
并排
Showing
38 changed file
with
3714 addition
and
37 deletion
+3714
-37
eng/Version.Details.xml
eng/Version.Details.xml
+2
-2
eng/common/templates/post-build/post-build.yml
eng/common/templates/post-build/post-build.yml
+12
-0
global.json
global.json
+1
-1
src/Compilers/CSharp/Portable/CSharpResources.resx
src/Compilers/CSharp/Portable/CSharpResources.resx
+15
-0
src/Compilers/CSharp/Portable/Compilation/CSharpCompilation.cs
...ompilers/CSharp/Portable/Compilation/CSharpCompilation.cs
+38
-0
src/Compilers/CSharp/Portable/Compilation/LexicalOrderSymbolComparer.cs
...CSharp/Portable/Compilation/LexicalOrderSymbolComparer.cs
+6
-4
src/Compilers/CSharp/Portable/Errors/ErrorCode.cs
src/Compilers/CSharp/Portable/Errors/ErrorCode.cs
+4
-7
src/Compilers/CSharp/Portable/Errors/MessageID.cs
src/Compilers/CSharp/Portable/Errors/MessageID.cs
+3
-1
src/Compilers/CSharp/Portable/Symbols/Source/SourceMethodSymbolWithAttributes.cs
...rtable/Symbols/Source/SourceMethodSymbolWithAttributes.cs
+46
-0
src/Compilers/CSharp/Portable/xlf/CSharpResources.cs.xlf
src/Compilers/CSharp/Portable/xlf/CSharpResources.cs.xlf
+25
-0
src/Compilers/CSharp/Portable/xlf/CSharpResources.de.xlf
src/Compilers/CSharp/Portable/xlf/CSharpResources.de.xlf
+25
-0
src/Compilers/CSharp/Portable/xlf/CSharpResources.es.xlf
src/Compilers/CSharp/Portable/xlf/CSharpResources.es.xlf
+25
-0
src/Compilers/CSharp/Portable/xlf/CSharpResources.fr.xlf
src/Compilers/CSharp/Portable/xlf/CSharpResources.fr.xlf
+25
-0
src/Compilers/CSharp/Portable/xlf/CSharpResources.it.xlf
src/Compilers/CSharp/Portable/xlf/CSharpResources.it.xlf
+25
-0
src/Compilers/CSharp/Portable/xlf/CSharpResources.ja.xlf
src/Compilers/CSharp/Portable/xlf/CSharpResources.ja.xlf
+25
-0
src/Compilers/CSharp/Portable/xlf/CSharpResources.ko.xlf
src/Compilers/CSharp/Portable/xlf/CSharpResources.ko.xlf
+25
-0
src/Compilers/CSharp/Portable/xlf/CSharpResources.pl.xlf
src/Compilers/CSharp/Portable/xlf/CSharpResources.pl.xlf
+25
-0
src/Compilers/CSharp/Portable/xlf/CSharpResources.pt-BR.xlf
src/Compilers/CSharp/Portable/xlf/CSharpResources.pt-BR.xlf
+25
-0
src/Compilers/CSharp/Portable/xlf/CSharpResources.ru.xlf
src/Compilers/CSharp/Portable/xlf/CSharpResources.ru.xlf
+25
-0
src/Compilers/CSharp/Portable/xlf/CSharpResources.tr.xlf
src/Compilers/CSharp/Portable/xlf/CSharpResources.tr.xlf
+25
-0
src/Compilers/CSharp/Portable/xlf/CSharpResources.zh-Hans.xlf
...Compilers/CSharp/Portable/xlf/CSharpResources.zh-Hans.xlf
+25
-0
src/Compilers/CSharp/Portable/xlf/CSharpResources.zh-Hant.xlf
...Compilers/CSharp/Portable/xlf/CSharpResources.zh-Hant.xlf
+25
-0
src/Compilers/CSharp/Test/Symbol/Symbols/ModuleInitializers/AccessibilityTests.cs
...t/Symbol/Symbols/ModuleInitializers/AccessibilityTests.cs
+410
-0
src/Compilers/CSharp/Test/Symbol/Symbols/ModuleInitializers/GenericsTests.cs
...p/Test/Symbol/Symbols/ModuleInitializers/GenericsTests.cs
+107
-0
src/Compilers/CSharp/Test/Symbol/Symbols/ModuleInitializers/IgnoredTests.cs
...rp/Test/Symbol/Symbols/ModuleInitializers/IgnoredTests.cs
+295
-0
src/Compilers/CSharp/Test/Symbol/Symbols/ModuleInitializers/ModuleInitializersTests.cs
...bol/Symbols/ModuleInitializers/ModuleInitializersTests.cs
+1126
-0
src/Compilers/CSharp/Test/Symbol/Symbols/ModuleInitializers/SignatureTests.cs
.../Test/Symbol/Symbols/ModuleInitializers/SignatureTests.cs
+205
-0
src/Compilers/CSharp/Test/Symbol/Symbols/ModuleInitializers/TargetsTests.cs
...rp/Test/Symbol/Symbols/ModuleInitializers/TargetsTests.cs
+513
-0
src/Compilers/CSharp/Test/Syntax/Diagnostics/DiagnosticTest.cs
...ompilers/CSharp/Test/Syntax/Diagnostics/DiagnosticTest.cs
+0
-6
src/Compilers/Core/Portable/Emit/CommonPEModuleBuilder.cs
src/Compilers/Core/Portable/Emit/CommonPEModuleBuilder.cs
+4
-5
src/Compilers/Core/Portable/InternalUtilities/ConcurrentSet.cs
...ompilers/Core/Portable/InternalUtilities/ConcurrentSet.cs
+7
-2
src/Compilers/Core/Portable/PEWriter/RootModuleStaticConstructor.cs
...ers/Core/Portable/PEWriter/RootModuleStaticConstructor.cs
+162
-0
src/Compilers/Core/Portable/PEWriter/RootModuleType.cs
src/Compilers/Core/Portable/PEWriter/RootModuleType.cs
+18
-7
src/Compilers/Core/Portable/Symbols/Attributes/AttributeDescription.cs
.../Core/Portable/Symbols/Attributes/AttributeDescription.cs
+3
-0
src/Compilers/Server/VBCSCompiler/MetadataCache.cs
src/Compilers/Server/VBCSCompiler/MetadataCache.cs
+2
-2
src/Compilers/VisualBasic/Portable/Symbols/Source/SourceMethodSymbol.vb
...VisualBasic/Portable/Symbols/Source/SourceMethodSymbol.vb
+2
-0
src/Compilers/VisualBasic/Test/Emit/Attributes/AttributeTests_WellKnownAttributes.vb
...est/Emit/Attributes/AttributeTests_WellKnownAttributes.vb
+407
-0
src/Test/Utilities/Portable/Traits/CompilerFeature.cs
src/Test/Utilities/Portable/Traits/CompilerFeature.cs
+1
-0
未找到文件。
eng/Version.Details.xml
浏览文件 @
b55510b4
...
...
@@ -3,9 +3,9 @@
<ProductDependencies>
</ProductDependencies>
<ToolsetDependencies>
<Dependency
Name=
"Microsoft.DotNet.Arcade.Sdk"
Version=
"1.0.0-beta.203
26.2
"
>
<Dependency
Name=
"Microsoft.DotNet.Arcade.Sdk"
Version=
"1.0.0-beta.203
65.6
"
>
<Uri>
https://github.com/dotnet/arcade
</Uri>
<Sha>
ed69753a3ffbdaa08365252c710d57a64d17f859
</Sha>
<Sha>
7cc59275eade471e29b88a797275818b0d513d0f
</Sha>
</Dependency>
<Dependency
Name=
"Microsoft.Net.Compilers.Toolset"
Version=
"3.8.0-1.20361.1"
>
<Uri>
https://github.com/dotnet/roslyn
</Uri>
...
...
eng/common/templates/post-build/post-build.yml
浏览文件 @
b55510b4
...
...
@@ -355,6 +355,18 @@ stages:
shippingFeed
:
'
https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-tools/nuget/v3/index.json'
symbolsFeed
:
'
https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-tools-symbols/nuget/v3/index.json'
-
template
:
\eng\common\templates\post-build\channels\generic-public-channel.yml
parameters
:
artifactsPublishingAdditionalParameters
:
${{ parameters.artifactsPublishingAdditionalParameters }}
publishInstallersAndChecksums
:
${{ parameters.publishInstallersAndChecksums }}
symbolPublishingAdditionalParameters
:
${{ parameters.symbolPublishingAdditionalParameters }}
stageName
:
'
VS16_8_Publishing'
channelName
:
'
VS
16.8'
channelId
:
1154
transportFeed
:
'
https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-tools-transport/nuget/v3/index.json'
shippingFeed
:
'
https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-tools/nuget/v3/index.json'
symbolsFeed
:
'
https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-tools-symbols/nuget/v3/index.json'
-
template
:
\eng\common\templates\post-build\channels\generic-public-channel.yml
parameters
:
artifactsPublishingAdditionalParameters
:
${{ parameters.artifactsPublishingAdditionalParameters }}
...
...
global.json
浏览文件 @
b55510b4
...
...
@@ -7,6 +7,6 @@
"xcopy-msbuild"
:
"16.4.0-alpha"
},
"msbuild-sdks"
:
{
"Microsoft.DotNet.Arcade.Sdk"
:
"1.0.0-beta.203
26.2
"
"Microsoft.DotNet.Arcade.Sdk"
:
"1.0.0-beta.203
65.6
"
}
}
src/Compilers/CSharp/Portable/CSharpResources.resx
浏览文件 @
b55510b4
...
...
@@ -6327,4 +6327,19 @@ To remove the warning, you can use /reference instead (set the Embed Interop Typ
<data
name=
"ERR_DoesNotOverrideBaseEqualityContract"
xml:space=
"preserve"
>
<value>
'{0}' does not override expected property from '{1}'.
</value>
</data>
<data
name=
"IDS_FeatureModuleInitializers"
xml:space=
"preserve"
>
<value>
module initializers
</value>
</data>
<data
name=
"ERR_ModuleInitializerMethodMustBeAccessibleOutsideTopLevelType"
xml:space=
"preserve"
>
<value>
Module initializer method '{0}' must be accessible at the module level
</value>
</data>
<data
name=
"ERR_ModuleInitializerMethodMustBeStaticParameterlessVoid"
xml:space=
"preserve"
>
<value>
Module initializer method '{0}' must be static, must have no parameters, and must return 'void'
</value>
</data>
<data
name=
"ERR_ModuleInitializerMethodAndContainingTypesMustNotBeGeneric"
xml:space=
"preserve"
>
<value>
Module initializer method '{0}' must not be generic and must not be contained in a generic type
</value>
</data>
<data
name=
"ERR_ModuleInitializerMethodMustBeOrdinary"
xml:space=
"preserve"
>
<value>
A module initializer must be an ordinary member method
</value>
</data>
</root>
src/Compilers/CSharp/Portable/Compilation/CSharpCompilation.cs
浏览文件 @
b55510b4
...
...
@@ -17,6 +17,7 @@
using
System.Threading
;
using
System.Threading.Tasks
;
using
Microsoft.Cci
;
using
Microsoft.CodeAnalysis
;
using
Microsoft.CodeAnalysis.CodeGen
;
using
Microsoft.CodeAnalysis.CSharp.Emit
;
using
Microsoft.CodeAnalysis.CSharp.Symbols
;
...
...
@@ -2057,6 +2058,14 @@ internal PointerTypeSymbol CreatePointerTypeSymbol(TypeSymbol elementType, Nulla
throw
new
NotImplementedException
();
}
private
ConcurrentSet
<
MethodSymbol
>?
_moduleInitializerMethods
;
internal
void
AddModuleInitializerMethod
(
MethodSymbol
method
)
{
Debug
.
Assert
(!
_declarationDiagnosticsFrozen
);
LazyInitializer
.
EnsureInitialized
(
ref
_moduleInitializerMethods
).
Add
(
method
);
}
#
endregion
#
region
Binding
...
...
@@ -2857,6 +2866,11 @@ internal override StrongNameKeys StrongNameKeys
filterOpt
:
filterOpt
,
cancellationToken
:
cancellationToken
);
if
(!
hasDeclarationErrors
&&
!
CommonCompiler
.
HasUnsuppressableErrors
(
methodBodyDiagnosticBag
))
{
GenerateModuleInitializer
(
moduleBeingBuilt
,
methodBodyDiagnosticBag
);
}
bool
hasMethodBodyError
=
!
FilterAndAppendAndFreeDiagnostics
(
diagnostics
,
ref
methodBodyDiagnosticBag
);
if
(
hasDeclarationErrors
||
hasMethodBodyError
)
...
...
@@ -2868,6 +2882,30 @@ internal override StrongNameKeys StrongNameKeys
return
true
;
}
private
void
GenerateModuleInitializer
(
PEModuleBuilder
moduleBeingBuilt
,
DiagnosticBag
methodBodyDiagnosticBag
)
{
Debug
.
Assert
(
_declarationDiagnosticsFrozen
);
if
(
_moduleInitializerMethods
is
object
)
{
var
ilBuilder
=
new
ILBuilder
(
moduleBeingBuilt
,
new
LocalSlotManager
(
slotAllocator
:
null
),
OptimizationLevel
.
Release
,
areLocalsZeroed
:
false
);
foreach
(
MethodSymbol
method
in
_moduleInitializerMethods
.
OrderBy
<
MethodSymbol
>(
LexicalOrderSymbolComparer
.
Instance
))
{
ilBuilder
.
EmitOpCode
(
ILOpCode
.
Call
,
stackAdjustment
:
0
);
ilBuilder
.
EmitToken
(
moduleBeingBuilt
.
Translate
(
method
,
methodBodyDiagnosticBag
,
needDeclaration
:
true
),
CSharpSyntaxTree
.
Dummy
.
GetRoot
(),
methodBodyDiagnosticBag
);
}
ilBuilder
.
EmitRet
(
isVoid
:
true
);
ilBuilder
.
Realize
();
moduleBeingBuilt
.
RootModuleType
.
SetStaticConstructorBody
(
ilBuilder
.
RealizedIL
);
}
}
internal
override
bool
GenerateResourcesAndDocumentationComments
(
CommonPEModuleBuilder
moduleBuilder
,
Stream
?
xmlDocStream
,
...
...
src/Compilers/CSharp/Portable/Compilation/LexicalOrderSymbolComparer.cs
浏览文件 @
b55510b4
...
...
@@ -8,10 +8,11 @@
namespace
Microsoft.CodeAnalysis.CSharp
{
/// <summary> This is an implementation of a special symbol comparer, which is supposed to be used for
/// sorting original definition symbols (explicitly or explicitly declared in source within the same
/// container) in lexical order of their declarations. It will not work on anything that uses non-source locations.
/// </summary>
/// <summary>
/// This is an implementation of a special symbol comparer, which is supposed to be used for sorting
/// original definition symbols (explicitly or implicitly declared in source within the same compilation)
/// in lexical order of their declarations. It will not work on anything that uses non-source locations.
/// </summary>
internal
class
LexicalOrderSymbolComparer
:
IComparer
<
Symbol
>
{
public
static
readonly
LexicalOrderSymbolComparer
Instance
=
new
LexicalOrderSymbolComparer
();
...
...
@@ -30,6 +31,7 @@ public int Compare(Symbol x, Symbol y)
var
xSortKey
=
x
.
GetLexicalSortKey
();
var
ySortKey
=
y
.
GetLexicalSortKey
();
Debug
.
Assert
((
object
)
x
.
DeclaringCompilation
==
y
.
DeclaringCompilation
);
comparison
=
LexicalSortKey
.
Compare
(
xSortKey
,
ySortKey
);
if
(
comparison
!=
0
)
...
...
src/Compilers/CSharp/Portable/Errors/ErrorCode.cs
浏览文件 @
b55510b4
...
...
@@ -1820,13 +1820,10 @@ internal enum ErrorCode
ERR_CannotConvertAddressOfToDelegate
=
8811
,
ERR_AddressOfToNonFunctionPointer
=
8812
,
ERR_8813
=
8813
,
// used by features/module-initializers
ERR_8814
=
8814
,
// used by features/module-initializers
ERR_8815
=
8815
,
// used by features/module-initializers
ERR_8816
=
8816
,
// used by features/module-initializers
ERR_ModuleInitializerMethodMustBeOrdinary
=
8813
,
ERR_ModuleInitializerMethodMustBeAccessibleOutsideTopLevelType
=
8814
,
ERR_ModuleInitializerMethodMustBeStaticParameterlessVoid
=
8815
,
ERR_ModuleInitializerMethodAndContainingTypesMustNotBeGeneric
=
8816
,
ERR_PartialMethodReturnTypeDifference
=
8817
,
ERR_PartialMethodRefReturnDifference
=
8818
,
...
...
src/Compilers/CSharp/Portable/Errors/MessageID.cs
浏览文件 @
b55510b4
...
...
@@ -207,7 +207,8 @@ internal enum MessageID
IDS_FeatureInitOnlySetters
=
MessageBase
+
12781
,
IDS_FeatureRecords
=
MessageBase
+
12782
,
IDS_FeatureNullPointerConstantPattern
=
MessageBase
+
12783
,
IDS_FeatureTargetTypedConditional
=
MessageBase
+
12784
,
IDS_FeatureModuleInitializers
=
MessageBase
+
12784
,
IDS_FeatureTargetTypedConditional
=
MessageBase
+
12785
,
}
// Message IDs may refer to strings that need to be localized.
...
...
@@ -334,6 +335,7 @@ internal static LanguageVersion RequiredVersion(this MessageID feature)
case
MessageID
.
IDS_FeatureRecords
:
case
MessageID
.
IDS_FeatureTargetTypedConditional
:
// semantic check
case
MessageID
.
IDS_FeatureStaticAnonymousFunction
:
// syntax check
case
MessageID
.
IDS_FeatureModuleInitializers
:
// semantic check on method attribute
return
LanguageVersion
.
Preview
;
// C# 8.0 features.
...
...
src/Compilers/CSharp/Portable/Symbols/Source/SourceMethodSymbolWithAttributes.cs
浏览文件 @
b55510b4
...
...
@@ -9,6 +9,7 @@
using
System.Linq
;
using
System.Runtime.InteropServices
;
using
System.Threading
;
using
Microsoft.CodeAnalysis
;
using
Microsoft.CodeAnalysis.CSharp.Syntax
;
using
Roslyn.Utilities
;
...
...
@@ -486,6 +487,11 @@ private void DecodeWellKnownAttributeAppliedToMethod(ref DecodeWellKnownAttribut
MessageID
.
IDS_FeatureMemberNotNull
.
CheckFeatureAvailability
(
arguments
.
Diagnostics
,
arguments
.
AttributeSyntaxOpt
);
CSharpAttributeData
.
DecodeMemberNotNullWhenAttribute
<
MethodWellKnownAttributeData
>(
ContainingType
,
ref
arguments
);
}
else
if
(
attribute
.
IsTargetAttribute
(
this
,
AttributeDescription
.
ModuleInitializerAttribute
))
{
MessageID
.
IDS_FeatureModuleInitializers
.
CheckFeatureAvailability
(
arguments
.
Diagnostics
,
arguments
.
AttributeSyntaxOpt
);
DecodeModuleInitializerAttribute
(
arguments
);
}
else
{
var
compilation
=
this
.
DeclaringCompilation
;
...
...
@@ -762,6 +768,46 @@ private void DecodeDllImportAttribute(ref DecodeWellKnownAttributeArguments<Attr
preserveSig
);
}
}
private
void
DecodeModuleInitializerAttribute
(
DecodeWellKnownAttributeArguments
<
AttributeSyntax
,
CSharpAttributeData
,
AttributeLocation
>
arguments
)
{
Debug
.
Assert
(
arguments
.
AttributeSyntaxOpt
is
object
);
if
(
MethodKind
!=
MethodKind
.
Ordinary
)
{
arguments
.
Diagnostics
.
Add
(
ErrorCode
.
ERR_ModuleInitializerMethodMustBeOrdinary
,
arguments
.
AttributeSyntaxOpt
.
Location
);
return
;
}
Debug
.
Assert
(
ContainingType
is
object
);
var
hasError
=
false
;
HashSet
<
DiagnosticInfo
>?
useSiteDiagnostics
=
null
;
if
(!
AccessCheck
.
IsSymbolAccessible
(
this
,
ContainingAssembly
,
ref
useSiteDiagnostics
))
{
arguments
.
Diagnostics
.
Add
(
ErrorCode
.
ERR_ModuleInitializerMethodMustBeAccessibleOutsideTopLevelType
,
arguments
.
AttributeSyntaxOpt
.
Location
,
Name
);
hasError
=
true
;
}
arguments
.
Diagnostics
.
Add
(
arguments
.
AttributeSyntaxOpt
,
useSiteDiagnostics
);
if
(!
IsStatic
||
ParameterCount
>
0
||
!
ReturnsVoid
)
{
arguments
.
Diagnostics
.
Add
(
ErrorCode
.
ERR_ModuleInitializerMethodMustBeStaticParameterlessVoid
,
arguments
.
AttributeSyntaxOpt
.
Location
,
Name
);
hasError
=
true
;
}
if
(
IsGenericMethod
||
ContainingType
.
IsGenericType
)
{
arguments
.
Diagnostics
.
Add
(
ErrorCode
.
ERR_ModuleInitializerMethodAndContainingTypesMustNotBeGeneric
,
arguments
.
AttributeSyntaxOpt
.
Location
,
Name
);
hasError
=
true
;
}
if
(!
hasError
&&
!
CallsAreOmitted
(
arguments
.
AttributeSyntaxOpt
.
SyntaxTree
))
{
DeclaringCompilation
.
AddModuleInitializerMethod
(
this
);
}
}
#
nullable
restore
internal
sealed
override
void
PostDecodeWellKnownAttributes
(
ImmutableArray
<
CSharpAttributeData
>
boundAttributes
,
ImmutableArray
<
AttributeSyntax
>
allAttributeSyntaxNodes
,
DiagnosticBag
diagnostics
,
AttributeLocation
symbolPart
,
WellKnownAttributeData
decodedData
)
...
...
src/Compilers/CSharp/Portable/xlf/CSharpResources.cs.xlf
浏览文件 @
b55510b4
...
...
@@ -502,6 +502,26 @@
<target state="translated">Chybějící vzor</target>
<note />
</trans-unit>
<trans-unit id="ERR_ModuleInitializerMethodAndContainingTypesMustNotBeGeneric">
<source>Module initializer method '{0}' must not be generic and must not be contained in a generic type</source>
<target state="new">Module initializer method '{0}' must not be generic and must not be contained in a generic type</target>
<note />
</trans-unit>
<trans-unit id="ERR_ModuleInitializerMethodMustBeAccessibleOutsideTopLevelType">
<source>Module initializer method '{0}' must be accessible at the module level</source>
<target state="new">Module initializer method '{0}' must be accessible at the module level</target>
<note />
</trans-unit>
<trans-unit id="ERR_ModuleInitializerMethodMustBeOrdinary">
<source>A module initializer must be an ordinary member method</source>
<target state="new">A module initializer must be an ordinary member method</target>
<note />
</trans-unit>
<trans-unit id="ERR_ModuleInitializerMethodMustBeStaticParameterlessVoid">
<source>Module initializer method '{0}' must be static, must have no parameters, and must return 'void'</source>
<target state="new">Module initializer method '{0}' must be static, must have no parameters, and must return 'void'</target>
<note />
</trans-unit>
<trans-unit id="ERR_MultipleAnalyzerConfigsInSameDir">
<source>Multiple analyzer config files cannot be in the same directory ('{0}').</source>
<target state="translated">Ve stejném adresáři nemůže být více konfiguračních souborů analyzátoru ({0}).</target>
...
...
@@ -1291,6 +1311,11 @@
<target state="new">MemberNotNull attribute</target>
<note />
</trans-unit>
<trans-unit id="IDS_FeatureModuleInitializers">
<source>module initializers</source>
<target state="new">module initializers</target>
<note />
</trans-unit>
<trans-unit id="IDS_FeatureNameShadowingInNestedFunctions">
<source>name shadowing in nested functions</source>
<target state="translated">skrývání názvů ve vnořených funkcích</target>
...
...
src/Compilers/CSharp/Portable/xlf/CSharpResources.de.xlf
浏览文件 @
b55510b4
...
...
@@ -502,6 +502,26 @@
<target state="translated">Muster fehlt.</target>
<note />
</trans-unit>
<trans-unit id="ERR_ModuleInitializerMethodAndContainingTypesMustNotBeGeneric">
<source>Module initializer method '{0}' must not be generic and must not be contained in a generic type</source>
<target state="new">Module initializer method '{0}' must not be generic and must not be contained in a generic type</target>
<note />
</trans-unit>
<trans-unit id="ERR_ModuleInitializerMethodMustBeAccessibleOutsideTopLevelType">
<source>Module initializer method '{0}' must be accessible at the module level</source>
<target state="new">Module initializer method '{0}' must be accessible at the module level</target>
<note />
</trans-unit>
<trans-unit id="ERR_ModuleInitializerMethodMustBeOrdinary">
<source>A module initializer must be an ordinary member method</source>
<target state="new">A module initializer must be an ordinary member method</target>
<note />
</trans-unit>
<trans-unit id="ERR_ModuleInitializerMethodMustBeStaticParameterlessVoid">
<source>Module initializer method '{0}' must be static, must have no parameters, and must return 'void'</source>
<target state="new">Module initializer method '{0}' must be static, must have no parameters, and must return 'void'</target>
<note />
</trans-unit>
<trans-unit id="ERR_MultipleAnalyzerConfigsInSameDir">
<source>Multiple analyzer config files cannot be in the same directory ('{0}').</source>
<target state="translated">Dasselbe Verzeichnis ({0}) darf nicht mehrere Konfigurationsdateien des Analysetools enthalten.</target>
...
...
@@ -1291,6 +1311,11 @@
<target state="new">MemberNotNull attribute</target>
<note />
</trans-unit>
<trans-unit id="IDS_FeatureModuleInitializers">
<source>module initializers</source>
<target state="new">module initializers</target>
<note />
</trans-unit>
<trans-unit id="IDS_FeatureNameShadowingInNestedFunctions">
<source>name shadowing in nested functions</source>
<target state="translated">Namensshadowing in geschachtelten Funktionen</target>
...
...
src/Compilers/CSharp/Portable/xlf/CSharpResources.es.xlf
浏览文件 @
b55510b4
...
...
@@ -502,6 +502,26 @@
<target state="translated">Falta un patrón.</target>
<note />
</trans-unit>
<trans-unit id="ERR_ModuleInitializerMethodAndContainingTypesMustNotBeGeneric">
<source>Module initializer method '{0}' must not be generic and must not be contained in a generic type</source>
<target state="new">Module initializer method '{0}' must not be generic and must not be contained in a generic type</target>
<note />
</trans-unit>
<trans-unit id="ERR_ModuleInitializerMethodMustBeAccessibleOutsideTopLevelType">
<source>Module initializer method '{0}' must be accessible at the module level</source>
<target state="new">Module initializer method '{0}' must be accessible at the module level</target>
<note />
</trans-unit>
<trans-unit id="ERR_ModuleInitializerMethodMustBeOrdinary">
<source>A module initializer must be an ordinary member method</source>
<target state="new">A module initializer must be an ordinary member method</target>
<note />
</trans-unit>
<trans-unit id="ERR_ModuleInitializerMethodMustBeStaticParameterlessVoid">
<source>Module initializer method '{0}' must be static, must have no parameters, and must return 'void'</source>
<target state="new">Module initializer method '{0}' must be static, must have no parameters, and must return 'void'</target>
<note />
</trans-unit>
<trans-unit id="ERR_MultipleAnalyzerConfigsInSameDir">
<source>Multiple analyzer config files cannot be in the same directory ('{0}').</source>
<target state="translated">No es posible que un mismo directorio ("{0}") contenga varios archivos de configuración del analizador.</target>
...
...
@@ -1291,6 +1311,11 @@
<target state="new">MemberNotNull attribute</target>
<note />
</trans-unit>
<trans-unit id="IDS_FeatureModuleInitializers">
<source>module initializers</source>
<target state="new">module initializers</target>
<note />
</trans-unit>
<trans-unit id="IDS_FeatureNameShadowingInNestedFunctions">
<source>name shadowing in nested functions</source>
<target state="translated">sombreado de nombres en funciones anidadas</target>
...
...
src/Compilers/CSharp/Portable/xlf/CSharpResources.fr.xlf
浏览文件 @
b55510b4
...
...
@@ -502,6 +502,26 @@
<target state="translated">Modèle manquant</target>
<note />
</trans-unit>
<trans-unit id="ERR_ModuleInitializerMethodAndContainingTypesMustNotBeGeneric">
<source>Module initializer method '{0}' must not be generic and must not be contained in a generic type</source>
<target state="new">Module initializer method '{0}' must not be generic and must not be contained in a generic type</target>
<note />
</trans-unit>
<trans-unit id="ERR_ModuleInitializerMethodMustBeAccessibleOutsideTopLevelType">
<source>Module initializer method '{0}' must be accessible at the module level</source>
<target state="new">Module initializer method '{0}' must be accessible at the module level</target>
<note />
</trans-unit>
<trans-unit id="ERR_ModuleInitializerMethodMustBeOrdinary">
<source>A module initializer must be an ordinary member method</source>
<target state="new">A module initializer must be an ordinary member method</target>
<note />
</trans-unit>
<trans-unit id="ERR_ModuleInitializerMethodMustBeStaticParameterlessVoid">
<source>Module initializer method '{0}' must be static, must have no parameters, and must return 'void'</source>
<target state="new">Module initializer method '{0}' must be static, must have no parameters, and must return 'void'</target>
<note />
</trans-unit>
<trans-unit id="ERR_MultipleAnalyzerConfigsInSameDir">
<source>Multiple analyzer config files cannot be in the same directory ('{0}').</source>
<target state="translated">Plusieurs fichiers config d'analyseur ne peuvent pas figurer dans le même répertoire ('{0}').</target>
...
...
@@ -1291,6 +1311,11 @@
<target state="new">MemberNotNull attribute</target>
<note />
</trans-unit>
<trans-unit id="IDS_FeatureModuleInitializers">
<source>module initializers</source>
<target state="new">module initializers</target>
<note />
</trans-unit>
<trans-unit id="IDS_FeatureNameShadowingInNestedFunctions">
<source>name shadowing in nested functions</source>
<target state="translated">ombrage des noms dans les fonctions imbriquées</target>
...
...
src/Compilers/CSharp/Portable/xlf/CSharpResources.it.xlf
浏览文件 @
b55510b4
...
...
@@ -502,6 +502,26 @@
<target state="translated">Criterio mancante</target>
<note />
</trans-unit>
<trans-unit id="ERR_ModuleInitializerMethodAndContainingTypesMustNotBeGeneric">
<source>Module initializer method '{0}' must not be generic and must not be contained in a generic type</source>
<target state="new">Module initializer method '{0}' must not be generic and must not be contained in a generic type</target>
<note />
</trans-unit>
<trans-unit id="ERR_ModuleInitializerMethodMustBeAccessibleOutsideTopLevelType">
<source>Module initializer method '{0}' must be accessible at the module level</source>
<target state="new">Module initializer method '{0}' must be accessible at the module level</target>
<note />
</trans-unit>
<trans-unit id="ERR_ModuleInitializerMethodMustBeOrdinary">
<source>A module initializer must be an ordinary member method</source>
<target state="new">A module initializer must be an ordinary member method</target>
<note />
</trans-unit>
<trans-unit id="ERR_ModuleInitializerMethodMustBeStaticParameterlessVoid">
<source>Module initializer method '{0}' must be static, must have no parameters, and must return 'void'</source>
<target state="new">Module initializer method '{0}' must be static, must have no parameters, and must return 'void'</target>
<note />
</trans-unit>
<trans-unit id="ERR_MultipleAnalyzerConfigsInSameDir">
<source>Multiple analyzer config files cannot be in the same directory ('{0}').</source>
<target state="translated">La stessa directory ('{0}') non può contenere più file di configurazione dell'analizzatore.</target>
...
...
@@ -1291,6 +1311,11 @@
<target state="new">MemberNotNull attribute</target>
<note />
</trans-unit>
<trans-unit id="IDS_FeatureModuleInitializers">
<source>module initializers</source>
<target state="new">module initializers</target>
<note />
</trans-unit>
<trans-unit id="IDS_FeatureNameShadowingInNestedFunctions">
<source>name shadowing in nested functions</source>
<target state="translated">shadowing dei nomi nelle funzioni annidate</target>
...
...
src/Compilers/CSharp/Portable/xlf/CSharpResources.ja.xlf
浏览文件 @
b55510b4
...
...
@@ -502,6 +502,26 @@
<target state="translated">パターンがありません</target>
<note />
</trans-unit>
<trans-unit id="ERR_ModuleInitializerMethodAndContainingTypesMustNotBeGeneric">
<source>Module initializer method '{0}' must not be generic and must not be contained in a generic type</source>
<target state="new">Module initializer method '{0}' must not be generic and must not be contained in a generic type</target>
<note />
</trans-unit>
<trans-unit id="ERR_ModuleInitializerMethodMustBeAccessibleOutsideTopLevelType">
<source>Module initializer method '{0}' must be accessible at the module level</source>
<target state="new">Module initializer method '{0}' must be accessible at the module level</target>
<note />
</trans-unit>
<trans-unit id="ERR_ModuleInitializerMethodMustBeOrdinary">
<source>A module initializer must be an ordinary member method</source>
<target state="new">A module initializer must be an ordinary member method</target>
<note />
</trans-unit>
<trans-unit id="ERR_ModuleInitializerMethodMustBeStaticParameterlessVoid">
<source>Module initializer method '{0}' must be static, must have no parameters, and must return 'void'</source>
<target state="new">Module initializer method '{0}' must be static, must have no parameters, and must return 'void'</target>
<note />
</trans-unit>
<trans-unit id="ERR_MultipleAnalyzerConfigsInSameDir">
<source>Multiple analyzer config files cannot be in the same directory ('{0}').</source>
<target state="translated">複数のアナライザー構成ファイルを同じディレクトリに入れることはできません ('{0}')。</target>
...
...
@@ -1291,6 +1311,11 @@
<target state="new">MemberNotNull attribute</target>
<note />
</trans-unit>
<trans-unit id="IDS_FeatureModuleInitializers">
<source>module initializers</source>
<target state="new">module initializers</target>
<note />
</trans-unit>
<trans-unit id="IDS_FeatureNameShadowingInNestedFunctions">
<source>name shadowing in nested functions</source>
<target state="translated">入れ子になった関数での名前シャドウイング</target>
...
...
src/Compilers/CSharp/Portable/xlf/CSharpResources.ko.xlf
浏览文件 @
b55510b4
...
...
@@ -502,6 +502,26 @@
<target state="translated">패턴이 없습니다.</target>
<note />
</trans-unit>
<trans-unit id="ERR_ModuleInitializerMethodAndContainingTypesMustNotBeGeneric">
<source>Module initializer method '{0}' must not be generic and must not be contained in a generic type</source>
<target state="new">Module initializer method '{0}' must not be generic and must not be contained in a generic type</target>
<note />
</trans-unit>
<trans-unit id="ERR_ModuleInitializerMethodMustBeAccessibleOutsideTopLevelType">
<source>Module initializer method '{0}' must be accessible at the module level</source>
<target state="new">Module initializer method '{0}' must be accessible at the module level</target>
<note />
</trans-unit>
<trans-unit id="ERR_ModuleInitializerMethodMustBeOrdinary">
<source>A module initializer must be an ordinary member method</source>
<target state="new">A module initializer must be an ordinary member method</target>
<note />
</trans-unit>
<trans-unit id="ERR_ModuleInitializerMethodMustBeStaticParameterlessVoid">
<source>Module initializer method '{0}' must be static, must have no parameters, and must return 'void'</source>
<target state="new">Module initializer method '{0}' must be static, must have no parameters, and must return 'void'</target>
<note />
</trans-unit>
<trans-unit id="ERR_MultipleAnalyzerConfigsInSameDir">
<source>Multiple analyzer config files cannot be in the same directory ('{0}').</source>
<target state="translated">분석기 구성 파일 여러 개가 동일한 디렉터리('{0}')에 있을 수 없습니다.</target>
...
...
@@ -1291,6 +1311,11 @@
<target state="new">MemberNotNull attribute</target>
<note />
</trans-unit>
<trans-unit id="IDS_FeatureModuleInitializers">
<source>module initializers</source>
<target state="new">module initializers</target>
<note />
</trans-unit>
<trans-unit id="IDS_FeatureNameShadowingInNestedFunctions">
<source>name shadowing in nested functions</source>
<target state="translated">중첩된 함수의 이름 섀도잉</target>
...
...
src/Compilers/CSharp/Portable/xlf/CSharpResources.pl.xlf
浏览文件 @
b55510b4
...
...
@@ -502,6 +502,26 @@
<target state="translated">Brak wzorca</target>
<note />
</trans-unit>
<trans-unit id="ERR_ModuleInitializerMethodAndContainingTypesMustNotBeGeneric">
<source>Module initializer method '{0}' must not be generic and must not be contained in a generic type</source>
<target state="new">Module initializer method '{0}' must not be generic and must not be contained in a generic type</target>
<note />
</trans-unit>
<trans-unit id="ERR_ModuleInitializerMethodMustBeAccessibleOutsideTopLevelType">
<source>Module initializer method '{0}' must be accessible at the module level</source>
<target state="new">Module initializer method '{0}' must be accessible at the module level</target>
<note />
</trans-unit>
<trans-unit id="ERR_ModuleInitializerMethodMustBeOrdinary">
<source>A module initializer must be an ordinary member method</source>
<target state="new">A module initializer must be an ordinary member method</target>
<note />
</trans-unit>
<trans-unit id="ERR_ModuleInitializerMethodMustBeStaticParameterlessVoid">
<source>Module initializer method '{0}' must be static, must have no parameters, and must return 'void'</source>
<target state="new">Module initializer method '{0}' must be static, must have no parameters, and must return 'void'</target>
<note />
</trans-unit>
<trans-unit id="ERR_MultipleAnalyzerConfigsInSameDir">
<source>Multiple analyzer config files cannot be in the same directory ('{0}').</source>
<target state="translated">Wiele plików konfiguracji analizatora nie może znajdować się w tym samym katalogu („{0}”).</target>
...
...
@@ -1291,6 +1311,11 @@
<target state="new">MemberNotNull attribute</target>
<note />
</trans-unit>
<trans-unit id="IDS_FeatureModuleInitializers">
<source>module initializers</source>
<target state="new">module initializers</target>
<note />
</trans-unit>
<trans-unit id="IDS_FeatureNameShadowingInNestedFunctions">
<source>name shadowing in nested functions</source>
<target state="translated">zasłanianie nazw w funkcjach zagnieżdżonych</target>
...
...
src/Compilers/CSharp/Portable/xlf/CSharpResources.pt-BR.xlf
浏览文件 @
b55510b4
...
...
@@ -502,6 +502,26 @@
<target state="translated">Padrão ausente</target>
<note />
</trans-unit>
<trans-unit id="ERR_ModuleInitializerMethodAndContainingTypesMustNotBeGeneric">
<source>Module initializer method '{0}' must not be generic and must not be contained in a generic type</source>
<target state="new">Module initializer method '{0}' must not be generic and must not be contained in a generic type</target>
<note />
</trans-unit>
<trans-unit id="ERR_ModuleInitializerMethodMustBeAccessibleOutsideTopLevelType">
<source>Module initializer method '{0}' must be accessible at the module level</source>
<target state="new">Module initializer method '{0}' must be accessible at the module level</target>
<note />
</trans-unit>
<trans-unit id="ERR_ModuleInitializerMethodMustBeOrdinary">
<source>A module initializer must be an ordinary member method</source>
<target state="new">A module initializer must be an ordinary member method</target>
<note />
</trans-unit>
<trans-unit id="ERR_ModuleInitializerMethodMustBeStaticParameterlessVoid">
<source>Module initializer method '{0}' must be static, must have no parameters, and must return 'void'</source>
<target state="new">Module initializer method '{0}' must be static, must have no parameters, and must return 'void'</target>
<note />
</trans-unit>
<trans-unit id="ERR_MultipleAnalyzerConfigsInSameDir">
<source>Multiple analyzer config files cannot be in the same directory ('{0}').</source>
<target state="translated">Não é possível que haja vários arquivos de configuração do analisador no mesmo diretório ('{0}').</target>
...
...
@@ -1289,6 +1309,11 @@
<target state="new">MemberNotNull attribute</target>
<note />
</trans-unit>
<trans-unit id="IDS_FeatureModuleInitializers">
<source>module initializers</source>
<target state="new">module initializers</target>
<note />
</trans-unit>
<trans-unit id="IDS_FeatureNameShadowingInNestedFunctions">
<source>name shadowing in nested functions</source>
<target state="translated">sombreamento de nome em funções aninhadas</target>
...
...
src/Compilers/CSharp/Portable/xlf/CSharpResources.ru.xlf
浏览文件 @
b55510b4
...
...
@@ -502,6 +502,26 @@
<target state="translated">Отсутствует шаблон</target>
<note />
</trans-unit>
<trans-unit id="ERR_ModuleInitializerMethodAndContainingTypesMustNotBeGeneric">
<source>Module initializer method '{0}' must not be generic and must not be contained in a generic type</source>
<target state="new">Module initializer method '{0}' must not be generic and must not be contained in a generic type</target>
<note />
</trans-unit>
<trans-unit id="ERR_ModuleInitializerMethodMustBeAccessibleOutsideTopLevelType">
<source>Module initializer method '{0}' must be accessible at the module level</source>
<target state="new">Module initializer method '{0}' must be accessible at the module level</target>
<note />
</trans-unit>
<trans-unit id="ERR_ModuleInitializerMethodMustBeOrdinary">
<source>A module initializer must be an ordinary member method</source>
<target state="new">A module initializer must be an ordinary member method</target>
<note />
</trans-unit>
<trans-unit id="ERR_ModuleInitializerMethodMustBeStaticParameterlessVoid">
<source>Module initializer method '{0}' must be static, must have no parameters, and must return 'void'</source>
<target state="new">Module initializer method '{0}' must be static, must have no parameters, and must return 'void'</target>
<note />
</trans-unit>
<trans-unit id="ERR_MultipleAnalyzerConfigsInSameDir">
<source>Multiple analyzer config files cannot be in the same directory ('{0}').</source>
<target state="translated">В одном каталоге ("{0}") не может находиться несколько файлов конфигурации анализатора.</target>
...
...
@@ -1291,6 +1311,11 @@
<target state="new">MemberNotNull attribute</target>
<note />
</trans-unit>
<trans-unit id="IDS_FeatureModuleInitializers">
<source>module initializers</source>
<target state="new">module initializers</target>
<note />
</trans-unit>
<trans-unit id="IDS_FeatureNameShadowingInNestedFunctions">
<source>name shadowing in nested functions</source>
<target state="translated">скрытие имен во вложенных функциях</target>
...
...
src/Compilers/CSharp/Portable/xlf/CSharpResources.tr.xlf
浏览文件 @
b55510b4
...
...
@@ -502,6 +502,26 @@
<target state="translated">Desen eksik</target>
<note />
</trans-unit>
<trans-unit id="ERR_ModuleInitializerMethodAndContainingTypesMustNotBeGeneric">
<source>Module initializer method '{0}' must not be generic and must not be contained in a generic type</source>
<target state="new">Module initializer method '{0}' must not be generic and must not be contained in a generic type</target>
<note />
</trans-unit>
<trans-unit id="ERR_ModuleInitializerMethodMustBeAccessibleOutsideTopLevelType">
<source>Module initializer method '{0}' must be accessible at the module level</source>
<target state="new">Module initializer method '{0}' must be accessible at the module level</target>
<note />
</trans-unit>
<trans-unit id="ERR_ModuleInitializerMethodMustBeOrdinary">
<source>A module initializer must be an ordinary member method</source>
<target state="new">A module initializer must be an ordinary member method</target>
<note />
</trans-unit>
<trans-unit id="ERR_ModuleInitializerMethodMustBeStaticParameterlessVoid">
<source>Module initializer method '{0}' must be static, must have no parameters, and must return 'void'</source>
<target state="new">Module initializer method '{0}' must be static, must have no parameters, and must return 'void'</target>
<note />
</trans-unit>
<trans-unit id="ERR_MultipleAnalyzerConfigsInSameDir">
<source>Multiple analyzer config files cannot be in the same directory ('{0}').</source>
<target state="translated">Birden çok çözümleyici yapılandırma dosyası aynı dizinde ('{0}') olamaz.</target>
...
...
@@ -1291,6 +1311,11 @@
<target state="new">MemberNotNull attribute</target>
<note />
</trans-unit>
<trans-unit id="IDS_FeatureModuleInitializers">
<source>module initializers</source>
<target state="new">module initializers</target>
<note />
</trans-unit>
<trans-unit id="IDS_FeatureNameShadowingInNestedFunctions">
<source>name shadowing in nested functions</source>
<target state="translated">iç içe işlevlerde ad gölgeleme</target>
...
...
src/Compilers/CSharp/Portable/xlf/CSharpResources.zh-Hans.xlf
浏览文件 @
b55510b4
...
...
@@ -502,6 +502,26 @@
<target state="translated">模式缺失</target>
<note />
</trans-unit>
<trans-unit id="ERR_ModuleInitializerMethodAndContainingTypesMustNotBeGeneric">
<source>Module initializer method '{0}' must not be generic and must not be contained in a generic type</source>
<target state="new">Module initializer method '{0}' must not be generic and must not be contained in a generic type</target>
<note />
</trans-unit>
<trans-unit id="ERR_ModuleInitializerMethodMustBeAccessibleOutsideTopLevelType">
<source>Module initializer method '{0}' must be accessible at the module level</source>
<target state="new">Module initializer method '{0}' must be accessible at the module level</target>
<note />
</trans-unit>
<trans-unit id="ERR_ModuleInitializerMethodMustBeOrdinary">
<source>A module initializer must be an ordinary member method</source>
<target state="new">A module initializer must be an ordinary member method</target>
<note />
</trans-unit>
<trans-unit id="ERR_ModuleInitializerMethodMustBeStaticParameterlessVoid">
<source>Module initializer method '{0}' must be static, must have no parameters, and must return 'void'</source>
<target state="new">Module initializer method '{0}' must be static, must have no parameters, and must return 'void'</target>
<note />
</trans-unit>
<trans-unit id="ERR_MultipleAnalyzerConfigsInSameDir">
<source>Multiple analyzer config files cannot be in the same directory ('{0}').</source>
<target state="translated">多个分析器配置文件不能位于同一目录({0})中。</target>
...
...
@@ -1291,6 +1311,11 @@
<target state="new">MemberNotNull attribute</target>
<note />
</trans-unit>
<trans-unit id="IDS_FeatureModuleInitializers">
<source>module initializers</source>
<target state="new">module initializers</target>
<note />
</trans-unit>
<trans-unit id="IDS_FeatureNameShadowingInNestedFunctions">
<source>name shadowing in nested functions</source>
<target state="translated">在嵌套函数中的名称映射</target>
...
...
src/Compilers/CSharp/Portable/xlf/CSharpResources.zh-Hant.xlf
浏览文件 @
b55510b4
...
...
@@ -502,6 +502,26 @@
<target state="translated">缺少模式</target>
<note />
</trans-unit>
<trans-unit id="ERR_ModuleInitializerMethodAndContainingTypesMustNotBeGeneric">
<source>Module initializer method '{0}' must not be generic and must not be contained in a generic type</source>
<target state="new">Module initializer method '{0}' must not be generic and must not be contained in a generic type</target>
<note />
</trans-unit>
<trans-unit id="ERR_ModuleInitializerMethodMustBeAccessibleOutsideTopLevelType">
<source>Module initializer method '{0}' must be accessible at the module level</source>
<target state="new">Module initializer method '{0}' must be accessible at the module level</target>
<note />
</trans-unit>
<trans-unit id="ERR_ModuleInitializerMethodMustBeOrdinary">
<source>A module initializer must be an ordinary member method</source>
<target state="new">A module initializer must be an ordinary member method</target>
<note />
</trans-unit>
<trans-unit id="ERR_ModuleInitializerMethodMustBeStaticParameterlessVoid">
<source>Module initializer method '{0}' must be static, must have no parameters, and must return 'void'</source>
<target state="new">Module initializer method '{0}' must be static, must have no parameters, and must return 'void'</target>
<note />
</trans-unit>
<trans-unit id="ERR_MultipleAnalyzerConfigsInSameDir">
<source>Multiple analyzer config files cannot be in the same directory ('{0}').</source>
<target state="translated">多個分析器組態檔無法處於相同目錄 ('{0}') 中。</target>
...
...
@@ -1291,6 +1311,11 @@
<target state="new">MemberNotNull attribute</target>
<note />
</trans-unit>
<trans-unit id="IDS_FeatureModuleInitializers">
<source>module initializers</source>
<target state="new">module initializers</target>
<note />
</trans-unit>
<trans-unit id="IDS_FeatureNameShadowingInNestedFunctions">
<source>name shadowing in nested functions</source>
<target state="translated">巢狀函式中的名稱鏡像處理</target>
...
...
src/Compilers/CSharp/Test/Symbol/Symbols/ModuleInitializers/AccessibilityTests.cs
0 → 100644
浏览文件 @
b55510b4
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using
Microsoft.CodeAnalysis.CSharp.Test.Utilities
;
using
Microsoft.CodeAnalysis.Test.Utilities
;
using
Roslyn.Test.Utilities
;
using
Xunit
;
namespace
Microsoft.CodeAnalysis.CSharp.UnitTests.Symbols.ModuleInitializers
{
[
CompilerTrait
(
CompilerFeature
.
ModuleInitializers
)]
public
sealed
class
AccessibilityTests
:
CSharpTestBase
{
private
static
readonly
CSharpParseOptions
s_parseOptions
=
TestOptions
.
RegularPreview
;
[
Theory
]
[
InlineData
(
"private"
)]
[
InlineData
(
"protected"
)]
[
InlineData
(
"private protected"
)]
public
void
DisallowedMethodAccessibility
(
string
keywords
)
{
string
source
=
@"
using System.Runtime.CompilerServices;
class C
{
[ModuleInitializer]
"
+
keywords
+
@" static void M() { }
}
namespace System.Runtime.CompilerServices { class ModuleInitializerAttribute : System.Attribute { } }
"
;
var
compilation
=
CreateCompilation
(
source
,
parseOptions
:
s_parseOptions
);
compilation
.
VerifyEmitDiagnostics
(
// (6,6): error CS8796: Module initializer method 'M' must be accessible at the module level
// [ModuleInitializer]
Diagnostic
(
ErrorCode
.
ERR_ModuleInitializerMethodMustBeAccessibleOutsideTopLevelType
,
"ModuleInitializer"
).
WithArguments
(
"M"
).
WithLocation
(
6
,
6
)
);
}
[
Theory
]
[
InlineData
(
"public"
)]
[
InlineData
(
"internal"
)]
[
InlineData
(
"protected internal"
)]
public
void
AllowedMethodAccessibility
(
string
keywords
)
{
string
source
=
@"
using System;
using System.Runtime.CompilerServices;
class C
{
[ModuleInitializer]
"
+
keywords
+
@" static void M() => Console.WriteLine(""C.M"");
}
class Program
{
static void Main() => Console.WriteLine(""Program.Main"");
}
namespace System.Runtime.CompilerServices { class ModuleInitializerAttribute : System.Attribute { } }
"
;
CompileAndVerify
(
source
,
parseOptions
:
s_parseOptions
,
expectedOutput
:
@"
C.M
Program.Main"
);
}
[
Theory
]
[
InlineData
(
"public"
)]
[
InlineData
(
"internal"
)]
public
void
AllowedTopLevelTypeAccessibility
(
string
keywords
)
{
string
source
=
@"
using System;
using System.Runtime.CompilerServices;
"
+
keywords
+
@" class C
{
[ModuleInitializer]
public static void M() => Console.WriteLine(""C.M"");
}
class Program
{
static void Main() => Console.WriteLine(""Program.Main"");
}
namespace System.Runtime.CompilerServices { class ModuleInitializerAttribute : System.Attribute { } }
"
;
CompileAndVerify
(
source
,
parseOptions
:
s_parseOptions
,
expectedOutput
:
@"
C.M
Program.Main"
);
}
[
Theory
]
[
InlineData
(
"private"
)]
[
InlineData
(
"protected"
)]
[
InlineData
(
"private protected"
)]
public
void
DisallowedNestedTypeAccessibility
(
string
keywords
)
{
string
source
=
@"
using System.Runtime.CompilerServices;
public class C
{
"
+
keywords
+
@" class Nested
{
[ModuleInitializer]
public static void M() { }
}
}
namespace System.Runtime.CompilerServices { class ModuleInitializerAttribute : System.Attribute { } }
"
;
var
compilation
=
CreateCompilation
(
source
,
parseOptions
:
s_parseOptions
);
compilation
.
VerifyEmitDiagnostics
(
// (8,10): error CS8796: Module initializer method 'M' must be accessible at the module level
// [ModuleInitializer]
Diagnostic
(
ErrorCode
.
ERR_ModuleInitializerMethodMustBeAccessibleOutsideTopLevelType
,
"ModuleInitializer"
).
WithArguments
(
"M"
).
WithLocation
(
8
,
10
)
);
}
[
Fact
]
public
void
ModuleInitializerOnPrivatePartialMethod
()
{
string
source
=
@"
using System;
using System.Runtime.CompilerServices;
partial class C
{
[ModuleInitializer] // 1
static partial void M1();
[ModuleInitializer] // 2
static partial void M2();
static partial void M2() { }
static partial void M3();
[ModuleInitializer] // 3
static partial void M3() { }
[ModuleInitializer] // 4
static partial void M4();
[ModuleInitializer] // 5
static partial void M4() { }
}
class Program
{
}
namespace System.Runtime.CompilerServices { class ModuleInitializerAttribute : System.Attribute { } }
"
;
var
compilation
=
CreateCompilation
(
source
,
parseOptions
:
s_parseOptions
);
compilation
.
VerifyEmitDiagnostics
(
// (7,6): error CS8814: Module initializer method 'M1' must be accessible at the module level
// [ModuleInitializer] // 1
Diagnostic
(
ErrorCode
.
ERR_ModuleInitializerMethodMustBeAccessibleOutsideTopLevelType
,
"ModuleInitializer"
).
WithArguments
(
"M1"
).
WithLocation
(
7
,
6
),
// (10,6): error CS8814: Module initializer method 'M2' must be accessible at the module level
// [ModuleInitializer] // 2
Diagnostic
(
ErrorCode
.
ERR_ModuleInitializerMethodMustBeAccessibleOutsideTopLevelType
,
"ModuleInitializer"
).
WithArguments
(
"M2"
).
WithLocation
(
10
,
6
),
// (15,6): error CS8814: Module initializer method 'M3' must be accessible at the module level
// [ModuleInitializer] // 3
Diagnostic
(
ErrorCode
.
ERR_ModuleInitializerMethodMustBeAccessibleOutsideTopLevelType
,
"ModuleInitializer"
).
WithArguments
(
"M3"
).
WithLocation
(
15
,
6
),
// (18,6): error CS8814: Module initializer method 'M4' must be accessible at the module level
// [ModuleInitializer] // 4
Diagnostic
(
ErrorCode
.
ERR_ModuleInitializerMethodMustBeAccessibleOutsideTopLevelType
,
"ModuleInitializer"
).
WithArguments
(
"M4"
).
WithLocation
(
18
,
6
),
// (20,6): error CS0579: Duplicate 'ModuleInitializer' attribute
// [ModuleInitializer] // 5
Diagnostic
(
ErrorCode
.
ERR_DuplicateAttribute
,
"ModuleInitializer"
).
WithArguments
(
"ModuleInitializer"
).
WithLocation
(
20
,
6
)
);
}
[
Fact
]
public
void
ModuleInitializerOnPrivatePartialMethod_AllowMultiple
()
{
string
source
=
@"
using System;
using System.Runtime.CompilerServices;
partial class C
{
[ModuleInitializer] // 1
static partial void M1();
[ModuleInitializer] // 2
static partial void M2();
static partial void M2() { }
static partial void M3();
[ModuleInitializer] // 3
static partial void M3() { }
[ModuleInitializer] // 4
static partial void M4();
[ModuleInitializer] // 5
static partial void M4() { }
}
class Program
{
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.All, AllowMultiple = true)]
class ModuleInitializerAttribute : System.Attribute { }
}
"
;
var
compilation
=
CreateCompilation
(
source
,
parseOptions
:
s_parseOptions
);
compilation
.
VerifyEmitDiagnostics
(
// (7,6): error CS8814: Module initializer method 'M1' must be accessible at the module level
// [ModuleInitializer] // 1
Diagnostic
(
ErrorCode
.
ERR_ModuleInitializerMethodMustBeAccessibleOutsideTopLevelType
,
"ModuleInitializer"
).
WithArguments
(
"M1"
).
WithLocation
(
7
,
6
),
// (10,6): error CS8814: Module initializer method 'M2' must be accessible at the module level
// [ModuleInitializer] // 2
Diagnostic
(
ErrorCode
.
ERR_ModuleInitializerMethodMustBeAccessibleOutsideTopLevelType
,
"ModuleInitializer"
).
WithArguments
(
"M2"
).
WithLocation
(
10
,
6
),
// (15,6): error CS8814: Module initializer method 'M3' must be accessible at the module level
// [ModuleInitializer] // 3
Diagnostic
(
ErrorCode
.
ERR_ModuleInitializerMethodMustBeAccessibleOutsideTopLevelType
,
"ModuleInitializer"
).
WithArguments
(
"M3"
).
WithLocation
(
15
,
6
),
// (18,6): error CS8814: Module initializer method 'M4' must be accessible at the module level
// [ModuleInitializer] // 4
Diagnostic
(
ErrorCode
.
ERR_ModuleInitializerMethodMustBeAccessibleOutsideTopLevelType
,
"ModuleInitializer"
).
WithArguments
(
"M4"
).
WithLocation
(
18
,
6
),
// (20,6): error CS8814: Module initializer method 'M4' must be accessible at the module level
// [ModuleInitializer] // 5
Diagnostic
(
ErrorCode
.
ERR_ModuleInitializerMethodMustBeAccessibleOutsideTopLevelType
,
"ModuleInitializer"
).
WithArguments
(
"M4"
).
WithLocation
(
20
,
6
)
);
}
[
Fact
]
public
void
ModuleInitializerOnPublicPartialMethod
()
{
string
source
=
@"
using System;
using System.Runtime.CompilerServices;
partial class C
{
[ModuleInitializer]
public static partial void M1();
public static partial void M1() { Console.Write(1); }
public static partial void M2();
[ModuleInitializer]
public static partial void M2() { Console.Write(2); }
}
class Program
{
public static void Main()
{
Console.Write(3);
}
}
namespace System.Runtime.CompilerServices { class ModuleInitializerAttribute : System.Attribute { } }
"
;
CompileAndVerify
(
source
,
parseOptions
:
s_parseOptions
,
expectedOutput
:
@"123"
);
}
[
Fact
]
public
void
DuplicateModuleInitializerOnPublicPartialMethod
()
{
string
source
=
@"
using System;
using System.Runtime.CompilerServices;
partial class C
{
[ModuleInitializer]
public static partial void M1();
[ModuleInitializer] // 1
public static partial void M1() { }
}
namespace System.Runtime.CompilerServices { class ModuleInitializerAttribute : System.Attribute { } }
"
;
var
compilation
=
CreateCompilation
(
source
,
parseOptions
:
s_parseOptions
);
compilation
.
VerifyEmitDiagnostics
(
// (9,6): error CS0579: Duplicate 'ModuleInitializer' attribute
// [ModuleInitializer] // 1
Diagnostic
(
ErrorCode
.
ERR_DuplicateAttribute
,
"ModuleInitializer"
).
WithArguments
(
"ModuleInitializer"
).
WithLocation
(
9
,
6
)
);
}
[
Fact
]
public
void
DuplicateModuleInitializerOnPublicPartialMethod_AllowMultiple
()
{
string
source
=
@"
using System;
using System.Runtime.CompilerServices;
partial class C
{
[ModuleInitializer]
public static partial void M1();
[ModuleInitializer]
public static partial void M1() { Console.Write(1); }
}
class Program
{
static void Main()
{
Console.Write(2);
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.All, AllowMultiple = true)]
class ModuleInitializerAttribute : System.Attribute { }
}
"
;
CompileAndVerify
(
source
,
expectedOutput
:
"12"
,
parseOptions
:
s_parseOptions
);
}
[
Theory
]
[
InlineData
(
"public"
)]
[
InlineData
(
"internal"
)]
[
InlineData
(
"protected internal"
)]
public
void
AllowedNestedTypeAccessibility
(
string
keywords
)
{
string
source
=
@"
using System;
using System.Runtime.CompilerServices;
public class C
{
"
+
keywords
+
@" class Nested
{
[ModuleInitializer]
public static void M() => Console.WriteLine(""C.M"");
}
}
class Program
{
static void Main() => Console.WriteLine(""Program.Main"");
}
namespace System.Runtime.CompilerServices { class ModuleInitializerAttribute : System.Attribute { } }
"
;
CompileAndVerify
(
source
,
parseOptions
:
s_parseOptions
,
expectedOutput
:
@"
C.M
Program.Main"
);
}
[
Fact
]
public
void
ImplicitPublicInterfaceMethodAccessibility
()
{
string
source
=
@"
using System;
using System.Runtime.CompilerServices;
interface I
{
[ModuleInitializer]
static void M() => Console.WriteLine(""I.M"");
}
class Program
{
static void Main() => Console.WriteLine(""Program.Main"");
}
namespace System.Runtime.CompilerServices { class ModuleInitializerAttribute : System.Attribute { } }
"
;
CompileAndVerify
(
source
,
parseOptions
:
s_parseOptions
,
targetFramework
:
TargetFramework
.
NetStandardLatest
,
expectedOutput
:
ExecutionConditionUtil
.
IsMonoOrCoreClr
?
@"
I.M
Program.Main"
:
null
,
verify
:
ExecutionConditionUtil
.
IsMonoOrCoreClr
?
Verification
.
Passes
:
Verification
.
Skipped
);
}
[
Fact
]
public
void
ImplicitPublicInterfaceNestedTypeAccessibility
()
{
string
source
=
@"
using System;
using System.Runtime.CompilerServices;
interface I
{
class Nested
{
[ModuleInitializer]
internal static void M() => Console.WriteLine(""C.M"");
}
}
class Program
{
static void Main() => Console.WriteLine(""Program.Main"");
}
namespace System.Runtime.CompilerServices { class ModuleInitializerAttribute : System.Attribute { } }
"
;
CompileAndVerify
(
source
,
parseOptions
:
s_parseOptions
,
expectedOutput
:
@"
C.M
Program.Main"
);
}
}
}
src/Compilers/CSharp/Test/Symbol/Symbols/ModuleInitializers/GenericsTests.cs
0 → 100644
浏览文件 @
b55510b4
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using
Microsoft.CodeAnalysis.CSharp.Test.Utilities
;
using
Microsoft.CodeAnalysis.Test.Utilities
;
using
Xunit
;
namespace
Microsoft.CodeAnalysis.CSharp.UnitTests.Symbols.ModuleInitializers
{
[
CompilerTrait
(
CompilerFeature
.
ModuleInitializers
)]
public
sealed
class
GenericsTests
:
CSharpTestBase
{
private
static
readonly
CSharpParseOptions
s_parseOptions
=
TestOptions
.
RegularPreview
;
[
Fact
]
public
void
MustNotBeGenericMethod
()
{
string
source
=
@"
using System.Runtime.CompilerServices;
class C
{
[ModuleInitializer]
internal static void M<T>() { }
}
namespace System.Runtime.CompilerServices { class ModuleInitializerAttribute : System.Attribute { } }
"
;
var
compilation
=
CreateCompilation
(
source
,
parseOptions
:
s_parseOptions
);
compilation
.
VerifyEmitDiagnostics
(
// (6,6): error CS8798: Module initializer method 'M' must not be generic and must not be contained in a generic type
// [ModuleInitializer]
Diagnostic
(
ErrorCode
.
ERR_ModuleInitializerMethodAndContainingTypesMustNotBeGeneric
,
"ModuleInitializer"
).
WithArguments
(
"M"
).
WithLocation
(
6
,
6
)
);
}
[
Fact
]
public
void
MustNotBeContainedInGenericType
()
{
string
source
=
@"
using System.Runtime.CompilerServices;
class C<T>
{
[ModuleInitializer]
internal static void M() { }
}
namespace System.Runtime.CompilerServices { class ModuleInitializerAttribute : System.Attribute { } }
"
;
var
compilation
=
CreateCompilation
(
source
,
parseOptions
:
s_parseOptions
);
compilation
.
VerifyEmitDiagnostics
(
// (6,6): error CS8798: Module initializer method 'M' must not be generic and must not be contained in a generic type
// [ModuleInitializer]
Diagnostic
(
ErrorCode
.
ERR_ModuleInitializerMethodAndContainingTypesMustNotBeGeneric
,
"ModuleInitializer"
).
WithArguments
(
"M"
).
WithLocation
(
6
,
6
)
);
}
[
Fact
]
public
void
MustNotBeGenericAndContainedInGenericType
()
{
string
source
=
@"
using System.Runtime.CompilerServices;
class C<T>
{
[ModuleInitializer]
internal static void M<U>() { }
}
namespace System.Runtime.CompilerServices { class ModuleInitializerAttribute : System.Attribute { } }
"
;
var
compilation
=
CreateCompilation
(
source
,
parseOptions
:
s_parseOptions
);
compilation
.
VerifyEmitDiagnostics
(
// (6,6): error CS8816: Module initializer method 'M' must not be generic and must not be contained in a generic type
// [ModuleInitializer]
Diagnostic
(
ErrorCode
.
ERR_ModuleInitializerMethodAndContainingTypesMustNotBeGeneric
,
"ModuleInitializer"
).
WithArguments
(
"M"
).
WithLocation
(
6
,
6
)
);
}
[
Fact
]
public
void
MustNotBeContainedInGenericTypeWithParametersDeclaredByContainingGenericType
()
{
string
source
=
@"
using System.Runtime.CompilerServices;
class C<T>
{
internal class Nested
{
[ModuleInitializer]
internal static void M() { }
}
}
namespace System.Runtime.CompilerServices { class ModuleInitializerAttribute : System.Attribute { } }
"
;
var
compilation
=
CreateCompilation
(
source
,
parseOptions
:
s_parseOptions
);
compilation
.
VerifyEmitDiagnostics
(
// (8,10): error CS8798: Module initializer method 'M' must not be generic and must not be contained in a generic type
// [ModuleInitializer]
Diagnostic
(
ErrorCode
.
ERR_ModuleInitializerMethodAndContainingTypesMustNotBeGeneric
,
"ModuleInitializer"
).
WithArguments
(
"M"
).
WithLocation
(
8
,
10
)
);
}
}
}
src/Compilers/CSharp/Test/Symbol/Symbols/ModuleInitializers/IgnoredTests.cs
0 → 100644
浏览文件 @
b55510b4
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using
Microsoft.CodeAnalysis.CSharp.Symbols
;
using
Microsoft.CodeAnalysis.CSharp.Symbols.Metadata.PE
;
using
Microsoft.CodeAnalysis.CSharp.Test.Utilities
;
using
Microsoft.CodeAnalysis.Test.Utilities
;
using
Xunit
;
namespace
Microsoft.CodeAnalysis.CSharp.UnitTests.Symbols.ModuleInitializers
{
[
CompilerTrait
(
CompilerFeature
.
ModuleInitializers
)]
public
sealed
class
IgnoredTests
:
CSharpTestBase
{
[
Fact
]
public
void
IgnoredOnReturnValue
()
{
string
source
=
@"
using System.Runtime.CompilerServices;
class C
{
[return: ModuleInitializer]
internal static void M()
{
}
}
namespace System.Runtime.CompilerServices { class ModuleInitializerAttribute : System.Attribute { } }
"
;
CompileAndVerify
(
source
,
options
:
TestOptions
.
DebugDll
.
WithMetadataImportOptions
(
MetadataImportOptions
.
All
),
symbolValidator
:
module
=>
{
Assert
.
Equal
(
MetadataImportOptions
.
All
,
((
PEModuleSymbol
)
module
).
ImportOptions
);
var
rootModuleType
=
(
TypeSymbol
)
module
.
GlobalNamespace
.
GetMember
(
"<Module>"
);
Assert
.
Null
(
rootModuleType
.
GetMember
(
".cctor"
));
});
}
[
Fact
]
public
void
IgnoredOnMethodParameter
()
{
string
source
=
@"
using System.Runtime.CompilerServices;
class C
{
internal static void M([ModuleInitializer] int p)
{
}
}
namespace System.Runtime.CompilerServices { class ModuleInitializerAttribute : System.Attribute { } }
"
;
CompileAndVerify
(
source
,
options
:
TestOptions
.
DebugDll
.
WithMetadataImportOptions
(
MetadataImportOptions
.
All
),
symbolValidator
:
module
=>
{
Assert
.
Equal
(
MetadataImportOptions
.
All
,
((
PEModuleSymbol
)
module
).
ImportOptions
);
var
rootModuleType
=
(
TypeSymbol
)
module
.
GlobalNamespace
.
GetMember
(
"<Module>"
);
Assert
.
Null
(
rootModuleType
.
GetMember
(
".cctor"
));
});
}
[
Fact
]
public
void
IgnoredOnGenericParameter
()
{
string
source
=
@"
using System.Runtime.CompilerServices;
class C
{
internal static void M<[ModuleInitializer] T>()
{
}
}
namespace System.Runtime.CompilerServices { class ModuleInitializerAttribute : System.Attribute { } }
"
;
CompileAndVerify
(
source
,
options
:
TestOptions
.
DebugDll
.
WithMetadataImportOptions
(
MetadataImportOptions
.
All
),
symbolValidator
:
module
=>
{
Assert
.
Equal
(
MetadataImportOptions
.
All
,
((
PEModuleSymbol
)
module
).
ImportOptions
);
var
rootModuleType
=
(
TypeSymbol
)
module
.
GlobalNamespace
.
GetMember
(
"<Module>"
);
Assert
.
Null
(
rootModuleType
.
GetMember
(
".cctor"
));
});
}
[
Fact
]
public
void
IgnoredOnClass
()
{
string
source
=
@"
using System.Runtime.CompilerServices;
[ModuleInitializer]
class C
{
internal static void M() { }
}
namespace System.Runtime.CompilerServices { class ModuleInitializerAttribute : System.Attribute { } }
"
;
CompileAndVerify
(
source
,
options
:
TestOptions
.
DebugDll
.
WithMetadataImportOptions
(
MetadataImportOptions
.
All
),
symbolValidator
:
module
=>
{
Assert
.
Equal
(
MetadataImportOptions
.
All
,
((
PEModuleSymbol
)
module
).
ImportOptions
);
var
rootModuleType
=
(
TypeSymbol
)
module
.
GlobalNamespace
.
GetMember
(
"<Module>"
);
Assert
.
Null
(
rootModuleType
.
GetMember
(
".cctor"
));
});
}
[
Fact
]
public
void
IgnoredOnEvent
()
{
string
source
=
@"
using System.Runtime.CompilerServices;
class C
{
[ModuleInitializer]
public event System.Action E;
}
namespace System.Runtime.CompilerServices { class ModuleInitializerAttribute : System.Attribute { } }
"
;
CompileAndVerify
(
source
,
options
:
TestOptions
.
DebugDll
.
WithMetadataImportOptions
(
MetadataImportOptions
.
All
),
symbolValidator
:
module
=>
{
Assert
.
Equal
(
MetadataImportOptions
.
All
,
((
PEModuleSymbol
)
module
).
ImportOptions
);
var
rootModuleType
=
(
TypeSymbol
)
module
.
GlobalNamespace
.
GetMember
(
"<Module>"
);
Assert
.
Null
(
rootModuleType
.
GetMember
(
".cctor"
));
});
}
[
Fact
]
public
void
IgnoredOnProperty
()
{
string
source
=
@"
using System.Runtime.CompilerServices;
class C
{
[ModuleInitializer]
public int P { get; set; }
}
namespace System.Runtime.CompilerServices { class ModuleInitializerAttribute : System.Attribute { } }
"
;
CompileAndVerify
(
source
,
options
:
TestOptions
.
DebugDll
.
WithMetadataImportOptions
(
MetadataImportOptions
.
All
),
symbolValidator
:
module
=>
{
Assert
.
Equal
(
MetadataImportOptions
.
All
,
((
PEModuleSymbol
)
module
).
ImportOptions
);
var
rootModuleType
=
(
TypeSymbol
)
module
.
GlobalNamespace
.
GetMember
(
"<Module>"
);
Assert
.
Null
(
rootModuleType
.
GetMember
(
".cctor"
));
});
}
[
Fact
]
public
void
IgnoredOnIndexer
()
{
string
source
=
@"
using System.Runtime.CompilerServices;
class C
{
[ModuleInitializer]
public int this[int p] => p;
}
namespace System.Runtime.CompilerServices { class ModuleInitializerAttribute : System.Attribute { } }
"
;
CompileAndVerify
(
source
,
options
:
TestOptions
.
DebugDll
.
WithMetadataImportOptions
(
MetadataImportOptions
.
All
),
symbolValidator
:
module
=>
{
Assert
.
Equal
(
MetadataImportOptions
.
All
,
((
PEModuleSymbol
)
module
).
ImportOptions
);
var
rootModuleType
=
(
TypeSymbol
)
module
.
GlobalNamespace
.
GetMember
(
"<Module>"
);
Assert
.
Null
(
rootModuleType
.
GetMember
(
".cctor"
));
});
}
[
Fact
]
public
void
IgnoredOnField
()
{
string
source
=
@"
using System.Runtime.CompilerServices;
class C
{
[ModuleInitializer]
public int F;
}
namespace System.Runtime.CompilerServices { class ModuleInitializerAttribute : System.Attribute { } }
"
;
CompileAndVerify
(
source
,
options
:
TestOptions
.
DebugDll
.
WithMetadataImportOptions
(
MetadataImportOptions
.
All
),
symbolValidator
:
module
=>
{
Assert
.
Equal
(
MetadataImportOptions
.
All
,
((
PEModuleSymbol
)
module
).
ImportOptions
);
var
rootModuleType
=
(
TypeSymbol
)
module
.
GlobalNamespace
.
GetMember
(
"<Module>"
);
Assert
.
Null
(
rootModuleType
.
GetMember
(
".cctor"
));
});
}
[
Fact
]
public
void
IgnoredOnModule
()
{
string
source
=
@"
using System.Runtime.CompilerServices;
[module: ModuleInitializer]
namespace System.Runtime.CompilerServices { class ModuleInitializerAttribute : System.Attribute { } }
"
;
CompileAndVerify
(
source
,
options
:
TestOptions
.
DebugDll
.
WithMetadataImportOptions
(
MetadataImportOptions
.
All
),
symbolValidator
:
module
=>
{
Assert
.
Equal
(
MetadataImportOptions
.
All
,
((
PEModuleSymbol
)
module
).
ImportOptions
);
var
rootModuleType
=
(
TypeSymbol
)
module
.
GlobalNamespace
.
GetMember
(
"<Module>"
);
Assert
.
Null
(
rootModuleType
.
GetMember
(
".cctor"
));
});
}
[
Fact
]
public
void
IgnoredOnAssembly
()
{
string
source
=
@"
using System.Runtime.CompilerServices;
[assembly: ModuleInitializer]
namespace System.Runtime.CompilerServices { class ModuleInitializerAttribute : System.Attribute { } }
"
;
CompileAndVerify
(
source
,
options
:
TestOptions
.
DebugDll
.
WithMetadataImportOptions
(
MetadataImportOptions
.
All
),
symbolValidator
:
module
=>
{
Assert
.
Equal
(
MetadataImportOptions
.
All
,
((
PEModuleSymbol
)
module
).
ImportOptions
);
var
rootModuleType
=
(
TypeSymbol
)
module
.
GlobalNamespace
.
GetMember
(
"<Module>"
);
Assert
.
Null
(
rootModuleType
.
GetMember
(
".cctor"
));
});
}
[
Fact
]
public
void
IgnoredWhenConstructorArgumentIsSpecified
()
{
string
source
=
@"
using System.Runtime.CompilerServices;
class C
{
[ModuleInitializer(42)]
internal static void M()
{
}
}
namespace System.Runtime.CompilerServices
{
class ModuleInitializerAttribute : System.Attribute
{
public ModuleInitializerAttribute(int p) { }
}
}
"
;
CompileAndVerify
(
source
,
options
:
TestOptions
.
DebugDll
.
WithMetadataImportOptions
(
MetadataImportOptions
.
All
),
symbolValidator
:
module
=>
{
Assert
.
Equal
(
MetadataImportOptions
.
All
,
((
PEModuleSymbol
)
module
).
ImportOptions
);
var
rootModuleType
=
(
TypeSymbol
)
module
.
GlobalNamespace
.
GetMember
(
"<Module>"
);
Assert
.
Null
(
rootModuleType
.
GetMember
(
".cctor"
));
});
}
}
}
src/Compilers/CSharp/Test/Symbol/Symbols/ModuleInitializers/ModuleInitializersTests.cs
0 → 100644
浏览文件 @
b55510b4
此差异已折叠。
点击以展开。
src/Compilers/CSharp/Test/Symbol/Symbols/ModuleInitializers/SignatureTests.cs
0 → 100644
浏览文件 @
b55510b4
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using
Microsoft.CodeAnalysis.CSharp.Test.Utilities
;
using
Microsoft.CodeAnalysis.Test.Utilities
;
using
Roslyn.Test.Utilities
;
using
Xunit
;
namespace
Microsoft.CodeAnalysis.CSharp.UnitTests.Symbols.ModuleInitializers
{
[
CompilerTrait
(
CompilerFeature
.
ModuleInitializers
)]
public
sealed
class
SignatureTests
:
CSharpTestBase
{
private
static
readonly
CSharpParseOptions
s_parseOptions
=
TestOptions
.
RegularPreview
;
[
Fact
]
public
void
MustNotBeInstanceMethod
()
{
string
source
=
@"
using System.Runtime.CompilerServices;
class C
{
[ModuleInitializer]
internal void M() { }
}
namespace System.Runtime.CompilerServices { class ModuleInitializerAttribute : System.Attribute { } }
"
;
var
compilation
=
CreateCompilation
(
source
,
parseOptions
:
s_parseOptions
);
compilation
.
VerifyEmitDiagnostics
(
// (6,6): error CS8815: Module initializer method 'M' must be static, must have no parameters, and must return 'void'
// [ModuleInitializer]
Diagnostic
(
ErrorCode
.
ERR_ModuleInitializerMethodMustBeStaticParameterlessVoid
,
"ModuleInitializer"
).
WithArguments
(
"M"
).
WithLocation
(
6
,
6
)
);
}
[
Fact
]
public
void
MustNotBeInstanceMethodInInterface
()
{
string
source
=
@"
using System.Runtime.CompilerServices;
interface i
{
[ModuleInitializer]
internal void M1();
[ModuleInitializer]
internal void M2() { }
}
namespace System.Runtime.CompilerServices { class ModuleInitializerAttribute : System.Attribute { } }
"
;
var
compilation
=
CreateCompilation
(
source
,
parseOptions
:
s_parseOptions
,
targetFramework
:
TargetFramework
.
NetStandardLatest
);
compilation
.
VerifyEmitDiagnostics
(
// (6,6): error CS8815: Module initializer method 'M1' must be static, must have no parameters, and must return 'void'
// [ModuleInitializer]
Diagnostic
(
ErrorCode
.
ERR_ModuleInitializerMethodMustBeStaticParameterlessVoid
,
"ModuleInitializer"
).
WithArguments
(
"M1"
).
WithLocation
(
6
,
6
),
// (9,6): error CS8815: Module initializer method 'M2' must be static, must have no parameters, and must return 'void'
// [ModuleInitializer]
Diagnostic
(
ErrorCode
.
ERR_ModuleInitializerMethodMustBeStaticParameterlessVoid
,
"ModuleInitializer"
).
WithArguments
(
"M2"
).
WithLocation
(
9
,
6
)
);
}
[
Fact
]
public
void
MustNotHaveParameters
()
{
string
source
=
@"
using System.Runtime.CompilerServices;
static class C
{
[ModuleInitializer]
internal static void M(object p) { }
}
namespace System.Runtime.CompilerServices { class ModuleInitializerAttribute : System.Attribute { } }
"
;
var
compilation
=
CreateCompilation
(
source
,
parseOptions
:
s_parseOptions
);
compilation
.
VerifyEmitDiagnostics
(
// (6,6): error CS8815: Module initializer method 'M' must be static, must have no parameters, and must return 'void'
// [ModuleInitializer]
Diagnostic
(
ErrorCode
.
ERR_ModuleInitializerMethodMustBeStaticParameterlessVoid
,
"ModuleInitializer"
).
WithArguments
(
"M"
).
WithLocation
(
6
,
6
)
);
}
[
Fact
]
public
void
MustNotHaveOptionalParameters
()
{
string
source
=
@"
using System.Runtime.CompilerServices;
static class C
{
[ModuleInitializer]
internal static void M(object p = null) { }
}
namespace System.Runtime.CompilerServices { class ModuleInitializerAttribute : System.Attribute { } }
"
;
var
compilation
=
CreateCompilation
(
source
,
parseOptions
:
s_parseOptions
);
compilation
.
VerifyEmitDiagnostics
(
// (6,6): error CS8815: Module initializer method 'M' must be static, must have no parameters, and must return 'void'
// [ModuleInitializer]
Diagnostic
(
ErrorCode
.
ERR_ModuleInitializerMethodMustBeStaticParameterlessVoid
,
"ModuleInitializer"
).
WithArguments
(
"M"
).
WithLocation
(
6
,
6
)
);
}
[
Fact
]
public
void
MustNotHaveParamsArrayParameters
()
{
string
source
=
@"
using System.Runtime.CompilerServices;
static class C
{
[ModuleInitializer]
internal static void M(params object[] p) { }
}
namespace System.Runtime.CompilerServices { class ModuleInitializerAttribute : System.Attribute { } }
"
;
var
compilation
=
CreateCompilation
(
source
,
parseOptions
:
s_parseOptions
);
compilation
.
VerifyEmitDiagnostics
(
// (6,6): error CS8815: Module initializer method 'M' must be static, must have no parameters, and must return 'void'
// [ModuleInitializer]
Diagnostic
(
ErrorCode
.
ERR_ModuleInitializerMethodMustBeStaticParameterlessVoid
,
"ModuleInitializer"
).
WithArguments
(
"M"
).
WithLocation
(
6
,
6
)
);
}
[
Fact
]
public
void
MustNotReturnAValue
()
{
string
source
=
@"
using System.Runtime.CompilerServices;
static class C
{
[ModuleInitializer]
internal static object M() => null;
}
namespace System.Runtime.CompilerServices { class ModuleInitializerAttribute : System.Attribute { } }
"
;
var
compilation
=
CreateCompilation
(
source
,
parseOptions
:
s_parseOptions
);
compilation
.
VerifyEmitDiagnostics
(
// (6,6): error CS8815: Module initializer method 'M' must be static, must have no parameters, and must return 'void'
// [ModuleInitializer]
Diagnostic
(
ErrorCode
.
ERR_ModuleInitializerMethodMustBeStaticParameterlessVoid
,
"ModuleInitializer"
).
WithArguments
(
"M"
).
WithLocation
(
6
,
6
)
);
}
[
Fact
]
public
void
MayBeAsyncVoid
()
{
string
source
=
@"
using System;
using System.Runtime.CompilerServices;
static class C
{
[ModuleInitializer]
internal static async void M() => Console.WriteLine(""C.M"");
}
class Program
{
static void Main() => Console.WriteLine(""Program.Main"");
}
namespace System.Runtime.CompilerServices { class ModuleInitializerAttribute : System.Attribute { } }
"
;
CompileAndVerify
(
source
,
parseOptions
:
s_parseOptions
,
expectedOutput
:
@"
C.M
Program.Main"
);
}
[
Fact
]
public
void
MayNotReturnAwaitableWithVoidResult
()
{
string
source
=
@"
using System.Runtime.CompilerServices;
using System.Threading.Tasks;
static class C
{
[ModuleInitializer]
internal static async Task M() { }
}
namespace System.Runtime.CompilerServices { class ModuleInitializerAttribute : System.Attribute { } }
"
;
var
compilation
=
CreateCompilation
(
source
,
parseOptions
:
s_parseOptions
);
compilation
.
VerifyEmitDiagnostics
(
// (6,6): error CS8815: Module initializer method 'M' must be static, must have no parameters, and must return 'void'
// [ModuleInitializer]
Diagnostic
(
ErrorCode
.
ERR_ModuleInitializerMethodMustBeStaticParameterlessVoid
,
"ModuleInitializer"
).
WithArguments
(
"M"
).
WithLocation
(
7
,
6
),
// (8,32): warning CS1998: This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.
// internal static async Task M() { }
Diagnostic
(
ErrorCode
.
WRN_AsyncLacksAwaits
,
"M"
).
WithLocation
(
8
,
32
));
}
}
}
src/Compilers/CSharp/Test/Symbol/Symbols/ModuleInitializers/TargetsTests.cs
0 → 100644
浏览文件 @
b55510b4
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using
Microsoft.CodeAnalysis.CSharp.Test.Utilities
;
using
Microsoft.CodeAnalysis.Test.Utilities
;
using
Xunit
;
namespace
Microsoft.CodeAnalysis.CSharp.UnitTests.Symbols.ModuleInitializers
{
[
CompilerTrait
(
CompilerFeature
.
ModuleInitializers
)]
public
sealed
class
TargetsTests
:
CSharpTestBase
{
private
static
readonly
CSharpParseOptions
s_parseOptions
=
TestOptions
.
RegularPreview
;
[
Fact
]
public
void
TargetMustNotBeLocalFunction
()
{
string
source
=
@"
using System.Runtime.CompilerServices;
class C
{
internal static void M()
{
LocalFunction();
[ModuleInitializer]
static void LocalFunction() { }
}
}
namespace System.Runtime.CompilerServices { class ModuleInitializerAttribute : System.Attribute { } }
"
;
var
compilation
=
CreateCompilation
(
source
,
parseOptions
:
s_parseOptions
);
compilation
.
VerifyEmitDiagnostics
(
// (9,10): error CS8795: A module initializer must be an ordinary member method
// [ModuleInitializer]
Diagnostic
(
ErrorCode
.
ERR_ModuleInitializerMethodMustBeOrdinary
,
"ModuleInitializer"
).
WithLocation
(
9
,
10
)
);
}
[
Fact
]
public
void
IgnoredOnLocalFunctionWithBadAttributeTargets
()
{
string
source
=
@"
using System;
using System.Runtime.CompilerServices;
class C
{
internal static void M()
{
LocalFunction();
[ModuleInitializer]
static void LocalFunction() { }
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Class)]
class ModuleInitializerAttribute : System.Attribute { }
}
"
;
var
compilation
=
CreateCompilation
(
source
,
parseOptions
:
s_parseOptions
);
compilation
.
VerifyEmitDiagnostics
(
// (10,10): error CS0592: Attribute 'ModuleInitializer' is not valid on this declaration type. It is only valid on 'class' declarations.
// [ModuleInitializer]
Diagnostic
(
ErrorCode
.
ERR_AttributeOnBadSymbolType
,
"ModuleInitializer"
).
WithArguments
(
"ModuleInitializer"
,
"class"
).
WithLocation
(
10
,
10
)
);
}
[
Fact
]
public
void
TargetMustNotBeDestructor
()
{
string
source
=
@"
using System.Runtime.CompilerServices;
class C
{
[ModuleInitializer]
~C() { }
}
namespace System.Runtime.CompilerServices { class ModuleInitializerAttribute : System.Attribute { } }
"
;
var
compilation
=
CreateCompilation
(
source
,
parseOptions
:
s_parseOptions
);
compilation
.
VerifyEmitDiagnostics
(
// (6,6): error CS8795: A module initializer must be an ordinary member method
// [ModuleInitializer]
Diagnostic
(
ErrorCode
.
ERR_ModuleInitializerMethodMustBeOrdinary
,
"ModuleInitializer"
).
WithLocation
(
6
,
6
)
);
}
[
Fact
]
public
void
IgnoredOnDestructorWithBadAttributeTargets
()
{
string
source
=
@"
using System;
using System.Runtime.CompilerServices;
class C
{
[ModuleInitializer]
~C() { }
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Class)]
class ModuleInitializerAttribute : System.Attribute { }
}
"
;
var
compilation
=
CreateCompilation
(
source
,
parseOptions
:
s_parseOptions
);
compilation
.
VerifyEmitDiagnostics
(
// (7,6): error CS0592: Attribute 'ModuleInitializer' is not valid on this declaration type. It is only valid on 'class' declarations.
// [ModuleInitializer]
Diagnostic
(
ErrorCode
.
ERR_AttributeOnBadSymbolType
,
"ModuleInitializer"
).
WithArguments
(
"ModuleInitializer"
,
"class"
).
WithLocation
(
7
,
6
)
);
}
[
Fact
]
public
void
TargetMustNotBeOperator
()
{
string
source
=
@"
using System.Runtime.CompilerServices;
class C
{
[ModuleInitializer]
public static C operator -(C p) => p;
}
namespace System.Runtime.CompilerServices { class ModuleInitializerAttribute : System.Attribute { } }
"
;
var
compilation
=
CreateCompilation
(
source
,
parseOptions
:
s_parseOptions
);
compilation
.
VerifyEmitDiagnostics
(
// (6,6): error CS8795: A module initializer must be an ordinary member method
// [ModuleInitializer]
Diagnostic
(
ErrorCode
.
ERR_ModuleInitializerMethodMustBeOrdinary
,
"ModuleInitializer"
).
WithLocation
(
6
,
6
)
);
}
[
Fact
]
public
void
IgnoredOnOperatorWithBadAttributeTargets
()
{
string
source
=
@"
using System;
using System.Runtime.CompilerServices;
class C
{
[ModuleInitializer]
public static C operator -(C p) => p;
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Class)]
class ModuleInitializerAttribute : System.Attribute { }
}
"
;
var
compilation
=
CreateCompilation
(
source
,
parseOptions
:
s_parseOptions
);
compilation
.
VerifyEmitDiagnostics
(
// (7,6): error CS0592: Attribute 'ModuleInitializer' is not valid on this declaration type. It is only valid on 'class' declarations.
// [ModuleInitializer]
Diagnostic
(
ErrorCode
.
ERR_AttributeOnBadSymbolType
,
"ModuleInitializer"
).
WithArguments
(
"ModuleInitializer"
,
"class"
).
WithLocation
(
7
,
6
)
);
}
[
Fact
]
public
void
TargetMustNotBeConversionOperator
()
{
string
source
=
@"
using System.Runtime.CompilerServices;
class C
{
[ModuleInitializer]
public static explicit operator int(C p) => default;
}
namespace System.Runtime.CompilerServices { class ModuleInitializerAttribute : System.Attribute { } }
"
;
var
compilation
=
CreateCompilation
(
source
,
parseOptions
:
s_parseOptions
);
compilation
.
VerifyEmitDiagnostics
(
// (6,6): error CS8795: A module initializer must be an ordinary member method
// [ModuleInitializer]
Diagnostic
(
ErrorCode
.
ERR_ModuleInitializerMethodMustBeOrdinary
,
"ModuleInitializer"
).
WithLocation
(
6
,
6
)
);
}
[
Fact
]
public
void
IgnoredOnConversionOperatorWithBadAttributeTargets
()
{
string
source
=
@"
using System;
using System.Runtime.CompilerServices;
class C
{
[ModuleInitializer]
public static explicit operator int(C p) => default;
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Class)]
class ModuleInitializerAttribute : System.Attribute { }
}
"
;
var
compilation
=
CreateCompilation
(
source
,
parseOptions
:
s_parseOptions
);
compilation
.
VerifyEmitDiagnostics
(
// (7,6): error CS0592: Attribute 'ModuleInitializer' is not valid on this declaration type. It is only valid on 'class' declarations.
// [ModuleInitializer]
Diagnostic
(
ErrorCode
.
ERR_AttributeOnBadSymbolType
,
"ModuleInitializer"
).
WithArguments
(
"ModuleInitializer"
,
"class"
).
WithLocation
(
7
,
6
)
);
}
[
Fact
]
public
void
TargetMustNotBeEventAccessor
()
{
string
source
=
@"
using System.Runtime.CompilerServices;
class C
{
public event System.Action E
{
[ModuleInitializer]
add { }
[ModuleInitializer]
remove { }
}
}
namespace System.Runtime.CompilerServices { class ModuleInitializerAttribute : System.Attribute { } }
"
;
var
compilation
=
CreateCompilation
(
source
,
parseOptions
:
s_parseOptions
);
compilation
.
VerifyEmitDiagnostics
(
// (8,10): error CS8795: A module initializer must be an ordinary member method
// [ModuleInitializer]
Diagnostic
(
ErrorCode
.
ERR_ModuleInitializerMethodMustBeOrdinary
,
"ModuleInitializer"
).
WithLocation
(
8
,
10
),
// (10,10): error CS8795: A module initializer must be an ordinary member method
// [ModuleInitializer]
Diagnostic
(
ErrorCode
.
ERR_ModuleInitializerMethodMustBeOrdinary
,
"ModuleInitializer"
).
WithLocation
(
10
,
10
)
);
}
[
Fact
]
public
void
IgnoredOnEventAccessorsWithBadAttributeTargets
()
{
string
source
=
@"
using System;
using System.Runtime.CompilerServices;
class C
{
public event System.Action E
{
[ModuleInitializer]
add { }
[ModuleInitializer]
remove { }
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Class)]
class ModuleInitializerAttribute : System.Attribute { }
}
"
;
var
compilation
=
CreateCompilation
(
source
,
parseOptions
:
s_parseOptions
);
compilation
.
VerifyEmitDiagnostics
(
// (9,10): error CS0592: Attribute 'ModuleInitializer' is not valid on this declaration type. It is only valid on 'class' declarations.
// [ModuleInitializer]
Diagnostic
(
ErrorCode
.
ERR_AttributeOnBadSymbolType
,
"ModuleInitializer"
).
WithArguments
(
"ModuleInitializer"
,
"class"
).
WithLocation
(
9
,
10
),
// (11,10): error CS0592: Attribute 'ModuleInitializer' is not valid on this declaration type. It is only valid on 'class' declarations.
// [ModuleInitializer]
Diagnostic
(
ErrorCode
.
ERR_AttributeOnBadSymbolType
,
"ModuleInitializer"
).
WithArguments
(
"ModuleInitializer"
,
"class"
).
WithLocation
(
11
,
10
)
);
}
[
Fact
]
public
void
TargetMustNotBePropertyAccessor
()
{
string
source
=
@"
using System.Runtime.CompilerServices;
class C
{
public int P
{
[ModuleInitializer]
get;
[ModuleInitializer]
set;
}
}
namespace System.Runtime.CompilerServices { class ModuleInitializerAttribute : System.Attribute { } }
"
;
var
compilation
=
CreateCompilation
(
source
,
parseOptions
:
s_parseOptions
);
compilation
.
VerifyEmitDiagnostics
(
// (8,10): error CS8795: A module initializer must be an ordinary member method
// [ModuleInitializer]
Diagnostic
(
ErrorCode
.
ERR_ModuleInitializerMethodMustBeOrdinary
,
"ModuleInitializer"
).
WithLocation
(
8
,
10
),
// (10,10): error CS8795: A module initializer must be an ordinary member method
// [ModuleInitializer]
Diagnostic
(
ErrorCode
.
ERR_ModuleInitializerMethodMustBeOrdinary
,
"ModuleInitializer"
).
WithLocation
(
10
,
10
)
);
}
[
Fact
]
public
void
IgnoredOnPropertyAccessorsWithBadAttributeTargets
()
{
string
source
=
@"
using System;
using System.Runtime.CompilerServices;
class C
{
public int P
{
[ModuleInitializer]
get;
[ModuleInitializer]
set;
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Class)]
class ModuleInitializerAttribute : System.Attribute { }
}
"
;
var
compilation
=
CreateCompilation
(
source
,
parseOptions
:
s_parseOptions
);
compilation
.
VerifyEmitDiagnostics
(
// (9,10): error CS0592: Attribute 'ModuleInitializer' is not valid on this declaration type. It is only valid on 'class' declarations.
// [ModuleInitializer]
Diagnostic
(
ErrorCode
.
ERR_AttributeOnBadSymbolType
,
"ModuleInitializer"
).
WithArguments
(
"ModuleInitializer"
,
"class"
).
WithLocation
(
9
,
10
),
// (11,10): error CS0592: Attribute 'ModuleInitializer' is not valid on this declaration type. It is only valid on 'class' declarations.
// [ModuleInitializer]
Diagnostic
(
ErrorCode
.
ERR_AttributeOnBadSymbolType
,
"ModuleInitializer"
).
WithArguments
(
"ModuleInitializer"
,
"class"
).
WithLocation
(
11
,
10
)
);
}
[
Fact
]
public
void
TargetMustNotBeIndexerAccessor
()
{
string
source
=
@"
using System.Runtime.CompilerServices;
class C
{
public int this[int p]
{
[ModuleInitializer]
get => p;
[ModuleInitializer]
set { }
}
}
namespace System.Runtime.CompilerServices { class ModuleInitializerAttribute : System.Attribute { } }
"
;
var
compilation
=
CreateCompilation
(
source
,
parseOptions
:
s_parseOptions
);
compilation
.
VerifyEmitDiagnostics
(
// (8,10): error CS8795: A module initializer must be an ordinary member method
// [ModuleInitializer]
Diagnostic
(
ErrorCode
.
ERR_ModuleInitializerMethodMustBeOrdinary
,
"ModuleInitializer"
).
WithLocation
(
8
,
10
),
// (10,10): error CS8795: A module initializer must be an ordinary member method
// [ModuleInitializer]
Diagnostic
(
ErrorCode
.
ERR_ModuleInitializerMethodMustBeOrdinary
,
"ModuleInitializer"
).
WithLocation
(
10
,
10
)
);
}
[
Fact
]
public
void
IgnoredOnIndexerAccessorsWithBadAttributeTargets
()
{
string
source
=
@"
using System;
using System.Runtime.CompilerServices;
class C
{
public int this[int p]
{
[ModuleInitializer]
get => p;
[ModuleInitializer]
set { }
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Class)]
class ModuleInitializerAttribute : System.Attribute { }
}
"
;
var
compilation
=
CreateCompilation
(
source
,
parseOptions
:
s_parseOptions
);
compilation
.
VerifyEmitDiagnostics
(
// (9,10): error CS0592: Attribute 'ModuleInitializer' is not valid on this declaration type. It is only valid on 'class' declarations.
// [ModuleInitializer]
Diagnostic
(
ErrorCode
.
ERR_AttributeOnBadSymbolType
,
"ModuleInitializer"
).
WithArguments
(
"ModuleInitializer"
,
"class"
).
WithLocation
(
9
,
10
),
// (11,10): error CS0592: Attribute 'ModuleInitializer' is not valid on this declaration type. It is only valid on 'class' declarations.
// [ModuleInitializer]
Diagnostic
(
ErrorCode
.
ERR_AttributeOnBadSymbolType
,
"ModuleInitializer"
).
WithArguments
(
"ModuleInitializer"
,
"class"
).
WithLocation
(
11
,
10
)
);
}
[
Fact
]
public
void
TargetMustNotBeStaticConstructor
()
{
string
source
=
@"
using System.Runtime.CompilerServices;
class C
{
[ModuleInitializer]
static C() { }
}
namespace System.Runtime.CompilerServices { class ModuleInitializerAttribute : System.Attribute { } }
"
;
var
compilation
=
CreateCompilation
(
source
,
parseOptions
:
s_parseOptions
);
compilation
.
VerifyEmitDiagnostics
(
// (6,6): error CS8795: A module initializer must be an ordinary member method
// [ModuleInitializer]
Diagnostic
(
ErrorCode
.
ERR_ModuleInitializerMethodMustBeOrdinary
,
"ModuleInitializer"
).
WithLocation
(
6
,
6
)
);
}
[
Fact
]
public
void
IgnoredOnStaticConstructorWithBadAttributeTargets
()
{
string
source
=
@"
using System;
using System.Runtime.CompilerServices;
class C
{
[ModuleInitializer]
static C() { }
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Method)]
class ModuleInitializerAttribute : System.Attribute { }
}
"
;
var
compilation
=
CreateCompilation
(
source
,
parseOptions
:
s_parseOptions
);
compilation
.
VerifyEmitDiagnostics
(
// (7,6): error CS0592: Attribute 'ModuleInitializer' is not valid on this declaration type. It is only valid on 'method' declarations.
// [ModuleInitializer]
Diagnostic
(
ErrorCode
.
ERR_AttributeOnBadSymbolType
,
"ModuleInitializer"
).
WithArguments
(
"ModuleInitializer"
,
"method"
).
WithLocation
(
7
,
6
)
);
}
[
Fact
]
public
void
TargetMustNotBeInstanceConstructor
()
{
string
source
=
@"
using System.Runtime.CompilerServices;
class C
{
[ModuleInitializer]
public C() { }
}
namespace System.Runtime.CompilerServices { class ModuleInitializerAttribute : System.Attribute { } }
"
;
var
compilation
=
CreateCompilation
(
source
,
parseOptions
:
s_parseOptions
);
compilation
.
VerifyEmitDiagnostics
(
// (6,6): error CS8795: A module initializer must be an ordinary member method
// [ModuleInitializer]
Diagnostic
(
ErrorCode
.
ERR_ModuleInitializerMethodMustBeOrdinary
,
"ModuleInitializer"
).
WithLocation
(
6
,
6
)
);
}
[
Fact
]
public
void
IgnoredOnInstanceConstructorWithBadAttributeTargets
()
{
string
source
=
@"
using System;
using System.Runtime.CompilerServices;
class C
{
[ModuleInitializer]
public C() { }
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Method)]
class ModuleInitializerAttribute : System.Attribute { }
}
"
;
var
compilation
=
CreateCompilation
(
source
,
parseOptions
:
s_parseOptions
);
compilation
.
VerifyEmitDiagnostics
(
// (7,6): error CS0592: Attribute 'ModuleInitializer' is not valid on this declaration type. It is only valid on 'method' declarations.
// [ModuleInitializer]
Diagnostic
(
ErrorCode
.
ERR_AttributeOnBadSymbolType
,
"ModuleInitializer"
).
WithArguments
(
"ModuleInitializer"
,
"method"
).
WithLocation
(
7
,
6
)
);
}
}
}
src/Compilers/CSharp/Test/Syntax/Diagnostics/DiagnosticTest.cs
浏览文件 @
b55510b4
...
...
@@ -31,12 +31,6 @@ public void Resources()
ErrorCode
.
Void
,
ErrorCode
.
Unknown
,
ErrorCode
.
WRN_ALinkWarn
,
// Not reported, but retained to allow configuring class of related warnings. See CSharpDiagnosticFilter.Filter.
// The following error codes are reserved by feature branches
ErrorCode
.
ERR_8813
,
ErrorCode
.
ERR_8814
,
ErrorCode
.
ERR_8815
,
ErrorCode
.
ERR_8816
,
};
foreach
(
ErrorCode
code
in
Enum
.
GetValues
(
typeof
(
ErrorCode
)))
{
...
...
src/Compilers/Core/Portable/Emit/CommonPEModuleBuilder.cs
浏览文件 @
b55510b4
...
...
@@ -469,8 +469,6 @@ internal abstract class PEModuleBuilder<TCompilation, TSourceModuleSymbol, TAsse
where
TEmbeddedTypesManager
:
CommonEmbeddedTypesManager
where
TModuleCompilationState
:
ModuleCompilationState
<
TNamedTypeSymbol
,
TMethodSymbol
>
{
private
readonly
Cci
.
RootModuleType
_rootModuleType
=
new
Cci
.
RootModuleType
();
internal
readonly
TSourceModuleSymbol
SourceModule
;
internal
readonly
TCompilation
Compilation
;
...
...
@@ -479,6 +477,7 @@ internal abstract class PEModuleBuilder<TCompilation, TSourceModuleSymbol, TAsse
private
HashSet
<
string
>
_namesOfTopLevelTypes
;
internal
readonly
TModuleCompilationState
CompilationState
;
public
Cci
.
RootModuleType
RootModuleType
{
get
;
}
=
new
Cci
.
RootModuleType
();
public
abstract
TEmbeddedTypesManager
EmbeddedTypesManagerOpt
{
get
;
}
...
...
@@ -562,9 +561,9 @@ public override IEnumerable<Cci.INamespaceTypeDefinition> GetTopLevelTypeDefinit
Dispatch
(
typeReferenceIndexer
);
}
AddTopLevelType
(
names
,
_r
ootModuleType
);
VisitTopLevelType
(
typeReferenceIndexer
,
_r
ootModuleType
);
yield
return
_r
ootModuleType
;
AddTopLevelType
(
names
,
R
ootModuleType
);
VisitTopLevelType
(
typeReferenceIndexer
,
R
ootModuleType
);
yield
return
R
ootModuleType
;
foreach
(
var
typeDef
in
GetAnonymousTypeDefinitions
(
context
))
{
...
...
src/Compilers/Core/Portable/InternalUtilities/ConcurrentSet.cs
浏览文件 @
b55510b4
...
...
@@ -4,7 +4,6 @@
#
nullable
enable
using
System
;
using
System.Collections
;
using
System.Collections.Concurrent
;
using
System.Collections.Generic
;
...
...
@@ -178,7 +177,13 @@ void ICollection<T>.Add(T item)
public
void
CopyTo
(
T
[]
array
,
int
arrayIndex
)
{
throw
new
NotImplementedException
();
// PERF: Do not use dictionary.Keys here because that creates a snapshot
// of the collection resulting in a List<T> allocation.
// Instead, enumerate the set and copy over the elements.
foreach
(
var
element
in
this
)
{
array
[
arrayIndex
++]
=
element
;
}
}
}
}
src/Compilers/Core/Portable/PEWriter/RootModuleStaticConstructor.cs
0 → 100644
浏览文件 @
b55510b4
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using
System.Collections.Generic
;
using
System.Collections.Immutable
;
using
System.Reflection
;
using
Microsoft.CodeAnalysis
;
using
Microsoft.CodeAnalysis.CodeGen
;
using
Microsoft.CodeAnalysis.Debugging
;
using
Microsoft.CodeAnalysis.Emit
;
using
Roslyn.Utilities
;
namespace
Microsoft.Cci
{
internal
sealed
partial
class
RootModuleStaticConstructor
:
IMethodDefinition
,
IMethodBody
{
public
RootModuleStaticConstructor
(
ITypeDefinition
containingTypeDefinition
,
ImmutableArray
<
byte
>
il
)
{
ContainingTypeDefinition
=
containingTypeDefinition
;
IL
=
il
;
}
// IMethodDefinition implementation
public
ITypeDefinition
ContainingTypeDefinition
{
get
;
}
public
string
Name
=>
WellKnownMemberNames
.
StaticConstructorName
;
public
IMethodBody
GetBody
(
EmitContext
context
)
=>
this
;
public
IEnumerable
<
IGenericMethodParameter
>
GenericParameters
=>
SpecializedCollections
.
EmptyEnumerable
<
IGenericMethodParameter
>();
public
bool
IsImplicitlyDeclared
=>
true
;
public
bool
HasDeclarativeSecurity
=>
false
;
public
bool
IsAbstract
=>
false
;
public
bool
IsAccessCheckedOnOverride
=>
false
;
public
bool
IsConstructor
=>
false
;
public
bool
IsExternal
=>
false
;
public
bool
IsHiddenBySignature
=>
true
;
public
bool
IsNewSlot
=>
false
;
public
bool
IsPlatformInvoke
=>
false
;
public
bool
IsRuntimeSpecial
=>
true
;
public
bool
IsSealed
=>
false
;
public
bool
IsSpecialName
=>
true
;
public
bool
IsStatic
=>
true
;
public
bool
IsVirtual
=>
false
;
public
ImmutableArray
<
IParameterDefinition
>
Parameters
=>
ImmutableArray
<
IParameterDefinition
>.
Empty
;
public
IPlatformInvokeInformation
PlatformInvokeData
=>
null
;
public
bool
RequiresSecurityObject
=>
false
;
public
bool
ReturnValueIsMarshalledExplicitly
=>
false
;
public
IMarshallingInformation
ReturnValueMarshallingInformation
=>
null
;
public
ImmutableArray
<
byte
>
ReturnValueMarshallingDescriptor
=>
default
;
public
IEnumerable
<
SecurityAttribute
>
SecurityAttributes
=>
null
;
public
INamespace
ContainingNamespace
=>
null
;
public
TypeMemberVisibility
Visibility
=>
TypeMemberVisibility
.
Private
;
public
bool
AcceptsExtraArguments
=>
false
;
public
ushort
GenericParameterCount
=>
0
;
public
bool
IsGeneric
=>
false
;
public
ImmutableArray
<
IParameterTypeInformation
>
ExtraParameters
=>
ImmutableArray
<
IParameterTypeInformation
>.
Empty
;
public
IGenericMethodInstanceReference
AsGenericMethodInstanceReference
=>
null
;
public
ISpecializedMethodReference
AsSpecializedMethodReference
=>
null
;
public
CallingConvention
CallingConvention
=>
CallingConvention
.
Default
;
public
ushort
ParameterCount
=>
0
;
public
ImmutableArray
<
ICustomModifier
>
ReturnValueCustomModifiers
=>
ImmutableArray
<
ICustomModifier
>.
Empty
;
public
ImmutableArray
<
ICustomModifier
>
RefCustomModifiers
=>
ImmutableArray
<
ICustomModifier
>.
Empty
;
public
bool
ReturnValueIsByRef
=>
false
;
public
IDefinition
AsDefinition
(
EmitContext
context
)
=>
this
;
public
void
Dispatch
(
MetadataVisitor
visitor
)
=>
visitor
.
Visit
((
IMethodDefinition
)
this
);
public
IEnumerable
<
ICustomAttribute
>
GetAttributes
(
EmitContext
context
)
=>
SpecializedCollections
.
EmptyEnumerable
<
ICustomAttribute
>();
public
ITypeReference
GetContainingType
(
EmitContext
context
)
=>
ContainingTypeDefinition
;
public
MethodImplAttributes
GetImplementationAttributes
(
EmitContext
context
)
=>
default
;
public
ImmutableArray
<
IParameterTypeInformation
>
GetParameters
(
EmitContext
context
)
=>
ImmutableArray
<
IParameterTypeInformation
>.
Empty
;
public
IMethodDefinition
GetResolvedMethod
(
EmitContext
context
)
=>
this
;
public
IEnumerable
<
ICustomAttribute
>
GetReturnValueAttributes
(
EmitContext
context
)
=>
SpecializedCollections
.
EmptyEnumerable
<
ICustomAttribute
>();
public
ITypeReference
GetType
(
EmitContext
context
)
=>
context
.
Module
.
GetPlatformType
(
PlatformType
.
SystemVoid
,
context
);
// IMethodBody implementation
public
ushort
MaxStack
=>
0
;
public
ImmutableArray
<
byte
>
IL
{
get
;
}
public
IMethodDefinition
MethodDefinition
=>
this
;
public
ImmutableArray
<
ExceptionHandlerRegion
>
ExceptionRegions
=>
ImmutableArray
<
ExceptionHandlerRegion
>.
Empty
;
public
bool
AreLocalsZeroed
=>
false
;
public
bool
HasStackalloc
=>
false
;
public
ImmutableArray
<
ILocalDefinition
>
LocalVariables
=>
ImmutableArray
<
ILocalDefinition
>.
Empty
;
public
StateMachineMoveNextBodyDebugInfo
MoveNextBodyInfo
=>
null
;
public
ImmutableArray
<
SequencePoint
>
SequencePoints
=>
ImmutableArray
<
SequencePoint
>.
Empty
;
public
bool
HasDynamicLocalVariables
=>
false
;
public
ImmutableArray
<
LocalScope
>
LocalScopes
=>
ImmutableArray
<
LocalScope
>.
Empty
;
public
IImportScope
ImportScope
=>
null
;
public
DebugId
MethodId
=>
default
;
public
ImmutableArray
<
StateMachineHoistedLocalScope
>
StateMachineHoistedLocalScopes
=>
ImmutableArray
<
StateMachineHoistedLocalScope
>.
Empty
;
public
string
StateMachineTypeName
=>
null
;
public
ImmutableArray
<
EncHoistedLocalInfo
>
StateMachineHoistedLocalSlots
=>
ImmutableArray
<
EncHoistedLocalInfo
>.
Empty
;
public
ImmutableArray
<
ITypeReference
>
StateMachineAwaiterSlots
=>
ImmutableArray
<
ITypeReference
>.
Empty
;
public
ImmutableArray
<
ClosureDebugInfo
>
ClosureDebugInfo
=>
ImmutableArray
<
ClosureDebugInfo
>.
Empty
;
public
ImmutableArray
<
LambdaDebugInfo
>
LambdaDebugInfo
=>
ImmutableArray
<
LambdaDebugInfo
>.
Empty
;
public
DynamicAnalysisMethodBodyData
DynamicAnalysisData
=>
null
;
}
}
src/Compilers/Core/Portable/PEWriter/RootModuleType.cs
浏览文件 @
b55510b4
...
...
@@ -4,10 +4,11 @@
#
nullable
enable
using
System
;
using
System.Collections.Generic
;
using
System.Runtime.InteropServices
;
using
System.Collections.Immutable
;
using
System.Diagnostics
;
using
System.Reflection.Metadata
;
using
System.Runtime.InteropServices
;
using
Roslyn.Utilities
;
using
EmitContext
=
Microsoft
.
CodeAnalysis
.
Emit
.
EmitContext
;
...
...
@@ -18,6 +19,21 @@ namespace Microsoft.Cci
/// </summary>
internal
class
RootModuleType
:
INamespaceTypeDefinition
{
private
IReadOnlyList
<
IMethodDefinition
>?
_methods
;
public
void
SetStaticConstructorBody
(
ImmutableArray
<
byte
>
il
)
{
Debug
.
Assert
(
_methods
is
null
);
_methods
=
SpecializedCollections
.
SingletonReadOnlyList
(
new
RootModuleStaticConstructor
(
containingTypeDefinition
:
this
,
il
));
}
public
IEnumerable
<
IMethodDefinition
>
GetMethods
(
EmitContext
context
)
{
return
_methods
??=
SpecializedCollections
.
EmptyReadOnlyList
<
IMethodDefinition
>();
}
public
TypeDefinitionHandle
TypeDef
{
get
{
return
default
(
TypeDefinitionHandle
);
}
...
...
@@ -138,11 +154,6 @@ public LayoutKind Layout
get
{
return
LayoutKind
.
Auto
;
}
}
public
IEnumerable
<
IMethodDefinition
>
GetMethods
(
EmitContext
context
)
{
return
SpecializedCollections
.
EmptyEnumerable
<
IMethodDefinition
>();
}
public
IEnumerable
<
INestedTypeDefinition
>
GetNestedTypes
(
EmitContext
context
)
{
return
SpecializedCollections
.
EmptyEnumerable
<
INestedTypeDefinition
>();
...
...
src/Compilers/Core/Portable/Symbols/Attributes/AttributeDescription.cs
浏览文件 @
b55510b4
...
...
@@ -428,6 +428,8 @@ static AttributeDescription()
private
static
readonly
byte
[][]
s_signaturesOfEnumeratorCancellationAttribute
=
{
s_signature_HasThis_Void
};
private
static
readonly
byte
[][]
s_signaturesOfNativeIntegerAttribute
=
{
s_signature_HasThis_Void
,
s_signature_HasThis_Void_SzArray_Boolean
};
private
static
readonly
byte
[][]
s_signaturesOfModuleInitializerAttribute
=
{
s_signature_HasThis_Void
};
// early decoded attributes:
internal
static
readonly
AttributeDescription
OptionalAttribute
=
new
AttributeDescription
(
"System.Runtime.InteropServices"
,
"OptionalAttribute"
,
s_signaturesOfOptionalAttribute
);
internal
static
readonly
AttributeDescription
ComImportAttribute
=
new
AttributeDescription
(
"System.Runtime.InteropServices"
,
"ComImportAttribute"
,
s_signaturesOfComImportAttribute
);
...
...
@@ -559,5 +561,6 @@ static AttributeDescription()
internal
static
readonly
AttributeDescription
EnumeratorCancellationAttribute
=
new
AttributeDescription
(
"System.Runtime.CompilerServices"
,
"EnumeratorCancellationAttribute"
,
s_signaturesOfEnumeratorCancellationAttribute
);
internal
static
readonly
AttributeDescription
SkipLocalsInitAttribute
=
new
AttributeDescription
(
"System.Runtime.CompilerServices"
,
"SkipLocalsInitAttribute"
,
s_signaturesOfSkipLocalsInitAttribute
);
internal
static
readonly
AttributeDescription
NativeIntegerAttribute
=
new
AttributeDescription
(
"System.Runtime.CompilerServices"
,
"NativeIntegerAttribute"
,
s_signaturesOfNativeIntegerAttribute
);
internal
static
readonly
AttributeDescription
ModuleInitializerAttribute
=
new
AttributeDescription
(
"System.Runtime.CompilerServices"
,
"ModuleInitializerAttribute"
,
s_signaturesOfModuleInitializerAttribute
);
}
}
src/Compilers/Server/VBCSCompiler/MetadataCache.cs
浏览文件 @
b55510b4
...
...
@@ -15,8 +15,8 @@ namespace Microsoft.CodeAnalysis.CompilerServer
{
internal
class
MetadataAndSymbolCache
{
// Store
100 entries -- arbitrary number
private
const
int
CacheSize
=
1
00
;
// Store
500 entries -- Out of ~8.7M projects, only about 4,000 had more than 500 references
private
const
int
CacheSize
=
5
00
;
private
readonly
ConcurrentLruCache
<
FileKey
,
Metadata
>
_metadataCache
=
new
ConcurrentLruCache
<
FileKey
,
Metadata
>(
CacheSize
);
...
...
src/Compilers/VisualBasic/Portable/Symbols/Source/SourceMethodSymbol.vb
浏览文件 @
b55510b4
...
...
@@ -1721,6 +1721,8 @@ lReportErrorOnTwoTokens:
End
If
ElseIf
VerifyObsoleteAttributeAppliedToMethod
(
arguments
,
AttributeDescription
.
ObsoleteAttribute
)
Then
ElseIf
VerifyObsoleteAttributeAppliedToMethod
(
arguments
,
AttributeDescription
.
DeprecatedAttribute
)
Then
ElseIf
arguments
.
Attribute
.
IsTargetAttribute
(
Me
,
AttributeDescription
.
ModuleInitializerAttribute
)
Then
arguments
.
Diagnostics
.
Add
(
ERRID
.
WRN_AttributeNotSupportedInVB
,
arguments
.
AttributeSyntaxOpt
.
Location
,
AttributeDescription
.
ModuleInitializerAttribute
.
FullName
)
Else
Dim
methodImpl
As
MethodSymbol
=
If
(
Me
.
IsPartial
,
PartialImplementationPart
,
Me
)
...
...
src/Compilers/VisualBasic/Test/Emit/Attributes/AttributeTests_WellKnownAttributes.vb
浏览文件 @
b55510b4
...
...
@@ -5813,6 +5813,413 @@ BC30657: 'sc1_method' has a return type that is not supported or parameter types
]]
></
expected
>
)
End
Sub
#End Region
#Region "ModuleInitializerAttribute"
<
Fact
>
Public
Sub
ModuleInitializerAttributeOnMethod
()
Dim
source
=
<
compilation
>
<
file
name
=
"attr.vb"
><
!
[
CDATA
[
Namespace
System.Runtime.CompilerServices
Public
Class
ModuleInitializerAttribute
Inherits
Attribute
End
Class
End
Namespace
Class
Program
<
System
.
Runtime
.
CompilerServices
.
ModuleInitializerAttribute
>
Sub
S
()
End
Sub
<
System
.
Runtime
.
CompilerServices
.
ModuleInitializerAttribute
>
Function
F
()
As
Integer
Return
1
End
Function
End
Class
]]
>
</
file
>
</
compilation
>
Dim
compilation
=
CreateCompilationWithMscorlib40
(
source
)
CompilationUtils
.
AssertTheseDiagnostics
(
compilation
,
<
expected
><
!
[
CDATA
[
BC42381
:
'System.Runtime.CompilerServices.ModuleInitializerAttribute' is not supported in VB.
<
System
.
Runtime
.
CompilerServices
.
ModuleInitializerAttribute
>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
BC42381
:
'System.Runtime.CompilerServices.ModuleInitializerAttribute' is not supported in VB.
<
System
.
Runtime
.
CompilerServices
.
ModuleInitializerAttribute
>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
]]
></
expected
>
)
End
Sub
<
Fact
>
Public
Sub
ModuleInitializerAttributeOnClass
()
Dim
source
=
<
compilation
>
<
file
name
=
"a.vb"
>
<
!
[
CDATA
[
Namespace
System.Runtime.CompilerServices
Class
ModuleInitializerAttribute
Inherits
System
.
Attribute
End
Class
End
Namespace
<
System
.
Runtime
.
CompilerServices
.
ModuleInitializerAttribute
>
Class
C
End
Class
]]
>
</
file
>
</
compilation
>
Dim
comp
=
CreateCompilationWithMscorlib40
(
source
)
CompilationUtils
.
AssertNoDiagnostics
(
comp
)
End
Sub
<
Fact
>
Public
Sub
ModuleInitializerAttributeOnProperty
()
Dim
source
=
<
compilation
>
<
file
name
=
"a.vb"
>
<
!
[
CDATA
[
Namespace
System.Runtime.CompilerServices
Class
ModuleInitializerAttribute
Inherits
System
.
Attribute
End
Class
End
Namespace
Class
C
<
System
.
Runtime
.
CompilerServices
.
ModuleInitializerAttribute
>
Property
P
As
Integer
Get
Return
1
End
Get
Set
End
Set
End
Property
End
Class
]]
>
</
file
>
</
compilation
>
Dim
comp
=
CreateCompilationWithMscorlib40
(
source
)
CompilationUtils
.
AssertNoDiagnostics
(
comp
)
End
Sub
<
Fact
>
Public
Sub
ModuleInitializerAttributeOnAccessors
()
Dim
source
=
<
compilation
>
<
file
name
=
"a.vb"
>
<
!
[
CDATA
[
Namespace
System.Runtime.CompilerServices
Class
ModuleInitializerAttribute
Inherits
System
.
Attribute
End
Class
End
Namespace
Class
C
Property
P
As
Integer
<
System
.
Runtime
.
CompilerServices
.
ModuleInitializerAttribute
>
Get
Return
1
End
Get
<
System
.
Runtime
.
CompilerServices
.
ModuleInitializerAttribute
>
Set
End
Set
End
Property
End
Class
]]
>
</
file
>
</
compilation
>
Dim
comp
=
CreateCompilationWithMscorlib40
(
source
)
CompilationUtils
.
AssertTheseDiagnostics
(
comp
,
<
expected
><
!
[
CDATA
[
BC42381
:
'System.Runtime.CompilerServices.ModuleInitializerAttribute' is not supported in VB.
<
System
.
Runtime
.
CompilerServices
.
ModuleInitializerAttribute
>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
BC42381
:
'System.Runtime.CompilerServices.ModuleInitializerAttribute' is not supported in VB.
<
System
.
Runtime
.
CompilerServices
.
ModuleInitializerAttribute
>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
]]
></
expected
>
)
End
Sub
<
Fact
>
Public
Sub
ModuleInitializerAttributeOnModule
()
Dim
source
=
<
compilation
>
<
file
name
=
"a.vb"
>
<
!
[
CDATA
[
<
Module
:
System.Runtime.CompilerServices.ModuleInitializerAttribute
>
Namespace
System.Runtime.CompilerServices
Class
ModuleInitializerAttribute
Inherits
System
.
Attribute
End
Class
End
Namespace
]]
>
</
file
>
</
compilation
>
Dim
comp
=
CreateCompilationWithMscorlib40
(
source
)
CompilationUtils
.
AssertNoDiagnostics
(
comp
)
End
Sub
<
Fact
>
Public
Sub
ModuleInitializerAttributeOnAssembly
()
Dim
source
=
<
compilation
>
<
file
name
=
"a.vb"
>
<
!
[
CDATA
[
<
Assembly
:
System
.
Runtime
.
CompilerServices
.
ModuleInitializerAttribute
>
Namespace
System.Runtime.CompilerServices
Class
ModuleInitializerAttribute
Inherits
System
.
Attribute
End
Class
End
Namespace
]]
>
</
file
>
</
compilation
>
Dim
comp
=
CreateCompilationWithMscorlib40
(
source
)
CompilationUtils
.
AssertNoDiagnostics
(
comp
)
End
Sub
<
Fact
>
Public
Sub
ModuleInitializerAttributeOnEnum
()
Dim
source
=
<
compilation
>
<
file
name
=
"a.vb"
>
<
!
[
CDATA
[
Namespace
System.Runtime.CompilerServices
Class
ModuleInitializerAttribute
Inherits
System
.
Attribute
End
Class
End
Namespace
<
System
.
Runtime
.
CompilerServices
.
ModuleInitializerAttribute
>
Enum
E
Member
End
Enum
]]
>
</
file
>
</
compilation
>
Dim
comp
=
CreateCompilationWithMscorlib40
(
source
)
CompilationUtils
.
AssertNoDiagnostics
(
comp
)
End
Sub
<
Fact
>
Public
Sub
ModuleInitializerAttributeOnEnumMember
()
Dim
source
=
<
compilation
>
<
file
name
=
"a.vb"
>
<
!
[
CDATA
[
Namespace
System.Runtime.CompilerServices
Class
ModuleInitializerAttribute
Inherits
System
.
Attribute
End
Class
End
Namespace
Enum
E
<
System
.
Runtime
.
CompilerServices
.
ModuleInitializerAttribute
>
Member1
<
System
.
Runtime
.
CompilerServices
.
ModuleInitializerAttribute
>
Member2
End
Enum
]]
>
</
file
>
</
compilation
>
Dim
comp
=
CreateCompilationWithMscorlib40
(
source
)
CompilationUtils
.
AssertNoDiagnostics
(
comp
)
End
Sub
<
Fact
>
Public
Sub
ModuleInitializerAttributeOnEvent
()
Dim
source
=
<
compilation
>
<
file
name
=
"a.vb"
>
<
!
[
CDATA
[
Namespace
System.Runtime.CompilerServices
Class
ModuleInitializerAttribute
Inherits
System
.
Attribute
End
Class
End
Namespace
Class
C
<
System
.
Runtime
.
CompilerServices
.
ModuleInitializerAttribute
>
Event
E
(
ByVal
i
As
Integer
)
End
Class
]]
>
</
file
>
</
compilation
>
Dim
comp
=
CreateCompilationWithMscorlib40
(
source
)
CompilationUtils
.
AssertNoDiagnostics
(
comp
)
End
Sub
<
Fact
>
Public
Sub
ModuleInitializerAttributeOnDelegate
()
Dim
source
=
<
compilation
>
<
file
name
=
"a.vb"
>
<
!
[
CDATA
[
Namespace
System.Runtime.CompilerServices
Class
ModuleInitializerAttribute
Inherits
System
.
Attribute
End
Class
End
Namespace
Class
C
<
System
.
Runtime
.
CompilerServices
.
ModuleInitializerAttribute
>
Delegate
Sub
D
()
End
Class
]]
>
</
file
>
</
compilation
>
Dim
comp
=
CreateCompilationWithMscorlib40
(
source
)
CompilationUtils
.
AssertNoDiagnostics
(
comp
)
End
Sub
<
Fact
>
Public
Sub
ModuleInitializerAttributeOnInterface
()
Dim
source
=
<
compilation
>
<
file
name
=
"a.vb"
>
<
!
[
CDATA
[
Namespace
System.Runtime.CompilerServices
Class
ModuleInitializerAttribute
Inherits
System
.
Attribute
End
Class
End
Namespace
<
System
.
Runtime
.
CompilerServices
.
ModuleInitializerAttribute
>
Interface
I
End
Interface
]]
>
</
file
>
</
compilation
>
Dim
comp
=
CreateCompilationWithMscorlib40
(
source
)
CompilationUtils
.
AssertNoDiagnostics
(
comp
)
End
Sub
<
Fact
>
Public
Sub
ModuleInitializerAttributeOnStructure
()
Dim
source
=
<
compilation
>
<
file
name
=
"a.vb"
>
<
!
[
CDATA
[
Namespace
System.Runtime.CompilerServices
Class
ModuleInitializerAttribute
Inherits
System
.
Attribute
End
Class
End
Namespace
<
System
.
Runtime
.
CompilerServices
.
ModuleInitializerAttribute
>
Structure
S
End
Structure
]]
>
</
file
>
</
compilation
>
Dim
comp
=
CreateCompilationWithMscorlib40
(
source
)
CompilationUtils
.
AssertNoDiagnostics
(
comp
)
End
Sub
<
Fact
>
Public
Sub
ModuleInitializerAttributeOnReturnValue
()
Dim
source
=
<
compilation
>
<
file
name
=
"a.vb"
>
<
!
[
CDATA
[
Namespace
System.Runtime.CompilerServices
Class
ModuleInitializerAttribute
Inherits
System
.
Attribute
End
Class
End
Namespace
Class
C
Function
F
()
As
<
System
.
Runtime
.
CompilerServices
.
ModuleInitializerAttribute
>
Integer
Return
1
End
Function
End
Class
]]
>
</
file
>
</
compilation
>
Dim
comp
=
CreateCompilationWithMscorlib40
(
source
)
CompilationUtils
.
AssertNoDiagnostics
(
comp
)
End
Sub
<
Fact
>
Public
Sub
ModuleInitializerAttributeOnParameter
()
Dim
source
=
<
compilation
>
<
file
name
=
"a.vb"
>
<
!
[
CDATA
[
Namespace
System.Runtime.CompilerServices
Class
ModuleInitializerAttribute
Inherits
System
.
Attribute
End
Class
End
Namespace
Class
C
Sub
M
(
<
System
.
Runtime
.
CompilerServices
.
ModuleInitializerAttribute
>
ByVal
i
As
Integer
)
End
Sub
End
Class
]]
>
</
file
>
</
compilation
>
Dim
comp
=
CreateCompilationWithMscorlib40
(
source
)
CompilationUtils
.
AssertNoDiagnostics
(
comp
)
End
Sub
<
Fact
>
Public
Sub
ModuleInitializerAttributeOnField
()
Dim
source
=
<
compilation
>
<
file
name
=
"a.vb"
>
<
!
[
CDATA
[
Namespace
System.Runtime.CompilerServices
Class
ModuleInitializerAttribute
Inherits
System
.
Attribute
End
Class
End
Namespace
Class
C
<
System
.
Runtime
.
CompilerServices
.
ModuleInitializerAttribute
>
Dim
i
As
Integer
End
Class
]]
>
</
file
>
</
compilation
>
Dim
comp
=
CreateCompilationWithMscorlib40
(
source
)
CompilationUtils
.
AssertNoDiagnostics
(
comp
)
End
Sub
#End Region
<
Fact
,
WorkItem
(
807
,
"https://github.com/dotnet/roslyn/issues/807"
)
>
...
...
src/Test/Utilities/Portable/Traits/CompilerFeature.cs
浏览文件 @
b55510b4
...
...
@@ -38,5 +38,6 @@ public enum CompilerFeature
TopLevelStatements
,
InitOnlySetters
,
AnonymousFunctions
,
ModuleInitializers
,
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录